Merge tag 'phy-for-4.4-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/kishon...
[firefly-linux-kernel-4.4.55.git] / arch / s390 / kernel / entry.S
index 582fe44ab07cc69aaef1d4f782f6f89364914974..857b6526d29833507c3abec126b90a24e491956f 100644 (file)
@@ -20,8 +20,9 @@
 #include <asm/page.h>
 #include <asm/sigp.h>
 #include <asm/irq.h>
-#include <asm/fpu-internal.h>
 #include <asm/vx-insn.h>
+#include <asm/setup.h>
+#include <asm/nmi.h>
 
 __PT_R0      = __PT_GPRS
 __PT_R1      = __PT_GPRS + 8
@@ -139,6 +140,28 @@ _PIF_WORK  = (_PIF_PER_TRAP)
 #endif
        .endm
 
+       /*
+        * The TSTMSK macro generates a test-under-mask instruction by
+        * calculating the memory offset for the specified mask value.
+        * Mask value can be any constant.  The macro shifts the mask
+        * value to calculate the memory offset for the test-under-mask
+        * instruction.
+        */
+       .macro TSTMSK addr, mask, size=8, bytepos=0
+               .if (\bytepos < \size) && (\mask >> 8)
+                       .if (\mask & 0xff)
+                               .error "Mask exceeds byte boundary"
+                       .endif
+                       TSTMSK \addr, "(\mask >> 8)", \size, "(\bytepos + 1)"
+                       .exitm
+               .endif
+               .ifeq \mask
+                       .error "Mask must not be zero"
+               .endif
+               off = \size - \bytepos - 1
+               tm      off+\addr, \mask
+       .endm
+
        .section .kprobes.text, "ax"
 
 /*
@@ -164,8 +187,11 @@ ENTRY(__switch_to)
        stg     %r15,__LC_KERNEL_STACK          # store end of kernel stack
        lg      %r15,__THREAD_ksp(%r1)          # load kernel stack of next
        lctl    %c4,%c4,__TASK_pid(%r3)         # load pid to control reg. 4
-       mvc     __LC_CURRENT_PID+4(4,%r0),__TASK_pid(%r3) # store pid of next
+       mvc     __LC_CURRENT_PID(4,%r0),__TASK_pid(%r3) # store pid of next
        lmg     %r6,%r15,__SF_GPRS(%r15)        # load gprs of next task
+       TSTMSK  __LC_MACHINE_FLAGS,MACHINE_FLAG_LPP
+       bzr     %r14
+       .insn   s,0xb2800000,__LC_LPP           # set program parameter
        br      %r14
 
 .L__critical_start:
@@ -180,8 +206,8 @@ ENTRY(sie64a)
        stmg    %r6,%r14,__SF_GPRS(%r15)        # save kernel registers
        stg     %r2,__SF_EMPTY(%r15)            # save control block pointer
        stg     %r3,__SF_EMPTY+8(%r15)          # save guest register save area
-       xc      __SF_EMPTY+16(16,%r15),__SF_EMPTY+16(%r15) # host id & reason
-       tm      __LC_CPU_FLAGS+7,_CIF_FPU       # load guest fp/vx registers ?
+       xc      __SF_EMPTY+16(8,%r15),__SF_EMPTY+16(%r15) # reason code = 0
+       TSTMSK  __LC_CPU_FLAGS,_CIF_FPU         # load guest fp/vx registers ?
        jno     .Lsie_load_guest_gprs
        brasl   %r14,load_fpu_regs              # load guest fp/vx regs
 .Lsie_load_guest_gprs:
@@ -195,16 +221,9 @@ ENTRY(sie64a)
        oi      __SIE_PROG0C+3(%r14),1          # we are going into SIE now
        tm      __SIE_PROG20+3(%r14),3          # last exit...
        jnz     .Lsie_skip
-       tm      __LC_CPU_FLAGS+7,_CIF_FPU
+       TSTMSK  __LC_CPU_FLAGS,_CIF_FPU
        jo      .Lsie_skip                      # exit if fp/vx regs changed
-       tm      __LC_MACHINE_FLAGS+6,0x20       # MACHINE_FLAG_LPP
-       jz      .Lsie_enter
-       .insn   s,0xb2800000,__LC_CURRENT_PID   # set guest id to pid
-.Lsie_enter:
        sie     0(%r14)
-       tm      __LC_MACHINE_FLAGS+6,0x20       # MACHINE_FLAG_LPP
-       jz      .Lsie_skip
-       .insn   s,0xb2800000,__SF_EMPTY+16(%r15)# set host id
 .Lsie_skip:
        ni      __SIE_PROG0C+3(%r14),0xfe       # no longer in SIE
        lctlg   %c1,%c1,__LC_USER_ASCE          # load primary asce
@@ -221,11 +240,11 @@ sie_exit:
        lg      %r14,__SF_EMPTY+8(%r15)         # load guest register save area
        stmg    %r0,%r13,0(%r14)                # save guest gprs 0-13
        lmg     %r6,%r14,__SF_GPRS(%r15)        # restore kernel registers
-       lg      %r2,__SF_EMPTY+24(%r15)         # return exit reason code
+       lg      %r2,__SF_EMPTY+16(%r15)         # return exit reason code
        br      %r14
 .Lsie_fault:
        lghi    %r14,-EFAULT
-       stg     %r14,__SF_EMPTY+24(%r15)        # set exit reason code
+       stg     %r14,__SF_EMPTY+16(%r15)        # set exit reason code
        j       sie_exit
 
        EX_TABLE(.Lrewind_pad,.Lsie_fault)
@@ -271,7 +290,7 @@ ENTRY(system_call)
        stg     %r2,__PT_ORIG_GPR2(%r11)
        stg     %r7,STACK_FRAME_OVERHEAD(%r15)
        lgf     %r9,0(%r8,%r10)                 # get system call add.
-       tm      __TI_flags+7(%r12),_TIF_TRACE
+       TSTMSK  __TI_flags(%r12),_TIF_TRACE
        jnz     .Lsysc_tracesys
        basr    %r14,%r9                        # call sys_xxxx
        stg     %r2,__PT_R2(%r11)               # store return value
@@ -279,11 +298,11 @@ ENTRY(system_call)
 .Lsysc_return:
        LOCKDEP_SYS_EXIT
 .Lsysc_tif:
-       tm      __PT_FLAGS+7(%r11),_PIF_WORK
+       TSTMSK  __PT_FLAGS(%r11),_PIF_WORK
        jnz     .Lsysc_work
-       tm      __TI_flags+7(%r12),_TIF_WORK
+       TSTMSK  __TI_flags(%r12),_TIF_WORK
        jnz     .Lsysc_work                     # check for work
-       tm      __LC_CPU_FLAGS+7,_CIF_WORK
+       TSTMSK  __LC_CPU_FLAGS,_CIF_WORK
        jnz     .Lsysc_work
 .Lsysc_restore:
        lg      %r14,__LC_VDSO_PER_CPU
@@ -299,23 +318,23 @@ ENTRY(system_call)
 # One of the work bits is on. Find out which one.
 #
 .Lsysc_work:
-       tm      __LC_CPU_FLAGS+7,_CIF_MCCK_PENDING
+       TSTMSK  __LC_CPU_FLAGS,_CIF_MCCK_PENDING
        jo      .Lsysc_mcck_pending
-       tm      __TI_flags+7(%r12),_TIF_NEED_RESCHED
+       TSTMSK  __TI_flags(%r12),_TIF_NEED_RESCHED
        jo      .Lsysc_reschedule
 #ifdef CONFIG_UPROBES
-       tm      __TI_flags+7(%r12),_TIF_UPROBE
+       TSTMSK  __TI_flags(%r12),_TIF_UPROBE
        jo      .Lsysc_uprobe_notify
 #endif
-       tm      __PT_FLAGS+7(%r11),_PIF_PER_TRAP
+       TSTMSK  __PT_FLAGS(%r11),_PIF_PER_TRAP
        jo      .Lsysc_singlestep
-       tm      __TI_flags+7(%r12),_TIF_SIGPENDING
+       TSTMSK  __TI_flags(%r12),_TIF_SIGPENDING
        jo      .Lsysc_sigpending
-       tm      __TI_flags+7(%r12),_TIF_NOTIFY_RESUME
+       TSTMSK  __TI_flags(%r12),_TIF_NOTIFY_RESUME
        jo      .Lsysc_notify_resume
-       tm      __LC_CPU_FLAGS+7,_CIF_FPU
+       TSTMSK  __LC_CPU_FLAGS,_CIF_FPU
        jo      .Lsysc_vxrs
-       tm      __LC_CPU_FLAGS+7,_CIF_ASCE
+       TSTMSK  __LC_CPU_FLAGS,_CIF_ASCE
        jo      .Lsysc_uaccess
        j       .Lsysc_return           # beware of critical section cleanup
 
@@ -354,7 +373,7 @@ ENTRY(system_call)
 .Lsysc_sigpending:
        lgr     %r2,%r11                # pass pointer to pt_regs
        brasl   %r14,do_signal
-       tm      __PT_FLAGS+7(%r11),_PIF_SYSCALL
+       TSTMSK  __PT_FLAGS(%r11),_PIF_SYSCALL
        jno     .Lsysc_return
        lmg     %r2,%r7,__PT_R2(%r11)   # load svc arguments
        lg      %r10,__TI_sysc_table(%r12)      # address of system call table
@@ -414,7 +433,7 @@ ENTRY(system_call)
        basr    %r14,%r9                # call sys_xxx
        stg     %r2,__PT_R2(%r11)       # store return value
 .Lsysc_tracenogo:
-       tm      __TI_flags+7(%r12),_TIF_TRACE
+       TSTMSK  __TI_flags(%r12),_TIF_TRACE
        jz      .Lsysc_return
        lgr     %r2,%r11                # pass pointer to pt_regs
        larl    %r14,.Lsysc_return
@@ -544,6 +563,8 @@ ENTRY(io_int_handler)
        stmg    %r8,%r9,__PT_PSW(%r11)
        mvc     __PT_INT_CODE(12,%r11),__LC_SUBCHANNEL_ID
        xc      __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
+       TSTMSK  __LC_CPU_FLAGS,_CIF_IGNORE_IRQ
+       jo      .Lio_restore
        TRACE_IRQS_OFF
        xc      __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
 .Lio_loop:
@@ -554,7 +575,7 @@ ENTRY(io_int_handler)
        lghi    %r3,THIN_INTERRUPT
 .Lio_call:
        brasl   %r14,do_IRQ
-       tm      __LC_MACHINE_FLAGS+6,0x10       # MACHINE_FLAG_LPAR
+       TSTMSK  __LC_MACHINE_FLAGS,MACHINE_FLAG_LPAR
        jz      .Lio_return
        tpi     0
        jz      .Lio_return
@@ -564,9 +585,9 @@ ENTRY(io_int_handler)
        LOCKDEP_SYS_EXIT
        TRACE_IRQS_ON
 .Lio_tif:
-       tm      __TI_flags+7(%r12),_TIF_WORK
+       TSTMSK  __TI_flags(%r12),_TIF_WORK
        jnz     .Lio_work               # there is work to do (signals etc.)
-       tm      __LC_CPU_FLAGS+7,_CIF_WORK
+       TSTMSK  __LC_CPU_FLAGS,_CIF_WORK
        jnz     .Lio_work
 .Lio_restore:
        lg      %r14,__LC_VDSO_PER_CPU
@@ -594,7 +615,7 @@ ENTRY(io_int_handler)
        # check for preemptive scheduling
        icm     %r0,15,__TI_precount(%r12)
        jnz     .Lio_restore            # preemption is disabled
-       tm      __TI_flags+7(%r12),_TIF_NEED_RESCHED
+       TSTMSK  __TI_flags(%r12),_TIF_NEED_RESCHED
        jno     .Lio_restore
        # switch to kernel stack
        lg      %r1,__PT_R15(%r11)
@@ -626,17 +647,17 @@ ENTRY(io_int_handler)
 # One of the work bits is on. Find out which one.
 #
 .Lio_work_tif:
-       tm      __LC_CPU_FLAGS+7,_CIF_MCCK_PENDING
+       TSTMSK  __LC_CPU_FLAGS,_CIF_MCCK_PENDING
        jo      .Lio_mcck_pending
-       tm      __TI_flags+7(%r12),_TIF_NEED_RESCHED
+       TSTMSK  __TI_flags(%r12),_TIF_NEED_RESCHED
        jo      .Lio_reschedule
-       tm      __TI_flags+7(%r12),_TIF_SIGPENDING
+       TSTMSK  __TI_flags(%r12),_TIF_SIGPENDING
        jo      .Lio_sigpending
-       tm      __TI_flags+7(%r12),_TIF_NOTIFY_RESUME
+       TSTMSK  __TI_flags(%r12),_TIF_NOTIFY_RESUME
        jo      .Lio_notify_resume
-       tm      __LC_CPU_FLAGS+7,_CIF_FPU
+       TSTMSK  __LC_CPU_FLAGS,_CIF_FPU
        jo      .Lio_vxrs
-       tm      __LC_CPU_FLAGS+7,_CIF_ASCE
+       TSTMSK  __LC_CPU_FLAGS,_CIF_ASCE
        jo      .Lio_uaccess
        j       .Lio_return             # beware of critical section cleanup
 
@@ -719,6 +740,8 @@ ENTRY(ext_int_handler)
        mvc     __PT_INT_PARM(4,%r11),__LC_EXT_PARAMS
        mvc     __PT_INT_PARM_LONG(8,%r11),0(%r1)
        xc      __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
+       TSTMSK  __LC_CPU_FLAGS,_CIF_IGNORE_IRQ
+       jo      .Lio_restore
        TRACE_IRQS_OFF
        xc      __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
        lgr     %r2,%r11                # pass pointer to pt_regs
@@ -748,27 +771,22 @@ ENTRY(psw_idle)
        br      %r14
 .Lpsw_idle_end:
 
-/* Store floating-point controls and floating-point or vector extension
- * registers instead.  A critical section cleanup assures that the registers
- * are stored even if interrupted for some other work. The register %r2
- * designates a struct fpu to store register contents. If the specified
- * structure does not contain a register save area, the register store is
- * omitted (see also comments in arch_dup_task_struct()).
- *
- * The CIF_FPU flag is set in any case.  The CIF_FPU triggers a lazy restore
- * of the register contents at system call or io return.
+/*
+ * Store floating-point controls and floating-point or vector register
+ * depending whether the vector facility is available. A critical section
+ * cleanup assures that the registers are stored even if interrupted for
+ * some other work.  The CIF_FPU flag is set to trigger a lazy restore
+ * of the register contents at return from io or a system call.
  */
 ENTRY(save_fpu_regs)
        lg      %r2,__LC_CURRENT
        aghi    %r2,__TASK_thread
