Index | Thread | Search

From:
Mark Kettenis <mark.kettenis@xs4all.nl>
Subject:
Re: SEV-SNP: bus_dma(9): Rescind and claim DMA bounce buffer
To:
hshoexer <hshoexer@yerbouti.franken.de>
Cc:
tech@openbsd.org
Date:
Thu, 24 Sep 2026 19:33:39 +0200

Download raw body.

Thread
> Date: Thu, 24 Sep 2026 18:14:41 +0200
> From: hshoexer <hshoexer@yerbouti.franken.de>
> 
> 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?

Sorry, too much jargon I'm not familliar with.  Can you explain what
does actually does?

> 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 <machine/bus.h>
> +#include <machine/snp.h>
>  
>  #include <uvm/uvm_extern.h>
>  
> @@ -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
> 
>