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

Re: [PATCH v3 3/3] xen/x86: move d->arch.physaddr_bitsize field handling to pv32


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • Date: Mon, 8 Dec 2025 21:21:30 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • 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=6ZLetCFDuJZr4FOq/Ep6H0TruFN0Jjex2HqkTby0WI8=; b=l0A2lwbK8bR8ryb64UQRirtM02dt6dT+8Rvtj6VUKsd1yFncbj+CzXH3A1Mh5nX8Gd2kzybAtAh/TzniWaz65Bpc9XXRO3ngWY1roHTP0iR1/u8YDaESKu4tJOGFrJrQegjHkduUJDZ4anIDF626HoOuz0G+i5nqCPo7Ea69FkkxfsuN9RewKvWr8pP6PUZD01hMX8mPOWPKcagiqDTkgLhg9ObfO3Vf9GLEHBt7zP87UYLZ11kmYdp50rLIc4UWmyX12UlXD5CvsVH0hwo8DkQsxECt8nQUH1p9AfAri2495MZmne4xrarFVR6GjSKGRzS27HXsQmcUfF4ybRmqcA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=B5nEXjAmZlM+HrKZ5glVjJ7mk6CTe9dd1wEIyqpZLxn15OAt+LxBnbbxR5OcVNTQNNcbfwY0R/x3HI6/Kfd8YOfepQ1+XTXKK7j8kWiw43oA45eDI6gxVnY3OS4qz6KuLiCc8YWsnuNlKXC0VvGtcIxiNx9Cyw+T9P1m4LvzzxtZA8VCICrfWBFfmhQcS8gCVqraD9tTsxm3nbtuAA6xC5TbmnIP+3lR5+2Te/vRnA2lFSPuVpsBIgxnQa+bEMEcFe+mJQjcU5M8F0ygiFmxQgAI37CngEWJrjjflgKZ6Nw6F2XcvXgb9/Q4NpDmluMw1lsw+pzsjY5Ep5ULWw7bGw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 08 Dec 2025 19:21:52 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>



On 08.12.25 14:44, Jan Beulich wrote:
On 28.11.2025 16:22, Grygorii Strashko wrote:
--- a/xen/arch/x86/include/asm/mm.h
+++ b/xen/arch/x86/include/asm/mm.h
@@ -619,9 +619,12 @@ void __iomem *ioremap_wc(paddr_t pa, size_t len);
extern int memory_add(unsigned long spfn, unsigned long epfn, unsigned int pxm); -void domain_set_alloc_bitsize(struct domain *d);
-unsigned int domain_clamp_alloc_bitsize(struct domain *d, unsigned int bits);
-#define domain_clamp_alloc_bitsize(d, bits) domain_clamp_alloc_bitsize(d, bits)
+#ifdef CONFIG_PV32
+#define domain_clamp_alloc_bitsize(d, bits)                                    
\
+    (((d) && (d)->arch.pv.physaddr_bitsize)                                    
\
+         ? min_t(uint32_t, (d)->arch.pv.physaddr_bitsize, (bits))              
\
+         : (bits))

I'm not quite sure if converting to a macro was a good idea. But now that it's
done this way, so be it. Just that a couple of issues may want / need sorting:
- d is now evaluated up to 3 times,
- indentation is wrong,
- the use of uint32_t is against ./CODING_STYLE (I dislike the use of min_t()
   anyway, but what do you do when a macro was asked for; of course we could
   [easily] arrange for BITS_PER_LONG to be of type "unsigned int"),
- the use of "bits" in min_t() doesn't really need parentheses.


I'll update it.

--- a/xen/arch/x86/pv/domain.c
+++ b/xen/arch/x86/pv/domain.c
@@ -254,7 +254,11 @@ int switch_compat(struct domain *d)
              goto undo_and_fail;
      }
- domain_set_alloc_bitsize(d);
+    if ( MACH2PHYS_COMPAT_NR_ENTRIES(d) < max_page )

You mention the change in condition in the revlog (but not in the description),

The updated chunk was based on snippet from Andrew [1], which
used incorrect condition - I've changed it and noted in change log

[1] https://patchwork.kernel.org/comment/26680551/

and I'm having trouble to follow why ...

--- a/xen/arch/x86/x86_64/mm.c
+++ b/xen/arch/x86/x86_64/mm.c
@@ -1119,26 +1119,6 @@ unmap:
      return ret;
  }
-void domain_set_alloc_bitsize(struct domain *d)
-{

The domain_set_alloc_bitsize() inlined in  switch_compat() and x86 PV domain
always created as 64bit domain.

At the beginning of switch_compat() there is:

 ( is_pv_32bit_domain(d) )
        return 0;
[2]
above ensures that switch_compat() can be actually called only once (at least 
it can reach
point [2] only once, because there is no way to reset PV domain state 
32bit->64bit

this is original condition which says:
-    if ( !is_pv_32bit_domain(d) ||

do nothing if !is_pv_32bit_domain(d)
 - for inlined code is_pv_32bit_domain(d) == true, so is_pv_32bit_domain(d) can 
be ignored

-         (MACH2PHYS_COMPAT_NR_ENTRIES(d) >= max_page) ||

do nothing if (MACH2PHYS_COMPAT_NR_ENTRIES(d) >= max_page)
  - inlinded code should proceed if this condition is opposite
    (MACH2PHYS_COMPAT_NR_ENTRIES(d) < max_page)

-         d->arch.physaddr_bitsize > 0 )

do nothing if d->arch.physaddr_bitsize > 0 (already set)
  - inlined code will be executed only once, so (d->arch.physaddr_bitsize ==/!= 
0)
    can be ignored


... this 3rd part is going away.

Another observation: MACH2PHYS_COMPAT_NR_ENTRIES(d) is looks like a const, as
(d)->arch.hv_compat_vstart is always 0.

grep -rw hv_compat_vstart ./*
./arch/x86/include/asm/config.h:#define HYPERVISOR_COMPAT_VIRT_START(d) 
((d)->arch.hv_compat_vstart)
./arch/x86/include/asm/domain.h:    unsigned int hv_compat_vstart;


--
Best regards,
-grygorii




 


Rackspace

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