-       tm      __LC_CPU_FLAGS+7,_CIF_FPU
+       TSTMSK  __LC_CPU_FLAGS,_CIF_FPU
        bor     %r14
        stfpc   __THREAD_FPU_fpc(%r2)
 .Lsave_fpu_regs_fpc_end:
        lg      %r3,__THREAD_FPU_regs(%r2)
-       ltgr    %r3,%r3
-       jz      .Lsave_fpu_regs_done      # no save area -> set CIF_FPU
-       tm      __THREAD_FPU_flags+3(%r2),FPU_USE_VX
+       TSTMSK  __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
        jz      .Lsave_fpu_regs_fp        # no -> store FP regs
 .Lsave_fpu_regs_vx_low:
        VSTM    %v0,%v15,0,%r3            # vstm 0,15,0(3)
@@ -797,41 +815,30 @@ ENTRY(save_fpu_regs)
        br      %r14
 .Lsave_fpu_regs_end:
 
-/* Load floating-point controls and floating-point or vector extension
- * registers.  A critical section cleanup assures that the register contents
- * are loaded even if interrupted for some other work. Depending on the saved
- * FP/VX state, the vector-enablement control, CR0.46, is either set or cleared.
+/*
+ * Load floating-point controls and floating-point or vector registers.
+ * A critical section cleanup assures that the register contents are
+ * loaded even if interrupted for some other work.
  *
  * There are special calling conventions to fit into sysc and io return work:
  *     %r15:   <kernel stack>
  * The function requires:
- *     %r4 and __SF_EMPTY+32(%r15)
+ *     %r4
  */
 load_fpu_regs:
        lg      %r4,__LC_CURRENT
        aghi    %r4,__TASK_thread
