From 5a563cba69a8de6445df6dad2c1e1452d7b4dba4 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 15 Jul 2024 11:00:46 +0200 Subject: [PATCH] 6.1-stable patches added patches: hpet-support-32-bit-userspace.patch xhci-always-resume-roothubs-if-xhc-was-reset-during-resume.patch --- queue-6.1/hpet-support-32-bit-userspace.patch | 113 ++++++++++++++++++ queue-6.1/series | 2 + ...thubs-if-xhc-was-reset-during-resume.patch | 78 ++++++++++++ 3 files changed, 193 insertions(+) create mode 100644 queue-6.1/hpet-support-32-bit-userspace.patch create mode 100644 queue-6.1/xhci-always-resume-roothubs-if-xhc-was-reset-during-resume.patch diff --git a/queue-6.1/hpet-support-32-bit-userspace.patch b/queue-6.1/hpet-support-32-bit-userspace.patch new file mode 100644 index 00000000000..44fae209b60 --- /dev/null +++ b/queue-6.1/hpet-support-32-bit-userspace.patch @@ -0,0 +1,113 @@ +From 4e60131d0d36af65ab9c9144f4f163fe97ae36e8 Mon Sep 17 00:00:00 2001 +From: He Zhe +Date: Thu, 6 Jun 2024 20:39:08 +0800 +Subject: hpet: Support 32-bit userspace + +From: He Zhe + +commit 4e60131d0d36af65ab9c9144f4f163fe97ae36e8 upstream. + +hpet_compat_ioctl and read file operations failed to handle parameters from +32-bit userspace and thus samples/timers/hpet_example.c fails as below. + +root@intel-x86-64:~# ./hpet_example-32.out poll /dev/hpet 1 2 +-hpet: executing poll +hpet_poll: HPET_IRQFREQ failed + +This patch fixes cmd and arg handling in hpet_compat_ioctl and adds compat +handling for 32-bit userspace in hpet_read. + +hpet_example now shows that it works for both 64-bit and 32-bit. + +root@intel-x86-64:~# ./hpet_example-32.out poll /dev/hpet 1 2 +-hpet: executing poll +hpet_poll: info.hi_flags 0x0 +hpet_poll: expired time = 0xf4298 +hpet_poll: revents = 0x1 +hpet_poll: data 0x1 +hpet_poll: expired time = 0xf4235 +hpet_poll: revents = 0x1 +hpet_poll: data 0x1 +root@intel-x86-64:~# ./hpet_example-64.out poll /dev/hpet 1 2 +-hpet: executing poll +hpet_poll: info.hi_flags 0x0 +hpet_poll: expired time = 0xf42a1 +hpet_poll: revents = 0x1 +hpet_poll: data 0x1 +hpet_poll: expired time = 0xf4232 +hpet_poll: revents = 0x1 +hpet_poll: data 0x1 + +Cc: stable@vger.kernel.org +Signed-off-by: He Zhe +Fixes: 54066a57c584 ("hpet: kill BKL, add compat_ioctl") +Reviewed-by: Arnd Bergmann +Link: https://lore.kernel.org/r/20240606123908.738733-1-zhe.he@windriver.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/char/hpet.c | 34 +++++++++++++++++++++++++++++----- + 1 file changed, 29 insertions(+), 5 deletions(-) + +--- a/drivers/char/hpet.c ++++ b/drivers/char/hpet.c +@@ -289,8 +289,13 @@ hpet_read(struct file *file, char __user + if (!devp->hd_ireqfreq) + return -EIO; + +- if (count < sizeof(unsigned long)) +- return -EINVAL; ++ if (in_compat_syscall()) { ++ if (count < sizeof(compat_ulong_t)) ++ return -EINVAL; ++ } else { ++ if (count < sizeof(unsigned long)) ++ return -EINVAL; ++ } + + add_wait_queue(&devp->hd_waitqueue, &wait); + +@@ -314,9 +319,16 @@ hpet_read(struct file *file, char __user + schedule(); + } + +- retval = put_user(data, (unsigned long __user *)buf); +- if (!retval) +- retval = sizeof(unsigned long); ++ if (in_compat_syscall()) { ++ retval = put_user(data, (compat_ulong_t __user *)buf); ++ if (!retval) ++ retval = sizeof(compat_ulong_t); ++ } else { ++ retval = put_user(data, (unsigned long __user *)buf); ++ if (!retval) ++ retval = sizeof(unsigned long); ++ } ++ + out: + __set_current_state(TASK_RUNNING); + remove_wait_queue(&devp->hd_waitqueue, &wait); +@@ -671,12 +683,24 @@ struct compat_hpet_info { + unsigned short hi_timer; + }; + ++/* 32-bit types would lead to different command codes which should be ++ * translated into 64-bit ones before passed to hpet_ioctl_common ++ */ ++#define COMPAT_HPET_INFO _IOR('h', 0x03, struct compat_hpet_info) ++#define COMPAT_HPET_IRQFREQ _IOW('h', 0x6, compat_ulong_t) ++ + static long + hpet_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) + { + struct hpet_info info; + int err; + ++ if (cmd == COMPAT_HPET_INFO) ++ cmd = HPET_INFO; ++ ++ if (cmd == COMPAT_HPET_IRQFREQ) ++ cmd = HPET_IRQFREQ; ++ + mutex_lock(&hpet_mutex); + err = hpet_ioctl_common(file->private_data, cmd, arg, &info); + mutex_unlock(&hpet_mutex); diff --git a/queue-6.1/series b/queue-6.1/series index 076627e443a..1ee8b2c992f 100644 --- a/queue-6.1/series +++ b/queue-6.1/series @@ -57,3 +57,5 @@ usb-serial-mos7840-fix-crash-on-resume.patch usb-add-usb_quirk_no_set_intf-quirk-for-start-bp-850k.patch usb-gadget-configfs-prevent-oob-read-write-in-usb_string_copy.patch usb-core-fix-duplicate-endpoint-bug-by-clearing-reserved-bits-in-the-descriptor.patch +hpet-support-32-bit-userspace.patch +xhci-always-resume-roothubs-if-xhc-was-reset-during-resume.patch diff --git a/queue-6.1/xhci-always-resume-roothubs-if-xhc-was-reset-during-resume.patch b/queue-6.1/xhci-always-resume-roothubs-if-xhc-was-reset-during-resume.patch new file mode 100644 index 00000000000..50413770881 --- /dev/null +++ b/queue-6.1/xhci-always-resume-roothubs-if-xhc-was-reset-during-resume.patch @@ -0,0 +1,78 @@ +From 79989bd4ab86404743953fa382af0a22900050cf Mon Sep 17 00:00:00 2001 +From: Mathias Nyman +Date: Thu, 27 Jun 2024 17:55:23 +0300 +Subject: xhci: always resume roothubs if xHC was reset during resume + +From: Mathias Nyman + +commit 79989bd4ab86404743953fa382af0a22900050cf upstream. + +Usb device connect may not be detected after runtime resume if +xHC is reset during resume. + +In runtime resume cases xhci_resume() will only resume roothubs if there +are pending port events. If the xHC host is reset during runtime resume +due to a Save/Restore Error (SRE) then these pending port events won't be +detected as PORTSC change bits are not immediately set by host after reset. + +Unconditionally resume roothubs if xHC is reset during resume to ensure +device connections are detected. + +Also return early with error code if starting xHC fails after reset. + +Issue was debugged and a similar solution suggested by Remi Pommarel. +Using this instead as it simplifies future refactoring. + +Reported-by: Remi Pommarel +Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218987 +Suggested-by: Remi Pommarel +Tested-by: Remi Pommarel +Cc: stable@vger.kernel.org +Signed-off-by: Mathias Nyman +Link: https://lore.kernel.org/r/20240627145523.1453155-2-mathias.nyman@linux.intel.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/host/xhci.c | 16 +++++++++++++--- + 1 file changed, 13 insertions(+), 3 deletions(-) + +--- a/drivers/usb/host/xhci.c ++++ b/drivers/usb/host/xhci.c +@@ -1247,10 +1247,20 @@ int xhci_resume(struct xhci_hcd *xhci, b + xhci_dbg(xhci, "Start the secondary HCD\n"); + retval = xhci_run(xhci->shared_hcd); + } +- ++ if (retval) ++ return retval; ++ /* ++ * Resume roothubs unconditionally as PORTSC change bits are not ++ * immediately visible after xHC reset ++ */ + hcd->state = HC_STATE_SUSPENDED; +- if (xhci->shared_hcd) ++ ++ if (xhci->shared_hcd) { + xhci->shared_hcd->state = HC_STATE_SUSPENDED; ++ usb_hcd_resume_root_hub(xhci->shared_hcd); ++ } ++ usb_hcd_resume_root_hub(hcd); ++ + goto done; + } + +@@ -1274,7 +1284,6 @@ int xhci_resume(struct xhci_hcd *xhci, b + + xhci_dbc_resume(xhci); + +- done: + if (retval == 0) { + /* + * Resume roothubs only if there are pending events. +@@ -1293,6 +1302,7 @@ int xhci_resume(struct xhci_hcd *xhci, b + usb_hcd_resume_root_hub(hcd); + } + } ++done: + /* + * If system is subject to the Quirk, Compliance Mode Timer needs to + * be re-initialized Always after a system resume. Ports are subject -- 2.47.3