^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * IOP Coprocessor-6 access handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (c) 2006, Intel Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <asm/traps.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <asm/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) static int cp6_trap(struct pt_regs *regs, unsigned int instr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) u32 temp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) /* enable cp6 access */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) asm volatile (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) "mrc p15, 0, %0, c15, c1, 0\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) "orr %0, %0, #(1 << 6)\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) "mcr p15, 0, %0, c15, c1, 0\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) : "=r"(temp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) /* permit kernel space cp6 access
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * deny user space cp6 access
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) static struct undef_hook cp6_hook = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) .instr_mask = 0x0f000ff0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) .instr_val = 0x0e000610,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) .cpsr_mask = MODE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) .cpsr_val = SVC_MODE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) .fn = cp6_trap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) void __init iop_init_cp6_handler(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) register_undef_hook(&cp6_hook);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) }