* [pve-devel] [PATCH qemy-server v2] query-machine-capabilities: make it work on non-x86 arch
@ 2024-11-23 5:38 Jing Luo via pve-devel
0 siblings, 0 replies; only message in thread
From: Jing Luo via pve-devel @ 2024-11-23 5:38 UTC (permalink / raw)
To: pve-devel; +Cc: Jing Luo
[-- Attachment #1: Type: message/rfc822, Size: 6376 bytes --]
From: Jing Luo <jing@jing.rocks>
To: pve-devel@lists.proxmox.com
Cc: Jing Luo <jing@jing.rocks>
Subject: [PATCH qemy-server v2] query-machine-capabilities: make it work on non-x86 arch
Date: Sat, 23 Nov 2024 14:38:15 +0900
Message-ID: <20241123054046.1634788-1-jing@jing.rocks>
This little program has inline assembly code that won't work on non-x86
arch:
query-machine-capabilities.c: In function 'query_cpu_capabilities':
query-machine-capabilities.c:29:5: error: impossible constraint in 'asm'
29 | asm volatile("cpuid"
| ^~~
So let's define a marco if we find ourselves not on x86, and skip the actual
querying, just write false to things since non-x86 cpu definitely won't
support AMD SEV.
Signed-off-by: Jing Luo <jing@jing.rocks>
---
Changes to v2: use Lukas' suggestion to use gcc's built in macro
---
query-machine-capabilities/query-machine-capabilities.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/query-machine-capabilities/query-machine-capabilities.c b/query-machine-capabilities/query-machine-capabilities.c
index 0c522afc..ed684603 100644
--- a/query-machine-capabilities/query-machine-capabilities.c
+++ b/query-machine-capabilities/query-machine-capabilities.c
@@ -21,6 +21,7 @@ typedef struct {
} cpu_caps_t;
void query_cpu_capabilities(cpu_caps_t *res) {
+#ifdef __x86_64__
uint32_t eax, ebx, ecx, edx;
// query Encrypted Memory Capabilities, see:
@@ -37,6 +38,13 @@ void query_cpu_capabilities(cpu_caps_t *res) {
res->cbitpos = ebx & 0x3f;
res->reduced_phys_bits = (ebx >> 6) & 0x3f;
+#else
+ res->sev_support = false;
+ res->sev_es_support = false;
+ res->sev_snp_support = false;
+ res->cbitpos = 0;
+ res->reduced_phys_bits = 0;
+#endif
}
int prepare_output_directory() {
--
2.47.0
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-11-23 5:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-23 5:38 [pve-devel] [PATCH qemy-server v2] query-machine-capabilities: make it work on non-x86 arch Jing Luo via pve-devel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox