• Heiko Carstens's avatar
    s390: fix transactional execution control register handling · a1c5befc
    Heiko Carstens authored
    Dan Horák reported the following crash related to transactional execution:
    
    User process fault: interruption code 0013 ilc:3 in libpthread-2.26.so[3ff93c00000+1b000]
    CPU: 2 PID: 1 Comm: /init Not tainted 4.13.4-300.fc27.s390x #1
    Hardware name: IBM 2827 H43 400 (z/VM 6.4.0)
    task: 00000000fafc8000 task.stack: 00000000fafc4000
    User PSW : 0705200180000000 000003ff93c14e70
               R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:1 AS:0 CC:2 PM:0 RI:0 EA:3
    User GPRS: 0000000000000077 000003ff00000000 000003ff93144d48 000003ff93144d5e
               0000000000000000 0000000000000002 0000000000000000 000003ff00000000
               0000000000000000 0000000000000418 0000000000000000 000003ffcc9fe770
               000003ff93d28f50 000003ff9310acf0 000003ff92b0319a 000003ffcc9fe6d0
    User Code: 000003ff93c14e62: 60e0b030            std     %f14,48(%r11)
               000003ff93c14e66: 60f0b038            std     %f15,56(%r11)
              #000003ff93c14e6a: e5600000ff0e        tbegin  0,65294
              >000003ff93c14e70: a7740006            brc     7,3ff93c14e7c
               000003ff93c14e74: a7080000            lhi     %r0,0
               000003ff93c14e78: a7f40023            brc     15,3ff93c14ebe
               000003ff93c14e7c: b2220000            ipm     %r0
               000003ff93c14e80: 8800001c            srl     %r0,28
    
    There are several bugs with control register handling with respect to
    transactional execution:
    
    - on task switch update_per_regs() is only called if the next task has
      an mm (is not a kernel thread). This however is incorrect. This
      breaks e.g. for user mode helper handling, where the kernel creates
      a kernel thread and then execve's a user space program. Control
      register contents related to transactional execution won't be
      updated on execve. If the previous task ran with transactional
      execution disabled then the new task will also run with
      transactional execution disabled, which is incorrect. Therefore call
      update_per_regs() unconditionally within switch_to().
    
    - on startup the transactional execution facility is not enabled for
      the idle thread. This is not really a bug, but an inconsistency to
      other facilities. Therefore enable the facility if it is available.
    
    - on fork the new thread's per_flags field is not cleared. This means
      that a child process inherits the PER_FLAG_NO_TE flag. This flag can
      be set with a ptrace request to disable transactional execution for
      the current process. It should not be inherited by new child
      processes in order to be consistent with the handling of all other
      PER related debugging options. Therefore clear the per_flags field in
      copy_thread_tls().
    Reported-and-tested-by: default avatarDan Horák <dan@danny.cz>
    Fixes: d35339a4 ("s390: add support for transactional memory")
    Cc: <stable@vger.kernel.org> # v3.7+
    Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
    Reviewed-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
    Reviewed-by: default avatarHendrik Brueckner <brueckner@linux.vnet.ibm.com>
    Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
    a1c5befc
process.c 5.81 KB