* [PATCH] LoongArch: ptrace: Use UAPI types in UAPI header
@ 2025-10-29 15:20 Thomas Weißschuh
2025-11-03 9:12 ` Huacai Chen
2025-11-14 4:41 ` Huacai Chen
0 siblings, 2 replies; 7+ messages in thread
From: Thomas Weißschuh @ 2025-10-29 15:20 UTC (permalink / raw)
To: Huacai Chen, WANG Xuerui, Jiaxun Yang
Cc: loongarch, linux-kernel, Thomas Weißschuh
The kernel UAPI headers already contain fixed-width integer types,
there is no need to rely on libc types. There may not be a libc
available or it may not provide <stdint.h>, like for example on nolibc.
This also aligns the header with the rest of the LoongArch UAPI headers.
Fixes: 803b0fc5c3f2 ("LoongArch: Add process management")
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
I'd like to take this through the nolibc tree, as this currently breaks
the upcoming nolibc ptrace support.
---
arch/loongarch/include/uapi/asm/ptrace.h | 40 ++++++++++++++------------------
1 file changed, 18 insertions(+), 22 deletions(-)
diff --git a/arch/loongarch/include/uapi/asm/ptrace.h b/arch/loongarch/include/uapi/asm/ptrace.h
index aafb3cd9e943..215e0f9e8aa3 100644
--- a/arch/loongarch/include/uapi/asm/ptrace.h
+++ b/arch/loongarch/include/uapi/asm/ptrace.h
@@ -10,10 +10,6 @@
#include <linux/types.h>
-#ifndef __KERNEL__
-#include <stdint.h>
-#endif
-
/*
* For PTRACE_{POKE,PEEK}USR. 0 - 31 are GPRs,
* 32 is syscall's original ARG0, 33 is PC, 34 is BADVADDR.
@@ -41,44 +37,44 @@ struct user_pt_regs {
} __attribute__((aligned(8)));
struct user_fp_state {
- uint64_t fpr[32];
- uint64_t fcc;
- uint32_t fcsr;
+ __u64 fpr[32];
+ __u64 fcc;
+ __u32 fcsr;
};
struct user_lsx_state {
/* 32 registers, 128 bits width per register. */
- uint64_t vregs[32*2];
+ __u64 vregs[32*2];
};
struct user_lasx_state {
/* 32 registers, 256 bits width per register. */
- uint64_t vregs[32*4];
+ __u64 vregs[32*4];
};
struct user_lbt_state {
- uint64_t scr[4];
- uint32_t eflags;
- uint32_t ftop;
+ __u64 scr[4];
+ __u32 eflags;
+ __u32 ftop;
};
struct user_watch_state {
- uint64_t dbg_info;
+ __u64 dbg_info;
struct {
- uint64_t addr;
- uint64_t mask;
- uint32_t ctrl;
- uint32_t pad;
+ __u64 addr;
+ __u64 mask;
+ __u32 ctrl;
+ __u32 pad;
} dbg_regs[8];
};
struct user_watch_state_v2 {
- uint64_t dbg_info;
+ __u64 dbg_info;
struct {
- uint64_t addr;
- uint64_t mask;
- uint32_t ctrl;
- uint32_t pad;
+ __u64 addr;
+ __u64 mask;
+ __u32 ctrl;
+ __u32 pad;
} dbg_regs[14];
};
---
base-commit: 3a8660878839faadb4f1a6dd72c3179c1df56787
change-id: 20251029-loongarch-uapi-ptrace-types-0c5c6756f7e0
Best regards,
--
Thomas Weißschuh <linux@weissschuh.net>
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] LoongArch: ptrace: Use UAPI types in UAPI header
2025-10-29 15:20 [PATCH] LoongArch: ptrace: Use UAPI types in UAPI header Thomas Weißschuh
@ 2025-11-03 9:12 ` Huacai Chen
2025-11-03 9:27 ` Thomas Weißschuh
2025-11-03 9:41 ` Arnd Bergmann
2025-11-14 4:41 ` Huacai Chen
1 sibling, 2 replies; 7+ messages in thread
From: Huacai Chen @ 2025-11-03 9:12 UTC (permalink / raw)
To: Thomas Weißschuh; +Cc: WANG Xuerui, Jiaxun Yang, loongarch, linux-kernel
Hi, Thomas,
On Wed, Oct 29, 2025 at 11:20 PM Thomas Weißschuh <linux@weissschuh.net> wrote:
>
> The kernel UAPI headers already contain fixed-width integer types,
> there is no need to rely on libc types. There may not be a libc
> available or it may not provide <stdint.h>, like for example on nolibc.
>
> This also aligns the header with the rest of the LoongArch UAPI headers.
Thank you for your patch, but could you please tell me some history
and user guide about the three styles: u64, __u64 and unint64_t?
Huacai
>
> Fixes: 803b0fc5c3f2 ("LoongArch: Add process management")
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
> I'd like to take this through the nolibc tree, as this currently breaks
> the upcoming nolibc ptrace support.
> ---
> arch/loongarch/include/uapi/asm/ptrace.h | 40 ++++++++++++++------------------
> 1 file changed, 18 insertions(+), 22 deletions(-)
>
> diff --git a/arch/loongarch/include/uapi/asm/ptrace.h b/arch/loongarch/include/uapi/asm/ptrace.h
> index aafb3cd9e943..215e0f9e8aa3 100644
> --- a/arch/loongarch/include/uapi/asm/ptrace.h
> +++ b/arch/loongarch/include/uapi/asm/ptrace.h
> @@ -10,10 +10,6 @@
>
> #include <linux/types.h>
>
> -#ifndef __KERNEL__
> -#include <stdint.h>
> -#endif
> -
> /*
> * For PTRACE_{POKE,PEEK}USR. 0 - 31 are GPRs,
> * 32 is syscall's original ARG0, 33 is PC, 34 is BADVADDR.
> @@ -41,44 +37,44 @@ struct user_pt_regs {
> } __attribute__((aligned(8)));
>
> struct user_fp_state {
> - uint64_t fpr[32];
> - uint64_t fcc;
> - uint32_t fcsr;
> + __u64 fpr[32];
> + __u64 fcc;
> + __u32 fcsr;
> };
>
> struct user_lsx_state {
> /* 32 registers, 128 bits width per register. */
> - uint64_t vregs[32*2];
> + __u64 vregs[32*2];
> };
>
> struct user_lasx_state {
> /* 32 registers, 256 bits width per register. */
> - uint64_t vregs[32*4];
> + __u64 vregs[32*4];
> };
>
> struct user_lbt_state {
> - uint64_t scr[4];
> - uint32_t eflags;
> - uint32_t ftop;
> + __u64 scr[4];
> + __u32 eflags;
> + __u32 ftop;
> };
>
> struct user_watch_state {
> - uint64_t dbg_info;
> + __u64 dbg_info;
> struct {
> - uint64_t addr;
> - uint64_t mask;
> - uint32_t ctrl;
> - uint32_t pad;
> + __u64 addr;
> + __u64 mask;
> + __u32 ctrl;
> + __u32 pad;
> } dbg_regs[8];
> };
>
> struct user_watch_state_v2 {
> - uint64_t dbg_info;
> + __u64 dbg_info;
> struct {
> - uint64_t addr;
> - uint64_t mask;
> - uint32_t ctrl;
> - uint32_t pad;
> + __u64 addr;
> + __u64 mask;
> + __u32 ctrl;
> + __u32 pad;
> } dbg_regs[14];
> };
>
>
> ---
> base-commit: 3a8660878839faadb4f1a6dd72c3179c1df56787
> change-id: 20251029-loongarch-uapi-ptrace-types-0c5c6756f7e0
>
> Best regards,
> --
> Thomas Weißschuh <linux@weissschuh.net>
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] LoongArch: ptrace: Use UAPI types in UAPI header
2025-11-03 9:12 ` Huacai Chen
@ 2025-11-03 9:27 ` Thomas Weißschuh
2025-11-03 9:38 ` Huacai Chen
2025-11-03 9:41 ` Arnd Bergmann
1 sibling, 1 reply; 7+ messages in thread
From: Thomas Weißschuh @ 2025-11-03 9:27 UTC (permalink / raw)
To: Huacai Chen; +Cc: WANG Xuerui, Jiaxun Yang, loongarch, linux-kernel
Hi Huacai,
On 2025-11-03 17:12:58+0800, Huacai Chen wrote:
> On Wed, Oct 29, 2025 at 11:20 PM Thomas Weißschuh <linux@weissschuh.net> wrote:
> >
> > The kernel UAPI headers already contain fixed-width integer types,
> > there is no need to rely on libc types. There may not be a libc
> > available or it may not provide <stdint.h>, like for example on nolibc.
> >
> > This also aligns the header with the rest of the LoongArch UAPI headers.
> Thank you for your patch, but could you please tell me some history
> and user guide about the three styles: u64, __u64 and unint64_t?
uint64_t -> userspace type, should not be used within the kernel
can technically be used in UAPI it will be somewhat
nonstandard and introduce a dependency on libc with no
upsides.
u64 -> kernel-internal type, used for regular kernel code
defined in include/linux/types.h
__u64 -> UAPI type usable from both kernel and userspace code
defined in include/uapi/linux/types.
As a note: When applying the patch I want to clarify the commit message
a bit, as nolibc indeed has a stdint.h header. The real breakage comes
from a validation step we perform which does not add the libc include
directory to the include path.
Thomas
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] LoongArch: ptrace: Use UAPI types in UAPI header
2025-11-03 9:27 ` Thomas Weißschuh
@ 2025-11-03 9:38 ` Huacai Chen
2025-11-08 10:08 ` Thomas Weißschuh
0 siblings, 1 reply; 7+ messages in thread
From: Huacai Chen @ 2025-11-03 9:38 UTC (permalink / raw)
To: Thomas Weißschuh; +Cc: WANG Xuerui, Jiaxun Yang, loongarch, linux-kernel
On Mon, Nov 3, 2025 at 5:27 PM Thomas Weißschuh <linux@weissschuh.net> wrote:
>
> Hi Huacai,
>
> On 2025-11-03 17:12:58+0800, Huacai Chen wrote:
> > On Wed, Oct 29, 2025 at 11:20 PM Thomas Weißschuh <linux@weissschuh.net> wrote:
> > >
> > > The kernel UAPI headers already contain fixed-width integer types,
> > > there is no need to rely on libc types. There may not be a libc
> > > available or it may not provide <stdint.h>, like for example on nolibc.
> > >
> > > This also aligns the header with the rest of the LoongArch UAPI headers.
>
> > Thank you for your patch, but could you please tell me some history
> > and user guide about the three styles: u64, __u64 and unint64_t?
>
> uint64_t -> userspace type, should not be used within the kernel
> can technically be used in UAPI it will be somewhat
> nonstandard and introduce a dependency on libc with no
> upsides.
But a simple grep shows there are many uses of uint64_t in the kernel
code, are they all wrong?
Huacai
>
> u64 -> kernel-internal type, used for regular kernel code
> defined in include/linux/types.h
>
> __u64 -> UAPI type usable from both kernel and userspace code
> defined in include/uapi/linux/types.
>
> As a note: When applying the patch I want to clarify the commit message
> a bit, as nolibc indeed has a stdint.h header. The real breakage comes
> from a validation step we perform which does not add the libc include
> directory to the include path.
>
>
> Thomas
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] LoongArch: ptrace: Use UAPI types in UAPI header
2025-11-03 9:12 ` Huacai Chen
2025-11-03 9:27 ` Thomas Weißschuh
@ 2025-11-03 9:41 ` Arnd Bergmann
1 sibling, 0 replies; 7+ messages in thread
From: Arnd Bergmann @ 2025-11-03 9:41 UTC (permalink / raw)
To: Huacai Chen, Thomas Weißschuh
Cc: WANG Xuerui, Jiaxun Yang, loongarch, linux-kernel
On Mon, Nov 3, 2025, at 10:12, Huacai Chen wrote:
> Hi, Thomas,
>
> On Wed, Oct 29, 2025 at 11:20 PM Thomas Weißschuh <linux@weissschuh.net> wrote:
>>
>> The kernel UAPI headers already contain fixed-width integer types,
>> there is no need to rely on libc types. There may not be a libc
>> available or it may not provide <stdint.h>, like for example on nolibc.
>>
>> This also aligns the header with the rest of the LoongArch UAPI headers.
Thanks! I ran into the same issue for a different series, so this is most welcome.
> Thank you for your patch, but could you please tell me some history
> and user guide about the three styles: u64, __u64 and unint64_t?
The kernel uapi headers use __u64 etc so they can be included in user
applications without clashing with any types they might define themselves
auch as u64.
The uint64_t style types are problematic because they are provided
by toolchain in userspace, so build-testing the uapi headers would depend
on a working (userspace) cross-compiler rather than just a minimal
(nolibc) toolchain, and because the standard headers are meant to
only be included if specified explicitly by application source code
rather than indirectly from another header.
This was more problematic in the past when it was more common for
applications to be built with pre-c99 compilers that were missing
stdint.h altogether.
Arnd
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] LoongArch: ptrace: Use UAPI types in UAPI header
2025-11-03 9:38 ` Huacai Chen
@ 2025-11-08 10:08 ` Thomas Weißschuh
0 siblings, 0 replies; 7+ messages in thread
From: Thomas Weißschuh @ 2025-11-08 10:08 UTC (permalink / raw)
To: Huacai Chen; +Cc: WANG Xuerui, Jiaxun Yang, loongarch, linux-kernel
On 2025-11-03 17:38:49+0800, Huacai Chen wrote:
> On Mon, Nov 3, 2025 at 5:27 PM Thomas Weißschuh <linux@weissschuh.net> wrote:
> > On 2025-11-03 17:12:58+0800, Huacai Chen wrote:
> > > On Wed, Oct 29, 2025 at 11:20 PM Thomas Weißschuh <linux@weissschuh.net> wrote:
> > > >
> > > > The kernel UAPI headers already contain fixed-width integer types,
> > > > there is no need to rely on libc types. There may not be a libc
> > > > available or it may not provide <stdint.h>, like for example on nolibc.
> > > >
> > > > This also aligns the header with the rest of the LoongArch UAPI headers.
> >
> > > Thank you for your patch, but could you please tell me some history
> > > and user guide about the three styles: u64, __u64 and unint64_t?
> >
> > uint64_t -> userspace type, should not be used within the kernel
> > can technically be used in UAPI it will be somewhat
> > nonstandard and introduce a dependency on libc with no
> > upsides.
> But a simple grep shows there are many uses of uint64_t in the kernel
> code, are they all wrong?
Yes, they are wrong. See also the explanation from Arnd.
> > u64 -> kernel-internal type, used for regular kernel code
> > defined in include/linux/types.h
> >
> > __u64 -> UAPI type usable from both kernel and userspace code
> > defined in include/uapi/linux/types.
> >
> > As a note: When applying the patch I want to clarify the commit message
> > a bit, as nolibc indeed has a stdint.h header. The real breakage comes
> > from a validation step we perform which does not add the libc include
> > directory to the include path.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] LoongArch: ptrace: Use UAPI types in UAPI header
2025-10-29 15:20 [PATCH] LoongArch: ptrace: Use UAPI types in UAPI header Thomas Weißschuh
2025-11-03 9:12 ` Huacai Chen
@ 2025-11-14 4:41 ` Huacai Chen
1 sibling, 0 replies; 7+ messages in thread
From: Huacai Chen @ 2025-11-14 4:41 UTC (permalink / raw)
To: Thomas Weißschuh; +Cc: WANG Xuerui, Jiaxun Yang, loongarch, linux-kernel
Applied, thanks.
Huacai
On Wed, Oct 29, 2025 at 11:20 PM Thomas Weißschuh <linux@weissschuh.net> wrote:
>
> The kernel UAPI headers already contain fixed-width integer types,
> there is no need to rely on libc types. There may not be a libc
> available or it may not provide <stdint.h>, like for example on nolibc.
>
> This also aligns the header with the rest of the LoongArch UAPI headers.
>
> Fixes: 803b0fc5c3f2 ("LoongArch: Add process management")
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
> I'd like to take this through the nolibc tree, as this currently breaks
> the upcoming nolibc ptrace support.
> ---
> arch/loongarch/include/uapi/asm/ptrace.h | 40 ++++++++++++++------------------
> 1 file changed, 18 insertions(+), 22 deletions(-)
>
> diff --git a/arch/loongarch/include/uapi/asm/ptrace.h b/arch/loongarch/include/uapi/asm/ptrace.h
> index aafb3cd9e943..215e0f9e8aa3 100644
> --- a/arch/loongarch/include/uapi/asm/ptrace.h
> +++ b/arch/loongarch/include/uapi/asm/ptrace.h
> @@ -10,10 +10,6 @@
>
> #include <linux/types.h>
>
> -#ifndef __KERNEL__
> -#include <stdint.h>
> -#endif
> -
> /*
> * For PTRACE_{POKE,PEEK}USR. 0 - 31 are GPRs,
> * 32 is syscall's original ARG0, 33 is PC, 34 is BADVADDR.
> @@ -41,44 +37,44 @@ struct user_pt_regs {
> } __attribute__((aligned(8)));
>
> struct user_fp_state {
> - uint64_t fpr[32];
> - uint64_t fcc;
> - uint32_t fcsr;
> + __u64 fpr[32];
> + __u64 fcc;
> + __u32 fcsr;
> };
>
> struct user_lsx_state {
> /* 32 registers, 128 bits width per register. */
> - uint64_t vregs[32*2];
> + __u64 vregs[32*2];
> };
>
> struct user_lasx_state {
> /* 32 registers, 256 bits width per register. */
> - uint64_t vregs[32*4];
> + __u64 vregs[32*4];
> };
>
> struct user_lbt_state {
> - uint64_t scr[4];
> - uint32_t eflags;
> - uint32_t ftop;
> + __u64 scr[4];
> + __u32 eflags;
> + __u32 ftop;
> };
>
> struct user_watch_state {
> - uint64_t dbg_info;
> + __u64 dbg_info;
> struct {
> - uint64_t addr;
> - uint64_t mask;
> - uint32_t ctrl;
> - uint32_t pad;
> + __u64 addr;
> + __u64 mask;
> + __u32 ctrl;
> + __u32 pad;
> } dbg_regs[8];
> };
>
> struct user_watch_state_v2 {
> - uint64_t dbg_info;
> + __u64 dbg_info;
> struct {
> - uint64_t addr;
> - uint64_t mask;
> - uint32_t ctrl;
> - uint32_t pad;
> + __u64 addr;
> + __u64 mask;
> + __u32 ctrl;
> + __u32 pad;
> } dbg_regs[14];
> };
>
>
> ---
> base-commit: 3a8660878839faadb4f1a6dd72c3179c1df56787
> change-id: 20251029-loongarch-uapi-ptrace-types-0c5c6756f7e0
>
> Best regards,
> --
> Thomas Weißschuh <linux@weissschuh.net>
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-11-14 4:41 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-29 15:20 [PATCH] LoongArch: ptrace: Use UAPI types in UAPI header Thomas Weißschuh
2025-11-03 9:12 ` Huacai Chen
2025-11-03 9:27 ` Thomas Weißschuh
2025-11-03 9:38 ` Huacai Chen
2025-11-08 10:08 ` Thomas Weißschuh
2025-11-03 9:41 ` Arnd Bergmann
2025-11-14 4:41 ` Huacai Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox