From: Sven Schnelle <svens@linux.ibm.com>
To: Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Janosch Frank <frankja@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
borntraeger@linux.ibm.com, linux-s390@vger.kernel.org
Subject: [PATCH 1/2] s390/traps: Remove PIF_GUEST_FAULT
Date: Thu, 9 Jul 2026 21:54:59 +0200 [thread overview]
Message-ID: <20260709195500.1241833-2-svens@linux.ibm.com> (raw)
In-Reply-To: <20260709195500.1241833-1-svens@linux.ibm.com>
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
next prev parent reply other threads:[~2026-07-09 19:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260709195500.1241833-2-svens@linux.ibm.com \
--to=svens@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=frankja@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=linux-s390@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.