xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Oleksandr Andrushchenko <andr2000@gmail.com>
Cc: xen-devel@lists.xenproject.org, ian.jackson@eu.citrix.com,
	Wei Liu <wei.liu2@citrix.com>
Subject: Re: Problem with IOMEM and domain reboot
Date: Tue, 6 Feb 2018 12:36:40 +0000	[thread overview]
Message-ID: <20180206123640.wifqw64camyfpobj@citrix.com> (raw)
In-Reply-To: <ebf78aec-dcfd-72d9-dac2-06b29e4a66ae@gmail.com>

On Wed, Dec 20, 2017 at 06:27:02PM +0200, Oleksandr Andrushchenko wrote:
> Hi, all!
> 
> While trying to reboot a domain which has iomem configured
> (we are passing through some devices), I found an issue,
> that after domain reboot those iomem's are incorrectly re-mapped,
> e.g. for the configuration snippet below fe960 -> 0.
> 
> Part of the domain config I use:
> iomem=[
>     "0xfd010,1@0xfd000",
>     "fe960,8",
> ]
> 
> During domain creation:
> libxl_create.c:210:libxl__domain_build_info_setdefault: iomem gfn fd000
> start fd010
> libxl_create.c:210:libxl__domain_build_info_setdefault: iomem gfn
> ffffffffffffffff start fe960
> 
> which means that for fe960 initial value was set to LIBXL_INVALID_GFN
> and then on domain configuration,
> tools/libxl/libxl_create.c:libxl__domain_build_info_setdefault:
> 
>     for (i = 0 ; i < b_info->num_iomem; i++)
>         if (b_info->iomem[i].gfn == LIBXL_INVALID_GFN)
>             b_info->iomem[i].gfn = b_info->iomem[i].start;
> 
> made that GFN for fe960 to be set to the correct value.
> 
> But during domain reboot I see that
> tools/xl/xl_vmcontrol.c:reload_domain_config
> tries to replicate configuration from the original domain config
> being rebooted, but that leads to iomem's GFN to be set to 0 (if configured
> in form [IOMEM_START,NUM_PAGES], but for [IOMEM_START,NUM_PAGES[@GFN] it is
> ok):
> 
> iomem gfn fd000 start fd010
> iomem gfn 0 start fe960
> 
> Thus, further domain restart procedure leads to invalid mapping, e.g. fe960
> -> 0.
> 
> I created a patch which allowed me to reboot the domain, but I would love
> to hear comments on what would be the proper fix.
> 
> Thank you,
> Oleksandr
> 

> From aa1f20af73a5a3c8f2c904b857a79334d18d41ff Mon Sep 17 00:00:00 2001
> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
> Date: Wed, 20 Dec 2017 17:51:18 +0200
> Subject: [PATCH] [HACK] Reset iomem's gfn to LIBXL_INVALID_GFN on reboot
> 
> During domain reboot its configuration is partially reused
> to re-create a new domain, but iomem's GFN field for the
> iomem is only restored for those memory ranges, which are
> configured in form of [IOMEM_START,NUM_PAGES[@GFN], but not for
> those in form of [IOMEM_START,NUM_PAGES], e.g. without GFN.
> For the latter GFN is reset to 0, but while mapping ranges
> to a domain during reboot there is a check that GFN treated
> as valid if it is not equal to LIBXL_INVALID_GFN, thus making
> Xen to map IOMEM_START to address 0 in the guest's address space.
> 
> Workaround it by resseting GFN to LIBXL_INVALID_GFN, so xl
> can set proper values for mapping on reboot.
> 
> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
> ---
>  tools/libxl/libxl_domain.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c
> index ef1a0927b00d..2678ad2ad54f 100644
> --- a/tools/libxl/libxl_domain.c
> +++ b/tools/libxl/libxl_domain.c
> @@ -1647,6 +1647,15 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid,
>          }
>      }
>  
> +    /* reset IOMEM's GFN to initial value */
> +    {
> +        int i;
> +
> +        for (i = 0; i < d_config->b_info.num_iomem; i++)
> +            if (d_config->b_info.iomem[i].gfn == 0)
> +                d_config->b_info.iomem[i].gfn = LIBXL_INVALID_GFN;
> +    }
> +

I don't think this is necessary. Instead we should tell libxl to save
the generated value into the template. Add an update_config hook for the
iomem type should be better.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2018-02-06 12:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-20 16:27 Problem with IOMEM and domain reboot Oleksandr Andrushchenko
2018-02-01  7:19 ` Oleksandr Andrushchenko
2018-02-06 12:36 ` Wei Liu [this message]
2018-02-06 12:44   ` Oleksandr Andrushchenko
2018-02-06 12:52     ` Wei Liu
2018-02-07 12:14       ` Oleksandr Andrushchenko
2018-02-12 17:22         ` Oleksandr Grytsov
2018-02-13 12:24           ` Wei Liu
2019-01-23 16:28             ` Andrii Anisov
2019-01-24 16:26               ` Wei Liu

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=20180206123640.wifqw64camyfpobj@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=andr2000@gmail.com \
    --cc=ian.jackson@eu.citrix.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 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).