Re: hv_hypercall_pg page permissios

2020-06-16 Thread Christoph Hellwig
On Tue, Jun 16, 2020 at 01:24:15PM +0200, Peter Zijlstra wrote: > > +void *module_alloc_prot(unsigned long size, pgprot_t prot) > > { > > + unsigned int flags = (pgprot_val(prot) & _PAGE_NX) ? > > + 0 : VM_FLUSH_RESET_PERMS; > > void *p; > > > > if (PAGE_ALIGN(size) >

Re: hv_hypercall_pg page permissios

2020-06-16 Thread Peter Zijlstra
On Tue, Jun 16, 2020 at 12:52:00PM +0200, Christoph Hellwig wrote: > I think something like this should solve the issue: > > -- > diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h > index e988bac0a4a1c3..716e4de44a8e78 100644 > --- a/arch/x86/include/asm/module.h > +++ b/

Re: hv_hypercall_pg page permissios

2020-06-16 Thread Christoph Hellwig
On Tue, Jun 16, 2020 at 12:42:30PM +0200, Christoph Hellwig wrote: > On Tue, Jun 16, 2020 at 12:40:32PM +0200, Peter Zijlstra wrote: > > On Tue, Jun 16, 2020 at 12:33:13PM +0200, Christoph Hellwig wrote: > > > sorry, s/ftrace/kprobes/. See my updated branch here: > > > > > > http://git.infradead.

Re: hv_hypercall_pg page permissios

2020-06-16 Thread Vitaly Kuznetsov
Christoph Hellwig writes: > On Tue, Jun 16, 2020 at 11:55:49AM +0200, Christoph Hellwig wrote: >> Actually, what do you think of this one: > I see Peter has some concerns but if vmalloc_exec() used to work then open-coding it with the right flags should do. I've also tested your patch with Hyper

Re: hv_hypercall_pg page permissios

2020-06-16 Thread Christoph Hellwig
On Tue, Jun 16, 2020 at 12:40:32PM +0200, Peter Zijlstra wrote: > On Tue, Jun 16, 2020 at 12:33:13PM +0200, Christoph Hellwig wrote: > > sorry, s/ftrace/kprobes/. See my updated branch here: > > > > http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/module_alloc-cleanup > > Ah the i

Re: hv_hypercall_pg page permissios

2020-06-16 Thread Peter Zijlstra
On Tue, Jun 16, 2020 at 12:33:13PM +0200, Christoph Hellwig wrote: > sorry, s/ftrace/kprobes/. See my updated branch here: > > http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/module_alloc-cleanup Ah the insn slot page, yes. Didn't you just loose VM_FLUSH_RESET_PERMS there?

Re: hv_hypercall_pg page permissios

2020-06-16 Thread Christoph Hellwig
On Tue, Jun 16, 2020 at 12:31:37PM +0200, Peter Zijlstra wrote: > On Tue, Jun 16, 2020 at 12:24:12PM +0200, Christoph Hellwig wrote: > > On Tue, Jun 16, 2020 at 12:23:50PM +0200, Christoph Hellwig wrote: > > > > > + hv_hypercall_pg = module_alloc(PAGE_SIZE); > > > > if (hv_hypercall_

Re: hv_hypercall_pg page permissios

2020-06-16 Thread Peter Zijlstra
On Tue, Jun 16, 2020 at 12:24:12PM +0200, Christoph Hellwig wrote: > On Tue, Jun 16, 2020 at 12:23:50PM +0200, Christoph Hellwig wrote: > > > + hv_hypercall_pg = module_alloc(PAGE_SIZE); > > > if (hv_hypercall_pg == NULL) { > > > wrmsrl(HV_X64_MSR_GUEST_OS_ID, 0); > > > goto

Re: hv_hypercall_pg page permissios

2020-06-16 Thread Christoph Hellwig
On Tue, Jun 16, 2020 at 12:23:50PM +0200, Christoph Hellwig wrote: > On Tue, Jun 16, 2020 at 12:18:07PM +0200, Peter Zijlstra wrote: > > > It does. But it also means every other user of PAGE_KERNEL_EXEC > > > should trigger this, of which there are a few (kexec, tboot, hibernate, > > > early xen p

Re: hv_hypercall_pg page permissios

2020-06-16 Thread Christoph Hellwig
On Tue, Jun 16, 2020 at 12:18:07PM +0200, Peter Zijlstra wrote: > > It does. But it also means every other user of PAGE_KERNEL_EXEC > > should trigger this, of which there are a few (kexec, tboot, hibernate, > > early xen pv mapping, early SEV identity mapping) > > There are only 3 users in the e

Re: hv_hypercall_pg page permissios

2020-06-16 Thread Peter Zijlstra
On Tue, Jun 16, 2020 at 11:55:49AM +0200, Christoph Hellwig wrote: > + hv_hypercall_pg = __vmalloc_node_range(PAGE_SIZE, 1, VMALLOC_START, > + VMALLOC_END, GFP_KERNEL, PAGE_KERNEL_RX, > + VM_FLUSH_RESET_PERMS, NUMA_NO_NODE, __func__); I think that's wron

Re: hv_hypercall_pg page permissios

2020-06-16 Thread Peter Zijlstra
On Tue, Jun 16, 2020 at 09:23:18AM +0200, Christoph Hellwig wrote: > On Mon, Jun 15, 2020 at 07:49:41PM +, Dexuan Cui wrote: > > I did this experiment: > > 1. export vmalloc_exec and ptdump_walk_pgd_level_checkwx. > > 2. write a test module that calls them. > > 3. It turns out that every

Re: hv_hypercall_pg page permissios

2020-06-16 Thread Christoph Hellwig
On Tue, Jun 16, 2020 at 11:55:49AM +0200, Christoph Hellwig wrote: > Actually, what do you think of this one: Plus this whole series to kill of vmalloc_exec entirely: http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/vmalloc_exec-fixes

Re: hv_hypercall_pg page permissios

2020-06-16 Thread Christoph Hellwig
Actually, what do you think of this one: --- >From a5ee278f4244c6bfc0ce2d2b2fd4f99358dbde4d Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 16 Jun 2020 11:50:59 +0200 Subject: x86/hyperv: allocate the hypercall page with only read and execute bits Avoid a W^X violation cause by the

Re: hv_hypercall_pg page permissios

2020-06-16 Thread Christoph Hellwig
On Tue, Jun 16, 2020 at 11:29:33AM +0200, Vitaly Kuznetsov wrote: > it seems we need something like PAGE_KERNEL_READONLY_EXEC but we don't > seem to have one on x86. Hypercall page is special in a way that the > guest doesn't need to write there at all. vmalloc_exec() seems to have > only one other

RE: hv_hypercall_pg page permissios

2020-06-16 Thread Vitaly Kuznetsov
Dexuan Cui writes: >> From: linux-hyperv-ow...@vger.kernel.org >> On Behalf Of Dexuan Cui >> Sent: Monday, June 15, 2020 10:42 AM >> > > >> > > Hi hch, >> > > The patch is merged into the mainine recently, but unluckily we noticed >> > > a warning with CONFIG_DEBUG_WX=y >> > > >> > > Should we r

Re: hv_hypercall_pg page permissios

2020-06-16 Thread Christoph Hellwig
On Mon, Jun 15, 2020 at 07:49:41PM +, Dexuan Cui wrote: > I did this experiment: > 1. export vmalloc_exec and ptdump_walk_pgd_level_checkwx. > 2. write a test module that calls them. > 3. It turns out that every call of vmalloc_exec() triggers such a warning. > > vmalloc_exec() uses PAGE

RE: hv_hypercall_pg page permissios

2020-06-15 Thread Dexuan Cui
> From: linux-hyperv-ow...@vger.kernel.org > On Behalf Of Dexuan Cui > Sent: Monday, June 15, 2020 10:42 AM > > > > > > Hi hch, > > > The patch is merged into the mainine recently, but unluckily we noticed > > > a warning with CONFIG_DEBUG_WX=y > > > > > > Should we revert this patch, or figure ou

RE: hv_hypercall_pg page permissios

2020-06-15 Thread Dexuan Cui
> From: Vitaly Kuznetsov > Sent: Monday, June 15, 2020 1:35 AM > Dexuan Cui writes: > > >> From: linux-hyperv-ow...@vger.kernel.org > >> On Behalf Of Andy Lutomirski > >> Sent: Tuesday, April 7, 2020 2:01 PM > >> > On Apr 7, 2020, at 12:38 AM, Christoph Hellwig wrote: > >> > > >> > On Tue, Ap

RE: hv_hypercall_pg page permissios

2020-06-15 Thread Vitaly Kuznetsov
KY Srinivasan >> ; Stephen Hemminger ; >> Andy Lutomirski ; Peter Zijlstra >> Subject: Re: hv_hypercall_pg page permissios >> >> >> > On Apr 7, 2020, at 12:38 AM, Christoph Hellwig wrote: >> > >> > On Tue, Apr 07, 2020 at 0

RE: hv_hypercall_pg page permissios

2020-06-12 Thread Dexuan Cui
Andy Lutomirski ; Peter Zijlstra > Subject: Re: hv_hypercall_pg page permissios > > > > On Apr 7, 2020, at 12:38 AM, Christoph Hellwig wrote: > > > > On Tue, Apr 07, 2020 at 09:28:01AM +0200, Vitaly Kuznetsov wrote: > >> Christoph Hellwig writes: &