From 48515970a05a66990a896611f414d0fec62b72e0 Mon Sep 17 00:00:00 2001 From: Balazs Gerofi Date: Mon, 19 Feb 2018 11:10:34 +0900 Subject: [PATCH] ihk_mc_get_processor_id(): return -1 for non-McKernel CPUs Cherry-pick of c45641e97add9fde467844d9272f2626cf4317de --- arch/x86_64/kernel/local.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/x86_64/kernel/local.c b/arch/x86_64/kernel/local.c index 84262fc9..3ca416d9 100644 --- a/arch/x86_64/kernel/local.c +++ b/arch/x86_64/kernel/local.c @@ -107,9 +107,17 @@ void init_boot_processor_local(void) @ ensures \result == %gs; @ assigns \nothing; */ +extern int num_processors; int ihk_mc_get_processor_id(void) { int id; + void *gs; + + gs = (void *)rdmsr(MSR_GS_BASE); + if (gs < (void *)locals || + gs > ((void *)locals + LOCALS_SPAN * num_processors)) { + return -1; + } asm volatile("movl %%gs:0, %0" : "=r"(id));