Re: [PATCH v2] x86/fred: Consolidate the FRED stack pointer assignments

From: H. Peter Anvin

Date: Tue Dec 01 2026 - 17:15:38 EST


On December 1, 2026 2:31:59 AM PST, David Laight <david.laight.linux@xxxxxxxxx> wrote:
>On Mon, 30 Nov 2026 16:06:43 -0800
>"H. Peter Anvin" <hpa@xxxxxxxxx> wrote:
>
>> On November 30, 2026 4:02:52 PM PST, Sohil Mehta <sohil.mehta@xxxxxxxxx> wrote:
>> >On 11/30/2026 3:48 PM, Dave Hansen wrote:
>> >> On 11/30/26 15:43, Sohil Mehta wrote:
>> >>> KVM doesn't write to the same MSR as the kernel. KVM reads the value and
>> >>> writes to the VMCS field HOST_IA32_FRED_RSP1.
>> >>
>> >> This is all optimization, right? How about the series just does rdmsr()
>> >> for now. It's the smallest amount of code. Start there. Optimize later.
>> >
>> >Yes, we could do the optimization later.
>> >
>> >Sean's request originated here:
>> >https://lore.kernel.org/all/aahchI7oiFrjFAmb@xxxxxxxxxx/
>> >
>> >"The simplest approach would be to read the actual MSR. _If_ using a
>> >per-CPU read provides meaningful performance benefits over RDMSR, ...
>> >then have the kernel provide a dedicated accessor."
>> >
>> >So, I am assuming he is still okay with deferring the optimization.
>> >
>> >FWIW, I measured the cycle difference between the per-CPU read and the
>> >MSR read. It was ~6x more with the MSR read but with all the things
>> >happening during vCPU load 3 MSR reads shouldn't matter much.
>> >
>> >
>>
>> The one reason I see to avoid rdmsr is the idea of "frustrate an attacker" by resetting fixed-value control registers when convenient.
>>
>
>Unless you make writes to the per-cpu variables fault aren't they likely
>to be just as easy to overwrite?
>
>David

That would, in fact, be a good thing to do (ro_after_init percpu variables.)