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

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