* [PATCH v2 0/2] Clean and invalidate dcache for boot pagetables during setup @ 2014-03-11 13:19 Oleksandr Tyshchenko 2014-03-11 13:19 ` [PATCH v2 1/2] xen/arm: Introduce clean_and_invalidate_xen_dcache() macro Oleksandr Tyshchenko 2014-03-11 13:19 ` [PATCH v2 2/2] xen/arm: Clean and invalidate dcache for boot pagetables Oleksandr Tyshchenko 0 siblings, 2 replies; 7+ messages in thread From: Oleksandr Tyshchenko @ 2014-03-11 13:19 UTC (permalink / raw) To: xen-devel; +Cc: julien.grall, tim, ian.campbell, stefano.stabellini Hello, all. This small patch series are needed to avoid possible hangs during bringing up non-boot CPU. This solution was suggested by Julien Grall and Ian Campbell. Discussion in Xen project Mailing List: http://lists.xen.org/archives/html/xen-devel/2014-02/msg01575.html The first patch introduces a new macro clean_and_invalidate_xen_dcache(). Unlike existing macro clean_xen_dcache() this macro performs clean and invalidate dcache. The second patch replaces clean_xen_dcache() macro by a clean_and_invalidate_xen_dcache() for boot pagetables after cleaning them. This patch series was tested on DRA7 platform manufactured by TI. v2: - modify flush_page_to_ram() to call clean_and_invalidate_xen_dcache_va_range() function - some changes related to coding-style Oleksandr Tyshchenko (2): xen/arm: Introduce clean_and_invalidate_xen_dcache() macro xen/arm: Clean and invalidate dcache for boot pagetables xen/arch/arm/mm.c | 14 +++++--------- xen/include/asm-arm/page.h | 26 ++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 11 deletions(-) -- 1.7.9.5 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/2] xen/arm: Introduce clean_and_invalidate_xen_dcache() macro 2014-03-11 13:19 [PATCH v2 0/2] Clean and invalidate dcache for boot pagetables during setup Oleksandr Tyshchenko @ 2014-03-11 13:19 ` Oleksandr Tyshchenko 2014-03-11 13:37 ` Julien Grall 2014-03-11 13:19 ` [PATCH v2 2/2] xen/arm: Clean and invalidate dcache for boot pagetables Oleksandr Tyshchenko 1 sibling, 1 reply; 7+ messages in thread From: Oleksandr Tyshchenko @ 2014-03-11 13:19 UTC (permalink / raw) To: xen-devel; +Cc: julien.grall, tim, ian.campbell, stefano.stabellini This macro is very similar to clean_xen_dcache(), but it performs clean and invalidate dcache. Also modify flush_page_to_ram() to call clean_and_invalidate_xen_dcache_va_range() function. Signed-off-by: Oleksandr Tyshchenko <oleksandr.tyshchenko@globallogic.com> Reviewed-by: Julien Grall <julien.grall@linaro.org> CC: Ian Campbell <ian.campbell@citrix.com> --- xen/arch/arm/mm.c | 8 ++------ xen/include/asm-arm/page.h | 26 ++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 308a798..544aa87 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -344,13 +344,9 @@ unsigned long domain_page_map_to_mfn(const void *ptr) void flush_page_to_ram(unsigned long mfn) { - void *p, *v = map_domain_page(mfn); - - dsb(); /* So the CPU issues all writes to the range */ - for ( p = v; p < v + PAGE_SIZE ; p += cacheline_bytes ) - asm volatile (__clean_and_invalidate_xen_dcache_one(0) : : "r" (p)); - dsb(); /* So we know the flushes happen before continuing */ + void *v = map_domain_page(mfn); + clean_and_invalidate_xen_dcache_va_range(v, PAGE_SIZE); unmap_domain_page(v); } diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h index e00be9e..dfac003 100644 --- a/xen/include/asm-arm/page.h +++ b/xen/include/asm-arm/page.h @@ -226,7 +226,7 @@ static inline lpae_t mfn_to_xen_entry(unsigned long mfn) /* Actual cacheline size on the boot CPU. */ extern size_t cacheline_bytes; -/* Function for flushing medium-sized areas. +/* Functions for flushing medium-sized areas. * if 'range' is large enough we might want to use model-specific * full-cache flushes. */ static inline void clean_xen_dcache_va_range(void *p, unsigned long size) @@ -238,7 +238,17 @@ static inline void clean_xen_dcache_va_range(void *p, unsigned long size) dsb(); /* So we know the flushes happen before continuing */ } -/* Macro for flushing a single small item. The predicate is always +static inline void clean_and_invalidate_xen_dcache_va_range + (void *p, unsigned long size) +{ + void *end; + dsb(); /* So the CPU issues all writes to the range */ + for ( end = p + size; p < end; p += cacheline_bytes ) + asm volatile (__clean_and_invalidate_xen_dcache_one(0) : : "r" (p)); + dsb(); /* So we know the flushes happen before continuing */ +} + +/* Macros for flushing a single small item. The predicate is always * compile-time constant so this will compile down to 3 instructions in * the common case. */ #define clean_xen_dcache(x) do { \ @@ -253,6 +263,18 @@ static inline void clean_xen_dcache_va_range(void *p, unsigned long size) : : "r" (_p), "m" (*_p)); \ } while (0) +#define clean_and_invalidate_xen_dcache(x) do { \ + typeof(x) *_p = &(x); \ + if ( sizeof(x) > MIN_CACHELINE_BYTES || sizeof(x) > alignof(x) ) \ + clean_and_invalidate_xen_dcache_va_range(_p, sizeof(x)); \ + else \ + asm volatile ( \ + "dsb sy;" /* Finish all earlier writes */ \ + __clean_and_invalidate_xen_dcache_one(0) \ + "dsb sy;" /* Finish flush before continuing */ \ + : : "r" (_p), "m" (*_p)); \ +} while (0) + /* Flush the dcache for an entire page. */ void flush_page_to_ram(unsigned long mfn); -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] xen/arm: Introduce clean_and_invalidate_xen_dcache() macro 2014-03-11 13:19 ` [PATCH v2 1/2] xen/arm: Introduce clean_and_invalidate_xen_dcache() macro Oleksandr Tyshchenko @ 2014-03-11 13:37 ` Julien Grall 2014-03-12 14:05 ` Oleksandr Tyshchenko 0 siblings, 1 reply; 7+ messages in thread From: Julien Grall @ 2014-03-11 13:37 UTC (permalink / raw) To: Oleksandr Tyshchenko; +Cc: stefano.stabellini, tim, ian.campbell, xen-devel Hello Oleksandr, On 03/11/2014 01:19 PM, Oleksandr Tyshchenko wrote: > This macro is very similar to clean_xen_dcache(), but it performs > clean and invalidate dcache. > > Also modify flush_page_to_ram() to call > clean_and_invalidate_xen_dcache_va_range() function. > > Signed-off-by: Oleksandr Tyshchenko <oleksandr.tyshchenko@globallogic.com> > Reviewed-by: Julien Grall <julien.grall@linaro.org> Please remove this "Reviewed-by". I have only gave my "reviewed-by" on patch #2 (see V1). Regards, -- Julien Grall ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] xen/arm: Introduce clean_and_invalidate_xen_dcache() macro 2014-03-11 13:37 ` Julien Grall @ 2014-03-12 14:05 ` Oleksandr Tyshchenko 2014-03-14 15:08 ` Ian Campbell 0 siblings, 1 reply; 7+ messages in thread From: Oleksandr Tyshchenko @ 2014-03-12 14:05 UTC (permalink / raw) To: Julien Grall Cc: Stefano Stabellini, Tim Deegan, Ian Campbell, xen-devel@lists.xen.org On Tue, Mar 11, 2014 at 3:37 PM, Julien Grall <julien.grall@linaro.org> wrote: > Hello Oleksandr, > > On 03/11/2014 01:19 PM, Oleksandr Tyshchenko wrote: >> This macro is very similar to clean_xen_dcache(), but it performs >> clean and invalidate dcache. >> >> Also modify flush_page_to_ram() to call >> clean_and_invalidate_xen_dcache_va_range() function. >> >> Signed-off-by: Oleksandr Tyshchenko <oleksandr.tyshchenko@globallogic.com> >> Reviewed-by: Julien Grall <julien.grall@linaro.org> > > Please remove this "Reviewed-by". I have only gave my "reviewed-by" on > patch #2 (see V1). > > Regards, > > -- > Julien Grall Sorry, I will correct -- Oleksandr Tyshchenko | Embedded Developer GlobalLogic www.globallogic.com ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] xen/arm: Introduce clean_and_invalidate_xen_dcache() macro 2014-03-12 14:05 ` Oleksandr Tyshchenko @ 2014-03-14 15:08 ` Ian Campbell 2014-03-14 15:16 ` Oleksandr Tyshchenko 0 siblings, 1 reply; 7+ messages in thread From: Ian Campbell @ 2014-03-14 15:08 UTC (permalink / raw) To: Oleksandr Tyshchenko Cc: Julien Grall, Tim Deegan, Stefano Stabellini, xen-devel@lists.xen.org On Wed, 2014-03-12 at 16:05 +0200, Oleksandr Tyshchenko wrote: > On Tue, Mar 11, 2014 at 3:37 PM, Julien Grall <julien.grall@linaro.org> wrote: > > Hello Oleksandr, > > > > On 03/11/2014 01:19 PM, Oleksandr Tyshchenko wrote: > >> This macro is very similar to clean_xen_dcache(), but it performs > >> clean and invalidate dcache. > >> > >> Also modify flush_page_to_ram() to call > >> clean_and_invalidate_xen_dcache_va_range() function. > >> > >> Signed-off-by: Oleksandr Tyshchenko <oleksandr.tyshchenko@globallogic.com> > >> Reviewed-by: Julien Grall <julien.grall@linaro.org> > > > > Please remove this "Reviewed-by". I have only gave my "reviewed-by" on > > patch #2 (see V1). > Sorry, I will correct I replaced it with my Ack and applied this and the second patch. Thanks, Ian. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] xen/arm: Introduce clean_and_invalidate_xen_dcache() macro 2014-03-14 15:08 ` Ian Campbell @ 2014-03-14 15:16 ` Oleksandr Tyshchenko 0 siblings, 0 replies; 7+ messages in thread From: Oleksandr Tyshchenko @ 2014-03-14 15:16 UTC (permalink / raw) To: Ian Campbell Cc: Julien Grall, Tim Deegan, Stefano Stabellini, xen-devel@lists.xen.org > > I replaced it with my Ack and applied this and the second patch. > > Thanks, > Ian. > Thank you -- Oleksandr Tyshchenko | Embedded Developer GlobalLogic www.globallogic.com ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] xen/arm: Clean and invalidate dcache for boot pagetables 2014-03-11 13:19 [PATCH v2 0/2] Clean and invalidate dcache for boot pagetables during setup Oleksandr Tyshchenko 2014-03-11 13:19 ` [PATCH v2 1/2] xen/arm: Introduce clean_and_invalidate_xen_dcache() macro Oleksandr Tyshchenko @ 2014-03-11 13:19 ` Oleksandr Tyshchenko 1 sibling, 0 replies; 7+ messages in thread From: Oleksandr Tyshchenko @ 2014-03-11 13:19 UTC (permalink / raw) To: xen-devel; +Cc: julien.grall, tim, ian.campbell, stefano.stabellini We need to invalidate dcache too after zeroing boot pagetables to avoid unpredictable behavior which may take place after non-boot CPUs enable their caches. So, replace clean_xen_dcache() macro by a clean_and_invalidate_xen_dcache() for boot pagetables. Signed-off-by: Oleksandr Tyshchenko <oleksandr.tyshchenko@globallogic.com> Reviewed-by: Julien Grall <julien.grall@linaro.org> CC: Ian Campbell <ian.campbell@citrix.com> --- xen/arch/arm/mm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 544aa87..305879f 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -480,13 +480,13 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr) /* Clear the copy of the boot pagetables. Each secondary CPU * rebuilds these itself (see head.S) */ memset(boot_pgtable, 0x0, PAGE_SIZE); - clean_xen_dcache(boot_pgtable); + clean_and_invalidate_xen_dcache(boot_pgtable); #ifdef CONFIG_ARM_64 memset(boot_first, 0x0, PAGE_SIZE); - clean_xen_dcache(boot_first); + clean_and_invalidate_xen_dcache(boot_first); #endif memset(boot_second, 0x0, PAGE_SIZE); - clean_xen_dcache(boot_second); + clean_and_invalidate_xen_dcache(boot_second); /* Break up the Xen mapping into 4k pages and protect them separately. */ for ( i = 0; i < LPAE_ENTRIES; i++ ) -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-03-14 15:16 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-03-11 13:19 [PATCH v2 0/2] Clean and invalidate dcache for boot pagetables during setup Oleksandr Tyshchenko 2014-03-11 13:19 ` [PATCH v2 1/2] xen/arm: Introduce clean_and_invalidate_xen_dcache() macro Oleksandr Tyshchenko 2014-03-11 13:37 ` Julien Grall 2014-03-12 14:05 ` Oleksandr Tyshchenko 2014-03-14 15:08 ` Ian Campbell 2014-03-14 15:16 ` Oleksandr Tyshchenko 2014-03-11 13:19 ` [PATCH v2 2/2] xen/arm: Clean and invalidate dcache for boot pagetables Oleksandr Tyshchenko
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.