mirror of
https://github.com/torvalds/linux.git
synced 2026-05-24 15:12:13 +02:00
KVM: selftests: Kill eptPageTablePointer
Replace the struct overlay with explicit bitmasks, which is clearer and
less error-prone. See commit f18b4aebe1 ("kvm: selftests: do not use
bitfields larger than 32-bits for PTEs") for an example of why bitfields
are not preferable.
Remove the unused PAGE_SHIFT_4K definition while at it.
No functional change intended.
Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>
Link: https://patch.msgid.link/20251230230150.4150236-5-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
parent
60de423781
commit
b320c03d68
|
|
@ -10,10 +10,16 @@
|
|||
#include "processor.h"
|
||||
#include "vmx.h"
|
||||
|
||||
#define PAGE_SHIFT_4K 12
|
||||
|
||||
#define KVM_EPT_PAGE_TABLE_MIN_PADDR 0x1c0000
|
||||
|
||||
#define EPTP_MT_SHIFT 0 /* EPTP memtype bits 2:0 */
|
||||
#define EPTP_PWL_SHIFT 3 /* EPTP page walk length bits 5:3 */
|
||||
#define EPTP_AD_ENABLED_SHIFT 6 /* EPTP AD enabled bit 6 */
|
||||
|
||||
#define EPTP_WB (X86_MEMTYPE_WB << EPTP_MT_SHIFT)
|
||||
#define EPTP_PWL_4 (3ULL << EPTP_PWL_SHIFT) /* PWL is (levels - 1) */
|
||||
#define EPTP_AD_ENABLED (1ULL << EPTP_AD_ENABLED_SHIFT)
|
||||
|
||||
bool enable_evmcs;
|
||||
|
||||
struct hv_enlightened_vmcs *current_evmcs;
|
||||
|
|
@ -34,14 +40,6 @@ struct eptPageTableEntry {
|
|||
uint64_t suppress_ve:1;
|
||||
};
|
||||
|
||||
struct eptPageTablePointer {
|
||||
uint64_t memory_type:3;
|
||||
uint64_t page_walk_length:3;
|
||||
uint64_t ad_enabled:1;
|
||||
uint64_t reserved_11_07:5;
|
||||
uint64_t address:40;
|
||||
uint64_t reserved_63_52:12;
|
||||
};
|
||||
int vcpu_enable_evmcs(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
uint16_t evmcs_ver;
|
||||
|
|
@ -196,16 +194,15 @@ static inline void init_vmcs_control_fields(struct vmx_pages *vmx)
|
|||
vmwrite(PIN_BASED_VM_EXEC_CONTROL, rdmsr(MSR_IA32_VMX_TRUE_PINBASED_CTLS));
|
||||
|
||||
if (vmx->eptp_gpa) {
|
||||
uint64_t ept_paddr;
|
||||
struct eptPageTablePointer eptp = {
|
||||
.memory_type = X86_MEMTYPE_WB,
|
||||
.page_walk_length = 3, /* + 1 */
|
||||
.ad_enabled = ept_vpid_cap_supported(VMX_EPT_VPID_CAP_AD_BITS),
|
||||
.address = vmx->eptp_gpa >> PAGE_SHIFT_4K,
|
||||
};
|
||||
uint64_t eptp = vmx->eptp_gpa | EPTP_WB | EPTP_PWL_4;
|
||||
|
||||
memcpy(&ept_paddr, &eptp, sizeof(ept_paddr));
|
||||
vmwrite(EPT_POINTER, ept_paddr);
|
||||
TEST_ASSERT((vmx->eptp_gpa & ~PHYSICAL_PAGE_MASK) == 0,
|
||||
"Illegal bits set in vmx->eptp_gpa");
|
||||
|
||||
if (ept_vpid_cap_supported(VMX_EPT_VPID_CAP_AD_BITS))
|
||||
eptp |= EPTP_AD_ENABLED;
|
||||
|
||||
vmwrite(EPT_POINTER, eptp);
|
||||
sec_exec_ctl |= SECONDARY_EXEC_ENABLE_EPT;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user