[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/3] x86: Add support for CpuidUserDis


  • To: Alejandro Vallejo <alejandro.vallejo@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 8 May 2023 11:17:46 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2u83bdCLKqnnbdakJJyL+ltqn29nF2/1TNG5EbGKPzM=; b=c/TRlfR0otQ4K6XztKJwXeA3zj3dGQ/IFGFyBnuQfqMme8Jc7AhhY0PTy/qeXW1mWy9t7wg2fngtAsUE3X8cKTIQ6Ey9w9tjQUgNkrBc6Ln0jpSwRx9HcY6B0WyQIZQZEKf9MQwHdbRE60XxOgqPTB3Fy834APz9tfQQdJo4ZsafHJA3gacVZoau+inWtcc6fJmfWU1rfV5OqOpHfn9jWkoKS9kJVF/mOaGSF1EQhd64fxZce58+L6VUcH63fGhxwb0cgL/M5D4cB0Zs0CrmrTyRqnfd5tho65E6nNwVO5eOnCathJamqiC/KD/HwBfVIFDw9AV9xrRud5/HONz9xQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uw4yqoCB39j7A7aQvDRriBboaP6Fc9DRv/A81ICOFTEG33FsjwY+bum04HZTgQfZbNGICFoJSiElpk79vRqrTLQTS/MrFp4CleomOk7/QBqmQENgXdWOPDCItWZHfOBw4uWbNDjZ844s5LEf5WP9Jebj+0RCKM+JIaf/013vIFb/XbNolWpozrrgze80mfBP2f+3K5DAK+ZfC2kGWcBP15Dj+mjlVzvrY9MHz2GMY9y3VAmzi764v9ZRw+Zy9WxqB0kZ3tWyXiFkB9LGYCAKT57A1hVKNf9OeMtpmaQDhKU4R2fprUnp7hDvkwEWIMov0Y/RL8IgjrbqequbDyd2Ow==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 08 May 2023 09:18:08 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 05.05.2023 19:57, Alejandro Vallejo wrote:
> Includes a refactor to move vendor-specific probes to vendor-specific
> files.

I wonder whether the refactoring parts wouldn't better be split off.

> @@ -363,6 +375,21 @@ static void __init noinline amd_init_levelling(void)
>               ctxt_switch_masking = amd_ctxt_switch_masking;
>  }
>  
> +void amd_set_cpuid_user_dis(bool enable)
> +{
> +     const uint64_t msr_addr = MSR_K8_HWCR;

Nit: No MSR index is ever a 64-bit quantity. I'd recommend using MSR_K8_HWCR
directly in the two accesses below anyway, but otherwise the variable wants
to be "const unsigned int".

> +     const uint64_t bit = K8_HWCR_CPUID_USER_DIS;
> +     uint64_t val;
> +
> +     rdmsrl(msr_addr, val);
> +
> +     if (!!(val & bit) == enable)
> +             return;
> +
> +     val ^= bit;
> +     wrmsrl(msr_addr, val);
> +}
>[...]
> --- a/xen/arch/x86/cpu/intel.c
> +++ b/xen/arch/x86/cpu/intel.c
> @@ -226,8 +226,17 @@ static void cf_check intel_ctxt_switch_masking(const 
> struct vcpu *next)
>   */
>  static void __init noinline intel_init_levelling(void)
>  {
> -     if (probe_cpuid_faulting())
> +     /* Intel Fam0f is old enough that probing for CPUID faulting support

Nit: Style (/* on its own line).

> +      * introduces spurious #GP(0) when the appropriate MSRs are read,
> +      * so skip it altogether. In the case where Xen is virtualized these
> +      * MSRs may be emulated though, so we allow it in that case.
> +      */
> +     if ((cpu_has_hypervisor || boot_cpu_data.x86 !=0xf) &&

Nit: Style (blanks around binary operators). I'd also suggest swapping both
sides of the ||, to have the commonly true case first.

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.