-       tm      __LC_CPU_FLAGS+7,_CIF_FPU
+       TSTMSK  __LC_CPU_FLAGS,_CIF_FPU
        bnor    %r14
        lfpc    __THREAD_FPU_fpc(%r4)
-       stctg   %c0,%c0,__SF_EMPTY+32(%r15)     # store CR0
-       tm      __THREAD_FPU_flags+3(%r4),FPU_USE_VX    # VX-enabled task ?
+       TSTMSK  __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
        lg      %r4,__THREAD_FPU_regs(%r4)      # %r4 <- reg save area
-       jz      .Lload_fpu_regs_fp_ctl          # -> no VX, load FP regs
-.Lload_fpu_regs_vx_ctl:
-       tm      __SF_EMPTY+32+5(%r15),2         # test VX control
-       jo      .Lload_fpu_regs_vx
-       oi      __SF_EMPTY+32+5(%r15),2         # set VX control
-       lctlg   %c0,%c0,__SF_EMPTY+32(%r15)
+       jz      .Lload_fpu_regs_fp              # -> no VX, load FP regs
 .Lload_fpu_regs_vx:
        VLM     %v0,%v15,0,%r4
 .Lload_fpu_regs_vx_high:
        VLM     %v16,%v31,256,%r4
        j       .Lload_fpu_regs_done
