When booting without ACPI, hyperv_detect_via_smccc() detects Hyper-V by querying the SMCCC vendor hypervisor UID. In an Arm CCA Realm the SMCCC call is handled by the RMM rather than by the hypervisor, so the query never reaches Hyper-V and detection fails.
When running in a Realm, forward ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID to the host with RSI_HOST_CALL instead, which is how Hyper-V hypercalls are issued from a Realm. This is done in the Hyper-V code rather than in the generic arm_smccc_hypervisor_has_uuid() because the other users expect different behavior. hyperv_init() is an early_initcall and runs before the secondary CPUs are brought up, so a single __initdata host call structure is used without locking. ACPI-based detection and non-Realm guests are unaffected. Signed-off-by: Kameron Carr <[email protected]> --- arch/arm64/hyperv/mshyperv.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/arch/arm64/hyperv/mshyperv.c b/arch/arm64/hyperv/mshyperv.c index 4fdc26a..82572c5 100644 --- a/arch/arm64/hyperv/mshyperv.c +++ b/arch/arm64/hyperv/mshyperv.c @@ -11,6 +11,7 @@ #include <linux/types.h> #include <linux/acpi.h> +#include <linux/arm-rsi-cmds.h> #include <linux/export.h> #include <linux/errno.h> #include <linux/version.h> @@ -60,6 +61,27 @@ static bool __init hyperv_detect_via_acpi(void) #endif +/* + * In a Realm, the SMCCC call is handled by the RMM rather than by + * Hyper-V, so the vendor hypervisor UID query must be forwarded to the + * host with RSI_HOST_CALL, in the same way as hypercalls. + */ +static bool __init hyperv_realm_has_uuid(const uuid_t *hyperv_uuid) +{ + static struct rsi_host_call hc __initdata; + uuid_t uuid; + + hc.gprs[0] = ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID; + + if (rsi_host_call(__pa_symbol(&hc)) != RSI_SUCCESS || + hc.gprs[0] == SMCCC_RET_NOT_SUPPORTED) + return false; + + uuid = smccc_res_to_uuid(hc.gprs[0], hc.gprs[1], hc.gprs[2], + hc.gprs[3]); + return uuid_equal(&uuid, hyperv_uuid); +} + static bool __init hyperv_detect_via_smccc(void) { uuid_t hyperv_uuid = UUID_INIT( @@ -67,6 +89,9 @@ static bool __init hyperv_detect_via_smccc(void) 0x75, 0x6c, 0xef, 0x8e, 0x24, 0x70, 0x59, 0x16); + if (is_realm_world()) + return hyperv_realm_has_uuid(&hyperv_uuid); + return arm_smccc_hypervisor_has_uuid(&hyperv_uuid); } -- 2.45.4
