From 0c56ca17bf9766d6495ba29d11e80df1e840a06a Mon Sep 17 00:00:00 2001 From: Arun Chandran Date: Mon, 11 Aug 2014 15:21:27 +0530 Subject: [PATCH] LE BE switching worked with L3 Signed-off-by: Arun Chandran --- arch/arm64/kernel/machine_kexec.c | 1 - arch/arm64/kernel/relocate_kernel.S | 48 +++++++++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c index 363a246..5b15a00 100644 --- a/arch/arm64/kernel/machine_kexec.c +++ b/arch/arm64/kernel/machine_kexec.c @@ -623,7 +623,6 @@ static void kexec_list_flush_cb(void *ctx , unsigned int flag, break; case IND_SOURCE: __flush_dcache_area(addr, PAGE_SIZE); - __flush_dcache_area(dest, PAGE_SIZE); break; default: break; diff --git a/arch/arm64/kernel/relocate_kernel.S b/arch/arm64/kernel/relocate_kernel.S index 4b077e1..e890516 100644 --- a/arch/arm64/kernel/relocate_kernel.S +++ b/arch/arm64/kernel/relocate_kernel.S @@ -31,6 +31,13 @@ .align 3 +.macro dcache_line_size, reg, tmp +mrs \tmp, ctr_el0 // read CTR +ubfm \tmp, \tmp, #16, #19 // cache line size encoding +mov \reg, #4 // bytes per word +lsl \reg, \reg, \tmp // actual cache line size +.endm + .globl relocate_new_kernel relocate_new_kernel: @@ -56,25 +63,51 @@ relocate_new_kernel: .Ltest_source: tbz x10, IND_SOURCE_BIT, .Ltest_indirection - /* source: copy_page(x20 = dest, x21 = addr) */ + mov x0, x13 + add x1, x13, #PAGE_SIZE + + /* Invalidate the destination cache area to make sure that + * all the data required for the second stage kernel is + * intact at PoC. This is the safest place to do this activity + * as we are running with MMU and D-cache off. + */ +__inval_cache_range: + dcache_line_size x2, x3 + sub x3, x2, #1 + tst x1, x3 // end cache line aligned? + bic x1, x1, x3 + b.eq 1f + dc ivac, x1 // invalidate D / U line +1: tst x0, x3 // start cache line aligned? + bic x0, x0, x3 + b.eq 2f + dc ivac, x0 // invalidate D / U line + b 3f +2: dc ivac, x0 // invalidate D / U line +3: add x0, x0, x2 + cmp x0, x1 + b.lo 2b + dsb sy + /* source: copy_page(x20 = dest, x21 = addr) */ mov x20, x13 mov x21, x14 - prfm pldl1strm, [x21, #64] -1: ldp x22, x23, [x21] + /*prfm pldl1strm, [x21, #64] */ +.Lcopy_data: + ldp x22, x23, [x21] ldp x24, x25, [x21, #16] ldp x26, x27, [x21, #32] ldp x28, x29, [x21, #48] add x21, x21, #64 - prfm pldl1strm, [x21, #64] + /*prfm pldl1strm, [x21, #64]*/ stnp x22, x23, [x20] stnp x24, x25, [x20, #16] stnp x26, x27, [x20, #32] stnp x28, x29, [x20, #48] add x20, x20, #64 tst x21, #(PAGE_SIZE - 1) - b.ne 1b + b.ne .Lcopy_data /* dest += PAGE_SIZE */ @@ -115,6 +148,11 @@ relocate_new_kernel: mov x3, xzr ldr x4, kexec_kimage_start + + /* Clean entire I-cache */ + ic ialluis + isb + dsb sy br x4 .align 3 -- 1.7.9.5