Re: [PATCH v4 3/7] x86/sev: Initialize RMPOPT configuration MSRs
From: Ackerley Tng
Date: Fri May 01 2026 - 14:14:02 EST
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?
> + if (!topology_is_primary_thread(cpu))
> + continue;
> +
> + cpumask_set_cpu(cpu, &rmpopt_cpumask);
nit: perhaps flipping the condition is easier to read:
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...]
>