All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tim Deegan <tim@xen.org>
To: Jan Beulich <JBeulich@suse.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: open-coded page list manipulation in shadow code
Date: Fri, 30 Jan 2015 11:20:07 +0100	[thread overview]
Message-ID: <20150130102007.GA17164@deinos.phlegethon.org> (raw)
In-Reply-To: <54CB509B020000780005B264@mail.emea.novell.com>

At 08:36 +0000 on 30 Jan (1422603387), Jan Beulich wrote:
> >>> On 29.01.15 at 18:30, <tim@xen.org> wrote:
> > OK, here's what I have.  It keeps the mechanism the same, threading on
> > the main page list entry, but tidies it up to use the page_list operations
> > rather than open-coding.  I've tested it (lightly - basically jsut
> > boot testing) with 32bit, 32pae and 64bit Windows VMs (all SMP), with
> > bigmem=y and bigmem=n.
> > 
> > It was developed on top of your bigmem series, but it should apply OK
> > before patch 3/4, removing the need to nobble shadow-paging in that
> > patch.
> 
> Thanks, looks quite okay, just a couple of remarks.
> 
> > @@ -1525,6 +1495,14 @@ mfn_t shadow_alloc(struct domain *d,
> >      if ( shadow_type >= SH_type_min_shadow 
> >           && shadow_type <= SH_type_max_shadow )
> >          sp->u.sh.head = 1;
> > +
> > +#ifndef PAGE_LIST_NULL
> > +    /* The temporary list-head is on our stack.  Blank out the
> > +     * pointers to it in the shadows, just to get a clean failure if
> > +     * we accidentally follow them. */
> > +    tmp_list.next->prev = tmp_list.prev->next = NULL;
> > +#endif
> 
> Perhaps better to use LIST_POISON{1,2} here, so we don't point into
> PV VA space?

Yep, will do.

> > --- a/xen/arch/x86/mm/shadow/private.h
> > +++ b/xen/arch/x86/mm/shadow/private.h
> > @@ -318,6 +318,33 @@ static inline int mfn_oos_may_write(mfn_t gmfn)
> >  }
> >  #endif /* (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC) */
> >  
> > +/* Figure out the size (in pages) of a given shadow type */
> > +static inline u32
> > +shadow_size(unsigned int shadow_type) 
> > +{
> > +    static const u32 type_to_size[SH_type_unused] = {
> > +        1, /* SH_type_none           */
> > +        2, /* SH_type_l1_32_shadow   */
> > +        2, /* SH_type_fl1_32_shadow  */
> > +        4, /* SH_type_l2_32_shadow   */
> > +        1, /* SH_type_l1_pae_shadow  */
> > +        1, /* SH_type_fl1_pae_shadow */
> > +        1, /* SH_type_l2_pae_shadow  */
> > +        1, /* SH_type_l2h_pae_shadow */
> > +        1, /* SH_type_l1_64_shadow   */
> > +        1, /* SH_type_fl1_64_shadow  */
> > +        1, /* SH_type_l2_64_shadow   */
> > +        1, /* SH_type_l2h_64_shadow  */
> > +        1, /* SH_type_l3_64_shadow   */
> > +        1, /* SH_type_l4_64_shadow   */
> > +        1, /* SH_type_p2m_table      */
> > +        1, /* SH_type_monitor_table  */
> > +        1  /* SH_type_oos_snapshot   */
> > +        };
> > +    ASSERT(shadow_type < SH_type_unused);
> > +    return type_to_size[shadow_type];
> > +}
> 
> Isn't this going to lead to multiple instances of that static array?

Urgh, maybe.  I'd have thought this would end up as a common symbol
(if that's the term I mean - one where the linker will merge identical
copies) but I didn't check what actually happens.  I'll move it back
into a .c and just have the lookup function in the header.

> > +#ifndef PAGE_LIST_NULL
> > +    /* The temporary list-head is on our stack.  Blank out the
> > +     * pointers to it in the shadows, just to get a clean failure if
> > +     * we accidentally follow them. */
> > +    tmp_list.next->prev = tmp_list.prev->next = NULL;
> > +#endif
> 
> Same here. Perhaps worth putting into another inline helper?

Yep, will do so for v2.

Cheers,

Tim.

  reply	other threads:[~2015-01-30 10:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-26 16:35 open-coded page list manipulation in shadow code Jan Beulich
2015-01-27 10:50 ` Tim Deegan
2015-01-29 17:30   ` Tim Deegan
2015-01-30  8:36     ` Jan Beulich
2015-01-30 10:20       ` Tim Deegan [this message]
2015-01-30 10:26         ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150130102007.GA17164@deinos.phlegethon.org \
    --to=tim@xen.org \
    --cc=JBeulich@suse.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.