From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Wei Liu <wei.liu2@citrix.com>, Jan Beulich <JBeulich@suse.com>,
Tim Deegan <tim@xen.org>
Subject: [PATCH 1/3] x86/mm: Replace opencoded forms of l?e_{get, from}_page()
Date: Thu, 24 Aug 2017 14:14:55 +0100 [thread overview]
Message-ID: <1503580497-22936-2-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1503580497-22936-1-git-send-email-andrew.cooper3@citrix.com>
No functional change (confirmed by diffing the disassembly).
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Tim Deegan <tim@xen.org>
CC: George Dunlap <george.dunlap@eu.citrix.com>
---
xen/arch/x86/mm.c | 7 +++----
xen/arch/x86/mm/hap/hap.c | 3 +--
xen/arch/x86/mm/p2m-pt.c | 11 ++++-------
3 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index ed77270..e6b7829 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -692,8 +692,7 @@ int map_ldt_shadow_page(unsigned int off)
return 0;
}
- nl1e = l1e_from_pfn(mfn_x(page_to_mfn(page)),
- l1e_get_flags(l1e) | _PAGE_RW);
+ nl1e = l1e_from_page(page, l1e_get_flags(l1e) | _PAGE_RW);
spin_lock(&v->arch.pv_vcpu.shadow_ldt_lock);
l1e_write(&gdt_ldt_ptes(d, v)[off + 16], nl1e);
@@ -1315,7 +1314,7 @@ static int put_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn)
if ( l2e_get_flags(l2e) & _PAGE_PSE )
{
- struct page_info *page = mfn_to_page(_mfn(l2e_get_pfn(l2e)));
+ struct page_info *page = l2e_get_page(l2e);
unsigned int i;
for ( i = 0; i < (1u << PAGETABLE_ORDER); i++, page++ )
@@ -1944,7 +1943,7 @@ static int mod_l1_entry(l1_pgentry_t *pl1e, l1_pgentry_t nl1e,
page = get_page_from_gfn(pg_dom, l1e_get_pfn(nl1e), NULL, P2M_ALLOC);
if ( !page )
return -EINVAL;
- nl1e = l1e_from_pfn(mfn_x(page_to_mfn(page)), l1e_get_flags(nl1e));
+ nl1e = l1e_from_page(page, l1e_get_flags(nl1e));
}
/* Fast path for sufficiently-similar mappings. */
diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c
index cdc77a9..027ab8f 100644
--- a/xen/arch/x86/mm/hap/hap.c
+++ b/xen/arch/x86/mm/hap/hap.c
@@ -405,8 +405,7 @@ static void hap_install_xen_entries_in_l4(struct vcpu *v, mfn_t l4mfn)
/* Install the per-domain mappings for this domain */
l4e[l4_table_offset(PERDOMAIN_VIRT_START)] =
- l4e_from_pfn(mfn_x(page_to_mfn(d->arch.perdomain_l3_pg)),
- __PAGE_HYPERVISOR_RW);
+ l4e_from_page(d->arch.perdomain_l3_pg, __PAGE_HYPERVISOR_RW);
/* Install a linear mapping */
l4e[l4_table_offset(LINEAR_PT_VIRT_START)] =
diff --git a/xen/arch/x86/mm/p2m-pt.c b/xen/arch/x86/mm/p2m-pt.c
index 06e64b8..628a53e 100644
--- a/xen/arch/x86/mm/p2m-pt.c
+++ b/xen/arch/x86/mm/p2m-pt.c
@@ -168,7 +168,7 @@ p2m_free_entry(struct p2m_domain *p2m, l1_pgentry_t *p2m_entry, int page_order)
unmap_domain_page(l3_table);
}
- p2m_free_ptp(p2m, mfn_to_page(_mfn(l1e_get_pfn(*p2m_entry))));
+ p2m_free_ptp(p2m, l1e_get_page(*p2m_entry));
}
// Walk one level of the P2M table, allocating a new table if required.
@@ -210,8 +210,7 @@ p2m_next_level(struct p2m_domain *p2m, void **table,
if ( pg == NULL )
return -ENOMEM;
- new_entry = l1e_from_pfn(mfn_x(page_to_mfn(pg)),
- P2M_BASE_FLAGS | _PAGE_RW);
+ new_entry = l1e_from_page(pg, P2M_BASE_FLAGS | _PAGE_RW);
switch ( type ) {
case PGT_l3_page_table:
@@ -255,8 +254,7 @@ p2m_next_level(struct p2m_domain *p2m, void **table,
p2m->write_p2m_entry(p2m, gfn, l1_entry + i, new_entry, 2);
}
unmap_domain_page(l1_entry);
- new_entry = l1e_from_pfn(mfn_x(page_to_mfn(pg)),
- P2M_BASE_FLAGS | _PAGE_RW); /* disable PSE */
+ new_entry = l1e_from_page(pg, P2M_BASE_FLAGS | _PAGE_RW); /* disable PSE */
p2m_add_iommu_flags(&new_entry, 2, IOMMUF_readable|IOMMUF_writable);
p2m->write_p2m_entry(p2m, gfn, p2m_entry, new_entry, 3);
}
@@ -290,8 +288,7 @@ p2m_next_level(struct p2m_domain *p2m, void **table,
}
unmap_domain_page(l1_entry);
- new_entry = l1e_from_pfn(mfn_x(page_to_mfn(pg)),
- P2M_BASE_FLAGS | _PAGE_RW);
+ new_entry = l1e_from_page(pg, P2M_BASE_FLAGS | _PAGE_RW);
p2m_add_iommu_flags(&new_entry, 1, IOMMUF_readable|IOMMUF_writable);
p2m->write_p2m_entry(p2m, gfn, p2m_entry, new_entry, 2);
}
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-08-24 13:14 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-24 13:14 [PATCH 0/3] x86/mm: Nonfunctional code hygene improvements Andrew Cooper
2017-08-24 13:14 ` Andrew Cooper [this message]
2017-08-24 13:26 ` [PATCH 1/3] x86/mm: Replace opencoded forms of l?e_{get, from}_page() Jan Beulich
2017-08-24 14:19 ` Wei Liu
2017-08-25 14:56 ` George Dunlap
2017-08-24 13:14 ` [PATCH 2/3] x86/mm: Replace opencoded forms of map_l?t_from_l?e() Andrew Cooper
2017-08-24 13:28 ` Jan Beulich
2017-08-24 14:19 ` Wei Liu
2017-08-25 14:57 ` George Dunlap
2017-08-24 13:14 ` [PATCH 3/3] x86/mm: Introduce and use l?e_{get, from}_mfn() Andrew Cooper
2017-08-24 13:32 ` Jan Beulich
2017-08-24 13:34 ` Andrew Cooper
2017-08-24 14:17 ` Tim Deegan
2017-08-24 14:19 ` Wei Liu
2017-08-25 15:00 ` George Dunlap
2017-08-25 15:03 ` George Dunlap
2017-08-25 15:11 ` Andrew Cooper
2017-08-25 15:07 ` George Dunlap
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1503580497-22936-2-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=george.dunlap@eu.citrix.com \
--cc=tim@xen.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).