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

Hand over of the Xen shared info page

  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Anastasiia Lukianenko <anastasiia_lukianenko@xxxxxxxx>
  • Date: Thu, 13 May 2021 08:03:48 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.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=Fn1kRZLF+oerDgG2OBkAVIy0hqMaV/Q8Jdpx4vgoEN0=; b=InC7CIxpV8wSxQdaOiz6j2BSlrEvgxJLDvfCJtInhOVvZZtCefKs4w8DJJ4WHhNKVrIVAbMbhhn7V1qGs26OMm23GL8yPg9ZPYf0OvjX/HTIYdqw70ddpInXrxHT8RcSw8/putEaow2dS/eJWeY4PDnuddLGMgddV5T/yIXkJyPWktZfL6G3EqzYKcnPuyDm5bvpI9gY2FUnlsQnjFu8Tw1EUcXh3N3LYIwjPevNDTeFmS4knZTwLE0Sox2T3+4nkdj4uBe5WUuDGyUId8HjJHwjnknYoM/ertqVwT24P5hVhq0l9J4aW1ncMjwioWSy+lIe/Vgy/YuEI1hAEHgoqg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G/WTi4fFWpQh59ZFYgTepDFNuQ16QaS0y5wVHlqkaSwkwJyVSodO7/tP3jFDGWkSShem7Z37wMGQyuWc5W19hNk2p1IyGu2W6RJnx926A7SRLct2equ+rYtTiPtKYFbfzLaYaLc0wljc7tEVtISmjL9Jyz8icmAdNH5yoYdxFWM3Yt4qQFziD1bgU8H3xAC4872BqnyBGcpZ8SLlB2HYlj/0ZCZZv1cR8cc4W2vmTij89mRatJQlIpzHSme+ii4z7CXUo6GmTzvx0hvdYceUT04MsVoCqPym3jLBKK6mNyWBSLQcNR44+Aijw+zoGCHndwQZAI2G87N13LQVy29gRA==
  • Authentication-results: lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=epam.com;
  • Cc: Andrii Chepurnyi <Andrii_Chepurnyi@xxxxxxxx>, Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • Delivery-date: Thu, 13 May 2021 08:03:56 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHXR86B8dxtD5lx60CgXee9ciHSoQ==
  • Thread-topic: Hand over of the Xen shared info page

Hi all,

The problem described below concerns cases when a shared info page
needs to be handed over from one entity in the system to another, for
example, there is a bootloader or any other code that may run before
the guest OS' kernel.
Normally, to map the shared info page guests allocate a memory page
from their RAM and map the shared info on top of it. Specifically we
use XENMAPSPACE_shared_info memory space in  XENMEM_add_to_physmap
hypercall.  As the info page exists throughout the guest existence this
doesn't hurt the guest, but when the page gets out of accounting, e.g.
after bootloader jumps to Linux and the page is not handed over to it,
the mapped page becomes a problem.
Consider the case with U-boot bootloader which already has Xen support.
The U-boot’s Xen guest implementation allocates a shared info page
between Xen and the guest domain and U-boot uses domain's RAM address
space to create and map the shared info page by using
XENMEM_add_to_physmap hypercall [1].

After U-boot transfers control to the operating system (Linux, Android,
etc), the shared info page is still mapped in domain’s address space,
e.g. its RAM. So, after we leave U-boot, this page becomes just an
ordinary memory page from Linux POV while it is still a shared info
page from Xen POV. This can lead to undefined behavior, errors etc as
Xen can write something to the shared info page and when Linux tries to
use it - data corruption may happen.
This happens because there is no unmap function in Xen API to remove an
existing shared info page mapping. We could use only hypercall
XENMEM_remove_from_physmap which eventually will create a hole in the
domain's RAM address space which may also lead to guest’s crash while
accessing that memory.

We noticed this problem and the workaround was implemented using the
special GUEST_MAGIC memory region [2].

Now we want to make a proper solution based on GUEST_MAGIC_BASE, which
does not belong to the guest’s RAM address space [3]. Using the example
of how offsets for the console and xenstore are implemented, we can add
a new shared_info offset and increase the number of magic pages [4] and
implement related functionality, so there is a similar API to query
that magic page location as it is done for console PFN and others.
This approach would allow the use of the XENMEM_remove_from_physmap
hypercall without creating gaps in the RAM address space for Xen guest
OS [5].

[1] - 
[2] - 
[3] - 
[4] - 
[5] - 

Anastasiia Lukianenko



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