Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion block/blk-map.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,17 @@ static void bio_copy_kern_endio_read(struct bio *bio)
bio_copy_kern_endio(bio);
}

static bool blk_kern_needs_copy(void *kbuf, unsigned int len)
{
#ifdef CONFIG_LKL
char *buf = kbuf;

return !virt_addr_valid(buf) || !virt_addr_valid(buf + len - 1);
#else
return false;
#endif
}

/**
* bio_copy_kern - copy kernel address into bio
* @q: the struct request_queue for the bio
Expand Down Expand Up @@ -772,7 +783,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
return -EINVAL;

if (!blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf) ||
blk_queue_may_bounce(q))
blk_kern_needs_copy(kbuf, len) || blk_queue_may_bounce(q))
bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
else
bio = bio_map_kern(q, kbuf, len, gfp_mask);
Expand Down
Loading