diff mbox series

[RESEND,25/32] qmp: Add query-sgx command

Message ID 20210430062455.8117-26-yang.zhong@intel.com (mailing list archive)
State New, archived
Headers show
Series Qemu SGX virtualization | expand

Commit Message

Yang Zhong April 30, 2021, 6:24 a.m. UTC
This QMP query command can be used by some userspaces to retrieve
the SGX information when SGX is enabled on Intel platform.

Signed-off-by: Yang Zhong <yang.zhong@intel.com>
---
 monitor/qmp-cmds.c         |  6 ++++++
 qapi/misc.json             | 42 ++++++++++++++++++++++++++++++++++++++
 tests/qtest/qmp-cmd-test.c |  1 +
 3 files changed, 49 insertions(+)

Comments

Eric Blake May 3, 2021, 5:58 p.m. UTC | #1
On 4/30/21 1:24 AM, Yang Zhong wrote:
> This QMP query command can be used by some userspaces to retrieve
> the SGX information when SGX is enabled on Intel platform.
> 
> Signed-off-by: Yang Zhong <yang.zhong@intel.com>
> ---
>  monitor/qmp-cmds.c         |  6 ++++++
>  qapi/misc.json             | 42 ++++++++++++++++++++++++++++++++++++++
>  tests/qtest/qmp-cmd-test.c |  1 +
>  3 files changed, 49 insertions(+)
> 

> +++ b/qapi/misc.json
> @@ -519,3 +519,45 @@
>   'data': { '*option': 'str' },
>   'returns': ['CommandLineOptionInfo'],
>   'allow-preconfig': true }
> +
> +##
> +# @SGXInfo:
> +#
> +# Information about intel Safe Guard eXtension (SGX) support
> +#
> +# @sgx: true if SGX is support

is supported

> +#
> +# @sgx1: true if SGX1 is support
> +#
> +# @sgx2: true if SGX2 is support
> +#
> +# @flc: true if FLC is support

again, for each of these too.

> +#
> +# @section-size: The EPC section size for guest
> +#
> +# Since: 5.1

6.1 (5.1 was last year).

> +##
> +{ 'struct': 'SGXInfo',
> +  'data': { 'sgx': 'bool',
> +            'sgx1': 'bool',
> +            'sgx2': 'bool',
> +            'flc': 'bool',
> +            'section-size': 'uint64'}}
> +
> +##
> +# @query-sgx:
> +#
> +# Returns information about SGX
> +#
> +# Returns: @SGXInfo
> +#
> +# Since: 5.1

6.1

> +#
> +# Example:
> +#
> +# -> { "execute": "query-sgx" }
> +# <- { "return": { "sgx": true, "sgx1" : true, "sgx2" : true,
> +#                  "flc": true, "section-size" : 0 } }
> +#
> +##
> +{ 'command': 'query-sgx', 'returns': 'SGXInfo' }
> diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c
> index c98b78d033..b75f3364f3 100644
> --- a/tests/qtest/qmp-cmd-test.c
> +++ b/tests/qtest/qmp-cmd-test.c
> @@ -100,6 +100,7 @@ static bool query_is_ignored(const char *cmd)
>          /* Success depends on Host or Hypervisor SEV support */
>          "query-sev",
>          "query-sev-capabilities",
> +        "query-sgx",
>          NULL
>      };
>      int i;
>
Yang Zhong May 6, 2021, 9:08 a.m. UTC | #2
On Mon, May 03, 2021 at 12:58:34PM -0500, Eric Blake wrote:
> On 4/30/21 1:24 AM, Yang Zhong wrote:
> > This QMP query command can be used by some userspaces to retrieve
> > the SGX information when SGX is enabled on Intel platform.
> > 
> > Signed-off-by: Yang Zhong <yang.zhong@intel.com>
> > ---
> >  monitor/qmp-cmds.c         |  6 ++++++
> >  qapi/misc.json             | 42 ++++++++++++++++++++++++++++++++++++++
> >  tests/qtest/qmp-cmd-test.c |  1 +
> >  3 files changed, 49 insertions(+)
> > 
> 
> > +++ b/qapi/misc.json
> > @@ -519,3 +519,45 @@
> >   'data': { '*option': 'str' },
> >   'returns': ['CommandLineOptionInfo'],
> >   'allow-preconfig': true }
> > +
> > +##
> > +# @SGXInfo:
> > +#
> > +# Information about intel Safe Guard eXtension (SGX) support
> > +#
> > +# @sgx: true if SGX is support
> 
> is supported
> 
  Eric, thanks for your comments! I will change this mistake. thanks!

  Yang

