From nobody@FreeBSD.org  Wed Mar 26 18:05:46 2014
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTPS id 5598222A
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 26 Mar 2014 18:05:46 +0000 (UTC)
Received: from cgiserv.freebsd.org (cgiserv.freebsd.org [IPv6:2001:1900:2254:206a::50:4])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client did not present a certificate)
	by mx1.freebsd.org (Postfix) with ESMTPS id 28ADC660
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 26 Mar 2014 18:05:46 +0000 (UTC)
Received: from cgiserv.freebsd.org ([127.0.1.6])
	by cgiserv.freebsd.org (8.14.8/8.14.8) with ESMTP id s2QI5kpk098233
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 26 Mar 2014 18:05:46 GMT
	(envelope-from nobody@cgiserv.freebsd.org)
Received: (from nobody@localhost)
	by cgiserv.freebsd.org (8.14.8/8.14.8/Submit) id s2QI5k0K098229;
	Wed, 26 Mar 2014 18:05:46 GMT
	(envelope-from nobody)
Message-Id: <201403261805.s2QI5k0K098229@cgiserv.freebsd.org>
Date: Wed, 26 Mar 2014 18:05:46 GMT
From: Takuya ASADA <syuu@freebsd.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Intel Baytrail-M NUC panics because of buggy ACPI table
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         187966
>Category:       amd64
>Synopsis:       Intel Baytrail-M NUC panics because of buggy ACPI table
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-amd64
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 26 18:10:01 UTC 2014
>Closed-Date:    Thu Mar 27 07:21:51 UTC 2014
>Last-Modified:  Thu Mar 27 07:21:51 UTC 2014
>Originator:     Takuya ASADA
>Release:        -CURRENT
>Organization:
Cloudius Systems
>Environment:
FreeBSD nuc 11.0-CURRENT FreeBSD 11.0-CURRENT #5 ff55131(master)-dirty: Thu Mar 27 09:05:10 JST 2014 root@nuc:/usr/obj/usr/home/syuu/freebsd/sys/GENERIC amd64
>Description:
Intel Baytrail-M NUC(DN2820FYKH) does not able to boot FreeBSD-CURRENT/amd64, because of its buggy ACPI table.

It has two incorrect parameters on MADT: 

Type=Local APIC NMI
ACPI CPU=1
LINT Pin=60
Flags={Polarity=active-hi, Trigger=0x2} <-- trigger value is incorrect. 2 is reserved

Type=Local APIC NMI
ACPI CPU=2
LINT Pin=61
Flags={Polarity=0x2, Trigger=level} <-- polarity value is incorrect. 2 is reserved

Because of this, interrupt_trigger() panics with "Bogus Interrupt Trigger Mode".
Also interrupt_polarity() panics with "Bogus Interrupt Polarity".

I think this is BIOS bug, but we can do some workaround for the machine.
>How-To-Repeat:
Boot -CURRENT on NUC.
>Fix:
Linux uses level trigger and low polarity if the value is 0x2(reserved).
http://lxr.linux.no/linux+v3.13.5/arch/x86/kernel/acpi/boot.c#L1094

We can do similar workaround, but with warning message.

Patch attached with submission follows:

diff --git a/sys/x86/acpica/madt.c b/sys/x86/acpica/madt.c
index 9dfb77f..fdc86c0 100644
--- a/sys/x86/acpica/madt.c
+++ b/sys/x86/acpica/madt.c
@@ -308,14 +308,15 @@ interrupt_polarity(UINT16 IntiFlags, UINT8 Source)
 	case ACPI_MADT_POLARITY_ACTIVE_LOW:
 		return (INTR_POLARITY_LOW);
 	default:
-		panic("Bogus Interrupt Polarity");
+		printf("Bogus Interrupt Polarity %x, set to low\n",
+			IntiFlags & ACPI_MADT_POLARITY_MASK);
+		return (INTR_POLARITY_LOW);
 	}
 }
 
 static enum intr_trigger
 interrupt_trigger(UINT16 IntiFlags, UINT8 Source)
 {
-
 	switch (IntiFlags & ACPI_MADT_TRIGGER_MASK) {
 	case ACPI_MADT_TRIGGER_CONFORMS:
 		if (Source == AcpiGbl_FADT.SciInterrupt)
@@ -327,7 +328,9 @@ interrupt_trigger(UINT16 IntiFlags, UINT8 Source)
 	case ACPI_MADT_TRIGGER_LEVEL:
 		return (INTR_TRIGGER_LEVEL);
 	default:
-		panic("Bogus Interrupt Trigger Mode");
+		printf("Bogus Interrupt Trigger Mode %x, set to level\n",
+			IntiFlags & ACPI_MADT_TRIGGER_MASK);
+		return (INTR_TRIGGER_LEVEL);
 	}
 }
 


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed  
State-Changed-By: takawata 
State-Changed-When: Thu Mar 27 07:20:54 UTC 2014 
State-Changed-Why:  

Committed as revision 263795 


http://www.freebsd.org/cgi/query-pr.cgi?pr=187966 
>Unformatted:
