linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Renninger <trenn@suse.de>
To: hpa@zytor.com
Cc: lenb@kernel.org, initramfs@vger.kernel.org,
	robert.moore@intel.com, linux-kernel@vger.kernel.org,
	linux-acpi@vger.kernel.org, yinghai@kernel.org,
	Thomas Renninger <trenn@suse.de>
Subject: [PATCH 4/6] ACPI: Implement physical address table override
Date: Tue, 25 Sep 2012 16:55:59 +0200	[thread overview]
Message-ID: <1348584961-1476-5-git-send-email-trenn@suse.de> (raw)
In-Reply-To: <1348584961-1476-1-git-send-email-trenn@suse.de>

Previous patches stored ACPI tables provided via initrd in a memblock reserved
area.
If a table is loaded and the table type of an initrd provided one matches,
the one from initrd is prefered.
In case of a SSDT table, the OEM table id also has to match.

ACPI tables can be loaded at boot time (static table pointers in XSDT),
but also dynamically any time later via ASL commands load() or loadTable().
The override mechanism always works.


Signed-off-by: Thomas Renninger <trenn@suse.de>
---
 drivers/acpi/osl.c |   60 ++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 56 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index b20b079..007224b 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -681,12 +681,64 @@ acpi_os_table_override(struct acpi_table_header * existing_table,
 
 acpi_status
 acpi_os_physical_table_override(struct acpi_table_header *existing_table,
-				acpi_physical_address * new_address,
-				u32 *new_table_length)
+				acpi_physical_address *address,
+				u32 *table_length)
 {
-	return AE_SUPPORT;
-}
+#ifndef CONFIG_ACPI_INITRD_TABLE_OVERRIDE
+	*table_length = 0;
+	*address = 0;
+	return AE_OK;
+#else
+	int 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;
+
+		if (memcmp(existing_table->signature, table->signature, 4)) {
+			acpi_os_unmap_memory(table,
+				     ACPI_HEADER_SIZE);
+			continue;
+		}
+
+		/* Only override tables with matching oem id */
+		if (memcmp(table->oem_table_id, existing_table->oem_table_id,
+			   ACPI_OEM_TABLE_ID_SIZE)) {
+			acpi_os_unmap_memory(table,
+				     ACPI_HEADER_SIZE);
+			continue;
+		}
+
+		table_offset -= table->length;
+		*table_length = table->length;
+		acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
+		*address = acpi_tables_addr + table_offset;
+		break;
+	} while (table_offset + ACPI_HEADER_SIZE < all_tables_size);
+
+	return AE_OK;
+#endif
+}
 
 static irqreturn_t acpi_irq(int irq, void *dev_id)
 {
-- 
1.7.6.1


  parent reply	other threads:[~2012-09-25 14:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-25 14:55 [RESEND] Early cpio decoder and ACPI table override via initrd making use of it Thomas Renninger
     [not found] ` <1348584961-1476-1-git-send-email-trenn-l3A5Bk7waGM@public.gmane.org>
2012-09-25 14:55   ` [PATCH 1/6] lib: Add early cpio decoder Thomas Renninger
2012-09-25 14:55 ` [PATCH 2/6] X86 ACPI: Introduce x86 arch specific arch_reserve_mem_area() for e820 handling Thomas Renninger
2012-09-25 15:12   ` Thomas Renninger
2012-10-05 22:05     ` [PATCH] X86 ACPI: Use #ifdef not #if for CONFIG_X86 check Luck, Tony
2012-09-25 14:55 ` [PATCH 3/6] ACPI: Store valid ACPI tables passed via early initrd in reserved memblock areas Thomas Renninger
     [not found]   ` <1348584961-1476-4-git-send-email-trenn-l3A5Bk7waGM@public.gmane.org>
2012-09-25 15:15     ` H. Peter Anvin
2012-09-25 14:55 ` Thomas Renninger [this message]
2012-09-25 14:56 ` [PATCH 5/6] ACPI: Create acpi_table_taint() function to avoid code duplication Thomas Renninger
2012-09-25 14:56 ` [PATCH 6/6] ACPI: Document ACPI table overriding via initrd 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=1348584961-1476-5-git-send-email-trenn@suse.de \
    --to=trenn@suse.de \
    --cc=hpa@zytor.com \
    --cc=initramfs@vger.kernel.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robert.moore@intel.com \
    --cc=yinghai@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;
as well as URLs for NNTP newsgroup(s).