[PATCH] Prevent legacy io access on pmac

STALE7282d

7 messages, 3 authors, 2006-09-12 · open the first message on its own page

[PATCH] Prevent legacy io access on pmac

From: Olaf Hering <hidden>
Date: 2006-09-11 11:55:07

The ppc32 common config runs also on PReP/CHRP, which uses PC style IO
devices.  The probing is bogus, it crashes or floods dmesg.

ppc can boot one single binary on prep, chrp and pmac boards.
ppc64 can boot one single binary on pseries and G5 boards.
pmac has no legacy io, probing for PC style legacy hardware leads to a
hard crash:

* add check for parport_pc, exit on pmac.
32bit chrp has no ->check_legacy_ioport, the probe is always called.
64bit chrp has check_legacy_ioport, check for a "parallel" node

* add check for isapnp, only PReP boards may have real ISA slots.
32bit PReP will have no ->check_legacy_ioport, the probe is always called.

* update code in i8042_platform_init. Run ->check_legacy_ioport first, always
call request_region. No functional change. Remove whitespace before i8042_reset init.


Signed-off-by: Olaf Hering <redacted>

---
 arch/powerpc/platforms/pseries/setup.c |    6 ++++++
 drivers/input/serio/i8042-io.h         |   13 +++++--------
 drivers/parport/parport_pc.c           |    4 ++++
 drivers/pnp/pnpbios/core.c             |    8 ++++++++
 include/asm-powerpc/io.h               |    2 ++
 5 files changed, 25 insertions(+), 8 deletions(-)

Index: linux-2.6.18-rc6/arch/powerpc/platforms/pseries/setup.c
===================================================================
--- linux-2.6.18-rc6.orig/arch/powerpc/platforms/pseries/setup.c
+++ linux-2.6.18-rc6/arch/powerpc/platforms/pseries/setup.c
@@ -401,6 +401,12 @@ static int pSeries_check_legacy_ioport(u
 			return -ENODEV;
 		of_node_put(np);
 		break;
+	case PARALLEL_BASE:
+		np = of_find_node_by_type(NULL, "parallel");
+		if (np == NULL)
+			return -ENODEV;
+		of_node_put(np);
+		break;
 	}
 	return 0;
 }
Index: linux-2.6.18-rc6/drivers/input/serio/i8042-io.h
===================================================================
--- linux-2.6.18-rc6.orig/drivers/input/serio/i8042-io.h
+++ linux-2.6.18-rc6/drivers/input/serio/i8042-io.h
@@ -67,25 +67,22 @@ static inline int i8042_platform_init(vo
  * On some platforms touching the i8042 data register region can do really
  * bad things. Because of this the region is always reserved on such boxes.
  */
-#if !defined(__sh__) && !defined(__alpha__) && !defined(__mips__) && !defined(CONFIG_PPC_MERGE)
-	if (!request_region(I8042_DATA_REG, 16, "i8042"))
-		return -EBUSY;
-#endif
-
-        i8042_reset = 1;
-
 #if defined(CONFIG_PPC_MERGE)
 	if (check_legacy_ioport(I8042_DATA_REG))
 		return -EBUSY;
+#endif
+#if !defined(__sh__) && !defined(__alpha__) && !defined(__mips__)
 	if (!request_region(I8042_DATA_REG, 16, "i8042"))
 		return -EBUSY;
 #endif
+
+	i8042_reset = 1;
 	return 0;
 }
 
 static inline void i8042_platform_exit(void)
 {
-#if !defined(__sh__) && !defined(__alpha__) && !defined(CONFIG_PPC64)
+#if !defined(__sh__) && !defined(__alpha__)
 	release_region(I8042_DATA_REG, 16);
 #endif
 }
