Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xen: replace XENFEAT_auto_translated_physmap with xen_pv_domain()

Instead of testing the XENFEAT_auto_translated_physmap feature, just
use !xen_pv_domain() which is equivalent.

This has the advantage that a kernel not built with CONFIG_XEN_PV
will be smaller due to dead code elimination.

Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Message-ID: <20250826145608.10352-3-jgross@suse.com>

+33 -34
+7 -7
arch/x86/include/asm/xen/page.h
··· 12 12 #include <asm/extable.h> 13 13 #include <asm/page.h> 14 14 15 + #include <xen/xen.h> 15 16 #include <xen/interface/xen.h> 16 17 #include <xen/interface/grant_table.h> 17 - #include <xen/features.h> 18 18 19 19 /* Xen machine address */ 20 20 typedef struct xmaddr { ··· 162 162 * pfn_to_mfn. This will have to be removed when we figured 163 163 * out which call. 164 164 */ 165 - if (xen_feature(XENFEAT_auto_translated_physmap)) 165 + if (!xen_pv_domain()) 166 166 return pfn; 167 167 168 168 mfn = __pfn_to_mfn(pfn); ··· 175 175 176 176 static inline int phys_to_machine_mapping_valid(unsigned long pfn) 177 177 { 178 - if (xen_feature(XENFEAT_auto_translated_physmap)) 178 + if (!xen_pv_domain()) 179 179 return 1; 180 180 181 181 return __pfn_to_mfn(pfn) != INVALID_P2M_ENTRY; ··· 210 210 * gfn_to_pfn. This will have to be removed when we figure 211 211 * out which call. 212 212 */ 213 - if (xen_feature(XENFEAT_auto_translated_physmap)) 213 + if (!xen_pv_domain()) 214 214 return mfn; 215 215 216 216 pfn = mfn_to_pfn_no_overrides(mfn); ··· 242 242 /* Pseudo-physical <-> Guest conversion */ 243 243 static inline unsigned long pfn_to_gfn(unsigned long pfn) 244 244 { 245 - if (xen_feature(XENFEAT_auto_translated_physmap)) 245 + if (!xen_pv_domain()) 246 246 return pfn; 247 247 else 248 248 return pfn_to_mfn(pfn); ··· 250 250 251 251 static inline unsigned long gfn_to_pfn(unsigned long gfn) 252 252 { 253 - if (xen_feature(XENFEAT_auto_translated_physmap)) 253 + if (!xen_pv_domain()) 254 254 return gfn; 255 255 else 256 256 return mfn_to_pfn(gfn); ··· 284 284 { 285 285 unsigned long pfn; 286 286 287 - if (xen_feature(XENFEAT_auto_translated_physmap)) 287 + if (!xen_pv_domain()) 288 288 return mfn; 289 289 290 290 pfn = mfn_to_pfn(mfn);
+1 -1
arch/x86/xen/mmu.c
··· 41 41 int xen_unmap_domain_gfn_range(struct vm_area_struct *vma, 42 42 int nr, struct page **pages) 43 43 { 44 - if (xen_feature(XENFEAT_auto_translated_physmap)) 44 + if (!xen_pv_domain()) 45 45 return xen_xlate_unmap_gfn_range(vma, nr, pages); 46 46 47 47 if (!pages)
+2 -2
arch/x86/xen/p2m.c
··· 686 686 int i, ret = 0; 687 687 pte_t *pte; 688 688 689 - if (xen_feature(XENFEAT_auto_translated_physmap)) 689 + if (!xen_pv_domain()) 690 690 return 0; 691 691 692 692 if (kmap_ops) { ··· 769 769 { 770 770 int i, ret = 0; 771 771 772 - if (xen_feature(XENFEAT_auto_translated_physmap)) 772 + if (!xen_pv_domain()) 773 773 return 0; 774 774 775 775 for (i = 0; i < count; i++) {
+2 -2
drivers/xen/balloon.c
··· 302 302 * are not restored since this region is now known not to 303 303 * conflict with any devices. 304 304 */ 305 - if (!xen_feature(XENFEAT_auto_translated_physmap)) { 305 + if (xen_pv_domain()) { 306 306 unsigned long pfn, i; 307 307 308 308 pfn = PFN_DOWN(resource->start); ··· 626 626 */ 627 627 BUILD_BUG_ON(XEN_PAGE_SIZE != PAGE_SIZE); 628 628 629 - if (!xen_feature(XENFEAT_auto_translated_physmap)) { 629 + if (xen_pv_domain()) { 630 630 ret = xen_alloc_p2m_entry(page_to_pfn(page)); 631 631 if (ret < 0) 632 632 goto out_undo;
+1 -1
drivers/xen/gntdev.c
··· 1183 1183 if (!xen_domain()) 1184 1184 return -ENODEV; 1185 1185 1186 - use_ptemod = !xen_feature(XENFEAT_auto_translated_physmap); 1186 + use_ptemod = xen_pv_domain(); 1187 1187 1188 1188 err = misc_register(&gntdev_miscdev); 1189 1189 if (err != 0) {
+3 -3
drivers/xen/grant-table.c
··· 1449 1449 unsigned int nr_gframes = end_idx + 1; 1450 1450 int rc; 1451 1451 1452 - if (xen_feature(XENFEAT_auto_translated_physmap)) { 1452 + if (!xen_pv_domain()) { 1453 1453 struct xen_add_to_physmap xatp; 1454 1454 unsigned int i = end_idx; 1455 1455 rc = 0; ··· 1570 1570 if (max_nr_gframes < nr_grant_frames) 1571 1571 return -ENOSYS; 1572 1572 1573 - if (xen_feature(XENFEAT_auto_translated_physmap) && gnttab_shared.addr == NULL) { 1573 + if (!xen_pv_domain() && gnttab_shared.addr == NULL) { 1574 1574 gnttab_shared.addr = xen_auto_xlat_grant_frames.vaddr; 1575 1575 if (gnttab_shared.addr == NULL) { 1576 1576 pr_warn("gnttab share frames is not mapped!\n"); ··· 1588 1588 1589 1589 int gnttab_suspend(void) 1590 1590 { 1591 - if (!xen_feature(XENFEAT_auto_translated_physmap)) 1591 + if (xen_pv_domain()) 1592 1592 gnttab_interface->unmap_frames(); 1593 1593 return 0; 1594 1594 }
+6 -8
drivers/xen/privcmd.c
··· 271 271 struct mmap_gfn_state state; 272 272 273 273 /* We only support privcmd_ioctl_mmap_batch for non-auto-translated. */ 274 - if (xen_feature(XENFEAT_auto_translated_physmap)) 274 + if (!xen_pv_domain()) 275 275 return -ENOSYS; 276 276 277 277 if (copy_from_user(&mmapcmd, udata, sizeof(mmapcmd))) ··· 353 353 struct page **cur_pages = NULL; 354 354 int ret; 355 355 356 - if (xen_feature(XENFEAT_auto_translated_physmap)) 356 + if (!xen_pv_domain()) 357 357 cur_pages = &pages[st->index]; 358 358 359 359 BUG_ON(nr < 0); ··· 535 535 ret = -EINVAL; 536 536 goto out_unlock; 537 537 } 538 - if (xen_feature(XENFEAT_auto_translated_physmap)) { 538 + if (!xen_pv_domain()) { 539 539 ret = alloc_empty_pages(vma, nr_pages); 540 540 if (ret < 0) 541 541 goto out_unlock; ··· 779 779 goto out; 780 780 } 781 781 782 - if (IS_ENABLED(CONFIG_XEN_AUTO_XLATE) && 783 - xen_feature(XENFEAT_auto_translated_physmap)) { 782 + if (IS_ENABLED(CONFIG_XEN_AUTO_XLATE) && !xen_pv_domain()) { 784 783 unsigned int nr = DIV_ROUND_UP(kdata.num, XEN_PFN_PER_PAGE); 785 784 struct page **pages; 786 785 unsigned int i; ··· 810 811 if (rc) 811 812 goto out; 812 813 813 - if (IS_ENABLED(CONFIG_XEN_AUTO_XLATE) && 814 - xen_feature(XENFEAT_auto_translated_physmap)) { 814 + if (IS_ENABLED(CONFIG_XEN_AUTO_XLATE) && !xen_pv_domain()) { 815 815 rc = xen_remap_vma_range(vma, kdata.addr, kdata.num << PAGE_SHIFT); 816 816 } else { 817 817 unsigned int domid = ··· 1589 1591 int numgfns = (vma->vm_end - vma->vm_start) >> XEN_PAGE_SHIFT; 1590 1592 int rc; 1591 1593 1592 - if (!xen_feature(XENFEAT_auto_translated_physmap) || !numpgs || !pages) 1594 + if (xen_pv_domain() || !numpgs || !pages) 1593 1595 return; 1594 1596 1595 1597 rc = xen_unmap_domain_gfn_range(vma, numgfns, pages);
+2 -2
drivers/xen/unpopulated-alloc.c
··· 105 105 * are not restored since this region is now known not to 106 106 * conflict with any devices. 107 107 */ 108 - if (!xen_feature(XENFEAT_auto_translated_physmap)) { 108 + if (xen_pv_domain()) { 109 109 xen_pfn_t pfn = PFN_DOWN(res->start); 110 110 111 111 for (i = 0; i < alloc_pages; i++) { ··· 184 184 pages[i] = pg; 185 185 186 186 #ifdef CONFIG_XEN_HAVE_PVMMU 187 - if (!xen_feature(XENFEAT_auto_translated_physmap)) { 187 + if (xen_pv_domain()) { 188 188 ret = xen_alloc_p2m_entry(page_to_pfn(pg)); 189 189 if (ret < 0) { 190 190 unsigned int j;
+1 -1
drivers/xen/xenbus/xenbus_client.c
··· 955 955 void __init xenbus_ring_ops_init(void) 956 956 { 957 957 #ifdef CONFIG_XEN_PV 958 - if (!xen_feature(XENFEAT_auto_translated_physmap)) 958 + if (xen_pv_domain()) 959 959 ring_ops = &ring_ops_pv; 960 960 else 961 961 #endif
+2 -2
include/xen/grant_table.h
··· 164 164 { 165 165 if (flags & GNTMAP_contains_pte) 166 166 map->host_addr = addr; 167 - else if (xen_feature(XENFEAT_auto_translated_physmap)) 167 + else if (!xen_pv_domain()) 168 168 map->host_addr = __pa(addr); 169 169 else 170 170 map->host_addr = addr; ··· 181 181 { 182 182 if (flags & GNTMAP_contains_pte) 183 183 unmap->host_addr = addr; 184 - else if (xen_feature(XENFEAT_auto_translated_physmap)) 184 + else if (!xen_pv_domain()) 185 185 unmap->host_addr = __pa(addr); 186 186 else 187 187 unmap->host_addr = addr;
+2 -2
include/xen/mem-reservation.h
··· 39 39 xen_pfn_t *frames) 40 40 { 41 41 #ifdef CONFIG_XEN_HAVE_PVMMU 42 - if (!xen_feature(XENFEAT_auto_translated_physmap)) 42 + if (xen_pv_domain()) 43 43 __xenmem_reservation_va_mapping_update(count, pages, frames); 44 44 #endif 45 45 } ··· 48 48 struct page **pages) 49 49 { 50 50 #ifdef CONFIG_XEN_HAVE_PVMMU 51 - if (!xen_feature(XENFEAT_auto_translated_physmap)) 51 + if (xen_pv_domain()) 52 52 __xenmem_reservation_va_mapping_reset(count, pages); 53 53 #endif 54 54 }
+4 -3
include/xen/xen-ops.h
··· 6 6 #include <linux/notifier.h> 7 7 #include <linux/efi.h> 8 8 #include <linux/virtio_anchor.h> 9 + #include <xen/xen.h> 9 10 #include <xen/features.h> 10 11 #include <asm/xen/interface.h> 11 12 #include <xen/interface/vcpu.h> ··· 117 116 unsigned int domid, 118 117 struct page **pages) 119 118 { 120 - if (xen_feature(XENFEAT_auto_translated_physmap)) 119 + if (!xen_pv_domain()) 121 120 return xen_xlate_remap_gfn_array(vma, addr, gfn, nr, err_ptr, 122 121 prot, domid, pages); 123 122 ··· 151 150 int nr, int *err_ptr, 152 151 pgprot_t prot, unsigned int domid) 153 152 { 154 - if (xen_feature(XENFEAT_auto_translated_physmap)) 153 + if (!xen_pv_domain()) 155 154 return -EOPNOTSUPP; 156 155 157 156 return xen_remap_pfn(vma, addr, mfn, nr, err_ptr, prot, domid, ··· 176 175 pgprot_t prot, unsigned int domid, 177 176 struct page **pages) 178 177 { 179 - if (xen_feature(XENFEAT_auto_translated_physmap)) 178 + if (!xen_pv_domain()) 180 179 return -EOPNOTSUPP; 181 180 182 181 return xen_remap_pfn(vma, addr, &gfn, nr, NULL, prot, domid, false);