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

Re: [PATCH] x86/xstate: reset cached register values on resume


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 25 Aug 2021 17:02:08 +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-SenderADCheck; bh=h9ubc/t8G4P6EO93vmFcMmj1WhGVTIw3vPuXaI41xwM=; b=RJRxo/OWCov+jtkgcIsfwmoG6qBRYtOE7QzmMrwU0e8rEeypd/ObxHnoQWxGPmAErngDL/OW40zU7Zqlu07hroyHSv61P6sGUVz/OGpsRMqgm7Fk10KMfCxSmjZDKFpXML5I3H+xq2oMgKC5PQZ3C80kNCKdvupua7pKP6oF+ldnsl28XWvPuztAV8BjjAZYjUb1CLONLGVp1RdIAG1AYtEcN/7/B2u6y0h33dScq0RSPtAlP6kulnol9hRebbxp5kVzVCGzndvQLZJGgVwuWZZmlFafosXtFdfxWZDU8PqwSR9BB/y4PZczS7WmRHbHApS+ID4MeqTCFm0nJGTwgw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JZ+tLwHYyH6RSydbn6imIMsEHRZjvjYveHT+zLtYxopxGz0a4BCXH6AKfqTWgL51NKe56dFDeSVK2PTFrZqIrHMubuvYgWhVnYuINq8ROEKWEoDJSSJf29yjPZn3ptm7xxh5oGcTiqUkJAUugh3Or2wxdXbwZlfs2pZAJbrFFAklrx5YYhlLRONXikXG3PfSwnnxE7SaMWUj7XkKbKPn7wvzKF/ZsOR/vDb92Xo4zLRjMnQ/sDsnD2yUEG5UURUN104anOHDYhxDlIrEEUs5XE1VhWm5KVkKlWAc1XctUFgZxRLpAGzMdxJlJslSKijo0Hp/nNPnLxiUUmqQ8vdtog==
  • Authentication-results: lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=suse.com;
  • Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 25 Aug 2021 15:02:41 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 24.08.2021 23:11, Andrew Cooper wrote:
> On 18/08/2021 13:44, Andrew Cooper wrote:
>> On 18/08/2021 12:30, Marek Marczykowski-Górecki wrote:
>>> set_xcr0() and set_msr_xss() use cached value to avoid setting the
>>> register to the same value over and over. But suspend/resume implicitly
>>> reset the registers and since percpu areas are not deallocated on
>>> suspend anymore, the cache gets stale.
>>> Reset the cache on resume, to ensure the next write will really hit the
>>> hardware. Choose value 0, as it will never be a legitimate write to
>>> those registers - and so, will force write (and cache update).
>>>
>>> Note the cache is used io get_xcr0() and get_msr_xss() too, but:
>>> - set_xcr0() is called few lines below in xstate_init(), so it will
>>>   update the cache with appropriate value
>>> - get_msr_xss() is not used anywhere - and thus not before any
>>>   set_msr_xss() that will fill the cache
>>>
>>> Fixes: aca2a985a55a "xen: don't free percpu areas during suspend"
>>> Signed-off-by: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
>> I'd prefer to do this differently.  As I said in the thread, there are
>> other registers such as MSR_TSC_AUX which fall into the same category,
>> and I'd like to make something which works systematically.
> 
> Ok - after some searching, I think we have problems with:
> 
> cpu/common.c:47:DEFINE_PER_CPU(struct cpuidmasks, cpuidmasks);

Don't we have a problem here even during initial boot? I can't see
the per-CPU variable to get filled by what the registers hold. If
the register started out non-zero (the default on AMD iirc, as it's
not really masks there) but the first value to be written was zero,
we'd skip the write.

> cpu/common.c:120:static DEFINE_PER_CPU(uint64_t, msr_misc_features);

Almost the same here - we only initialize the variable on the BSP
afaics.

> msr.c:35:DEFINE_PER_CPU(uint32_t, tsc_aux);

And again no boot time setup at all for this one as it looks. Not 
sure how likely it is for firmware or bootloaders to use this MSR
(and then leave it non-zero).

Jan




 


Rackspace

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