Re: [Xen-devel] [PATCH v4 16/16] xen: Convert page_to_mfn and mfn_to_page to use typesafe MFN
>>> On 14.03.18 at 18:02,wrote: > On 03/02/2018 04:08 PM, Jan Beulich wrote: > On 21.02.18 at 15:02, wrote: >>> --- a/xen/arch/x86/pv/emul-priv-op.c >>> +++ b/xen/arch/x86/pv/emul-priv-op.c >>> @@ -43,16 +43,6 @@ >>> #include "emulate.h" >>> #include "mm.h" >>> >>> -/* Override macros from asm/page.h to make them work with mfn_t */ >>> -#undef mfn_to_page >>> -#define mfn_to_page(mfn) __mfn_to_page(mfn_x(mfn)) >>> -#undef page_to_mfn >>> -#define page_to_mfn(pg) _mfn(__page_to_mfn(pg)) >>> - >>> -/*** >>> - * I/O emulation support >>> - */ >> >> Why does this comment go away? > > From an earlier review, Andrew said: > > "If you're making this change, please take out the Descriptor Tables > comment like you do with I/O below, because the entire file is dedicated > to descriptor table support and it will save me one item on a cleanup > patch :)." Well, the reasoning isn't really correct, but I agree the comment is at least misplaced. Hence I'm fine with it being dropped, despite it being very unrelated to the purpose of the patch. IOW my ack stands with this one remark un-addressed. Jan ___ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v4 16/16] xen: Convert page_to_mfn and mfn_to_page to use typesafe MFN
Hi Jan, On 03/02/2018 04:08 PM, Jan Beulich wrote: On 21.02.18 at 15:02,wrote: --- a/xen/arch/x86/pv/emul-priv-op.c +++ b/xen/arch/x86/pv/emul-priv-op.c @@ -43,16 +43,6 @@ #include "emulate.h" #include "mm.h" -/* Override macros from asm/page.h to make them work with mfn_t */ -#undef mfn_to_page -#define mfn_to_page(mfn) __mfn_to_page(mfn_x(mfn)) -#undef page_to_mfn -#define page_to_mfn(pg) _mfn(__page_to_mfn(pg)) - -/*** - * I/O emulation support - */ Why does this comment go away? From an earlier review, Andrew said: "If you're making this change, please take out the Descriptor Tables comment like you do with I/O below, because the entire file is dedicated to descriptor table support and it will save me one item on a cleanup patch :)." The descriptor one got remove by 634afe43ac "x86/pv: Rename invalidate_shadow_ldt() to pv_destroy_ldt()". So it is not part of this patch anymore. @@ -478,10 +478,10 @@ extern paddr_t mem_hotplug; #define SHARED_M2P(_e) ((_e) == SHARED_M2P_ENTRY) #define compat_machine_to_phys_mapping ((unsigned int *)RDWR_COMPAT_MPT_VIRT_START) -#define _set_gpfn_from_mfn(mfn, pfn) ({\ -struct domain *d = page_get_owner(__mfn_to_page(mfn)); \ -unsigned long entry = (d && (d == dom_cow)) ? \ -SHARED_M2P_ENTRY : (pfn); \ +#define _set_gpfn_from_mfn(mfn, pfn) ({ \ +struct domain *d = page_get_owner(mfn_to_page(_mfn(mfn)));\ +unsigned long entry = (d && (d == dom_cow)) ? \ +SHARED_M2P_ENTRY : (pfn); \ Please don't break the alignment of the backslashes here. It also looks like three of the four lines could be left alone altogether. I am not sure why I modified the 3 other lines. I fixed it. @@ -157,10 +157,10 @@ static inline l4_pgentry_t l4e_from_paddr(paddr_t pa, unsigned int flags) #define l4e_from_intpte(intpte)((l4_pgentry_t) { (intpte_t)(intpte) }) /* Construct a pte from a page pointer and access flags. */ -#define l1e_from_page(page, flags) l1e_from_pfn(__page_to_mfn(page), (flags)) -#define l2e_from_page(page, flags) l2e_from_pfn(__page_to_mfn(page), (flags)) -#define l3e_from_page(page, flags) l3e_from_pfn(__page_to_mfn(page), (flags)) -#define l4e_from_page(page, flags) l4e_from_pfn(__page_to_mfn(page), (flags)) +#define l1e_from_page(page, flags) l1e_from_mfn(page_to_mfn(page), (flags)) +#define l2e_from_page(page, flags) l2e_from_mfn(page_to_mfn(page), (flags)) +#define l3e_from_page(page, flags) l3e_from_mfn(page_to_mfn(page), (flags)) +#define l4e_from_page(page, flags) l4e_from_mfn(page_to_mfn(page), (flags)) Would again have been nice if you got rid of the extra parentheses here at the same time. I admit, I don't spend my time trying to find the possible cleanup in the x86 code. I just do mechanical change and when I get bored I do a bit more. @@ -240,12 +240,12 @@ void copy_page_sse2(void *, const void *); #define __mfn_to_virt(mfn) (maddr_to_virt((paddr_t)(mfn) << PAGE_SHIFT)) /* Convert between machine frame numbers and page-info structures. */ -#define __mfn_to_page(mfn) (frame_table + pfn_to_pdx(mfn)) -#define __page_to_mfn(pg) pdx_to_pfn((unsigned long)((pg) - frame_table)) +#define mfn_to_page(mfn)(frame_table + mfn_to_pdx(mfn)) +#define page_to_mfn(pg) pdx_to_mfn((unsigned long)((pg) - frame_table)) /* Convert between machine addresses and page-info structures. */ -#define __maddr_to_page(ma) __mfn_to_page((ma) >> PAGE_SHIFT) -#define __page_to_maddr(pg) ((paddr_t)__page_to_mfn(pg) << PAGE_SHIFT) +#define __maddr_to_page(ma) mfn_to_page(maddr_to_mfn(ma)) +#define __page_to_maddr(pg) (mfn_to_maddr(page_to_mfn(pg))) Same here. With at least the first two items taken care of, relevant x86 pieces Acked-by: Jan Beulich I don't plan to address the first one as Andrew were happy with it. Cheers, -- Julien Grall ___ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v4 16/16] xen: Convert page_to_mfn and mfn_to_page to use typesafe MFN
>>> On 21.02.18 at 15:02,wrote: > --- a/xen/arch/x86/pv/emul-priv-op.c > +++ b/xen/arch/x86/pv/emul-priv-op.c > @@ -43,16 +43,6 @@ > #include "emulate.h" > #include "mm.h" > > -/* Override macros from asm/page.h to make them work with mfn_t */ > -#undef mfn_to_page > -#define mfn_to_page(mfn) __mfn_to_page(mfn_x(mfn)) > -#undef page_to_mfn > -#define page_to_mfn(pg) _mfn(__page_to_mfn(pg)) > - > -/*** > - * I/O emulation support > - */ Why does this comment go away? > @@ -478,10 +478,10 @@ extern paddr_t mem_hotplug; > #define SHARED_M2P(_e) ((_e) == SHARED_M2P_ENTRY) > > #define compat_machine_to_phys_mapping ((unsigned int > *)RDWR_COMPAT_MPT_VIRT_START) > -#define _set_gpfn_from_mfn(mfn, pfn) ({\ > -struct domain *d = page_get_owner(__mfn_to_page(mfn)); \ > -unsigned long entry = (d && (d == dom_cow)) ? \ > -SHARED_M2P_ENTRY : (pfn); \ > +#define _set_gpfn_from_mfn(mfn, pfn) ({ \ > +struct domain *d = page_get_owner(mfn_to_page(_mfn(mfn)));\ > +unsigned long entry = (d && (d == dom_cow)) ? \ > +SHARED_M2P_ENTRY : (pfn); \ Please don't break the alignment of the backslashes here. It also looks like three of the four lines could be left alone altogether. > @@ -157,10 +157,10 @@ static inline l4_pgentry_t l4e_from_paddr(paddr_t pa, > unsigned int flags) > #define l4e_from_intpte(intpte)((l4_pgentry_t) { (intpte_t)(intpte) }) > > /* Construct a pte from a page pointer and access flags. */ > -#define l1e_from_page(page, flags) l1e_from_pfn(__page_to_mfn(page), (flags)) > -#define l2e_from_page(page, flags) l2e_from_pfn(__page_to_mfn(page), (flags)) > -#define l3e_from_page(page, flags) l3e_from_pfn(__page_to_mfn(page), (flags)) > -#define l4e_from_page(page, flags) l4e_from_pfn(__page_to_mfn(page), (flags)) > +#define l1e_from_page(page, flags) l1e_from_mfn(page_to_mfn(page), (flags)) > +#define l2e_from_page(page, flags) l2e_from_mfn(page_to_mfn(page), (flags)) > +#define l3e_from_page(page, flags) l3e_from_mfn(page_to_mfn(page), (flags)) > +#define l4e_from_page(page, flags) l4e_from_mfn(page_to_mfn(page), (flags)) Would again have been nice if you got rid of the extra parentheses here at the same time. > @@ -240,12 +240,12 @@ void copy_page_sse2(void *, const void *); > #define __mfn_to_virt(mfn) (maddr_to_virt((paddr_t)(mfn) << PAGE_SHIFT)) > > /* Convert between machine frame numbers and page-info structures. */ > -#define __mfn_to_page(mfn) (frame_table + pfn_to_pdx(mfn)) > -#define __page_to_mfn(pg) pdx_to_pfn((unsigned long)((pg) - frame_table)) > +#define mfn_to_page(mfn)(frame_table + mfn_to_pdx(mfn)) > +#define page_to_mfn(pg) pdx_to_mfn((unsigned long)((pg) - frame_table)) > > /* Convert between machine addresses and page-info structures. */ > -#define __maddr_to_page(ma) __mfn_to_page((ma) >> PAGE_SHIFT) > -#define __page_to_maddr(pg) ((paddr_t)__page_to_mfn(pg) << PAGE_SHIFT) > +#define __maddr_to_page(ma) mfn_to_page(maddr_to_mfn(ma)) > +#define __page_to_maddr(pg) (mfn_to_maddr(page_to_mfn(pg))) Same here. With at least the first two items taken care of, relevant x86 pieces Acked-by: Jan Beulich Jan ___ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v4 16/16] xen: Convert page_to_mfn and mfn_to_page to use typesafe MFN
On Wed, Feb 21, 2018 at 02:02:59PM +, Julien Grall wrote: > Most of the users of page_to_mfn and mfn_to_page are either overriding > the macros to make them work with mfn_t or use mfn_x/_mfn because the > rest of the function use mfn_t. > > So make page_to_mfn and mfn_to_page return mfn_t by default. The __* > version are now dropped as this patch will convert all the remaining > non-typesafe callers. > > Only reasonable clean-ups are done in this patch. The rest will use > _mfn/mfn_x for the time being. > > Lastly, domain_page_to_mfn is also converted to use mfn_t given that > most of the callers are now switched to _mfn(domain_page_to_mfn(...)). > > Signed-off-by: Julien GrallReviewed-by: Wei Liu ___ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v4 16/16] xen: Convert page_to_mfn and mfn_to_page to use typesafe MFN
> From: Julien Grall [mailto:julien.gr...@arm.com] > Sent: Wednesday, February 21, 2018 10:03 PM > > Most of the users of page_to_mfn and mfn_to_page are either overriding > the macros to make them work with mfn_t or use mfn_x/_mfn because the > rest of the function use mfn_t. > > So make page_to_mfn and mfn_to_page return mfn_t by default. The __* > version are now dropped as this patch will convert all the remaining > non-typesafe callers. > > Only reasonable clean-ups are done in this patch. The rest will use > _mfn/mfn_x for the time being. > > Lastly, domain_page_to_mfn is also converted to use mfn_t given that > most of the callers are now switched to _mfn(domain_page_to_mfn(...)). > > Signed-off-by: Julien Grall> Reviewed-by: Kevin Tian ___ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v4 16/16] xen: Convert page_to_mfn and mfn_to_page to use typesafe MFN
On 02/21/2018 09:02 AM, Julien Grall wrote: > Most of the users of page_to_mfn and mfn_to_page are either overriding > the macros to make them work with mfn_t or use mfn_x/_mfn because the > rest of the function use mfn_t. > > So make page_to_mfn and mfn_to_page return mfn_t by default. The __* > version are now dropped as this patch will convert all the remaining > non-typesafe callers. > > Only reasonable clean-ups are done in this patch. The rest will use > _mfn/mfn_x for the time being. > > Lastly, domain_page_to_mfn is also converted to use mfn_t given that > most of the callers are now switched to _mfn(domain_page_to_mfn(...)). > > Signed-off-by: Julien GrallReviewed-by: Boris Ostrovsky ___ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v4 16/16] xen: Convert page_to_mfn and mfn_to_page to use typesafe MFN
> -Original Message- > From: Julien Grall [mailto:julien.gr...@arm.com] > Sent: 21 February 2018 14:03 > To: xen-de...@lists.xen.org > Cc: Julien Grall; Stefano Stabellini > ; Andrew Cooper ; > George Dunlap ; Ian Jackson > ; Jan Beulich ; Konrad > Rzeszutek Wilk ; Tim (Xen.org) ; > Wei Liu ; Razvan Cojocaru > ; Tamas K Lengyel ; > Paul Durrant ; Boris Ostrovsky > ; Suravee Suthikulpanit > ; Jun Nakajima > ; Kevin Tian ; George > Dunlap ; Gang Wei ; > Shane Wang > Subject: [PATCH v4 16/16] xen: Convert page_to_mfn and mfn_to_page to > use typesafe MFN > > Most of the users of page_to_mfn and mfn_to_page are either overriding > the macros to make them work with mfn_t or use mfn_x/_mfn because the > rest of the function use mfn_t. > > So make page_to_mfn and mfn_to_page return mfn_t by default. The __* > version are now dropped as this patch will convert all the remaining > non-typesafe callers. > > Only reasonable clean-ups are done in this patch. The rest will use > _mfn/mfn_x for the time being. > > Lastly, domain_page_to_mfn is also converted to use mfn_t given that > most of the callers are now switched to _mfn(domain_page_to_mfn(...)). > > Signed-off-by: Julien Grall Reviewed-by: Paul Durrant > > --- > > Andrew suggested to drop IS_VALID_PAGE in xen/tmem_xen.h. His > comment > was: > > "/sigh This is tautological. The definition of a "valid mfn" in this > case is one for which we have frametable entry, and by having a struct > page_info in our hands, this is by definition true (unless you have a > wild pointer, at which point your bug is elsewhere). > > IS_VALID_PAGE() is only ever used in assertions and never usefully, so > instead I would remove it entirely rather than trying to fix it up." > > I can remove the function in a separate patch at the begining of the > series if Konrad (TMEM maintainer) is happy with that. > > Cc: Stefano Stabellini > Cc: Julien Grall > Cc: Andrew Cooper > Cc: George Dunlap > Cc: Ian Jackson > Cc: Jan Beulich > Cc: Konrad Rzeszutek Wilk > Cc: Tim Deegan > Cc: Wei Liu > Cc: Razvan Cojocaru > Cc: Tamas K Lengyel > Cc: Paul Durrant > Cc: Boris Ostrovsky > Cc: Suravee Suthikulpanit > Cc: Jun Nakajima > Cc: Kevin Tian > Cc: George Dunlap > Cc: Gang Wei > Cc: Shane Wang > > Changes in v4: > - Drop __page_to_mfn and __mfn_to_page. Reword the commit > title/message to reflect that. > > Changes in v3: > - Rebase on the latest staging and fix some conflicts. Tags > haven't be retained. > - Switch the printf format to PRI_mfn > > Changes in v2: > - Some part have been moved in separate patch > - Remove one spurious comment > - Convert domain_page_to_mfn to use mfn_t > --- > xen/arch/arm/domain_build.c | 2 -- > xen/arch/arm/kernel.c | 2 +- > xen/arch/arm/mem_access.c | 2 +- > xen/arch/arm/mm.c | 8 > xen/arch/arm/p2m.c | 10 ++ > xen/arch/x86/cpu/vpmu.c | 4 ++-- > xen/arch/x86/domain.c | 21 +++-- > xen/arch/x86/domain_page.c | 6 +++--- > xen/arch/x86/hvm/dm.c | 2 +- > xen/arch/x86/hvm/dom0_build.c | 6 +++--- > xen/arch/x86/hvm/emulate.c | 6 +++--- > xen/arch/x86/hvm/hvm.c | 12 ++-- > xen/arch/x86/hvm/ioreq.c| 4 ++-- > xen/arch/x86/hvm/stdvga.c | 2 +- > xen/arch/x86/hvm/svm/svm.c | 4 ++-- > xen/arch/x86/hvm/viridian.c | 6 +++--- > xen/arch/x86/hvm/vmx/vmcs.c | 2 +- > xen/arch/x86/hvm/vmx/vmx.c | 10 +- > xen/arch/x86/hvm/vmx/vvmx.c | 6 +++--- > xen/arch/x86/mm.c | 4 > xen/arch/x86/mm/guest_walk.c| 6 +++--- > xen/arch/x86/mm/hap/guest_walk.c| 2 +- > xen/arch/x86/mm/hap/hap.c | 6 -- >
Re: [Xen-devel] [PATCH v4 16/16] xen: Convert page_to_mfn and mfn_to_page to use typesafe MFN
On 02/21/2018 04:02 PM, Julien Grall wrote: > Most of the users of page_to_mfn and mfn_to_page are either overriding > the macros to make them work with mfn_t or use mfn_x/_mfn because the > rest of the function use mfn_t. > > So make page_to_mfn and mfn_to_page return mfn_t by default. The __* > version are now dropped as this patch will convert all the remaining > non-typesafe callers. > > Only reasonable clean-ups are done in this patch. The rest will use > _mfn/mfn_x for the time being. > > Lastly, domain_page_to_mfn is also converted to use mfn_t given that > most of the callers are now switched to _mfn(domain_page_to_mfn(...)). > > Signed-off-by: Julien GrallAcked-by: Razvan Cojocaru Thanks, Razvan ___ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel
[Xen-devel] [PATCH v4 16/16] xen: Convert page_to_mfn and mfn_to_page to use typesafe MFN
Most of the users of page_to_mfn and mfn_to_page are either overriding the macros to make them work with mfn_t or use mfn_x/_mfn because the rest of the function use mfn_t. So make page_to_mfn and mfn_to_page return mfn_t by default. The __* version are now dropped as this patch will convert all the remaining non-typesafe callers. Only reasonable clean-ups are done in this patch. The rest will use _mfn/mfn_x for the time being. Lastly, domain_page_to_mfn is also converted to use mfn_t given that most of the callers are now switched to _mfn(domain_page_to_mfn(...)). Signed-off-by: Julien Grall--- Andrew suggested to drop IS_VALID_PAGE in xen/tmem_xen.h. His comment was: "/sigh This is tautological. The definition of a "valid mfn" in this case is one for which we have frametable entry, and by having a struct page_info in our hands, this is by definition true (unless you have a wild pointer, at which point your bug is elsewhere). IS_VALID_PAGE() is only ever used in assertions and never usefully, so instead I would remove it entirely rather than trying to fix it up." I can remove the function in a separate patch at the begining of the series if Konrad (TMEM maintainer) is happy with that. Cc: Stefano Stabellini Cc: Julien Grall Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Konrad Rzeszutek Wilk Cc: Tim Deegan Cc: Wei Liu Cc: Razvan Cojocaru Cc: Tamas K Lengyel Cc: Paul Durrant Cc: Boris Ostrovsky Cc: Suravee Suthikulpanit Cc: Jun Nakajima Cc: Kevin Tian Cc: George Dunlap Cc: Gang Wei Cc: Shane Wang Changes in v4: - Drop __page_to_mfn and __mfn_to_page. Reword the commit title/message to reflect that. Changes in v3: - Rebase on the latest staging and fix some conflicts. Tags haven't be retained. - Switch the printf format to PRI_mfn Changes in v2: - Some part have been moved in separate patch - Remove one spurious comment - Convert domain_page_to_mfn to use mfn_t --- xen/arch/arm/domain_build.c | 2 -- xen/arch/arm/kernel.c | 2 +- xen/arch/arm/mem_access.c | 2 +- xen/arch/arm/mm.c | 8 xen/arch/arm/p2m.c | 10 ++ xen/arch/x86/cpu/vpmu.c | 4 ++-- xen/arch/x86/domain.c | 21 +++-- xen/arch/x86/domain_page.c | 6 +++--- xen/arch/x86/hvm/dm.c | 2 +- xen/arch/x86/hvm/dom0_build.c | 6 +++--- xen/arch/x86/hvm/emulate.c | 6 +++--- xen/arch/x86/hvm/hvm.c | 12 ++-- xen/arch/x86/hvm/ioreq.c| 4 ++-- xen/arch/x86/hvm/stdvga.c | 2 +- xen/arch/x86/hvm/svm/svm.c | 4 ++-- xen/arch/x86/hvm/viridian.c | 6 +++--- xen/arch/x86/hvm/vmx/vmcs.c | 2 +- xen/arch/x86/hvm/vmx/vmx.c | 10 +- xen/arch/x86/hvm/vmx/vvmx.c | 6 +++--- xen/arch/x86/mm.c | 4 xen/arch/x86/mm/guest_walk.c| 6 +++--- xen/arch/x86/mm/hap/guest_walk.c| 2 +- xen/arch/x86/mm/hap/hap.c | 6 -- xen/arch/x86/mm/hap/nested_ept.c| 2 +- xen/arch/x86/mm/mem_sharing.c | 5 - xen/arch/x86/mm/p2m-ept.c | 8 xen/arch/x86/mm/p2m-pod.c | 6 -- xen/arch/x86/mm/p2m.c | 6 -- xen/arch/x86/mm/paging.c| 6 -- xen/arch/x86/mm/shadow/private.h| 16 ++-- xen/arch/x86/numa.c | 2 +- xen/arch/x86/physdev.c | 2 +- xen/arch/x86/pv/callback.c | 6 -- xen/arch/x86/pv/descriptor-tables.c | 6 -- xen/arch/x86/pv/dom0_build.c| 14 +++--- xen/arch/x86/pv/domain.c| 6 -- xen/arch/x86/pv/emul-gate-op.c | 6 -- xen/arch/x86/pv/emul-priv-op.c | 10 -- xen/arch/x86/pv/grant_table.c | 6 -- xen/arch/x86/pv/ro-page-fault.c | 6 -- xen/arch/x86/pv/shim.c | 4 +--- xen/arch/x86/smpboot.c | 6 -- xen/arch/x86/tboot.c| 4 ++-- xen/arch/x86/traps.c| 4 ++-- xen/arch/x86/x86_64/mm.c| 6 -- xen/common/domain.c | 4 ++-- xen/common/grant_table.c| 6