Skip to contentSkip to conversation

Turning iasl's "-oe" option into a documented, regular option?

Devel Moore 1 participant 1 message Sep 30, 2016 1 message not in the archive ACPI component architecture (acpica)

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Moore

#1 lore raw

The 2006 version of ACPICA was implemented in a window of the ACPI specification where it disallowed "module level code". By 2009, module level code was legal again, so ACPICA was changed to support it.

For older versions of ACPICA in this window, you should probably use an older iASL. When the new ACPI spec comes out in Q1 2017, the problems you are seeing may get worse, so it may be best to just use an older iASL for old ACPICA.

Certainly for any ACPICA after 2009, it is OK to use the latest iASL.

This whole thing is an incompatibility issue that was introduced years ago in the ACPI specification.

Quoted 402 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:mst(a)redhat.com]
Sent: Tuesday, September 27, 2016 4:17 PM
To: Moore, Robert <robert.moore(a)intel.com>
Cc: Laszlo Ersek <lersek(a)redhat.com>; devel(a)acpica.org; Box, David E <david.e.box(a)intel.com>
Subject: Re: Turning iasl's "-oe" option into a documented, regular option?

Quoted 1 line · Robert

I believe \_REV is deprecated because some operating systems did not

keep it updated.

Sorry about being unclear, this wasn't my point. I only tried to say that AML can be compatible with older OSPMs.

Quoted 1 line

We have a big issue concerning the External() opcode, because we would

rather not have firmware vendors disabling it. This would bypass the entire reason for the existence of this opcode.

Any suggestions?
At the moment latest iasl creating AML that breaks old OSPMs just pushes us to avoid using latest iasl.

Quoted 26 lines
Quoted 26 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:mst(a)redhat.com]
Sent: Tuesday, September 27, 2016 10:11 AM
To: Moore, Robert <robert.moore(a)intel.com>
Cc: Laszlo Ersek <lersek(a)redhat.com>; devel(a)acpica.org; Box, David E <david.e.box(a)intel.com>
Subject: Re: Turning iasl's "-oe" option into a documented, regular option?

Quoted 4 lines · Robert

We will take a look at this.

The "module-level code" (executable AML outside of any control method)

was made legal again around ACPI 3.0, and ACPICA supports it.

Absolutely. The issue for us is that unlike other code where we need to actually add the code in ASL in order to get something in AML, in this case the module-level code seems to be added unconditionally. So producing compatible code is easy - just don't call things from newer ACPI versions.
In other cases, in ASL we can do things like looking at \_REV and supplying compatibility code.

Quoted 6 lines
Quoted 6 lines

However in this case, there seems to literally be nothing we can do in ASL if we want to get ACPI 2.0 and back compatibility, because we care about supporting old OSPMs.

Our work-around for now is just using an old version of iasl or a new one with -oe, but if -oe will be gone I'm not sure what we can

do.

Quoted 129 lines
Quoted 129 lines
Quoted 5 lines

The External opcode is very important in order to easily parse control

method invocations -- especially noticeable in the disassembler, but can also assist with "normal" AML parsing.

Quoted 2 lines

Bob

Sure.
It makes sense to me that ACPI 3.0 is old enough that the default you chose is reasonable.
But being able to produce code that's compatible with historical ACPI versions and can run on old OSPMs also has value IMO.

Does this make sense?

Quoted 36 lines
Quoted 36 lines

-----Original Message-----
From: Laszlo Ersek [mailto:lersek(a)redhat.com]
Sent: Tuesday, September 27, 2016 3:30 AM
To: Moore, Robert
Cc: devel(a)acpica.org; Michael Tsirkin; Box, David E
Subject: Re: Turning iasl's "-oe" option into a documented, regular option?

Quoted 14 lines · Laszlo Ersek
Quoted 13 lines · Robert
Quoted 13 lines

-----Original Message-----
From: Laszlo Ersek [mailto:lersek(a)redhat.com]
Sent: Monday, September 26, 2016 3:11 PM
To: Moore, Robert
Cc: devel(a)acpica.org; Michael Tsirkin; Box, David E
Subject: Re: Turning iasl's "-oe" option into a documented, regular option?

Quoted 2 lines · Robert
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

