[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: Jan Beulich <jbeulich@xxxxxxxx>
- From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
- Date: Mon, 31 Jan 2022 11:35:43 +0000
- Accept-language: en-GB, en-US
- 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=NiAQYwMUm+EzrVf7M2IkJwJ2lIPvx082Ghp/3XvMeSg=; b=FAeIMSvJIt0j23nlL+Q+lcMd93Vyr5V8VB3+FR6QRgJ6zR3mpYTdbl3DSBqsy6JDfrJqOWCQ0U8DsUnb134SWYaTAK8Lscpl55iaAHEjcFaYNgZHw8aMFE866hIWB2nuOJqhj4kjzo9toM4Hxp4LomAoEbtRaGk/C58cc2oN7Ym3D0ZgIHslbG7bdpfGQm4GUhhiwhwbaPLcjt3r7HtfOao4qKQscoC0B90ChMyfQIzgAUZhiHWml865GSFmhm50rMzRW2XUVc0tkLACcClj9cLtdhKnCmcZ9HrGgoAVZp2grZPDs96kHhO8/TQglUPm6SyP855FxdQ3u1zc8Gf+qw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mgEPU8bfW63auB8/aqwOGaSeO50tx7tiOEpnzWxXK1jijcPvQjTFW/+lkL35VXK6iNbMLhE9m3D/mh6NsBtJJxuKcZAxCHOYIEKwYEBfOKeG1dBnadKk/6dOG1KIJ9AwQL/6r2HR1QPt/2FhdIZh/sluuavnQD7lVvWhj7gklSOvRrJ+bTkocsSyJJaKBX8b81IP25EyXX7CcksCQVqztFxdStT2MNBzIqTqgEtI5Oexr84THLuR9dJyymuvhn32TaktJy05tSYS7Q99p9PjuQVLLv1KH8JMsX3KfiF53mIH+otmT/Mt7Uq7uv9KZ3uRGVsUzzgiRJhCle4lHYwV/g==
- Authentication-results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
- Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- Delivery-date: Mon, 31 Jan 2022 11:35:54 +0000
- Ironport-data: A9a23:mHwfVKJ9G0oAhDQPFE+RPJIlxSXFcZb7ZxGr2PjKsXjdYENShGYCz jFLDT3QaPuJZGKjf911PIjg9E1Vu5DWyYQ3T1RlqX01Q3x08seUXt7xwmUcns+xwm8vaGo9s q3yv/GZdJhcokcxIn5BC5C5xZVG/fjgqoHUVaiUakideSc+EH170Us4wrZg6mJVqYPR7z2l6 IuaT/L3YDdJ6xYsWo7Dw/vewP/HlK2aVAIw5jTSV9gS1LPtvyB94KYkDbOwNxPFrrx8RYZWc QphIIaRpQs19z91Yj+sfy2SnkciGtY+NiDW4pZatjTLbrGvaUXe345iXMfwZ3u7hB3Vgsl29 osOsKCrbigVM5DSiv4AaxNxRnQW0a1uoNcrIFC6uM2XiUbHb2Ht07NlC0Re0Y8wo7gtRzsUr LpBdW5LPkvra+GemdpXTsFFgMg5IdatF4QYonx6lhnSDOo8QICFSKLPjTNd9Glr3psURKmCD yYfQQc3aASeYDMXAFo4F8wsxMnwlkD1fTIN/Tp5ooJoujOOnWSdyoPFINfTP9CHW8hRtkKZv X7duXT0BAkAM96SwibD9Wij7sfQmQvrVYRUE6e3ntZoilCOwm0YCDUNSEC25/K+jyaDt8l3c hJOvHB09O5rqRLtHoKVswCETGCs4gMFXOQOUOgG8yai9qfp/RSDG1AOZ2sUADA5j/MeSTsv3 16PutrmAz1zrbGYIU6gGqeoQSCaYnZMczJbDcMQZ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X6bRf6 Dsgvav0gDQH0j/Gf7LYUXtMdKzxeHjpdbDW1orFhQn4A6BgXeD87jhCSWV2R8YTndm3aoi2X KtqX272oyT99WAjjPM3W7a6Jpb3PH7zMFYOcCKgs8Jbh3xlweTYph7UbHqhkF2nAjv0idurD D/mWZmAy1B0QKWQohzm2q15+DU6kdr15Yl8y7BvZKsm72jeNtwMbs/uWsQSGqm16NnhqAg7E sD5RPoi3IcZymw7RjV9pzGUQpnmVGzpmdnmekPj2ZHWY9bc7NJq5cDlXklWqvoMRiKoLzPKt MeR/00JcwmBW+yfjTcpC1i0dasVnM8ElOPRVUDoNWc13xTkGpix0UVycQDljNYnahNB6Vs9q DBKOBlhbtORsgZYeZ0A/oAW9K+DijITQjXOGyfLFz7HOUMOm7LqZTw/LIpjdvaNaAg3d83gt DMQVlYvWk9dwbnDtCPxoRC9lTXTGC0TV3Wu4hjDlhCy8vBrZbQQF++oWEV4rydSq8kc77mst 6ISedrP8M=
- Ironport-sdr: HlDouB5w2hfk8P+ptChQiybKLIdewboiefLrcD1JoqkRGqWSYmpkB/ZK0GGk7l3kmcLIHRS/4Y BhvUhErLc13PN+RWnPUpeB+XNFAUCNtVE/Ivday5CC7RV3yJnSQcNsUxkpaZk50Twrj/cl1GGE Jyeiw9g/dZUoW7k23YGguBFeNbf5kJRm3ZjThIqVm/ad/Efg9jJ7mPQu9aK9qm5WifGkQGuXz2 Auc8QyMghNFTpe7C3dZ1TS761KJv8rq34CpseehcXHr2pNLP53RMI7dNyF8jZGL5RGstLJZK9C Kp/fY5Y9OBp/0UuwTUhVbKrp
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHYFEsmzjI7mjP2gUCbwx5jxoXzCax876wAgAAVGYA=
- Thread-topic: [PATCH v2 5/9] x86/spec-ctrl: Record the last write to MSR_SPEC_CTRL
On 31/01/2022 10:20, Jan Beulich wrote:
> 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>
Thanks.
> 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)?
I considered that, but decided against it. The PV and IST caching logic
is likely to be in asm, meaning that the single piece of C check-if-same
logic is in vmentry_spec_ctrl().
i.e. I think this is the right way forward. By the end of the PV work,
if there is obvious tidy-up to do, I will do so.
~Andrew
|