2003-02-03 01:30:54

by Adam Belay

[permalink] [raw]
Subject: [PATCH][RFC] Possible PnP BIOS GPF Solution for Sony VAIO and other laptops

The PnP BIOS may be wandering into segement 0x40. If that is the case, this
patch should fix the problem. I do not have a buggy system so I cannot test
this patch but I'd be intersted to hear the results. If you have a system that
has caused pnpbios problems in the past, I recommend you try this patch. If it
works, the system will not panic on startup. This patch is against 2.5.59 and
separate from my other recent patches.


--- a/drivers/pnp/pnpbios/core.c Fri Jan 31 16:59:57 2003
+++ b/drivers/pnp/pnpbios/core.c Fri Jan 31 17:01:07 2003
@@ -142,11 +142,13 @@
set_limit(cpu_gdt_table[cpu][(selname) >> 3], size); \
} while(0)

+static struct desc_struct bad_bios_desc = { 0, 0x00409200 };
+
/*
* At some point we want to use this stack frame pointer to unwind
- * after PnP BIOS oopses.
+ * after PnP BIOS oopses.
*/
-
+
u32 pnp_bios_fault_esp;
u32 pnp_bios_fault_eip;
u32 pnp_bios_is_utter_crap = 0;
@@ -160,6 +162,8 @@
{
unsigned long flags;
u16 status;
+ struct desc_struct save_desc_40;
+ int cpu;

/*
* PnP BIOSes are generally not terribly re-entrant.
@@ -168,6 +172,10 @@
if(pnp_bios_is_utter_crap)
return PNP_FUNCTION_NOT_SUPPORTED;

+ cpu = get_cpu();
+ save_desc_40 = cpu_gdt_table[cpu][0x40 / 8];
+ cpu_gdt_table[cpu][0x40 / 8] = bad_bios_desc;
+
/* On some boxes IRQ's during PnP BIOS calls are deadly. */
spin_lock_irqsave(&pnp_bios_lock, flags);

@@ -207,6 +215,9 @@
: "memory"
);
spin_unlock_irqrestore(&pnp_bios_lock, flags);
+
+ cpu_gdt_table[cpu][0x40 / 8] = save_desc_40;
+ put_cpu();

/* If we get here and this is set then the PnP BIOS faulted on us. */
if(pnp_bios_is_utter_crap)
@@ -1431,7 +1442,7 @@
* from devices that are can only be static such as
* those controlled by the "system" driver.
*/
- if (pnp_bios_get_dev_node(&nodenum, (char )1, node))
+ if (pnp_bios_get_dev_node(&nodenum, (char )0, node))
break;
nodes_got++;
dev = pnpbios_kmalloc(sizeof (struct pnp_dev), GFP_KERNEL);
@@ -1563,6 +1574,8 @@
pnp_bios_callpoint.segment = PNP_CS16;
pnp_bios_hdr = check;

+ set_base(bad_bios_desc, __va((unsigned long)0x40 << 4));
+ _set_limit((char *)&bad_bios_desc, 4095 - (0x40 << 4));
for(i=0; i < NR_CPUS; i++)
{
Q2_SET_SEL(i, PNP_CS32, &pnp_bios_callfunc, 64 * 1024);


2003-02-03 02:00:47

by CaT

[permalink] [raw]
Subject: Re: [PATCH][RFC] Possible PnP BIOS GPF Solution for Sony VAIO and other laptops

On Sun, Feb 02, 2003 at 08:37:02PM +0000, Adam Belay wrote:
> The PnP BIOS may be wandering into segement 0x40. If that is the case,
> this patch should fix the problem. I do not have a buggy system so I
> cannot test this patch but I'd be intersted to hear the results. If you
> have a system that has caused pnpbios problems in the past, I recommend
> you try this patch. If it works, the system will not panic on startup.
> This patch is against 2.5.59 and separate from my other recent patches.

This boots fine here. Then again 2.5.59 booted fine aswell. :) I also
don't get any oopses from reading /proc/bus/pnp stuff as I did before
when I first reported issues. As with the bootup, I also don't get these
issues with 2.5.59. (ie 2.5.59 works fine with or without this patch).

Sorry for not getting back to you earlier btw... I lost almost a
fortnights worth of email and yours was amongst them. :/

--
"Other countries of course, bear the same risk. But there's no doubt his
hatred is mainly directed at us. After all this is the guy who tried to kill my dad."
- George W. Bush Jr, 'President' of the United States
September 26, 2002 (from a political fundraiser in Huston, Texas)

2003-02-03 03:47:49

by Adam Belay

[permalink] [raw]
Subject: Re: [PATCH][RFC] Possible PnP BIOS GPF Solution for Sony VAIO and other laptops

On Mon, Feb 03, 2003 at 01:09:57PM +1100, CaT wrote:
> On Sun, Feb 02, 2003 at 08:37:02PM +0000, Adam Belay wrote:
> > The PnP BIOS may be wandering into segement 0x40. If that is the case,
> > this patch should fix the problem. I do not have a buggy system so I
> > cannot test this patch but I'd be intersted to hear the results. If you
> > have a system that has caused pnpbios problems in the past, I recommend
> > you try this patch. If it works, the system will not panic on startup.
> > This patch is against 2.5.59 and separate from my other recent patches.
>
> This boots fine here. Then again 2.5.59 booted fine aswell. :) I also
> don't get any oopses from reading /proc/bus/pnp stuff as I did before
> when I first reported issues. As with the bootup, I also don't get these
> issues with 2.5.59. (ie 2.5.59 works fine with or without this patch).

This can be explained. When the pnpbios makes a get current resource call
on a buggy system it causes a GPF. In 2.5.59 I designed the pnpbios driver
to avoid making this call when scanning for devices. It uses a get boot
resource call instead.

In other words...

Without this patch, if you made the following change it would panic.

* from devices that are can only be static such as
* those controlled by the "system" driver.
*/
- if (pnp_bios_get_dev_node(&nodenum, (char )1, node))
+ if (pnp_bios_get_dev_node(&nodenum, (char )0, node))
break;
nodes_got++;
dev = pnpbios_kmalloc(sizeof (struct pnp_dev), GFP_KERNEL);

1 = boot config
0 = current config

Therefore it can be concluded that this patch does indeed solve the problem
for your system :-).

>
> Sorry for not getting back to you earlier btw... I lost almost a
> fortnights worth of email and yours was amongst them. :/
>

Thank you for testing my patch.

Regards,
Adam