From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: Tim Deegan <tim@xen.org>
Cc: Olaf Hering <olaf@aepfle.de>, Wei Liu <wei.liu2@citrix.com>,
Ian Campbell <ian.campbell@citrix.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Julien Grall <julien.grall@linaro.org>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Andrew Jones <drjones@redhat.com>,
David Vrabel <david.vrabel@citrix.com>,
Jan Beulich <JBeulich@suse.com>,
xen-devel@lists.xenproject.org,
Daniel De Graaf <dgdegra@tycho.nsa.gov>,
Keir Fraser <keir@xen.org>
Subject: Re: [PATCH v6 04/10] xen: Introduce XENMEM_soft_reset operation
Date: Tue, 26 May 2015 10:05:24 +0200 [thread overview]
Message-ID: <87y4kbsr0b.fsf@vitty.brq.redhat.com> (raw)
In-Reply-To: <20150525161310.GG20679@deinos.phlegethon.org> (Tim Deegan's message of "Mon, 25 May 2015 17:13:10 +0100")
Tim Deegan <tim@xen.org> writes:
> At 12:06 +0200 on 25 May (1432555565), Vitaly Kuznetsov wrote:
>> Tim Deegan <tim@xen.org> writes:
>>
>> > At 17:26 +0100 on 22 May (1432315574), Jan Beulich wrote:
>> >> >>> On 22.05.15 at 17:36, <vkuznets@redhat.com> wrote:
>> >> >>>>> On 13.05.15 at 11:49, <vkuznets@redhat.com> wrote:
>> >> >>> + if ( !source_d->is_dying )
>> >> >>> + {
>> >> >>> + /*
>> >> >>> + * Make sure no allocation/remapping for the source domain is ongoing
>> >> >>> + * and set is_dying flag to prevent such actions in future.
>> >> >>> + */
>> >> >>> + spin_lock(&source_d->page_alloc_lock);
>> >> >>> + source_d->is_dying = DOMDYING_locked;
>> >> >>
>> >> >> Furthermore I don't see how this prevents there being further
>> >> >> changes to the GFN <-> MFN mappings for the guest (yet you rely
>> >> >> on them to be stable below afaict).
>> >> >>
>> >> >
>> >> > As you suggested below we can complement that by pausing both source and
>> >> > destination domains here. In that case these domains won't be changing
>> >> > their mappings by themselves but it would still be possible for the
>> >> > hypervisor to change something. We do have !d->is_dying check in many
>> >> > places though ... In theory we could have taken the p2m_lock() for both
>> >> > domains but I'm not sure all stuff I need here will cope with p2m_lock()
>> >> > already being held, this lock is x86-specific and I'm not sure we want
>> >> > it in the first place. I'd be very grateful for some additional ideas on
>> >> > how to make it safer.
>> >>
>> >> For whether p2m_lock() might be needed here I'd like to defer to
>> >> Tim.
>> >
>> > I don't think that will work. Given that you have to make this
>> > preemptable you can't hope to hold the p2m lock for the entire
>> > operation.
>> >
>> > If you want to make sure that the p2m mapping doesn't change
>> > underfoot, you can use get_gfn()/put_gfn() around each individual
>> > operation.
>>
>> Thanks, I see... An additional concern from Jan was (I suppose) about
>> the safeness (or correctness) of this operation as a whole: even when
>> both source and destination domains are paused their mappings can be
>> changed by the control domain (especially having possible preemption in
>> mind).
>
> True. I don't think there's anything you can do about that. As I
> said, you can't hold the p2m lock while your operation is
> preempted. AFAICT this operation is pretty much best-effort already;
> it doesn't really handle grant-table/shared/paged/readonly/access-controlled
> mappings.
This is intentional mostly intentional and desired: when a Linux guest
does e.g. kexec there is no easy way to transfer the knowledge from one
kernel to another. This operation is supposed to emulate a normal reboot
for a domain where all these special mappings are being lost.
>
>> > If you use get_gfn_type_access() it will also report
>> > superpage mappings, so you can drop the loop that attempts
>> > to detect them in the PoD case.
>>
>> Thanks, I'll have a look. This one is x86-specific but the whole PoD
>> case is already x86-specific because of p2m_is_pod().
>
> It might be worth adding this interface to arm, depending on
> what you want to do about p2m-access types. E.g. can a guest OS use
> this kexec operation to turn off all its p2m-access controls (and so
> escape from the control of an external security tool)?
Good question. We could definitely do
p2m_get_mem_access/p2m_set_mem_access to preserve this information but
I'm not sure we really need this. What happens when a domain reboots? It
gets new p2m and all p2m-access controls are being lost so all external
security tools are supposed to re-establish all the required p2m-access
controls. The only difference with soft-reset is the fact that the
memory content is being preserved but the same effect could in theory be
achieved by the guest domain itself by e.g. dumping all memory content
to a persistent storage, rebooting and restoring it.
>
>> > Incidentally, counting from 0-->max_mapped_gfn is unfortunate (though I
>> > know this is not the first code to do that). It would be better
>> > to introduce an iterator over the p2m itself, either some sort of
>> > for_each_gfn(dom, callback_fn, callback_arg) or a get_next_gfn(dom,
>> > base_gfn, &found_gfn) that skips unmapped areas.
>>
>> I agree. Do you see this as a compulsory part of this series?
>
> I don't think so; not in something like this form anyway. If you
> wanted to handle the source p2m changing underfoot by re-scanning for
> new entries, then you'd definitely want it.
No, not really. Protecting against a misbehaving control domain
(guaranteeing the correctness of the operation) is going
to be incomplete anyway. I think we just need to make this operation
safe so even the control domain won't be able to compromise the
hypervisor by doing something nasty.
>
> Tim.
--
Vitaly
next prev parent reply other threads:[~2015-05-26 8:05 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-13 9:49 [PATCH v6 00/10] toolstack-based approach to pvhvm guest kexec Vitaly Kuznetsov
2015-05-13 9:49 ` [PATCH v6 01/10] xen: introduce SHUTDOWN_soft_reset shutdown reason Vitaly Kuznetsov
2015-05-13 9:49 ` [PATCH v6 02/10] libxl: support " Vitaly Kuznetsov
2015-05-20 9:44 ` Wei Liu
2015-05-13 9:49 ` [PATCH v6 03/10] xen: introduce DOMDYING_locked state Vitaly Kuznetsov
2015-05-13 9:49 ` [PATCH v6 04/10] xen: Introduce XENMEM_soft_reset operation Vitaly Kuznetsov
2015-05-22 9:38 ` Jan Beulich
2015-05-22 15:36 ` Vitaly Kuznetsov
2015-05-22 16:26 ` Jan Beulich
2015-05-25 9:24 ` Tim Deegan
2015-05-25 10:06 ` Vitaly Kuznetsov
2015-05-25 16:13 ` Tim Deegan
2015-05-26 8:05 ` Vitaly Kuznetsov [this message]
2015-05-26 8:50 ` Jan Beulich
2015-05-13 9:49 ` [PATCH v6 05/10] xsm: add XENMEM_soft_reset support Vitaly Kuznetsov
2015-05-20 23:30 ` Daniel De Graaf
2015-05-21 9:49 ` Vitaly Kuznetsov
2015-05-21 14:25 ` Daniel De Graaf
2015-05-22 9:40 ` Jan Beulich
2015-05-22 14:58 ` Daniel De Graaf
2015-05-22 15:26 ` Jan Beulich
2015-05-22 14:59 ` Vitaly Kuznetsov
2015-05-13 9:49 ` [PATCH v6 06/10] libxc: support XENMEM_soft_reset operation Vitaly Kuznetsov
2015-05-13 9:49 ` [PATCH v6 07/10] libxc: introduce soft reset for HVM domains Vitaly Kuznetsov
2015-05-20 15:10 ` Julien Grall
2015-05-20 15:20 ` Vitaly Kuznetsov
2015-05-20 15:28 ` Julien Grall
2015-05-13 9:49 ` [PATCH v6 08/10] xl: introduce enum domain_restart_type Vitaly Kuznetsov
2015-05-13 9:49 ` [PATCH v6 09/10] libxc: add XC_DEVICE_MODEL_SAVE_FILE Vitaly Kuznetsov
2015-05-13 9:49 ` [PATCH v6 10/10] (lib)xl: soft reset support Vitaly Kuznetsov
2015-05-22 14:55 ` Vitaly Kuznetsov
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=87y4kbsr0b.fsf@vitty.brq.redhat.com \
--to=vkuznets@redhat.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=david.vrabel@citrix.com \
--cc=dgdegra@tycho.nsa.gov \
--cc=drjones@redhat.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=julien.grall@linaro.org \
--cc=keir@xen.org \
--cc=olaf@aepfle.de \
--cc=stefano.stabellini@eu.citrix.com \
--cc=tim@xen.org \
--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 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.