From: Julien Grall <julien.grall@linaro.org>
To: xen-devel@lists.xen.org
Cc: Elena Ufimtseva <elena.ufimtseva@oracle.com>,
George Dunlap <george.dunlap@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Julien Grall <julien.grall@linaro.org>, Tim Deegan <tim@xen.org>,
Jan Beulich <jbeulich@suse.com>
Subject: [PATCH v2 4/9] xen/x86: Use maddr_to_page and maddr_to_mfn to avoid open-coded >> PAGE_SHIFT
Date: Thu, 5 Oct 2017 18:42:17 +0100 [thread overview]
Message-ID: <20171005174222.29161-5-julien.grall@linaro.org> (raw)
In-Reply-To: <20171005174222.29161-1-julien.grall@linaro.org>
The constructions _mfn(... > PAGE_SHIFT) and mfn_to_page(... >> PAGE_SHIFT)
could respectively be replaced by maddr_to_mfn(...) and
maddr_to_page(...).
Signed-off-by: Julien Grall <julien.grall@linaro.org>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
Cc: Elena Ufimtseva <elena.ufimtseva@oracle.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Tim Deegan <tim@xen.org>
Cc: George Dunlap <george.dunlap@eu.citrix.com>
Changes in v2:
- Add Andrew's reviewed-by
---
xen/arch/x86/debug.c | 2 +-
xen/arch/x86/mm/shadow/common.c | 2 +-
xen/arch/x86/mm/shadow/multi.c | 6 +++---
xen/common/kimage.c | 6 +++---
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/xen/arch/x86/debug.c b/xen/arch/x86/debug.c
index 1c10b84a16..9159f32db4 100644
--- a/xen/arch/x86/debug.c
+++ b/xen/arch/x86/debug.c
@@ -98,7 +98,7 @@ dbg_pv_va2mfn(dbgva_t vaddr, struct domain *dp, uint64_t pgd3val)
l2_pgentry_t l2e, *l2t;
l1_pgentry_t l1e, *l1t;
unsigned long cr3 = (pgd3val ? pgd3val : dp->vcpu[0]->arch.cr3);
- mfn_t mfn = _mfn(cr3 >> PAGE_SHIFT);
+ mfn_t mfn = maddr_to_mfn(cr3);
DBGP2("vaddr:%lx domid:%d cr3:%lx pgd3:%lx\n", vaddr, dp->domain_id,
cr3, pgd3val);
diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c
index 86186cccdf..f65d2a6523 100644
--- a/xen/arch/x86/mm/shadow/common.c
+++ b/xen/arch/x86/mm/shadow/common.c
@@ -2640,7 +2640,7 @@ static int sh_remove_shadow_via_pointer(struct domain *d, mfn_t smfn)
ASSERT(sh_type_has_up_pointer(d, sp->u.sh.type));
if (sp->up == 0) return 0;
- pmfn = _mfn(sp->up >> PAGE_SHIFT);
+ pmfn = maddr_to_mfn(sp->up);
ASSERT(mfn_valid(pmfn));
vaddr = map_domain_page(pmfn);
ASSERT(vaddr);
diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c
index 28030acbf6..1e42e1d8ab 100644
--- a/xen/arch/x86/mm/shadow/multi.c
+++ b/xen/arch/x86/mm/shadow/multi.c
@@ -2425,7 +2425,7 @@ int sh_safe_not_to_sync(struct vcpu *v, mfn_t gl1mfn)
sp = mfn_to_page(smfn);
if ( sp->u.sh.count != 1 || !sp->up )
return 0;
- smfn = _mfn(sp->up >> PAGE_SHIFT);
+ smfn = maddr_to_mfn(sp->up);
ASSERT(mfn_valid(smfn));
#if (SHADOW_PAGING_LEVELS == 4)
@@ -2434,7 +2434,7 @@ int sh_safe_not_to_sync(struct vcpu *v, mfn_t gl1mfn)
ASSERT(sh_type_has_up_pointer(d, SH_type_l2_shadow));
if ( sp->u.sh.count != 1 || !sp->up )
return 0;
- smfn = _mfn(sp->up >> PAGE_SHIFT);
+ smfn = maddr_to_mfn(sp->up);
ASSERT(mfn_valid(smfn));
/* up to l4 */
@@ -2442,7 +2442,7 @@ int sh_safe_not_to_sync(struct vcpu *v, mfn_t gl1mfn)
if ( sp->u.sh.count != 1
|| !sh_type_has_up_pointer(d, SH_type_l3_64_shadow) || !sp->up )
return 0;
- smfn = _mfn(sp->up >> PAGE_SHIFT);
+ smfn = maddr_to_mfn(sp->up);
ASSERT(mfn_valid(smfn));
#endif
diff --git a/xen/common/kimage.c b/xen/common/kimage.c
index cf624d10fd..ebc71affd1 100644
--- a/xen/common/kimage.c
+++ b/xen/common/kimage.c
@@ -504,7 +504,7 @@ static void kimage_free_entry(kimage_entry_t entry)
{
struct page_info *page;
- page = mfn_to_page(entry >> PAGE_SHIFT);
+ page = maddr_to_page(entry);
free_domheap_page(page);
}
@@ -636,8 +636,8 @@ static struct page_info *kimage_alloc_page(struct kexec_image *image,
if ( old )
{
/* If so move it. */
- mfn_t old_mfn = _mfn(*old >> PAGE_SHIFT);
- mfn_t mfn = _mfn(addr >> PAGE_SHIFT);
+ mfn_t old_mfn = maddr_to_mfn(*old);
+ mfn_t mfn = maddr_to_mfn(addr);
copy_domain_page(mfn, old_mfn);
clear_domain_page(old_mfn);
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-10-05 17:42 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-05 17:42 [PATCH v2 0/9] xen: Convert __page_to_mfn and __mfn_to_page to use typesafe MFN Julien Grall
2017-10-05 17:42 ` [PATCH v2 1/9] xen/arm: domain_build: Clean-up insert_11_bank Julien Grall
2017-10-05 17:42 ` [PATCH v2 2/9] xen/arm32: mm: Rework is_xen_heap_page to avoid nameclash Julien Grall
2017-10-05 17:42 ` [PATCH v2 3/9] xen/x86: mem_sharing: Use copy_domain_page in __mem_sharing_unshare_page Julien Grall
2017-10-05 17:49 ` Andrew Cooper
2017-10-05 17:52 ` Tamas K Lengyel
2017-10-05 17:42 ` Julien Grall [this message]
2017-10-05 17:42 ` [PATCH v2 5/9] xen/kimage: Remove defined but unused variables Julien Grall
2017-10-05 17:42 ` [PATCH v2 6/9] xen/kexec, kimage: Convert kexec and kimage to use typesafe mfn_t Julien Grall
2017-10-05 17:51 ` Andrew Cooper
2017-10-05 17:42 ` [PATCH v2 7/9] xen/xenoprof: Convert the file to use typesafe MFN Julien Grall
2017-10-05 17:42 ` [PATCH v2 8/9] xen/tmem: Convert the file common/tmem_xen.c " Julien Grall
2017-10-05 17:42 ` [PATCH v2 9/9] xen: Convert __page_to_mfn and __mfn_to_page " Julien Grall
2017-10-05 17:59 ` Andrew Cooper
2017-10-05 18:31 ` Razvan Cojocaru
2017-10-06 9:11 ` Paul Durrant
2017-10-06 10:49 ` Julien Grall
2017-10-06 10:55 ` Paul Durrant
2017-10-06 11:00 ` Julien Grall
2017-10-06 11:44 ` Paul Durrant
2017-10-06 13:02 ` Boris Ostrovsky
2017-10-09 11:42 ` Jan Beulich
2017-10-09 12:20 ` Julien Grall
2017-10-09 13:40 ` Jan Beulich
2017-10-09 13:48 ` Julien Grall
2017-10-09 14:07 ` Jan Beulich
2017-10-10 5:18 ` Tian, Kevin
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=20171005174222.29161-5-julien.grall@linaro.org \
--to=julien.grall@linaro.org \
--cc=andrew.cooper3@citrix.com \
--cc=elena.ufimtseva@oracle.com \
--cc=george.dunlap@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=tim@xen.org \
--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).