From: Oleksandr Andrushchenko <andr2000@gmail.com>
To: Wei Liu <wei.liu2@citrix.com>
Cc: xen-devel@lists.xenproject.org, ian.jackson@eu.citrix.com
Subject: Re: Problem with IOMEM and domain reboot
Date: Wed, 7 Feb 2018 14:14:27 +0200 [thread overview]
Message-ID: <02540760-c159-ec87-d41e-161033fafe13@gmail.com> (raw)
In-Reply-To: <20180206125251.nirlx5ynwbzszrss@citrix.com>
On 02/06/2018 02:52 PM, Wei Liu wrote:
> On Tue, Feb 06, 2018 at 02:44:56PM +0200, Oleksandr Andrushchenko wrote:
>> 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.
>> Agree, this is why I tagged the patch as [HACK]
>> Unfortunately, I have little knowledge of libxl and not sure
>> how to properly fix it. Can you tell a bit more on what
>> a proper fix could be?
> See libxl__update_domain_configuration, which is called after domain
> construction is completed. It will call the update_config hook for a
> device type to save anything that is generated in the process of domain
> creation. One example is in libxl_nic. You can do the same to iomem I
> think.
>
> The end result is the generated values you care about are saved into the
> template. When the domain is migrated / rebooted libxl will use the
> saved values instead.
Thank you, will look at it to make a proper fix
> Strictly speaking your patch of adding the snippet to
> libxl_retrieve_domain_configuration isn't wrong, but I would prefer that
> function to only contain code to fetch states that can be changed during
> domain runtime. The iomem range isn't one of those states AIUI.
>
> Wei.
>
>
>>> Wei.
>> Thank you,
>> Oleksandr
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-02-07 12:14 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
2018-02-06 12:44 ` Oleksandr Andrushchenko
2018-02-06 12:52 ` Wei Liu
2018-02-07 12:14 ` Oleksandr Andrushchenko [this message]
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=02540760-c159-ec87-d41e-161033fafe13@gmail.com \
--to=andr2000@gmail.com \
--cc=ian.jackson@eu.citrix.com \
--cc=wei.liu2@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).