]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.16-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 23 Jan 2022 13:51:02 +0000 (14:51 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 23 Jan 2022 13:51:02 +0000 (14:51 +0100)
added patches:
alsa-core-fix-ssid-quirk-lookup-for-subvendor-0.patch
hid-ignore-battery-for-elan-touchscreen-on-hp-envy-x360-15t-dr100.patch
hid-uhid-fix-worker-destroying-device-without-any-protection.patch
hid-wacom-avoid-using-stale-array-indicies-to-read-contact-count.patch
hid-wacom-ignore-the-confidence-flag-when-a-touch-is-removed.patch
hid-wacom-reset-expected-and-received-contact-counts-at-the-same-time.patch
kvm-vmx-switch-blocked_vcpu_on_cpu_lock-to-raw-spinlock.patch
kvm-x86-mmu-fix-write-protection-of-pts-mapped-by-the-tdp-mmu.patch

queue-5.16/alsa-core-fix-ssid-quirk-lookup-for-subvendor-0.patch [new file with mode: 0644]
queue-5.16/hid-ignore-battery-for-elan-touchscreen-on-hp-envy-x360-15t-dr100.patch [new file with mode: 0644]
queue-5.16/hid-uhid-fix-worker-destroying-device-without-any-protection.patch [new file with mode: 0644]
queue-5.16/hid-wacom-avoid-using-stale-array-indicies-to-read-contact-count.patch [new file with mode: 0644]
queue-5.16/hid-wacom-ignore-the-confidence-flag-when-a-touch-is-removed.patch [new file with mode: 0644]
queue-5.16/hid-wacom-reset-expected-and-received-contact-counts-at-the-same-time.patch [new file with mode: 0644]
queue-5.16/kvm-vmx-switch-blocked_vcpu_on_cpu_lock-to-raw-spinlock.patch [new file with mode: 0644]
queue-5.16/kvm-x86-mmu-fix-write-protection-of-pts-mapped-by-the-tdp-mmu.patch [new file with mode: 0644]
queue-5.16/series [new file with mode: 0644]

diff --git a/queue-5.16/alsa-core-fix-ssid-quirk-lookup-for-subvendor-0.patch b/queue-5.16/alsa-core-fix-ssid-quirk-lookup-for-subvendor-0.patch
new file mode 100644 (file)
index 0000000..76cdc9a
--- /dev/null
@@ -0,0 +1,38 @@
+From 5576c4f24c56722a2d9fb9c447d896e5b312078b Mon Sep 17 00:00:00 2001
+From: Takashi Iwai <tiwai@suse.de>
+Date: Sun, 16 Jan 2022 09:28:38 +0100
+Subject: ALSA: core: Fix SSID quirk lookup for subvendor=0
+
+From: Takashi Iwai <tiwai@suse.de>
+
+commit 5576c4f24c56722a2d9fb9c447d896e5b312078b upstream.
+
+Some weird devices set the codec SSID vendor ID 0, and
+snd_pci_quirk_lookup_id() loop aborts at the point although it should
+still try matching with the SSID device ID.  This resulted in a
+missing quirk for some old Macs.
+
+Fix the loop termination condition to check both subvendor and
+subdevice.
+
+Fixes: 73355ddd8775 ("ALSA: hda: Code refactoring snd_hda_pick_fixup()")
+Cc: <stable@vger.kernel.org>
+BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=215495
+Link: https://lore.kernel.org/r/20220116082838.19382-1-tiwai@suse.de
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ sound/core/misc.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/sound/core/misc.c
++++ b/sound/core/misc.c
+@@ -112,7 +112,7 @@ snd_pci_quirk_lookup_id(u16 vendor, u16
+ {
+       const struct snd_pci_quirk *q;
+-      for (q = list; q->subvendor; q++) {
++      for (q = list; q->subvendor || q->subdevice; q++) {
+               if (q->subvendor != vendor)
+                       continue;
+               if (!q->subdevice ||
diff --git a/queue-5.16/hid-ignore-battery-for-elan-touchscreen-on-hp-envy-x360-15t-dr100.patch b/queue-5.16/hid-ignore-battery-for-elan-touchscreen-on-hp-envy-x360-15t-dr100.patch
new file mode 100644 (file)
index 0000000..0680e47
--- /dev/null
@@ -0,0 +1,46 @@
+From f3193ea1b6779023334faa72b214ece457e02656 Mon Sep 17 00:00:00 2001
+From: Karl Kurbjun <kkurbjun@gmail.com>
+Date: Sun, 9 Jan 2022 20:49:35 -0700
+Subject: HID: Ignore battery for Elan touchscreen on HP Envy X360 15t-dr100
+
+From: Karl Kurbjun <kkurbjun@gmail.com>
+
+commit f3193ea1b6779023334faa72b214ece457e02656 upstream.
+
+Battery status on Elan tablet driver is reported for the HP ENVY x360
+15t-dr100. There is no separate battery for the Elan controller resulting in a
+battery level report of 0% or 1% depending on whether a stylus has interacted
+with the screen. These low battery level reports causes a variety of bad
+behavior in desktop environments. This patch adds the appropriate quirk to
+indicate that the batery status is unused for this target.
+
+Cc: stable@vger.kernel.org
+Signed-off-by: Karl Kurbjun <kkurbjun@gmail.com>
+Signed-off-by: Jiri Kosina <jkosina@suse.cz>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/hid/hid-ids.h   |    1 +
+ drivers/hid/hid-input.c |    2 ++
+ 2 files changed, 3 insertions(+)
+
+--- a/drivers/hid/hid-ids.h
++++ b/drivers/hid/hid-ids.h
+@@ -398,6 +398,7 @@
+ #define USB_DEVICE_ID_HP_X2           0x074d
+ #define USB_DEVICE_ID_HP_X2_10_COVER  0x0755
+ #define I2C_DEVICE_ID_HP_ENVY_X360_15 0x2d05
++#define I2C_DEVICE_ID_HP_ENVY_X360_15T_DR100  0x29CF
+ #define I2C_DEVICE_ID_HP_SPECTRE_X360_15      0x2817
+ #define USB_DEVICE_ID_ASUS_UX550VE_TOUCHSCREEN        0x2544
+ #define USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN  0x2706
+--- a/drivers/hid/hid-input.c
++++ b/drivers/hid/hid-input.c
+@@ -329,6 +329,8 @@ static const struct hid_device_id hid_ba
+         HID_BATTERY_QUIRK_IGNORE },
+       { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_ENVY_X360_15),
+         HID_BATTERY_QUIRK_IGNORE },
++      { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_ENVY_X360_15T_DR100),
++        HID_BATTERY_QUIRK_IGNORE },
+       { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_SPECTRE_X360_15),
+         HID_BATTERY_QUIRK_IGNORE },
+       { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_SURFACE_GO_TOUCHSCREEN),
diff --git a/queue-5.16/hid-uhid-fix-worker-destroying-device-without-any-protection.patch b/queue-5.16/hid-uhid-fix-worker-destroying-device-without-any-protection.patch
new file mode 100644 (file)
index 0000000..a116313
--- /dev/null
@@ -0,0 +1,101 @@
+From 4ea5763fb79ed89b3bdad455ebf3f33416a81624 Mon Sep 17 00:00:00 2001
+From: Jann Horn <jannh@google.com>
+Date: Fri, 14 Jan 2022 14:33:30 +0100
+Subject: HID: uhid: Fix worker destroying device without any protection
+
+From: Jann Horn <jannh@google.com>
+
+commit 4ea5763fb79ed89b3bdad455ebf3f33416a81624 upstream.
+
+uhid has to run hid_add_device() from workqueue context while allowing
+parallel use of the userspace API (which is protected with ->devlock).
+But hid_add_device() can fail. Currently, that is handled by immediately
+destroying the associated HID device, without using ->devlock - but if
+there are concurrent requests from userspace, that's wrong and leads to
+NULL dereferences and/or memory corruption (via use-after-free).
+
+Fix it by leaving the HID device as-is in the worker. We can clean it up
+later, either in the UHID_DESTROY command handler or in the ->release()
+handler.
+
+Cc: stable@vger.kernel.org
+Fixes: 67f8ecc550b5 ("HID: uhid: fix timeout when probe races with IO")
+Signed-off-by: Jann Horn <jannh@google.com>
+Signed-off-by: Jiri Kosina <jkosina@suse.cz>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/hid/uhid.c |   29 +++++++++++++++++++++++++----
+ 1 file changed, 25 insertions(+), 4 deletions(-)
+
+--- a/drivers/hid/uhid.c
++++ b/drivers/hid/uhid.c
+@@ -28,11 +28,22 @@
+ struct uhid_device {
+       struct mutex devlock;
++
++      /* This flag tracks whether the HID device is usable for commands from
++       * userspace. The flag is already set before hid_add_device(), which
++       * runs in workqueue context, to allow hid_add_device() to communicate
++       * with userspace.
++       * However, if hid_add_device() fails, the flag is cleared without
++       * holding devlock.
++       * We guarantee that if @running changes from true to false while you're
++       * holding @devlock, it's still fine to access @hid.
++       */
+       bool running;
+       __u8 *rd_data;
+       uint rd_size;
++      /* When this is NULL, userspace may use UHID_CREATE/UHID_CREATE2. */
+       struct hid_device *hid;
+       struct uhid_event input_buf;
+@@ -63,9 +74,18 @@ static void uhid_device_add_worker(struc
+       if (ret) {
+               hid_err(uhid->hid, "Cannot register HID device: error %d\n", ret);
+-              hid_destroy_device(uhid->hid);
+-              uhid->hid = NULL;
++              /* We used to call hid_destroy_device() here, but that's really
++               * messy to get right because we have to coordinate with
++               * concurrent writes from userspace that might be in the middle
++               * of using uhid->hid.
++               * Just leave uhid->hid as-is for now, and clean it up when
++               * userspace tries to close or reinitialize the uhid instance.
++               *
++               * However, we do have to clear the ->running flag and do a
++               * wakeup to make sure userspace knows that the device is gone.
++               */
+               uhid->running = false;
++              wake_up_interruptible(&uhid->report_wait);
+       }
+ }
+@@ -474,7 +494,7 @@ static int uhid_dev_create2(struct uhid_
+       void *rd_data;
+       int ret;
+-      if (uhid->running)
++      if (uhid->hid)
+               return -EALREADY;
+       rd_size = ev->u.create2.rd_size;
+@@ -556,7 +576,7 @@ static int uhid_dev_create(struct uhid_d
+ static int uhid_dev_destroy(struct uhid_device *uhid)
+ {
+-      if (!uhid->running)
++      if (!uhid->hid)
+               return -EINVAL;
+       uhid->running = false;
+@@ -565,6 +585,7 @@ static int uhid_dev_destroy(struct uhid_
+       cancel_work_sync(&uhid->worker);
+       hid_destroy_device(uhid->hid);
++      uhid->hid = NULL;
+       kfree(uhid->rd_data);
+       return 0;
diff --git a/queue-5.16/hid-wacom-avoid-using-stale-array-indicies-to-read-contact-count.patch b/queue-5.16/hid-wacom-avoid-using-stale-array-indicies-to-read-contact-count.patch
new file mode 100644 (file)
index 0000000..b21dc6e
--- /dev/null
@@ -0,0 +1,44 @@
+From 20f3cf5f860f9f267a6a6e5642d3d0525edb1814 Mon Sep 17 00:00:00 2001
+From: Jason Gerecke <killertofu@gmail.com>
+Date: Tue, 18 Jan 2022 14:38:41 -0800
+Subject: HID: wacom: Avoid using stale array indicies to read contact count
+
+From: Jason Gerecke <killertofu@gmail.com>
+
+commit 20f3cf5f860f9f267a6a6e5642d3d0525edb1814 upstream.
+
+If we ever see a touch report with contact count data we initialize
+several variables used to read the contact count in the pre-report
+phase. These variables are never reset if we process a report which
+doesn't contain a contact count, however. This can cause the pre-
+report function to trigger a read of arbitrary memory (e.g. NULL
+if we're lucky) and potentially crash the driver.
+
+This commit restores resetting of the variables back to default
+"none" values that were used prior to the commit mentioned
+below.
+
+Link: https://github.com/linuxwacom/input-wacom/issues/276
+Fixes: 003f50ab673c (HID: wacom: Update last_slot_field during pre_report phase)
+CC: stable@vger.kernel.org
+Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
+Reviewed-by: Ping Cheng <ping.cheng@wacom.com>
+Signed-off-by: Jiri Kosina <jkosina@suse.cz>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/hid/wacom_wac.c |    4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/drivers/hid/wacom_wac.c
++++ b/drivers/hid/wacom_wac.c
+@@ -2682,6 +2682,10 @@ static void wacom_wac_finger_pre_report(
+       hid_data->confidence = true;
++      hid_data->cc_report = 0;
++      hid_data->cc_index = -1;
++      hid_data->cc_value_index = -1;
++
+       for (i = 0; i < report->maxfield; i++) {
+               struct hid_field *field = report->field[i];
+               int j;
diff --git a/queue-5.16/hid-wacom-ignore-the-confidence-flag-when-a-touch-is-removed.patch b/queue-5.16/hid-wacom-ignore-the-confidence-flag-when-a-touch-is-removed.patch
new file mode 100644 (file)
index 0000000..38e1e90
--- /dev/null
@@ -0,0 +1,80 @@
+From df03e9bd6d4806619b4cdc91a3d7695818a8e2b7 Mon Sep 17 00:00:00 2001
+From: Jason Gerecke <killertofu@gmail.com>
+Date: Tue, 18 Jan 2022 14:37:56 -0800
+Subject: HID: wacom: Ignore the confidence flag when a touch is removed
+
+From: Jason Gerecke <killertofu@gmail.com>
+
+commit df03e9bd6d4806619b4cdc91a3d7695818a8e2b7 upstream.
+
+AES hardware may internally re-classify a contact that it thought was
+intentional as a palm. Intentional contacts are reported as "down" with
+the confidence bit set. When this re-classification occurs, however, the
+state transitions to "up" with the confidence bit cleared. This kind of
+transition appears to be legal according to Microsoft docs, but we do
+not handle it correctly. Because the confidence bit is clear, we don't
+call `wacom_wac_finger_slot` and update userspace. This causes hung
+touches that confuse userspace and interfere with pen arbitration.
+
+This commit adds a special case to ignore the confidence flag if a contact
+is reported as removed. This ensures we do not leave a hung touch if one
+of these re-classification events occured. Ideally we'd have some way to
+also let userspace know that the touch has been re-classified as a palm
+and needs to be canceled, but that's not possible right now :)
+
+Link: https://github.com/linuxwacom/input-wacom/issues/288
+Fixes: 7fb0413baa7f (HID: wacom: Use "Confidence" flag to prevent reporting invalid contacts)
+CC: stable@vger.kernel.org
+Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
+Reviewed-by: Ping Cheng <ping.cheng@wacom.com>
+Signed-off-by: Jiri Kosina <jkosina@suse.cz>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/hid/wacom_wac.c |   29 ++++++++++++++++++++++++++---
+ 1 file changed, 26 insertions(+), 3 deletions(-)
+
+--- a/drivers/hid/wacom_wac.c
++++ b/drivers/hid/wacom_wac.c
+@@ -2588,6 +2588,24 @@ static void wacom_wac_finger_slot(struct
+       }
+ }
++static bool wacom_wac_slot_is_active(struct input_dev *dev, int key)
++{
++      struct input_mt *mt = dev->mt;
++      struct input_mt_slot *s;
++
++      if (!mt)
++              return false;
++
++      for (s = mt->slots; s != mt->slots + mt->num_slots; s++) {
++              if (s->key == key &&
++                      input_mt_get_value(s, ABS_MT_TRACKING_ID) >= 0) {
++                      return true;
++              }
++      }
++
++      return false;
++}
++
+ static void wacom_wac_finger_event(struct hid_device *hdev,
+               struct hid_field *field, struct hid_usage *usage, __s32 value)
+ {
+@@ -2638,9 +2656,14 @@ static void wacom_wac_finger_event(struc
+       }
+       if (usage->usage_index + 1 == field->report_count) {
+-              if (equivalent_usage == wacom_wac->hid_data.last_slot_field &&
+-                  wacom_wac->hid_data.confidence)
+-                      wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
++              if (equivalent_usage == wacom_wac->hid_data.last_slot_field) {
++                      bool touch_removed = wacom_wac_slot_is_active(wacom_wac->touch_input,
++                              wacom_wac->hid_data.id) && !wacom_wac->hid_data.tipswitch;
++
++                      if (wacom_wac->hid_data.confidence || touch_removed) {
++                              wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
++                      }
++              }
+       }
+ }
diff --git a/queue-5.16/hid-wacom-reset-expected-and-received-contact-counts-at-the-same-time.patch b/queue-5.16/hid-wacom-reset-expected-and-received-contact-counts-at-the-same-time.patch
new file mode 100644 (file)
index 0000000..a4358b1
--- /dev/null
@@ -0,0 +1,70 @@
+From 546e41ac994cc185ef3de610ca849a294b5df3ba Mon Sep 17 00:00:00 2001
+From: Jason Gerecke <killertofu@gmail.com>
+Date: Tue, 18 Jan 2022 14:37:55 -0800
+Subject: HID: wacom: Reset expected and received contact counts at the same time
+
+From: Jason Gerecke <killertofu@gmail.com>
+
+commit 546e41ac994cc185ef3de610ca849a294b5df3ba upstream.
+
+These two values go hand-in-hand and must be valid for the driver to
+behave correctly. We are currently lazy about updating the values and
+rely on the "expected" code flow to take care of making sure they're
+valid at the point they're needed. The "expected" flow changed somewhat
+with commit f8b6a74719b5 ("HID: wacom: generic: Support multiple tools
+per report"), however. This led to problems with the DTH-2452 due (in
+part) to *all* contacts being fully processed -- even those past the
+expected contact count. Specifically, the received count gets reset to
+0 once all expected fingers are processed, but not the expected count.
+The rest of the contacts in the report are then *also* processed since
+now the driver thinks we've only processed 0 of N expected contacts.
+
+Later commits such as 7fb0413baa7f (HID: wacom: Use "Confidence" flag to
+prevent reporting invalid contacts) worked around the DTH-2452 issue by
+skipping the invalid contacts at the end of the report, but this is not
+a complete fix. The confidence flag cannot be relied on when a contact
+is removed (see the following patch), and dealing with that condition
+re-introduces the DTH-2452 issue unless we also address this contact
+count laziness. By resetting expected and received counts at the same
+time we ensure the driver understands that there are 0 more contacts
+expected in the report. Similarly, we also make sure to reset the
+received count if for some reason we're out of sync in the pre-report
+phase.
+
+Link: https://github.com/linuxwacom/input-wacom/issues/288
+Fixes: f8b6a74719b5 ("HID: wacom: generic: Support multiple tools per report")
+CC: stable@vger.kernel.org
+Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
+Reviewed-by: Ping Cheng <ping.cheng@wacom.com>
+Signed-off-by: Jiri Kosina <jkosina@suse.cz>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/hid/wacom_wac.c |    6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+--- a/drivers/hid/wacom_wac.c
++++ b/drivers/hid/wacom_wac.c
+@@ -2692,11 +2692,14 @@ static void wacom_wac_finger_pre_report(
+           hid_data->cc_index >= 0) {
+               struct hid_field *field = report->field[hid_data->cc_index];
+               int value = field->value[hid_data->cc_value_index];
+-              if (value)
++              if (value) {
+                       hid_data->num_expected = value;
++                      hid_data->num_received = 0;
++              }
+       }
+       else {
+               hid_data->num_expected = wacom_wac->features.touch_max;
++              hid_data->num_received = 0;
+       }
+ }
+@@ -2724,6 +2727,7 @@ static void wacom_wac_finger_report(stru
+       input_sync(input);
+       wacom_wac->hid_data.num_received = 0;
++      wacom_wac->hid_data.num_expected = 0;
+       /* keep touch state for pen event */
+       wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(wacom_wac);
diff --git a/queue-5.16/kvm-vmx-switch-blocked_vcpu_on_cpu_lock-to-raw-spinlock.patch b/queue-5.16/kvm-vmx-switch-blocked_vcpu_on_cpu_lock-to-raw-spinlock.patch
new file mode 100644 (file)
index 0000000..bf01c7a
--- /dev/null
@@ -0,0 +1,105 @@
+From 5f02ef741a785678930f3ff0a8b6b2b0ef1bb402 Mon Sep 17 00:00:00 2001
+From: Marcelo Tosatti <mtosatti@redhat.com>
+Date: Tue, 18 Jan 2022 04:34:43 -0500
+Subject: KVM: VMX: switch blocked_vcpu_on_cpu_lock to raw spinlock
+
+From: Marcelo Tosatti <mtosatti@redhat.com>
+
+commit 5f02ef741a785678930f3ff0a8b6b2b0ef1bb402 upstream.
+
+blocked_vcpu_on_cpu_lock is taken from hard interrupt context
+(pi_wakeup_handler), therefore it cannot sleep.
+
+Switch it to a raw spinlock.
+
+Fixes:
+
+[41297.066254] BUG: scheduling while atomic: CPU 0/KVM/635218/0x00010001
+[41297.066323] Preemption disabled at:
+[41297.066324] [<ffffffff902ee47f>] irq_enter_rcu+0xf/0x60
+[41297.066339] Call Trace:
+[41297.066342]  <IRQ>
+[41297.066346]  dump_stack_lvl+0x34/0x44
+[41297.066353]  ? irq_enter_rcu+0xf/0x60
+[41297.066356]  __schedule_bug.cold+0x7d/0x8b
+[41297.066361]  __schedule+0x439/0x5b0
+[41297.066365]  ? task_blocks_on_rt_mutex.constprop.0.isra.0+0x1b0/0x440
+[41297.066369]  schedule_rtlock+0x1e/0x40
+[41297.066371]  rtlock_slowlock_locked+0xf1/0x260
+[41297.066374]  rt_spin_lock+0x3b/0x60
+[41297.066378]  pi_wakeup_handler+0x31/0x90 [kvm_intel]
+[41297.066388]  sysvec_kvm_posted_intr_wakeup_ipi+0x9d/0xd0
+[41297.066392]  </IRQ>
+[41297.066392]  asm_sysvec_kvm_posted_intr_wakeup_ipi+0x12/0x20
+...
+
+Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
+Cc: stable@vger.kernel.org
+Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/x86/kvm/vmx/posted_intr.c |   16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+--- a/arch/x86/kvm/vmx/posted_intr.c
++++ b/arch/x86/kvm/vmx/posted_intr.c
+@@ -15,7 +15,7 @@
+  * can find which vCPU should be waken up.
+  */
+ static DEFINE_PER_CPU(struct list_head, blocked_vcpu_on_cpu);
+-static DEFINE_PER_CPU(spinlock_t, blocked_vcpu_on_cpu_lock);
++static DEFINE_PER_CPU(raw_spinlock_t, blocked_vcpu_on_cpu_lock);
+ static inline struct pi_desc *vcpu_to_pi_desc(struct kvm_vcpu *vcpu)
+ {
+@@ -121,9 +121,9 @@ static void __pi_post_block(struct kvm_v
+                          new.control) != old.control);
+       if (!WARN_ON_ONCE(vcpu->pre_pcpu == -1)) {
+-              spin_lock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu));
++              raw_spin_lock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu));
+               list_del(&vcpu->blocked_vcpu_list);
+-              spin_unlock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu));
++              raw_spin_unlock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu));
+               vcpu->pre_pcpu = -1;
+       }
+ }
+@@ -154,11 +154,11 @@ int pi_pre_block(struct kvm_vcpu *vcpu)
+       local_irq_disable();
+       if (!WARN_ON_ONCE(vcpu->pre_pcpu != -1)) {
+               vcpu->pre_pcpu = vcpu->cpu;
+-              spin_lock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu));
++              raw_spin_lock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu));
+               list_add_tail(&vcpu->blocked_vcpu_list,
+                             &per_cpu(blocked_vcpu_on_cpu,
+                                      vcpu->pre_pcpu));
+-              spin_unlock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu));
++              raw_spin_unlock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu));
+       }
+       do {
+@@ -215,7 +215,7 @@ void pi_wakeup_handler(void)
+       struct kvm_vcpu *vcpu;
+       int cpu = smp_processor_id();
+-      spin_lock(&per_cpu(blocked_vcpu_on_cpu_lock, cpu));
++      raw_spin_lock(&per_cpu(blocked_vcpu_on_cpu_lock, cpu));
+       list_for_each_entry(vcpu, &per_cpu(blocked_vcpu_on_cpu, cpu),
+                       blocked_vcpu_list) {
+               struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu);
+@@ -223,13 +223,13 @@ void pi_wakeup_handler(void)
+               if (pi_test_on(pi_desc) == 1)
+                       kvm_vcpu_kick(vcpu);
+       }
+-      spin_unlock(&per_cpu(blocked_vcpu_on_cpu_lock, cpu));
++      raw_spin_unlock(&per_cpu(blocked_vcpu_on_cpu_lock, cpu));
+ }
+ void __init pi_init_cpu(int cpu)
+ {
+       INIT_LIST_HEAD(&per_cpu(blocked_vcpu_on_cpu, cpu));
+-      spin_lock_init(&per_cpu(blocked_vcpu_on_cpu_lock, cpu));
++      raw_spin_lock_init(&per_cpu(blocked_vcpu_on_cpu_lock, cpu));
+ }
+ bool pi_has_pending_interrupt(struct kvm_vcpu *vcpu)
diff --git a/queue-5.16/kvm-x86-mmu-fix-write-protection-of-pts-mapped-by-the-tdp-mmu.patch b/queue-5.16/kvm-x86-mmu-fix-write-protection-of-pts-mapped-by-the-tdp-mmu.patch
new file mode 100644 (file)
index 0000000..e850457
--- /dev/null
@@ -0,0 +1,56 @@
+From 7c8a4742c4abe205ec9daf416c9d42fd6b406e8e Mon Sep 17 00:00:00 2001
+From: David Matlack <dmatlack@google.com>
+Date: Thu, 13 Jan 2022 23:30:17 +0000
+Subject: KVM: x86/mmu: Fix write-protection of PTs mapped by the TDP MMU
+
+From: David Matlack <dmatlack@google.com>
+
+commit 7c8a4742c4abe205ec9daf416c9d42fd6b406e8e upstream.
+
+When the TDP MMU is write-protection GFNs for page table protection (as
+opposed to for dirty logging, or due to the HVA not being writable), it
+checks if the SPTE is already write-protected and if so skips modifying
+the SPTE and the TLB flush.
+
+This behavior is incorrect because it fails to check if the SPTE
+is write-protected for page table protection, i.e. fails to check
+that MMU-writable is '0'.  If the SPTE was write-protected for dirty
+logging but not page table protection, the SPTE could locklessly be made
+writable, and vCPUs could still be running with writable mappings cached
+in their TLB.
+
+Fix this by only skipping setting the SPTE if the SPTE is already
+write-protected *and* MMU-writable is already clear.  Technically,
+checking only MMU-writable would suffice; a SPTE cannot be writable
+without MMU-writable being set.  But check both to be paranoid and
+because it arguably yields more readable code.
+
+Fixes: 46044f72c382 ("kvm: x86/mmu: Support write protection for nesting in tdp MMU")
+Cc: stable@vger.kernel.org
+Signed-off-by: David Matlack <dmatlack@google.com>
+Message-Id: <20220113233020.3986005-2-dmatlack@google.com>
+Reviewed-by: Sean Christopherson <seanjc@google.com>
+Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/x86/kvm/mmu/tdp_mmu.c |    6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+--- a/arch/x86/kvm/mmu/tdp_mmu.c
++++ b/arch/x86/kvm/mmu/tdp_mmu.c
+@@ -1442,12 +1442,12 @@ static bool write_protect_gfn(struct kvm
+                   !is_last_spte(iter.old_spte, iter.level))
+                       continue;
+-              if (!is_writable_pte(iter.old_spte))
+-                      break;
+-
+               new_spte = iter.old_spte &
+                       ~(PT_WRITABLE_MASK | shadow_mmu_writable_mask);
++              if (new_spte == iter.old_spte)
++                      break;
++
+               tdp_mmu_set_spte(kvm, &iter, new_spte);
+               spte_set = true;
+       }
diff --git a/queue-5.16/series b/queue-5.16/series
new file mode 100644 (file)
index 0000000..0bd2738
--- /dev/null
@@ -0,0 +1,8 @@
+kvm-x86-mmu-fix-write-protection-of-pts-mapped-by-the-tdp-mmu.patch
+kvm-vmx-switch-blocked_vcpu_on_cpu_lock-to-raw-spinlock.patch
+hid-ignore-battery-for-elan-touchscreen-on-hp-envy-x360-15t-dr100.patch
+hid-uhid-fix-worker-destroying-device-without-any-protection.patch
+hid-wacom-reset-expected-and-received-contact-counts-at-the-same-time.patch
+hid-wacom-ignore-the-confidence-flag-when-a-touch-is-removed.patch
+hid-wacom-avoid-using-stale-array-indicies-to-read-contact-count.patch
+alsa-core-fix-ssid-quirk-lookup-for-subvendor-0.patch