Skip to content

Commit aefd946

Browse files
committed
csky: Fixup cpu speculative execution to IO area
For the memory size ( > 512MB, < 1GB), the MSA setting is: - SSEG0: PHY_START , PHY_START + 512MB - SSEG1: PHY_START + 512MB, PHY_START + 1GB But the real memory is no more than 1GB, there is a gap between the end size of memory and border of 1GB. CPU could speculatively execute to that gap and if the gap of the bus couldn't respond to the CPU request, then the crash will happen. Now make the setting with: - SSEG0: PHY_START , PHY_START + 512MB (no change) - SSEG1: Disabled (We use highmem to use the memory of 512MB~1GB) We also deprecated zhole_szie[] settings, it's only used by arm style CPUs. All memory gap should use Reserved setting of dts in csky system. Signed-off-by: Guo Ren <[email protected]>
1 parent 8f6bb79 commit aefd946

File tree

5 files changed

+25
-58
lines changed

5 files changed

+25
-58
lines changed

arch/csky/abiv1/inc/abi/entry.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,7 @@
172172
addi r6, 0xe
173173
cpwcr r6, cpcr30
174174

175-
lsri r6, 28
176-
addi r6, 2
177-
lsli r6, 28
178-
addi r6, 0xe
175+
movi r6, 0
179176
cpwcr r6, cpcr31
180177
.endm
181178

arch/csky/abiv2/inc/abi/entry.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,8 @@
290290
addi r6, 0x1ce
291291
mtcr r6, cr<30, 15> /* Set MSA0 */
292292

293-
lsri r6, 28
294-
addi r6, 2
295-
lsli r6, 28
296-
addi r6, 0x1ce
297-
mtcr r6, cr<31, 15> /* Set MSA1 */
293+
movi r6, 0
294+
mtcr r6, cr<31, 15> /* Clr MSA1 */
298295

299296
/* enable MMU */
300297
mfcr r6, cr18

arch/csky/kernel/head.S

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ END(_start)
2121
ENTRY(_start_smp_secondary)
2222
SETUP_MMU
2323

24+
/* copy msa1 from CPU0 */
25+
lrw r6, secondary_msa1
26+
ld.w r6, (r6, 0)
27+
mtcr r6, cr<31, 15>
28+
2429
/* set stack point */
2530
lrw r6, secondary_stack
2631
ld.w r6, (r6, 0)

arch/csky/kernel/setup.c

Lines changed: 14 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,9 @@ struct screen_info screen_info = {
2424
};
2525
#endif
2626

