diff options
author | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2009-12-07 06:51:43 -0500 |
---|---|---|
committer | Martin Schwidefsky <sky@mschwide.boeblingen.de.ibm.com> | 2009-12-07 06:51:33 -0500 |
commit | b11b53342773361f3353b285eb6a3fd6074e7997 (patch) | |
tree | b7fda314933b82d39cb8d30c7882ca3044dd0367 /arch/s390/kernel | |
parent | 61365e132ef987f7719af5d2e434db4465957637 (diff) |
[S390] Improve address space mode selection.
Introduce user_mode to replace the two variables switch_amode and
s390_noexec. There are three valid combinations of the old values:
1) switch_amode == 0 && s390_noexec == 0
2) switch_amode == 1 && s390_noexec == 0
3) switch_amode == 1 && s390_noexec == 1
They get replaced by
1) user_mode == HOME_SPACE_MODE
2) user_mode == PRIMARY_SPACE_MODE
3) user_mode == SECONDARY_SPACE_MODE
The new kernel parameter user_mode=[primary,secondary,home] lets
you choose the address space mode the user space processes should
use. In addition the CONFIG_S390_SWITCH_AMODE config option
is removed.
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/kernel')
-rw-r--r-- | arch/s390/kernel/setup.c | 36 | ||||
-rw-r--r-- | arch/s390/kernel/vdso.c | 9 |
2 files changed, 25 insertions, 20 deletions
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c index 061479ff029f..0663287fa1b3 100644 --- a/arch/s390/kernel/setup.c +++ b/arch/s390/kernel/setup.c | |||
@@ -305,9 +305,8 @@ static int __init early_parse_mem(char *p) | |||
305 | } | 305 | } |
306 | early_param("mem", early_parse_mem); | 306 | early_param("mem", early_parse_mem); |
307 | 307 | ||
308 | #ifdef CONFIG_S390_SWITCH_AMODE | 308 | unsigned int user_mode = HOME_SPACE_MODE; |
309 | unsigned int switch_amode = 0; | 309 | EXPORT_SYMBOL_GPL(user_mode); |
310 | EXPORT_SYMBOL_GPL(switch_amode); | ||
311 | 310 | ||
312 | static int set_amode_and_uaccess(unsigned long user_amode, | 311 | static int set_amode_and_uaccess(unsigned long user_amode, |
313 | unsigned long user32_amode) | 312 | unsigned long user32_amode) |
@@ -340,23 +339,29 @@ static int set_amode_and_uaccess(unsigned long user_amode, | |||
340 | */ | 339 | */ |
341 | static int __init early_parse_switch_amode(char *p) | 340 | static int __init early_parse_switch_amode(char *p) |
342 | { | 341 | { |
343 | switch_amode = 1; | 342 | if (user_mode != SECONDARY_SPACE_MODE) |
343 | user_mode = PRIMARY_SPACE_MODE; | ||
344 | return 0; | 344 | return 0; |
345 | } | 345 | } |
346 | early_param("switch_amode", early_parse_switch_amode); | 346 | early_param("switch_amode", early_parse_switch_amode); |
347 | 347 | ||
348 | #else /* CONFIG_S390_SWITCH_AMODE */ | 348 | static int __init early_parse_user_mode(char *p) |
349 | static inline int set_amode_and_uaccess(unsigned long user_amode, | ||
350 | unsigned long user32_amode) | ||
351 | { | 349 | { |
350 | if (p && strcmp(p, "primary") == 0) | ||
351 | user_mode = PRIMARY_SPACE_MODE; | ||
352 | #ifdef CONFIG_S390_EXEC_PROTECT | ||
353 | else if (p && strcmp(p, "secondary") == 0) | ||
354 | user_mode = SECONDARY_SPACE_MODE; | ||
355 | #endif | ||
356 | else if (!p || strcmp(p, "home") == 0) | ||
357 | user_mode = HOME_SPACE_MODE; | ||
358 | else | ||
359 | return 1; | ||
352 | return 0; | 360 | return 0; |
353 | } | 361 | } |
354 | #endif /* CONFIG_S390_SWITCH_AMODE */ | 362 | early_param("user_mode", early_parse_user_mode); |
355 | 363 | ||
356 | #ifdef CONFIG_S390_EXEC_PROTECT | 364 | #ifdef CONFIG_S390_EXEC_PROTECT |
357 | unsigned int s390_noexec = 0; | ||
358 | EXPORT_SYMBOL_GPL(s390_noexec); | ||
359 | |||
360 | /* | 365 | /* |
361 | * Enable execute protection? | 366 | * Enable execute protection? |
362 | */ | 367 | */ |
@@ -364,8 +369,7 @@ static int __init early_parse_noexec(char *p) | |||
364 | { | 369 | { |
365 | if (!strncmp(p, "off", 3)) | 370 | if (!strncmp(p, "off", 3)) |
366 | return 0; | 371 | return 0; |
367 | switch_amode = 1; | 372 | user_mode = SECONDARY_SPACE_MODE; |
368 | s390_noexec = 1; | ||
369 | return 0; | 373 | return 0; |
370 | } | 374 | } |
371 | early_param("noexec", early_parse_noexec); | 375 | early_param("noexec", early_parse_noexec); |
@@ -373,7 +377,7 @@ early_param("noexec", early_parse_noexec); | |||
373 | 377 | ||
374 | static void setup_addressing_mode(void) | 378 | static void setup_addressing_mode(void) |
375 | { | 379 | { |
376 | if (s390_noexec) { | 380 | if (user_mode == SECONDARY_SPACE_MODE) { |
377 | if (set_amode_and_uaccess(PSW_ASC_SECONDARY, | 381 | if (set_amode_and_uaccess(PSW_ASC_SECONDARY, |
378 | PSW32_ASC_SECONDARY)) | 382 | PSW32_ASC_SECONDARY)) |
379 | pr_info("Execute protection active, " | 383 | pr_info("Execute protection active, " |
@@ -381,7 +385,7 @@ static void setup_addressing_mode(void) | |||
381 | else | 385 | else |
382 | pr_info("Execute protection active, " | 386 | pr_info("Execute protection active, " |
383 | "mvcos not available\n"); | 387 | "mvcos not available\n"); |
384 | } else if (switch_amode) { | 388 | } else if (user_mode == PRIMARY_SPACE_MODE) { |
385 | if (set_amode_and_uaccess(PSW_ASC_PRIMARY, PSW32_ASC_PRIMARY)) | 389 | if (set_amode_and_uaccess(PSW_ASC_PRIMARY, PSW32_ASC_PRIMARY)) |
386 | pr_info("Address spaces switched, " | 390 | pr_info("Address spaces switched, " |
387 | "mvcos available\n"); | 391 | "mvcos available\n"); |
@@ -411,7 +415,7 @@ setup_lowcore(void) | |||
411 | lc->restart_psw.mask = PSW_BASE_BITS | PSW_DEFAULT_KEY; | 415 | lc->restart_psw.mask = PSW_BASE_BITS | PSW_DEFAULT_KEY; |
412 | lc->restart_psw.addr = | 416 | lc->restart_psw.addr = |
413 | PSW_ADDR_AMODE | (unsigned long) restart_int_handler; | 417 | PSW_ADDR_AMODE | (unsigned long) restart_int_handler; |
414 | if (switch_amode) | 418 | if (user_mode != HOME_SPACE_MODE) |
415 | lc->restart_psw.mask |= PSW_ASC_HOME; | 419 | lc->restart_psw.mask |= PSW_ASC_HOME; |
416 | lc->external_new_psw.mask = psw_kernel_bits; | 420 | lc->external_new_psw.mask = psw_kernel_bits; |
417 | lc->external_new_psw.addr = | 421 | lc->external_new_psw.addr = |
diff --git a/arch/s390/kernel/vdso.c b/arch/s390/kernel/vdso.c index adfb32aa6d59..5f99e66c51c3 100644 --- a/arch/s390/kernel/vdso.c +++ b/arch/s390/kernel/vdso.c | |||
@@ -86,7 +86,8 @@ static void vdso_init_data(struct vdso_data *vd) | |||
86 | unsigned int facility_list; | 86 | unsigned int facility_list; |
87 | 87 | ||
88 | facility_list = stfl(); | 88 | facility_list = stfl(); |
89 | vd->ectg_available = switch_amode && (facility_list & 1); | 89 | vd->ectg_available = |
90 | user_mode != HOME_SPACE_MODE && (facility_list & 1); | ||
90 | } | 91 | } |
91 | 92 | ||
92 | #ifdef CONFIG_64BIT | 93 | #ifdef CONFIG_64BIT |
@@ -114,7 +115,7 @@ int vdso_alloc_per_cpu(int cpu, struct _lowcore *lowcore) | |||
114 | 115 | ||
115 | lowcore->vdso_per_cpu_data = __LC_PASTE; | 116 | lowcore->vdso_per_cpu_data = __LC_PASTE; |
116 | 117 | ||
117 | if (!switch_amode || !vdso_enabled) | 118 | if (user_mode == HOME_SPACE_MODE || !vdso_enabled) |
118 | return 0; | 119 | return 0; |
119 | 120 | ||
120 | segment_table = __get_free_pages(GFP_KERNEL, SEGMENT_ORDER); | 121 | segment_table = __get_free_pages(GFP_KERNEL, SEGMENT_ORDER); |
@@ -160,7 +161,7 @@ void vdso_free_per_cpu(int cpu, struct _lowcore *lowcore) | |||
160 | unsigned long segment_table, page_table, page_frame; | 161 | unsigned long segment_table, page_table, page_frame; |
161 | u32 *psal, *aste; | 162 | u32 *psal, *aste; |
162 | 163 | ||
163 | if (!switch_amode || !vdso_enabled) | 164 | if (user_mode == HOME_SPACE_MODE || !vdso_enabled) |
164 | return; | 165 | return; |
165 | 166 | ||
166 | psal = (u32 *)(addr_t) lowcore->paste[4]; | 167 | psal = (u32 *)(addr_t) lowcore->paste[4]; |
@@ -184,7 +185,7 @@ static void __vdso_init_cr5(void *dummy) | |||
184 | 185 | ||
185 | static void vdso_init_cr5(void) | 186 | static void vdso_init_cr5(void) |
186 | { | 187 | { |
187 | if (switch_amode && vdso_enabled) | 188 | if (user_mode != HOME_SPACE_MODE && vdso_enabled) |
188 | on_each_cpu(__vdso_init_cr5, NULL, 1); | 189 | on_each_cpu(__vdso_init_cr5, NULL, 1); |
189 | } | 190 | } |
190 | #endif /* CONFIG_64BIT */ | 191 | #endif /* CONFIG_64BIT */ |