@@ -126,6 +126,36 @@ static bool __head check_la57_support(unsigned long physaddr)
126
126
}
127
127
#endif
128
128
129
+ static unsigned long sme_postprocess_startup (struct boot_params * bp , pmdval_t * pmd )
130
+ {
131
+ unsigned long vaddr , vaddr_end ;
132
+ int i ;
133
+
134
+ /* Encrypt the kernel and related (if SME is active) */
135
+ sme_encrypt_kernel (bp );
136
+
137
+ /*
138
+ * Clear the memory encryption mask from the .bss..decrypted section.
139
+ * The bss section will be memset to zero later in the initialization so
140
+ * there is no need to zero it after changing the memory encryption
141
+ * attribute.
142
+ */
143
+ if (sme_get_me_mask ()) {
144
+ vaddr = (unsigned long )__start_bss_decrypted ;
145
+ vaddr_end = (unsigned long )__end_bss_decrypted ;
146
+ for (; vaddr < vaddr_end ; vaddr += PMD_SIZE ) {
147
+ i = pmd_index (vaddr );
148
+ pmd [i ] -= sme_get_me_mask ();
149
+ }
150
+ }
151
+
152
+ /*
153
+ * Return the SME encryption mask (if SME is active) to be used as a
154
+ * modifier for the initial pgdir entry programmed into CR3.
155
+ */
156
+ return sme_get_me_mask ();
157
+ }
158
+
129
159
/* Code in __startup_64() can be relocated during execution, but the compiler
130
160
* doesn't have to generate PC-relative relocations when accessing globals from
131
161
* that function. Clang actually does not generate them, which leads to
@@ -135,7 +165,6 @@ static bool __head check_la57_support(unsigned long physaddr)
135
165
unsigned long __head __startup_64 (unsigned long physaddr ,
136
166
struct boot_params * bp )
137
167
{
138
- unsigned long vaddr , vaddr_end ;
139
168
unsigned long load_delta , * p ;
140
169
unsigned long pgtable_flags ;
141
170
pgdval_t * pgd ;
@@ -276,34 +305,7 @@ unsigned long __head __startup_64(unsigned long physaddr,
276
305
*/
277
306
* fixup_long (& phys_base , physaddr ) += load_delta - sme_get_me_mask ();
278
307
279
- /* Encrypt the kernel and related (if SME is active) */
280
- sme_encrypt_kernel (bp );
281
-
282
- /*
283
- * Clear the memory encryption mask from the .bss..decrypted section.
284
- * The bss section will be memset to zero later in the initialization so
285
- * there is no need to zero it after changing the memory encryption
286
- * attribute.
287
- *
288
- * This is early code, use an open coded check for SME instead of
289
- * using cc_platform_has(). This eliminates worries about removing
290
- * instrumentation or checking boot_cpu_data in the cc_platform_has()
291
- * function.
292
- */
293
- if (sme_get_me_mask ()) {
294
- vaddr = (unsigned long )__start_bss_decrypted ;
295
- vaddr_end = (unsigned long )__end_bss_decrypted ;
296
- for (; vaddr < vaddr_end ; vaddr += PMD_SIZE ) {
297
- i = pmd_index (vaddr );
298
- pmd [i ] -= sme_get_me_mask ();
299
- }
300
- }
301
-
302
- /*
303
- * Return the SME encryption mask (if SME is active) to be used as a
304
- * modifier for the initial pgdir entry programmed into CR3.
305
- */
306
- return sme_get_me_mask ();
308
+ return sme_postprocess_startup (bp , pmd );
307
309
}
308
310
309
311
unsigned long __startup_secondary_64 (void )
0 commit comments