From nobody Sun Feb 8 17:47:05 2026 Received: from minute.unseen.parts (minute.unseen.parts [139.162.151.61]) (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 3457F1A08A8; Fri, 31 Jan 2025 10:41:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=139.162.151.61 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738320107; cv=none; b=RNNNeOfEHtcK9+YOSXdC8KivIN0kHNWEAOVTZSwkdENY6KpVV6M7pVaoGxcgmjWAgd7RZKColW802QVs5z8RZxCBJH+UxcSbauiaOk/VzSEYrevAEs4+7ggOXiSOyL9t6G+uzoNlo1ucALO7z9JcWFnvR0DC70hVoxPJUhoicaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738320107; c=relaxed/simple; bh=FvUcElkzZxWemXu8o2v6yzMjy18Dz06KV1AZW2e9Wwg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=n1BhOTvJNPZXQVetC5i9RjjPqjEYj2PBEMBLiHPBtyvYKVw47CKAds5BmqHzjr2jF8qxSHf3p0XbPhwBQvXQEuA1ypcogfNj0i5YX9qJKc9xFDAvWMHqHPbVObjPLoQnmeos5ihfhw9i2em6oyZHJhUgj+cs1GvgMOudDJA+luQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unseen.parts; spf=pass smtp.mailfrom=unseen.parts; dkim=pass (2048-bit key) header.d=unseen.parts header.i=@unseen.parts header.b=Y+/onOgT; arc=none smtp.client-ip=139.162.151.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unseen.parts Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=unseen.parts Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=unseen.parts header.i=@unseen.parts header.b="Y+/onOgT" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=unseen.parts; s=sig; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=x70ymYXNjFz5gwuDFcplwidgQVEhIt9St3oi8cLdKS0=; b=Y+/onOgTePPnhq0d1ZoX7xg49r BmWhJVU0LlAs8CztfnHrBhnenCVVhCqYUGk8se899njn4d9i7V31kNpeQYtQjuKO/wPR9DgtL5u9h 8tXatmafHh7RBtI2cF8a1OZJ9c0J4msowp8IQWkOSvF9SlEt0YJdhsusF8KeT5pMAwgsGSjT+ch9Q mLjSgbC6WaS7lFgbSdt7Qt7iT9XDKX/eWRCn5FsVIErPMM04XrXyETmkBZu3ebHCMn7FFz5kpJuaK orNwqWdtvE1vj1PiA/LqED9jtMoClJPA4Uwx0cK/p1K1KNctkkKzPvx3L/4SM6bZBvA9mathxRm0h U93Mybgg==; Received: from ink by minute.unseen.parts with local (Exim 4.96) (envelope-from ) id 1tdoSo-0002sT-01; Fri, 31 Jan 2025 11:41:30 +0100 From: Ivan Kokshaysky To: Richard Henderson , Matt Turner , Oleg Nesterov , Al Viro , Arnd Bergmann , "Paul E. McKenney" Cc: "Maciej W. Rozycki" , Magnus Lindholm , John Paul Adrian Glaubitz , linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 1/4] alpha/uapi: do not expose kernel-only stack frame structures Date: Fri, 31 Jan 2025 11:41:26 +0100 Message-Id: <20250131104129.11052-2-ink@unseen.parts> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250131104129.11052-1-ink@unseen.parts> References: <20250131104129.11052-1-ink@unseen.parts> 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" Parts of asm/ptrace.h went into UAPI with commit 96433f6ee490 ("UAPI: (Scripted) Disintegrate arch/alpha/include/asm") back in 2012. At first glance it looked correct, as many other architectures expose 'struct pt_regs' for ptrace(2) PTRACE_GETREGS/PTRACE_SETREGS requests and bpf(2) BPF_PROG_TYPE_KPROBE/BPF_PROG_TYPE_PERF_EVENT program types. On Alpha, however, these requests have never been implemented; 'struct pt_regs' describes internal kernel stack frame which has nothing to do with userspace. Same applies to 'struct switch_stack', as PTRACE_GETFPREG/PTRACE_SETFPREG are not implemented either. Move this stuff back into internal asm, where we can ajust it without causing a lot of confusion about possible UAPI breakage. Cc: stable@vger.kernel.org Fixes: 96433f6ee490 ("UAPI: (Scripted) Disintegrate arch/alpha/include/asm") Signed-off-by: Ivan Kokshaysky --- arch/alpha/include/asm/ptrace.h | 62 +++++++++++++++++++++++++- arch/alpha/include/uapi/asm/ptrace.h | 65 ++-------------------------- 2 files changed, 64 insertions(+), 63 deletions(-) diff --git a/arch/alpha/include/asm/ptrace.h b/arch/alpha/include/asm/ptrac= e.h index 3557ce64ed21..693d4c5b4dc7 100644 --- a/arch/alpha/include/asm/ptrace.h +++ b/arch/alpha/include/asm/ptrace.h @@ -2,8 +2,68 @@ #ifndef _ASMAXP_PTRACE_H #define _ASMAXP_PTRACE_H =20 -#include +/* + * This struct defines the way the registers are stored on the + * kernel stack during a system call or other kernel entry + * + * NOTE! I want to minimize the overhead of system calls, so this + * struct has as little information as possible. It does not have + * + * - floating point regs: the kernel doesn't change those + * - r9-15: saved by the C compiler + * + * This makes "fork()" and "exec()" a bit more complex, but should + * give us low system call latency. + */ =20 +struct pt_regs { + unsigned long r0; + unsigned long r1; + unsigned long r2; + unsigned long r3; + unsigned long r4; + unsigned long r5; + unsigned long r6; + unsigned long r7; + unsigned long r8; + unsigned long r19; + unsigned long r20; + unsigned long r21; + unsigned long r22; + unsigned long r23; + unsigned long r24; + unsigned long r25; + unsigned long r26; + unsigned long r27; + unsigned long r28; + unsigned long hae; +/* JRP - These are the values provided to a0-a2 by PALcode */ + unsigned long trap_a0; + unsigned long trap_a1; + unsigned long trap_a2; +/* These are saved by PAL-code: */ + unsigned long ps; + unsigned long pc; + unsigned long gp; + unsigned long r16; + unsigned long r17; + unsigned long r18; +}; + +/* + * This is the extended stack used by signal handlers and the context + * switcher: it's pushed after the normal "struct pt_regs". + */ +struct switch_stack { + unsigned long r9; + unsigned long r10; + unsigned long r11; + unsigned long r12; + unsigned long r13; + unsigned long r14; + unsigned long r15; + unsigned long r26; +}; =20 #define arch_has_single_step() (1) #define user_mode(regs) (((regs)->ps & 8) !=3D 0) diff --git a/arch/alpha/include/uapi/asm/ptrace.h b/arch/alpha/include/uapi= /asm/ptrace.h index 5ca45934fcbb..ad55dc283d8d 100644 --- a/arch/alpha/include/uapi/asm/ptrace.h +++ b/arch/alpha/include/uapi/asm/ptrace.h @@ -2,72 +2,13 @@ #ifndef _UAPI_ASMAXP_PTRACE_H #define _UAPI_ASMAXP_PTRACE_H =20 - /* - * This struct defines the way the registers are stored on the - * kernel stack during a system call or other kernel entry - * - * NOTE! I want to minimize the overhead of system calls, so this - * struct has as little information as possible. It does not have - * - * - floating point regs: the kernel doesn't change those - * - r9-15: saved by the C compiler + * We don't HAVE_REGS_AND_STACK_ACCESS_API. * - * This makes "fork()" and "exec()" a bit more complex, but should - * give us low system call latency. + * Provide empty pt_regs structure for libbpf and the likes + * to avoid breaking the compilation. */ - struct pt_regs { - unsigned long r0; - unsigned long r1; - unsigned long r2; - unsigned long r3; - unsigned long r4; - unsigned long r5; - unsigned long r6; - unsigned long r7; - unsigned long r8; - unsigned long r19; - unsigned long r20; - unsigned long r21; - unsigned long r22; - unsigned long r23; - unsigned long r24; - unsigned long r25; - unsigned long r26; - unsigned long r27; - unsigned long r28; - unsigned long hae; -/* JRP - These are the values provided to a0-a2 by PALcode */ - unsigned long trap_a0; - unsigned long trap_a1; - unsigned long trap_a2; -/* These are saved by PAL-code: */ - unsigned long ps; - unsigned long pc; - unsigned long gp; - unsigned long r16; - unsigned long r17; - unsigned long r18; }; =20 -/* - * This is the extended stack used by signal handlers and the context - * switcher: it's pushed after the normal "struct pt_regs". - */ -struct switch_stack { - unsigned long r9; - unsigned long r10; - unsigned long r11; - unsigned long r12; - unsigned long r13; - unsigned long r14; - unsigned long r15; - unsigned long r26; -#ifndef __KERNEL__ - unsigned long fp[32]; /* fp[31] is fpcr */ -#endif -}; - - #endif /* _UAPI_ASMAXP_PTRACE_H */ --=20 2.39.5 From nobody Sun Feb 8 17:47:05 2026 Received: from minute.unseen.parts (minute.unseen.parts [139.162.151.61]) (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 345D91A841F; Fri, 31 Jan 2025 10:41:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=139.162.151.61 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738320106; cv=none; b=c6DXQpHtFaUhoTJhPZvjwEfZNQtjhMjtzSc4Pw+dKiVSu05azqmJ8SMwi1UbWIxVqveKNrPTCNGf5FkuIN6Hegg6dkOHplAmUIxwCtK+TRQYsmTRukJz2qUoKwpc3yhfJ9v7HV7WR6GCZcd8nzEmSSufxK2BOxCjH2xWGAgW1AQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738320106; c=relaxed/simple; bh=2smcxiM5XxvdBYtmUPSHoVVdF7QRv39VYQIaMXNvlQw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eZEpdS48/NxBexZMqqx5Bn9r7JSjs3BN049TXLaX9zhSsf3KsIOPb8RiM4bdFWm22mtsMgpcoOjisKVT36ZGkRbH0Az6NC55z7TurcnNkhx0XsB1N7cUAMQl/5liz9pgJ25u9wQHAIlayt2QuDIt45a/uRdDGlfHvHi6gy8CfOk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unseen.parts; spf=pass smtp.mailfrom=unseen.parts; dkim=pass (2048-bit key) header.d=unseen.parts header.i=@unseen.parts header.b=tK1KFcJK; arc=none smtp.client-ip=139.162.151.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unseen.parts Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=unseen.parts Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=unseen.parts header.i=@unseen.parts header.b="tK1KFcJK" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=unseen.parts; s=sig; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=w9J9KG9gtYSXkPS4T/DDE4Wq8DI7ifOopO6LJW54POY=; b=tK1KFcJKIm0EeRPu8gwy6D67N0 FM/hLWvKySDnvfiE1hi8n9pC6KQ0Itczn0SUpeKwvboQ3ftMPsVuwjLABM1hTLsqe5o9ahJJKOZGO ywb2QorCbUhps8R3J0Z87+8cW3ta8VYC0eh0HYieFFEixM5+wqy9/AV6+Q18BhBdH/KZVS2cZ/TfN AH04rDbRsf3biIJqBVYW5/ZNs1BnYAKn1muF075JwQaa+LeFbSuAPzMQlnWikv5f+DSX7PCaaCOvc ZdI46NqGAHlfaecgRyZ+JCccJhAWv7EhNR6pYHqxFNVWOYmooG/UXOdSu5CIoX1KEvgdcjYomYYX4 Wew0Ztyw==; Received: from ink by minute.unseen.parts with local (Exim 4.96) (envelope-from ) id 1tdoSo-0002sX-0L; Fri, 31 Jan 2025 11:41:30 +0100 From: Ivan Kokshaysky To: Richard Henderson , Matt Turner , Oleg Nesterov , Al Viro , Arnd Bergmann , "Paul E. McKenney" Cc: "Maciej W. Rozycki" , Magnus Lindholm , John Paul Adrian Glaubitz , linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 2/4] alpha: replace hardcoded stack offsets with autogenerated ones Date: Fri, 31 Jan 2025 11:41:27 +0100 Message-Id: <20250131104129.11052-3-ink@unseen.parts> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250131104129.11052-1-ink@unseen.parts> References: <20250131104129.11052-1-ink@unseen.parts> 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" Cc: stable@vger.kernel.org Signed-off-by: Ivan Kokshaysky Reviewed-by: Maciej W. Rozycki --- arch/alpha/kernel/asm-offsets.c | 4 ++++ arch/alpha/kernel/entry.S | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/alpha/kernel/asm-offsets.c b/arch/alpha/kernel/asm-offset= s.c index 4cfeae42c79a..e9dad60b147f 100644 --- a/arch/alpha/kernel/asm-offsets.c +++ b/arch/alpha/kernel/asm-offsets.c @@ -19,9 +19,13 @@ static void __used foo(void) DEFINE(TI_STATUS, offsetof(struct thread_info, status)); BLANK(); =20 + DEFINE(SP_OFF, offsetof(struct pt_regs, ps)); DEFINE(SIZEOF_PT_REGS, sizeof(struct pt_regs)); BLANK(); =20 + DEFINE(SWITCH_STACK_SIZE, sizeof(struct switch_stack)); + BLANK(); + DEFINE(HAE_CACHE, offsetof(struct alpha_machine_vector, hae_cache)); DEFINE(HAE_REG, offsetof(struct alpha_machine_vector, hae_register)); } diff --git a/arch/alpha/kernel/entry.S b/arch/alpha/kernel/entry.S index dd26062d75b3..6fb38365539d 100644 --- a/arch/alpha/kernel/entry.S +++ b/arch/alpha/kernel/entry.S @@ -15,10 +15,6 @@ .set noat .cfi_sections .debug_frame =20 -/* Stack offsets. */ -#define SP_OFF 184 -#define SWITCH_STACK_SIZE 64 - .macro CFI_START_OSF_FRAME func .align 4 .globl \func --=20 2.39.5 From nobody Sun Feb 8 17:47:05 2026 Received: from minute.unseen.parts (minute.unseen.parts [139.162.151.61]) (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 3462D1ADC6E; Fri, 31 Jan 2025 10:41:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=139.162.151.61 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738320105; cv=none; b=L87tdYOmGQ5XO6CkcgZENPpVfJMbf9bzdBdjOHZF3K1+YqjbEToTCoHihDASah5IsM7ZOjJxyHDVgBi17j7n/zV55g3OST+IAjvmflYFzw5ydxg6LoBEpeObUZQZfgNKPjAbg/h8u4dVD0W6otu0BMqeqDPiMh+zGhV2WLwQ/Jg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738320105; c=relaxed/simple; bh=/3GSmpoCAJhdUHcsH0C4nkKAgmCmf7SvRKRvXj901CA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FUMjYBCa1PQ6RqzkiGilgOLU7vOuxYWPvFJRVlPNndWOVJRXdFsQzHZVpDOgARb/qLGcQtCbP5Ff4dwSIaz1z2SMiMRIJzChCGkE1rZQ+YQEW+qgNMNSdwhx4r3Du1p5HR1d3CWHHJqwJqIiP/72L05KE6STu4tlwnIX/p7VqPE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unseen.parts; spf=pass smtp.mailfrom=unseen.parts; dkim=pass (2048-bit key) header.d=unseen.parts header.i=@unseen.parts header.b=sdQu1rAt; arc=none smtp.client-ip=139.162.151.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unseen.parts Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=unseen.parts Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=unseen.parts header.i=@unseen.parts header.b="sdQu1rAt" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=unseen.parts; s=sig; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=MAGc3C782RcuVPqtgCHWbk9Msj4KMIw5qLn2RNcmO7Q=; b=sdQu1rAtDXIA23nZh/MXfGQVH2 iebOwnwEv1eUX+oiO5uKHUoTMJjtnLDcvYlwH9CzhYQYoeoPjTNktLc7wk3pKjC7ehCdtO9e69rTY Hu6zV/LVhjbCZUsUkSHjvLs/1MAQ6X4q8s+IUGic8F1ZPLYWVPVRWgIPAPZtRINURkW/gpLlNHHt/ BSKEe6vvCMJM44GZLvn6VPn3tNpocnMR+JcL7G5C3rM4pdN3dn3O0CfDIEEnfGTB8F2Qn15SLDz65 ReBkAqp3JTVfIrHEXvx8qN+aEocYh4mijmmqKKfMCmVXkxFVkg+D0/VjrT0ad4BH1ElpIEoESAYZj 8/tiKwKw==; Received: from ink by minute.unseen.parts with local (Exim 4.96) (envelope-from ) id 1tdoSo-0002sc-0k; Fri, 31 Jan 2025 11:41:30 +0100 From: Ivan Kokshaysky To: Richard Henderson , Matt Turner , Oleg Nesterov , Al Viro , Arnd Bergmann , "Paul E. McKenney" Cc: "Maciej W. Rozycki" , Magnus Lindholm , John Paul Adrian Glaubitz , linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 3/4] alpha: make stack 16-byte aligned (most cases) Date: Fri, 31 Jan 2025 11:41:28 +0100 Message-Id: <20250131104129.11052-4-ink@unseen.parts> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250131104129.11052-1-ink@unseen.parts> References: <20250131104129.11052-1-ink@unseen.parts> 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" Add padding between the PAL-saved and kernel-saved registers so that 'struct pt_regs' have an even number of 64-bit words. This makes the stack properly aligned for most of the kernel code, except two handlers which need special threatment. Cc: stable@vger.kernel.org Tested-by: Magnus Lindholm Signed-off-by: Ivan Kokshaysky Reviewed-by: Maciej W. Rozycki --- arch/alpha/include/asm/ptrace.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/alpha/include/asm/ptrace.h b/arch/alpha/include/asm/ptrac= e.h index 693d4c5b4dc7..694b82ca62f3 100644 --- a/arch/alpha/include/asm/ptrace.h +++ b/arch/alpha/include/asm/ptrace.h @@ -41,6 +41,8 @@ struct pt_regs { unsigned long trap_a0; unsigned long trap_a1; unsigned long trap_a2; +/* This makes the stack 16-byte aligned as GCC expects */ + unsigned long __pad0; /* These are saved by PAL-code: */ unsigned long ps; unsigned long pc; --=20 2.39.5 From nobody Sun Feb 8 17:47:05 2026 Received: from minute.unseen.parts (minute.unseen.parts [139.162.151.61]) (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 344D9169397; Fri, 31 Jan 2025 10:41:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=139.162.151.61 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738320106; cv=none; b=QTaTHD0HgsPPeFw8ggd6UOHUGX81oQb5laO4n/GI8FhU647MDKNEtzy6BEOuBd0fd6adefhhOQFV1LCDPV5hWcvXOuEu3cfUpFNZu6CGMcT1a2E+Q5APyH0Riv0nSwMmgJpZXheAzJSqGneqrMgIygEuI3GbCcE+h5e7I3kPR0M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738320106; c=relaxed/simple; bh=UmkogZvigA1LG9ifwuDFidnqTNx1Ze4OAqXxiu0DjmM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=l+Mzl2ODm7uoWwsug/9vibMfJyRHSR0OjLKROm/aQGrvWsUIcBagO+YEJuukJiyevxtigOJqASjeenxfET5tJyqh5miaikya/IvifKxGaTNMkX9e3N0HzGIuJXNs8tnoQqoG3iGOdZNj41iS9naw3az3oDJU0PU8g5hliMMAn60= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unseen.parts; spf=pass smtp.mailfrom=unseen.parts; dkim=pass (2048-bit key) header.d=unseen.parts header.i=@unseen.parts header.b=mvIAz6yH; arc=none smtp.client-ip=139.162.151.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unseen.parts Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=unseen.parts Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=unseen.parts header.i=@unseen.parts header.b="mvIAz6yH" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=unseen.parts; s=sig; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=CVklSc7jRXRCj1OD8jzeeoWSSLGdwqxyPk1kaSQ2dQs=; b=mvIAz6yHZ17hpW9qKMABSP81i3 xvC6ONYVRMytXYdLtBUquARBa7e8TBVPMn7F/B1+n1VA/QMFSX5qhehoezjIkyuy9tW1+mrKSrZl5 R1Qx27kc+u5et8JtdV4l5z0xBXpbDhyT3h/dJOsgLzse4bXFADLG16xjMHxHC4XiHbDmRxHqP5SLR bw94Hw855L+N1RGRTTPZ1xCVU6IYl46f8mND0R4FFp4bSmnMPhLxdlcjjBUVDnBrkmTxkyedp2Zew aXrlA5NO0VKJBQ7RT9XOesZg+V+MkMFcLMtmw3RkOBIil9L7WnqybOZrHHgZjwylm0hGSO/1JMTNB GykKYWaw==; Received: from ink by minute.unseen.parts with local (Exim 4.96) (envelope-from ) id 1tdoSo-0002sh-16; Fri, 31 Jan 2025 11:41:30 +0100 From: Ivan Kokshaysky To: Richard Henderson , Matt Turner , Oleg Nesterov , Al Viro , Arnd Bergmann , "Paul E. McKenney" Cc: "Maciej W. Rozycki" , Magnus Lindholm , John Paul Adrian Glaubitz , linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 4/4] alpha: align stack for page fault and user unaligned trap handlers Date: Fri, 31 Jan 2025 11:41:29 +0100 Message-Id: <20250131104129.11052-5-ink@unseen.parts> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250131104129.11052-1-ink@unseen.parts> References: <20250131104129.11052-1-ink@unseen.parts> 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" do_page_fault() and do_entUna() are special because they use non-standard stack frame layout. Fix them manually. Cc: stable@vger.kernel.org Tested-by: Magnus Lindholm Suggested-by: "Maciej W. Rozycki" Signed-off-by: Ivan Kokshaysky Reviewed-by: Maciej W. Rozycki --- arch/alpha/kernel/entry.S | 20 ++++++++++---------- arch/alpha/kernel/traps.c | 2 +- arch/alpha/mm/fault.c | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/arch/alpha/kernel/entry.S b/arch/alpha/kernel/entry.S index 6fb38365539d..f4d41b4538c2 100644 --- a/arch/alpha/kernel/entry.S +++ b/arch/alpha/kernel/entry.S @@ -194,8 +194,8 @@ CFI_END_OSF_FRAME entArith CFI_START_OSF_FRAME entMM SAVE_ALL /* save $9 - $15 so the inline exception code can manipulate them. */ - subq $sp, 56, $sp - .cfi_adjust_cfa_offset 56 + subq $sp, 64, $sp + .cfi_adjust_cfa_offset 64 stq $9, 0($sp) stq $10, 8($sp) stq $11, 16($sp) @@ -210,7 +210,7 @@ CFI_START_OSF_FRAME entMM .cfi_rel_offset $13, 32 .cfi_rel_offset $14, 40 .cfi_rel_offset $15, 48 - addq $sp, 56, $19 + addq $sp, 64, $19 /* handle the fault */ lda $8, 0x3fff bic $sp, $8, $8 @@ -223,7 +223,7 @@ CFI_START_OSF_FRAME entMM ldq $13, 32($sp) ldq $14, 40($sp) ldq $15, 48($sp) - addq $sp, 56, $sp + addq $sp, 64, $sp .cfi_restore $9 .cfi_restore $10 .cfi_restore $11 @@ -231,7 +231,7 @@ CFI_START_OSF_FRAME entMM .cfi_restore $13 .cfi_restore $14 .cfi_restore $15 - .cfi_adjust_cfa_offset -56 + .cfi_adjust_cfa_offset -64 /* finish up the syscall as normal. */ br ret_from_sys_call CFI_END_OSF_FRAME entMM @@ -378,8 +378,8 @@ entUnaUser: .cfi_restore $0 .cfi_adjust_cfa_offset -256 SAVE_ALL /* setup normal kernel stack */ - lda $sp, -56($sp) - .cfi_adjust_cfa_offset 56 + lda $sp, -64($sp) + .cfi_adjust_cfa_offset 64 stq $9, 0($sp) stq $10, 8($sp) stq $11, 16($sp) @@ -395,7 +395,7 @@ entUnaUser: .cfi_rel_offset $14, 40 .cfi_rel_offset $15, 48 lda $8, 0x3fff - addq $sp, 56, $19 + addq $sp, 64, $19 bic $sp, $8, $8 jsr $26, do_entUnaUser ldq $9, 0($sp) @@ -405,7 +405,7 @@ entUnaUser: ldq $13, 32($sp) ldq $14, 40($sp) ldq $15, 48($sp) - lda $sp, 56($sp) + lda $sp, 64($sp) .cfi_restore $9 .cfi_restore $10 .cfi_restore $11 @@ -413,7 +413,7 @@ entUnaUser: .cfi_restore $13 .cfi_restore $14 .cfi_restore $15 - .cfi_adjust_cfa_offset -56 + .cfi_adjust_cfa_offset -64 br ret_from_sys_call CFI_END_OSF_FRAME entUna =20 diff --git a/arch/alpha/kernel/traps.c b/arch/alpha/kernel/traps.c index a9a38c80c4a7..7004397937cf 100644 --- a/arch/alpha/kernel/traps.c +++ b/arch/alpha/kernel/traps.c @@ -649,7 +649,7 @@ s_reg_to_mem (unsigned long s_reg) static int unauser_reg_offsets[32] =3D { R(r0), R(r1), R(r2), R(r3), R(r4), R(r5), R(r6), R(r7), R(r8), /* r9 ... r15 are stored in front of regs. */ - -56, -48, -40, -32, -24, -16, -8, + -64, -56, -48, -40, -32, -24, -16, /* padding at -8 */ R(r16), R(r17), R(r18), R(r19), R(r20), R(r21), R(r22), R(r23), R(r24), R(r25), R(r26), R(r27), R(r28), R(gp), diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c index 8c9850437e67..a9816bbc9f34 100644 --- a/arch/alpha/mm/fault.c +++ b/arch/alpha/mm/fault.c @@ -78,8 +78,8 @@ __load_new_mm_context(struct mm_struct *next_mm) =20 /* Macro for exception fixup code to access integer registers. */ #define dpf_reg(r) \ - (((unsigned long *)regs)[(r) <=3D 8 ? (r) : (r) <=3D 15 ? (r)-16 : \ - (r) <=3D 18 ? (r)+10 : (r)-10]) + (((unsigned long *)regs)[(r) <=3D 8 ? (r) : (r) <=3D 15 ? (r)-17 : \ + (r) <=3D 18 ? (r)+11 : (r)-10]) =20 asmlinkage void do_page_fault(unsigned long address, unsigned long mmcsr, --=20 2.39.5