2005-12-23 06:16:00

by Al Viro

[permalink] [raw]
Subject: [WTF?] sys_tas() on m32r

asmlinkage int sys_tas(int *addr)
{
int oldval;
unsigned long flags;

if (!access_ok(VERIFY_WRITE, addr, sizeof (int)))
return -EFAULT;
local_irq_save(flags);
oldval = *addr;
if (!oldval)
*addr = 1;
local_irq_restore(flags);
return oldval;
}
in arch/m32r/kernel/sys_m32r.c. Trivial oops *AND* ability to trigger
IO with interrupts disabled.


2005-12-23 07:50:41

by liyu

[permalink] [raw]
Subject: Re: [WTF?] sys_tas() on m32r

Al Viro 写道:

>asmlinkage int sys_tas(int *addr)
>{
> int oldval;
> unsigned long flags;
>
> if (!access_ok(VERIFY_WRITE, addr, sizeof (int)))
> return -EFAULT;
> local_irq_save(flags);
> oldval = *addr;
> if (!oldval)
> *addr = 1;
> local_irq_restore(flags);
> return oldval;
>}
>in arch/m32r/kernel/sys_m32r.c. Trivial oops *AND* ability to trigger
>IO with interrupts disabled.
>-
>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>the body of a message to [email protected]
>More majordomo info at http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at http://www.tux.org/lkml/
>
>
>
>
The memory that parameter addr pointer is in user-space.
To access these memory, you should use function like copy_from_user().

-liyu




2005-12-23 07:54:53

by Al Viro

[permalink] [raw]
Subject: Re: [WTF?] sys_tas() on m32r

On Fri, Dec 23, 2005 at 03:50:32PM +0800, liyu wrote:
> >in arch/m32r/kernel/sys_m32r.c. Trivial oops *AND* ability to trigger
> >IO with interrupts disabled.

> The memory that parameter addr pointer is in user-space.
> To access these memory, you should use function like copy_from_user().

... which is deadly with interrupts disabled/under a spinlock. Exactly.

2005-12-23 13:56:10

by Andrew Morton

[permalink] [raw]
Subject: Re: [WTF?] sys_tas() on m32r

Al Viro <[email protected]> wrote:
>
> asmlinkage int sys_tas(int *addr)
> {
> int oldval;
> unsigned long flags;
>
> if (!access_ok(VERIFY_WRITE, addr, sizeof (int)))
> return -EFAULT;
> local_irq_save(flags);
> oldval = *addr;
> if (!oldval)
> *addr = 1;
> local_irq_restore(flags);
> return oldval;
> }
> in arch/m32r/kernel/sys_m32r.c. Trivial oops *AND* ability to trigger
> IO with interrupts disabled.

Yeah. I pointed this out to Takata in October last year and then promptly
forgot about it. It's rather amazing that this code (which appears to be in
live use in linuxthreads) hasn't generated oopses.

The problem is that touching *addr will generate an oops if that page isn't
paged in. If we convert it to use get_user() then that's an improvement,
but we must not run get_user() under spinlock or local_irq_disable().

The safe-and-slow way to do this is to pin the page with get_user_pages().

A smarter way to do it is to do something similar to filemap_copy_from_user():

for ( ; ; ) {
get_user(c, addr);
inc_preempt_count();
if (get_user(oldval, addr)) {
dec_preempt_count();
continue;
}
if (!oldval && put_user(1, addr)) {
dec_preempt_count();
continue;
}
dec_preempt_count();
break;
}

ie: try to fault the page in with get_user(), then switch into atomic mode
and try the memory access. If the page isn't there any more, get_user()
and put_user() will return -EFAULT without entering the pagefault handler
(the in_atomic() test in do_page_fault()) so we can just retry the pagein.



The above all assumes CONFIG_MMU. I guess sys_tas() as it stands is OK if
!CONFIG_MMU.

2005-12-23 19:06:07

by Lee Revell

[permalink] [raw]
Subject: Re: [WTF?] sys_tas() on m32r

On Fri, 2005-12-23 at 05:55 -0800, Andrew Morton wrote:
> Al Viro <[email protected]> wrote:
> >
> > asmlinkage int sys_tas(int *addr)
> > {
> > int oldval;
> > unsigned long flags;
> >
> > if (!access_ok(VERIFY_WRITE, addr, sizeof (int)))
> > return -EFAULT;
> > local_irq_save(flags);
> > oldval = *addr;
> > if (!oldval)
> > *addr = 1;
> > local_irq_restore(flags);
> > return oldval;
> > }
> > in arch/m32r/kernel/sys_m32r.c. Trivial oops *AND* ability to trigger
> > IO with interrupts disabled.
>
> Yeah. I pointed this out to Takata in October last year and then promptly
> forgot about it. It's rather amazing that this code (which appears to be in
> live use in linuxthreads) hasn't generated oopses.

No one uses LinuxThreads anymore?

Even the oldest of the old (Debian stable) have moved to NPTL.

Lee

2005-12-27 05:27:47

by Hirokazu Takata

[permalink] [raw]
Subject: Re: [WTF?] sys_tas() on m32r

Hi,

From: Andrew Morton <[email protected]>
Date: Fri, 23 Dec 2005 05:55:26 -0800
> Al Viro <[email protected]> wrote:
> >
> > asmlinkage int sys_tas(int *addr)
> > {
> > int oldval;
> > unsigned long flags;
> >
> > if (!access_ok(VERIFY_WRITE, addr, sizeof (int)))
> > return -EFAULT;
> > local_irq_save(flags);
> > oldval = *addr;
> > if (!oldval)
> > *addr = 1;
> > local_irq_restore(flags);
> > return oldval;
> > }
> > in arch/m32r/kernel/sys_m32r.c. Trivial oops *AND* ability to trigger
> > IO with interrupts disabled.
>
> Yeah. I pointed this out to Takata in October last year and then promptly
> forgot about it. It's rather amazing that this code (which appears to be in
> live use in linuxthreads) hasn't generated oopses.

