Skip to contentSkip to conversation

uninline check_signature()

PATCH New Heiko Carstens 8 participants 17 messages Jul 16, 2007 – Aug 12, 2007 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 16 lines · Linux Kernel Mailing List
Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=cc2ea416b2aa04d0c34ff2281a23dae5b76b7b3b
Commit:     cc2ea416b2aa04d0c34ff2281a23dae5b76b7b3b
Parent:     4e7bd66318b3ae60fbba7d886d9a98b71ffbf74e
Author:     Andrew Morton <[email protected]>
AuthorDate: Sun Jul 15 23:41:38 2007 -0700
Committer:  Linus Torvalds <[email protected]>
CommitDate: Mon Jul 16 09:05:50 2007 -0700

uninline check_signature()

This is a rather bizarre thing to have inlined in io.h. Stick it in lib/ instead.

While we're there, despaghetti it a bit, and fix its off-by-one behaviour when passed a zero length.

Quoted 7 lines
---
 include/linux/io.h    |   29 ++---------------------------
 lib/Makefile          |    2 +-
 lib/check_signature.c |   26 ++++++++++++++++++++++++++
 3 files changed, 29 insertions(+), 28 deletions(-)

Hmm.. this breaks s390 and probably m68k and UML as well:

CC lib/check_signature.o
lib/check_signature.c: In function 'check_signature':
lib/check_signature.c:19: error: implicit declaration of function 'readb'

Actually we tried to fix this, but it looks like there was no final
conclusion: http://lkml.org/lkml/2007/6/28/98

Now what? Revert until things have been sorted out?

maintainer
#2 lore raw
Quoted 25 lines · On Tue, 17 Jul 2007 00:12:57 +0200 Heiko Carstens <[email protected]>…
Quoted 16 lines · Linux Kernel Mailing List
Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=cc2ea416b2aa04d0c34ff2281a23dae5b76b7b3b
Commit:     cc2ea416b2aa04d0c34ff2281a23dae5b76b7b3b
Parent:     4e7bd66318b3ae60fbba7d886d9a98b71ffbf74e
Author:     Andrew Morton <[email protected]>
AuthorDate: Sun Jul 15 23:41:38 2007 -0700
Committer:  Linus Torvalds <[email protected]>
CommitDate: Mon Jul 16 09:05:50 2007 -0700

uninline check_signature()

This is a rather bizarre thing to have inlined in io.h. Stick it in lib/ instead.

While we're there, despaghetti it a bit, and fix its off-by-one behaviour when passed a zero length.

Quoted 7 lines
---
 include/linux/io.h    |   29 ++---------------------------
 lib/Makefile          |    2 +-
 lib/check_signature.c |   26 ++++++++++++++++++++++++++
 3 files changed, 29 insertions(+), 28 deletions(-)
Quoted 5 lines

Hmm.. this breaks s390 and probably m68k and UML as well:

CC lib/check_signature.o
lib/check_signature.c: In function 'check_signature':
lib/check_signature.c:19: error: implicit declaration of function 'readb'

Yep. They were already broken, only less so.

Quoted 4 lines

Actually we tried to fix this, but it looks like there was no final
conclusion: http://lkml.org/lkml/2007/6/28/98

Now what? Revert until things have been sorted out?

No, no revert, please. If the architecture doesn't support readb() then we need some reliable way of working that out within Kconfig.

#3 lore raw
Quoted 3 lines · Andrew Morton

No, no revert, please. If the architecture doesn't support readb() then we need some reliable way of working that out within Kconfig.

Isn't that CONFIG_HAS_IOMEM?

Linus

#4 lore raw
Quoted 6 lines · Linus Torvalds
Quoted 3 lines · Andrew Morton

No, no revert, please. If the architecture doesn't support readb() then we need some reliable way of working that out within Kconfig.

Isn't that CONFIG_HAS_IOMEM?

That was my understanding as well considering commits 5ea8176994003483a18c8fed580901e2125f8a83 and 23db764d3db5a4bb1e104ad9310e5dc18e4ffa1b