27-
phys_addr_t __init_memblock memblock_end_of_REG0(void)
28-
{
29-
return (memblock.memory.regions[0].base +
30-
memblock.memory.regions[0].size);
31-
}
32-
33-
phys_addr_t __init_memblock memblock_start_of_REG1(void)
34-
{
35-
return memblock.memory.regions[1].base;
36-
}
37-
38-
size_t __init_memblock memblock_size_of_REG1(void)
39-
{
40-
return memblock.memory.regions[1].size;
41-
}
42-
4327
static void __init csky_memblock_init(void)
4428
{
4529
unsigned long zone_size[MAX_NR_ZONES];
46-
unsigned long zhole_size[MAX_NR_ZONES];
4730
signed long size;
4831

4932
memblock_reserve(__pa(_stext), _end - _stext);
@@ -54,54 +37,36 @@ static void __init csky_memblock_init(void)
5437
memblock_dump_all();
5538

5639
memset(zone_size, 0, sizeof(zone_size));
57-
memset(zhole_size, 0, sizeof(zhole_size));
5840

5941
min_low_pfn = PFN_UP(memblock_start_of_DRAM());
60-
max_pfn = PFN_DOWN(memblock_end_of_DRAM());
61-
62-
max_low_pfn = PFN_UP(memblock_end_of_REG0());
63-
if (max_low_pfn == 0)
64-
max_low_pfn = max_pfn;
42+
max_low_pfn = max_pfn = PFN_DOWN(memblock_end_of_DRAM());
6543

6644
size = max_pfn - min_low_pfn;
6745

68-
if (memblock.memory.cnt > 1) {
69-
zone_size[ZONE_NORMAL] =
70-
PFN_DOWN(memblock_start_of_REG1()) - min_low_pfn;
71-
zhole_size[ZONE_NORMAL] =
72-
PFN_DOWN(memblock_start_of_REG1()) - max_low_pfn;
46+
if (size <= PFN_DOWN(SSEG_SIZE - PHYS_OFFSET_OFFSET))
47+
zone_size[ZONE_NORMAL] = size;
48+
else if (size < PFN_DOWN(LOWMEM_LIMIT - PHYS_OFFSET_OFFSET)) {
49+
zone_size[ZONE_NORMAL] =
50+
PFN_DOWN(SSEG_SIZE - PHYS_OFFSET_OFFSET);
51+
max_low_pfn = min_low_pfn + zone_size[ZONE_NORMAL];
7352
} else {
74-
if (size <= PFN_DOWN(LOWMEM_LIMIT - PHYS_OFFSET_OFFSET))
75-
zone_size[ZONE_NORMAL] = max_pfn - min_low_pfn;
76-
else {
77-
zone_size[ZONE_NORMAL] =
53+
zone_size[ZONE_NORMAL] =
7854
PFN_DOWN(LOWMEM_LIMIT - PHYS_OFFSET_OFFSET);
79-
max_low_pfn = min_low_pfn + zone_size[ZONE_NORMAL];
80-
}
55+
max_low_pfn = min_low_pfn + zone_size[ZONE_NORMAL];
56+
write_mmu_msa1(read_mmu_msa0() + SSEG_SIZE);
8157
}
8258

8359
#ifdef CONFIG_HIGHMEM
84-
size = 0;
85-
if (memblock.memory.cnt > 1) {
86-
size = PFN_DOWN(memblock_size_of_REG1());
87-
highstart_pfn = PFN_DOWN(memblock_start_of_REG1());
88-
} else {
89-
size = max_pfn - min_low_pfn -
90-
PFN_DOWN(LOWMEM_LIMIT - PHYS_OFFSET_OFFSET);
91-
highstart_pfn = min_low_pfn +
92-
PFN_DOWN(LOWMEM_LIMIT - PHYS_OFFSET_OFFSET);
93-
}
94-
95-
if (size > 0)
96-
zone_size[ZONE_HIGHMEM] = size;
60+
zone_size[ZONE_HIGHMEM] = max_pfn - max_low_pfn;
9761

98-
highend_pfn = max_pfn;
62+
highstart_pfn = max_low_pfn;
63+
highend_pfn = max_pfn;
9964
#endif
10065
memblock_set_current_limit(PFN_PHYS(max_low_pfn));
10166

10267
dma_contiguous_reserve(0);
10368

104-
free_area_init_node(0, zone_size, min_low_pfn, zhole_size);
69+
free_area_init_node(0, zone_size, min_low_pfn, NULL);
10570
}
10671

10772
void __init setup_arch(char **cmdline_p)

arch/csky/kernel/smp.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ volatile unsigned int secondary_hint;
159159
volatile unsigned int secondary_ccr;
160160
volatile unsigned int secondary_stack;
161161

162+
unsigned long secondary_msa1;
163+
162164
int __cpu_up(unsigned int cpu, struct task_struct *tidle)
163165
{
164166
unsigned long mask = 1 << cpu;
@@ -167,6 +169,7 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle)
167169
(unsigned int) task_stack_page(tidle) + THREAD_SIZE - 8;
168170
secondary_hint = mfcr("cr31");
169171
secondary_ccr = mfcr("cr18");
172+
secondary_msa1 = read_mmu_msa1();
170173

171174
/*
172175
* Because other CPUs are in reset status, we must flush data

0 commit comments

Comments
 (0)