* [PATCH v3 0/2] xen: arm: introduce a function and flush dcache while preparing the device tree for Dom0 @ 2013-11-27 16:55 Oleksandr Dmytryshyn 2013-11-27 16:55 ` [PATCH v3 1/2] xen: arm: introduce raw_copy_to_guest_flush_dcache() function Oleksandr Dmytryshyn 2013-11-27 16:55 ` [PATCH v3 2/2] xen: arm: flush dcache while preparing the device tree for Dom0 Oleksandr Dmytryshyn 0 siblings, 2 replies; 5+ messages in thread From: Oleksandr Dmytryshyn @ 2013-11-27 16:55 UTC (permalink / raw) To: xen-devel; +Cc: andrii.anisov Difference between the previous patchset: raw_copy_to_guest_helper() function now is static. Currently we use OMAP5 ES2.0 Panda5 board to work with the hypervisor. Without flushing dcache the hypervisor couldn't copy the device tree correctly when booting the kernel dom0 Image (memory with device tree is corrupted). As the result - when we try to load the kernel dom0 Image - dom0 hungs frequently. This issue is not reproduced with the kernel dom0 zImage because the zImage decompressor code flushes all dcache before starting the decompressed kernel Image. When the hypervisor loads the kernel image or initrd, this memory region isn't corrupted because the hypervisor code flushes the dcache. Oleksandr Dmytryshyn (2): xen: arm: introduce raw_copy_to_guest_flush_dcache() function xen: arm: flush dcache while preparing the device tree for Dom0 xen/arch/arm/domain_build.c | 3 ++- xen/arch/arm/guestcopy.c | 16 +++++++++++++++- xen/include/asm-arm/guest_access.h | 2 ++ 3 files changed, 19 insertions(+), 2 deletions(-) -- 1.8.2.rc2 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3 1/2] xen: arm: introduce raw_copy_to_guest_flush_dcache() function 2013-11-27 16:55 [PATCH v3 0/2] xen: arm: introduce a function and flush dcache while preparing the device tree for Dom0 Oleksandr Dmytryshyn @ 2013-11-27 16:55 ` Oleksandr Dmytryshyn 2013-11-27 16:59 ` Andrew Cooper 2013-11-27 16:55 ` [PATCH v3 2/2] xen: arm: flush dcache while preparing the device tree for Dom0 Oleksandr Dmytryshyn 1 sibling, 1 reply; 5+ messages in thread From: Oleksandr Dmytryshyn @ 2013-11-27 16:55 UTC (permalink / raw) To: xen-devel; +Cc: andrii.anisov This function flushes the dcache while copying the data. Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com> --- xen/arch/arm/guestcopy.c | 16 +++++++++++++++- xen/include/asm-arm/guest_access.h | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/guestcopy.c b/xen/arch/arm/guestcopy.c index d146cd6..4d4af09 100644 --- a/xen/arch/arm/guestcopy.c +++ b/xen/arch/arm/guestcopy.c @@ -5,7 +5,8 @@ #include <asm/mm.h> #include <asm/guest_access.h> -unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len) +static unsigned long raw_copy_to_guest_helper(void *to, const void *from, + unsigned len, unsigned flush_dcache) { /* XXX needs to handle faults */ unsigned offset = (vaddr_t)to & ~PAGE_MASK; @@ -24,6 +25,8 @@ unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len) p = map_domain_page(g>>PAGE_SHIFT); p += offset; memcpy(p, from, size); + if (flush_dcache) + flush_xen_dcache_va_range(p, size); unmap_domain_page(p - offset); len -= size; @@ -35,6 +38,17 @@ unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len) return 0; } +unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len) +{ + return raw_copy_to_guest_helper(to, from, len, 0); +} + +unsigned long raw_copy_to_guest_flush_dcache(void *to, const void *from, + unsigned len) +{ + return raw_copy_to_guest_helper(to, from, len, 1); +} + unsigned long raw_clear_guest(void *to, unsigned len) { /* XXX needs to handle faults */ diff --git a/xen/include/asm-arm/guest_access.h b/xen/include/asm-arm/guest_access.h index 8ff088f..5876988 100644 --- a/xen/include/asm-arm/guest_access.h +++ b/xen/include/asm-arm/guest_access.h @@ -11,6 +11,8 @@ (likely(count < (~0UL/size)) && access_ok(addr,count*size)) unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len); +unsigned long raw_copy_to_guest_flush_dcache(void *to, const void *from, + unsigned len); unsigned long raw_copy_from_guest(void *to, const void *from, unsigned len); unsigned long raw_clear_guest(void *to, unsigned len); -- 1.8.2.rc2 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3 1/2] xen: arm: introduce raw_copy_to_guest_flush_dcache() function 2013-11-27 16:55 ` [PATCH v3 1/2] xen: arm: introduce raw_copy_to_guest_flush_dcache() function Oleksandr Dmytryshyn @ 2013-11-27 16:59 ` Andrew Cooper 2013-11-27 17:05 ` Oleksandr Dmytryshyn 0 siblings, 1 reply; 5+ messages in thread From: Andrew Cooper @ 2013-11-27 16:59 UTC (permalink / raw) To: Oleksandr Dmytryshyn; +Cc: andrii.anisov, xen-devel On 27/11/13 16:55, Oleksandr Dmytryshyn wrote: > This function flushes the dcache while copying the data. > > Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com> > --- > xen/arch/arm/guestcopy.c | 16 +++++++++++++++- > xen/include/asm-arm/guest_access.h | 2 ++ > 2 files changed, 17 insertions(+), 1 deletion(-) > > diff --git a/xen/arch/arm/guestcopy.c b/xen/arch/arm/guestcopy.c > index d146cd6..4d4af09 100644 > --- a/xen/arch/arm/guestcopy.c > +++ b/xen/arch/arm/guestcopy.c > @@ -5,7 +5,8 @@ > #include <asm/mm.h> > #include <asm/guest_access.h> > > -unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len) > +static unsigned long raw_copy_to_guest_helper(void *to, const void *from, > + unsigned len, unsigned flush_dcache) > { > /* XXX needs to handle faults */ > unsigned offset = (vaddr_t)to & ~PAGE_MASK; > @@ -24,6 +25,8 @@ unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len) > p = map_domain_page(g>>PAGE_SHIFT); > p += offset; > memcpy(p, from, size); > + if (flush_dcache) I know this is nitpicking, but Xens coding style requires spaces inside the brackets for the if. So "if ( flush_dcache )" ~Andrew > + flush_xen_dcache_va_range(p, size); > > unmap_domain_page(p - offset); > len -= size; > @@ -35,6 +38,17 @@ unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len) > return 0; > } > > +unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len) > +{ > + return raw_copy_to_guest_helper(to, from, len, 0); > +} > + > +unsigned long raw_copy_to_guest_flush_dcache(void *to, const void *from, > + unsigned len) > +{ > + return raw_copy_to_guest_helper(to, from, len, 1); > +} > + > unsigned long raw_clear_guest(void *to, unsigned len) > { > /* XXX needs to handle faults */ > diff --git a/xen/include/asm-arm/guest_access.h b/xen/include/asm-arm/guest_access.h > index 8ff088f..5876988 100644 > --- a/xen/include/asm-arm/guest_access.h > +++ b/xen/include/asm-arm/guest_access.h > @@ -11,6 +11,8 @@ > (likely(count < (~0UL/size)) && access_ok(addr,count*size)) > > unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len); > +unsigned long raw_copy_to_guest_flush_dcache(void *to, const void *from, > + unsigned len); > unsigned long raw_copy_from_guest(void *to, const void *from, unsigned len); > unsigned long raw_clear_guest(void *to, unsigned len); > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3 1/2] xen: arm: introduce raw_copy_to_guest_flush_dcache() function 2013-11-27 16:59 ` Andrew Cooper @ 2013-11-27 17:05 ` Oleksandr Dmytryshyn 0 siblings, 0 replies; 5+ messages in thread From: Oleksandr Dmytryshyn @ 2013-11-27 17:05 UTC (permalink / raw) To: Andrew Cooper; +Cc: andrii.anisov, xen-devel Hi, Andrew. I'll fix this in the next patch-set. Oleksandr Dmytryshyn | Product Engineering and Development GlobalLogic P x3657 M +38.067.382.2525 www.globallogic.com http://www.globallogic.com/email_disclaimer.txt On Wed, Nov 27, 2013 at 6:59 PM, Andrew Cooper <andrew.cooper3@citrix.com> wrote: > On 27/11/13 16:55, Oleksandr Dmytryshyn wrote: >> This function flushes the dcache while copying the data. >> >> Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com> >> --- >> xen/arch/arm/guestcopy.c | 16 +++++++++++++++- >> xen/include/asm-arm/guest_access.h | 2 ++ >> 2 files changed, 17 insertions(+), 1 deletion(-) >> >> diff --git a/xen/arch/arm/guestcopy.c b/xen/arch/arm/guestcopy.c >> index d146cd6..4d4af09 100644 >> --- a/xen/arch/arm/guestcopy.c >> +++ b/xen/arch/arm/guestcopy.c >> @@ -5,7 +5,8 @@ >> #include <asm/mm.h> >> #include <asm/guest_access.h> >> >> -unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len) >> +static unsigned long raw_copy_to_guest_helper(void *to, const void *from, >> + unsigned len, unsigned flush_dcache) >> { >> /* XXX needs to handle faults */ >> unsigned offset = (vaddr_t)to & ~PAGE_MASK; >> @@ -24,6 +25,8 @@ unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len) >> p = map_domain_page(g>>PAGE_SHIFT); >> p += offset; >> memcpy(p, from, size); >> + if (flush_dcache) > > I know this is nitpicking, but Xens coding style requires spaces inside > the brackets for the if. > > So "if ( flush_dcache )" > > ~Andrew > >> + flush_xen_dcache_va_range(p, size); >> >> unmap_domain_page(p - offset); >> len -= size; >> @@ -35,6 +38,17 @@ unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len) >> return 0; >> } >> >> +unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len) >> +{ >> + return raw_copy_to_guest_helper(to, from, len, 0); >> +} >> + >> +unsigned long raw_copy_to_guest_flush_dcache(void *to, const void *from, >> + unsigned len) >> +{ >> + return raw_copy_to_guest_helper(to, from, len, 1); >> +} >> + >> unsigned long raw_clear_guest(void *to, unsigned len) >> { >> /* XXX needs to handle faults */ >> diff --git a/xen/include/asm-arm/guest_access.h b/xen/include/asm-arm/guest_access.h >> index 8ff088f..5876988 100644 >> --- a/xen/include/asm-arm/guest_access.h >> +++ b/xen/include/asm-arm/guest_access.h >> @@ -11,6 +11,8 @@ >> (likely(count < (~0UL/size)) && access_ok(addr,count*size)) >> >> unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len); >> +unsigned long raw_copy_to_guest_flush_dcache(void *to, const void *from, >> + unsigned len); >> unsigned long raw_copy_from_guest(void *to, const void *from, unsigned len); >> unsigned long raw_clear_guest(void *to, unsigned len); >> > ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3 2/2] xen: arm: flush dcache while preparing the device tree for Dom0 2013-11-27 16:55 [PATCH v3 0/2] xen: arm: introduce a function and flush dcache while preparing the device tree for Dom0 Oleksandr Dmytryshyn 2013-11-27 16:55 ` [PATCH v3 1/2] xen: arm: introduce raw_copy_to_guest_flush_dcache() function Oleksandr Dmytryshyn @ 2013-11-27 16:55 ` Oleksandr Dmytryshyn 1 sibling, 0 replies; 5+ messages in thread From: Oleksandr Dmytryshyn @ 2013-11-27 16:55 UTC (permalink / raw) To: xen-devel; +Cc: andrii.anisov Without flushing dcache the hypervisor couldn't copy the device tree correctly when booting the kernel dom0 Image (memory with device tree is corrupted). As the result - when we try to load the kernel dom0 Image - dom0 hungs frequently. This issue is not reproduced with the kernel dom0 zImage because the zImage decompressor code flushes all dcache before starting the decompressed kernel Image. When the hypervisor loads the kernel image or initrd, this memory region isn't corrupted because the hypervisor code flushes the dcache. Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com> --- xen/arch/arm/domain_build.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index e9bb01f..99e785a 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -906,7 +906,8 @@ static void dtb_load(struct kernel_info *kinfo) printk("Loading dom0 DTB to 0x%"PRIpaddr"-0x%"PRIpaddr"\n", kinfo->dtb_paddr, kinfo->dtb_paddr + fdt_totalsize(kinfo->fdt)); - rc = raw_copy_to_guest(dtb_virt, kinfo->fdt, fdt_totalsize(kinfo->fdt)); + rc = raw_copy_to_guest_flush_dcache(dtb_virt, kinfo->fdt, + fdt_totalsize(kinfo->fdt)); if ( rc != 0 ) panic("Unable to copy the DTB to dom0 memory (rc = %lu)\n", rc); xfree(kinfo->fdt); -- 1.8.2.rc2 ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-11-27 17:05 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-11-27 16:55 [PATCH v3 0/2] xen: arm: introduce a function and flush dcache while preparing the device tree for Dom0 Oleksandr Dmytryshyn 2013-11-27 16:55 ` [PATCH v3 1/2] xen: arm: introduce raw_copy_to_guest_flush_dcache() function Oleksandr Dmytryshyn 2013-11-27 16:59 ` Andrew Cooper 2013-11-27 17:05 ` Oleksandr Dmytryshyn 2013-11-27 16:55 ` [PATCH v3 2/2] xen: arm: flush dcache while preparing the device tree for Dom0 Oleksandr Dmytryshyn
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.