[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH] xen/memory: Introduce a hypercall to provide unallocated space

  • To: Julien Grall <julien@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 3 Aug 2021 14:49:06 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5o1+euuGaeef4K+5sV0xHolnET/doU0w/KSKPmokUHY=; b=MKoBIaJuVF0M7RMkFRe+sQtk6lA/nc56v3pZri99BHS4W/GdcsJXg2Nmwq8df5YLc8t8z1RnhfSiEw/h7KTUDu7ofyqC9w2TJ0dVSV3JnKt1dutmFX88Ek+1qZajdU+C/BWphjoiCng5OhzWOwQqYu17x1FobquZtscbPwRUeiJGhk1NT71JzzOycfKdF60BIJFCLj+pTb/7msKhLOxyHS2J60d2X1tOgdwMljFyB1OniXFy3xcVUD8w2KWxYmLAkk+Ow7sGvgdXGIPzS0oxNqfwr3gbtQeOthFF2bsXMdzoNzTLhMGw+/c9eO4gck0//K2w0Ry4jDUUjhhKhstnRQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=llni0UMx0J+qnfwMHK1dRPgm98AIsy81EtPhRlbyZLa1JpbufYAtW7DPLy+FUgNeXVKei0ejIe015CHUCOCGUocEQLQuGIR5GeHzPKnJ8vedNy/KTKksjOD6oGVHzhuNafR2VCO8JCgXqgPpfLVxL/C3qpmdtBYn+hhlTW4D4FhD8U8tX/Kk+G59zAMT2WQfOoy1mQ9IXuXFM8rxcNDV3tHGJsMwAwzutKqvBi2tuReZynSwr8mJrHZCXF9qEZUfMhk9QjH65BgWwFIxjD4TFVUW5XghMiuQfg3Yf3kwpJiscRqI8qCRIEDbTwsGtZ6vNkF5M+GqRwJb19h3xpjdZg==
  • Authentication-results: lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=suse.com;
  • Cc: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>, Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>, "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Wei Chen <Wei.Chen@xxxxxxx>, Oleksandr Tyshchenko <olekstysh@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 03 Aug 2021 12:49:20 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 28.07.2021 21:53, Julien Grall wrote:
> On 28/07/2021 20:00, Andrew Cooper wrote:
>> On 28/07/2021 18:27, Julien Grall wrote:
>>> On 28/07/2021 18:19, Andrew Cooper wrote:
>>>> On 28/07/2021 17:18, Oleksandr Tyshchenko wrote:
>>>>> From: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>
>>>>> Add XENMEM_get_unallocated_space hypercall which purpose is to
>>>>> query hypervisor to find regions of guest physical address space
>>>>> which are unused and can be used to create grant/foreign mappings
>>>>> instead of wasting real pages from the domain memory for
>>>>> establishing these mappings. The problem with the current Linux
>>>>> on Xen on Arm behaviour is if we want to map some guest memory
>>>>> regions in advance or to perform cache mappings in the backend
>>>>> we might run out of memory in the host (see XSA-300).
>>>>> This of course, depends on the both host and guest memory sizes.
>>>>> The "unallocated space" can't be figured out precisely by
>>>>> the domain on Arm without hypervisor involvement:
>>>>> - not all device I/O regions are known by the time domain starts
>>>>>     creating grant/foreign mappings
>>>>> - the Dom0 is not aware of memory regions used for the identity
>>>>>     mappings needed for the PV drivers to work
>>>>> In both cases we might end up re-using these regions by
>>>>> a mistake. So, the hypervisor which maintains the P2M for the domain
>>>>> is in the best position to provide "unallocated space".
>>>> I'm afraid this does not improve the situation.
>>>> If a guest follows the advice from XENMEM_get_unallocated_space, and
>>>> subsequently a new IO or identity region appears, everything will
>>>> explode, because the "safe area" wasn't actually safe.
>>>> The safe range *must* be chosen by the toolstack, because nothing else
>>>> can do it safely or correctly.
>>> The problem is how do you size it? In particular, a backend may map
>>> multiple time the same page (for instance if the page is granted twice).
>> The number of mapped grants is limited by the size of the maptrack table
>> in Xen, which is a toolstack input to the domaincreate hypercall.
>> Therefore, the amount of space required is known and bounded.
>> There are a handful of other frames required in the current ABI (shared
>> info, vcpu info, etc).
>> The areas where things do become fuzzy is things like foreign mappings,
>> acquire_resource, etc for the control domain, which are effectively
>> unbounded from the domain's point of view.
>> For those, its entirely fine to say "here 128G of safe mapping space" or
>> so.  Even the quantity of mapping dom0 can make is limited by the shadow
>> memory pool and the number of pagetables Xen is willing to expend on the
>> second stage translation tables.
> FWIW, on Arm, we don't have shadow memory pool.

Where do you take 2nd level page table memory from then?

>>>> Once a safe range (or ranges) has been chosen, any subsequent action
>>>> which overlaps with the ranges must be rejected, as it will violate the
>>>> guarantees provided.
>>>> Furthermore, the ranges should be made available to the guest via normal
>>>> memory map means.  On x86, this is via the E820 table, and on ARM I
>>>> presume the DTB.  There is no need for a new hypercall.
>>> Device-Tree only works if you have a guest using it. How about ACPI?
>> ACPI inherits E820 from x86 (its a trivial format), and UEFI was also
>> based on it.
>> But whichever...  All firmware interfaces have a memory map.
> This will be UEFI memory map. However, I am a bit confused how we can 
> tell the OS the region will be used for grant/foreign mapping. Is it 
> possible to reserved a new type?

As with about any non-abandoned specification it is in principle
possible to define/reserve new types. Question how practical it is,
i.e. in particular how long it may take to get to the point where
we have a firmly reserved type. Short of this I wonder whether you,
Andrew, were thinking to re-use an existing type (in which case the
question of disambiguation arises).

As a result I wonder whether a "middle" approach wouldn't be better:
Have the range be determined up front (by tool stack or Xen), but
communicate it to the guest by PV means (hypercall, shared info,
start info, or yet some other table).




Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.