@@ -58,68 +58,59 @@ static inline unsigned long nmi_get_mcesa_size(void)
5858
5959/*
6060 * The initial machine check extended save area for the boot CPU.
61- * It will be replaced by nmi_init() with an allocated structure.
62- * The structure is required for machine check happening early in
63- * the boot process.
61+ * It will be replaced on the boot CPU reinit with an allocated
62+ * structure. The structure is required for machine check happening
63+ * early in the boot process.
6464 */
6565static struct mcesa boot_mcesa __initdata __aligned (MCESA_MAX_SIZE );
6666
67- void __init nmi_alloc_boot_cpu ( struct lowcore * lc )
67+ void __init nmi_alloc_mcesa_early ( u64 * mcesad )
6868{
6969 if (!nmi_needs_mcesa ())
7070 return ;
71- lc -> mcesad = __pa (& boot_mcesa );
71+ * mcesad = __pa (& boot_mcesa );
7272 if (MACHINE_HAS_GS )
73- lc -> mcesad |= ilog2 (MCESA_MAX_SIZE );
73+ * mcesad |= ilog2 (MCESA_MAX_SIZE );
7474}
7575
76- static int __init nmi_init (void )
76+ static void __init nmi_alloc_cache (void )
7777{
78- unsigned long origin , cr0 , size ;
78+ unsigned long size ;
7979
8080 if (!nmi_needs_mcesa ())
81- return 0 ;
81+ return ;
8282 size = nmi_get_mcesa_size ();
8383 if (size > MCESA_MIN_SIZE )
8484 mcesa_origin_lc = ilog2 (size );
8585 /* create slab cache for the machine-check-extended-save-areas */
8686 mcesa_cache = kmem_cache_create ("nmi_save_areas" , size , size , 0 , NULL );
8787 if (!mcesa_cache )
8888 panic ("Couldn't create nmi save area cache" );
89- origin = (unsigned long ) kmem_cache_alloc (mcesa_cache , GFP_KERNEL );
90- if (!origin )
91- panic ("Couldn't allocate nmi save area" );
92- /* The pointer is stored with mcesa_bits ORed in */
93- kmemleak_not_leak ((void * ) origin );
94- __ctl_store (cr0 , 0 , 0 );
95- __ctl_clear_bit (0 , 28 ); /* disable lowcore protection */
96- /* Replace boot_mcesa on the boot CPU */
97- S390_lowcore .mcesad = __pa (origin ) | mcesa_origin_lc ;
98- __ctl_load (cr0 , 0 , 0 );
99- return 0 ;
10089}
101- early_initcall (nmi_init );
10290
103- int nmi_alloc_per_cpu ( struct lowcore * lc )
91+ int __ref nmi_alloc_mcesa ( u64 * mcesad )
10492{
10593 unsigned long origin ;
10694
95+ * mcesad = 0 ;
10796 if (!nmi_needs_mcesa ())
10897 return 0 ;
98+ if (!mcesa_cache )
99+ nmi_alloc_cache ();
109100 origin = (unsigned long ) kmem_cache_alloc (mcesa_cache , GFP_KERNEL );
110101 if (!origin )
111102 return - ENOMEM ;
112103 /* The pointer is stored with mcesa_bits ORed in */
113104 kmemleak_not_leak ((void * ) origin );
114- lc -> mcesad = __pa (origin ) | mcesa_origin_lc ;
105+ * mcesad = __pa (origin ) | mcesa_origin_lc ;
115106 return 0 ;
116107}
117108
118- void nmi_free_per_cpu ( struct lowcore * lc )
109+ void nmi_free_mcesa ( u64 * mcesad )
119110{
120111 if (!nmi_needs_mcesa ())
121112 return ;
122- kmem_cache_free (mcesa_cache , __va (lc -> mcesad & MCESA_ORIGIN_MASK ));
113+ kmem_cache_free (mcesa_cache , __va (* mcesad & MCESA_ORIGIN_MASK ));
123114}
124115
125116static notrace void s390_handle_damage (void )
0 commit comments