All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <amc96@cam.ac.uk>
To: Julien Grall <julien.grall.oss@gmail.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Xen-devel <xen-devel@lists.xenproject.org>,
	"George Dunlap" <George.Dunlap@eu.citrix.com>,
	"Ian Jackson" <iwj@xenproject.org>,
	"Jan Beulich" <JBeulich@suse.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Wei Liu" <wl@xen.org>, "Paul Durrant" <paul@xen.org>,
	"Michał Leszczyński" <michal.leszczynski@cert.pl>,
	"Hubert Jasudowicz" <hubert.jasudowicz@cert.pl>,
	"Tamas K Lengyel" <tamas@tklengyel.com>,
	"Andrew Cooper" <amc96@cam.ac.uk>
Subject: Re: [PATCH v3 2/7] xen/memory: Fix acquire_resource size semantics
Date: Tue, 12 Jan 2021 20:57:43 +0000	[thread overview]
Message-ID: <ac46431b-3d68-e758-f598-0d39c6c39aeb@cam.ac.uk> (raw)
In-Reply-To: <CAJ=z9a30MFcV4=5YU9O2oHmNeMU3vdPwSJ6vYCpDi5Zoi6aNtQ@mail.gmail.com>

On 12/01/2021 20:15, Julien Grall wrote:
> Hi Andrew,
>
> On Tue, 12 Jan 2021 at 19:49, Andrew Cooper <andrew.cooper3@citrix.com> wrote:
>> Calling XENMEM_acquire_resource with a NULL frame_list is a request for the
>> size of the resource, but the returned 32 is bogus.
>>
>> If someone tries to follow it for XENMEM_resource_ioreq_server, the acquire
>> call will fail as IOREQ servers currently top out at 2 frames, and it is only
>> half the size of the default grant table limit for guests.
> I haven't yet looked at the code, just wanted to seek some clarification here.
> Are we expecting someone else outside the tools (e.g. QEMU) to rely on
> the new behavior? If so, what would happen if such code ran on older
> Xen?
>
> IOW, will that code require some compatibility layer to function?

This is total mess.

Requesting the size of a resource was never implemented for userspace. 
The two current users of this interface (domain builder for gnttab
seeding, qemu for ioreq server) make blind mapping calls with a priori
knowledge of the offsets and sizes.

The next patch in this series adds the xenforeignmemory_resource_size()
API for userspace, so we can reliably say that anything built against
anything earlier than Xen 4.15 isn't making size requests.

The added complication is that if you have Xen 4.15, and Linux 4.18 or
later without the kernel fix provided by Roger (which is CC stable),
you'll get a bogus 32 back from the size requests.

But that is fine because nothing is making size requests yet.

The first concrete user of size requests will be Michał's Processor
Trace series, where there is a daemon to map the PT buffer and shuffle
the contents into a file.  That will also depend on new content in 4.15.

At some point in the future, Qemu is going to have to change it's
approach, when we want to support more than 128 vcpus.  This is the
point at which the synchronous ioreq page needs to turn into two pages. 
In practice, qemu could make a size call, or could make the same
calculation as Xen makes, as Qemu does know d->max_vcpus via other means.


Honestly, I'm expecting that Linux stable will do the rounds faster than
Xen 4.15 gets rolled out to distros.  The chances of having a bleeding
edge Xen, and not an up-to-date (or at least patched) dom0 kernel is
minimal.

>> Also, no users actually request a resource size, because it was never wired up
>> in the sole implementaion of resource acquisition in Linux.
> s/implementation/
>
>> Introduce a new resource_max_frames() to calculate the size of a resource, and
>> implement it the IOREQ and grant subsystems.
> in the?

Fixed, thanks,

~Andrew


  reply	other threads:[~2021-01-12 20:58 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-12 19:48 [PATCH v3 0/7] Multiple fixes to XENMEM_acquire_resource Andrew Cooper
2021-01-12 19:48 ` [PATCH v3 1/7] xen/gnttab: Rework resource acquisition Andrew Cooper
2021-01-15 11:43   ` Jan Beulich
2021-01-15 16:03     ` Andrew Cooper
2021-01-15 16:26       ` Jan Beulich
2021-01-15 16:27         ` Jan Beulich
2021-01-15 11:56   ` Jan Beulich
2021-01-15 16:57     ` Andrew Cooper
2021-01-18  8:23       ` Jan Beulich
2021-01-28 22:56         ` Andrew Cooper
2021-01-29  9:33           ` Jan Beulich
2021-01-29 17:44             ` Ian Jackson
2021-01-12 19:48 ` [PATCH v3 2/7] xen/memory: Fix acquire_resource size semantics Andrew Cooper
2021-01-12 20:15   ` Julien Grall
2021-01-12 20:57     ` Andrew Cooper [this message]
2021-01-12 21:05       ` Tamas K Lengyel
2021-01-12 19:48 ` [PATCH v3 3/7] tools/foreignmem: Support querying the size of a resource Andrew Cooper
2021-01-12 19:48 ` [PATCH v3 4/7] xen/memory: Clarify the XENMEM_acquire_resource ABI description Andrew Cooper
2021-01-12 19:48 ` [PATCH v3 5/7] xen/memory: Improve compat XENMEM_acquire_resource handling Andrew Cooper
2021-01-15 15:37   ` Jan Beulich
2021-01-28 23:32     ` Andrew Cooper
2021-02-01 14:12       ` Jan Beulich
2021-01-12 19:48 ` [PATCH v3 6/7] xen/memory: Indent part of acquire_resource() Andrew Cooper
2021-01-12 19:48 ` [PATCH v3 7/7] xen/memory: Fix mapping grant tables with XENMEM_acquire_resource Andrew Cooper
2021-01-15 16:12   ` Jan Beulich
2021-01-28 23:44     ` Andrew Cooper
2021-01-29  9:46       ` Jan Beulich
2021-01-29 18:18         ` Andrew Cooper
2021-02-01 12:56           ` 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=ac46431b-3d68-e758-f598-0d39c6c39aeb@cam.ac.uk \
    --to=amc96@cam.ac.uk \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=hubert.jasudowicz@cert.pl \
    --cc=iwj@xenproject.org \
    --cc=julien.grall.oss@gmail.com \
    --cc=michal.leszczynski@cert.pl \
    --cc=paul@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.