From: David Hildenbrand <david@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: junkang.fjk@alibaba-inc.com, yang.zhang.wz@gmail.com
Subject: Re: [PATCH 1/3] KVM: x86: block guest protection keys unless the host has them enabled
Date: Thu, 24 Aug 2017 19:54:15 +0200 [thread overview]
Message-ID: <77a8f441-651e-c77a-4c5c-e9a6b93f7480@redhat.com> (raw)
In-Reply-To: <1503569573-55057-2-git-send-email-pbonzini@redhat.com>
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
next prev parent reply other threads:[~2017-08-24 17:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-24 10:12 [PATCH 0/3] KVM, pkeys: fix handling of PKRU across migration Paolo Bonzini
2017-08-24 10:12 ` [PATCH 1/3] KVM: x86: block guest protection keys unless the host has them enabled Paolo Bonzini
2017-08-24 17:54 ` David Hildenbrand [this message]
2017-08-24 10:12 ` [PATCH 2/3] KVM: x86: simplify handling of PKRU Paolo Bonzini
2017-08-24 18:00 ` David Hildenbrand
2017-08-24 10:12 ` [PATCH 3/3] KVM, pkeys: do not use PKRU value in vcpu->arch.guest_fpu.state Paolo Bonzini
2017-08-25 0:43 ` [PATCH 0/3] KVM, pkeys: fix handling of PKRU across migration Yang Zhang
[not found] ` <CAFv8KnHxM-ozJ0xLvUD+x50B-GTAN_TB9520RLeNn5H2RVXiSA@mail.gmail.com>
2017-09-11 10:01 ` Paolo Bonzini
2017-08-28 2:50 ` Yang Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=77a8f441-651e-c77a-4c5c-e9a6b93f7480@redhat.com \
--to=david@redhat.com \
--cc=junkang.fjk@alibaba-inc.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=yang.zhang.wz@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®