Download raw body.
SEV-SNP: bus_dma(9): Rescind and claim DMA bounce buffer pages 2/4
Hi,
this is patch 2/4 implementing SEV-SNP guest support for OpenBSD.
When creating DMA maps, rescind DMA bounce buffer pages to the
hypervisor. When destroying DMA maps, claim these pages back from
the hypervisor.
ok? comments?
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.53.0
SEV-SNP: bus_dma(9): Rescind and claim DMA bounce buffer pages 2/4