Yes, I remember it.

> The problem is that touching *addr will generate an oops if that page isn't
> paged in. If we convert it to use get_user() then that's an improvement,
> but we must not run get_user() under spinlock or local_irq_disable().

Exactly.
This problem has been bothering me, but I cannot find a good solusion...

> The safe-and-slow way to do this is to pin the page with get_user_pages().
>
> A smarter way to do it is to do something similar to filemap_copy_from_user():
>
> for ( ; ; ) {
> get_user(c, addr);
> inc_preempt_count();
> if (get_user(oldval, addr)) {
> dec_preempt_count();
> continue;
> }
> if (!oldval && put_user(1, addr)) {
> dec_preempt_count();
> continue;
> }
> dec_preempt_count();
> break;
> }
>
> ie: try to fault the page in with get_user(), then switch into atomic mode
> and try the memory access. If the page isn't there any more, get_user()
> and put_user() will return -EFAULT without entering the pagefault handler
> (the in_atomic() test in do_page_fault()) so we can just retry the pagein.
>
>
>
>
> The above all assumes CONFIG_MMU. I guess sys_tas() as it stands is OK if
> !CONFIG_MMU.
>

I tried the latter way as the following patch, but the result was not
so gratifying; some hangups/lockups or kernel panics happened unexpectedly.

Am I missing anything?
Any more comments or suggestions will be greatly appreciated.

Thank you.

-- Takata


arch/m32r/kernel/sys_m32r.c | 41 ++++++++++++++---------------------------
1 file changed, 14 insertions(+), 27 deletions(-)

Index: linux-2.6.15-rc7/arch/m32r/kernel/sys_m32r.c
===================================================================
--- linux-2.6.15-rc7.orig/arch/m32r/kernel/sys_m32r.c 2005-12-27 10:33:05.301372856 +0900
+++ linux-2.6.15-rc7/arch/m32r/kernel/sys_m32r.c 2005-12-27 10:33:10.222624712 +0900
@@ -29,44 +29,31 @@

/*
* sys_tas() - test-and-set
- * linuxthreads testing version
*/
-#ifndef CONFIG_SMP
asmlinkage int sys_tas(int *addr)
{
int oldval;
- unsigned long flags;

if (!access_ok(VERIFY_WRITE, addr, sizeof (int)))
return -EFAULT;
- local_irq_save(flags);
- oldval = *addr;
- if (!oldval)
- *addr = 1;
- local_irq_restore(flags);
- return oldval;
-}
-#else /* CONFIG_SMP */
-#include <linux/spinlock.h>
-
-static DEFINE_SPINLOCK(tas_lock);
-
-asmlinkage int sys_tas(int *addr)
-{
- int oldval;

- if (!access_ok(VERIFY_WRITE, addr, sizeof (int)))
- return -EFAULT;
-
- _raw_spin_lock(&tas_lock);
- oldval = *addr;
- if (!oldval)
- *addr = 1;
- _raw_spin_unlock(&tas_lock);
+ for ( ; ; ) {
+ get_user(oldval, addr);
+ inc_preempt_count();
+ if (get_user(oldval, addr)) {
+ dec_preempt_count();
+ continue;
+ }
+ if (!oldval && put_user(1, addr)) {
+ dec_preempt_count();
+ continue;
+ }
+ dec_preempt_count();
+ break;
+ }

return oldval;
}
-#endif /* CONFIG_SMP */

