Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/x86/x86 Check for undefined behaviour when doing ri...
details: https://anonhg.NetBSD.org/src/rev/e0fd5e6a7570
branches: trunk
changeset: 359086:e0fd5e6a7570
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Sun Jan 28 15:00:42 2018 +0000
description:
Check for undefined behaviour when doing right-shift.
diffstat:
sys/arch/x86/x86/cpu_topology.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diffs (30 lines):
diff -r 395a128b0386 -r e0fd5e6a7570 sys/arch/x86/x86/cpu_topology.c
--- a/sys/arch/x86/x86/cpu_topology.c Sun Jan 28 14:34:26 2018 +0000
+++ b/sys/arch/x86/x86/cpu_topology.c Sun Jan 28 15:00:42 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_topology.c,v 1.10 2017/09/07 06:40:42 msaitoh Exp $ */
+/* $NetBSD: cpu_topology.c,v 1.11 2018/01/28 15:00:42 mlelstv Exp $ */
/*-
* Copyright (c) 2009 Mindaugas Rasiukevicius <rmind at NetBSD org>,
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.10 2017/09/07 06:40:42 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.11 2018/01/28 15:00:42 mlelstv Exp $");
#include <sys/param.h>
#include <sys/bitops.h>
@@ -151,7 +151,10 @@
}
if (smt_bits + core_bits) {
- ci->ci_package_id = apic_id >> (smt_bits + core_bits);
+ if (smt_bits + core_bits < sizeof(apic_id) * NBBY)
+ ci->ci_package_id = apic_id >> (smt_bits + core_bits);
+ else
+ ci->ci_package_id = 0;
}
if (core_bits) {
u_int core_mask = __BITS(smt_bits, smt_bits + core_bits - 1);
Home |
Main Index |
Thread Index |
Old Index