target/i386: sev: add 'sev-max-guests' field to 'query-sev-capabilities'
PATCH v2 1/1 target/i386: sev: add 'sev-max-guests' field to 'query-sev-capabilities'
There are limited numbers of the SEV guests that can be run concurrently. A management applications may need to know this limit so that it can place SEV VMs on hosts which have suitable resources available.
Currently, this limit is not exposed to the application. Add a new 'sev-max-guest' field in the query-sev-capabilities to provide this information.
---
changes since v1:
- document the new field and add (since 4.1) annotation.
qapi/target.json | 9 +++++++-- target/i386/sev.c | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-)
qapi/target.json +7 -2
@@ -177,13 +177,17 @@ # @reduced-phys-bits: Number of physical Address bit reduction when SEV is # enabled # +# @sev-max-guests: maximum number of concurrent SEV guest with SEV-ES disabled +# (since 4.1) +# # Since: 2.12 ## { 'struct': 'SevCapability', 'data': { 'pdh': 'str', 'cert-chain': 'str', 'cbitpos': 'int', - 'reduced-phys-bits': 'int'}, + 'reduced-phys-bits': 'int', + 'sev-max-guests': 'int'}, 'if': 'defined(TARGET_I386)' } ##
@@ -200,7 +204,8 @@ # # -> { "execute": "query-sev-capabilities" } # <- { "return": { "pdh": "8CCDD8DDD", "cert-chain": "888CCCDDDEE", -# "cbitpos": 47, "reduced-phys-bits": 5}} +# "cbitpos": 47, "reduced-phys-bits": 5, +# "sev-max-guests" : 15}} # ## { 'command': 'query-sev-capabilities', 'returns': 'SevCapability',
target/i386/sev.c +7 -2
@@ -488,7 +488,7 @@ sev_get_capabilities(void)guchar *pdh_data =NULL ;guchar *cert_chain_data =NULL ;size_t pdh_len =0 , cert_chain_len =0 ; -uint32_t ebx; +uint32_t ebx, ecx, edx;int fd; fd =open (DEFAULT_SEV_DEVICE ,O_RDWR );
@@ -507,7 +507,7 @@ sev_get_capabilities(void) cap->pdh =g_base64_encode (pdh_data, pdh_len); cap->cert_chain =g_base64_encode (cert_chain_data, cert_chain_len); -host_cpuid (0x8000001F ,0 ,NULL , &ebx,NULL ,NULL ); +host_cpuid (0x8000001F ,0 ,NULL , &ebx, &ecx, &edx); cap->cbitpos = ebx &0x3f ;/*
@@ -516,6 +516,11 @@ sev_get_capabilities(void)*/ cap->reduced_phys_bits =1 ; +/* +* The maximum number of SEV guests with SEV-ES disabled that can run +* simultaneously. +*/ + cap->sev_max_guests = ecx - edx +1 ; out:g_free (pdh_data);g_free (cert_chain_data);
Signature · 1 line
2.17.1
Quoted 49 lines · Brijesh
There are limited numbers of the SEV guests that can be run concurrently. A management applications may need to know this limit so that it can place SEV VMs on hosts which have suitable resources available.
Currently, this limit is not exposed to the application. Add a new 'sev-max-guest' field in the query-sev-capabilities to provide this information.
Cc Paolo Bonzini <[email protected]>Cc Markus Armbruster <[email protected]>Cc Eric Blake <[email protected]>Cc Daniel P. Berrangé <[email protected]>Cc Laszlo Ersek <[email protected]>Cc Erik Skultety <[email protected]>Cc Tom Lendacky <[email protected]>Signed-off-by Brijesh Singh <[email protected]>---
changes since v1:
- document the new field and add (since 4.1) annotation.qapi/target.json | 9 +++++++-- target/i386/sev.c | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-)qapi/target.json +5
-1@@ -177,13 +177,17 @@ # @reduced-phys-bits: Number of physical Address bit reduction when SEV is # enabled # +# @sev-max-guests: maximum number of concurrent SEV guest with SEV-ES disabled +# (since 4.1) +# # Since: 2.12 ## { 'struct': 'SevCapability', 'data': { 'pdh': 'str', 'cert-chain': 'str', 'cbitpos': 'int', - 'reduced-phys-bits': 'int'}, + 'reduced-phys-bits': 'int', + 'sev-max-guests': 'int'}, 'if': 'defined(TARGET_I386)' } ##
qapi/target.json line 208
Quoted 6 lines
qapi/target.json +2
-1@@ -200,7 +204,8 @@ # # -> { "execute": "query-sev-capabilities" } # <- { "return": { "pdh": "8CCDD8DDD", "cert-chain": "888CCCDDDEE", -# "cbitpos": 47, "reduced-phys-bits": 5}} +# "cbitpos": 47, "reduced-phys-bits": 5, +# "sev-max-guests" : 15}}
There seems to be a superfluous space character before the colon, but I don't think it matters much.
Quoted 28 lines
qapi/target.json +0
-0# ## { 'command': 'query-sev-capabilities', 'returns': 'SevCapability',target/i386/sev.c +2
-2@@ -488,7 +488,7 @@ sev_get_capabilities(void)guchar *pdh_data =NULL ;guchar *cert_chain_data =NULL ;size_t pdh_len =0 , cert_chain_len =0 ; -uint32_t ebx; +uint32_t ebx, ecx, edx;int fd; fd =open (DEFAULT_SEV_DEVICE ,O_RDWR );@@ -507,7 +507,7 @@ sev_get_capabilities(void) cap->pdh =g_base64_encode (pdh_data, pdh_len); cap->cert_chain =g_base64_encode (cert_chain_data, cert_chain_len); -host_cpuid (0x8000001F ,0 ,NULL , &ebx,NULL ,NULL ); +host_cpuid (0x8000001F ,0 ,NULL , &ebx, &ecx, &edx); cap->cbitpos = ebx &0x3f ;/* @@ -516,6 +516,11 @@ sev_get_capabilities(void)*/
target/i386/sev.c sev_get_capabilities(void) · line 526
Quoted 10 lines
target/i386/sev.c +5
-0cap->reduced_phys_bits =1 ; +/* +* The maximum number of SEV guests with SEV-ES disabled that can run +* simultaneously. +*/ + cap->sev_max_guests = ecx - edx +1 ; out:g_free (pdh_data);g_free (cert_chain_data);
Thanks!
Laszlo
Quoted 89 lines · Laszlo Ersek
Quoted 49 lines · Brijesh
There are limited numbers of the SEV guests that can be run concurrently. A management applications may need to know this limit so that it can place SEV VMs on hosts which have suitable resources available.
Currently, this limit is not exposed to the application. Add a new 'sev-max-guest' field in the query-sev-capabilities to provide this information.
Cc Paolo Bonzini <[email protected]>Cc Markus Armbruster <[email protected]>Cc Eric Blake <[email protected]>Cc Daniel P. Berrangé <[email protected]>Cc Laszlo Ersek <[email protected]>Cc Erik Skultety <[email protected]>Cc Tom Lendacky <[email protected]>Signed-off-by Brijesh Singh <[email protected]>---
changes since v1:
- document the new field and add (since 4.1) annotation.qapi/target.json | 9 +++++++-- target/i386/sev.c | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-)qapi/target.json +5
-1@@ -177,13 +177,17 @@ # @reduced-phys-bits: Number of physical Address bit reduction when SEV is # enabled # +# @sev-max-guests: maximum number of concurrent SEV guest with SEV-ES disabled +# (since 4.1) +# # Since: 2.12 ## { 'struct': 'SevCapability', 'data': { 'pdh': 'str', 'cert-chain': 'str', 'cbitpos': 'int', - 'reduced-phys-bits': 'int'}, + 'reduced-phys-bits': 'int', + 'sev-max-guests': 'int'}, 'if': 'defined(TARGET_I386)' } ##qapi/target.json line 208
Quoted 6 lines
qapi/target.json +2
-1@@ -200,7 +204,8 @@ # # -> { "execute": "query-sev-capabilities" } # <- { "return": { "pdh": "8CCDD8DDD", "cert-chain": "888CCCDDDEE", -# "cbitpos": 47, "reduced-phys-bits": 5}} +# "cbitpos": 47, "reduced-phys-bits": 5, +# "sev-max-guests" : 15}}There seems to be a superfluous space character before the colon, but I don't think it matters much.
Quoted 29 lines
qapi/target.json +0
-0# ## { 'command': 'query-sev-capabilities', 'returns': 'SevCapability',target/i386/sev.c +2
-2@@ -488,7 +488,7 @@ sev_get_capabilities(void)guchar *pdh_data =NULL ;guchar *cert_chain_data =NULL ;size_t pdh_len =0 , cert_chain_len =0 ; -uint32_t ebx; +uint32_t ebx, ecx, edx;int fd; fd =open (DEFAULT_SEV_DEVICE ,O_RDWR );@@ -507,7 +507,7 @@ sev_get_capabilities(void) cap->pdh =g_base64_encode (pdh_data, pdh_len); cap->cert_chain =g_base64_encode (cert_chain_data, cert_chain_len); -host_cpuid (0x8000001F ,0 ,NULL , &ebx,NULL ,NULL ); +host_cpuid (0x8000001F ,0 ,NULL , &ebx, &ecx, &edx); cap->cbitpos = ebx &0x3f ;/* @@ -516,6 +516,11 @@ sev_get_capabilities(void)*/ cap->reduced_phys_bits =1 ;
Quoted 11 lines
target/i386/sev.c sev_get_capabilities(void) · line 526
Quoted 9 lines
target/i386/sev.c +5
-0+/* +* The maximum number of SEV guests with SEV-ES disabled that can run +* simultaneously. +*/ + cap->sev_max_guests = ecx - edx +1 ; out:g_free (pdh_data);g_free (cert_chain_data);Reviewed-by Laszlo Ersek <[email protected]>
As mentioned in v1, I don't think a management application should need to run QEMU in order to figure this out.
Paolo
Quoted 102 lines · Paolo Bonzini
Quoted 89 lines · Laszlo Ersek
Quoted 49 lines · Brijesh
There are limited numbers of the SEV guests that can be run concurrently. A management applications may need to know this limit so that it can place SEV VMs on hosts which have suitable resources available.
Currently, this limit is not exposed to the application. Add a new 'sev-max-guest' field in the query-sev-capabilities to provide this information.
Cc Paolo Bonzini <[email protected]>Cc Markus Armbruster <[email protected]>Cc Eric Blake <[email protected]>Cc Daniel P. Berrangé <[email protected]>Cc Laszlo Ersek <[email protected]>Cc Erik Skultety <[email protected]>Cc Tom Lendacky <[email protected]>Signed-off-by Brijesh Singh <[email protected]>---
changes since v1:
- document the new field and add (since 4.1) annotation.qapi/target.json | 9 +++++++-- target/i386/sev.c | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-)qapi/target.json +5
-1@@ -177,13 +177,17 @@ # @reduced-phys-bits: Number of physical Address bit reduction when SEV is # enabled # +# @sev-max-guests: maximum number of concurrent SEV guest with SEV-ES disabled +# (since 4.1) +# # Since: 2.12 ## { 'struct': 'SevCapability', 'data': { 'pdh': 'str', 'cert-chain': 'str', 'cbitpos': 'int', - 'reduced-phys-bits': 'int'}, + 'reduced-phys-bits': 'int', + 'sev-max-guests': 'int'}, 'if': 'defined(TARGET_I386)' } ##qapi/target.json line 208
Quoted 6 lines
qapi/target.json +2
-1@@ -200,7 +204,8 @@ # # -> { "execute": "query-sev-capabilities" } # <- { "return": { "pdh": "8CCDD8DDD", "cert-chain": "888CCCDDDEE", -# "cbitpos": 47, "reduced-phys-bits": 5}} +# "cbitpos": 47, "reduced-phys-bits": 5, +# "sev-max-guests" : 15}}There seems to be a superfluous space character before the colon, but I don't think it matters much.
Quoted 29 lines
qapi/target.json +0
-0# ## { 'command': 'query-sev-capabilities', 'returns': 'SevCapability',target/i386/sev.c +2
-2@@ -488,7 +488,7 @@ sev_get_capabilities(void)guchar *pdh_data =NULL ;guchar *cert_chain_data =NULL ;size_t pdh_len =0 , cert_chain_len =0 ; -uint32_t ebx; +uint32_t ebx, ecx, edx;int fd; fd =open (DEFAULT_SEV_DEVICE ,O_RDWR );@@ -507,7 +507,7 @@ sev_get_capabilities(void) cap->pdh =g_base64_encode (pdh_data, pdh_len); cap->cert_chain =g_base64_encode (cert_chain_data, cert_chain_len); -host_cpuid (0x8000001F ,0 ,NULL , &ebx,NULL ,NULL ); +host_cpuid (0x8000001F ,0 ,NULL , &ebx, &ecx, &edx); cap->cbitpos = ebx &0x3f ;/* @@ -516,6 +516,11 @@ sev_get_capabilities(void)*/ cap->reduced_phys_bits =1 ;Quoted 11 lines
target/i386/sev.c sev_get_capabilities(void) · line 526
Quoted 9 lines
target/i386/sev.c +5
-0+/* +* The maximum number of SEV guests with SEV-ES disabled that can run +* simultaneously. +*/ + cap->sev_max_guests = ecx - edx +1 ; out:g_free (pdh_data);g_free (cert_chain_data);Reviewed-by Laszlo Ersek <[email protected]>
Quoted 2 lines
As mentioned in v1, I don't think a management application should need to run QEMU in order to figure this out.
Libvirt is already running this query-sev-capabilities command to find out information about SEV support, so from our POV this is the natural place to report the max limits.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 102 lines · Paolo Bonzini
Quoted 89 lines · Laszlo Ersek
Quoted 49 lines · Brijesh
There are limited numbers of the SEV guests that can be run concurrently. A management applications may need to know this limit so that it can place SEV VMs on hosts which have suitable resources available.
Currently, this limit is not exposed to the application. Add a new 'sev-max-guest' field in the query-sev-capabilities to provide this information.
Cc Paolo Bonzini <[email protected]>Cc Markus Armbruster <[email protected]>Cc Eric Blake <[email protected]>Cc Daniel P. Berrangé <[email protected]>Cc Laszlo Ersek <[email protected]>Cc Erik Skultety <[email protected]>Cc Tom Lendacky <[email protected]>Signed-off-by Brijesh Singh <[email protected]>---
changes since v1:
- document the new field and add (since 4.1) annotation.qapi/target.json | 9 +++++++-- target/i386/sev.c | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-)qapi/target.json +5
-1@@ -177,13 +177,17 @@ # @reduced-phys-bits: Number of physical Address bit reduction when SEV is # enabled # +# @sev-max-guests: maximum number of concurrent SEV guest with SEV-ES disabled +# (since 4.1) +# # Since: 2.12 ## { 'struct': 'SevCapability', 'data': { 'pdh': 'str', 'cert-chain': 'str', 'cbitpos': 'int', - 'reduced-phys-bits': 'int'}, + 'reduced-phys-bits': 'int', + 'sev-max-guests': 'int'}, 'if': 'defined(TARGET_I386)' } ##qapi/target.json line 208
Quoted 6 lines
qapi/target.json +2
-1@@ -200,7 +204,8 @@ # # -> { "execute": "query-sev-capabilities" } # <- { "return": { "pdh": "8CCDD8DDD", "cert-chain": "888CCCDDDEE", -# "cbitpos": 47, "reduced-phys-bits": 5}} +# "cbitpos": 47, "reduced-phys-bits": 5, +# "sev-max-guests" : 15}}There seems to be a superfluous space character before the colon, but I don't think it matters much.
Quoted 29 lines
qapi/target.json +0
-0# ## { 'command': 'query-sev-capabilities', 'returns': 'SevCapability',target/i386/sev.c +2
-2@@ -488,7 +488,7 @@ sev_get_capabilities(void)guchar *pdh_data =NULL ;guchar *cert_chain_data =NULL ;size_t pdh_len =0 , cert_chain_len =0 ; -uint32_t ebx; +uint32_t ebx, ecx, edx;int fd; fd =open (DEFAULT_SEV_DEVICE ,O_RDWR );@@ -507,7 +507,7 @@ sev_get_capabilities(void) cap->pdh =g_base64_encode (pdh_data, pdh_len); cap->cert_chain =g_base64_encode (cert_chain_data, cert_chain_len); -host_cpuid (0x8000001F ,0 ,NULL , &ebx,NULL ,NULL ); +host_cpuid (0x8000001F ,0 ,NULL , &ebx, &ecx, &edx); cap->cbitpos = ebx &0x3f ;/* @@ -516,6 +516,11 @@ sev_get_capabilities(void)*/ cap->reduced_phys_bits =1 ;Quoted 11 lines
target/i386/sev.c sev_get_capabilities(void) · line 526
Quoted 9 lines
target/i386/sev.c +5
-0+/* +* The maximum number of SEV guests with SEV-ES disabled that can run +* simultaneously. +*/ + cap->sev_max_guests = ecx - edx +1 ; out:g_free (pdh_data);g_free (cert_chain_data);Reviewed-by Laszlo Ersek <[email protected]>
Quoted 2 lines
As mentioned in v1, I don't think a management application should need to run QEMU in order to figure this out.
Sorry, I didn't mean to ignore your feedback; I hadn't seen it.
Thanks
Laszlo
Quoted 16 lines · Brijesh
There are limited numbers of the SEV guests that can be run concurrently. A management applications may need to know this limit so that it can place SEV VMs on hosts which have suitable resources available.
Currently, this limit is not exposed to the application. Add a new 'sev-max-guest' field in the query-sev-capabilities to provide this information.
Cc Paolo Bonzini <[email protected]>Cc Markus Armbruster <[email protected]>Cc Eric Blake <[email protected]>Cc Daniel P. Berrangé <[email protected]>Cc Laszlo Ersek <[email protected]>Cc Erik Skultety <[email protected]>Cc Tom Lendacky <[email protected]>Signed-off-by Brijesh Singh <[email protected]>
Quoted 1 line
---
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 81 lines · Brijesh
There are limited numbers of the SEV guests that can be run concurrently. A management applications may need to know this limit so that it can place SEV VMs on hosts which have suitable resources available.
Currently, this limit is not exposed to the application. Add a new 'sev-max-guest' field in the query-sev-capabilities to provide this information.
Cc Paolo Bonzini <[email protected]>Cc Markus Armbruster <[email protected]>Cc Eric Blake <[email protected]>Cc Daniel P. Berrangé <[email protected]>Cc Laszlo Ersek <[email protected]>Cc Erik Skultety <[email protected]>Cc Tom Lendacky <[email protected]>Signed-off-by Brijesh Singh <[email protected]>---
changes since v1:
- document the new field and add (since 4.1) annotation.qapi/target.json | 9 +++++++-- target/i386/sev.c | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-)qapi/target.json +7
-2@@ -177,13 +177,17 @@ # @reduced-phys-bits: Number of physical Address bit reduction when SEV is # enabled # +# @sev-max-guests: maximum number of concurrent SEV guest with SEV-ES disabled +# (since 4.1) +# # Since: 2.12 ## { 'struct': 'SevCapability', 'data': { 'pdh': 'str', 'cert-chain': 'str', 'cbitpos': 'int', - 'reduced-phys-bits': 'int'}, + 'reduced-phys-bits': 'int', + 'sev-max-guests': 'int'}, 'if': 'defined(TARGET_I386)' } ##@@ -200,7 +204,8 @@ # # -> { "execute": "query-sev-capabilities" } # <- { "return": { "pdh": "8CCDD8DDD", "cert-chain": "888CCCDDDEE", -# "cbitpos": 47, "reduced-phys-bits": 5}} +# "cbitpos": 47, "reduced-phys-bits": 5, +# "sev-max-guests" : 15}} # ## { 'command': 'query-sev-capabilities', 'returns': 'SevCapability',target/i386/sev.c +2
-2@@ -488,7 +488,7 @@ sev_get_capabilities(void)guchar *pdh_data =NULL ;guchar *cert_chain_data =NULL ;size_t pdh_len =0 , cert_chain_len =0 ; -uint32_t ebx; +uint32_t ebx, ecx, edx;int fd; fd =open (DEFAULT_SEV_DEVICE ,O_RDWR );@@ -507,7 +507,7 @@ sev_get_capabilities(void) cap->pdh =g_base64_encode (pdh_data, pdh_len); cap->cert_chain =g_base64_encode (cert_chain_data, cert_chain_len); -host_cpuid (0x8000001F ,0 ,NULL , &ebx,NULL ,NULL ); +host_cpuid (0x8000001F ,0 ,NULL , &ebx, &ecx, &edx); cap->cbitpos = ebx &0x3f ;/*
target/i386/sev.c sev_get_capabilities(void) · line 523
Quoted 8 lines
target/i386/sev.c +5
-0@@ -516,6 +516,11 @@ sev_get_capabilities(void)*/ cap->reduced_phys_bits =1 ; +/* +* The maximum number of SEV guests with SEV-ES disabled that can run +* simultaneously. +*/ + cap->sev_max_guests = ecx - edx +1 ;
I'm not that familiar with QEMU code, so I guess ^this works as intended, but to the idea (and per my comment in v1):