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

Re: [PATCH v4 1/5] xen/domctl, tools: Introduce a new domctl to get guest memory map


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Henry Wang <xin.wang2@xxxxxxx>
  • Date: Fri, 19 Apr 2024 10:27:11 +0800
  • 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=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=L08/V9RoPBCV4Ouu/mBWPc5rRZ3PXDyRzfaE62nNzF8=; b=ZWgQfDOiOeO/eQVscQBiIxpLAhgGJ02Q9D0eFgPdcHlnszrIlR9uM+/8TRrILIhj3Po7lVEuAA81XVYFbNYwVUng4fnM1KFs1wwxQR2BCzA/uwUTUwMrahfKB0B4YFGtMuJgAn72VCAQ1n4trVyaZFWtmOdx92W4KCxr7VWWcNtB0ic2eR7DqF2JYUMd60+KogigFUJLsmfBX1XIYwtAU00gP6nKhan9CSI/iObV+Vh74tq47N6BSeVme7j3q3eCQHC6/iHWd8eQepX50QIFcxHebR4wBIwIW8SW+mfffDxhYH4jIZnoSaDif4QpZny6T2ZcjiSTcu04Lxu7SaNtYA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZN4RyI+PU8yz3ZZsA/mqNC0k/2r4BuypUnXXFvDnj+c2DMNUcML1DtBYwEwqKd6XRyZXmSB0ZD353PZXNhO9o+BqVQLqU1LgyFC3nhcz05PXx1VT3dQ+FuVFXpA8DxEI8XQrJGTVsuSkrQdxWCXVjUVioFFQynHlTAn/W+hlv0W/nnHgwD0l+1ABersOOBBt+kmQtSz0oTiY7lEWwkdb0GAySDtpLyjYpxb/aDi+FRJ9HVnP2zYT4EJHRCyS9l6iDCYusO8OR69Z8uqa1EntXnTWJBEkghSh2PMd3GvYpKR22ooTKcfckAYGKHyCxpmbsUmj4+nCU8/cCr+75HeZeg==
  • Cc: Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Alec Kwapis <alec.kwapis@xxxxxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 19 Apr 2024 02:27:35 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Jan,

On 4/18/2024 8:37 PM, Jan Beulich wrote:
On 09.04.2024 06:53, Henry Wang wrote:
--- a/tools/libs/ctrl/xc_domain.c
+++ b/tools/libs/ctrl/xc_domain.c
@@ -697,6 +697,43 @@ int xc_domain_setmaxmem(xc_interface *xch,
      return do_domctl(xch, &domctl);
  }
+int xc_get_domain_mem_map(xc_interface *xch, uint32_t domid,
+                          struct xen_mem_region mem_regions[],
+                          uint32_t *nr_regions)
+{
+    int rc;
+    uint32_t nr = *nr_regions;
+    struct xen_domctl domctl = {
+        .cmd         = XEN_DOMCTL_get_mem_map,
+        .domain      = domid,
+        .u.mem_map = {
+            .nr_mem_regions = nr,
+        },
+    };
+
+    DECLARE_HYPERCALL_BOUNCE(mem_regions, sizeof(xen_mem_region_t) * nr,
+                             XC_HYPERCALL_BUFFER_BOUNCE_OUT);
+
+    if ( !mem_regions || xc_hypercall_bounce_pre(xch, mem_regions) || nr < 1 )
Why the nr < 1 part? For a caller to size the necessary buffer, it may want
to pass in 0 (and a NULL buffer pointer) first.

I will drop this nr < 1 part.

@@ -176,6 +175,33 @@ long arch_do_domctl(struct xen_domctl *domctl, struct 
domain *d,
return rc;
      }
+    case XEN_DOMCTL_get_mem_map:
+    {
+        int rc = 0;
+        uint32_t nr_regions;
unsigned int (see ./CODING_STYLE)?

Ok, I will use unsigned int.

--- a/xen/include/public/arch-arm.h
+++ b/xen/include/public/arch-arm.h
@@ -223,6 +223,13 @@ typedef uint64_t xen_pfn_t;
   */
  #define XEN_LEGACY_MAX_VCPUS 1
+/*
+ * Maximum number of memory map regions for guest memory layout.
+ * Used by XEN_DOMCTL_get_mem_map, currently there is only one region
+ * for the guest magic pages.
+ */
+#define XEN_MAX_MEM_REGIONS 1
Why is this in the public header? I can only find Xen-internal uses.

It will also be used in the init-dom0less app which is the toolstack side.

--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -946,6 +946,33 @@ struct xen_domctl_paging_mempool {
      uint64_aligned_t size; /* Size in bytes. */
  };
+#ifndef XEN_MAX_MEM_REGIONS
+#define XEN_MAX_MEM_REGIONS 1
+#endif
+
+struct xen_mem_region {
+    uint64_aligned_t start;
+    uint64_aligned_t size;
+#define XEN_MEM_REGION_DEFAULT    0
I can't spot any use of this. What's its purpose?

I can drop it. My original intention is to define a default type since the struct arch_domain should be zalloc-ed.

+#define XEN_MEM_REGION_MAGIC      1
+    uint32_t         type;
+    /* Must be zero */
+    uint32_t         pad;
This being OUT only, I don't think the comment makes sense. I'd omit it
completely; if you absolutely want one, please say "will" instead of "must".

Sure, I will follow your suggestion. Thanks.

Kind regards,
Henry



Jan




 


Rackspace

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