From: Julien Grall <julien.grall@arm.com>
To: xen-devel@lists.xenproject.org,
George Dunlap <george.dunlap@eu.citrix.com>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Tim Deegan" <tim@xen.org>, "Wei Liu" <wl@xen.org>,
"Jan Beulich" <jbeulich@suse.com>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [Xen-devel] [PATCH v3 01/14] xen/x86: Make mfn_to_gfn typesafe
Date: Mon, 29 Jul 2019 13:13:42 +0100 [thread overview]
Message-ID: <b2fba871-bcb7-2d08-25d1-8501964cb71d@arm.com> (raw)
In-Reply-To: <20190603160350.29806-2-julien.grall@arm.com>
Hi,
@George can I get an ack for this patch?
Cheers,
On 6/3/19 5:03 PM, Julien Grall wrote:
> No functional changes intended.
>
> Signed-off-by: Julien Grall <julien.grall@arm.com>
>
> ---
> Changes in v3:
> - Remove gfn_x(...) for gfn used in parameter of __trace_var(...).
>
> Changes in v2:
> - Patch added
> ---
> xen/arch/x86/mm/p2m.c | 2 +-
> xen/arch/x86/mm/shadow/common.c | 31 ++++++++++++++++++-------------
> xen/arch/x86/mm/shadow/multi.c | 4 ++--
> xen/include/asm-x86/p2m.h | 6 +++---
> 4 files changed, 24 insertions(+), 19 deletions(-)
>
> diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
> index 4c9954867c..279278715e 100644
> --- a/xen/arch/x86/mm/p2m.c
> +++ b/xen/arch/x86/mm/p2m.c
> @@ -951,7 +951,7 @@ guest_physmap_add_entry(struct domain *d, gfn_t gfn, mfn_t mfn,
> }
> if ( page_get_owner(mfn_to_page(mfn_add(mfn, i))) != d )
> continue;
> - ogfn = _gfn(mfn_to_gfn(d, mfn_add(mfn, i)));
> + ogfn = mfn_to_gfn(d, mfn_add(mfn, i));
> if ( !gfn_eq(ogfn, _gfn(INVALID_M2P_ENTRY)) &&
> !gfn_eq(ogfn, gfn_add(gfn, i)) )
> {
> diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c
> index 795201dc82..1e67bd072a 100644
> --- a/xen/arch/x86/mm/shadow/common.c
> +++ b/xen/arch/x86/mm/shadow/common.c
> @@ -474,7 +474,8 @@ static inline void trace_resync(int event, mfn_t gmfn)
> if ( tb_init_done )
> {
> /* Convert gmfn to gfn */
> - unsigned long gfn = mfn_to_gfn(current->domain, gmfn);
> + gfn_t gfn = mfn_to_gfn(current->domain, gmfn);
> +
> __trace_var(event, 0/*!tsc*/, sizeof(gfn), &gfn);
> }
> }
> @@ -985,7 +986,8 @@ static inline void trace_shadow_prealloc_unpin(struct domain *d, mfn_t smfn)
> if ( tb_init_done )
> {
> /* Convert smfn to gfn */
> - unsigned long gfn;
> + gfn_t gfn;
> +
> ASSERT(mfn_valid(smfn));
> gfn = mfn_to_gfn(d, backpointer(mfn_to_page(smfn)));
> __trace_var(TRC_SHADOW_PREALLOC_UNPIN, 0/*!tsc*/, sizeof(gfn), &gfn);
> @@ -1861,7 +1863,8 @@ static inline void trace_shadow_wrmap_bf(mfn_t gmfn)
> if ( tb_init_done )
> {
> /* Convert gmfn to gfn */
> - unsigned long gfn = mfn_to_gfn(current->domain, gmfn);
> + gfn_t gfn = mfn_to_gfn(current->domain, gmfn);
> +
> __trace_var(TRC_SHADOW_WRMAP_BF, 0/*!tsc*/, sizeof(gfn), &gfn);
> }
> }
> @@ -1946,7 +1949,7 @@ int sh_remove_write_access(struct domain *d, mfn_t gmfn,
> #if SHADOW_OPTIMIZATIONS & SHOPT_WRITABLE_HEURISTIC
> if ( curr->domain == d )
> {
> - unsigned long gfn;
> + gfn_t gfn;
> /* Heuristic: there is likely to be only one writeable mapping,
> * and that mapping is likely to be in the current pagetable,
> * in the guest's linear map (on non-HIGHPTE linux and windows)*/
> @@ -1969,8 +1972,9 @@ int sh_remove_write_access(struct domain *d, mfn_t gmfn,
> GUESS(0xC0000000UL + (fault_addr >> 10), 1);
>
> /* Linux lowmem: first 896MB is mapped 1-to-1 above 0xC0000000 */
> - if ((gfn = mfn_to_gfn(d, gmfn)) < 0x38000 )
> - GUESS(0xC0000000UL + (gfn << PAGE_SHIFT), 4);
> + gfn = mfn_to_gfn(d, gmfn);
> + if ( gfn_x(gfn) < 0x38000 )
> + GUESS(0xC0000000UL + gfn_to_gaddr(gfn), 4);
>
> /* FreeBSD: Linear map at 0xBFC00000 */
> if ( level == 1 )
> @@ -1987,8 +1991,9 @@ int sh_remove_write_access(struct domain *d, mfn_t gmfn,
> }
>
> /* Linux lowmem: first 896MB is mapped 1-to-1 above 0xC0000000 */
> - if ((gfn = mfn_to_gfn(d, gmfn)) < 0x38000 )
> - GUESS(0xC0000000UL + (gfn << PAGE_SHIFT), 4);
> + gfn = mfn_to_gfn(d, gmfn);
> + if ( gfn_x(gfn) < 0x38000 )
> + GUESS(0xC0000000UL + gfn_to_gaddr(gfn), 4);
>
> /* FreeBSD PAE: Linear map at 0xBF800000 */
> switch ( level )
> @@ -2016,15 +2021,15 @@ int sh_remove_write_access(struct domain *d, mfn_t gmfn,
> * had it at 0xffff810000000000, and older kernels yet had it
> * at 0x0000010000000000UL */
> gfn = mfn_to_gfn(d, gmfn);
> - GUESS(0xffff880000000000UL + (gfn << PAGE_SHIFT), 4);
> - GUESS(0xffff810000000000UL + (gfn << PAGE_SHIFT), 4);
> - GUESS(0x0000010000000000UL + (gfn << PAGE_SHIFT), 4);
> + GUESS(0xffff880000000000UL + gfn_to_gaddr(gfn), 4);
> + GUESS(0xffff810000000000UL + gfn_to_gaddr(gfn), 4);
> + GUESS(0x0000010000000000UL + gfn_to_gaddr(gfn), 4);
>
> /*
> * 64bit Solaris kernel page map at
> * kpm_vbase; 0xfffffe0000000000UL
> */
> - GUESS(0xfffffe0000000000UL + (gfn << PAGE_SHIFT), 4);
> + GUESS(0xfffffe0000000000UL + gfn_to_gaddr(gfn), 4);
>
> /* FreeBSD 64bit: linear map 0xffff800000000000 */
> switch ( level )
> @@ -2037,7 +2042,7 @@ int sh_remove_write_access(struct domain *d, mfn_t gmfn,
> + ((fault_addr & VADDR_MASK) >> 27), 6); break;
> }
> /* FreeBSD 64bit: direct map at 0xffffff0000000000 */
> - GUESS(0xffffff0000000000 + (gfn << PAGE_SHIFT), 6);
> + GUESS(0xffffff0000000000 + gfn_to_gaddr(gfn), 6);
> }
>
> #undef GUESS
> diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c
> index 5f8a745de2..74681ba85c 100644
> --- a/xen/arch/x86/mm/shadow/multi.c
> +++ b/xen/arch/x86/mm/shadow/multi.c
> @@ -1076,7 +1076,7 @@ static inline void shadow_vram_get_l1e(shadow_l1e_t new_sl1e,
> || !mfn_valid(mfn) ) /* mfn can be invalid in mmio_direct */
> return;
>
> - gfn = mfn_to_gfn(d, mfn);
> + gfn = gfn_x(mfn_to_gfn(d, mfn));
> /* Page sharing not supported on shadow PTs */
> BUG_ON(SHARED_M2P(gfn));
>
> @@ -1107,7 +1107,7 @@ static inline void shadow_vram_put_l1e(shadow_l1e_t old_sl1e,
> || !mfn_valid(mfn) ) /* mfn can be invalid in mmio_direct */
> return;
>
> - gfn = mfn_to_gfn(d, mfn);
> + gfn = gfn_x(mfn_to_gfn(d, mfn));
> /* Page sharing not supported on shadow PTs */
> BUG_ON(SHARED_M2P(gfn));
>
> diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
> index 09ef7e02fd..1a075547e2 100644
> --- a/xen/include/asm-x86/p2m.h
> +++ b/xen/include/asm-x86/p2m.h
> @@ -506,12 +506,12 @@ static inline struct page_info *get_page_from_gfn(
> }
>
> /* General conversion function from mfn to gfn */
> -static inline unsigned long mfn_to_gfn(const struct domain *d, mfn_t mfn)
> +static inline gfn_t mfn_to_gfn(const struct domain *d, mfn_t mfn)
> {
> if ( paging_mode_translate(d) )
> - return get_gpfn_from_mfn(mfn_x(mfn));
> + return _gfn(get_gpfn_from_mfn(mfn_x(mfn)));
> else
> - return mfn_x(mfn);
> + return _gfn(mfn_x(mfn));
> }
>
> #ifdef CONFIG_HVM
>
--
Julien Grall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-07-29 12:14 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 [this message]
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 ` [PATCH v3 06/14] xen: Convert is_xen_heap_mfn " Julien Grall
2019-06-03 16:03 ` [Xen-devel] " 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=b2fba871-bcb7-2d08-25d1-8501964cb71d@arm.com \
--to=julien.grall@arm.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=roger.pau@citrix.com \
--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).