cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

cp6.c (956B)


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