From nobody Mon Feb 9 19:26:08 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