-----Original Message-----
From: Laszlo Ersek [mailto:lersek(a)redhat.com]
Sent: Monday, September 26, 2016 2:23 PM
To: Moore, Robert <robert.moore(a)intel.com>
Cc: devel(a)acpica.org; Michael Tsirkin <mtsirkin(a)redhat.com>
Subject: Turning iasl's "-oe" option into a documented, regular

option?

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Hi,

the addition of the External() opcode (i.e., 0x15), from ACPI v6.0, causes iASL to generate AML that breaks old versions of ACPICA's AML interpreter that are shipped with old (but still variably supported) Linux distributions, for example, RHEL-

5.11.

Quoted 49 lines
Quoted 49 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

The breakage happens despite the If(0) conditional that surrounds the opcode and is supposed to hide it.

Please explain further. The design of the External opcode was

specifically chosen as to not break existing interpreters.

Quoted 43 lines

At the moment I can provide only the following info: when we boot the
RHEL-5.11 kernel against AML that was generated with recent iASL (without passing the -oe switch), the kernel logs

Quoted 37 lines

ACPI: Core revision 20060707
ACPI Error (psloop-0196): Found unknown opcode 15 at AML address
ffffc20000008da8 offset 4, ignoring [20060707] ACPI Error (psloop-0196): Found unknown opcode 15 at AML address ffffc20000008daf offset B, ignoring [20060707] ACPI Error (psloop-0196): Found unknown opcode 15 at AML address ffffc20000008db6 offset 12, ignoring [20060707] ACPI Error (psloop-0196): Found unknown opcode 15 at AML address ffffc20000008dbd offset 19, ignoring [20060707] ACPI Error (psloop-0196): Found unknown opcode 3 at AML address ffffc20000008dc2 offset 1E, ignoring [20060707] ACPI Error (psloop-0196): Found unknown opcode 15 at AML address ffffc20000008dc4 offset 20, ignoring [20060707] ACPI Error (psloop-0196): Found unknown opcode 3 at AML address ffffc20000008dc9 offset 25, ignoring [20060707] ACPI Error (psloop-0196): Found unknown opcode 15 at AML address ffffc20000008dcb offset 27, ignoring [20060707] ACPI Error (psloop-0196): Found unknown opcode 3 at AML address ffffc20000008dd0 offset 2C, ignoring [20060707] ACPI Error (psloop-0196): Found unknown opcode 15 at AML address ffffc20000008dd2 offset 2E, ignoring [20060707] ACPI Error (psloop-0196): Found unknown opcode 15 at AML address ffffc20000008da8 offset 4, ignoring [20060707] ACPI Error (psloop-0196): Found unknown opcode 15 at AML address ffffc20000008daf offset B, ignoring [20060707] ACPI Error (psloop-0196): Found unknown opcode 15 at AML address ffffc20000008db6 offset 12, ignoring [20060707] ACPI Error (psloop-0196): Found unknown opcode 15 at AML address ffffc20000008dbd offset 19, ignoring [20060707] ACPI Error (psloop-0196): Found unknown opcode 3 at AML address ffffc20000008dc2 offset 1E, ignoring [20060707] ACPI Error (psloop-0196): Found unknown opcode 15 at AML address ffffc20000008dc4 offset 20, ignoring [20060707] ACPI Error (psloop-0196): Found unknown opcode 3 at AML address ffffc20000008dc9 offset 25, ignoring [20060707] ACPI Error (psloop-0196): Found unknown opcode 15 at AML address

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

ffffc20000008dcb offset 27, ignoring [20060707] ACPI Error (psloop-0196): Found unknown opcode 3 at AML address ffffc20000008dd0 offset 2C, ignoring [20060707] ACPI Error (psloop-0196): Found unknown opcode 15 at AML address ffffc20000008dd2 offset 2E, ignoring [20060707] ACPI Error (dsobject-0134): [ON^D] Namespace lookup failure, AE_NOT_FOUND ACPI Exception (tbxface-0113): AE_NOT_FOUND, Could not load

namespace [20060707] ACPI Exception (tbxface-0120):

Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

AE_NOT_FOUND, Could not load tables [20060707]
ACPI: Unable to load the System Description Tables

I haven't looked into the "[ON^D] Namespace lookup failure"

specifically, but I think it's a consequence of the earlier parsing errors (the parser assumes that unknown opcodes are 1 byte in size, which I think isn't correct for External(), so I think the parser gets out of sync with the AML byte stream).

Quoted 1 line
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

With the RHEL-6 (our currently closest data point, in time), we get

