xen/x86: move d->arch.physaddr_bitsize field handling to pv32
v4 cover xen/x86: move d->arch.physaddr_bitsize field handling to pv32
From: Grygorii Strashko <[email protected]>
The d->arch.physaddr_bitsize field is used only by PV32 code so as the domain_clamp_alloc_bitsize() function.
So move them into PV32 code.
changes in v4:
- rebase
- split patch 3 on two:
move domain_clamp_alloc_bitsize()
move d->arch.physaddr_bitsize
changes in v3:
- added tags
- changed patch 3
changes in v2:
- split on 3 patches
- move physaddr_bitsize in struct pv_domain
- make minimal style adjustments as requested
v3: https://patchwork.kernel.org/project/xen-devel/cover/[email protected]/
v2: https://patchwork.kernel.org/project/xen-devel/cover/[email protected]/
Grygorii Strashko (2):
xen/x86: move domain_clamp_alloc_bitsize() into pv32 code xen/x86: move d->arch.physaddr_bitsize field handling into pv32
xen/arch/x86/include/asm/domain.h | 6 +++--- xen/arch/x86/include/asm/mm.h | 12 ++++++++++-- xen/arch/x86/pv/dom0_build.c | 7 +++++-- xen/arch/x86/pv/domain.c | 2 +- xen/arch/x86/x86_64/mm.c | 7 ------- 5 files changed, 19 insertions(+), 15 deletions(-)
Signature · 1 line
2.34.1
PATCH v4 1/2 xen/x86: move domain_clamp_alloc_bitsize() into pv32 code
From: Grygorii Strashko <[email protected]>
The d->arch.physaddr_bitsize field is used only by PV32 code so as the domain_clamp_alloc_bitsize() function.
Hence move domain_clamp_alloc_bitsize() function into PV32 code and convert it to macro.
---
changes in v4:
- rebase
- split out moving d->arch.physaddr_bitsize in separate patch
- fix comments for domain_clamp_alloc_bitsize() macro
xen/arch/x86/include/asm/mm.h | 12 ++++++++++-- xen/arch/x86/x86_64/mm.c | 7 ------- 2 files changed, 10 insertions(+), 9 deletions(-)
xen/arch/x86/include/asm/mm.h +10 -2
@@ -619,8 +619,16 @@ void __iomem *ioremap_wc(paddr_t pa, size_t len);extern int memory_add (unsigned long spfn,unsigned long epfn,unsigned int pxm); -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) ({ \ + struct domain *_d = (d); \ + \ + ((_d && \ + _d->arch.physaddr_bitsize) \ + ? min_t(unsigned int, _d->arch.physaddr_bitsize, bits) \ + : bits); \ +}) +#endif unsigned long domain_get_maximum_gpfn (struct domain *d);
xen/arch/x86/x86_64/mm.c +0 -7
@@ -1119,13 +1119,6 @@ unmap:return ret; } -unsigned int domain_clamp_alloc_bitsize (struct domain *d,unsigned int bits) -{ -if ( (d ==NULL ) || (d->arch.physaddr_bitsize ==0 ) ) -return bits; -return min (d->arch.physaddr_bitsize, bits); -} -static int transfer_pages_to_heap (struct mem_hotadd_info *info) {unsigned long i;
Signature · 1 line
2.34.1
Re: [PATCH v4 1/2] xen/x86: move domain_clamp_alloc_bitsize() into pv32 code
xen/arch/x86/include/asm/mm.h void __iomem *ioremap_wc(paddr_t pa, size_t len); · line 624
Quoted 11 lines · Grygorii Strashko
xen/arch/x86/include/asm/mm.h +3
-2@@ -619,8 +619,16 @@ void __iomem *ioremap_wc(paddr_t pa, size_t len);extern int memory_add (unsigned long spfn,unsigned long epfn,unsigned int pxm); -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) ({ \ + struct domain *_d = (d); \
This imo wants to be pointer-to-const. Question is whether then I'm upsetting you again, Andrew?
xen/arch/x86/include/asm/mm.h void __iomem *ioremap_wc(paddr_t pa, size_t len); · line 629
Quoted 4 lines
xen/arch/x86/include/asm/mm.h +4
-0+ ((_d && \ + _d->arch.physaddr_bitsize) \ + ? min_t(unsigned int, _d->arch.physaddr_bitsize, bits) \ + : bits); \
This imo wants to look more like
((_d && _d->arch.physaddr_bitsize) \
? min_t(unsigned int, _d->arch.physaddr_bitsize, bits) \
: (bits)); \The parenthesization of the latter use of "bits" is a must.
With the adjustments (happy to carry out while committing, so long as there's agreement):
Albeit, as indicated before, I'm not quite happy with the use of min_t(). Maybe another macro-local variable _bits should be introduced?
Jan
Re: [PATCH v4 1/2] xen/x86: move domain_clamp_alloc_bitsize() into pv32 code
Quoted 21 lines · Jan Beulich
xen/arch/x86/include/asm/mm.h void __iomem *ioremap_wc(paddr_t pa, size_t len); · line 624
Quoted 11 lines · Grygorii Strashko
xen/arch/x86/include/asm/mm.h +3
-2@@ -619,8 +619,16 @@ void __iomem *ioremap_wc(paddr_t pa, size_t len);extern int memory_add (unsigned long spfn,unsigned long epfn,unsigned int pxm); -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) ({ \ + struct domain *_d = (d); \This imo wants to be pointer-to-const. Question is whether then I'm upsetting you again, Andrew?
xen/arch/x86/include/asm/mm.h void __iomem *ioremap_wc(paddr_t pa, size_t len); · line 629
Quoted 4 lines
xen/arch/x86/include/asm/mm.h +4
-0+ ((_d && \ + _d->arch.physaddr_bitsize) \ + ? min_t(unsigned int, _d->arch.physaddr_bitsize, bits) \ + : bits); \
Quoted 8 lines
This imo wants to look more like
((_d && _d->arch.physaddr_bitsize) \ ? min_t(unsigned int, _d->arch.physaddr_bitsize, bits) \ : (bits)); \The parenthesization of the latter use of "bits" is a must.
I'm ok with above adjustments, thank you.
Quoted 8 lines
With the adjustments (happy to carry out while committing, so long as there's agreement):
Reviewed-by Jan Beulich <[email protected]>Albeit, as indicated before, I'm not quite happy with the use of
min_t(). Maybe another macro-local variable_bitsshould be introduced?
Signature · 2 lines
Best regards, -grygorii
PATCH v4 2/2 xen/x86: move d->arch.physaddr_bitsize field handling into pv32
In reply to Grygorii StrashkoFrom: Grygorii Strashko <[email protected]>
The d->arch.physaddr_bitsize field is used only by PV32 code, so move d->arch.physaddr_bitsize field under PV32 ifdef into struct pv_domain.
---
changes in v4:
- rebase
- new patch
xen/arch/x86/include/asm/domain.h | 6 +++--- xen/arch/x86/include/asm/mm.h | 4 ++-- xen/arch/x86/pv/dom0_build.c | 7 +++++-- xen/arch/x86/pv/domain.c | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-)
xen/arch/x86/include/asm/domain.h +3 -3
@@ -290,6 +290,9 @@ struct pv_domain#ifdef CONFIG_PV32 unsigned int hv_compat_vstart; + +/* Maximum physical-address bitwidth supported by this guest. */ +unsigned int physaddr_bitsize;#endif /* map_domain_page() mapping cache. */
@@ -319,9 +322,6 @@ struct arch_domain {struct page_info *perdomain_l3_pg; -/* Maximum physical-address bitwidth supported by this guest. */ -unsigned int physaddr_bitsize; -/* I/O-port admin-specified access capabilities. */ struct rangeset *ioport_caps;uint32_t pci_cf8;
xen/arch/x86/include/asm/mm.h +2 -2
@@ -624,8 +624,8 @@ extern int memory_add(unsigned long spfn, unsigned long epfn, unsigned int pxm);struct domain *_d = (d); \ \ ((_d && \ - _d->arch.physaddr_bitsize) \ - ? min_t(unsigned int, _d->arch.physaddr_bitsize, bits) \ + _d->arch.pv.physaddr_bitsize) \ + ? min_t(unsigned int, _d->arch.pv.physaddr_bitsize, bits) \ : bits); \ })#endif
xen/arch/x86/pv/dom0_build.c +5 -2
@@ -626,8 +626,10 @@ static int __init dom0_construct(const struct boot_domain *bd) initrd_mfn =paddr_to_pfn (initrd->start); mfn = initrd_mfn; count =PFN_UP (initrd_len); -if ( d->arch.physaddr_bitsize && - ((mfn + count -1 ) >> (d->arch.physaddr_bitsize -PAGE_SHIFT )) ) + +#ifdef CONFIG_PV32 +if ( d->arch.pv.physaddr_bitsize && + ((mfn + count -1 ) >> (d->arch.pv.physaddr_bitsize -PAGE_SHIFT )) ) { order =get_order_from_pages (count); page =alloc_domheap_pages (d, order, MEMF_no_scrub);
@@ -650,6 +652,7 @@ static int __init dom0_construct(const struct boot_domain *bd) initrd->start = pfn_to_paddr(initrd_mfn); } else +#endif {while ( count-- )if (assign_pages (mfn_to_page (_mfn (mfn++)),1 , d,0 ) )
xen/arch/x86/pv/domain.c +1 -1
@@ -257,7 +257,7 @@ int switch_compat(struct domain *d) d->arch.pv.hv_compat_vstart = __HYPERVISOR_COMPAT_VIRT_START;if (MACH2PHYS_COMPAT_NR_ENTRIES (d) < max_page ) - d->arch.physaddr_bitsize = + d->arch.pv.physaddr_bitsize =/* 2^n entries can be contained in guest's p2m mapping space */ fls (MACH2PHYS_COMPAT_NR_ENTRIES (d)) -1 +PAGE_SHIFT ;
Signature · 1 line
2.34.1
Re: [PATCH v4 2/2] xen/x86: move d->arch.physaddr_bitsize field handling into pv32
Quoted 6 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
The
d->arch.physaddr_bitsizefield is used only by PV32 code, so moved->arch.physaddr_bitsizefield under PV32 ifdef into structpv_domain.Signed-off-by Grygorii Strashko <[email protected]>
(Yes, much nicer split out.)