Commit c8bef10a authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman

powerpc/8xx: Refactor kernel address boundary comparison

Now that linear and IMMR dedicated TLB handling is gone, kernel
boundary address comparison is similar in ITLB miss handler and
in DTLB miss handler.

Create a macro named compare_to_kernel_boundary.

When TASK_SIZE is strictly below 0x80000000 and PAGE_OFFSET is
above 0x80000000, it is enough to compare to 0x8000000, and this
can be done with a single instruction.

Using not. instruction, we get to use 'blt' conditional branch as
when doing a regular comparison:

0x00000000 <= addr <= 0x7fffffff ==>
0xffffffff >= NOT(addr) >= 0x80000000
The above test corresponds to a 'blt'

Otherwise, do a regular comparison using two instructions.
Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/6312575d06a8813105e6564a3b12e1d373aa1b2f.1589866984.git.christophe.leroy@csgroup.eu
parent a0591b60
...@@ -32,10 +32,15 @@ ...@@ -32,10 +32,15 @@
#include "head_32.h" #include "head_32.h"
.macro compare_to_kernel_boundary scratch, addr
#if CONFIG_TASK_SIZE <= 0x80000000 && CONFIG_PAGE_OFFSET >= 0x80000000 #if CONFIG_TASK_SIZE <= 0x80000000 && CONFIG_PAGE_OFFSET >= 0x80000000
/* By simply checking Address >= 0x80000000, we know if its a kernel address */ /* By simply checking Address >= 0x80000000, we know if its a kernel address */
#define SIMPLE_KERNEL_ADDRESS 1 not. \scratch, \addr
#else
rlwinm \scratch, \addr, 16, 0xfff8
cmpli cr0, \scratch, PAGE_OFFSET@h
#endif #endif
.endm
/* /*
* We need an ITLB miss handler for kernel addresses if: * We need an ITLB miss handler for kernel addresses if:
...@@ -209,20 +214,11 @@ InstructionTLBMiss: ...@@ -209,20 +214,11 @@ InstructionTLBMiss:
mtspr SPRN_MD_EPN, r10 mtspr SPRN_MD_EPN, r10
#ifdef ITLB_MISS_KERNEL #ifdef ITLB_MISS_KERNEL
mfcr r11 mfcr r11
#if defined(SIMPLE_KERNEL_ADDRESS) compare_to_kernel_boundary r10, r10
cmpi cr0, r10, 0 /* Address >= 0x80000000 */
#else
rlwinm r10, r10, 16, 0xfff8
cmpli cr0, r10, PAGE_OFFSET@h
#endif
#endif #endif
mfspr r10, SPRN_M_TWB /* Get level 1 table */ mfspr r10, SPRN_M_TWB /* Get level 1 table */
#ifdef ITLB_MISS_KERNEL #ifdef ITLB_MISS_KERNEL
#if defined(SIMPLE_KERNEL_ADDRESS)
bge+ 3f
#else
blt+ 3f blt+ 3f
#endif
rlwinm r10, r10, 0, 20, 31 rlwinm r10, r10, 0, 20, 31
oris r10, r10, (swapper_pg_dir - PAGE_OFFSET)@ha oris r10, r10, (swapper_pg_dir - PAGE_OFFSET)@ha
3: 3:
...@@ -288,9 +284,7 @@ DataStoreTLBMiss: ...@@ -288,9 +284,7 @@ DataStoreTLBMiss:
* kernel page tables. * kernel page tables.
*/ */
mfspr r10, SPRN_MD_EPN mfspr r10, SPRN_MD_EPN
rlwinm r10, r10, 16, 0xfff8 compare_to_kernel_boundary r10, r10
cmpli cr0, r10, PAGE_OFFSET@h
mfspr r10, SPRN_M_TWB /* Get level 1 table */ mfspr r10, SPRN_M_TWB /* Get level 1 table */
blt+ 3f blt+ 3f
rlwinm r10, r10, 0, 20, 31 rlwinm r10, r10, 0, 20, 31
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment