Skip to content

Commit d8e0420

Browse files
Jeremy Fitzhardingekonradwilk
Jeremy Fitzhardinge
authored andcommitted
xen: define BIOVEC_PHYS_MERGEABLE()
Impact: allow Xen control of bio merging When running in Xen domain with device access, we need to make sure the block subsystem doesn't merge requests across pages which aren't machine physically contiguous. To do this, we define our own BIOVEC_PHYS_MERGEABLE. When CONFIG_XEN isn't enabled, or we're not running in a Xen domain, this has identical behaviour to the normal implementation. When running under Xen, we also make sure the underlying machine pages are the same or adjacent. Signed-off-by: Jeremy Fitzhardinge <[email protected]> Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
1 parent 23ace95 commit d8e0420

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

arch/x86/include/asm/io.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
#include <asm-generic/int-ll64.h>
4242
#include <asm/page.h>
4343

44+
#include <xen/xen.h>
45+
4446
#define build_mmio_read(name, size, type, reg, barrier) \
4547
static inline type name(const volatile void __iomem *addr) \
4648
{ type ret; asm volatile("mov" size " %1,%0":reg (ret) \
@@ -349,6 +351,17 @@ extern void __iomem *early_memremap(resource_size_t phys_addr,
349351
extern void early_iounmap(void __iomem *addr, unsigned long size);
350352
extern void fixup_early_ioremap(void);
351353

354+
#ifdef CONFIG_XEN
355+
struct bio_vec;
356+
357+
extern bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
358+
const struct bio_vec *vec2);
359+
360+
#define BIOVEC_PHYS_MERGEABLE(vec1, vec2) \
361+
(__BIOVEC_PHYS_MERGEABLE(vec1, vec2) && \
362+
(!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2)))
363+
#endif /* CONFIG_XEN */
364+
352365
#define IO_SPACE_LIMIT 0xffff
353366

354367
#endif /* _ASM_X86_IO_H */

drivers/xen/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
obj-y += grant-table.o features.o events.o manage.o
1+
obj-y += grant-table.o features.o events.o manage.o biomerge.o
22
obj-y += xenbus/
33

44
nostackp := $(call cc-option, -fno-stack-protector)

drivers/xen/biomerge.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <linux/bio.h>
2+
#include <linux/io.h>
3+
#include <xen/page.h>
4+
5+
bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
6+
const struct bio_vec *vec2)
7+
{
8+
unsigned long mfn1 = pfn_to_mfn(page_to_pfn(vec1->bv_page));
9+
unsigned long mfn2 = pfn_to_mfn(page_to_pfn(vec2->bv_page));
10+
11+
return __BIOVEC_PHYS_MERGEABLE(vec1, vec2) &&
12+
((mfn1 == mfn2) || ((mfn1+1) == mfn2));
13+
}

0 commit comments

Comments
 (0)