Quoted 1 line

ACPI: Core revision 20090903

and no error messages; the tables are parsed and they work

fine.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 3 lines

So, it seems that the interpreter in RHEL-5.11 tries to parse the

package that is conditional on If(0). As Michael said this is not for execution (yet), just for interpretation, but it breaks the interpreter nonetheless.

Quoted 3 lines

Here's a memory dump from the guest kernel, around virtual address

0xffffc20000008da8 (for which the first error message is

printed):

Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 5 lines

crash> rd -8 ffffc20000008d80 100
ffffc20000008d80: 44 53 44 54 8b 11 00 00 01 b5 42 4f 43 48
53
20

DSDT......BOCHS

Quoted 3 lines

ffffc20000008d90: 42 58 50 43 44 53 44 54 01 00 00 00 42 58
50
43

BXPCDSDT....BXPC

Quoted 3 lines

ffffc20000008da0: 01 00 00 00 a0 43 05 00 15 50 30 53 5f 01
00
15

.....C...P0S_...

Quoted 2 lines
                                 ^  ^  ^  ^  ^
                                 |  |  |  |  ExternalOp (@

0xffffc20000008da8)

Quoted 4 lines
                                 |  |  |  Predicate
                                 |  |  ByteData = 0x05
                                 |  PkgLeadByte = 67 dec =

0100_0011

bin;

Quoted 5 lines
                                 |  PkgLength = 0x53 = 83 dec
                                 IfOp

ffffc20000008db0: 50 30 45 5f 01 00 15 50 31 56 5f 01 00 15
50
31

P0E_...P1V_...P1

Quoted 2 lines

ffffc20000008dc0: 53 5f 03 00 15 50 31 45 5f 03 00 15 50 31
4c 5f

S_...P1E_...P1L_

Quoted 3 lines

ffffc20000008dd0: 03 00 15 5c 2f 03 5f 53 42 5f 50 43 49 30
50
43

...\/._SB_PCI0PC

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 1 line

ffffc20000008de0: 4e 54 08 02

NT..

Quoted 4 lines

I believe that the interpreter must have seen a change, between
20060707

and 20090903, that makes it skip a conditional package *even for parsing* if it can determine that the predicate is constant

false.

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines

(This skipping is possible because the package length is encoded at a fixed position within DefIfElse, so it can be parsed before / independently of the conditional block ("TermList") itself:

Quoted 3 lines

DefIfElse := IfOp PkgLength Predicate TermList DefElse
)

I think I've found it.

Using various historical Fedora kernels, I first narrowed it down to v2.6.31..v2.6.32. (The former breaks, the latter works, with the
External() opcodes in the AML.)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Then, using a RHEL-6 virtual machine, I performed an inverse bisection on this range. The bisection was restricted to the drivers/acpi/ subdirectory.

Here's the bisection log (again, note that "bad" means "working", and "good" means "broken", because I was looking for a commit that fixed things, not for a commit that regressed

things):

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

git bisect start '--' 'drivers/acpi/'
# good: [74fca6a42863ffacaf7ba6f1936a9f228950f657] Linux 2.6.31 git bisect good 74fca6a42863ffacaf7ba6f1936a9f228950f657
# bad: [22763c5cf3690a681551162c15d34d935308c8d7] Linux 2.6.32 git bisect bad 22763c5cf3690a681551162c15d34d935308c8d7 # bad: [53de5356be3ac62c22ae1da266943059b169d9b1] ACPI: don't pass handle for fixed hardware notifications git bisect bad 53de5356be3ac62c22ae1da266943059b169d9b1
# bad: [985f38781d19101aba121df423f92c87b208c6df] Merge branch 'acpica' into release git bisect bad 985f38781d19101aba121df423f92c87b208c6df
# bad: [e678902ee899f6b0ab48166b410cdc9f1c27a350] ACPICA:
Remove error message for Store(Localx,Localx) git bisect bad e678902ee899f6b0ab48166b410cdc9f1c27a350
# good: [0444e8f6d72d6e38f92d48884bc90bbc6c22fd5a] ACPICA:

Fix:

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Predefined object repair executed only once git bisect good 0444e8f6d72d6e38f92d48884bc90bbc6c22fd5a
# good: [d9adc2e031bd22d5d9607a53a8d3b30e0b675f39] ACPICA:
reformat predefined method table, no functional change git bisect good d9adc2e031bd22d5d9607a53a8d3b30e0b675f39
# bad: [8a964236800839263b3dddd7f7851d666e7d53e1] ACPICA:

