@@ -169,17 +169,64 @@ module_param_named(debug, uv_nmi_debug, int, 0644);
169
169
pr_info(fmt, ##__VA_ARGS__); \
170
170
} while (0)
171
171
172
- /*
173
- * Valid NMI Actions:
174
- * "dump" - dump process stack for each cpu
175
- * "ips" - dump IP info for each cpu
176
- * "kdump" - do crash dump
177
- * "kdb" - enter KDB (default)
178
- * "kgdb" - enter KGDB
179
- * "health" - check if CPUs respond to NMI
180
- */
181
- static char uv_nmi_action [8 ] = "kdb" ;
182
- module_param_string (action , uv_nmi_action , sizeof (uv_nmi_action ), 0644 );
172
+ /* Valid NMI Actions */
173
+ #define ACTION_LEN 16
174
+ static struct nmi_action {
175
+ char * action ;
176
+ char * desc ;
177
+ } valid_acts [] = {
178
+ { "kdump" , "do kernel crash dump" },
179
+ { "dump" , "dump process stack for each cpu" },
180
+ { "ips" , "dump Inst Ptr info for each cpu" },
181
+ { "kdb" , "enter KDB (needs kgdboc= assignment)" },
182
+ { "kgdb" , "enter KGDB (needs gdb target remote)" },
183
+ { "health" , "check if CPUs respond to NMI" },
184
+ };
185
+ typedef char action_t [ACTION_LEN ];
186
+ static action_t uv_nmi_action = { "dump" };
187
+
188
+ static int param_get_action (char * buffer , const struct kernel_param * kp )
189
+ {
190
+ return sprintf (buffer , "%s\n" , uv_nmi_action );
191
+ }
192
+
193
+ static int param_set_action (const char * val , const struct kernel_param * kp )
194
+ {
195
+ int i ;
196
+ int n = ARRAY_SIZE (valid_acts );
197
+ char arg [ACTION_LEN ], * p ;
198
+
199
+ /* (remove possible '\n') */
200
+ strncpy (arg , val , ACTION_LEN - 1 );
201
+ arg [ACTION_LEN - 1 ] = '\0' ;
202
+ p = strchr (arg , '\n' );
203
+ if (p )
204
+ * p = '\0' ;
205
+
206
+ for (i = 0 ; i < n ; i ++ )
207
+ if (!strcmp (arg , valid_acts [i ].action ))
208
+ break ;
209
+
210
+ if (i < n ) {
211
+ strcpy (uv_nmi_action , arg );
212
+ pr_info ("UV: New NMI action:%s\n" , uv_nmi_action );
213
+ return 0 ;
214
+ }
215
+
216
+ pr_err ("UV: Invalid NMI action:%s, valid actions are:\n" , arg );
217
+ for (i = 0 ; i < n ; i ++ )
218
+ pr_err ("UV: %-8s - %s\n" ,
219
+ valid_acts [i ].action , valid_acts [i ].desc );
220
+ return - EINVAL ;
221
+ }
222
+
223
+ static const struct kernel_param_ops param_ops_action = {
224
+ .get = param_get_action ,
225
+ .set = param_set_action ,
226
+ };
227
+ #define param_check_action (name , p ) __param_check(name, p, action_t)
228
+
229
+ module_param_named (action , uv_nmi_action , action , 0644 );
183
230
184
231
static inline bool uv_nmi_action_is (const char * action )
185
232
{
0 commit comments