]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.17-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 26 May 2022 15:15:09 +0000 (17:15 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 26 May 2022 15:15:09 +0000 (17:15 +0200)
added patches:
acpi-sysfs-fix-bert-error-region-memory-mapping.patch

queue-5.17/acpi-sysfs-fix-bert-error-region-memory-mapping.patch [new file with mode: 0644]
queue-5.17/series

diff --git a/queue-5.17/acpi-sysfs-fix-bert-error-region-memory-mapping.patch b/queue-5.17/acpi-sysfs-fix-bert-error-region-memory-mapping.patch
new file mode 100644 (file)
index 0000000..4cbc37b
--- /dev/null
@@ -0,0 +1,85 @@
+From 1bbc21785b7336619fb6a67f1fff5afdaf229acc Mon Sep 17 00:00:00 2001
+From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
+Date: Thu, 7 Apr 2022 11:51:20 +0100
+Subject: ACPI: sysfs: Fix BERT error region memory mapping
+
+From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
+
+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 <lorenzo.pieralisi@arm.com>
+Tested-by: Veronika Kabatova <vkabatov@redhat.com>
+Tested-by: Aristeu Rozanski <aris@redhat.com>
+Acked-by: Ard Biesheuvel <ardb@kernel.org>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Cc: dann frazier <dann.frazier@canonical.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/acpi/sysfs.c |   25 ++++++++++++++++++-------
+ 1 file changed, 18 insertions(+), 7 deletions(-)
+
+--- a/drivers/acpi/sysfs.c
++++ b/drivers/acpi/sysfs.c
+@@ -415,19 +415,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)
index b6914d8f432e20a03cd47f96e9c15473278d208b..a4730e04a4a1b51983ba2571bb406c90e9880f8e 100644 (file)
@@ -107,3 +107,4 @@ random-convert-to-using-fops-read_iter.patch
 random-convert-to-using-fops-write_iter.patch
 random-wire-up-fops-splice_-read-write-_iter.patch
 random-check-for-signals-after-page-of-pool-writes.patch
+acpi-sysfs-fix-bert-error-region-memory-mapping.patch