mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org, Alan Cox <alan@lxorguk.ukuu.org.uk>
Subject: Re: [patch] tls-2.5.31-C3
Date: Tue, 13 Aug 2002 00:46:34 +1000	[thread overview]
Message-ID: <20020813004634.026db357.sfr@canb.auug.org.au> (raw)
In-Reply-To: <Pine.LNX.4.44.0208121205170.2561-100000@localhost.localdomain>

On Mon, 12 Aug 2002 12:07:19 +0200 (CEST) Ingo Molnar <mingo@elte.hu> wrote:
> 
> you can save/restore 0x40 in kernel-space if you need to no problem.

How about the following (untested, not even compiled):

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

diff -ruN 2.5.31/arch/i386/kernel/apm.c 2.5.31-apm.1/arch/i386/kernel/apm.c
--- 2.5.31/arch/i386/kernel/apm.c	2002-08-02 11:11:34.000000000 +1000
+++ 2.5.31-apm.1/arch/i386/kernel/apm.c	2002-08-13 00:20:56.000000000 +1000
@@ -215,6 +215,7 @@
 #include <linux/pm.h>
 #include <linux/kernel.h>
 #include <linux/smp_lock.h>
+#include <linux/smp.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
@@ -419,6 +420,7 @@
 static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue);
 static struct apm_user *	user_list;
 static spinlock_t		user_list_lock = SPIN_LOCK_UNLOCKED;
+static struct desc_struct	bad_bios_desc = { 0, 0x00409200 };
 
 static char			driver_version[] = "1.16";	/* no spaces */
 
@@ -569,7 +571,12 @@
 {
 	APM_DECL_SEGS
 	unsigned long	flags;
+	int			cpu;
+	struct desc_struct	save_desc_40;
 
+	cpu = get_cpu();
+	save_desc_40 = cpu_gdt_table[cpu][0x40 / 8];
+	cpu_gdt_table[cpu][0x40 / 8] = bad_bios_desc;
 	local_save_flags(flags);
 	APM_DO_CLI;
 	APM_DO_SAVE_SEGS;
@@ -591,6 +598,8 @@
 		: "memory", "cc");
 	APM_DO_RESTORE_SEGS;
 	local_irq_restore(flags);
+	cpu_gdt_table[cpu][0x40 / 8] = save_desc_40;
+	put_cpu();
 	return *eax & 0xff;
 }
 
@@ -613,7 +622,12 @@
 	u8		error;
 	APM_DECL_SEGS
 	unsigned long	flags;
+	int			cpu;
+	struct desc_struct	save_desc_40;
 
+	cpu = get_cpu();
+	save_desc_40 = cpu_gdt_table[cpu][0x40 / 8];
+	cpu_gdt_table[cpu][0x40 / 8] = bad_bios_desc;
 	local_save_flags(flags);
 	APM_DO_CLI;
 	APM_DO_SAVE_SEGS;
@@ -639,6 +653,8 @@
 	}
 	APM_DO_RESTORE_SEGS;
 	local_irq_restore(flags);
+	cpu_gdt_table[smp_processor_id()][0x40 / 8] = save_desc_40;
+	put_cpu();
 	return error;
 }
 
@@ -1923,17 +1939,14 @@
 	 * that extends up to the end of page zero (that we have reserved).
 	 * This is for buggy BIOS's that refer to (real mode) segment 0x40
 	 * even though they are called in protected mode.
-	 *
-	 * NOTE: on SMP we call into the APM BIOS only on CPU#0, so it's
-	 * enough to modify CPU#0's GDT.
 	 */
