xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Matt Wilson <msw@amazon.com>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: Annie Li <annie.li@oracle.com>,
	Steven Noonan <snoonan@amazon.com>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: Re: [PATCH] xen/grant-table: correctly initialize grant table version 1
Date: Thu, 20 Dec 2012 13:19:47 -0800	[thread overview]
Message-ID: <20121220211945.GA15542@u109add4315675089e695.ant.amazon.com> (raw)
In-Reply-To: <1355997710.26722.12.camel@zakaz.uk.xensource.com>

On Thu, Dec 20, 2012 at 10:01:50AM +0000, Ian Campbell wrote:
> On Wed, 2012-12-19 at 20:20 +0000, Matt Wilson wrote:
> > Commit 85ff6acb075a484780b3d763fdf41596d8fc0970 (xen/granttable: Grant
> > tables V2 implementation) changed the GREFS_PER_GRANT_FRAME macro from
> > a constant to a conditional expression. The expression depends on
> > grant_table_version being appropriately set. Unfortunately, at init
> > time grant_table_version will be 0. The GREFS_PER_GRANT_FRAME
> > conditional expression checks for "grant_table_version == 1", and
> > therefore returns the number of grant references per frame for v2.
> > 
> > This causes gnttab_init() to allocate fewer pages for gnttab_list, as
> > a frame can old half the number of v2 entries than v1 entries. After
> > gnttab_resume() is called, grant_table_version is appropriately
> > set. nr_init_grefs will then be miscalculated and gnttab_free_count
> > will hold a value larger than the actual number of free gref entries.
> > 
> > If a guest is heavily utilizing improperly initialized v1 grant
> > tables, memory corruption can occur.
> 
> Good catch!
> 
> [...]
> @@ -1080,10 +1081,9 @@ static void gnttab_request_version(void)
> >  		panic("we need grant tables version 2, but only version 1 is available");
> >  	} else {
> >  		grant_table_version = 1;
> > +		grefs_per_grant_frame = PAGE_SIZE / sizeof(struct grant_entry_v1);
> >  		gnttab_interface = &gnttab_v1_ops;
> >  	}
> > -	printk(KERN_INFO "Grant tables using version %d layout.\n",
> > -		grant_table_version);
> 
> You remove this here, and re-add it in the gnttab_resume callsite but I
> don't  see anything added at the gnttab_init callsite. It would be
> useful to keep this print at start of day too.
>
> Oh, I see, gnttab_init also calls gnttab_resume later so we get the
> message from there, with gnttab_request_version getting called twice.

Right, I was just avoiding printing the "Grant tables using version 1
layout." message at init time.
 
> Can we avoid doing this twice by moving the tail of gnttab_resume
> (everything except the gnttab_request_version) into a new gnttab_setup
> and calling that from gnttab_resume and gnttab_init (instead of calling
> resume)?

Sure, I can do that.

Matt

  reply	other threads:[~2012-12-20 21:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-19 20:20 [PATCH] xen/grant-table: correctly initialize grant table version 1 Matt Wilson
2012-12-20  3:42 ` ANNIE LI
2012-12-20 21:24   ` Matt Wilson
2012-12-20 10:01 ` Ian Campbell
2012-12-20 21:19   ` Matt Wilson [this message]
     [not found] <Message-ID: <1355997710.26722.12.camel@zakaz.uk.xensource.com>
2013-01-06 11:14 ` [PATCH v2] " Matt Wilson
     [not found] ` <1357470882-17345-1-git-send-email-msw@amazon.com>
2013-01-09  2:40   ` ANNIE LI
     [not found]   ` <50ECD89A.50100@oracle.com>
2013-01-09 12:02     ` Ian Campbell
     [not found]     ` <1357732929.7989.250.camel@zakaz.uk.xensource.com>
2013-01-09 15:02       ` annie li
2013-01-10  9:16       ` Matt Wilson
     [not found]       ` <20130110091652.GB6316@u109add4315675089e695.ant.amazon.com>
2013-01-10 10:32         ` Ian Campbell
2013-01-10 11:02         ` ANNIE LI
2013-01-11 21:35   ` Konrad Rzeszutek Wilk
     [not found]   ` <20130111213550.GA31149@phenom.dumpdata.com>
2013-01-14  9:29     ` Matt Wilson
     [not found]     ` <20130114092936.GB15043@u109add4315675089e695.ant.amazon.com>
2013-01-14 15:31       ` Konrad Rzeszutek Wilk

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=20121220211945.GA15542@u109add4315675089e695.ant.amazon.com \
    --to=msw@amazon.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=annie.li@oracle.com \
    --cc=konrad.wilk@oracle.com \
    --cc=snoonan@amazon.com \
    --cc=xen-devel@lists.xen.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).