Socket ID is an unsigned value and starts at 0. Subtracting 1
from it is incorrect and the result will underflow if
socket_id=0.

Remove substraction when extracting socket_id from c->apicid.

Signed-off-by: Yazen Ghannam <yazen.ghan...@amd.com>
---
Link:
http://lkml.kernel.org/r/1472674900-60688-1-git-send-email-yazen.ghan...@amd.com

v1->v2:
* Don't do logical AND so as to not restrict # of sockets to 2.

 arch/x86/kernel/cpu/amd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index f3d8a92..793bc23 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -365,7 +365,7 @@ static void amd_detect_cmp(struct cpuinfo_x86 *c)
         if (c->x86 != 0x17 || !cpuid_edx(0x80000006))
                return;
 
-       socket_id       = (c->apicid >> bits) - 1;
+       socket_id       = c->apicid >> bits;
        core_complex_id = (c->apicid & ((1 << bits) - 1)) >> 3;
 
        per_cpu(cpu_llc_id, cpu) = (socket_id << 3) | core_complex_id;
-- 
1.9.1

Reply via email to