diff mbox series

[1/1] lib/fwts_cpu: correct determination of SEV enablement

Message ID 20250418095434.8281-1-heinrich.schuchardt@canonical.com
State Accepted
Headers show
Series [1/1] lib/fwts_cpu: correct determination of SEV enablement | expand

Commit Message

Heinrich Schuchardt April 18, 2025, 9:54 a.m. UTC
MSR_FEATURE_CONTROL (0xC0000080) bit 12 changes
when module kvm_amd is loaded and unloaded.

MSR_VM_CR (0xC0010114) bit 4 reflects the BIOS setting.
The SVMDIS—Bit is described in [1].

[1]
AMD64 Architecture Programmer’s Manual
Volume 2, System Programming
https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/programmer-references/24593.pdf
3.1.7 Extended Feature Enable Register (EFER), page 55

Link: https://bugs.launchpad.net/ubuntu/+source/fwts/+bug/2098458
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
 src/cpu/virt/virt_svm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Ivan Hu May 26, 2025, 4:16 a.m. UTC | #1
Thanks for the patch.

We're currently discussing the MSR behaviour with AMD engineers, but haven't received any feedback yet:
https://lists.ubuntu.com/archives/fwts-devel/2025-April/013980.html

Let's go ahead and apply this patch, test with MSR_VM_CR, and observe any potential impact going forward.

Cheers,
Ivan

On 2025/4/18 17:54, Heinrich Schuchardt wrote:
> MSR_FEATURE_CONTROL (0xC0000080) bit 12 changes
> when module kvm_amd is loaded and unloaded.
> 
> MSR_VM_CR (0xC0010114) bit 4 reflects the BIOS setting.
> The SVMDIS—Bit is described in [1].
> 
> [1]
> AMD64 Architecture Programmer’s Manual
> Volume 2, System Programming
> https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/programmer-references/24593.pdf
> 3.1.7 Extended Feature Enable Register (EFER), page 55
> 
> Link: https://bugs.launchpad.net/ubuntu/+source/fwts/+bug/2098458
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
>   src/cpu/virt/virt_svm.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/cpu/virt/virt_svm.c b/src/cpu/virt/virt_svm.c
> index d86f54f4..450a7f2a 100644
> --- a/src/cpu/virt/virt_svm.c
> +++ b/src/cpu/virt/virt_svm.c
> @@ -37,7 +37,7 @@
>   #include <limits.h>
>   #include <errno.h>
>   
> -#define MSR_FEATURE_CONTROL	0xC0000080
> +#define MSR_VM_CR		0xC0010114
>   
>   extern fwts_cpuinfo_x86 *fwts_virt_cpuinfo;
>   
> @@ -58,10 +58,10 @@ static int vt_locked_by_bios(fwts_framework *fw)
>   	if (!can_lock_with_msr())
>   		return 0;
>   
> -	if (fwts_cpu_readmsr(fw, 0, MSR_FEATURE_CONTROL, &msr))
> +	if (fwts_cpu_readmsr(fw, 0, MSR_VM_CR, &msr))
>   		return -1;
>   
> -	return ((msr & 0x1000) == 0x1000); /* SVM capable but locked by bios*/
> +	return ((msr & 0x10) == 0x10); /* SVM locked */
>   }
>   
>   void virt_check_svm(fwts_framework *fw)
diff mbox series

Patch

diff --git a/src/cpu/virt/virt_svm.c b/src/cpu/virt/virt_svm.c
index d86f54f4..450a7f2a 100644
--- a/src/cpu/virt/virt_svm.c
+++ b/src/cpu/virt/virt_svm.c
@@ -37,7 +37,7 @@ 
 #include <limits.h>
 #include <errno.h>
 
-#define MSR_FEATURE_CONTROL	0xC0000080
+#define MSR_VM_CR		0xC0010114
 
 extern fwts_cpuinfo_x86 *fwts_virt_cpuinfo;
 
@@ -58,10 +58,10 @@  static int vt_locked_by_bios(fwts_framework *fw)
 	if (!can_lock_with_msr())
 		return 0;
 
-	if (fwts_cpu_readmsr(fw, 0, MSR_FEATURE_CONTROL, &msr))
+	if (fwts_cpu_readmsr(fw, 0, MSR_VM_CR, &msr))
 		return -1;
 
-	return ((msr & 0x1000) == 0x1000); /* SVM capable but locked by bios*/
+	return ((msr & 0x10) == 0x10); /* SVM locked */
 }
 
 void virt_check_svm(fwts_framework *fw)