-	for (i = 0; i < NR_CPUS; i++) {
-		set_base(cpu_gdt_table[i][APM_40 >> 3],
-			 __va((unsigned long)0x40 << 4));
-		_set_limit((char *)&cpu_gdt_table[i][APM_40 >> 3], 4095 - (0x40 << 4));
+	set_base(bad_bios_desc, __va((unsigned long)0x40 << 4));
+	_set_limit((char *)&bad_bios_desc, 4095 - (0x40 << 4));
+
+	apm_bios_entry.offset = apm_info.bios.offset;
+	apm_bios_entry.segment = APM_CS;
 
-		apm_bios_entry.offset = apm_info.bios.offset;
-		apm_bios_entry.segment = APM_CS;
+	for (i = 0; i < NR_CPUS; i++) {
 		set_base(cpu_gdt_table[i][APM_CS >> 3],
 			 __va((unsigned long)apm_info.bios.cseg << 4));
 		set_base(cpu_gdt_table[i][APM_CS_16 >> 3],
diff -ruN 2.5.31/arch/i386/kernel/head.S 2.5.31-apm.1/arch/i386/kernel/head.S
--- 2.5.31/arch/i386/kernel/head.S	2002-07-28 21:11:25.000000000 +1000
+++ 2.5.31-apm.1/arch/i386/kernel/head.S	2002-08-13 00:29:38.000000000 +1000
@@ -427,7 +427,10 @@
 	 * The APM segments have byte granularity and their bases
 	 * and limits are set at run time.
 	 */
-	.quad 0x0040920000000000	/* 0x40 APM set up for bad BIOS's */
+	.quad 0x0000000000000000	/* 0x40 APM will be used for bad BIOS's
+					 * Will be saved and restored
+					 * across BIOS calls. MUST NOT BE ONE
+					 * OF THE FOLLOWING THREE! */
 	.quad 0x00409a0000000000	/* 0x48 APM CS    code */
 	.quad 0x00009a0000000000	/* 0x50 APM CS 16 code (16 bit) */
 	.quad 0x0040920000000000	/* 0x58 APM DS    data */
diff -ruN 2.5.31/include/linux/apm_bios.h 2.5.31-apm.1/include/linux/apm_bios.h
--- 2.5.31/include/linux/apm_bios.h	2001-08-14 09:39:28.000000000 +1000
+++ 2.5.31-apm.1/include/linux/apm_bios.h	2002-08-13 00:38:52.000000000 +1000
@@ -21,8 +21,7 @@
 
 #ifdef __KERNEL__
 
-#define APM_40		0x40
-#define APM_CS		(APM_40 + 8)
+#define APM_CS		0x48
 #define APM_CS_16	(APM_CS + 8)
 #define APM_DS		(APM_CS_16 + 8)
 

  parent reply	other threads:[~2002-08-12 14:44 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-07 18:10 [patch] tls-2.5.30-A1 Ingo Molnar
2002-08-07 18:33 ` Linus Torvalds
2002-08-07 18:43   ` Stephen Rothwell
2002-08-07 18:57     ` Linus Torvalds
2002-08-07 19:40       ` Alexandre Julliard
2002-08-07 19:31   ` Ingo Molnar
2002-08-07 19:49     ` Alexandre Julliard
2002-08-07 22:01   ` Alan Cox
2002-08-07 22:36   ` Luca Barbieri
2002-08-07 22:54     ` Ingo Molnar
2002-08-07 23:21       ` Luca Barbieri
2002-08-07 23:35         ` DMA Problems with Intel 845 Chipset and Northwood CPU Mark Cuss
2002-08-08  0:58           ` John L. Korpi
2002-08-08 16:12             ` Mark Cuss
2002-08-11 21:46   ` [patch] tls-2.5.31-C3 Ingo Molnar
2002-08-12  7:34     ` Stephen Rothwell
2002-08-12 10:07       ` Ingo Molnar
2002-08-12  8:23         ` Stephen Rothwell
2002-08-12 10:08           ` Alan Cox
2002-08-12 10:49             ` Ingo Molnar
2002-08-12 10:34               ` Alan Cox
2002-08-12 12:17                 ` Ingo Molnar
2002-08-12 11:47                   ` Alan Cox
2002-08-12 12:55                     ` Ingo Molnar
2002-08-12 12:29                       ` Alan Cox
2002-08-12 10:35               ` Alan Cox
2002-08-12 13:10             ` Kasper Dupont
2002-08-12 15:20             ` Ingo Molnar
2002-08-12 14:46         ` Stephen Rothwell [this message]
2002-08-12 12:18     ` Luca Barbieri
2002-08-12 15:12       ` Ingo Molnar
2002-08-12 13:43         ` Luca Barbieri
2002-08-12 15:57           ` Ingo Molnar
2002-08-12 14:17             ` Luca Barbieri
2002-08-12 15:53     ` [patch] tls-2.5.31-D3 Ingo Molnar
2002-08-12 16:13       ` [patch] tls-2.5.31-D4 Ingo Molnar
2002-08-12 14:32         ` Luca Barbieri
2002-08-12 17:06         ` [patch] tls-2.5.31-D5 Ingo Molnar
2002-08-12 15:21           ` Jakub Jelinek
2002-08-12 17:41             ` Ingo Molnar
2002-08-12 15:54               ` Luca Barbieri
2002-08-12 18:03               ` [patch] tls-2.5.31-D9 Ingo Molnar
2002-08-13  1:50               ` [patch] tls-2.5.31-D5 Alexandre Julliard
2002-08-12 17:24           ` [patch] tls-2.5.31-D7 Ingo Molnar
2002-08-12 15:45             ` Christoph Hellwig
2002-08-07 19:02 ` [patch] tls-2.5.30-A1 Christoph Hellwig
2002-08-08 12:25 ` Jamie Lokier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020813004634.026db357.sfr@canb.auug.org.au \
    --to=sfr@canb.auug.org.au \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®