Re: [PATCH v11 3/6] x86/sev: Initialize RMPOPT configuration MSRs

K Prateek Nayak <[email protected]> Thu, 30 Jul 2026 08:25:37 +0530
Newsgroups dev.linux.lists.linux-coco,org.kernel.vger.kvm,org.kernel.vger.linux-crypto,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
Hello Boris,

On 7/30/2026 7:37 AM, Borislav Petkov wrote:
> On Mon, Jul 27, 2026 at 07:04:57PM +0000, Ashish Kalra wrote:
>> @@ -705,10 +760,12 @@ bool snp_probe_rmptable_info(void)
>>  	if (cpu_feature_enabled(X86_FEATURE_SEGMENTED_RMP))
>>  		rdmsrq(MSR_AMD64_RMP_CFG, rmp_cfg);
>>  
>> -	if (rmp_cfg & MSR_AMD64_SEG_RMP_ENABLED)
>> +	if (rmp_cfg & MSR_AMD64_SEG_RMP_ENABLED) {
>>  		return probe_segmented_rmptable_info();
>> -	else
>> +	} else {
>> +		setup_clear_cpu_cap(X86_FEATURE_RMPOPT);
> 
> That looks a bit squirreled away in a probing function. Let's make that a bit
> more obvious:
> 
> bool snp_probe_rmptable_info(void)
> {
>         if (cpu_feature_enabled(X86_FEATURE_SEGMENTED_RMP)) {
>                 rdmsrq(MSR_AMD64_RMP_CFG, rmp_cfg);
> 
>                 if (rmp_cfg & MSR_AMD64_SEG_RMP_ENABLED)
>                         return probe_segmented_rmptable_info();
>         } else {

I believe there can be cases where CPUID advertises
X86_FEATURE_SEGMENTED_RMP but rmf_cfg doesn't set
MSR_AMD64_SEG_RMP_ENABLED because otherwise checking rmp_cfg in
addition to the feature bit makes no sense.

In that case we should attempt a probe_contiguous_rmptable_info() even
for X86_FEATURE_SEGMENTED_RMP.

Essentially drop that "else" and do something like:

bool snp_probe_rmptable_info(void)
{
	if (cpu_feature_enabled(X86_FEATURE_SEGMENTED_RMP)) {
		rdmsrq(MSR_AMD64_RMP_CFG, rmp_cfg);

		if (rmp_cfg & MSR_AMD64_SEG_RMP_ENABLED)
			return probe_segmented_rmptable_info();
	}

	/*
	 * Segmented RMP is either not supported on the platform or
	 * is disabled by the firmware. RMPOPT is not not supported
	 * without segmented RMP.
	 */
	setup_clear_cpu_cap(X86_FEATURE_RMPOPT);

	return probe_contiguous_rmptable_info();
}

>                 /* RMPOPT is supported only with a segmented RMP table. */
>                 setup_clear_cpu_cap(X86_FEATURE_RMPOPT);
> 
>                 return probe_contiguous_rmptable_info();
>         }       
> }


-- 
Thanks and Regards,
Prateek