On 2021/6/2 2:30, Tom Lendacky wrote:
On 5/26/21 2:24 AM, Pu Wen wrote:
The first two bits of the CPUID leaf 0x8000001F EAX indicate whether SEV or SME is supported respectively. It's better to check whether SEV or SME is supported before checking the SEV MSR(0xc0010131) to see whether SEV or SME is enabled.
This also avoid the MSR reading failure on the first generation Hygon Dhyana CPU which does not support SEV or SME.
Fixes: eab696d8e8b9 ("x86/sev: Do not require Hypervisor CPUID bit for SEV guests") Cc: stable@vger.kernel.org # v5.10+ Signed-off-by: Pu Wen puwen@hygon.cn
I think the commit message needs to be expanded to clarify the situations and provide more detail.
Okay.
This is both a bare-metal issue and a guest/VM issue. Since Hygon doesn't support the MSR_AMD64_SEV MSR, reading that MSR results in a #GP - either directly from hardware in the bare-metal case or via the hypervisor (because the RDMSR is actually intercepted) in the guest/VM case, resulting in a failed boot. And since this is very early in the boot phase, rdmsrl_safe()/native_read_msr_safe() can't be used.
The description is good, will add this.
So by checking the CPUID information before attempting the RDMSR, this goes back to the behavior before the patch identified in the Fixes: tag.
With an improved commit message:
Acked-by: Tom Lendacky thomas.lendacky@amd.com
Thanks, will send patch v2 with improved commit messages.