Matthew Garrett ([info]mjg59) wrote,
@ 2008-07-31 20:47:00
Previous Entry  Add to memories!  Tell a Friend!  Next Entry
Entry tags:advogato, fedora

Various people have asked me why there'd ever be a justification for ACPI tables to base various types of behaviour on the operating system they're running on, and why Linux claims to be Windows. There's pretty straightforward explanations that don't involve conspiracies, but they're not necessarily obvious. Let's start from the beginning.

ACPI provides two mechanisms for determining the OS, _OS and _OSI. _OS is an ACPI object containing a string. This string is supposed to represent the operating system. Windows 98 contained "Microsoft Windows", NT4 "Microsoft Windows NT" and ME "Microsoft WindowsME: Millennium Edition". All later versions of Windows contain "Microsoft Windows NT". Linux was "Linux" up until 2.6.9, and has been "Microsoft Windows NT" since then.

The obvious drawback to _OS is that it's a single string. _OSI was introduced with later versions of ACPI, providing an interface for ACPI tables to request which interfaces an OS supported. Interfaces may be something like "3.0 Thermal Model", indicating support for a specific aspect of ACPI, but may also be used to indicate the interfaces supported by the OS. The _OSI method is passed a string and returns either true or false depending on whether the OS claims to support that interface. The OS can therefore claim to support many different interfaces. Linux implements pretty much every aspect of ACPI that Windows does, and so claims to support all the interfaces that Windows implements. As a result, Linux will return true when asked if it implements support for any of the Windows interfaces (up to and including Vista).

That's all straightforward enough, but leaves two questions. The first is why Linux now claims "Microsoft Windows NT" for _OS. That's actually pretty simple - some DSDTs only check for various _OSI strings if _OS is "Microsoft Windows NT". This is stupid of them, but not a violation of the ACPI spec. The second is why Linux returns false for _OSI("Linux"). This is a little more subtle, but it basically boils down to "There is no Linux interface". The behaviour of Linux changes over time. We make no guarantees that its behaviour will be consistent over time as we find and fix bugs. Microsoft take a different approach. Their ACPI behaviour has few changes over time. Something claiming to be Windows 2000 will always behave the same way. We can't even bump the interface string per release - doing so would require us to maintain every broken behaviour we've ever implemented and switch between them depending on what the BIOS asked us for. Linux does not provide a stable ACPI API to platform firmware, and we make no guarantees that it ever will. The only behaviour you can depend on is that Linux will conform to either the ACPI spec or (where it differs) the behaviour of Windows. If you find behaviour that does not fall into either of those categories, then it's likely that the behaviour will change when we notice. The reason we removed Linux from the supported interfaces list in 2.6.24 was that we were beginning to see BIOSes that changed behaviour when they detected that they were running on Linux, and changes we wanted to make could have potentially broken these BIOSes.

Anyway. That's why we claim to be Windows. Now, why would a DSDT want to do anything with that information? It should be noted that making decisions based on this is not a contravention of the ACPI spec - section 5.7.2 even describes a case of this. There are a few situations under which this can be helpful. The first is due to varying interpretations of the spec. Early versions of Windows require that hotswap bays signal their removal by sending a bus check notification to the parent IDE bus. Later versions want a device check notification on the device itself. Both are valid, but you ideally want to use the right one on the corresponding OS. Checking the OS version lets you do so.


Red Stripe makes a lousy spec-compliant ACPI implementation. That is because it is not a spec-compliant ACPI implementation, it is beer! Hooray beer!


Another is user experience. Not all hardware is supported by all operating systems. For instance, older versions of Windows don't support high-precision event timers (HPET). The HPET is defined as an ACPI device, and so will show up as an unknown device in the Windows device manager unless the firmware disables it. This is acheived by altering a flag in the _STA response depending on the Windows version - earlier versions are told that the device should be invisible, and later versions are told that it should be exposed. Finally, there's bug workarounds. An example of this is Windows 98 crashing if a thermal zone reports a temperature of less than 15.8 degrees celsius. Working around that seems like a perfectly reasonable thing for a piece of hardware to do, since Microsoft don't make it easy for vendors to provide hotpatched versions of Windows.

The final part of this mystery is why various BIOSes attempt to check whether they're running on Linux. Almost all the BIOSes I've examined do nothing with this information, which is consistent with someone writing an OS lookup table many years ago and adding Linux just in case someone found it useful. People don't generally write ACPI tables from scratch (doing so would be very dull), so they'll base it on the one from a previous version. Code won't be removed unless it's breaking things, so you'll end up with various odd evolutionary dead ends that have persisted anyway. If your ACPI firmware checks for Linux, this is not inherently a bug in your BIOS. It's more likely that nobody cared enough to remove two lines of code that might turn out to be useful one day.



