On Wed, Feb 12, 2025, at 02:43, Roman Kisel wrote:
> +static bool hyperv_detect_via_smccc(void)
> +{
> +     struct arm_smccc_res res = {};
> +
> +     if (arm_smccc_1_1_get_conduit() != SMCCC_CONDUIT_HVC)
> +             return false;
> +     arm_smccc_1_1_hvc(ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID, &res);
> +     if (res.a0 == SMCCC_RET_NOT_SUPPORTED)
> +             return false;
> +
> +     return res.a0 == ARM_SMCCC_VENDOR_HYP_UID_HYPERV_REG_0 &&
> +             res.a1 == ARM_SMCCC_VENDOR_HYP_UID_HYPERV_REG_1 &&
> +             res.a2 == ARM_SMCCC_VENDOR_HYP_UID_HYPERV_REG_2 &&
> +             res.a3 == ARM_SMCCC_VENDOR_HYP_UID_HYPERV_REG_3;
> +}

I had to double-check that this function is safe to call on
other hypervisors, at least when they follow the smccc spec.

Seeing that we have the same helper function checking for
ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_* and there was another
patch set adding a copy for gunyah, I wonder if we can
put this into a drivers/firmware/smccc/smccc.c directly
the same way we handle soc_id, and make it return a uuid_t,
or perhaps take a constant uuid_t to compare against.

      Arnd

Reply via email to