Blame SOURCES/kvm-qapi-Cleanup-SGX-related-comments-and-restore-sectio.patch

2bc292
From a6a327ae392c02b8e8c75b5d702d929ff8fe408d Mon Sep 17 00:00:00 2001
2bc292
From: Yang Zhong <yang.zhong@intel.com>
2bc292
Date: Thu, 20 Jan 2022 17:31:04 -0500
2bc292
Subject: [PATCH 05/12] qapi: Cleanup SGX related comments and restore
2bc292
 @section-size
2bc292
MIME-Version: 1.0
2bc292
Content-Type: text/plain; charset=UTF-8
2bc292
Content-Transfer-Encoding: 8bit
2bc292
2bc292
RH-Author: Paul Lai <plai@redhat.com>
2bc292
RH-MergeRequest: 65: Enable SGX and add SGX Numa support
2bc292
RH-Commit: [5/5] 0d3b9f37cd3cce202050ba3bd51eef4410ef3d38
2bc292
RH-Bugzilla: 2033708
2bc292
RH-Acked-by: Paolo Bonzini <None>
2bc292
RH-Acked-by: Bandan Das <None>
2bc292
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
2bc292
2bc292
The SGX NUMA patches were merged into Qemu 7.0 release, we need
2bc292
clarify detailed version history information and also change
2bc292
some related comments, which make SGX related comments clearer.
2bc292
2bc292
The QMP command schema promises backwards compatibility as standard.
2bc292
We temporarily restore "@section-size", which can avoid incompatible
2bc292
API breakage. The "@section-size" will be deprecated in 7.2 version.
2bc292
2bc292
Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
2bc292
Signed-off-by: Yang Zhong <yang.zhong@intel.com>
2bc292
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2bc292
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
2bc292
Message-Id: <20220120223104.437161-1-yang.zhong@intel.com>
2bc292
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2bc292
Signed-off-by: Paul Lai <plai@redhat.com>
2bc292
---
2bc292
 docs/about/deprecated.rst | 13 +++++++++++++
2bc292
 hw/i386/sgx.c             | 11 +++++++++--
2bc292
 qapi/machine.json         |  4 ++--
2bc292
 qapi/misc-target.json     | 22 +++++++++++++++++-----
2bc292
 4 files changed, 41 insertions(+), 9 deletions(-)
2bc292
2bc292
diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
2bc292
index ff7488cb63..33925edf45 100644
2bc292
--- a/docs/about/deprecated.rst
2bc292
+++ b/docs/about/deprecated.rst
2bc292
@@ -270,6 +270,19 @@ accepted incorrect commands will return an error. Users should make sure that
2bc292
 all arguments passed to ``device_add`` are consistent with the documented
2bc292
 property types.
2bc292
 
2bc292
+``query-sgx`` return value member ``section-size`` (since 7.0)
2bc292
+''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
2bc292
+
2bc292
+Member ``section-size`` in return value elements with meta-type ``uint64`` is
2bc292
+deprecated.  Use ``sections`` instead.
2bc292
+
2bc292
+
2bc292
+``query-sgx-capabilities`` return value member ``section-size`` (since 7.0)
2bc292
+'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
2bc292
+
2bc292
+Member ``section-size`` in return value elements with meta-type ``uint64`` is
2bc292
+deprecated.  Use ``sections`` instead.
2bc292
+
2bc292
 System accelerators
2bc292
 -------------------
2bc292
 
2bc292
diff --git a/hw/i386/sgx.c b/hw/i386/sgx.c
2bc292
index 5de5dd0893..a2b318dd93 100644
2bc292
--- a/hw/i386/sgx.c
2bc292
+++ b/hw/i386/sgx.c
2bc292
@@ -83,7 +83,7 @@ static uint64_t sgx_calc_section_metric(uint64_t low, uint64_t high)
2bc292
            ((high & MAKE_64BIT_MASK(0, 20)) << 32);
2bc292
 }
2bc292
 
2bc292
-static SGXEPCSectionList *sgx_calc_host_epc_sections(void)
2bc292
+static SGXEPCSectionList *sgx_calc_host_epc_sections(uint64_t *size)
2bc292
 {
2bc292
     SGXEPCSectionList *head = NULL, **tail = &head;
2bc292
     SGXEPCSection *section;
2bc292
@@ -106,6 +106,7 @@ static SGXEPCSectionList *sgx_calc_host_epc_sections(void)
2bc292
         section = g_new0(SGXEPCSection, 1);
2bc292
         section->node = j++;
2bc292
         section->size = sgx_calc_section_metric(ecx, edx);
2bc292
+        *size += section->size;
2bc292
         QAPI_LIST_APPEND(tail, section);
2bc292
     }
2bc292
 
