Skip to content

Commit f96cb0d

Browse files
Claudio Imbrendahcahca
authored andcommitted
s390/entry: Remove __GMAP_ASCE and use _PIF_GUEST_FAULT again
Now that the guest ASCE is passed as a parameter to __sie64a(), _PIF_GUEST_FAULT can be used again to determine whether the fault was a guest or host fault. Since the guest ASCE will not be taken from the gmap pointer in lowcore anymore, __GMAP_ASCE can be removed. For the same reason the guest ASCE needs now to be saved into the cr1 save area unconditionally. Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com> Acked-by: Janosch Frank <frankja@linux.ibm.com> Reviewed-by: Heiko Carstens <hca@linux.ibm.com> Link: https://lore.kernel.org/r/20241022120601.167009-2-imbrenda@linux.ibm.com Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
1 parent f4d5e64 commit f96cb0d

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

arch/s390/include/asm/ptrace.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
#define PIF_SYSCALL 0 /* inside a system call */
1515
#define PIF_EXECVE_PGSTE_RESTART 1 /* restart execve for PGSTE binaries */
1616
#define PIF_SYSCALL_RET_SET 2 /* return value was set via ptrace */
17+
#define PIF_GUEST_FAULT 3 /* indicates program check in sie64a */
1718
#define PIF_FTRACE_FULL_REGS 4 /* all register contents valid (ftrace) */
1819

1920
#define _PIF_SYSCALL BIT(PIF_SYSCALL)
2021
#define _PIF_EXECVE_PGSTE_RESTART BIT(PIF_EXECVE_PGSTE_RESTART)
2122
#define _PIF_SYSCALL_RET_SET BIT(PIF_SYSCALL_RET_SET)
23+
#define _PIF_GUEST_FAULT BIT(PIF_GUEST_FAULT)
2224
#define _PIF_FTRACE_FULL_REGS BIT(PIF_FTRACE_FULL_REGS)
2325

2426
#define PSW32_MASK_PER _AC(0x40000000, UL)

arch/s390/kernel/asm-offsets.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <linux/purgatory.h>
1414
#include <linux/pgtable.h>
1515
#include <linux/ftrace.h>
16-
#include <asm/gmap.h>
1716
#include <asm/stacktrace.h>
1817

1918
int main(void)
@@ -161,7 +160,6 @@ int main(void)
161160
OFFSET(__LC_PGM_TDB, lowcore, pgm_tdb);
162161
BLANK();
163162
/* gmap/sie offsets */
164-
OFFSET(__GMAP_ASCE, gmap, asce);
165163
OFFSET(__SIE_PROG0C, kvm_s390_sie_block, prog0c);
166164
OFFSET(__SIE_PROG20, kvm_s390_sie_block, prog20);
167165
/* kexec_sha_region */

arch/s390/kernel/entry.S

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -327,13 +327,23 @@ SYM_CODE_START(pgm_check_handler)
327327
GET_LC %r13
328328
stpt __LC_SYS_ENTER_TIMER(%r13)
329329
BPOFF
330-
lgr %r10,%r15
331330
lmg %r8,%r9,__LC_PGM_OLD_PSW(%r13)
331+
xgr %r10,%r10
332+
xgr %r12,%r12
332333
tmhh %r8,0x0001 # coming from user space?
333334
jno .Lpgm_skip_asce
334335
lctlg %c1,%c1,__LC_KERNEL_ASCE(%r13)
335336
j 3f # -> fault in user space
336337
.Lpgm_skip_asce:
338+
#if IS_ENABLED(CONFIG_KVM)
339+
lg %r11,__LC_CURRENT(%r13)
340+
tm __TI_sie(%r11),0xff
341+
jz 1f
342+
BPENTER __SF_SIE_FLAGS(%r15),_TIF_ISOLATE_BP_GUEST
343+
SIEEXIT __SF_SIE_CONTROL(%r15),%r13
344+
lg %r12,__SF_SIE_GUEST_ASCE(%r15)
345+
lghi %r10,_PIF_GUEST_FAULT
346+
#endif
337347
1: tmhh %r8,0x4000 # PER bit set in old PSW ?
338348
jnz 2f # -> enabled, can't be a double fault
339349
tm __LC_PGM_ILC+3(%r13),0x80 # check for per exception
@@ -344,21 +354,13 @@ SYM_CODE_START(pgm_check_handler)
344354
CHECK_VMAP_STACK __LC_SAVE_AREA,%r13,4f
345355
3: lg %r15,__LC_KERNEL_STACK(%r13)
346356
4: la %r11,STACK_FRAME_OVERHEAD(%r15)
347-
xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
357+
stg %r10,__PT_FLAGS(%r11)
358+
stg %r12,__PT_CR1(%r11)
348359
xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
349360
stmg %r0,%r7,__PT_R0(%r11)
350361
mvc __PT_R8(64,%r11),__LC_SAVE_AREA(%r13)
351362
mvc __PT_LAST_BREAK(8,%r11),__LC_PGM_LAST_BREAK(%r13)
352-
stctg %c1,%c1,__PT_CR1(%r11)
353-
#if IS_ENABLED(CONFIG_KVM)
354-
ltg %r12,__LC_GMAP(%r13)
355-
jz 5f
356-
clc __GMAP_ASCE(8,%r12), __PT_CR1(%r11)
357-
jne 5f
358-
BPENTER __SF_SIE_FLAGS(%r10),_TIF_ISOLATE_BP_GUEST
359-
SIEEXIT __SF_SIE_CONTROL(%r10),%r13
360-
#endif
361-
5: stmg %r8,%r9,__PT_PSW(%r11)
363+
stmg %r8,%r9,__PT_PSW(%r11)
362364
# clear user controlled registers to prevent speculative use
363365
xgr %r0,%r0
364366
xgr %r1,%r1

arch/s390/mm/fault.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,13 @@ early_initcall(fault_init);
6868
static enum fault_type get_fault_type(struct pt_regs *regs)
6969
{
7070
union teid teid = { .val = regs->int_parm_long };
71-
struct gmap *gmap;
7271

7372
if (likely(teid.as == PSW_BITS_AS_PRIMARY)) {
7473
if (user_mode(regs))
7574
return USER_FAULT;
7675
if (!IS_ENABLED(CONFIG_PGSTE))
7776
return KERNEL_FAULT;
78-
gmap = (struct gmap *)get_lowcore()->gmap;
79-
if (gmap && gmap->asce == regs->cr1)
77+
if (test_pt_regs_flag(regs, PIF_GUEST_FAULT))
8078
return GMAP_FAULT;
8179
return KERNEL_FAULT;
8280
}
@@ -187,7 +185,7 @@ static void dump_fault_info(struct pt_regs *regs)
187185
pr_cont("user ");
188186
break;
189187
case GMAP_FAULT:
190-
asce = ((struct gmap *)get_lowcore()->gmap)->asce;
188+
asce = regs->cr1;
191189
pr_cont("gmap ");
192190
break;
193191
case KERNEL_FAULT:

0 commit comments

Comments
 (0)