config S390
        def_bool y
+       select ARCH_BINFMT_ELF_STATE
        select ARCH_HAS_DEVMEM_IS_ALLOWED
        select ARCH_HAS_ELF_RANDOMIZE
        select ARCH_HAS_GCOV_PROFILE_ALL
 
 #define ELF_DATA       ELFDATA2MSB
 #define ELF_ARCH       EM_S390
 
+/* s390 specific phdr types */
+#define PT_S390_PGSTE  0x70000000
+
 /*
  * ELF register definitions..
  */
         && (x)->e_ident[EI_CLASS] == ELF_CLASS)
 #define compat_start_thread    start_thread31
 
+struct arch_elf_state {
+       int rc;
+};
+
+#define INIT_ARCH_ELF_STATE { .rc = 0 }
+
+#define arch_check_elf(ehdr, interp, interp_ehdr, state) (0)
+#ifdef CONFIG_PGSTE
+#define arch_elf_pt_proc(ehdr, phdr, elf, interp, state)       \
+({                                                             \
+       struct arch_elf_state *_state = state;                  \
+       if ((phdr)->p_type == PT_S390_PGSTE &&                  \
+           !page_table_allocate_pgste &&                       \
+           !test_thread_flag(TIF_PGSTE) &&                     \
+           !current->mm->context.alloc_pgste) {                \
+               set_thread_flag(TIF_PGSTE);                     \
+               set_pt_regs_flag(task_pt_regs(current),         \
+                                PIF_SYSCALL_RESTART);          \
+               _state->rc = -EAGAIN;                           \
+       }                                                       \
+       _state->rc;                                             \
+})
+#else
+#define arch_elf_pt_proc(ehdr, phdr, elf, interp, state)       \
+({                                                             \
+       (state)->rc;                                            \
+})
+#endif
+
 /* For SVR4/S390 the function pointer to be registered with `atexit` is
    passed in R14. */
 #define ELF_PLAT_INIT(_r, load_addr) \
 
        mm->context.gmap_asce = 0;
        mm->context.flush_mm = 0;
 #ifdef CONFIG_PGSTE
-       mm->context.alloc_pgste = page_table_allocate_pgste;
+       mm->context.alloc_pgste = page_table_allocate_pgste ||
+               test_thread_flag(TIF_PGSTE) ||
+               current->mm->context.alloc_pgste;
        mm->context.has_pgste = 0;
        mm->context.use_skey = 0;
        mm->context.use_cmma = 0;
 
 
 #define PIF_SYSCALL            0       /* inside a system call */
 #define PIF_PER_TRAP           1       /* deliver sigtrap on return to user */
+#define PIF_SYSCALL_RESTART    2       /* restart the current system call */
 
 #define _PIF_SYSCALL           _BITUL(PIF_SYSCALL)
 #define _PIF_PER_TRAP          _BITUL(PIF_PER_TRAP)
+#define _PIF_SYSCALL_RESTART   _BITUL(PIF_SYSCALL_RESTART)
 
 #ifndef __ASSEMBLY__
 
 
 #define TIF_UPROBE             3       /* breakpointed or single-stepping */
 #define TIF_GUARDED_STORAGE    4       /* load guarded storage control block */
 #define TIF_PATCH_PENDING      5       /* pending live patching update */
+#define TIF_PGSTE              6       /* New mm's will use 4K page tables */
 
 #define TIF_31BIT              16      /* 32bit process */
 #define TIF_MEMDIE             17      /* is terminating due to OOM killer */
 
                   _TIF_SYSCALL_TRACEPOINT)
 _CIF_WORK      = (_CIF_MCCK_PENDING | _CIF_ASCE_PRIMARY | \
                   _CIF_ASCE_SECONDARY | _CIF_FPU)
-_PIF_WORK      = (_PIF_PER_TRAP)
+_PIF_WORK      = (_PIF_PER_TRAP | _PIF_SYSCALL_RESTART)
 
 #define BASED(name) name-cleanup_critical(%r13)
 
        jo      .Lsysc_mcck_pending
        TSTMSK  __TI_flags(%r12),_TIF_NEED_RESCHED
        jo      .Lsysc_reschedule
+       TSTMSK  __PT_FLAGS(%r11),_PIF_SYSCALL_RESTART
+       jo      .Lsysc_syscall_restart
 #ifdef CONFIG_UPROBES
        TSTMSK  __TI_flags(%r12),_TIF_UPROBE
        jo      .Lsysc_uprobe_notify
        jo      .Lsysc_patch_pending    # handle live patching just before
                                        # signals and possible syscall restart
 #endif
+       TSTMSK  __PT_FLAGS(%r11),_PIF_SYSCALL_RESTART
+       jo      .Lsysc_syscall_restart
        TSTMSK  __TI_flags(%r12),_TIF_SIGPENDING
        jo      .Lsysc_sigpending
        TSTMSK  __TI_flags(%r12),_TIF_NOTIFY_RESUME
        larl    %r14,.Lsysc_return
        jg      do_per_trap
 
+#
+# _PIF_SYSCALL_RESTART is set, repeat the current system call
+#
+.Lsysc_syscall_restart:
+       ni      __PT_FLAGS+7(%r11),255-_PIF_SYSCALL_RESTART
+       lmg     %r1,%r7,__PT_R1(%r11)   # load svc arguments
+       lg      %r2,__PT_ORIG_GPR2(%r11)
+       j       .Lsysc_do_svc
+
 #
 # call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
 # and after the system call