From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 41ECDCDE00D for ; Thu, 25 Jun 2026 17:35:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pCGLDie0xV9RJpzuDsm4ooq0RYqsnGfSauPh4xAqSiU=; b=NwPtsRIJF7prk7S/U2GEAw53tc C8TkSi0uslET87+cR88Vb+ySKCKhltipKkjto0nlM0yQ5Q8r175dOKbhJJDN5unQVJwx9TTHjTVhJ jVws0syARZaXe4qTAV0TK1ItLrNPYVuzPp+w+UuhjsKGwu1ad0py7SpZo2DixXegKCRdOi8aV29hA hnUhKRVdyr86D4Eag9A9qXGFU16DUuNaDErr1SFaY0p9S0lZpeCb4FXSXCQmjkU4CcxHGUvSvIWHp KYEsUqj2/suckyu1GZjW7qh3s/QCGhLBTDCDBeEPv4jhKwX0FfwBRBmJg0hyIghAPQqQklOZ/b2bp IM/k8EAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wcnyz-00000009YWE-00AL; Thu, 25 Jun 2026 17:35:21 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wcnys-00000009YQb-31c3 for linux-arm-kernel@bombadil.infradead.org; Thu, 25 Jun 2026 17:35:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=pCGLDie0xV9RJpzuDsm4ooq0RYqsnGfSauPh4xAqSiU=; b=cR5KWbueyCw+HDih08bLi/PPcy k/5Gibd/b/593lKPx2jv1Jdv9jl1xU8KvpdhqFsWpqqDKgVPjx12wD3B1ulochroE1sDlGGsBqatV APkrcq633WmFfCLMAz6XDWNpzrCy0ivOI4IcI/3yLChk0JDl9qCms1kwfDtjm9liHy6W9eafg32qx S+cpbzoLEinFmLmmZqWTvWTRICds5mj268opRk692aEnCbDVMakiow6JLqwqxaW1LeudJib9Z6TZi iZXvN9s7D/+l/J6PaMVhoS3htOhprYU8Fjsf67FiFKVetdcJmfFwinQuwwTOP/21NI2gEpwl0xk39 eUL0IYFg==; Received: from linux.microsoft.com ([13.77.154.182]) by desiato.infradead.org with esmtp (Exim 4.99.2 #2 (Red Hat Linux)) id 1wcnyo-00000003v6C-1DVa for linux-arm-kernel@lists.infradead.org; Thu, 25 Jun 2026 17:35:13 +0000 Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 9C38320B716A; Thu, 25 Jun 2026 10:35:01 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 9C38320B716A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1782408901; bh=pCGLDie0xV9RJpzuDsm4ooq0RYqsnGfSauPh4xAqSiU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BICiPGL9/pP6WwXAXBdcA7yNVbztfOWWxG0mxTLYY/WH6WLeJxZUdTqL20mGEs8eP oYNR8q1OtbM15vKJ1CddYV5UIbjZr32P7hlajorvYpHQLCBDTESkSEzdTw4fwqYvvm QnryAzB1nJW/H57R9kgjuQyolQawY3F/akuCQCKc= From: Kameron Carr To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, longli@microsoft.com Cc: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, lpieralisi@kernel.org, sudeep.holla@kernel.org, arnd@arndb.de, thuth@redhat.com, linux-hyperv@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, mhklinux@outlook.com Subject: [PATCH v2 2/6] firmware: smccc: Detect hypervisor via RSI host call in CCA Realms Date: Thu, 25 Jun 2026 10:34:56 -0700 Message-ID: <20260625173500.1995481-3-kameroncarr@linux.microsoft.com> X-Mailer: git-send-email 2.43.7 In-Reply-To: <20260625173500.1995481-1-kameroncarr@linux.microsoft.com> References: <20260625173500.1995481-1-kameroncarr@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260625_183510_608106_50B62D60 X-CRM114-Status: GOOD ( 12.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Modify arm_smccc_hypervisor_has_uuid() to check is_realm_world() and use rsi_host_call() to query the hypervisor vendor UUID when inside a Realm. The realm path is factored into a helper, arm_smccc_realm_get_hypervisor_uuid(), that owns a file-static rsi_host_call buffer (uuid_hc) serialized by a spinlock. The RSI-specific includes, file-static state and helper are guarded with CONFIG_ARM64 because does not exist on 32-bit ARM. For non-Realm environments, the existing arm_smccc_1_1_invoke() path is unchanged. Signed-off-by: Kameron Carr --- drivers/firmware/smccc/smccc.c | 41 +++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/smccc/smccc.c b/drivers/firmware/smccc/smccc.c index bdee057db2fd3..a876b7aa2dc99 100644 --- a/drivers/firmware/smccc/smccc.c +++ b/drivers/firmware/smccc/smccc.c @@ -12,6 +12,12 @@ #include #include +#ifdef CONFIG_ARM64 +#include +#include +#include +#endif + static u32 smccc_version = ARM_SMCCC_VERSION_1_0; static enum arm_smccc_conduit smccc_conduit = SMCCC_CONDUIT_NONE; @@ -67,12 +73,45 @@ s32 arm_smccc_get_soc_id_revision(void) } EXPORT_SYMBOL_GPL(arm_smccc_get_soc_id_revision); +#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); + if (res.a0 == SMCCC_RET_NOT_SUPPORTED) return false; -- 2.45.4