summaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-rakk.c
diff options
context:
space:
mode:
authorSean Christopherson <seanjc@google.com>2026-09-23 09:37:21 -0700
committerPaolo Bonzini <pbonzini@redhat.com>2026-09-26 00:39:55 -0400
commit93de2a6a4b91b72607136dd656edf03fb399d27f (patch)
tree9220c76eb23cb39a146fac9692ee69afa4aa3135 /drivers/hid/hid-rakk.c
downloadlinux-stable-93de2a6a4b91b72607136dd656edf03fb399d27f.tar.gz
linux-stable-93de2a6a4b91b72607136dd656edf03fb399d27f.zip
KVM: SEV: Do cache maintenance on the source VM during intra-host migrationgrafted
Manually perform cache maintenance on the source VM during intra-host migration to ensure no stale data is left in CPU caches after the VM is destroyed. Because the source VM is "converted" to a non-SEV VM, KVM's memory reclaim flows won't trigger cache maintenance, e.g. when all guest memory is reclaimed in response to detaching from the mmu_notifier. Note, relying on the destination VM to do cache maintenance isn't an option as KVM doesn't require identical guest memory configurations, i.e. the source VM may have access to memory that the destination VM does not. Enforcing equivalent memory configurations is infeasible, as it would require a *deep* comparison of memslots, e.g. to verify that not only are the memslot identical, but what the memslots point at is also identical. Fixes: b56639318bb2 ("KVM: SEV: Add support for SEV intra host migration") Cc: stable@vger.kernel.org Reported-by: Stefan Teodorescu <fane@google.com> Signed-off-by: Sean Christopherson <seanjc@google.com> Message-ID: <20260923163721.1584779-3-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'drivers/hid/hid-rakk.c')
-rw-r--r--drivers/hid/hid-rakk.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/drivers/hid/hid-rakk.c b/drivers/hid/hid-rakk.c
new file mode 100644
index 000000000..1140058a7
--- /dev/null
+++ b/drivers/hid/hid-rakk.c
@@ -0,0 +1,75 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * HID driver for Rakk devices
+ *
+ * Copyright (c) 2026 Karl Cayme
+ *
+ * The Rakk Dasig X gaming mouse has a faulty HID report descriptor that
+ * declares USAGE_MAXIMUM = 3 (buttons 1-3) while actually sending 5 button
+ * bits (REPORT_COUNT = 5). This causes the kernel to ignore side buttons
+ * (buttons 4 and 5). This driver fixes the descriptor so all 5 buttons
+ * are properly recognized across 3 modes (wired, dongle, and Bluetooth).
+ */
+
+#include <linux/device.h>
+#include <linux/hid.h>
+#include <linux/module.h>
+#include "hid-ids.h"
+
+/*
+ * The faulty byte is at offset 17 in the report descriptor for all three
+ * connection modes (USB direct, wireless dongle, and Bluetooth).
+ *
+ * Bytes 16-17 are: 0x29 0x03 (USAGE_MAXIMUM = 3)
+ * The fix changes byte 17 to 0x05 (USAGE_MAXIMUM = 5).
+ *
+ * Original descriptor bytes 0-17:
+ * 05 01 09 02 a1 01 85 01 09 01 a1 00 05 09 19 01 29 03
+ * ^^
+ * Should be 0x05 to declare 5 buttons instead of 3.
+ */
+#define RAKK_RDESC_USAGE_MAX_OFFSET 17
+#define RAKK_RDESC_USAGE_MAX_ORIG 0x03
+#define RAKK_RDESC_USAGE_MAX_FIXED 0x05
+#define RAKK_RDESC_USB_SIZE 193
+#define RAKK_RDESC_DONGLE_SIZE 150
+#define RAKK_RDESC_BT_SIZE 89
+
+static const __u8 *rakk_report_fixup(struct hid_device *hdev, __u8 *rdesc,
+ unsigned int *rsize)
+{
+ if (((*rsize == RAKK_RDESC_USB_SIZE &&
+ hdev->product == USB_DEVICE_ID_TELINK_RAKK_DASIG_X) ||
+ (*rsize == RAKK_RDESC_DONGLE_SIZE &&
+ hdev->product == USB_DEVICE_ID_TELINK_RAKK_DASIG_X_DONGLE) ||
+ (*rsize == RAKK_RDESC_BT_SIZE &&
+ hdev->product == USB_DEVICE_ID_TELINK_RAKK_DASIG_X_BT)) &&
+ rdesc[RAKK_RDESC_USAGE_MAX_OFFSET] == RAKK_RDESC_USAGE_MAX_ORIG) {
+ hid_info(hdev, "fixing Rakk Dasig X button count (3 -> 5)\n");
+ rdesc[RAKK_RDESC_USAGE_MAX_OFFSET] = RAKK_RDESC_USAGE_MAX_FIXED;
+ }
+
+ return rdesc;
+}
+
+static const struct hid_device_id rakk_devices[] = {
+ { HID_USB_DEVICE(USB_VENDOR_ID_TELINK,
+ USB_DEVICE_ID_TELINK_RAKK_DASIG_X) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_TELINK,
+ USB_DEVICE_ID_TELINK_RAKK_DASIG_X_DONGLE) },
+ { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_TELINK,
+ USB_DEVICE_ID_TELINK_RAKK_DASIG_X_BT) },
+ { }
+};
+MODULE_DEVICE_TABLE(hid, rakk_devices);
+
+static struct hid_driver rakk_driver = {
+ .name = "rakk",
+ .id_table = rakk_devices,
+ .report_fixup = rakk_report_fixup,
+};
+module_hid_driver(rakk_driver);
+
+MODULE_DESCRIPTION("HID driver for Rakk Dasig X mouse - fix side button support");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Karl Cayme");