Re: [PATCH v4 3/7] x86/sev: Initialize RMPOPT configuration MSRs
From: Kalra, Ashish
Date: Tue May 05 2026 - 16:06:10 EST
Hello Ackerley,
On 5/1/2026 1:12 PM, Ackerley Tng wrote:
> Ashish Kalra <Ashish.Kalra@xxxxxxx> writes:
>
>>
>> [...snip...]
>>
>> +void snp_setup_rmpopt(void)
>> +{
>> + u64 rmpopt_base;
>> + int cpu;
>> +
>> + if (!cpu_feature_enabled(X86_FEATURE_RMPOPT))
>> + return;
>> +
>> + /*
>> + * RMPOPT_BASE MSR is per-core, so only one thread per core needs to
>> + * setup RMPOPT_BASE MSR.
>> + */
>> +
>> + for_each_online_cpu(cpu) {
>
> Dave mentioned hotplug in v3 [1], which led me to check. From this
> series, it looks like RMPOPT won't ever be performed for newly-plugged
> cpus, is that okay?
Yes, with this current series, RMPOPT won't be performed on newly-plugged
CPUs, i was computing and storing the cpumask for threads to fire RMPOPT on,
statically during the setup code to save computing it again on the
worker thread, but i believe the simple fix for handling hotplugged CPUs
would be to compute the cpumask every time the worker thread executes.
>
>> + if (!topology_is_primary_thread(cpu))
>> + continue;
>> +
>> + cpumask_set_cpu(cpu, &rmpopt_cpumask);
>
> nit: perhaps flipping the condition is easier to read:
Yes.
>
> if (topology_is_primary_thread(cpu))
> cpumask_set_cpu()
>
>> + }
>> +
>> + rmpopt_pa_start = ALIGN_DOWN(PFN_PHYS(min_low_pfn), SZ_1G);
>> + rmpopt_base = rmpopt_pa_start | MSR_AMD64_RMPOPT_ENABLE;
>> +
>> + /*
>> + * Per-CPU RMPOPT tables support at most 2 TB of addressable memory
>> + * for RMP optimizations. Initialize the per-CPU RMPOPT table base
>> + * to the starting physical address to enable RMP optimizations for
>> + * up to 2 TB of system RAM on all CPUs.
>> + */
>> + wrmsrq_on_cpus(&rmpopt_cpumask, MSR_AMD64_RMPOPT_BASE, rmpopt_base);
>> +}
>
> [1] https://lore.kernel.org/all/ab41b1d8-e464-4ad6-ac07-7318686db10e@xxxxxxxxx/
>
>>
>> [...snip...]
>>