From: Paolo Bonzini <pbonzini@redhat.com>
To: Jim Mattson <jmattson@google.com>, Babu Moger <babu.moger@amd.com>
Cc: Jonathan Corbet <corbet@lwn.net>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
"H . Peter Anvin" <hpa@zytor.com>,
Sean Christopherson <sean.j.christopherson@intel.com>,
the arch/x86 maintainers <x86@kernel.org>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Joerg Roedel <joro@8bytes.org>,
Dave Hansen <dave.hansen@linux.intel.com>,
Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
mchehab+samsung@kernel.org, changbin.du@intel.com,
Nadav Amit <namit@vmware.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
yang.shi@linux.alibaba.com, asteinhauser@google.com,
anshuman.khandual@arm.com, Jan Kiszka <jan.kiszka@siemens.com>,
Andrew Morton <akpm@linux-foundation.org>,
steven.price@arm.com, rppt@linux.vnet.ibm.com, peterx@redhat.com,
Dan Williams <dan.j.williams@intel.com>,
arjunroy@google.com, logang@deltatee.com,
Thomas Hellstrom <thellstrom@vmware.com>,
Andrea Arcangeli <aarcange@redhat.com>,
justin.he@arm.com, robin.murphy@arm.com, ira.weiny@intel.com,
Kees Cook <keescook@chromium.org>,
Juergen Gross <jgross@suse.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
pawan.kumar.gupta@linux.intel.com, "Yu,
Fenghua" <fenghua.yu@intel.com>,
vineela.tummalapalli@intel.com, yamada.masahiro@socionext.com,
sam@ravnborg.org, acme@redhat.com, linux-doc@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
kvm list <kvm@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] KVM: x86: Move pkru save/restore to x86.c
Date: Sat, 9 May 2020 14:59:17 +0200 [thread overview]
Message-ID: <90657d4b-cb2b-0678-fd9c-a281bb85fadf@redhat.com> (raw)
In-Reply-To: <CALMp9eQj_aFcqR+v9SvFjKFxVjaHHzU44udcczJVqOR5vLQbWQ@mail.gmail.com>
On 09/05/20 00:09, Jim Mattson wrote:
>> + if (static_cpu_has(X86_FEATURE_PKU) &&
>> + kvm_read_cr4_bits(vcpu, X86_CR4_PKE) &&
>> + vcpu->arch.pkru != vcpu->arch.host_pkru)
>> + __write_pkru(vcpu->arch.pkru);
> This doesn't seem quite right to me. Though rdpkru and wrpkru are
> contingent upon CR4.PKE, the PKRU resource isn't. It can be read with
> XSAVE and written with XRSTOR. So, if we don't set the guest PKRU
> value here, the guest can read the host value, which seems dodgy at
> best.
>
> Perhaps the second conjunct should be: (kvm_read_cr4_bits(vcpu,
> X86_CR4_PKE) || (vcpu->arch.xcr0 & XFEATURE_MASK_PKRU)).
You're right. The bug was preexistent, but we should fix it in 5.7 and
stable as well.
>> }
>> EXPORT_SYMBOL_GPL(kvm_load_guest_xsave_state);
>>
>> void kvm_load_host_xsave_state(struct kvm_vcpu *vcpu)
>> {
>> + /*
>> + * eager fpu is enabled if PKEY is supported and CR4 is switched
>> + * back on host, so it is safe to read guest PKRU from current
>> + * XSAVE.
>> + */
> I don't understand the relevance of this comment to the code below.
>
It's probably stale.
Paolo
next prev parent reply other threads:[~2020-05-09 12:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-08 21:09 [PATCH v2 0/3] arch/x86: Enable MPK feature on AMD Babu Moger
2020-05-08 21:09 ` [PATCH v2 1/3] arch/x86: Rename config X86_INTEL_MEMORY_PROTECTION_KEYS to generic x86 Babu Moger
2020-05-08 21:09 ` [PATCH v2 2/3] KVM: x86: Move pkru save/restore to x86.c Babu Moger
2020-05-08 22:09 ` Jim Mattson
2020-05-09 12:59 ` Paolo Bonzini [this message]
2020-05-11 13:49 ` Babu Moger
2020-05-11 13:57 ` Paolo Bonzini
2020-05-08 21:10 ` [PATCH v2 3/3] KVM: SVM: Add support for MPK feature on AMD Babu Moger
2020-05-08 21:55 ` Sean Christopherson
2020-05-08 22:02 ` Babu Moger
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=90657d4b-cb2b-0678-fd9c-a281bb85fadf@redhat.com \
--to=pbonzini@redhat.com \
--cc=aarcange@redhat.com \
--cc=acme@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=andrew.cooper3@citrix.com \
--cc=anshuman.khandual@arm.com \
--cc=arjunroy@google.com \
--cc=asteinhauser@google.com \
--cc=babu.moger@amd.com \
--cc=bigeasy@linutronix.de \
--cc=bp@alien8.de \
--cc=changbin.du@intel.com \
--cc=corbet@lwn.net \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=fenghua.yu@intel.com \
--cc=hpa@zytor.com \
--cc=ira.weiny@intel.com \
--cc=jan.kiszka@siemens.com \
--cc=jgross@suse.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=justin.he@arm.com \
--cc=keescook@chromium.org \
--cc=kvm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=logang@deltatee.com \
--cc=luto@kernel.org \
--cc=mchehab+samsung@kernel.org \
--cc=mingo@redhat.com \
--cc=namit@vmware.com \
--cc=pawan.kumar.gupta@linux.intel.com \
--cc=peterx@redhat.com \
--cc=peterz@infradead.org \
--cc=robin.murphy@arm.com \
--cc=rppt@linux.vnet.ibm.com \
--cc=sam@ravnborg.org \
--cc=sean.j.christopherson@intel.com \
--cc=steven.price@arm.com \
--cc=tglx@linutronix.de \
--cc=thellstrom@vmware.com \
--cc=vineela.tummalapalli@intel.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
--cc=x86@kernel.org \
--cc=yamada.masahiro@socionext.com \
--cc=yang.shi@linux.alibaba.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;
as well as URLs for NNTP newsgroup(s).