MIPS: Add defs & probing of [X]ContextConfig
authorJames Hogan <james.hogan@imgtec.com>
Wed, 11 May 2016 12:50:52 +0000 (13:50 +0100)
committerRalf Baechle <ralf@linux-mips.org>
Fri, 13 May 2016 13:30:25 +0000 (15:30 +0200)
The CP0_[X]ContextConfig registers are present if CP0_Config3.CTXTC or
CP0_Config3.SM are set, and provide more control over which bits of
CP0_[X]Context are set to the faulting virtual address on a TLB
exception.

KVM/VZ will need to be able to save and restore these registers in the
guest context, so add the relevant definitions and probing of the
ContextConfig feature in the root context first.

[ralf@linux-mips.org: resolve merge conflict.]

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/13225/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/include/asm/cpu-features.h
arch/mips/include/asm/cpu.h
arch/mips/include/asm/mipsregs.h
arch/mips/kernel/cpu-probe.c

index 5d82b01..7962b25 100644 (file)
 # define cpu_has_badinstrp     (cpu_data[0].options & MIPS_CPU_BADINSTRP)
 #endif
 
+#ifndef cpu_has_contextconfig
+# define cpu_has_contextconfig (cpu_data[0].options & MIPS_CPU_CTXTC)
+#endif
+
 #endif /* __ASM_CPU_FEATURES_H */
index 0cf90d6..ddcb2ab 100644 (file)
@@ -407,6 +407,7 @@ enum cpu_type_enum {
 #define MIPS_CPU_EBASE_WG      MBIT_ULL(43)    /* CPU has EBase.WG */
 #define MIPS_CPU_BADINSTR      MBIT_ULL(44)    /* CPU has BadInstr register */
 #define MIPS_CPU_BADINSTRP     MBIT_ULL(45)    /* CPU has BadInstrP register */
+#define MIPS_CPU_CTXTC         MBIT_ULL(46)    /* CPU has [X]ConfigContext registers */
 
 /*
  * CPU ASE encodings
index b1f8f84..08864cb 100644 (file)
@@ -1228,9 +1228,15 @@ do {                                                                     \
 #define read_c0_context()      __read_ulong_c0_register($4, 0)
 #define write_c0_context(val)  __write_ulong_c0_register($4, 0, val)
 
+#define read_c0_contextconfig()                __read_32bit_c0_register($4, 1)
+#define write_c0_contextconfig(val)    __write_32bit_c0_register($4, 1, val)
+
 #define read_c0_userlocal()    __read_ulong_c0_register($4, 2)
 #define write_c0_userlocal(val) __write_ulong_c0_register($4, 2, val)
 
+#define read_c0_xcontextconfig()       __read_ulong_c0_register($4, 3)
+#define write_c0_xcontextconfig(val)   __write_ulong_c0_register($4, 3, val)
+
 #define read_c0_pagemask()     __read_32bit_c0_register($5, 0)
 #define write_c0_pagemask(val) __write_32bit_c0_register($5, 0, val)
 
index 8e54d51..963ce7e 100644 (file)
@@ -687,10 +687,12 @@ static inline unsigned int decode_config3(struct cpuinfo_mips *c)
 
        if (config3 & MIPS_CONF3_SM) {
                c->ases |= MIPS_ASE_SMARTMIPS;
-               c->options |= MIPS_CPU_RIXI;
+               c->options |= MIPS_CPU_RIXI | MIPS_CPU_CTXTC;
        }
        if (config3 & MIPS_CONF3_RXI)
                c->options |= MIPS_CPU_RIXI;
+       if (config3 & MIPS_CONF3_CTXTC)
+               c->options |= MIPS_CPU_CTXTC;
        if (config3 & MIPS_CONF3_DSP)
                c->ases |= MIPS_ASE_DSP;
        if (config3 & MIPS_CONF3_DSP2P) {