From: Thomas Renninger <trenn@suse.de>
To: unlisted-recipients:; (no To-header on input)
Cc: hpa@zytor.com, linux-kernel@vger.kernel.org, x86@kernel.org,
devel@acpica.org, mingo@redhat.com, ck@conrad-kostecki.de,
tglx@linutronix.de, trenn@suse.de, rjw@rjwysocki.net
Subject: [PATCH 1/4] ACPI: Provide support for ACPI table adding via OS
Date: Tue, 18 Feb 2014 19:22:40 +0100 [thread overview]
Message-ID: <1392747763-3384-2-git-send-email-trenn@suse.de> (raw)
In-Reply-To: <1392747763-3384-1-git-send-email-trenn@suse.de>
This is done the same way as the previous ACPI physical table override
mechanism.
How to override or add tables via initrd, please look up:
Documentation/acpi/initrd_table_override.txt
SSDTs can only be overridden, not added.
Overriding only happens if the OEM id of the table header matches the one
with the BIOS provided one.
All table types (SSDTs are an exception), must only show up once.
So either you:
- Add a fresh new table for adding of which type (signature) none exists
in the BIOS -> OS ACPI table adding happens.
or
- Add a table which already exists in BIOS, but the OEM id must match the
one of the table of the same type (signature) that exists in BIOS already
-> OS ACPI table overriding happens
Typically one copies away the original ACPI table, disassembles,
modifies (for example adding debug strings), compiles it and provides
the table via initrd for overriding (will have the same OEM id).
But this is not necessary, one could also come up with a selfmade
table for overriding, by taking care that the signature and OEM id is
the same as the one provided by BIOS
In ACPI table overriding case you see in dmesg:
ACPI: Override [DSDT- BXDSDT], this is unsafe: tainting kernel
Disabling lock debugging due to kernel taint
In ACPI table adding case you see in dmesg (BGRT table got added):
ACPI: Add [BGRT-SLIC-WKS], this is unsafe: tainting kernel
ACPI: BGRT 000000007fffd1ba 000038 (v00 HPQOEM SLIC-WKS 01072009
INTL 20130823)
Signed-off-by: Thomas Renninger <trenn@suse.de>
CC: hpa@zytor.com
CC: tglx@linutronix.de
CC: ck@conrad-kostecki.de
CC: linux-kernel@vger.kernel.org
CC: x86@kernel.org
CC: mingo@redhat.com
CC: rjw@rjwysocki.net
CC: devel@acpica.org
---
drivers/acpi/osl.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 88 insertions(+), 1 deletions(-)
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index fc1aa79..07439b4 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -566,6 +566,8 @@ static const char * const table_sigs[] = {
#define ACPI_OVERRIDE_TABLES 64
static struct cpio_data __initdata acpi_initrd_files[ACPI_OVERRIDE_TABLES];
+/* Remember physical address of overriden or added tables */
+static acpi_physical_address acpi_table_overridden[ACPI_OVERRIDE_TABLES];
#define MAP_CHUNK_SIZE (NR_FIX_BTMAPS << PAGE_SHIFT)
@@ -715,7 +717,7 @@ acpi_os_physical_table_override(struct acpi_table_header *existing_table,
*address = 0;
return AE_OK;
#else
- int table_offset = 0;
+ int no, table_offset = 0;
struct acpi_table_header *table;
*table_length = 0;
@@ -759,6 +761,12 @@ acpi_os_physical_table_override(struct acpi_table_header *existing_table,
*table_length = table->length;
acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
*address = acpi_tables_addr + table_offset;
+ for (no = 0; no < ACPI_OVERRIDE_TABLES; no++) {
+ if (acpi_table_overridden[no] == 0) {
+ acpi_table_overridden[no] = *address;
+ break;
+ }
+ }
break;
} while (table_offset + ACPI_HEADER_SIZE < all_tables_size);
@@ -768,6 +776,85 @@ acpi_os_physical_table_override(struct acpi_table_header *existing_table,
#endif
}
+acpi_status
+acpi_os_physical_table_add(acpi_physical_address *address,
+ u32 *table_length)
+{
+#ifndef CONFIG_ACPI_INITRD_TABLE_OVERRIDE
+ *table_length = 0;
+ *address = 0;
+ return AE_OK;
+#else
+ int no, table_offset = 0;
+ struct acpi_table_header *table;
+
+ *table_length = 0;
+ *address = 0;
+
+ if (!acpi_tables_addr)
+ return AE_OK;
+
+ do {
+ if (table_offset + ACPI_HEADER_SIZE > all_tables_size) {
+ WARN_ON(1);
+ return AE_OK;
+ }
+
+ table = acpi_os_map_memory(acpi_tables_addr + table_offset,
+ ACPI_HEADER_SIZE);
+
+ if (table_offset + table->length > all_tables_size) {
+ acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
+ WARN_ON(1);
+ return AE_OK;
+ }
+
+ table_offset += table->length;
+
+ /* Do not add SSDTs for now, they might be intended to get
+ overridden when an SSDT gets loaded dynamically in ACPI
+ context at any time later */
+ if (!memcmp("SSDT", table->signature, 4)) {
+ acpi_os_unmap_memory(table,
+ ACPI_HEADER_SIZE);
+ continue;
+ }
+
+ /* Only add tables that have not been overridden already */
+ for (no = 0; no < ACPI_OVERRIDE_TABLES; no++) {
+ if (acpi_table_overridden[no] == 0)
+ break;
+ if (acpi_table_overridden[no] ==
+ acpi_tables_addr + table_offset - table->length)
+ break;
+ }
+ /* All tables have been added or overridden */
+ if (acpi_table_overridden[no] != 0) {
+ acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
+ continue;
+ }
+ /* Max table override/add limit reached */
+ if (no == ACPI_OVERRIDE_TABLES) {
+ acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
+ return AE_ERROR;
+ }
+
+ table_offset -= table->length;
+ *table_length = table->length;
+ *address = acpi_tables_addr + table_offset;
+ /* do not add this table again */
+ acpi_table_overridden[no] = *address;
+ pr_warn(PREFIX
+ "Add [%4.4s-%8.8s], this is unsafe: tainting kernel\n",
+ table->signature, table->oem_table_id);
+ add_taint(TAINT_OVERRIDDEN_ACPI_TABLE, LOCKDEP_NOW_UNRELIABLE);
+ acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
+ return AE_OK;
+ } while (table_offset + ACPI_HEADER_SIZE < all_tables_size);
+ return AE_OK;
+#endif
+}
+
static irqreturn_t acpi_irq(int irq, void *dev_id)
{
u32 handled;
--
1.7.6.1
next prev parent reply other threads:[~2014-02-18 18:23 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-14 10:23 [PATCH] x86: HPET force enable for Soekris net6501 Conrad Kostecki
2014-02-14 17:46 ` H. Peter Anvin
2014-02-14 18:06 ` AW: " Conrad Kostecki
2014-02-14 18:08 ` H. Peter Anvin
2014-02-14 18:13 ` AW: " Conrad Kostecki
2014-02-14 18:16 ` H. Peter Anvin
2014-02-14 18:21 ` Thomas Gleixner
2014-02-14 18:22 ` H. Peter Anvin
2014-02-14 18:38 ` Thomas Gleixner
2014-02-14 18:39 ` H. Peter Anvin
2014-02-14 19:15 ` Thomas Gleixner
2014-02-14 19:26 ` H. Peter Anvin
2014-02-14 19:59 ` Thomas Gleixner
2014-02-14 20:06 ` H. Peter Anvin
2014-02-14 21:16 ` Thomas Gleixner
2014-02-14 21:18 ` H. Peter Anvin
2014-02-14 21:47 ` Thomas Gleixner
2014-02-14 21:48 ` H. Peter Anvin
2014-02-17 16:28 ` Thomas Renninger
2014-02-17 17:19 ` H. Peter Anvin
2014-02-17 18:23 ` Thomas Renninger
2014-02-17 18:47 ` H. Peter Anvin
2014-02-17 19:25 ` Thomas Renninger
2014-02-17 19:40 ` H. Peter Anvin
2014-02-18 18:22 ` ACPI: Also allow ACPI table adding via initrd not only overriding Thomas Renninger
2014-02-18 18:22 ` Thomas Renninger [this message]
2014-02-18 18:27 ` [PATCH 1/4] ACPI: Provide support for ACPI table adding via OS H. Peter Anvin
2014-02-18 18:44 ` Thomas Renninger
2014-02-18 20:51 ` H. Peter Anvin
2014-02-19 11:22 ` Thomas Renninger
2014-02-21 7:24 ` [Devel] " Zheng, Lv
2014-02-21 7:28 ` Zheng, Lv
2014-02-18 18:22 ` [PATCH 2/4] ACPICA: Introduce new acpi_os_physical_table_add OS callback Thomas Renninger
2014-02-18 18:22 ` [PATCH 3/4] ACPICA: Add BGRT signature to known signatures Thomas Renninger
2014-02-18 18:22 ` [PATCH 4/4] ACPI: Add new table signatures that can be overridden/added Thomas Renninger
2014-02-18 18:38 ` [Devel] ACPI: Also allow ACPI table adding via initrd not only overriding Moore, Robert
2014-02-18 18:52 ` Thomas Renninger
2014-02-18 19:59 ` Moore, Robert
2014-02-19 11:14 ` Thomas Renninger
2014-02-19 13:03 ` Thomas Gleixner
2014-02-14 18:28 ` AW: AW: AW: [PATCH] x86: HPET force enable for Soekris net6501 Conrad Kostecki
2014-09-09 13:56 ` Eric Sesterhenn
2014-09-09 14:54 ` Thomas Gleixner
2014-09-09 15:26 ` H. Peter Anvin
2014-09-09 15:41 ` Thomas Gleixner
2014-09-12 9:41 ` Eric Sesterhenn
2014-09-12 10:37 ` Thomas Gleixner
2014-09-12 11:06 ` [PATCH] x86: HPET force enable for e6xx based systems Eric Sesterhenn
2014-09-16 0:58 ` [tip:x86/platform] " tip-bot for Peter Neubauer
[not found] <1393608241-31037-1-git-send-email-trenn@suse.de>
2014-02-28 17:23 ` [PATCH 1/4] ACPI: Provide support for ACPI table adding via OS Thomas Renninger
2014-02-28 17:27 ` Thomas Renninger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1392747763-3384-2-git-send-email-trenn@suse.de \
--to=trenn@suse.de \
--cc=ck@conrad-kostecki.de \
--cc=devel@acpica.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rjw@rjwysocki.net \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®