Topic: DIE BIOS VENDORS, DIE!

This is a story about what our computers have to ingurgitate every time
we let them talk to the BIOS. The short story is: HUGE AMOUNTS OF CRAP!
The long story follows...

We call this the age of information and technology, the age of
communication. Well, we don't but marketers, politicians and all around
bullshiters do. Actually people are less technical now than they used to
be at the beginning of the computer age. They use technology, yes. But
they do just that: USE IT. Sure you can ride the bus, that doesn't make
you knowladgeable of its inner-workings.


Anyway, to get back on the subject, people tend to think that if they
take some computer science courses or attend/graduate such an University
then they're all knowing. Actually its quite the contrary nowadays. IN
REAL LIFE, most of the teachers and graduating students are incapable
of doing even the most simple tasks. Students come rushing at job
interviews with buzz words such as XML, encapsulation, Java(tm), OO,
templating, generalization, abstraction, cloud computing, AJAX... must I
go on?! But ask them to do the simplest of tasks, like reversing a
string and they fuck up. Why? They don't have access to something like:

System.IO::STDLIB.string.reverse.in-place()

at that point all their ``skills'' are gone and you can see a big black
hole forming in their heads.

http://img46.imageshack.us/img46/2923/dilbertcertification.jpg

``But they are cheap labor. They are. So what if they get it wrong?
They're 10 times cheaper than that weird 40-ish bearded developer that
we have!''

This would be the less stupid variant of the following:

``Come to think about it, if they're not cheap enough we can always
outsource. Yes, yes. So what if its a sensible part of hardware that we
need to get right, they can fix it with software... better yet, we can
sell them the fix afterwards and make them sign an NDA for it!"

Skip forward a few years. The product ends up on the market. They sell
it like its the best thing ever. Flawless. Optimized for Windows(c)
even. So it must be great.

I think that by this point you get the general idea.

So what actually did happen at h2k9? We started taking suspend/resume
code further and further. Laptops started suspending properly. So we
needed to resume them as well. Some did, some did not. But some acted
really weird, like halting, rebooting or just freezing randomly when we
got back from suspend.

We started fixing the almost working ones. Working, testing, poking the
hardware to see what would happen, the works. We got some results and
some bottlenecks as expected. As we got further and further people
started to join in.

If at first it was only me and mlarkin@, after a few days kettenis@ and
deraadt@ jumped in and then more and more people were joining, fixing the
drivers for suspend/resume, testing and adding bits and pieces to the
process. This meant a great speed-up for the suspend/resume effort.

But then, one dreaded night I decided to go back to those broken
machines and see what was happening there. Most of the other laptops got
pretty damn far except those.

It all started somewhere around 6pm. I plugged my serial cable and
started spilling printfs all over the suspend code path to see how
far I get. To my surprize the laptop suspended but wanted to resume
right away and instead it rebooted.

So I started putting printfs in the resume code path. The framework has
an unfold mechanism when suspend fails. This is a cool feature, thanks
to deraadt@, that saves you from a failed suspend by unrolling and
resuming the suspended devices.

Nothing showed up. Not a single line. This was bad. This meant that the
wakeup locore code was breaking it. This meant that things happened
before we switched to protected mode or very soon after. How do you
debug that? Well... print something, right? So I added some assembly to
print to the serial port. And it worked!

Great, that meant I can see where it panics. And it was just before
making the jump in protected mode. Yes...

By this time I got mlarkin@ in on the issue and he started looking into
it as well. Everybody, except dms@, went for beer already, but we were
still in the hackingroom looking into this. It was very strange. Finally
at about 2-3AM it hit us! The BIOS was trashing the GDT and the IDT!!!
This was incredible! The BIOS was screwing us over.

One hour later we had a fix that worked and got these laptops all the
way on resume. It was incredible! We could not belive it. We were so
happy we fixed it and so pissed at the BIOS vendors. We went for beer
and the bar was empty. Everyone went to sleep already. It was 3-4AM.

Great, so next day I get the okays and commit the patch. This fixed more
than one brand, so other computers started to go further. But after one
or two days I got some that did not just because of that patch. How
could that be? It just cleaned the GDT and IDT and reinitialized them,
it was supposed to be redundant and harmless on most laptops.

Some laptops did something else, they purposely messed with these in
order to get video back. So when we were cleaning them and doing our own
bios reset routine the BIOS wasn't getting what it expected and froze
the machine. Yes, its amazing.

So now we have a bunch of cases:
    - some need the GDT/IDT clean-up
    - some don't because they freeze
    - some need the x86_emu part to emulate the BIOS video code
    - some need a mix of the above

This is the crap they push down your throat when you pay them, this is
the thing that they don't make public and only give away for fun and
profit to your local friendly corporation.

