diff mbox series

[RFC,11/12] xue: prevent dom0 (or other domain) from using the device

Message ID 74ffafdaa109f6067f2ecbc89b885a8a9cdbadaf.1654486751.git-series.marmarek@invisiblethingslab.com (mailing list archive)
State Superseded
Headers show
Series Add Xue - console over USB 3 Debug Capability | expand

Commit Message

Marek Marczykowski-Górecki June 6, 2022, 3:40 a.m. UTC
Mark config space of the device as read-only, to prevent dom0 (or
others) re-configuring the USB controller while it's used as a debug
console.

This isn't strictly necessary, as the xhci and xhci-dbc drivers can
co-exists, but that's a simpler option.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
---
 xen/drivers/char/xue.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/xen/drivers/char/xue.c b/xen/drivers/char/xue.c
index 8863b996c619..ff62b868e906 100644
--- a/xen/drivers/char/xue.c
+++ b/xen/drivers/char/xue.c
@@ -70,6 +70,13 @@  static void __init cf_check xue_uart_init_postirq(struct serial_port *port)
     serial_async_transmit(port);
     init_timer(&uart->timer, xue_uart_poll, port, 0);
     set_timer(&uart->timer, NOW() + MILLISECS(1));
+
+    if ( pci_ro_device(0, (uart->xue.xhc_cf8 >> 16) & 0xff,
+                          (uart->xue.xhc_cf8 >> 8) & 0xff) )
+            printk(XENLOG_INFO "Could not mark config space of %02x:%02x.%u read-only.\n",
+                   (uart->xue.xhc_cf8 >> 16) & 0xff,
+                   (uart->xue.xhc_cf8 >> 11) & 0x1f,
+                   (uart->xue.xhc_cf8 >> 8) & 0x0f);
 }
 
 static int cf_check xue_uart_tx_ready(struct serial_port *port)