virtio_ring.c (97acb6a8fcc4e5c2cdc2693a35acdc5a7461aaa3) virtio_ring.c (88938359e2dfe1f5f5840268b98935948db8fbd9)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/* Virtio ring implementation.
3 *
4 * Copyright 2007 Rusty Russell IBM Corporation
5 */
6#include <linux/virtio.h>
7#include <linux/virtio_ring.h>
8#include <linux/virtio_config.h>
9#include <linux/device.h>
10#include <linux/slab.h>
11#include <linux/module.h>
12#include <linux/hrtimer.h>
13#include <linux/dma-mapping.h>
1// SPDX-License-Identifier: GPL-2.0-or-later
2/* Virtio ring implementation.
3 *
4 * Copyright 2007 Rusty Russell IBM Corporation
5 */
6#include <linux/virtio.h>
7#include <linux/virtio_ring.h>
8#include <linux/virtio_config.h>
9#include <linux/device.h>
10#include <linux/slab.h>
11#include <linux/module.h>
12#include <linux/hrtimer.h>
13#include <linux/dma-mapping.h>
14#include <linux/kmsan.h>
14#include <linux/spinlock.h>
15#include <xen/xen.h>
16
17#ifdef DEBUG
18/* For development, we want to crash whenever the ring is screwed. */
19#define BAD_RING(_vq, fmt, args...) \
20 do { \
21 dev_err(&(_vq)->vq.vdev->dev, \

--- 325 unchanged lines hidden (view full) ---

347 return vq->vq.vdev->dev.parent;
348}
349
350/* Map one sg entry. */
351static dma_addr_t vring_map_one_sg(const struct vring_virtqueue *vq,
352 struct scatterlist *sg,
353 enum dma_data_direction direction)
354{
15#include <linux/spinlock.h>
16#include <xen/xen.h>
17
18#ifdef DEBUG
19/* For development, we want to crash whenever the ring is screwed. */
20#define BAD_RING(_vq, fmt, args...) \
21 do { \
22 dev_err(&(_vq)->vq.vdev->dev, \

--- 325 unchanged lines hidden (view full) ---

348 return vq->vq.vdev->dev.parent;
349}
350
351/* Map one sg entry. */
352static dma_addr_t vring_map_one_sg(const struct vring_virtqueue *vq,
353 struct scatterlist *sg,
354 enum dma_data_direction direction)
355{
355 if (!vq->use_dma_api)
356 if (!vq->use_dma_api) {
357 /*
358 * If DMA is not used, KMSAN doesn't know that the scatterlist
359 * is initialized by the hardware. Explicitly check/unpoison it
360 * depending on the direction.
361 */
362 kmsan_handle_dma(sg_page(sg), sg->offset, sg->length, direction);
356 return (dma_addr_t)sg_phys(sg);
363 return (dma_addr_t)sg_phys(sg);
364 }
357
358 /*
359 * We can't use dma_map_sg, because we don't use scatterlists in
360 * the way it expects (we don't guarantee that the scatterlist
361 * will exist for the lifetime of the mapping).
362 */
363 return dma_map_page(vring_dma_dev(vq),
364 sg_page(sg), sg->offset, sg->length,

--- 2494 unchanged lines hidden ---
365
366 /*
367 * We can't use dma_map_sg, because we don't use scatterlists in
368 * the way it expects (we don't guarantee that the scatterlist
369 * will exist for the lifetime of the mapping).
370 */
371 return dma_map_page(vring_dma_dev(vq),
372 sg_page(sg), sg->offset, sg->length,

--- 2494 unchanged lines hidden ---