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

Re: [PATCH v2 5/8] x86/hvm: Context switch MSR_PKRS


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 12 Jan 2023 14:10:57 +0100
  • 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=Y8pvCEsvK9DpiCgrrDOLt2avq5yLrFutttlavfM94sM=; b=ejICGx2iUpleIm22rl3I8wReweV4VPHxr8y7hbifV2jVNHYBKIiwRoWKGWdqnOHf7574Hv5lnydXtHSLSe0bYqYkb+P71Ae4tmHgbqiO1gQA+tvPO8WBrEBAi/Dw/f0yb+uZZCRxH+Hif4M/Zb72xFvZv17yRHEsr4fAV7GjBzVDe1kHtSuSdcQSrntebGcf8QDHIyMrtZLVm3sTq5Nnwk1aH/xGneb9nvByt91GtxBTrPjCGfsHh20AnDApDN3akjTB2XyNIuDjOoaHdlKxUrAWJk2zhYPvgvLjmB6w6cOROAfiDi93fQBq6145mcs39lgSFGLYkHdofngNSLldfg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DsEj8FBMnPzSm+X7RHzWq9Ui07w5qduz2StPOet9pvZeYATGdqrYqcdd2ajcDp/RN3zmRL7sRO91eu+RzgsJCeILCF9CDv1g7ohRxL3jC+V2X3LyYD5zWvGmoW3wN7AfCm0yp0QrDTft5Yx6fTHFMiUL4KREQYVU9G7Ilgc7sa8IGYDcpAqv6BXX+fiy9OEgObmaeXPN0nHsnHUn2CwVQqYASJzEFYJgzOoPZJcQJAGCxct2Uek4hVeNlTUkacS7dskik4bf3CVTknEEYDlWjXYlwdT7qvmnn5lj3+8GfV3PV5O6NTRR5aVfuv4pWGF57FcsABxJBFMOdkDiWTRAMg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 12 Jan 2023 13:11:15 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 10.01.2023 18:18, Andrew Cooper wrote:
> +static inline void wrpkrs(uint32_t pkrs)
> +{
> +    uint32_t *this_pkrs = &this_cpu(pkrs);
> +
> +    if ( *this_pkrs != pkrs )
> +    {
> +        *this_pkrs = pkrs;
> +
> +        wrmsr_ns(MSR_PKRS, pkrs, 0);
> +    }
> +}
> +
> +static inline void wrpkrs_and_cache(uint32_t pkrs)
> +{
> +    this_cpu(pkrs) = pkrs;
> +    wrmsr_ns(MSR_PKRS, pkrs, 0);
> +}

Just to confirm - there's no anticipation of uses of this in async
contexts, i.e. there's no concern about the ordering of cache vs hardware
writes?

> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -54,6 +54,7 @@
>  #include <asm/spec_ctrl.h>
>  #include <asm/guest.h>
>  #include <asm/microcode.h>
> +#include <asm/prot-key.h>
>  #include <asm/pv/domain.h>
>  
>  /* opt_nosmp: If true, secondary processors are ignored. */
> @@ -1804,6 +1805,9 @@ void __init noreturn __start_xen(unsigned long mbi_p)
>      if ( opt_invpcid && cpu_has_invpcid )
>          use_invpcid = true;
>  
> +    if ( cpu_has_pks )
> +        wrpkrs_and_cache(0); /* Must be before setting CR4.PKS */

Same question here as for PKRU wrt the BSP during S3 resume.

Jan



 


Rackspace

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