From: Greg Kroah-Hartman Date: Thu, 26 May 2022 15:14:29 +0000 (+0200) Subject: 4.19-stable patches X-Git-Tag: v5.18.1~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d236b52da97741c88fa648f5c477c654b87949a7;p=thirdparty%2Fkernel%2Fstable-queue.git 4.19-stable patches added patches: acpi-sysfs-fix-bert-error-region-memory-mapping.patch acpi-sysfs-make-sparse-happy-about-address-space-in-use.patch --- diff --git a/queue-4.19/acpi-sysfs-fix-bert-error-region-memory-mapping.patch b/queue-4.19/acpi-sysfs-fix-bert-error-region-memory-mapping.patch new file mode 100644 index 00000000000..6a187c5f71c --- /dev/null +++ b/queue-4.19/acpi-sysfs-fix-bert-error-region-memory-mapping.patch @@ -0,0 +1,85 @@ +From 1bbc21785b7336619fb6a67f1fff5afdaf229acc Mon Sep 17 00:00:00 2001 +From: Lorenzo Pieralisi +Date: Thu, 7 Apr 2022 11:51:20 +0100 +Subject: ACPI: sysfs: Fix BERT error region memory mapping + +From: Lorenzo Pieralisi + +commit 1bbc21785b7336619fb6a67f1fff5afdaf229acc upstream. + +Currently the sysfs interface maps the BERT error region as "memory" +(through acpi_os_map_memory()) in order to copy the error records into +memory buffers through memory operations (eg memory_read_from_buffer()). + +The OS system cannot detect whether the BERT error region is part of +system RAM or it is "device memory" (eg BMC memory) and therefore it +cannot detect which memory attributes the bus to memory support (and +corresponding kernel mapping, unless firmware provides the required +information). + +The acpi_os_map_memory() arch backend implementation determines the +mapping attributes. On arm64, if the BERT error region is not present in +the EFI memory map, the error region is mapped as device-nGnRnE; this +triggers alignment faults since memcpy unaligned accesses are not +allowed in device-nGnRnE regions. + +The ACPI sysfs code cannot therefore map by default the BERT error +region with memory semantics but should use a safer default. + +Change the sysfs code to map the BERT error region as MMIO (through +acpi_os_map_iomem()) and use the memcpy_fromio() interface to read the +error region into the kernel buffer. + +Link: https://lore.kernel.org/linux-arm-kernel/31ffe8fc-f5ee-2858-26c5-0fd8bdd68702@arm.com +Link: https://lore.kernel.org/linux-acpi/CAJZ5v0g+OVbhuUUDrLUCfX_mVqY_e8ubgLTU98=jfjTeb4t+Pw@mail.gmail.com +Signed-off-by: Lorenzo Pieralisi +Tested-by: Veronika Kabatova +Tested-by: Aristeu Rozanski +Acked-by: Ard Biesheuvel +Signed-off-by: Rafael J. Wysocki +Cc: dann frazier +Signed-off-by: Greg Kroah-Hartman +--- + drivers/acpi/sysfs.c | 25 ++++++++++++++++++------- + 1 file changed, 18 insertions(+), 7 deletions(-) + +--- a/drivers/acpi/sysfs.c ++++ b/drivers/acpi/sysfs.c +@@ -438,19 +438,30 @@ static ssize_t acpi_data_show(struct fil + loff_t offset, size_t count) + { + struct acpi_data_attr *data_attr; +- void *base; +- ssize_t rc; ++ void __iomem *base; ++ ssize_t size; + + data_attr = container_of(bin_attr, struct acpi_data_attr, attr); ++ size = data_attr->attr.size; + +- base = acpi_os_map_memory(data_attr->addr, data_attr->attr.size); ++ if (offset < 0) ++ return -EINVAL; ++ ++ if (offset >= size) ++ return 0; ++ ++ if (count > size - offset) ++ count = size - offset; ++ ++ base = acpi_os_map_iomem(data_attr->addr, size); + if (!base) + return -ENOMEM; +- rc = memory_read_from_buffer(buf, count, &offset, base, +- data_attr->attr.size); +- acpi_os_unmap_memory(base, data_attr->attr.size); + +- return rc; ++ memcpy_fromio(buf, base + offset, count); ++ ++ acpi_os_unmap_iomem(base, size); ++ ++ return count; + } + + static int acpi_bert_data_init(void *th, struct acpi_data_attr *data_attr) diff --git a/queue-4.19/acpi-sysfs-make-sparse-happy-about-address-space-in-use.patch b/queue-4.19/acpi-sysfs-make-sparse-happy-about-address-space-in-use.patch new file mode 100644 index 00000000000..8e4a4a3911b --- /dev/null +++ b/queue-4.19/acpi-sysfs-make-sparse-happy-about-address-space-in-use.patch @@ -0,0 +1,43 @@ +From bdd56d7d8931e842775d2e5b93d426a8d1940e33 Mon Sep 17 00:00:00 2001 +From: Andy Shevchenko +Date: Wed, 16 Jun 2021 20:03:32 +0300 +Subject: ACPI: sysfs: Make sparse happy about address space in use + +From: Andy Shevchenko + +commit bdd56d7d8931e842775d2e5b93d426a8d1940e33 upstream. + +Sparse is not happy about address space in use in acpi_data_show(): + +drivers/acpi/sysfs.c:428:14: warning: incorrect type in assignment (different address spaces) +drivers/acpi/sysfs.c:428:14: expected void [noderef] __iomem *base +drivers/acpi/sysfs.c:428:14: got void * +drivers/acpi/sysfs.c:431:59: warning: incorrect type in argument 4 (different address spaces) +drivers/acpi/sysfs.c:431:59: expected void const *from +drivers/acpi/sysfs.c:431:59: got void [noderef] __iomem *base +drivers/acpi/sysfs.c:433:30: warning: incorrect type in argument 1 (different address spaces) +drivers/acpi/sysfs.c:433:30: expected void *logical_address +drivers/acpi/sysfs.c:433:30: got void [noderef] __iomem *base + +Indeed, acpi_os_map_memory() returns a void pointer with dropped specific +address space. Hence, we don't need to carry out __iomem in acpi_data_show(). + +Signed-off-by: Andy Shevchenko +Signed-off-by: Rafael J. Wysocki +Cc: dann frazier +Signed-off-by: Greg Kroah-Hartman +--- + drivers/acpi/sysfs.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/acpi/sysfs.c ++++ b/drivers/acpi/sysfs.c +@@ -438,7 +438,7 @@ static ssize_t acpi_data_show(struct fil + loff_t offset, size_t count) + { + struct acpi_data_attr *data_attr; +- void __iomem *base; ++ void *base; + ssize_t rc; + + data_attr = container_of(bin_attr, struct acpi_data_attr, attr); diff --git a/queue-4.19/series b/queue-4.19/series index 0edebbe36df..9b582ddbf50 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -2,3 +2,5 @@ x86-pci-xen-disable-pci-msi-masking-for-xen_hvm-guests.patch staging-rtl8723bs-prevent-ssid-overflow-in-rtw_wx_set_scan.patch tcp-change-source-port-randomizarion-at-connect-time.patch secure_seq-use-the-64-bits-of-the-siphash-for-port-offset-calculation.patch +acpi-sysfs-make-sparse-happy-about-address-space-in-use.patch +acpi-sysfs-fix-bert-error-region-memory-mapping.patch