diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2024-08-14 18:31:34 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2024-08-14 18:31:34 +0000 |
commit | 26f56a15832a2e2f81ad5d45526764e2464405d0 (patch) | |
tree | bacb81dbf76be641ffb8d5504e866c6e2a6ca50d /sys/arch/amd64/include | |
parent | d062defce09c4bd429cc510d5162ee3d6d702524 (diff) |
Implement bounce buffering for AMD SEV in amd64 bus dma.
When running as SEV guest, as indicated by variable cpu_sev_guestmode,
allocate additional pages for each segment on dma map creation.
These pages are mapped with the PMAP_NOCRYPT attribute, i.e. the
crypt bit is not set in the PTE. Thus, these pages are shared with
the hypervisor.
When the map is loaded with actual pages, the address in the
descriptor is replaced by the corresponding bounce buffer. Using
bus_dmamap_sync(), data is copied from the encrypted pages used by
guest drivers to the unencrypted bounce buffers shared with the
hypervisor, and vice versa.
If the kernel is not running in SEV guest mode, which means as
normal host or non-SEV guest, no bounce buffers are used.
from hshoexer@; based on ancient code of mickey@; OK kettenis@
Diffstat (limited to 'sys/arch/amd64/include')
-rw-r--r-- | sys/arch/amd64/include/bus.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sys/arch/amd64/include/bus.h b/sys/arch/amd64/include/bus.h index 33d6cd6eaeb..d3c16404292 100644 --- a/sys/arch/amd64/include/bus.h +++ b/sys/arch/amd64/include/bus.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bus.h,v 1.35 2020/10/28 09:58:57 jsg Exp $ */ +/* $OpenBSD: bus.h,v 1.36 2024/08/14 18:31:33 bluhm Exp $ */ /* $NetBSD: bus.h,v 1.6 1996/11/10 03:19:25 thorpej Exp $ */ /*- @@ -552,6 +552,9 @@ typedef struct bus_dmamap *bus_dmamap_t; struct bus_dma_segment { bus_addr_t ds_addr; /* DMA address */ bus_size_t ds_len; /* length of transfer */ + vaddr_t _ds_va; /* mapped loaded data */ + vaddr_t _ds_bounce_va; /* mapped bounced data */ + /* * Ugh. need this so can pass alignment down from bus_dmamem_alloc * to scatter gather maps. only the first one is used so the rest is @@ -655,6 +658,11 @@ struct bus_dmamap { void *_dm_cookie; /* cookie for bus-specific functions */ + struct vm_page **_dm_pages; /* replacement pages */ + vaddr_t _dm_pgva; /* those above -- mapped */ + int _dm_npages; /* number of pages allocated */ + int _dm_nused; /* number of pages replaced */ + /* * PUBLIC MEMBERS: these are used by machine-independent code. */ |