* [PATCH 0/2] s390: Remove PIF_GUEST_FAULT and add PER trap flag
@ 2026-07-09 19:54 Sven Schnelle
2026-07-09 19:54 ` [PATCH 1/2] s390/traps: Remove PIF_GUEST_FAULT Sven Schnelle
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Sven Schnelle @ 2026-07-09 19:54 UTC (permalink / raw)
To: Heiko Carstens, Vasily Gorbik, Alexander Gordeev
Cc: Janosch Frank, Claudio Imbrenda, borntraeger, linux-s390
While looking at the syscall code I noticed that entry.S still sets
PIF_GUEST_FAULT in ptregs even though it's only used in __do_pgm_check().
Remove that and pass it directly to __do_pgm_check(). Heiko suggested
to also add a define for the per trap flag in system_call().
Sven Schnelle (2):
s390/traps: Remove PIF_GUEST_FAULT
s390/syscalls: Use define instead of '1' to indicate PER trap
arch/s390/include/asm/ptrace.h | 4 +---
arch/s390/kernel/entry.S | 9 +++++----
arch/s390/kernel/entry.h | 10 ++++++++--
arch/s390/kernel/syscall.c | 4 ++--
arch/s390/kernel/traps.c | 4 ++--
5 files changed, 18 insertions(+), 13 deletions(-)
--
2.53.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] s390/traps: Remove PIF_GUEST_FAULT
2026-07-09 19:54 [PATCH 0/2] s390: Remove PIF_GUEST_FAULT and add PER trap flag Sven Schnelle
@ 2026-07-09 19:54 ` Sven Schnelle
2026-07-09 19:55 ` [PATCH 2/2] s390/syscalls: Use define instead of '1' to indicate PER trap Sven Schnelle
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Sven Schnelle @ 2026-07-09 19:54 UTC (permalink / raw)
To: Heiko Carstens, Vasily Gorbik, Alexander Gordeev
Cc: Janosch Frank, Claudio Imbrenda, borntraeger, linux-s390
PIF_GUEST_FAULT is only used to pass information whether a fault was
caused when executing SIE or when executing host code. Instead of
using ptregs for this, just pass the flag directly as argument to
__do_pgm_check(). This also saves the time required to read the flag
from ptregs, although this likely isn't much as it is already in the
data cache.
Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
---
arch/s390/include/asm/ptrace.h | 4 +---
arch/s390/kernel/entry.S | 7 ++++---
arch/s390/kernel/entry.h | 7 ++++++-
arch/s390/kernel/traps.c | 4 ++--
4 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/arch/s390/include/asm/ptrace.h b/arch/s390/include/asm/ptrace.h
index 495e310c3d6d..6411e3584283 100644
--- a/arch/s390/include/asm/ptrace.h
+++ b/arch/s390/include/asm/ptrace.h
@@ -16,13 +16,11 @@
#define PIF_SYSCALL 0 /* inside a system call */
#define PIF_PSW_ADDR_ADJUSTED 1 /* psw address has been adjusted */
#define PIF_SYSCALL_RET_SET 2 /* return value was set via ptrace */
-#define PIF_GUEST_FAULT 3 /* indicates program check in sie64a */
-#define PIF_FTRACE_FULL_REGS 4 /* all register contents valid (ftrace) */
+#define PIF_FTRACE_FULL_REGS 3 /* all register contents valid (ftrace) */
#define _PIF_SYSCALL BIT(PIF_SYSCALL)
#define _PIF_ADDR_PSW_ADJUSTED BIT(PIF_PSW_ADDR_ADJUSTED)
#define _PIF_SYSCALL_RET_SET BIT(PIF_SYSCALL_RET_SET)
-#define _PIF_GUEST_FAULT BIT(PIF_GUEST_FAULT)
#define _PIF_FTRACE_FULL_REGS BIT(PIF_FTRACE_FULL_REGS)
#define PSW32_MASK_PER _AC(0x40000000, UL)
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
index 79a45efae23d..d70eef7a0b29 100644
--- a/arch/s390/kernel/entry.S
+++ b/arch/s390/kernel/entry.S
@@ -31,6 +31,7 @@
#include <asm/nospec-insn.h>
#include <asm/lowcore.h>
#include <asm/machine.h>
+#include "entry.h"
_LPP_OFFSET = __LC_LPP
@@ -321,7 +322,7 @@ SYM_CODE_START(pgm_check_handler)
jz 1f
BPENTER __SF_SIE_FLAGS(%r15),_TIF_ISOLATE_BP_GUEST
SIEEXIT __SF_SIE_CONTROL(%r15),%r13
- lghi %r10,_PIF_GUEST_FAULT
+ lghi %r10,PGM_FLAG_GUEST_FAULT
#endif
1: tmhh %r8,0x4000 # PER bit set in old PSW ?
jnz 2f # -> enabled, can't be a double fault
@@ -332,7 +333,7 @@ SYM_CODE_START(pgm_check_handler)
CHECK_VMAP_STACK __LC_SAVE_AREA,%r13,4f
3: lg %r15,__LC_KERNEL_STACK(%r13)
4: la %r11,STACK_FRAME_OVERHEAD(%r15)
- stg %r10,__PT_FLAGS(%r11)
+ xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
stmg %r0,%r7,__PT_R0(%r11)
mvc __PT_R8(64,%r11),__LC_SAVE_AREA(%r13)
@@ -341,13 +342,13 @@ SYM_CODE_START(pgm_check_handler)
# clear user controlled registers to prevent speculative use
xgr %r0,%r0
xgr %r1,%r1
- xgr %r3,%r3
xgr %r4,%r4
xgr %r5,%r5
xgr %r6,%r6
xgr %r7,%r7
xgr %r12,%r12
lgr %r2,%r11
+ lgr %r3,%r10
brasl %r14,__do_pgm_check
tmhh %r8,0x0001 # returning to user space?
jno .Lpgm_exit_kernel
diff --git a/arch/s390/kernel/entry.h b/arch/s390/kernel/entry.h
index fb67b4abe68c..d18a9a63f6b8 100644
--- a/arch/s390/kernel/entry.h
+++ b/arch/s390/kernel/entry.h
@@ -2,6 +2,10 @@
#ifndef _ENTRY_H
#define _ENTRY_H
+#define PGM_FLAG_GUEST_FAULT 1
+
+#ifndef __ASSEMBLER__
+
#include <linux/percpu.h>
#include <linux/types.h>
#include <linux/signal.h>
@@ -21,7 +25,7 @@ void early_pgm_check_handler(void);
struct task_struct *__switch_to_asm(struct task_struct *prev, struct task_struct *next);
void __ret_from_fork(struct task_struct *prev, struct pt_regs *regs);
-void __do_pgm_check(struct pt_regs *regs);
+void __do_pgm_check(struct pt_regs *regs, unsigned long flags);
void __do_syscall(struct pt_regs *regs, int per_trap);
void __do_early_pgm_check(struct pt_regs *regs);
@@ -70,4 +74,5 @@ extern struct exception_table_entry _stop_amode31_ex_table[];
#define __amode31_ref __section(".amode31.refs")
extern long _start_amode31_refs[], _end_amode31_refs[];
+#endif /* __ASSEMBLER__ */
#endif /* _ENTRY_H */
diff --git a/arch/s390/kernel/traps.c b/arch/s390/kernel/traps.c
index 564403496a7c..a5c259dd4295 100644
--- a/arch/s390/kernel/traps.c
+++ b/arch/s390/kernel/traps.c
@@ -327,7 +327,7 @@ void __init trap_init(void)
static void (*pgm_check_table[128])(struct pt_regs *regs);
-void noinstr __do_pgm_check(struct pt_regs *regs)
+void noinstr __do_pgm_check(struct pt_regs *regs, unsigned long flags)
{
struct lowcore *lc = get_lowcore();
bool percpu_needs_fixup;
@@ -346,7 +346,7 @@ void noinstr __do_pgm_check(struct pt_regs *regs)
* the fault number in current->thread.gmap_int_code. KVM will be
* able to use this information to handle the fault.
*/
- if (test_pt_regs_flag(regs, PIF_GUEST_FAULT)) {
+ if (flags & PGM_FLAG_GUEST_FAULT) {
current->thread.gmap_teid.val = regs->int_parm_long;
current->thread.gmap_int_code = regs->int_code & 0xffff;
return;
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] s390/syscalls: Use define instead of '1' to indicate PER trap
2026-07-09 19:54 [PATCH 0/2] s390: Remove PIF_GUEST_FAULT and add PER trap flag Sven Schnelle
2026-07-09 19:54 ` [PATCH 1/2] s390/traps: Remove PIF_GUEST_FAULT Sven Schnelle
@ 2026-07-09 19:55 ` Sven Schnelle
2026-07-10 7:43 ` [PATCH 0/2] s390: Remove PIF_GUEST_FAULT and add PER trap flag Heiko Carstens
2026-07-10 8:40 ` Vasily Gorbik
3 siblings, 0 replies; 5+ messages in thread
From: Sven Schnelle @ 2026-07-09 19:55 UTC (permalink / raw)
To: Heiko Carstens, Vasily Gorbik, Alexander Gordeev
Cc: Janosch Frank, Claudio Imbrenda, borntraeger, linux-s390
Make the code a bit easier to read by defining SYSCALL_PER_TRAP
instead of passing '1' to __do_syscall().
Suggested-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
---
arch/s390/kernel/entry.S | 2 +-
arch/s390/kernel/entry.h | 3 ++-
arch/s390/kernel/syscall.c | 4 ++--
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
index d70eef7a0b29..10dd9bbdf985 100644
--- a/arch/s390/kernel/entry.S
+++ b/arch/s390/kernel/entry.S
@@ -368,7 +368,7 @@ SYM_CODE_START(pgm_check_handler)
mvc __LC_RETURN_PSW(8,%r13),__LC_SVC_NEW_PSW(%r13)
larl %r14,.Lsysc_per
stg %r14,__LC_RETURN_PSW+8(%r13)
- lghi %r14,1
+ lghi %r14,SYSCALL_FLAG_PER_TRAP
LBEAR __LC_PGM_LAST_BREAK(%r13)
LPSWEY __LC_RETURN_PSW,__LC_RETURN_LPSWE # branch to .Lsysc_per
SYM_CODE_END(pgm_check_handler)
diff --git a/arch/s390/kernel/entry.h b/arch/s390/kernel/entry.h
index d18a9a63f6b8..dc84ab497251 100644
--- a/arch/s390/kernel/entry.h
+++ b/arch/s390/kernel/entry.h
@@ -3,6 +3,7 @@
#define _ENTRY_H
#define PGM_FLAG_GUEST_FAULT 1
+#define SYSCALL_FLAG_PER_TRAP 1
#ifndef __ASSEMBLER__
@@ -26,7 +27,7 @@ void early_pgm_check_handler(void);
struct task_struct *__switch_to_asm(struct task_struct *prev, struct task_struct *next);
void __ret_from_fork(struct task_struct *prev, struct pt_regs *regs);
void __do_pgm_check(struct pt_regs *regs, unsigned long flags);
-void __do_syscall(struct pt_regs *regs, int per_trap);
+void __do_syscall(struct pt_regs *regs, unsigned long flags);
void __do_early_pgm_check(struct pt_regs *regs);
void do_protection_exception(struct pt_regs *regs);
diff --git a/arch/s390/kernel/syscall.c b/arch/s390/kernel/syscall.c
index 75d5a3cab14e..b6c643756a7c 100644
--- a/arch/s390/kernel/syscall.c
+++ b/arch/s390/kernel/syscall.c
@@ -93,7 +93,7 @@ SYSCALL_DEFINE0(ni_syscall)
return -ENOSYS;
}
-void noinstr __do_syscall(struct pt_regs *regs, int per_trap)
+void noinstr __do_syscall(struct pt_regs *regs, unsigned long flags)
{
unsigned long nr;
@@ -106,7 +106,7 @@ void noinstr __do_syscall(struct pt_regs *regs, int per_trap)
current->thread.last_break = regs->last_break;
local_irq_enable();
regs->orig_gpr2 = regs->gprs[2];
- if (unlikely(per_trap))
+ if (unlikely(flags & SYSCALL_FLAG_PER_TRAP))
set_thread_flag(TIF_PER_TRAP);
regs->flags = 0;
set_pt_regs_flag(regs, PIF_SYSCALL);
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] s390: Remove PIF_GUEST_FAULT and add PER trap flag
2026-07-09 19:54 [PATCH 0/2] s390: Remove PIF_GUEST_FAULT and add PER trap flag Sven Schnelle
2026-07-09 19:54 ` [PATCH 1/2] s390/traps: Remove PIF_GUEST_FAULT Sven Schnelle
2026-07-09 19:55 ` [PATCH 2/2] s390/syscalls: Use define instead of '1' to indicate PER trap Sven Schnelle
@ 2026-07-10 7:43 ` Heiko Carstens
2026-07-10 8:40 ` Vasily Gorbik
3 siblings, 0 replies; 5+ messages in thread
From: Heiko Carstens @ 2026-07-10 7:43 UTC (permalink / raw)
To: Sven Schnelle
Cc: Vasily Gorbik, Alexander Gordeev, Janosch Frank, Claudio Imbrenda,
borntraeger, linux-s390
On Thu, Jul 09, 2026 at 09:54:58PM +0200, Sven Schnelle wrote:
> While looking at the syscall code I noticed that entry.S still sets
> PIF_GUEST_FAULT in ptregs even though it's only used in __do_pgm_check().
> Remove that and pass it directly to __do_pgm_check(). Heiko suggested
> to also add a define for the per trap flag in system_call().
>
> Sven Schnelle (2):
> s390/traps: Remove PIF_GUEST_FAULT
> s390/syscalls: Use define instead of '1' to indicate PER trap
>
> arch/s390/include/asm/ptrace.h | 4 +---
> arch/s390/kernel/entry.S | 9 +++++----
> arch/s390/kernel/entry.h | 10 ++++++++--
> arch/s390/kernel/syscall.c | 4 ++--
> arch/s390/kernel/traps.c | 4 ++--
> 5 files changed, 18 insertions(+), 13 deletions(-)
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] s390: Remove PIF_GUEST_FAULT and add PER trap flag
2026-07-09 19:54 [PATCH 0/2] s390: Remove PIF_GUEST_FAULT and add PER trap flag Sven Schnelle
` (2 preceding siblings ...)
2026-07-10 7:43 ` [PATCH 0/2] s390: Remove PIF_GUEST_FAULT and add PER trap flag Heiko Carstens
@ 2026-07-10 8:40 ` Vasily Gorbik
3 siblings, 0 replies; 5+ messages in thread
From: Vasily Gorbik @ 2026-07-10 8:40 UTC (permalink / raw)
To: Sven Schnelle
Cc: Heiko Carstens, Alexander Gordeev, Janosch Frank,
Claudio Imbrenda, borntraeger, linux-s390
On Thu, Jul 09, 2026 at 09:54:58PM +0200, Sven Schnelle wrote:
> While looking at the syscall code I noticed that entry.S still sets
> PIF_GUEST_FAULT in ptregs even though it's only used in __do_pgm_check().
> Remove that and pass it directly to __do_pgm_check(). Heiko suggested
> to also add a define for the per trap flag in system_call().
>
> Sven Schnelle (2):
> s390/traps: Remove PIF_GUEST_FAULT
> s390/syscalls: Use define instead of '1' to indicate PER trap
>
> arch/s390/include/asm/ptrace.h | 4 +---
> arch/s390/kernel/entry.S | 9 +++++----
> arch/s390/kernel/entry.h | 10 ++++++++--
> arch/s390/kernel/syscall.c | 4 ++--
> arch/s390/kernel/traps.c | 4 ++--
> 5 files changed, 18 insertions(+), 13 deletions(-)
Applied, thank you!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-07-10 8:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-09 19:54 [PATCH 0/2] s390: Remove PIF_GUEST_FAULT and add PER trap flag Sven Schnelle
2026-07-09 19:54 ` [PATCH 1/2] s390/traps: Remove PIF_GUEST_FAULT Sven Schnelle
2026-07-09 19:55 ` [PATCH 2/2] s390/syscalls: Use define instead of '1' to indicate PER trap Sven Schnelle
2026-07-10 7:43 ` [PATCH 0/2] s390: Remove PIF_GUEST_FAULT and add PER trap flag Heiko Carstens
2026-07-10 8:40 ` Vasily Gorbik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox