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

Re: [PATCH v2 5/9] x86/spec-ctrl: Record the last write to MSR_SPEC_CTRL


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 31 Jan 2022 11:20:12 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=yvrJp6ijHcBVRTAQYTzW44VhUrzcp4P0tZMksR7l+KI=; b=H4SM0OtHWGSswjwqUJBjP7UvuE4akXSHCKDe3d0bawOjQwCqIkHWOheLdDVzW2Er2vcKNiCZz/EotAR0Az6PnWwZH179VY0lhazfkZKg1U3XLt0h7nyO7mJp/rOSIZFOJZIGveg6vD8dxDrcuJpZi5j48xo+tWdXAwsCRNInJAOp90CQ2XYQJks7lqbJShyWq334w3Ez254+18rm/Olgdujpiv+MeRNBzT7CgZaqB2BAR3yo2QzqX+X/HZ9r0nPWLRDPj2ULLUxqxaohMV2QEJ7dMa8Vv3Z3Uayic+IDdRo07qGfI37ER44qOgaS3pY5XTP4ZLk3i8hTm2MKZQnDiA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iQZgXDHyrDXTjxLH2LfaSiWX95FmYUxIECYGadkgsNyC0xZ7VGsTcamK4YRBiKiIEKssLwD+dFE3eIAzYbK/2zsUuvB/P98WrWSlkwPKXyB4OxOJr8wlcpGe/ScEJcVmr2GrGZzY/aFgwE9Oz5GsS6vVM7XIAKM1AYRI9szh2tlhB6SJVO9L3mBfH4QjvzIwCD3JLI8Y11AT4LwWsKznwMTKRuZJWCL2ZrUaN6hMEfbVgvaVYr9LFmFA8xYBfj31kQJBUNGUy8Z7uqJvPNVLGtFJNE8pjiwDE1U2gVOWFAo9IH33b+K6QOX7R1AAGqgtBUX2EV4AtL8YYLA8MSE9MA==
  • 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>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 31 Jan 2022 10:20:17 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 28.01.2022 14:29, Andrew Cooper wrote:
> In some cases, writes to MSR_SPEC_CTRL do not have interesting side effects,
> and we should implement lazy context switching like we do with other MSRs.
> 
> In the short term, this will be used by the SVM infrastructure, but I expect
> to extend it to other contexts in due course.
> 
> Introduce cpu_info.last_spec_ctrl for the purpose, and cache writes made from
> the boot/resume paths.  The value can't live in regular per-cpu data when it
> is eventually used for PV guests when XPTI might be active.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

Technically
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
But ...

> --- a/xen/arch/x86/acpi/power.c
> +++ b/xen/arch/x86/acpi/power.c
> @@ -296,7 +296,10 @@ static int enter_state(u32 state)
>      ci->spec_ctrl_flags |= (default_spec_ctrl_flags & SCF_ist_wrmsr);
>  
>      if ( boot_cpu_has(X86_FEATURE_IBRSB) )
> +    {
>          wrmsrl(MSR_SPEC_CTRL, default_xen_mcu_opt_ctrl);
> +        ci->last_spec_ctrl = default_xen_mcu_opt_ctrl;
> +    }

... wouldn't we better have a write_spec_ctrl() helper doing both,
perhaps with the check-if-same logic added as well (overridable by
a "force" boolean input, unless the cases where the write cannot be
skipped can be entirely determined from previous and new values)?

Jan




 


Rackspace

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