THIS IS THE STUFF YOU GET FIXED FOR FREE FROM OPENBSD!

Enjoy your laptop, its been fixed. Stop buying the next one blindly.
Better have sane hardware than blinken-lights hardware. Be smart, don't
just shop for the pretty colors. And remember to support OpenBSD in any
way you can through donations or CDs.

Everything is simple, we're stupid.
gopher://sdf.lonestar.org/1/user/bulibuta

Re: DIE BIOS VENDORS, DIE!

A friend of mine once told me he has seen these lines of code in a piece of software written by some outsourcing contractor:

if (i==3)
{
i=3;
}
else
i=i;

Never play leap frog with a unicorn

Re: DIE BIOS VENDORS, DIE!

Maybe they got paid per line of code?

"You mean your not going to give me a new laptop after I spilled soda all over mine?"- a glimpse of the crap that comes to the geek squad window.

Re: DIE BIOS VENDORS, DIE!

caffeinefreak wrote:

Maybe they got paid per line of code?


that's one theory

Never play leap frog with a unicorn

Re: DIE BIOS VENDORS, DIE!

Cygnum wrote:

A friend of mine once told me he has seen these lines of code in a piece of software written by some outsourcing contractor:

if (i==3)
{
i=3;
}
else
i=i;

I think I saw this example in the daily WTF or somewhere else... seems very familiar!

Everything is simple, we're stupid.
gopher://sdf.lonestar.org/1/user/bulibuta

Re: DIE BIOS VENDORS, DIE!

just turn it off guys.

aint no hollaback girl

Re: DIE BIOS VENDORS, DIE!

eh?

Everything is simple, we're stupid.
gopher://sdf.lonestar.org/1/user/bulibuta

Re: DIE BIOS VENDORS, DIE!

bulibuta wrote:
Cygnum wrote:

A friend of mine once told me he has seen these lines of code in a piece of software written by some outsourcing contractor:

if (i==3)
{
i=3;
}
else
i=i;

I think I saw this example in the daily WTF or somewhere else... seems very familiar!

Hmm, I think a variation of this was also in the book "How not to program in C++". If I remember, I think they were trying to get the debugger to trip a breakpoint.

"You have demonstrated their weaknesses could be found using less sophisticated thinking. We are no longer capable of such thinking."
"Why do the work yourself when you can find someone smarter then you to do the work for you?"

Re: DIE BIOS VENDORS, DIE!

Getting back to the article, I think it's cool that we have a BSD developer here at Neworder who is helping to improve one of the more respected operating systems out there. Power management has always been one of those constant headaches for me in the past. I've had laptops running FreeBSD in the past that would suspend without a problem, but would NEVER resume. Very frustrating, even though this was more than likely a hardware compatibility issue rather than a software issue. "DIE APM" should have been added to the title as well, in my opinion.

Go Saints! Who Dat!

Re: DIE BIOS VENDORS, DIE!

The last time I tried running a linux distro it took me forever to get the wireless card working. And even after that, if the computer would idle for too long the wireless just stopped working and nothing I did besides rebooting would get it working. So hurray for someone trying to improve the competition.

"You mean your not going to give me a new laptop after I spilled soda all over mine?"- a glimpse of the crap that comes to the geek squad window.

Re: DIE BIOS VENDORS, DIE!

This stuff is exactly the reason I stick to windows and run linux boxes only through VMWare.

Never play leap frog with a unicorn

Re: DIE BIOS VENDORS, DIE!

THA wrote:
bulibuta wrote:
Cygnum wrote:

A friend of mine once told me he has seen these lines of code in a piece of software written by some outsourcing contractor:

if (i==3)
{
i=3;
}
else
i=i;

I think I saw this example in the daily WTF or somewhere else... seems very familiar!

Hmm, I think a variation of this was also in the book "How not to program in C++". If I remember, I think they were trying to get the debugger to trip a breakpoint.

yes, it should have been for debugging and later someone forgot to remove it.

I am a veggie coz I hate plants. I am a non-veggie coz I hate animals and I am a cannibal because I hate humans. :-)

Re: DIE BIOS VENDORS, DIE!

@resolution: well of course some of the ACPI stuff goes through the APM daemon so that you can call zzz and friends. And that code has been reviewed as well. Its scheduled for major changes once the next hackathon comes along.

Everything is simple, we're stupid.
gopher://sdf.lonestar.org/1/user/bulibuta

Re: DIE BIOS VENDORS, DIE!

nice article. a lot of stuff gets outsourced to India and China- h/w and s/w. there are good engineers in both india and china. then why do you get buggy stuff?

they don't take/like jobs which pays them 1/10 th of what the others get. if they get paid 1/10 th they produce an output of 1/10th. i mean something like that.

developing free and open source software is a passion and had a different support system, that however is a totally different issue.

Bulibuta: Look at your post count. you are elite smile

