summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/kvm/include/x86/kvm_util_arch.h
diff options
context:
space:
mode:
authorYosry Ahmed <yosry.ahmed@linux.dev>2025-12-30 15:01:42 -0800
committerSean Christopherson <seanjc@google.com>2026-01-08 12:02:12 -0800
commit508d1cc3ca0ac428b1d5d614519bc497868c2e9f (patch)
tree5cf4f6afb24edde70d9647193bb8c6f5bc982069 /tools/testing/selftests/kvm/include/x86/kvm_util_arch.h
parent8296b16c0a2ba018c3235db5325d679e603899d6 (diff)
downloadlinux-next-508d1cc3ca0ac428b1d5d614519bc497868c2e9f.tar.gz
linux-next-508d1cc3ca0ac428b1d5d614519bc497868c2e9f.zip
KVM: selftests: Reuse virt mapping functions for nested EPTs
Rework tdp_map() and friends to use __virt_pg_map() and drop the custom EPT code in __tdp_pg_map() and tdp_create_pte(). The EPT code and __virt_pg_map() are practically identical, the main differences are: - EPT uses the EPT struct overlay instead of the PTE masks. - EPT always assumes 4-level EPTs. To reuse __virt_pg_map(), extend the PTE masks to work with EPT's RWX and X-only capabilities, and provide a tdp_mmu_init() API so that EPT can pass in the EPT PTE masks along with the root page level (which is currently hardcoded to '4'). Don't reuse KVM's insane overloading of the USER bit for EPT_R as there's no reason to multiplex bits in the selftests, e.g. selftests aren't trying to shadow guest PTEs and thus don't care about funnelling protections into a common permissions check. Another benefit of reusing the code is having separate handling for upper-level PTEs vs 4K PTEs, which avoids some quirks like setting the large bit on a 4K PTE in the EPTs. For all intents and purposes, no functional change intended. Suggested-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev> Co-developed-by: Sean Christopherson <seanjc@google.com> Link: https://patch.msgid.link/20251230230150.4150236-14-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'tools/testing/selftests/kvm/include/x86/kvm_util_arch.h')
-rw-r--r--tools/testing/selftests/kvm/include/x86/kvm_util_arch.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/testing/selftests/kvm/include/x86/kvm_util_arch.h b/tools/testing/selftests/kvm/include/x86/kvm_util_arch.h
index 05a1fc1780f2..1cf84b8212c6 100644
--- a/tools/testing/selftests/kvm/include/x86/kvm_util_arch.h
+++ b/tools/testing/selftests/kvm/include/x86/kvm_util_arch.h
@@ -14,6 +14,8 @@ struct pte_masks {
uint64_t present;
uint64_t writable;
uint64_t user;
+ uint64_t readable;
+ uint64_t executable;
uint64_t accessed;
uint64_t dirty;
uint64_t huge;
@@ -37,8 +39,6 @@ struct kvm_vm_arch {
uint64_t s_bit;
int sev_fd;
bool is_pt_protected;
-
- struct kvm_mmu *tdp_mmu;
};
static inline bool __vm_arch_has_protected_memory(struct kvm_vm_arch *arch)