Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1432452 > unrolled thread

[PATCH 2/5] mmu: pass execonly value when initializing rsvd bits

Started byBandan Das <bsd@redhat.com>
First post2016-06-28 06:40 +0200
Last post2016-06-29 05:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/5] mmu: pass execonly value when initializing rsvd bits Bandan Das <bsd@redhat.com> - 2016-06-28 06:40 +0200
    Re: [PATCH 2/5] mmu: pass execonly value when initializing rsvd bits Xiao Guangrong <guangrong.xiao@linux.intel.com> - 2016-06-29 05:20 +0200

#1432452 — [PATCH 2/5] mmu: pass execonly value when initializing rsvd bits

FromBandan Das <bsd@redhat.com>
Date2016-06-28 06:40 +0200
Subject[PATCH 2/5] mmu: pass execonly value when initializing rsvd bits
Message-ID<rOSYy-1Xl-15@gated-at.bofh.it>
In reset_tdp_shadow_zero_bits_mask, we always pass false
when initializing the reserved bits. By initializing with the
correct value of ept exec only, the host can correctly
identify if the guest pte is valid. Note that
kvm_init_shadow_ept_mmu() already knows about execonly.

Signed-off-by: Bandan Das <bsd@redhat.com>
---
 arch/x86/kvm/mmu.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index a50af79..875d4f7 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -3831,23 +3831,27 @@ static inline bool boot_cpu_is_amd(void)
 
 /*
  * the direct page table on host, use as much mmu features as
- * possible, however, kvm currently does not do execution-protection.
+ * possible
  */
 static void
 reset_tdp_shadow_zero_bits_mask(struct kvm_vcpu *vcpu,
 				struct kvm_mmu *context)
 {
+	bool execonly;
+
 	if (boot_cpu_is_amd())
 		__reset_rsvds_bits_mask(vcpu, &context->shadow_zero_check,
 					boot_cpu_data.x86_phys_bits,
 					context->shadow_root_level, false,
 					boot_cpu_has(X86_FEATURE_GBPAGES),
 					true, true);
-	else
+	else {
+		execonly = !(context->guest_rsvd_check.bad_mt_xwr &
+			     (1ull << VMX_EPT_EXECUTABLE_MASK));
 		__reset_rsvds_bits_mask_ept(&context->shadow_zero_check,
 					    boot_cpu_data.x86_phys_bits,
-					    false);
-
+					    execonly);
+	}
 }
 
 /*
-- 
2.5.5

[toc] | [next] | [standalone]


#1433416

FromXiao Guangrong <guangrong.xiao@linux.intel.com>
Date2016-06-29 05:20 +0200
Message-ID<rPecF-7fD-1@gated-at.bofh.it>
In reply to#1432452

On 06/28/2016 12:32 PM, Bandan Das wrote:
> In reset_tdp_shadow_zero_bits_mask, we always pass false
> when initializing the reserved bits. By initializing with the
> correct value of ept exec only, the host can correctly
> identify if the guest pte is valid. Note that
> kvm_init_shadow_ept_mmu() already knows about execonly.
>
> Signed-off-by: Bandan Das <bsd@redhat.com>
> ---
>   arch/x86/kvm/mmu.c | 12 ++++++++----
>   1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index a50af79..875d4f7 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -3831,23 +3831,27 @@ static inline bool boot_cpu_is_amd(void)
>
>   /*
>    * the direct page table on host, use as much mmu features as
> - * possible, however, kvm currently does not do execution-protection.
> + * possible
>    */
>   static void
>   reset_tdp_shadow_zero_bits_mask(struct kvm_vcpu *vcpu,
>   				struct kvm_mmu *context)
>   {

It is not necessary. reset_tdp_shadow_zero_bits_mask() is used for
the guest without nested-ept, host never sets shadow execute-only
actively.

For the nested ept guest, kvm_init_shadow_ept_mmu() has already
handled xonly case perfectly.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web