Skip to contentSkip to conversation

parisc: Avoid compat syscalls when COMPAT=n

PATCH In review Helge Deller 5 participants 10 messages Apr 7 – Apr 8 PA-RISC architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 parisc: Avoid compat syscalls when COMPAT=n

From: Helge Deller <[email protected]>

Drop unnecessary code and syscall tables when we run a 64-bit kernel with conpat mode disabled.

---
 arch/parisc/kernel/syscall.S | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
arch/parisc/kernel/syscall.S +7 -4
index f58c4bccfbce..bc5421ca537f 100644
@@ -241,7 +241,7 @@ linux_gateway_entry:
 	/* Note!  We cannot use the syscall table that is mapped
 	nearby since the gateway page is mapped execute-only. */
 
-#ifdef CONFIG_64BIT
+#if defined(CONFIG_64BIT) && defined(CONFIG_COMPAT)
 	ldil	L%sys_call_table, %r1
 	or,ev	%r2,%r2,%r2
 	ldil	L%sys_call_table64, %r1
@@ -250,7 +250,7 @@ linux_gateway_entry:
 	ldo	R%sys_call_table64(%r1), %r19
 #else
 	load32	sys_call_table, %r19
-#endif	
+#endif
 	comiclr,>>	__NR_Linux_syscalls, %r20, %r0
 	b,n	.Lsyscall_nosys
 	
@@ -374,7 +374,7 @@ tracesys_next:
 	/* Note!  We cannot use the syscall table that is mapped
 	nearby since the gateway page is mapped execute-only. */
 
-#ifdef CONFIG_64BIT
+#if defined(CONFIG_64BIT) && defined(CONFIG_COMPAT)
 	LDREG	TASK_PT_GR30(%r1), %r19		/* get users sp back */
 	extrd,u	%r19,63,1,%r2			/* W hidden in bottom bit */
 
@@ -1326,16 +1326,19 @@ ENTRY(lws_table)
 END(lws_table)
 	/* End of lws table */
 
-#ifdef CONFIG_64BIT
+#ifdef CONFIG_COMPAT
 #define __SYSCALL_WITH_COMPAT(nr, native, compat)	__SYSCALL(nr, compat)
 #else
 #define __SYSCALL_WITH_COMPAT(nr, native, compat)	__SYSCALL(nr, native)
 #endif
 #define __SYSCALL(nr, entry)	ASM_ULONG_INSN entry
+
 	.align 8
 ENTRY(sys_call_table)
 	.export sys_call_table,data
+#if defined(CONFIG_COMPAT) || !defined(CONFIG_64BIT)
 #include <asm/syscall_table_32.h>    /* 32-bit syscalls */
+#endif
 END(sys_call_table)
 
 #ifdef CONFIG_64BIT
Signature · 1 line
2.53.0
#1 lore raw

PATCH 2/5 parisc: let is_compat_task() return false for COMPAT=n

From: Helge Deller <[email protected]>

---
 arch/parisc/include/asm/compat.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/parisc/include/asm/compat.h +1 -1
index 339d1b833fa7..13a5a55dec65 100644
@@ -130,7 +130,7 @@ typedef compat_ulong_t compat_elf_gregset_t[COMPAT_ELF_NGREG];
 
 static inline int __is_compat_task(struct task_struct *t)
 {
-	return test_tsk_thread_flag(t, TIF_32BIT);
+	return IS_ENABLED(CONFIG_COMPAT) && test_tsk_thread_flag(t, TIF_32BIT);
 }
 
 static inline int is_compat_task(void)
Signature · 1 line
2.53.0
#2 lore raw

PATCH 3/5 parisc: Fix signal code to depend on CONFIG_COMPAT instead of CONFIG_64BIT

In reply to Helge Deller

From: Helge Deller <[email protected]>

The signal handler code used CONFIG_64BIT to decide if compat handling code should be compiled in. Fix it to use CONFIG_COMPAT instead. This allows to disable CONFIG_COMPAT even when running a 64-bit kernel.

---
 arch/parisc/kernel/signal.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
arch/parisc/kernel/signal.c +9 -9
index e8d27def6c52..64a62006bb15 100644
@@ -80,7 +80,7 @@ sys_rt_sigreturn(struct pt_regs *regs, int in_syscall)
 	sigset_t set;
 	unsigned long usp = (regs->gr[30] & ~(0x01UL));
 	unsigned long sigframe_size = PARISC_RT_SIGFRAME_SIZE;