2bc292
@@ -156,6 +157,7 @@ SGXInfo *qmp_query_sgx_capabilities(Error **errp)
2bc292
 {
2bc292
     SGXInfo *info = NULL;
2bc292
     uint32_t eax, ebx, ecx, edx;
2bc292
+    uint64_t size = 0;
2bc292
 
2bc292
     int fd = qemu_open_old("/dev/sgx_vepc", O_RDWR);
2bc292
     if (fd < 0) {
2bc292
@@ -173,7 +175,8 @@ SGXInfo *qmp_query_sgx_capabilities(Error **errp)
2bc292
     info->sgx1 = eax & (1U << 0) ? true : false;
2bc292
     info->sgx2 = eax & (1U << 1) ? true : false;
2bc292
 
2bc292
-    info->sections = sgx_calc_host_epc_sections();
2bc292
+    info->sections = sgx_calc_host_epc_sections(&size);
2bc292
+    info->section_size = size;
2bc292
 
2bc292
     close(fd);
2bc292
 
2bc292
@@ -220,12 +223,14 @@ SGXInfo *qmp_query_sgx(Error **errp)
2bc292
         return NULL;
2bc292
     }
2bc292
 
2bc292
+    SGXEPCState *sgx_epc = &pcms->sgx_epc;
2bc292
     info = g_new0(SGXInfo, 1);
2bc292
 
2bc292
     info->sgx = true;
2bc292
     info->sgx1 = true;
2bc292
     info->sgx2 = true;
2bc292
     info->flc = true;
2bc292
+    info->section_size = sgx_epc->size;
2bc292
     info->sections = sgx_get_epc_sections_list();
2bc292
 
2bc292
     return info;
2bc292
@@ -249,6 +254,8 @@ void hmp_info_sgx(Monitor *mon, const QDict *qdict)
2bc292
                    info->sgx2 ? "enabled" : "disabled");
2bc292
     monitor_printf(mon, "FLC support: %s\n",
2bc292
                    info->flc ? "enabled" : "disabled");
2bc292
+    monitor_printf(mon, "size: %" PRIu64 "\n",
2bc292
+                   info->section_size);
2bc292
 
2bc292
     section_list = info->sections;
2bc292
     for (section = section_list; section; section = section->next) {
2bc292
diff --git a/qapi/machine.json b/qapi/machine.json
2bc292
index 16e771affc..a9f33d0f27 100644
2bc292
--- a/qapi/machine.json
2bc292
+++ b/qapi/machine.json
2bc292
@@ -1207,7 +1207,7 @@
2bc292
 #
2bc292
 # @memdev: memory backend linked with device
2bc292
 #
2bc292
-# @node: the numa node
2bc292
+# @node: the numa node (Since: 7.0)
2bc292
 #
2bc292
 # Since: 6.2
2bc292
 ##
2bc292
@@ -1288,7 +1288,7 @@
2bc292
 #
2bc292
 # @memdev: memory backend linked with device
2bc292
 #
2bc292
-# @node: the numa node
2bc292
+# @node: the numa node (Since: 7.0)
2bc292
 #
2bc292
 # Since: 6.2
2bc292
 ##
2bc292
diff --git a/qapi/misc-target.json b/qapi/misc-target.json
2bc292
index 1022aa0184..4bc45d2474 100644
2bc292
--- a/qapi/misc-target.json
2bc292
+++ b/qapi/misc-target.json
2bc292
@@ -344,9 +344,9 @@
2bc292
 #
2bc292
 # @node: the numa node
2bc292
 #
2bc292
-# @size: the size of epc section
2bc292
+# @size: the size of EPC section
2bc292
 #
2bc292
-# Since: 6.2
2bc292
+# Since: 7.0
2bc292
 ##
2bc292
 { 'struct': 'SGXEPCSection',
2bc292
   'data': { 'node': 'int',
2bc292
@@ -365,7 +365,13 @@
2bc292
 #
2bc292
 # @flc: true if FLC is supported
2bc292
 #
2bc292
-# @sections: The EPC sections info for guest
2bc292
+# @section-size: The EPC section size for guest
2bc292
+#                Redundant with @sections.  Just for backward compatibility.
2bc292
+#
2bc292
+# @sections: The EPC sections info for guest (Since: 7.0)
2bc292
+#
2bc292
+# Features:
2bc292
+# @deprecated: Member @section-size is deprecated.  Use @sections instead.
2bc292
 #
2bc292
 # Since: 6.2
2bc292
 ##
2bc292
@@ -374,6 +380,8 @@
2bc292
             'sgx1': 'bool',
2bc292
             'sgx2': 'bool',
2bc292
             'flc': 'bool',
2bc292
+            'section-size': { 'type': 'uint64',
2bc292
+                    'features': [ 'deprecated' ] },
2bc292
             'sections': ['SGXEPCSection']},
2bc292
    'if': 'TARGET_I386' }
2bc292
 
2bc292
@@ -390,7 +398,9 @@
2bc292
 #
2bc292
 # -> { "execute": "query-sgx" }
2bc292
 # <- { "return": { "sgx": true, "sgx1" : true, "sgx2" : true,
2bc292
-#                  "flc": true, "section-size" : 0 } }
2bc292
+#                  "flc": true,  "section-size" : 96468992,
2bc292
+#                  "sections": [{"node": 0, "size": 67108864},
2bc292
+#                  {"node": 1, "size": 29360128}]} }
2bc292
 #
2bc292
 ##
2bc292
 { 'command': 'query-sgx', 'returns': 'SGXInfo', 'if': 'TARGET_I386' }
2bc292
@@ -408,7 +418,9 @@
2bc292
 #
2bc292
 # -> { "execute": "query-sgx-capabilities" }
2bc292
 # <- { "return": { "sgx": true, "sgx1" : true, "sgx2" : true,
2bc292
-#                  "flc": true, "section-size" : 0 } }
2bc292
+#                  "flc": true, "section-size" : 96468992,
2bc292
+#                  "section" : [{"node": 0, "size": 67108864},
2bc292
+#                  {"node": 1, "size": 29360128}]} }
2bc292
 #
2bc292
 ##
2bc292
 { 'command': 'query-sgx-capabilities', 'returns': 'SGXInfo', 'if': 'TARGET_I386' }
2bc292
-- 
2bc292
2.27.0
2bc292