From nobody Fri Oct 2 08:24:49 2026 Received: from out-186.mta0.migadu.com (out-186.mta0.migadu.com [91.218.175.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26E2940F753 for ; Mon, 3 Aug 2026 12:42:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.186 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785760955; cv=none; b=f5AYy/36y8jC6ifrvrt18BvmgEFaahZ0c6mBUR/xTfCkZexr3FLJB57q2jN3y3ILxeukIgpVxS42vGHPqIA8eSuZ/DWYMV1LjvVJyRO7imWWLn77WgbCPVOlLtW5yPq65ZJLCWaAsdLhYnR7gFIDGyah5r+MWAxbpp0LsGS7/Ns= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785760955; c=relaxed/simple; bh=/iCvHcbpKF86s8mUijJ9mtfUoT/0j522f9t+I2F3pQY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pgOp4ewM3+l6lDZltupPTiJfk/a3c3x1HveyZxWzzdAG4LNegLA8G3UYmGjKPgGXvgurZOVtv4dh6LURMESMtH8OqFgyWBtd5JdJJy/IwmCFBYonPXVzEw8BY2Vi4RLGWxcW68n/kMl5gpaZU2GjB2zStWr3wZdBHfibM/63DwQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=nv1sXr73; arc=none smtp.client-ip=91.218.175.186 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="nv1sXr73" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1785760951; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bVKtopwMrqzEnOyVedKGwt1g22ev9g5F8tMkWzZJze8=; b=nv1sXr73B89awbKPZkmi8w6iiuTkHiV6qBC96Bqef22ErCzkvNaTiaWHZRxq+A3UC+/29v wLkDtFrKl4t1Srl7LCdrgb4f9uZNQuHyDC9fzst/xRHLcgrjlQujELaOfTM/Tb46n5Zz3Y 36yGJ+M1qi4XRNQl7Xx5uZAuJGnFdVo= From: Fuad Tabba To: maz@kernel.org, oupton@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Cc: catalin.marinas@arm.com, will@kernel.org, rostedt@goodmis.org, mhiramat@kernel.org, alexandru.elisei@arm.com, vdonnefort@google.com, joey.gouly@arm.com, seiden@linux.ibm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, qperret@google.com, ardb@kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, tabba@google.com, fuad.tabba@linux.dev Subject: [PATCH v2 01/11] tracing: Include linux/types.h in trace_remote_event.h Date: Mon, 3 Aug 2026 13:42:10 +0100 Message-Id: <20260803124220.332248-2-fuad.tabba@linux.dev> In-Reply-To: <20260803124220.332248-1-fuad.tabba@linux.dev> References: <20260803124220.332248-1-fuad.tabba@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" trace_remote_event.h uses bool without including linux/types.h, so a translation unit that includes it ahead of anything else that pulls types.h in fails to build, as with nvhe/trace.h at EL2. Fixes: 072529158e60 ("tracing: Add events to trace remotes") Acked-by: Steven Rostedt Signed-off-by: Fuad Tabba --- include/linux/trace_remote_event.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/trace_remote_event.h b/include/linux/trace_remot= e_event.h index c8ae1e1f5e721..e4cc2d4497bcf 100644 --- a/include/linux/trace_remote_event.h +++ b/include/linux/trace_remote_event.h @@ -3,6 +3,8 @@ #ifndef _LINUX_TRACE_REMOTE_EVENTS_H #define _LINUX_TRACE_REMOTE_EVENTS_H =20 +#include + struct trace_remote; struct trace_event_fields; struct trace_seq; --=20 2.39.5 From nobody Fri Oct 2 08:24:49 2026 Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B6CF410D20 for ; Mon, 3 Aug 2026 12:42:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.185 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785760957; cv=none; b=GoLbSai//n+iWnJhJlmQn3stT8kvPvnkaZZTW1jCTNzQCnVrYAke/jGapJq30Dap+jqOrJDoucYwXdbBJ/xqCenAQ4ZZJcuHJKw2FSrHlBsTrjbCJBapkbPrQzLdCWZkrd7TRRn57EQ9QZyGpEmllBgqN2CnwAbstgBaCnRgTbY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785760957; c=relaxed/simple; bh=GaZD8YNbLBwQa9XjzIdEKqb+R+kYZ0rTi364A3qmdig=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dpMjx2mJxB0IGvvITMV7EqP9JThXClBPwsdCzx2/Xb4P4yBU5YmI7dSHAWtatPM6WAyf8hwII8XNUAxl26vWWRcedDApofdid2OnEHYfAWtbCLaxh1m7GYv3D1wxDuJ5eY6MiHKs8QTeibWTrRedxT0mDqvpQQ8UEqZOqU1Fywo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=fLluRGTU; arc=none smtp.client-ip=91.218.175.185 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="fLluRGTU" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1785760954; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mbmwUYRMkOEfVhoKhlo/B+eCrpuKcZd9NIaZ5Zet0iU=; b=fLluRGTUvfCee++jU1Sc9EXXlzbd+DqgR6e7R71FS/ubVVD+C8AvO6b9xRkSWHFsykTebX kTf9qaC7colywkIX+UtMZ5xMrFa1LSI2XxJOPdHRuFXXfiTYBNkxnUHcN68UFZgMr+ht2y NzW+WKmLfD/Ofk+XYumKkQVQSJF1pHY= From: Fuad Tabba To: maz@kernel.org, oupton@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Cc: catalin.marinas@arm.com, will@kernel.org, rostedt@goodmis.org, mhiramat@kernel.org, alexandru.elisei@arm.com, vdonnefort@google.com, joey.gouly@arm.com, seiden@linux.ibm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, qperret@google.com, ardb@kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, tabba@google.com, fuad.tabba@linux.dev Subject: [PATCH v2 02/11] KVM: arm64: nVHE: Share the stacktrace per-CPU declarations with EL2 Date: Mon, 3 Aug 2026 13:42:11 +0100 Message-Id: <20260803124220.332248-3-fuad.tabba@linux.dev> In-Reply-To: <20260803124220.332248-1-fuad.tabba@linux.dev> References: <20260803124220.332248-1-fuad.tabba@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" The declarations for overflow_stack, kvm_stacktrace_info and pkvm_stacktrace are only visible to the host (the first two sit in the host-only section of stacktrace/nvhe.h, the last is private to kvm/stacktrace.c), so the definitions in nvhe/stacktrace.c compile with no declaration in sight and sparse suggests making them static. DECLARE_KVM_NVHE_PER_CPU() resolves to the right symbol name on both sides of the build: move the declarations where both can see them and include the header from the EL2 side unconditionally. No functional change intended. Signed-off-by: Fuad Tabba --- arch/arm64/include/asm/stacktrace/nvhe.h | 10 ++++++++-- arch/arm64/kvm/hyp/nvhe/stacktrace.c | 3 +-- arch/arm64/kvm/stacktrace.c | 3 --- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/arch/arm64/include/asm/stacktrace/nvhe.h b/arch/arm64/include/= asm/stacktrace/nvhe.h index 171f9edef49fc..a631a577cbe5d 100644 --- a/arch/arm64/include/asm/stacktrace/nvhe.h +++ b/arch/arm64/include/asm/stacktrace/nvhe.h @@ -37,6 +37,14 @@ static inline void kvm_nvhe_unwind_init(struct unwind_st= ate *state, state->pc =3D pc; } =20 +DECLARE_KVM_NVHE_PER_CPU(unsigned long [OVERFLOW_STACK_SIZE/sizeof(long)],= overflow_stack); +DECLARE_KVM_NVHE_PER_CPU(struct kvm_nvhe_stacktrace_info, kvm_stacktrace_i= nfo); + +#ifdef CONFIG_PKVM_STACKTRACE +DECLARE_KVM_NVHE_PER_CPU(unsigned long [NVHE_STACKTRACE_SIZE/sizeof(long)], + pkvm_stacktrace); +#endif + #ifndef __KVM_NVHE_HYPERVISOR__ /* * Conventional (non-protected) nVHE HYP stack unwinder @@ -45,8 +53,6 @@ static inline void kvm_nvhe_unwind_init(struct unwind_sta= te *state, * (by the host in EL1). */ =20 -DECLARE_KVM_NVHE_PER_CPU(unsigned long [OVERFLOW_STACK_SIZE/sizeof(long)],= overflow_stack); -DECLARE_KVM_NVHE_PER_CPU(struct kvm_nvhe_stacktrace_info, kvm_stacktrace_i= nfo); DECLARE_PER_CPU(unsigned long, kvm_arm_hyp_stack_base); =20 void kvm_nvhe_dump_backtrace(unsigned long hyp_offset); diff --git a/arch/arm64/kvm/hyp/nvhe/stacktrace.c b/arch/arm64/kvm/hyp/nvhe= /stacktrace.c index 7c832d60d22bb..11fadbebbf1d6 100644 --- a/arch/arm64/kvm/hyp/nvhe/stacktrace.c +++ b/arch/arm64/kvm/hyp/nvhe/stacktrace.c @@ -8,6 +8,7 @@ #include #include #include +#include =20 DEFINE_PER_CPU(unsigned long [OVERFLOW_STACK_SIZE/sizeof(long)], overflow_= stack) __aligned(16); @@ -35,8 +36,6 @@ static void hyp_prepare_backtrace(unsigned long fp, unsig= ned long pc) } =20 #ifdef CONFIG_PKVM_STACKTRACE -#include - DEFINE_PER_CPU(unsigned long [NVHE_STACKTRACE_SIZE/sizeof(long)], pkvm_sta= cktrace); =20 static struct stack_info stackinfo_get_overflow(void) diff --git a/arch/arm64/kvm/stacktrace.c b/arch/arm64/kvm/stacktrace.c index 9724c320126b7..69377195e18b7 100644 --- a/arch/arm64/kvm/stacktrace.c +++ b/arch/arm64/kvm/stacktrace.c @@ -198,9 +198,6 @@ static void hyp_dump_backtrace(unsigned long hyp_offset) } =20 #ifdef CONFIG_PKVM_STACKTRACE -DECLARE_KVM_NVHE_PER_CPU(unsigned long [NVHE_STACKTRACE_SIZE/sizeof(long)], - pkvm_stacktrace); - /* * pkvm_dump_backtrace - Dump the protected nVHE HYP backtrace. * --=20 2.39.5 From nobody Fri Oct 2 08:24:49 2026 Received: from out-181.mta0.migadu.com (out-181.mta0.migadu.com [91.218.175.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9324740F75B for ; Mon, 3 Aug 2026 12:42:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785760960; cv=none; b=C4oFBOAEVdsyEU1u6KVO3NWU69wToRvSgnuvfvNh4syjQZSzkXZD5c9LZBmKsf9hF2r46Bw0PPm7oFS5QqljVwmYFzFYieTc0LqD3ctYEd9n43leb95irqpjrcC98OQ4v8LWs0mjXCK1jiQUUYDWLLl8NVIfOy1oUvdBjX09890= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785760960; c=relaxed/simple; bh=964nyES0bpmlC1jVFJFVmRXV0epLfd7qUJ0SK0/0qeM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iCV2pTE0O2HJ4ADpErzd6WXFEjHcDv+bcEsAEKSj/yvVgj99q5E0kgzjq11kOjWF3eZpkA9yOGxvWAOnzb3JeTNYLfx8JCYqywxQ4FpDqvlKmAcGAZP4QZy2r9e2FS9TxtHMrCob8eDtNrY1QAnzQWAJVOB9m/rcZL7LVshBkpo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=xhTJaeM1; arc=none smtp.client-ip=91.218.175.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="xhTJaeM1" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1785760956; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ClYTj8QzgBnO7N7CWSz26CsAj405Dm7DCBLVlh0azJ4=; b=xhTJaeM1jik5dmoy0svqefAsSjE0Q9FL+W+l+FLUK14nyvekFwB9ivciH/MxcMM4A98SJu L2YXNA1MfU/SmNabpQQvCDbz24P8sSKw1b82Tngdql+NNZKLtkKyb6Dk0ZqLn4djsYg+Uh VtVaC+vIDTSXjNT3kdD6kujQk9YzzKI= From: Fuad Tabba To: maz@kernel.org, oupton@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Cc: catalin.marinas@arm.com, will@kernel.org, rostedt@goodmis.org, mhiramat@kernel.org, alexandru.elisei@arm.com, vdonnefort@google.com, joey.gouly@arm.com, seiden@linux.ibm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, qperret@google.com, ardb@kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, tabba@google.com, fuad.tabba@linux.dev Subject: [PATCH v2 03/11] KVM: arm64: nVHE: Declare the hyp event IDs before defining them Date: Mon, 3 Aug 2026 13:42:12 +0100 Message-Id: <20260803124220.332248-4-fuad.tabba@linux.dev> In-Reply-To: <20260803124220.332248-1-fuad.tabba@linux.dev> References: <20260803124220.332248-1-fuad.tabba@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" The defining expansion of HYP_EVENT() in events.c is the first time its translation unit meets hyp_event_id_, so sparse suggests making the symbols static. Include kvm_hypevents.h ahead of define_events.h so the extern declarations come first, as with the tracepoint headers. No functional change intended. Reviewed-by: Vincent Donnefort Tested-by: Vincent Donnefort Signed-off-by: Fuad Tabba --- arch/arm64/kvm/hyp/nvhe/events.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/events.c b/arch/arm64/kvm/hyp/nvhe/eve= nts.c index add9383aadb5a..b845be0acd117 100644 --- a/arch/arm64/kvm/hyp/nvhe/events.c +++ b/arch/arm64/kvm/hyp/nvhe/events.c @@ -7,6 +7,8 @@ #include #include =20 +#include + #include =20 int __tracing_enable_event(unsigned short id, bool enable) --=20 2.39.5 From nobody Fri Oct 2 08:24:49 2026 Received: from out-186.mta0.migadu.com (out-186.mta0.migadu.com [91.218.175.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05688412C08 for ; Mon, 3 Aug 2026 12:42:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.186 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785760962; cv=none; b=L+hRFVePSjBhqZWDqVNuen4KcGRunxl6xoW+u0bD6/s+5p7trHSRKWIk5UsOlXbh17RcqMGvj7cS9URt0GkyOEmfYK2EOSp3yvr6aTr7f79uhIrG7ryigpUUDRnxUyh8tv0P4x3tJQ3+D27YlFc8ezTOOL4L9eSIyg6p6+wADnE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785760962; c=relaxed/simple; bh=CpskfQyNSuQnKK28n7Fb63ydz6/PMV/vlQveuN/a3ec=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=upUgMIsnjMidTu4bFTRhlW5sybsdSWn2blDkZ30/FQKVPUTVxWUqFFMZM4xH2k7xTw5sTLxE4HMWhvSiV2u4Ty1XsKmbfYrvUAYlwxF5TABZkwL2KMY9PEIGq6a9NWONdqWt0EWdB5a+W30xwBeO+90HaV1tjVyt7jcbRaB9l34= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=cbL730Bd; arc=none smtp.client-ip=91.218.175.186 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="cbL730Bd" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1785760958; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a5F+MIK/Sq7LP625lI93wSHp0p+82BAhT+VDlBkJm/w=; b=cbL730BddzEsmkX2O7vuBy2DSDMtr0VqHztnxtYXdppgMiARCQCZ/QSajI9GwyEVkG1cog v6H0su53vSgi7L7dzYEHLPCmcVUqUxy/6gZuKktrjDqz2vjMtmbgsf2YF1L9pLD7rk5IV6 djHVSstSfFnbIseexSlb/QxsFAtleDM= From: Fuad Tabba To: maz@kernel.org, oupton@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Cc: catalin.marinas@arm.com, will@kernel.org, rostedt@goodmis.org, mhiramat@kernel.org, alexandru.elisei@arm.com, vdonnefort@google.com, joey.gouly@arm.com, seiden@linux.ibm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, qperret@google.com, ardb@kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, tabba@google.com, fuad.tabba@linux.dev Subject: [PATCH v2 04/11] KVM: arm64: nVHE: Use NULL to reset the trace buffer backing pointer Date: Mon, 3 Aug 2026 13:42:13 +0100 Message-Id: <20260803124220.332248-5-fuad.tabba@linux.dev> In-Reply-To: <20260803124220.332248-1-fuad.tabba@linux.dev> References: <20260803124220.332248-1-fuad.tabba@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" bpages_backing_start is a pointer; resetting it to plain 0 triggers a sparse warning. No functional change intended. Reviewed-by: Vincent Donnefort Signed-off-by: Fuad Tabba --- arch/arm64/kvm/hyp/nvhe/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/nvhe/trace.c b/arch/arm64/kvm/hyp/nvhe/trac= e.c index e7e150ab265ff..177fe3d8fbb13 100644 --- a/arch/arm64/kvm/hyp/nvhe/trace.c +++ b/arch/arm64/kvm/hyp/nvhe/trace.c @@ -93,7 +93,7 @@ static void hyp_trace_buffer_unload_bpage_backing(struct = hyp_trace_buffer *trace =20 __release_host_mem(start, size); =20 - trace_buffer->bpages_backing_start =3D 0; + trace_buffer->bpages_backing_start =3D NULL; trace_buffer->bpages_backing_size =3D 0; } =20 --=20 2.39.5 From nobody Fri Oct 2 08:24:49 2026 Received: from out-180.mta0.migadu.com (out-180.mta0.migadu.com [91.218.175.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 687674156DA for ; Mon, 3 Aug 2026 12:43:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785760988; cv=none; b=XqUf36Z3NZijoF/KAPTvQ/29+PBd6wR0RFfK51zomv6uewKcOvhB8wjJRuJAKXVzWrQbF3AyF90yylIrixEl6gDUfUZ1bPh7D3KzxNo7cCJ0WcIXNfzGpIRDll5Qs03FqS0xFOs0PT+jti6KmPvsbYyE0Tcy0PWRW0qZxz3rHO8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785760988; c=relaxed/simple; bh=BwXfUSI8RZ5WlNlvsW4Dg8xPJP7duOd+6j4GH2NB7KQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=J0dXqK7sCpZ0UkInOUiB4hiQOfex9luwgjSaX0T2QGbZZggVpsqBvttfEqVPNukyZZ51C+QoFY5ALxt+lv3MqBwjOyIb8SyIQGd3OPK+WsprGcLgKOjPVgcGtKN4vGkfTGHHFZUNTOiQWCkZ+8hT3k2qK0sTOnRqY6d6LbYAMSs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=ebv10M55; arc=none smtp.client-ip=91.218.175.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ebv10M55" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1785760983; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/0h+UWlinGdaNRWQ3ePtD6vflPt+g0iOPa3K/aYZ+gU=; b=ebv10M550xegZcKAjU41448qc3wUASeRpVTzK5M+vRWQQTholPHKOqF5TXMVZA3FzVxl/7 keKCBl5SzT98GNFFT2Nat3Kx01ua/TsCqFuJhQBuvzn9atx3Tbw73KD37mivrj3V+Fn3D0 +rzwlzD80L3EdxzLpfvotGFOALn3Avc= From: Fuad Tabba To: maz@kernel.org, oupton@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Cc: catalin.marinas@arm.com, will@kernel.org, rostedt@goodmis.org, mhiramat@kernel.org, alexandru.elisei@arm.com, vdonnefort@google.com, joey.gouly@arm.com, seiden@linux.ibm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, qperret@google.com, ardb@kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, tabba@google.com, fuad.tabba@linux.dev Subject: [PATCH v2 05/11] KVM: arm64: nVHE: Run the source checker under C=2 Date: Mon, 3 Aug 2026 13:42:14 +0100 Message-Id: <20260803124220.332248-6-fuad.tabba@linux.dev> In-Reply-To: <20260803124220.332248-1-fuad.tabba@linux.dev> References: <20260803124220.332248-1-fuad.tabba@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" The custom %.nvhe.o rule reuses rule_cc_o_c, which hooks the source checker only for C=3D1, and that only when the object is rebuilt. The C=3D2 hook, cmd_force_checksrc, hangs off the standard %.o rule that nVHE objects do not use, so "make C=3D2" silently skips every nVHE source file. Call cmd_force_checksrc after the compile rule, as the standard rule does. Fixes: 7621712918ad4 ("KVM: arm64: Add build rules for separate VHE/nVHE ob= ject files") Reviewed-by: Vincent Donnefort Tested-by: Vincent Donnefort Signed-off-by: Fuad Tabba --- arch/arm64/kvm/hyp/nvhe/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/kvm/hyp/nvhe/Makefile b/arch/arm64/kvm/hyp/nvhe/Mak= efile index f57450ebcb498..ccc1fe8394094 100644 --- a/arch/arm64/kvm/hyp/nvhe/Makefile +++ b/arch/arm64/kvm/hyp/nvhe/Makefile @@ -49,6 +49,7 @@ targets +=3D $(hyp-obj) kvm_nvhe.tmp.o kvm_nvhe.rel.o hyp= .lds hyp-reloc.S hyp-relo # avoids file name clashes for files shared with VHE. $(obj)/%.nvhe.o: $(src)/%.c FORCE $(call if_changed_rule,cc_o_c) + $(call cmd,force_checksrc) $(obj)/%.nvhe.o: $(src)/%.S FORCE $(call if_changed_rule,as_o_S) =20 --=20 2.39.5 From nobody Fri Oct 2 08:24:49 2026 Received: from out-180.mta0.migadu.com (out-180.mta0.migadu.com [91.218.175.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C04E4156FD for ; Mon, 3 Aug 2026 12:43:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785760990; cv=none; b=Ywbrv7cf7+FMn871AQHf1gjTHxMC/0+Y2U0h2AUY61EyEd99n7UG2KV1HLJctv8dwk8OwsZP+WufjffWd+xtthpnyScxEnpuwoU5+Lv5uhlrLyQ12nkri+Epsjz9TDeIEq+mLHKjh2bvfFtPO63sLpt8sZlK7y+dw35gLNSXXmc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785760990; c=relaxed/simple; bh=8eH8qSzPuak64zpqRzFkW4jtyt9rW2sXsAdwvlZWV9o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=b0tUZ4tAFhmlLnMsSAyafbjDIDj8NkTogYYru26hQnLq8fhvI/sS5QmtwxSbAKtWMVbQUPFMvYVJ/VJKFkyJnhj3SYlW+BW4uKBuaZ4fv0PgUpJIeXxxSie0AbVKlKkbbEvtj6RVnqjNhohN6uYBztQyCGMz75Lfo2syUZNKJv4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=QOJDzn5h; arc=none smtp.client-ip=91.218.175.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="QOJDzn5h" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1785760986; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sjtjOJ8VIAIzCYAs/x+lZGyja9IHYPAp3SWkrVb/Pdo=; b=QOJDzn5hPJpNt2zdH6Up7gBtbqVcOniEobzwgopvbrCl0RRWTXIHClvLEo2354rbjLMQwY ARYchshgpVDRYG1563FUdXZ4dPVdwP/rKaZexiPPHvfTrgQNPR3P3km6OipFl5UI/Ibrmm 4ys1v8u2h5YeaPR6ma2nSZM1gwX7OCA= From: Fuad Tabba To: maz@kernel.org, oupton@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Cc: catalin.marinas@arm.com, will@kernel.org, rostedt@goodmis.org, mhiramat@kernel.org, alexandru.elisei@arm.com, vdonnefort@google.com, joey.gouly@arm.com, seiden@linux.ibm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, qperret@google.com, ardb@kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, tabba@google.com, fuad.tabba@linux.dev Subject: [PATCH v2 06/11] arm64: pi: Run the source checker on the libfdt objects under C=2 Date: Mon, 3 Aug 2026 13:42:15 +0100 Message-Id: <20260803124220.332248-7-fuad.tabba@linux.dev> In-Reply-To: <20260803124220.332248-1-fuad.tabba@linux.dev> References: <20260803124220.332248-1-fuad.tabba@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" The custom lib-%.o rule reuses rule_cc_o_c, which hooks the source checker only for C=3D1, and that only when the object is rebuilt. The C=3D2 hook, cmd_force_checksrc, hangs off the standard %.o rule, so "make C=3D2" silently skips the two libfdt objects. Call cmd_force_checksrc after the compile rule, as the standard rule does. Fixes: aacd149b6238 ("arm64: head: avoid relocating the kernel twice for KA= SLR") Signed-off-by: Fuad Tabba --- arch/arm64/kernel/pi/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/kernel/pi/Makefile b/arch/arm64/kernel/pi/Makefile index be92d73c25b21..96243c291e39d 100644 --- a/arch/arm64/kernel/pi/Makefile +++ b/arch/arm64/kernel/pi/Makefile @@ -34,6 +34,7 @@ $(obj)/lib-%.pi.o: OBJCOPYFLAGS +=3D --prefix-alloc-secti= ons=3D.init =20 $(obj)/lib-%.o: $(srctree)/lib/%.c FORCE $(call if_changed_rule,cc_o_c) + $(call cmd,force_checksrc) =20 obj-y :=3D idreg-override.pi.o \ map_kernel.pi.o map_range.pi.o \ --=20 2.39.5 From nobody Fri Oct 2 08:24:49 2026 Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46632415F1F for ; Mon, 3 Aug 2026 12:43:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785760997; cv=none; b=ePs+mMvB1DoitaxnURXJkiLqOuHzw4jpV1/l4Gc12wpDGfsiDftVUNb8m8iVSagFpfg5aIQTRnMYnsYDNFbMou4bAgG86aUoHsyi8w7iSb2R/w6CFrKzzF9+XLBsR/eI0zZ5d8Q6hwoKCkyudMn4Srve7k0wzxo0Sydvf+HAvi8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785760997; c=relaxed/simple; bh=bQ+/Qw3KeLIOai823DsWpPtAJXBCSSsvbk1lv3ttuZ8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DlqUyiqXUtogD/cHFwwqnedFUAxPBv4QPNd0KpZTh2n6BUz050GhtO1COyfvhn5JH0a5vVyqt0iK7sEnhgoix/QJRjGdd7RZsX2AcqlbFO8ZDc4l5n3Srea2yijjSGcGfwnX87e+RGzm5MO8qokpoYzGufeE8hj1g4mrlqwH/28= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=uP0th6Yb; arc=none smtp.client-ip=91.218.175.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="uP0th6Yb" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1785760988; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g4PpMNlGsTWFD0SxKNjrPtX+vudl8Lxy+1dKyA5gL04=; b=uP0th6Ybl/87b4WO3nVCyJ3/VT0+4W1vDpjHnYl4QDRRATFUyNMF/ChIbt++BLMdQ+ra3i Yg4Xf4yCC/DfUq3JuM6GOkDrYMlDhP/iLHYLCuKGXVcgauZdilAtqLDPHpZMqXC1zpz12N Nqh7hFfCpO4X8knMvMxoEN5Ap38zEvw= From: Fuad Tabba To: maz@kernel.org, oupton@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Cc: catalin.marinas@arm.com, will@kernel.org, rostedt@goodmis.org, mhiramat@kernel.org, alexandru.elisei@arm.com, vdonnefort@google.com, joey.gouly@arm.com, seiden@linux.ibm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, qperret@google.com, ardb@kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, tabba@google.com, fuad.tabba@linux.dev Subject: [PATCH v2 07/11] KVM: arm64: nVHE: Pass host VA arguments as pointers Date: Mon, 3 Aug 2026 13:42:16 +0100 Message-Id: <20260803124220.332248-8-fuad.tabba@linux.dev> In-Reply-To: <20260803124220.332248-1-fuad.tabba@linux.dev> References: <20260803124220.332248-1-fuad.tabba@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Four hypercalls take host VAs as unsigned long: the donated vm, pgd and vcpu regions, and the tracing descriptor. Retype the arguments and their EL2 consumers as void *, so that the typed hypercall declarations introduced later in the series can attach a sparse address space to them; an address space attaches only to pointers. No functional change intended. Signed-off-by: Fuad Tabba --- arch/arm64/kvm/hyp/include/nvhe/pkvm.h | 5 ++--- arch/arm64/kvm/hyp/include/nvhe/trace.h | 4 ++-- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 ++++---- arch/arm64/kvm/hyp/nvhe/pkvm.c | 11 +++++------ arch/arm64/kvm/hyp/nvhe/trace.c | 4 ++-- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/arch/arm64/kvm/hyp/include/nvhe/pkvm.h b/arch/arm64/kvm/hyp/in= clude/nvhe/pkvm.h index c904647d2f760..2643a1a819668 100644 --- a/arch/arm64/kvm/hyp/include/nvhe/pkvm.h +++ b/arch/arm64/kvm/hyp/include/nvhe/pkvm.h @@ -69,10 +69,9 @@ void pkvm_hyp_vm_table_init(void *tbl); =20 int __pkvm_reserve_vm(void); void __pkvm_unreserve_vm(pkvm_handle_t handle); -int __pkvm_init_vm(struct kvm *host_kvm, unsigned long vm_hva, - unsigned long pgd_hva); +int __pkvm_init_vm(struct kvm *host_kvm, void *vm_hva, void *pgd_hva); int __pkvm_init_vcpu(pkvm_handle_t handle, struct kvm_vcpu *host_vcpu, - unsigned long vcpu_hva); + void *vcpu_hva); =20 int __pkvm_reclaim_dying_guest_page(pkvm_handle_t handle, u64 gfn); int __pkvm_start_teardown_vm(pkvm_handle_t handle); diff --git a/arch/arm64/kvm/hyp/include/nvhe/trace.h b/arch/arm64/kvm/hyp/i= nclude/nvhe/trace.h index 8813ff250f8e0..4aa36fd76b9e2 100644 --- a/arch/arm64/kvm/hyp/include/nvhe/trace.h +++ b/arch/arm64/kvm/hyp/include/nvhe/trace.h @@ -46,7 +46,7 @@ static inline pid_t __tracing_get_vcpu_pid(struct kvm_cpu= _context *host_ctxt) void *tracing_reserve_entry(unsigned long length); void tracing_commit_entry(void); =20 -int __tracing_load(unsigned long desc_va, size_t desc_size); +int __tracing_load(void *desc_va, size_t desc_size); void __tracing_unload(void); int __tracing_enable(bool enable); int __tracing_swap_reader(unsigned int cpu); @@ -59,7 +59,7 @@ static inline void tracing_commit_entry(void) { } #define HYP_EVENT(__name, __proto, __struct, __assign, __printk) \ static inline void trace_##__name(__proto) {} =20 -static inline int __tracing_load(unsigned long desc_va, size_t desc_size) = { return -ENODEV; } +static inline int __tracing_load(void *desc_va, size_t desc_size) { return= -ENODEV; } static inline void __tracing_unload(void) { } static inline int __tracing_enable(bool enable) { return -ENODEV; } static inline int __tracing_swap_reader(unsigned int cpu) { return -ENODEV= ; } diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/h= yp-main.c index d3df96ed8ba42..23cb4313c60a2 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c @@ -577,8 +577,8 @@ static void handle___pkvm_unreserve_vm(struct kvm_cpu_c= ontext *host_ctxt) static void handle___pkvm_init_vm(struct kvm_cpu_context *host_ctxt) { DECLARE_REG(struct kvm *, host_kvm, host_ctxt, 1); - DECLARE_REG(unsigned long, vm_hva, host_ctxt, 2); - DECLARE_REG(unsigned long, pgd_hva, host_ctxt, 3); + DECLARE_REG(void *, vm_hva, host_ctxt, 2); + DECLARE_REG(void *, pgd_hva, host_ctxt, 3); =20 host_kvm =3D kern_hyp_va(host_kvm); cpu_reg(host_ctxt, 1) =3D __pkvm_init_vm(host_kvm, vm_hva, pgd_hva); @@ -588,7 +588,7 @@ static void handle___pkvm_init_vcpu(struct kvm_cpu_cont= ext *host_ctxt) { DECLARE_REG(pkvm_handle_t, handle, host_ctxt, 1); DECLARE_REG(struct kvm_vcpu *, host_vcpu, host_ctxt, 2); - DECLARE_REG(unsigned long, vcpu_hva, host_ctxt, 3); + DECLARE_REG(void *, vcpu_hva, host_ctxt, 3); =20 host_vcpu =3D kern_hyp_va(host_vcpu); cpu_reg(host_ctxt, 1) =3D __pkvm_init_vcpu(handle, host_vcpu, vcpu_hva); @@ -634,7 +634,7 @@ static void handle___pkvm_finalize_teardown_vm(struct k= vm_cpu_context *host_ctxt =20 static void handle___tracing_load(struct kvm_cpu_context *host_ctxt) { - DECLARE_REG(unsigned long, desc_hva, host_ctxt, 1); + DECLARE_REG(void *, desc_hva, host_ctxt, 1); DECLARE_REG(size_t, desc_size, host_ctxt, 2); =20 cpu_reg(host_ctxt, 1) =3D __tracing_load(desc_hva, desc_size); diff --git a/arch/arm64/kvm/hyp/nvhe/pkvm.c b/arch/arm64/kvm/hyp/nvhe/pkvm.c index 24d6f164129ac..205c52535c887 100644 --- a/arch/arm64/kvm/hyp/nvhe/pkvm.c +++ b/arch/arm64/kvm/hyp/nvhe/pkvm.c @@ -644,9 +644,9 @@ static size_t pkvm_get_hyp_vm_size(unsigned int nr_vcpu= s) size_mul(sizeof(struct pkvm_hyp_vcpu *), nr_vcpus)); } =20 -static void *map_donated_memory_noclear(unsigned long host_va, size_t size) +static void *map_donated_memory_noclear(void *host_va, size_t size) { - void *va =3D (void *)kern_hyp_va(host_va); + void *va =3D kern_hyp_va(host_va); =20 if (!PAGE_ALIGNED(va)) return NULL; @@ -658,7 +658,7 @@ static void *map_donated_memory_noclear(unsigned long h= ost_va, size_t size) return va; } =20 -static void *map_donated_memory(unsigned long host_va, size_t size) +static void *map_donated_memory(void *host_va, size_t size) { void *va =3D map_donated_memory_noclear(host_va, size); =20 @@ -805,8 +805,7 @@ void teardown_selftest_vm(void) * * Return 0 success, negative error code on failure. */ -int __pkvm_init_vm(struct kvm *host_kvm, unsigned long vm_hva, - unsigned long pgd_hva) +int __pkvm_init_vm(struct kvm *host_kvm, void *vm_hva, void *pgd_hva) { struct pkvm_hyp_vm *hyp_vm =3D NULL; size_t vm_size, pgd_size; @@ -897,7 +896,7 @@ static int register_hyp_vcpu(struct pkvm_hyp_vm *hyp_vm, } =20 int __pkvm_init_vcpu(pkvm_handle_t handle, struct kvm_vcpu *host_vcpu, - unsigned long vcpu_hva) + void *vcpu_hva) { struct pkvm_hyp_vcpu *hyp_vcpu; struct pkvm_hyp_vm *hyp_vm; diff --git a/arch/arm64/kvm/hyp/nvhe/trace.c b/arch/arm64/kvm/hyp/nvhe/trac= e.c index 177fe3d8fbb13..97203ddd3cf45 100644 --- a/arch/arm64/kvm/hyp/nvhe/trace.c +++ b/arch/arm64/kvm/hyp/nvhe/trace.c @@ -206,9 +206,9 @@ static bool hyp_trace_desc_is_valid(struct hyp_trace_de= sc *desc, size_t desc_siz return true; } =20 -int __tracing_load(unsigned long desc_hva, size_t desc_size) +int __tracing_load(void *desc_hva, size_t desc_size) { - struct hyp_trace_desc *desc =3D (struct hyp_trace_desc *)kern_hyp_va(desc= _hva); + struct hyp_trace_desc *desc =3D kern_hyp_va(desc_hva); int ret; =20 ret =3D __admit_host_mem(desc, desc_size); --=20 2.39.5 From nobody Fri Oct 2 08:24:49 2026 Received: from out-179.mta0.migadu.com (out-179.mta0.migadu.com [91.218.175.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 273D740626C for ; Mon, 3 Aug 2026 12:43:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785760995; cv=none; b=HmrkXnZEhkI4V7wEi2xcB32e8j6mv2qaJhsMci7/igZPqMGNWUJ7zcdyiEd5hSwuPG0hE1GyBbW/EtUhT1NupUTBqXV4fc2cHN/7rxZftPnnvb6z9LdmmSvcfbLm0JFldG7nET78hCQSrRo77KHiGpqC87048i5szS689WL5or0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785760995; c=relaxed/simple; bh=eWPvosX4xmUOLdHLHklwkbWwVFF7a9X4ZRTfU1WpQp0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LkdwA/KQuqBzQXL5lYloQe5wl5j9z9B3aI9BNJWW8LVNNpLJqxsfGn9Helam6HeIGUzXIIGLR5SlEED0b/Y8b4XrSQ6lIZbIm5NFaN2MPtqUx1urSxUWQmh1bD9XKqI+Coi8/PJHgFUEmsfXKIyNsCaHUIPpLYCtYAZ+hFtvc5E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=kufom7Wk; arc=none smtp.client-ip=91.218.175.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="kufom7Wk" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1785760991; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8449deZzWWvUrdWZNQWJEv7MjXt9tctoupcrsbbFYlI=; b=kufom7Wk8zNEVBVOzbGv1Z3IbOdydRL/B50xpDo4j7BXJ6jsRykAkla61jiFncEILCNIFH oalM5q86jzwRveN5eXew/rclc7LztYxRVyKkEYmRsUcIe5t4Um00vkQMoDQceMrDjgdecU QFv1lI/Vy0ofOl1+WMbe+g0rjJprSF0= From: Fuad Tabba To: maz@kernel.org, oupton@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Cc: catalin.marinas@arm.com, will@kernel.org, rostedt@goodmis.org, mhiramat@kernel.org, alexandru.elisei@arm.com, vdonnefort@google.com, joey.gouly@arm.com, seiden@linux.ibm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, qperret@google.com, ardb@kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, tabba@google.com, fuad.tabba@linux.dev Subject: [PATCH v2 08/11] KVM: arm64: Move the host hypercall interface to its own header Date: Mon, 3 Aug 2026 13:42:17 +0100 Message-Id: <20260803124220.332248-9-fuad.tabba@linux.dev> In-Reply-To: <20260803124220.332248-1-fuad.tabba@linux.dev> References: <20260803124220.332248-1-fuad.tabba@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Move the kvm_call_hyp() dispatch macros and pkvm_handle_t out of kvm_host.h into a new kvm_hcall.h, giving the host<->hyp hypercall interface a single home that subsequent patches build on to restore type-checking across the boundary. The only adjustment to the moved code is the checkpatch-mandated space in "while (0)". No functional change intended. Signed-off-by: Fuad Tabba --- arch/arm64/include/asm/kvm_hcall.h | 68 ++++++++++++++++++++++++++++++ arch/arm64/include/asm/kvm_host.h | 48 +-------------------- 2 files changed, 69 insertions(+), 47 deletions(-) create mode 100644 arch/arm64/include/asm/kvm_hcall.h diff --git a/arch/arm64/include/asm/kvm_hcall.h b/arch/arm64/include/asm/kv= m_hcall.h new file mode 100644 index 0000000000000..d925b2c28a3d8 --- /dev/null +++ b/arch/arm64/include/asm/kvm_hcall.h @@ -0,0 +1,68 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * The host<->hyp hypercall interface. + * + * Copyright (C) 2026 Google LLC + * Author: Fuad Tabba + */ + +#ifndef __ARM64_KVM_HCALL_H__ +#define __ARM64_KVM_HCALL_H__ + +#include +#include +#include +#include + +#include +#include +#include + +typedef u16 pkvm_handle_t; + +#ifndef __KVM_NVHE_HYPERVISOR__ +#define kvm_call_hyp_nvhe(f, ...) \ + ({ \ + struct arm_smccc_res res; \ + \ + arm_smccc_1_1_hvc(KVM_HOST_SMCCC_FUNC(f), \ + ##__VA_ARGS__, &res); \ + if (WARN_ON(res.a0 !=3D SMCCC_RET_SUCCESS)) \ + res.a1 =3D -EOPNOTSUPP; \ + \ + res.a1; \ + }) + +/* + * The isb() below is there to guarantee the same behaviour on VHE as on != VHE, + * where the eret to EL1 acts as a context synchronization event. + */ +#define kvm_call_hyp(f, ...) \ + do { \ + if (has_vhe()) { \ + f(__VA_ARGS__); \ + isb(); \ + } else { \ + kvm_call_hyp_nvhe(f, ##__VA_ARGS__); \ + } \ + } while (0) + +#define kvm_call_hyp_ret(f, ...) \ + ({ \ + typeof(f(__VA_ARGS__)) ret; \ + \ + if (has_vhe()) { \ + ret =3D f(__VA_ARGS__); \ + } else { \ + ret =3D kvm_call_hyp_nvhe(f, ##__VA_ARGS__); \ + } \ + \ + ret; \ + }) +#else /* __KVM_NVHE_HYPERVISOR__ */ +#define kvm_call_hyp(f, ...) f(__VA_ARGS__) +#define kvm_call_hyp_ret(f, ...) f(__VA_ARGS__) +#define kvm_call_hyp_nvhe(f, ...) f(__VA_ARGS__) +#endif /* __KVM_NVHE_HYPERVISOR__ */ + +#endif /* __ARM64_KVM_HCALL_H__ */ diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm= _host.h index bae2c4f92ef5c..81d359ac7af14 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -27,6 +27,7 @@ #include #include #include +#include #include =20 #define __KVM_HAVE_ARCH_INTC_INITIALIZED @@ -251,8 +252,6 @@ struct kvm_smccc_features { unsigned long vendor_hyp_bmap_2; /* Function numbers 64-127 */ }; =20 -typedef u16 pkvm_handle_t; - struct kvm_protected_vm { pkvm_handle_t handle; struct kvm_hyp_memcache teardown_mc; @@ -1252,51 +1251,6 @@ void kvm_arm_resume_guest(struct kvm *kvm); =20 #define vcpu_has_run_once(vcpu) (!!READ_ONCE((vcpu)->pid)) =20 -#ifndef __KVM_NVHE_HYPERVISOR__ -#define kvm_call_hyp_nvhe(f, ...) \ - ({ \ - struct arm_smccc_res res; \ - \ - arm_smccc_1_1_hvc(KVM_HOST_SMCCC_FUNC(f), \ - ##__VA_ARGS__, &res); \ - if (WARN_ON(res.a0 !=3D SMCCC_RET_SUCCESS)) \ - res.a1 =3D -EOPNOTSUPP; \ - \ - res.a1; \ - }) - -/* - * The isb() below is there to guarantee the same behaviour on VHE as on != VHE, - * where the eret to EL1 acts as a context synchronization event. - */ -#define kvm_call_hyp(f, ...) \ - do { \ - if (has_vhe()) { \ - f(__VA_ARGS__); \ - isb(); \ - } else { \ - kvm_call_hyp_nvhe(f, ##__VA_ARGS__); \ - } \ - } while(0) - -#define kvm_call_hyp_ret(f, ...) \ - ({ \ - typeof(f(__VA_ARGS__)) ret; \ - \ - if (has_vhe()) { \ - ret =3D f(__VA_ARGS__); \ - } else { \ - ret =3D kvm_call_hyp_nvhe(f, ##__VA_ARGS__); \ - } \ - \ - ret; \ - }) -#else /* __KVM_NVHE_HYPERVISOR__ */ -#define kvm_call_hyp(f, ...) f(__VA_ARGS__) -#define kvm_call_hyp_ret(f, ...) f(__VA_ARGS__) -#define kvm_call_hyp_nvhe(f, ...) f(__VA_ARGS__) -#endif /* __KVM_NVHE_HYPERVISOR__ */ - int handle_exit(struct kvm_vcpu *vcpu, int exception_index); void handle_exit_early(struct kvm_vcpu *vcpu, int exception_index); =20 --=20 2.39.5 From nobody Fri Oct 2 08:24:49 2026 Received: from out-179.mta0.migadu.com (out-179.mta0.migadu.com [91.218.175.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 92073409633 for ; Mon, 3 Aug 2026 12:43:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785760998; cv=none; b=RX8aIPQtgUdPYpA0JBdrJDyWcZIYIbr1hfqExT5wzXGiHm8g4Jwle3oBFfSzA3iQh+xGhOkN46Ezb/4Lu2/X4LtlstWbl7etrZ7TfDVom5NjHkP0yoCEcpx4Au4B2yJyXlfb9iv64c1zKPHykNwR6xv6nxD/XO0sNzLs7w3DMHU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785760998; c=relaxed/simple; bh=uL1Gd9ShDAFn+Vob0c2HGgJFcaw0C/Ts5tiVCiJNzHk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kz7JM0a1lXuXxNZW6ZO+pJF3OMM+JUGOOL6pnWm9Kv4B272xzVOZGsGTDdIseV3/TP56rnovRAr86tTGA3adAVARDZ4l8O3n6u/ew7s0mJeei0hTYjUqZfTgUl389PjXFM5d+Gy33ra4L9RegJkD7hag3ZUa7iASaYP7Eur2GME= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=BwdAKX8k; arc=none smtp.client-ip=91.218.175.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="BwdAKX8k" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1785760993; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oMu2F6yU/P7jnsdMnWb4spsSAPbWFFNzzR0sAj34cJQ=; b=BwdAKX8k/SaucyMEo8941hNe5F272UOlaN2FFTS89VfJftw7bC01QuBjWqJ4GvF1rIbQK0 FT5v8zB4DD9esYz371AefcNcEHwPg58t/7MjbJJoeXL2U0QrsICjqnfSEhNsb8oyrZ7SnP OIBnhh3J8OZa2kH3EOFbc5hjrF0PncE= From: Fuad Tabba To: maz@kernel.org, oupton@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Cc: catalin.marinas@arm.com, will@kernel.org, rostedt@goodmis.org, mhiramat@kernel.org, alexandru.elisei@arm.com, vdonnefort@google.com, joey.gouly@arm.com, seiden@linux.ibm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, qperret@google.com, ardb@kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, tabba@google.com, fuad.tabba@linux.dev Subject: [PATCH v2 09/11] KVM: arm64: Type-check hypercall arguments at the caller Date: Mon, 3 Aug 2026 13:42:18 +0100 Message-Id: <20260803124220.332248-10-fuad.tabba@linux.dev> In-Reply-To: <20260803124220.332248-1-fuad.tabba@linux.dev> References: <20260803124220.332248-1-fuad.tabba@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" kvm_call_hyp_nvhe() reduces its target to an SMCCC function number, so the compiler never sees a callable: arguments that are wrong in number, type or order are silently marshalled into registers. The kvm_call_hyp() wrappers only catch this on the VHE branch, and the pKVM-only hypercalls have no such branch. Declare each hypercall's signature once in kvm_hcall.h and generate a typed stub from it, in the mold of the syscall wrappers. Make kvm_call_hyp_nvhe() resolve to the stub so every caller is checked against the declared signature; a stale or mistyped call now fails to compile. The stubs inline to the same SMCCC call the untyped macro used to make: the compiled callers are unchanged, apart from hypercall returns now being tested at their declared width. The stage-2 protection arguments are declared u64 rather than enum kvm_pgtable_prot, as kvm_pgtable.h includes linux/kvm_host.h and the enum cannot be completed here. Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Fuad Tabba --- arch/arm64/include/asm/kvm_hcall.h | 168 ++++++++++++++++++++++++++++- arch/arm64/kvm/hyp_trace.c | 2 +- 2 files changed, 168 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/kvm_hcall.h b/arch/arm64/include/asm/kv= m_hcall.h index d925b2c28a3d8..1c9c182ddcd1b 100644 --- a/arch/arm64/include/asm/kvm_hcall.h +++ b/arch/arm64/include/asm/kvm_hcall.h @@ -9,6 +9,7 @@ #ifndef __ARM64_KVM_HCALL_H__ #define __ARM64_KVM_HCALL_H__ =20 +#include #include #include #include @@ -16,12 +17,37 @@ =20 #include #include +#include #include =20 typedef u16 pkvm_handle_t; =20 +struct kvm; +struct kvm_s2_mmu; +struct kvm_vcpu; +struct vgic_v3_cpu_if; +struct vgic_v5_cpu_if; + +/* + * Hypercall signatures are declared as (type, name) argument pairs. + * __KVM_HCALL_MAP() applies a macro to each pair, in the mold of __MAP() + * in . The ladder is indexed by list entries, two per + * argument; __KVM_HCALL_MAP_N() takes that count explicitly. + */ +#define __KVM_HCALL_MAP2(m, t, a, ...) m(t, a) +#define __KVM_HCALL_MAP4(m, t, a, ...) m(t, a), __KVM_HCALL_MAP2(m, __VA_A= RGS__) +#define __KVM_HCALL_MAP6(m, t, a, ...) m(t, a), __KVM_HCALL_MAP4(m, __VA_A= RGS__) +#define __KVM_HCALL_MAP8(m, t, a, ...) m(t, a), __KVM_HCALL_MAP6(m, __VA_A= RGS__) +#define __KVM_HCALL_MAP10(m, t, a, ...) m(t, a), __KVM_HCALL_MAP8(m, __VA_= ARGS__) +#define __KVM_HCALL_MAP12(m, t, a, ...) m(t, a), __KVM_HCALL_MAP10(m, __VA= _ARGS__) +#define __KVM_HCALL_MAP_N(n, m, ...) CONCATENATE(__KVM_HCALL_MAP, n)(m, __= VA_ARGS__) +#define __KVM_HCALL_MAP(m, ...) __KVM_HCALL_MAP_N(COUNT_ARGS(__VA_ARGS__),= m, __VA_ARGS__) + +#define __KVM_HCALL_DECL(t, a) t a +#define __KVM_HCALL_ARGS(t, a) a + #ifndef __KVM_NVHE_HYPERVISOR__ -#define kvm_call_hyp_nvhe(f, ...) \ +#define __kvm_call_hyp_nvhe(f, ...) \ ({ \ struct arm_smccc_res res; \ \ @@ -33,6 +59,43 @@ typedef u16 pkvm_handle_t; res.a1; \ }) =20 +/* + * Generate a typed stub for each declared hypercall. kvm_call_hyp_nvhe() + * resolves to the stub, so a call with the wrong argument count or types + * fails to compile instead of being silently truncated to an SMCCC functi= on + * number and a pile of registers. The stub inlines to the same SMCCC call + * the untyped macro used to make. + */ +#define DECLARE_KVM_HOST_HCALL(ret, name, ...) \ + static __always_inline \ + ret nvhe_hvc_##name(__KVM_HCALL_MAP(__KVM_HCALL_DECL, __VA_ARGS__)) \ + { \ + return (ret)__kvm_call_hyp_nvhe(name, \ + __KVM_HCALL_MAP(__KVM_HCALL_ARGS, __VA_ARGS__));\ + } + +#define DECLARE_KVM_HOST_HCALL_VOID(name, ...) \ + static __always_inline \ + void nvhe_hvc_##name(__KVM_HCALL_MAP(__KVM_HCALL_DECL, __VA_ARGS__)) \ + { \ + __kvm_call_hyp_nvhe(name, \ + __KVM_HCALL_MAP(__KVM_HCALL_ARGS, __VA_ARGS__));\ + } + +#define DECLARE_KVM_HOST_HCALL0(ret, name) \ + static __always_inline ret nvhe_hvc_##name(void) \ + { \ + return (ret)__kvm_call_hyp_nvhe(name); \ + } + +#define DECLARE_KVM_HOST_HCALL0_VOID(name) \ + static __always_inline void nvhe_hvc_##name(void) \ + { \ + __kvm_call_hyp_nvhe(name); \ + } + +#define kvm_call_hyp_nvhe(f, ...) nvhe_hvc_##f(__VA_ARGS__) + /* * The isb() below is there to guarantee the same behaviour on VHE as on != VHE, * where the eret to EL1 acts as a context synchronization event. @@ -63,6 +126,109 @@ typedef u16 pkvm_handle_t; #define kvm_call_hyp(f, ...) f(__VA_ARGS__) #define kvm_call_hyp_ret(f, ...) f(__VA_ARGS__) #define kvm_call_hyp_nvhe(f, ...) f(__VA_ARGS__) + +#define DECLARE_KVM_HOST_HCALL(ret, name, ...) +#define DECLARE_KVM_HOST_HCALL_VOID(name, ...) +#define DECLARE_KVM_HOST_HCALL0(ret, name) +#define DECLARE_KVM_HOST_HCALL0_VOID(name) #endif /* __KVM_NVHE_HYPERVISOR__ */ =20 +/* Hypercalls that are unavailable once pKVM has finalised. */ +DECLARE_KVM_HOST_HCALL(int, __pkvm_init, + phys_addr_t, phys, unsigned long, size, + unsigned long *, per_cpu_base, u32, hyp_va_bits) +DECLARE_KVM_HOST_HCALL(unsigned long, __pkvm_create_private_mapping, + phys_addr_t, phys, size_t, size, u64, prot) +DECLARE_KVM_HOST_HCALL(int, __pkvm_cpu_set_vector, + enum arm64_hyp_spectre_vector, slot) +DECLARE_KVM_HOST_HCALL0_VOID(__kvm_enable_ssbs) +DECLARE_KVM_HOST_HCALL0_VOID(__vgic_v3_init_lrs) +DECLARE_KVM_HOST_HCALL0(u64, __vgic_v3_get_gic_config) + +DECLARE_KVM_HOST_HCALL0(int, __pkvm_prot_finalize) + +/* Hypercalls that are always available and common to [nh]VHE/pKVM. */ +DECLARE_KVM_HOST_HCALL_VOID(__kvm_adjust_pc, + struct kvm_vcpu *, vcpu) +DECLARE_KVM_HOST_HCALL(int, __kvm_vcpu_run, + struct kvm_vcpu *, vcpu) +DECLARE_KVM_HOST_HCALL0_VOID(__kvm_flush_vm_context) +DECLARE_KVM_HOST_HCALL_VOID(__kvm_tlb_flush_vmid_ipa, + struct kvm_s2_mmu *, mmu, phys_addr_t, ipa, int, level) +DECLARE_KVM_HOST_HCALL_VOID(__kvm_tlb_flush_vmid_ipa_nsh, + struct kvm_s2_mmu *, mmu, phys_addr_t, ipa, int, level) +DECLARE_KVM_HOST_HCALL_VOID(__kvm_tlb_flush_vmid, + struct kvm_s2_mmu *, mmu) +DECLARE_KVM_HOST_HCALL_VOID(__kvm_tlb_flush_vmid_range, + struct kvm_s2_mmu *, mmu, phys_addr_t, start, unsigned long, pages) +DECLARE_KVM_HOST_HCALL_VOID(__kvm_flush_cpu_context, + struct kvm_s2_mmu *, mmu) +DECLARE_KVM_HOST_HCALL_VOID(__kvm_timer_set_cntvoff, + u64, cntvoff) +DECLARE_KVM_HOST_HCALL(int, __tracing_load, + void *, desc_hva, size_t, desc_size) +DECLARE_KVM_HOST_HCALL0_VOID(__tracing_unload) +DECLARE_KVM_HOST_HCALL(int, __tracing_enable, + bool, enable) +DECLARE_KVM_HOST_HCALL(int, __tracing_swap_reader, + unsigned int, cpu) +DECLARE_KVM_HOST_HCALL_VOID(__tracing_update_clock, + u32, mult, u32, shift, u64, epoch_ns, u64, epoch_cyc) +DECLARE_KVM_HOST_HCALL(int, __tracing_reset, + unsigned int, cpu) +DECLARE_KVM_HOST_HCALL(int, __tracing_enable_event, + unsigned short, id, bool, enable) +DECLARE_KVM_HOST_HCALL_VOID(__tracing_write_event, + u64, id) +DECLARE_KVM_HOST_HCALL_VOID(__vgic_v3_save_aprs, + struct vgic_v3_cpu_if *, cpu_if) +DECLARE_KVM_HOST_HCALL_VOID(__vgic_v3_restore_vmcr_aprs, + struct vgic_v3_cpu_if *, cpu_if) +DECLARE_KVM_HOST_HCALL_VOID(__vgic_v5_save_apr, + struct vgic_v5_cpu_if *, cpu_if) +DECLARE_KVM_HOST_HCALL_VOID(__vgic_v5_restore_vmcr_apr, + struct vgic_v5_cpu_if *, cpu_if) + +/* Hypercalls that are available only when pKVM has finalised. */ +DECLARE_KVM_HOST_HCALL(int, __pkvm_host_share_hyp, + u64, pfn) +DECLARE_KVM_HOST_HCALL(int, __pkvm_host_unshare_hyp, + u64, pfn) +DECLARE_KVM_HOST_HCALL(int, __pkvm_host_donate_guest, + u64, pfn, u64, gfn) +DECLARE_KVM_HOST_HCALL(int, __pkvm_host_share_guest, + u64, pfn, u64, gfn, u64, nr_pages, u64, prot) +DECLARE_KVM_HOST_HCALL(int, __pkvm_host_unshare_guest, + pkvm_handle_t, handle, u64, gfn, u64, nr_pages) +DECLARE_KVM_HOST_HCALL(int, __pkvm_host_relax_perms_guest, + u64, gfn, u64, prot) +DECLARE_KVM_HOST_HCALL(int, __pkvm_host_wrprotect_guest, + pkvm_handle_t, handle, u64, gfn, u64, nr_pages) +DECLARE_KVM_HOST_HCALL(int, __pkvm_host_test_clear_young_guest, + pkvm_handle_t, handle, u64, gfn, u64, nr_pages, bool, mkold) +DECLARE_KVM_HOST_HCALL(int, __pkvm_host_mkyoung_guest, + u64, gfn) +DECLARE_KVM_HOST_HCALL0(int, __pkvm_reserve_vm) +DECLARE_KVM_HOST_HCALL_VOID(__pkvm_unreserve_vm, + pkvm_handle_t, handle) +DECLARE_KVM_HOST_HCALL(int, __pkvm_init_vm, + struct kvm *, host_kvm, void *, vm_hva, void *, pgd_hva) +DECLARE_KVM_HOST_HCALL(int, __pkvm_init_vcpu, + pkvm_handle_t, handle, struct kvm_vcpu *, host_vcpu, + void *, vcpu_hva) +DECLARE_KVM_HOST_HCALL0(int, __pkvm_vcpu_in_poison_fault) +DECLARE_KVM_HOST_HCALL(int, __pkvm_force_reclaim_guest_page, + phys_addr_t, phys) +DECLARE_KVM_HOST_HCALL(int, __pkvm_reclaim_dying_guest_page, + pkvm_handle_t, handle, u64, gfn) +DECLARE_KVM_HOST_HCALL(int, __pkvm_start_teardown_vm, + pkvm_handle_t, handle) +DECLARE_KVM_HOST_HCALL(int, __pkvm_finalize_teardown_vm, + pkvm_handle_t, handle) +DECLARE_KVM_HOST_HCALL_VOID(__pkvm_vcpu_load, + pkvm_handle_t, handle, unsigned int, vcpu_idx, u64, hcr_el2) +DECLARE_KVM_HOST_HCALL0_VOID(__pkvm_vcpu_put) +DECLARE_KVM_HOST_HCALL_VOID(__pkvm_tlb_flush_vmid, + pkvm_handle_t, handle) + #endif /* __ARM64_KVM_HCALL_H__ */ diff --git a/arch/arm64/kvm/hyp_trace.c b/arch/arm64/kvm/hyp_trace.c index 9644c424819b7..44937e257375a 100644 --- a/arch/arm64/kvm/hyp_trace.c +++ b/arch/arm64/kvm/hyp_trace.c @@ -269,7 +269,7 @@ static struct trace_buffer_desc *hyp_trace_load(unsigne= d long size, void *priv) if (ret) goto err_free_buffer; =20 - ret =3D kvm_call_hyp_nvhe(__tracing_load, (unsigned long)desc, desc_size); + ret =3D kvm_call_hyp_nvhe(__tracing_load, desc, desc_size); if (ret) goto err_unload_pages; =20 --=20 2.39.5 From nobody Fri Oct 2 08:24:49 2026 Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3F5740801D for ; Mon, 3 Aug 2026 12:43:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785761018; cv=none; b=Rav6ahv6gumod5UmxfY8kcgeMjngJCL0cxpFlGC+UtpUDU86pDKoigpI1xPXISlAHQsObfvbySnXiu89FUS3uVsjOGQGYsLpRAvG4Syf7FC8fBVQueqhn0PxPfECdUHYG9D15RbI46qJdRs5EwJXurG8zWOWaumoNqq05+pEHgM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785761018; c=relaxed/simple; bh=p9y8PVofVqsMh8E6AECWqBeJZzD1r/lavSy+xrxYBTI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OQoE4Y+xUJeLNQNl4O1RNd1B1HTxkQhw9fvzJkt25QxlDAjUS2ncHutSWfyYQvkhz9O+qWk+HU8WouI06oCnEkTF6FmAesva69+tKaQOON01EnXHzSVuK1eogNfv7vn39k2jQN9U0eo8l3o1RARdJaPPOlPNKmxjBMZVDb5cBtA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=wv4PyifF; arc=none smtp.client-ip=91.218.175.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="wv4PyifF" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1785761013; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zK1+mNJJDDQzuV7pWTTW33lVLo+EX2p+ZTSBdvKD6hk=; b=wv4PyifFRzaC48a0d0DniJbheZ74mJGYguEcKFFwngvwldRGUF/FCVPM3kulX3HH+Zjg4T 049HOh+X2dPZb3pqKtD7tC+O9v4u6hKIXPvLWz/e3/yMDAR+TPeU6nnnRsRsPtVCpc7mkg zfnvtjMo7cn6a5Tt9/0nr520uBnWeo0= From: Fuad Tabba To: maz@kernel.org, oupton@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Cc: catalin.marinas@arm.com, will@kernel.org, rostedt@goodmis.org, mhiramat@kernel.org, alexandru.elisei@arm.com, vdonnefort@google.com, joey.gouly@arm.com, seiden@linux.ibm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, qperret@google.com, ardb@kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, tabba@google.com, fuad.tabba@linux.dev Subject: [PATCH v2 10/11] KVM: arm64: nVHE: Check hypercall handlers against the declared ABI Date: Mon, 3 Aug 2026 13:42:19 +0100 Message-Id: <20260803124220.332248-11-fuad.tabba@linux.dev> In-Reply-To: <20260803124220.332248-1-fuad.tabba@linux.dev> References: <20260803124220.332248-1-fuad.tabba@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Each hypercall handler unmarshals its arguments from the host context with hand-written DECLARE_REG() casts that nothing ties to what the caller passed: a handler can disagree with its caller in argument type, count or register index without a diagnostic. Generate the unmarshalling instead. DEFINE_KVM_HOST_HCALL() expands to the handle_() glue, modelled on the syscall wrappers, and checks the handler's parameter list against the signature declared in kvm_hcall.h, so both ends of every hypercall are now compiled against the same declaration. Handler bodies keep their logic and lose the DECLARE_REG() and return-register boilerplate. The compiled handlers are instruction-for-instruction identical, apart from flush_hyp_vcpu() and sync_hyp_vcpu() now being inlined into their only caller. Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Fuad Tabba --- arch/arm64/include/asm/kvm_hcall.h | 19 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 421 ++++++++++++++--------------- 2 files changed, 214 insertions(+), 226 deletions(-) diff --git a/arch/arm64/include/asm/kvm_hcall.h b/arch/arm64/include/asm/kv= m_hcall.h index 1c9c182ddcd1b..39374bae4bea4 100644 --- a/arch/arm64/include/asm/kvm_hcall.h +++ b/arch/arm64/include/asm/kvm_hcall.h @@ -44,6 +44,8 @@ struct vgic_v5_cpu_if; #define __KVM_HCALL_MAP(m, ...) __KVM_HCALL_MAP_N(COUNT_ARGS(__VA_ARGS__),= m, __VA_ARGS__) =20 #define __KVM_HCALL_DECL(t, a) t a +#define __KVM_HCALL_LONG(t, a) unsigned long a +#define __KVM_HCALL_CAST(t, a) (__force t) a #define __KVM_HCALL_ARGS(t, a) a =20 #ifndef __KVM_NVHE_HYPERVISOR__ @@ -127,10 +129,19 @@ struct vgic_v5_cpu_if; #define kvm_call_hyp_ret(f, ...) f(__VA_ARGS__) #define kvm_call_hyp_nvhe(f, ...) f(__VA_ARGS__) =20 -#define DECLARE_KVM_HOST_HCALL(ret, name, ...) -#define DECLARE_KVM_HOST_HCALL_VOID(name, ...) -#define DECLARE_KVM_HOST_HCALL0(ret, name) -#define DECLARE_KVM_HOST_HCALL0_VOID(name) +/* + * At EL2 each declaration emits the canonical signature of the hypercall, + * which DEFINE_KVM_HOST_HCALL() in hyp-main.c checks the handler + * definition against. + */ +#define DECLARE_KVM_HOST_HCALL(ret, name, ...) \ + typedef ret kvm_host_hcall_sig_##name(__KVM_HCALL_MAP(__KVM_HCALL_DECL, _= _VA_ARGS__)); +#define DECLARE_KVM_HOST_HCALL_VOID(name, ...) \ + typedef void kvm_host_hcall_sig_##name(__KVM_HCALL_MAP(__KVM_HCALL_DECL, = __VA_ARGS__)); +#define DECLARE_KVM_HOST_HCALL0(ret, name) \ + typedef ret kvm_host_hcall_sig_##name(void); +#define DECLARE_KVM_HOST_HCALL0_VOID(name) \ + typedef void kvm_host_hcall_sig_##name(void); #endif /* __KVM_NVHE_HYPERVISOR__ */ =20 /* Hypercalls that are unavailable once pKVM has finalised. */ diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/h= yp-main.c index 23cb4313c60a2..6986ce55fd9ef 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c @@ -24,6 +24,63 @@ =20 DEFINE_PER_CPU(struct kvm_nvhe_init_params, kvm_init_params); =20 +/* + * Define a hypercall handler: handle_ unmarshals the arguments from + * the host context and hands them, correctly typed, to the body that + * follows the macro. The parameter list is type-checked against the + * signature declared in , so the handler cannot drift + * from what the typed caller stubs marshal in. Modelled on the syscall + * wrappers. + */ +/* Truncate the fixed list of argument registers to the declared signature= . */ +#define KVM_HOST_HCALL_REGS(...) \ + __KVM_HCALL_MAP_N(COUNT_ARGS(__VA_ARGS__), __KVM_HCALL_ARGS \ + ,, cpu_reg(host_ctxt, 1),, cpu_reg(host_ctxt, 2) \ + ,, cpu_reg(host_ctxt, 3),, cpu_reg(host_ctxt, 4) \ + ,, cpu_reg(host_ctxt, 5),, cpu_reg(host_ctxt, 6)) + +#define DEFINE_KVM_HOST_HCALL(ret, name, ...) \ + static kvm_host_hcall_sig_##name __do_##name; \ + static __always_inline \ + ret __se_##name(__KVM_HCALL_MAP(__KVM_HCALL_LONG, __VA_ARGS__)) \ + { \ + return __do_##name(__KVM_HCALL_MAP(__KVM_HCALL_CAST, __VA_ARGS__)); \ + } \ + static void handle_##name(struct kvm_cpu_context *host_ctxt) \ + { \ + cpu_reg(host_ctxt, 1) =3D __se_##name(KVM_HOST_HCALL_REGS(__VA_ARGS__));= \ + } \ + static ret __do_##name(__KVM_HCALL_MAP(__KVM_HCALL_DECL, __VA_ARGS__)) + +#define DEFINE_KVM_HOST_HCALL_VOID(name, ...) \ + static kvm_host_hcall_sig_##name __do_##name; \ + static __always_inline \ + void __se_##name(__KVM_HCALL_MAP(__KVM_HCALL_LONG, __VA_ARGS__)) \ + { \ + __do_##name(__KVM_HCALL_MAP(__KVM_HCALL_CAST, __VA_ARGS__)); \ + } \ + static void handle_##name(struct kvm_cpu_context *host_ctxt) \ + { \ + __se_##name(KVM_HOST_HCALL_REGS(__VA_ARGS__)); \ + } \ + static void __do_##name(__KVM_HCALL_MAP(__KVM_HCALL_DECL, __VA_ARGS__)) + +#define DEFINE_KVM_HOST_HCALL0(ret, name) \ + static kvm_host_hcall_sig_##name __do_##name; \ + static void handle_##name(struct kvm_cpu_context *host_ctxt) \ + { \ + cpu_reg(host_ctxt, 1) =3D __do_##name(); \ + } \ + static ret __do_##name(void) + +#define DEFINE_KVM_HOST_HCALL0_VOID(name) \ + static kvm_host_hcall_sig_##name __do_##name; \ + static void handle_##name(struct kvm_cpu_context *host_ctxt) \ + { \ + __do_##name(); \ + } \ + static void __do_##name(void) + /* Number of implemented GICv3 LRs. Used by flush_hyp_vcpu(). */ unsigned int hyp_gicv3_nr_lr; =20 @@ -185,11 +242,9 @@ static void sync_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_vc= pu) host_cpu_if->vgic_lr[i] =3D hyp_cpu_if->vgic_lr[i]; } =20 -static void handle___pkvm_vcpu_load(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL_VOID(__pkvm_vcpu_load, + pkvm_handle_t, handle, unsigned int, vcpu_idx, u64, hcr_el2) { - DECLARE_REG(pkvm_handle_t, handle, host_ctxt, 1); - DECLARE_REG(unsigned int, vcpu_idx, host_ctxt, 2); - DECLARE_REG(u64, hcr_el2, host_ctxt, 3); struct pkvm_hyp_vcpu *hyp_vcpu; =20 hyp_vcpu =3D pkvm_load_hyp_vcpu(handle, vcpu_idx); @@ -206,7 +261,7 @@ static void handle___pkvm_vcpu_load(struct kvm_cpu_cont= ext *host_ctxt) } } =20 -static void handle___pkvm_vcpu_put(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL0_VOID(__pkvm_vcpu_put) { struct pkvm_hyp_vcpu *hyp_vcpu =3D pkvm_get_loaded_hyp_vcpu(); =20 @@ -214,9 +269,9 @@ static void handle___pkvm_vcpu_put(struct kvm_cpu_conte= xt *host_ctxt) pkvm_put_hyp_vcpu(hyp_vcpu); } =20 -static void handle___kvm_vcpu_run(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL(int, __kvm_vcpu_run, + struct kvm_vcpu *, host_vcpu) { - DECLARE_REG(struct kvm_vcpu *, host_vcpu, host_ctxt, 1); int ret; =20 if (unlikely(is_protected_kvm_enabled())) { @@ -228,15 +283,11 @@ static void handle___kvm_vcpu_run(struct kvm_cpu_cont= ext *host_ctxt) * loading a vcpu. Therefore, if SME features enabled the host * is misbehaving. */ - if (unlikely(system_supports_sme() && read_sysreg_s(SYS_SVCR))) { - ret =3D -EINVAL; - goto out; - } + if (unlikely(system_supports_sme() && read_sysreg_s(SYS_SVCR))) + return -EINVAL; =20 - if (!hyp_vcpu) { - ret =3D -EINVAL; - goto out; - } + if (!hyp_vcpu) + return -EINVAL; =20 flush_hyp_vcpu(hyp_vcpu); =20 @@ -251,8 +302,8 @@ static void handle___kvm_vcpu_run(struct kvm_cpu_contex= t *host_ctxt) ret =3D __kvm_vcpu_run(vcpu); fpsimd_lazy_switch_to_host(vcpu); } -out: - cpu_reg(host_ctxt, 1) =3D ret; + + return ret; } =20 static int pkvm_refill_memcache(struct pkvm_hyp_vcpu *hyp_vcpu) @@ -264,184 +315,150 @@ static int pkvm_refill_memcache(struct pkvm_hyp_vcp= u *hyp_vcpu) &host_vcpu->arch.pkvm_memcache); } =20 -static void handle___pkvm_host_donate_guest(struct kvm_cpu_context *host_c= txt) +DEFINE_KVM_HOST_HCALL(int, __pkvm_host_donate_guest, + u64, pfn, u64, gfn) { - DECLARE_REG(u64, pfn, host_ctxt, 1); - DECLARE_REG(u64, gfn, host_ctxt, 2); struct pkvm_hyp_vcpu *hyp_vcpu; - int ret =3D -EINVAL; + int ret; =20 hyp_vcpu =3D pkvm_get_loaded_hyp_vcpu(); if (!hyp_vcpu || !pkvm_hyp_vcpu_is_protected(hyp_vcpu)) - goto out; + return -EINVAL; =20 ret =3D pkvm_refill_memcache(hyp_vcpu); if (ret) - goto out; + return ret; =20 - ret =3D __pkvm_host_donate_guest(pfn, gfn, hyp_vcpu); -out: - cpu_reg(host_ctxt, 1) =3D ret; + return __pkvm_host_donate_guest(pfn, gfn, hyp_vcpu); } =20 -static void handle___pkvm_host_share_guest(struct kvm_cpu_context *host_ct= xt) +DEFINE_KVM_HOST_HCALL(int, __pkvm_host_share_guest, + u64, pfn, u64, gfn, u64, nr_pages, u64, prot) { - DECLARE_REG(u64, pfn, host_ctxt, 1); - DECLARE_REG(u64, gfn, host_ctxt, 2); - DECLARE_REG(u64, nr_pages, host_ctxt, 3); - DECLARE_REG(enum kvm_pgtable_prot, prot, host_ctxt, 4); struct pkvm_hyp_vcpu *hyp_vcpu; - int ret =3D -EINVAL; + int ret; =20 hyp_vcpu =3D pkvm_get_loaded_hyp_vcpu(); if (!hyp_vcpu || pkvm_hyp_vcpu_is_protected(hyp_vcpu)) - goto out; + return -EINVAL; =20 ret =3D pkvm_refill_memcache(hyp_vcpu); if (ret) - goto out; + return ret; =20 - ret =3D __pkvm_host_share_guest(pfn, gfn, nr_pages, hyp_vcpu, prot); -out: - cpu_reg(host_ctxt, 1) =3D ret; + return __pkvm_host_share_guest(pfn, gfn, nr_pages, hyp_vcpu, prot); } =20 -static void handle___pkvm_host_unshare_guest(struct kvm_cpu_context *host_= ctxt) +DEFINE_KVM_HOST_HCALL(int, __pkvm_host_unshare_guest, + pkvm_handle_t, handle, u64, gfn, u64, nr_pages) { - DECLARE_REG(pkvm_handle_t, handle, host_ctxt, 1); - DECLARE_REG(u64, gfn, host_ctxt, 2); - DECLARE_REG(u64, nr_pages, host_ctxt, 3); struct pkvm_hyp_vm *hyp_vm; - int ret =3D -EINVAL; + int ret; =20 hyp_vm =3D get_np_pkvm_hyp_vm(handle); if (!hyp_vm) - goto out; + return -EINVAL; =20 ret =3D __pkvm_host_unshare_guest(gfn, nr_pages, hyp_vm); put_pkvm_hyp_vm(hyp_vm); -out: - cpu_reg(host_ctxt, 1) =3D ret; + + return ret; } =20 -static void handle___pkvm_host_relax_perms_guest(struct kvm_cpu_context *h= ost_ctxt) +DEFINE_KVM_HOST_HCALL(int, __pkvm_host_relax_perms_guest, + u64, gfn, u64, prot) { - DECLARE_REG(u64, gfn, host_ctxt, 1); - DECLARE_REG(enum kvm_pgtable_prot, prot, host_ctxt, 2); struct pkvm_hyp_vcpu *hyp_vcpu; - int ret =3D -EINVAL; =20 hyp_vcpu =3D pkvm_get_loaded_hyp_vcpu(); if (!hyp_vcpu || pkvm_hyp_vcpu_is_protected(hyp_vcpu)) - goto out; + return -EINVAL; =20 - ret =3D __pkvm_host_relax_perms_guest(gfn, hyp_vcpu, prot); -out: - cpu_reg(host_ctxt, 1) =3D ret; + return __pkvm_host_relax_perms_guest(gfn, hyp_vcpu, prot); } =20 -static void handle___pkvm_host_wrprotect_guest(struct kvm_cpu_context *hos= t_ctxt) +DEFINE_KVM_HOST_HCALL(int, __pkvm_host_wrprotect_guest, + pkvm_handle_t, handle, u64, gfn, u64, nr_pages) { - DECLARE_REG(pkvm_handle_t, handle, host_ctxt, 1); - DECLARE_REG(u64, gfn, host_ctxt, 2); - DECLARE_REG(u64, nr_pages, host_ctxt, 3); struct pkvm_hyp_vm *hyp_vm; - int ret =3D -EINVAL; + int ret; =20 hyp_vm =3D get_np_pkvm_hyp_vm(handle); if (!hyp_vm) - goto out; + return -EINVAL; =20 ret =3D __pkvm_host_wrprotect_guest(gfn, nr_pages, hyp_vm); put_pkvm_hyp_vm(hyp_vm); -out: - cpu_reg(host_ctxt, 1) =3D ret; + + return ret; } =20 -static void handle___pkvm_host_test_clear_young_guest(struct kvm_cpu_conte= xt *host_ctxt) +DEFINE_KVM_HOST_HCALL(int, __pkvm_host_test_clear_young_guest, + pkvm_handle_t, handle, u64, gfn, u64, nr_pages, bool, mkold) { - DECLARE_REG(pkvm_handle_t, handle, host_ctxt, 1); - DECLARE_REG(u64, gfn, host_ctxt, 2); - DECLARE_REG(u64, nr_pages, host_ctxt, 3); - DECLARE_REG(bool, mkold, host_ctxt, 4); struct pkvm_hyp_vm *hyp_vm; - int ret =3D -EINVAL; + int ret; =20 hyp_vm =3D get_np_pkvm_hyp_vm(handle); if (!hyp_vm) - goto out; + return -EINVAL; =20 ret =3D __pkvm_host_test_clear_young_guest(gfn, nr_pages, mkold, hyp_vm); put_pkvm_hyp_vm(hyp_vm); -out: - cpu_reg(host_ctxt, 1) =3D ret; + + return ret; } =20 -static void handle___pkvm_host_mkyoung_guest(struct kvm_cpu_context *host_= ctxt) +DEFINE_KVM_HOST_HCALL(int, __pkvm_host_mkyoung_guest, + u64, gfn) { - DECLARE_REG(u64, gfn, host_ctxt, 1); struct pkvm_hyp_vcpu *hyp_vcpu; - int ret =3D -EINVAL; =20 hyp_vcpu =3D pkvm_get_loaded_hyp_vcpu(); if (!hyp_vcpu || pkvm_hyp_vcpu_is_protected(hyp_vcpu)) - goto out; + return -EINVAL; =20 - ret =3D __pkvm_host_mkyoung_guest(gfn, hyp_vcpu); -out: - cpu_reg(host_ctxt, 1) =3D ret; + return __pkvm_host_mkyoung_guest(gfn, hyp_vcpu); } =20 -static void handle___kvm_adjust_pc(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL_VOID(__kvm_adjust_pc, + struct kvm_vcpu *, vcpu) { - DECLARE_REG(struct kvm_vcpu *, vcpu, host_ctxt, 1); - __kvm_adjust_pc(kern_hyp_va(vcpu)); } =20 -static void handle___kvm_flush_vm_context(struct kvm_cpu_context *host_ctx= t) +DEFINE_KVM_HOST_HCALL0_VOID(__kvm_flush_vm_context) { __kvm_flush_vm_context(); } =20 -static void handle___kvm_tlb_flush_vmid_ipa(struct kvm_cpu_context *host_c= txt) +DEFINE_KVM_HOST_HCALL_VOID(__kvm_tlb_flush_vmid_ipa, + struct kvm_s2_mmu *, mmu, phys_addr_t, ipa, int, level) { - DECLARE_REG(struct kvm_s2_mmu *, mmu, host_ctxt, 1); - DECLARE_REG(phys_addr_t, ipa, host_ctxt, 2); - DECLARE_REG(int, level, host_ctxt, 3); - __kvm_tlb_flush_vmid_ipa(kern_hyp_va(mmu), ipa, level); } =20 -static void handle___kvm_tlb_flush_vmid_ipa_nsh(struct kvm_cpu_context *ho= st_ctxt) +DEFINE_KVM_HOST_HCALL_VOID(__kvm_tlb_flush_vmid_ipa_nsh, + struct kvm_s2_mmu *, mmu, phys_addr_t, ipa, int, level) { - DECLARE_REG(struct kvm_s2_mmu *, mmu, host_ctxt, 1); - DECLARE_REG(phys_addr_t, ipa, host_ctxt, 2); - DECLARE_REG(int, level, host_ctxt, 3); - __kvm_tlb_flush_vmid_ipa_nsh(kern_hyp_va(mmu), ipa, level); } =20 -static void -handle___kvm_tlb_flush_vmid_range(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL_VOID(__kvm_tlb_flush_vmid_range, + struct kvm_s2_mmu *, mmu, phys_addr_t, start, unsigned long, pages) { - DECLARE_REG(struct kvm_s2_mmu *, mmu, host_ctxt, 1); - DECLARE_REG(phys_addr_t, start, host_ctxt, 2); - DECLARE_REG(unsigned long, pages, host_ctxt, 3); - __kvm_tlb_flush_vmid_range(kern_hyp_va(mmu), start, pages); } =20 -static void handle___kvm_tlb_flush_vmid(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL_VOID(__kvm_tlb_flush_vmid, + struct kvm_s2_mmu *, mmu) { - DECLARE_REG(struct kvm_s2_mmu *, mmu, host_ctxt, 1); - __kvm_tlb_flush_vmid(kern_hyp_va(mmu)); } =20 -static void handle___pkvm_tlb_flush_vmid(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL_VOID(__pkvm_tlb_flush_vmid, + pkvm_handle_t, handle) { - DECLARE_REG(pkvm_handle_t, handle, host_ctxt, 1); struct pkvm_hyp_vm *hyp_vm =3D get_np_pkvm_hyp_vm(handle); =20 if (!hyp_vm) @@ -451,19 +468,19 @@ static void handle___pkvm_tlb_flush_vmid(struct kvm_c= pu_context *host_ctxt) put_pkvm_hyp_vm(hyp_vm); } =20 -static void handle___kvm_flush_cpu_context(struct kvm_cpu_context *host_ct= xt) +DEFINE_KVM_HOST_HCALL_VOID(__kvm_flush_cpu_context, + struct kvm_s2_mmu *, mmu) { - DECLARE_REG(struct kvm_s2_mmu *, mmu, host_ctxt, 1); - __kvm_flush_cpu_context(kern_hyp_va(mmu)); } =20 -static void handle___kvm_timer_set_cntvoff(struct kvm_cpu_context *host_ct= xt) +DEFINE_KVM_HOST_HCALL_VOID(__kvm_timer_set_cntvoff, + u64, cntvoff) { - __kvm_timer_set_cntvoff(cpu_reg(host_ctxt, 1)); + __kvm_timer_set_cntvoff(cntvoff); } =20 -static void handle___kvm_enable_ssbs(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL0_VOID(__kvm_enable_ssbs) { u64 tmp; =20 @@ -472,72 +489,61 @@ static void handle___kvm_enable_ssbs(struct kvm_cpu_c= ontext *host_ctxt) write_sysreg_el2(tmp, SYS_SCTLR); } =20 -static void handle___vgic_v3_get_gic_config(struct kvm_cpu_context *host_c= txt) +DEFINE_KVM_HOST_HCALL0(u64, __vgic_v3_get_gic_config) { - cpu_reg(host_ctxt, 1) =3D __vgic_v3_get_gic_config(); + return __vgic_v3_get_gic_config(); } =20 -static void handle___vgic_v3_init_lrs(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL0_VOID(__vgic_v3_init_lrs) { __vgic_v3_init_lrs(); } =20 -static void handle___vgic_v3_save_aprs(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL_VOID(__vgic_v3_save_aprs, + struct vgic_v3_cpu_if *, cpu_if) { - DECLARE_REG(struct vgic_v3_cpu_if *, cpu_if, host_ctxt, 1); - __vgic_v3_save_aprs(kern_hyp_va(cpu_if)); } =20 -static void handle___vgic_v3_restore_vmcr_aprs(struct kvm_cpu_context *hos= t_ctxt) +DEFINE_KVM_HOST_HCALL_VOID(__vgic_v3_restore_vmcr_aprs, + struct vgic_v3_cpu_if *, cpu_if) { - DECLARE_REG(struct vgic_v3_cpu_if *, cpu_if, host_ctxt, 1); - __vgic_v3_restore_vmcr_aprs(kern_hyp_va(cpu_if)); } =20 -static void handle___pkvm_init(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL(int, __pkvm_init, + phys_addr_t, phys, unsigned long, size, + unsigned long *, per_cpu_base, u32, hyp_va_bits) { - DECLARE_REG(phys_addr_t, phys, host_ctxt, 1); - DECLARE_REG(unsigned long, size, host_ctxt, 2); - DECLARE_REG(unsigned long *, per_cpu_base, host_ctxt, 3); - DECLARE_REG(u32, hyp_va_bits, host_ctxt, 4); - /* * __pkvm_init() will return only if an error occurred, otherwise it * will tail-call in __pkvm_init_finalise() which will have to deal * with the host context directly. */ - cpu_reg(host_ctxt, 1) =3D __pkvm_init(phys, size, per_cpu_base, hyp_va_bi= ts); + return __pkvm_init(phys, size, per_cpu_base, hyp_va_bits); } =20 -static void handle___pkvm_cpu_set_vector(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL(int, __pkvm_cpu_set_vector, + enum arm64_hyp_spectre_vector, slot) { - DECLARE_REG(enum arm64_hyp_spectre_vector, slot, host_ctxt, 1); - - cpu_reg(host_ctxt, 1) =3D pkvm_cpu_set_vector(slot); + return pkvm_cpu_set_vector(slot); } =20 -static void handle___pkvm_host_share_hyp(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL(int, __pkvm_host_share_hyp, + u64, pfn) { - DECLARE_REG(u64, pfn, host_ctxt, 1); - - cpu_reg(host_ctxt, 1) =3D __pkvm_host_share_hyp(pfn); + return __pkvm_host_share_hyp(pfn); } =20 -static void handle___pkvm_host_unshare_hyp(struct kvm_cpu_context *host_ct= xt) +DEFINE_KVM_HOST_HCALL(int, __pkvm_host_unshare_hyp, + u64, pfn) { - DECLARE_REG(u64, pfn, host_ctxt, 1); - - cpu_reg(host_ctxt, 1) =3D __pkvm_host_unshare_hyp(pfn); + return __pkvm_host_unshare_hyp(pfn); } =20 -static void handle___pkvm_create_private_mapping(struct kvm_cpu_context *h= ost_ctxt) +DEFINE_KVM_HOST_HCALL(unsigned long, __pkvm_create_private_mapping, + phys_addr_t, phys, size_t, size, u64, prot) { - DECLARE_REG(phys_addr_t, phys, host_ctxt, 1); - DECLARE_REG(size_t, size, host_ctxt, 2); - DECLARE_REG(enum kvm_pgtable_prot, prot, host_ctxt, 3); - /* * __pkvm_create_private_mapping() populates a pointer with the * hypervisor start address of the allocation. @@ -554,154 +560,125 @@ static void handle___pkvm_create_private_mapping(st= ruct kvm_cpu_context *host_ct if (err) haddr =3D (unsigned long)ERR_PTR(err); =20 - cpu_reg(host_ctxt, 1) =3D haddr; + return haddr; } =20 -static void handle___pkvm_prot_finalize(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL0(int, __pkvm_prot_finalize) { - cpu_reg(host_ctxt, 1) =3D __pkvm_prot_finalize(); + return __pkvm_prot_finalize(); } =20 -static void handle___pkvm_reserve_vm(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL0(int, __pkvm_reserve_vm) { - cpu_reg(host_ctxt, 1) =3D __pkvm_reserve_vm(); + return __pkvm_reserve_vm(); } =20 -static void handle___pkvm_unreserve_vm(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL_VOID(__pkvm_unreserve_vm, + pkvm_handle_t, handle) { - DECLARE_REG(pkvm_handle_t, handle, host_ctxt, 1); - __pkvm_unreserve_vm(handle); } =20 -static void handle___pkvm_init_vm(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL(int, __pkvm_init_vm, + struct kvm *, host_kvm, void *, vm_hva, void *, pgd_hva) { - DECLARE_REG(struct kvm *, host_kvm, host_ctxt, 1); - DECLARE_REG(void *, vm_hva, host_ctxt, 2); - DECLARE_REG(void *, pgd_hva, host_ctxt, 3); - - host_kvm =3D kern_hyp_va(host_kvm); - cpu_reg(host_ctxt, 1) =3D __pkvm_init_vm(host_kvm, vm_hva, pgd_hva); + return __pkvm_init_vm(kern_hyp_va(host_kvm), vm_hva, pgd_hva); } =20 -static void handle___pkvm_init_vcpu(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL(int, __pkvm_init_vcpu, + pkvm_handle_t, handle, struct kvm_vcpu *, host_vcpu, + void *, vcpu_hva) { - DECLARE_REG(pkvm_handle_t, handle, host_ctxt, 1); - DECLARE_REG(struct kvm_vcpu *, host_vcpu, host_ctxt, 2); - DECLARE_REG(void *, vcpu_hva, host_ctxt, 3); - - host_vcpu =3D kern_hyp_va(host_vcpu); - cpu_reg(host_ctxt, 1) =3D __pkvm_init_vcpu(handle, host_vcpu, vcpu_hva); + return __pkvm_init_vcpu(handle, kern_hyp_va(host_vcpu), vcpu_hva); } =20 -static void handle___pkvm_vcpu_in_poison_fault(struct kvm_cpu_context *hos= t_ctxt) +DEFINE_KVM_HOST_HCALL0(int, __pkvm_vcpu_in_poison_fault) { - int ret; struct pkvm_hyp_vcpu *hyp_vcpu =3D pkvm_get_loaded_hyp_vcpu(); =20 - ret =3D hyp_vcpu ? __pkvm_vcpu_in_poison_fault(hyp_vcpu) : -EINVAL; - cpu_reg(host_ctxt, 1) =3D ret; + return hyp_vcpu ? __pkvm_vcpu_in_poison_fault(hyp_vcpu) : -EINVAL; } =20 -static void handle___pkvm_force_reclaim_guest_page(struct kvm_cpu_context = *host_ctxt) +DEFINE_KVM_HOST_HCALL(int, __pkvm_force_reclaim_guest_page, + phys_addr_t, phys) { - DECLARE_REG(phys_addr_t, phys, host_ctxt, 1); - - cpu_reg(host_ctxt, 1) =3D __pkvm_host_force_reclaim_page_guest(phys); + return __pkvm_host_force_reclaim_page_guest(phys); } =20 -static void handle___pkvm_reclaim_dying_guest_page(struct kvm_cpu_context = *host_ctxt) +DEFINE_KVM_HOST_HCALL(int, __pkvm_reclaim_dying_guest_page, + pkvm_handle_t, handle, u64, gfn) { - DECLARE_REG(pkvm_handle_t, handle, host_ctxt, 1); - DECLARE_REG(u64, gfn, host_ctxt, 2); - - cpu_reg(host_ctxt, 1) =3D __pkvm_reclaim_dying_guest_page(handle, gfn); + return __pkvm_reclaim_dying_guest_page(handle, gfn); } =20 -static void handle___pkvm_start_teardown_vm(struct kvm_cpu_context *host_c= txt) +DEFINE_KVM_HOST_HCALL(int, __pkvm_start_teardown_vm, + pkvm_handle_t, handle) { - DECLARE_REG(pkvm_handle_t, handle, host_ctxt, 1); - - cpu_reg(host_ctxt, 1) =3D __pkvm_start_teardown_vm(handle); + return __pkvm_start_teardown_vm(handle); } =20 -static void handle___pkvm_finalize_teardown_vm(struct kvm_cpu_context *hos= t_ctxt) +DEFINE_KVM_HOST_HCALL(int, __pkvm_finalize_teardown_vm, + pkvm_handle_t, handle) { - DECLARE_REG(pkvm_handle_t, handle, host_ctxt, 1); - - cpu_reg(host_ctxt, 1) =3D __pkvm_finalize_teardown_vm(handle); + return __pkvm_finalize_teardown_vm(handle); } =20 -static void handle___tracing_load(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL(int, __tracing_load, + void *, desc_hva, size_t, desc_size) { - DECLARE_REG(void *, desc_hva, host_ctxt, 1); - DECLARE_REG(size_t, desc_size, host_ctxt, 2); - - cpu_reg(host_ctxt, 1) =3D __tracing_load(desc_hva, desc_size); + return __tracing_load(desc_hva, desc_size); } =20 -static void handle___tracing_unload(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL0_VOID(__tracing_unload) { __tracing_unload(); } =20 -static void handle___tracing_enable(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL(int, __tracing_enable, + bool, enable) { - DECLARE_REG(bool, enable, host_ctxt, 1); - - cpu_reg(host_ctxt, 1) =3D __tracing_enable(enable); + return __tracing_enable(enable); } =20 -static void handle___tracing_swap_reader(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL(int, __tracing_swap_reader, + unsigned int, cpu) { - DECLARE_REG(unsigned int, cpu, host_ctxt, 1); - - cpu_reg(host_ctxt, 1) =3D __tracing_swap_reader(cpu); + return __tracing_swap_reader(cpu); } =20 -static void handle___tracing_update_clock(struct kvm_cpu_context *host_ctx= t) +DEFINE_KVM_HOST_HCALL_VOID(__tracing_update_clock, + u32, mult, u32, shift, u64, epoch_ns, u64, epoch_cyc) { - DECLARE_REG(u32, mult, host_ctxt, 1); - DECLARE_REG(u32, shift, host_ctxt, 2); - DECLARE_REG(u64, epoch_ns, host_ctxt, 3); - DECLARE_REG(u64, epoch_cyc, host_ctxt, 4); - __tracing_update_clock(mult, shift, epoch_ns, epoch_cyc); } =20 -static void handle___tracing_reset(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL(int, __tracing_reset, + unsigned int, cpu) { - DECLARE_REG(unsigned int, cpu, host_ctxt, 1); - - cpu_reg(host_ctxt, 1) =3D __tracing_reset(cpu); + return __tracing_reset(cpu); } =20 -static void handle___tracing_enable_event(struct kvm_cpu_context *host_ctx= t) +DEFINE_KVM_HOST_HCALL(int, __tracing_enable_event, + unsigned short, id, bool, enable) { - DECLARE_REG(unsigned short, id, host_ctxt, 1); - DECLARE_REG(bool, enable, host_ctxt, 2); - - cpu_reg(host_ctxt, 1) =3D __tracing_enable_event(id, enable); + return __tracing_enable_event(id, enable); } =20 -static void handle___tracing_write_event(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL_VOID(__tracing_write_event, + u64, id) { - DECLARE_REG(u64, id, host_ctxt, 1); - trace_selftest(id); } =20 -static void handle___vgic_v5_save_apr(struct kvm_cpu_context *host_ctxt) +DEFINE_KVM_HOST_HCALL_VOID(__vgic_v5_save_apr, + struct vgic_v5_cpu_if *, cpu_if) { - DECLARE_REG(struct vgic_v5_cpu_if *, cpu_if, host_ctxt, 1); - __vgic_v5_save_apr(kern_hyp_va(cpu_if)); } =20 -static void handle___vgic_v5_restore_vmcr_apr(struct kvm_cpu_context *host= _ctxt) +DEFINE_KVM_HOST_HCALL_VOID(__vgic_v5_restore_vmcr_apr, + struct vgic_v5_cpu_if *, cpu_if) { - DECLARE_REG(struct vgic_v5_cpu_if *, cpu_if, host_ctxt, 1); - __vgic_v5_restore_vmcr_apr(kern_hyp_va(cpu_if)); } =20 --=20 2.39.5 From nobody Fri Oct 2 08:24:49 2026 Received: from out-170.mta0.migadu.com (out-170.mta0.migadu.com [91.218.175.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24342422536 for ; Mon, 3 Aug 2026 12:43:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785761020; cv=none; b=CXSDHcS/USnBXX87SZVipIlzQ7vcE3XVuNsDt/R0kvlpV04fHlcaQTQgtJpcVPcRUlbRGstu8QYbNdKHriIhfkCSI2lHhOsyIaZD4WU4pmlvtlVDn/FurRnuFh9JC7+dRhwOnnxhSmr3MhmPIdWAOULqyTMPkWoikBBZT02PzNk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785761020; c=relaxed/simple; bh=7ILijJdXtqQa2Kbu9QgR1NHjUSeKgId76bWfAeZB5R8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=R8b6FngH3jRp7EbCVdCGQJe2eFq10zhsG0maaG68DE1Kur2ffLyHZK5oVIhgYhEkzQnXonNV2GkWOAq4dULHNw34CH/hftOKavGwOrabPJkSCwvRcjTyPDfk4U44ecsq7/41qxIQPIJx9q1ei99iIlLvr4Txa0KtzxiEkmMmtHI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=IM2bJR3K; arc=none smtp.client-ip=91.218.175.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="IM2bJR3K" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1785761016; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q0rqVXntntPGNtRhW7boCS4de5223r2PVD+Op+TiuUo=; b=IM2bJR3K2lCEgntYhrvI/GFbu+ZxQcmX8fQUb5XVT2+OfYOPwLzvaCtmnvyLCA+aPIekpy m5w0llo4isyLaffnxmvFVhoIF+C+ydsEG8X/BnK59E9Y1oE9ssoT0qaZQDtGonQm8jNIHQ X4ZvozcfaRmjHdA1CBUPj7+RrX/icH0= From: Fuad Tabba To: maz@kernel.org, oupton@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Cc: catalin.marinas@arm.com, will@kernel.org, rostedt@goodmis.org, mhiramat@kernel.org, alexandru.elisei@arm.com, vdonnefort@google.com, joey.gouly@arm.com, seiden@linux.ibm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, qperret@google.com, ardb@kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, tabba@google.com, fuad.tabba@linux.dev Subject: [PATCH v2 11/11] KVM: arm64: Tag host-VA hypercall parameters __kern Date: Mon, 3 Aug 2026 13:42:20 +0100 Message-Id: <20260803124220.332248-12-fuad.tabba@linux.dev> In-Reply-To: <20260803124220.332248-1-fuad.tabba@linux.dev> References: <20260803124220.332248-1-fuad.tabba@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" The nVHE hypervisor takes host virtual addresses as hypercall arguments and translates each with kern_hyp_va() before use. Nothing marks them as host-owned, so dereferencing one untranslated at EL2 - a recurring bug class - is invisible to the compiler. Add a __kern sparse address space, active only for EL2 code, and tag the host-VA parameters in the hypercall declarations. kern_hyp_va_host() is the only sanctioned unwrap: it translates the address, preserves the pointee type (stripped of qualifiers, as with the percpu accessors) and drops the tag with a __force cast, so an untranslated host VA fails sparse. The tag flows from the shared declaration into the generated handler and on into the donated-memory and tracing-descriptor helpers, so a handler cannot extract a host VA without it. Host code sees plain pointers, and the tag is checker-only: no code is generated. Signed-off-by: Fuad Tabba --- arch/arm64/include/asm/kvm_hcall.h | 43 ++++++++++++------- arch/arm64/include/asm/kvm_mmu.h | 10 +++++ arch/arm64/kvm/hyp/include/nvhe/pkvm.h | 6 ++- arch/arm64/kvm/hyp/include/nvhe/trace.h | 5 ++- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 57 +++++++++++++------------ arch/arm64/kvm/hyp/nvhe/pkvm.c | 11 ++--- arch/arm64/kvm/hyp/nvhe/trace.c | 4 +- 7 files changed, 82 insertions(+), 54 deletions(-) diff --git a/arch/arm64/include/asm/kvm_hcall.h b/arch/arm64/include/asm/kv= m_hcall.h index 39374bae4bea4..3958396a83345 100644 --- a/arch/arm64/include/asm/kvm_hcall.h +++ b/arch/arm64/include/asm/kvm_hcall.h @@ -28,6 +28,18 @@ struct kvm_vcpu; struct vgic_v3_cpu_if; struct vgic_v5_cpu_if; =20 +/* + * A host VA carried by a hypercall argument. At EL2 such a pointer must n= ot + * be dereferenced until it is translated with kern_hyp_va_host(); sparse + * flags any use that skips the translation. The tag describes the EL2 view + * only: the host dereferences its own VAs freely. + */ +#if defined(__KVM_NVHE_HYPERVISOR__) && defined(__CHECKER__) +#define __kern __attribute__((noderef, address_space(__kern))) +#else +#define __kern +#endif + /* * Hypercall signatures are declared as (type, name) argument pairs. * __KVM_HCALL_MAP() applies a macro to each pair, in the mold of __MAP() @@ -160,24 +172,24 @@ DECLARE_KVM_HOST_HCALL0(int, __pkvm_prot_finalize) =20 /* Hypercalls that are always available and common to [nh]VHE/pKVM. */ DECLARE_KVM_HOST_HCALL_VOID(__kvm_adjust_pc, - struct kvm_vcpu *, vcpu) + struct kvm_vcpu __kern *, vcpu) DECLARE_KVM_HOST_HCALL(int, __kvm_vcpu_run, - struct kvm_vcpu *, vcpu) + struct kvm_vcpu __kern *, vcpu) DECLARE_KVM_HOST_HCALL0_VOID(__kvm_flush_vm_context) DECLARE_KVM_HOST_HCALL_VOID(__kvm_tlb_flush_vmid_ipa, - struct kvm_s2_mmu *, mmu, phys_addr_t, ipa, int, level) + struct kvm_s2_mmu __kern *, mmu, phys_addr_t, ipa, int, level) DECLARE_KVM_HOST_HCALL_VOID(__kvm_tlb_flush_vmid_ipa_nsh, - struct kvm_s2_mmu *, mmu, phys_addr_t, ipa, int, level) + struct kvm_s2_mmu __kern *, mmu, phys_addr_t, ipa, int, level) DECLARE_KVM_HOST_HCALL_VOID(__kvm_tlb_flush_vmid, - struct kvm_s2_mmu *, mmu) + struct kvm_s2_mmu __kern *, mmu) DECLARE_KVM_HOST_HCALL_VOID(__kvm_tlb_flush_vmid_range, - struct kvm_s2_mmu *, mmu, phys_addr_t, start, unsigned long, pages) + struct kvm_s2_mmu __kern *, mmu, phys_addr_t, start, unsigned long, pages) DECLARE_KVM_HOST_HCALL_VOID(__kvm_flush_cpu_context, - struct kvm_s2_mmu *, mmu) + struct kvm_s2_mmu __kern *, mmu) DECLARE_KVM_HOST_HCALL_VOID(__kvm_timer_set_cntvoff, u64, cntvoff) DECLARE_KVM_HOST_HCALL(int, __tracing_load, - void *, desc_hva, size_t, desc_size) + void __kern *, desc_hva, size_t, desc_size) DECLARE_KVM_HOST_HCALL0_VOID(__tracing_unload) DECLARE_KVM_HOST_HCALL(int, __tracing_enable, bool, enable) @@ -192,13 +204,13 @@ DECLARE_KVM_HOST_HCALL(int, __tracing_enable_event, DECLARE_KVM_HOST_HCALL_VOID(__tracing_write_event, u64, id) DECLARE_KVM_HOST_HCALL_VOID(__vgic_v3_save_aprs, - struct vgic_v3_cpu_if *, cpu_if) + struct vgic_v3_cpu_if __kern *, cpu_if) DECLARE_KVM_HOST_HCALL_VOID(__vgic_v3_restore_vmcr_aprs, - struct vgic_v3_cpu_if *, cpu_if) + struct vgic_v3_cpu_if __kern *, cpu_if) DECLARE_KVM_HOST_HCALL_VOID(__vgic_v5_save_apr, - struct vgic_v5_cpu_if *, cpu_if) + struct vgic_v5_cpu_if __kern *, cpu_if) DECLARE_KVM_HOST_HCALL_VOID(__vgic_v5_restore_vmcr_apr, - struct vgic_v5_cpu_if *, cpu_if) + struct vgic_v5_cpu_if __kern *, cpu_if) =20 /* Hypercalls that are available only when pKVM has finalised. */ DECLARE_KVM_HOST_HCALL(int, __pkvm_host_share_hyp, @@ -223,10 +235,11 @@ DECLARE_KVM_HOST_HCALL0(int, __pkvm_reserve_vm) DECLARE_KVM_HOST_HCALL_VOID(__pkvm_unreserve_vm, pkvm_handle_t, handle) DECLARE_KVM_HOST_HCALL(int, __pkvm_init_vm, - struct kvm *, host_kvm, void *, vm_hva, void *, pgd_hva) + struct kvm __kern *, host_kvm, void __kern *, vm_hva, + void __kern *, pgd_hva) DECLARE_KVM_HOST_HCALL(int, __pkvm_init_vcpu, - pkvm_handle_t, handle, struct kvm_vcpu *, host_vcpu, - void *, vcpu_hva) + pkvm_handle_t, handle, struct kvm_vcpu __kern *, host_vcpu, + void __kern *, vcpu_hva) DECLARE_KVM_HOST_HCALL0(int, __pkvm_vcpu_in_poison_fault) DECLARE_KVM_HOST_HCALL(int, __pkvm_force_reclaim_guest_page, phys_addr_t, phys) diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_= mmu.h index 6eae7e7e2a684..57f65257bb56d 100644 --- a/arch/arm64/include/asm/kvm_mmu.h +++ b/arch/arm64/include/asm/kvm_mmu.h @@ -7,6 +7,8 @@ #ifndef __ARM64_KVM_MMU_H__ #define __ARM64_KVM_MMU_H__ =20 +#include + #include #include #include @@ -140,6 +142,14 @@ static __always_inline unsigned long __kern_hyp_va(uns= igned long v) =20 #define kern_hyp_va(v) ((typeof(v))(__kern_hyp_va((unsigned long)(v)))) =20 +/* + * Translate a __kern-tagged host VA, dropping the tag: the only sanctioned + * unwrap. Translation only, no ownership or bounds validation; the result + * carries the pointee type stripped of the tag and of any cv-qualifiers. + */ +#define kern_hyp_va_host(v) \ + ((TYPEOF_UNQUAL(*(v)) *)__kern_hyp_va((unsigned long)(__force void *)(v))) + extern u32 __hyp_va_bits; =20 /* diff --git a/arch/arm64/kvm/hyp/include/nvhe/pkvm.h b/arch/arm64/kvm/hyp/in= clude/nvhe/pkvm.h index 2643a1a819668..c1171451e1be7 100644 --- a/arch/arm64/kvm/hyp/include/nvhe/pkvm.h +++ b/arch/arm64/kvm/hyp/include/nvhe/pkvm.h @@ -7,6 +7,7 @@ #ifndef __ARM64_KVM_NVHE_PKVM_H__ #define __ARM64_KVM_NVHE_PKVM_H__ =20 +#include #include =20 #include @@ -69,9 +70,10 @@ void pkvm_hyp_vm_table_init(void *tbl); =20 int __pkvm_reserve_vm(void); void __pkvm_unreserve_vm(pkvm_handle_t handle); -int __pkvm_init_vm(struct kvm *host_kvm, void *vm_hva, void *pgd_hva); +int __pkvm_init_vm(struct kvm *host_kvm, void __kern *vm_hva, + void __kern *pgd_hva); int __pkvm_init_vcpu(pkvm_handle_t handle, struct kvm_vcpu *host_vcpu, - void *vcpu_hva); + void __kern *vcpu_hva); =20 int __pkvm_reclaim_dying_guest_page(pkvm_handle_t handle, u64 gfn); int __pkvm_start_teardown_vm(pkvm_handle_t handle); diff --git a/arch/arm64/kvm/hyp/include/nvhe/trace.h b/arch/arm64/kvm/hyp/i= nclude/nvhe/trace.h index 4aa36fd76b9e2..c2db9f70ea265 100644 --- a/arch/arm64/kvm/hyp/include/nvhe/trace.h +++ b/arch/arm64/kvm/hyp/include/nvhe/trace.h @@ -4,6 +4,7 @@ =20 #include =20 +#include #include =20 static inline pid_t __tracing_get_vcpu_pid(struct kvm_cpu_context *host_ct= xt) @@ -46,7 +47,7 @@ static inline pid_t __tracing_get_vcpu_pid(struct kvm_cpu= _context *host_ctxt) void *tracing_reserve_entry(unsigned long length); void tracing_commit_entry(void); =20 -int __tracing_load(void *desc_va, size_t desc_size); +int __tracing_load(void __kern *desc_va, size_t desc_size); void __tracing_unload(void); int __tracing_enable(bool enable); int __tracing_swap_reader(unsigned int cpu); @@ -59,7 +60,7 @@ static inline void tracing_commit_entry(void) { } #define HYP_EVENT(__name, __proto, __struct, __assign, __printk) \ static inline void trace_##__name(__proto) {} =20 -static inline int __tracing_load(void *desc_va, size_t desc_size) { return= -ENODEV; } +static inline int __tracing_load(void __kern *desc_va, size_t desc_size) {= return -ENODEV; } static inline void __tracing_unload(void) { } static inline int __tracing_enable(bool enable) { return -ENODEV; } static inline int __tracing_swap_reader(unsigned int cpu) { return -ENODEV= ; } diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/h= yp-main.c index 6986ce55fd9ef..f8ea1661b3166 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c @@ -270,7 +270,7 @@ DEFINE_KVM_HOST_HCALL0_VOID(__pkvm_vcpu_put) } =20 DEFINE_KVM_HOST_HCALL(int, __kvm_vcpu_run, - struct kvm_vcpu *, host_vcpu) + struct kvm_vcpu __kern *, host_vcpu) { int ret; =20 @@ -295,7 +295,7 @@ DEFINE_KVM_HOST_HCALL(int, __kvm_vcpu_run, =20 sync_hyp_vcpu(hyp_vcpu); } else { - struct kvm_vcpu *vcpu =3D kern_hyp_va(host_vcpu); + struct kvm_vcpu *vcpu =3D kern_hyp_va_host(host_vcpu); =20 /* The host is fully trusted, run its vCPU directly. */ fpsimd_lazy_switch_to_guest(vcpu); @@ -422,9 +422,9 @@ DEFINE_KVM_HOST_HCALL(int, __pkvm_host_mkyoung_guest, } =20 DEFINE_KVM_HOST_HCALL_VOID(__kvm_adjust_pc, - struct kvm_vcpu *, vcpu) + struct kvm_vcpu __kern *, vcpu) { - __kvm_adjust_pc(kern_hyp_va(vcpu)); + __kvm_adjust_pc(kern_hyp_va_host(vcpu)); } =20 DEFINE_KVM_HOST_HCALL0_VOID(__kvm_flush_vm_context) @@ -433,27 +433,27 @@ DEFINE_KVM_HOST_HCALL0_VOID(__kvm_flush_vm_context) } =20 DEFINE_KVM_HOST_HCALL_VOID(__kvm_tlb_flush_vmid_ipa, - struct kvm_s2_mmu *, mmu, phys_addr_t, ipa, int, level) + struct kvm_s2_mmu __kern *, mmu, phys_addr_t, ipa, int, level) { - __kvm_tlb_flush_vmid_ipa(kern_hyp_va(mmu), ipa, level); + __kvm_tlb_flush_vmid_ipa(kern_hyp_va_host(mmu), ipa, level); } =20 DEFINE_KVM_HOST_HCALL_VOID(__kvm_tlb_flush_vmid_ipa_nsh, - struct kvm_s2_mmu *, mmu, phys_addr_t, ipa, int, level) + struct kvm_s2_mmu __kern *, mmu, phys_addr_t, ipa, int, level) { - __kvm_tlb_flush_vmid_ipa_nsh(kern_hyp_va(mmu), ipa, level); + __kvm_tlb_flush_vmid_ipa_nsh(kern_hyp_va_host(mmu), ipa, level); } =20 DEFINE_KVM_HOST_HCALL_VOID(__kvm_tlb_flush_vmid_range, - struct kvm_s2_mmu *, mmu, phys_addr_t, start, unsigned long, pages) + struct kvm_s2_mmu __kern *, mmu, phys_addr_t, start, unsigned long, pages) { - __kvm_tlb_flush_vmid_range(kern_hyp_va(mmu), start, pages); + __kvm_tlb_flush_vmid_range(kern_hyp_va_host(mmu), start, pages); } =20 DEFINE_KVM_HOST_HCALL_VOID(__kvm_tlb_flush_vmid, - struct kvm_s2_mmu *, mmu) + struct kvm_s2_mmu __kern *, mmu) { - __kvm_tlb_flush_vmid(kern_hyp_va(mmu)); + __kvm_tlb_flush_vmid(kern_hyp_va_host(mmu)); } =20 DEFINE_KVM_HOST_HCALL_VOID(__pkvm_tlb_flush_vmid, @@ -469,9 +469,9 @@ DEFINE_KVM_HOST_HCALL_VOID(__pkvm_tlb_flush_vmid, } =20 DEFINE_KVM_HOST_HCALL_VOID(__kvm_flush_cpu_context, - struct kvm_s2_mmu *, mmu) + struct kvm_s2_mmu __kern *, mmu) { - __kvm_flush_cpu_context(kern_hyp_va(mmu)); + __kvm_flush_cpu_context(kern_hyp_va_host(mmu)); } =20 DEFINE_KVM_HOST_HCALL_VOID(__kvm_timer_set_cntvoff, @@ -500,15 +500,15 @@ DEFINE_KVM_HOST_HCALL0_VOID(__vgic_v3_init_lrs) } =20 DEFINE_KVM_HOST_HCALL_VOID(__vgic_v3_save_aprs, - struct vgic_v3_cpu_if *, cpu_if) + struct vgic_v3_cpu_if __kern *, cpu_if) { - __vgic_v3_save_aprs(kern_hyp_va(cpu_if)); + __vgic_v3_save_aprs(kern_hyp_va_host(cpu_if)); } =20 DEFINE_KVM_HOST_HCALL_VOID(__vgic_v3_restore_vmcr_aprs, - struct vgic_v3_cpu_if *, cpu_if) + struct vgic_v3_cpu_if __kern *, cpu_if) { - __vgic_v3_restore_vmcr_aprs(kern_hyp_va(cpu_if)); + __vgic_v3_restore_vmcr_aprs(kern_hyp_va_host(cpu_if)); } =20 DEFINE_KVM_HOST_HCALL(int, __pkvm_init, @@ -580,16 +580,17 @@ DEFINE_KVM_HOST_HCALL_VOID(__pkvm_unreserve_vm, } =20 DEFINE_KVM_HOST_HCALL(int, __pkvm_init_vm, - struct kvm *, host_kvm, void *, vm_hva, void *, pgd_hva) + struct kvm __kern *, host_kvm, void __kern *, vm_hva, + void __kern *, pgd_hva) { - return __pkvm_init_vm(kern_hyp_va(host_kvm), vm_hva, pgd_hva); + return __pkvm_init_vm(kern_hyp_va_host(host_kvm), vm_hva, pgd_hva); } =20 DEFINE_KVM_HOST_HCALL(int, __pkvm_init_vcpu, - pkvm_handle_t, handle, struct kvm_vcpu *, host_vcpu, - void *, vcpu_hva) + pkvm_handle_t, handle, struct kvm_vcpu __kern *, host_vcpu, + void __kern *, vcpu_hva) { - return __pkvm_init_vcpu(handle, kern_hyp_va(host_vcpu), vcpu_hva); + return __pkvm_init_vcpu(handle, kern_hyp_va_host(host_vcpu), vcpu_hva); } =20 DEFINE_KVM_HOST_HCALL0(int, __pkvm_vcpu_in_poison_fault) @@ -624,7 +625,7 @@ DEFINE_KVM_HOST_HCALL(int, __pkvm_finalize_teardown_vm, } =20 DEFINE_KVM_HOST_HCALL(int, __tracing_load, - void *, desc_hva, size_t, desc_size) + void __kern *, desc_hva, size_t, desc_size) { return __tracing_load(desc_hva, desc_size); } @@ -671,15 +672,15 @@ DEFINE_KVM_HOST_HCALL_VOID(__tracing_write_event, } =20 DEFINE_KVM_HOST_HCALL_VOID(__vgic_v5_save_apr, - struct vgic_v5_cpu_if *, cpu_if) + struct vgic_v5_cpu_if __kern *, cpu_if) { - __vgic_v5_save_apr(kern_hyp_va(cpu_if)); + __vgic_v5_save_apr(kern_hyp_va_host(cpu_if)); } =20 DEFINE_KVM_HOST_HCALL_VOID(__vgic_v5_restore_vmcr_apr, - struct vgic_v5_cpu_if *, cpu_if) + struct vgic_v5_cpu_if __kern *, cpu_if) { - __vgic_v5_restore_vmcr_apr(kern_hyp_va(cpu_if)); + __vgic_v5_restore_vmcr_apr(kern_hyp_va_host(cpu_if)); } =20 typedef void (*hcall_t)(struct kvm_cpu_context *); diff --git a/arch/arm64/kvm/hyp/nvhe/pkvm.c b/arch/arm64/kvm/hyp/nvhe/pkvm.c index 205c52535c887..9c33d983058a3 100644 --- a/arch/arm64/kvm/hyp/nvhe/pkvm.c +++ b/arch/arm64/kvm/hyp/nvhe/pkvm.c @@ -644,9 +644,9 @@ static size_t pkvm_get_hyp_vm_size(unsigned int nr_vcpu= s) size_mul(sizeof(struct pkvm_hyp_vcpu *), nr_vcpus)); } =20 -static void *map_donated_memory_noclear(void *host_va, size_t size) +static void *map_donated_memory_noclear(void __kern *host_va, size_t size) { - void *va =3D kern_hyp_va(host_va); + void *va =3D kern_hyp_va_host(host_va); =20 if (!PAGE_ALIGNED(va)) return NULL; @@ -658,7 +658,7 @@ static void *map_donated_memory_noclear(void *host_va, = size_t size) return va; } =20 -static void *map_donated_memory(void *host_va, size_t size) +static void *map_donated_memory(void __kern *host_va, size_t size) { void *va =3D map_donated_memory_noclear(host_va, size); =20 @@ -805,7 +805,8 @@ void teardown_selftest_vm(void) * * Return 0 success, negative error code on failure. */ -int __pkvm_init_vm(struct kvm *host_kvm, void *vm_hva, void *pgd_hva) +int __pkvm_init_vm(struct kvm *host_kvm, void __kern *vm_hva, + void __kern *pgd_hva) { struct pkvm_hyp_vm *hyp_vm =3D NULL; size_t vm_size, pgd_size; @@ -896,7 +897,7 @@ static int register_hyp_vcpu(struct pkvm_hyp_vm *hyp_vm, } =20 int __pkvm_init_vcpu(pkvm_handle_t handle, struct kvm_vcpu *host_vcpu, - void *vcpu_hva) + void __kern *vcpu_hva) { struct pkvm_hyp_vcpu *hyp_vcpu; struct pkvm_hyp_vm *hyp_vm; diff --git a/arch/arm64/kvm/hyp/nvhe/trace.c b/arch/arm64/kvm/hyp/nvhe/trac= e.c index 97203ddd3cf45..4410006321a99 100644 --- a/arch/arm64/kvm/hyp/nvhe/trace.c +++ b/arch/arm64/kvm/hyp/nvhe/trace.c @@ -206,9 +206,9 @@ static bool hyp_trace_desc_is_valid(struct hyp_trace_de= sc *desc, size_t desc_siz return true; } =20 -int __tracing_load(void *desc_hva, size_t desc_size) +int __tracing_load(void __kern *desc_hva, size_t desc_size) { - struct hyp_trace_desc *desc =3D kern_hyp_va(desc_hva); + struct hyp_trace_desc *desc =3D kern_hyp_va_host(desc_hva); int ret; =20 ret =3D __admit_host_mem(desc, desc_size); --=20 2.39.5