From: patrick Date: Wed, 23 Jun 2021 19:46:13 +0000 (+0000) Subject: The first page of the I/O virtual address space is reserved so that X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7ffc43e0b98cb16a850c7792a5955388a81bfb56;p=openbsd The first page of the I/O virtual address space is reserved so that is easier to spot misconfiguration or wrong behaviour where NULL is used as address. Right now that page is not part of the IOVA at all, so when we reserve regions, like PCI I/O space, which can cover that page as well, extent(9) will panic. Instead, include it in the IOVA but reserve it right away. This way that page can be reserved twice. --- diff --git a/sys/arch/arm64/dev/smmu.c b/sys/arch/arm64/dev/smmu.c index 07a5539a21d..9cf65a68a90 100644 --- a/sys/arch/arm64/dev/smmu.c +++ b/sys/arch/arm64/dev/smmu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smmu.c,v 1.14 2021/05/16 15:10:19 deraadt Exp $ */ +/* $OpenBSD: smmu.c,v 1.15 2021/06/23 19:46:13 patrick Exp $ */ /* * Copyright (c) 2008-2009,2014-2016 Dale Rahn * Copyright (c) 2021 Patrick Wildt @@ -750,10 +750,13 @@ smmu_domain_create(struct smmu_softc *sc, uint32_t sid) snprintf(dom->sd_exname, sizeof(dom->sd_exname), "%s:%x", sc->sc_dev.dv_xname, sid); - dom->sd_iovamap = extent_create(dom->sd_exname, PAGE_SIZE, + dom->sd_iovamap = extent_create(dom->sd_exname, 0, (1LL << iovabits) - 1, M_DEVBUF, NULL, 0, EX_WAITOK | EX_NOCOALESCE); + /* Reserve first page (to catch NULL access) */ + extent_alloc_region(dom->sd_iovamap, 0, PAGE_SIZE, EX_WAITOK); + #if 0 /* FIXME PCIe address space */ {