All of lore.kernel.org
 help / color / mirror / Atom feed
From: Akio Takebe <takebe_akio@jp.fujitsu.com>
To: Akio Takebe <takebe_akio@jp.fujitsu.com>,
	xen-devel <xen-devel@lists.xensource.com>,
	xen-ia64-devel <xen-ia64-devel@lists.xensource.com>
Cc: Keir Fraser <Keir.Fraser@cl.cam.ac.uk>,
	Alex Williamson <alex.williamson@hp.com>
Subject: Re: [Xen-devel] [Patch 0/3] Disable ACPI SRAT, SLIT on dom0 <take 3>
Date: Mon, 30 Jul 2007 07:58:40 +0900	[thread overview]
Message-ID: <9EC7D234010038takebe_akio@jp.fujitsu.com> (raw)
In-Reply-To: <9CC7D2331E8597takebe_akio@jp.fujitsu.com>

[-- Attachment #1: Mail message body --]
[-- Type: text/plain, Size: 215 bytes --]

Hi,

Add acpi_table_disable() into xen/drivers/acpi/tables.c
This function can disable a ACPI table by updating the table header.

Signed-off-by: Akio Takebe <takebe_akio@jp.fujitsu.com>

Best Regards,

Akio Takebe

[-- Attachment #2: add_acpi_table_disable.v3.patch --]
[-- Type: application/octet-stream, Size: 13319 bytes --]

# HG changeset patch
# User root@localhost.localdomain
# Date 1185747642 -32400
# Node ID e9def100a760f032c78c635f4d792a8432db1a97
# Parent  7e81d7ec1bb9d5cb32332011d2c3eb27d70c635b
Add acpi_table_disable() into xen/drivers/acpi/tables.c
This function can disable a ACPI table by updating the table header.

Signed-off-by: Akio Takebe <takebe_akio@jp.fujitsu.com>

diff -r 7e81d7ec1bb9 -r e9def100a760 xen/drivers/acpi/tables.c
--- a/xen/drivers/acpi/tables.c	Mon Jul 30 07:17:24 2007 +0900
+++ b/xen/drivers/acpi/tables.c	Mon Jul 30 07:20:42 2007 +0900
@@ -73,6 +73,7 @@ struct acpi_table_sdt {
 
 static unsigned long sdt_pa;	/* Physical Address */
 static unsigned long sdt_count;	/* Table count */
+static struct acpi_table_rsdp *rsdp;
 unsigned char acpi_rsdp_rev;
 
 static struct acpi_table_sdt sdt_entry[ACPI_MAX_TABLES] __initdata;
@@ -389,34 +390,11 @@ acpi_table_parse_madt(enum acpi_madt_ent
 					    handler, max_entries);
 }
 
-int __init acpi_table_parse(enum acpi_table_id id, acpi_table_handler handler)
-{
-	int count = 0;
-	unsigned int i = 0;
-
-	if (!handler)
-		return -EINVAL;
-
-	for (i = 0; i < sdt_count; i++) {
-		if (sdt_entry[i].id != id)
-			continue;
-		count++;
-		if (count == 1)
-			handler(sdt_entry[i].pa, sdt_entry[i].size);
-
-		else
-			printk(KERN_WARNING PREFIX
-			       "%d duplicate %s table ignored.\n", count,
-			       acpi_table_signatures[id]);
-	}
-
-	return count;
-}
-
-static int __init acpi_table_get_sdt(struct acpi_table_rsdp *rsdp)
+
+static int __init
+__acpi_table_disable(struct acpi_table_rsdp *rsdp, int table_id, char *table_name)
 {
 	struct acpi_table_header *header = NULL;
-	unsigned int i, id = 0;
 
 	if (!rsdp)
 		return -EINVAL;
@@ -460,17 +438,15 @@ static int __init acpi_table_get_sdt(str
 			return -ENODEV;
 		}
 
-		sdt_count =
-		    (header->length - sizeof(struct acpi_table_header)) >> 3;
-		if (sdt_count > ACPI_MAX_TABLES) {
-			printk(KERN_WARNING PREFIX
-			       "Truncated %lu XSDT entries\n",
-			       (sdt_count - ACPI_MAX_TABLES));
-			sdt_count = ACPI_MAX_TABLES;
-		}
-
-		for (i = 0; i < sdt_count; i++)
-			sdt_entry[i].pa = (unsigned long)mapped_xsdt->entry[i];
+		if (table_id < sdt_count){
+			header = (struct acpi_table_header *)
+			   __acpi_map_table(mapped_xsdt->entry[table_id], sizeof(struct acpi_table_header));
+		} else {
+			printk(KERN_WARNING PREFIX
+			       "Unable to disable entry %d\n",
+			       table_id);
+			return -ENODEV;
+		}
 	}
 
 	/* Then check RSDT */
@@ -509,18 +485,15 @@ static int __init acpi_table_get_sdt(str
 			printk(KERN_WARNING PREFIX "Invalid RSDT checksum\n");
 			return -ENODEV;
 		}
-
-		sdt_count =
-		    (header->length - sizeof(struct acpi_table_header)) >> 2;
-		if (sdt_count > ACPI_MAX_TABLES) {
-			printk(KERN_WARNING PREFIX
-			       "Truncated %lu RSDT entries\n",
-			       (sdt_count - ACPI_MAX_TABLES));
-			sdt_count = ACPI_MAX_TABLES;
-		}
-
-		for (i = 0; i < sdt_count; i++)
-			sdt_entry[i].pa = (unsigned long)mapped_rsdt->entry[i];
+		if (table_id < sdt_count){
+			header = (struct acpi_table_header *)
+			   __acpi_map_table(mapped_rsdt->entry[table_id], sizeof(struct acpi_table_header));
+		} else {
+			printk(KERN_WARNING PREFIX
+			       "Unable to disable entry %d\n",
+			       table_id);
+			return -ENODEV;
+		}
 	}
 
 	else {
@@ -529,88 +502,26 @@ static int __init acpi_table_get_sdt(str
 		return -ENODEV;
 	}
 
-	acpi_table_print(header, sdt_pa);
-
-	for (i = 0; i < sdt_count; i++) {
-
-		/* map in just the header */
-		header = (struct acpi_table_header *)
-		    __acpi_map_table(sdt_entry[i].pa,
-				     sizeof(struct acpi_table_header));
-		if (!header)
-			continue;
-
-		/* remap in the entire table before processing */
-		header = (struct acpi_table_header *)
-		    __acpi_map_table(sdt_entry[i].pa, header->length);
-		if (!header)
-			continue;
-
-		acpi_table_print(header, sdt_entry[i].pa);
-
-		if (acpi_table_compute_checksum(header, header->length)) {
-			printk(KERN_WARNING "  >>> ERROR: Invalid checksum\n");
-			continue;
-		}
-
-		sdt_entry[i].size = header->length;
-
-		for (id = 0; id < ACPI_TABLE_COUNT; id++) {
-			if (!strncmp((char *)&header->signature,
-				     acpi_table_signatures[id],
-				     sizeof(header->signature))) {
-				sdt_entry[i].id = id;
-			}
-		}
-	}
-
-	/* 
-	 * The DSDT is *not* in the RSDT (why not? no idea.) but we want
-	 * to print its info, because this is what people usually blacklist
-	 * against. Unfortunately, we don't know the phys_addr, so just
-	 * print 0. Maybe no one will notice.
-	 */
-	if (!acpi_get_table_header_early(ACPI_DSDT, &header))
-		acpi_table_print(header, 0);
+	memcpy(header->signature, "OEMx", 4);
+	memcpy(header->oem_id, "xxxxxx", 6);
+	memcpy(header->oem_id+1, table_name, 4);
+	memcpy(header->oem_table_id, "Xen     ", 8);
+	header->checksum = 0;
+	header->checksum = generate_acpi_checksum(header, header->length);
 
 	return 0;
 }
 
-/*
- * acpi_table_init()
- *
- * find RSDP, find and checksum SDT/XSDT.
- * checksum all tables, print SDT/XSDT
- * 
- * result: sdt_entry[] is initialized
- */
-
-int __init acpi_table_init(void)
-{
-	struct acpi_table_rsdp *rsdp = NULL;
-	unsigned long rsdp_phys = 0;
+int __init
+acpi_table_disable(enum acpi_table_id table_id)
+{
 	int result = 0;
-
-	/* Locate and map the Root System Description Table (RSDP) */
-
-	rsdp_phys = acpi_find_rsdp();
-	if (!rsdp_phys) {
-		printk(KERN_ERR PREFIX "Unable to locate RSDP\n");
-		return -ENODEV;
-	}
-
-	rsdp = (struct acpi_table_rsdp *)__acpi_map_table(rsdp_phys,
-		sizeof(struct acpi_table_rsdp));
+	int i, id = 0;
+
 	if (!rsdp) {
-		printk(KERN_WARNING PREFIX "Unable to map RSDP\n");
-		return -ENODEV;
-	}
-
-	printk(KERN_DEBUG PREFIX
-	       "RSDP (v%3.3d %6.6s                                ) @ 0x%p\n",
-	       rsdp->revision, rsdp->oem_id, (void *)rsdp_phys);
-
-	acpi_rsdp_rev = rsdp->revision;
+		printk(KERN_WARNING PREFIX "%s: Unable to map RSDP\n", __func__);
+		return -ENODEV;
+	}
 
 	if (rsdp->revision < 2)
 		result =
@@ -623,6 +534,262 @@ int __init acpi_table_init(void)
 						 rsdp)->length);
 
 	if (result) {
+		printk(KERN_WARNING "%s: ERROR: Invalid RSDP checksum\n", __func__);
+		return -ENODEV;
+	}
+
+
+	/* search entry id of table_id */
+	for (i = 0; i < sdt_count; i++) {
+		if (sdt_entry[i].id == table_id)
+			id = i;		
+	}
+
+	if (!id){
+		printk(KERN_WARNING PREFIX 
+		       "%s: Unable to find the table(%s)\n",
+		       __func__, acpi_table_signatures[table_id]);
+		return -ENOENT;
+	}
+
+	return __acpi_table_disable(rsdp, id, acpi_table_signatures[table_id]);
+}
+
+ 
+int __init acpi_table_parse(enum acpi_table_id id, acpi_table_handler handler)
+{
+	int count = 0;
+	unsigned int i = 0;
+
+	if (!handler)
+		return -EINVAL;
+
+	for (i = 0; i < sdt_count; i++) {
+		if (sdt_entry[i].id != id)
+			continue;
+		count++;
+		if (count == 1)
+			handler(sdt_entry[i].pa, sdt_entry[i].size);
+
+		else
+			printk(KERN_WARNING PREFIX
+			       "%d duplicate %s table ignored.\n", count,
+			       acpi_table_signatures[id]);
+	}
+
+	return count;
+}
+
+static int __init acpi_table_get_sdt(struct acpi_table_rsdp *rsdp)
+{
+	struct acpi_table_header *header = NULL;
+	unsigned int i, id = 0;
+
+	if (!rsdp)
+		return -EINVAL;
+
+	/* First check XSDT (but only on ACPI 2.0-compatible systems) */
+
+	if ((rsdp->revision >= 2) &&
+	    (((struct acpi20_table_rsdp *)rsdp)->xsdt_address)) {
+
+		struct acpi_table_xsdt *mapped_xsdt = NULL;
+
+		sdt_pa = ((struct acpi20_table_rsdp *)rsdp)->xsdt_address;
+
+		/* map in just the header */
+		header = (struct acpi_table_header *)
+		    __acpi_map_table(sdt_pa, sizeof(struct acpi_table_header));
+
+		if (!header) {
+			printk(KERN_WARNING PREFIX
+			       "Unable to map XSDT header\n");
+			return -ENODEV;
+		}
+
+		/* remap in the entire table before processing */
+		mapped_xsdt = (struct acpi_table_xsdt *)
+		    __acpi_map_table(sdt_pa, header->length);
+		if (!mapped_xsdt) {
+			printk(KERN_WARNING PREFIX "Unable to map XSDT\n");
+			return -ENODEV;
+		}
+		header = &mapped_xsdt->header;
+
+		if (strncmp(header->signature, "XSDT", 4)) {
+			printk(KERN_WARNING PREFIX
+			       "XSDT signature incorrect\n");
+			return -ENODEV;
+		}
+
+		if (acpi_table_compute_checksum(header, header->length)) {
+			printk(KERN_WARNING PREFIX "Invalid XSDT checksum\n");
+			return -ENODEV;
+		}
+
+		sdt_count =
+		    (header->length - sizeof(struct acpi_table_header)) >> 3;
+		if (sdt_count > ACPI_MAX_TABLES) {
+			printk(KERN_WARNING PREFIX
+			       "Truncated %lu XSDT entries\n",
+			       (sdt_count - ACPI_MAX_TABLES));
+			sdt_count = ACPI_MAX_TABLES;
+		}
+
+		for (i = 0; i < sdt_count; i++)
+			sdt_entry[i].pa = (unsigned long)mapped_xsdt->entry[i];
+	}
+
+	/* Then check RSDT */
+
+	else if (rsdp->rsdt_address) {
+
+		struct acpi_table_rsdt *mapped_rsdt = NULL;
+
+		sdt_pa = rsdp->rsdt_address;
+
+		/* map in just the header */
+		header = (struct acpi_table_header *)
+		    __acpi_map_table(sdt_pa, sizeof(struct acpi_table_header));
+		if (!header) {
+			printk(KERN_WARNING PREFIX
+			       "Unable to map RSDT header\n");
+			return -ENODEV;
+		}
+
+		/* remap in the entire table before processing */
+		mapped_rsdt = (struct acpi_table_rsdt *)
+		    __acpi_map_table(sdt_pa, header->length);
+		if (!mapped_rsdt) {
+			printk(KERN_WARNING PREFIX "Unable to map RSDT\n");
+			return -ENODEV;
+		}
+		header = &mapped_rsdt->header;
+
+		if (strncmp(header->signature, "RSDT", 4)) {
+			printk(KERN_WARNING PREFIX
+			       "RSDT signature incorrect\n");
+			return -ENODEV;
+		}
+
+		if (acpi_table_compute_checksum(header, header->length)) {
+			printk(KERN_WARNING PREFIX "Invalid RSDT checksum\n");
+			return -ENODEV;
+		}
+
+		sdt_count =
+		    (header->length - sizeof(struct acpi_table_header)) >> 2;
+		if (sdt_count > ACPI_MAX_TABLES) {
+			printk(KERN_WARNING PREFIX
+			       "Truncated %lu RSDT entries\n",
+			       (sdt_count - ACPI_MAX_TABLES));
+			sdt_count = ACPI_MAX_TABLES;
+		}
+
+		for (i = 0; i < sdt_count; i++)
+			sdt_entry[i].pa = (unsigned long)mapped_rsdt->entry[i];
+	}
+
+	else {
+		printk(KERN_WARNING PREFIX
+		       "No System Description Table (RSDT/XSDT) specified in RSDP\n");
+		return -ENODEV;
+	}
+
+	acpi_table_print(header, sdt_pa);
+
+	for (i = 0; i < sdt_count; i++) {
+
+		/* map in just the header */
+		header = (struct acpi_table_header *)
+		    __acpi_map_table(sdt_entry[i].pa,
+				     sizeof(struct acpi_table_header));
+		if (!header)
+			continue;
+
+		/* remap in the entire table before processing */
+		header = (struct acpi_table_header *)
+		    __acpi_map_table(sdt_entry[i].pa, header->length);
+		if (!header)
+			continue;
+
+		acpi_table_print(header, sdt_entry[i].pa);
+
+		if (acpi_table_compute_checksum(header, header->length)) {
+			printk(KERN_WARNING "  >>> ERROR: Invalid checksum\n");
+			continue;
+		}
+
+		sdt_entry[i].size = header->length;
+
+		for (id = 0; id < ACPI_TABLE_COUNT; id++) {
+			if (!strncmp((char *)&header->signature,
+				     acpi_table_signatures[id],
+				     sizeof(header->signature))) {
+				sdt_entry[i].id = id;
+			}
+		}
+	}
+
+	/* 
+	 * The DSDT is *not* in the RSDT (why not? no idea.) but we want
+	 * to print its info, because this is what people usually blacklist
+	 * against. Unfortunately, we don't know the phys_addr, so just
+	 * print 0. Maybe no one will notice.
+	 */
+	if (!acpi_get_table_header_early(ACPI_DSDT, &header))
+		acpi_table_print(header, 0);
+
+	return 0;
+}
+
+/*
+ * acpi_table_init()
+ *
+ * find RSDP, find and checksum SDT/XSDT.
+ * checksum all tables, print SDT/XSDT
+ * 
+ * result: sdt_entry[] is initialized
+ */
+
+int __init acpi_table_init(void)
+{
+	unsigned long rsdp_phys = 0;
+	int result = 0;
+	rsdp = NULL;
+
+	/* Locate and map the Root System Description Table (RSDP) */
+
+	rsdp_phys = acpi_find_rsdp();
+	if (!rsdp_phys) {
+		printk(KERN_ERR PREFIX "Unable to locate RSDP\n");
+		return -ENODEV;
+	}
+
+	rsdp = (struct acpi_table_rsdp *)__acpi_map_table(rsdp_phys,
+		sizeof(struct acpi_table_rsdp));
+	if (!rsdp) {
+		printk(KERN_WARNING PREFIX "Unable to map RSDP\n");
+		return -ENODEV;
+	}
+
+	printk(KERN_DEBUG PREFIX
+	       "RSDP (v%3.3d %6.6s                                ) @ 0x%p\n",
+	       rsdp->revision, rsdp->oem_id, (void *)rsdp_phys);
+
+	acpi_rsdp_rev = rsdp->revision;
+
+	if (rsdp->revision < 2)
+		result =
+		    acpi_table_compute_checksum(rsdp,
+						sizeof(struct acpi_table_rsdp));
+	else
+		result =
+		    acpi_table_compute_checksum(rsdp,
+						((struct acpi20_table_rsdp *)
+						 rsdp)->length);
+
+	if (result) {
 		printk(KERN_WARNING "  >>> ERROR: Invalid checksum\n");
 		return -ENODEV;
 	}
diff -r 7e81d7ec1bb9 -r e9def100a760 xen/include/xen/acpi.h
--- a/xen/include/xen/acpi.h	Mon Jul 30 07:17:24 2007 +0900
+++ b/xen/include/xen/acpi.h	Mon Jul 30 07:20:42 2007 +0900
@@ -383,6 +383,7 @@ int acpi_numa_init (void);
 int acpi_numa_init (void);
 
 int acpi_table_init (void);
+int acpi_table_disable(enum acpi_table_id table_id);
 int acpi_table_parse (enum acpi_table_id id, acpi_table_handler handler);
 int acpi_get_table_header_early (enum acpi_table_id id, struct acpi_table_header **header);
 int acpi_table_parse_madt (enum acpi_madt_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries);

[-- Attachment #3: Type: text/plain, Size: 152 bytes --]

_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@lists.xensource.com
http://lists.xensource.com/xen-ia64-devel

  parent reply	other threads:[~2007-07-29 22:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-29 22:52 [Patch 0/3] Disable ACPI SRAT, SLIT on dom0 <take 3> Akio Takebe
2007-07-29 22:56 ` Akio Takebe
2007-07-30 15:31   ` [Xen-ia64-devel] " Alex Williamson
2007-07-29 22:58 ` Akio Takebe [this message]
2007-07-29 23:00 ` [Xen-devel] " Akio Takebe

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=9EC7D234010038takebe_akio@jp.fujitsu.com \
    --to=takebe_akio@jp.fujitsu.com \
    --cc=Keir.Fraser@cl.cam.ac.uk \
    --cc=alex.williamson@hp.com \
    --cc=xen-devel@lists.xensource.com \
    --cc=xen-ia64-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.