浏览代码

[MIPS] Add BUG_ON assertion for attempt to run kernel on the wrong CPU type.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Franck Bui-Huu 17 年之前
父节点
当前提交
dec8b1ca99
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      arch/mips/kernel/cpu-probe.c

+ 8 - 0
arch/mips/kernel/cpu-probe.c

@@ -922,6 +922,14 @@ __init void cpu_probe(void)
 	default:
 	default:
 		c->cputype = CPU_UNKNOWN;
 		c->cputype = CPU_UNKNOWN;
 	}
 	}
+
+	/*
+	 * Platform code can force the cpu type to optimize code
+	 * generation. In that case be sure the cpu type is correctly
+	 * manually setup otherwise it could trigger some nasty bugs.
+	 */
+	BUG_ON(current_cpu_type() != c->cputype);
+
 	if (c->options & MIPS_CPU_FPU) {
 	if (c->options & MIPS_CPU_FPU) {
 		c->fpu_id = cpu_get_fpu_id();
 		c->fpu_id = cpu_get_fpu_id();