Skip to content

Commit c870720

Browse files
committed
Merge branches 'acpi-apei', 'acpi-misc' and 'pnp'
Merge ACPI APEI updates, a miscellaneous update related to ACPI, and a PNP update for 6.18-rc1: - Remove redundant assignments in erst_dbg_{ioctl|write}() in the ACPI APEI driver (Thorsten Blum) - Allow the ACPI APEI EINJ to handle more types of addresses than just MMIO (Jiaqi Yan) - Use str_low_high() helper in two places in the ACPI code (Chelsy Ratnawat) - Use str_plural() to simplify the PNP code (Xichao Zhao) * acpi-apei: ACPI: APEI: EINJ: Allow more types of addresses except MMIO ACPI: APEI: Remove redundant assignments in erst_dbg_{ioctl|write}() * acpi-misc: ACPI: Use str_low_high() helper in two places * pnp: PNP: isapnp: use str_plural() to simplify the code
4 parents 02e9542 + 7d444f5 + 39c8788 + b8db551 commit c870720

File tree

5 files changed

+51
-17
lines changed

5 files changed

+51
-17
lines changed

drivers/acpi/apei/einj-core.c

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,43 @@ static int __einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
656656
return rc;
657657
}
658658

659+
/* Allow almost all types of address except MMIO. */
660+
static bool is_allowed_range(u64 base_addr, u64 size)
661+
{
662+
int i;
663+
/*
664+
* MMIO region is usually claimed with IORESOURCE_MEM + IORES_DESC_NONE.
665+
* However, IORES_DESC_NONE is treated like a wildcard when we check if
666+
* region intersects with known resource. So do an allow list check for
667+
* IORES_DESCs that definitely or most likely not MMIO.
668+
*/
669+
int non_mmio_desc[] = {
670+
IORES_DESC_CRASH_KERNEL,
671+
IORES_DESC_ACPI_TABLES,
672+
IORES_DESC_ACPI_NV_STORAGE,
673+
IORES_DESC_PERSISTENT_MEMORY,
674+
IORES_DESC_PERSISTENT_MEMORY_LEGACY,
675+
/* Treat IORES_DESC_DEVICE_PRIVATE_MEMORY as MMIO. */
676+
IORES_DESC_RESERVED,
677+
IORES_DESC_SOFT_RESERVED,
678+
};
679+
680+
if (region_intersects(base_addr, size, IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE)
681+
== REGION_INTERSECTS)
682+
return true;
683+
684+
for (i = 0; i < ARRAY_SIZE(non_mmio_desc); ++i) {
685+
if (region_intersects(base_addr, size, IORESOURCE_MEM, non_mmio_desc[i])
686+
== REGION_INTERSECTS)
687+
return true;
688+
}
689+
690+
if (arch_is_platform_page(base_addr))
691+
return true;
692+
693+
return false;
694+
}
695+
659696
/* Inject the specified hardware error */
660697
int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2, u64 param3,
661698
u64 param4)
@@ -702,19 +739,15 @@ int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2, u64 param3,
702739
* Disallow crazy address masks that give BIOS leeway to pick
703740
* injection address almost anywhere. Insist on page or
704741
* better granularity and that target address is normal RAM or
705-
* NVDIMM.
742+
* as long as is not MMIO.
706743
*/
707744
base_addr = param1 & param2;
708745
size = ~param2 + 1;
709746

710-
if (((param2 & PAGE_MASK) != PAGE_MASK) ||
711-
((region_intersects(base_addr, size, IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE)
712-
!= REGION_INTERSECTS) &&
713-
(region_intersects(base_addr, size, IORESOURCE_MEM, IORES_DESC_PERSISTENT_MEMORY)
714-
!= REGION_INTERSECTS) &&
715-
(region_intersects(base_addr, size, IORESOURCE_MEM, IORES_DESC_SOFT_RESERVED)
716-
!= REGION_INTERSECTS) &&
717-
!arch_is_platform_page(base_addr)))
747+
if ((param2 & PAGE_MASK) != PAGE_MASK)
748+
return -EINVAL;
749+
750+
if (!is_allowed_range(base_addr, size))
718751
return -EINVAL;
719752

720753
if (is_zero_pfn(base_addr >> PAGE_SHIFT))

drivers/acpi/apei/erst-dbg.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,8 @@ static long erst_dbg_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
6060

6161
switch (cmd) {
6262
case APEI_ERST_CLEAR_RECORD:
63-
rc = copy_from_user(&record_id, (void __user *)arg,
64-
sizeof(record_id));
65-
if (rc)
63+
if (copy_from_user(&record_id, (void __user *)arg,
64+
sizeof(record_id)))
6665
return -EFAULT;
6766
return erst_clear(record_id);
6867
case APEI_ERST_GET_RECORD_COUNT:
@@ -175,8 +174,7 @@ static ssize_t erst_dbg_write(struct file *filp, const char __user *ubuf,
175174
erst_dbg_buf = p;
176175
erst_dbg_buf_len = usize;
177176
}
178-
rc = copy_from_user(erst_dbg_buf, ubuf, usize);
179-
if (rc) {
177+
if (copy_from_user(erst_dbg_buf, ubuf, usize)) {
180178
rc = -EFAULT;
181179
goto out;
182180
}

drivers/acpi/pci_irq.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/acpi.h>
2323
#include <linux/slab.h>
2424
#include <linux/interrupt.h>
25+
#include <linux/string_choices.h>
2526

2627
struct acpi_prt_entry {
2728
struct acpi_pci_id id;
@@ -468,7 +469,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
468469
dev_dbg(&dev->dev, "PCI INT %c%s -> GSI %u (%s, %s) -> IRQ %d\n",
469470
pin_name(pin), link_desc, gsi,
470471
(triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge",
471-
(polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq);
472+
str_low_high(polarity == ACPI_ACTIVE_LOW), dev->irq);
472473

473474
kfree(entry);
474475
return 0;

drivers/acpi/resource.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/slab.h>
1818
#include <linux/irq.h>
1919
#include <linux/dmi.h>
20+
#include <linux/string_choices.h>
2021

2122
#ifdef CONFIG_X86
2223
#define valid_IRQ(i) (((i) != 0) && ((i) != 2))
@@ -780,7 +781,7 @@ static void acpi_dev_get_irqresource(struct resource *res, u32 gsi,
780781
pr_warn("ACPI: IRQ %d override to %s%s, %s%s\n", gsi,
781782
t ? "level" : "edge",
782783
trig == triggering ? "" : "(!)",
783-
p ? "low" : "high",
784+
str_low_high(p),
784785
pol == polarity ? "" : "(!)");
785786
triggering = trig;
786787
polarity = pol;

drivers/pnp/isapnp/core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <linux/init.h>
2828
#include <linux/isapnp.h>
2929
#include <linux/mutex.h>
30+
#include <linux/string_choices.h>
3031
#include <asm/io.h>
3132

3233
#include "../base.h"
@@ -1037,7 +1038,7 @@ static int __init isapnp_init(void)
10371038
if (cards)
10381039
printk(KERN_INFO
10391040
"isapnp: %i Plug & Play card%s detected total\n", cards,
1040-
cards > 1 ? "s" : "");
1041+
str_plural(cards));
10411042
else
10421043
printk(KERN_INFO "isapnp: No Plug & Play card found\n");
10431044

0 commit comments

Comments
 (0)