Skip to content

Commit 0f42831

Browse files
committed
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>
1 parent 34c605f commit 0f42831

12 files changed

Lines changed: 33 additions & 34 deletions

File tree

arch/x86/include/asm/xen/page.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
#include <asm/extable.h>
1313
#include <asm/page.h>
1414

15+
#include <xen/xen.h>
1516
#include <xen/interface/xen.h>
1617
#include <xen/interface/grant_table.h>
17-
#include <xen/features.h>
1818

1919
/* Xen machine address */
2020
typedef struct xmaddr {
@@ -162,7 +162,7 @@ static inline unsigned long pfn_to_mfn(unsigned long pfn)
162162
* pfn_to_mfn. This will have to be removed when we figured
163163
* out which call.
164164
*/
165-
if (xen_feature(XENFEAT_auto_translated_physmap))
165+
if (!xen_pv_domain())
166166
return pfn;
167167

168168
mfn = __pfn_to_mfn(pfn);
@@ -175,7 +175,7 @@ static inline unsigned long pfn_to_mfn(unsigned long pfn)
175175

176176
static inline int phys_to_machine_mapping_valid(unsigned long pfn)
177177
{
178-
if (xen_feature(XENFEAT_auto_translated_physmap))
178+
if (!xen_pv_domain())
179179
return 1;
180180

181181
return __pfn_to_mfn(pfn) != INVALID_P2M_ENTRY;
@@ -210,7 +210,7 @@ static inline unsigned long mfn_to_pfn(unsigned long mfn)
210210
* gfn_to_pfn. This will have to be removed when we figure
211211
* out which call.
212212
*/
213-
if (xen_feature(XENFEAT_auto_translated_physmap))
213+
if (!xen_pv_domain())
214214
return mfn;
215215

216216
pfn = mfn_to_pfn_no_overrides(mfn);
@@ -242,15 +242,15 @@ static inline xpaddr_t machine_to_phys(xmaddr_t machine)
242242
/* Pseudo-physical <-> Guest conversion */
243243
static inline unsigned long pfn_to_gfn(unsigned long pfn)
244244
{
245-
if (xen_feature(XENFEAT_auto_translated_physmap))
245+
if (!xen_pv_domain())
246246
return pfn;
247247
else
248248
return pfn_to_mfn(pfn);
249249
}
250250

251251
static inline unsigned long gfn_to_pfn(unsigned long gfn)
252252
{
253-
if (xen_feature(XENFEAT_auto_translated_physmap))
253+
if (!xen_pv_domain())
254254
return gfn;
255255
else
256256
return mfn_to_pfn(gfn);
@@ -284,7 +284,7 @@ static inline unsigned long bfn_to_local_pfn(unsigned long mfn)
284284
{
285285
unsigned long pfn;
286286

287-
if (xen_feature(XENFEAT_auto_translated_physmap))
287+
if (!xen_pv_domain())
288288
return mfn;
289289

290290
pfn = mfn_to_pfn(mfn);

arch/x86/xen/mmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ EXPORT_SYMBOL_GPL(arbitrary_virt_to_machine);
4141
int xen_unmap_domain_gfn_range(struct vm_area_struct *vma,
4242
int nr, struct page **pages)
4343
{
44-
if (xen_feature(XENFEAT_auto_translated_physmap))
44+
if (!xen_pv_domain())
4545
return xen_xlate_unmap_gfn_range(vma, nr, pages);
4646

4747
if (!pages)

arch/x86/xen/p2m.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops,
686686
int i, ret = 0;
687687
pte_t *pte;
688688

689-
if (xen_feature(XENFEAT_auto_translated_physmap))
689+
if (!xen_pv_domain())
690690
return 0;
691691

692692
if (kmap_ops) {
@@ -769,7 +769,7 @@ int clear_foreign_p2m_mapping(struct gnttab_unmap_grant_ref *unmap_ops,
769769
{
770770
int i, ret = 0;
771771

772-
if (xen_feature(XENFEAT_auto_translated_physmap))
772+
if (!xen_pv_domain())
773773
return 0;
774774

775775
for (i = 0; i < count; i++) {

drivers/xen/balloon.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ static enum bp_state reserve_additional_memory(void)
302302
* are not restored since this region is now known not to
303303
* conflict with any devices.
304304
*/
305-
if (!xen_feature(XENFEAT_auto_translated_physmap)) {
305+
if (xen_pv_domain()) {
306306
unsigned long pfn, i;
307307

308308
pfn = PFN_DOWN(resource->start);
@@ -626,7 +626,7 @@ int xen_alloc_ballooned_pages(unsigned int nr_pages, struct page **pages)
626626
*/
627627
BUILD_BUG_ON(XEN_PAGE_SIZE != PAGE_SIZE);
628628

629-
if (!xen_feature(XENFEAT_auto_translated_physmap)) {
629+
if (xen_pv_domain()) {
630630
ret = xen_alloc_p2m_entry(page_to_pfn(page));
631631
if (ret < 0)
632632
goto out_undo;

drivers/xen/gntdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ static int __init gntdev_init(void)
11831183
if (!xen_domain())
11841184
return -ENODEV;
11851185

1186-
use_ptemod = !xen_feature(XENFEAT_auto_translated_physmap);
1186+
use_ptemod = xen_pv_domain();
11871187

11881188
err = misc_register(&gntdev_miscdev);
11891189
if (err != 0) {

drivers/xen/grant-table.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@ static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
14491449
unsigned int nr_gframes = end_idx + 1;
14501450
int rc;
14511451

1452-
if (xen_feature(XENFEAT_auto_translated_physmap)) {
1452+
if (!xen_pv_domain()) {
14531453
struct xen_add_to_physmap xatp;
14541454
unsigned int i = end_idx;
14551455
rc = 0;
@@ -1570,7 +1570,7 @@ static int gnttab_setup(void)
15701570
if (max_nr_gframes < nr_grant_frames)
15711571
return -ENOSYS;
15721572

1573-
if (xen_feature(XENFEAT_auto_translated_physmap) && gnttab_shared.addr == NULL) {
1573+
if (!xen_pv_domain() && gnttab_shared.addr == NULL) {
15741574
gnttab_shared.addr = xen_auto_xlat_grant_frames.vaddr;
15751575
if (gnttab_shared.addr == NULL) {
15761576
pr_warn("gnttab share frames is not mapped!\n");
@@ -1588,7 +1588,7 @@ int gnttab_resume(void)
15881588

15891589
int gnttab_suspend(void)
15901590
{
1591-
if (!xen_feature(XENFEAT_auto_translated_physmap))
1591+
if (xen_pv_domain())
15921592
gnttab_interface->unmap_frames();
15931593
return 0;
15941594
}

drivers/xen/privcmd.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ static long privcmd_ioctl_mmap(struct file *file, void __user *udata)
271271
struct mmap_gfn_state state;
272272

273273
/* We only support privcmd_ioctl_mmap_batch for non-auto-translated. */
274-
if (xen_feature(XENFEAT_auto_translated_physmap))
274+
if (!xen_pv_domain())
275275
return -ENOSYS;
276276

277277
if (copy_from_user(&mmapcmd, udata, sizeof(mmapcmd)))
@@ -353,7 +353,7 @@ static int mmap_batch_fn(void *data, int nr, void *state)
353353
struct page **cur_pages = NULL;
354354
int ret;
355355

356-
if (xen_feature(XENFEAT_auto_translated_physmap))
356+
if (!xen_pv_domain())
357357
cur_pages = &pages[st->index];
358358

359359
BUG_ON(nr < 0);
@@ -535,7 +535,7 @@ static long privcmd_ioctl_mmap_batch(
535535
ret = -EINVAL;
536536
goto out_unlock;
537537
}
538-
if (xen_feature(XENFEAT_auto_translated_physmap)) {
538+
if (!xen_pv_domain()) {
539539
ret = alloc_empty_pages(vma, nr_pages);
540540
if (ret < 0)
541541
goto out_unlock;
@@ -779,8 +779,7 @@ static long privcmd_ioctl_mmap_resource(struct file *file,
779779
goto out;
780780
}
781781

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()) {
784783
unsigned int nr = DIV_ROUND_UP(kdata.num, XEN_PFN_PER_PAGE);
785784
struct page **pages;
786785
unsigned int i;
@@ -811,8 +810,7 @@ static long privcmd_ioctl_mmap_resource(struct file *file,
811810
if (rc)
812811
goto out;
813812

814-
if (IS_ENABLED(CONFIG_XEN_AUTO_XLATE) &&
815-
xen_feature(XENFEAT_auto_translated_physmap)) {
813+
if (IS_ENABLED(CONFIG_XEN_AUTO_XLATE) && !xen_pv_domain()) {
816814
rc = xen_remap_vma_range(vma, kdata.addr, kdata.num << PAGE_SHIFT);
817815
} else {
818816
unsigned int domid =
@@ -1591,7 +1589,7 @@ static void privcmd_close(struct vm_area_struct *vma)
15911589
int numgfns = (vma->vm_end - vma->vm_start) >> XEN_PAGE_SHIFT;
15921590
int rc;
15931591

1594-
if (!xen_feature(XENFEAT_auto_translated_physmap) || !numpgs || !pages)
1592+
if (xen_pv_domain() || !numpgs || !pages)
15951593
return;
15961594

15971595
rc = xen_unmap_domain_gfn_range(vma, numgfns, pages);

drivers/xen/unpopulated-alloc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static int fill_list(unsigned int nr_pages)
105105
* are not restored since this region is now known not to
106106
* conflict with any devices.
107107
*/
108-
if (!xen_feature(XENFEAT_auto_translated_physmap)) {
108+
if (xen_pv_domain()) {
109109
xen_pfn_t pfn = PFN_DOWN(res->start);
110110

111111
for (i = 0; i < alloc_pages; i++) {
@@ -184,7 +184,7 @@ int xen_alloc_unpopulated_pages(unsigned int nr_pages, struct page **pages)
184184
pages[i] = pg;
185185

186186
#ifdef CONFIG_XEN_HAVE_PVMMU
187-
if (!xen_feature(XENFEAT_auto_translated_physmap)) {
187+
if (xen_pv_domain()) {
188188
ret = xen_alloc_p2m_entry(page_to_pfn(pg));
189189
if (ret < 0) {
190190
unsigned int j;

drivers/xen/xenbus/xenbus_client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ static const struct xenbus_ring_ops ring_ops_hvm = {
955955
void __init xenbus_ring_ops_init(void)
956956
{
957957
#ifdef CONFIG_XEN_PV
958-
if (!xen_feature(XENFEAT_auto_translated_physmap))
958+
if (xen_pv_domain())
959959
ring_ops = &ring_ops_pv;
960960
else
961961
#endif

include/xen/grant_table.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ gnttab_set_map_op(struct gnttab_map_grant_ref *map, phys_addr_t addr,
164164
{
165165
if (flags & GNTMAP_contains_pte)
166166
map->host_addr = addr;
167-
else if (xen_feature(XENFEAT_auto_translated_physmap))
167+
else if (!xen_pv_domain())
168168
map->host_addr = __pa(addr);
169169
else
170170
map->host_addr = addr;
@@ -181,7 +181,7 @@ gnttab_set_unmap_op(struct gnttab_unmap_grant_ref *unmap, phys_addr_t addr,
181181
{
182182
if (flags & GNTMAP_contains_pte)
183183
unmap->host_addr = addr;
184-
else if (xen_feature(XENFEAT_auto_translated_physmap))
184+
else if (!xen_pv_domain())
185185
unmap->host_addr = __pa(addr);
186186
else
187187
unmap->host_addr = addr;

0 commit comments

Comments
 (0)