From: Julien Grall <julien.grall@arm.com>
To: xen-devel@lists.xenproject.org
Cc: "Stefano Stabellini" <sstabellini@kernel.org>,
"Wei Liu" <wl@xen.org>,
"Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>,
"George Dunlap" <George.Dunlap@eu.citrix.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Ian Jackson" <ian.jackson@eu.citrix.com>,
"George Dunlap" <george.dunlap@citrix.com>,
"Tim Deegan" <tim@xen.org>, "Julien Grall" <julien.grall@arm.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [Xen-devel] [PATCH v3 06/14] xen: Convert is_xen_heap_mfn to use typesafe MFN
Date: Mon, 3 Jun 2019 17:03:42 +0100 [thread overview]
Message-ID: <20190603160350.29806-7-julien.grall@arm.com> (raw)
Message-ID: <20190603160342.oGKje5UHUXHBixtBl8oLu7mC4IKnDOz83af7ij5MW0g@z> (raw)
In-Reply-To: <20190603160350.29806-1-julien.grall@arm.com>
No functional changes.
Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
---
Changes in v3:
- Add George's reviewed-by
Changes in v2:
- Fix coding style
- Merge the declaration for gpfn and old_gpfn
- Don't open-code mfn_valid
- Add Jan's reviewed-by
- Use mfn_add(mfn, -1)
- Add Stefano's acked-by for ARM parts
---
xen/arch/x86/mm.c | 10 +++++-----
xen/arch/x86/mm/p2m.c | 2 +-
xen/arch/x86/mm/shadow/multi.c | 2 +-
xen/common/page_alloc.c | 4 ++--
xen/include/asm-arm/mm.h | 8 ++++----
xen/include/asm-x86/mm.h | 2 +-
6 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 2f620d9aeb..3d3d8bd7a8 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -4458,8 +4458,8 @@ int xenmem_add_to_physmap_one(
gfn_t gpfn)
{
struct page_info *page = NULL;
- unsigned long gfn = 0; /* gcc ... */
- unsigned long prev_mfn, old_gpfn;
+ unsigned long gfn = 0 /* gcc ... */, old_gpfn;
+ mfn_t prev_mfn;
int rc = 0;
mfn_t mfn = INVALID_MFN;
p2m_type_t p2mt;
@@ -4505,12 +4505,12 @@ int xenmem_add_to_physmap_one(
}
/* Remove previously mapped page if it was present. */
- prev_mfn = mfn_x(get_gfn(d, gfn_x(gpfn), &p2mt));
- if ( mfn_valid(_mfn(prev_mfn)) )
+ prev_mfn = get_gfn(d, gfn_x(gpfn), &p2mt);
+ if ( mfn_valid(prev_mfn) )
{
if ( is_xen_heap_mfn(prev_mfn) )
/* Xen heap frames are simply unhooked from this phys slot. */
- rc = guest_physmap_remove_page(d, gpfn, _mfn(prev_mfn), PAGE_ORDER_4K);
+ rc = guest_physmap_remove_page(d, gpfn, prev_mfn, PAGE_ORDER_4K);
else
/* Normal domain memory is freed, to avoid leaking memory. */
rc = guest_remove_page(d, gfn_x(gpfn));
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index 279278715e..e03f0ae630 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -2970,7 +2970,7 @@ int p2m_add_foreign(struct domain *tdom, unsigned long fgfn,
prev_mfn = get_gfn(tdom, gpfn, &p2mt_prev);
if ( mfn_valid(prev_mfn) )
{
- if ( is_xen_heap_mfn(mfn_x(prev_mfn)) )
+ if ( is_xen_heap_mfn(prev_mfn) )
/* Xen heap frames are simply unhooked from this phys slot */
rc = guest_physmap_remove_page(tdom, _gfn(gpfn), prev_mfn, 0);
else
diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c
index 74681ba85c..26798b317c 100644
--- a/xen/arch/x86/mm/shadow/multi.c
+++ b/xen/arch/x86/mm/shadow/multi.c
@@ -559,7 +559,7 @@ _sh_propagate(struct vcpu *v,
* caching attributes in the shadows to match what was asked for.
*/
if ( (level == 1) && is_hvm_domain(d) &&
- !is_xen_heap_mfn(mfn_x(target_mfn)) )
+ !is_xen_heap_mfn(target_mfn) )
{
int type;
diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
index 71e24dbb2d..04c9dc0c65 100644
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -2104,9 +2104,9 @@ void init_xenheap_pages(paddr_t ps, paddr_t pe)
* Yuk! Ensure there is a one-page buffer between Xen and Dom zones, to
* prevent merging of power-of-two blocks across the zone boundary.
*/
- if ( ps && !is_xen_heap_mfn(paddr_to_pfn(ps)-1) )
+ if ( ps && !is_xen_heap_mfn(mfn_add(maddr_to_mfn(ps), -1)) )
ps += PAGE_SIZE;
- if ( !is_xen_heap_mfn(paddr_to_pfn(pe)) )
+ if ( !is_xen_heap_mfn(maddr_to_mfn(pe)) )
pe -= PAGE_SIZE;
memguard_guard_range(maddr_to_virt(ps), pe - ps);
diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h
index b56018aace..a9c8352b94 100644
--- a/xen/include/asm-arm/mm.h
+++ b/xen/include/asm-arm/mm.h
@@ -138,16 +138,16 @@ extern vaddr_t xenheap_virt_start;
#endif
#ifdef CONFIG_ARM_32
-#define is_xen_heap_page(page) is_xen_heap_mfn(mfn_x(page_to_mfn(page)))
+#define is_xen_heap_page(page) is_xen_heap_mfn(page_to_mfn(page))
#define is_xen_heap_mfn(mfn) ({ \
- unsigned long mfn_ = (mfn); \
+ unsigned long mfn_ = mfn_x(mfn); \
(mfn_ >= mfn_x(xenheap_mfn_start) && \
mfn_ < mfn_x(xenheap_mfn_end)); \
})
#else
#define is_xen_heap_page(page) ((page)->count_info & PGC_xen_heap)
#define is_xen_heap_mfn(mfn) \
- (mfn_valid(_mfn(mfn)) && is_xen_heap_page(mfn_to_page(_mfn(mfn))))
+ (mfn_valid(mfn) && is_xen_heap_page(mfn_to_page(mfn)))
#endif
#define is_xen_fixed_mfn(mfn) \
@@ -246,7 +246,7 @@ static inline paddr_t __virt_to_maddr(vaddr_t va)
#ifdef CONFIG_ARM_32
static inline void *maddr_to_virt(paddr_t ma)
{
- ASSERT(is_xen_heap_mfn(ma >> PAGE_SHIFT));
+ ASSERT(is_xen_heap_mfn(maddr_to_mfn(ma)));
ma -= mfn_to_maddr(xenheap_mfn_start);
return (void *)(unsigned long) ma + XENHEAP_VIRT_START;
}
diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h
index 0d954e1bd8..e420d88137 100644
--- a/xen/include/asm-x86/mm.h
+++ b/xen/include/asm-x86/mm.h
@@ -278,7 +278,7 @@ struct page_info
#define is_xen_heap_page(page) ((page)->count_info & PGC_xen_heap)
#define is_xen_heap_mfn(mfn) \
- (__mfn_valid(mfn) && is_xen_heap_page(mfn_to_page(_mfn(mfn))))
+ (mfn_valid(mfn) && is_xen_heap_page(mfn_to_page(mfn)))
#define is_xen_fixed_mfn(mfn) \
(((mfn_to_maddr(mfn)) >= __pa(&_stext)) && \
((mfn_to_maddr(mfn)) <= __pa(&__2M_rwdata_end)))
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-06-03 16:04 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-03 16:03 [PATCH v3 00/14] xen/arm: Properly disable M2P on Arm Julien Grall
2019-06-03 16:03 ` [Xen-devel] " Julien Grall
2019-06-03 16:03 ` [PATCH v3 01/14] xen/x86: Make mfn_to_gfn typesafe Julien Grall
2019-06-03 16:03 ` [Xen-devel] " Julien Grall
2019-06-04 16:06 ` Jan Beulich
2019-07-29 12:13 ` Julien Grall
2019-08-19 13:50 ` George Dunlap
2019-06-03 16:03 ` [PATCH v3 02/14] xen/x86: Use mfn_to_gfn rather than mfn_to_gmfn Julien Grall
2019-06-03 16:03 ` [Xen-devel] " Julien Grall
2019-06-03 16:03 ` [PATCH v3 03/14] xen/grant-table: Make arch specific macros typesafe Julien Grall
2019-06-03 16:03 ` [Xen-devel] " Julien Grall
2019-06-03 16:03 ` [PATCH v3 04/14] xen: Convert hotplug page function to use typesafe MFN Julien Grall
2019-06-03 16:03 ` [Xen-devel] " Julien Grall
2019-06-03 16:03 ` [PATCH v3 05/14] xen: Convert is_xen_fixed_mfn " Julien Grall
2019-06-03 16:03 ` [Xen-devel] " Julien Grall
2019-06-03 16:03 ` Julien Grall [this message]
2019-06-03 16:03 ` [Xen-devel] [PATCH v3 06/14] xen: Convert is_xen_heap_mfn " Julien Grall
2019-06-03 16:03 ` [PATCH v3 07/14] xen: Introduce HAS_M2P config and use to protect mfn_to_gmfn call Julien Grall
2019-06-03 16:03 ` [Xen-devel] " Julien Grall
2019-06-04 16:14 ` Jan Beulich
2019-06-04 16:22 ` Julien Grall
2019-06-05 7:14 ` Jan Beulich
2019-06-05 9:35 ` Julien Grall
2019-06-05 10:10 ` Jan Beulich
2019-07-29 12:08 ` Julien Grall
2019-06-03 16:03 ` [PATCH v3 08/14] xen: Remove mfn_to_gmfn macro Julien Grall
2019-06-03 16:03 ` [Xen-devel] " Julien Grall
2019-06-03 16:03 ` [PATCH v3 09/14] xen/x86: mm: Re-implement set_gpfn_from_mfn() as a static inline function Julien Grall
2019-06-03 16:03 ` [Xen-devel] " Julien Grall
2019-06-04 16:21 ` Jan Beulich
2019-06-04 16:23 ` Julien Grall
2019-06-05 7:18 ` Jan Beulich
2019-06-03 16:03 ` [PATCH v3 10/14] xen/x86: pv: Convert update_intpte() to use typesafe MFN Julien Grall
2019-06-03 16:03 ` [Xen-devel] " Julien Grall
2019-06-03 16:03 ` [PATCH v3 11/14] xen/x86: p2m: Remove duplicate error message in p2m_pt_audit_p2m() Julien Grall
2019-06-03 16:03 ` [Xen-devel] " Julien Grall
2019-06-05 10:43 ` Jan Beulich
2019-06-05 10:44 ` Julien Grall
2019-06-03 16:03 ` [PATCH v3 12/14] xen/x86: p2m: Rework printk format in audit_p2m() Julien Grall
2019-06-03 16:03 ` [Xen-devel] " Julien Grall
2019-06-03 16:03 ` [PATCH v3 13/14] xen/mm: Convert {s, g}et_gpfn_from_mfn() to use typesafe MFN Julien Grall
2019-06-03 16:03 ` [Xen-devel] " Julien Grall
2019-06-05 11:01 ` Jan Beulich
2019-06-05 11:03 ` Julien Grall
2019-06-03 16:03 ` [PATCH v3 14/14] xen/mm: Provide dummy M2P-related helpers when !CONFIG_HAVE_M2P Julien Grall
2019-06-03 16:03 ` [Xen-devel] " Julien Grall
2019-06-05 11:07 ` Jan Beulich
2019-06-05 11:17 ` Julien Grall
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=20190603160350.29806-7-julien.grall@arm.com \
--to=julien.grall@arm.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=konrad.wilk@oracle.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=tim@xen.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.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).