lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <BN9PR11MB52761DE1C48A5931B5AD93B78C4C9@BN9PR11MB5276.namprd11.prod.outlook.com>
Date:   Thu, 6 Jan 2022 00:51:20 +0000
From:   "Tian, Kevin" <kevin.tian@...el.com>
To:     Paolo Bonzini <pbonzini@...hat.com>,
        "Zhong, Yang" <yang.zhong@...el.com>,
        "x86@...nel.org" <x86@...nel.org>,
        "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-doc@...r.kernel.org" <linux-doc@...r.kernel.org>,
        "linux-kselftest@...r.kernel.org" <linux-kselftest@...r.kernel.org>,
        "tglx@...utronix.de" <tglx@...utronix.de>,
        "mingo@...hat.com" <mingo@...hat.com>,
        "bp@...en8.de" <bp@...en8.de>,
        "dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>,
        "corbet@....net" <corbet@....net>,
        "shuah@...nel.org" <shuah@...nel.org>,
        "Christopherson,, Sean" <seanjc@...gle.com>
CC:     "Nakajima, Jun" <jun.nakajima@...el.com>,
        "jing2.liu@...ux.intel.com" <jing2.liu@...ux.intel.com>,
        "Liu, Jing2" <jing2.liu@...el.com>,
        "Zeng, Guang" <guang.zeng@...el.com>,
        "Wang, Wei W" <wei.w.wang@...el.com>
Subject: RE: [PATCH v5 07/21] x86/fpu: Provide fpu_enable_guest_xfd_features()
 for KVM

> From: Paolo Bonzini <pbonzini@...hat.com>
> Sent: Wednesday, January 5, 2022 9:07 PM
> 
> On 1/5/22 13:35, Yang Zhong wrote:
> > +int fpu_enable_guest_xfd_features(struct fpu_guest *guest_fpu, u64
> xfeatures)
> > +{
> > +	lockdep_assert_preemption_enabled();
> > +
> 
> The old fpu_update_guest_perm_features(guest_fpu) is equivalent to
> 
> 	fpu_enable_guest_xfd_features(guest_fpu, guest_fpu->perm);
> 
> Missing doc comment:
> 
> /*
>   * fpu_enable_guest_xfd_features - Enable xfeatures according to guest
> perm
>   * @guest_fpu:         Pointer to the guest FPU container
>   * @xfeatures:         Features requested by guest CPUID
>   *
>   * Enable all dynamic xfeatures according to guest perm and requested
> CPUID.
>   * Invoked if the caller wants to conservatively expand fpstate buffer instead
>   * of waiting until XCR0 or XFD MSR is written.
>   *
>   * Return: 0 on success, error code otherwise
>   */

It's not equivalent. The old interface enables all xfeatures allowed by
guest perm while the new one just enables feature bits according to
the caller request. It also becomes a more general interface instead of
being only for conservative expansion. Since both points in the old
comment don't hold now and this function is obvious, we didn't put
a comment here (on par with other KVM helpers in that block).

If still necessary we could add one like below:

/*
  * fpu_enable_guest_xfd_features - Enable xfeatures for guest fpu container
  * @guest_fpu:         Pointer to the guest FPU container
  * @xfeatures:         Features requested by the caller
  *
  * Enable dynamic xfeatures and expand guest fpstate buffer accordingly.
  * KVM should call this function before the requested xfeatures are used
  * by the guest.
  *
  * Return: 0 on success, error code otherwise
  */

> 
> Also, the check for 32-bit is slightly imprecise:
> 
> 	/* Dynamic xfeatures are not supported with 32-bit kernels. */
> 	if (!IS_ENABLED(CONFIG_X86_64))
> -		return 0;
> +		return -EINVAL;
> 
> since we only get here with xfeatures != 0 (if it compiles, just removing
> the IS_ENABLED check altogether would be even better).  With these changes,
> 
> Reviewed-by: Paolo Bonzini <pbonzini@...hat.com>
> 
> Thanks,
> 
> Paolo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