From d48da202c6ce1cd0c1dc96a17fe92ee1ddb42a53 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 29 Jul 2019 17:57:54 +0200 Subject: [PATCH] 4.9-stable patches added patches: usb-pci-quirks-correct-amd-pll-quirk-detection.patch usb-wusbcore-fix-unbalanced-get-put-cluster_id.patch x86-speculation-mds-apply-more-accurate-check-on-hypervisor-platform.patch x86-sysfb_efi-add-quirks-for-some-devices-with-swapped-width-and-height.patch --- queue-4.9/series | 4 + ...irks-correct-amd-pll-quirk-detection.patch | 103 ++++++++++++++++++ ...re-fix-unbalanced-get-put-cluster_id.patch | 61 +++++++++++ ...ccurate-check-on-hypervisor-platform.patch | 41 +++++++ ...evices-with-swapped-width-and-height.patch | 91 ++++++++++++++++ 5 files changed, 300 insertions(+) create mode 100644 queue-4.9/usb-pci-quirks-correct-amd-pll-quirk-detection.patch create mode 100644 queue-4.9/usb-wusbcore-fix-unbalanced-get-put-cluster_id.patch create mode 100644 queue-4.9/x86-speculation-mds-apply-more-accurate-check-on-hypervisor-platform.patch create mode 100644 queue-4.9/x86-sysfb_efi-add-quirks-for-some-devices-with-swapped-width-and-height.patch diff --git a/queue-4.9/series b/queue-4.9/series index 428ee3150f1..31472a93d54 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -199,3 +199,7 @@ mm-kmemleak.c-fix-check-for-softirq-context.patch mm-mmu_notifier-use-hlist_add_head_rcu.patch locking-lockdep-fix-lock-used-or-unused-stats-error.patch locking-lockdep-hide-unused-class-variable.patch +usb-wusbcore-fix-unbalanced-get-put-cluster_id.patch +usb-pci-quirks-correct-amd-pll-quirk-detection.patch +x86-sysfb_efi-add-quirks-for-some-devices-with-swapped-width-and-height.patch +x86-speculation-mds-apply-more-accurate-check-on-hypervisor-platform.patch diff --git a/queue-4.9/usb-pci-quirks-correct-amd-pll-quirk-detection.patch b/queue-4.9/usb-pci-quirks-correct-amd-pll-quirk-detection.patch new file mode 100644 index 00000000000..d1842a060d4 --- /dev/null +++ b/queue-4.9/usb-pci-quirks-correct-amd-pll-quirk-detection.patch @@ -0,0 +1,103 @@ +From f3dccdaade4118070a3a47bef6b18321431f9ac6 Mon Sep 17 00:00:00 2001 +From: Ryan Kennedy +Date: Thu, 4 Jul 2019 11:35:28 -0400 +Subject: usb: pci-quirks: Correct AMD PLL quirk detection + +From: Ryan Kennedy + +commit f3dccdaade4118070a3a47bef6b18321431f9ac6 upstream. + +The AMD PLL USB quirk is incorrectly enabled on newer Ryzen +chipsets. The logic in usb_amd_find_chipset_info currently checks +for unaffected chipsets rather than affected ones. This broke +once a new chipset was added in e788787ef. It makes more sense +to reverse the logic so it won't need to be updated as new +chipsets are added. Note that the core of the workaround in +usb_amd_quirk_pll does correctly check the chipset. + +Signed-off-by: Ryan Kennedy +Fixes: e788787ef4f9 ("usb:xhci:Add quirk for Certain failing HP keyboard on reset after resume") +Cc: stable +Acked-by: Alan Stern +Link: https://lore.kernel.org/r/20190704153529.9429-2-ryan5544@gmail.com +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/usb/host/pci-quirks.c | 31 +++++++++++++++++++------------ + 1 file changed, 19 insertions(+), 12 deletions(-) + +--- a/drivers/usb/host/pci-quirks.c ++++ b/drivers/usb/host/pci-quirks.c +@@ -187,7 +187,7 @@ int usb_amd_find_chipset_info(void) + { + unsigned long flags; + struct amd_chipset_info info; +- int ret; ++ int need_pll_quirk = 0; + + spin_lock_irqsave(&amd_lock, flags); + +@@ -201,21 +201,28 @@ int usb_amd_find_chipset_info(void) + spin_unlock_irqrestore(&amd_lock, flags); + + if (!amd_chipset_sb_type_init(&info)) { +- ret = 0; + goto commit; + } + +- /* Below chipset generations needn't enable AMD PLL quirk */ +- if (info.sb_type.gen == AMD_CHIPSET_UNKNOWN || +- info.sb_type.gen == AMD_CHIPSET_SB600 || +- info.sb_type.gen == AMD_CHIPSET_YANGTZE || +- (info.sb_type.gen == AMD_CHIPSET_SB700 && +- info.sb_type.rev > 0x3b)) { ++ switch (info.sb_type.gen) { ++ case AMD_CHIPSET_SB700: ++ need_pll_quirk = info.sb_type.rev <= 0x3B; ++ break; ++ case AMD_CHIPSET_SB800: ++ case AMD_CHIPSET_HUDSON2: ++ case AMD_CHIPSET_BOLTON: ++ need_pll_quirk = 1; ++ break; ++ default: ++ need_pll_quirk = 0; ++ break; ++ } ++ ++ if (!need_pll_quirk) { + if (info.smbus_dev) { + pci_dev_put(info.smbus_dev); + info.smbus_dev = NULL; + } +- ret = 0; + goto commit; + } + +@@ -234,7 +241,7 @@ int usb_amd_find_chipset_info(void) + } + } + +- ret = info.probe_result = 1; ++ need_pll_quirk = info.probe_result = 1; + printk(KERN_DEBUG "QUIRK: Enable AMD PLL fix\n"); + + commit: +@@ -245,7 +252,7 @@ commit: + + /* Mark that we where here */ + amd_chipset.probe_count++; +- ret = amd_chipset.probe_result; ++ need_pll_quirk = amd_chipset.probe_result; + + spin_unlock_irqrestore(&amd_lock, flags); + +@@ -259,7 +266,7 @@ commit: + spin_unlock_irqrestore(&amd_lock, flags); + } + +- return ret; ++ return need_pll_quirk; + } + EXPORT_SYMBOL_GPL(usb_amd_find_chipset_info); + diff --git a/queue-4.9/usb-wusbcore-fix-unbalanced-get-put-cluster_id.patch b/queue-4.9/usb-wusbcore-fix-unbalanced-get-put-cluster_id.patch new file mode 100644 index 00000000000..ab91c18ee7c --- /dev/null +++ b/queue-4.9/usb-wusbcore-fix-unbalanced-get-put-cluster_id.patch @@ -0,0 +1,61 @@ +From f90bf1ece48a736097ea224430578fe586a9544c Mon Sep 17 00:00:00 2001 +From: Phong Tran +Date: Wed, 24 Jul 2019 09:06:01 +0700 +Subject: usb: wusbcore: fix unbalanced get/put cluster_id + +From: Phong Tran + +commit f90bf1ece48a736097ea224430578fe586a9544c upstream. + +syzboot reported that +https://syzkaller.appspot.com/bug?extid=fd2bd7df88c606eea4ef + +There is not consitency parameter in cluste_id_get/put calling. +In case of getting the id with result is failure, the wusbhc->cluster_id +will not be updated and this can not be used for wusb_cluster_id_put(). + +Tested report +https://groups.google.com/d/msg/syzkaller-bugs/0znZopp3-9k/oxOrhLkLEgAJ + +Reproduce and gdb got the details: + +139 addr = wusb_cluster_id_get(); +(gdb) n +140 if (addr == 0) +(gdb) print addr +$1 = 254 '\376' +(gdb) n +142 result = __hwahc_set_cluster_id(hwahc, addr); +(gdb) print result +$2 = -71 +(gdb) break wusb_cluster_id_put +Breakpoint 3 at 0xffffffff836e3f20: file drivers/usb/wusbcore/wusbhc.c, line 384. +(gdb) s +Thread 2 hit Breakpoint 3, wusb_cluster_id_put (id=0 '\000') at drivers/usb/wusbcore/wusbhc.c:384 +384 id = 0xff - id; +(gdb) n +385 BUG_ON(id >= CLUSTER_IDS); +(gdb) print id +$3 = 255 '\377' + +Reported-by: syzbot+fd2bd7df88c606eea4ef@syzkaller.appspotmail.com +Signed-off-by: Phong Tran +Cc: stable +Link: https://lore.kernel.org/r/20190724020601.15257-1-tranmanphong@gmail.com +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/usb/host/hwa-hc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/usb/host/hwa-hc.c ++++ b/drivers/usb/host/hwa-hc.c +@@ -173,7 +173,7 @@ out: + return result; + + error_set_cluster_id: +- wusb_cluster_id_put(wusbhc->cluster_id); ++ wusb_cluster_id_put(addr); + error_cluster_id_get: + goto out; + diff --git a/queue-4.9/x86-speculation-mds-apply-more-accurate-check-on-hypervisor-platform.patch b/queue-4.9/x86-speculation-mds-apply-more-accurate-check-on-hypervisor-platform.patch new file mode 100644 index 00000000000..e00fa7175ff --- /dev/null +++ b/queue-4.9/x86-speculation-mds-apply-more-accurate-check-on-hypervisor-platform.patch @@ -0,0 +1,41 @@ +From 517c3ba00916383af6411aec99442c307c23f684 Mon Sep 17 00:00:00 2001 +From: Zhenzhong Duan +Date: Thu, 25 Jul 2019 10:39:09 +0800 +Subject: x86/speculation/mds: Apply more accurate check on hypervisor platform + +From: Zhenzhong Duan + +commit 517c3ba00916383af6411aec99442c307c23f684 upstream. + +X86_HYPER_NATIVE isn't accurate for checking if running on native platform, +e.g. CONFIG_HYPERVISOR_GUEST isn't set or "nopv" is enabled. + +Checking the CPU feature bit X86_FEATURE_HYPERVISOR to determine if it's +running on native platform is more accurate. + +This still doesn't cover the platforms on which X86_FEATURE_HYPERVISOR is +unsupported, e.g. VMware, but there is nothing which can be done about this +scenario. + +Fixes: 8a4b06d391b0 ("x86/speculation/mds: Add sysfs reporting for MDS") +Signed-off-by: Zhenzhong Duan +Signed-off-by: Thomas Gleixner +Cc: stable@vger.kernel.org +Link: https://lkml.kernel.org/r/1564022349-17338-1-git-send-email-zhenzhong.duan@oracle.com +Signed-off-by: Greg Kroah-Hartman + +--- + arch/x86/kernel/cpu/bugs.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/arch/x86/kernel/cpu/bugs.c ++++ b/arch/x86/kernel/cpu/bugs.c +@@ -1205,7 +1205,7 @@ static ssize_t l1tf_show_state(char *buf + static ssize_t mds_show_state(char *buf) + { + #ifdef CONFIG_HYPERVISOR_GUEST +- if (x86_hyper) { ++ if (boot_cpu_has(X86_FEATURE_HYPERVISOR)) { + return sprintf(buf, "%s; SMT Host state unknown\n", + mds_strings[mds_mitigation]); + } diff --git a/queue-4.9/x86-sysfb_efi-add-quirks-for-some-devices-with-swapped-width-and-height.patch b/queue-4.9/x86-sysfb_efi-add-quirks-for-some-devices-with-swapped-width-and-height.patch new file mode 100644 index 00000000000..df9876a0005 --- /dev/null +++ b/queue-4.9/x86-sysfb_efi-add-quirks-for-some-devices-with-swapped-width-and-height.patch @@ -0,0 +1,91 @@ +From d02f1aa39189e0619c3525d5cd03254e61bf606a Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Sun, 21 Jul 2019 17:24:18 +0200 +Subject: x86/sysfb_efi: Add quirks for some devices with swapped width and height + +From: Hans de Goede + +commit d02f1aa39189e0619c3525d5cd03254e61bf606a upstream. + +Some Lenovo 2-in-1s with a detachable keyboard have a portrait screen but +advertise a landscape resolution and pitch, resulting in a messed up +display if the kernel tries to show anything on the efifb (because of the +wrong pitch). + +Fix this by adding a new DMI match table for devices which need to have +their width and height swapped. + +At first it was tried to use the existing table for overriding some of the +efifb parameters, but some of the affected devices have variants with +different LCD resolutions which will not work with hardcoded override +values. + +Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1730783 +Signed-off-by: Hans de Goede +Signed-off-by: Thomas Gleixner +Cc: stable@vger.kernel.org +Link: https://lkml.kernel.org/r/20190721152418.11644-1-hdegoede@redhat.com +Signed-off-by: Greg Kroah-Hartman + +--- + arch/x86/kernel/sysfb_efi.c | 46 ++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 46 insertions(+) + +--- a/arch/x86/kernel/sysfb_efi.c ++++ b/arch/x86/kernel/sysfb_efi.c +@@ -231,9 +231,55 @@ static const struct dmi_system_id efifb_ + {}, + }; + ++/* ++ * Some devices have a portrait LCD but advertise a landscape resolution (and ++ * pitch). We simply swap width and height for these devices so that we can ++ * correctly deal with some of them coming with multiple resolutions. ++ */ ++static const struct dmi_system_id efifb_dmi_swap_width_height[] __initconst = { ++ { ++ /* ++ * Lenovo MIIX310-10ICR, only some batches have the troublesome ++ * 800x1280 portrait screen. Luckily the portrait version has ++ * its own BIOS version, so we match on that. ++ */ ++ .matches = { ++ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"), ++ DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "MIIX 310-10ICR"), ++ DMI_EXACT_MATCH(DMI_BIOS_VERSION, "1HCN44WW"), ++ }, ++ }, ++ { ++ /* Lenovo MIIX 320-10ICR with 800x1280 portrait screen */ ++ .matches = { ++ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"), ++ DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, ++ "Lenovo MIIX 320-10ICR"), ++ }, ++ }, ++ { ++ /* Lenovo D330 with 800x1280 or 1200x1920 portrait screen */ ++ .matches = { ++ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"), ++ DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, ++ "Lenovo ideapad D330-10IGM"), ++ }, ++ }, ++ {}, ++}; ++ + __init void sysfb_apply_efi_quirks(void) + { + if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI || + !(screen_info.capabilities & VIDEO_CAPABILITY_SKIP_QUIRKS)) + dmi_check_system(efifb_dmi_system_table); ++ ++ if (screen_info.orig_video_isVGA == VIDEO_TYPE_EFI && ++ dmi_check_system(efifb_dmi_swap_width_height)) { ++ u16 temp = screen_info.lfb_width; ++ ++ screen_info.lfb_width = screen_info.lfb_height; ++ screen_info.lfb_height = temp; ++ screen_info.lfb_linelength = 4 * screen_info.lfb_width; ++ } + } -- 2.47.3