Re: [PATCH v10 2/6] x86/sev: Initialize RMPOPT configuration MSRs
From: Kalra, Ashish
Date: Mon Jul 20 2026 - 18:39:01 EST
Hello Boris,
On 7/20/2026 5:17 PM, Borislav Petkov wrote:
> On Tue, Jun 30, 2026 at 06:10:13PM +0000, Ashish Kalra wrote:
>> @@ -490,6 +494,11 @@ static bool __init setup_rmptable(void)
>> if (rmp_cfg & MSR_AMD64_SEG_RMP_ENABLED) {
>> if (!setup_segmented_rmptable())
>> return false;
>> + /*
>> + * RMPOPT requires a segmented RMP, so indicate that the
>> + * system is capable of configuring and running RMPOPT.
>> + */
>> + rmpopt_capable = true;
>
> So we're capable of doing RMPOPT when setup_segmented_rmptable() has
> succeeded. Which means, when rmp_segment_table is not NULL, i.e., when we have
> a segmented table.
>
> Which means that instead of testing rmpopt_capable, you need to test
> CC_ATTR_HOST_SEV_SNP and rmp_segment_table != NULL and you can put that in
> a helper local to arch/x86/virt/svm/sev.c
>
> Which means, you don't need that bool.
>
Agreed on dropping the bool — I'll derive it in a local helper.
One issue though: rmp_segment_table != NULL isn't segmented-only. setup_contiguous_rmptable() also allocates rmp_segment_table
(the contiguous RMP is stored as a single segment in the same table), so it's non-NULL for the contiguous case too.
To keep it segmented-only, I'll also need to gate on the segmented-RMP mode, something like:
static bool rmpopt_capable(void)
{
return cpu_feature_enabled(X86_FEATURE_RMPOPT) &&
cc_platform_has(CC_ATTR_HOST_SEV_SNP) &&
(rmp_cfg & MSR_AMD64_SEG_RMP_ENABLED) &&
rmp_segment_table;
}
The CC_ATTR_HOST_SEV_SNP check also handles SNP being disabled at runtime, so snp_clear_rmpopt_capable() and its caller go away as well.
Thanks,
Ashish