mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-23 12:31:13 +01:00
arm64: Implement busdma bits for KMSAN
This works identically to amd64. In particular, only the bus_dma_bounce_impl busdma implementation handles KMSAN at the moment. MFC after: 2 weeks Sponsored by: Klara, Inc. Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D43157
This commit is contained in:
parent
90010126b0
commit
5fa4151e92
@ -40,9 +40,10 @@
|
|||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
#include <sys/ktr.h>
|
#include <sys/ktr.h>
|
||||||
#include <sys/lock.h>
|
#include <sys/lock.h>
|
||||||
#include <sys/proc.h>
|
|
||||||
#include <sys/memdesc.h>
|
#include <sys/memdesc.h>
|
||||||
|
#include <sys/msan.h>
|
||||||
#include <sys/mutex.h>
|
#include <sys/mutex.h>
|
||||||
|
#include <sys/proc.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
|
|
||||||
@ -104,6 +105,9 @@ struct bus_dmamap {
|
|||||||
#define DMAMAP_FROM_DMAMEM (1 << 1)
|
#define DMAMAP_FROM_DMAMEM (1 << 1)
|
||||||
#define DMAMAP_MBUF (1 << 2)
|
#define DMAMAP_MBUF (1 << 2)
|
||||||
int sync_count;
|
int sync_count;
|
||||||
|
#ifdef KMSAN
|
||||||
|
struct memdesc kmsan_mem;
|
||||||
|
#endif
|
||||||
struct sync_list slist[];
|
struct sync_list slist[];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1149,8 +1153,20 @@ bounce_bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map,
|
|||||||
*/
|
*/
|
||||||
dsb(sy);
|
dsb(sy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kmsan_bus_dmamap_sync(&map->kmsan_mem, op);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef KMSAN
|
||||||
|
static void
|
||||||
|
bounce_bus_dmamap_load_kmsan(bus_dmamap_t map, struct memdesc *mem)
|
||||||
|
{
|
||||||
|
if (map == NULL)
|
||||||
|
return;
|
||||||
|
memcpy(&map->kmsan_mem, mem, sizeof(map->kmsan_mem));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
struct bus_dma_impl bus_dma_bounce_impl = {
|
struct bus_dma_impl bus_dma_bounce_impl = {
|
||||||
.tag_create = bounce_bus_dma_tag_create,
|
.tag_create = bounce_bus_dma_tag_create,
|
||||||
.tag_destroy = bounce_bus_dma_tag_destroy,
|
.tag_destroy = bounce_bus_dma_tag_destroy,
|
||||||
@ -1166,5 +1182,8 @@ struct bus_dma_impl bus_dma_bounce_impl = {
|
|||||||
.map_waitok = bounce_bus_dmamap_waitok,
|
.map_waitok = bounce_bus_dmamap_waitok,
|
||||||
.map_complete = bounce_bus_dmamap_complete,
|
.map_complete = bounce_bus_dmamap_complete,
|
||||||
.map_unload = bounce_bus_dmamap_unload,
|
.map_unload = bounce_bus_dmamap_unload,
|
||||||
.map_sync = bounce_bus_dmamap_sync
|
.map_sync = bounce_bus_dmamap_sync,
|
||||||
|
#ifdef KMSAN
|
||||||
|
.load_kmsan = bounce_bus_dmamap_load_kmsan,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
@ -149,4 +149,16 @@ _bus_dmamap_complete(bus_dma_tag_t dmat, bus_dmamap_t map,
|
|||||||
return (tc->impl->map_complete(dmat, map, segs, nsegs, error));
|
return (tc->impl->map_complete(dmat, map, segs, nsegs, error));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef KMSAN
|
||||||
|
static inline void
|
||||||
|
_bus_dmamap_load_kmsan(bus_dma_tag_t dmat, bus_dmamap_t map,
|
||||||
|
struct memdesc *mem)
|
||||||
|
{
|
||||||
|
struct bus_dma_tag_common *tc;
|
||||||
|
|
||||||
|
tc = (struct bus_dma_tag_common *)dmat;
|
||||||
|
return (tc->impl->load_kmsan(map, mem));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* !_MACHINE_BUS_DMA_H_ */
|
#endif /* !_MACHINE_BUS_DMA_H_ */
|
||||||
|
@ -75,6 +75,9 @@ struct bus_dma_impl {
|
|||||||
void (*map_unload)(bus_dma_tag_t dmat, bus_dmamap_t map);
|
void (*map_unload)(bus_dma_tag_t dmat, bus_dmamap_t map);
|
||||||
void (*map_sync)(bus_dma_tag_t dmat, bus_dmamap_t map,
|
void (*map_sync)(bus_dma_tag_t dmat, bus_dmamap_t map,
|
||||||
bus_dmasync_op_t op);
|
bus_dmasync_op_t op);
|
||||||
|
#ifdef KMSAN
|
||||||
|
void (*load_kmsan)(bus_dmamap_t map, struct memdesc *mem);
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
int common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
|
int common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
|
||||||
|
Loading…
Reference in New Issue
Block a user