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

Re: [PATCH 3/3] x86: Use CpuidUserDis if an AMD HVM guest toggles CPUID faulting


  • To: Alejandro Vallejo <alejandro.vallejo@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 8 May 2023 15:18:20 +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=fWRPL6YneaoJ91jGEXzcRq759h8bxvZnyP2YvrxalZQ=; b=JezcqsJmsQEbTP45NYM7m2gml4Xw+4tG3wE02FRrI5AyPoaMcNl411mqeflATSJRUzu3YTNhJcg4h5NaOslhneUSy0YEDobDqgf66nAoiRIyePOi5c9ChpjF4EBXsEgYJFawRFiAPlRD+67VHCxLhN3J138s0RIH9bLnCxKsxCcXYTGuZf4Vx2tQeIPo5brXsdnZHFtOaydM0RsVTQsjYmqjVB/mMbEHJaWq9+n9EvhYfTLlKefMX7/yza0wzivpH3glF3HBvsMO4b65WFiQDh6qoZVbbHgky3Nq1MI+WafxuMIJITtoh+rxo+NWDXVrJ1HKR3/V2vtZ/gDvKQepYw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KfWN+H1uAMUpoMXaldDpKZ/Z42pc2mh7q4TGXESMhcPIwv1NrCn+wWkbGz/XeQyNH4sR/5nvBVBuAm2+WFBF6757/GCfO0SQ4mAr+rAKCABa3XIi06dg6OxYqklW8PUS7xFVh4SkUcKq305gtGqDbI/XRTCat8BMXFrjtQ6HjdUaLWgdC01nEpJmvKySjCyyFj/66IELgQGFBQthxL12G9108+3ok8hhYnBFwVXRB79zxlbXLCwk00oBhMaNYUAe/yHakeXw0Ft4O7mD8LfYoTfdJY+0fZwUFGFR1jfhZbuL2BkRs4Y1n1TfnLQQQbSjlqpNpwWURT9EUOob8H2wRA==
  • 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 13:18:45 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 05.05.2023 19:57, Alejandro Vallejo wrote:
> This is in order to aid guests of AMD hardware that we have exposed
> CPUID faulting to. If they try to modify the Intel MSR that enables
> the feature, trigger levelling so AMD's version of it (CpuidUserDis)
> is used instead.
> 
> Signed-off-by: Alejandro Vallejo <alejandro.vallejo@xxxxxxxxx>
> ---
>  xen/arch/x86/msr.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)

Don't you also need to update cpu-policy.c:calculate_host_policy()
for the guest to actually know it can use the functionality? Which
in turn would appear to require some form of adjustment to
lib/x86/policy.c:x86_cpu_policies_are_compatible().

> --- a/xen/arch/x86/msr.c
> +++ b/xen/arch/x86/msr.c
> @@ -431,6 +431,13 @@ int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_t 
> val)
>      {
>          bool old_cpuid_faulting = msrs->misc_features_enables.cpuid_faulting;
>  
> +        /*
> +         * The boot CPU must support Intel's CPUID faulting _or_
> +         * AMD's CpuidUserDis.
> +         */
> +        bool can_fault_cpuid = cpu_has_cpuid_faulting ||
> +                               boot_cpu_has(X86_FEATURE_CPUID_USER_DIS);

I'd like to suggest that in such a comment it not be emphasized that
it's the boot CPU (alone) we check. In fact I'm not convinced any
comment is needed here at all. I'm further inclined to suggest to
omit this (single-use) variable altogether.

Jan



 


Rackspace

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