all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH qemu-server v3] query-machine-capabilities: limit AuthenticAMD and GenuineIntel checks to x86-64
@ 2026-07-30  1:47 Kaiyang Wu
  2026-08-06 14:45 ` applied: " Fiona Ebner
  0 siblings, 1 reply; 2+ messages in thread
From: Kaiyang Wu @ 2026-07-30  1:47 UTC (permalink / raw)
  To: pve-devel; +Cc: Kaiyang Wu

Intel TDX and AMD SEV are both x86-64-only extensions [0] [1]. The current
method of checking results in compilation errors on "unknown" vendors,
where the current placeholder string length ("Unknown") mismatches the
lengths of both "AuthenticAMD" and "GenuineIntel":

    error: ‘strncmp’ of strings of length 7 and 12 and bound of 12
    evaluates to nonzero [-Werror=string-compare]

Limit the machine capability checks for Intel TDX and AMD SEV to x86-64 to
fix build.

[0]: https://docs.kernel.org/arch/x86/tdx.html
[1]: https://docs.kernel.org/virt/kvm/x86/amd-memory-encryption.html

Signed-off-by: Kaiyang Wu <wukaiyang@loongfans.cn>
---

v1: https://lore.proxmox.com/pve-devel/20260603055031.106241-1-wukaiyang@loongfans.cn/
v2: https://lore.proxmox.com/pve-devel/20260729111024.58285-2-wukaiyang@loongfans.cn/

Changes v1 -> v2:
- Use conditional compilation to limit Intel TDX and AMD SEV checks to x86-64
- Eliminate the vendor string length check

Changes v2 -> v3:
- Remove the extra 'else' block to fix compilation on aarch64

 .../query-machine-capabilities.c              | 31 +++++++++----------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/src/query-machine-capabilities/query-machine-capabilities.c b/src/query-machine-capabilities/query-machine-capabilities.c
index abb47acd..b47ed698 100644
--- a/src/query-machine-capabilities/query-machine-capabilities.c
+++ b/src/query-machine-capabilities/query-machine-capabilities.c
@@ -204,6 +204,7 @@ int main() {
         eprintf("Error writing to file '" OUTPUT_PATH "': %s\n", strerror(errno));
     }
 
+#ifdef __x86_64__
     if (strncmp(vendor, "AuthenticAMD", 12) == 0) {
         cpu_caps_amd_sev_t caps_sev;
         query_cpu_capabilities_sev(&caps_sev);
@@ -233,22 +234,20 @@ int main() {
             );
         }
     }
-#ifdef __aarch64__
-    else {
-        cpu_caps_arm_t caps_arm;
-        query_cpu_capabilities_arm(&caps_arm);
-
-        ret = fprintf(file,
-            " \"arm-caps\": {"
-            " \"vendor\": \"%s\","
-            " \"aes\": %s,"
-            " \"sha2\": %s"
-            " }",
-            vendor,
-            caps_arm.aes ? "true" : "false",
-            caps_arm.sha2 ? "true" : "false"
-        );
-    }
+#elif defined(__aarch64__)
+    cpu_caps_arm_t caps_arm;
+    query_cpu_capabilities_arm(&caps_arm);
+
+    ret = fprintf(file,
+        " \"arm-caps\": {"
+        " \"vendor\": \"%s\","
+        " \"aes\": %s,"
+        " \"sha2\": %s"
+        " }",
+        vendor,
+        caps_arm.aes ? "true" : "false",
+        caps_arm.sha2 ? "true" : "false"
+    );
 #endif
 
     if (ret < 0) {
-- 
2.55.0




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* applied: [PATCH qemu-server v3] query-machine-capabilities: limit AuthenticAMD and GenuineIntel checks to x86-64
  2026-07-30  1:47 [PATCH qemu-server v3] query-machine-capabilities: limit AuthenticAMD and GenuineIntel checks to x86-64 Kaiyang Wu
@ 2026-08-06 14:45 ` Fiona Ebner
  0 siblings, 0 replies; 2+ messages in thread
From: Fiona Ebner @ 2026-08-06 14:45 UTC (permalink / raw)
  To: pve-devel, Kaiyang Wu

On Thu, 30 Jul 2026 09:47:05 +0800, Kaiyang Wu wrote:
> Intel TDX and AMD SEV are both x86-64-only extensions [0] [1]. The current
> method of checking results in compilation errors on "unknown" vendors,
> where the current placeholder string length ("Unknown") mismatches the
> lengths of both "AuthenticAMD" and "GenuineIntel":
> 
>     error: ‘strncmp’ of strings of length 7 and 12 and bound of 12
>     evaluates to nonzero [-Werror=string-compare]
> 
> [...]

Applied, thanks! I put the check for ret < 0 inside the conditional
compilation to avoid having a stand-alone duplicate when compiled on
neither x86_64 nor aarch64.

[1/1] query-machine-capabilities: limit AuthenticAMD and GenuineIntel checks to x86-64
      commit: c3cf6795a4e48ca4dd02d922f9227070c13f2b59




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-06 14:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-30  1:47 [PATCH qemu-server v3] query-machine-capabilities: limit AuthenticAMD and GenuineIntel checks to x86-64 Kaiyang Wu
2026-08-06 14:45 ` applied: " Fiona Ebner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal