aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Mattson <jmattson@google.com>2018-05-09 17:02:04 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2018-05-14 12:24:25 -0400
commit1313cc2bd8f6568dd8801feef446afbe43e6d313 (patch)
treef96c07d1053c8e3647a9254523fe073c39839e69
parentab5df31cee7f8f17adb59717cf569d315ec02644 (diff)
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>
-rw-r--r--arch/x86/include/asm/kvm_host.h3
-rw-r--r--arch/x86/kvm/mmu.c5
2 files changed, 6 insertions, 2 deletions
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 187c8e09a019..b27de80f5870 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -258,7 +258,8 @@ union kvm_mmu_page_role {
258 unsigned smep_andnot_wp:1; 258 unsigned smep_andnot_wp:1;
259 unsigned smap_andnot_wp:1; 259 unsigned smap_andnot_wp:1;
260 unsigned ad_disabled:1; 260 unsigned ad_disabled:1;
261 unsigned :7; 261 unsigned guest_mode:1;
262 unsigned :6;
262 263
263 /* 264 /*
264 * This is left at the top of the word so that 265 * This is left at the top of the word so that
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 98717cafdbcb..ca04766edbd4 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -4468,6 +4468,7 @@ static void init_kvm_tdp_mmu(struct kvm_vcpu *vcpu)
4468 struct kvm_mmu *context = &vcpu->arch.mmu; 4468 struct kvm_mmu *context = &vcpu->arch.mmu;
4469 4469
4470 context->base_role.word = 0; 4470 context->base_role.word = 0;
4471 context->base_role.guest_mode = is_guest_mode(vcpu);
4471 context->base_role.smm = is_smm(vcpu); 4472 context->base_role.smm = is_smm(vcpu);
4472 context->base_role.ad_disabled = (shadow_accessed_mask == 0); 4473 context->base_role.ad_disabled = (shadow_accessed_mask == 0);
4473 context->page_fault = tdp_page_fault; 4474 context->page_fault = tdp_page_fault;
@@ -4534,6 +4535,7 @@ void kvm_init_shadow_mmu(struct kvm_vcpu *vcpu)
4534 = smep && !is_write_protection(vcpu); 4535 = smep && !is_write_protection(vcpu);
4535 context->base_role.smap_andnot_wp 4536 context->base_role.smap_andnot_wp
4536 = smap && !is_write_protection(vcpu); 4537 = smap && !is_write_protection(vcpu);
4538 context->base_role.guest_mode = is_guest_mode(vcpu);
4537 context->base_role.smm = is_smm(vcpu); 4539 context->base_role.smm = is_smm(vcpu);
4538 reset_shadow_zero_bits_mask(vcpu, context); 4540 reset_shadow_zero_bits_mask(vcpu, context);
4539} 4541}
@@ -4559,7 +4561,7 @@ void kvm_init_shadow_ept_mmu(struct kvm_vcpu *vcpu, bool execonly,
4559 context->root_hpa = INVALID_PAGE; 4561 context->root_hpa = INVALID_PAGE;
4560 context->direct_map = false; 4562 context->direct_map = false;
4561 context->base_role.ad_disabled = !accessed_dirty; 4563 context->base_role.ad_disabled = !accessed_dirty;
4562 4564 context->base_role.guest_mode = 1;
4563 update_permission_bitmask(vcpu, context, true); 4565 update_permission_bitmask(vcpu, context, true);
4564 update_pkru_bitmask(vcpu, context, true); 4566 update_pkru_bitmask(vcpu, context, true);
4565 update_last_nonleaf_level(vcpu, context); 4567 update_last_nonleaf_level(vcpu, context);
@@ -4820,6 +4822,7 @@ static void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
4820 mask.smep_andnot_wp = 1; 4822 mask.smep_andnot_wp = 1;
4821 mask.smap_andnot_wp = 1; 4823 mask.smap_andnot_wp = 1;
4822 mask.smm = 1; 4824 mask.smm = 1;
4825 mask.guest_mode = 1;
4823 mask.ad_disabled = 1; 4826 mask.ad_disabled = 1;
4824 4827
4825 /* 4828 /*