svn commit: r316767 - head/sys/amd64/amd64

Konstantin Belousov kostikbel at gmail.com
Tue Apr 18 13:46:03 UTC 2017


On Tue, Apr 18, 2017 at 12:41:09PM +0000, Dexuan Cui wrote:
> > From: owner-svn-src-head at freebsd.org [mailto:owner-svn-src-
> > head at freebsd.org] On Behalf Of Konstantin Belousov
> > Sent: Thursday, April 13, 2017 23:50
> > 
> > Author: kib
> > Date: Thu Apr 13 15:49:55 2017
> > New Revision: 316767
> > URL:
> > 
> > Log:
> >   Map DMAP as nx.
> > 
> >   Demotions preserve PG_NX, so it is enough to set nx bit for initial
> >   lowest-level paging entries.
> > 
> > Modified:
> >   head/sys/amd64/amd64/pmap.c
>  
> Hi kib,
> Unluckily this patch breaks Hyper-V VM:
> 
> In dev/hyperv/vmbus/hyperv.c: hypercall_create() we allocate one
> page and pass its physical address to the hypervisor, which initializes
> the page with executable code.
> 
> Later in dev/hyperv/vmbus/hyperv.c: hypercall_post_message(), we
> "call" the executable code in the above page.
> 
> Now with NX, the "call" gets a fault and as a result FreeBSD VM
> can't boot on Hyper-V.
> 
> It looks memory allocated by bus_dmamem_alloc() and malloc()
> is not executable now.
> 
> What else can we use?
> I guess we can only use contigmalloc() or kmem_malloc() to
> get a page that can be executable and use vtophys() to get its
> physical address?
Yes, the kmem_malloc() is considered to be a suitable substitution for
regular malloc(9) if the executable mapping is needed.  See r317072
for a similar fix for the same issue.


More information about the svn-src-head mailing list