[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 23/38] arm: use correct attributes for mappings in copy_from_paddr()



On Wed, 2012-06-06 at 18:38 +0100, Stefano Stabellini wrote:
> On Fri, 1 Jun 2012, Ian Campbell wrote:
> > The DTB is in RAM (hence bufferable), kernel is in flash and therefor 
> > requires
> > a device type mapping (hence dev shared).
> > 
> > Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
> > ---
> >  xen/arch/arm/kernel.c       |    8 ++++----
> >  xen/arch/arm/setup.c        |    2 +-
> >  xen/include/asm-arm/setup.h |    2 +-
> >  3 files changed, 6 insertions(+), 6 deletions(-)
> > 
> > diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c
> > index 130d488..1a705c9 100644
> > --- a/xen/arch/arm/kernel.c
> > +++ b/xen/arch/arm/kernel.c
> > @@ -39,7 +39,7 @@ struct minimal_dtb_header {
> >   * @paddr: source physical address
> >   * @len: length to copy
> >   */
> > -void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len)
> > +void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len, int 
> > mattr)
> >  {
> >      void *src = (void *)FIXMAP_ADDR(FIXMAP_MISC);
> >  
> > @@ -51,7 +51,7 @@ void copy_from_paddr(void *dst, paddr_t paddr, unsigned 
> > long len)
> >          s = paddr & (PAGE_SIZE-1);
> >          l = min(PAGE_SIZE - s, len);
> >  
> > -        set_fixmap(FIXMAP_MISC, p, DEV_SHARED);
> > +        set_fixmap(FIXMAP_MISC, p, mattr);
> >          memcpy(dst, src + s, l);
> >  
> >          paddr += l;
> > @@ -111,7 +111,7 @@ static int kernel_try_zimage_prepare(struct kernel_info 
> > *info)
> >      /*
> >       * Check for an appended DTB.
> >       */
> > -    copy_from_paddr(&dtb_hdr, KERNEL_FLASH_ADDRESS + end - start, 
> > sizeof(dtb_hdr));
> > +    copy_from_paddr(&dtb_hdr, KERNEL_FLASH_ADDRESS + end - start, 
> > sizeof(dtb_hdr), DEV_SHARED);
> >      if (be32_to_cpu(dtb_hdr.magic) == DTB_MAGIC) {
> >          end += be32_to_cpu(dtb_hdr.total_size);
> >      }
> > @@ -151,7 +151,7 @@ static int kernel_try_elf_prepare(struct kernel_info 
> > *info)
> >      if ( info->kernel_img == NULL )
> >          panic("Cannot allocate temporary buffer for kernel.\n");
> >  
> > -    copy_from_paddr(info->kernel_img, KERNEL_FLASH_ADDRESS, 
> > KERNEL_FLASH_SIZE);
> > +    copy_from_paddr(info->kernel_img, KERNEL_FLASH_ADDRESS, 
> > KERNEL_FLASH_SIZE, DEV_SHARED);
> >  
> >      if ( (rc = elf_init(&info->elf.elf, info->kernel_img, 
> > KERNEL_FLASH_SIZE )) != 0 )
> >          return rc;
> > diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> > index b0cfacc..f5473cd 100644
> > --- a/xen/arch/arm/setup.c
> > +++ b/xen/arch/arm/setup.c
> > @@ -122,7 +122,7 @@ static void __init setup_mm(unsigned long dtb_paddr, 
> > size_t dtb_size)
> >       * TODO: handle other payloads too.
> >       */
> >      device_tree_flattened = mfn_to_virt(alloc_boot_pages(dtb_pages, 1));
> > -    copy_from_paddr(device_tree_flattened, dtb_paddr, dtb_size);
> > +    copy_from_paddr(device_tree_flattened, dtb_paddr, dtb_size, 
> > BUFFERABLE);
> >  
> >      /* Add non-xenheap memory */
> >      init_boot_pages(pfn_to_paddr(xenheap_mfn_start + xenheap_pages),
> > diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h
> > index 05ff89e..faadccc 100644
> > --- a/xen/include/asm-arm/setup.h
> > +++ b/xen/include/asm-arm/setup.h
> > @@ -3,7 +3,7 @@
> >  
> >  #include <public/version.h>
> >  
> > -void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len);
> > +void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len, int 
> > mattr);
> >  
> >  void arch_get_xen_caps(xen_capabilities_info_t *info);
> >  
> 
> The patch is correct, but it shouldn't call the new parameter mattr
> because it can easily be confused with the memattr bits (see
> http://marc.info/?l=xen-devel&m=133856578918985).
> I would call it "int attrindx" instead.

Yes, this is a good point and attrindx is a good name, I'll make that
change.

I also added a comment to the two sets of #defines explaining which they
are. Updated patch is:

8<------------------------------------------------

>From 08f78c5b7e31ed0f6533ff6a378c586c0db58276 Mon Sep 17 00:00:00 2001
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Mon, 14 May 2012 14:02:26 +0100
Subject: [PATCH] arm: use correct attributes for mappings in
 copy_from_paddr()

The DTB is in RAM (hence bufferable), kernel is in flash and therefor requires
a device type mapping (hence dev shared).

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Acked-by: David Vrabel <david.vrabel@xxxxxxxxxx>
---
 xen/arch/arm/kernel.c       |    8 ++++----
 xen/arch/arm/setup.c        |    2 +-
 xen/include/asm-arm/page.h  |   15 +++++++++++++++
 xen/include/asm-arm/setup.h |    2 +-
 4 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c
index 130d488..2d56130 100644
--- a/xen/arch/arm/kernel.c
+++ b/xen/arch/arm/kernel.c
@@ -39,7 +39,7 @@ struct minimal_dtb_header {
  * @paddr: source physical address
  * @len: length to copy
  */
-void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len)
+void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len, int attrindx)
 {
     void *src = (void *)FIXMAP_ADDR(FIXMAP_MISC);
 
@@ -51,7 +51,7 @@ void copy_from_paddr(void *dst, paddr_t paddr, unsigned long 
len)
         s = paddr & (PAGE_SIZE-1);
         l = min(PAGE_SIZE - s, len);
 
-        set_fixmap(FIXMAP_MISC, p, DEV_SHARED);
+        set_fixmap(FIXMAP_MISC, p, attrindx);
         memcpy(dst, src + s, l);
 
         paddr += l;
@@ -111,7 +111,7 @@ static int kernel_try_zimage_prepare(struct kernel_info 
*info)
     /*
      * Check for an appended DTB.
      */
-    copy_from_paddr(&dtb_hdr, KERNEL_FLASH_ADDRESS + end - start, 
sizeof(dtb_hdr));
+    copy_from_paddr(&dtb_hdr, KERNEL_FLASH_ADDRESS + end - start, 
sizeof(dtb_hdr), DEV_SHARED);
     if (be32_to_cpu(dtb_hdr.magic) == DTB_MAGIC) {
         end += be32_to_cpu(dtb_hdr.total_size);
     }
@@ -151,7 +151,7 @@ static int kernel_try_elf_prepare(struct kernel_info *info)
     if ( info->kernel_img == NULL )
         panic("Cannot allocate temporary buffer for kernel.\n");
 
-    copy_from_paddr(info->kernel_img, KERNEL_FLASH_ADDRESS, KERNEL_FLASH_SIZE);
+    copy_from_paddr(info->kernel_img, KERNEL_FLASH_ADDRESS, KERNEL_FLASH_SIZE, 
DEV_SHARED);
 
     if ( (rc = elf_init(&info->elf.elf, info->kernel_img, KERNEL_FLASH_SIZE )) 
!= 0 )
         return rc;
diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index d6c0178..fd70553 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -122,7 +122,7 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t 
dtb_size)
      * TODO: handle other payloads too.
      */
     device_tree_flattened = mfn_to_virt(alloc_boot_pages(dtb_pages, 1));
