[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: Tue, 24 Aug 2021 22:11:41 +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=D51h2qHY2OK/DVylJ3RtXiH4c0xJ/8VDp2bS2TibvT0=; b=JUQlRMwG7dcUcpGyppY1sPZJO3SiFjSI+y3zkwhfazSYz4nSwOrLo8I0B+FKPkLDfzJ7r94Xe/otoJ15ztWSZQwmUUzjgJ26wpTyI9dqbw0BRKydcAyWo1a+g4maH1vlyrK9iuMXlpcNPRjFApgvqiNa1py9finZiJYKOb0G3nlRdKlTTJriCLCoUdRpvfvZ0PHRoQiQ3HD2PvpI6IZjXXlo0hz+B8fKLCGIfYpnstWnZVHdhKa6S1N0EbH0Ux30XUgI43pydrheJKD40f4jDSdvuoVnSzzWMKMMGxzkng/aHj74quODHEVN/yxN0gdld00k6TauU3aYw6ggNPH/xA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PkoOPctKzPGh4p0vKPourGX7Pr9jhv7Ih3JEmh8jsRWPcEddgbtNqBDX3vY2fD8LyOHmhsq1dfl2+NdvCUsIpVYCYYGdmMFK2tRZcUfb3yPVDafcqaICLNY2WH8MPmHeUwgq1fu463DIQhSsfACvZW5P8QFPUGL341qm0lSAS7mhOZbCqiY8dRk1yabzcV8JGmrUhkbt75LvBrk7J2K0ZOqfdLdWiNgSx+Ar2GbzC8PXlNt8n+NE15X3qAuSFNDrGFmLvVbpIUSAwboHlmXRHNiLu8we04gllMWKixRYOt4aCqH81IF5kAfBPM3ICj1S/2WnvNirZtOM6nQnfMz7zQ==
- Authentication-results: esa1.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: Tue, 24 Aug 2021 21:12:10 +0000
- Ironport-hdrordr: A9a23:/7yIvqPe6LmZcsBcT0/155DYdb4zR+YMi2TDiHofdfUFSKClfp 6V8cjztSWUtN4QMEtQ/exoS5PwPk80kqQFnbX5XI3SITUO3VHHEGgM1/qb/9SNIVydygcZ79 YbT0EcMqyBMbEZt7eC3ODQKb9Jq7PmgcPY99s2jU0dKj2CA5sQnjuRYTzrdHGeKjM2YKbRWK Dsnfau8FGbCAoqh4mAdzY4dtmGg+eOuIPtYBYACRJiwA6SjQmw4Lq/NxSDxB8RXx5G3L9nqA H+4k3Ez5Tml8v+5g7X1mfV4ZgTsNz9yuFbDMjJrsQOMD3jhiuheYwkcbyfuzIepv2p9T8R4Z fxiiZlG/42x2Laf2mzrxeo8w780Aw243un8lOciWuLm72yeBsKT+56wa5JeBrQ7EQt+Ptm1r hQ4m6fv51LSTvdgSXU/bHzJlNXv3vxhUBnvf8YjnRZX4dbQqRWt5Yj8ERcF4pFND7m6bogDP JlAKjnlbVrmGuhHjTkV1RUsZuRtixZJGbBfqFCgL3U79FupgE986NCr/Zvx0vpnfkGOup5D+ etCNUiqFgBdL5PUUrRbN1xN/dfMVa9NS4kBljiaWgPJJt3Tk4llKSHl4ndxNvaNaDgn6FC1K gobjtjxCcPkgTVeJaz4KE=
- Ironport-sdr: 0jo70kKppi8+0oJ20If2HQbaH3yP2W7/OJ4zWXkjHkxY+RV4eSNSYFN2dpCRF8tmw/yx6nCjRe a2Us8MhzSpJekrBKOmo7Fa+XDhlcXot09dT+ve/vAqILw8uVRdf9AHGWXdW3Tp7ct3H1mf5Yam +WmrhZxJs3Wm3QboUJhxXyWBeRJQpK84Pp3e3QPCgBt5eDtYMh94JRksbo3cD9xAj3/gwM1e4U FyC7owtlheSDESmIUUK6qO3efiO2JhVApp4E78gD5uxRUSDucPzEqtXgFfdzZ+HEhHgJ3cAiDH oBRDFgaekT2oLI0moO5qDaHM
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
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);
cpu/common.c:120:static DEFINE_PER_CPU(uint64_t, msr_misc_features);
msr.c:35:DEFINE_PER_CPU(uint32_t, tsc_aux);
xstate.c:36:static DEFINE_PER_CPU(uint64_t, xcr0);
xstate.c:79:static DEFINE_PER_CPU(uint64_t, xss);
There is also:
traps.c:100:DEFINE_PER_CPU(uint64_t, efer);
which we *almost* handle correctly, but fail to update the cache on the
BSP out of S3.
For the APIC, I think we have issues with:
irq.c:1083:static DEFINE_PER_CPU(struct pending_eoi,
pending_eoi[NR_DYNAMIC_VECTORS]);
because we don't defer S3 until all pending EOIs are complete.
I gave up trying to figure out the MCE or power governor logic so we may
have additional issues there.
Additionally,
flushtlb.c:34:DEFINE_PER_CPU(u32, tlbflush_time);
really does need setting appropriately, although I think the only
fallout is a few unnecessary TLB flushes.
~Andrew
|