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

Re: [PATCH v8 08/13] vpci/header: program p2m with guest BAR view


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Mon, 24 Jul 2023 15:16:13 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1vNs+4AI76zkJDkRv5AgPDPbYeF+/XeT2zqMQI2mYSA=; b=h7KqaULSz+FJ5mhvJtB2oil6+GuWZu5l7xeDC2lJUC9t9qE82wFZiOw2l37NZChwg0urgOr4+8PmcBkSEIaIQ+ASEoIW3fksmgg7FWgw/q2ahx7JN7CU/WPhyvcy/Aoitpo91jxiMSLkFCjS0Aeyw3P8IBWyU2BPzYn61JXWuO+fJhMAe9Geg5Av7mAP3fJohtmh3tlAkCupwIxLN+T4uQRlDt1DmJectqKWVVczZc/XuHVD+DwdrQrkPtmYBGMLKB0IE1VccCaQFddIOEZSAGJGVbP+x/MVPlFzoUCvWMDJhMdZ4tWU8O8QBf4ZIpKCeC1cX4WooWOypewP4CsV2Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B3fWN55LwSV+/07AXWu9jV02PDA6ZaYmh26UjB16U6od0u8pYyC333WrpY4RezP4L+RSbn6Q6mKTj60dbkTg5OqntmHzT3xeSfVFPyTgSssRjQkoPc0yYODYc/v9bNSq0HFB78T6U/LviGHaNcAobEe9E9fdtf0Rp4oTPN0qrX3NraXFoQldAE31HtBwf5rOgvr7A7zKAKYnJ/i1V5wqVxN125wofT1n1gXI+vbZw7JFYFSr63iUEBpg35b7CjTQzupG4stQ81u6SqJuOzAP4BT+3g/BzrBbDAB49Qf4hdPORQFXaq15wyMa+CPEarToSbE012SnMP7XdpYG+Yudtg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 24 Jul 2023 13:16:34 +0000
  • Ironport-data: A9a23:RvHpDK/j4dSGieXcWDcbDrUDUH+TJUtcMsCJ2f8bNWPcYEJGY0x3y zYaCG/Tb6neYGr1LowiOtmy8U8Eu8WAyoJqSQJspXg8E34SpcT7XtnIdU2Y0wF+jCHgZBk+s 5hBMImowOQcFCK0SsKFa+C5xZVE/fjUAOG6UKicYXoZqTZMEE8JkQhkl/MynrlmiN24BxLlk d7pqojUNUTNNwRcawr40Ird7ks21BjOkGlA5AdmOqoQ5AS2e0Q9V/rzG4ngdxMUfaEMdgKKb 76r5K20+Grf4yAsBruN+losWhRXKlJ6FVHmZkt+A8BOsDAbzsAB+v9T2M4nQVVWk120c+VZk 72hg3ASpTABZcUgkMxFO/VR/roX0aduoNcrKlDn2SCfItGvn9IBDJyCAWlvVbD09NqbDklF6 KIfOh9UMCmfuKWN5JKlas50nfw8eZyD0IM34hmMzBn/JNN/G9XpZfWP4tVVmjAtmspJAPDSI dIDbiZiZwjBZBsJPUoLDJU5n6GjgXyXnz9w8QrJ4/ZopTWOilUujdABM/KMEjCObd9SkUuC4 HrP4kzyAw0ANczZwj2Amp6prraWzHOnA9xCSdVU8NZh2HOiljNKKycoSFqLodiUlBDhQ91Qf hl8Fi0G6PJaGFaQZtv3UgC8oXWElgUBQNcWGOo/gCmzza7T7xecF3IzZDdLY9w7t+c7XTUvk FSOmrvBIjhis6acT36HwZ6SoSmvIigeLWIEZigsQBMM5p/op4RbpgLCSJNvHbC4ivXxGCrs2 HaaoS4mnbIRgMUXkaKh8jj6bymEo5HISks/4FXRV2f8tAdhPtf6Osqv9ETR6utGIMCBVF6ds XMYms+YqucTEZWKky/LS+IIdF2028u43PTnqQYHN/EcG/6FohZPoag4DOlCGXpU
  • Ironport-hdrordr: A9a23:f0J4G6iAIOebGZXsiQBgzVmZunBQXioji2hC6mlwRA09TyX5ra 2TdZUgpHvJYVMqMk3I9uruBEDtex3hHP1OkOws1NWZLWrbUQKTRekP0WKF+Vzd8kXFndK1vp 0QEZSWZueRMbEAt7ec3OG5eexQvOVu8sqT9JjjJ6EGd3AVV0lihT0JezpyCidNNW977QJSLu vn2iJAzQDQAEg/X4CAKVQuefPMnNHPnIKOW296O/Z2gDP+9Q9B8dTBYmOl4is=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon, Jul 24, 2023 at 12:43:26PM +0200, Jan Beulich wrote:
> On 20.07.2023 02:32, Volodymyr Babchuk wrote:
> > @@ -52,8 +66,8 @@ static int cf_check map_range(
> >           * - {un}map_mmio_regions doesn't support preemption.
> >           */
> >  
> > -        rc = map->map ? map_mmio_regions(map->d, _gfn(s), size, _mfn(s))
> > -                      : unmap_mmio_regions(map->d, _gfn(s), size, _mfn(s));
> > +        rc = map->map ? map_mmio_regions(map->d, start_gfn, size, _mfn(s))
> > +                      : unmap_mmio_regions(map->d, start_gfn, size, 
> > _mfn(s));
> 
> Aiui this is the first direct exposure of these functions to DomU-s;

I guess it depends on how direct you consider exposure from
XEN_DOMCTL_memory_mapping hypercall, as that's what gets called by
QEMU also in order to set up BAR mappings.

> so far all calls were Xen-internal or from a domctl. There are a
> couple of Arm TODOs listed in the comment ahead, but I'm not sure
> that's all what is lacking here, and it's unclear whether this can
> sensibly be left as a follow-on activity (at the very least known
> open issues need mentioning as TODOs).
> 
> For example the x86 function truncates an unsigned long local
> variable to (signed) int in its main return statement. This may for
> the moment still be only a theoretical issue, but will need dealing
> with sooner or later, I think.

One bit that we need to add is the iomem_access_permitted() plus the
xsm_iomem_mapping() checks to map_range().

> Furthermore this yet again allows DomU-s to fiddle with their p2m.
> To a degree this is unavoidable, I suppose. But some thought may
> need putting into this anyway. Aiui on real hardware if a BAR is
> placed over RAM, behavior is simply undefined. Once the BAR is
> moved away though, behavior will become defined again: The RAM will
> "reappear" in case the earlier undefined-ness made it disappear. I
> don't know how the Arm variants of the functions behave, but on x86
> the RAM pages will disappear from the guest's p2m upon putting a
> BAR there, but they won't reappear upon unmapping of the BAR.

Yeah, that's unfortunate, but I'm afraid it's the same behavior when
using QEMU, so I wouldn't consider it strictly a regression from the
current handling that we do for BARs when doing PCI passthrough.

Furthermore, I don't see any easy way to deal with this so that RAM
can be re-added when the BAR is re positioned to not overlap a RAM
region.

> Luckily at least preemption looks to be handled in a satisfactory
> manner already.

I spend quite a lot of time trying to make sure this was at least
attempted to solve properly.

Thanks, Roger.



 


Rackspace

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