From: Mike Larkin Subject: Re: SEV-SNP: bus_dma(9): Rescind and claim DMA bounce buffer To: tech@openbsd.org Date: Fri, 2 Oct 2026 23:24:26 -0700 On Thu, Sep 24, 2026 at 06:14:41PM +0200, hshoexer wrote: > Hi, > > when creating DMA maps, rescind DMA bounce buffer pages to the > hypervisor. When destroying DMA maps, claim these pages back from > the hypervisor. > > ok? > i don't understand why we are unconditionally doing snp-related stuff in the shared busdma path here. I followed the trail back into that first diff and don't see anywhere where we short-circuit if snp is not in use. these snp calls should have something like if (snp) { ... } around them IMO. also now snp is sneaking into the busdma path and causing some contamination here... is there a better way to do this? > Take care, > HJ. > --- > sys/arch/amd64/amd64/bus_dma.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/sys/arch/amd64/amd64/bus_dma.c b/sys/arch/amd64/amd64/bus_dma.c > index f4efff95a18..2e69319739c 100644 > --- a/sys/arch/amd64/amd64/bus_dma.c > +++ b/sys/arch/amd64/amd64/bus_dma.c > @@ -100,6 +100,7 @@ > #endif > > #include > +#include > > #include > > @@ -255,6 +256,8 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments, > return (ENOMEM); > } > > + snp_rescind_pages(&mlist); > + > sva = va; > ssize = sz; > pgnext = TAILQ_FIRST(&mlist); > @@ -269,6 +272,7 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments, > map->_dm_npages = 0; > km_free((void *)sva, ssize, &kv_any, &kp_none); > free(map, M_DEVBUF, mapsize); > + snp_claim_pages(&mlist); > uvm_pglistfree(&mlist); > return (ENOMEM); > } > @@ -307,6 +311,7 @@ _bus_dmamap_destroy(bus_dma_tag_t t, bus_dmamap_t map) > for (pg = map->_dm_pages; map->_dm_npages--; pg++) { > TAILQ_INSERT_TAIL(&mlist, *pg, pageq); > } > + snp_claim_pages(&mlist); > uvm_pglistfree(&mlist); > } > > -- > 2.47.3 >