From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Tamas K Lengyel <tamas@tklengyel.com>
Cc: xen-devel@lists.xenproject.org, henry.wang@arm.com,
Jan Beulich <jbeulich@suse.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
George Dunlap <george.dunlap@citrix.com>, Wei Liu <wl@xen.org>,
Julien Grall <julien@xen.org>,
Stefano Stabellini <sstabellini@kernel.org>
Subject: Re: [PATCH v5 06/10] x86/mem-sharing: copy GADDR based shared guest areas
Date: Tue, 3 Oct 2023 16:29:50 +0200 [thread overview]
Message-ID: <ZRwlXls8xRyc8AX4@MacBookPdeRoger> (raw)
In-Reply-To: <CABfawhnHg3KrGP-hp4_Q8GvSf2nVSVSyK24HKqAGuWp_AtD8-A@mail.gmail.com>
On Tue, Oct 03, 2023 at 09:53:11AM -0400, Tamas K Lengyel wrote:
> On Mon, Oct 2, 2023 at 11:13 AM Roger Pau Monne <roger.pau@citrix.com> wrote:
> >
> > From: Jan Beulich <jbeulich@suse.com>
> >
> > In preparation of the introduction of new vCPU operations allowing to
> > register the respective areas (one of the two is x86-specific) by
> > guest-physical address, add the necessary fork handling (with the
> > backing function yet to be filled in).
> >
> > Signed-off-by: Jan Beulich <jbeulich@suse.com>
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> > ---
> > Changes since v4:
> > - Rely on map_guest_area() to populate the child p2m if necessary.
> > ---
> > xen/arch/x86/mm/mem_sharing.c | 31 +++++++++++++++++++++++++++++++
> > xen/common/domain.c | 7 +++++++
> > 2 files changed, 38 insertions(+)
> >
> > diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c
> > index 5f8f1fb4d871..99cf001fd70f 100644
> > --- a/xen/arch/x86/mm/mem_sharing.c
> > +++ b/xen/arch/x86/mm/mem_sharing.c
> > @@ -1641,6 +1641,24 @@ static void copy_vcpu_nonreg_state(struct vcpu *d_vcpu, struct vcpu *cd_vcpu)
> > hvm_set_nonreg_state(cd_vcpu, &nrs);
> > }
> >
> > +static int copy_guest_area(struct guest_area *cd_area,
> > + const struct guest_area *d_area,
> > + struct vcpu *cd_vcpu,
> > + const struct domain *d)
> > +{
> > + unsigned int offset;
> > +
> > + /* Check if no area to map, or already mapped. */
> > + if ( !d_area->pg || cd_area->pg )
> > + return 0;
> > +
> > + offset = PAGE_OFFSET(d_area->map);
> > + return map_guest_area(cd_vcpu, gfn_to_gaddr(
> > + mfn_to_gfn(d, page_to_mfn(d_area->pg))) +
> > + offset,
> > + PAGE_SIZE - offset, cd_area, NULL);
> > +}
> > +
> > static int copy_vpmu(struct vcpu *d_vcpu, struct vcpu *cd_vcpu)
> > {
> > struct vpmu_struct *d_vpmu = vcpu_vpmu(d_vcpu);
> > @@ -1709,6 +1727,16 @@ static int copy_vcpu_settings(struct domain *cd, const struct domain *d)
> > return ret;
> > }
> >
> > + /* Same for the (physically registered) runstate and time info areas. */
> > + ret = copy_guest_area(&cd_vcpu->runstate_guest_area,
> > + &d_vcpu->runstate_guest_area, cd_vcpu, d);
> > + if ( ret )
> > + return ret;
> > + ret = copy_guest_area(&cd_vcpu->arch.time_guest_area,
> > + &d_vcpu->arch.time_guest_area, cd_vcpu, d);
> > + if ( ret )
> > + return ret;
> > +
> > ret = copy_vpmu(d_vcpu, cd_vcpu);
> > if ( ret )
> > return ret;
> > @@ -1950,7 +1978,10 @@ int mem_sharing_fork_reset(struct domain *d, bool reset_state,
> >
> > state:
> > if ( reset_state )
> > + {
> > rc = copy_settings(d, pd);
> > + /* TBD: What to do here with -ERESTART? */
>
> There is no situation where we get an -ERESTART here currently. Is
> map_guest_area expected to run into situations where it fails with
> that rc?
Yes, there's a spin_trylock() call that will result in
map_guest_area() returning -ERESTART.
> If yes we might need a lock in place so we can block until it
> can succeed.
I'm not sure whether returning -ERESTART can actually happen in
map_guest_area() for the fork case: the child domain is still paused
at this point, so there can't be concurrent guest hypercalls that
would also cause the domain hypercall_deadlock_mutex to be acquired.
The comment was added by Jan, so I cannot be certain about the
intention, neither I would like to misinterpret his words. My
understanding is that future uses of copy_settings() might indeed need
to report -ERESTART, and that it would need to be propagated for
proper hypercall continuations at some point.
Thanks, Roger.
next prev parent reply other threads:[~2023-10-03 14:30 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-02 15:11 [PATCH v5 00/10] runstate/time area registration by (guest) physical address Roger Pau Monne
2023-10-02 15:11 ` [PATCH v5 01/10] mem_sharing/fork: do not attempt to populate vcpu_info page Roger Pau Monne
[not found] ` <CABfawhm2XMmfyx7vZvGdLZcot3=Mrrx3T5nS3vUR+Ur9j5mkWg@mail.gmail.com>
2023-10-03 7:15 ` Roger Pau Monné
2023-10-05 12:10 ` Julien Grall
2023-10-05 12:42 ` George Dunlap
2023-10-05 12:47 ` Julien Grall
[not found] ` <CABfawhmyP_y38002v=v1G2p66ZamhGKrj=0Jm1H_-c_j9VQG8Q@mail.gmail.com>
2023-10-05 12:42 ` Roger Pau Monné
2023-10-05 13:15 ` Tamas K Lengyel
2023-10-02 15:11 ` [PATCH v5 02/10] x86/shim: zap runstate and time area handles during shutdown Roger Pau Monne
2023-10-02 15:11 ` [PATCH v5 03/10] domain: GADDR based shared guest area registration alternative - teardown Roger Pau Monne
2023-10-02 15:11 ` [PATCH v5 04/10] domain: update GADDR based runstate guest area Roger Pau Monne
2023-10-02 15:11 ` [PATCH v5 05/10] x86: update GADDR based secondary time area Roger Pau Monne
2023-10-02 15:11 ` [PATCH v5 06/10] x86/mem-sharing: copy GADDR based shared guest areas Roger Pau Monne
[not found] ` <CABfawhnHg3KrGP-hp4_Q8GvSf2nVSVSyK24HKqAGuWp_AtD8-A@mail.gmail.com>
2023-10-03 14:29 ` Roger Pau Monné [this message]
2023-10-03 15:07 ` Julien Grall
2023-10-03 20:25 ` Tamas K Lengyel
2023-10-04 8:20 ` Roger Pau Monné
2023-10-04 11:01 ` Julien Grall
2023-10-04 13:00 ` Roger Pau Monné
2023-10-04 13:06 ` Julien Grall
2023-10-04 13:53 ` [PATCH v6 " Roger Pau Monne
2023-10-04 21:36 ` Tamas K Lengyel
2023-10-16 9:55 ` Jan Beulich
2023-10-16 10:59 ` Roger Pau Monné
2023-10-02 15:11 ` [PATCH v5 07/10] domain: map/unmap " Roger Pau Monne
2023-10-02 16:40 ` Julien Grall
2023-10-02 15:11 ` [PATCH v5 08/10] domain: introduce GADDR based runstate area registration alternative Roger Pau Monne
2023-10-02 16:43 ` Julien Grall
2023-10-02 15:11 ` [PATCH v5 09/10] x86: introduce GADDR based secondary time " Roger Pau Monne
2023-10-02 16:44 ` Julien Grall
2023-10-02 15:11 ` [PATCH v5 10/10] common: convert vCPU info area registration Roger Pau Monne
2023-10-04 17:15 ` Julien Grall
2023-10-05 1:27 ` [PATCH v5 00/10] runstate/time area registration by (guest) physical address Henry Wang
2023-10-05 13:12 ` Julien Grall
2023-10-05 18:58 ` [CRITICAL for 4.18] " Andrew Cooper
2023-10-05 22:40 ` Julien Grall
2023-10-05 22:43 ` Julien Grall
2023-10-06 8:00 ` Roger Pau Monné
2023-10-06 8:22 ` Roger Pau Monné
2023-10-06 10:21 ` Andrew Cooper
2023-10-16 10:04 ` Jan Beulich
2023-10-16 10:07 ` Jan Beulich
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=ZRwlXls8xRyc8AX4@MacBookPdeRoger \
--to=roger.pau@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=henry.wang@arm.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=sstabellini@kernel.org \
--cc=tamas@tklengyel.com \
--cc=wl@xen.org \
--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.