2019-06-03 07:44:50 +02:00
/* SPDX-License-Identifier: GPL-2.0-only */
2016-04-27 17:47:12 +01:00
/ *
* Hibernate l o w - l e v e l s u p p o r t
*
* Copyright ( C ) 2 0 1 6 A R M L t d .
* Author : James M o r s e < j a m e s . m o r s e @arm.com>
* /
# include < l i n u x / l i n k a g e . h >
# include < l i n u x / e r r n o . h >
# include < a s m / a s m - o f f s e t s . h >
# include < a s m / a s s e m b l e r . h >
# include < a s m / c p u t y p e . h >
# include < a s m / m e m o r y . h >
# include < a s m / p a g e . h >
# include < a s m / v i r t . h >
/ *
* Resume f r o m h i b e r n a t e
*
* Loads t e m p o r a r y p a g e t a b l e s t h e n r e s t o r e s t h e m e m o r y i m a g e .
* Finally b r a n c h e s t o c p u _ r e s u m e ( ) t o r e s t o r e t h e s t a t e s a v e d b y
* swsusp_ a r c h _ s u s p e n d ( ) .
*
* Because t h i s c o d e h a s t o b e c o p i e d t o a ' s a f e ' p a g e , i t c a n ' t c a l l o u t t o
* other f u n c t i o n s b y P C - r e l a t i v e a d d r e s s . A l s o r e m e m b e r t h a t i t m a y b e
* mid- w a y t h r o u g h o v e r - w r i t i n g o t h e r f u n c t i o n s . F o r t h i s r e a s o n i t c o n t a i n s
arm64: Rename arm64-internal cache maintenance functions
Although naming across the codebase isn't that consistent, it
tends to follow certain patterns. Moreover, the term "flush"
isn't defined in the Arm Architecture reference manual, and might
be interpreted to mean clean, invalidate, or both for a cache.
Rename arm64-internal functions to make the naming internally
consistent, as well as making it consistent with the Arm ARM, by
specifying whether it applies to the instruction, data, or both
caches, whether the operation is a clean, invalidate, or both.
Also specify which point the operation applies to, i.e., to the
point of unification (PoU), coherency (PoC), or persistence
(PoP).
This commit applies the following sed transformation to all files
under arch/arm64:
"s/\b__flush_cache_range\b/caches_clean_inval_pou_macro/g;"\
"s/\b__flush_icache_range\b/caches_clean_inval_pou/g;"\
"s/\binvalidate_icache_range\b/icache_inval_pou/g;"\
"s/\b__flush_dcache_area\b/dcache_clean_inval_poc/g;"\
"s/\b__inval_dcache_area\b/dcache_inval_poc/g;"\
"s/__clean_dcache_area_poc\b/dcache_clean_poc/g;"\
"s/\b__clean_dcache_area_pop\b/dcache_clean_pop/g;"\
"s/\b__clean_dcache_area_pou\b/dcache_clean_pou/g;"\
"s/\b__flush_cache_user_range\b/caches_clean_inval_user_pou/g;"\
"s/\b__flush_icache_all\b/icache_inval_all_pou/g;"
Note that __clean_dcache_area_poc is deliberately missing a word
boundary check at the beginning in order to match the efistub
symbols in image-vars.h.
Also note that, despite its name, __flush_icache_range operates
on both instruction and data caches. The name change here
reflects that.
No functional change intended.
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Fuad Tabba <tabba@google.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20210524083001.2586635-19-tabba@google.com
Signed-off-by: Will Deacon <will@kernel.org>
2021-05-24 09:30:01 +01:00
* code f r o m c a c h e s _ c l e a n _ i n v a l _ p o u ( ) a n d u s e s t h e c o p y _ p a g e ( ) m a c r o .
2016-04-27 17:47:12 +01:00
*
* This ' s a f e ' p a g e i s m a p p e d v i a t t b r0 , a n d e x e c u t e d f r o m t h e r e . T h i s f u n c t i o n
* switches t o a c o p y o f t h e l i n e a r m a p i n t t b r1 , p e r f o r m s t h e r e s t o r e , t h e n
* switches t t b r1 t o t h e o r i g i n a l k e r n e l ' s s w a p p e r _ p g _ d i r .
*
* All o f m e m o r y g e t s w r i t t e n t o , i n c l u d i n g c o d e . W e n e e d t o c l e a n t h e k e r n e l
* text t o t h e P o i n t o f C o h e r e n c e ( P o C ) b e f o r e s e c o n d a r y c o r e s c a n b e b o o t e d .
* Because t h e k e r n e l m o d u l e s a n d e x e c u t a b l e p a g e s m a p p e d t o u s e r s p a c e a r e
* also w r i t t e n a s d a t a , w e c l e a n a l l p a g e s w e t o u c h t o t h e P o i n t o f
* Unification ( P o U ) .
*
* x0 : physical a d d r e s s o f t e m p o r a r y p a g e t a b l e s
* x1 : physical a d d r e s s o f s w a p p e r p a g e t a b l e s
* x2 : address o f c p u _ r e s u m e
* x3 : linear m a p a d d r e s s o f r e s t o r e _ p b l i s t i n t h e c u r r e n t k e r n e l
* x4 : physical a d d r e s s o f _ _ h y p _ s t u b _ v e c t o r s , o r 0
* x5 : physical a d d r e s s o f a z e r o p a g e t h a t r e m a i n s z e r o a f t e r r e s u m e
* /
.pushsection " .hibernate_exit .text " , " ax"
2020-05-01 12:54:29 +01:00
SYM_ C O D E _ S T A R T ( s w s u s p _ a r c h _ s u s p e n d _ e x i t )
2016-04-27 17:47:12 +01:00
/ *
* We e x e c u t e f r o m t t b r0 , c h a n g e t t b r1 t o o u r c o p i e d l i n e a r m a p t a b l e s
* with a b r e a k - b e f o r e - m a k e v i a t h e z e r o p a g e
* /
2019-08-07 16:55:19 +01:00
break_ b e f o r e _ m a k e _ t t b r _ s w i t c h x5 , x0 , x6 , x8
2016-04-27 17:47:12 +01:00
mov x21 , x1
mov x30 , x2
mov x24 , x4
mov x25 , x5
/* walk the restore_pblist and use copy_page() to over-write memory */
mov x19 , x3
1 : ldr x10 , [ x19 , #H I B E R N _ P B E _ O R I G ]
mov x0 , x10
ldr x1 , [ x19 , #H I B E R N _ P B E _ A D D R ]
copy_ p a g e x0 , x1 , x2 , x3 , x4 , x5 , x6 , x7 , x8 , x9
add x1 , x10 , #P A G E _ S I Z E
arm64: Rename arm64-internal cache maintenance functions
Although naming across the codebase isn't that consistent, it
tends to follow certain patterns. Moreover, the term "flush"
isn't defined in the Arm Architecture reference manual, and might
be interpreted to mean clean, invalidate, or both for a cache.
Rename arm64-internal functions to make the naming internally
consistent, as well as making it consistent with the Arm ARM, by
specifying whether it applies to the instruction, data, or both
caches, whether the operation is a clean, invalidate, or both.
Also specify which point the operation applies to, i.e., to the
point of unification (PoU), coherency (PoC), or persistence
(PoP).
This commit applies the following sed transformation to all files
under arch/arm64:
"s/\b__flush_cache_range\b/caches_clean_inval_pou_macro/g;"\
"s/\b__flush_icache_range\b/caches_clean_inval_pou/g;"\
"s/\binvalidate_icache_range\b/icache_inval_pou/g;"\
"s/\b__flush_dcache_area\b/dcache_clean_inval_poc/g;"\
"s/\b__inval_dcache_area\b/dcache_inval_poc/g;"\
"s/__clean_dcache_area_poc\b/dcache_clean_poc/g;"\
"s/\b__clean_dcache_area_pop\b/dcache_clean_pop/g;"\
"s/\b__clean_dcache_area_pou\b/dcache_clean_pou/g;"\
"s/\b__flush_cache_user_range\b/caches_clean_inval_user_pou/g;"\
"s/\b__flush_icache_all\b/icache_inval_all_pou/g;"
Note that __clean_dcache_area_poc is deliberately missing a word
boundary check at the beginning in order to match the efistub
symbols in image-vars.h.
Also note that, despite its name, __flush_icache_range operates
on both instruction and data caches. The name change here
reflects that.
No functional change intended.
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Fuad Tabba <tabba@google.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20210524083001.2586635-19-tabba@google.com
Signed-off-by: Will Deacon <will@kernel.org>
2021-05-24 09:30:01 +01:00
/* Clean the copied page to PoU - based on caches_clean_inval_pou() */
2016-09-09 14:07:14 +01:00
raw_ d c a c h e _ l i n e _ s i z e x2 , x3
2016-04-27 17:47:12 +01:00
sub x3 , x2 , #1
bic x4 , x10 , x3
2021-05-24 09:29:46 +01:00
2 : /* clean D line / unified line */
alternative_ i n s n " d c c v a u , x4 " , " d c c i v a c , x4 " , A R M 6 4 _ W O R K A R O U N D _ C L E A N _ C A C H E
2016-04-27 17:47:12 +01:00
add x4 , x4 , x2
cmp x4 , x1
b. l o 2 b
ldr x19 , [ x19 , #H I B E R N _ P B E _ N E X T ]
cbnz x19 , 1 b
dsb i s h / * w a i t f o r P o U c l e a n i n g t o f i n i s h * /
/* switch to the restored kernels page tables */
2019-08-07 16:55:19 +01:00
break_ b e f o r e _ m a k e _ t t b r _ s w i t c h x25 , x21 , x6 , x8
2016-04-27 17:47:12 +01:00
ic i a l l u i s
dsb i s h
isb
cbz x24 , 3 f / * D o w e n e e d t o r e - i n i t i a l i s e E L 2 ? * /
hvc #0
3 : ret
2020-05-01 12:54:29 +01:00
SYM_ C O D E _ E N D ( s w s u s p _ a r c h _ s u s p e n d _ e x i t )
2016-04-27 17:47:12 +01:00
.popsection