| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * ACPI configfs support |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (c) 2016 Intel Corporation |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 7 | | - * under the terms of the GNU General Public License version 2 as published by |
|---|
| 8 | | - * the Free Software Foundation. |
|---|
| 9 | 6 | */ |
|---|
| 10 | 7 | |
|---|
| 11 | 8 | #define pr_fmt(fmt) "ACPI configfs: " fmt |
|---|
| .. | .. |
|---|
| 14 | 11 | #include <linux/module.h> |
|---|
| 15 | 12 | #include <linux/configfs.h> |
|---|
| 16 | 13 | #include <linux/acpi.h> |
|---|
| 14 | +#include <linux/security.h> |
|---|
| 17 | 15 | |
|---|
| 18 | 16 | #include "acpica/accommon.h" |
|---|
| 19 | 17 | #include "acpica/actables.h" |
|---|
| .. | .. |
|---|
| 31 | 29 | { |
|---|
| 32 | 30 | const struct acpi_table_header *header = data; |
|---|
| 33 | 31 | struct acpi_table *table; |
|---|
| 34 | | - int ret; |
|---|
| 32 | + int ret = security_locked_down(LOCKDOWN_ACPI_TABLES); |
|---|
| 33 | + |
|---|
| 34 | + if (ret) |
|---|
| 35 | + return ret; |
|---|
| 35 | 36 | |
|---|
| 36 | 37 | table = container_of(cfg, struct acpi_table, cfg); |
|---|
| 37 | 38 | |
|---|
| .. | .. |
|---|
| 56 | 57 | if (!table->header) |
|---|
| 57 | 58 | return -ENOMEM; |
|---|
| 58 | 59 | |
|---|
| 59 | | - ACPI_INFO(("Host-directed Dynamic ACPI Table Load:")); |
|---|
| 60 | | - ret = acpi_tb_install_and_load_table( |
|---|
| 61 | | - ACPI_PTR_TO_PHYSADDR(table->header), |
|---|
| 62 | | - ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL, FALSE, |
|---|
| 63 | | - &table->index); |
|---|
| 60 | + ret = acpi_load_table(table->header, &table->index); |
|---|
| 64 | 61 | if (ret) { |
|---|
| 65 | 62 | kfree(table->header); |
|---|
| 66 | 63 | table->header = NULL; |
|---|
| .. | .. |
|---|
| 97 | 94 | |
|---|
| 98 | 95 | CONFIGFS_BIN_ATTR(acpi_table_, aml, NULL, MAX_ACPI_TABLE_SIZE); |
|---|
| 99 | 96 | |
|---|
| 100 | | -struct configfs_bin_attribute *acpi_table_bin_attrs[] = { |
|---|
| 97 | +static struct configfs_bin_attribute *acpi_table_bin_attrs[] = { |
|---|
| 101 | 98 | &acpi_table_attr_aml, |
|---|
| 102 | 99 | NULL, |
|---|
| 103 | 100 | }; |
|---|
| 104 | 101 | |
|---|
| 105 | | -ssize_t acpi_table_signature_show(struct config_item *cfg, char *str) |
|---|
| 102 | +static ssize_t acpi_table_signature_show(struct config_item *cfg, char *str) |
|---|
| 106 | 103 | { |
|---|
| 107 | 104 | struct acpi_table_header *h = get_header(cfg); |
|---|
| 108 | 105 | |
|---|
| 109 | 106 | if (!h) |
|---|
| 110 | 107 | return -EINVAL; |
|---|
| 111 | 108 | |
|---|
| 112 | | - return sprintf(str, "%.*s\n", ACPI_NAME_SIZE, h->signature); |
|---|
| 109 | + return sprintf(str, "%.*s\n", ACPI_NAMESEG_SIZE, h->signature); |
|---|
| 113 | 110 | } |
|---|
| 114 | 111 | |
|---|
| 115 | | -ssize_t acpi_table_length_show(struct config_item *cfg, char *str) |
|---|
| 112 | +static ssize_t acpi_table_length_show(struct config_item *cfg, char *str) |
|---|
| 116 | 113 | { |
|---|
| 117 | 114 | struct acpi_table_header *h = get_header(cfg); |
|---|
| 118 | 115 | |
|---|
| .. | .. |
|---|
| 122 | 119 | return sprintf(str, "%d\n", h->length); |
|---|
| 123 | 120 | } |
|---|
| 124 | 121 | |
|---|
| 125 | | -ssize_t acpi_table_revision_show(struct config_item *cfg, char *str) |
|---|
| 122 | +static ssize_t acpi_table_revision_show(struct config_item *cfg, char *str) |
|---|
| 126 | 123 | { |
|---|
| 127 | 124 | struct acpi_table_header *h = get_header(cfg); |
|---|
| 128 | 125 | |
|---|
| .. | .. |
|---|
| 132 | 129 | return sprintf(str, "%d\n", h->revision); |
|---|
| 133 | 130 | } |
|---|
| 134 | 131 | |
|---|
| 135 | | -ssize_t acpi_table_oem_id_show(struct config_item *cfg, char *str) |
|---|
| 132 | +static ssize_t acpi_table_oem_id_show(struct config_item *cfg, char *str) |
|---|
| 136 | 133 | { |
|---|
| 137 | 134 | struct acpi_table_header *h = get_header(cfg); |
|---|
| 138 | 135 | |
|---|
| .. | .. |
|---|
| 142 | 139 | return sprintf(str, "%.*s\n", ACPI_OEM_ID_SIZE, h->oem_id); |
|---|
| 143 | 140 | } |
|---|
| 144 | 141 | |
|---|
| 145 | | -ssize_t acpi_table_oem_table_id_show(struct config_item *cfg, char *str) |
|---|
| 142 | +static ssize_t acpi_table_oem_table_id_show(struct config_item *cfg, char *str) |
|---|
| 146 | 143 | { |
|---|
| 147 | 144 | struct acpi_table_header *h = get_header(cfg); |
|---|
| 148 | 145 | |
|---|
| .. | .. |
|---|
| 152 | 149 | return sprintf(str, "%.*s\n", ACPI_OEM_TABLE_ID_SIZE, h->oem_table_id); |
|---|
| 153 | 150 | } |
|---|
| 154 | 151 | |
|---|
| 155 | | -ssize_t acpi_table_oem_revision_show(struct config_item *cfg, char *str) |
|---|
| 152 | +static ssize_t acpi_table_oem_revision_show(struct config_item *cfg, char *str) |
|---|
| 156 | 153 | { |
|---|
| 157 | 154 | struct acpi_table_header *h = get_header(cfg); |
|---|
| 158 | 155 | |
|---|
| .. | .. |
|---|
| 162 | 159 | return sprintf(str, "%d\n", h->oem_revision); |
|---|
| 163 | 160 | } |
|---|
| 164 | 161 | |
|---|
| 165 | | -ssize_t acpi_table_asl_compiler_id_show(struct config_item *cfg, char *str) |
|---|
| 162 | +static ssize_t acpi_table_asl_compiler_id_show(struct config_item *cfg, |
|---|
| 163 | + char *str) |
|---|
| 166 | 164 | { |
|---|
| 167 | 165 | struct acpi_table_header *h = get_header(cfg); |
|---|
| 168 | 166 | |
|---|
| 169 | 167 | if (!h) |
|---|
| 170 | 168 | return -EINVAL; |
|---|
| 171 | 169 | |
|---|
| 172 | | - return sprintf(str, "%.*s\n", ACPI_NAME_SIZE, h->asl_compiler_id); |
|---|
| 170 | + return sprintf(str, "%.*s\n", ACPI_NAMESEG_SIZE, h->asl_compiler_id); |
|---|
| 173 | 171 | } |
|---|
| 174 | 172 | |
|---|
| 175 | | -ssize_t acpi_table_asl_compiler_revision_show(struct config_item *cfg, |
|---|
| 176 | | - char *str) |
|---|
| 173 | +static ssize_t acpi_table_asl_compiler_revision_show(struct config_item *cfg, |
|---|
| 174 | + char *str) |
|---|
| 177 | 175 | { |
|---|
| 178 | 176 | struct acpi_table_header *h = get_header(cfg); |
|---|
| 179 | 177 | |
|---|
| .. | .. |
|---|
| 192 | 190 | CONFIGFS_ATTR_RO(acpi_table_, asl_compiler_id); |
|---|
| 193 | 191 | CONFIGFS_ATTR_RO(acpi_table_, asl_compiler_revision); |
|---|
| 194 | 192 | |
|---|
| 195 | | -struct configfs_attribute *acpi_table_attrs[] = { |
|---|
| 193 | +static struct configfs_attribute *acpi_table_attrs[] = { |
|---|
| 196 | 194 | &acpi_table_attr_signature, |
|---|
| 197 | 195 | &acpi_table_attr_length, |
|---|
| 198 | 196 | &acpi_table_attr_revision, |
|---|
| .. | .. |
|---|
| 229 | 227 | struct acpi_table *table = container_of(cfg, struct acpi_table, cfg); |
|---|
| 230 | 228 | |
|---|
| 231 | 229 | ACPI_INFO(("Host-directed Dynamic ACPI Table Unload")); |
|---|
| 232 | | - acpi_tb_unload_table(table->index); |
|---|
| 230 | + acpi_unload_table(table->index); |
|---|
| 231 | + config_item_put(cfg); |
|---|
| 233 | 232 | } |
|---|
| 234 | 233 | |
|---|
| 235 | | -struct configfs_group_operations acpi_table_group_ops = { |
|---|
| 234 | +static struct configfs_group_operations acpi_table_group_ops = { |
|---|
| 236 | 235 | .make_item = acpi_table_make_item, |
|---|
| 237 | 236 | .drop_item = acpi_table_drop_item, |
|---|
| 238 | 237 | }; |
|---|