Commit 0f428312 authored by Juergen Gross's avatar Juergen Gross
Browse files

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: default avatarJason Andryuk <jason.andryuk@amd.com>
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
Message-ID: <20250826145608.10352-3-jgross@suse.com>
parent 34c605fe
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -12,9 +12,9 @@
#include <asm/extable.h>
#include <asm/page.h>

#include <xen/xen.h>
#include <xen/interface/xen.h>
#include <xen/interface/grant_table.h>
#include <xen/features.h>

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

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

static inline int phys_to_machine_mapping_valid(unsigned long pfn)
{
	if (xen_feature(XENFEAT_auto_translated_physmap))
	if (!xen_pv_domain())
		return 1;

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

	pfn = mfn_to_pfn_no_overrides(mfn);
@@ -242,7 +242,7 @@ static inline xpaddr_t machine_to_phys(xmaddr_t machine)
/* Pseudo-physical <-> Guest conversion */
static inline unsigned long pfn_to_gfn(unsigned long pfn)
{
	if (xen_feature(XENFEAT_auto_translated_physmap))
	if (!xen_pv_domain())
		return pfn;
	else
		return pfn_to_mfn(pfn);
@@ -250,7 +250,7 @@ static inline unsigned long pfn_to_gfn(unsigned long pfn)

static inline unsigned long gfn_to_pfn(unsigned long gfn)
{
	if (xen_feature(XENFEAT_auto_translated_physmap))
	if (!xen_pv_domain())
		return gfn;
	else
		return mfn_to_pfn(gfn);
@@ -284,7 +284,7 @@ static inline unsigned long bfn_to_local_pfn(unsigned long mfn)
{
	unsigned long pfn;

	if (xen_feature(XENFEAT_auto_translated_physmap))
	if (!xen_pv_domain())
		return mfn;

	pfn = mfn_to_pfn(mfn);
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ EXPORT_SYMBOL_GPL(arbitrary_virt_to_machine);
int xen_unmap_domain_gfn_range(struct vm_area_struct *vma,
			       int nr, struct page **pages)
{
	if (xen_feature(XENFEAT_auto_translated_physmap))
	if (!xen_pv_domain())
		return xen_xlate_unmap_gfn_range(vma, nr, pages);

	if (!pages)
+2 −2
Original line number Diff line number Diff line
@@ -686,7 +686,7 @@ int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops,
	int i, ret = 0;
	pte_t *pte;

	if (xen_feature(XENFEAT_auto_translated_physmap))
	if (!xen_pv_domain())
		return 0;

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

	if (xen_feature(XENFEAT_auto_translated_physmap))
	if (!xen_pv_domain())
		return 0;

	for (i = 0; i < count; i++) {
+2 −2
Original line number Diff line number Diff line
@@ -302,7 +302,7 @@ static enum bp_state reserve_additional_memory(void)
         * are not restored since this region is now known not to
         * conflict with any devices.
         */ 
	if (!xen_feature(XENFEAT_auto_translated_physmap)) {
	if (xen_pv_domain()) {
		unsigned long pfn, i;

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

			if (!xen_feature(XENFEAT_auto_translated_physmap)) {
			if (xen_pv_domain()) {
				ret = xen_alloc_p2m_entry(page_to_pfn(page));
				if (ret < 0)
					goto out_undo;
+1 −1
Original line number Diff line number Diff line
@@ -1183,7 +1183,7 @@ static int __init gntdev_init(void)
	if (!xen_domain())
		return -ENODEV;

	use_ptemod = !xen_feature(XENFEAT_auto_translated_physmap);
	use_ptemod = xen_pv_domain();

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