[edk2-devel] [PATCH 04/12] OvmfPkg/ResetVector: Perform a simple SEV-ES sanity check

Lendacky, Thomas posted 12 patches 5 years, 1 month ago
There is a newer version of this series
[edk2-devel] [PATCH 04/12] OvmfPkg/ResetVector: Perform a simple SEV-ES sanity check
Posted by Lendacky, Thomas 5 years, 1 month ago
From: Tom Lendacky <thomas.lendacky@amd.com>

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3108

If a hypervisor incorrectly reports through CPUID that SEV-ES is not
active, ensure that a #VC exception was not taken. If it is found that
a #VC was taken, then the code enters a HLT loop.

Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
---
 OvmfPkg/ResetVector/Ia32/PageTables64.asm | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/OvmfPkg/ResetVector/Ia32/PageTables64.asm b/OvmfPkg/ResetVector/Ia32/PageTables64.asm
index 3cd909df4f09..b08f31157cbf 100644
--- a/OvmfPkg/ResetVector/Ia32/PageTables64.asm
+++ b/OvmfPkg/ResetVector/Ia32/PageTables64.asm
@@ -153,6 +153,21 @@ SevEncBitLowHlt:
     jmp       SevEncBitLowHlt
 
 NoSev:
+    ;
+    ; Perform an SEV-ES sanity check by seeing if a #VC exception occurred.
+    ;
+    cmp       byte[SEV_ES_WORK_AREA], 0
+    jz        NoSevPass
+
+    ;
+    ; A #VC was received, yet CPUID indicates no SEV-ES support, something
+    ; isn't right.
+    ;
+NoSevEsVcHlt:
+    hlt
+    jmp       NoSevEsVcHlt
+
+NoSevPass:
     xor       eax, eax
 
 SevExit:
-- 
2.28.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#68904): https://edk2.groups.io/g/devel/message/68904
Mute This Topic: https://groups.io/mt/78986154/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH 04/12] OvmfPkg/ResetVector: Perform a simple SEV-ES sanity check
Posted by Laszlo Ersek 5 years, 1 month ago
On 12/15/20 21:51, Lendacky, Thomas wrote:
> From: Tom Lendacky <thomas.lendacky@amd.com>
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3108
> 
> If a hypervisor incorrectly reports through CPUID that SEV-ES is not
> active, ensure that a #VC exception was not taken. If it is found that
> a #VC was taken, then the code enters a HLT loop.
> 
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
> Cc: Brijesh Singh <brijesh.singh@amd.com>
> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
>  OvmfPkg/ResetVector/Ia32/PageTables64.asm | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/OvmfPkg/ResetVector/Ia32/PageTables64.asm b/OvmfPkg/ResetVector/Ia32/PageTables64.asm
> index 3cd909df4f09..b08f31157cbf 100644
> --- a/OvmfPkg/ResetVector/Ia32/PageTables64.asm
> +++ b/OvmfPkg/ResetVector/Ia32/PageTables64.asm
> @@ -153,6 +153,21 @@ SevEncBitLowHlt:
>      jmp       SevEncBitLowHlt
>  
>  NoSev:
> +    ;
> +    ; Perform an SEV-ES sanity check by seeing if a #VC exception occurred.
> +    ;
> +    cmp       byte[SEV_ES_WORK_AREA], 0
> +    jz        NoSevPass
> +
> +    ;
> +    ; A #VC was received, yet CPUID indicates no SEV-ES support, something
> +    ; isn't right.
> +    ;
> +NoSevEsVcHlt:
> +    hlt
> +    jmp       NoSevEsVcHlt
> +
> +NoSevPass:
>      xor       eax, eax
>  
>  SevExit:
> 

(Please consider the CLI question for this patch as well.)

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

Thanks
Laszlo



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#69631): https://edk2.groups.io/g/devel/message/69631
Mute This Topic: https://groups.io/mt/78986154/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH 04/12] OvmfPkg/ResetVector: Perform a simple SEV-ES sanity check
Posted by Lendacky, Thomas 5 years, 1 month ago
On 1/4/21 2:00 PM, Laszlo Ersek wrote:
> On 12/15/20 21:51, Lendacky, Thomas wrote:
>> From: Tom Lendacky <thomas.lendacky@amd.com>
>>
>> BZ: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D3108&amp;data=04%7C01%7Cthomas.lendacky%40amd.com%7C653d18caa3484d3cd37608d8b0eb6075%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637453872278185152%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=K8Tcu8N5gC3IxFtz2ZxNxa4hCJIAI72Gr8adBt6vaBU%3D&amp;reserved=0
>>
>> If a hypervisor incorrectly reports through CPUID that SEV-ES is not
>> active, ensure that a #VC exception was not taken. If it is found that
>> a #VC was taken, then the code enters a HLT loop.
>>
>> Cc: Jordan Justen <jordan.l.justen@intel.com>
>> Cc: Laszlo Ersek <lersek@redhat.com>
>> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
>> Cc: Brijesh Singh <brijesh.singh@amd.com>
>> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
>> ---
>>   OvmfPkg/ResetVector/Ia32/PageTables64.asm | 15 +++++++++++++++
>>   1 file changed, 15 insertions(+)
>>
>> diff --git a/OvmfPkg/ResetVector/Ia32/PageTables64.asm b/OvmfPkg/ResetVector/Ia32/PageTables64.asm
>> index 3cd909df4f09..b08f31157cbf 100644
>> --- a/OvmfPkg/ResetVector/Ia32/PageTables64.asm
>> +++ b/OvmfPkg/ResetVector/Ia32/PageTables64.asm
>> @@ -153,6 +153,21 @@ SevEncBitLowHlt:
>>       jmp       SevEncBitLowHlt
>>   
>>   NoSev:
>> +    ;
>> +    ; Perform an SEV-ES sanity check by seeing if a #VC exception occurred.
>> +    ;
>> +    cmp       byte[SEV_ES_WORK_AREA], 0
>> +    jz        NoSevPass
>> +
>> +    ;
>> +    ; A #VC was received, yet CPUID indicates no SEV-ES support, something
>> +    ; isn't right.
>> +    ;
>> +NoSevEsVcHlt:
>> +    hlt
>> +    jmp       NoSevEsVcHlt
>> +
>> +NoSevPass:
>>       xor       eax, eax
>>   
>>   SevExit:
>>
> 
> (Please consider the CLI question for this patch as well.)

Yup, I'll add a CLI.

Thanks,
Tom

> 
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
> 
> Thanks
> Laszlo
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#69634): https://edk2.groups.io/g/devel/message/69634
Mute This Topic: https://groups.io/mt/78986154/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-