I am a veggie coz I hate plants. I am a non-veggie coz I hate animals and I am a cannibal because I hate humans. :-)

Re: DIE BIOS VENDORS, DIE!

I never got to read that fancy magazine (2600), is it that elite? I stopped reading IT magazines in the '90s as they all seemed to get less and less professional and almost the same thing got written each issue. I still get some of them at work now and so I got a chance to browse through them again after 10 years... the same format/articles/bla.

Everything is simple, we're stupid.
gopher://sdf.lonestar.org/1/user/bulibuta

Re: DIE BIOS VENDORS, DIE!

i dont know and have not read any 2600 magazines. i just know that 2600 Hz was the frequency of the dialer.

I am a veggie coz I hate plants. I am a non-veggie coz I hate animals and I am a cannibal because I hate humans. :-)

Re: DIE BIOS VENDORS, DIE!

nice article, even though i think some here would've enjoyed a bit more technicalities.
in any case good job!

acpi=off always worked for me whenever dmesg | grep MSFT found something  big_smile

i hear very common that problems with suspend/resume are 'not caused' by the actual bios vendors, but by our friends in redmond and their best intentions of 'optimizing' hardware to run windblowz.

btw believe it or not, i once had to return about 20 shiny new workstations (produced by a two letter vendor) purchased by a small college due to this very reason. i remember the clerks eyes in the store when i started explaining why we are returning brand new workstations, which worked perfectly 'fine' with windblowz vista, yet would freeze their ass of in just about any major distro i tried on them. smile)) a little under a month later, we got a 100% refund since the store was unable to provide a different model. soo stupid on their part, but luckily there are plenty of stores out there. just it is too bad that most of times it is impossible to find out whenever linux will run fine on the machine, prior to purchasing it.

as far as i'm concerned hardware manufacturers should be obliged by law to indicate if the hardware is windows specific. otherwise it is like buying a car which may or may not run on diesel, this is bullshit! if the car needs gasoline so be it, but at least let the buyer know beforehand. this at least would seem logical, no?

ps i'm rather curious whenever a specific [intel] compiler is used to build DSDT smile somethign tells me, that a lot must depend on compiler used...

Last edited by gr00ve (2010-02-09 13:02:39)

fx64 is a Fedora 12 x86_64 spin features software for audio, video, graphics, office, internet, filesharing, instant messaging, and system administration. Post install script automatically installs Java, Flash, Skype and VirtualBox; 10K+ applications, games and utilities available from RPMFUSION. FREE!!!

Re: DIE BIOS VENDORS, DIE!

thanks, I tried to keep the article readable to most people without going through too many details. I'll be a bit more technical on the next article.

the problem is, with ACPI, that you have to identify your OS as Windows most of the times. Otherwise you're running untested buggy AML code.

As for DSDT see here. Its compiled by gcc.

Everything is simple, we're stupid.
gopher://sdf.lonestar.org/1/user/bulibuta

Re: DIE BIOS VENDORS, DIE!

bulibuta wrote:

eh?

The problem is probably that whatever you're using is about 0.00000% of the market share, and as firmware is basically code spaghetti, they will be reluctant to break their back for you - for fear of breaking something for say, windows, for no perceived increase in revenue.

- I work in the field.

aint no hollaback girl

Re: DIE BIOS VENDORS, DIE!

after posting this I realise it was pretty obvious. Usually if you just request information from BIOS vendors they will comply; it's when you ask them to fix stuff they aren't interested, and everything becomes a feature.

aint no hollaback girl

Re: DIE BIOS VENDORS, DIE!

Eh, I think I removed Iolaus' last post by mistake. It's been a long day. I'll try and put the pieces back...

<Iolaus> Triple post. I'm certified.

Go Saints! Who Dat!

Re: DIE BIOS VENDORS, DIE!

You work in what field? And you can't turn ACPI off for most laptops nowadays because it might go boom.

ACPI != suspend resume, amongst other things it controls CPU speed steps, sensors, fans, timers... Some laptops are a plain old brick without ACPI implemented in the OS.

Everything is simple, we're stupid.
gopher://sdf.lonestar.org/1/user/bulibuta

Re: DIE BIOS VENDORS, DIE!

just turn the laptop off .... with the off button

aint no hollaback girl

Re: DIE BIOS VENDORS, DIE!

haha

Everything is simple, we're stupid.
gopher://sdf.lonestar.org/1/user/bulibuta

Re: DIE BIOS VENDORS, DIE!

bulibuta wrote:

Better have sane hardware than blinken-lights hardware. Be smart, don't

QFTTTT!


MY question:

? URL source for info on *nix friendly bioses in this regard?

(vista / windows 7 is far from me).

Im buying a laptop soon.

Everyone Dances with the Grim Reaper..Someday