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


Groups > linux.kernel > #1719117 > unrolled thread

[PATCH 1/3] KVM: x86: block guest protection keys unless the host has them enabled

Started byPaolo Bonzini <pbonzini@redhat.com>
First post2017-08-24 12:20 +0200
Last post2017-08-24 20:00 +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 1/3] KVM: x86: block guest protection keys unless the host has them enabled Paolo Bonzini <pbonzini@redhat.com> - 2017-08-24 12:20 +0200
    Re: [PATCH 1/3] KVM: x86: block guest protection keys unless the host  has them enabled David Hildenbrand <david@redhat.com> - 2017-08-24 20:00 +0200

#1719117 — [PATCH 1/3] KVM: x86: block guest protection keys unless the host has them enabled

FromPaolo Bonzini <pbonzini@redhat.com>
Date2017-08-24 12:20 +0200
Subject[PATCH 1/3] KVM: x86: block guest protection keys unless the host has them enabled
Message-ID<uhXp0-563-19@gated-at.bofh.it>
If the host has protection keys disabled, we cannot read and write the
guest PKRU---RDPKRU and WRPKRU fail with #GP(0) if CR4.PKE=0.  Block
the PKU cpuid bit in that case.

This ensures that guest_CR4.PKE=1 implies host_CR4.PKE=1.

Fixes: 1be0e61c1f255faaeab04a390e00c8b9b9042870
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 arch/x86/kvm/cpuid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 59ca2eea522c..19adbb418443 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -469,7 +469,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
 			entry->ecx &= kvm_cpuid_7_0_ecx_x86_features;
 			cpuid_mask(&entry->ecx, CPUID_7_ECX);
 			/* PKU is not yet implemented for shadow paging. */
-			if (!tdp_enabled)
+			if (!tdp_enabled || !boot_cpu_has(X86_FEATURE_OSPKE))
 				entry->ecx &= ~F(PKU);
 			entry->edx &= kvm_cpuid_7_0_edx_x86_features;
 			entry->edx &= get_scattered_cpuid_leaf(7, 0, CPUID_EDX);
-- 
1.8.3.1

[toc] | [next] | [standalone]


#1719479 — Re: [PATCH 1/3] KVM: x86: block guest protection keys unless the host has them enabled

FromDavid Hildenbrand <david@redhat.com>
Date2017-08-24 20:00 +0200
SubjectRe: [PATCH 1/3] KVM: x86: block guest protection keys unless the host has them enabled
Message-ID<ui4Aa-1eO-3@gated-at.bofh.it>
In reply to#1719117
On 24.08.2017 12:12, Paolo Bonzini wrote:
> If the host has protection keys disabled, we cannot read and write the
> guest PKRU---RDPKRU and WRPKRU fail with #GP(0) if CR4.PKE=0.  Block
> the PKU cpuid bit in that case.
> 
> This ensures that guest_CR4.PKE=1 implies host_CR4.PKE=1.
> 
> Fixes: 1be0e61c1f255faaeab04a390e00c8b9b9042870
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  arch/x86/kvm/cpuid.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index 59ca2eea522c..19adbb418443 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -469,7 +469,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
>  			entry->ecx &= kvm_cpuid_7_0_ecx_x86_features;
>  			cpuid_mask(&entry->ecx, CPUID_7_ECX);
>  			/* PKU is not yet implemented for shadow paging. */
> -			if (!tdp_enabled)
> +			if (!tdp_enabled || !boot_cpu_has(X86_FEATURE_OSPKE))
>  				entry->ecx &= ~F(PKU);
>  			entry->edx &= kvm_cpuid_7_0_edx_x86_features;
>  			entry->edx &= get_scattered_cpuid_leaf(7, 0, CPUID_EDX);
> 

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 

Thanks,

David

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web