Index: linux-2.6.18-rc6/drivers/parport/parport_pc.c
===================================================================
--- linux-2.6.18-rc6.orig/drivers/parport/parport_pc.c
+++ linux-2.6.18-rc6/drivers/parport/parport_pc.c
@@ -3374,6 +3374,10 @@ __setup("parport_init_mode=",parport_ini
 
 static int __init parport_pc_init(void)
 {
+#if defined(CONFIG_PPC_MERGE)
+	if (check_legacy_ioport(PARALLEL_BASE))
+		return -EBUSY;
+#endif
 	if (parse_parport_params())
 		return -EINVAL;
 
Index: linux-2.6.18-rc6/include/asm-powerpc/io.h
===================================================================
--- linux-2.6.18-rc6.orig/include/asm-powerpc/io.h
+++ linux-2.6.18-rc6/include/asm-powerpc/io.h
@@ -11,6 +11,8 @@
 
 /* Check of existence of legacy devices */
 extern int check_legacy_ioport(unsigned long base_port);
+#define PARALLEL_BASE	0x378
+#define PNPBIOS_BASE	0xf000	/* only relevant for PReP */
 
 #ifndef CONFIG_PPC64
 #include <asm-ppc/io.h>
Index: linux-2.6.18-rc6/drivers/pnp/pnpbios/core.c
===================================================================
--- linux-2.6.18-rc6.orig/drivers/pnp/pnpbios/core.c
+++ linux-2.6.18-rc6/drivers/pnp/pnpbios/core.c
@@ -526,6 +526,10 @@ static int __init pnpbios_init(void)
 {
 	int ret;
 
+#if defined(CONFIG_PPC_MERGE)
+	if (check_legacy_ioport(PNPBIOS_BASE))
+		return -ENODEV;
+#endif
 	if (pnpbios_disabled || dmi_check_system(pnpbios_dmi_table)) {
 		printk(KERN_INFO "PnPBIOS: Disabled\n");
 		return -ENODEV;
@@ -575,6 +579,10 @@ subsys_initcall(pnpbios_init);
 
 static int __init pnpbios_thread_init(void)
 {
+#if defined(CONFIG_PPC_MERGE)
+	if (check_legacy_ioport(PNPBIOS_BASE))
+		return 0;
+#endif
 	if (pnpbios_disabled)
 		return 0;
 #ifdef CONFIG_HOTPLUG

Re: [PATCH] Prevent legacy io access on pmac

From: Olaf Hering <hidden>
Date: 2006-09-11 15:17:35

On Mon, Sep 11, Olaf Hering wrote:
* add check for parport_pc, exit on pmac.
How do I allow parport on PCI cards?

Re: [PATCH] Prevent legacy io access on pmac

From: Segher Boessenkool <hidden>
Date: 2006-09-11 15:30:24

quoted
* add check for parport_pc, exit on pmac.
How do I allow parport on PCI cards?
Use the parport_serial driver...  cards that are fixed at the
legacy address probably won't work at all on a PowerMac, the PCI
bridges would have to be set up specially and you'll run into all
kinds of problems.

Cards that have a parport with a configurable base address work
fine in a PowerMac.


Segher

Re: [PATCH] Prevent legacy io access on pmac

From: Olaf Hering <hidden>
Date: 2006-09-11 16:01:31

On Mon, Sep 11, Olaf Hering wrote:
The ppc32 common config runs also on PReP/CHRP, which uses PC style IO
devices.  The probing is bogus, it crashes or floods dmesg.

ppc can boot one single binary on prep, chrp and pmac boards.
ppc64 can boot one single binary on pseries and G5 boards.
pmac has no legacy io, probing for PC style legacy hardware leads to a
hard crash:
drivers/input/touchscreen/mk712.c pokes at 0x262 and other IO ports.
A comment in the driver suggests that it is only used on Gateway
computers. Should the driver be X86 only?

Re: [PATCH] Prevent legacy io access on pmac

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: 2006-09-11 23:11:28

On Mon, 2006-09-11 at 17:17 +0200, Olaf Hering wrote:
On Mon, Sep 11, Olaf Hering wrote:
quoted
* add check for parport_pc, exit on pmac.
How do I allow parport on PCI cards?
Doesn't the driver have explicit PCI probing like 8250 ?

Ben.

Re: [PATCH] Prevent legacy io access on pmac

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: 2006-09-11 23:14:48

On Mon, 2006-09-11 at 13:53 +0200, Olaf Hering wrote:
The ppc32 common config runs also on PReP/CHRP, which uses PC style IO
devices.  The probing is bogus, it crashes or floods dmesg.

ppc can boot one single binary on prep, chrp and pmac boards.
ppc64 can boot one single binary on pseries and G5 boards.
pmac has no legacy io, probing for PC style legacy hardware leads to a
hard crash:

* add check for parport_pc, exit on pmac.
32bit chrp has no ->check_legacy_ioport, the probe is always called.
64bit chrp has check_legacy_ioport, check for a "parallel" node

* add check for isapnp, only PReP boards may have real ISA slots.
32bit PReP will have no ->check_legacy_ioport, the probe is always called.

* update code in i8042_platform_init. Run ->check_legacy_ioport first, always
call request_region. No functional change. Remove whitespace before i8042_reset init.


Signed-off-by: Olaf Hering <redacted>
Looks good to me.

Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Re: [PATCH] Prevent legacy io access on pmac

From: Olaf Hering <hidden>
Date: 2006-09-12 19:29:56

Follow up to the previous patch:

Update the return values in i8402 and parport to -ENODEV.

---
 drivers/input/serio/i8042-io.h |    2 +-
 drivers/parport/parport_pc.c   |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Index: linux-2.6.18-rc6/drivers/input/serio/i8042-io.h
===================================================================
--- linux-2.6.18-rc6.orig/drivers/input/serio/i8042-io.h
+++ linux-2.6.18-rc6/drivers/input/serio/i8042-io.h
@@ -69,7 +69,7 @@ static inline int i8042_platform_init(vo
  */
 #if defined(CONFIG_PPC_MERGE)
 	if (check_legacy_ioport(I8042_DATA_REG))
-		return -EBUSY;
+		return -ENODEV;
 #endif
 #if !defined(__sh__) && !defined(__alpha__) && !defined(__mips__)
 	if (!request_region(I8042_DATA_REG, 16, "i8042"))
Index: linux-2.6.18-rc6/drivers/parport/parport_pc.c
===================================================================
--- linux-2.6.18-rc6.orig/drivers/parport/parport_pc.c
+++ linux-2.6.18-rc6/drivers/parport/parport_pc.c
@@ -3376,7 +3376,7 @@ static int __init parport_pc_init(void)
 {
 #if defined(CONFIG_PPC_MERGE)
 	if (check_legacy_ioport(PARALLEL_BASE))
-		return -EBUSY;
+		return -ENODEV;
 #endif
 	if (parse_parport_params())
 		return -EINVAL;
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help