thebeanogamer / rpms / qemu-kvm

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