so the patch below should be correct... Geert, Roman?

Subject: [PATCH] Make check_signature() depend on CONFIG_HAS_IOMEM

From: Heiko Carstens <[email protected]>

check_signature() uses readb() and therefore should only be build on CONFIG_HAS_IOMEM.

Otherwise breaks s390:
lib/check_signature.c: In function `check_signature':
lib/check_signature.c:19: error: implicit declaration of function `readb'

---
 lib/Makefile |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
lib/Makefile +2 -2
Index: linux-2.6/lib/Makefile
===================================================================
@@ -13,7 +13,7 @@ lib-$(CONFIG_SMP) += cpumask.o
 lib-y	+= kobject.o kref.o kobject_uevent.o klist.o
 
 obj-y += div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \
-	 bust_spinlocks.o hexdump.o check_signature.o
+	 bust_spinlocks.o hexdump.o
 
 ifeq ($(CONFIG_DEBUG_KOBJECT),y)
 CFLAGS_kobject.o += -DDEBUG
@@ -21,7 +21,7 @@ CFLAGS_kobject_uevent.o += -DDEBUG
 endif
 
 obj-$(CONFIG_GENERIC_IOMAP) += iomap.o
-obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o
+obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o check_signature.o
 obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o
 obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock_debug.o
 lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o
#5 lore raw
Quoted 44 lines · Heiko Carstens
Quoted 6 lines · Linus Torvalds
Quoted 3 lines · Andrew Morton

No, no revert, please. If the architecture doesn't support readb() then we need some reliable way of working that out within Kconfig.

Isn't that CONFIG_HAS_IOMEM?

That was my understanding as well considering commits 5ea8176994003483a18c8fed580901e2125f8a83 and 23db764d3db5a4bb1e104ad9310e5dc18e4ffa1b

so the patch below should be correct... Geert, Roman?

Subject: [PATCH] Make check_signature() depend on CONFIG_HAS_IOMEM

From: Heiko Carstens <[email protected]>

check_signature() uses readb() and therefore should only be build on CONFIG_HAS_IOMEM.

Otherwise breaks s390:
lib/check_signature.c: In function `check_signature':
lib/check_signature.c:19: error: implicit declaration of function `readb'

---
 lib/Makefile |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

Index: linux-2.6/lib/Makefile
===================================================================

lib/Makefile +1 -1
@@ -13,7 +13,7 @@ lib-$(CONFIG_SMP) += cpumask.o
 lib-y	+= kobject.o kref.o kobject_uevent.o klist.o
 
 obj-y += div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \
-	 bust_spinlocks.o hexdump.o check_signature.o
+	 bust_spinlocks.o hexdump.o
 
 ifeq ($(CONFIG_DEBUG_KOBJECT),y)
 CFLAGS_kobject.o += -DDEBUG

lib/Makefile CFLAGS_kobject_uevent.o += -DDEBUG · line 27

Quoted 8 lines
lib/Makefile +1 -1
@@ -21,7 +21,7 @@ CFLAGS_kobject_uevent.o += -DDEBUG
 endif
 
 obj-$(CONFIG_GENERIC_IOMAP) += iomap.o
-obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o
+obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o check_signature.o
 obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o
 obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock_debug.o
 lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o

I saw this patch went in.

iomap_copy.o ues the raw I/O memory accessors, so it truly depends on CONFIG_HAS_IOMEM.

check_signature.o depends on ISA/PCI I/O memory, not on generic I/O memory.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#6 lore raw
Quoted 4 lines · Geert Uytterhoeven

I saw this patch went in.

iomap_copy.o ues the raw I/O memory accessors, so it truly depends on CONFIG_HAS_IOMEM.

This works for UML.

Jeff

Signature · 1 line
Work email - jdike at linux dot intel dot com
#7 lore raw
Quoted 7 lines · Jeff Dike
Quoted 4 lines · Geert Uytterhoeven

I saw this patch went in.

iomap_copy.o ues the raw I/O memory accessors, so it truly depends on CONFIG_HAS_IOMEM.

