Skip to content

Commit 468a3bc

Browse files
hcahcaVasily Gorbik
authored andcommitted
s390/cmma: move parsing of cmma kernel parameter to early boot code
The "cmma=" kernel command line parameter needs to be parsed early for upcoming changes. Therefore move the parsing code. Note that EX_TABLE handling of cmma_test_essa() needs to be open-coded, since the early boot code doesn't have infrastructure for handling expected exceptions. Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent 92b519f commit 468a3bc

File tree

7 files changed

+58
-42
lines changed

7 files changed

+58
-42
lines changed

arch/s390/boot/ipl_parm.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <linux/init.h>
44
#include <linux/ctype.h>
55
#include <linux/pgtable.h>
6+
#include <asm/page-states.h>
67
#include <asm/ebcdic.h>
78
#include <asm/sclp.h>
89
#include <asm/sections.h>
@@ -24,6 +25,7 @@ unsigned int __bootdata_preserved(zlib_dfltcc_support) = ZLIB_DFLTCC_FULL;
2425
struct ipl_parameter_block __bootdata_preserved(ipl_block);
2526
int __bootdata_preserved(ipl_block_valid);
2627
int __bootdata_preserved(__kaslr_enabled);
28+
int __bootdata_preserved(cmma_flag) = 1;
2729

2830
unsigned long vmalloc_size = VMALLOC_DEFAULT_SIZE;
2931
unsigned long memory_limit;
@@ -295,6 +297,12 @@ void parse_boot_command_line(void)
295297
if (!strcmp(param, "nokaslr"))
296298
__kaslr_enabled = 0;
297299

300+
if (!strcmp(param, "cmma")) {
301+
rc = kstrtobool(val, &enabled);
302+
if (!rc && !enabled)
303+
cmma_flag = 0;
304+
}
305+
298306
#if IS_ENABLED(CONFIG_KVM)
299307
if (!strcmp(param, "prot_virt")) {
300308
rc = kstrtobool(val, &enabled);

arch/s390/boot/startup.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#include <linux/string.h>
33
#include <linux/elf.h>
4+
#include <asm/page-states.h>
45
#include <asm/boot_data.h>
56
#include <asm/sections.h>
67
#include <asm/maccess.h>
@@ -57,6 +58,48 @@ static void detect_facilities(void)
5758
machine.has_nx = 1;
5859
}
5960

61+
static int cmma_test_essa(void)
62+
{
63+
unsigned long reg1, reg2, tmp = 0;
64+
int rc = 1;
65+
psw_t old;
66+
67+
/* Test ESSA_GET_STATE */
68+
asm volatile(
69+
" mvc 0(16,%[psw_old]),0(%[psw_pgm])\n"
70+
" epsw %[reg1],%[reg2]\n"
71+
" st %[reg1],0(%[psw_pgm])\n"
72+
" st %[reg2],4(%[psw_pgm])\n"
73+
" larl %[reg1],1f\n"
74+
" stg %[reg1],8(%[psw_pgm])\n"
75+
" .insn rrf,0xb9ab0000,%[tmp],%[tmp],%[cmd],0\n"
76+
" la %[rc],0\n"
77+
"1: mvc 0(16,%[psw_pgm]),0(%[psw_old])\n"
78+
: [reg1] "=&d" (reg1),
79+
[reg2] "=&a" (reg2),
80+
[rc] "+&d" (rc),
81+
[tmp] "=&d" (tmp),
82+
"+Q" (S390_lowcore.program_new_psw),
83+
"=Q" (old)
84+
: [psw_old] "a" (&old),
85+
[psw_pgm] "a" (&S390_lowcore.program_new_psw),
86+
[cmd] "i" (ESSA_GET_STATE)
87+
: "cc", "memory");
88+
return rc;
89+
}
90+
91+
static void cmma_init(void)
92+
{
93+
if (!cmma_flag)
94+
return;
95+
if (cmma_test_essa()) {
96+
cmma_flag = 0;
97+
return;
98+
}
99+
if (test_facility(147))
100+
cmma_flag = 2;
101+
}
102+
60103
static void setup_lpp(void)
61104
{
62105
S390_lowcore.current_pid = 0;
@@ -306,6 +349,7 @@ void startup_kernel(void)
306349
setup_boot_command_line();
307350
parse_boot_command_line();
308351
detect_facilities();
352+
cmma_init();
309353
sanitize_prot_virt_host();
310354
max_physmem_end = detect_max_physmem_end();
311355
setup_ident_map_size(max_physmem_end);

arch/s390/include/asm/page-states.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#ifndef PAGE_STATES_H
88
#define PAGE_STATES_H
99

10+
#include <asm/sections.h>
11+
1012
#define ESSA_GET_STATE 0
1113
#define ESSA_SET_STABLE 1
1214
#define ESSA_SET_UNUSED 2
@@ -18,4 +20,6 @@
1820

1921
#define ESSA_MAX ESSA_SET_STABLE_NODAT
2022

23+
extern int __bootdata_preserved(cmma_flag);
24+
2125
#endif

arch/s390/include/asm/setup.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ static inline void vmcp_cma_reserve(void) { }
125125

126126
void report_user_fault(struct pt_regs *regs, long signr, int is_mm_fault);
127127

128-
void cmma_init(void);
129128
void cmma_init_nodat(void);
130129

131130
extern void (*_machine_restart)(char *command);

arch/s390/kernel/early.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ decompressor_handled_param(vmalloc);
4646
decompressor_handled_param(dfltcc);
4747
decompressor_handled_param(facilities);
4848
decompressor_handled_param(nokaslr);
49+
decompressor_handled_param(cmma);
4950
#if IS_ENABLED(CONFIG_KVM)
5051
decompressor_handled_param(prot_virt);
5152
#endif

arch/s390/mm/init.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ void __init mem_init(void)
164164

165165
pv_init();
166166
kfence_split_mapping();
167-
/* Setup guest page hinting */
168-
cmma_init();
169167

170168
/* this will put all low memory onto the freelists */
171169
memblock_free_all();

arch/s390/mm/page-states.c

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,45 +18,7 @@
1818
#include <asm/facility.h>
1919
#include <asm/page-states.h>
2020

21-
static int cmma_flag = 1;
22-
23-
static int __init cmma(char *str)
24-
{
25-
bool enabled;
26-
27-
if (!kstrtobool(str, &enabled))
28-
cmma_flag = enabled;
29-
return 1;
30-
}
31-
__setup("cmma=", cmma);
32-
33-
static inline int cmma_test_essa(void)
34-
{
35-
unsigned long tmp = 0;
36-
int rc = -EOPNOTSUPP;
37-
38-
/* test ESSA_GET_STATE */
39-
asm volatile(
40-
" .insn rrf,0xb9ab0000,%[tmp],%[tmp],%[cmd],0\n"
41-
"0: la %[rc],0\n"
42-
"1:\n"
43-
EX_TABLE(0b, 1b)
44-
: [rc] "+&d" (rc), [tmp] "+&d" (tmp)
45-
: [cmd] "i" (ESSA_GET_STATE));
46-
return rc;
47-
}
48-
49-
void __init cmma_init(void)
50-
{
51-
if (!cmma_flag)
52-
return;
53-
if (cmma_test_essa()) {
54-
cmma_flag = 0;
55-
return;
56-
}
57-
if (test_facility(147))
58-
cmma_flag = 2;
59-
}
21+
int __bootdata_preserved(cmma_flag);
6022

6123
static __always_inline void essa(unsigned long paddr, unsigned char cmd)
6224
{

0 commit comments

Comments
 (0)