[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <dadac419-acda-7ba5-b7bb-4bc5b6fee92d@huawei.com>
Date: Fri, 18 Nov 2022 09:41:03 +0800
From: "liaochang (A)" <liaochang1@...wei.com>
To: Steven Rostedt <rostedt@...dmis.org>,
Chen Guokai <chenguokai17@...ls.ucas.ac.cn>
CC: <paul.walmsley@...ive.com>, <palmer@...belt.com>,
<aou@...s.berkeley.edu>, <mingo@...hat.com>,
<sfr@...b.auug.org.au>, <linux-riscv@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>,
Peter Zijlstra <peterz@...radead.org>,
Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH v4 2/8] riscv/kprobe: Allocate detour buffer from module
area
在 2022/11/17 9:25, Steven Rostedt 写道:
> On Sun, 6 Nov 2022 18:03:10 +0800
> Chen Guokai <chenguokai17@...ls.ucas.ac.cn> wrote:
>
>> @@ -84,6 +85,30 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
>> }
>>
>> #ifdef CONFIG_MMU
>> +#if defined(CONFIG_OPTPROBES) && defined(CONFIG_64BIT)
>> +void *alloc_optinsn_page(void)
>> +{
>> + void *page;
>> +
>> + page = __vmalloc_node_range(PAGE_SIZE, 1, MODULES_VADDR,
>> + MODULES_END, GFP_KERNEL,
>> + PAGE_KERNEL, 0, NUMA_NO_NODE,
>> + __builtin_return_address(0));
>> + if (!page)
>> + return NULL;
>> +
>> + set_vm_flush_reset_perms(page);
>> + /*
>> + * First make the page read-only, and only then make it executable to
>> + * prevent it from being W+X in between.
>> + */
>> + set_memory_ro((unsigned long)page, 1);
>> + set_memory_x((unsigned long)page, 1);
>
> FYI, the above combination is going to be going away:
>
> https://lore.kernel.org/all/Y10OyLCLAAS6rsZv@hirez.programming.kicks-ass.net/
Thanks for reminding, i will use this API in next revision.
> -- Steve
>
>
>> +
>> + return page;
>> +}
>> +#endif
>> +
>
--
BR,
Liao, Chang
Powered by blists - more mailing lists