This works for UML.

Of course. UML (and s390) doesn't have (a need for) I/O memory because it uses paravirtualization for all drivers.

M68k uses I/O memory for all I/O (hence it sets CONFIG_HAS_IOMEM), but many m68k machines don't have PCI or ISA (hence it doesn't set CONFIG_PCI resp. CONFIG_ISA).

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#8 lore raw
Quoted 4 lines · Geert Uytterhoeven

M68k uses I/O memory for all I/O (hence it sets CONFIG_HAS_IOMEM), but many m68k machines don't have PCI or ISA (hence it doesn't set CONFIG_PCI resp. CONFIG_ISA).

It doesn't matter whether the machine has PCI or ISA. The only thing that matters is whether the thing compiles (which in turn depends on whether it has "readb()", which in turn is what HAS_IOMEM is all about).

So I do think that HAS_IOMEM is the right thing here.

Linus

#9 lore raw
Quoted 10 lines · Linus Torvalds
Quoted 3 lines · Geert Uytterhoeven

M68k uses I/O memory for all I/O (hence it sets CONFIG_HAS_IOMEM), but many m68k machines don't have PCI or ISA (hence it doesn't set CONFIG_PCI resp. CONFIG_ISA).

It doesn't matter whether the machine has PCI or ISA. The only thing that matters is whether the thing compiles (which in turn depends on whether it has "readb()", which in turn is what HAS_IOMEM is all about).

So I do think that HAS_IOMEM is the right thing here.

Good, I guess then either I'll have to do something similar to what ARM does:

| #elif !defined(readb)
| 
| #define readb(c)                        (__readwrite_bug("readb"),0)
| #define readw(c)                        (__readwrite_bug("readw"),0)
| #define readl(c)                        (__readwrite_bug("readl"),0)
| #define writeb(v,c)                     __readwrite_bug("writeb")
| #define writew(v,c)                     __readwrite_bug("writew")
| #define writel(v,c)                     __readwrite_bug("writel")
| 
| #define check_signature(io,sig,len)     (0)
| 
| #endif  /* __mem_pci */

(but use the real BUG() instead, I don't think the above will still
compile now check_signature() is out-of-line)

And we'll all live with a check_signature() in our kernel, which is used only by a few legacy drivers that depend on ISA || PCI...

OR I'll have to disable HAS_IOMEM on m68k, and invent a new Kconfig symbol for lots of other stuff that currently depends on HAS_IOMEM...

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#10 lore raw
Quoted 5 lines · Geert Uytterhoeven

And we'll all live with a check_signature() in our kernel, which is used only by a few legacy drivers that depend on ISA || PCI...

OR I'll have to disable HAS_IOMEM on m68k, and invent a new Kconfig symbol for lots of other stuff that currently depends on HAS_IOMEM...

Actually... Is there any reason why it's not simply
kmalloc
memcpy_fromio
memcmp
on all targets? Or just a variably-sized auto array, since we never do it for large stuff, IIRC...

#11 lore raw
In reply to Geert Uytterhoeven
Quoted 3 lines · Geert Uytterhoeven

OR I'll have to disable HAS_IOMEM on m68k, and invent a new Kconfig symbol for lots of other stuff that currently depends on HAS_IOMEM...

Well, as far as I'm concerned, you could also make all drivers that actually need "check_signature()" do a Kconfig level

select CHECK_SIGNATURE

along with a

config CHECK_SIGNATURE
bool
default n

in lib/Kconfig, and thus make it totally independent of any hw/bus features at all, and simply depend on whether it is needed or not. I'd be ok with that, and it's certainly "correct" too.

Hmm?

Linus

#12 lore raw
Quoted 15 lines · Linus Torvalds
Quoted 2 lines · Geert Uytterhoeven

OR I'll have to disable HAS_IOMEM on m68k, and invent a new Kconfig symbol for lots of other stuff that currently depends on HAS_IOMEM...

Well, as far as I'm concerned, you could also make all drivers that actually need "check_signature()" do a Kconfig level

