Michael Roth <michael.roth@xxxxxxx> writes: > Most of the current 'query-sev' command is relevant to both legacy > SEV/SEV-ES guests and SEV-SNP guests, with 2 exceptions: > > - 'policy' is a 64-bit field for SEV-SNP, not 32-bit, and > the meaning of the bit positions has changed > - 'handle' is not relevant to SEV-SNP > > To address this, this patch adds a new 'sev-type' field that can be > used as a discriminator to select between SEV and SEV-SNP-specific > fields/formats without breaking compatibility for existing management > tools (so long as management tools that add support for launching > SEV-SNP guest update their handling of query-sev appropriately). > > The corresponding HMP command has also been fixed up similarly. > > Signed-off-by: Michael Roth <michael.roth@xxxxxxx> > --- > qapi/misc-target.json | 71 ++++++++++++++++++++++++++++++++++--------- > target/i386/sev.c | 50 ++++++++++++++++++++---------- > target/i386/sev.h | 3 ++ > 3 files changed, 94 insertions(+), 30 deletions(-) > > diff --git a/qapi/misc-target.json b/qapi/misc-target.json > index 4e0a6492a9..daceb85d95 100644 > --- a/qapi/misc-target.json > +++ b/qapi/misc-target.json > @@ -47,6 +47,49 @@ > 'send-update', 'receive-update' ], > 'if': 'TARGET_I386' } > > +## > +# @SevGuestType: > +# > +# An enumeration indicating the type of SEV guest being run. > +# > +# @sev: The guest is a legacy SEV or SEV-ES guest. Single space after ':', please. Recommend a blank line between argument descriptions. > +# @sev-snp: The guest is an SEV-SNP guest. > +# > +# Since: 6.2 The type is since 9.1, but its members become results of query-sev, where they are since 2.12. See also my reply to Daniel's question on PATCH 21. > +## > +{ 'enum': 'SevGuestType', > + 'data': [ 'sev', 'sev-snp' ], > + 'if': 'TARGET_I386' } > + > +## > +# @SevGuestInfo: > +# > +# Information specific to legacy SEV/SEV-ES guests. > +# > +# @policy: SEV policy value I know you're just moving existing documentation. Still: this is rather sparse. Where would I find what numbers to pass for @policy? > +# > +# @handle: SEV firmware handle > +# > +# Since: 2.12 > +## > +{ 'struct': 'SevGuestInfo', > + 'data': { 'policy': 'uint32', > + 'handle': 'uint32' }, > + 'if': 'TARGET_I386' } > + > +## > +# @SevSnpGuestInfo: > +# > +# Information specific to SEV-SNP guests. > +# > +# @snp-policy: SEV-SNP policy value Same question. > +# > +# Since: 6.2 9.1 > +## > +{ 'struct': 'SevSnpGuestInfo', > + 'data': { 'snp-policy': 'uint64' }, > + 'if': 'TARGET_I386' } > + > ## > # @SevInfo: > # > @@ -60,25 +103,25 @@ > # > # @build-id: SEV FW build id > # > -# @policy: SEV policy value > -# > # @state: SEV guest state > # > -# @handle: SEV firmware handle > +# @sev-type: Type of SEV guest being run > # > # Since: 2.12 > ## > -{ 'struct': 'SevInfo', > - 'data': { 'enabled': 'bool', > - 'api-major': 'uint8', > - 'api-minor' : 'uint8', > - 'build-id' : 'uint8', > - 'policy' : 'uint32', > - 'state' : 'SevState', > - 'handle' : 'uint32' > - }, > - 'if': 'TARGET_I386' > -} > +{ 'union': 'SevInfo', > + 'base': { 'enabled': 'bool', > + 'api-major': 'uint8', > + 'api-minor' : 'uint8', > + 'build-id' : 'uint8', > + 'state' : 'SevState', > + 'sev-type' : 'SevGuestType' }, > + 'discriminator': 'sev-type', > + 'data': { > + 'sev': 'SevGuestInfo', > + 'sev-snp': 'SevSnpGuestInfo' }, > + 'if': 'TARGET_I386' } > + > > ## > # @query-sev: [...]