bpf: Prevent memory disambiguation attack
[linux/fpc-iii.git] / drivers / firmware / google / coreboot_table-acpi.c
blobfb98db2d20e2bab5100ed8e91f88f7796f293abc
1 /*
2 * coreboot_table-acpi.c
4 * Using ACPI to locate Coreboot table and provide coreboot table access.
6 * Copyright 2017 Google Inc.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License v2.0 as published by
10 * the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
18 #include <linux/acpi.h>
19 #include <linux/device.h>
20 #include <linux/err.h>
21 #include <linux/init.h>
22 #include <linux/io.h>
23 #include <linux/kernel.h>
24 #include <linux/module.h>
25 #include <linux/platform_device.h>
27 #include "coreboot_table.h"
29 static int coreboot_table_acpi_probe(struct platform_device *pdev)
31 phys_addr_t phyaddr;
32 resource_size_t len;
33 struct coreboot_table_header __iomem *header = NULL;
34 struct resource *res;
35 void __iomem *ptr = NULL;
37 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
38 if (!res)
39 return -EINVAL;
41 len = resource_size(res);
42 if (!res->start || !len)
43 return -EINVAL;
45 phyaddr = res->start;
46 header = ioremap_cache(phyaddr, sizeof(*header));
47 if (header == NULL)
48 return -ENOMEM;
50 ptr = ioremap_cache(phyaddr,
51 header->header_bytes + header->table_bytes);
52 iounmap(header);
53 if (!ptr)
54 return -ENOMEM;
56 return coreboot_table_init(ptr);
59 static int coreboot_table_acpi_remove(struct platform_device *pdev)
61 return coreboot_table_exit();
64 static const struct acpi_device_id cros_coreboot_acpi_match[] = {
65 { "GOOGCB00", 0 },
66 { "BOOT0000", 0 },
67 { }
69 MODULE_DEVICE_TABLE(acpi, cros_coreboot_acpi_match);
71 static struct platform_driver coreboot_table_acpi_driver = {
72 .probe = coreboot_table_acpi_probe,
73 .remove = coreboot_table_acpi_remove,
74 .driver = {
75 .name = "coreboot_table_acpi",
76 .acpi_match_table = ACPI_PTR(cros_coreboot_acpi_match),
80 static int __init coreboot_table_acpi_init(void)
82 return platform_driver_register(&coreboot_table_acpi_driver);
85 module_init(coreboot_table_acpi_init);
87 MODULE_AUTHOR("Google, Inc.");
88 MODULE_LICENSE("GPL");