From: Michal Privoznik <[email protected]>

Detecting SGX support is done in two ways and both have to
succeed in order for caps to have the capability:

  1) the sgx-epc device needs to be present,
  2) the query-sgx-capabilities command needs to return data
     instead of an error.

So far, the only caps file that meets both requirements is
caps_7.0.0_x86_64. Soon the minimal version is going to be bumped
to QEMU-7.2. But caps_11.0.0_x86_64 has the device and the only
thing missing is the proper reply to the monitor command.
Therefore, copy data over.

Signed-off-by: Michal Privoznik <[email protected]>
---
 .../domaincapsdata/qemu_11.0.0-q35.x86_64.xml | 11 ++++++++-
 .../domaincapsdata/qemu_11.0.0-tcg.x86_64.xml | 11 ++++++++-
 tests/domaincapsdata/qemu_11.0.0.x86_64.xml   | 11 ++++++++-
 .../caps_11.0.0_x86_64.replies                | 23 +++++++++++++++----
 .../caps_11.0.0_x86_64.xml                    | 11 +++++++++
 5 files changed, 59 insertions(+), 8 deletions(-)

diff --git a/tests/domaincapsdata/qemu_11.0.0-q35.x86_64.xml 
b/tests/domaincapsdata/qemu_11.0.0-q35.x86_64.xml
index 4b951a5ed4..1d834a221e 100644
--- a/tests/domaincapsdata/qemu_11.0.0-q35.x86_64.xml
+++ b/tests/domaincapsdata/qemu_11.0.0-q35.x86_64.xml
@@ -1321,7 +1321,16 @@
     <ps2 supported='yes'/>
     <tdx supported='yes'/>
     <sev supported='no'/>
-    <sgx supported='no'/>
+    <sgx supported='yes'>
+      <flc>no</flc>
+      <sgx1>yes</sgx1>
+      <sgx2>no</sgx2>
+      <section_size unit='KiB'>524288</section_size>
+      <sections>
+        <section node='0' size='262144' unit='KiB'/>
+        <section node='1' size='262144' unit='KiB'/>
+      </sections>
+    </sgx>
     <hyperv supported='yes'>
       <enum name='features'>
         <value>relaxed</value>
diff --git a/tests/domaincapsdata/qemu_11.0.0-tcg.x86_64.xml 
b/tests/domaincapsdata/qemu_11.0.0-tcg.x86_64.xml
index aef68494d3..3ba1d74336 100644
--- a/tests/domaincapsdata/qemu_11.0.0-tcg.x86_64.xml
+++ b/tests/domaincapsdata/qemu_11.0.0-tcg.x86_64.xml
@@ -2339,7 +2339,16 @@
     <ps2 supported='yes'/>
     <tdx supported='no'/>
     <sev supported='no'/>
-    <sgx supported='no'/>
+    <sgx supported='yes'>
+      <flc>no</flc>
+      <sgx1>yes</sgx1>
+      <sgx2>no</sgx2>
+      <section_size unit='KiB'>524288</section_size>
+      <sections>
+        <section node='0' size='262144' unit='KiB'/>
+        <section node='1' size='262144' unit='KiB'/>
+      </sections>
+    </sgx>
     <hyperv supported='yes'>
       <enum name='features'>
         <value>relaxed</value>
diff --git a/tests/domaincapsdata/qemu_11.0.0.x86_64.xml 
b/tests/domaincapsdata/qemu_11.0.0.x86_64.xml
index 4648a3a071..03b2d78fb5 100644
--- a/tests/domaincapsdata/qemu_11.0.0.x86_64.xml
+++ b/tests/domaincapsdata/qemu_11.0.0.x86_64.xml
@@ -1319,7 +1319,16 @@
     <ps2 supported='yes'/>
     <tdx supported='yes'/>
     <sev supported='no'/>
-    <sgx supported='no'/>
+    <sgx supported='yes'>
+      <flc>no</flc>
+      <sgx1>yes</sgx1>
+      <sgx2>no</sgx2>
+      <section_size unit='KiB'>524288</section_size>
+      <sections>
+        <section node='0' size='262144' unit='KiB'/>
+        <section node='1' size='262144' unit='KiB'/>
+      </sections>
+    </sgx>
     <hyperv supported='yes'>
       <enum name='features'>
         <value>relaxed</value>
diff --git a/tests/qemucapabilitiesdata/caps_11.0.0_x86_64.replies 
b/tests/qemucapabilitiesdata/caps_11.0.0_x86_64.replies
index e3ca9b4cf8..1b6f2583b6 100644
--- a/tests/qemucapabilitiesdata/caps_11.0.0_x86_64.replies
+++ b/tests/qemucapabilitiesdata/caps_11.0.0_x86_64.replies
@@ -40498,11 +40498,24 @@
 }
 
 {
-  "id": "libvirt-48",
-  "error": {
-    "class": "GenericError",
-    "desc": "Could not open '/dev/sgx_vepc': No such file or directory"
-  }
+  "return": {
+    "sgx": true,
+    "flc": false,
+    "sgx1": true,
+    "sgx2": false,
+    "section-size": 536870912,
+    "sections": [
+      {
+        "node": 0,
+        "size": 268435456
+      },
+      {
+        "node": 1,
+        "size": 268435456
+      }
+    ]
+  },
+  "id": "libvirt-48"
 }
 
 {
diff --git a/tests/qemucapabilitiesdata/caps_11.0.0_x86_64.xml 
b/tests/qemucapabilitiesdata/caps_11.0.0_x86_64.xml
index 8724ce5b56..bac7951f73 100644
--- a/tests/qemucapabilitiesdata/caps_11.0.0_x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_11.0.0_x86_64.xml
@@ -173,6 +173,7 @@
   <flag name='migration.blocked-reasons'/>
   <flag name='query-stats'/>
   <flag name='query-stats-schemas'/>
+  <flag name='sgx-epc'/>
   <flag name='thread-context'/>
   <flag name='screenshot-format-png'/>
   <flag name='machine-hpet'/>
@@ -4884,6 +4885,16 @@
   <machine type='tcg' name='pc-i440fx-9.2' hotplugCpus='yes' maxCpus='255' 
defaultCPU='qemu64-x86_64-cpu' defaultRAMid='pc.ram' acpi='yes'/>
   <machine type='tcg' name='pc-q35-10.1' hotplugCpus='yes' maxCpus='4096' 
defaultCPU='qemu64-x86_64-cpu' defaultRAMid='pc.ram' acpi='yes'/>
   <machine type='tcg' name='pc-i440fx-7.2' hotplugCpus='yes' maxCpus='255' 
defaultCPU='qemu64-x86_64-cpu' defaultRAMid='pc.ram' deprecated='yes' 
acpi='yes'/>
+  <sgx supported='yes'>
+    <flc>no</flc>
+    <sgx1>yes</sgx1>
+    <sgx2>no</sgx2>
+    <section_size unit='KiB'>524288</section_size>
+    <sections>
+      <section node='0' size='262144' unit='KiB'/>
+      <section node='1' size='262144' unit='KiB'/>
+    </sections>
+  </sgx>
   <hypervCapabilities supported='yes'>
     <cap name='relaxed'/>
     <cap name='vapic'/>
-- 
2.53.0

Reply via email to