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

Re: [PATCH v2 4/5] xen/arm: Find unallocated spaces for magic pages of direct-mapped domU


  • To: Michal Orzel <michal.orzel@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Henry Wang <xin.wang2@xxxxxxx>
  • Date: Tue, 12 Mar 2024 11:25:12 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org 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=L6Bl6PBC4FkJYU4JrYrA1g5R3/1rnZdldtNvmWVMzVg=; b=gFUNiXstml1GznjOqxTfeu6PdkZS84uu/VA9eDKLGLHzbLvHJ6zgEmVNvhIKwQ0/CU26Q1ndLL4KeCVrg3kgWRZopaMY44GFXvK9HyN+ESyWXRBUIuqrqK+5rOXnIsMn2Tx6s+GuXoIWGGcYq8T1KD40TKR794sMbUCy35DK3TFOhjWOAq59u2NKs45PxRVf/OTcTC8OjHzt98ATArYVcVjS3Ox9xrSXA75xF8Q5GXjC5d7xL9jXId8axIDaqCJUIJNmtv4NBuanT1sVn2VmqvBgtRWuFngMCZEV1lHdoIRKMz3+0dWuM2qkXb5h9e+zSAGGn+TxwnDLu4MiNmS7Ww==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k0EXCHCIzKofh+bL8opTTCZS50GlUOhva2KJ/zj8Enj2B94LQKrAOPb+FWXGaghfRLqEre15HeJ/6l/Lkc12CuNZTN+d84qfH4j9jEKBdp8DSa/VUYJ0xLux1gN+/8Ey6dWKYX+DNYs5u6rsxYfCQYS0ahM2K5fh53WW1+5GjjjaCnYPX9kVFomSEAS1hp8F4KIMa3VFwXOG5jG2NInf9zATx1FwRA8ry4482gi/ycLV4KWOWHHzN56p4jH5OcIQQlrBu9wqIC/LHZJ0k2Lp6O+4roXzXKh5oYbj+vH+KKFXl3ttvFmZC073obs2QpT6JTqHdtVg8cQMMD9ZXLZw5g==
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, "Volodymyr Babchuk" <Volodymyr_Babchuk@xxxxxxxx>, Alec Kwapis <alec.kwapis@xxxxxxxxxxxxx>, Carlo Nonato <carlo.nonato@xxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 12 Mar 2024 03:25:45 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Michal,

On 3/11/2024 9:46 PM, Michal Orzel wrote:
Hi Henry,

diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c
index 1e1c8d83ae..99447bfb0c 100644
--- a/xen/arch/arm/dom0less-build.c
+++ b/xen/arch/arm/dom0less-build.c
@@ -682,6 +682,49 @@ static int __init prepare_dtb_domU(struct domain *d, 
struct kernel_info *kinfo)
if ( kinfo->dom0less_feature & DOM0LESS_ENHANCED_NO_XS )
      {
+        if ( is_domain_direct_mapped(d) )
+        {
This whole block is dependent on static memory feature that is compiled out by 
default.
Shouldn't you move it to static-memory.c ?

This makes sense. I will convert this block to a function then move to static-memory.c in v3.

+            struct meminfo *avail_magic_regions = xzalloc(struct meminfo);
I can't see corresponding xfree(avail_magic_regions). It's not going to be used 
after unused memory
regions are retrieved.

Hmmm I realized I've made a mess here and below. I will do the proper error handling in v3.

+            struct meminfo *rsrv_mem = &bootinfo.reserved_mem;
+            struct mem_map_domain *mem_map = &d->arch.mem_map;
+            uint64_t magic_region_start = INVALID_PADDR;
What's the purpose of this initialization? magic_region_start is going to be 
re-assigned before making use of this value.

Personally for variables holding an address, I would like to init the local variable to a poison value before use. But you are right it does not make a difference here I think. I can drop the initialization if you prefer not having it, sure.

+            uint64_t magic_region_size = GUEST_MAGIC_SIZE;
Why not paddr_t?

Good catch, I mixed struct meminfo with the newly added struct. Will use paddr_t.
+
+            magic_region_start = avail_magic_regions->bank[0].start;
+
+            /*
+             * Register the magic region as reserved mem to make sure this
+             * region will not be counted when allocating extended regions.
Well, this is only true in case find_unallocated_memory() is used to retrieve 
free regions.
What if our direct mapped domU used partial dtb and IOMMU is in use? In this 
case,
find_memory_holes() will be used and the behavior will be different.

Also, I'm not sure if it is a good idea to call find_unused_memory twice (with 
lots of steps inside)
just to retrieve 16MB (btw. add_ext_regions will only return 64MB+ regions) 
region for magic pages.
I'll let other maintainers share their opinion.

I agree with your point. Let's wait a bit longer for more ideas/comments. If no other inputs, I think I will drop the "adding to reserved_mem" part of logic and record the found unused memory in kinfo, then use rangeset_remove_range() to remove this range in both

find_unallocated_memory() and find_memory_holes().

Also, CCing Carlo since he was in a need of retrieving free memory regions as 
well for cache coloring with dom0.

(+ Carlo)
Any inputs from your side for this topic Carlo?

Kind regards,
Henry
~Michal




 


Rackspace

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