Quoted 7 lines
Quoted 7 lines

acpi_reset:

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Bypass port validation mechanism git bisect bad 8a964236800839263b3dddd7f7851d666e7d53e1
# bad: [7f0c826a437157d2b19662977e9cf3b472cf24a6] ACPICA: Add support for module-level executable AML code git bisect bad 7f0c826a437157d2b19662977e9cf3b472cf24a6
# good: [999e08f99846a1fd6ee9642ec306a2d318925116] ACPICA:

ACPI 4:

Quoted 73 lines
Quoted 73 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line

Add

validation for new predefined names.

Quoted 1 line

git bisect good 999e08f99846a1fd6ee9642ec306a2d318925116

and the result is

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

7f0c826a437157d2b19662977e9cf3b472cf24a6 is the first bad commit commit 7f0c826a437157d2b19662977e9cf3b472cf24a6

Author: Lin Ming <ming.m.lin(a)intel.com>
Date:   Thu Aug 13 14:03:15 2009 +0800

ACPICA: Add support for module-level executable AML code

Add limited support for executable AML code that exists

outside

Quoted 1 line
Quoted 1 line
Quoted 1 line

of any control method. This type of code has been illegal

since

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

ACPI 2.0. The code must exist in an If/Else/While block.
All

AML

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

tables are supported, including tables that are
dynamically

loaded.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

ACPICA BZ 762.

http://acpica.org/bugzilla/show_bug.cgi?id=762

Signed-off-by Lin Ming <ming.m.lin(a)intel.com>
Signed-off-by Bob Moore <robert.moore(a)intel.com>
Signed-off-by Len Brown <len.brown(a)intel.com>
Quoted 6 lines
Quoted 6 lines
Quoted 1 line

:040000 040000 53420ff22ed1d5b42867eb0b7690bef936e59448

e73f6a01af9a9f3d4ae58c856ce77305997d697e M drivers

Now, if we re-investigate the AML code dumped from the guest, it seems that the If(0) statement is placed directly in the root scope

of the DSDT:

Quoted 15 lines
Quoted 15 lines
Quoted 5 lines

crash> rd -8 ffffc20000008d80 100
ffffc20000008d80: 44 53 44 54 8b 11 00 00 01 b5 42 4f 43 48
53
20

DSDT......BOCHS

Quoted 3 lines

ffffc20000008d90: 42 58 50 43 44 53 44 54 01 00 00 00 42 58
50
43

BXPCDSDT....BXPC

Quoted 3 lines

ffffc20000008da0: 01 00 00 00 a0 43 05 00 15 50 30 53 5f 01
00
15

.....C...P0S_...

Quoted 7 lines
Quoted 7 lines

Therefore the bisection result makes sense: the If(0) construct in question exists outside of any control method.

The problem is -- as long as we can believe the commit message of
7f0c826a43 --, this is invalid AML, and has been invalid since ACPI

2.0.

Quoted 12 lines
Quoted 12 lines

In other words, the "hiding" logic for the External() opcode produces executable AML code (i.e., If(0)) outside of any control method, which is
-- apparently -- invalid, and only works where it works because commit
7f0c826a4371 added a compat (?) fallback.

... The ACPICA bugzilla has been relocated to a different URL since the above commit; the currently valid URL for the BZ referenced in the commit message is:

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

https://bugs.acpica.org/show_bug.cgi?id=762

For reference, the DSDT ASL that defines the P0S method as External
-- that is, the ASL that now breaks for RHEL-5.11 -- goes like

this:

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Scope(\_SB.PCI0) {
...

    Method(_CRS, 0) {
        /* Fields provided by dynamically created ssdt */
        External(P0S, IntObj)
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

See
<http://git.qemu.org/?p=qemu.git;a=blob;f=hw/i386/acpi-dsdt-pci-
crs.dsl;h=b375a19cf604c3f8d02ee5edd799fdacab4f14f9;hb=stable-

1.7#l75>.

Quoted 4 lines
Quoted 4 lines

I believe if iASL added the If(0) construct in the scope of the _CRS method, rather than in the root scope of the DSDT, then things should work even with kernels that don't have commit

7f0c826a43.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Thanks
Laszlo