From d90a6f1029abec7036e701883b04fac35fa43927 Mon Sep 17 00:00:00 2001 From: jmcneill Date: Sat, 26 Dec 2020 10:56:25 +0000 Subject: [PATCH] AHCI 1.3.1 specification says that it is good practice for system software to 'zero-out' the memory allocated and referenced by PxCLB and PxFB. --- sys/dev/ic/ahcisata_core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/dev/ic/ahcisata_core.c b/sys/dev/ic/ahcisata_core.c index ee71d69ce555..617581842175 100644 --- a/sys/dev/ic/ahcisata_core.c +++ b/sys/dev/ic/ahcisata_core.c @@ -1,4 +1,4 @@ -/* $NetBSD: ahcisata_core.c,v 1.87 2020/12/25 08:57:38 skrll Exp $ */ +/* $NetBSD: ahcisata_core.c,v 1.88 2020/12/26 10:56:25 jmcneill Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.87 2020/12/25 08:57:38 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.88 2020/12/26 10:56:25 jmcneill Exp $"); #include #include @@ -363,6 +363,9 @@ ahci_attach(struct ahci_softc *sc) return; } sc->sc_cmd_hdr = cmdhp; + memset(cmdhp, 0, dmasize); + bus_dmamap_sync(sc->sc_dmat, sc->sc_cmd_hdrd, 0, dmasize, + BUS_DMASYNC_PREWRITE); ahci_enable_intrs(sc); @@ -429,6 +432,9 @@ ahci_attach(struct ahci_softc *sc) ", error=%d\n", AHCINAME(sc), error); break; } + memset(cmdtblp, 0, dmasize); + bus_dmamap_sync(sc->sc_dmat, achp->ahcic_cmd_tbld, 0, + dmasize, BUS_DMASYNC_PREWRITE); achp->ahcic_cmdh = (struct ahci_cmd_header *) ((char *)cmdhp + AHCI_CMDH_SIZE * port); achp->ahcic_bus_cmdh = sc->sc_cmd_hdrd->dm_segs[0].ds_addr +