From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: xen-devel@lists.xensource.com,
Ian Campbell <Ian.Campbell@citrix.com>,
alex@alex.org.uk
Subject: Re: workaround for dom0 crash due to QEMU using O_DIRECT
Date: Mon, 8 Jul 2013 15:18:53 -0400 [thread overview]
Message-ID: <20130708191853.GA4927@phenom.dumpdata.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1307041539280.5067@kaball.uk.xensource.com>
On Thu, Jul 04, 2013 at 07:19:40PM +0100, Stefano Stabellini wrote:
> Hi Alex,
> speaking with Ian about the dom0 kernel crash caused by using O_DIRECT
> in QEMU, we came up with a simple workaround that should turn the crash
> into a data corruption problem (same as native).
<chuckles> You should for fun also do 0xEE on the 'trade_page' whenever
we update the PTE. That way we can detect the corruption as by default
the trade_page would be 00.
>
> The idea is that when we balloon out pages, we replace the original page
> with a mapping of a scrub page, so that if the network stack wants to
> access an old grant that doesn't exist anymore, it should find a valid
> page mapped there (the scrub page).
This will I think make it hard to do increase_reservation
as it consults the P2M to make sure the PFN is indeed 'free'.
But then this is a debug patch..
>
> Could you please try the appended patch for Linux with QEMU that uses
> O_DIRECT to open a file on NFS?
>
> Thanks!
>
> - Stefano
>
> ---
>
>
> diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
> index 930fb68..0663fda 100644
> --- a/drivers/xen/balloon.c
> +++ b/drivers/xen/balloon.c
> @@ -88,6 +88,7 @@ EXPORT_SYMBOL_GPL(balloon_stats);
>
> /* We increase/decrease in batches which fit in a page */
> static xen_pfn_t frame_list[PAGE_SIZE / sizeof(unsigned long)];
> +static struct page* trade_page;
>
> #ifdef CONFIG_HIGHMEM
> #define inc_totalhigh_pages() (totalhigh_pages++)
> @@ -423,7 +424,7 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp)
> if (xen_pv_domain() && !PageHighMem(page)) {
> ret = HYPERVISOR_update_va_mapping(
> (unsigned long)__va(pfn << PAGE_SHIFT),
> - __pte_ma(0), 0);
> + pfn_pte(page_to_pfn(trade_page), PAGE_KERNEL), 0);
> BUG_ON(ret);
> }
> #endif
> @@ -436,7 +437,7 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp)
> /* No more mappings: invalidate P2M and add to balloon. */
> for (i = 0; i < nr_pages; i++) {
> pfn = mfn_to_pfn(frame_list[i]);
> - __set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
> + __set_phys_to_machine(pfn, pfn_to_mfn(page_to_pfn(trade_page)));
> balloon_append(pfn_to_page(pfn));
> }
>
> @@ -591,6 +592,10 @@ static int __init balloon_init(void)
> if (!xen_domain())
> return -ENODEV;
>
> + trade_page = alloc_page(GFP_KERNEL);
> + if (trade_page == NULL)
> + return -ENOMEM;
> +
> pr_info("xen/balloon: Initialising balloon driver.\n");
>
> balloon_stats.current_pages = xen_pv_domain()
next prev parent reply other threads:[~2013-07-08 19:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-04 18:19 workaround for dom0 crash due to QEMU using O_DIRECT Stefano Stabellini
2013-07-04 18:25 ` Alex Bligh
2013-07-04 19:09 ` Stefano Stabellini
2013-07-16 14:25 ` Diana Crisan
2013-07-18 17:27 ` Stefano Stabellini
2013-07-08 19:18 ` Konrad Rzeszutek Wilk [this message]
2013-07-08 19:40 ` Alex Bligh
2013-07-08 20:48 ` Ian Campbell
2013-07-08 22:40 ` Alex Bligh
2013-07-09 13:39 ` George Dunlap
2013-07-09 15:52 ` Alex Bligh
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=20130708191853.GA4927@phenom.dumpdata.com \
--to=konrad.wilk@oracle.com \
--cc=Ian.Campbell@citrix.com \
--cc=alex@alex.org.uk \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/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.