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

Re: Mapping memory into a domain


  • To: Demi Marie Obenour <demiobenour@xxxxxxxxx>, Xen developer discussion <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Alejandro Vallejo <agarciav@xxxxxxx>
  • Date: Mon, 5 May 2025 13:32:47 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=gmail.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Co2k8Dvcv0C0IMqeGm4Y4i8zTo2rRA74FE65agiEEbY=; b=Vdc6ls4WK86Gg1oaLRN0qfuvlZzAF0KChoyo/9vCISpcggM8IE1PLN77hXS81xung3ZhaTwxCuW99CwBtALqUbiENgeGyMjfUspruZojuUWdUo/ZlnL2rONlgXeNEZrCQxngm3iocwh77RgInopwXjC2Xh/i8uWLd/YfLBMMEIeGBbpBCoMpTl3+Aer6EH4VwmVV9u//hXORWvfNKV5ULTCOIyRFGlq9uHOaiIlOb04Xnrx8QPx7ZH2sp0g1PQTyMvUwH0anU+NHw75BRNsIONTQjIkeOpUXnHzXdDURgfZ2SX6LpyKOGelJfPnLlyNzhxYR/w9nHzEzEpFhe9Cjpw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=T//xABOGXvC0fEhwDWeUwgh/aKDLETJ2xTtn4CKIY7InKZE0/e+huu3koIJLA4CTLpvuguuzxTE8vsEk9N1FhdYzODxv2nyxDKH1V8H5fOoYqhGwMcyhvrCAYDIHDL5Ks5CQLiOUqLxqHjBZu3uqntG37snuNSdtMkKNboRmeTeZzv4O4upop5ovJ3VlaW3dBVhm9dKysHwuUc3y6LEKNRYDB4e4HlAYvRKiN2L5aKFBqtqppmV3g4Fo2hBZ6LigOObMLRfvJ1bqdR/Sz4GJubuKcGmKO+BTaoQ6TdaHKwsx17H9zTgdxDUjbuPRLg5oCYOx8iz09zIZLn6DJpl4FA==
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Xen-devel <xen-devel-bounces@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 05 May 2025 11:33:04 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

I suppose this is still about multiplexing the GPU driver the way we
last discussed at Xen Summit?

On Mon May 5, 2025 at 12:51 AM CEST, Demi Marie Obenour wrote:
> What are the appropriate Xen internal functions for:
>
> 1. Turning a PFN into an MFN?
> 2. Mapping an MFN into a guest?
> 3. Unmapping that MFN from a guest?

The p2m is the single source of truth about such mappings.

This is all racy business. You want to keep the p2m lock for the full
duration of whatever operation you wish do, or you risk another CPU
taking it and pulling the rug under your feet at the most inconvenient
time.

In general all this faff is hidden under way too many layers beneath
copy_{to,from}_guest(). Other p2m manipulation high-level constructs
that might do interesting things worth looking at may be 
{map,unmap}_mmio_region()

Note that not every pfn has an associated mfn. Not even every valid pfn
has necessarily an associated mfn (there's pod). And all of this is
volatile business in the presence of a baloon driver or vPCI placing
mmio windows over guest memory.

In general anything up this alley would need a cohesive pair for
map/unmap and a credible plan for concurrency and how it's all handled
in conjunction with other bits that touch the p2m.

>
> The first patch I am going to send with this information is a documentation
> patch so that others do not need to figure this out for themselves.
> I remember being unsure even after looking through the source code, which
> is why I am asking here.

That's not surprising. There's per-arch stuff, per-p2mtype stuff,
per-guesttype stuff. Plus madness like on-demand memory. It's no wonder
such helpers don't exist and the general manipulations are hard to
explain.

Cheers,
Alejandro



 


Rackspace

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