select CHECK_SIGNATURE

along with a

config CHECK_SIGNATURE
bool
default n

Quoted 5 lines

in lib/Kconfig, and thus make it totally independent of any hw/bus features at all, and simply depend on whether it is needed or not. I'd be ok with that, and it's certainly "correct" too.

Hmm?

(will cook a patch when I find a timeslot)

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#13 lore raw

PATCH 1/1 Introduce CONFIG_CHECK_SIGNATURE (was: Re: uninline check_signature())

In reply to Linus Torvalds

Hi Linus,

Quoted 15 lines · Linus Torvalds
Quoted 2 lines · Geert Uytterhoeven

OR I'll have to disable HAS_IOMEM on m68k, and invent a new Kconfig symbol for lots of other stuff that currently depends on HAS_IOMEM...

Well, as far as I'm concerned, you could also make all drivers that actually need "check_signature()" do a Kconfig level

select CHECK_SIGNATURE

along with a

config CHECK_SIGNATURE
bool
default n

Quoted 5 lines

in lib/Kconfig, and thus make it totally independent of any hw/bus features at all, and simply depend on whether it is needed or not. I'd be ok with that, and it's certainly "correct" too.

Hmm?

So here it is...

---
Subject: Introduce CONFIG_CHECK_SIGNATURE

Introduce CONFIG_CHECK_SIGNATURE to control inclusion of check_signature() and avoid problems on platforms that don't have readb().

Let the few legacy (ISA || PCI || X86) drivers that need check_signature() select CONFIG_CHECK_SIGNATURE.

---
 drivers/block/Kconfig      |    1 +
 drivers/input/misc/Kconfig |    1 +
 drivers/scsi/Kconfig       |    6 ++++++
 lib/Kconfig                |    3 +++
 lib/Makefile               |    3 ++-
 5 files changed, 13 insertions(+), 1 deletion(-)
drivers/block/Kconfig +1 -0
@@ -62,6 +62,7 @@ config AMIGA_Z2RAM
 config BLK_DEV_XD
 	tristate "XT hard disk support"
 	depends on ISA && ISA_DMA_API
+	select CHECK_SIGNATURE
 	help
 	  Very old 8 bit hard disk controllers used in the IBM XT computer
 	  will be supported if you say Y here.
drivers/input/misc/Kconfig +1 -0
@@ -68,6 +68,7 @@ config INPUT_WISTRON_BTNS
 	select INPUT_POLLDEV
 	select NEW_LEDS
 	select LEDS_CLASS
+	select CHECK_SIGNATURE
 	help
 	  Say Y here for support of Winstron laptop button interface, used on
 	  laptops of various brands, including Acer and Fujitsu-Siemens. If
drivers/scsi/Kconfig +6 -0
@@ -367,6 +367,7 @@ config SCSI_3W_9XXX
 config SCSI_7000FASST
 	tristate "7000FASST SCSI support"
 	depends on ISA && SCSI && ISA_DMA_API
+	select CHECK_SIGNATURE
 	help
 	  This driver supports the Western Digital 7000 SCSI host adapter
 	  family.  Some information is in the source:
@@ -388,6 +389,7 @@ config SCSI_AHA152X
 	tristate "Adaptec AHA152X/2825 support"
 	depends on ISA && SCSI && !64BIT
 	select SCSI_SPI_ATTRS
+	select CHECK_SIGNATURE
 	---help---
 	  This is a driver for the AHA-1510, AHA-1520, AHA-1522, and AHA-2825
 	  SCSI host adapters. It also works for the AVA-1505, but the IRQ etc.
@@ -583,6 +585,7 @@ config SCSI_DTC3280
 	tristate "DTC3180/3280 SCSI support"
 	depends on ISA && SCSI
 	select SCSI_SPI_ATTRS
+	select CHECK_SIGNATURE
 	help
 	  This is support for DTC 3180/3280 SCSI Host Adapters.  Please read
 	  the SCSI-HOWTO, available from