-.Lload_fpu_regs_fp_ctl:
-       tm      __SF_EMPTY+32+5(%r15),2         # test VX control
-       jz      .Lload_fpu_regs_fp
-       ni      __SF_EMPTY+32+5(%r15),253       # clear VX control
-       lctlg   %c0,%c0,__SF_EMPTY+32(%r15)
 .Lload_fpu_regs_fp:
        ld      0,0(%r4)
        ld      1,8(%r4)
@@ -854,16 +861,6 @@ load_fpu_regs:
        br      %r14
 .Lload_fpu_regs_end:
 
-/* Test and set the vector enablement control in CR0.46 */
-ENTRY(__ctl_set_vx)
-       stctg   %c0,%c0,__SF_EMPTY(%r15)
-       tm      __SF_EMPTY+5(%r15),2
-       bor     %r14
-       oi      __SF_EMPTY+5(%r15),2
-       lctlg   %c0,%c0,__SF_EMPTY(%r15)
-       br      %r14
-.L__ctl_set_vx_end:
-
 .L__critical_end:
 
 /*
@@ -878,11 +875,11 @@ ENTRY(mcck_int_handler)
        lg      %r12,__LC_THREAD_INFO
        larl    %r13,cleanup_critical
        lmg     %r8,%r9,__LC_MCK_OLD_PSW
-       tm      __LC_MCCK_CODE,0x80     # system damage?
+       TSTMSK  __LC_MCCK_CODE,MCCK_CODE_SYSTEM_DAMAGE
        jo      .Lmcck_panic            # yes -> rest of mcck code invalid
        lghi    %r14,__LC_CPU_TIMER_SAVE_AREA
        mvc     __LC_MCCK_ENTER_TIMER(8),0(%r14)
-       tm      __LC_MCCK_CODE+5,0x02   # stored cpu timer value valid?
+       TSTMSK  __LC_MCCK_CODE,MCCK_CODE_CPU_TIMER_VALID
        jo      3f
        la      %r14,__LC_SYNC_ENTER_TIMER
        clc     0(8,%r14),__LC_ASYNC_ENTER_TIMER
@@ -896,7 +893,7 @@ ENTRY(mcck_int_handler)
        la      %r14,__LC_LAST_UPDATE_TIMER
 2:     spt     0(%r14)
        mvc     __LC_MCCK_ENTER_TIMER(8),0(%r14)
-3:     tm      __LC_MCCK_CODE+2,0x09   # mwp + ia of old psw valid?
+3:     TSTMSK  __LC_MCCK_CODE,(MCCK_CODE_PSW_MWP_VALID|MCCK_CODE_PSW_IA_VALID)
        jno     .Lmcck_panic            # no -> skip cleanup critical
        SWITCH_ASYNC __LC_GPREGS_SAVE_AREA+64,__LC_MCCK_ENTER_TIMER
 .Lmcck_skip:
@@ -916,7 +913,7 @@ ENTRY(mcck_int_handler)
        la      %r11,STACK_FRAME_OVERHEAD(%r1)
        lgr     %r15,%r1
        ssm     __LC_PGM_NEW_PSW        # turn dat on, keep irqs off
-       tm      __LC_CPU_FLAGS+7,_CIF_MCCK_PENDING
+       TSTMSK  __LC_CPU_FLAGS,_CIF_MCCK_PENDING
        jno     .Lmcck_return
        TRACE_IRQS_OFF
        brasl   %r14,s390_handle_mcck
@@ -941,7 +938,10 @@ ENTRY(mcck_int_handler)
 # PSW restart interrupt handler
 #
 ENTRY(restart_int_handler)
-       stg     %r15,__LC_SAVE_AREA_RESTART
+       TSTMSK  __LC_MACHINE_FLAGS,MACHINE_FLAG_LPP
+       jz      0f
+       .insn   s,0xb2800000,__LC_LPP
+0:     stg     %r15,__LC_SAVE_AREA_RESTART
        lg      %r15,__LC_RESTART_STACK
        aghi    %r15,-__PT_SIZE                 # create pt_regs on stack
        xc      0(__PT_SIZE,%r15),0(%r15)
@@ -1019,10 +1019,6 @@ cleanup_critical:
        jl      0f
        clg     %r9,BASED(.Lcleanup_table+104)  # .Lload_fpu_regs_end
        jl      .Lcleanup_load_fpu_regs
-       clg     %r9,BASED(.Lcleanup_table+112)  # __ctl_set_vx
-       jl      0f
-       clg     %r9,BASED(.Lcleanup_table+120)  # .L__ctl_set_vx_end
-       jl      .Lcleanup___ctl_set_vx
 0:     br      %r14
 
        .align  8
@@ -1041,8 +1037,6 @@ cleanup_critical:
        .quad   .Lsave_fpu_regs_end
        .quad   load_fpu_regs
        .quad   .Lload_fpu_regs_end
-       .quad   __ctl_set_vx
-       .quad   .L__ctl_set_vx_end
 
 #if IS_ENABLED(CONFIG_KVM)
 .Lcleanup_table_sie:
@@ -1051,10 +1045,7 @@ cleanup_critical:
 
 .Lcleanup_sie:
        lg      %r9,__SF_EMPTY(%r15)            # get control block pointer
-       tm      __LC_MACHINE_FLAGS+6,0x20       # MACHINE_FLAG_LPP
-       jz      0f
-       .insn   s,0xb2800000,__SF_EMPTY+16(%r15)# set host id
-0:     ni      __SIE_PROG0C+3(%r9),0xfe        # no longer in SIE
+       ni      __SIE_PROG0C+3(%r9),0xfe        # no longer in SIE
        lctlg   %c1,%c1,__LC_USER_ASCE          # load primary asce
        larl    %r9,sie_exit                    # skip forward to sie_exit
        br      %r14
@@ -1206,7 +1197,7 @@ cleanup_critical:
        .quad   .Lpsw_idle_lpsw
 
 .Lcleanup_save_fpu_regs:
-       tm      __LC_CPU_FLAGS+7,_CIF_FPU
+       TSTMSK  __LC_CPU_FLAGS,_CIF_FPU
        bor     %r14
        clg     %r9,BASED(.Lcleanup_save_fpu_regs_done)
        jhe     5f
@@ -1224,9 +1215,7 @@ cleanup_critical:
        stfpc   __THREAD_FPU_fpc(%r2)
 1:     # Load register save area and check if VX is active
        lg      %r3,__THREAD_FPU_regs(%r2)
-       ltgr    %r3,%r3
-       jz      5f                        # no save area -> set CIF_FPU
-       tm      __THREAD_FPU_flags+3(%r2),FPU_USE_VX
+       TSTMSK  __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
        jz      4f                        # no VX -> store FP regs
 2:     # Store vector registers (V0-V15)
        VSTM    %v0,%v15,0,%r3            # vstm 0,15,0(3)
@@ -1266,43 +1255,27 @@ cleanup_critical:
        .quad   .Lsave_fpu_regs_done
 
 .Lcleanup_load_fpu_regs:
-       tm      __LC_CPU_FLAGS+7,_CIF_FPU
+       TSTMSK  __LC_CPU_FLAGS,_CIF_FPU
        bnor    %r14
        clg     %r9,BASED(.Lcleanup_load_fpu_regs_done)
        jhe     1f
        clg     %r9,BASED(.Lcleanup_load_fpu_regs_fp)
        jhe     2f
-       clg     %r9,BASED(.Lcleanup_load_fpu_regs_fp_ctl)
-       jhe     3f
        clg     %r9,BASED(.Lcleanup_load_fpu_regs_vx_high)
-       jhe     4f
+       jhe     3f
        clg     %r9,BASED(.Lcleanup_load_fpu_regs_vx)
-       jhe     5f
-       clg     %r9,BASED(.Lcleanup_load_fpu_regs_vx_ctl)
-       jhe     6f
+       jhe     4f
        lg      %r4,__LC_CURRENT
        aghi    %r4,__TASK_thread
        lfpc    __THREAD_FPU_fpc(%r4)
-       tm      __THREAD_FPU_flags+3(%r4),FPU_USE_VX    # VX-enabled task ?
+       TSTMSK  __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
        lg      %r4,__THREAD_FPU_regs(%r4)      # %r4 <- reg save area
-       jz      3f                              # -> no VX, load FP regs
-6:     # Set VX-enablement control
-       stctg   %c0,%c0,__SF_EMPTY+32(%r15)     # store CR0
-       tm      __SF_EMPTY+32+5(%r15),2         # test VX control
-       jo      5f
-       oi      __SF_EMPTY+32+5(%r15),2         # set VX control
-       lctlg   %c0,%c0,__SF_EMPTY+32(%r15)
-5:     # Load V0 ..V15 registers
+       jz      2f                              # -> no VX, load FP regs
+4:     # Load V0 ..V15 registers
        VLM     %v0,%v15,0,%r4
-4:     # Load V16..V31 registers
+3:     # Load V16..V31 registers
        VLM     %v16,%v31,256,%r4
        j       1f
-3:     # Clear VX-enablement control for FP
-       stctg   %c0,%c0,__SF_EMPTY+32(%r15)     # store CR0
-       tm      __SF_EMPTY+32+5(%r15),2         # test VX control
-       jz      2f
-       ni      __SF_EMPTY+32+5(%r15),253       # clear VX control
-       lctlg   %c0,%c0,__SF_EMPTY+32(%r15)
 2:     # Load floating-point registers
        ld      0,0(%r4)
        ld      1,8(%r4)
@@ -1324,28 +1297,15 @@ cleanup_critical:
        ni      __LC_CPU_FLAGS+7,255-_CIF_FPU
        lg      %r9,48(%r11)            # return from load_fpu_regs
        br      %r14
-.Lcleanup_load_fpu_regs_vx_ctl:
-       .quad   .Lload_fpu_regs_vx_ctl
 .Lcleanup_load_fpu_regs_vx:
        .quad   .Lload_fpu_regs_vx
 .Lcleanup_load_fpu_regs_vx_high:
        .quad   .Lload_fpu_regs_vx_high
-.Lcleanup_load_fpu_regs_fp_ctl:
-       .quad   .Lload_fpu_regs_fp_ctl
 .Lcleanup_load_fpu_regs_fp:
        .quad   .Lload_fpu_regs_fp
 .Lcleanup_load_fpu_regs_done:
        .quad   .Lload_fpu_regs_done
 
-.Lcleanup___ctl_set_vx:
-       stctg   %c0,%c0,__SF_EMPTY(%r15)
-       tm      __SF_EMPTY+5(%r15),2
-       bor     %r14
-       oi      __SF_EMPTY+5(%r15),2
-       lctlg   %c0,%c0,__SF_EMPTY(%r15)
-       lg      %r9,48(%r11)            # return from __ctl_set_vx
-       br      %r14
-
 /*
  * Integer constants
  */