diff mbox

[BUG,bisected] : apei_hest_parse explosion

Message ID 5350252.GArARx6b7p@vostro.rjw.lan (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Rafael Wysocki Feb. 22, 2013, 12:30 p.m. UTC
On Friday, February 22, 2013 09:22:15 AM Thomas Gleixner wrote:
> On Fri, 22 Feb 2013, Rafael J. Wysocki wrote:
> > On Friday, February 22, 2013 02:40:58 AM Rafael J. Wysocki wrote:
> > > It looks like the hest_tab memory mapping is unmapped between acpi_hest_init()
> > > and aer_acpi_firmware_first(), but I have no idea what may be responsible for
> > > that.
> > > 
> > > And the only relevant difference between now and before the commit above seems
> > > to be the change of the acpi_hest_init() ordering (which now is called earlier).
> > 
> > We actually don't really need to do that thing so early, I think.  It looks like
> > we only need to make it available early enough for the AER driver to be able to
> > use it, so I wonder if moving the acpi_hest_init() to a separate
> > subsys_initcall() will work around the problem.  That is, something like the
> > patch below.
> 
> Yes, that makes the machine boot.

Although for a reason I didn't think about.

> > But even if this helps, I will be wanting to understand what's up here.
> 
> It's very simple. I have "acpi=off" on the command line. With that
> acpi_hest_init is never called, so hest_disable is not set .....

Well, that explains things (and means that acpi=off doesn't really get much
test coverage these days).

> Brilliant stuff that.

The appended patch should fix the breakage too, can you please verify?

Rafael


---
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Subject: ACPI / APEI: Fix crash in apei_hest_parse() for acpi=off

After commit 92ef2a2 (ACPI: Change the ordering of PCI root bridge
driver registrarion), acpi_hest_init() is never called for acpi=off
(acpi_disabled), so hest_disable is not set, but hest_tab is NULL,
which causes apei_hest_parse() to crash when it is called from
aer_acpi_firmware_first().

Fix that by making apei_hest_parse() check if hest_tab is not NULL
in addition to checking hest_disable.  Also remove the now useless
acpi_disabled check from apei_hest_parse().

Reported-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/apei/hest.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Thomas Gleixner Feb. 22, 2013, 2:39 p.m. UTC | #1
On Fri, 22 Feb 2013, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Subject: ACPI / APEI: Fix crash in apei_hest_parse() for acpi=off
> 
> After commit 92ef2a2 (ACPI: Change the ordering of PCI root bridge
> driver registrarion), acpi_hest_init() is never called for acpi=off
> (acpi_disabled), so hest_disable is not set, but hest_tab is NULL,
> which causes apei_hest_parse() to crash when it is called from
> aer_acpi_firmware_first().
> 
> Fix that by making apei_hest_parse() check if hest_tab is not NULL
> in addition to checking hest_disable.  Also remove the now useless
> acpi_disabled check from apei_hest_parse().
> 
> Reported-by: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Tested-by: Thomas Gleixner <tglx@linutronix.de>
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rafael Wysocki Feb. 22, 2013, 9 p.m. UTC | #2
On Friday, February 22, 2013 03:39:44 PM Thomas Gleixner wrote:
> On Fri, 22 Feb 2013, Rafael J. Wysocki wrote:
> > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > Subject: ACPI / APEI: Fix crash in apei_hest_parse() for acpi=off
> > 
> > After commit 92ef2a2 (ACPI: Change the ordering of PCI root bridge
> > driver registrarion), acpi_hest_init() is never called for acpi=off
> > (acpi_disabled), so hest_disable is not set, but hest_tab is NULL,
> > which causes apei_hest_parse() to crash when it is called from
> > aer_acpi_firmware_first().
> > 
> > Fix that by making apei_hest_parse() check if hest_tab is not NULL
> > in addition to checking hest_disable.  Also remove the now useless
> > acpi_disabled check from apei_hest_parse().
> > 
> > Reported-by: Thomas Gleixner <tglx@linutronix.de>
> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> Tested-by: Thomas Gleixner <tglx@linutronix.de>

Thanks!

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Yinghai Lu Feb. 22, 2013, 11:46 p.m. UTC | #3
On Fri, Feb 22, 2013 at 4:30 AM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> On Friday, February 22, 2013 09:22:15 AM Thomas Gleixner wrote:
>> On Fri, 22 Feb 2013, Rafael J. Wysocki wrote:
>> > On Friday, February 22, 2013 02:40:58 AM Rafael J. Wysocki wrote:
>> > > It looks like the hest_tab memory mapping is unmapped between acpi_hest_init()
>> > > and aer_acpi_firmware_first(), but I have no idea what may be responsible for
>> > > that.
>> > >
>> > > And the only relevant difference between now and before the commit above seems
>> > > to be the change of the acpi_hest_init() ordering (which now is called earlier).
>> >
>> > We actually don't really need to do that thing so early, I think.  It looks like
>> > we only need to make it available early enough for the AER driver to be able to
>> > use it, so I wonder if moving the acpi_hest_init() to a separate
>> > subsys_initcall() will work around the problem.  That is, something like the
>> > patch below.
>>
>> Yes, that makes the machine boot.
>
> Although for a reason I didn't think about.
>
>> > But even if this helps, I will be wanting to understand what's up here.
>>
>> It's very simple. I have "acpi=off" on the command line. With that
>> acpi_hest_init is never called, so hest_disable is not set .....
>
> Well, that explains things (and means that acpi=off doesn't really get much
> test coverage these days).
>
>> Brilliant stuff that.
>
> The appended patch should fix the breakage too, can you please verify?
>
> Rafael
>
>
> ---
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Subject: ACPI / APEI: Fix crash in apei_hest_parse() for acpi=off
>
> After commit 92ef2a2 (ACPI: Change the ordering of PCI root bridge
> driver registrarion), acpi_hest_init() is never called for acpi=off
> (acpi_disabled), so hest_disable is not set, but hest_tab is NULL,
> which causes apei_hest_parse() to crash when it is called from
> aer_acpi_firmware_first().
>
> Fix that by making apei_hest_parse() check if hest_tab is not NULL
> in addition to checking hest_disable.  Also remove the now useless
> acpi_disabled check from apei_hest_parse().
>
> Reported-by: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>  drivers/acpi/apei/hest.c |    5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> Index: test/drivers/acpi/apei/hest.c
> ===================================================================
> --- test.orig/drivers/acpi/apei/hest.c
> +++ test/drivers/acpi/apei/hest.c
> @@ -89,7 +89,7 @@ int apei_hest_parse(apei_hest_func_t fun
>         struct acpi_hest_header *hest_hdr;
>         int i, rc, len;
>
> -       if (hest_disable)
> +       if (hest_disable || !hest_tab)
>                 return -EINVAL;
>
>         hest_hdr = (struct acpi_hest_header *)(hest_tab + 1);
> @@ -216,9 +216,6 @@ void __init acpi_hest_init(void)
>                 return;
>         }
>
> -       if (acpi_disabled)
> -               goto err;
> -
>         status = acpi_get_table(ACPI_SIG_HEST, 0,
>                                 (struct acpi_table_header **)&hest_tab);
>         if (status == AE_NOT_FOUND)
>

Acked-by: Yinghai Lu <yinghai@kernel.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

Index: test/drivers/acpi/apei/hest.c
===================================================================
--- test.orig/drivers/acpi/apei/hest.c
+++ test/drivers/acpi/apei/hest.c
@@ -89,7 +89,7 @@  int apei_hest_parse(apei_hest_func_t fun
 	struct acpi_hest_header *hest_hdr;
 	int i, rc, len;
 
-	if (hest_disable)
+	if (hest_disable || !hest_tab)
 		return -EINVAL;
 
 	hest_hdr = (struct acpi_hest_header *)(hest_tab + 1);
@@ -216,9 +216,6 @@  void __init acpi_hest_init(void)
 		return;
 	}
 
-	if (acpi_disabled)
-		goto err;
-
 	status = acpi_get_table(ACPI_SIG_HEST, 0,
 				(struct acpi_table_header **)&hest_tab);
 	if (status == AE_NOT_FOUND)