Skip to content

Commit 8374c2c

Browse files
maciej-w-rozyckitsbogend
authored andcommitted
MIPS: Always record SEGBITS in cpu_data.vmbits
With a 32-bit kernel running on 64-bit MIPS hardware the hardcoded value of `cpu_vmbits' only records the size of compatibility useg and does not reflect the size of native xuseg or the complete range of values allowed in the VPN2 field of TLB entries. An upcoming change will need the actual VPN2 value range permitted even in 32-bit kernel configurations, so always include the `vmbits' member in `struct cpuinfo_mips' and probe for SEGBITS when running on 64-bit hardware and resorting to the currently hardcoded value of 31 on 32-bit processors. No functional change for users of `cpu_vmbits'. Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
1 parent ec8bf18 commit 8374c2c

5 files changed

Lines changed: 12 additions & 8 deletions

File tree

arch/mips/include/asm/cpu-features.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,6 @@
484484
# endif
485485
# ifndef cpu_vmbits
486486
# define cpu_vmbits cpu_data[0].vmbits
487-
# define __NEED_VMBITS_PROBE
488487
# endif
489488
#endif
490489

arch/mips/include/asm/cpu-info.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ struct cpuinfo_mips {
8080
int srsets; /* Shadow register sets */
8181
int package;/* physical package number */
8282
unsigned int globalnumber;
83-
#ifdef CONFIG_64BIT
8483
int vmbits; /* Virtual memory size in bits */
85-
#endif
8684
void *data; /* Additional data */
8785
unsigned int watch_reg_count; /* Number that exist */
8886
unsigned int watch_reg_use_cnt; /* Usable by ptrace */

arch/mips/include/asm/mipsregs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,6 +1871,8 @@ do { \
18711871

18721872
#define read_c0_entryhi() __read_ulong_c0_register($10, 0)
18731873
#define write_c0_entryhi(val) __write_ulong_c0_register($10, 0, val)
1874+
#define read_c0_entryhi_64() __read_64bit_c0_register($10, 0)
1875+
#define write_c0_entryhi_64(val) __write_64bit_c0_register($10, 0, val)
18741876

18751877
#define read_c0_guestctl1() __read_32bit_c0_register($10, 4)
18761878
#define write_c0_guestctl1(val) __write_32bit_c0_register($10, 4, val)

arch/mips/kernel/cpu-probe.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,14 @@ static inline void set_elf_base_platform(const char *plat)
210210

211211
static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
212212
{
213-
#ifdef __NEED_VMBITS_PROBE
214-
write_c0_entryhi(0x3fffffffffffe000ULL);
215-
back_to_back_c0_hazard();
216-
c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL);
217-
#endif
213+
int vmbits = 31;
214+
215+
if (cpu_has_64bits) {
216+
write_c0_entryhi_64(0x3fffffffffffe000ULL);
217+
back_to_back_c0_hazard();
218+
vmbits = fls64(read_c0_entryhi_64() & 0x3fffffffffffe000ULL);
219+
}
220+
c->vmbits = vmbits;
218221
}
219222

220223
static void set_isa(struct cpuinfo_mips *c, unsigned int isa)

arch/mips/kernel/cpu-r3k-probe.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ void cpu_probe(void)
137137
else
138138
cpu_set_nofpu_opts(c);
139139

140+
c->vmbits = 31;
141+
140142
reserve_exception_space(0, 0x400);
141143
}
142144

0 commit comments

Comments
 (0)