]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
xtensa: enable coprocessors that are being flushed
authorMax Filippov <jcmvbkbc@gmail.com>
Mon, 26 Nov 2018 21:29:41 +0000 (13:29 -0800)
committerMax Filippov <jcmvbkbc@gmail.com>
Tue, 27 Nov 2018 02:37:47 +0000 (18:37 -0800)
commit2958b66694e018c552be0b60521fec27e8d12988
tree60b3cfc5e1aa1a7f91736874a919012fa45175a2
parent2e6e902d185027f8e3cb8b7305238f7e35d6a436
xtensa: enable coprocessors that are being flushed

coprocessor_flush_all may be called from a context of a thread that is
different from the thread being flushed. In that case contents of the
cpenable special register may not match ti->cpenable of the target
thread, resulting in unhandled coprocessor exception in the kernel
context.
Set cpenable special register to the ti->cpenable of the target register
for the duration of the flush and restore it afterwards.
This fixes the following crash caused by coprocessor register inspection
in native gdb:

  (gdb) p/x $w0
  Illegal instruction in kernel: sig: 9 [#1] PREEMPT
  Call Trace:
    ___might_sleep+0x184/0x1a4
    __might_sleep+0x41/0xac
    exit_signals+0x14/0x218
    do_exit+0xc9/0x8b8
    die+0x99/0xa0
    do_illegal_instruction+0x18/0x6c
    common_exception+0x77/0x77
    coprocessor_flush+0x16/0x3c
    arch_ptrace+0x46c/0x674
    sys_ptrace+0x2ce/0x3b4
    system_call+0x54/0x80
    common_exception+0x77/0x77
  note: gdb[100] exited with preempt_count 1
  Killed

Cc: stable@vger.kernel.org
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
arch/xtensa/kernel/process.c