code-patching.c (1136fa0c07de570dc17858745af8be169d1440ba) | code-patching.c (591b4b268435f00d2f0b81f786c2c7bd5ef66416) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Copyright 2008 Michael Ellerman, IBM Corporation. 4 */ 5 6#include <linux/kprobes.h> 7#include <linux/vmalloc.h> 8#include <linux/init.h> --- 29 unchanged lines hidden (view full) --- 38int raw_patch_instruction(u32 *addr, ppc_inst_t instr) 39{ 40 return __patch_instruction(addr, instr, addr); 41} 42 43#ifdef CONFIG_STRICT_KERNEL_RWX 44static DEFINE_PER_CPU(struct vm_struct *, text_poke_area); 45 | 1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Copyright 2008 Michael Ellerman, IBM Corporation. 4 */ 5 6#include <linux/kprobes.h> 7#include <linux/vmalloc.h> 8#include <linux/init.h> --- 29 unchanged lines hidden (view full) --- 38int raw_patch_instruction(u32 *addr, ppc_inst_t instr) 39{ 40 return __patch_instruction(addr, instr, addr); 41} 42 43#ifdef CONFIG_STRICT_KERNEL_RWX 44static DEFINE_PER_CPU(struct vm_struct *, text_poke_area); 45 |
46static int map_patch_area(void *addr, unsigned long text_poke_addr); 47static void unmap_patch_area(unsigned long addr); 48 |
|
46static int text_area_cpu_up(unsigned int cpu) 47{ 48 struct vm_struct *area; | 49static int text_area_cpu_up(unsigned int cpu) 50{ 51 struct vm_struct *area; |
52 unsigned long addr; 53 int err; |
|
49 50 area = get_vm_area(PAGE_SIZE, VM_ALLOC); 51 if (!area) { 52 WARN_ONCE(1, "Failed to create text area for cpu %d\n", 53 cpu); 54 return -1; 55 } | 54 55 area = get_vm_area(PAGE_SIZE, VM_ALLOC); 56 if (!area) { 57 WARN_ONCE(1, "Failed to create text area for cpu %d\n", 58 cpu); 59 return -1; 60 } |
61 62 // Map/unmap the area to ensure all page tables are pre-allocated 63 addr = (unsigned long)area->addr; 64 err = map_patch_area(empty_zero_page, addr); 65 if (err) 66 return err; 67 68 unmap_patch_area(addr); 69 |
|
56 this_cpu_write(text_poke_area, area); 57 58 return 0; 59} 60 61static int text_area_cpu_down(unsigned int cpu) 62{ 63 free_vm_area(this_cpu_read(text_poke_area)); --- 290 unchanged lines hidden --- | 70 this_cpu_write(text_poke_area, area); 71 72 return 0; 73} 74 75static int text_area_cpu_down(unsigned int cpu) 76{ 77 free_vm_area(this_cpu_read(text_poke_area)); --- 290 unchanged lines hidden --- |