From nobody Tue Feb 10 00:57:52 2026 Received: from mail.zytor.com (terminus.zytor.com [198.137.202.136]) (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 78730262FF6; Wed, 12 Nov 2025 04:38:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.136 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762922331; cv=none; b=ervQ5RDh+VjeIUB4ACCUnUsV3p+R+pJsErm1AEl1rrLlE8Jjy6t2vj0rRbylL+++r6w74ikygGrXRnrYmTnHaIjsI1LeKoLR5SY+m9JOHQXlBqRO+5ztKdS1ktrpXWOKHP5oGyq3u+IncMKgjp2ysGlmh7ECd/B6rsxBX2D1Wic= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762922331; c=relaxed/simple; bh=wrfnXTqj1a54O3v0leFzikk/6KI95YcRoT9sTgch9BM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Chi+X5ABWzN0y6va9G031O+dSJyvUPB8H8tj/VTpF26htRsaOd1gk7MBoVbwTCSeFahWqFRPNlL2KbygiR16MBKfveIxN7cxOUwhmAG6zEONk+GUU4RVfYibxhp/d3hute5oBGntsU+LizC8LOkZsQVvXmRg+8amW/GHweuB130= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zytor.com; spf=pass smtp.mailfrom=zytor.com; dkim=pass (2048-bit key) header.d=zytor.com header.i=@zytor.com header.b=D7WNS7Eb; arc=none smtp.client-ip=198.137.202.136 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zytor.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zytor.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=zytor.com header.i=@zytor.com header.b="D7WNS7Eb" Received: from mail.zytor.com (c-76-133-66-138.hsd1.ca.comcast.net [76.133.66.138]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 5AC4bYDV542538 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 11 Nov 2025 20:37:51 -0800 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 5AC4bYDV542538 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025102301; t=1762922272; bh=GMMOcY5k7WMRbb5RjzJJtEFLgKhj6ZkdpyvvaWniwlU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=D7WNS7EbpirDhdlVdB86gK7uihe3y5A5N/RIwZLiGL8TO45lYCCPqR/KNi3sNWimE iyKjMIEFgzUQUr2FIjmvaS2Y5JbInKCBOo62CPe9x3AZMsNPwb4u+xzhFk5sB3LVxD zhQDlx99DArdwnKHQj2YA3O0f5obsoumWPfYaCjl7tT+O52dT41sIOxUGXbfwPxbJU Hlp6AnLql4DQQEgI/NSGfGkJIms2dV0toBRKwcbhxL2G7KeX1dOZcX5YSdBfLYVOAZ 7iQBfnlgL7DxeFcghKxiB0wHCSmC+niGvrvdCcwQIV0KOSfFs+XfW2/PKhLuUmT7Af 9ewipLxNs73wA== From: "H. Peter Anvin" To: "H. Peter Anvin" , "Jason A. Donenfeld" , "Peter Zijlstra (Intel)" , "Theodore Ts'o" , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Xin Li , Andrew Cooper , Andy Lutomirski , Ard Biesheuvel , Borislav Petkov , Brian Gerst , Dave Hansen , Ingo Molnar , James Morse , Jarkko Sakkinen , Josh Poimboeuf , Kees Cook , Nam Cao , Oleg Nesterov , Perry Yuan , Thomas Gleixner , Thomas Huth , Uros Bizjak , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-sgx@vger.kernel.org, x86@kernel.org Subject: [PATCH v2 9/9] x86/entry/vdso32: when using int $0x80, use it directly Date: Tue, 11 Nov 2025 20:37:27 -0800 Message-ID: <20251112043730.992152-10-hpa@zytor.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251112043730.992152-1-hpa@zytor.com> References: <20251112043730.992152-1-hpa@zytor.com> 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 Content-Type: text/plain; charset="utf-8" When neither sysenter32 nor syscall32 is available (on either FRED-capable 64-bit hardware or old 32-bit hardware), there is no reason to do a bunch of stack shuffling in __kernel_vsyscall. Unfortunately, just overwriting the initial "push" instructions will mess up the CFI annotations, so suffer the 3-byte NOP if not applicable. Similarly, inline the int $0x80 when doing inline system calls in the vdso instead of calling __kernel_vsyscall. Signed-off-by: H. Peter Anvin (Intel) --- arch/x86/entry/vdso/vdso32/system_call.S | 18 ++++++++++++++---- arch/x86/include/asm/vdso/sys_call.h | 4 +++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/arch/x86/entry/vdso/vdso32/system_call.S b/arch/x86/entry/vdso= /vdso32/system_call.S index 7b1c0f16e511..9157cf9c5749 100644 --- a/arch/x86/entry/vdso/vdso32/system_call.S +++ b/arch/x86/entry/vdso/vdso32/system_call.S @@ -14,6 +14,18 @@ ALIGN __kernel_vsyscall: CFI_STARTPROC + + /* + * If using int $0x80, there is no reason to muck about with the + * stack here. Unfortunately just overwriting the push instructions + * would mess up the CFI annotations, but it is only a 3-byte + * NOP in that case. This could be avoided by patching the + * vdso symbol table (not the code) and entry point, but that + * would a fair bit of tooling work or by simply compiling + * two different vDSO images, but that doesn't seem worth it. + */ + ALTERNATIVE "int $0x80; ret", "", X86_FEATURE_SYSFAST32 + /* * Reshuffle regs so that all of any of the entry instructions * will preserve enough state. @@ -52,11 +64,9 @@ __kernel_vsyscall: #define SYSENTER_SEQUENCE "movl %esp, %ebp; sysenter" #define SYSCALL_SEQUENCE "movl %ecx, %ebp; syscall" =20 - /* If SYSENTER (Intel) or SYSCALL32 (AMD) is available, use it. */ - ALTERNATIVE_2 "", SYSENTER_SEQUENCE, X86_FEATURE_SYSFAST32, \ - SYSCALL_SEQUENCE, X86_FEATURE_SYSCALL32 + ALTERNATIVE SYSENTER_SEQUENCE, SYSCALL_SEQUENCE, X86_FEATURE_SYSCALL32 =20 - /* Enter using int $0x80 */ + /* Re-enter using int $0x80 */ int $0x80 SYM_INNER_LABEL(int80_landing_pad, SYM_L_GLOBAL) =20 diff --git a/arch/x86/include/asm/vdso/sys_call.h b/arch/x86/include/asm/vd= so/sys_call.h index 6b1fbcdcbd5c..603ad8a83c66 100644 --- a/arch/x86/include/asm/vdso/sys_call.h +++ b/arch/x86/include/asm/vdso/sys_call.h @@ -27,7 +27,9 @@ #define __sys_reg5 "r8" #define __sys_reg6 "r9" #else -#define __sys_instr "call __kernel_vsyscall" +#define __sys_instr ALTERNATIVE("ds;ds;ds;int $0x80", \ + "call __kernel_vsyscall", \ + X86_FEATURE_SYSFAST32) #define __sys_clobber "memory" #define __sys_nr(x,y) __NR_ ## x ## y #define __sys_reg1 "ebx" --=20 2.51.1