[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <b2a9056a-d181-44ae-bb9f-a809f52cf691@www.fastmail.com>
Date: Wed, 19 May 2021 16:15:16 -0700
From: "Andy Lutomirski" <luto@...nel.org>
To: "Dave Hansen" <dave.hansen@...el.com>,
"Paolo Bonzini" <pbonzini@...hat.com>,
"Jon Kohler" <jon@...anix.com>,
"Sean Christopherson" <seanjc@...gle.com>
Cc: "Babu Moger" <babu.moger@....com>,
"the arch/x86 maintainers" <x86@...nel.org>,
"H. Peter Anvin" <hpa@...or.com>,
"Vitaly Kuznetsov" <vkuznets@...hat.com>,
"Wanpeng Li" <wanpengli@...cent.com>,
"Jim Mattson" <jmattson@...gle.com>,
"Joerg Roedel" <joro@...tes.org>,
"Fenghua Yu" <fenghua.yu@...el.com>,
"Yu-cheng Yu" <yu-cheng.yu@...el.com>,
"Tony Luck" <tony.luck@...el.com>,
"Uros Bizjak" <ubizjak@...il.com>,
"Petteri Aimonen" <jpa@....mail.kapsi.fi>,
"Kan Liang" <kan.liang@...ux.intel.com>,
"Andrew Morton" <akpm@...ux-foundation.org>,
"Mike Rapoport" <rppt@...nel.org>,
"Benjamin Thiel" <b.thiel@...teo.de>,
"Fan Yang" <Fan_Yang@...u.edu.cn>,
"Juergen Gross" <jgross@...e.com>,
"Dave Jiang" <dave.jiang@...el.com>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
"Ricardo Neri" <ricardo.neri-calderon@...ux.intel.com>,
"Arvind Sankar" <nivedita@...m.mit.edu>,
"Linux Kernel Mailing List" <linux-kernel@...r.kernel.org>,
"kvm list" <kvm@...r.kernel.org>
Subject: Re: [PATCH] KVM: x86: add hint to skip hidden rdpkru under kvm_load_host_xsave_state
On Wed, May 19, 2021, at 3:44 PM, Dave Hansen wrote:
> On 5/17/21 12:46 AM, Paolo Bonzini wrote:
> > On 14/05/21 07:11, Andy Lutomirski wrote:
> >> That's nice, but it fails to restore XINUSE[PKRU]. As far as I know,
> >> that bit is live, and the only way to restore it to 0 is with
> >> XRSTOR(S).
> >
> > The manual says "It is possible for XINUSE[i] to be 1 even when state
> > component i is in its initial configuration" so this is architecturally
> > valid. Does the XINUSE optimization matter for PKRU which is a single
> > word?
>
> In Linux with normal userspace, virtually never.
>
> The hardware defaults PKRU to 0x0 which means "no restrictions on any
> keys". Linux defaults PKRU via 'init_pkru_value' to the most
> restrictive value. This ensures that new non-zero-pkey-assigned memory
> is protected by default.
>
> But, that also means PKRU is virtually never in its init state in Linux.
> An app would probably need to manipulate PKRU with XRSTOR to get
> XINUSE[PKRU]=0.
>
> It would only even *possibly* be useful if running a KVM guest that had
> PKRU=0x0 (sorry I don't consider things using KVM "normal userspace" :P ).
>
There was at least one report from the rr camp of glibc behaving differently depending on the result of XGETBV(1). It's at least impolite to change the XINUSE register for a guest behind its back.
Admittedly that particular report wasn't about PKRU, and *Linux* guests won't run with XINUSE[PKRU]=0 under normal circumstances, but non-Linux guests could certainly do so.
Powered by blists - more mailing lists