hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/x86/kernel/acpi/boot.c
....@@ -1,26 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * boot.c - Architecture-Specific Low-Level ACPI Boot Support
34 *
45 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
56 * Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
6
- *
7
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as published by
11
- * the Free Software Foundation; either version 2 of the License, or
12
- * (at your option) any later version.
13
- *
14
- * This program is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
- * GNU General Public License for more details.
18
- *
19
- * You should have received a copy of the GNU General Public License
20
- * along with this program; if not, write to the Free Software
21
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
- *
23
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
247 */
258
269 #include <linux/init.h>
....@@ -32,22 +15,23 @@
3215 #include <linux/dmi.h>
3316 #include <linux/irq.h>
3417 #include <linux/slab.h>
35
-#include <linux/bootmem.h>
18
+#include <linux/memblock.h>
3619 #include <linux/ioport.h>
3720 #include <linux/pci.h>
3821 #include <linux/efi-bgrt.h>
3922 #include <linux/serial_core.h>
23
+#include <linux/pgtable.h>
4024
4125 #include <asm/e820/api.h>
4226 #include <asm/irqdomain.h>
4327 #include <asm/pci_x86.h>
44
-#include <asm/pgtable.h>
4528 #include <asm/io_apic.h>
4629 #include <asm/apic.h>
4730 #include <asm/io.h>
4831 #include <asm/mpspec.h>
4932 #include <asm/smp.h>
5033 #include <asm/i8259.h>
34
+#include <asm/setup.h>
5135
5236 #include "sleep.h" /* To include x86_acpi_suspend_lowlevel */
5337 static int __initdata acpi_force = 0;
....@@ -61,6 +45,7 @@
6145 #define PREFIX "ACPI: "
6246
6347 int acpi_noirq; /* skip ACPI IRQ initialization */
48
+static int acpi_nobgrt; /* skip ACPI BGRT */
6449 int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */
6550 EXPORT_SYMBOL(acpi_pci_disabled);
6651
....@@ -196,7 +181,7 @@
196181 }
197182
198183 static int __init
199
-acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end)
184
+acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end)
200185 {
201186 struct acpi_madt_local_x2apic *processor = NULL;
202187 #ifdef CONFIG_X86_X2APIC
....@@ -209,7 +194,7 @@
209194 if (BAD_MADT_ENTRY(processor, end))
210195 return -EINVAL;
211196
212
- acpi_table_print_madt_entry(header);
197
+ acpi_table_print_madt_entry(&header->common);
213198
214199 #ifdef CONFIG_X86_X2APIC
215200 apic_id = processor->local_apic_id;
....@@ -241,7 +226,7 @@
241226 }
242227
243228 static int __init
244
-acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end)
229
+acpi_parse_lapic(union acpi_subtable_headers * header, const unsigned long end)
245230 {
246231 struct acpi_madt_local_apic *processor = NULL;
247232
....@@ -250,7 +235,7 @@
250235 if (BAD_MADT_ENTRY(processor, end))
251236 return -EINVAL;
252237
253
- acpi_table_print_madt_entry(header);
238
+ acpi_table_print_madt_entry(&header->common);
254239
255240 /* Ignore invalid ID */
256241 if (processor->id == 0xff)
....@@ -271,7 +256,7 @@
271256 }
272257
273258 static int __init
274
-acpi_parse_sapic(struct acpi_subtable_header *header, const unsigned long end)
259
+acpi_parse_sapic(union acpi_subtable_headers *header, const unsigned long end)
275260 {
276261 struct acpi_madt_local_sapic *processor = NULL;
277262
....@@ -280,7 +265,7 @@
280265 if (BAD_MADT_ENTRY(processor, end))
281266 return -EINVAL;
282267
283
- acpi_table_print_madt_entry(header);
268
+ acpi_table_print_madt_entry(&header->common);
284269
285270 acpi_register_lapic((processor->id << 8) | processor->eid,/* APIC ID */
286271 processor->processor_id, /* ACPI ID */
....@@ -290,7 +275,7 @@
290275 }
291276
292277 static int __init
293
-acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header,
278
+acpi_parse_lapic_addr_ovr(union acpi_subtable_headers * header,
294279 const unsigned long end)
295280 {
296281 struct acpi_madt_local_apic_override *lapic_addr_ovr = NULL;
....@@ -300,7 +285,7 @@
300285 if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
301286 return -EINVAL;
302287
303
- acpi_table_print_madt_entry(header);
288
+ acpi_table_print_madt_entry(&header->common);
304289
305290 acpi_lapic_addr = lapic_addr_ovr->address;
306291
....@@ -308,7 +293,7 @@
308293 }
309294
310295 static int __init
311
-acpi_parse_x2apic_nmi(struct acpi_subtable_header *header,
296
+acpi_parse_x2apic_nmi(union acpi_subtable_headers *header,
312297 const unsigned long end)
313298 {
314299 struct acpi_madt_local_x2apic_nmi *x2apic_nmi = NULL;
....@@ -318,7 +303,7 @@
318303 if (BAD_MADT_ENTRY(x2apic_nmi, end))
319304 return -EINVAL;
320305
321
- acpi_table_print_madt_entry(header);
306
+ acpi_table_print_madt_entry(&header->common);
322307
323308 if (x2apic_nmi->lint != 1)
324309 printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
....@@ -327,7 +312,7 @@
327312 }
328313
329314 static int __init
330
-acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long end)
315
+acpi_parse_lapic_nmi(union acpi_subtable_headers * header, const unsigned long end)
331316 {
332317 struct acpi_madt_local_apic_nmi *lapic_nmi = NULL;
333318
....@@ -336,7 +321,7 @@
336321 if (BAD_MADT_ENTRY(lapic_nmi, end))
337322 return -EINVAL;
338323
339
- acpi_table_print_madt_entry(header);
324
+ acpi_table_print_madt_entry(&header->common);
340325
341326 if (lapic_nmi->lint != 1)
342327 printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n");
....@@ -448,7 +433,7 @@
448433 }
449434
450435 static int __init
451
-acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end)
436
+acpi_parse_ioapic(union acpi_subtable_headers * header, const unsigned long end)
452437 {
453438 struct acpi_madt_io_apic *ioapic = NULL;
454439 struct ioapic_domain_cfg cfg = {
....@@ -461,7 +446,7 @@
461446 if (BAD_MADT_ENTRY(ioapic, end))
462447 return -EINVAL;
463448
464
- acpi_table_print_madt_entry(header);
449
+ acpi_table_print_madt_entry(&header->common);
465450
466451 /* Statically assign IRQ numbers for IOAPICs hosting legacy IRQs */
467452 if (ioapic->global_irq_base < nr_legacy_irqs())
....@@ -507,7 +492,7 @@
507492 }
508493
509494 static int __init
510
-acpi_parse_int_src_ovr(struct acpi_subtable_header * header,
495
+acpi_parse_int_src_ovr(union acpi_subtable_headers * header,
511496 const unsigned long end)
512497 {
513498 struct acpi_madt_interrupt_override *intsrc = NULL;
....@@ -517,7 +502,7 @@
517502 if (BAD_MADT_ENTRY(intsrc, end))
518503 return -EINVAL;
519504
520
- acpi_table_print_madt_entry(header);
505
+ acpi_table_print_madt_entry(&header->common);
521506
522507 if (intsrc->source_irq == acpi_gbl_FADT.sci_interrupt) {
523508 acpi_sci_ioapic_setup(intsrc->source_irq,
....@@ -549,7 +534,7 @@
549534 }
550535
551536 static int __init
552
-acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end)
537
+acpi_parse_nmi_src(union acpi_subtable_headers * header, const unsigned long end)
553538 {
554539 struct acpi_madt_nmi_source *nmi_src = NULL;
555540
....@@ -558,7 +543,7 @@
558543 if (BAD_MADT_ENTRY(nmi_src, end))
559544 return -EINVAL;
560545
561
- acpi_table_print_madt_entry(header);
546
+ acpi_table_print_madt_entry(&header->common);
562547
563548 /* TBD: Support nimsrc entries? */
564549
....@@ -847,7 +832,7 @@
847832 /**
848833 * acpi_ioapic_registered - Check whether IOAPIC assoicatied with @gsi_base
849834 * has been registered
850
- * @handle: ACPI handle of the IOAPIC deivce
835
+ * @handle: ACPI handle of the IOAPIC device
851836 * @gsi_base: GSI base associated with the IOAPIC
852837 *
853838 * Assume caller holds some type of lock to serialize acpi_ioapic_registered()
....@@ -932,7 +917,11 @@
932917 * the resource tree during the lateinit timeframe.
933918 */
934919 #define HPET_RESOURCE_NAME_SIZE 9
935
- hpet_res = alloc_bootmem(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE);
920
+ hpet_res = memblock_alloc(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE,
921
+ SMP_CACHE_BYTES);
922
+ if (!hpet_res)
923
+ panic("%s: Failed to allocate %zu bytes\n", __func__,
924
+ sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE);
936925
937926 hpet_res->name = (void *)&hpet_res[1];
938927 hpet_res->flags = IORESOURCE_MEM;
....@@ -1351,6 +1340,17 @@
13511340 return 0;
13521341 }
13531342
1343
+static int __init disable_acpi_xsdt(const struct dmi_system_id *d)
1344
+{
1345
+ if (!acpi_force) {
1346
+ pr_notice("%s detected: force use of acpi=rsdt\n", d->ident);
1347
+ acpi_gbl_do_not_use_xsdt = TRUE;
1348
+ } else {
1349
+ pr_notice("Warning: DMI blacklist says broken, but acpi XSDT forced\n");
1350
+ }
1351
+ return 0;
1352
+}
1353
+
13541354 static int __init dmi_disable_acpi(const struct dmi_system_id *d)
13551355 {
13561356 if (!acpi_force) {
....@@ -1473,6 +1473,19 @@
14731473 .matches = {
14741474 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
14751475 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
1476
+ },
1477
+ },
1478
+ /*
1479
+ * Boxes that need ACPI XSDT use disabled due to corrupted tables
1480
+ */
1481
+ {
1482
+ .callback = disable_acpi_xsdt,
1483
+ .ident = "Advantech DAC-BJ01",
1484
+ .matches = {
1485
+ DMI_MATCH(DMI_SYS_VENDOR, "NEC"),
1486
+ DMI_MATCH(DMI_PRODUCT_NAME, "Bearlake CRB Board"),
1487
+ DMI_MATCH(DMI_BIOS_VERSION, "V1.12"),
1488
+ DMI_MATCH(DMI_BIOS_DATE, "02/01/2011"),
14761489 },
14771490 },
14781491 {}
....@@ -1630,7 +1643,7 @@
16301643 acpi_process_madt();
16311644
16321645 acpi_table_parse(ACPI_SIG_HPET, acpi_parse_hpet);
1633
- if (IS_ENABLED(CONFIG_ACPI_BGRT))
1646
+ if (IS_ENABLED(CONFIG_ACPI_BGRT) && !acpi_nobgrt)
16341647 acpi_table_parse(ACPI_SIG_BGRT, acpi_parse_bgrt);
16351648
16361649 if (!acpi_noirq)
....@@ -1681,6 +1694,13 @@
16811694 return 0;
16821695 }
16831696 early_param("acpi", parse_acpi);
1697
+
1698
+static int __init parse_acpi_bgrt(char *arg)
1699
+{
1700
+ acpi_nobgrt = true;
1701
+ return 0;
1702
+}
1703
+early_param("bgrt_disable", parse_acpi_bgrt);
16841704
16851705 /* FIXME: Using pci= for an ACPI parameter is a travesty. */
16861706 static int __init parse_pci(char *arg)
....@@ -1770,3 +1790,13 @@
17701790 e820__range_add(addr, size, E820_TYPE_ACPI);
17711791 e820__update_table_print();
17721792 }
1793
+
1794
+void x86_default_set_root_pointer(u64 addr)
1795
+{
1796
+ boot_params.acpi_rsdp_addr = addr;
1797
+}
1798
+
1799
+u64 x86_default_get_root_pointer(void)
1800
+{
1801
+ return boot_params.acpi_rsdp_addr;
1802
+}