(Post a new comment)


[info]sweh
2008-07-31 08:19 pm UTC (link)
Another is user experience. Not all hardware is supported by all operating systems. For instance, older versions of Windows don't support high-precision event timers (HPET). The HPET is defined as an ACPI device, and so will show up as an unknown device in the Windows device manager unless the firmware disables it.

Personally, I consider that incorrect behaviour. It's too tight a linkage between the OS and the hardware and could actually _prevent_ the OS from future enhancements that did support the device. It's also not consistent; if I load Windows onto a machine with an audio controller I have no driver for, then it shows up as an unknown device (potentially it might flag it as audio, if you're lucky). You then need to load a driver or live with the unknown device. If I plug in a Bambleweeny 57 then I'll get the same behaviour. But now the motherboard is hiding things from me just because it thinks it knows better? Bleh. How inconsistent.

This behaviour also prevents new OS versions from coming out and identifying themselves correctly. The motherboard may not configure itself properly as a result. So now everything now identifies itself as Windows NT (no doubt Windows 7 will also claim it's NT to the BIOS), which basically makes this whole model void.

I feel this should be under control of the OS and not the motherboard; if the OS wants different behaviour then it should make a (standardised API) call ("set hotswap bays to device mode"). That's what an OS is _meant_ to do; configure and manage the hardware.

Unfortunately, it seems we're stuck with this model for now.

(Reply to this) (Thread)


[info]mjg59
2008-07-31 09:08 pm UTC (link)
Before Vista, there's no way to support the HPET in Windows - it'd require a full rewrite of the timer infrastructure. Hiding hardware that can never be supported in a specific OS version seems like a reasonable thing to do.

(Reply to this) (Parent)(Thread)

(no subject) - [info]sweh, 2008-07-31 10:44 pm UTC
(no subject) - [info]mjg59, 2008-07-31 11:07 pm UTC
(no subject) - [info]sweh, 2008-07-31 11:15 pm UTC
(no subject) - [info]mjg59, 2008-07-31 11:21 pm UTC
(no subject) - [info]sweh, 2008-07-31 11:44 pm UTC
(no subject) - [info]ewx, 2008-08-01 08:09 am UTC
(no subject) - [info]ajaxxx, 2008-07-31 11:07 pm UTC
(no subject) - [info]sweh, 2008-07-31 11:18 pm UTC
(no subject) - [info]ajaxxx, 2008-08-01 04:40 am UTC
(no subject) - (Anonymous), 2008-08-01 11:19 am UTC

(Reply from suspended user)
WMI
[info]rasker
2008-07-31 08:43 pm UTC (link)
A couple of years ago when I was config-ing an HP laptop for linux I had to delve into the dsdt to find out why some keys were not working. It seems some key info from pnp032 button device was being diverted to wmi in the dsdt (I think acpi events were being diverted to an area accessible to wmi but not accessible to acpi in linux). Makes the whole 'standards' thing pretty useless on the whole when vendors start doing this.

(Reply to this) (Thread)

Re: WMI
[info]mjg59
2008-07-31 09:05 pm UTC (link)
I've actually written a driver for the HP WMI support. It should be in 2.6.27. There's no standard way to present most of the functionality that's presented through the WMI interface, so I can sympathise with them to an extent - on the other hand, the fact that the little (i) key generates a WMI event seems somewhat bongtastic.

(Reply to this) (Parent)

(Reply from suspended user)

(Reply from suspended user)

(Reply from suspended user)

[info]base3
2008-07-31 08:43 pm UTC (link)
thanks for this public service

(Reply to this)


[info]nikborton
2008-07-31 08:54 pm UTC (link)
I completely understand why Linux pretends to /not be/ Linux, but I don't quite get how...

If Linux doesn't have a consistent ACPI interface/implementation, how can it consistently support multiple versions of Windows interfaces?

(Reply to this) (Thread)


[info]mjg59
2008-07-31 09:07 pm UTC (link)
It doesn't, but at least we have agreement on how it should behave in those situations - we can test against Windows and then fix things when they diverge. Divergence can then be considered a bug. Effectively, you can think of Windows as being there to disambiguate fuzzy areas of the spec.

(Reply to this) (Parent)(Thread)

(no subject) - [info]nikborton, 2008-07-31 09:20 pm UTC
(no subject) - [info]jldugger, 2008-07-31 10:07 pm UTC
(no subject) - [info]mjg59, 2008-07-31 10:13 pm UTC

(Reply from suspended user)

(Reply from suspended user)

[info]ajaxxx
2008-07-31 09:07 pm UTC (link)
It can't. It doesn't. It attempts to be progressively more conformant as time goes on. Newer Linux kernels should do a better job of pretending to be Windows than older ones.

(Reply to this) (Parent)(Thread)

(no subject) - (Anonymous), 2008-07-31 11:28 pm UTC
(no subject) - [info]mjg59, 2008-07-31 11:30 pm UTC
(no subject) - (Anonymous), 2008-08-01 12:18 am UTC
(no subject) - [info]fooishbar, 2008-08-01 01:51 am UTC
(no subject) - [info]mjg59, 2008-08-01 04:38 am UTC
(no subject) - [info]fooishbar, 2008-07-31 11:52 pm UTC
(no subject) - (Anonymous), 2008-08-01 12:22 am UTC
(no subject) - (Anonymous), 2008-08-01 12:22 am UTC
(no subject) - [info]fooishbar, 2008-08-01 12:28 am UTC
(no subject) - [info]sneakums, 2008-08-01 12:04 am UTC
(no subject) - (Anonymous), 2008-08-01 12:19 am UTC
(no subject) - [info]sneakums, 2008-08-01 01:29 am UTC
(no subject) - [info]ajaxxx, 2008-08-01 04:36 am UTC
(no subject) - (Anonymous), 2008-08-01 09:00 am UTC

(Reply from suspended user)

(Reply from suspended user)

(Reply from suspended user)
nice
(Anonymous)
2008-08-01 12:37 am UTC (link)

Thanks for this very good explanation, i dont have mtch time but BIOS programming always sounded interesting to me.

Waiting next thread when you get the mobo.


You both are lovely!

(Reply to this)

Do feature testing, not version testing
(Anonymous)
2008-08-01 12:38 am UTC (link)
It still seems fundamentally broken to check for versions of an OS rather than supported features. "3.0 Thermal Interface" makes sense. "Windows 2000" does not.

(Reply to this) (Thread)

Re: Do feature testing, not version testing
(Anonymous)
2008-08-01 01:13 am UTC (link)
Apparently some people like chewing gum+paperclip fixes...

Who knew?

If anyone needs any popsicle sticks, just say the word.

(Reply to this) (Parent)

Re: Do feature testing, not version testing
[info]mjg59
2008-08-01 04:40 am UTC (link)
I agree, in an ideal world that would be the way things should work. This isn't an ideal world. Vendors don't define every single functional difference in their ACPI, and it would end up being awkward if they did. Do you really want to have firmware checking for _OSI("Crashes with low temperatures") or _OSI("Fails if provided certain types of package references")?

(Reply to this) (Parent)(Thread)

Re: Do feature testing, not version testing - (Anonymous), 2008-08-01 09:58 pm UTC
On a related note
(Anonymous)
2008-08-01 01:16 am UTC (link)
My sarcasm seems to be spreading.

It could infect the whole kernel team soon, and then development will actually start moving backwards with the slated goal to be ACPI compliant with Windows 3.1

-Ryan

(Reply to this) (Thread)

Re: On a related note
[info]sneakums
2008-08-01 01:30 am UTC (link)
Windows 98 was the first Microsoft operating system to support ACPI.

(Reply to this) (Parent)(Thread)

Re: On a related note - (Anonymous), 2008-08-01 01:47 am UTC
Re: On a related note - [info]sneakums, 2008-08-01 01:54 am UTC
Re: On a related note - (Anonymous), 2008-08-01 01:57 am UTC
Re: On a related note - [info]sneakums, 2008-08-01 02:13 am UTC
Re: On a related note - [info]mjg59, 2008-08-01 04:42 am UTC
Re: On a related note - (Anonymous), 2008-08-01 09:03 am UTC
Re: On a related note - [info]fooishbar, 2008-08-01 09:26 am UTC

[info]pjc50
2008-08-01 08:23 am UTC (link)
It never ceases to amaze me the amount and nature of the nerd rage that Matthew's blog posts inspire...

(Reply to this) (Thread)


(Anonymous)
2008-08-01 09:21 am UTC (link)
Matthew Garret- Foxconn's BOHICA Avenger?

(Reply to this) (Parent)

(no subject) - (Anonymous), 2008-08-01 12:38 pm UTC
(no subject) - [info]lionsphil, 2008-08-01 12:51 pm UTC
(no subject) - (Anonymous), 2008-08-01 03:44 pm UTC
(no subject) - [info]mjg59, 2008-08-01 01:18 pm UTC
Lesson of the day
(Anonymous)
2008-08-01 09:25 am UTC (link)
Being a Red Hat employee means never admitting you were wrong.

Being Matthew Garrett means never saying you're sorry.

Tell you what, if I am wrong, I will issue a full page of why I was wrong, an apology as far as it is appropriate, etc.

If Garrett is wrong, I highly suspect he'll likely issue a full page of why the kernel should have bent over.

-Ryan

(Reply to this) (Thread)

Re: Lesson of the day
[info]fooishbar
2008-08-01 09:33 am UTC (link)
And posting up private contact details of Foxconn employees, pulling the whole I'M BIGGER THAN YOU DON'T YOU SEE WHAT I'VE DONE FOR OPEN SOURCE routine after (rightfully) getting banned from many Ubuntu IRC channels as well as the Ubuntu forums, abusing people who claim that Linux should just work on the hardware and abusing Foxconn/AMI for making such a terribly godawful buggy BIOS with no idea what the actual bug is, etc, etc ... that's all good, is it?

If you don't like the proposed course of action, go to linux-kernel and win them over on the technical arguments of your argument (which is, obviously, bulletproof). Even if that fails (which I'm sure it won't, what with your extensive ACPI expertise of having abused Foxconn once), you can just fork the kernel, and Ryanix can be pure and beautiful. I'm sure people will flock to it.

Remember: this isn't your blog, so you can either respond or not respond. Changing the text of my comment to link to Bananarama videos isn't an option.

Anyway, if you could just point to the specific bugs in the BIOS which are causing this issue, I'm sure all the AMI and Foxconn users would really appreciate it, as that'd enable it to be fixed.

(Reply to this) (Parent)(Thread)

Re: Lesson of the day - (Anonymous), 2008-08-01 09:40 am UTC
Re: Lesson of the day - [info]fooishbar, 2008-08-01 09:52 am UTC
Re: Lesson of the day - (Anonymous), 2008-08-01 09:59 am UTC
Re: Lesson of the day - [info]fooishbar, 2008-08-01 10:07 am UTC
Re: Lesson of the day - (Anonymous), 2008-08-01 10:12 am UTC
Re: Lesson of the day - [info]fooishbar, 2008-08-01 10:25 am UTC
Re: Lesson of the day - (Anonymous), 2008-08-01 10:31 am UTC
Re: Lesson of the day - [info]fooishbar, 2008-08-01 10:33 am UTC
Re: Lesson of the day - (Anonymous), 2008-08-01 10:24 am UTC
Re: Lesson of the day - [info]fooishbar, 2008-08-01 10:29 am UTC
Re: Lesson of the day - [info]jmtd, 2008-08-01 10:26 am UTC
Re: Lesson of the day - (Anonymous), 2008-08-01 10:44 am UTC
Re: Lesson of the day - [info]pjc50, 2008-08-01 10:49 am UTC
Re: Lesson of the day - (Anonymous), 2008-08-01 11:32 am UTC
Re: Lesson of the day - [info]mjg59, 2008-08-01 12:20 pm UTC
Re: Lesson of the day - (Anonymous), 2008-08-01 12:37 pm UTC
Re: Lesson of the day - [info]pjc50, 2008-08-01 12:55 pm UTC
Re: Lesson of the day - [info]mjg59, 2008-08-01 01:17 pm UTC
Re: Lesson of the day - (Anonymous), 2008-08-01 12:34 pm UTC
Re: Lesson of the day - (Anonymous), 2008-08-01 12:44 pm UTC
Re: Lesson of the day - [info]fooishbar, 2008-08-01 01:57 pm UTC
Re: Lesson of the day - (Anonymous), 2008-08-01 02:22 pm UTC
Re: Lesson of the day - (Anonymous), 2008-08-01 03:48 pm UTC
Re: Lesson of the day - [info]mjg59, 2008-08-01 03:50 pm UTC
I have the fixed BIOS
(Anonymous)
2008-08-01 01:44 pm UTC (link)
Hot off the presses, getting ready to flash it.

Brunning says that this is just a development version, but it works on all their systems, and that soon they will release final version which also cleans out lots of cruft that has built up and has no reason to be there.

-Ryan

(Reply to this)

Thank You
(Anonymous)
2008-08-01 02:52 pm UTC (link)
Lunatic conspiracy theories make our community look bad. A voice of sanity and reason was much needed on this topic among some people who just love to jump to conclusions about conspiracies. Thanks Matt for the in-depth and very insightful explanation, it is much appreciated.

(Reply to this) (Thread)

Re: Thank You
(Anonymous)
2008-08-01 06:43 pm UTC (link)
You can laugh at me all you want, I’m not crying foul because I know more than him, I’m crying foul because he’s obviously taking advantage of the situation to try and make an end run around the people that are in charge of this operation.

I was on the phone with Brunning again earlier and voiced my opinion there that the kernel should never have to hack it’s way around a bad BIOS.

They’ll do it for one BIOS, then the other one, then before you know it, everyone’s BIOS is so fucking incoherent and broken in every way you can imagine, and you’ll still have that idiot saying “code around it”.

Reminds me of a story my dad told me once about being in Germany, and the road they were on was straight for miles, then there was a curve, for no reason, then it jogged back over.

He asked the other guy in the car why that happened, the guy said “There used to be a house there”.

So Garrett wants to make design decisions now that will impact the quality of the kernel even after the rationale no longer applies.

-Ryan

(Reply to this) (Parent)(Thread)

Re: Thank You - [info]mjg59, 2008-08-01 06:48 pm UTC
(no subject) - [info]ajaxxx, 2008-08-01 08:37 pm UTC
(no subject) - (Anonymous), 2008-08-01 11:39 pm UTC
Mildly amusing? - (Anonymous), 2008-08-02 12:23 am UTC
Re: Thank You - (Anonymous), 2008-08-02 12:03 am UTC
Re: Thank You - (Anonymous), 2008-08-02 06:57 am UTC
Re: Thank You - (Anonymous), 2008-08-02 02:20 pm UTC
Re: Thank You - (Anonymous), 2008-08-03 03:36 pm UTC
Re: Thank You - [info]realmotk, 2008-08-11 02:26 am UTC

[info]anthonybaxter
2008-08-04 02:30 am UTC (link)
I think mjg could rent his services out as a troll-attractor.

(Reply to this)

Windows Vista won't boot on Dell Dimension
(Anonymous)
2008-09-18 09:36 am UTC (link)
Good Day

Windows vista is also causing lots of boot issues, so I often get questions like this:

I have a Dell Dimension, which won’t boot to Windows (Vista), and none the repair options work:

Startup repair: Reports fix fail due to problem with registry

System Restore: Reports no restore points available

Windows Complete PC Restore: Reports no backups available

Windows Memory Diagnostic Tool: No memory problems

Command Prompt.
Can’t think of any appropriate command to use here.

So I booted with the system DVD (as one would with XP) but the upgrade
option has been greyed don’t want to do a new setup. I want to restore existing
installation.

What should I do?

------------------------------------------------------------

And here is the answer:

You can't do a 'repair install' because you need to launch the Vista DVD
from within Windows, not, as you have been doing, booting straight from the
DVD; that is why the 'upgrade' is greyed out.

If you cannot launch Vista and none of the repair variants will work a clean
install is the only other option.

To save problems in future it is actually a good idea to image the hard
drive, using program like True Image. What I do is install operating system, download all updates, check system I working okay for a day or two, activate system, then create image of the whole drive/partition. Any time I get a problem I can re-image the drive/partition quickly and be up and running without much trouble. And minor fixes are done by using any registry repair software, there are plenty of them on the market today.

Regards,
Carl

(Reply to this)

Windows Vista won't run on Dell Dimension
(Anonymous)
2008-09-18 11:03 pm UTC (link)
Hello Everybody

Windows vista is also causing lots of boot problems, so I often get questions like this:

I have a Dell Dimension, which won’t boot to Windows (Vista), and none the repair options work:

Startup repair: Reports fix fail due to problem with registry

System Restore: Reports no restore points available

Windows Complete PC Restore: Reports no backups available

Windows Memory Diagnostic Tool: No memory problems

Command Prompt.
Can’t think of any appropriate command to use here.

So I booted with the system DVD (as one would with XP) but the upgrade
option has been greyed don’t want to do a new setup. I want to fix existing
installation.

What should I do?

------------------------------------------------------------

And here is the answer:

You can't do a 'repair install' because you need to launch the Vista DVD
from within Windows, not, as you have been doing, booting straight from the
DVD; that is why the 'upgrade' is greyed out.

If you cannot launch Vista and none of the repair variants will work a clean
install is the only other variant.

To save problems in future it is actually a good idea to image the hard
drive, using something like True Image. What I do is install operating system, download all updates, check system I working okay for a day or two, activate system, then image the drive/partition. Any time I get a problem I can re-image the drive/partition quickly and be up and running without much inconvenience. And minor fixes are done by using any registry repair utility, there are plenty of them on the market today.

Cheers,
Carl

(Reply to this)


Create an Account
Forgot your login?
Login w/ OpenID
English • Español • Deutsch • Русский…