Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/sbus Do not attach if the STIP register is way too s...



details:   https://anonhg.NetBSD.org/src/rev/16fada4f83ae
branches:  trunk
changeset: 329174:16fada4f83ae
user:      martin <martin%NetBSD.org@localhost>
date:      Tue May 13 05:30:38 2014 +0000

description:
Do not attach if the STIP register is way too small (this happens in qemu
due to buggy emulation and causes crashes).

diffstat:

 sys/dev/sbus/tcx.c |  20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diffs (51 lines):

diff -r f474a49ffc8b -r 16fada4f83ae sys/dev/sbus/tcx.c
--- a/sys/dev/sbus/tcx.c        Tue May 13 02:53:54 2014 +0000
+++ b/sys/dev/sbus/tcx.c        Tue May 13 05:30:38 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcx.c,v 1.47 2014/05/09 11:51:49 jdc Exp $ */
+/*     $NetBSD: tcx.c,v 1.48 2014/05/13 05:30:38 martin Exp $ */
 
 /*
  *  Copyright (c) 1996, 1998, 2009 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcx.c,v 1.47 2014/05/09 11:51:49 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcx.c,v 1.48 2014/05/13 05:30:38 martin Exp $");
 
 /*
  * define for cg8 emulation on S24 (24-bit version of tcx) for the SS5;
@@ -273,9 +273,6 @@
        if (sc->sc_8bit) {
                printf(" (8-bit only TCX)\n");
                ramsize = 1024 * 1024;
-               /* XXX - fix THC and TEC offsets */
-               sc->sc_physaddr[TCX_REG_TEC].oa_base += 0x1000;
-               sc->sc_physaddr[TCX_REG_THC].oa_base += 0x1000;
        } else {
                printf(" (S24)\n");
                ramsize = 4 * 1024 * 1024;
@@ -289,12 +286,19 @@
 
        fb->fb_type.fb_type = FBTYPE_TCXCOLOR;
 
-
        if (sa->sa_nreg != TCX_NREG) {
-               printf("%s: only %d register sets\n",
-                       device_xname(self), sa->sa_nreg);
+               aprint_error("\n");
+               aprint_error_dev(self, "only %d register sets\n",
+                       sa->sa_nreg);
                return;
        }
+       if (sa->sa_reg[TCX_REG_STIP].oa_size < 0x1000) {
+               aprint_error("\n");
+               aprint_error_dev(self, "STIP register too small (0x%x)\n",
+                   sa->sa_reg[TCX_REG_STIP].oa_size);
+               return;
+       }
+
        memcpy(sc->sc_physaddr, sa->sa_reg,
              sa->sa_nreg * sizeof(struct openprom_addr));
 



Home | Main Index | Thread Index | Old Index