All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger@xen.org>
To: Julien Grall <julien@xen.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>,
	"paul@xen.org" <paul@xen.org>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	"Xia, Hongyan" <hongyxia@amazon.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	George Dunlap <george.dunlap@citrix.com>,
	Bertrand Marquis <bertrand.marquis@arm.com>,
	Jan Beulich <jbeulich@suse.com>,
	xen-devel@lists.xenproject.org, nd@arm.com,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: Re: [RFC PATCH 1/1] xen: Use a global mapping for runstate
Date: Fri, 29 May 2020 09:19:43 +0200	[thread overview]
Message-ID: <20200529071930.GI1195@Air-de-Roger> (raw)
In-Reply-To: <e63a83a1-7d71-9cc5-517a-275e17880e2b@xen.org>

On Thu, May 28, 2020 at 07:54:35PM +0100, Julien Grall wrote:
> Hi Bertrand,
> 
> Thank you for the patch.
> 
> On 28/05/2020 16:25, Bertrand Marquis wrote:
> > +static int map_runstate_area(struct vcpu *v,
> > +                    struct vcpu_register_runstate_memory_area *area)
> > +{
> > +    unsigned long offset = area->addr.p & ~PAGE_MASK;
> > +    void *mapping;
> > +    struct page_info *page;
> > +    size_t size = sizeof(struct vcpu_runstate_info);
> > +
> > +    ASSERT(runstate_guest(v) == NULL);
> > +
> > +    /* do not allow an area crossing 2 pages */
> > +    if ( offset > (PAGE_SIZE - size) )
> > +        return -EINVAL;
> 
> This is a change in behavior for the guest. If we are going forward with
> this, this will want a separate patch with its own explanation why this is
> done.

I don't think we can go this route without supporting crossing a page
boundary.

Linux will BUG if VCPUOP_register_runstate_memory_area fails, and
AFAICT there's no check in Linux to assure the runstate area doesn't
cross a page boundary. If we want to go this route we must support the
area crossing a page boundary, or else we will break existing
guests.

> > +
> > +#ifdef CONFIG_ARM
> > +    page = get_page_from_gva(v, area->addr.p, GV2M_WRITE);
> 
> A guest is allowed to setup the runstate for a different vCPU than the
> current one. This will lead to get_page_from_gva() to fail as the function
> cannot yet work with a vCPU other than current.
> 
> AFAICT, there is no restriction on when the runstate hypercall can be
> called. So this can even be called before the vCPU is brought up.
> 
> I was going to suggest to use the current vCPU for translating the address.
> However, it would be reasonable for an OS to use the same virtual address
> for all the vCPUs assuming the page-tables are different per vCPU.

Hm, it's a tricky question. Using the current vCPU page tables would
seem like a good compromise, but it needs to get added to the header
as a note, and this should ideally be merged at the start of a
development cycle to get people time to test and report issues.

> Recent Linux are using a per-cpu area, so the virtual address should be
> different for each vCPU. But I don't know how the other OSes works. Roger
> should be able to help for FreeBSD at least.

FreeBSD doesn't use VCPUOP_register_runstate_memory_area at all, so we
are safe in that regard.

I never got around to implementing the required scheduler changes in
order to support stolen time accounting.  Note sure this has changed
since I last checked, the bhyve and KVM guys also had interest in
properly accounting for stolen time on FreeBSD IIRC.

Roger.


  reply	other threads:[~2020-05-29  7:20 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-28 15:25 [RFC PATCH 0/1] Runstate error with KPTI Bertrand Marquis
2020-05-28 15:25 ` [RFC PATCH 1/1] xen: Use a global mapping for runstate Bertrand Marquis
2020-05-28 16:53   ` Roger Pau Monné
2020-05-28 17:19     ` Bertrand Marquis
2020-05-28 19:12       ` Julien Grall
2020-05-29  8:15         ` Bertrand Marquis
2020-05-28 18:54   ` Julien Grall
2020-05-29  7:19     ` Roger Pau Monné [this message]
2020-05-29  8:24       ` Bertrand Marquis
2020-05-29  7:35     ` Jan Beulich
2020-05-29  8:32       ` Bertrand Marquis
2020-05-29  8:37         ` Jan Beulich
2020-05-29 13:26         ` Roger Pau Monné
2020-05-29 13:37           ` Julien Grall
2020-05-29 14:36             ` Roger Pau Monné
2020-05-29 10:59       ` Julien Grall
2020-05-29 13:09         ` Roger Pau Monné
2020-05-29  8:13     ` Bertrand Marquis
2020-05-29  8:45       ` Jan Beulich
2020-05-29  9:18         ` Bertrand Marquis
2020-05-29  9:27           ` Roger Pau Monné
2020-05-29 13:53             ` Bertrand Marquis
2020-05-29  9:31           ` Jan Beulich
2020-05-29 10:52           ` Julien Grall
2020-05-29  9:43       ` Julien Grall
2020-05-29 14:02         ` Bertrand Marquis
2020-05-29 14:15           ` Julien Grall
2020-05-29 14:21             ` Bertrand Marquis
2020-05-29  9:49       ` Hongyan Xia

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=20200529071930.GI1195@Air-de-Roger \
    --to=roger@xen.org \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=bertrand.marquis@arm.com \
    --cc=george.dunlap@citrix.com \
    --cc=hongyxia@amazon.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=nd@arm.com \
    --cc=paul@xen.org \
    --cc=sstabellini@kernel.org \
    --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.