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 Fix a bug where mapping the very end of iom...
details: https://anonhg.NetBSD.org/src/rev/754edb14aec2
branches: trunk
changeset: 747139:754edb14aec2
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Thu Sep 03 23:25:04 2009 +0000
description:
Fix a bug where mapping the very end of iomem accidentally returns an
address in the ISA hole (because addr+size calculations wrap to 0). Fixes
ohci on VirtualPC 7 for Mac, which places OHCI at base address 0xfffff000
size 0x1000.
diffstat:
sys/arch/x86/x86/bus_space.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diffs (70 lines):
diff -r f5cc236be256 -r 754edb14aec2 sys/arch/x86/x86/bus_space.c
--- a/sys/arch/x86/x86/bus_space.c Thu Sep 03 21:06:21 2009 +0000
+++ b/sys/arch/x86/x86/bus_space.c Thu Sep 03 23:25:04 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_space.c,v 1.23 2009/07/29 12:02:06 cegger Exp $ */
+/* $NetBSD: bus_space.c,v 1.24 2009/09/03 23:25:04 jmcneill Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.23 2009/07/29 12:02:06 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.24 2009/09/03 23:25:04 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -174,7 +174,7 @@
}
#ifndef XEN
- if (bpa >= IOM_BEGIN && (bpa + size) <= IOM_END) {
+ if (bpa >= IOM_BEGIN && (bpa + size) != 0 && (bpa + size) <= IOM_END) {
*bshp = (bus_space_handle_t)ISA_HOLE_VADDR(bpa);
return(0);
}
@@ -299,12 +299,12 @@
endpa = x86_round_page(bpa + size);
#ifdef DIAGNOSTIC
- if (endpa <= pa)
+ if (endpa != 0 && endpa <= pa)
panic("x86_mem_add_mapping: overflow");
#endif
#ifdef XEN
- if (bpa >= IOM_BEGIN && (bpa + size) <= IOM_END) {
+ if (bpa >= IOM_BEGIN && (bpa + size) != 0 && (bpa + size) <= IOM_END) {
sva = (vaddr_t)ISA_HOLE_VADDR(pa);
} else
#endif /* XEN */
@@ -319,7 +319,7 @@
va = sva;
xpte = 0;
- for (; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) {
+ for (; pa != endpa; pa += PAGE_SIZE, va += PAGE_SIZE) {
/*
* PG_N doesn't exist on 386's, so we assume that
* the mainboard has wired up device space non-cacheable
@@ -372,7 +372,8 @@
if (t == X86_BUS_SPACE_IO) {
bpa = bsh;
} else if (t == X86_BUS_SPACE_MEM) {
- if (bsh >= atdevbase && (bsh + size) <= (atdevbase + IOM_SIZE)) {
+ if (bsh >= atdevbase && (bsh + size) != 0 &&
+ (bsh + size) <= (atdevbase + IOM_SIZE)) {
bpa = (bus_addr_t)ISA_PHYSADDR(bsh);
} else {
@@ -423,7 +424,7 @@
} else if (t == X86_BUS_SPACE_MEM) {
ex = iomem_ex;
- if (bsh >= atdevbase &&
+ if (bsh >= atdevbase && (bsh + size) != 0 &&
(bsh + size) <= (atdevbase + IOM_SIZE)) {
bpa = (bus_addr_t)ISA_PHYSADDR(bsh);
goto ok;
Home |
Main Index |
Thread Index |
Old Index