Skip to content

Commit 35d86fb

Browse files
committed
drm/vmwgfx: Print errors when running on broken/unsupported configs
virtualbox implemented an incomplete version of the svga device which they decided to drop soon after the initial release. The device was always broken in various ways and never supported by vmwgfx. vmwgfx should refuse to load on those configurations but currently drm has no way of reloading fbdev when the specific pci driver refuses to load, which would leave users without a usable fb. Instead of refusing to load print an error and disable a bunch of functionality that virtualbox never implemented to at least get fb to work on their setup. Signed-off-by: Zack Rusin <[email protected]> Reviewed-by: Martin Krastev <[email protected]> Reviewed-by: Maaz Mombasawala <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 4904384 commit 35d86fb

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

drivers/gpu/drm/vmwgfx/vmwgfx_drv.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
#include <drm/ttm/ttm_placement.h>
4646
#include <generated/utsrelease.h>
4747

48+
#ifdef CONFIG_X86
49+
#include <asm/hypervisor.h>
50+
#endif
4851
#include <linux/cc_platform.h>
4952
#include <linux/dma-mapping.h>
5053
#include <linux/module.h>
@@ -897,6 +900,16 @@ static int vmw_driver_load(struct vmw_private *dev_priv, u32 pci_id)
897900
cap2_names, ARRAY_SIZE(cap2_names));
898901
}
899902

903+
if (!vmwgfx_supported(dev_priv)) {
904+
vmw_disable_backdoor();
905+
drm_err_once(&dev_priv->drm,
906+
"vmwgfx seems to be running on an unsupported hypervisor.");
907+
drm_err_once(&dev_priv->drm,
908+
"This configuration is likely broken.");
909+
drm_err_once(&dev_priv->drm,
910+
"Please switch to a supported graphics device to avoid problems.");
911+
}
912+
900913
ret = vmw_dma_select_mode(dev_priv);
901914
if (unlikely(ret != 0)) {
902915
drm_info(&dev_priv->drm,
@@ -1320,6 +1333,22 @@ static void vmw_master_drop(struct drm_device *dev,
13201333
vmw_kms_legacy_hotspot_clear(dev_priv);
13211334
}
13221335

1336+
bool vmwgfx_supported(struct vmw_private *vmw)
1337+
{
1338+
#if defined(CONFIG_X86)
1339+
return hypervisor_is_type(X86_HYPER_VMWARE);
1340+
#elif defined(CONFIG_ARM64)
1341+
/*
1342+
* On aarch64 only svga3 is supported
1343+
*/
1344+
return vmw->pci_id == VMWGFX_PCI_ID_SVGA3;
1345+
#else
1346+
drm_warn_once(&vmw->drm,
1347+
"vmwgfx is running on an unknown architecture.");
1348+
return false;
1349+
#endif
1350+
}
1351+
13231352
/**
13241353
* __vmw_svga_enable - Enable SVGA mode, FIFO and use of VRAM.
13251354
*

drivers/gpu/drm/vmwgfx/vmwgfx_drv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,7 @@ static inline u32 vmw_max_num_uavs(struct vmw_private *dev_priv)
773773

774774
extern void vmw_svga_enable(struct vmw_private *dev_priv);
775775
extern void vmw_svga_disable(struct vmw_private *dev_priv);
776+
bool vmwgfx_supported(struct vmw_private *vmw);
776777

777778

778779
/**
@@ -1358,6 +1359,7 @@ int vmw_bo_cpu_blit(struct ttm_buffer_object *dst,
13581359
struct vmw_diff_cpy *diff);
13591360

13601361
/* Host messaging -vmwgfx_msg.c: */
1362+
void vmw_disable_backdoor(void);
13611363
int vmw_host_get_guestinfo(const char *guest_info_param,
13621364
char *buffer, size_t *length);
13631365
__printf(1, 2) int vmw_host_printf(const char *fmt, ...);

drivers/gpu/drm/vmwgfx/vmwgfx_msg.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,3 +1179,12 @@ int vmw_mksstat_remove_ioctl(struct drm_device *dev, void *data,
11791179

11801180
return -EAGAIN;
11811181
}
1182+
1183+
/**
1184+
* vmw_disable_backdoor: Disables all backdoor communication
1185+
* with the hypervisor.
1186+
*/
1187+
void vmw_disable_backdoor(void)
1188+
{
1189+
vmw_msg_enabled = 0;
1190+
}

0 commit comments

Comments
 (0)