> > +#
> > +# @sgx1: true if SGX1 is support
> > +#
> > +# @sgx2: true if SGX2 is support
> > +#
> > +# @flc: true if FLC is support
> 
> again, for each of these too.

  Ditto, thanks!

  Yang

> 
> > +#
> > +# @section-size: The EPC section size for guest
> > +#
> > +# Since: 5.1
> 
> 6.1 (5.1 was last year).
> 

  Yes, i will change this version, thanks!

  Yang  

> > +##
> > +{ 'struct': 'SGXInfo',
> > +  'data': { 'sgx': 'bool',
> > +            'sgx1': 'bool',
> > +            'sgx2': 'bool',
> > +            'flc': 'bool',
> > +            'section-size': 'uint64'}}
> > +
> > +##
> > +# @query-sgx:
> > +#
> > +# Returns information about SGX
> > +#
> > +# Returns: @SGXInfo
> > +#
> > +# Since: 5.1
> 
> 6.1

  Ditto, thanks!

  Yang

> 
> > +#
> > +# Example:
> > +#
> > +# -> { "execute": "query-sgx" }
> > +# <- { "return": { "sgx": true, "sgx1" : true, "sgx2" : true,
> > +#                  "flc": true, "section-size" : 0 } }
> > +#
> > +##
> > +{ 'command': 'query-sgx', 'returns': 'SGXInfo' }
> > diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c
> > index c98b78d033..b75f3364f3 100644
> > --- a/tests/qtest/qmp-cmd-test.c
> > +++ b/tests/qtest/qmp-cmd-test.c
> > @@ -100,6 +100,7 @@ static bool query_is_ignored(const char *cmd)
> >          /* Success depends on Host or Hypervisor SEV support */
> >          "query-sev",
> >          "query-sev-capabilities",
> > +        "query-sgx",
> >          NULL
> >      };
> >      int i;
> > 
> 
> -- 
> Eric Blake, Principal Software Engineer
> Red Hat, Inc.           +1-919-301-3226
> Virtualization:  qemu.org | libvirt.org
diff mbox series

Patch

diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
index f7d64a6457..d63d59149f 100644
--- a/monitor/qmp-cmds.c
+++ b/monitor/qmp-cmds.c
@@ -351,3 +351,9 @@  void qmp_display_reload(DisplayReloadOptions *arg, Error **errp)
         abort();
     }
 }
+
+SGXInfo *qmp_query_sgx(Error **errp)
+{
+    error_setg(errp, QERR_FEATURE_DISABLED, "query-sgx");
+    return NULL;
+}
diff --git a/qapi/misc.json b/qapi/misc.json
index 156f98203e..112a2f71cf 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -519,3 +519,45 @@ 
  'data': { '*option': 'str' },
  'returns': ['CommandLineOptionInfo'],
  'allow-preconfig': true }
+
+##
+# @SGXInfo:
+#
+# Information about intel Safe Guard eXtension (SGX) support
+#
+# @sgx: true if SGX is support
+#
+# @sgx1: true if SGX1 is support
+#
+# @sgx2: true if SGX2 is support
+#
+# @flc: true if FLC is support
+#
+# @section-size: The EPC section size for guest
+#
+# Since: 5.1
+##
+{ 'struct': 'SGXInfo',
+  'data': { 'sgx': 'bool',
+            'sgx1': 'bool',
+            'sgx2': 'bool',
+            'flc': 'bool',
+            'section-size': 'uint64'}}
+
+##
+# @query-sgx:
+#
+# Returns information about SGX
+#
+# Returns: @SGXInfo
+#
+# Since: 5.1
+#
+# Example:
+#
+# -> { "execute": "query-sgx" }
+# <- { "return": { "sgx": true, "sgx1" : true, "sgx2" : true,
+#                  "flc": true, "section-size" : 0 } }
+#
+##
+{ 'command': 'query-sgx', 'returns': 'SGXInfo' }
diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c
index c98b78d033..b75f3364f3 100644
--- a/tests/qtest/qmp-cmd-test.c
+++ b/tests/qtest/qmp-cmd-test.c
@@ -100,6 +100,7 @@  static bool query_is_ignored(const char *cmd)
         /* Success depends on Host or Hypervisor SEV support */
         "query-sev",
         "query-sev-capabilities",
+        "query-sgx",
         NULL
     };
     int i;