From nobody Mon May 4 13:13:44 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 9D822388E4A; Mon, 4 May 2026 09:55:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888546; cv=none; b=gcCSKbPxQSzTbBi5ISlgHjNr2RZdQicpwF7JwB8dqxvCcH7HYB17cx1GY/5oU8K9eeWZfPFA1iBOlr/1Jz86jRc/089QTRpOt2OA4ByTniPykr0mrTFextPQXWMvZC3RGLbWZQJO/v3X5xQPUwPGKSQzqNgr07OQbJjocL80TiI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777888546; c=relaxed/simple; bh=wjRL/mtTmM466QZccJAhwqIkO0TRt5vePwpu/6/frHU=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=BgQSrSAV5F0/y2/UuqR45+PDuWo1Gkb00gVoQN/zPy6H+vqnJQpIon5kw6DKv8dcTP4m53EyMtRl61NN7TkjfydJ2SM8MgnZs20tn2hmkh9m0DvTTf+6biv3bAx/C8yD1/hf1btK+pfLR3qmZnRKJs9FiW1bNGU+Wb5uWyx+qCI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=slv+5BH1; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=6s8PTSze; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="slv+5BH1"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="6s8PTSze" Date: Mon, 04 May 2026 09:55:40 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1777888542; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CCPmvDNygSBrIRCh3MuKwCM1q//t6vp+rPmuq7Wzz4Q=; b=slv+5BH1meYY6CBKiyjR+2yYezoOTkM0a/k1a/gElgzFT8aviQle6lznIXIn3QyC42ry+p 5Njt+c7nbVneqzvyoxNjjOxy6iputDwfYMUyafG1tt1b4AdGs9KGg9PAJ80IxH/GgY562T W66VFG3e/Je7KxZPsM+EHcUS5UGyhdnPcrmoh8V31wCFQq4mCvUj+9FWN+XHc5aA6QhHgB spvWnNJ/Njxu0/jPeijqUbbg7LooETv/NXQDtAiCqrUvA2jjGnIhuEj6oAnnlMX4Hp/z75 cIUalJUhVpw1eO/XeIzJ4q1aLRvivfnaJsz/llUg2mYvbVMQV94h9d/ygP9NZA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1777888542; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CCPmvDNygSBrIRCh3MuKwCM1q//t6vp+rPmuq7Wzz4Q=; b=6s8PTSzeIXcU9vPYAmwHwVCmblazVTRRB4t3jgcWATlisx20rnjd1xOUXBhE0+nVWOuRy9 v7mG8pPTXSRKWrAw== From: "tip-bot2 for Borislav Petkov (AMD)" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/sev] x86/entry: Zap the #VC entry user and kernel macros Cc: "Borislav Petkov (AMD)" , "Nikunj A. Dadhania" , Tom Lendacky , Joerg Roedel , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260420164352.32129-1-bp@kernel.org> References: <20260420164352.32129-1-bp@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177788854080.424702.7806993053330133040.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the x86/sev branch of tip: Commit-ID: 52705e72e265406255f83dbd0c725fddc5bd2c83 Gitweb: https://git.kernel.org/tip/52705e72e265406255f83dbd0c725fddc= 5bd2c83 Author: Borislav Petkov (AMD) AuthorDate: Mon, 20 Apr 2026 18:43:52 +02:00 Committer: Borislav Petkov (AMD) CommitterDate: Mon, 04 May 2026 11:18:41 +02:00 x86/entry: Zap the #VC entry user and kernel macros Drop the separate kernel and user macros in favor of calling a single #VC C handler which multiplexes between the kernel and user #VC entry points by looking at CS's RPL. Zap unused DEFINE_IDTENTRY_VC while at it. There should be no functionality change resulting from this - just code simplification. Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Nikunj A. Dadhania Reviewed-by: Tom Lendacky Acked-by: Joerg Roedel Tested-by: Nikunj A. Dadhania Link: https://patch.msgid.link/20260420164352.32129-1-bp@kernel.org --- arch/x86/coco/sev/internal.h | 3 +++ arch/x86/coco/sev/vc-handle.c | 12 ++++++++++-- arch/x86/entry/entry_64.S | 4 ++-- arch/x86/entry/entry_fred.c | 10 ---------- arch/x86/include/asm/idtentry.h | 29 +++-------------------------- 5 files changed, 18 insertions(+), 40 deletions(-) diff --git a/arch/x86/coco/sev/internal.h b/arch/x86/coco/sev/internal.h index b1d0c66..b9632c0 100644 --- a/arch/x86/coco/sev/internal.h +++ b/arch/x86/coco/sev/internal.h @@ -70,6 +70,9 @@ void svsm_pval_pages(struct snp_psc_desc *desc); int svsm_perform_call_protocol(struct svsm_call *call); bool snp_svsm_vtpm_probe(void); =20 +noinstr void kernel_exc_vmm_communication(struct pt_regs *regs, unsigned l= ong error_code); +noinstr void user_exc_vmm_communication(struct pt_regs *regs, unsigned lon= g error_code); + static inline u64 sev_es_rd_ghcb_msr(void) { return native_rdmsrq(MSR_AMD64_SEV_ES_GHCB); diff --git a/arch/x86/coco/sev/vc-handle.c b/arch/x86/coco/sev/vc-handle.c index d98b5c0..96b62b4 100644 --- a/arch/x86/coco/sev/vc-handle.c +++ b/arch/x86/coco/sev/vc-handle.c @@ -954,7 +954,7 @@ static __always_inline bool vc_is_db(unsigned long erro= r_code) * Runtime #VC exception handler when raised from kernel mode. Runs in NMI= mode * and will panic when an error happens. */ -DEFINE_IDTENTRY_VC_KERNEL(exc_vmm_communication) +noinstr void kernel_exc_vmm_communication(struct pt_regs *regs, unsigned l= ong error_code) { irqentry_state_t irq_state; =20 @@ -1006,7 +1006,7 @@ DEFINE_IDTENTRY_VC_KERNEL(exc_vmm_communication) * Runtime #VC exception handler when raised from user mode. Runs in IRQ m= ode * and will kill the current task with SIGBUS when an error happens. */ -DEFINE_IDTENTRY_VC_USER(exc_vmm_communication) +noinstr void user_exc_vmm_communication(struct pt_regs *regs, unsigned lon= g error_code) { /* * Handle #DB before calling into !noinstr code to avoid recursive #DB. @@ -1032,6 +1032,14 @@ DEFINE_IDTENTRY_VC_USER(exc_vmm_communication) irqentry_exit_to_user_mode(regs); } =20 +DEFINE_IDTENTRY_RAW_ERRORCODE(exc_vmm_communication) +{ + if (user_mode(regs)) + return user_exc_vmm_communication(regs, error_code); + else + return kernel_exc_vmm_communication(regs, error_code); +} + bool __init handle_vc_boot_ghcb(struct pt_regs *regs) { unsigned long exit_code =3D regs->orig_ax; diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S index 42447b1..c6d9965 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S @@ -492,7 +492,7 @@ SYM_CODE_START(\asmsym) =20 movq %rsp, %rdi /* pt_regs pointer */ =20 - call kernel_\cfunc + call \cfunc =20 /* * No need to switch back to the IST stack. The current stack is either @@ -503,7 +503,7 @@ SYM_CODE_START(\asmsym) =20 /* Switch to the regular task stack */ .Lfrom_usermode_switch_stack_\@: - idtentry_body user_\cfunc, has_error_code=3D1 + idtentry_body \cfunc, has_error_code=3D1 =20 _ASM_NOKPROBE(\asmsym) SYM_CODE_END(\asmsym) diff --git a/arch/x86/entry/entry_fred.c b/arch/x86/entry/entry_fred.c index fbe2d10..fb3594d 100644 --- a/arch/x86/entry/entry_fred.c +++ b/arch/x86/entry/entry_fred.c @@ -177,16 +177,6 @@ static noinstr void fred_extint(struct pt_regs *regs) } } =20 -#ifdef CONFIG_AMD_MEM_ENCRYPT -noinstr void exc_vmm_communication(struct pt_regs *regs, unsigned long err= or_code) -{ - if (user_mode(regs)) - return user_exc_vmm_communication(regs, error_code); - else - return kernel_exc_vmm_communication(regs, error_code); -} -#endif - static noinstr void fred_hwexc(struct pt_regs *regs, unsigned long error_c= ode) { /* Optimize for #PF. That's the only exception which matters performance = wise */ diff --git a/arch/x86/include/asm/idtentry.h b/arch/x86/include/asm/idtentr= y.h index 42bf6a5..20f5487 100644 --- a/arch/x86/include/asm/idtentry.h +++ b/arch/x86/include/asm/idtentry.h @@ -340,17 +340,14 @@ static __always_inline void __##func(struct pt_regs *= regs) __visible void noist_##func(struct pt_regs *regs) =20 /** - * DECLARE_IDTENTRY_VC - Declare functions for the VC entry point + * DECLARE_IDTENTRY_VC - Declare a function for the VC entry point * @vector: Vector number (ignored for C) * @func: Function name of the entry point * - * Maps to DECLARE_IDTENTRY_RAW_ERRORCODE, but declares also the - * safe_stack C handler. + * Maps to DECLARE_IDTENTRY_RAW_ERRORCODE. */ #define DECLARE_IDTENTRY_VC(vector, func) \ - DECLARE_IDTENTRY_RAW_ERRORCODE(vector, func); \ - __visible noinstr void kernel_##func(struct pt_regs *regs, unsigned long = error_code); \ - __visible noinstr void user_##func(struct pt_regs *regs, unsigned long = error_code) + DECLARE_IDTENTRY_RAW_ERRORCODE(vector, func); =20 /** * DEFINE_IDTENTRY_IST - Emit code for IST entry points @@ -391,26 +388,6 @@ static __always_inline void __##func(struct pt_regs *r= egs) #define DEFINE_IDTENTRY_DF(func) \ DEFINE_IDTENTRY_RAW_ERRORCODE(func) =20 -/** - * DEFINE_IDTENTRY_VC_KERNEL - Emit code for VMM communication handler - * when raised from kernel mode - * @func: Function name of the entry point - * - * Maps to DEFINE_IDTENTRY_RAW_ERRORCODE - */ -#define DEFINE_IDTENTRY_VC_KERNEL(func) \ - DEFINE_IDTENTRY_RAW_ERRORCODE(kernel_##func) - -/** - * DEFINE_IDTENTRY_VC_USER - Emit code for VMM communication handler - * when raised from user mode - * @func: Function name of the entry point - * - * Maps to DEFINE_IDTENTRY_RAW_ERRORCODE - */ -#define DEFINE_IDTENTRY_VC_USER(func) \ - DEFINE_IDTENTRY_RAW_ERRORCODE(user_##func) - #else /* CONFIG_X86_64 */ =20 /**