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 gcc 4.8 issues:



details:   https://anonhg.NetBSD.org/src/rev/178d536fb6aa
branches:  trunk
changeset: 791145:178d536fb6aa
user:      mrg <mrg%NetBSD.org@localhost>
date:      Wed Nov 06 20:19:03 2013 +0000

description:
gcc 4.8 issues:
- avoid running over the end of an array (this is a real bug, but
  i didn't really look closely at what memory is clobbered.  it
  may not actually matter.)
- move variables inside their #if usage.

diffstat:

 sys/arch/x86/x86/i8259.c  |   8 +++++---
 sys/arch/x86/x86/mpbios.c |   8 +++++---
 sys/arch/x86/x86/pmap.c   |  14 +++++++++-----
 3 files changed, 19 insertions(+), 11 deletions(-)

diffs (124 lines):

diff -r b848a6211dd2 -r 178d536fb6aa sys/arch/x86/x86/i8259.c
--- a/sys/arch/x86/x86/i8259.c  Wed Nov 06 19:57:17 2013 +0000
+++ b/sys/arch/x86/x86/i8259.c  Wed Nov 06 20:19:03 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i8259.c,v 1.15 2008/12/18 12:18:20 cegger Exp $        */
+/*     $NetBSD: i8259.c,v 1.16 2013/11/06 20:19:03 mrg Exp $   */
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i8259.c,v 1.15 2008/12/18 12:18:20 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i8259.c,v 1.16 2013/11/06 20:19:03 mrg Exp $");
 
 #include <sys/param.h> 
 #include <sys/systm.h>
@@ -233,9 +233,11 @@
 {
        int irqs, irq;
        struct cpu_info *ci = &cpu_info_primary;
+       const size_t array_len = MIN(__arraycount(ci->ci_isources),
+                                    NUM_LEGACY_IRQS);
 
        irqs = 0;
-       for (irq = 0; irq < NUM_LEGACY_IRQS; irq++)
+       for (irq = 0; irq < array_len; irq++)
                if (ci->ci_isources[irq] != NULL)
                        irqs |= 1 << irq;
        if (irqs >= 0x100) /* any IRQs >= 8 in use */
diff -r b848a6211dd2 -r 178d536fb6aa sys/arch/x86/x86/mpbios.c
--- a/sys/arch/x86/x86/mpbios.c Wed Nov 06 19:57:17 2013 +0000
+++ b/sys/arch/x86/x86/mpbios.c Wed Nov 06 20:19:03 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mpbios.c,v 1.61 2013/08/21 16:37:31 christos Exp $     */
+/*     $NetBSD: mpbios.c,v 1.62 2013/11/06 20:19:03 mrg Exp $  */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -96,7 +96,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpbios.c,v 1.61 2013/08/21 16:37:31 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpbios.c,v 1.62 2013/11/06 20:19:03 mrg Exp $");
 
 #include "acpica.h"
 #include "lapic.h"
@@ -552,7 +552,9 @@
        int             count;
        int             type;
        int             intr_cnt, cur_intr;
+#if NLAPIC > 0
        paddr_t         lapic_base;
+#endif
        const struct dflt_conf_entry *dflt_conf;
        const int *dflt_bus_irq;
        const struct mpbios_int *iep;
@@ -580,11 +582,11 @@
 #if NACPICA > 0
        if (mpacpi_ncpu == 0) {
 #endif
+#if NLAPIC > 0
                lapic_base = LAPIC_BASE;
                if (mp_cth != NULL)
                        lapic_base = (paddr_t)mp_cth->apic_address;
 
-#if NLAPIC > 0
                lapic_boot_init(lapic_base);
 #endif
 #if NACPICA > 0
diff -r b848a6211dd2 -r 178d536fb6aa sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c   Wed Nov 06 19:57:17 2013 +0000
+++ b/sys/arch/x86/x86/pmap.c   Wed Nov 06 20:19:03 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.180 2013/10/05 16:50:31 rmind Exp $ */
+/*     $NetBSD: pmap.c,v 1.181 2013/11/06 20:19:03 mrg Exp $   */
 
 /*-
  * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
@@ -171,7 +171,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.180 2013/10/05 16:50:31 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.181 2013/11/06 20:19:03 mrg Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -505,8 +505,8 @@
 #define PTESLEW(pte, id) ((pte)+(id)*NPTECL)
 #define VASLEW(va,id) ((va)+(id)*NPTECL*PAGE_SIZE)
 #else
-#define PTESLEW(pte, id) (pte)
-#define VASLEW(va,id) (va)
+#define PTESLEW(pte, id) ((void)id, pte)
+#define VASLEW(va,id) ((void)id, va)
 #endif
 
 /*
@@ -4220,9 +4220,10 @@
        struct pmap *kpm = pmap_kernel();
 #if !defined(XEN) || !defined(__x86_64__)
        struct pmap *pm;
+       long old;
 #endif
        int s, i;
-       long needed_kptp[PTP_LEVELS], target_nptp, old;
+       long needed_kptp[PTP_LEVELS], target_nptp;
        bool invalidate = false;
 
        s = splvm();    /* to be safe */
@@ -4235,7 +4236,10 @@
        }
 
        maxkvaddr = x86_round_pdr(maxkvaddr);
+#if !defined(XEN) || !defined(__x86_64__)
        old = nkptp[PTP_LEVELS - 1];
+#endif
+
        /*
         * This loop could be optimized more, but pmap_growkernel()
         * is called infrequently.



Home | Main Index | Thread Index | Old Index