mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-23 16:53:58 -05:00
virtio_bt: Fix alignment in configuration struct
The current version of the configuration structure has unaligned 16-bit fields, but according to the specification [1], access to the configuration space must be aligned. Add a second, aligned version of the configuration structure and a new feature bit indicating that this version is being used. [1] https://docs.oasis-open.org/virtio/virtio/v1.1/virtio-v1.1.pdf Signed-off-by: Igor Skalkin <Igor.Skalkin@opensynergy.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
3b1c7c00b8
commit
47c50853bb
2 changed files with 21 additions and 3 deletions
|
@ -313,7 +313,12 @@ static int virtbt_probe(struct virtio_device *vdev)
|
||||||
if (virtio_has_feature(vdev, VIRTIO_BT_F_VND_HCI)) {
|
if (virtio_has_feature(vdev, VIRTIO_BT_F_VND_HCI)) {
|
||||||
__u16 vendor;
|
__u16 vendor;
|
||||||
|
|
||||||
virtio_cread(vdev, struct virtio_bt_config, vendor, &vendor);
|
if (virtio_has_feature(vdev, VIRTIO_BT_F_CONFIG_V2))
|
||||||
|
virtio_cread(vdev, struct virtio_bt_config_v2,
|
||||||
|
vendor, &vendor);
|
||||||
|
else
|
||||||
|
virtio_cread(vdev, struct virtio_bt_config,
|
||||||
|
vendor, &vendor);
|
||||||
|
|
||||||
switch (vendor) {
|
switch (vendor) {
|
||||||
case VIRTIO_BT_CONFIG_VENDOR_ZEPHYR:
|
case VIRTIO_BT_CONFIG_VENDOR_ZEPHYR:
|
||||||
|
@ -346,6 +351,10 @@ static int virtbt_probe(struct virtio_device *vdev)
|
||||||
if (virtio_has_feature(vdev, VIRTIO_BT_F_MSFT_EXT)) {
|
if (virtio_has_feature(vdev, VIRTIO_BT_F_MSFT_EXT)) {
|
||||||
__u16 msft_opcode;
|
__u16 msft_opcode;
|
||||||
|
|
||||||
|
if (virtio_has_feature(vdev, VIRTIO_BT_F_CONFIG_V2))
|
||||||
|
virtio_cread(vdev, struct virtio_bt_config_v2,
|
||||||
|
msft_opcode, &msft_opcode);
|
||||||
|
else
|
||||||
virtio_cread(vdev, struct virtio_bt_config,
|
virtio_cread(vdev, struct virtio_bt_config,
|
||||||
msft_opcode, &msft_opcode);
|
msft_opcode, &msft_opcode);
|
||||||
|
|
||||||
|
@ -402,6 +411,7 @@ static const unsigned int virtbt_features[] = {
|
||||||
VIRTIO_BT_F_VND_HCI,
|
VIRTIO_BT_F_VND_HCI,
|
||||||
VIRTIO_BT_F_MSFT_EXT,
|
VIRTIO_BT_F_MSFT_EXT,
|
||||||
VIRTIO_BT_F_AOSP_EXT,
|
VIRTIO_BT_F_AOSP_EXT,
|
||||||
|
VIRTIO_BT_F_CONFIG_V2,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct virtio_driver virtbt_driver = {
|
static struct virtio_driver virtbt_driver = {
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#define VIRTIO_BT_F_VND_HCI 0 /* Indicates vendor command support */
|
#define VIRTIO_BT_F_VND_HCI 0 /* Indicates vendor command support */
|
||||||
#define VIRTIO_BT_F_MSFT_EXT 1 /* Indicates MSFT vendor support */
|
#define VIRTIO_BT_F_MSFT_EXT 1 /* Indicates MSFT vendor support */
|
||||||
#define VIRTIO_BT_F_AOSP_EXT 2 /* Indicates AOSP vendor support */
|
#define VIRTIO_BT_F_AOSP_EXT 2 /* Indicates AOSP vendor support */
|
||||||
|
#define VIRTIO_BT_F_CONFIG_V2 3 /* Use second version configuration */
|
||||||
|
|
||||||
enum virtio_bt_config_type {
|
enum virtio_bt_config_type {
|
||||||
VIRTIO_BT_CONFIG_TYPE_PRIMARY = 0,
|
VIRTIO_BT_CONFIG_TYPE_PRIMARY = 0,
|
||||||
|
@ -28,4 +29,11 @@ struct virtio_bt_config {
|
||||||
__u16 msft_opcode;
|
__u16 msft_opcode;
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
struct virtio_bt_config_v2 {
|
||||||
|
__u8 type;
|
||||||
|
__u8 alignment;
|
||||||
|
__u16 vendor;
|
||||||
|
__u16 msft_opcode;
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* _UAPI_LINUX_VIRTIO_BT_H */
|
#endif /* _UAPI_LINUX_VIRTIO_BT_H */
|
||||||
|
|
Loading…
Add table
Reference in a new issue