[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] x86/xstate: reset cached register values on resume
- To: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- Date: Wed, 18 Aug 2021 13:44:31 +0100
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=aFYhDBhUCS0YD40eROBDEVLhliCAdHbpSCDqVnK4Ujw=; b=XagxKyL1OacL9L2ylVGI1zdH8tsqaYtdQkW+V3KbfT57jEahAPeNmZQYpGjwHD1OXtcdYjXJ60it78FyNK3iE6RclH2A5gTCu5Jj0aHajYUL/xxWnrJwoYWHo8O8s48ntK4O+mixazNj8uWEJbTiZxplXIgt8q30rQbJgY3LqtekfPGlPc7cLq9ewE8nEGNVrE2PERa6kDBjYL/v34uo4MfbG8dIFJBfrAd/IVHz+6jPFc4EySJxYxtDN9pVKABZ9UFYVZS//DG7/ldtoavgHQcwKn/DXTYbjjtxwB35dTActdMYKiKS4mfZfjZ9Jya53K+LPz/l3urOA1ZNGEbc5Q==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B+zd/1sz+CC5JZwDENWYA5HeOfahd/7TyGnBOKF3q3NM6LPOgyZ919AJYDkwNpa1CAWAOanSLhoSNH7T9RrntwmbZF9Kq/bOetlxMaFr0ErYKhOlXF1WBkhe5Jqe4rGUv1ls+OUTxOqTuxZ88JrBM1yJRzHOniVJ8AQYa5QxxpAFeXwkP/S78VUCZVwcPvtDrxOd7+CcEgCIVJw8XzzXO4Aed9a5ojdxsou+UmnLOepFL5S6OvZw/eRQFry0baRooeuukGAvsJ7xpuxN1V9tBsrKDRzRW1iNyi5w3CHpXwsGjhwt9/9+/K4p6rO7HM/O0fktw34LlCT7HssSqncp/g==
- Authentication-results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
- Cc: Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
- Delivery-date: Wed, 18 Aug 2021 12:44:49 +0000
- Ironport-hdrordr: A9a23:iBQxpK7XRqifRmMWwgPXwDjXdLJyesId70hD6qkQc3Fom62j5q eTdZEgvyMc5wx/ZJhNo7690ey7MBDhHP1OkO0s1NWZPDUO0VHARO1fBMnZsl/d8kXFndK1vp 0QFpSWZueQMbB75/yKnDVREbwbsaa6GHbDv5ah859vJzsaGp2J921Ce2Cm+tUdfng9OXI+fq Dsn/Zvln6bVlk8SN+0PXUBV/irnay3qHq3CSR2fyLO8WO1/EiV1II=
- Ironport-sdr: /tGpiP0w/p082c32XK/uuIea1KV2XQ4FX0mDxRr0wUzYmzD5b15/4iryO46vevfYxbhgMin5/f MXoWp4k0ivRsZyToEh9sJLd1Zaha2A6StZge34I0RpGC1Kt0+kZUid/37cYu8eVwZm7hogmLtw so9Id6vX7CtNQ3Og6QRfdgPwrU3QpuhIntq95FFsAzGYlhdMZhmruvjfieot5vnXcNZQj9hTTq D+bOYVOtlVAdBdNaWJbDYL67SOQ0MEzGh33SbLEgpnyvDDpYDrncvWufEmaXpxGFkfAr4Q4N7f 3qHc8PBBSKj9kGTVIYIdPWHL
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
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.
~Andrew
|