From mboxrd@z Thu Jan 1 00:00:00 1970 From: George Dunlap Subject: Re: [PATCH v2 5/5] x86/mm: only a single instance of gw_page_flags[] is needed Date: Mon, 26 Oct 2015 14:59:32 +0000 Message-ID: <562E3FD4.5020302@citrix.com> References: <562E12E802000078000AE785@prv-mh.provo.novell.com> <562E225002000078000AE8AF@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZqjFK-00026T-Pa for xen-devel@lists.xenproject.org; Mon, 26 Oct 2015 14:59:38 +0000 In-Reply-To: <562E225002000078000AE8AF@prv-mh.provo.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich , xen-devel Cc: George Dunlap , Andrew Cooper , Keir Fraser List-Id: xen-devel@lists.xenproject.org On 26/10/15 11:53, Jan Beulich wrote: > None of its elements depends on GUEST_PAGING_LEVELS. > > Signed-off-by: Jan Beulich > Reviewed-by: Andrew Cooper > --- > v2: Re-base on top of earlier changes. Acked-by: George Dunlap > > --- a/xen/arch/x86/mm/guest_walk.c > +++ b/xen/arch/x86/mm/guest_walk.c > @@ -32,30 +32,32 @@ asm(".file \"" __OBJECT_FILE__ "\""); > #include > #include > > +extern const uint32_t gw_page_flags[]; > +#if GUEST_PAGING_LEVELS == CONFIG_PAGING_LEVELS > +const uint32_t gw_page_flags[] = { > + /* I/F - Usr Wr */ > + /* 0 0 0 0 */ _PAGE_PRESENT, > + /* 0 0 0 1 */ _PAGE_PRESENT|_PAGE_RW, > + /* 0 0 1 0 */ _PAGE_PRESENT|_PAGE_USER, > + /* 0 0 1 1 */ _PAGE_PRESENT|_PAGE_RW|_PAGE_USER, > + /* 0 1 0 0 */ _PAGE_PRESENT, > + /* 0 1 0 1 */ _PAGE_PRESENT|_PAGE_RW, > + /* 0 1 1 0 */ _PAGE_PRESENT|_PAGE_USER, > + /* 0 1 1 1 */ _PAGE_PRESENT|_PAGE_RW|_PAGE_USER, > + /* 1 0 0 0 */ _PAGE_PRESENT|_PAGE_NX_BIT, > + /* 1 0 0 1 */ _PAGE_PRESENT|_PAGE_RW|_PAGE_NX_BIT, > + /* 1 0 1 0 */ _PAGE_PRESENT|_PAGE_USER|_PAGE_NX_BIT, > + /* 1 0 1 1 */ _PAGE_PRESENT|_PAGE_RW|_PAGE_USER|_PAGE_NX_BIT, > + /* 1 1 0 0 */ _PAGE_PRESENT|_PAGE_NX_BIT, > + /* 1 1 0 1 */ _PAGE_PRESENT|_PAGE_RW|_PAGE_NX_BIT, > + /* 1 1 1 0 */ _PAGE_PRESENT|_PAGE_USER|_PAGE_NX_BIT, > + /* 1 1 1 1 */ _PAGE_PRESENT|_PAGE_RW|_PAGE_USER|_PAGE_NX_BIT, > +}; > +#endif > > /* Flags that are needed in a pagetable entry, with the sense of NX inverted */ > static uint32_t mandatory_flags(struct vcpu *v, uint32_t pfec) > { > - static const uint32_t flags[] = { > - /* I/F - Usr Wr */ > - /* 0 0 0 0 */ _PAGE_PRESENT, > - /* 0 0 0 1 */ _PAGE_PRESENT|_PAGE_RW, > - /* 0 0 1 0 */ _PAGE_PRESENT|_PAGE_USER, > - /* 0 0 1 1 */ _PAGE_PRESENT|_PAGE_RW|_PAGE_USER, > - /* 0 1 0 0 */ _PAGE_PRESENT, > - /* 0 1 0 1 */ _PAGE_PRESENT|_PAGE_RW, > - /* 0 1 1 0 */ _PAGE_PRESENT|_PAGE_USER, > - /* 0 1 1 1 */ _PAGE_PRESENT|_PAGE_RW|_PAGE_USER, > - /* 1 0 0 0 */ _PAGE_PRESENT|_PAGE_NX_BIT, > - /* 1 0 0 1 */ _PAGE_PRESENT|_PAGE_RW|_PAGE_NX_BIT, > - /* 1 0 1 0 */ _PAGE_PRESENT|_PAGE_USER|_PAGE_NX_BIT, > - /* 1 0 1 1 */ _PAGE_PRESENT|_PAGE_RW|_PAGE_USER|_PAGE_NX_BIT, > - /* 1 1 0 0 */ _PAGE_PRESENT|_PAGE_NX_BIT, > - /* 1 1 0 1 */ _PAGE_PRESENT|_PAGE_RW|_PAGE_NX_BIT, > - /* 1 1 1 0 */ _PAGE_PRESENT|_PAGE_USER|_PAGE_NX_BIT, > - /* 1 1 1 1 */ _PAGE_PRESENT|_PAGE_RW|_PAGE_USER|_PAGE_NX_BIT, > - }; > - > /* Don't demand not-NX if the CPU wouldn't enforce it. */ > if ( !guest_supports_nx(v) ) > pfec &= ~PFEC_insn_fetch; > @@ -65,7 +67,7 @@ static uint32_t mandatory_flags(struct v > && !(pfec & PFEC_user_mode) ) > pfec &= ~PFEC_write_access; > > - return flags[(pfec & 0x1f) >> 1] | _PAGE_INVALID_BITS; > + return gw_page_flags[(pfec & 0x1f) >> 1] | _PAGE_INVALID_BITS; > } > > /* Modify a guest pagetable entry to set the Accessed and Dirty bits. > > >