Skip to content

Commit 1313cc2

Browse files
jsmattsonjrbonzini
authored andcommitted
kvm: mmu: Add guest_mode to kvm_mmu_page_role
L1 and L2 need to have disjoint mappings, so that L1's APIC access page (under VMX) can be omitted from L2's mappings. Signed-off-by: Jim Mattson <jmattson@google.com> Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent ab5df31 commit 1313cc2

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎arch/x86/include/asm/kvm_host.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ union kvm_mmu_page_role {
258258
unsigned smep_andnot_wp:1;
259259
unsigned smap_andnot_wp:1;
260260
unsigned ad_disabled:1;
261-
unsigned :7;
261+
unsigned guest_mode:1;
262+
unsigned :6;
262263

263264
/*
264265
* This is left at the top of the word so that

‎arch/x86/kvm/mmu.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4468,6 +4468,7 @@ static void init_kvm_tdp_mmu(struct kvm_vcpu *vcpu)
44684468
struct kvm_mmu *context = &vcpu->arch.mmu;
44694469

44704470
context->base_role.word = 0;
4471+
context->base_role.guest_mode = is_guest_mode(vcpu);
44714472
context->base_role.smm = is_smm(vcpu);
44724473
context->base_role.ad_disabled = (shadow_accessed_mask == 0);
44734474
context->page_fault = tdp_page_fault;
@@ -4534,6 +4535,7 @@ void kvm_init_shadow_mmu(struct kvm_vcpu *vcpu)
45344535
= smep && !is_write_protection(vcpu);
45354536
context->base_role.smap_andnot_wp
45364537
= smap && !is_write_protection(vcpu);
4538+
context->base_role.guest_mode = is_guest_mode(vcpu);
45374539
context->base_role.smm = is_smm(vcpu);
45384540
reset_shadow_zero_bits_mask(vcpu, context);
45394541
}
@@ -4559,7 +4561,7 @@ void kvm_init_shadow_ept_mmu(struct kvm_vcpu *vcpu, bool execonly,
45594561
context->root_hpa = INVALID_PAGE;
45604562
context->direct_map = false;
45614563
context->base_role.ad_disabled = !accessed_dirty;
4562-
4564+
context->base_role.guest_mode = 1;
45634565
update_permission_bitmask(vcpu, context, true);
45644566
update_pkru_bitmask(vcpu, context, true);
45654567
update_last_nonleaf_level(vcpu, context);
@@ -4820,6 +4822,7 @@ static void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
48204822
mask.smep_andnot_wp = 1;
48214823
mask.smap_andnot_wp = 1;
48224824
mask.smm = 1;
4825+
mask.guest_mode = 1;
48234826
mask.ad_disabled = 1;
48244827

48254828
/*

0 commit comments

Comments
 (0)