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 Remove unaligned access to mpbios_page[]



details:   https://anonhg.NetBSD.org/src/rev/0f60b62f1fa3
branches:  trunk
changeset: 320432:0f60b62f1fa3
user:      kamil <kamil%NetBSD.org@localhost>
date:      Sat Jul 07 23:05:50 2018 +0000

description:
Remove unaligned access to mpbios_page[]

Replace unaligned pointer dereference with a more portable construct that
is free from Undefined Behavior semantics.

sys/arch/x86/x86/mpbios.c:308:11, load of misaligned address 0xffff800031c7a413 for type 'const __uint16_t' which requires 2 byte alignment

Detected with Kernel Undefined Behavior Sanitizer

diffstat:

 sys/arch/x86/x86/mpbios.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r c3850bf21eee -r 0f60b62f1fa3 sys/arch/x86/x86/mpbios.c
--- a/sys/arch/x86/x86/mpbios.c Sat Jul 07 21:35:16 2018 +0000
+++ b/sys/arch/x86/x86/mpbios.c Sat Jul 07 23:05:50 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mpbios.c,v 1.66 2017/05/23 03:18:40 nonaka Exp $       */
+/*     $NetBSD: mpbios.c,v 1.67 2018/07/07 23:05:50 kamil Exp $        */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -96,7 +96,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpbios.c,v 1.66 2017/05/23 03:18:40 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpbios.c,v 1.67 2018/07/07 23:05:50 kamil Exp $");
 
 #include "acpica.h"
 #include "lapic.h"
@@ -305,7 +305,8 @@
        ebda = *(const uint16_t *)(&mpbios_page[0x40e]);
        ebda <<= 4;
 
-       memtop = *(const uint16_t *)(&mpbios_page[0x413]);
+       memtop = mpbios_page[0x413];
+       memtop |= (uint16_t)mpbios_page[0x414] << 8;
        memtop <<= 10;
 
        mpbios_page = NULL;



Home | Main Index | Thread Index | Old Index