Skip to content

Commit d085eb8

Browse files
committed
vhost: disable for OABI
vhost is currently broken on the some ARM configs. The reason is that the ring element addresses are passed between components with different alignments assumptions. Thus, if guest selects a pointer and host then gets and dereferences it, then alignment assumed by the host's compiler might be greater than the actual alignment of the pointer. compiler on the host from assuming pointer is aligned. This actually triggers on ARM with -mabi=apcs-gnu - which is a deprecated configuration. With this OABI, compiler assumes that all structures are 4 byte aligned - which is stronger than virtio guarantees for available and used rings, which are merely 2 bytes. Thus a guest without -mabi=apcs-gnu running on top of host with -mabi=apcs-gnu will be broken. The correct fix is to force alignment of structures - however that is an intrusive fix that's best deferred until the next release. We didn't previously support such ancient systems at all - this surfaced after vdpa support prompted removing dependency of vhost on VIRTULIZATION. So for now, let's just add something along the lines of depends on !ARM || AEABI to the virtio Kconfig declaration, and add a comment that it has to do with struct member alignment. Note: we can't make VHOST and VHOST_RING themselves have a dependency since these are selected. Add a new symbol for that. We should be able to drop this dependency down the road. Fixes: 20c384f ("vhost: refine vhost and vringh kconfig") Suggested-by: Ard Biesheuvel <[email protected]> Suggested-by: Richard Earnshaw <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 15064e7 commit d085eb8

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

drivers/misc/mic/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ config MIC_COSM
116116

117117
config VOP
118118
tristate "VOP Driver"
119-
depends on VOP_BUS
119+
depends on VOP_BUS && VHOST_DPN
120120
select VHOST_RING
121121
select VIRTIO
122122
help

drivers/net/caif/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ config CAIF_HSI
5050

5151
config CAIF_VIRTIO
5252
tristate "CAIF virtio transport driver"
53-
depends on CAIF && HAS_DMA
53+
depends on CAIF && HAS_DMA && VHOST_DPN
5454
select VHOST_RING
5555
select VIRTIO
5656
select GENERIC_ALLOCATOR

drivers/vdpa/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if VDPA
1010

1111
config VDPA_SIM
1212
tristate "vDPA device simulator"
13-
depends on RUNTIME_TESTING_MENU && HAS_DMA
13+
depends on RUNTIME_TESTING_MENU && HAS_DMA && VHOST_DPN
1414
select VHOST_RING
1515
default n
1616
help

drivers/vhost/Kconfig

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ config VHOST_RING
1313
This option is selected by any driver which needs to access
1414
the host side of a virtio ring.
1515

16+
config VHOST_DPN
17+
bool
18+
depends on !ARM || AEABI
19+
default y
20+
help
21+
Anything selecting VHOST or VHOST_RING must depend on VHOST_DPN.
22+
This excludes the deprecated ARM ABI since that forces a 4 byte
23+
alignment on all structs - incompatible with virtio spec requirements.
24+
1625
config VHOST
1726
tristate
1827
select VHOST_IOTLB
@@ -28,7 +37,7 @@ if VHOST_MENU
2837

2938
config VHOST_NET
3039
tristate "Host kernel accelerator for virtio net"
31-
depends on NET && EVENTFD && (TUN || !TUN) && (TAP || !TAP)
40+
depends on NET && EVENTFD && (TUN || !TUN) && (TAP || !TAP) && VHOST_DPN
3241
select VHOST
3342
---help---
3443
This kernel module can be loaded in host kernel to accelerate
@@ -40,7 +49,7 @@ config VHOST_NET
4049

4150
config VHOST_SCSI
4251
tristate "VHOST_SCSI TCM fabric driver"
43-
depends on TARGET_CORE && EVENTFD
52+
depends on TARGET_CORE && EVENTFD && VHOST_DPN
4453
select VHOST
4554
default n
4655
---help---
@@ -49,7 +58,7 @@ config VHOST_SCSI
4958

5059
config VHOST_VSOCK
5160
tristate "vhost virtio-vsock driver"
52-
depends on VSOCKETS && EVENTFD
61+
depends on VSOCKETS && EVENTFD && VHOST_DPN
5362
select VHOST
5463
select VIRTIO_VSOCKETS_COMMON
5564
default n
@@ -63,7 +72,7 @@ config VHOST_VSOCK
6372

6473
config VHOST_VDPA
6574
tristate "Vhost driver for vDPA-based backend"
66-
depends on EVENTFD
75+
depends on EVENTFD && VHOST_DPN
6776
select VHOST
6877
depends on VDPA
6978
help

0 commit comments

Comments
 (0)