From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 572E53EE1D4; Thu, 25 Jun 2026 17:35:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782408909; cv=none; b=R9urZHuzvjh0KmjkC3GlTox18htwdq7kx21+o4EXYqS8Pbw3OcxCCv7fgnYWgEQtWGekWRmqtK5oBu75pVosSwDWRGDg5KhEyv+4VSs7jsI/tOLgqwuAoPvQ9x3Ws2hPKtNl6ZsEpUEHlIJBm21mmd7IA7VXd1SGPzyki8mfJw8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782408909; c=relaxed/simple; bh=Mzsol2h+WkBDLgcMWdvVifM1T+sDbw2PQ7eKlxQch9g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DxXAcDRaOb9c1WKJKotvWcClrKfAtrSPMrj/OCe8xlTh/fdSVpxEGxwPf/ZOr+SELncEJKRzhJrKCAwA0D6E397/OGIxARfjqP7CPDJrhEkCtTC9tHOVD1Bl5bN5QoS9hlBw+ipe6R+LmozhJcwWIpS/+TVV7r/ME4McEysteyQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=RxwPVkXf; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="RxwPVkXf" Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 07CF620B716B; Thu, 25 Jun 2026 10:35:02 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 07CF620B716B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1782408902; bh=Q4plg/CCnAHmMhU7oNaxdOrf7OwTGoSq+OW/a8bsz8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RxwPVkXf0/SDnnz5NPRshY33e6dlHY9NkBHoDkJwEez7QIZ6ZxOw63ocj1nyj/bhH aPTVfGqXryVUrhoHVuTe8vZfMKGW0HYLF7XtIoWAG8ke4EnPo1aX2OV0EhOQP85hCP wcc3DR2olTd01we6nLCQsYhZVPDljacrdal/pAtc= 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 3/6] arm64: hyperv: Add per-CPU RSI host call infrastructure for CCA Realms Date: Thu, 25 Jun 2026 10:34:57 -0700 Message-ID: <20260625173500.1995481-4-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> Precedence: bulk X-Mailing-List: linux-arch@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Arm CCA Realms cannot issue Hyper-V hypercalls via HVC; the guest must route them through the RSI_HOST_CALL interface, which takes the IPA of a per-CPU rsi_host_call structure as its argument. Add hv_hostcall_array as a per-CPU struct array and allocate it during hyperv_init(). The allocation is gated on is_realm_world() so non-Realm arm64 Hyper-V guests pay no memory cost. Signed-off-by: Kameron Carr --- arch/arm64/hyperv/mshyperv.c | 32 ++++++++++++++++++++++++++++++- arch/arm64/include/asm/mshyperv.h | 4 ++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/arch/arm64/hyperv/mshyperv.c b/arch/arm64/hyperv/mshyperv.c index 4fdc26ade1d74..7d536d7fb557e 100644 --- a/arch/arm64/hyperv/mshyperv.c +++ b/arch/arm64/hyperv/mshyperv.c @@ -15,10 +15,15 @@ #include #include #include +#include #include +#include static bool hyperv_initialized; +struct rsi_host_call *hv_hostcall_array; +EXPORT_SYMBOL_GPL(hv_hostcall_array); + int hv_get_hypervisor_version(union hv_hypervisor_version_info *info) { hv_get_vpreg_128(HV_REGISTER_HYPERVISOR_VERSION, @@ -60,6 +65,12 @@ static bool __init hyperv_detect_via_acpi(void) #endif +static void hv_hostcall_free(void) +{ + kfree(hv_hostcall_array); + hv_hostcall_array = NULL; +} + static bool __init hyperv_detect_via_smccc(void) { uuid_t hyperv_uuid = UUID_INIT( @@ -85,6 +96,20 @@ static int __init hyperv_init(void) if (!hyperv_detect_via_acpi() && !hyperv_detect_via_smccc()) return 0; + /* + * The RSI host-call buffers are only ever used when + * is_realm_world() is true. Skip the allocation on non-Realm + * guests. A single contiguous array of nr_cpu_ids entries is + * allocated; each CPU indexes into it by its processor ID. + */ + if (is_realm_world()) { + hv_hostcall_array = kcalloc(nr_cpu_ids, + sizeof(struct rsi_host_call), + GFP_KERNEL); + if (!hv_hostcall_array) + return -ENOMEM; + } + /* Setup the guest ID */ guest_id = hv_generate_guest_id(LINUX_VERSION_CODE); hv_set_vpreg(HV_REGISTER_GUEST_OS_ID, guest_id); @@ -106,12 +131,13 @@ static int __init hyperv_init(void) ret = hv_common_init(); if (ret) - return ret; + goto free_hostcall_mem; ret = cpuhp_setup_state(CPUHP_AP_HYPERV_ONLINE, "arm64/hyperv_init:online", hv_common_cpu_init, hv_common_cpu_die); if (ret < 0) { hv_common_free(); + hv_hostcall_free(); return ret; } @@ -125,6 +151,10 @@ static int __init hyperv_init(void) hyperv_initialized = true; return 0; + +free_hostcall_mem: + hv_hostcall_free(); + return ret; } early_initcall(hyperv_init); diff --git a/arch/arm64/include/asm/mshyperv.h b/arch/arm64/include/asm/mshyperv.h index b721d3134ab66..c207a3f79b99b 100644 --- a/arch/arm64/include/asm/mshyperv.h +++ b/arch/arm64/include/asm/mshyperv.h @@ -63,4 +63,8 @@ static inline u64 hv_get_non_nested_msr(unsigned int reg) #include +/* Per-CPU-indexed RSI host call structures for CCA Realms */ +struct rsi_host_call; +extern struct rsi_host_call *hv_hostcall_array; + #endif -- 2.45.4