-#ifdef CONFIG_64BIT
+#ifdef CONFIG_COMPAT
 	struct compat_rt_sigframe __user * compat_frame;
 	
 	if (is_compat_task())
@@ -96,7 +96,7 @@ sys_rt_sigreturn(struct pt_regs *regs, int in_syscall)
 
 	regs->orig_r28 = 1; /* no restarts for sigreturn */
 
-#ifdef CONFIG_64BIT
+#ifdef CONFIG_COMPAT
 	compat_frame = (struct compat_rt_sigframe __user *)frame;
 	
 	if (is_compat_task()) {
@@ -112,7 +112,7 @@ sys_rt_sigreturn(struct pt_regs *regs, int in_syscall)
 	set_current_blocked(&set);
 
 	/* Good thing we saved the old gr[30], eh? */
-#ifdef CONFIG_64BIT
+#ifdef CONFIG_COMPAT
 	if (is_compat_task()) {
 		DBG(1, "%s: compat_frame->uc.uc_mcontext 0x%p\n",
 				__func__, &compat_frame->uc.uc_mcontext);
@@ -218,13 +218,13 @@ setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs,
 	unsigned long haddr, sigframe_size;
 	unsigned long start;
 	int err = 0;
-#ifdef CONFIG_64BIT
+#ifdef CONFIG_COMPAT
 	struct compat_rt_sigframe __user * compat_frame;
 #endif
-	
+
 	usp = (regs->gr[30] & ~(0x01UL));
 	sigframe_size = PARISC_RT_SIGFRAME_SIZE;
-#ifdef CONFIG_64BIT
+#ifdef CONFIG_COMPAT
 	if (is_compat_task()) {
 		/* The gcc alloca implementation leaves garbage in the upper 32 bits of sp */
 		usp = (compat_uint_t)usp;
@@ -239,7 +239,7 @@ setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs,
 	if (start >= TASK_SIZE_MAX - sigframe_size)
 		return -EFAULT;
 	
-#ifdef CONFIG_64BIT
+#ifdef CONFIG_COMPAT
 
 	compat_frame = (struct compat_rt_sigframe __user *)frame;
 	
@@ -349,8 +349,8 @@ setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs,
 
 	regs->gr[2]  = rp;			/* userland return pointer */
 	regs->gr[26] = ksig->sig;               /* signal number */
-	
-#ifdef CONFIG_64BIT
+
+#ifdef CONFIG_COMPAT
 	if (is_compat_task()) {
 		regs->gr[25] = A(&compat_frame->info); /* siginfo pointer */
 		regs->gr[24] = A(&compat_frame->uc);   /* ucontext pointer */
Signature · 1 line
2.53.0
#3 lore raw

PATCH 4/5 parisc: Fix default stack size when COMPAT=n

In reply to Helge Deller

From: Helge Deller <[email protected]>

The CONFIG_STACK_MAX_DEFAULT_SIZE_MB config option does not exist when CONFIG_COMPAT is disabled. Use default 1GB stack in this case.

---
 arch/parisc/kernel/sys_parisc.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/parisc/kernel/sys_parisc.c +4 -0
index b2cdbb8a12b1..0ffe91d214d6 100644
@@ -50,9 +50,13 @@ static inline unsigned long COLOR_ALIGN(unsigned long addr,
 }
 
 
+#ifdef CONFIG_COMPAT
 #define STACK_SIZE_DEFAULT (USER_WIDE_MODE			\
 			? (1 << 30)	/* 1 GB */		\
 			: (CONFIG_STACK_MAX_DEFAULT_SIZE_MB*1024*1024))
+#else
+#define STACK_SIZE_DEFAULT (1 << 30)
+#endif
 
 unsigned long calc_max_stack_size(unsigned long stack_max)
 {
Signature · 1 line
2.53.0
#4 lore raw

PATCH 5/5 parisc: Allow to disable COMPAT mode on 64-bit kernel

In reply to Helge Deller

From: Helge Deller <[email protected]>

Although we don't yet have a 64-bit userspace, allowing to disable the compat mode should be possible.

---
 arch/parisc/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/parisc/Kconfig +2 -1
index 5a8cd50e8d70..d2273d5c08a0 100644
@@ -355,7 +355,8 @@ config ARCH_SPARSEMEM_DEFAULT
 source "kernel/Kconfig.hz"
 
 config COMPAT
-	def_bool y
+	bool "Kernel support for 32-bit binaries"
+	default 64BIT
 	depends on 64BIT
 
 config AUDIT_ARCH
Signature · 1 line
2.53.0
#5 lore raw
In reply to Helge Deller

Hi Helge,

thanks for these patches!

Quoted 8 lines · Helge Deller

From: Helge Deller <[email protected]>

Drop unnecessary code and syscall tables when we run a 64-bit kernel with conpat mode disabled.

---
 arch/parisc/kernel/syscall.S | 11 +++++++----

The series currently does not disable the 32-bit vDSO when CONFIG_COMPAT=n. Is this intentional? For me it would be convenient disabling it to avoid the dependency on a 32-bit toolchain.

arch/parisc/kernel/syscall.S linux_gateway_entry: · line 244

Quoted 12 lines
 1 file changed, 7 insertions(+), 4 deletions(-)
arch/parisc/kernel/syscall.S +1 -1
index f58c4bccfbce..bc5421ca537f 100644
@@ -241,7 +241,7 @@ linux_gateway_entry:
 	/* Note!  We cannot use the syscall table that is mapped
 	nearby since the gateway page is mapped execute-only. */
 
-#ifdef CONFIG_64BIT
+#if defined(CONFIG_64BIT) && defined(CONFIG_COMPAT)

Shouldn't this also be just plain '#ifdef CONFIG_COMPAT' like in the other patches?

Quoted 13 lines
arch/parisc/kernel/syscall.S +1 -1
 	ldil	L%sys_call_table, %r1
 	or,ev	%r2,%r2,%r2
 	ldil	L%sys_call_table64, %r1
@@ -250,7 +250,7 @@ linux_gateway_entry:
 	ldo	R%sys_call_table64(%r1), %r19
 #else
 	load32	sys_call_table, %r19
-#endif	
+#endif
 	comiclr,>>	__NR_Linux_syscalls, %r20, %r0
 	b,n	.Lsyscall_nosys
 

arch/parisc/kernel/syscall.S tracesys_next: · line 377

Quoted 5 lines
arch/parisc/kernel/syscall.S +1 -1
@@ -374,7 +374,7 @@ tracesys_next:
 	/* Note!  We cannot use the syscall table that is mapped
 	nearby since the gateway page is mapped execute-only. */
 
-#ifdef CONFIG_64BIT
+#if defined(CONFIG_64BIT) && defined(CONFIG_COMPAT)

Ditto.

Quoted 6 lines
arch/parisc/kernel/syscall.S +0 -0
 	LDREG	TASK_PT_GR30(%r1), %r19		/* get users sp back */
 	extrd,u	%r19,63,1,%r2			/* W hidden in bottom bit */
 
@@ -1326,16 +1326,19 @@ ENTRY(lws_table)
 END(lws_table)
 	/* End of lws table */

(...)

maintainer
#6 lore raw
Quoted 6 lines · Thomas Weißschuh
Quoted 5 lines · Helge Deller

From: Helge Deller <[email protected]>

Drop unnecessary code and syscall tables when we run a 64-bit kernel with conpat mode disabled.

Quoted 6 lines
Quoted 3 lines
---
  arch/parisc/kernel/syscall.S | 11 +++++++----

The series currently does not disable the 32-bit vDSO when CONFIG_COMPAT=n. Is this intentional?

No, but I had not yet figured out how :-)

Quoted 2 lines

For me it would be convenient
disabling it to avoid the dependency on a 32-bit toolchain.

Right. Will try.

Quoted 10 lines
Quoted 10 lines
  1 file changed, 7 insertions(+), 4 deletions(-)
arch/parisc/kernel/syscall.S +0 -0
index f58c4bccfbce..bc5421ca537f 100644
@@ -241,7 +241,7 @@ linux_gateway_entry:
  	/* Note!  We cannot use the syscall table that is mapped
  	nearby since the gateway page is mapped execute-only. */
 
Quoted 5 lines

arch/parisc/kernel/syscall.S linux_gateway_entry: · line 244

Quoted 2 lines
arch/parisc/kernel/syscall.S +1 -1
-#ifdef CONFIG_64BIT
+#if defined(CONFIG_64BIT) && defined(CONFIG_COMPAT)

Shouldn't this also be just plain '#ifdef CONFIG_COMPAT' like in the other patches?

Yes. (will fix both),

Thanks!
Helge

#7 lore raw
In reply to Helge Deller
Quoted 6 lines · Helge Deller

From: Helge Deller <[email protected]>

Drop unnecessary code and syscall tables when we run a 64-bit kernel with conpat mode disabled.

Hi

Where can I download 64-bit parisc userspace? I am interested in trying it.

Mikulas

Quoted 60 lines
---
 arch/parisc/kernel/syscall.S | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
arch/parisc/kernel/syscall.S +7 -4
index f58c4bccfbce..bc5421ca537f 100644
@@ -241,7 +241,7 @@ linux_gateway_entry:
 	/* Note!  We cannot use the syscall table that is mapped
 	nearby since the gateway page is mapped execute-only. */
 
-#ifdef CONFIG_64BIT
+#if defined(CONFIG_64BIT) && defined(CONFIG_COMPAT)
 	ldil	L%sys_call_table, %r1
 	or,ev	%r2,%r2,%r2
 	ldil	L%sys_call_table64, %r1
@@ -250,7 +250,7 @@ linux_gateway_entry:
 	ldo	R%sys_call_table64(%r1), %r19
 #else
 	load32	sys_call_table, %r19
-#endif	
+#endif
 	comiclr,>>	__NR_Linux_syscalls, %r20, %r0
 	b,n	.Lsyscall_nosys
 
@@ -374,7 +374,7 @@ tracesys_next:
 	/* Note!  We cannot use the syscall table that is mapped
 	nearby since the gateway page is mapped execute-only. */
 
-#ifdef CONFIG_64BIT
+#if defined(CONFIG_64BIT) && defined(CONFIG_COMPAT)
 	LDREG	TASK_PT_GR30(%r1), %r19		/* get users sp back */
 	extrd,u	%r19,63,1,%r2			/* W hidden in bottom bit */
 
@@ -1326,16 +1326,19 @@ ENTRY(lws_table)
 END(lws_table)
 	/* End of lws table */
 
-#ifdef CONFIG_64BIT
+#ifdef CONFIG_COMPAT
 #define __SYSCALL_WITH_COMPAT(nr, native, compat)	__SYSCALL(nr, compat)
 #else
 #define __SYSCALL_WITH_COMPAT(nr, native, compat)	__SYSCALL(nr, native)
 #endif
 #define __SYSCALL(nr, entry)	ASM_ULONG_INSN entry
+
 	.align 8
 ENTRY(sys_call_table)
 	.export sys_call_table,data
+#if defined(CONFIG_COMPAT) || !defined(CONFIG_64BIT)
 #include <asm/syscall_table_32.h>    /* 32-bit syscalls */
+#endif
 END(sys_call_table)
 
 #ifdef CONFIG_64BIT
Signature · 1 line
2.53.0
maintainer
#8 lore raw

Hi Mikulas,

Quoted 7 lines · Mikulas Patocka
Quoted 4 lines · Helge Deller

From: Helge Deller <[email protected]>

Drop unnecessary code and syscall tables when we run a 64-bit kernel with conpat mode disabled.

Where can I download 64-bit parisc userspace? I am interested in trying it.

Sorry, there is none (yet).
Static binaries do work already, but userspace with shared libraries is being worked on by Dave. Various patches have been submitted to gcc/glibc during the last few weeks and progress was made, but it's not finished yet.

Helge

#9 lore raw

Hi Mikulas,

Quoted 9 lines · Helge Deller

Hi Mikulas,

Quoted 6 lines · Mikulas Patocka
Quoted 4 lines · Helge Deller

From: Helge Deller <[email protected]>

Drop unnecessary code and syscall tables when we run a 64-bit kernel with conpat mode disabled.

Quoted 6 lines
Quoted 1 line

Where can I download 64-bit parisc userspace? I am interested in trying it.

Sorry, there is none (yet).
Static binaries do work already, but userspace with shared libraries is being worked on by Dave. Various patches have been submitted to gcc/glibc during the last few weeks and progress was made, but it's not finished yet.

Helge slightly exaggerates the progress...

The major change is fixing the shared library support in 64-bit ld. For ld to be really useful, we need stub support for long branches. At the moment, there is only one stub section which handles dynamic symbols. This might be sufficient to work on glibc but gcc is too big to build without long branch support. -mlong-calls didn't work on hpux because the millicode library, milli.a, contains some short branches.

I have a few more binutils patches for hpux and testsuite.

I have some gcc updates for the 64-bit hpux support but I have been holding off till gcc-16 releases. This improves EH handling.

Sven started on glibc port but this work has stalled.

I can cross build gcc with 64-bit ld on hpux:
https://gcc.gnu.org/pipermail/gcc-testresults/2026-April/873088.html

GCC test results are mostly similar to those with HP ld.

I have a 64-bit GNU userspace for hpux that I use in testing.

Dave

Signature · 1 line
John David Anglin  [email protected]