diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-09-27 13:36:30 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-09-27 13:36:30 +0200 |
commit | 87fdab48af04783a84d8b3b1443b4e884555182f (patch) | |
tree | 3d68ca1cb672e5c48df85fbf2d48c2cedfd145d8 | |
parent | 25aeeb3bc64eeb2885db63cf7266b0c932037acd (diff) | |
download | patches-87fdab48af04783a84d8b3b1443b4e884555182f.tar.gz |
more patches
-rw-r--r-- | 0001-PCI-ACPI-do-not-reference-a-pci-device-after-it-has-.patch | 36 | ||||
-rw-r--r-- | 0001-scsi-stex-properly-zero-out-the-passthrough-command-.patch | 61 | ||||
-rw-r--r-- | 0001-vsmp-driver.patch | 381 | ||||
-rw-r--r-- | 0002-USB-xhci-make-xhci_get_endpoint_address-static.patch | 37 | ||||
-rw-r--r-- | series | 4 |
5 files changed, 519 insertions, 0 deletions
diff --git a/0001-PCI-ACPI-do-not-reference-a-pci-device-after-it-has-.patch b/0001-PCI-ACPI-do-not-reference-a-pci-device-after-it-has-.patch new file mode 100644 index 00000000000000..336f2fe923977d --- /dev/null +++ b/0001-PCI-ACPI-do-not-reference-a-pci-device-after-it-has-.patch @@ -0,0 +1,36 @@ +From 979409d043158380b77704b8cbec889ad674b613 Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +Date: Thu, 28 Apr 2022 16:25:56 +0200 +Subject: [PATCH 1/2] PCI/ACPI: do not reference a pci device after it has been + released + +In acpi_get_pci_dev(), the debugging message for when a PCI bridge is +not found uses a pointer to a pci device whose reference has just been +dropped. The chance that this really is a device that is now been +removed from the system is almost impossible to happen, but to be safe, +let's print out the debugging message based on the acpi root device +which we do have a valid reference to at the moment. + +Cc: Bjorn Helgaas <bhelgaas@google.com> +Cc: "Rafael J. Wysocki" <rafael@kernel.org> +Cc: Len Brown <lenb@kernel.org> +Cc: linux-pci@vger.kernel.org +Cc: linux-acpi@vger.kernel.org +Reported-by: whitehat002 <hackyzh002@gmail.com> +Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +--- + drivers/acpi/pci_root.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/acpi/pci_root.c ++++ b/drivers/acpi/pci_root.c +@@ -372,7 +372,8 @@ struct pci_dev *acpi_get_pci_dev(acpi_ha + * case pdev->subordinate will be NULL for the parent. + */ + if (!pbus) { +- dev_dbg(&pdev->dev, "Not a PCI-to-PCI bridge\n"); ++ dev_dbg(&root->device->dev, ++ "dev %d, function %d is not a PCI-to-PCI bridge\n", dev, fn); + pdev = NULL; + break; + } diff --git a/0001-scsi-stex-properly-zero-out-the-passthrough-command-.patch b/0001-scsi-stex-properly-zero-out-the-passthrough-command-.patch new file mode 100644 index 00000000000000..dcf8218088fb3d --- /dev/null +++ b/0001-scsi-stex-properly-zero-out-the-passthrough-command-.patch @@ -0,0 +1,61 @@ +From 8105ed43507cb6a7ef4df7b059bc721a7fd4ca2d Mon Sep 17 00:00:00 2001 +From: Linus Torvalds <torvalds@linux-foundation.org> +Date: Fri, 9 Sep 2022 08:50:30 +0200 +Subject: [PATCH] scsi: stex: properly zero out the passthrough command + structure + +The passthrough structure is declared off of the stack, so it needs to +be set to zero before copied back to userspace to prevent any +unintentional data leakage. Switch things to be statically allocated +which will fill the unused fields with 0 automatically. + +Reported-by: hdthky <hdthky0@gmail.com> +Cc: stable <stable@kernel.org> +Cc: "James E.J. Bottomley" <jejb@linux.ibm.com> +Cc: "Martin K. Petersen" <martin.petersen@oracle.com> +Cc: Dan Carpenter <dan.carpenter@oracle.com> +Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +--- + drivers/scsi/stex.c | 17 +++++++++-------- + include/scsi/scsi_cmnd.h | 2 +- + 2 files changed, 10 insertions(+), 9 deletions(-) + +--- a/drivers/scsi/stex.c ++++ b/drivers/scsi/stex.c +@@ -665,16 +665,17 @@ static int stex_queuecommand_lck(struct + return 0; + case PASSTHRU_CMD: + if (cmd->cmnd[1] == PASSTHRU_GET_DRVVER) { +- struct st_drvver ver; ++ const struct st_drvver ver = { ++ .major = ST_VER_MAJOR, ++ .minor = ST_VER_MINOR, ++ .oem = ST_OEM, ++ .build = ST_BUILD_VER, ++ .signature[0] = PASSTHRU_SIGNATURE, ++ .console_id = host->max_id - 1, ++ .host_no = hba->host->host_no, ++ }; + size_t cp_len = sizeof(ver); + +- ver.major = ST_VER_MAJOR; +- ver.minor = ST_VER_MINOR; +- ver.oem = ST_OEM; +- ver.build = ST_BUILD_VER; +- ver.signature[0] = PASSTHRU_SIGNATURE; +- ver.console_id = host->max_id - 1; +- ver.host_no = hba->host->host_no; + cp_len = scsi_sg_copy_from_buffer(cmd, &ver, cp_len); + if (sizeof(ver) == cp_len) + cmd->result = DID_OK << 16; +--- a/include/scsi/scsi_cmnd.h ++++ b/include/scsi/scsi_cmnd.h +@@ -201,7 +201,7 @@ static inline unsigned int scsi_get_resi + for_each_sg(scsi_sglist(cmd), sg, nseg, __i) + + static inline int scsi_sg_copy_from_buffer(struct scsi_cmnd *cmd, +- void *buf, int buflen) ++ const void *buf, int buflen) + { + return sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), + buf, buflen); diff --git a/0001-vsmp-driver.patch b/0001-vsmp-driver.patch new file mode 100644 index 00000000000000..c34aa26b09e2c0 --- /dev/null +++ b/0001-vsmp-driver.patch @@ -0,0 +1,381 @@ +From e7d31ee0349c4800a4da34de3319352370e0799a Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +Date: Tue, 6 Sep 2022 15:57:53 +0200 +Subject: [PATCH] vsmp driver + +first cut to cleanup +--- + Documentation/ABI/stable/sysfs-driver-vsmp | 5 + MAINTAINERS | 6 + drivers/virt/Kconfig | 2 + drivers/virt/Makefile | 2 + drivers/virt/vsmp/Kconfig | 12 + + drivers/virt/vsmp/Makefile | 6 + drivers/virt/vsmp/vsmp.c | 294 +++++++++++++++++++++++++++++ + 7 files changed, 327 insertions(+) + create mode 100644 Documentation/ABI/stable/sysfs-driver-vsmp + create mode 100644 drivers/virt/vsmp/Kconfig + create mode 100644 drivers/virt/vsmp/Makefile + create mode 100644 drivers/virt/vsmp/vsmp.c + +--- /dev/null ++++ b/Documentation/ABI/stable/sysfs-driver-vsmp +@@ -0,0 +1,5 @@ ++What: /sys/hypervisor/vsmp/version ++Date: Aug 2022 ++Contact: Eial Czerwacki <eial.czerwacki@sap.com> ++ linux-vsmp@sap.com ++Description: Shows the full version of the vSMP hypervisor +--- a/MAINTAINERS ++++ b/MAINTAINERS +@@ -21814,6 +21814,12 @@ F: lib/test_printf.c + F: lib/test_scanf.c + F: lib/vsprintf.c + ++VSMP GUEST DRIVER ++M: Eial Czerwacki <eial.czerwacki@sap.com> ++M: linux-vsmp@sap.com ++S: Maintained ++F: drivers/virt/vsmp ++ + VT1211 HARDWARE MONITOR DRIVER + M: Juerg Haefliger <juergh@gmail.com> + L: linux-hwmon@vger.kernel.org +--- a/drivers/virt/Kconfig ++++ b/drivers/virt/Kconfig +@@ -52,4 +52,6 @@ source "drivers/virt/coco/efi_secret/Kco + + source "drivers/virt/coco/sev-guest/Kconfig" + ++source "drivers/virt/vsmp/Kconfig" ++ + endif +--- a/drivers/virt/Makefile ++++ b/drivers/virt/Makefile +@@ -11,3 +11,5 @@ obj-$(CONFIG_NITRO_ENCLAVES) += nitro_en + obj-$(CONFIG_ACRN_HSM) += acrn/ + obj-$(CONFIG_EFI_SECRET) += coco/efi_secret/ + obj-$(CONFIG_SEV_GUEST) += coco/sev-guest/ ++ ++obj-$(CONFIG_VSMP) += vsmp/ +--- /dev/null ++++ b/drivers/virt/vsmp/Kconfig +@@ -0,0 +1,12 @@ ++# SPDX-License-Identifier: GPL-2.0-only ++config VSMP ++ tristate "vSMP Guest Support" ++ depends on X86_64 && PCI ++ select SYS_HYPERVISOR ++ help ++ Support for vSMP Guest Driver. ++ ++ This driver allows information gathering of data from the vSMP hypervisor when ++ running on top of a vSMP-based hypervisor. ++ ++ If unsure, say no. +--- /dev/null ++++ b/drivers/virt/vsmp/Makefile +@@ -0,0 +1,6 @@ ++# SPDX-License-Identifier: GPL-2.0 ++# ++# Makefile for vSMP Guest driver ++# ++ ++obj-$(CONFIG_VSMP) = vsmp.o +--- /dev/null ++++ b/drivers/virt/vsmp/vsmp.c +@@ -0,0 +1,294 @@ ++// SPDX-License-Identifier: GPL-2.0-only ++/* ++ * vSMP driver ++ * ++ * (C) Copyright 2022 SAP SE ++ * (C) Copyright 2022 Greg Kroah-Hartman <gregkh@linuxfoundation.org> ++ */ ++#include <linux/module.h> ++#include <linux/slab.h> ++#include <linux/kobject.h> ++#include <linux/pci.h> ++#include <linux/sysfs.h> ++ ++// R/W ops handlers ++#define vsmp_read_reg32_from_cfg(dev, _reg_) \ ++ ((u32) vsmp_read_reg_from_cfg(dev, (_reg_), VSMP_CTL_REG_SIZE_32BIT)) ++ ++enum reg_size_type { ++ VSMP_CTL_REG_SIZE_8BIT = 0, ++ VSMP_CTL_REG_SIZE_16BIT, ++ VSMP_CTL_REG_SIZE_32BIT, ++ VSMP_CTL_REG_SIZE_64BIT ++}; ++ ++struct vsmp_dev { ++ void __iomem *cfg_addr; ++ struct kobject kobj; ++ struct pci_dev *pdev; ++}; ++ ++#define VSMP_VERSION_REG 0x0c ++ ++/* ++ * Read a value from a specific register in the vSMP's device config space ++ */ ++static u64 vsmp_read_reg_from_cfg(struct vsmp_dev *vdev, u64 reg, enum reg_size_type type) ++{ ++ u64 ret_val; ++ ++ switch (type) { ++ case VSMP_CTL_REG_SIZE_8BIT: ++ ret_val = readb(vdev->cfg_addr + reg); ++ break; ++ ++ case VSMP_CTL_REG_SIZE_16BIT: ++ ret_val = readw(vdev->cfg_addr + reg); ++ break; ++ ++ case VSMP_CTL_REG_SIZE_32BIT: ++ ret_val = readl(vdev->cfg_addr + reg); ++ break; ++ ++ case VSMP_CTL_REG_SIZE_64BIT: ++ ret_val = readq(vdev->cfg_addr + reg); ++ break; ++ ++ default: ++ dev_err(&vdev->pdev->dev, "Unsupported reg size type %d.\n", type); ++ ret_val = (u64) -EINVAL; ++ } ++ ++ dev_dbg(&vdev->pdev->dev, "%s: read 0x%llx from reg 0x%llx of %d bits\n", ++ __func__, ret_val, reg, (type + 1) * 8); ++ return ret_val; ++} ++ ++/* ++ * Read a buffer from the bar byte by byte for halt on ++ * null termination. ++ * Expected buffs are strings. ++ */ ++static ssize_t read_buff_from_bar_in_bytes(char *out, u8 __iomem *buff, ssize_t len) ++{ ++ u32 i; ++ ++ for (i = 0; i < len; i++) { ++ out[i] = ioread8(&buff[i]); ++ if (!out[i]) ++ break; ++ } ++ ++ return i; ++} ++ ++/* ++ * Read a buffer from a specific offset in a specific bar, ++ * maxed to a predefined len size-wise from the vSMP device ++ */ ++static int vsmp_read_buff_from_bar(struct vsmp_dev *vdev, u8 bar, u32 offset, ++ char *out, ssize_t len, bool halt_on_null) ++{ ++ u8 __iomem *buff; ++ u64 bar_start = pci_resource_start(vdev->pdev, bar); ++ u32 bar_len = pci_resource_len(vdev->pdev, bar); ++ ssize_t actual_len = len; ++ ++ /* incase of overflow, warn and use max len possible */ ++ if ((offset + len) > bar_len) { ++ WARN_ON((offset + len) > actual_len); ++ actual_len = bar_len - offset; ++ dev_dbg(&vdev->pdev->dev, "%lu overflows bar len, using %ld len instead\n", len, actual_len); ++ } ++ ++ buff = ioremap(bar_start + offset, actual_len); ++ if (!buff) ++ return -ENOMEM; ++ ++ if (halt_on_null) ++ read_buff_from_bar_in_bytes(out, buff, len); ++ else ++ memcpy_fromio(out, buff, len); ++ ++ iounmap(buff); ++ ++ return 0; ++} ++ ++/* ++ * Generic function to read from the bar ++ */ ++/* ++ * This is the maximal possible length of the version which is a text string ++ * the real len is usually much smaller, thus the driver uses this once to read ++ * the version string and record it's actual len. ++ * From that point and on, the actual len will be used in each call. ++ */ ++#define VERSION_MAX_LEN (1 << 19) ++ ++/* ++ * Retrieve str in order to determine the proper length. ++ * This is the best way to maintain backwards compatibility with all ++ * vSMP versions. ++ */ ++static ssize_t get_version_len(struct vsmp_dev *vdev) ++{ ++ ssize_t len = 0; ++ u64 reg_val = vsmp_read_reg32_from_cfg(vdev, VSMP_VERSION_REG); ++ char *version_str = kzalloc(VERSION_MAX_LEN, GFP_KERNEL); ++ ++ if (!version_str) ++ return len; ++ ++ if (vsmp_read_reg32_from_cfg(vdev, VSMP_VERSION_REG) < 0) { ++ kfree(version_str); ++ dev_err(&vdev->pdev->dev, "Failed to read value of reg 0x%x\n", VSMP_VERSION_REG); ++ return len; ++ } ++ ++ memset(version_str, 0, VERSION_MAX_LEN); ++ if (vsmp_read_buff_from_bar(vdev, 0, reg_val, version_str, VERSION_MAX_LEN, true)) { ++ kfree(version_str); ++ dev_err(&vdev->pdev->dev, "Failed to read buffer from bar\n"); ++ return len; ++ } ++ ++ len = strlen(version_str); ++ kfree(version_str); ++ ++ return len; ++} ++ ++static ssize_t version1_show(struct kobject *kobj, ++ struct kobj_attribute *attr, char *buf) ++{ ++ return sysfs_emit(buf, "1\n"); ++} ++ ++static ssize_t version2_show(struct kobject *kobj, ++ struct kobj_attribute *attr, char *buf) ++{ ++ return sysfs_emit(buf, "2\n"); ++} ++ ++static ssize_t version3_show(struct kobject *kobj, ++ struct kobj_attribute *attr, char *buf) ++{ ++ return sysfs_emit(buf, "3\n"); ++} ++ ++static ssize_t version_len_show(struct kobject *kobj, ++ struct kobj_attribute *attr, char *buf) ++{ ++ struct vsmp_dev *vdev = container_of(kobj, struct vsmp_dev, kobj); ++ int length; ++ ++ length = (int)get_version_len(vdev); ++ ++ return sysfs_emit(buf, "%d\n", length); ++} ++ ++static struct kobj_attribute version1 = __ATTR_RO(version1); ++static struct kobj_attribute version2 = __ATTR_RO(version2); ++static struct kobj_attribute version3 = __ATTR_RO(version3); ++static struct kobj_attribute version_len = __ATTR_RO(version_len); ++ ++static struct attribute *vsmp_attrs[] = { ++ &version1.attr, ++ &version2.attr, ++ &version3.attr, ++ &version_len.attr, ++}; ++ATTRIBUTE_GROUPS(vsmp); ++ ++static void vsmp_release(struct kobject *kobj) ++{ ++ struct vsmp_dev *vdev = container_of(kobj, struct vsmp_dev, kobj); ++ ++ kfree(vdev); ++} ++ ++static ssize_t vsmp_show(struct kobject *kobj, struct attribute *attr, char *buf) ++{ ++ struct kobj_attribute *kobj_attr; ++ ++ kobj_attr = container_of(attr, struct kobj_attribute, attr); ++ return kobj_attr->show(kobj, kobj_attr, buf); ++} ++ ++static const struct sysfs_ops vsmp_ops = { ++ .show = vsmp_show, ++}; ++ ++static struct kobj_type vsmp_type = { ++ .release = vsmp_release, ++ .sysfs_ops = &vsmp_ops, ++ .default_groups = vsmp_groups, ++}; ++ ++static int vsmp_pci_probe(struct pci_dev *pci, const struct pci_device_id *id) ++{ ++ struct vsmp_dev *vdev; ++ u64 cfg_start; ++ u32 cfg_len; ++ int retval; ++ ++ vdev = kzalloc(sizeof(*vdev), GFP_KERNEL); ++ if (!vdev) ++ return -ENOMEM; ++ ++ vdev->pdev = pci; ++ ++ /* ++ * Open the cfg address space of the vSDP device ++ */ ++ cfg_start = pci_resource_start(pci, 0); ++ cfg_len = pci_resource_len(pci, 0); ++ ++ dev_dbg(&pci->dev, "Mapping bar 0: [0x%llx,0x%llx]\n", cfg_start, cfg_start + cfg_len); ++ ++ vdev->cfg_addr = ioremap(cfg_start, cfg_len); ++ if (!vdev->cfg_addr) { ++ dev_err(&pci->dev, "Failed to map vSMP pci controller, exiting.\n"); ++ kfree(vdev); ++ return -ENODEV; ++ } ++ ++ pci_set_drvdata(pci, vdev); ++ ++ retval = kobject_init_and_add(&vdev->kobj, &vsmp_type, hypervisor_kobj, "vsmp"); ++ if (retval) { ++ kobject_put(&vdev->kobj); ++ dev_err(&vdev->pdev->dev, "Failed to create vSMP sysfs entry, exiting.\n"); ++ return -ENODEV; ++ } ++ ++ return 0; ++} ++ ++static void vsmp_pci_remove(struct pci_dev *pci) ++{ ++ struct vsmp_dev *vdev = pci_get_drvdata(pci); ++ ++ iounmap(vdev->cfg_addr); ++ kobject_del(&vdev->kobj); ++} ++ ++#define PCI_DEVICE_ID_SAP_FLX_VSMP_CTL 0x1011 ++static const struct pci_device_id vsmp_pci_table[] = { ++ { PCI_VDEVICE(SCALEMP, PCI_DEVICE_ID_SAP_FLX_VSMP_CTL), 0, }, ++ { 0, }, /* terminate list */ ++}; ++ ++static struct pci_driver vsmp_pci_driver = { ++ .name = "vSMP", ++ .id_table = vsmp_pci_table, ++ .probe = vsmp_pci_probe, ++ .remove = vsmp_pci_remove, ++}; ++ ++module_pci_driver(vsmp_pci_driver); ++ ++MODULE_LICENSE("GPL v2"); ++MODULE_AUTHOR("Eial Czerwacki <eial.czerwacki@sap.com>"); ++MODULE_DESCRIPTION("vSMP hypervisor driver"); diff --git a/0002-USB-xhci-make-xhci_get_endpoint_address-static.patch b/0002-USB-xhci-make-xhci_get_endpoint_address-static.patch new file mode 100644 index 00000000000000..76b23f0f2f6226 --- /dev/null +++ b/0002-USB-xhci-make-xhci_get_endpoint_address-static.patch @@ -0,0 +1,37 @@ +From 7a69923c1e15500776aafcc706646ec2bf17ed17 Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +Date: Thu, 1 Sep 2022 15:46:19 +0200 +Subject: [PATCH 2/2] USB: xhci: make xhci_get_endpoint_address static + +This is only called in the xhci.c file, so make the symbol static. + +Cc: Mathias Nyman <mathias.nyman@intel.com> +Cc: linux-usb@vger.kernel.org +Cc: linux-kernel@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +--- + drivers/usb/host/xhci.c | 2 +- + drivers/usb/host/xhci.h | 1 - + 2 files changed, 1 insertion(+), 2 deletions(-) + +--- a/drivers/usb/host/xhci.c ++++ b/drivers/usb/host/xhci.c +@@ -1482,7 +1482,7 @@ EXPORT_SYMBOL_GPL(xhci_get_endpoint_inde + /* The reverse operation to xhci_get_endpoint_index. Calculate the USB endpoint + * address from the XHCI endpoint index. + */ +-unsigned int xhci_get_endpoint_address(unsigned int ep_index) ++static unsigned int xhci_get_endpoint_address(unsigned int ep_index) + { + unsigned int number = DIV_ROUND_UP(ep_index, 2); + unsigned int direction = ep_index % 2 ? USB_DIR_OUT : USB_DIR_IN; +--- a/drivers/usb/host/xhci.h ++++ b/drivers/usb/host/xhci.h +@@ -2041,7 +2041,6 @@ int xhci_setup_addressable_virt_dev(stru + void xhci_copy_ep0_dequeue_into_input_ctx(struct xhci_hcd *xhci, + struct usb_device *udev); + unsigned int xhci_get_endpoint_index(struct usb_endpoint_descriptor *desc); +-unsigned int xhci_get_endpoint_address(unsigned int ep_index); + unsigned int xhci_last_valid_endpoint(u32 added_ctxs); + void xhci_endpoint_zero(struct xhci_hcd *xhci, struct xhci_virt_device *virt_dev, struct usb_host_endpoint *ep); + void xhci_update_tt_active_eps(struct xhci_hcd *xhci, @@ -1,4 +1,8 @@ # +0001-scsi-stex-properly-zero-out-the-passthrough-command-.patch +0001-vsmp-driver.patch +0001-PCI-ACPI-do-not-reference-a-pci-device-after-it-has-.patch +0002-USB-xhci-make-xhci_get_endpoint_address-static.patch 0001-lib-vdso-use-grep-E-instead-of-egrep.patch 0002-scripts-selinux-use-grep-E-instead-of-egrep.patch 0003-scripts-coccicheck-use-grep-E-instead-of-egrep.patch |