Skip to content

Commit fac3725

Browse files
committed
KVM: selftests: riscv: Set PTE A and D bits in VS-stage page table
Supporting hardware updates of PTE A and D bits is optional for any RISC-V implementation so current software strategy is to always set these bits in both G-stage (hypervisor) and VS-stage (guest kernel). If PTE A and D bits are not set by software (hypervisor or guest) then RISC-V implementations not supporting hardware updates of these bits will cause traps even for perfectly valid PTEs. Based on above explanation, the VS-stage page table created by various KVM selftest applications is not correct because PTE A and D bits are not set. This patch fixes VS-stage page table programming of PTE A and D bits for KVM selftests. Fixes: 3e06cdf ("KVM: selftests: Add initial support for RISC-V 64-bit") Signed-off-by: Anup Patel <[email protected]> Tested-by: Mayuresh Chitale <[email protected]> Signed-off-by: Anup Patel <[email protected]>
1 parent 8c3ce49 commit fac3725

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tools/testing/selftests/kvm/include/riscv/processor.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ static inline void set_reg(struct kvm_vm *vm, uint32_t vcpuid, uint64_t id,
101101
#define PGTBL_PTE_WRITE_SHIFT 2
102102
#define PGTBL_PTE_READ_MASK 0x0000000000000002ULL
103103
#define PGTBL_PTE_READ_SHIFT 1
104-
#define PGTBL_PTE_PERM_MASK (PGTBL_PTE_EXECUTE_MASK | \
104+
#define PGTBL_PTE_PERM_MASK (PGTBL_PTE_ACCESSED_MASK | \
105+
PGTBL_PTE_DIRTY_MASK | \
106+
PGTBL_PTE_EXECUTE_MASK | \
105107
PGTBL_PTE_WRITE_MASK | \
106108
PGTBL_PTE_READ_MASK)
107109
#define PGTBL_PTE_VALID_MASK 0x0000000000000001ULL

0 commit comments

Comments
 (0)