[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YxDP6jie4cwzZIHp@google.com>
Date: Thu, 1 Sep 2022 15:29:46 +0000
From: Sean Christopherson <seanjc@...gle.com>
To: Kyle Huey <me@...ehuey.com>
Cc: Dave Hansen <dave.hansen@...ux.intel.com>,
Thomas Gleixner <tglx@...utronix.de>,
Borislav Petkov <bp@...en8.de>, Ingo Molnar <mingo@...hat.com>,
x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>,
Paolo Bonzini <pbonzini@...hat.com>,
Andy Lutomirski <luto@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
linux-kselftest@...r.kernel.org,
Robert O'Callahan <robert@...llahan.org>,
David Manouchehri <david.manouchehri@...eup.net>,
Borislav Petkov <bp@...e.de>, stable@...r.kernel.org
Subject: Re: [PATCH v6 1/2] x86/fpu: Allow PKRU to be (once again) written by
ptrace.
On Mon, Aug 29, 2022, Kyle Huey wrote:
> @@ -1246,6 +1246,21 @@ static int copy_uabi_to_xstate(struct fpstate *fpstate, const void *kbuf,
> }
> }
>
> + /*
> + * Update the user protection key storage. Allow KVM to
> + * pass in a NULL pkru pointer if the mask bit is unset
> + * for its legacy ABI behavior.
> + */
> + if (pkru)
> + *pkru = 0;
> +
> + if (hdr.xfeatures & XFEATURE_MASK_PKRU) {
> + struct pkru_state *xpkru;
> +
> + xpkru = __raw_xsave_addr(xsave, XFEATURE_PKRU);
> + *pkru = xpkru->pkru;
> + }
What about writing this as:
if (hdr.xfeatures & XFEATURE_MASK_PKRU) {
...
*pkru = xpkru->pkru;
} else if (pkru) {
*pkru = 0;
}
to make it slightly more obvious that @pkru must be non-NULL if the feature flag
is enabled?
Or we could be paranoid, though I'm not sure this is worthwhile.
if ((hdr.xfeatures & XFEATURE_MASK_PKRU) &&
!WARN_ON_ONCE(!pkru)) {
...
*pkru = xpkru->pkru;
} else if (pkru) {
*pkru = 0;
}
Otherwise, looks good from a KVM perspective. Thanks!
Powered by blists - more mailing lists