Oleksandr Dmytryshyn
2013-Nov-27 17:09 UTC
[PATCH v4 0/2] xen: arm: introduce a function and flush dcache while preparing the device tree for Dom0
Changes from v3 to v4: Added spaces inside the brackets for the if. Changes from v2 to v3: 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
Oleksandr Dmytryshyn
2013-Nov-27 17:09 UTC
[PATCH v4 1/2] xen: arm: introduce raw_copy_to_guest_flush_dcache() function
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..08800a4 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
Oleksandr Dmytryshyn
2013-Nov-27 17:09 UTC
[PATCH v4 2/2] xen: arm: flush dcache while preparing the device tree for Dom0
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
Ian Campbell
2013-Nov-27 17:14 UTC
Re: [PATCH v4 1/2] xen: arm: introduce raw_copy_to_guest_flush_dcache() function
On Wed, 2013-11-27 at 19:09 +0200, Oleksandr Dmytryshyn wrote:> This function flushes the dcache while copying the data. > > Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>Thanks. For future reference: Please can you list the Acked-/Reviewed-by etc which people gave on previous iterations here as described in http://wiki.xen.org/wiki/Submitting_Xen_Patches when you resend. This means that reviews don''t need to remember if they''ve been through a patch and is helpful for committers too if they don''t have to go hunting for previous threads.. No need to resend just for this, I''ll manage this time. Thanks, Ian.> --- > 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..08800a4 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); >
Oleksandr Dmytryshyn
2013-Nov-27 17:23 UTC
Re: [PATCH v4 1/2] xen: arm: introduce raw_copy_to_guest_flush_dcache() function
Hi, Ian. I''ll do it next time. 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 7:14 PM, Ian Campbell <Ian.Campbell@citrix.com> wrote:> On Wed, 2013-11-27 at 19:09 +0200, Oleksandr Dmytryshyn wrote: >> This function flushes the dcache while copying the data. >> >> Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com> > > Thanks. > > For future reference: Please can you list the Acked-/Reviewed-by etc > which people gave on previous iterations here as described in > http://wiki.xen.org/wiki/Submitting_Xen_Patches when you resend. > > This means that reviews don''t need to remember if they''ve been through a > patch and is helpful for committers too if they don''t have to go hunting > for previous threads.. > > No need to resend just for this, I''ll manage this time. > > Thanks, > Ian. > >> --- >> 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..08800a4 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); >> > >