All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: "Anthony Liguori" <anthony@codemonkey.ws>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Cc: "Juergen Gross" <JGross@suse.com>,
	"Anthony Liguori" <aliguori@amzn.com>,
	"Wei Liu" <wei.liu2@citrix.com>,
	"Anthony Liguori" <aliguori@amazon.com>,
	"KarimAllah Ahmed" <karahmed@amazon.de>,
	"Jan H. Schönherr" <jschoenh@amazon.de>,
	"Jan Beulich" <JBeulich@suse.com>,
	"Paul Durrant" <paul.durrant@citrix.com>,
	"Matt Wilson" <msw@amazon.com>,
	xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH 16/22] vixen: pass grant table operations through to the outer Xen
Date: Sun, 7 Jan 2018 16:45:21 +0000	[thread overview]
Message-ID: <b7537c8a-e6c1-1525-63cc-07098521a69a@citrix.com> (raw)
In-Reply-To: <CA+aC4kt-_vQO76O5Q_tgrssdvO7MwPf6ndjbnwnVZOhSx9sXdg@mail.gmail.com>

On 07/01/2018 15:42, Anthony Liguori wrote:
> On Sun, Jan 7, 2018 at 12:36 AM, Roger Pau Monné <roger.pau@citrix.com> wrote:
>> On Sat, Jan 06, 2018 at 02:54:31PM -0800, Anthony Liguori wrote:
>>>  static long
>>> +vixen_gnttab_setup_table(
>>> +    XEN_GUEST_HANDLE_PARAM(gnttab_setup_table_t) uop, unsigned int count)
>>> +{
>>> +    long rc;
>>> +
>>> +    struct gnttab_setup_table op;
>>> +    xen_pfn_t *frame_list = NULL;
>>> +    static void *grant_table;
>>> +    XEN_GUEST_HANDLE(xen_pfn_t) old_frame_list;
>>> +
>>> +    if ( count != 1 )
>>> +        return -EINVAL;
>>> +
>>> +    if ( unlikely(copy_from_guest(&op, uop, 1) != 0) )
>>> +    {
>>> +        gdprintk(XENLOG_INFO, "Fault while reading gnttab_setup_table_t.\n");
>>> +        return -EFAULT;
>>> +    }
>>> +
>>> +    if ( grant_table == NULL ) {
>>> +        struct xen_add_to_physmap xatp;
>>> +        struct domain *d;
>>> +        int i;
>>> +
>>> +        for ( i = 0; i < max_grant_frames; i++ )
>>> +        {
>>> +             grant_table = alloc_xenheap_page();
>> This is wasting one memory page, grant table frames don't need to be
>> populated.
> Well they have to have a valid struct page_info in order for the guest
> to map it within its address space.
>
> Or did you have something else in mind?

Mapping of L0 frames into L1 is a giant mess.

First of all, some technical facts:
1) Frames which we map from L0 into L1 do not need to replace existing
RAM.  We can use any GFNs up to maxphysaddr.
2) Mapped frames should not replace RAM, and particularly not frames in
.data or .bss, because of the performance hit from shattered host
superpages.
3) Ideally, we'd want to map into entirely unused GFNs, because then we
don't have to interfere with what was there before.

In Xen, to allow a frame to be used by a guest, we need to set up domain
ownership for it.  This requires a struct page_info to exist, which by
default only occurs for pages L1 Xen things is RAM.

There is a completely gross way of dealing with this by faking up L1's
E820 map to include a range as RAM, and adding every entry in that range
into the badpages list.  This causes L1 Xen to put together page_info's
for them, but otherwise ignore their existence.

Off the top of my head, frames needing special attention are:
* The special pages, including Xenstore and Console rings.  These are
real frames (as opposed to mappings), but live inside an E820 hole from
L1's point of view.
* Shared info
* Grant table/status frames
* Vcpuinfo frames
* Event_fifo (if we care to wire that up, but perhaps its not worth it).

What I started doing in PV-shim (before switching to the SP2 side of
things fully) was to hard code these mapping frames immediately after
the special pages, which is a horrible but safe (as far as I can tell)
way of doing things.

