diff --git a/src/lib/qemu/hw/usb/hcd-xhci.c b/src/lib/qemu/hw/usb/hcd-xhci.c
index c673bed..cd930da 100644
--- a/src/lib/qemu/hw/usb/hcd-xhci.c
+++ b/src/lib/qemu/hw/usb/hcd-xhci.c
@@ -486,6 +486,8 @@ struct XHCIState {
 
 #define TYPE_XHCI "nec-usb-xhci"
 
+#ifndef __cplusplus
+
 #define XHCI(obj) \
     OBJECT_CHECK(XHCIState, (obj), TYPE_XHCI)
 
@@ -1349,6 +1351,14 @@ static void xhci_set_ep_state(XHCIState *xhci, XHCIEPContext *epctx,
 static void xhci_ep_kick_timer(void *opaque)
 {
     XHCIEPContext *epctx = opaque;
+
+    /*
+     * We might have blocked in the entry lock, while the endpoint was stopped
+     * by another thread
+     */
+    if (epctx->state == CC_STOPPED)
+        return;
+
     xhci_kick_ep(epctx->xhci, epctx->slotid, epctx->epid, 0);
 }
 
@@ -2361,6 +2371,7 @@ static TRBCCode xhci_address_slot(XHCIState *xhci, unsigned int slotid,
 
     if (bsr) {
         slot_ctx[3] = SLOT_DEFAULT << SLOT_STATE_SHIFT;
+        usb_device_reset(dev);
     } else {
         USBPacket p;
         uint8_t buf[1];
@@ -3914,3 +3925,5 @@ static void xhci_register_types(void)
 }
 
 type_init(xhci_register_types)
+
+#endif /* __cplusplus */