/*
* sys_pipe() is the normal C calling standard for creating


---
There are several error patterns:

1) soft lockup
:
Initializing random number generator...done.
Recovering nvi editor sessions... done.
Setting up X server socket directory /tmp/.X11-unix...done.
Setting up ICE socket directory /tmp/.ICE-unix...done.
INIT: Entering runlevel: 2
Starting portmap daemon: portmap.
Starting internet superserver: inetd.
Starting OpenBSD Secure Shell server: sshdBUG: soft lockup detected on CPU#0!

BPC[880dee20]:PSW[00004000]:LR [88026734]:FP [ffffffff]
BBPC[880050a0]:BBPSW[00000070]:SPU[7fa61d68]:SPI[88f01e50]
R0 [881a00e8]:R1 [881a0140]:R2 [880050a0]:R3 [00000000]
R4 [880055c8]:R5 [0000000b]:R6 [881a0090]:R7 [00000001]
R8 [880050a0]:R9 [88f4e9a0]:R10[2ada2000]:R11[2ada20c4]
R12[00000003]
ACC0H[00000000]:ACC0L[00010000]
ACC1H[00000000]:ACC1L[0000000c]
--> <hangup>

2) simply hangup
:
Initializing random number generator...done.
Recovering nvi editor sessions... done.
Setting up X server socket directory /tmp/.X11-unix...done.
Setting up ICE socket directory /tmp/.ICE-unix...done.
INIT: Entering runlevel: 2
Starting portmap daemon: portmap.
Starting internet superserver: inetd.
Starting OpenBSD Secure Shell server: sshd
--> <hangup>

3) kernel panic
:
Initializing random number generator...done.
Recovering nvi editor sessions... done.
Setting up X server socket directory /tmp/.X11-unix...done.
Setting up ICE socket directory /tmp/.ICE-unix...done.
INIT: Entering runlevel: 2
Starting portmap daemon: portmap.
Starting internet superserver: inetdkernel BUG at include/linux/dcache.h:294!
Kernel panic - not syncing: BUG!


--- .config for the debug ---------
#
# Automatically generated make config: don't edit
# Linux kernel version: 2.6.15-rc7
# Tue Dec 27 13:48:20 2005
#
CONFIG_M32R=y
# CONFIG_UID16 is not set
CONFIG_GENERIC_ISA_DMA=y
CONFIG_GENERIC_HARDIRQS=y
CONFIG_GENERIC_IRQ_PROBE=y

#
# Code maturity level options
#
CONFIG_EXPERIMENTAL=y
CONFIG_CLEAN_COMPILE=y
CONFIG_LOCK_KERNEL=y
CONFIG_INIT_ENV_ARG_LIMIT=32

#
# General setup
#
CONFIG_LOCALVERSION=""
CONFIG_LOCALVERSION_AUTO=y
CONFIG_SWAP=y
CONFIG_SYSVIPC=y
# CONFIG_POSIX_MQUEUE is not set
CONFIG_BSD_PROCESS_ACCT=y
# CONFIG_BSD_PROCESS_ACCT_V3 is not set
CONFIG_SYSCTL=y
# CONFIG_AUDIT is not set
CONFIG_HOTPLUG=y
CONFIG_KOBJECT_UEVENT=y
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
# CONFIG_CPUSETS is not set
CONFIG_INITRAMFS_SOURCE=""
# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
CONFIG_EMBEDDED=y
# CONFIG_KALLSYMS is not set
CONFIG_PRINTK=y
CONFIG_BUG=y
CONFIG_BASE_FULL=y
# CONFIG_FUTEX is not set
# CONFIG_EPOLL is not set
CONFIG_SHMEM=y
CONFIG_CC_ALIGN_FUNCTIONS=0
CONFIG_CC_ALIGN_LABELS=0
CONFIG_CC_ALIGN_LOOPS=0
CONFIG_CC_ALIGN_JUMPS=0
# CONFIG_TINY_SHMEM is not set
CONFIG_BASE_SMALL=0

#
# Loadable module support
#
CONFIG_MODULES=y
CONFIG_MODULE_UNLOAD=y
# CONFIG_MODULE_FORCE_UNLOAD is not set
CONFIG_OBSOLETE_MODPARM=y
# CONFIG_MODVERSIONS is not set
# CONFIG_MODULE_SRCVERSION_ALL is not set
CONFIG_KMOD=y
CONFIG_STOP_MACHINE=y

#
# Block layer
#

#
# IO Schedulers
#
CONFIG_IOSCHED_NOOP=y
# CONFIG_IOSCHED_AS is not set
CONFIG_IOSCHED_DEADLINE=y
CONFIG_IOSCHED_CFQ=y
# CONFIG_DEFAULT_AS is not set
CONFIG_DEFAULT_DEADLINE=y
# CONFIG_DEFAULT_CFQ is not set
# CONFIG_DEFAULT_NOOP is not set
CONFIG_DEFAULT_IOSCHED="deadline"

#
# Processor type and features
#
# CONFIG_PLAT_MAPPI is not set
# CONFIG_PLAT_USRV is not set
CONFIG_PLAT_M32700UT=y
# CONFIG_PLAT_OPSPUT is not set
# CONFIG_PLAT_OAKS32R is not set
# CONFIG_PLAT_MAPPI2 is not set
# CONFIG_PLAT_MAPPI3 is not set
CONFIG_CHIP_M32700=y
# CONFIG_CHIP_M32102 is not set
# CONFIG_CHIP_VDEC2 is not set
# CONFIG_CHIP_OPSP is not set
CONFIG_MMU=y
CONFIG_TLB_ENTRIES=32
CONFIG_ISA_M32R2=y
CONFIG_ISA_DSP_LEVEL2=y
CONFIG_ISA_DUAL_ISSUE=y
CONFIG_BUS_CLOCK=50000000
CONFIG_TIMER_DIVIDE=128
# CONFIG_CPU_LITTLE_ENDIAN is not set
CONFIG_MEMORY_START=0x08000000
CONFIG_MEMORY_SIZE=0x01000000
CONFIG_NOHIGHMEM=y
CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
CONFIG_SELECT_MEMORY_MODEL=y
# CONFIG_FLATMEM_MANUAL is not set
CONFIG_DISCONTIGMEM_MANUAL=y
# CONFIG_SPARSEMEM_MANUAL is not set
CONFIG_DISCONTIGMEM=y
CONFIG_FLAT_NODE_MEM_MAP=y
CONFIG_NEED_MULTIPLE_NODES=y
# CONFIG_SPARSEMEM_STATIC is not set
CONFIG_SPLIT_PTLOCK_CPUS=4
CONFIG_IRAM_START=0x00f00000
CONFIG_IRAM_SIZE=0x00080000
CONFIG_RWSEM_GENERIC_SPINLOCK=y
# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
CONFIG_GENERIC_CALIBRATE_DELAY=y
CONFIG_PREEMPT=y
CONFIG_SMP=y
# CONFIG_CHIP_M32700_TS1 is not set
CONFIG_NR_CPUS=2

#
# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
#
# CONFIG_ISA is not set

#
# PCCARD (PCMCIA/CardBus) support
#
# CONFIG_PCCARD is not set

#
# PCI Hotplug Support
#

#
# Executable file formats
#
CONFIG_BINFMT_ELF=y
# CONFIG_BINFMT_MISC is not set

#
# Networking
#
CONFIG_NET=y

#
# Networking options
#
CONFIG_PACKET=y
# CONFIG_PACKET_MMAP is not set
CONFIG_UNIX=y
# CONFIG_NET_KEY is not set
CONFIG_INET=y
# CONFIG_IP_MULTICAST is not set
# CONFIG_IP_ADVANCED_ROUTER is not set
CONFIG_IP_FIB_HASH=y
CONFIG_IP_PNP=y
CONFIG_IP_PNP_DHCP=y
# CONFIG_IP_PNP_BOOTP is not set
# CONFIG_IP_PNP_RARP is not set
# CONFIG_NET_IPIP is not set
# CONFIG_NET_IPGRE is not set
# CONFIG_ARPD is not set
# CONFIG_SYN_COOKIES is not set
# CONFIG_INET_AH is not set
# CONFIG_INET_ESP is not set
# CONFIG_INET_IPCOMP is not set
# CONFIG_INET_TUNNEL is not set
CONFIG_INET_DIAG=y
CONFIG_INET_TCP_DIAG=y
# CONFIG_TCP_CONG_ADVANCED is not set
CONFIG_TCP_CONG_BIC=y
# CONFIG_IPV6 is not set
# CONFIG_NETFILTER is not set

#
# DCCP Configuration (EXPERIMENTAL)
#
# CONFIG_IP_DCCP is not set

#
# SCTP Configuration (EXPERIMENTAL)
#
# CONFIG_IP_SCTP is not set
# CONFIG_ATM is not set
# CONFIG_BRIDGE is not set
# CONFIG_VLAN_8021Q is not set
# CONFIG_DECNET is not set
# CONFIG_LLC2 is not set
# CONFIG_IPX is not set
# CONFIG_ATALK is not set
# CONFIG_X25 is not set
# CONFIG_LAPB is not set
# CONFIG_NET_DIVERT is not set
# CONFIG_ECONET is not set
# CONFIG_WAN_ROUTER is not set

#
# QoS and/or fair queueing
#
# CONFIG_NET_SCHED is not set

#
# Network testing
#
# CONFIG_NET_PKTGEN is not set
# CONFIG_HAMRADIO is not set
# CONFIG_IRDA is not set
# CONFIG_BT is not set
# CONFIG_IEEE80211 is not set

#
# Device Drivers
#

#
# Generic Driver Options
#
CONFIG_STANDALONE=y
CONFIG_PREVENT_FIRMWARE_BUILD=y
CONFIG_FW_LOADER=y
# CONFIG_DEBUG_DRIVER is not set

#
# Connector - unified userspace <-> kernelspace linker
#
CONFIG_CONNECTOR=y
CONFIG_PROC_EVENTS=y

#
# Memory Technology Devices (MTD)
#
CONFIG_MTD=y
# CONFIG_MTD_DEBUG is not set
# CONFIG_MTD_CONCAT is not set
CONFIG_MTD_PARTITIONS=y
CONFIG_MTD_REDBOOT_PARTS=y
CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
# CONFIG_MTD_CMDLINE_PARTS is not set

#
# User Modules And Translation Layers
#
# CONFIG_MTD_CHAR is not set
CONFIG_MTD_BLOCK=y
# CONFIG_FTL is not set
# CONFIG_NFTL is not set
# CONFIG_INFTL is not set
# CONFIG_RFD_FTL is not set

#
# RAM/ROM/Flash chip drivers
#
CONFIG_MTD_CFI=m
CONFIG_MTD_JEDECPROBE=m
CONFIG_MTD_GEN_PROBE=m
CONFIG_MTD_CFI_ADV_OPTIONS=y
# CONFIG_MTD_CFI_NOSWAP is not set
CONFIG_MTD_CFI_BE_BYTE_SWAP=y
# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
CONFIG_MTD_CFI_GEOMETRY=y
CONFIG_MTD_MAP_BANK_WIDTH_1=y
CONFIG_MTD_MAP_BANK_WIDTH_2=y
CONFIG_MTD_MAP_BANK_WIDTH_4=y
# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
CONFIG_MTD_CFI_I1=y
# CONFIG_MTD_CFI_I2 is not set
# CONFIG_MTD_CFI_I4 is not set
# CONFIG_MTD_CFI_I8 is not set
# CONFIG_MTD_OTP is not set
# CONFIG_MTD_CFI_INTELEXT is not set
CONFIG_MTD_CFI_AMDSTD=m
CONFIG_MTD_CFI_AMDSTD_RETRY=0
# CONFIG_MTD_CFI_STAA is not set
CONFIG_MTD_CFI_UTIL=m
# CONFIG_MTD_RAM is not set
# CONFIG_MTD_ROM is not set
# CONFIG_MTD_ABSENT is not set

#
# Mapping drivers for chip access
#
# CONFIG_MTD_COMPLEX_MAPPINGS is not set
# CONFIG_MTD_PHYSMAP is not set
# CONFIG_MTD_PLATRAM is not set

#
# Self-contained MTD device drivers
#
# CONFIG_MTD_SLRAM is not set
# CONFIG_MTD_PHRAM is not set
# CONFIG_MTD_MTDRAM is not set
# CONFIG_MTD_BLKMTD is not set
# CONFIG_MTD_BLOCK2MTD is not set

#
# Disk-On-Chip Device Drivers
#
# CONFIG_MTD_DOC2000 is not set
# CONFIG_MTD_DOC2001 is not set
# CONFIG_MTD_DOC2001PLUS is not set

#
# NAND Flash Device Drivers
#
# CONFIG_MTD_NAND is not set

#
# OneNAND Flash Device Drivers
#
# CONFIG_MTD_ONENAND is not set

#
# Parallel port support
#
# CONFIG_PARPORT is not set

#
# Plug and Play support
#

#
# Block devices
#
# CONFIG_BLK_DEV_COW_COMMON is not set
CONFIG_BLK_DEV_LOOP=y
# CONFIG_BLK_DEV_CRYPTOLOOP is not set
# CONFIG_BLK_DEV_NBD is not set
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_COUNT=16
CONFIG_BLK_DEV_RAM_SIZE=4096
# CONFIG_BLK_DEV_INITRD is not set
# CONFIG_CDROM_PKTCDVD is not set
CONFIG_ATA_OVER_ETH=m

#
# ATA/ATAPI/MFM/RLL support
#
CONFIG_IDE=y
CONFIG_BLK_DEV_IDE=y

#
# Please see Documentation/ide.txt for help/info on IDE drives
#
# CONFIG_BLK_DEV_IDE_SATA is not set
CONFIG_BLK_DEV_IDEDISK=y
# CONFIG_IDEDISK_MULTI_MODE is not set
CONFIG_BLK_DEV_IDECD=m
# CONFIG_BLK_DEV_IDETAPE is not set
# CONFIG_BLK_DEV_IDEFLOPPY is not set
# CONFIG_BLK_DEV_IDESCSI is not set
# CONFIG_IDE_TASK_IOCTL is not set

#
# IDE chipset support/bugfixes
#
CONFIG_IDE_GENERIC=y
# CONFIG_IDE_ARM is not set
# CONFIG_BLK_DEV_IDEDMA is not set
# CONFIG_IDEDMA_AUTO is not set
# CONFIG_BLK_DEV_HD is not set

#
# SCSI device support
#
# CONFIG_RAID_ATTRS is not set
CONFIG_SCSI=m
CONFIG_SCSI_PROC_FS=y

#
# SCSI support type (disk, tape, CD-ROM)
#
CONFIG_BLK_DEV_SD=m
# CONFIG_CHR_DEV_ST is not set
# CONFIG_CHR_DEV_OSST is not set
CONFIG_BLK_DEV_SR=m
# CONFIG_BLK_DEV_SR_VENDOR is not set
CONFIG_CHR_DEV_SG=m
# CONFIG_CHR_DEV_SCH is not set

#
# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
#
CONFIG_SCSI_MULTI_LUN=y
# CONFIG_SCSI_CONSTANTS is not set
# CONFIG_SCSI_LOGGING is not set

#
# SCSI Transport Attributes
#
# CONFIG_SCSI_SPI_ATTRS is not set
# CONFIG_SCSI_FC_ATTRS is not set
# CONFIG_SCSI_ISCSI_ATTRS is not set
# CONFIG_SCSI_SAS_ATTRS is not set

#
# SCSI low-level drivers
#
# CONFIG_ISCSI_TCP is not set
# CONFIG_SCSI_SATA is not set
# CONFIG_SCSI_DEBUG is not set

#
# Multi-device support (RAID and LVM)
#
# CONFIG_MD is not set

#
# Fusion MPT device support
#
# CONFIG_FUSION is not set

#
# IEEE 1394 (FireWire) support
#

#
# I2O device support
#

#
# Network device support
#
CONFIG_NETDEVICES=y
# CONFIG_DUMMY is not set
# CONFIG_BONDING is not set
# CONFIG_EQUALIZER is not set
# CONFIG_TUN is not set

#
# PHY device support
#
# CONFIG_PHYLIB is not set

#
# Ethernet (10 or 100Mbit)
#
CONFIG_NET_ETHERNET=y
CONFIG_MII=y
CONFIG_SMC91X=y
# CONFIG_NE2000 is not set

#
# Ethernet (1000 Mbit)
#

#
# Ethernet (10000 Mbit)
#

#
# Token Ring devices
#

#
# Wireless LAN (non-hamradio)
#
# CONFIG_NET_RADIO is not set

#
# Wan interfaces
#
# CONFIG_WAN is not set
# CONFIG_PPP is not set
# CONFIG_SLIP is not set
# CONFIG_SHAPER is not set
# CONFIG_NETCONSOLE is not set
# CONFIG_NETPOLL is not set
# CONFIG_NET_POLL_CONTROLLER is not set

#
# ISDN subsystem
#
# CONFIG_ISDN is not set

#
# Telephony Support
#
# CONFIG_PHONE is not set

#
# Input device support
#
CONFIG_INPUT=y

#
# Userland interfaces
#
# CONFIG_INPUT_MOUSEDEV is not set
# CONFIG_INPUT_JOYDEV is not set
# CONFIG_INPUT_TSDEV is not set
# CONFIG_INPUT_EVDEV is not set
# CONFIG_INPUT_EVBUG is not set

#
# Input Device Drivers
#
# CONFIG_INPUT_KEYBOARD is not set
# CONFIG_INPUT_MOUSE is not set
# CONFIG_INPUT_JOYSTICK is not set
# CONFIG_INPUT_TOUCHSCREEN is not set
# CONFIG_INPUT_MISC is not set

#
# Hardware I/O ports
#
CONFIG_SERIO=y
# CONFIG_SERIO_I8042 is not set
CONFIG_SERIO_SERPORT=y
# CONFIG_SERIO_LIBPS2 is not set
# CONFIG_SERIO_RAW is not set
# CONFIG_GAMEPORT is not set

#
# Character devices
#
CONFIG_VT=y
CONFIG_VT_CONSOLE=y
CONFIG_HW_CONSOLE=y
# CONFIG_SERIAL_NONSTANDARD is not set

#
# Serial drivers
#
# CONFIG_SERIAL_8250 is not set

#
# Non-8250 serial port support
#
CONFIG_SERIAL_CORE=y
CONFIG_SERIAL_CORE_CONSOLE=y
CONFIG_SERIAL_M32R_SIO=y
CONFIG_SERIAL_M32R_SIO_CONSOLE=y
CONFIG_SERIAL_M32R_PLDSIO=y
CONFIG_UNIX98_PTYS=y
CONFIG_LEGACY_PTYS=y
CONFIG_LEGACY_PTY_COUNT=256

#
# IPMI
#
# CONFIG_IPMI_HANDLER is not set

#
# Watchdog Cards
#
# CONFIG_WATCHDOG is not set
# CONFIG_RTC is not set
CONFIG_DS1302=y
# CONFIG_DTLK is not set
# CONFIG_R3964 is not set

#
# Ftape, the floppy tape device driver
#
# CONFIG_RAW_DRIVER is not set

#
# TPM devices
#
# CONFIG_TCG_TPM is not set
# CONFIG_TELCLOCK is not set

#
# I2C support
#
# CONFIG_I2C is not set

#
# Dallas's 1-wire bus
#
# CONFIG_W1 is not set

#
# Hardware Monitoring support
#
# CONFIG_HWMON is not set
# CONFIG_HWMON_VID is not set

#
# Misc devices
#

#
# Multimedia Capabilities Port drivers
#

#
# Multimedia devices
#
CONFIG_VIDEO_DEV=m

#
# Video For Linux
#

#
# Video Adapters
#
# CONFIG_VIDEO_CPIA is not set
CONFIG_VIDEO_M32R_AR=m
CONFIG_VIDEO_M32R_AR_M64278=m

#
# Radio Adapters
#
# CONFIG_RADIO_MAESTRO is not set

#
# Digital Video Broadcasting Devices
#
# CONFIG_DVB is not set

#
# Graphics support
#
CONFIG_FB=y
CONFIG_FB_CFB_FILLRECT=y
CONFIG_FB_CFB_COPYAREA=y
CONFIG_FB_CFB_IMAGEBLIT=y
# CONFIG_FB_MACMODES is not set
# CONFIG_FB_MODE_HELPERS is not set
# CONFIG_FB_TILEBLITTING is not set
CONFIG_FB_S1D13XXX=y
# CONFIG_FB_VIRTUAL is not set

#
# Console display driver support
#
# CONFIG_VGA_CONSOLE is not set
CONFIG_DUMMY_CONSOLE=y
CONFIG_FRAMEBUFFER_CONSOLE=y
# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
# CONFIG_FONTS is not set
CONFIG_FONT_8x8=y
CONFIG_FONT_8x16=y

#
# Logo configuration
#
CONFIG_LOGO=y
CONFIG_LOGO_LINUX_MONO=y
CONFIG_LOGO_LINUX_VGA16=y
CONFIG_LOGO_LINUX_CLUT224=y
CONFIG_LOGO_M32R_CLUT224=y
# CONFIG_BACKLIGHT_LCD_SUPPORT is not set

#
# Sound
#
# CONFIG_SOUND is not set

#
# USB support
#
# CONFIG_USB_ARCH_HAS_HCD is not set
# CONFIG_USB_ARCH_HAS_OHCI is not set

#
# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
#

#
# USB Gadget Support
#
# CONFIG_USB_GADGET is not set

#
# MMC/SD Card support
#
# CONFIG_MMC is not set

#
# InfiniBand support
#

#
# SN Devices
#

#
# File systems
#
CONFIG_EXT2_FS=y
# CONFIG_EXT2_FS_XATTR is not set
# CONFIG_EXT2_FS_XIP is not set
CONFIG_EXT3_FS=y
CONFIG_EXT3_FS_XATTR=y
# CONFIG_EXT3_FS_POSIX_ACL is not set
# CONFIG_EXT3_FS_SECURITY is not set
CONFIG_JBD=y
CONFIG_JBD_DEBUG=y
CONFIG_FS_MBCACHE=y
CONFIG_REISERFS_FS=m
# CONFIG_REISERFS_CHECK is not set
# CONFIG_REISERFS_PROC_INFO is not set
# CONFIG_REISERFS_FS_XATTR is not set
# CONFIG_JFS_FS is not set
# CONFIG_FS_POSIX_ACL is not set
# CONFIG_XFS_FS is not set
# CONFIG_MINIX_FS is not set
# CONFIG_ROMFS_FS is not set
CONFIG_INOTIFY=y
# CONFIG_QUOTA is not set
CONFIG_DNOTIFY=y
# CONFIG_AUTOFS_FS is not set
# CONFIG_AUTOFS4_FS is not set
# CONFIG_FUSE_FS is not set

#
# CD-ROM/DVD Filesystems
#
CONFIG_ISO9660_FS=m
CONFIG_JOLIET=y
# CONFIG_ZISOFS is not set
CONFIG_UDF_FS=m
CONFIG_UDF_NLS=y

#
# DOS/FAT/NT Filesystems
#
CONFIG_FAT_FS=m
CONFIG_MSDOS_FS=m
CONFIG_VFAT_FS=m
CONFIG_FAT_DEFAULT_CODEPAGE=437
CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
# CONFIG_NTFS_FS is not set

#
# Pseudo filesystems
#
CONFIG_PROC_FS=y
CONFIG_PROC_KCORE=y
CONFIG_SYSFS=y
CONFIG_TMPFS=y
# CONFIG_HUGETLB_PAGE is not set
CONFIG_RAMFS=y
# CONFIG_RELAYFS_FS is not set

#
# Miscellaneous filesystems
#
# CONFIG_ADFS_FS is not set
# CONFIG_AFFS_FS is not set
# CONFIG_HFS_FS is not set
# CONFIG_HFSPLUS_FS is not set
# CONFIG_BEFS_FS is not set
# CONFIG_BFS_FS is not set
# CONFIG_EFS_FS is not set
# CONFIG_JFFS_FS is not set
# CONFIG_JFFS2_FS is not set
# CONFIG_CRAMFS is not set
# CONFIG_VXFS_FS is not set
# CONFIG_HPFS_FS is not set
# CONFIG_QNX4FS_FS is not set
# CONFIG_SYSV_FS is not set
# CONFIG_UFS_FS is not set

#
# Network File Systems
#
CONFIG_NFS_FS=y
CONFIG_NFS_V3=y
# CONFIG_NFS_V3_ACL is not set
# CONFIG_NFS_V4 is not set
# CONFIG_NFS_DIRECTIO is not set
# CONFIG_NFSD is not set
CONFIG_ROOT_NFS=y
CONFIG_LOCKD=y
CONFIG_LOCKD_V4=y
CONFIG_NFS_COMMON=y
CONFIG_SUNRPC=y
# CONFIG_RPCSEC_GSS_KRB5 is not set
# CONFIG_RPCSEC_GSS_SPKM3 is not set
# CONFIG_SMB_FS is not set
# CONFIG_CIFS is not set
# CONFIG_NCP_FS is not set
# CONFIG_CODA_FS is not set
# CONFIG_AFS_FS is not set
# CONFIG_9P_FS is not set

#
# Partition Types
#
# CONFIG_PARTITION_ADVANCED is not set
CONFIG_MSDOS_PARTITION=y

#
# Native Language Support
#
CONFIG_NLS=y
CONFIG_NLS_DEFAULT="iso8859-1"
# CONFIG_NLS_CODEPAGE_437 is not set
# CONFIG_NLS_CODEPAGE_737 is not set
# CONFIG_NLS_CODEPAGE_775 is not set
# CONFIG_NLS_CODEPAGE_850 is not set
# CONFIG_NLS_CODEPAGE_852 is not set
# CONFIG_NLS_CODEPAGE_855 is not set
# CONFIG_NLS_CODEPAGE_857 is not set
# CONFIG_NLS_CODEPAGE_860 is not set
# CONFIG_NLS_CODEPAGE_861 is not set
# CONFIG_NLS_CODEPAGE_862 is not set
# CONFIG_NLS_CODEPAGE_863 is not set
# CONFIG_NLS_CODEPAGE_864 is not set
# CONFIG_NLS_CODEPAGE_865 is not set
# CONFIG_NLS_CODEPAGE_866 is not set
# CONFIG_NLS_CODEPAGE_869 is not set
# CONFIG_NLS_CODEPAGE_936 is not set
# CONFIG_NLS_CODEPAGE_950 is not set
# CONFIG_NLS_CODEPAGE_932 is not set
# CONFIG_NLS_CODEPAGE_949 is not set
# CONFIG_NLS_CODEPAGE_874 is not set
# CONFIG_NLS_ISO8859_8 is not set
# CONFIG_NLS_CODEPAGE_1250 is not set
# CONFIG_NLS_CODEPAGE_1251 is not set
# CONFIG_NLS_ASCII is not set
# CONFIG_NLS_ISO8859_1 is not set
# CONFIG_NLS_ISO8859_2 is not set
# CONFIG_NLS_ISO8859_3 is not set
# CONFIG_NLS_ISO8859_4 is not set
# CONFIG_NLS_ISO8859_5 is not set
# CONFIG_NLS_ISO8859_6 is not set
# CONFIG_NLS_ISO8859_7 is not set
# CONFIG_NLS_ISO8859_9 is not set
# CONFIG_NLS_ISO8859_13 is not set
# CONFIG_NLS_ISO8859_14 is not set
# CONFIG_NLS_ISO8859_15 is not set
# CONFIG_NLS_KOI8_R is not set
# CONFIG_NLS_KOI8_U is not set
# CONFIG_NLS_UTF8 is not set

#
# Profiling support
#
CONFIG_PROFILING=y
CONFIG_OPROFILE=y

#
# Kernel hacking
#
# CONFIG_PRINTK_TIME is not set
CONFIG_DEBUG_KERNEL=y
# CONFIG_MAGIC_SYSRQ is not set
CONFIG_LOG_BUF_SHIFT=15
CONFIG_DETECT_SOFTLOCKUP=y
# CONFIG_SCHEDSTATS is not set
# CONFIG_DEBUG_SLAB is not set
CONFIG_DEBUG_PREEMPT=y
CONFIG_DEBUG_SPINLOCK=y
# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
# CONFIG_DEBUG_KOBJECT is not set
# CONFIG_DEBUG_BUGVERBOSE is not set
CONFIG_DEBUG_INFO=y
# CONFIG_DEBUG_FS is not set
# CONFIG_DEBUG_VM is not set
# CONFIG_FRAME_POINTER is not set
# CONFIG_RCU_TORTURE_TEST is not set
# CONFIG_DEBUG_STACKOVERFLOW is not set
# CONFIG_DEBUG_STACK_USAGE is not set

#
# Security options
#
# CONFIG_KEYS is not set
# CONFIG_SECURITY is not set

#
# Cryptographic options
#
# CONFIG_CRYPTO is not set

#
# Hardware crypto devices
#

#
# Library routines
#
# CONFIG_CRC_CCITT is not set
# CONFIG_CRC16 is not set
CONFIG_CRC32=y
# CONFIG_LIBCRC32C is not set

--

2005-12-27 06:37:00

by Hirokazu Takata

[permalink] [raw]
Subject: Re: [WTF?] sys_tas() on m32r

From: Lee Revell <[email protected]>
Date: Fri, 23 Dec 2005 14:10:34 -0500
> No one uses LinuxThreads anymore?
>
> Even the oldest of the old (Debian stable) have moved to NPTL.
>
> Lee
>

Of course, I hope to migrate from LinuxThreads to NPTL.
I think it is necessary because LinuxThreads is deprecated as you said.

BTW, to port NPTL, GNU tools with TLS support are required for m32r.
We need much work to prepare tools before implementing kernel and NPTL. ;-)

On the other hand, I'm not certain that supporting NPTL is really good
thing for embedded processors like m32r.

A thread pointer register is required to keep an thread pointer value
all the time; I'm anxious that this will increase register pressure
and worsen code performance...

-- Takata

2005-12-27 09:34:19

by Jesper Juhl

[permalink] [raw]
Subject: Re: [WTF?] sys_tas() on m32r

On 12/23/05, Lee Revell <[email protected]> wrote:
> On Fri, 2005-12-23 at 05:55 -0800, Andrew Morton wrote:
> > Al Viro <[email protected]> wrote:
> > >
> > > asmlinkage int sys_tas(int *addr)
> > > {
> > > int oldval;
> > > unsigned long flags;
> > >
> > > if (!access_ok(VERIFY_WRITE, addr, sizeof (int)))
> > > return -EFAULT;
> > > local_irq_save(flags);
> > > oldval = *addr;
> > > if (!oldval)
> > > *addr = 1;
> > > local_irq_restore(flags);
> > > return oldval;
> > > }
> > > in arch/m32r/kernel/sys_m32r.c. Trivial oops *AND* ability to trigger
> > > IO with interrupts disabled.
> >
> > Yeah. I pointed this out to Takata in October last year and then promptly
> > forgot about it. It's rather amazing that this code (which appears to be in
> > live use in linuxthreads) hasn't generated oopses.
>
> No one uses LinuxThreads anymore?
>
Slackware still uses LinuxThreads.
Latest release and -current include both NPTL & LinuxThreads, and use
NPTL if the running kernel is >2.6.4 or LinuxThreads if <=2.6.4 or
when running a 2.4 kernel (2.4 is still the default kernel in
Slackware although 2.6.x is also fully supported).

--
Jesper Juhl <[email protected]>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html

2005-12-27 13:22:38

by Andrew Morton

[permalink] [raw]
Subject: Re: [WTF?] sys_tas() on m32r

Hirokazu Takata <[email protected]> wrote:
>
> I tried the latter way as the following patch, but the result was not
> so gratifying; some hangups/lockups or kernel panics happened unexpectedly.
>
> Am I missing anything?
> Any more comments or suggestions will be greatly appreciated.
>
> ...
> --- linux-2.6.15-rc7.orig/arch/m32r/kernel/sys_m32r.c 2005-12-27 10:33:05.301372856 +0900
> +++ linux-2.6.15-rc7/arch/m32r/kernel/sys_m32r.c 2005-12-27 10:33:10.222624712 +0900
> @@ -29,44 +29,31 @@
>
> /*
> * sys_tas() - test-and-set
> - * linuxthreads testing version
> */
> -#ifndef CONFIG_SMP
> asmlinkage int sys_tas(int *addr)
> {
> int oldval;
> - unsigned long flags;
>
> if (!access_ok(VERIFY_WRITE, addr, sizeof (int)))
> return -EFAULT;
> - local_irq_save(flags);
> - oldval = *addr;
> - if (!oldval)
> - *addr = 1;
> - local_irq_restore(flags);
> - return oldval;
> -}
> -#else /* CONFIG_SMP */
> -#include <linux/spinlock.h>
> -
> -static DEFINE_SPINLOCK(tas_lock);
> -
> -asmlinkage int sys_tas(int *addr)
> -{
> - int oldval;
>
> - if (!access_ok(VERIFY_WRITE, addr, sizeof (int)))
> - return -EFAULT;
> -
> - _raw_spin_lock(&tas_lock);
> - oldval = *addr;
> - if (!oldval)
> - *addr = 1;
> - _raw_spin_unlock(&tas_lock);
> + for ( ; ; ) {
> + get_user(oldval, addr);

We need to check for -EFAULT here and fail the syscall if a fault was
detected. Without this we'll certainly get lockups if the user passed a
bad address. But this doesn't seem sufficient to eplain the problems which
you've observed.


2005-12-28 00:36:22

by Hirokazu Takata

[permalink] [raw]
Subject: Re: [WTF?] sys_tas() on m32r

Sorry, I'll report later.
I will be offline until Jan. 5, 2006.

-- Takata

From: Andrew Morton <[email protected]>
Date: Tue, 27 Dec 2005 05:22:14 -0800
> Hirokazu Takata <[email protected]> wrote:
> >
> > I tried the latter way as the following patch, but the result was not
> > so gratifying; some hangups/lockups or kernel panics happened unexpectedly.
> >
> > Am I missing anything?
> > Any more comments or suggestions will be greatly appreciated.
> >
> > ...
> > --- linux-2.6.15-rc7.orig/arch/m32r/kernel/sys_m32r.c 2005-12-27 10:33:05.301372856 +0900
> > +++ linux-2.6.15-rc7/arch/m32r/kernel/sys_m32r.c 2005-12-27 10:33:10.222624712 +0900
> > @@ -29,44 +29,31 @@
> >
> > /*
> > * sys_tas() - test-and-set
> > - * linuxthreads testing version
> > */
> > -#ifndef CONFIG_SMP
> > asmlinkage int sys_tas(int *addr)
> > {
> > int oldval;
> > - unsigned long flags;
> >
> > if (!access_ok(VERIFY_WRITE, addr, sizeof (int)))
> > return -EFAULT;
> > - local_irq_save(flags);
> > - oldval = *addr;
> > - if (!oldval)
> > - *addr = 1;
> > - local_irq_restore(flags);
> > - return oldval;
> > -}
> > -#else /* CONFIG_SMP */
> > -#include <linux/spinlock.h>
> > -
> > -static DEFINE_SPINLOCK(tas_lock);
> > -
> > -asmlinkage int sys_tas(int *addr)
> > -{
> > - int oldval;
> >
> > - if (!access_ok(VERIFY_WRITE, addr, sizeof (int)))
> > - return -EFAULT;
> > -
> > - _raw_spin_lock(&tas_lock);
> > - oldval = *addr;
> > - if (!oldval)
> > - *addr = 1;
> > - _raw_spin_unlock(&tas_lock);
> > + for ( ; ; ) {
> > + get_user(oldval, addr);
>
> We need to check for -EFAULT here and fail the syscall if a fault was
> detected. Without this we'll certainly get lockups if the user passed a
> bad address. But this doesn't seem sufficient to eplain the problems which
> you've observed.
>
>