-    copy_from_paddr(device_tree_flattened, dtb_paddr, dtb_size);
+    copy_from_paddr(device_tree_flattened, dtb_paddr, dtb_size, BUFFERABLE);
 
     /* Add non-xenheap memory */
     init_boot_pages(pfn_to_paddr(xenheap_mfn_start + xenheap_pages),
diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h
index 6efe23c..2b6c1780 100644
--- a/xen/include/asm-arm/page.h
+++ b/xen/include/asm-arm/page.h
@@ -36,6 +36,14 @@
 #define MAIR0VAL 0xeeaa4400
 #define MAIR1VAL 0xff000004
 
+/*
+ * Attribute Indexes.
+ *
+ * These are valid in the AttrIndx[2:0] field of an LPAE stage 1 page
+ * table entry. They are indexes into the bytes of the MAIR*
+ * registers, as defined above.
+ *
+ */
 #define UNCACHED      0x0
 #define BUFFERABLE    0x1
 #define WRITETHROUGH  0x2
@@ -46,6 +54,13 @@
 #define DEV_WC        BUFFERABLE
 #define DEV_CACHED    WRITEBACK
 
+/*
+ * Stage 2 Memory Type.
+ *
+ * These are valid in the MemAttr[3:0] field of an LPAE stage 2 page
+ * table entry.
+ *
+ */
 #define MATTR_DEV     0x1
 #define MATTR_MEM     0xf
 
diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h
index 05ff89e..6433b4e 100644
--- a/xen/include/asm-arm/setup.h
+++ b/xen/include/asm-arm/setup.h
@@ -3,7 +3,7 @@
 
 #include <public/version.h>
 
-void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len);
+void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len, int 
attrindx);
 
 void arch_get_xen_caps(xen_capabilities_info_t *info);
 
-- 
1.7.9.1





_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.