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

Re: [PATCH v3 4/7] xen/arm: dom0less seed xenstore grant table entry


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Mon, 7 Apr 2025 14:17:32 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.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=HobXPlNt+p2Bv4LM+pPpXt8v2ZDWVNzLqjENRlroOtg=; b=nUy7MgFhLrl0oxBS61G/Pvv9nYjaTBLYNP8cyWn/YsytTtT6wHNOZFNyH6KoSgnqjJqoDI8gK7hgK2QdtWrJWu/jgtfNvpaJEg6mMN9wzHez2zTAwRQYfg3NcIAbCEMVBo4QCBoX+kNI1ZOoAWWF96tVc35ObBSkMnxY1qrxZvWSPDELVU4nrjCypp8t9166S2AR5LgQwt7DLXrATR+GtLqkFT8otovIaqFRiSDwBg34DBF0ilvFoAxdzcXQZ9GxK5k5qWwODlcm72BPBm2roHG0ka3ftpFLd5CsfF6tzv/9bHfgzOQOtDcv7GraESG6xF4BwEHF44AKtPoTEcHDiw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=W7nF42KNMap4pRXrfatG759+E5aki6l4CLLMgNlx+HOHtr+YhuZSFSIqfLovtI5E6gj7uO4yrbfc9PKxTIhGyvPqOrvX66hsS+scJ/NWOfFRSd+LH7hE7W0BLpFRlOcqsGVIp60Ur7giqXBwwssNTJh6/8gCN9zLu6GRw3RKFUrYeJRCHhyGeJGxg8j2pXahFh78mxq1Cy+Cz2Ve+Dkn7zO/LCe0QB5yHYcAzXMlLkNF/FmmQa69Z4bF+ZFh0n5Q+rbQZEixKVIWJOcgb1Pa5ktNAVxcZn9cAVGczhTu2DzelTVWT+bk7rFFw8b+v4d57vX0s8P67SIcpq0LldLpBA==
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 07 Apr 2025 18:17:42 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 2025-04-04 03:34, Jan Beulich wrote:
On 03.04.2025 23:46, Jason Andryuk wrote:
xenstored maps other domains' xenstore pages.  Currently this relies on
init-dom0less or xl to seed the grants from Dom0.  With split
hardware/control/xenstore domains, this is problematic since we don't
want the hardware domain to be able to map other domains' resources
without their permission.  Instead have the hypervisor seed the grant
table entry for every dom0less domain.  The grant is then accessible as
normal.

C xenstored uses grants, so it can map the xenstore pages from a
non-dom0 xenstore domain.  OCaml xenstored uses foreign mappings, so it
can only run from a privileged domain (dom0).

Signed-off-by: Jason Andryuk <jason.andryuk@xxxxxxx>
---
v3:
Expand commit message about C vs. OCaml xenstored.
Remove __init and flags from gnttab_seed_entry()
Change frame to uint32_t
ASSERT gfn fits in a uint32_t

Ehem. For this you need to use ...

--- a/xen/arch/arm/dom0less-build.c
+++ b/xen/arch/arm/dom0less-build.c
@@ -788,6 +788,12 @@ static void __init initialize_domU_xenstore(void)
          rc = alloc_xenstore_evtchn(d);
          if ( rc < 0 )
              panic("%pd: Failed to allocate xenstore_evtchn\n", d);
+
+        if ( gfn != ~0ULL )
+        {
+            ASSERT(gfn <= UINT_MAX);

... UINT32_MAX here. Furthermore may I remind you that INVALID_GFN ==
UINT32_MAX in 32-bit environments.

Yes, thanks.

The ~0ULL may also better be UINT64_MAX.

I'll also add

#define XENSTORE_PFN_LATE_ALLOC UINT64_MAX

@@ -85,6 +89,9 @@ static inline void grant_table_destroy(struct domain *d) {}
static inline void grant_table_init_vcpu(struct vcpu *v) {} +static inline void gnttab_seed_entry(struct domain *d, int idx,
+                                     domid_t be_domid, uint32_t frame) {}

Hmm. While generally I prefer using such wrappers, I wonder if in this
case it wouldn't end up more clear if a conditional was added in
initialize_domU_xenstore(). Ideally using IS_ENABLED(), which - aiui -
would require moving the declaration of the function.

Ok.

Thanks,
Jason



 


Rackspace

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