Ideally, L1 could work out a safe place to use for mappings (which
ideally, would be a block of GFNs immediately above the last used
frame), but this cannot be done with the toolstack-provided E820 alone,
because it is insufficiently descriptive as it deliberately omits
information which can be found in the DSDT (e.g. ACPI hotplug regions).

The only reasonable option is for L0 to fully understand the guest
physical address, and be able to report the details fully to L1,
probably in an E820-like way but with our own type identifiers to cover
the options which aren't in the E820 spec.

This allows L1 to be positively told information such as "This range is
safe for mapping into", without having to go and parse all the secondary
layout information which is derived from this information in the first
place.  Having said that, this will require hypervisor and toolstack
changes, so isn't reasonable to retrofit.

Overall I want to ensure that, whatever plan we come up with for the
shim, it doesn't further tangle things up and make them harder to untangle.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-01-07 16:45 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-06 22:54 [PATCH 00/22] Vixen: A PV-in-HVM shim Anthony Liguori
2018-01-06 22:54 ` [PATCH 01/22] ---- x86/Kconfig: Options for Xen and PVH support Anthony Liguori
2018-01-06 22:54 ` [PATCH 02/22] x86/entry: Probe for Xen early during boot Anthony Liguori
2018-01-06 22:54 ` [PATCH 03/22] x86/guest: Hypercall support Anthony Liguori
2018-01-06 22:54 ` [PATCH 04/22] x86: Don't use potentially incorrect CPUID values for topology information Anthony Liguori
2018-01-06 22:54 ` [PATCH 05/22] char: optionally redirect {, g}printk output to QEMU debug log Anthony Liguori
2018-01-07  0:18   ` Anthony Liguori
2018-01-07  0:35     ` Matt Wilson
2018-01-06 22:54 ` [PATCH 06/22] console: do not print banner if below info log threshold Anthony Liguori
2018-01-06 22:54 ` [PATCH 07/22] vixen: introduce is_vixen() to allow altering behavior Anthony Liguori
2018-01-07  0:06   ` Matt Wilson
2018-01-07  0:26     ` Anthony Liguori
2018-01-06 22:54 ` [PATCH 08/22] vixen: allow dom0 to be created with a domid != 0 Anthony Liguori
2018-01-06 22:54 ` [PATCH 09/22] vixen: modify the e820 table to advertise HVM special pages as RAM Anthony Liguori
2018-01-07  8:16   ` Roger Pau Monné
2018-01-07 15:27     ` Anthony Liguori
2018-01-08  9:51       ` Roger Pau Monné
2018-01-08  9:54         ` Andrew Cooper
2018-01-08 10:23           ` Roger Pau Monné
2018-01-06 22:54 ` [PATCH 10/22] vixen: do not permit access to physical IRQs if in Vixen mode Anthony Liguori
2018-01-07  8:18   ` Roger Pau Monné
2018-01-07 15:28     ` Anthony Liguori
2018-01-06 22:54 ` [PATCH 11/22] vixen: early initialization of Vixen including shared_info mapping Anthony Liguori
2018-01-07  8:23   ` Roger Pau Monné
2018-01-07 15:33     ` Anthony Liguori
2018-01-08  9:55       ` Roger Pau Monné
2018-01-06 22:54 ` [PATCH 12/22] vixen: paravirtualization TSC frequency calculation Anthony Liguori
2018-01-06 22:54 ` [PATCH 13/22] vixen: Use SCHEDOP_shutdown to shutdown the machine Anthony Liguori
2018-01-07  8:27   ` Roger Pau Monné
2018-01-07 15:35     ` Anthony Liguori
2018-01-06 22:54 ` [PATCH 14/22] vixen: forward VCPUOP_register_runstate_memory_area to outer Xen Anthony Liguori
2018-01-06 22:54 ` [PATCH 15/22] vixen: pass through version hypercalls to parent Xen Anthony Liguori
2018-01-07  8:31   ` Roger Pau Monné
2018-01-07 15:40     ` Anthony Liguori
2018-01-07 15:55       ` Andrew Cooper
2018-01-08  9:36       ` Jan Beulich
2018-01-06 22:54 ` [PATCH 16/22] vixen: pass grant table operations through to the outer Xen Anthony Liguori
2018-01-07  8:36   ` Roger Pau Monné
2018-01-07 15:42     ` Anthony Liguori
2018-01-07 16:45       ` Andrew Cooper [this message]
2018-01-07 17:09         ` Anthony Liguori
2018-01-07 18:45           ` Anthony Liguori
2018-01-08 10:12         ` Roger Pau Monné
2018-01-08 10:05       ` Roger Pau Monné
2018-01-06 22:54 ` [PATCH 17/22] vixen: setup infrastructure to receive event channel notifications Anthony Liguori
2018-01-07  8:42   ` Roger Pau Monné
2018-01-07 15:45     ` Anthony Liguori
2018-01-06 22:54 ` [PATCH 18/22] vixen: Introduce ECS_PROXY for event channel proxying Anthony Liguori
2018-01-07  8:44   ` Roger Pau Monné
2018-01-07 15:46     ` Anthony Liguori
2018-01-08 10:04       ` Jan H. Schönherr
2018-01-06 22:54 ` [PATCH 19/22] vixen: Fix Vixen adaptation of send_global_virq() Anthony Liguori
2018-01-06 22:54 ` [PATCH 20/22] vixen: event channel passthrough support Anthony Liguori
2018-01-06 22:54 ` [PATCH 21/22] vixen: provide Xencons implementation Anthony Liguori
2018-01-06 22:54 ` [PATCH 22/22] vixen: dom0 builder support Anthony Liguori
2018-01-07  0:24   ` Matt Wilson
2018-01-07  9:02   ` Roger Pau Monné
2018-01-07 15:52     ` Anthony Liguori
2018-01-08 10:03       ` Roger Pau Monné
2018-01-08 18:22   ` Konrad Rzeszutek Wilk
2018-01-08 18:26     ` Anthony Liguori
2018-01-06 23:29 ` [PATCH 00/22] Vixen: A PV-in-HVM shim Anthony Liguori
2018-01-06 23:50 ` Andrew Cooper
2018-01-06 23:59   ` Matt Wilson
2018-01-07  0:05   ` Anthony Liguori
2018-01-07 20:29     ` Anthony Liguori
2018-01-08 11:54 ` Wei Liu
2018-01-08 12:11   ` Roger Pau Monné
2018-01-08 12:14     ` Wei Liu
2018-01-08 16:02     ` Anthony Liguori
2018-01-08 16:28       ` George Dunlap
     [not found]         ` <CA+aC4kt5zbymFbHqCMV-oB80cw2dXWTcTztpa4EnqOKELKs7qg@mail.gmail.com>
     [not found]           ` <CA+aC4ku_0MB34=Y=yF3XwADyXttYd8t3Dw7XcOhOr+8aS9nONA@mail.gmail.com>
     [not found]             ` <CA+aC4kvsVXDFTHrcRK76868zmqCVuKtrjpSLJk=dYNdxL0PSCw@mail.gmail.com>
     [not found]               ` <CA+aC4kujGxWQzSfWP=8qP2SWd0G+qBod8HCLuosPg9SzS-22Vw@mail.gmail.com>
2018-01-08 16:41                 ` Anthony Liguori
2018-01-08 16:30       ` Wei Liu
2018-01-08 16:39         ` Ian Jackson
2018-01-08 17:03           ` Anthony Liguori
2018-01-08 17:34             ` Wei Liu
2018-01-08 17:47               ` Anthony Liguori
2018-01-08 17:53                 ` Ian Jackson
2018-01-08 17:11         ` Anthony Liguori
2018-01-08 16:38       ` Roger Pau Monné

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=b7537c8a-e6c1-1525-63cc-07098521a69a@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=JGross@suse.com \
    --cc=aliguori@amazon.com \
    --cc=aliguori@amzn.com \
    --cc=anthony@codemonkey.ws \
    --cc=jschoenh@amazon.de \
    --cc=karahmed@amazon.de \
    --cc=msw@amazon.com \
    --cc=paul.durrant@citrix.com \
    --cc=roger.pau@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 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.