]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Merge branch 'zImage_fixes' of git://git.linaro.org/people/nico/linux into devel...
authorRussell King <rmk+kernel@arm.linux.org.uk>
Sat, 7 May 2011 07:34:02 +0000 (08:34 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Sat, 7 May 2011 07:34:02 +0000 (08:34 +0100)
1  2 
arch/arm/boot/compressed/head.S
arch/arm/boot/compressed/misc.c

index a36f4526689b8e6b4a3904ff76429a8b91937109,8d5d91aefbb9dbe0fdae3d75bfcd6e3174cf3e9d..c363458a4e632424b119c97370bf52d8dca8ed08
  
  #if defined(CONFIG_DEBUG_ICEDCC)
  
 -#if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_V6K)
 +#if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_V6K) || defined(CONFIG_CPU_V7)
                .macro  loadsp, rb, tmp
                .endm
                .macro  writeb, ch, rb
                mcr     p14, 0, \ch, c0, c5, 0
                .endm
 -#elif defined(CONFIG_CPU_V7)
 -              .macro  loadsp, rb, tmp
 -              .endm
 -              .macro  writeb, ch, rb
 -wait:         mrc     p14, 0, pc, c0, c1, 0
 -              bcs     wait
 -              mcr     p14, 0, \ch, c0, c5, 0
 -              .endm
  #elif defined(CONFIG_CPU_XSCALE)
                .macro  loadsp, rb, tmp
                .endm
@@@ -179,16 -187,29 +179,29 @@@ not_angel
                bl      cache_on
  
  restart:      adr     r0, LC0
-               ldmia   r0, {r1, r2, r3, r5, r6, r9, r11, r12}
-               ldr     sp, [r0, #32]
+               ldmia   r0, {r1, r2, r3, r6, r10, r11, r12}
+               ldr     sp, [r0, #28]
  
                /*
                 * We might be running at a different address.  We need
                 * to fix up various pointers.
                 */
                sub     r0, r0, r1              @ calculate the delta offset
-               add     r5, r5, r0              @ _start
                add     r6, r6, r0              @ _edata
+               add     r10, r10, r0            @ inflated kernel size location
+               /*
+                * The kernel build system appends the size of the
+                * decompressed kernel at the end of the compressed data
+                * in little-endian form.
+                */
+               ldrb    r9, [r10, #0]
+               ldrb    lr, [r10, #1]
+               orr     r9, r9, lr, lsl #8
+               ldrb    lr, [r10, #2]
+               ldrb    r10, [r10, #3]
+               orr     r9, r9, lr, lsl #16
+               orr     r9, r9, r10, lsl #24
  
  #ifndef CONFIG_ZBOOT_ROM
                /* malloc space is above the relocated stack (64k max) */
  /*
   * Check to see if we will overwrite ourselves.
   *   r4  = final kernel address
-  *   r5  = start of this image
   *   r9  = size of decompressed image
   *   r10 = end of this image, including  bss/stack/malloc space if non XIP
   * We basically want:
-  *   r4 >= r10 -> OK
-  *   r4 + image length <= r5 -> OK
+  *   r4 - 16k page directory >= r10 -> OK
+  *   r4 + image length <= current position (pc) -> OK
   */
+               add     r10, r10, #16384
                cmp     r4, r10
                bhs     wont_overwrite
                add     r10, r4, r9
-               cmp     r10, r5
+    ARM(               cmp     r10, pc         )
+  THUMB(               mov     lr, pc          )
+  THUMB(               cmp     r10, lr         )
                bls     wont_overwrite
  
  /*
   * Relocate ourselves past the end of the decompressed kernel.
-  *   r5  = start of this image
   *   r6  = _edata
   *   r10 = end of the decompressed kernel
   * Because we always copy ahead, we need to do it from the end and go
   * backward in case the source and destination overlap.
   */
-               /* Round up to next 256-byte boundary. */
-               add     r10, r10, #256
+               /*
+                * Bump to the next 256-byte boundary with the size of
+                * the relocation code added. This avoids overwriting
+                * ourself when the offset is small.
+                */
+               add     r10, r10, #((reloc_code_end - restart + 256) & ~255)
                bic     r10, r10, #255
  
+               /* Get start of code we want to copy and align it down. */
+               adr     r5, restart
+               bic     r5, r5, #31
                sub     r9, r6, r5              @ size to copy
                add     r9, r9, #31             @ rounded up to a multiple
                bic     r9, r9, #31             @ ... of 32 bytes
                /* Preserve offset to relocated code. */
                sub     r6, r9, r6
  
+ #ifndef CONFIG_ZBOOT_ROM
+               /* cache_clean_flush may use the stack, so relocate it */
+               add     sp, sp, r6
+ #endif
                bl      cache_clean_flush
  
                adr     r0, BSYM(restart)
@@@ -333,12 -368,11 +360,11 @@@ not_relocated:  mov     r0, #
  LC0:          .word   LC0                     @ r1
                .word   __bss_start             @ r2
                .word   _end                    @ r3
-               .word   _start                  @ r5
                .word   _edata                  @ r6
-               .word   _image_size             @ r9
+               .word   input_data_end - 4      @ r10 (inflated size location)
                .word   _got_start              @ r11
                .word   _got_end                @ ip
-               .word   user_stack_end          @ sp
+               .word   .L_user_stack_end       @ sp
                .size   LC0, . - LC0
  
  #ifdef CONFIG_ARCH_RPC
@@@ -735,6 -769,12 +761,6 @@@ proc_types
                W(b)    __armv4_mmu_cache_off
                W(b)    __armv6_mmu_cache_flush
  
 -              .word   0x560f5810              @ Marvell PJ4 ARMv6
 -              .word   0xff0ffff0
 -              W(b)    __armv4_mmu_cache_on
 -              W(b)    __armv4_mmu_cache_off
 -              W(b)    __armv6_mmu_cache_flush
 -
                .word   0x000f0000              @ new CPU Id
                .word   0x000f0000
                W(b)    __armv7_mmu_cache_on
@@@ -1056,8 -1096,9 +1082,9 @@@ memdump:        mov     r12, r
  #endif
  
                .ltorg
+ reloc_code_end:
  
                .align
                .section ".stack", "aw", %nobits
user_stack:   .space  4096
- user_stack_end:
.L_user_stack:        .space  4096
.L_user_stack_end:
index 2df38263124c2676e0b0ec62a95de05a1e2ad891,65871a7ba0d73acd4d2ae0eb7256fe5b2372566f..832d37236c59fdc92c852166d64a6b0c6efc71d5
@@@ -26,8 -26,6 +26,6 @@@ unsigned int __machine_arch_type
  #include <linux/linkage.h>
  #include <asm/string.h>
  
- #include <asm/unaligned.h>
  
  static void putstr(const char *ptr);
  extern void error(char *x);
@@@ -36,7 -34,7 +34,7 @@@
  
  #ifdef CONFIG_DEBUG_ICEDCC
  
 -#if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_V6K)
 +#if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_V6K) || defined(CONFIG_CPU_V7)
  
  static void icedcc_putc(int ch)
  {
        asm("mcr p14, 0, %0, c0, c5, 0" : : "r" (ch));
  }
  
 -#elif defined(CONFIG_CPU_V7)
 -
 -static void icedcc_putc(int ch)
 -{
 -      asm(
 -      "wait:  mrc     p14, 0, pc, c0, c1, 0                   \n\
 -              bcs     wait                                    \n\
 -              mcr     p14, 0, %0, c0, c5, 0                   "
 -      : : "r" (ch));
 -}
  
  #elif defined(CONFIG_CPU_XSCALE)
  
@@@ -139,13 -147,12 +137,12 @@@ void *memcpy(void *__dest, __const voi
  }
  
  /*
-  * gzip delarations
+  * gzip declarations
   */
  extern char input_data[];
  extern char input_data_end[];
  
  unsigned char *output_data;
- unsigned long output_ptr;
  
  unsigned long free_mem_ptr;
  unsigned long free_mem_end_ptr;
@@@ -170,15 -177,15 +167,15 @@@ asmlinkage void __div0(void
        error("Attempting division by 0!");
  }
  
- extern void do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x));
+ extern int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x));
  
  
- unsigned long
+ void
  decompress_kernel(unsigned long output_start, unsigned long free_mem_ptr_p,
                unsigned long free_mem_ptr_end_p,
                int arch_id)
  {
-       unsigned char *tmp;
+       int ret;
  
        output_data             = (unsigned char *)output_start;
        free_mem_ptr            = free_mem_ptr_p;
  
        arch_decomp_setup();
  
-       tmp = (unsigned char *) (((unsigned long)input_data_end) - 4);
-       output_ptr = get_unaligned_le32(tmp);
        putstr("Uncompressing Linux...");
-       do_decompress(input_data, input_data_end - input_data,
-                       output_data, error);
-       putstr(" done, booting the kernel.\n");
-       return output_ptr;
+       ret = do_decompress(input_data, input_data_end - input_data,
+                           output_data, error);
+       if (ret)
+               error("decompressor returned an error");
+       else
+               putstr(" done, booting the kernel.\n");
  }