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

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