Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: vboxvideo: Fix reporting invalid suggested-offset-properties

The x and y hints receives from the host are unsigned 32 bit integers and
they get set to -1 (0xffffffff) when invalid. Before this commit the
vboxvideo driver was storing them in an u16 causing the -1 to be truncated
to 65535 which, once reported to userspace, was breaking gnome 3.26+
in Wayland mode.

This commit stores the host values in 32 bit variables, removing the
truncation and checks for -1, replacing it with 0 as -1 is not a valid
suggested-offset-property value. Likewise the properties are now
initialized to 0 instead of -1, since -1 is not a valid value.
This fixes gnome 3.26+ in Wayland mode not working with the vboxvideo
driver.

Reported-by: Gianfranco Costamagna <locutusofborg@debian.org>
Cc: stable@vger.kernel.org
Cc: Michael Thayer <michael.thayer@oracle.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Hans de Goede and committed by
Greg Kroah-Hartman
ce10d7b4 69ccc624

+24 -14
+4 -4
drivers/staging/vboxvideo/vbox_drv.h
··· 137 137 char name[32]; 138 138 struct vbox_crtc *vbox_crtc; 139 139 struct { 140 - u16 width; 141 - u16 height; 140 + u32 width; 141 + u32 height; 142 142 bool disconnected; 143 143 } mode_hint; 144 144 }; ··· 150 150 unsigned int crtc_id; 151 151 u32 fb_offset; 152 152 bool cursor_enabled; 153 - u16 x_hint; 154 - u16 y_hint; 153 + u32 x_hint; 154 + u32 y_hint; 155 155 }; 156 156 157 157 struct vbox_encoder {
+2 -2
drivers/staging/vboxvideo/vbox_irq.c
··· 150 150 151 151 disconnected = !(hints->enabled); 152 152 crtc_id = vbox_conn->vbox_crtc->crtc_id; 153 - vbox_conn->mode_hint.width = hints->cx & 0x8fff; 154 - vbox_conn->mode_hint.height = hints->cy & 0x8fff; 153 + vbox_conn->mode_hint.width = hints->cx; 154 + vbox_conn->mode_hint.height = hints->cy; 155 155 vbox_conn->vbox_crtc->x_hint = hints->dx; 156 156 vbox_conn->vbox_crtc->y_hint = hints->dy; 157 157 vbox_conn->mode_hint.disconnected = disconnected;
+18 -8
drivers/staging/vboxvideo/vbox_mode.c
··· 553 553 ++num_modes; 554 554 } 555 555 vbox_set_edid(connector, preferred_width, preferred_height); 556 - drm_object_property_set_value( 557 - &connector->base, vbox->dev->mode_config.suggested_x_property, 558 - vbox_connector->vbox_crtc->x_hint); 559 - drm_object_property_set_value( 560 - &connector->base, vbox->dev->mode_config.suggested_y_property, 561 - vbox_connector->vbox_crtc->y_hint); 556 + 557 + if (vbox_connector->vbox_crtc->x_hint != -1) 558 + drm_object_property_set_value(&connector->base, 559 + vbox->dev->mode_config.suggested_x_property, 560 + vbox_connector->vbox_crtc->x_hint); 561 + else 562 + drm_object_property_set_value(&connector->base, 563 + vbox->dev->mode_config.suggested_x_property, 0); 564 + 565 + if (vbox_connector->vbox_crtc->y_hint != -1) 566 + drm_object_property_set_value(&connector->base, 567 + vbox->dev->mode_config.suggested_y_property, 568 + vbox_connector->vbox_crtc->y_hint); 569 + else 570 + drm_object_property_set_value(&connector->base, 571 + vbox->dev->mode_config.suggested_y_property, 0); 562 572 563 573 return num_modes; 564 574 } ··· 650 640 651 641 drm_mode_create_suggested_offset_properties(dev); 652 642 drm_object_attach_property(&connector->base, 653 - dev->mode_config.suggested_x_property, -1); 643 + dev->mode_config.suggested_x_property, 0); 654 644 drm_object_attach_property(&connector->base, 655 - dev->mode_config.suggested_y_property, -1); 645 + dev->mode_config.suggested_y_property, 0); 656 646 drm_connector_register(connector); 657 647 658 648 drm_mode_connector_attach_encoder(connector, encoder);