Re: [PATCH v5 2/6] firmware: smccc: Detect hypervisor via RSI host call in CCA Realms

From
Kameron Carr <hidden>
Date
2026-10-31 00:35:58
Also in
linux-arch, linux-arm-kernel, lkml
Reply to
Catalin Marinas, 2026-10-29
On 10/29/2026 3:54 PM, Catalin Marinas wrote:
On Fri, Oct 02, 2026 at 02:57:21PM -0700, Kameron Carr wrote:
quoted
+#ifdef CONFIG_ARM64
+static struct rsi_host_call uuid_hc;
+static DEFINE_SPINLOCK(uuid_hc_lock);
+
+/*
+ * Helper function to get the hypervisor UUID via an RsiHostCall.
+ */
+static void arm_smccc_realm_get_hypervisor_uuid(struct arm_smccc_res *res)
+{
+	guard(spinlock_irqsave)(&uuid_hc_lock);
+
+	memset(&uuid_hc, 0, sizeof(uuid_hc));
+	uuid_hc.gprs[0] = ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID;
+
+	if (rsi_host_call(__pa_symbol(&uuid_hc)) != RSI_SUCCESS) {
+		res->a0 = SMCCC_RET_NOT_SUPPORTED;
+		return;
+	}
+
+	res->a0 = uuid_hc.gprs[0];
+	res->a1 = uuid_hc.gprs[1];
+	res->a2 = uuid_hc.gprs[2];
+	res->a3 = uuid_hc.gprs[3];
+}
+#endif
+
 bool arm_smccc_hypervisor_has_uuid(const uuid_t *hyp_uuid)
 {
 	struct arm_smccc_res res = {};
 	uuid_t uuid;
 
-	arm_smccc_1_1_invoke(ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID, &res);
+#ifdef CONFIG_ARM64
+	if (is_realm_world())
+		arm_smccc_realm_get_hypervisor_uuid(&res);
+	else
+#endif
+		arm_smccc_1_1_invoke(ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID,
+				     &res);
Is this meant to be generic? I'm not sure the trick to pass
ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID in gprs[0] and forward it to the
host is a documented ABI. I think it even confuses other realm guests
that don't expect this (e.g. kvm_init_hyp_services()).

I thought realms should stick to the RSI interface and not try to guess
the host hypervisor. But if you do need this, a better fit would be in
hyperv_detect_via_smccc() (if realms don't boot with ACPI).

I'll leave it to Sudeep or Suzuki to comment further.
I moved this code to a Hyper-V specific location as you suggested.

Let me know if you have any other concerns.

[v6] https://lore.kernel.org/all/20261031001412.4150488-1-kameroncarr@linux.microsoft.com/ (local)

-- 
Regards,
Kameron
Thread (17 messages) 17 messages, 6 authors, last reply 16d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help