diff mbox series

[v3,5/5] sev/i386: Enable an SEV-ES guest based on SEV policy

Message ID 8e560a8577066c07b5bf1e5993fbd6d697702384.1600205384.git.thomas.lendacky@amd.com (mailing list archive)
State New, archived
Headers show
Series Qemu SEV-ES guest support | expand

Commit Message

Tom Lendacky Sept. 15, 2020, 9:29 p.m. UTC
From: Tom Lendacky <thomas.lendacky@amd.com>

Update the sev_es_enabled() function return value to be based on the SEV
policy that has been specified. SEV-ES is enabled if SEV is enabled and
the SEV-ES policy bit is set in the policy object.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
---
 target/i386/sev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Dr. David Alan Gilbert Sept. 17, 2020, 3:34 p.m. UTC | #1
* Tom Lendacky (thomas.lendacky@amd.com) wrote:
> From: Tom Lendacky <thomas.lendacky@amd.com>
> 
> Update the sev_es_enabled() function return value to be based on the SEV
> policy that has been specified. SEV-ES is enabled if SEV is enabled and
> the SEV-ES policy bit is set in the policy object.
> 
> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
>  target/i386/sev.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/target/i386/sev.c b/target/i386/sev.c
> index 6ddefc65fa..bcaadaa2f9 100644
> --- a/target/i386/sev.c
> +++ b/target/i386/sev.c
> @@ -70,6 +70,8 @@ struct SevGuestState {
>  #define DEFAULT_GUEST_POLICY    0x1 /* disable debug */
>  #define DEFAULT_SEV_DEVICE      "/dev/sev"
>  
> +#define GUEST_POLICY_SEV_ES_BIT (1 << 2)
> +

I'm surprised that all the policy bits aren't defined in a header somewhere.

But other than that,


Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

>  /* SEV Information Block GUID = 00f771de-1a7e-4fcb-890e-68c77e2fb44e */
>  #define SEV_INFO_BLOCK_GUID \
>      "\xde\x71\xf7\x00\x7e\x1a\xcb\x4f\x89\x0e\x68\xc7\x7e\x2f\xb4\x4e"
> @@ -375,7 +377,7 @@ sev_enabled(void)
>  bool
>  sev_es_enabled(void)
>  {
> -    return false;
> +    return sev_enabled() && (sev_guest->policy & GUEST_POLICY_SEV_ES_BIT);
>  }
>  
>  uint64_t
> -- 
> 2.28.0
>
Tom Lendacky Sept. 17, 2020, 4:07 p.m. UTC | #2
On 9/17/20 10:34 AM, Dr. David Alan Gilbert wrote:
> * Tom Lendacky (thomas.lendacky@amd.com) wrote:
>> From: Tom Lendacky <thomas.lendacky@amd.com>
>>
>> Update the sev_es_enabled() function return value to be based on the SEV
>> policy that has been specified. SEV-ES is enabled if SEV is enabled and
>> the SEV-ES policy bit is set in the policy object.
>>
>> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
>> ---
>>   target/i386/sev.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/target/i386/sev.c b/target/i386/sev.c
>> index 6ddefc65fa..bcaadaa2f9 100644
>> --- a/target/i386/sev.c
>> +++ b/target/i386/sev.c
>> @@ -70,6 +70,8 @@ struct SevGuestState {
>>   #define DEFAULT_GUEST_POLICY    0x1 /* disable debug */
>>   #define DEFAULT_SEV_DEVICE      "/dev/sev"
>>   
>> +#define GUEST_POLICY_SEV_ES_BIT (1 << 2)
>> +
> 
> I'm surprised that all the policy bits aren't defined in a header somewhere.

I have another version to be issued with changes to use QemuUUID, so I can 
look at moving the bits to a header.

Thanks,
Tom

> 
> But other than that,
> 
> 
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> 
>>   /* SEV Information Block GUID = 00f771de-1a7e-4fcb-890e-68c77e2fb44e */
>>   #define SEV_INFO_BLOCK_GUID \
>>       "\xde\x71\xf7\x00\x7e\x1a\xcb\x4f\x89\x0e\x68\xc7\x7e\x2f\xb4\x4e"
>> @@ -375,7 +377,7 @@ sev_enabled(void)
>>   bool
>>   sev_es_enabled(void)
>>   {
>> -    return false;
>> +    return sev_enabled() && (sev_guest->policy & GUEST_POLICY_SEV_ES_BIT);
>>   }
>>   
>>   uint64_t
>> -- 
>> 2.28.0
>>
Tom Lendacky Sept. 17, 2020, 4:11 p.m. UTC | #3
On 9/17/20 11:07 AM, Tom Lendacky wrote:
> On 9/17/20 10:34 AM, Dr. David Alan Gilbert wrote:
>> * Tom Lendacky (thomas.lendacky@amd.com) wrote:
>>> From: Tom Lendacky <thomas.lendacky@amd.com>
>>>
>>> Update the sev_es_enabled() function return value to be based on the SEV
>>> policy that has been specified. SEV-ES is enabled if SEV is enabled and
>>> the SEV-ES policy bit is set in the policy object.
>>>
>>> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
>>> ---
>>>   target/i386/sev.c | 4 +++-
>>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/target/i386/sev.c b/target/i386/sev.c
>>> index 6ddefc65fa..bcaadaa2f9 100644
>>> --- a/target/i386/sev.c
>>> +++ b/target/i386/sev.c
>>> @@ -70,6 +70,8 @@ struct SevGuestState {
>>>   #define DEFAULT_GUEST_POLICY    0x1 /* disable debug */
>>>   #define DEFAULT_SEV_DEVICE      "/dev/sev"
>>> +#define GUEST_POLICY_SEV_ES_BIT (1 << 2)
>>> +
>>
>> I'm surprised that all the policy bits aren't defined in a header 
>> somewhere.
> 
> I have another version to be issued with changes to use QemuUUID, so I can 
> look at moving the bits to a header.

Hmmm... and they already are defined in target/i386/sev_i386.h. I guess I 
was looking for sev.h and didn't notice sev_i386.h. So I'll update to use 
the values in sev_i386.h.

Thanks,
Tom

> 
> Thanks,
> Tom
> 
>>
>> But other than that,
>>
>>
>> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
>>
>>>   /* SEV Information Block GUID = 00f771de-1a7e-4fcb-890e-68c77e2fb44e */
>>>   #define SEV_INFO_BLOCK_GUID \
>>>       "\xde\x71\xf7\x00\x7e\x1a\xcb\x4f\x89\x0e\x68\xc7\x7e\x2f\xb4\x4e"
>>> @@ -375,7 +377,7 @@ sev_enabled(void)
>>>   bool
>>>   sev_es_enabled(void)
>>>   {
>>> -    return false;
>>> +    return sev_enabled() && (sev_guest->policy & 
>>> GUEST_POLICY_SEV_ES_BIT);
>>>   }
>>>   uint64_t
>>> -- 
>>> 2.28.0
>>>
diff mbox series

Patch

diff --git a/target/i386/sev.c b/target/i386/sev.c
index 6ddefc65fa..bcaadaa2f9 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -70,6 +70,8 @@  struct SevGuestState {
 #define DEFAULT_GUEST_POLICY    0x1 /* disable debug */
 #define DEFAULT_SEV_DEVICE      "/dev/sev"
 
+#define GUEST_POLICY_SEV_ES_BIT (1 << 2)
+
 /* SEV Information Block GUID = 00f771de-1a7e-4fcb-890e-68c77e2fb44e */
 #define SEV_INFO_BLOCK_GUID \
     "\xde\x71\xf7\x00\x7e\x1a\xcb\x4f\x89\x0e\x68\xc7\x7e\x2f\xb4\x4e"
@@ -375,7 +377,7 @@  sev_enabled(void)
 bool
 sev_es_enabled(void)
 {
-    return false;
+    return sev_enabled() && (sev_guest->policy & GUEST_POLICY_SEV_ES_BIT);
 }
 
 uint64_t