@@ -657,6 +660,7 @@ config SCSI_EATA_PIO
 config SCSI_FUTURE_DOMAIN
 	tristate "Future Domain 16xx SCSI/AHA-2920A support"
 	depends on (ISA || PCI) && SCSI
+	select CHECK_SIGNATURE
 	---help---
 	  This is support for Future Domain's 16-bit SCSI host adapters
 	  (TMC-1660/1680, TMC-1650/1670, TMC-3260, TMC-1610M/MER/MEX) and
@@ -1324,6 +1328,7 @@ config SCSI_LPFC
 config SCSI_SEAGATE
 	tristate "Seagate ST-02 and Future Domain TMC-8xx SCSI support"
 	depends on X86 && ISA && SCSI
+	select CHECK_SIGNATURE
 	---help---
 	  These are 8-bit SCSI controllers; the ST-01 is also supported by
 	  this driver.  It is explained in section 3.9 of the SCSI-HOWTO,
@@ -1397,6 +1402,7 @@ config SCSI_T128
 	tristate "Trantor T128/T128F/T228 SCSI support"
 	depends on ISA && SCSI
 	select SCSI_SPI_ATTRS
+	select CHECK_SIGNATURE
 	---help---
 	  This is support for a SCSI host adapter. It is explained in section
 	  3.11 of the SCSI-HOWTO, available from
lib/Kconfig +3 -0
@@ -138,4 +138,7 @@ config HAS_DMA
 	depends on !NO_DMA
 	default y
 
+config CHECK_SIGNATURE
+	bool
+
 endmenu
lib/Makefile +2 -1
@@ -21,7 +21,8 @@ CFLAGS_kobject_uevent.o += -DDEBUG
 endif
 
 obj-$(CONFIG_GENERIC_IOMAP) += iomap.o
-obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o check_signature.o
+obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o
+obj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o
 obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o
 obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock_debug.o
 lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#14 lore raw
In reply to Linus Torvalds
Quoted 5 lines · Linus Torvalds
Quoted 2 lines · Andrew Morton

No, no revert, please. If the architecture doesn't support readb() then we need some reliable way of working that out within Kconfig.

Isn't that CONFIG_HAS_IOMEM?

No, having memory mapped I/O doesn't mean you have PCI. How to access memory mapped I/O depends on the bus behind the device.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#15 lore raw
Quoted 9 lines · Geert Uytterhoeven
Quoted 5 lines · Linus Torvalds
Quoted 2 lines · Andrew Morton

No, no revert, please. If the architecture doesn't support readb() then we need some reliable way of working that out within Kconfig.

Isn't that CONFIG_HAS_IOMEM?

No, having memory mapped I/O doesn't mean you have PCI. How to access memory mapped I/O depends on the bus behind the device.

Like I said before:

| Just make check_signature() depend on ISA || PCI (and maybe || X86_32).

It's used by only a handful of legacy drivers.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#16 lore raw
In reply to Geert Uytterhoeven
Quoted 6 lines · Geert Uytterhoeven
Quoted 4 lines
Quoted 2 lines

No, no revert, please. If the architecture doesn't support readb() then we need some reliable way of working that out within Kconfig.

Isn't that CONFIG_HAS_IOMEM?

No, having memory mapped I/O doesn't mean you have PCI.

Hmm, TURBOchannel is not PCI, but is still accessible with
{read,write}{b,w,l}().

Quoted 1 line

How to access memory mapped I/O depends on the bus behind the device.

I would have thought this is to be resolved within ioremap() so that
drivers can be made portable without twisting your arms. With the more recent ioport_map() call that may be extended to port I/O type devices as well. The Alpha with its dense and sparse I/O space proves it can be done for arbitrarily complicated arrangements.

Maciej

#17 lore raw
In reply to Heiko Carstens

Hi Heiko,

Quoted 5 lines · Heiko Carstens

Hmm.. this breaks s390 and probably m68k and UML as well:

CC lib/check_signature.o
lib/check_signature.c: In function 'check_signature':
lib/check_signature.c:19: error: implicit declaration of function 'readb'

Just to confirm: it breaks UML too.