1 diff -Naur -X ../exclude-files orig/arch/um/common.ld.in um/arch/um/common.ld.in
2 --- orig/arch/um/common.ld.in 1969-12-31 19:00:00.000000000 -0500
3 +++ um/arch/um/common.ld.in 2003-10-21 03:26:06.000000000 -0400
5 + .kstrtab : { *(.kstrtab) }
7 + . = ALIGN(16); /* Exception table */
8 + __start___ex_table = .;
9 + __ex_table : { *(__ex_table) }
10 + __stop___ex_table = .;
12 + __start___ksymtab = .; /* Kernel symbol table */
13 + __ksymtab : { *(__ksymtab) }
14 + __stop___ksymtab = .;
16 + .unprotected : { *(.unprotected) }
18 + PROVIDE (_unprotected_end = .);
21 + __uml_setup_start = .;
22 + .uml.setup.init : { *(.uml.setup.init) }
23 + __uml_setup_end = .;
24 + __uml_help_start = .;
25 + .uml.help.init : { *(.uml.help.init) }
27 + __uml_postsetup_start = .;
28 + .uml.postsetup.init : { *(.uml.postsetup.init) }
29 + __uml_postsetup_end = .;
31 + .setup.init : { *(.setup.init) }
33 + __initcall_start = .;
34 + .initcall.init : { *(.initcall.init) }
36 + __uml_initcall_start = .;
37 + .uml.initcall.init : { *(.uml.initcall.init) }
38 + __uml_initcall_end = .;
40 + __exitcall_begin = .;
41 + .exitcall : { *(.exitcall.exit) }
43 + __uml_exitcall_begin = .;
44 + .uml.exitcall : { *(.uml.exitcall.exit) }
45 + __uml_exitcall_end = .;
47 + __preinit_array_start = .;
48 + .preinit_array : { *(.preinit_array) }
49 + __preinit_array_end = .;
50 + __init_array_start = .;
51 + .init_array : { *(.init_array) }
52 + __init_array_end = .;
53 + __fini_array_start = .;
54 + .fini_array : { *(.fini_array) }
55 + __fini_array_end = .;
57 + .data.init : { *(.data.init) }
58 diff -Naur -X ../exclude-files orig/arch/um/config_block.in um/arch/um/config_block.in
59 --- orig/arch/um/config_block.in 1969-12-31 19:00:00.000000000 -0500
60 +++ um/arch/um/config_block.in 2003-10-21 03:26:06.000000000 -0400
62 +mainmenu_option next_comment
63 +comment 'Block Devices'
65 +bool 'Virtual block device' CONFIG_BLK_DEV_UBD
66 +dep_bool ' Always do synchronous disk IO for UBD' CONFIG_BLK_DEV_UBD_SYNC $CONFIG_BLK_DEV_UBD
67 +bool 'COW device' CONFIG_COW
69 +if [ "$CONFIG_BLK_DEV_UBD" = "y" -o "$CONFIG_COW" = "y" ] ; then
70 + define_bool CONFIG_COW_COMMON y
73 +tristate 'Loopback device support' CONFIG_BLK_DEV_LOOP
74 +dep_tristate 'Network block device support' CONFIG_BLK_DEV_NBD $CONFIG_NET
75 +tristate 'RAM disk support' CONFIG_BLK_DEV_RAM
76 +if [ "$CONFIG_BLK_DEV_RAM" = "y" -o "$CONFIG_BLK_DEV_RAM" = "m" ]; then
77 + int ' Default RAM disk size' CONFIG_BLK_DEV_RAM_SIZE 4096
79 +dep_bool ' Initial RAM disk (initrd) support' CONFIG_BLK_DEV_INITRD $CONFIG_BLK_DEV_RAM
81 +tristate 'Example IO memory driver' CONFIG_MMAPPER
84 diff -Naur -X ../exclude-files orig/arch/um/config_char.in um/arch/um/config_char.in
85 --- orig/arch/um/config_char.in 1969-12-31 19:00:00.000000000 -0500
86 +++ um/arch/um/config_char.in 2003-10-21 03:26:06.000000000 -0400
88 +mainmenu_option next_comment
89 +comment 'Character Devices'
91 +define_bool CONFIG_STDIO_CONSOLE y
93 +bool 'Virtual serial line' CONFIG_SSL
95 +bool 'file descriptor channel support' CONFIG_FD_CHAN
96 +bool 'null channel support' CONFIG_NULL_CHAN
97 +bool 'port channel support' CONFIG_PORT_CHAN
98 +bool 'pty channel support' CONFIG_PTY_CHAN
99 +bool 'tty channel support' CONFIG_TTY_CHAN
100 +bool 'xterm channel support' CONFIG_XTERM_CHAN
101 +string 'Default main console channel initialization' CONFIG_CON_ZERO_CHAN \
103 +string 'Default console channel initialization' CONFIG_CON_CHAN "xterm"
104 +string 'Default serial line channel initialization' CONFIG_SSL_CHAN "pty"
107 +bool 'Unix98 PTY support' CONFIG_UNIX98_PTYS
108 +if [ "$CONFIG_UNIX98_PTYS" = "y" ]; then
109 + int 'Maximum number of Unix98 PTYs in use (0-2048)' CONFIG_UNIX98_PTY_COUNT 256
112 +bool 'Watchdog Timer Support' CONFIG_WATCHDOG
113 +dep_bool ' Disable watchdog shutdown on close' CONFIG_WATCHDOG_NOWAYOUT \
115 +dep_tristate ' Software Watchdog' CONFIG_SOFT_WATCHDOG $CONFIG_WATCHDOG
116 +dep_tristate ' UML watchdog' CONFIG_UML_WATCHDOG $CONFIG_WATCHDOG
118 +tristate 'Sound support' CONFIG_UML_SOUND
119 +define_tristate CONFIG_SOUND $CONFIG_UML_SOUND
120 +define_tristate CONFIG_HOSTAUDIO $CONFIG_UML_SOUND
122 +bool 'Enable tty logging' CONFIG_TTY_LOG
125 diff -Naur -X ../exclude-files orig/arch/um/config.in um/arch/um/config.in
126 --- orig/arch/um/config.in 1969-12-31 19:00:00.000000000 -0500
127 +++ um/arch/um/config.in 2003-12-14 11:34:02.000000000 -0500
129 +define_bool CONFIG_USERMODE y
131 +mainmenu_name "Linux/Usermode Kernel Configuration"
133 +define_bool CONFIG_ISA n
134 +define_bool CONFIG_SBUS n
135 +define_bool CONFIG_PCI n
137 +define_bool CONFIG_UID16 y
139 +define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM y
141 +mainmenu_option next_comment
142 +comment 'Code maturity level options'
143 +bool 'Prompt for development and/or incomplete code/drivers' CONFIG_EXPERIMENTAL
146 +mainmenu_option next_comment
147 +comment 'General Setup'
149 +bool 'Separate kernel address space support' CONFIG_MODE_SKAS
151 +# This is to ensure that at least one of the modes is enabled. When neither
152 +# is present in defconfig, they default to N, which is bad.
153 +if [ "$CONFIG_MODE_SKAS" != "y" ]; then
154 + define_bool CONFIG_MODE_TT y
157 +bool 'Tracing thread support' CONFIG_MODE_TT
158 +if [ "$CONFIG_MODE_TT" != "y" ]; then
159 + bool 'Statically linked binary when CONFIG_MODE_TT is disabled' CONFIG_STATIC_LINK
161 +bool 'Networking support' CONFIG_NET
162 +bool 'System V IPC' CONFIG_SYSVIPC
163 +bool 'BSD Process Accounting' CONFIG_BSD_PROCESS_ACCT
164 +bool 'Sysctl support' CONFIG_SYSCTL
165 +tristate 'Kernel support for a.out binaries' CONFIG_BINFMT_AOUT
166 +tristate 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF
167 +tristate 'Kernel support for MISC binaries' CONFIG_BINFMT_MISC
168 +tristate 'Host filesystem' CONFIG_HOSTFS
169 +tristate 'Honeypot proc filesystem' CONFIG_HPPFS
170 +bool 'Management console' CONFIG_MCONSOLE
171 +dep_bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ $CONFIG_MCONSOLE
172 +bool '2G/2G host address space split' CONFIG_HOST_2G_2G
173 +bool 'Symmetric multi-processing support' CONFIG_UML_SMP
174 +define_bool CONFIG_SMP $CONFIG_UML_SMP
175 +int 'Nesting level' CONFIG_NEST_LEVEL 0
176 +int 'Kernel address space size (in .5G units)' CONFIG_KERNEL_HALF_GIGS 1
177 +bool 'Highmem support' CONFIG_HIGHMEM
178 +bool '/proc/mm' CONFIG_PROC_MM
179 +int 'Kernel stack size order' CONFIG_KERNEL_STACK_ORDER 2
180 +bool 'Real-time Clock' CONFIG_UML_REAL_TIME_CLOCK
183 +mainmenu_option next_comment
184 +comment 'Loadable module support'
185 +bool 'Enable loadable module support' CONFIG_MODULES
186 +if [ "$CONFIG_MODULES" = "y" ]; then
187 +# MODVERSIONS does not yet work in this architecture
188 +# bool ' Set version information on all module symbols' CONFIG_MODVERSIONS
189 + bool ' Kernel module loader' CONFIG_KMOD
193 +source arch/um/config_char.in
195 +source arch/um/config_block.in
197 +define_bool CONFIG_NETDEVICES $CONFIG_NET
199 +if [ "$CONFIG_NET" = "y" ]; then
200 + source arch/um/config_net.in
201 + source net/Config.in
206 +mainmenu_option next_comment
207 +comment 'SCSI support'
209 +tristate 'SCSI support' CONFIG_SCSI
211 +if [ "$CONFIG_SCSI" != "n" ]; then
212 + source arch/um/config_scsi.in
216 +source drivers/md/Config.in
218 +source drivers/mtd/Config.in
220 +source lib/Config.in
222 +mainmenu_option next_comment
223 +comment 'Kernel hacking'
224 +bool 'Debug memory allocations' CONFIG_DEBUG_SLAB
225 +bool 'Enable kernel debugging symbols' CONFIG_DEBUGSYM
226 +if [ "$CONFIG_XTERM_CHAN" = "y" ]; then
227 + dep_bool 'Enable ptrace proxy' CONFIG_PT_PROXY $CONFIG_DEBUGSYM
229 + define_bool CONFIG_PT_PROXY n
231 +dep_bool 'Enable gprof support' CONFIG_GPROF $CONFIG_DEBUGSYM
232 +dep_bool 'Enable gcov support' CONFIG_GCOV $CONFIG_DEBUGSYM
234 diff -Naur -X ../exclude-files orig/arch/um/config_net.in um/arch/um/config_net.in
235 --- orig/arch/um/config_net.in 1969-12-31 19:00:00.000000000 -0500
236 +++ um/arch/um/config_net.in 2003-10-21 03:26:06.000000000 -0400
238 +mainmenu_option next_comment
239 +comment 'Network Devices'
241 +# UML virtual driver
242 +bool 'Virtual network device' CONFIG_UML_NET
244 +dep_bool ' Ethertap transport' CONFIG_UML_NET_ETHERTAP $CONFIG_UML_NET
245 +dep_bool ' TUN/TAP transport' CONFIG_UML_NET_TUNTAP $CONFIG_UML_NET
246 +dep_bool ' SLIP transport' CONFIG_UML_NET_SLIP $CONFIG_UML_NET
247 +dep_bool ' SLiRP transport' CONFIG_UML_NET_SLIRP $CONFIG_UML_NET
248 +dep_bool ' Daemon transport' CONFIG_UML_NET_DAEMON $CONFIG_UML_NET
249 +dep_bool ' Multicast transport' CONFIG_UML_NET_MCAST $CONFIG_UML_NET
250 +dep_bool ' pcap transport' CONFIG_UML_NET_PCAP $CONFIG_UML_NET
252 +# Below are hardware-independent drivers mirrored from
253 +# drivers/net/Config.in. It would be nice if Linux
254 +# had HW independent drivers separated from the other
255 +# but it does not. Until then each non-ISA/PCI arch
256 +# needs to provide it's own menu of network drivers
258 +tristate 'Dummy net driver support' CONFIG_DUMMY
259 +tristate 'Bonding driver support' CONFIG_BONDING
260 +tristate 'EQL (serial line load balancing) support' CONFIG_EQUALIZER
261 +tristate 'Universal TUN/TAP device driver support' CONFIG_TUN
262 +if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
263 + if [ "$CONFIG_NETLINK" = "y" ]; then
264 + tristate 'Ethertap network tap (OBSOLETE)' CONFIG_ETHERTAP
268 +tristate 'PPP (point-to-point protocol) support' CONFIG_PPP
269 +if [ ! "$CONFIG_PPP" = "n" ]; then
270 + dep_bool ' PPP multilink support (EXPERIMENTAL)' CONFIG_PPP_MULTILINK $CONFIG_EXPERIMENTAL
271 + dep_bool ' PPP filtering' CONFIG_PPP_FILTER $CONFIG_FILTER
272 + dep_tristate ' PPP support for async serial ports' CONFIG_PPP_ASYNC $CONFIG_PPP
273 + dep_tristate ' PPP support for sync tty ports' CONFIG_PPP_SYNC_TTY $CONFIG_PPP
274 + dep_tristate ' PPP Deflate compression' CONFIG_PPP_DEFLATE $CONFIG_PPP
275 + dep_tristate ' PPP BSD-Compress compression' CONFIG_PPP_BSDCOMP $CONFIG_PPP
276 + dep_tristate ' PPP over Ethernet (EXPERIMENTAL)' CONFIG_PPPOE $CONFIG_PPP $CONFIG_EXPERIMENTAL
279 +tristate 'SLIP (serial line) support' CONFIG_SLIP
280 +dep_bool ' CSLIP compressed headers' CONFIG_SLIP_COMPRESSED $CONFIG_SLIP
281 +dep_bool ' Keepalive and linefill' CONFIG_SLIP_SMART $CONFIG_SLIP
282 +dep_bool ' Six bit SLIP encapsulation' CONFIG_SLIP_MODE_SLIP6 $CONFIG_SLIP
285 diff -Naur -X ../exclude-files orig/arch/um/config.release um/arch/um/config.release
286 --- orig/arch/um/config.release 1969-12-31 19:00:00.000000000 -0500
287 +++ um/arch/um/config.release 2003-10-21 03:26:06.000000000 -0400
290 +# Automatically generated make config: don't edit
293 +# CONFIG_ISA is not set
294 +# CONFIG_SBUS is not set
295 +# CONFIG_PCI is not set
297 +CONFIG_RWSEM_XCHGADD_ALGORITHM=y
300 +# Code maturity level options
302 +CONFIG_EXPERIMENTAL=y
309 +CONFIG_BSD_PROCESS_ACCT=y
311 +CONFIG_BINFMT_AOUT=y
313 +CONFIG_BINFMT_MISC=y
315 +# CONFIG_HPPFS is not set
317 +CONFIG_MAGIC_SYSRQ=y
318 +# CONFIG_HOST_2G_2G is not set
319 +# CONFIG_UML_SMP is not set
320 +# CONFIG_SMP is not set
322 +CONFIG_KERNEL_HALF_GIGS=1
325 +# Loadable module support
333 +CONFIG_STDIO_CONSOLE=y
336 +# CONFIG_NULL_CHAN is not set
341 +CONFIG_CON_ZERO_CHAN="fd:0,fd:1"
342 +CONFIG_CON_CHAN="xterm"
343 +CONFIG_SSL_CHAN="pty"
344 +CONFIG_UNIX98_PTYS=y
345 +CONFIG_UNIX98_PTY_COUNT=256
346 +# CONFIG_WATCHDOG is not set
350 +# CONFIG_TTY_LOG is not set
355 +CONFIG_BLK_DEV_UBD=y
356 +# CONFIG_BLK_DEV_UBD_SYNC is not set
357 +CONFIG_BLK_DEV_LOOP=y
358 +CONFIG_BLK_DEV_NBD=y
359 +CONFIG_BLK_DEV_RAM=y
360 +CONFIG_BLK_DEV_RAM_SIZE=4096
361 +CONFIG_BLK_DEV_INITRD=y
362 +# CONFIG_MMAPPER is not set
369 +CONFIG_UML_NET_ETHERTAP=y
370 +CONFIG_UML_NET_TUNTAP=y
371 +CONFIG_UML_NET_SLIP=y
372 +CONFIG_UML_NET_DAEMON=y
373 +CONFIG_UML_NET_MCAST=y
379 +CONFIG_PPP_MULTILINK=y
380 +# CONFIG_PPP_ASYNC is not set
381 +CONFIG_PPP_SYNC_TTY=m
382 +CONFIG_PPP_DEFLATE=m
383 +CONFIG_PPP_BSDCOMP=m
388 +# Networking options
391 +CONFIG_PACKET_MMAP=y
392 +# CONFIG_NETLINK_DEV is not set
393 +# CONFIG_NETFILTER is not set
394 +# CONFIG_FILTER is not set
397 +# CONFIG_IP_MULTICAST is not set
398 +# CONFIG_IP_ADVANCED_ROUTER is not set
399 +# CONFIG_IP_PNP is not set
400 +# CONFIG_NET_IPIP is not set
401 +# CONFIG_NET_IPGRE is not set
402 +# CONFIG_ARPD is not set
403 +# CONFIG_INET_ECN is not set
404 +# CONFIG_SYN_COOKIES is not set
405 +# CONFIG_IPV6 is not set
406 +# CONFIG_KHTTPD is not set
407 +# CONFIG_ATM is not set
408 +# CONFIG_VLAN_8021Q is not set
413 +# CONFIG_IPX is not set
414 +# CONFIG_ATALK is not set
419 +# CONFIG_DECNET is not set
420 +# CONFIG_BRIDGE is not set
421 +# CONFIG_X25 is not set
422 +# CONFIG_LAPB is not set
423 +# CONFIG_LLC is not set
424 +# CONFIG_NET_DIVERT is not set
425 +# CONFIG_ECONET is not set
426 +# CONFIG_WAN_ROUTER is not set
427 +# CONFIG_NET_FASTROUTE is not set
428 +# CONFIG_NET_HW_FLOWCONTROL is not set
431 +# QoS and/or fair queueing
433 +# CONFIG_NET_SCHED is not set
438 +# CONFIG_NET_PKTGEN is not set
446 +CONFIG_REISERFS_FS=m
447 +# CONFIG_REISERFS_CHECK is not set
448 +# CONFIG_REISERFS_PROC_INFO is not set
450 +# CONFIG_ADFS_FS_RW is not set
456 +# CONFIG_JBD_DEBUG is not set
466 +# CONFIG_JOLIET is not set
467 +# CONFIG_ZISOFS is not set
470 +# CONFIG_NTFS_FS is not set
474 +CONFIG_DEVFS_MOUNT=y
475 +# CONFIG_DEVFS_DEBUG is not set
478 +# CONFIG_QNX4FS_RW is not set
483 +# CONFIG_UDF_RW is not set
485 +# CONFIG_UFS_FS_WRITE is not set
488 +# Network File Systems
490 +# CONFIG_CODA_FS is not set
491 +# CONFIG_INTERMEZZO_FS is not set
499 +# CONFIG_SMB_FS is not set
500 +# CONFIG_NCP_FS is not set
501 +# CONFIG_ZISOFS_FS is not set
502 +CONFIG_ZLIB_FS_INFLATE=m
507 +# CONFIG_PARTITION_ADVANCED is not set
508 +CONFIG_MSDOS_PARTITION=y
509 +# CONFIG_SMB_NLS is not set
513 +# Native Language Support
515 +CONFIG_NLS_DEFAULT="iso8859-1"
516 +# CONFIG_NLS_CODEPAGE_437 is not set
517 +# CONFIG_NLS_CODEPAGE_737 is not set
518 +# CONFIG_NLS_CODEPAGE_775 is not set
519 +# CONFIG_NLS_CODEPAGE_850 is not set
520 +# CONFIG_NLS_CODEPAGE_852 is not set
521 +# CONFIG_NLS_CODEPAGE_855 is not set
522 +# CONFIG_NLS_CODEPAGE_857 is not set
523 +# CONFIG_NLS_CODEPAGE_860 is not set
524 +# CONFIG_NLS_CODEPAGE_861 is not set
525 +# CONFIG_NLS_CODEPAGE_862 is not set
526 +# CONFIG_NLS_CODEPAGE_863 is not set
527 +# CONFIG_NLS_CODEPAGE_864 is not set
528 +# CONFIG_NLS_CODEPAGE_865 is not set
529 +# CONFIG_NLS_CODEPAGE_866 is not set
530 +# CONFIG_NLS_CODEPAGE_869 is not set
531 +# CONFIG_NLS_CODEPAGE_936 is not set
532 +# CONFIG_NLS_CODEPAGE_950 is not set
533 +# CONFIG_NLS_CODEPAGE_932 is not set
534 +# CONFIG_NLS_CODEPAGE_949 is not set
535 +# CONFIG_NLS_CODEPAGE_874 is not set
536 +# CONFIG_NLS_ISO8859_8 is not set
537 +# CONFIG_NLS_CODEPAGE_1250 is not set
538 +# CONFIG_NLS_CODEPAGE_1251 is not set
539 +# CONFIG_NLS_ISO8859_1 is not set
540 +# CONFIG_NLS_ISO8859_2 is not set
541 +# CONFIG_NLS_ISO8859_3 is not set
542 +# CONFIG_NLS_ISO8859_4 is not set
543 +# CONFIG_NLS_ISO8859_5 is not set
544 +# CONFIG_NLS_ISO8859_6 is not set
545 +# CONFIG_NLS_ISO8859_7 is not set
546 +# CONFIG_NLS_ISO8859_9 is not set
547 +# CONFIG_NLS_ISO8859_13 is not set
548 +# CONFIG_NLS_ISO8859_14 is not set
549 +# CONFIG_NLS_ISO8859_15 is not set
550 +# CONFIG_NLS_KOI8_R is not set
551 +# CONFIG_NLS_KOI8_U is not set
552 +# CONFIG_NLS_UTF8 is not set
560 +# SCSI support type (disk, tape, CD-ROM)
562 +# CONFIG_BLK_DEV_SD is not set
563 +# CONFIG_CHR_DEV_ST is not set
564 +# CONFIG_BLK_DEV_SR is not set
565 +# CONFIG_CHR_DEV_SG is not set
568 +# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
570 +# CONFIG_SCSI_DEBUG_QUEUES is not set
571 +# CONFIG_SCSI_MULTI_LUN is not set
572 +# CONFIG_SCSI_CONSTANTS is not set
573 +# CONFIG_SCSI_LOGGING is not set
577 +# Multi-device support (RAID and LVM)
579 +# CONFIG_MD is not set
582 +# Memory Technology Devices (MTD)
584 +# CONFIG_MTD is not set
589 +# CONFIG_DEBUG_SLAB is not set
590 +# CONFIG_DEBUGSYM is not set
591 diff -Naur -X ../exclude-files orig/arch/um/config_scsi.in um/arch/um/config_scsi.in
592 --- orig/arch/um/config_scsi.in 1969-12-31 19:00:00.000000000 -0500
593 +++ um/arch/um/config_scsi.in 2003-10-21 03:26:06.000000000 -0400
595 +comment 'SCSI support type (disk, tape, CD-ROM)'
597 +dep_tristate ' SCSI disk support' CONFIG_BLK_DEV_SD $CONFIG_SCSI
599 +if [ "$CONFIG_BLK_DEV_SD" != "n" ]; then
600 + int 'Maximum number of SCSI disks that can be loaded as modules' CONFIG_SD_EXTRA_DEVS 40
603 +dep_tristate ' SCSI tape support' CONFIG_CHR_DEV_ST $CONFIG_SCSI
605 +dep_tristate ' SCSI CD-ROM support' CONFIG_BLK_DEV_SR $CONFIG_SCSI
607 +if [ "$CONFIG_BLK_DEV_SR" != "n" ]; then
608 + bool ' Enable vendor-specific extensions (for SCSI CDROM)' CONFIG_BLK_DEV_SR_VENDOR
609 + int 'Maximum number of CDROM devices that can be loaded as modules' CONFIG_SR_EXTRA_DEVS 2
611 +dep_tristate ' SCSI generic support' CONFIG_CHR_DEV_SG $CONFIG_SCSI
613 +comment 'Some SCSI devices (e.g. CD jukebox) support multiple LUNs'
615 +#if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
616 + bool ' Enable extra checks in new queueing code' CONFIG_SCSI_DEBUG_QUEUES
619 +bool ' Probe all LUNs on each SCSI device' CONFIG_SCSI_MULTI_LUN
621 +bool ' Verbose SCSI error reporting (kernel size +=12K)' CONFIG_SCSI_CONSTANTS
622 +bool ' SCSI logging facility' CONFIG_SCSI_LOGGING
624 +dep_tristate 'SCSI debugging host simulator (EXPERIMENTAL)' CONFIG_SCSI_DEBUG $CONFIG_SCSI
625 diff -Naur -X ../exclude-files orig/arch/um/defconfig um/arch/um/defconfig
626 --- orig/arch/um/defconfig 1969-12-31 19:00:00.000000000 -0500
627 +++ um/arch/um/defconfig 2003-12-17 02:15:39.000000000 -0500
630 +# Automatically generated make config: don't edit
633 +# CONFIG_ISA is not set
634 +# CONFIG_SBUS is not set
635 +# CONFIG_PCI is not set
637 +CONFIG_RWSEM_XCHGADD_ALGORITHM=y
640 +# Code maturity level options
642 +CONFIG_EXPERIMENTAL=y
651 +CONFIG_BSD_PROCESS_ACCT=y
653 +CONFIG_BINFMT_AOUT=y
655 +CONFIG_BINFMT_MISC=y
659 +CONFIG_MAGIC_SYSRQ=y
660 +# CONFIG_HOST_2G_2G is not set
661 +# CONFIG_UML_SMP is not set
662 +# CONFIG_SMP is not set
664 +CONFIG_KERNEL_HALF_GIGS=1
665 +# CONFIG_HIGHMEM is not set
667 +CONFIG_KERNEL_STACK_ORDER=2
668 +CONFIG_UML_REAL_TIME_CLOCK=y
671 +# Loadable module support
674 +# CONFIG_KMOD is not set
679 +CONFIG_STDIO_CONSOLE=y
687 +CONFIG_CON_ZERO_CHAN="fd:0,fd:1"
688 +CONFIG_CON_CHAN="xterm"
689 +CONFIG_SSL_CHAN="pty"
690 +CONFIG_UNIX98_PTYS=y
691 +CONFIG_UNIX98_PTY_COUNT=256
692 +# CONFIG_WATCHDOG is not set
693 +# CONFIG_WATCHDOG_NOWAYOUT is not set
694 +# CONFIG_SOFT_WATCHDOG is not set
695 +# CONFIG_UML_WATCHDOG is not set
699 +# CONFIG_TTY_LOG is not set
704 +CONFIG_BLK_DEV_UBD=y
705 +# CONFIG_BLK_DEV_UBD_SYNC is not set
706 +# CONFIG_COW is not set
708 +CONFIG_BLK_DEV_LOOP=y
709 +CONFIG_BLK_DEV_NBD=y
710 +CONFIG_BLK_DEV_RAM=y
711 +CONFIG_BLK_DEV_RAM_SIZE=4096
712 +CONFIG_BLK_DEV_INITRD=y
713 +# CONFIG_MMAPPER is not set
720 +CONFIG_UML_NET_ETHERTAP=y
721 +CONFIG_UML_NET_TUNTAP=y
722 +CONFIG_UML_NET_SLIP=y
723 +CONFIG_UML_NET_SLIRP=y
724 +CONFIG_UML_NET_DAEMON=y
725 +CONFIG_UML_NET_MCAST=y
726 +# CONFIG_UML_NET_PCAP is not set
728 +# CONFIG_BONDING is not set
729 +# CONFIG_EQUALIZER is not set
732 +# CONFIG_PPP_MULTILINK is not set
733 +# CONFIG_PPP_FILTER is not set
734 +# CONFIG_PPP_ASYNC is not set
735 +# CONFIG_PPP_SYNC_TTY is not set
736 +# CONFIG_PPP_DEFLATE is not set
737 +# CONFIG_PPP_BSDCOMP is not set
738 +# CONFIG_PPPOE is not set
740 +# CONFIG_SLIP_COMPRESSED is not set
741 +# CONFIG_SLIP_SMART is not set
742 +# CONFIG_SLIP_MODE_SLIP6 is not set
745 +# Networking options
748 +CONFIG_PACKET_MMAP=y
749 +# CONFIG_NETLINK_DEV is not set
750 +# CONFIG_NETFILTER is not set
751 +# CONFIG_FILTER is not set
754 +# CONFIG_IP_MULTICAST is not set
755 +# CONFIG_IP_ADVANCED_ROUTER is not set
756 +# CONFIG_IP_PNP is not set
757 +# CONFIG_NET_IPIP is not set
758 +# CONFIG_NET_IPGRE is not set
759 +# CONFIG_ARPD is not set
760 +# CONFIG_INET_ECN is not set
761 +# CONFIG_SYN_COOKIES is not set
762 +# CONFIG_IPV6 is not set
763 +# CONFIG_KHTTPD is not set
766 +# SCTP Configuration (EXPERIMENTAL)
768 +CONFIG_IPV6_SCTP__=y
769 +# CONFIG_IP_SCTP is not set
770 +# CONFIG_ATM is not set
771 +# CONFIG_VLAN_8021Q is not set
776 +# CONFIG_IPX is not set
777 +# CONFIG_ATALK is not set
782 +# CONFIG_DEV_APPLETALK is not set
783 +# CONFIG_DECNET is not set
784 +# CONFIG_BRIDGE is not set
785 +# CONFIG_X25 is not set
786 +# CONFIG_LAPB is not set
787 +# CONFIG_LLC is not set
788 +# CONFIG_NET_DIVERT is not set
789 +# CONFIG_ECONET is not set
790 +# CONFIG_WAN_ROUTER is not set
791 +# CONFIG_NET_FASTROUTE is not set
792 +# CONFIG_NET_HW_FLOWCONTROL is not set
795 +# QoS and/or fair queueing
797 +# CONFIG_NET_SCHED is not set
802 +# CONFIG_NET_PKTGEN is not set
808 +# CONFIG_QFMT_V2 is not set
811 +CONFIG_REISERFS_FS=y
812 +# CONFIG_REISERFS_CHECK is not set
813 +# CONFIG_REISERFS_PROC_INFO is not set
814 +# CONFIG_ADFS_FS is not set
815 +# CONFIG_ADFS_FS_RW is not set
816 +# CONFIG_AFFS_FS is not set
817 +# CONFIG_HFS_FS is not set
818 +# CONFIG_HFSPLUS_FS is not set
819 +# CONFIG_BEFS_FS is not set
820 +# CONFIG_BEFS_DEBUG is not set
821 +# CONFIG_BFS_FS is not set
822 +# CONFIG_EXT3_FS is not set
823 +# CONFIG_JBD is not set
824 +# CONFIG_JBD_DEBUG is not set
829 +# CONFIG_EFS_FS is not set
831 +CONFIG_JFFS_FS_VERBOSE=0
832 +CONFIG_JFFS_PROC_FS=y
834 +CONFIG_JFFS2_FS_DEBUG=0
835 +# CONFIG_CRAMFS is not set
836 +# CONFIG_TMPFS is not set
839 +# CONFIG_JOLIET is not set
840 +# CONFIG_ZISOFS is not set
841 +# CONFIG_JFS_FS is not set
842 +# CONFIG_JFS_DEBUG is not set
843 +# CONFIG_JFS_STATISTICS is not set
845 +# CONFIG_VXFS_FS is not set
846 +# CONFIG_NTFS_FS is not set
847 +# CONFIG_NTFS_RW is not set
848 +# CONFIG_HPFS_FS is not set
851 +CONFIG_DEVFS_MOUNT=y
852 +# CONFIG_DEVFS_DEBUG is not set
854 +# CONFIG_QNX4FS_FS is not set
855 +# CONFIG_QNX4FS_RW is not set
856 +# CONFIG_ROMFS_FS is not set
858 +# CONFIG_SYSV_FS is not set
859 +# CONFIG_UDF_FS is not set
860 +# CONFIG_UDF_RW is not set
861 +# CONFIG_UFS_FS is not set
862 +# CONFIG_UFS_FS_WRITE is not set
865 +# Network File Systems
867 +# CONFIG_CODA_FS is not set
868 +# CONFIG_INTERMEZZO_FS is not set
869 +# CONFIG_NFS_FS is not set
870 +# CONFIG_NFS_V3 is not set
871 +# CONFIG_NFS_DIRECTIO is not set
872 +# CONFIG_ROOT_NFS is not set
873 +# CONFIG_NFSD is not set
874 +# CONFIG_NFSD_V3 is not set
875 +# CONFIG_NFSD_TCP is not set
876 +# CONFIG_SUNRPC is not set
877 +# CONFIG_LOCKD is not set
878 +# CONFIG_SMB_FS is not set
879 +# CONFIG_NCP_FS is not set
880 +# CONFIG_NCPFS_PACKET_SIGNING is not set
881 +# CONFIG_NCPFS_IOCTL_LOCKING is not set
882 +# CONFIG_NCPFS_STRONG is not set
883 +# CONFIG_NCPFS_NFS_NS is not set
884 +# CONFIG_NCPFS_OS2_NS is not set
885 +# CONFIG_NCPFS_SMALLDOS is not set
886 +# CONFIG_NCPFS_NLS is not set
887 +# CONFIG_NCPFS_EXTRAS is not set
888 +# CONFIG_ZISOFS_FS is not set
893 +# CONFIG_PARTITION_ADVANCED is not set
894 +CONFIG_MSDOS_PARTITION=y
895 +# CONFIG_SMB_NLS is not set
899 +# Native Language Support
901 +CONFIG_NLS_DEFAULT="iso8859-1"
902 +# CONFIG_NLS_CODEPAGE_437 is not set
903 +# CONFIG_NLS_CODEPAGE_737 is not set
904 +# CONFIG_NLS_CODEPAGE_775 is not set
905 +# CONFIG_NLS_CODEPAGE_850 is not set
906 +# CONFIG_NLS_CODEPAGE_852 is not set
907 +# CONFIG_NLS_CODEPAGE_855 is not set
908 +# CONFIG_NLS_CODEPAGE_857 is not set
909 +# CONFIG_NLS_CODEPAGE_860 is not set
910 +# CONFIG_NLS_CODEPAGE_861 is not set
911 +# CONFIG_NLS_CODEPAGE_862 is not set
912 +# CONFIG_NLS_CODEPAGE_863 is not set
913 +# CONFIG_NLS_CODEPAGE_864 is not set
914 +# CONFIG_NLS_CODEPAGE_865 is not set
915 +# CONFIG_NLS_CODEPAGE_866 is not set
916 +# CONFIG_NLS_CODEPAGE_869 is not set
917 +# CONFIG_NLS_CODEPAGE_936 is not set
918 +# CONFIG_NLS_CODEPAGE_950 is not set
919 +# CONFIG_NLS_CODEPAGE_932 is not set
920 +# CONFIG_NLS_CODEPAGE_949 is not set
921 +# CONFIG_NLS_CODEPAGE_874 is not set
922 +# CONFIG_NLS_ISO8859_8 is not set
923 +# CONFIG_NLS_CODEPAGE_1250 is not set
924 +# CONFIG_NLS_CODEPAGE_1251 is not set
925 +# CONFIG_NLS_ISO8859_1 is not set
926 +# CONFIG_NLS_ISO8859_2 is not set
927 +# CONFIG_NLS_ISO8859_3 is not set
928 +# CONFIG_NLS_ISO8859_4 is not set
929 +# CONFIG_NLS_ISO8859_5 is not set
930 +# CONFIG_NLS_ISO8859_6 is not set
931 +# CONFIG_NLS_ISO8859_7 is not set
932 +# CONFIG_NLS_ISO8859_9 is not set
933 +# CONFIG_NLS_ISO8859_13 is not set
934 +# CONFIG_NLS_ISO8859_14 is not set
935 +# CONFIG_NLS_ISO8859_15 is not set
936 +# CONFIG_NLS_KOI8_R is not set
937 +# CONFIG_NLS_KOI8_U is not set
938 +# CONFIG_NLS_UTF8 is not set
946 +# SCSI support type (disk, tape, CD-ROM)
948 +# CONFIG_BLK_DEV_SD is not set
949 +# CONFIG_CHR_DEV_ST is not set
950 +# CONFIG_BLK_DEV_SR is not set
951 +# CONFIG_CHR_DEV_SG is not set
954 +# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
956 +# CONFIG_SCSI_DEBUG_QUEUES is not set
957 +# CONFIG_SCSI_MULTI_LUN is not set
958 +# CONFIG_SCSI_CONSTANTS is not set
959 +# CONFIG_SCSI_LOGGING is not set
963 +# Multi-device support (RAID and LVM)
965 +# CONFIG_MD is not set
966 +# CONFIG_BLK_DEV_MD is not set
967 +# CONFIG_MD_LINEAR is not set
968 +# CONFIG_MD_RAID0 is not set
969 +# CONFIG_MD_RAID1 is not set
970 +# CONFIG_MD_RAID5 is not set
971 +# CONFIG_MD_MULTIPATH is not set
972 +# CONFIG_BLK_DEV_LVM is not set
975 +# Memory Technology Devices (MTD)
978 +# CONFIG_MTD_DEBUG is not set
979 +# CONFIG_MTD_PARTITIONS is not set
980 +# CONFIG_MTD_CONCAT is not set
981 +# CONFIG_MTD_REDBOOT_PARTS is not set
982 +# CONFIG_MTD_CMDLINE_PARTS is not set
985 +# User Modules And Translation Layers
989 +# CONFIG_FTL is not set
990 +# CONFIG_NFTL is not set
993 +# RAM/ROM/Flash chip drivers
995 +# CONFIG_MTD_CFI is not set
996 +# CONFIG_MTD_JEDECPROBE is not set
997 +# CONFIG_MTD_GEN_PROBE is not set
998 +# CONFIG_MTD_CFI_INTELEXT is not set
999 +# CONFIG_MTD_CFI_AMDSTD is not set
1000 +# CONFIG_MTD_CFI_STAA is not set
1001 +# CONFIG_MTD_RAM is not set
1002 +# CONFIG_MTD_ROM is not set
1003 +# CONFIG_MTD_ABSENT is not set
1004 +# CONFIG_MTD_OBSOLETE_CHIPS is not set
1005 +# CONFIG_MTD_AMDSTD is not set
1006 +# CONFIG_MTD_SHARP is not set
1007 +# CONFIG_MTD_JEDEC is not set
1010 +# Mapping drivers for chip access
1012 +# CONFIG_MTD_PHYSMAP is not set
1013 +# CONFIG_MTD_PCI is not set
1014 +# CONFIG_MTD_PCMCIA is not set
1017 +# Self-contained MTD device drivers
1019 +# CONFIG_MTD_PMC551 is not set
1020 +# CONFIG_MTD_SLRAM is not set
1021 +# CONFIG_MTD_MTDRAM is not set
1022 +CONFIG_MTD_BLKMTD=y
1025 +# Disk-On-Chip Device Drivers
1027 +# CONFIG_MTD_DOC1000 is not set
1028 +# CONFIG_MTD_DOC2000 is not set
1029 +# CONFIG_MTD_DOC2001 is not set
1030 +# CONFIG_MTD_DOCPROBE is not set
1033 +# NAND Flash Device Drivers
1035 +# CONFIG_MTD_NAND is not set
1040 +# CONFIG_CRC32 is not set
1041 +CONFIG_ZLIB_INFLATE=y
1042 +CONFIG_ZLIB_DEFLATE=y
1047 +# CONFIG_DEBUG_SLAB is not set
1050 +# CONFIG_GPROF is not set
1051 +# CONFIG_GCOV is not set
1052 diff -Naur -X ../exclude-files orig/arch/um/drivers/chan_kern.c um/arch/um/drivers/chan_kern.c
1053 --- orig/arch/um/drivers/chan_kern.c 1969-12-31 19:00:00.000000000 -0500
1054 +++ um/arch/um/drivers/chan_kern.c 2003-11-07 07:25:34.000000000 -0500
1057 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
1058 + * Licensed under the GPL
1061 +#include <linux/stddef.h>
1062 +#include <linux/kernel.h>
1063 +#include <linux/list.h>
1064 +#include <linux/slab.h>
1065 +#include <linux/tty.h>
1066 +#include <linux/string.h>
1067 +#include <linux/tty_flip.h>
1068 +#include <asm/irq.h>
1069 +#include "chan_kern.h"
1070 +#include "user_util.h"
1072 +#include "irq_user.h"
1076 +static void *not_configged_init(char *str, int device, struct chan_opts *opts)
1078 + printk(KERN_ERR "Using a channel type which is configured out of "
1083 +static int not_configged_open(int input, int output, int primary, void *data,
1086 + printk(KERN_ERR "Using a channel type which is configured out of "
1091 +static void not_configged_close(int fd, void *data)
1093 + printk(KERN_ERR "Using a channel type which is configured out of "
1097 +static int not_configged_read(int fd, char *c_out, void *data)
1099 + printk(KERN_ERR "Using a channel type which is configured out of "
1104 +static int not_configged_write(int fd, const char *buf, int len, void *data)
1106 + printk(KERN_ERR "Using a channel type which is configured out of "
1111 +static int not_configged_console_write(int fd, const char *buf, int len,
1114 + printk(KERN_ERR "Using a channel type which is configured out of "
1119 +static int not_configged_window_size(int fd, void *data, unsigned short *rows,
1120 + unsigned short *cols)
1122 + printk(KERN_ERR "Using a channel type which is configured out of "
1127 +static void not_configged_free(void *data)
1129 + printk(KERN_ERR "Using a channel type which is configured out of "
1133 +static struct chan_ops not_configged_ops = {
1134 + .init = not_configged_init,
1135 + .open = not_configged_open,
1136 + .close = not_configged_close,
1137 + .read = not_configged_read,
1138 + .write = not_configged_write,
1139 + .console_write = not_configged_console_write,
1140 + .window_size = not_configged_window_size,
1141 + .free = not_configged_free,
1145 +static void tty_receive_char(struct tty_struct *tty, char ch)
1147 + if(tty == NULL) return;
1149 + if(I_IXON(tty) && !I_IXOFF(tty) && !tty->raw) {
1150 + if(ch == STOP_CHAR(tty)){
1154 + else if(ch == START_CHAR(tty)){
1160 + if((tty->flip.flag_buf_ptr == NULL) ||
1161 + (tty->flip.char_buf_ptr == NULL))
1163 + tty_insert_flip_char(tty, ch, TTY_NORMAL);
1166 +static int open_one_chan(struct chan *chan, int input, int output, int primary)
1170 + if(chan->opened) return(0);
1171 + if(chan->ops->open == NULL) fd = 0;
1172 + else fd = (*chan->ops->open)(input, output, primary, chan->data,
1174 + if(fd < 0) return(fd);
1181 +int open_chan(struct list_head *chans)
1183 + struct list_head *ele;
1184 + struct chan *chan;
1187 + list_for_each(ele, chans){
1188 + chan = list_entry(ele, struct chan, list);
1189 + ret = open_one_chan(chan, chan->input, chan->output,
1191 + if(chan->primary) err = ret;
1196 +void chan_enable_winch(struct list_head *chans, void *line)
1198 + struct list_head *ele;
1199 + struct chan *chan;
1201 + list_for_each(ele, chans){
1202 + chan = list_entry(ele, struct chan, list);
1203 + if(chan->primary && chan->output && chan->ops->winch){
1204 + register_winch(chan->fd, line);
1210 +void enable_chan(struct list_head *chans, void *data)
1212 + struct list_head *ele;
1213 + struct chan *chan;
1215 + list_for_each(ele, chans){
1216 + chan = list_entry(ele, struct chan, list);
1217 + if(!chan->opened) continue;
1219 + line_setup_irq(chan->fd, chan->input, chan->output, data);
1223 +void close_chan(struct list_head *chans)
1225 + struct list_head *ele;
1226 + struct chan *chan;
1228 + /* Close in reverse order as open in case more than one of them
1229 + * refers to the same device and they save and restore that device's
1230 + * state. Then, the first one opened will have the original state,
1231 + * so it must be the last closed.
1233 + for(ele = chans->prev; ele != chans; ele = ele->prev){
1234 + chan = list_entry(ele, struct chan, list);
1235 + if(!chan->opened) continue;
1236 + if(chan->ops->close != NULL)
1237 + (*chan->ops->close)(chan->fd, chan->data);
1243 +int write_chan(struct list_head *chans, const char *buf, int len,
1246 + struct list_head *ele;
1247 + struct chan *chan;
1250 + list_for_each(ele, chans){
1251 + chan = list_entry(ele, struct chan, list);
1252 + if(!chan->output || (chan->ops->write == NULL)) continue;
1253 + n = chan->ops->write(chan->fd, buf, len, chan->data);
1254 + if(chan->primary){
1256 + if((ret == -EAGAIN) || ((ret >= 0) && (ret < len))){
1257 + reactivate_fd(chan->fd, write_irq);
1258 + if(ret == -EAGAIN) ret = 0;
1265 +int console_write_chan(struct list_head *chans, const char *buf, int len)
1267 + struct list_head *ele;
1268 + struct chan *chan;
1271 + list_for_each(ele, chans){
1272 + chan = list_entry(ele, struct chan, list);
1273 + if(!chan->output || (chan->ops->console_write == NULL))
1275 + n = chan->ops->console_write(chan->fd, buf, len, chan->data);
1276 + if(chan->primary) ret = n;
1281 +int chan_window_size(struct list_head *chans, unsigned short *rows_out,
1282 + unsigned short *cols_out)
1284 + struct list_head *ele;
1285 + struct chan *chan;
1287 + list_for_each(ele, chans){
1288 + chan = list_entry(ele, struct chan, list);
1289 + if(chan->primary){
1290 + if(chan->ops->window_size == NULL) return(0);
1291 + return(chan->ops->window_size(chan->fd, chan->data,
1292 + rows_out, cols_out));
1298 +void free_one_chan(struct chan *chan)
1300 + list_del(&chan->list);
1301 + if(chan->ops->free != NULL)
1302 + (*chan->ops->free)(chan->data);
1303 + free_irq_by_fd(chan->fd);
1304 + if(chan->primary && chan->output) ignore_sigio_fd(chan->fd);
1308 +void free_chan(struct list_head *chans)
1310 + struct list_head *ele, *next;
1311 + struct chan *chan;
1313 + list_for_each_safe(ele, next, chans){
1314 + chan = list_entry(ele, struct chan, list);
1315 + free_one_chan(chan);
1319 +static int one_chan_config_string(struct chan *chan, char *str, int size,
1325 + CONFIG_CHUNK(str, size, n, "none", 1);
1329 + CONFIG_CHUNK(str, size, n, chan->ops->type, 0);
1331 + if(chan->dev == NULL){
1332 + CONFIG_CHUNK(str, size, n, "", 1);
1336 + CONFIG_CHUNK(str, size, n, ":", 0);
1337 + CONFIG_CHUNK(str, size, n, chan->dev, 0);
1342 +static int chan_pair_config_string(struct chan *in, struct chan *out,
1343 + char *str, int size, char **error_out)
1347 + n = one_chan_config_string(in, str, size, error_out);
1352 + CONFIG_CHUNK(str, size, n, "", 1);
1356 + CONFIG_CHUNK(str, size, n, ",", 1);
1357 + n = one_chan_config_string(out, str, size, error_out);
1360 + CONFIG_CHUNK(str, size, n, "", 1);
1365 +int chan_config_string(struct list_head *chans, char *str, int size,
1368 + struct list_head *ele;
1369 + struct chan *chan, *in = NULL, *out = NULL;
1371 + list_for_each(ele, chans){
1372 + chan = list_entry(ele, struct chan, list);
1373 + if(!chan->primary)
1381 + return(chan_pair_config_string(in, out, str, size, error_out));
1386 + struct chan_ops *ops;
1389 +struct chan_type chan_table[] = {
1390 +#ifdef CONFIG_FD_CHAN
1391 + { "fd", &fd_ops },
1393 + { "fd", ¬_configged_ops },
1396 +#ifdef CONFIG_NULL_CHAN
1397 + { "null", &null_ops },
1399 + { "null", ¬_configged_ops },
1402 +#ifdef CONFIG_PORT_CHAN
1403 + { "port", &port_ops },
1405 + { "port", ¬_configged_ops },
1408 +#ifdef CONFIG_PTY_CHAN
1409 + { "pty", &pty_ops },
1410 + { "pts", &pts_ops },
1412 + { "pty", ¬_configged_ops },
1413 + { "pts", ¬_configged_ops },
1416 +#ifdef CONFIG_TTY_CHAN
1417 + { "tty", &tty_ops },
1419 + { "tty", ¬_configged_ops },
1422 +#ifdef CONFIG_XTERM_CHAN
1423 + { "xterm", &xterm_ops },
1425 + { "xterm", ¬_configged_ops },
1429 +static struct chan *parse_chan(char *str, int pri, int device,
1430 + struct chan_opts *opts)
1432 + struct chan_type *entry;
1433 + struct chan_ops *ops;
1434 + struct chan *chan;
1440 + for(i = 0; i < sizeof(chan_table)/sizeof(chan_table[0]); i++){
1441 + entry = &chan_table[i];
1442 + if(!strncmp(str, entry->key, strlen(entry->key))){
1444 + str += strlen(entry->key);
1449 + printk(KERN_ERR "parse_chan couldn't parse \"%s\"\n",
1453 + if(ops->init == NULL) return(NULL);
1454 + data = (*ops->init)(str, device, opts);
1455 + if(data == NULL) return(NULL);
1457 + chan = kmalloc(sizeof(*chan), GFP_KERNEL);
1458 + if(chan == NULL) return(NULL);
1459 + *chan = ((struct chan) { .list = LIST_HEAD_INIT(chan->list),
1471 +int parse_chan_pair(char *str, struct list_head *chans, int pri, int device,
1472 + struct chan_opts *opts)
1474 + struct chan *new, *chan;
1477 + if(!list_empty(chans)){
1478 + chan = list_entry(chans->next, struct chan, list);
1479 + if(chan->pri >= pri) return(0);
1481 + INIT_LIST_HEAD(chans);
1484 + out = strchr(str, ',');
1489 + new = parse_chan(in, pri, device, opts);
1490 + if(new == NULL) return(-1);
1492 + list_add(&new->list, chans);
1494 + new = parse_chan(out, pri, device, opts);
1495 + if(new == NULL) return(-1);
1496 + list_add(&new->list, chans);
1500 + new = parse_chan(str, pri, device, opts);
1501 + if(new == NULL) return(-1);
1502 + list_add(&new->list, chans);
1509 +int chan_out_fd(struct list_head *chans)
1511 + struct list_head *ele;
1512 + struct chan *chan;
1514 + list_for_each(ele, chans){
1515 + chan = list_entry(ele, struct chan, list);
1516 + if(chan->primary && chan->output)
1522 +void chan_interrupt(struct list_head *chans, struct tq_struct *task,
1523 + struct tty_struct *tty, int irq, void *dev)
1525 + struct list_head *ele, *next;
1526 + struct chan *chan;
1530 + list_for_each_safe(ele, next, chans){
1531 + chan = list_entry(ele, struct chan, list);
1532 + if(!chan->input || (chan->ops->read == NULL)) continue;
1534 + if((tty != NULL) &&
1535 + (tty->flip.count >= TTY_FLIPBUF_SIZE)){
1536 + queue_task(task, &tq_timer);
1539 + err = chan->ops->read(chan->fd, &c, chan->data);
1541 + tty_receive_char(tty, c);
1544 + if(err == 0) reactivate_fd(chan->fd, irq);
1546 + if(chan->primary){
1549 + line_disable(dev, irq);
1550 + close_chan(chans);
1555 + if(chan->ops->close != NULL)
1556 + chan->ops->close(chan->fd, chan->data);
1557 + free_one_chan(chan);
1562 + if(tty) tty_flip_buffer_push(tty);
1566 + * Overrides for Emacs so that we follow Linus's tabbing style.
1567 + * Emacs will notice this stuff at the end of the file and automatically
1568 + * adjust the settings for this buffer only. This must remain at the end
1570 + * ---------------------------------------------------------------------------
1571 + * Local variables:
1572 + * c-file-style: "linux"
1575 diff -Naur -X ../exclude-files orig/arch/um/drivers/chan_user.c um/arch/um/drivers/chan_user.c
1576 --- orig/arch/um/drivers/chan_user.c 1969-12-31 19:00:00.000000000 -0500
1577 +++ um/arch/um/drivers/chan_user.c 2003-11-07 07:23:45.000000000 -0500
1580 + * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
1581 + * Licensed under the GPL
1584 +#include <unistd.h>
1585 +#include <stdlib.h>
1587 +#include <termios.h>
1588 +#include <string.h>
1589 +#include <signal.h>
1590 +#include <sys/stat.h>
1591 +#include <sys/ioctl.h>
1592 +#include <sys/socket.h>
1593 +#include "kern_util.h"
1594 +#include "user_util.h"
1595 +#include "chan_user.h"
1597 +#include "helper.h"
1599 +#include "choose-mode.h"
1602 +void generic_close(int fd, void *unused)
1604 + os_close_file(fd);
1607 +int generic_read(int fd, char *c_out, void *unused)
1611 + n = os_read_file(fd, c_out, sizeof(*c_out));
1620 +/* XXX Trivial wrapper around os_write_file */
1622 +int generic_write(int fd, const char *buf, int n, void *unused)
1624 + return(os_write_file(fd, buf, n));
1627 +int generic_console_write(int fd, const char *buf, int n, void *unused)
1629 + struct termios save, new;
1633 + tcgetattr(fd, &save);
1635 + new.c_oflag |= OPOST;
1636 + tcsetattr(fd, TCSAFLUSH, &new);
1638 + err = generic_write(fd, buf, n, NULL);
1639 + if(isatty(fd)) tcsetattr(fd, TCSAFLUSH, &save);
1643 +int generic_window_size(int fd, void *unused, unsigned short *rows_out,
1644 + unsigned short *cols_out)
1649 + ret = os_window_size(fd, &rows, &cols);
1653 + ret = ((*rows_out != rows) || (*cols_out != cols));
1661 +void generic_free(void *data)
1666 +static void winch_handler(int sig)
1670 +struct winch_data {
1676 +static int winch_thread(void *arg)
1678 + struct winch_data *data = arg;
1680 + int pty_fd, pipe_fd;
1684 + os_close_file(data->close_me);
1685 + pty_fd = data->pty_fd;
1686 + pipe_fd = data->pipe_fd;
1687 + count = os_write_file(pipe_fd, &c, sizeof(c));
1688 + if(count != sizeof(c))
1689 + printk("winch_thread : failed to write synchronization "
1690 + "byte, err = %d\n", -count);
1692 + signal(SIGWINCH, winch_handler);
1693 + sigfillset(&sigs);
1694 + sigdelset(&sigs, SIGWINCH);
1695 + if(sigprocmask(SIG_SETMASK, &sigs, NULL) < 0){
1696 + printk("winch_thread : sigprocmask failed, errno = %d\n",
1702 + printk("winch_thread : setsid failed, errno = %d\n", errno);
1706 + err = os_new_tty_pgrp(pty_fd, os_getpid());
1708 + printk("winch_thread : new_tty_pgrp failed, err = %d\n", -err);
1712 + count = os_read_file(pipe_fd, &c, sizeof(c));
1713 + if(count != sizeof(c))
1714 + printk("winch_thread : failed to read synchronization byte, "
1715 + "err = %d\n", -count);
1720 + count = os_write_file(pipe_fd, &c, sizeof(c));
1721 + if(count != sizeof(c))
1722 + printk("winch_thread : write failed, err = %d\n",
1727 +static int winch_tramp(int fd, void *device_data, int *fd_out)
1729 + struct winch_data data;
1730 + unsigned long stack;
1731 + int fds[2], pid, n, err;
1734 + err = os_pipe(fds, 1, 1);
1736 + printk("winch_tramp : os_pipe failed, err = %d\n", -err);
1740 + data = ((struct winch_data) { .pty_fd = fd,
1741 + .pipe_fd = fds[1],
1742 + .close_me = fds[0] } );
1743 + pid = run_helper_thread(winch_thread, &data, 0, &stack, 0);
1745 + printk("fork of winch_thread failed - errno = %d\n", errno);
1749 + os_close_file(fds[1]);
1751 + n = os_read_file(fds[0], &c, sizeof(c));
1752 + if(n != sizeof(c)){
1753 + printk("winch_tramp : failed to read synchronization byte\n");
1754 + printk("read failed, err = %d\n", -n);
1755 + printk("fd %d will not support SIGWINCH\n", fd);
1761 +void register_winch(int fd, void *device_data)
1763 + int pid, thread, thread_fd;
1770 + pid = tcgetpgrp(fd);
1771 + if(!CHOOSE_MODE_PROC(is_tracer_winch, is_skas_winch, pid, fd,
1772 + device_data) && (pid == -1)){
1773 + thread = winch_tramp(fd, device_data, &thread_fd);
1775 + register_winch_irq(thread_fd, fd, thread, device_data);
1777 + count = os_write_file(thread_fd, &c, sizeof(c));
1778 + if(count != sizeof(c))
1779 + printk("register_winch : failed to write "
1780 + "synchronization byte, err = %d\n",
1787 + * Overrides for Emacs so that we follow Linus's tabbing style.
1788 + * Emacs will notice this stuff at the end of the file and automatically
1789 + * adjust the settings for this buffer only. This must remain at the end
1791 + * ---------------------------------------------------------------------------
1792 + * Local variables:
1793 + * c-file-style: "linux"
1796 diff -Naur -X ../exclude-files orig/arch/um/drivers/cow.h um/arch/um/drivers/cow.h
1797 --- orig/arch/um/drivers/cow.h 1969-12-31 19:00:00.000000000 -0500
1798 +++ um/arch/um/drivers/cow.h 2004-01-16 03:45:20.000000000 -0500
1803 +#include <asm/types.h>
1805 +#if __BYTE_ORDER == __BIG_ENDIAN
1806 +# define ntohll(x) (x)
1807 +# define htonll(x) (x)
1808 +#elif __BYTE_ORDER == __LITTLE_ENDIAN
1809 +# define ntohll(x) bswap_64(x)
1810 +# define htonll(x) bswap_64(x)
1812 +#error "__BYTE_ORDER not defined"
1815 +extern int init_cow_file(int fd, char *cow_file, char *backing_file,
1816 + int sectorsize, int alignment, int *bitmap_offset_out,
1817 + unsigned long *bitmap_len_out, int *data_offset_out);
1819 +extern int file_reader(__u64 offset, char *buf, int len, void *arg);
1820 +extern int read_cow_header(int (*reader)(__u64, char *, int, void *),
1821 + void *arg, __u32 *version_out,
1822 + char **backing_file_out, time_t *mtime_out,
1823 + __u64 *size_out, int *sectorsize_out,
1824 + __u32 *align_out, int *bitmap_offset_out);
1826 +extern int write_cow_header(char *cow_file, int fd, char *backing_file,
1827 + int sectorsize, int alignment, long long *size);
1829 +extern void cow_sizes(int version, __u64 size, int sectorsize, int align,
1830 + int bitmap_offset, unsigned long *bitmap_len_out,
1831 + int *data_offset_out);
1836 + * ---------------------------------------------------------------------------
1837 + * Local variables:
1838 + * c-file-style: "linux"
1841 diff -Naur -X ../exclude-files orig/arch/um/drivers/cow_kern.c um/arch/um/drivers/cow_kern.c
1842 --- orig/arch/um/drivers/cow_kern.c 1969-12-31 19:00:00.000000000 -0500
1843 +++ um/arch/um/drivers/cow_kern.c 2004-01-10 05:55:04.000000000 -0500
1845 +#define COW_MAJOR 60
1846 +#define MAJOR_NR COW_MAJOR
1848 +#include <linux/stddef.h>
1849 +#include <linux/kernel.h>
1850 +#include <linux/ctype.h>
1851 +#include <linux/stat.h>
1852 +#include <linux/vmalloc.h>
1853 +#include <linux/blkdev.h>
1854 +#include <linux/blk.h>
1855 +#include <linux/fs.h>
1856 +#include <linux/genhd.h>
1857 +#include <linux/devfs_fs.h>
1858 +#include <asm/uaccess.h>
1859 +#include "2_5compat.h"
1861 +#include "ubd_user.h"
1863 +#define COW_SHIFT 4
1869 + struct block_device *cow_bdev;
1870 + char *backing_path;
1871 + dev_t backing_dev;
1872 + struct block_device *backing_bdev;
1874 + unsigned long *bitmap;
1875 + unsigned long bitmap_len;
1876 + int bitmap_offset;
1878 + devfs_handle_t devfs;
1879 + struct semaphore sem;
1880 + struct semaphore io_sem;
1882 + spinlock_t io_lock;
1883 + struct buffer_head *bh;
1884 + struct buffer_head *bhtail;
1888 +#define DEFAULT_COW { \
1890 + .cow_path = NULL, \
1892 + .backing_path = NULL, \
1893 + .backing_dev = 0, \
1895 + .bitmap_len = 0, \
1896 + .bitmap_offset = 0, \
1897 + .data_offset = 0, \
1899 + .working = ATOMIC_INIT(0), \
1900 + .io_lock = SPIN_LOCK_UNLOCKED, \
1903 +#define MAX_DEV (8)
1904 +#define MAX_MINOR (MAX_DEV << COW_SHIFT)
1906 +struct cow cow_dev[MAX_DEV] = { [ 0 ... MAX_DEV - 1 ] = DEFAULT_COW };
1908 +/* Not modified by this driver */
1909 +static int blk_sizes[MAX_MINOR] = { [ 0 ... MAX_MINOR - 1 ] = BLOCK_SIZE };
1910 +static int hardsect_sizes[MAX_MINOR] = { [ 0 ... MAX_MINOR - 1 ] = 512 };
1912 +/* Protected by cow_lock */
1913 +static int sizes[MAX_MINOR] = { [ 0 ... MAX_MINOR - 1 ] = 0 };
1915 +static struct hd_struct cow_part[MAX_MINOR] =
1916 + { [ 0 ... MAX_MINOR - 1 ] = { 0, 0, 0 } };
1918 +/* Protected by io_request_lock */
1919 +static request_queue_t *cow_queue;
1921 +static int cow_open(struct inode *inode, struct file *filp);
1922 +static int cow_release(struct inode * inode, struct file * file);
1923 +static int cow_ioctl(struct inode * inode, struct file * file,
1924 + unsigned int cmd, unsigned long arg);
1925 +static int cow_revalidate(kdev_t rdev);
1927 +static struct block_device_operations cow_blops = {
1929 + .release = cow_release,
1930 + .ioctl = cow_ioctl,
1931 + .revalidate = cow_revalidate,
1934 +/* Initialized in an initcall, and unchanged thereafter */
1935 +devfs_handle_t cow_dir_handle;
1937 +#define INIT_GENDISK(maj, name, parts, shift, bsizes, max, blops) \
1940 + .major_name = name, \
1941 + .minor_shift = shift, \
1942 + .max_p = 1 << shift, \
1944 + .sizes = bsizes, \
1946 + .real_devices = NULL, \
1953 +static spinlock_t cow_lock = SPIN_LOCK_UNLOCKED;
1955 +static struct gendisk cow_gendisk = INIT_GENDISK(MAJOR_NR, "cow", cow_part,
1956 + COW_SHIFT, sizes, MAX_DEV,
1959 +static int cow_add(int n)
1961 + struct cow *dev = &cow_dev[n];
1962 + char name[sizeof("nnnnnn\0")];
1963 + int err = -ENODEV;
1965 + if(dev->cow_path == NULL)
1968 + sprintf(name, "%d", n);
1969 + dev->devfs = devfs_register(cow_dir_handle, name, DEVFS_FL_REMOVABLE,
1970 + MAJOR_NR, n << COW_SHIFT, S_IFBLK |
1971 + S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
1972 + &cow_blops, NULL);
1974 + init_MUTEX_LOCKED(&dev->sem);
1975 + init_MUTEX(&dev->io_sem);
1984 + * Add buffer_head to back of pending list
1986 +static void cow_add_bh(struct cow *cow, struct buffer_head *bh)
1988 + unsigned long flags;
1990 + spin_lock_irqsave(&cow->io_lock, flags);
1991 + if(cow->bhtail != NULL){
1992 + cow->bhtail->b_reqnext = bh;
1999 + spin_unlock_irqrestore(&cow->io_lock, flags);
2003 + * Grab first pending buffer
2005 +static struct buffer_head *cow_get_bh(struct cow *cow)
2007 + struct buffer_head *bh;
2009 + spin_lock_irq(&cow->io_lock);
2012 + if(bh == cow->bhtail)
2013 + cow->bhtail = NULL;
2014 + cow->bh = bh->b_reqnext;
2015 + bh->b_reqnext = NULL;
2017 + spin_unlock_irq(&cow->io_lock);
2022 +static void cow_handle_bh(struct cow *cow, struct buffer_head *bh,
2023 + struct buffer_head **cow_bh, int ncow_bh)
2028 + ll_rw_block(WRITE, ncow_bh, cow_bh);
2030 + for(i = 0; i < ncow_bh ; i++){
2031 + wait_on_buffer(cow_bh[i]);
2032 + brelse(cow_bh[i]);
2035 + ll_rw_block(WRITE, 1, &bh);
2039 +static struct buffer_head *cow_new_bh(struct cow *dev, int sector)
2041 + struct buffer_head *bh;
2043 + sector = (dev->bitmap_offset + sector / 8) / dev->sectorsize;
2044 + bh = getblk(dev->cow_dev, sector, dev->sectorsize);
2045 + memcpy(bh->b_data, dev->bitmap + sector / (8 * sizeof(dev->bitmap[0])),
2050 +/* Copied from loop.c, needed to avoid deadlocking in make_request. */
2052 +static int cow_thread(void *data)
2054 + struct cow *dev = data;
2055 + struct buffer_head *bh;
2058 + exit_files(current);
2060 + sprintf(current->comm, "cow%d", dev - cow_dev);
2062 + spin_lock_irq(¤t->sigmask_lock);
2063 + sigfillset(¤t->blocked);
2064 + flush_signals(current);
2065 + spin_unlock_irq(¤t->sigmask_lock);
2067 + atomic_inc(&dev->working);
2069 + current->policy = SCHED_OTHER;
2070 + current->nice = -20;
2072 + current->flags |= PF_NOIO;
2075 + * up sem, we are running
2080 + int start, len, nbh, i, update_bitmap = 0;
2081 + struct buffer_head *cow_bh[2];
2083 + down_interruptible(&dev->io_sem);
2085 + * could be upped because of tear-down, not because of
2088 + if(!atomic_read(&dev->working))
2091 + bh = cow_get_bh(dev);
2093 + printk(KERN_ERR "cow: missing bh\n");
2097 + start = bh->b_blocknr * bh->b_size / dev->sectorsize;
2098 + len = bh->b_size / dev->sectorsize;
2099 + for(i = 0; i < len ; i++){
2100 + if(ubd_test_bit(start + i,
2101 + (unsigned char *) dev->bitmap))
2104 + update_bitmap = 1;
2105 + ubd_set_bit(start + i, (unsigned char *) dev->bitmap);
2111 + if(update_bitmap){
2112 + cow_bh[0] = cow_new_bh(dev, start);
2114 + if(start / dev->sectorsize !=
2115 + (start + len) / dev->sectorsize){
2116 + cow_bh[1] = cow_new_bh(dev, start + len);
2121 + bh->b_dev = dev->cow_dev;
2122 + bh->b_blocknr += dev->data_offset / dev->sectorsize;
2124 + cow_handle_bh(dev, bh, cow_bh, nbh);
2127 + * upped both for pending work and tear-down, lo_pending
2128 + * will hit zero then
2130 + if(atomic_dec_and_test(&dev->working))
2138 +static int cow_make_request(request_queue_t *q, int rw, struct buffer_head *bh)
2143 + minor = MINOR(bh->b_rdev);
2144 + n = minor >> COW_SHIFT;
2145 + dev = &cow_dev[n];
2147 + dev->end_io = NULL;
2148 + if(ubd_test_bit(bh->b_rsector, (unsigned char *) dev->bitmap)){
2149 + bh->b_rdev = dev->cow_dev;
2150 + bh->b_rsector += dev->data_offset / dev->sectorsize;
2152 + else if(rw == WRITE){
2153 + bh->b_dev = dev->cow_dev;
2154 + bh->b_blocknr += dev->data_offset / dev->sectorsize;
2156 + cow_add_bh(dev, bh);
2161 + bh->b_rdev = dev->backing_dev;
2171 + cow_dir_handle = devfs_mk_dir (NULL, "cow", NULL);
2172 + if (devfs_register_blkdev(MAJOR_NR, "cow", &cow_blops)) {
2173 + printk(KERN_ERR "cow: unable to get major %d\n", MAJOR_NR);
2176 + read_ahead[MAJOR_NR] = 8; /* 8 sector (4kB) read-ahead */
2177 + blksize_size[MAJOR_NR] = blk_sizes;
2178 + blk_size[MAJOR_NR] = sizes;
2179 + INIT_HARDSECT(hardsect_size, MAJOR_NR, hardsect_sizes);
2181 + cow_queue = BLK_DEFAULT_QUEUE(MAJOR_NR);
2182 + blk_init_queue(cow_queue, NULL);
2183 + INIT_ELV(cow_queue, &cow_queue->elevator);
2184 + blk_queue_make_request(cow_queue, cow_make_request);
2186 + add_gendisk(&cow_gendisk);
2188 + for(i=0;i<MAX_DEV;i++)
2194 +__initcall(cow_init);
2196 +static int reader(__u64 start, char *buf, int count, void *arg)
2198 + dev_t dev = *((dev_t *) arg);
2199 + struct buffer_head *bh;
2201 + int cur, offset, left, n, blocksize = get_hardsect_size(dev);
2203 + if(blocksize == 0)
2204 + panic("Zero blocksize");
2206 + block = start / blocksize;
2207 + offset = start % blocksize;
2211 + n = (left > blocksize) ? blocksize : left;
2213 + bh = bread(dev, block, (n < 512) ? 512 : n);
2218 + memcpy(&buf[cur], bh->b_data + offset, n);
2229 +static int cow_open(struct inode *inode, struct file *filp)
2231 + int (*dev_ioctl)(struct inode *, struct file *, unsigned int,
2236 + __u32 version, align;
2238 + char *backing_file;
2239 + int n, offset, err = 0;
2241 + n = DEVICE_NR(inode->i_rdev);
2244 + dev = &cow_dev[n];
2245 + offset = n << COW_SHIFT;
2247 + spin_lock(&cow_lock);
2249 + if(dev->count == 0){
2250 + dev->cow_dev = name_to_kdev_t(dev->cow_path);
2251 + if(dev->cow_dev == 0){
2252 + printk(KERN_ERR "cow_open - name_to_kdev_t(\"%s\") "
2253 + "failed\n", dev->cow_path);
2257 + dev->backing_dev = name_to_kdev_t(dev->backing_path);
2258 + if(dev->backing_dev == 0){
2259 + printk(KERN_ERR "cow_open - name_to_kdev_t(\"%s\") "
2260 + "failed\n", dev->backing_path);
2267 + dev->cow_bdev = bdget(dev->cow_dev);
2268 + if(dev->cow_bdev == NULL){
2269 + printk(KERN_ERR "cow_open - bdget(\"%s\") failed\n",
2273 + dev->backing_bdev = bdget(dev->backing_dev);
2274 + if(dev->backing_bdev == NULL){
2275 + printk(KERN_ERR "cow_open - bdget(\"%s\") failed\n",
2276 + dev->backing_path);
2283 + err = blkdev_get(dev->cow_bdev, FMODE_READ|FMODE_WRITE, 0,
2286 + printk("cow_open - blkdev_get of COW device failed, "
2287 + "error = %d\n", err);
2291 + err = blkdev_get(dev->backing_bdev, FMODE_READ, 0, BDEV_RAW);
2293 + printk("cow_open - blkdev_get of backing device "
2294 + "failed, error = %d\n", err);
2298 + err = read_cow_header(reader, &dev->cow_dev, &version,
2299 + &backing_file, &mtime, &size,
2300 + &dev->sectorsize, &align,
2301 + &dev->bitmap_offset);
2303 + printk(KERN_ERR "cow_open - read_cow_header failed, "
2304 + "err = %d\n", err);
2308 + cow_sizes(version, size, dev->sectorsize, align,
2309 + dev->bitmap_offset, &dev->bitmap_len,
2310 + &dev->data_offset);
2311 + dev->bitmap = (void *) vmalloc(dev->bitmap_len);
2312 + if(dev->bitmap == NULL){
2314 + printk(KERN_ERR "Failed to vmalloc COW bitmap\n");
2317 + flush_tlb_kernel_vm();
2319 + err = reader(dev->bitmap_offset, (char *) dev->bitmap,
2320 + dev->bitmap_len, &dev->cow_dev);
2322 + printk(KERN_ERR "Failed to read COW bitmap\n");
2323 + vfree(dev->bitmap);
2327 + dev_ioctl = dev->backing_bdev->bd_op->ioctl;
2329 + set_fs(KERNEL_DS);
2330 + err = (*dev_ioctl)(inode, filp, BLKGETSIZE,
2331 + (unsigned long) &sizes[offset]);
2334 + printk(KERN_ERR "cow_open - BLKGETSIZE failed, "
2335 + "error = %d\n", err);
2339 + kernel_thread(cow_thread, dev,
2340 + CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
2345 + spin_unlock(&cow_lock);
2349 +static int cow_release(struct inode * inode, struct file * file)
2354 + n = DEVICE_NR(inode->i_rdev);
2357 + dev = &cow_dev[n];
2359 + spin_lock(&cow_lock);
2361 + if(--dev->count > 0)
2364 + err = blkdev_put(dev->cow_bdev, BDEV_RAW);
2366 + printk("cow_release - blkdev_put of cow device failed, "
2367 + "error = %d\n", err);
2368 + bdput(dev->cow_bdev);
2369 + dev->cow_bdev = 0;
2371 + err = blkdev_put(dev->backing_bdev, BDEV_RAW);
2373 + printk("cow_release - blkdev_put of backing device failed, "
2374 + "error = %d\n", err);
2375 + bdput(dev->backing_bdev);
2376 + dev->backing_bdev = 0;
2379 + spin_unlock(&cow_lock);
2383 +static int cow_ioctl(struct inode * inode, struct file * file,
2384 + unsigned int cmd, unsigned long arg)
2387 + int (*dev_ioctl)(struct inode *, struct file *, unsigned int,
2391 + n = DEVICE_NR(inode->i_rdev);
2394 + dev = &cow_dev[n];
2396 + dev_ioctl = dev->backing_bdev->bd_op->ioctl;
2397 + return((*dev_ioctl)(inode, file, cmd, arg));
2400 +static int cow_revalidate(kdev_t rdev)
2402 + printk(KERN_ERR "Need to implement cow_revalidate\n");
2406 +static int parse_unit(char **ptr)
2408 + char *str = *ptr, *end;
2411 + if(isdigit(*str)) {
2412 + n = simple_strtoul(str, &end, 0);
2417 + else if (('a' <= *str) && (*str <= 'h')) {
2425 +static int cow_setup(char *str)
2428 + char *cow_name, *backing_name;
2431 + unit = parse_unit(&str);
2433 + printk(KERN_ERR "cow_setup - Couldn't parse unit number\n");
2438 + printk(KERN_ERR "cow_setup - Missing '=' after unit "
2445 + backing_name = strchr(str, ',');
2446 + if(backing_name == NULL){
2447 + printk(KERN_ERR "cow_setup - missing backing device name\n");
2450 + *backing_name = '\0';
2453 + spin_lock(&cow_lock);
2455 + dev = &cow_dev[unit];
2456 + dev->cow_path = cow_name;
2457 + dev->backing_path = backing_name;
2459 + spin_unlock(&cow_lock);
2463 +__setup("cow", cow_setup);
2466 + * Overrides for Emacs so that we follow Linus's tabbing style.
2467 + * Emacs will notice this stuff at the end of the file and automatically
2468 + * adjust the settings for this buffer only. This must remain at the end
2470 + * ---------------------------------------------------------------------------
2471 + * Local variables:
2472 + * c-file-style: "linux"
2475 diff -Naur -X ../exclude-files orig/arch/um/drivers/cow_sys.h um/arch/um/drivers/cow_sys.h
2476 --- orig/arch/um/drivers/cow_sys.h 1969-12-31 19:00:00.000000000 -0500
2477 +++ um/arch/um/drivers/cow_sys.h 2003-12-17 10:53:03.000000000 -0500
2479 +#ifndef __COW_SYS_H__
2480 +#define __COW_SYS_H__
2482 +#include "kern_util.h"
2483 +#include "user_util.h"
2487 +static inline void *cow_malloc(int size)
2489 + return(um_kmalloc(size));
2492 +static inline void cow_free(void *ptr)
2497 +#define cow_printf printk
2499 +static inline char *cow_strdup(char *str)
2501 + return(uml_strdup(str));
2504 +static inline int cow_seek_file(int fd, __u64 offset)
2506 + return(os_seek_file(fd, offset));
2509 +static inline int cow_file_size(char *file, __u64 *size_out)
2511 + return(os_file_size(file, size_out));
2514 +static inline int cow_write_file(int fd, char *buf, int size)
2516 + return(os_write_file(fd, buf, size));
2522 + * ---------------------------------------------------------------------------
2523 + * Local variables:
2524 + * c-file-style: "linux"
2527 diff -Naur -X ../exclude-files orig/arch/um/drivers/cow_user.c um/arch/um/drivers/cow_user.c
2528 --- orig/arch/um/drivers/cow_user.c 1969-12-31 19:00:00.000000000 -0500
2529 +++ um/arch/um/drivers/cow_user.c 2004-01-10 05:56:22.000000000 -0500
2531 +#include <stddef.h>
2532 +#include <string.h>
2534 +#include <unistd.h>
2535 +#include <byteswap.h>
2536 +#include <sys/time.h>
2537 +#include <sys/param.h>
2538 +#include <sys/user.h>
2539 +#include <netinet/in.h>
2544 +#include "cow_sys.h"
2546 +#define PATH_LEN_V1 256
2548 +struct cow_header_v1 {
2551 + char backing_file[PATH_LEN_V1];
2557 +#define PATH_LEN_V2 MAXPATHLEN
2559 +struct cow_header_v2 {
2560 + unsigned long magic;
2561 + unsigned long version;
2562 + char backing_file[PATH_LEN_V2];
2568 +/* Define PATH_LEN_V3 as the usual value of MAXPATHLEN, just hard-code it in
2569 + * case other systems have different values for MAXPATHLEN
2571 +#define PATH_LEN_V3 4096
2573 +/* Changes from V2 -
2574 + * PATH_LEN_V3 as described above
2575 + * Explicitly specify field bit lengths for systems with different
2576 + * lengths for the usual C types. Not sure whether char or
2577 + * time_t should be changed, this can be changed later without
2578 + * breaking compatibility
2579 + * Add alignment field so that different alignments can be used for the
2581 + * Add cow_format field to allow for the possibility of different ways
2582 + * of specifying the COW blocks. For now, the only value is 0,
2583 + * for the traditional COW bitmap.
2584 + * Move the backing_file field to the end of the header. This allows
2585 + * for the possibility of expanding it into the padding required
2586 + * by the bitmap alignment.
2587 + * The bitmap and data portions of the file will be aligned as specified
2588 + * by the alignment field. This is to allow COW files to be
2589 + * put on devices with restrictions on access alignments, such as
2590 + * /dev/raw, with a 512 byte alignment restriction. This also
2591 + * allows the data to be more aligned more strictly than on
2592 + * sector boundaries. This is needed for ubd-mmap, which needs
2593 + * the data to be page aligned.
2594 + * Fixed (finally!) the rounding bug
2597 +struct cow_header_v3 {
2605 + char backing_file[PATH_LEN_V3];
2608 +/* COW format definitions - for now, we have only the usual COW bitmap */
2609 +#define COW_BITMAP 0
2612 + struct cow_header_v1 v1;
2613 + struct cow_header_v2 v2;
2614 + struct cow_header_v3 v3;
2617 +#define COW_MAGIC 0x4f4f4f4d /* MOOO */
2618 +#define COW_VERSION 3
2620 +#define DIV_ROUND(x, len) (((x) + (len) - 1) / (len))
2621 +#define ROUND_UP(x, align) DIV_ROUND(x, align) * (align)
2623 +void cow_sizes(int version, __u64 size, int sectorsize, int align,
2624 + int bitmap_offset, unsigned long *bitmap_len_out,
2625 + int *data_offset_out)
2628 + *bitmap_len_out = (size + sectorsize - 1) / (8 * sectorsize);
2630 + *data_offset_out = bitmap_offset + *bitmap_len_out;
2631 + *data_offset_out = (*data_offset_out + sectorsize - 1) /
2633 + *data_offset_out *= sectorsize;
2636 + *bitmap_len_out = DIV_ROUND(size, sectorsize);
2637 + *bitmap_len_out = DIV_ROUND(*bitmap_len_out, 8);
2639 + *data_offset_out = bitmap_offset + *bitmap_len_out;
2640 + *data_offset_out = ROUND_UP(*data_offset_out, align);
2644 +static int absolutize(char *to, int size, char *from)
2646 + char save_cwd[256], *slash;
2649 + if(getcwd(save_cwd, sizeof(save_cwd)) == NULL) {
2650 + cow_printf("absolutize : unable to get cwd - errno = %d\n",
2654 + slash = strrchr(from, '/');
2655 + if(slash != NULL){
2659 + cow_printf("absolutize : Can't cd to '%s' - "
2660 + "errno = %d\n", from, errno);
2664 + if(getcwd(to, size) == NULL){
2665 + cow_printf("absolutize : unable to get cwd of '%s' - "
2666 + "errno = %d\n", from, errno);
2669 + remaining = size - strlen(to);
2670 + if(strlen(slash) + 1 > remaining){
2671 + cow_printf("absolutize : unable to fit '%s' into %d "
2672 + "chars\n", from, size);
2675 + strcat(to, slash);
2678 + if(strlen(save_cwd) + 1 + strlen(from) + 1 > size){
2679 + cow_printf("absolutize : unable to fit '%s' into %d "
2680 + "chars\n", from, size);
2683 + strcpy(to, save_cwd);
2691 +int write_cow_header(char *cow_file, int fd, char *backing_file,
2692 + int sectorsize, int alignment, long long *size)
2694 + struct cow_header_v3 *header;
2695 + unsigned long modtime;
2698 + err = cow_seek_file(fd, 0);
2700 + cow_printf("write_cow_header - lseek failed, err = %d\n", -err);
2705 + header = cow_malloc(sizeof(*header));
2706 + if(header == NULL){
2707 + cow_printf("Failed to allocate COW V3 header\n");
2710 + header->magic = htonl(COW_MAGIC);
2711 + header->version = htonl(COW_VERSION);
2714 + if(strlen(backing_file) > sizeof(header->backing_file) - 1){
2715 + cow_printf("Backing file name \"%s\" is too long - names are "
2716 + "limited to %d characters\n", backing_file,
2717 + sizeof(header->backing_file) - 1);
2721 + if(absolutize(header->backing_file, sizeof(header->backing_file),
2725 + err = os_file_modtime(header->backing_file, &modtime);
2727 + cow_printf("Backing file '%s' mtime request failed, "
2728 + "err = %d\n", header->backing_file, -err);
2732 + err = cow_file_size(header->backing_file, size);
2734 + cow_printf("Couldn't get size of backing file '%s', "
2735 + "err = %d\n", header->backing_file, -err);
2739 + header->mtime = htonl(modtime);
2740 + header->size = htonll(*size);
2741 + header->sectorsize = htonl(sectorsize);
2742 + header->alignment = htonl(alignment);
2743 + header->cow_format = COW_BITMAP;
2745 + err = os_write_file(fd, header, sizeof(*header));
2746 + if(err != sizeof(*header)){
2747 + cow_printf("Write of header to new COW file '%s' failed, "
2748 + "err = %d\n", cow_file, -err);
2758 +int file_reader(__u64 offset, char *buf, int len, void *arg)
2760 + int fd = *((int *) arg);
2762 + return(pread(fd, buf, len, offset));
2765 +/* XXX Need to sanity-check the values read from the header */
2767 +int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg,
2768 + __u32 *version_out, char **backing_file_out,
2769 + time_t *mtime_out, __u64 *size_out,
2770 + int *sectorsize_out, __u32 *align_out,
2771 + int *bitmap_offset_out)
2773 + union cow_header *header;
2776 + unsigned long version, magic;
2778 + header = cow_malloc(sizeof(*header));
2779 + if(header == NULL){
2780 + cow_printf("read_cow_header - Failed to allocate header\n");
2784 + n = (*reader)(0, (char *) header, sizeof(*header), arg);
2785 + if(n < offsetof(typeof(header->v1), backing_file)){
2786 + cow_printf("read_cow_header - short header\n");
2790 + magic = header->v1.magic;
2791 + if(magic == COW_MAGIC) {
2792 + version = header->v1.version;
2794 + else if(magic == ntohl(COW_MAGIC)){
2795 + version = ntohl(header->v1.version);
2797 + /* No error printed because the non-COW case comes through here */
2800 + *version_out = version;
2803 + if(n < sizeof(header->v1)){
2804 + cow_printf("read_cow_header - failed to read V1 "
2808 + *mtime_out = header->v1.mtime;
2809 + *size_out = header->v1.size;
2810 + *sectorsize_out = header->v1.sectorsize;
2811 + *bitmap_offset_out = sizeof(header->v1);
2812 + *align_out = *sectorsize_out;
2813 + file = header->v1.backing_file;
2815 + else if(version == 2){
2816 + if(n < sizeof(header->v2)){
2817 + cow_printf("read_cow_header - failed to read V2 "
2821 + *mtime_out = ntohl(header->v2.mtime);
2822 + *size_out = ntohll(header->v2.size);
2823 + *sectorsize_out = ntohl(header->v2.sectorsize);
2824 + *bitmap_offset_out = sizeof(header->v2);
2825 + *align_out = *sectorsize_out;
2826 + file = header->v2.backing_file;
2828 + else if(version == 3){
2829 + if(n < sizeof(header->v3)){
2830 + cow_printf("read_cow_header - failed to read V2 "
2834 + *mtime_out = ntohl(header->v3.mtime);
2835 + *size_out = ntohll(header->v3.size);
2836 + *sectorsize_out = ntohl(header->v3.sectorsize);
2837 + *align_out = ntohl(header->v3.alignment);
2838 + *bitmap_offset_out = ROUND_UP(sizeof(header->v3), *align_out);
2839 + file = header->v3.backing_file;
2842 + cow_printf("read_cow_header - invalid COW version\n");
2846 + *backing_file_out = cow_strdup(file);
2847 + if(*backing_file_out == NULL){
2848 + cow_printf("read_cow_header - failed to allocate backing "
2858 +int init_cow_file(int fd, char *cow_file, char *backing_file, int sectorsize,
2859 + int alignment, int *bitmap_offset_out,
2860 + unsigned long *bitmap_len_out, int *data_offset_out)
2862 + __u64 size, offset;
2866 + err = write_cow_header(cow_file, fd, backing_file, sectorsize,
2867 + alignment, &size);
2871 + *bitmap_offset_out = ROUND_UP(sizeof(struct cow_header_v3), alignment);
2872 + cow_sizes(COW_VERSION, size, sectorsize, alignment, *bitmap_offset_out,
2873 + bitmap_len_out, data_offset_out);
2875 + offset = *data_offset_out + size - sizeof(zero);
2876 + err = cow_seek_file(fd, offset);
2878 + cow_printf("cow bitmap lseek failed : err = %d\n", -err);
2882 + /* does not really matter how much we write it is just to set EOF
2883 + * this also sets the entire COW bitmap
2884 + * to zero without having to allocate it
2886 + err = cow_write_file(fd, &zero, sizeof(zero));
2887 + if(err != sizeof(zero)){
2888 + cow_printf("Write of bitmap to new COW file '%s' failed, "
2889 + "err = %d\n", cow_file, -err);
2901 + * ---------------------------------------------------------------------------
2902 + * Local variables:
2903 + * c-file-style: "linux"
2906 diff -Naur -X ../exclude-files orig/arch/um/drivers/daemon.h um/arch/um/drivers/daemon.h
2907 --- orig/arch/um/drivers/daemon.h 1969-12-31 19:00:00.000000000 -0500
2908 +++ um/arch/um/drivers/daemon.h 2003-10-21 03:26:06.000000000 -0400
2911 + * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
2912 + * Licensed under the GPL
2915 +#include "net_user.h"
2917 +#define SWITCH_VERSION 3
2919 +struct daemon_data {
2930 +extern struct net_user_info daemon_user_info;
2932 +extern int daemon_user_write(int fd, void *buf, int len,
2933 + struct daemon_data *pri);
2936 + * Overrides for Emacs so that we follow Linus's tabbing style.
2937 + * Emacs will notice this stuff at the end of the file and automatically
2938 + * adjust the settings for this buffer only. This must remain at the end
2940 + * ---------------------------------------------------------------------------
2941 + * Local variables:
2942 + * c-file-style: "linux"
2945 diff -Naur -X ../exclude-files orig/arch/um/drivers/daemon_kern.c um/arch/um/drivers/daemon_kern.c
2946 --- orig/arch/um/drivers/daemon_kern.c 1969-12-31 19:00:00.000000000 -0500
2947 +++ um/arch/um/drivers/daemon_kern.c 2003-10-21 03:26:06.000000000 -0400
2950 + * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
2951 + * James Leu (jleu@mindspring.net).
2952 + * Copyright (C) 2001 by various other people who didn't put their name here.
2953 + * Licensed under the GPL.
2956 +#include "linux/kernel.h"
2957 +#include "linux/init.h"
2958 +#include "linux/netdevice.h"
2959 +#include "linux/etherdevice.h"
2960 +#include "net_kern.h"
2961 +#include "net_user.h"
2962 +#include "daemon.h"
2964 +struct daemon_init {
2969 +void daemon_init(struct net_device *dev, void *data)
2971 + struct uml_net_private *pri;
2972 + struct daemon_data *dpri;
2973 + struct daemon_init *init = data;
2975 + init_etherdev(dev, 0);
2977 + dpri = (struct daemon_data *) pri->user;
2978 + *dpri = ((struct daemon_data)
2979 + { .sock_type = init->sock_type,
2980 + .ctl_sock = init->ctl_sock,
2982 + .data_addr = NULL,
2983 + .local_addr = NULL,
2988 + printk("daemon backend (uml_switch version %d) - %s:%s",
2989 + SWITCH_VERSION, dpri->sock_type, dpri->ctl_sock);
2993 +static int daemon_read(int fd, struct sk_buff **skb,
2994 + struct uml_net_private *lp)
2996 + *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER);
2997 + if(*skb == NULL) return(-ENOMEM);
2998 + return(net_recvfrom(fd, (*skb)->mac.raw,
2999 + (*skb)->dev->mtu + ETH_HEADER_OTHER));
3002 +static int daemon_write(int fd, struct sk_buff **skb,
3003 + struct uml_net_private *lp)
3005 + return(daemon_user_write(fd, (*skb)->data, (*skb)->len,
3006 + (struct daemon_data *) &lp->user));
3009 +static struct net_kern_info daemon_kern_info = {
3010 + .init = daemon_init,
3011 + .protocol = eth_protocol,
3012 + .read = daemon_read,
3013 + .write = daemon_write,
3016 +int daemon_setup(char *str, char **mac_out, void *data)
3018 + struct daemon_init *init = data;
3021 + *init = ((struct daemon_init)
3022 + { .sock_type = "unix",
3023 + .ctl_sock = "/tmp/uml.ctl" });
3025 + remain = split_if_spec(str, mac_out, &init->sock_type, &init->ctl_sock,
3027 + if(remain != NULL)
3028 + printk(KERN_WARNING "daemon_setup : Ignoring data socket "
3029 + "specification\n");
3034 +static struct transport daemon_transport = {
3035 + .list = LIST_HEAD_INIT(daemon_transport.list),
3037 + .setup = daemon_setup,
3038 + .user = &daemon_user_info,
3039 + .kern = &daemon_kern_info,
3040 + .private_size = sizeof(struct daemon_data),
3041 + .setup_size = sizeof(struct daemon_init),
3044 +static int register_daemon(void)
3046 + register_transport(&daemon_transport);
3050 +__initcall(register_daemon);
3053 + * Overrides for Emacs so that we follow Linus's tabbing style.
3054 + * Emacs will notice this stuff at the end of the file and automatically
3055 + * adjust the settings for this buffer only. This must remain at the end
3057 + * ---------------------------------------------------------------------------
3058 + * Local variables:
3059 + * c-file-style: "linux"
3062 diff -Naur -X ../exclude-files orig/arch/um/drivers/daemon_user.c um/arch/um/drivers/daemon_user.c
3063 --- orig/arch/um/drivers/daemon_user.c 1969-12-31 19:00:00.000000000 -0500
3064 +++ um/arch/um/drivers/daemon_user.c 2003-10-21 03:26:06.000000000 -0400
3067 + * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
3068 + * James Leu (jleu@mindspring.net).
3069 + * Copyright (C) 2001 by various other people who didn't put their name here.
3070 + * Licensed under the GPL.
3074 +#include <unistd.h>
3075 +#include <stdint.h>
3076 +#include <sys/socket.h>
3077 +#include <sys/un.h>
3078 +#include <sys/time.h>
3079 +#include "net_user.h"
3080 +#include "daemon.h"
3081 +#include "kern_util.h"
3082 +#include "user_util.h"
3086 +#define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER)
3088 +enum request_type { REQ_NEW_CONTROL };
3090 +#define SWITCH_MAGIC 0xfeedface
3092 +struct request_v3 {
3095 + enum request_type type;
3096 + struct sockaddr_un sock;
3099 +static struct sockaddr_un *new_addr(void *name, int len)
3101 + struct sockaddr_un *sun;
3103 + sun = um_kmalloc(sizeof(struct sockaddr_un));
3105 + printk("new_addr: allocation of sockaddr_un failed\n");
3108 + sun->sun_family = AF_UNIX;
3109 + memcpy(sun->sun_path, name, len);
3113 +static int connect_to_switch(struct daemon_data *pri)
3115 + struct sockaddr_un *ctl_addr = pri->ctl_addr;
3116 + struct sockaddr_un *local_addr = pri->local_addr;
3117 + struct sockaddr_un *sun;
3118 + struct request_v3 req;
3121 + pri->control = socket(AF_UNIX, SOCK_STREAM, 0);
3122 + if(pri->control < 0){
3123 + printk("daemon_open : control socket failed, errno = %d\n",
3128 + if(connect(pri->control, (struct sockaddr *) ctl_addr,
3129 + sizeof(*ctl_addr)) < 0){
3130 + printk("daemon_open : control connect failed, errno = %d\n",
3136 + fd = socket(AF_UNIX, SOCK_DGRAM, 0);
3138 + printk("daemon_open : data socket failed, errno = %d\n",
3143 + if(bind(fd, (struct sockaddr *) local_addr, sizeof(*local_addr)) < 0){
3144 + printk("daemon_open : data bind failed, errno = %d\n",
3150 + sun = um_kmalloc(sizeof(struct sockaddr_un));
3152 + printk("new_addr: allocation of sockaddr_un failed\n");
3157 + req.magic = SWITCH_MAGIC;
3158 + req.version = SWITCH_VERSION;
3159 + req.type = REQ_NEW_CONTROL;
3160 + req.sock = *local_addr;
3161 + n = os_write_file(pri->control, &req, sizeof(req));
3162 + if(n != sizeof(req)){
3163 + printk("daemon_open : control setup request failed, err = %d\n",
3169 + n = os_read_file(pri->control, sun, sizeof(*sun));
3170 + if(n != sizeof(*sun)){
3171 + printk("daemon_open : read of data socket failed, err = %d\n",
3177 + pri->data_addr = sun;
3181 + os_close_file(fd);
3183 + os_close_file(pri->control);
3187 +static void daemon_user_init(void *data, void *dev)
3189 + struct daemon_data *pri = data;
3190 + struct timeval tv;
3197 + if(!strcmp(pri->sock_type, "unix"))
3198 + pri->ctl_addr = new_addr(pri->ctl_sock,
3199 + strlen(pri->ctl_sock) + 1);
3201 + name.pid = os_getpid();
3202 + gettimeofday(&tv, NULL);
3203 + name.usecs = tv.tv_usec;
3204 + pri->local_addr = new_addr(&name, sizeof(name));
3206 + pri->fd = connect_to_switch(pri);
3208 + kfree(pri->local_addr);
3209 + pri->local_addr = NULL;
3213 +static int daemon_open(void *data)
3215 + struct daemon_data *pri = data;
3219 +static void daemon_remove(void *data)
3221 + struct daemon_data *pri = data;
3223 + os_close_file(pri->fd);
3224 + os_close_file(pri->control);
3225 + if(pri->data_addr != NULL) kfree(pri->data_addr);
3226 + if(pri->ctl_addr != NULL) kfree(pri->ctl_addr);
3227 + if(pri->local_addr != NULL) kfree(pri->local_addr);
3230 +int daemon_user_write(int fd, void *buf, int len, struct daemon_data *pri)
3232 + struct sockaddr_un *data_addr = pri->data_addr;
3234 + return(net_sendto(fd, buf, len, data_addr, sizeof(*data_addr)));
3237 +static int daemon_set_mtu(int mtu, void *data)
3242 +struct net_user_info daemon_user_info = {
3243 + .init = daemon_user_init,
3244 + .open = daemon_open,
3246 + .remove = daemon_remove,
3247 + .set_mtu = daemon_set_mtu,
3248 + .add_address = NULL,
3249 + .delete_address = NULL,
3250 + .max_packet = MAX_PACKET - ETH_HEADER_OTHER
3254 + * Overrides for Emacs so that we follow Linus's tabbing style.
3255 + * Emacs will notice this stuff at the end of the file and automatically
3256 + * adjust the settings for this buffer only. This must remain at the end
3258 + * ---------------------------------------------------------------------------
3259 + * Local variables:
3260 + * c-file-style: "linux"
3263 diff -Naur -X ../exclude-files orig/arch/um/drivers/fd.c um/arch/um/drivers/fd.c
3264 --- orig/arch/um/drivers/fd.c 1969-12-31 19:00:00.000000000 -0500
3265 +++ um/arch/um/drivers/fd.c 2003-10-21 03:26:06.000000000 -0400
3268 + * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
3269 + * Licensed under the GPL
3273 +#include <stdlib.h>
3274 +#include <unistd.h>
3275 +#include <termios.h>
3277 +#include "user_util.h"
3278 +#include "chan_user.h"
3283 + struct termios tt;
3284 + char str[sizeof("1234567890\0")];
3287 +void *fd_init(char *str, int device, struct chan_opts *opts)
3289 + struct fd_chan *data;
3294 + printk("fd_init : channel type 'fd' must specify a file "
3299 + n = strtoul(str, &end, 0);
3300 + if((*end != '\0') || (end == str)){
3301 + printk("fd_init : couldn't parse file descriptor '%s'\n", str);
3304 + data = um_kmalloc(sizeof(*data));
3305 + if(data == NULL) return(NULL);
3306 + *data = ((struct fd_chan) { .fd = n,
3307 + .raw = opts->raw });
3311 +int fd_open(int input, int output, int primary, void *d, char **dev_out)
3313 + struct fd_chan *data = d;
3315 + if(data->raw && isatty(data->fd)){
3316 + tcgetattr(data->fd, &data->tt);
3319 + sprintf(data->str, "%d", data->fd);
3320 + *dev_out = data->str;
3324 +void fd_close(int fd, void *d)
3326 + struct fd_chan *data = d;
3328 + if(data->raw && isatty(fd)){
3329 + tcsetattr(fd, TCSAFLUSH, &data->tt);
3334 +int fd_console_write(int fd, const char *buf, int n, void *d)
3336 + struct fd_chan *data = d;
3338 + return(generic_console_write(fd, buf, n, &data->tt));
3341 +struct chan_ops fd_ops = {
3345 + .close = fd_close,
3346 + .read = generic_read,
3347 + .write = generic_write,
3348 + .console_write = fd_console_write,
3349 + .window_size = generic_window_size,
3350 + .free = generic_free,
3355 + * Overrides for Emacs so that we follow Linus's tabbing style.
3356 + * Emacs will notice this stuff at the end of the file and automatically
3357 + * adjust the settings for this buffer only. This must remain at the end
3359 + * ---------------------------------------------------------------------------
3360 + * Local variables:
3361 + * c-file-style: "linux"
3364 diff -Naur -X ../exclude-files orig/arch/um/drivers/harddog_kern.c um/arch/um/drivers/harddog_kern.c
3365 --- orig/arch/um/drivers/harddog_kern.c 1969-12-31 19:00:00.000000000 -0500
3366 +++ um/arch/um/drivers/harddog_kern.c 2003-10-21 03:26:06.000000000 -0400
3368 +/* UML hardware watchdog, shamelessly stolen from:
3370 + * SoftDog 0.05: A Software Watchdog Device
3372 + * (c) Copyright 1996 Alan Cox <alan@redhat.com>, All Rights Reserved.
3373 + * http://www.redhat.com
3375 + * This program is free software; you can redistribute it and/or
3376 + * modify it under the terms of the GNU General Public License
3377 + * as published by the Free Software Foundation; either version
3378 + * 2 of the License, or (at your option) any later version.
3380 + * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide
3381 + * warranty for any of this software. This material is provided
3382 + * "AS-IS" and at no charge.
3384 + * (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk>
3386 + * Software only watchdog driver. Unlike its big brother the WDT501P
3387 + * driver this won't always recover a failed machine.
3389 + * 03/96: Angelo Haritsis <ah@doc.ic.ac.uk> :
3391 + * Added soft_margin; use upon insmod to change the timer delay.
3392 + * NB: uses same minor as wdt (WATCHDOG_MINOR); we could use separate
3395 + * 19980911 Alan Cox
3396 + * Made SMP safe for 2.3.x
3398 + * 20011127 Joel Becker (jlbec@evilplan.org>
3399 + * Added soft_noboot; Allows testing the softdog trigger without
3400 + * requiring a recompile.
3401 + * Added WDIOC_GETTIMEOUT and WDIOC_SETTIMOUT.
3404 +#include <linux/module.h>
3405 +#include <linux/config.h>
3406 +#include <linux/types.h>
3407 +#include <linux/kernel.h>
3408 +#include <linux/fs.h>
3409 +#include <linux/mm.h>
3410 +#include <linux/miscdevice.h>
3411 +#include <linux/watchdog.h>
3412 +#include <linux/reboot.h>
3413 +#include <linux/smp_lock.h>
3414 +#include <linux/init.h>
3415 +#include <asm/uaccess.h>
3416 +#include "helper.h"
3417 +#include "mconsole.h"
3419 +MODULE_LICENSE("GPL");
3421 +/* Locked by the BKL in harddog_open and harddog_release */
3422 +static int timer_alive;
3423 +static int harddog_in_fd = -1;
3424 +static int harddog_out_fd = -1;
3427 + * Allow only one person to hold it open
3430 +extern int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock);
3432 +static int harddog_open(struct inode *inode, struct file *file)
3435 + char *sock = NULL;
3440 +#ifdef CONFIG_HARDDOG_NOWAYOUT
3441 + MOD_INC_USE_COUNT;
3444 +#ifdef CONFIG_MCONSOLE
3445 + sock = mconsole_notify_socket();
3447 + err = start_watchdog(&harddog_in_fd, &harddog_out_fd, sock);
3448 + if(err) return(err);
3455 +extern void stop_watchdog(int in_fd, int out_fd);
3457 +static int harddog_release(struct inode *inode, struct file *file)
3460 + * Shut off the timer.
3464 + stop_watchdog(harddog_in_fd, harddog_out_fd);
3465 + harddog_in_fd = -1;
3466 + harddog_out_fd = -1;
3473 +extern int ping_watchdog(int fd);
3475 +static ssize_t harddog_write(struct file *file, const char *data, size_t len,
3478 + /* Can't seek (pwrite) on this device */
3479 + if (ppos != &file->f_pos)
3483 + * Refresh the timer.
3486 + return(ping_watchdog(harddog_out_fd));
3490 +static int harddog_ioctl(struct inode *inode, struct file *file,
3491 + unsigned int cmd, unsigned long arg)
3493 + static struct watchdog_info ident = {
3496 + "UML Hardware Watchdog"
3501 + case WDIOC_GETSUPPORT:
3502 + if(copy_to_user((struct harddog_info *)arg, &ident,
3506 + case WDIOC_GETSTATUS:
3507 + case WDIOC_GETBOOTSTATUS:
3508 + return put_user(0,(int *)arg);
3509 + case WDIOC_KEEPALIVE:
3510 + return(ping_watchdog(harddog_out_fd));
3514 +static struct file_operations harddog_fops = {
3515 + .owner = THIS_MODULE,
3516 + .write = harddog_write,
3517 + .ioctl = harddog_ioctl,
3518 + .open = harddog_open,
3519 + .release = harddog_release,
3522 +static struct miscdevice harddog_miscdev = {
3523 + .minor = WATCHDOG_MINOR,
3524 + .name = "watchdog",
3525 + .fops = &harddog_fops,
3528 +static char banner[] __initdata = KERN_INFO "UML Watchdog Timer\n";
3530 +static int __init harddog_init(void)
3534 + ret = misc_register(&harddog_miscdev);
3544 +static void __exit harddog_exit(void)
3546 + misc_deregister(&harddog_miscdev);
3549 +module_init(harddog_init);
3550 +module_exit(harddog_exit);
3553 + * Overrides for Emacs so that we follow Linus's tabbing style.
3554 + * Emacs will notice this stuff at the end of the file and automatically
3555 + * adjust the settings for this buffer only. This must remain at the end
3557 + * ---------------------------------------------------------------------------
3558 + * Local variables:
3559 + * c-file-style: "linux"
3562 diff -Naur -X ../exclude-files orig/arch/um/drivers/harddog_user.c um/arch/um/drivers/harddog_user.c
3563 --- orig/arch/um/drivers/harddog_user.c 1969-12-31 19:00:00.000000000 -0500
3564 +++ um/arch/um/drivers/harddog_user.c 2003-10-21 03:26:06.000000000 -0400
3567 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3568 + * Licensed under the GPL
3572 +#include <unistd.h>
3574 +#include "user_util.h"
3576 +#include "helper.h"
3577 +#include "mconsole.h"
3579 +#include "choose-mode.h"
3588 +static void pre_exec(void *d)
3590 + struct dog_data *data = d;
3592 + dup2(data->stdin, 0);
3593 + dup2(data->stdout, 1);
3594 + dup2(data->stdout, 2);
3595 + os_close_file(data->stdin);
3596 + os_close_file(data->stdout);
3597 + os_close_file(data->close_me[0]);
3598 + os_close_file(data->close_me[1]);
3601 +int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock)
3603 + struct dog_data data;
3604 + int in_fds[2], out_fds[2], pid, n, err;
3605 + char pid_buf[sizeof("nnnnn\0")], c;
3606 + char *pid_args[] = { "/usr/bin/uml_watchdog", "-pid", pid_buf, NULL };
3607 + char *mconsole_args[] = { "/usr/bin/uml_watchdog", "-mconsole", NULL,
3609 + char **args = NULL;
3611 + err = os_pipe(in_fds, 1, 0);
3613 + printk("harddog_open - os_pipe failed, err = %d\n", -err);
3617 + err = os_pipe(out_fds, 1, 0);
3619 + printk("harddog_open - os_pipe failed, err = %d\n", -err);
3620 + goto out_close_in;
3623 + data.stdin = out_fds[0];
3624 + data.stdout = in_fds[1];
3625 + data.close_me[0] = out_fds[1];
3626 + data.close_me[1] = in_fds[0];
3629 + mconsole_args[2] = sock;
3630 + args = mconsole_args;
3633 + /* XXX The os_getpid() is not SMP correct */
3634 + sprintf(pid_buf, "%d", CHOOSE_MODE(tracing_pid, os_getpid()));
3638 + pid = run_helper(pre_exec, &data, args, NULL);
3640 + os_close_file(out_fds[0]);
3641 + os_close_file(in_fds[1]);
3645 + printk("harddog_open - run_helper failed, errno = %d\n", -err);
3646 + goto out_close_out;
3649 + n = os_read_file(in_fds[0], &c, sizeof(c));
3651 + printk("harddog_open - EOF on watchdog pipe\n");
3654 + goto out_close_out;
3657 + printk("harddog_open - read of watchdog pipe failed, "
3658 + "err = %d\n", -n);
3661 + goto out_close_out;
3663 + *in_fd_ret = in_fds[0];
3664 + *out_fd_ret = out_fds[1];
3668 + os_close_file(in_fds[0]);
3669 + os_close_file(in_fds[1]);
3671 + os_close_file(out_fds[0]);
3672 + os_close_file(out_fds[1]);
3677 +void stop_watchdog(int in_fd, int out_fd)
3679 + os_close_file(in_fd);
3680 + os_close_file(out_fd);
3683 +int ping_watchdog(int fd)
3688 + n = os_write_file(fd, &c, sizeof(c));
3689 + if(n != sizeof(c)){
3690 + printk("ping_watchdog - write failed, err = %d\n", -n);
3700 + * Overrides for Emacs so that we follow Linus's tabbing style.
3701 + * Emacs will notice this stuff at the end of the file and automatically
3702 + * adjust the settings for this buffer only. This must remain at the end
3704 + * ---------------------------------------------------------------------------
3705 + * Local variables:
3706 + * c-file-style: "linux"
3709 diff -Naur -X ../exclude-files orig/arch/um/drivers/hostaudio_kern.c um/arch/um/drivers/hostaudio_kern.c
3710 --- orig/arch/um/drivers/hostaudio_kern.c 1969-12-31 19:00:00.000000000 -0500
3711 +++ um/arch/um/drivers/hostaudio_kern.c 2004-02-12 05:46:22.000000000 -0500
3714 + * Copyright (C) 2002 Steve Schmidtke
3715 + * Licensed under the GPL
3718 +#include "linux/config.h"
3719 +#include "linux/module.h"
3720 +#include "linux/init.h"
3721 +#include "linux/slab.h"
3722 +#include "linux/fs.h"
3723 +#include "linux/sound.h"
3724 +#include "linux/soundcard.h"
3725 +#include "asm/uaccess.h"
3726 +#include "kern_util.h"
3730 +struct hostaudio_state {
3734 +struct hostmixer_state {
3738 +#define HOSTAUDIO_DEV_DSP "/dev/sound/dsp"
3739 +#define HOSTAUDIO_DEV_MIXER "/dev/sound/mixer"
3741 +/* Only changed from linux_main at boot time */
3742 +char *dsp = HOSTAUDIO_DEV_DSP;
3743 +char *mixer = HOSTAUDIO_DEV_MIXER;
3746 +" This is used to specify the host dsp device to the hostaudio driver.\n" \
3747 +" The default is \"" HOSTAUDIO_DEV_DSP "\".\n\n"
3749 +#define MIXER_HELP \
3750 +" This is used to specify the host mixer device to the hostaudio driver.\n" \
3751 +" The default is \"" HOSTAUDIO_DEV_MIXER "\".\n\n"
3754 +static int set_dsp(char *name, int *add)
3760 +__uml_setup("dsp=", set_dsp, "dsp=<dsp device>\n" DSP_HELP);
3762 +static int set_mixer(char *name, int *add)
3768 +__uml_setup("mixer=", set_mixer, "mixer=<mixer device>\n" MIXER_HELP);
3772 +MODULE_PARM(dsp, "s");
3773 +MODULE_PARM_DESC(dsp, DSP_HELP);
3775 +MODULE_PARM(mixer, "s");
3776 +MODULE_PARM_DESC(mixer, MIXER_HELP);
3780 +/* /dev/dsp file operations */
3782 +static ssize_t hostaudio_read(struct file *file, char *buffer, size_t count,
3785 + struct hostaudio_state *state = file->private_data;
3790 + printk("hostaudio: read called, count = %d\n", count);
3793 + kbuf = kmalloc(count, GFP_KERNEL);
3797 + err = os_read_file(state->fd, kbuf, count);
3801 + if(copy_to_user(buffer, kbuf, err))
3809 +static ssize_t hostaudio_write(struct file *file, const char *buffer,
3810 + size_t count, loff_t *ppos)
3812 + struct hostaudio_state *state = file->private_data;
3817 + printk("hostaudio: write called, count = %d\n", count);
3820 + kbuf = kmalloc(count, GFP_KERNEL);
3825 + if(copy_from_user(kbuf, buffer, count))
3828 + err = os_write_file(state->fd, kbuf, count);
3838 +static unsigned int hostaudio_poll(struct file *file,
3839 + struct poll_table_struct *wait)
3841 + unsigned int mask = 0;
3844 + printk("hostaudio: poll called (unimplemented)\n");
3850 +static int hostaudio_ioctl(struct inode *inode, struct file *file,
3851 + unsigned int cmd, unsigned long arg)
3853 + struct hostaudio_state *state = file->private_data;
3854 + unsigned long data = 0;
3858 + printk("hostaudio: ioctl called, cmd = %u\n", cmd);
3861 + case SNDCTL_DSP_SPEED:
3862 + case SNDCTL_DSP_STEREO:
3863 + case SNDCTL_DSP_GETBLKSIZE:
3864 + case SNDCTL_DSP_CHANNELS:
3865 + case SNDCTL_DSP_SUBDIVIDE:
3866 + case SNDCTL_DSP_SETFRAGMENT:
3867 + if(get_user(data, (int *) arg))
3874 + err = os_ioctl_generic(state->fd, cmd, (unsigned long) &data);
3877 + case SNDCTL_DSP_SPEED:
3878 + case SNDCTL_DSP_STEREO:
3879 + case SNDCTL_DSP_GETBLKSIZE:
3880 + case SNDCTL_DSP_CHANNELS:
3881 + case SNDCTL_DSP_SUBDIVIDE:
3882 + case SNDCTL_DSP_SETFRAGMENT:
3883 + if(put_user(data, (int *) arg))
3893 +static int hostaudio_open(struct inode *inode, struct file *file)
3895 + struct hostaudio_state *state;
3900 + printk("hostaudio: open called (host: %s)\n", dsp);
3903 + state = kmalloc(sizeof(struct hostaudio_state), GFP_KERNEL);
3907 + if(file->f_mode & FMODE_READ) r = 1;
3908 + if(file->f_mode & FMODE_WRITE) w = 1;
3910 + ret = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0);
3917 + file->private_data = state;
3921 +static int hostaudio_release(struct inode *inode, struct file *file)
3923 + struct hostaudio_state *state = file->private_data;
3926 + printk("hostaudio: release called\n");
3929 + os_close_file(state->fd);
3935 +/* /dev/mixer file operations */
3937 +static int hostmixer_ioctl_mixdev(struct inode *inode, struct file *file,
3938 + unsigned int cmd, unsigned long arg)
3940 + struct hostmixer_state *state = file->private_data;
3943 + printk("hostmixer: ioctl called\n");
3946 + return(os_ioctl_generic(state->fd, cmd, arg));
3949 +static int hostmixer_open_mixdev(struct inode *inode, struct file *file)
3951 + struct hostmixer_state *state;
3956 + printk("hostmixer: open called (host: %s)\n", mixer);
3959 + state = kmalloc(sizeof(struct hostmixer_state), GFP_KERNEL);
3960 + if(state == NULL) return(-ENOMEM);
3962 + if(file->f_mode & FMODE_READ) r = 1;
3963 + if(file->f_mode & FMODE_WRITE) w = 1;
3965 + ret = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0);
3968 + printk("hostaudio_open_mixdev failed to open '%s', err = %d\n",
3974 + file->private_data = state;
3978 +static int hostmixer_release(struct inode *inode, struct file *file)
3980 + struct hostmixer_state *state = file->private_data;
3983 + printk("hostmixer: release called\n");
3986 + os_close_file(state->fd);
3993 +/* kernel module operations */
3995 +static struct file_operations hostaudio_fops = {
3996 + .owner = THIS_MODULE,
3997 + .llseek = no_llseek,
3998 + .read = hostaudio_read,
3999 + .write = hostaudio_write,
4000 + .poll = hostaudio_poll,
4001 + .ioctl = hostaudio_ioctl,
4003 + .open = hostaudio_open,
4004 + .release = hostaudio_release,
4007 +static struct file_operations hostmixer_fops = {
4008 + .owner = THIS_MODULE,
4009 + .llseek = no_llseek,
4010 + .ioctl = hostmixer_ioctl_mixdev,
4011 + .open = hostmixer_open_mixdev,
4012 + .release = hostmixer_release,
4020 +MODULE_AUTHOR("Steve Schmidtke");
4021 +MODULE_DESCRIPTION("UML Audio Relay");
4022 +MODULE_LICENSE("GPL");
4024 +static int __init hostaudio_init_module(void)
4026 + printk(KERN_INFO "UML Audio Relay (host dsp = %s, host mixer = %s)\n",
4029 + module_data.dev_audio = register_sound_dsp(&hostaudio_fops, -1);
4030 + if(module_data.dev_audio < 0){
4031 + printk(KERN_ERR "hostaudio: couldn't register DSP device!\n");
4035 + module_data.dev_mixer = register_sound_mixer(&hostmixer_fops, -1);
4036 + if(module_data.dev_mixer < 0){
4037 + printk(KERN_ERR "hostmixer: couldn't register mixer "
4039 + unregister_sound_dsp(module_data.dev_audio);
4046 +static void __exit hostaudio_cleanup_module (void)
4048 + unregister_sound_mixer(module_data.dev_mixer);
4049 + unregister_sound_dsp(module_data.dev_audio);
4052 +module_init(hostaudio_init_module);
4053 +module_exit(hostaudio_cleanup_module);
4056 + * Overrides for Emacs so that we follow Linus's tabbing style.
4057 + * Emacs will notice this stuff at the end of the file and automatically
4058 + * adjust the settings for this buffer only. This must remain at the end
4060 + * ---------------------------------------------------------------------------
4061 + * Local variables:
4062 + * c-file-style: "linux"
4065 diff -Naur -X ../exclude-files orig/arch/um/drivers/line.c um/arch/um/drivers/line.c
4066 --- orig/arch/um/drivers/line.c 1969-12-31 19:00:00.000000000 -0500
4067 +++ um/arch/um/drivers/line.c 2003-11-07 03:03:57.000000000 -0500
4070 + * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
4071 + * Licensed under the GPL
4074 +#include "linux/sched.h"
4075 +#include "linux/slab.h"
4076 +#include "linux/list.h"
4077 +#include "linux/devfs_fs_kernel.h"
4078 +#include "asm/irq.h"
4079 +#include "asm/uaccess.h"
4080 +#include "chan_kern.h"
4081 +#include "irq_user.h"
4084 +#include "user_util.h"
4085 +#include "kern_util.h"
4087 +#include "irq_kern.h"
4089 +#define LINE_BUFSIZE 4096
4091 +static void line_interrupt(int irq, void *data, struct pt_regs *unused)
4093 + struct line *dev = data;
4095 + if(dev->count > 0)
4096 + chan_interrupt(&dev->chan_list, &dev->task, dev->tty, irq,
4100 +static void line_timer_cb(void *arg)
4102 + struct line *dev = arg;
4104 + line_interrupt(dev->driver->read_irq, dev, NULL);
4107 +static int write_room(struct line *dev)
4111 + if(dev->buffer == NULL) return(LINE_BUFSIZE - 1);
4113 + n = dev->head - dev->tail;
4114 + if(n <= 0) n = LINE_BUFSIZE + n;
4118 +static int buffer_data(struct line *line, const char *buf, int len)
4122 + if(line->buffer == NULL){
4123 + line->buffer = kmalloc(LINE_BUFSIZE, GFP_ATOMIC);
4124 + if(line->buffer == NULL){
4125 + printk("buffer_data - atomic allocation failed\n");
4128 + line->head = line->buffer;
4129 + line->tail = line->buffer;
4132 + room = write_room(line);
4133 + len = (len > room) ? room : len;
4135 + end = line->buffer + LINE_BUFSIZE - line->tail;
4137 + memcpy(line->tail, buf, len);
4138 + line->tail += len;
4141 + memcpy(line->tail, buf, end);
4144 + memcpy(line->buffer, buf, len);
4145 + line->tail = line->buffer + len;
4151 +static int flush_buffer(struct line *line)
4155 + if((line->buffer == NULL) || (line->head == line->tail)) return(1);
4157 + if(line->tail < line->head){
4158 + count = line->buffer + LINE_BUFSIZE - line->head;
4159 + n = write_chan(&line->chan_list, line->head, count,
4160 + line->driver->write_irq);
4161 + if(n < 0) return(n);
4162 + if(n == count) line->head = line->buffer;
4169 + count = line->tail - line->head;
4170 + n = write_chan(&line->chan_list, line->head, count,
4171 + line->driver->write_irq);
4172 + if(n < 0) return(n);
4175 + return(line->head == line->tail);
4178 +int line_write(struct line *lines, struct tty_struct *tty, int from_user,
4179 + const char *buf, int len)
4181 + struct line *line;
4183 + unsigned long flags;
4184 + int n, err, i, ret = 0;
4186 + if(tty->stopped) return 0;
4189 + new = kmalloc(len, GFP_KERNEL);
4192 + n = copy_from_user(new, buf, len);
4202 + i = minor(tty->device) - tty->driver.minor_start;
4206 + if(line->head != line->tail){
4207 + local_irq_save(flags);
4208 + ret += buffer_data(line, buf, len);
4209 + err = flush_buffer(line);
4210 + local_irq_restore(flags);
4215 + n = write_chan(&line->chan_list, buf, len,
4216 + line->driver->write_irq);
4225 + ret += buffer_data(line, buf + n, len);
4236 +static void line_write_interrupt(int irq, void *data, struct pt_regs *unused)
4238 + struct line *dev = data;
4239 + struct tty_struct *tty = dev->tty;
4242 + err = flush_buffer(dev);
4243 + if(err == 0) return;
4245 + dev->head = dev->buffer;
4246 + dev->tail = dev->buffer;
4249 + if(tty == NULL) return;
4251 + if(test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags) &&
4252 + (tty->ldisc.write_wakeup != NULL))
4253 + (tty->ldisc.write_wakeup)(tty);
4256 + * In blocking mode, everything sleeps on tty->write_wait.
4257 + * Sleeping in the console driver would break non-blocking
4261 + if (waitqueue_active(&tty->write_wait))
4262 + wake_up_interruptible(&tty->write_wait);
4266 +int line_setup_irq(int fd, int input, int output, void *data)
4268 + struct line *line = data;
4269 + struct line_driver *driver = line->driver;
4270 + int err = 0, flags = SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM;
4272 + if(input) err = um_request_irq(driver->read_irq, fd, IRQ_READ,
4273 + line_interrupt, flags,
4274 + driver->read_irq_name, line);
4275 + if(err) return(err);
4276 + if(output) err = um_request_irq(driver->write_irq, fd, IRQ_WRITE,
4277 + line_write_interrupt, flags,
4278 + driver->write_irq_name, line);
4279 + line->have_irq = 1;
4283 +void line_disable(struct line *line, int current_irq)
4285 + if(!line->have_irq) return;
4287 + if(line->driver->read_irq == current_irq)
4288 + free_irq_later(line->driver->read_irq, line);
4290 + free_irq(line->driver->read_irq, line);
4292 + if(line->driver->write_irq == current_irq)
4293 + free_irq_later(line->driver->write_irq, line);
4295 + free_irq(line->driver->write_irq, line);
4297 + line->have_irq = 0;
4300 +int line_open(struct line *lines, struct tty_struct *tty,
4301 + struct chan_opts *opts)
4303 + struct line *line;
4306 + if(tty == NULL) n = 0;
4307 + else n = minor(tty->device) - tty->driver.minor_start;
4311 + if(line->count == 0){
4316 + if(list_empty(&line->chan_list)){
4317 + err = parse_chan_pair(line->init_str, &line->chan_list,
4318 + line->init_pri, n, opts);
4320 + err = open_chan(&line->chan_list);
4323 + enable_chan(&line->chan_list, line);
4324 + INIT_TQUEUE(&line->task, line_timer_cb, line);
4328 + chan_enable_winch(&line->chan_list, line);
4332 + /* This is outside the if because the initial console is opened
4333 + * with tty == NULL
4338 + tty->driver_data = line;
4339 + chan_window_size(&line->chan_list, &tty->winsize.ws_row,
4340 + &tty->winsize.ws_col);
4349 +void line_close(struct line *lines, struct tty_struct *tty)
4351 + struct line *line;
4354 + if(tty == NULL) n = 0;
4355 + else n = minor(tty->device) - tty->driver.minor_start;
4361 + /* I don't like this, but I can't think of anything better. What's
4362 + * going on is that the tty is in the process of being closed for
4363 + * the last time. Its count hasn't been dropped yet, so it's still
4364 + * at 1. This may happen when line->count != 0 because of the initial
4365 + * console open (without a tty) bumping it up to 1.
4367 + if((line->tty != NULL) && (line->tty->count == 1))
4369 + if(line->count == 0)
4370 + line_disable(line, -1);
4374 +void close_lines(struct line *lines, int nlines)
4378 + for(i = 0; i < nlines; i++)
4379 + close_chan(&lines[i].chan_list);
4382 +int line_setup(struct line *lines, int num, char *init, int all_allowed)
4387 + if(*init == '=') n = -1;
4389 + n = simple_strtoul(init, &end, 0);
4391 + printk(KERN_ERR "line_setup failed to parse \"%s\"\n",
4398 + if((n >= 0) && (n >= num)){
4399 + printk("line_setup - %d out of range ((0 ... %d) allowed)\n",
4404 + if(lines[n].count > 0){
4405 + printk("line_setup - device %d is open\n", n);
4408 + if(lines[n].init_pri <= INIT_ONE){
4409 + lines[n].init_pri = INIT_ONE;
4410 + if(!strcmp(init, "none")) lines[n].valid = 0;
4412 + lines[n].init_str = init;
4413 + lines[n].valid = 1;
4417 + else if(!all_allowed){
4418 + printk("line_setup - can't configure all devices from "
4423 + for(i = 0; i < num; i++){
4424 + if(lines[i].init_pri <= INIT_ALL){
4425 + lines[i].init_pri = INIT_ALL;
4426 + if(!strcmp(init, "none")) lines[i].valid = 0;
4428 + lines[i].init_str = init;
4429 + lines[i].valid = 1;
4437 +int line_config(struct line *lines, int num, char *str)
4439 + char *new = uml_strdup(str);
4442 + printk("line_config - uml_strdup failed\n");
4445 + return(!line_setup(lines, num, new, 0));
4448 +int line_get_config(char *name, struct line *lines, int num, char *str,
4449 + int size, char **error_out)
4451 + struct line *line;
4455 + dev = simple_strtoul(name, &end, 0);
4456 + if((*end != '\0') || (end == name)){
4457 + *error_out = "line_get_config failed to parse device number";
4461 + if((dev < 0) || (dev >= num)){
4462 + *error_out = "device number of of range";
4466 + line = &lines[dev];
4470 + CONFIG_CHUNK(str, size, n, "none", 1);
4471 + else if(line->count == 0)
4472 + CONFIG_CHUNK(str, size, n, line->init_str, 1);
4473 + else n = chan_config_string(&line->chan_list, str, size, error_out);
4479 +int line_remove(struct line *lines, int num, char *str)
4481 + char config[sizeof("conxxxx=none\0")];
4483 + sprintf(config, "%s=none", str);
4484 + return(!line_setup(lines, num, config, 0));
4487 +static int line_write_room(struct tty_struct *tty)
4489 + struct line *dev = tty->driver_data;
4491 + return(write_room(dev));
4494 +void line_register_devfs(struct lines *set, struct line_driver *line_driver,
4495 + struct tty_driver *driver, struct line *lines,
4501 + driver->driver_name = line_driver->name;
4502 + driver->name = line_driver->devfs_name;
4503 + driver->major = line_driver->major;
4504 + driver->minor_start = line_driver->minor_start;
4505 + driver->type = line_driver->type;
4506 + driver->subtype = line_driver->subtype;
4507 + driver->magic = TTY_DRIVER_MAGIC;
4508 + driver->flags = TTY_DRIVER_REAL_RAW;
4512 + driver->table = kmalloc(n * sizeof(driver->table[0]), GFP_KERNEL);
4513 + driver->termios = kmalloc(n * sizeof(driver->termios[0]), GFP_KERNEL);
4514 + driver->termios_locked = kmalloc(n * sizeof(driver->termios_locked[0]),
4516 + if((driver->table == NULL) || (driver->termios == NULL) ||
4517 + (driver->termios_locked == NULL))
4518 + panic("Failed to allocate driver table");
4520 + memset(driver->table, 0, n * sizeof(driver->table[0]));
4521 + memset(driver->termios, 0, n * sizeof(driver->termios[0]));
4522 + memset(driver->termios_locked, 0,
4523 + n * sizeof(driver->termios_locked[0]));
4525 + driver->write_room = line_write_room;
4526 + driver->init_termios = tty_std_termios;
4528 + if (tty_register_driver(driver))
4529 + panic("line_register_devfs : Couldn't register driver\n");
4531 + from = line_driver->symlink_from;
4532 + to = line_driver->symlink_to;
4533 + err = devfs_mk_symlink(NULL, from, 0, to, NULL, NULL);
4534 + if(err) printk("Symlink creation from /dev/%s to /dev/%s "
4535 + "returned %d\n", from, to, err);
4537 + for(i = 0; i < nlines; i++){
4538 + if(!lines[i].valid)
4539 + tty_unregister_devfs(driver, driver->minor_start + i);
4542 + mconsole_register_dev(&line_driver->mc);
4545 +void lines_init(struct line *lines, int nlines)
4547 + struct line *line;
4550 + for(i = 0; i < nlines; i++){
4552 + INIT_LIST_HEAD(&line->chan_list);
4553 + sema_init(&line->sem, 1);
4554 + if(line->init_str != NULL){
4555 + line->init_str = uml_strdup(line->init_str);
4556 + if(line->init_str == NULL)
4557 + printk("lines_init - uml_strdup returned "
4564 + struct list_head list;
4568 + struct line *line;
4571 +void winch_interrupt(int irq, void *data, struct pt_regs *unused)
4573 + struct winch *winch = data;
4574 + struct tty_struct *tty;
4578 + if(winch->fd != -1){
4579 + err = generic_read(winch->fd, &c, NULL);
4581 + if(err != -EAGAIN){
4582 + printk("winch_interrupt : read failed, "
4583 + "errno = %d\n", -err);
4584 + printk("fd %d is losing SIGWINCH support\n",
4591 + tty = winch->line->tty;
4593 + chan_window_size(&winch->line->chan_list,
4594 + &tty->winsize.ws_row,
4595 + &tty->winsize.ws_col);
4596 + kill_pg(tty->pgrp, SIGWINCH, 1);
4599 + if(winch->fd != -1)
4600 + reactivate_fd(winch->fd, WINCH_IRQ);
4603 +DECLARE_MUTEX(winch_handler_sem);
4604 +LIST_HEAD(winch_handlers);
4606 +void register_winch_irq(int fd, int tty_fd, int pid, void *line)
4608 + struct winch *winch;
4610 + down(&winch_handler_sem);
4611 + winch = kmalloc(sizeof(*winch), GFP_KERNEL);
4612 + if(winch == NULL){
4613 + printk("register_winch_irq - kmalloc failed\n");
4616 + *winch = ((struct winch) { .list = LIST_HEAD_INIT(winch->list),
4621 + list_add(&winch->list, &winch_handlers);
4622 + if(um_request_irq(WINCH_IRQ, fd, IRQ_READ, winch_interrupt,
4623 + SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM,
4624 + "winch", winch) < 0)
4625 + printk("register_winch_irq - failed to register IRQ\n");
4627 + up(&winch_handler_sem);
4630 +static void winch_cleanup(void)
4632 + struct list_head *ele;
4633 + struct winch *winch;
4635 + list_for_each(ele, &winch_handlers){
4636 + winch = list_entry(ele, struct winch, list);
4637 + if(winch->fd != -1){
4638 + deactivate_fd(winch->fd, WINCH_IRQ);
4639 + os_close_file(winch->fd);
4641 + if(winch->pid != -1)
4642 + os_kill_process(winch->pid, 1);
4646 +__uml_exitcall(winch_cleanup);
4648 +char *add_xterm_umid(char *base)
4650 + char *umid, *title;
4653 + umid = get_umid(1);
4654 + if(umid == NULL) return(base);
4656 + len = strlen(base) + strlen(" ()") + strlen(umid) + 1;
4657 + title = kmalloc(len, GFP_KERNEL);
4658 + if(title == NULL){
4659 + printk("Failed to allocate buffer for xterm title\n");
4663 + strncpy(title, base, len);
4664 + len -= strlen(title);
4665 + snprintf(&title[strlen(title)], len, " (%s)", umid);
4670 + * Overrides for Emacs so that we follow Linus's tabbing style.
4671 + * Emacs will notice this stuff at the end of the file and automatically
4672 + * adjust the settings for this buffer only. This must remain at the end
4674 + * ---------------------------------------------------------------------------
4675 + * Local variables:
4676 + * c-file-style: "linux"
4679 diff -Naur -X ../exclude-files orig/arch/um/drivers/Makefile um/arch/um/drivers/Makefile
4680 --- orig/arch/um/drivers/Makefile 1969-12-31 19:00:00.000000000 -0500
4681 +++ um/arch/um/drivers/Makefile 2004-02-12 03:55:08.000000000 -0500
4684 +# Copyright (C) 2000, 2002, 2003 Jeff Dike (jdike@karaya.com)
4685 +# Licensed under the GPL
4688 +O_TARGET := built-in.o
4690 +CHAN_OBJS := chan_kern.o chan_user.o line.o
4692 +list-multi := slip.o slirp.o daemon.o mcast.o mconsole.o net.o ubd.o \
4693 + hostaudio.o pcap.o port.o harddog.o
4695 +slip-objs := slip_kern.o slip_user.o
4696 +slirp-objs := slirp_kern.o slirp_user.o
4697 +daemon-objs := daemon_kern.o daemon_user.o
4698 +mcast-objs := mcast_kern.o mcast_user.o
4699 +pcap-objs := pcap_kern.o pcap_user.o
4700 +pcap-libs := -lpcap -L/usr/lib
4701 +net-objs := net_kern.o net_user.o
4702 +mconsole-objs := mconsole_kern.o mconsole_user.o
4703 +hostaudio-objs := hostaudio_kern.o
4704 +ubd-objs := ubd_kern.o ubd_user.o
4705 +port-objs := port_kern.o port_user.o
4706 +harddog-objs := harddog_kern.o harddog_user.o
4708 +export-objs := mconsole_kern.o
4711 +obj-$(CONFIG_SSL) += ssl.o
4712 +obj-$(CONFIG_UML_NET_SLIP) += slip.o
4713 +obj-$(CONFIG_UML_NET_SLIRP) += slirp.o
4714 +obj-$(CONFIG_UML_NET_DAEMON) += daemon.o
4715 +obj-$(CONFIG_UML_NET_MCAST) += mcast.o
4716 +obj-$(CONFIG_UML_NET_PCAP) += pcap.o
4717 +obj-$(CONFIG_UML_NET) += net.o
4718 +obj-$(CONFIG_MCONSOLE) += mconsole.o
4719 +obj-$(CONFIG_MMAPPER) += mmapper_kern.o
4720 +obj-$(CONFIG_BLK_DEV_UBD) += ubd.o
4721 +obj-$(CONFIG_HOSTAUDIO) += hostaudio.o
4722 +obj-$(CONFIG_FD_CHAN) += fd.o
4723 +obj-$(CONFIG_NULL_CHAN) += null.o
4724 +obj-$(CONFIG_PORT_CHAN) += port.o
4725 +obj-$(CONFIG_PTY_CHAN) += pty.o
4726 +obj-$(CONFIG_TTY_CHAN) += tty.o
4727 +obj-$(CONFIG_XTERM_CHAN) += xterm.o xterm_kern.o
4728 +obj-$(CONFIG_UML_WATCHDOG) += harddog.o
4729 +obj-$(CONFIG_COW) += cow_kern.o
4730 +obj-$(CONFIG_COW_COMMON) += cow_user.o
4732 +CFLAGS_pcap_user.o = -I/usr/include/pcap
4734 +obj-y += stdio_console.o $(CHAN_OBJS)
4736 +USER_SINGLE_OBJS = $(foreach f,$(patsubst %.o,%,$(obj-y) $(obj-m)),$($(f)-objs))
4738 +USER_OBJS = $(filter %_user.o,$(obj-y) $(obj-m) $(USER_SINGLE_OBJS)) fd.o \
4739 + null.o pty.o tty.o xterm.o
4741 +include $(TOPDIR)/Rules.make
4743 +$(USER_OBJS) : %.o: %.c
4744 + $(CC) $(CFLAGS_$@) $(USER_CFLAGS) -c -o $@ $<
4756 +daemon.o : $(daemon-objs)
4758 +slip.o : $(slip-objs)
4760 +slirp.o : $(slirp-objs)
4762 +mcast.o : $(mcast-objs)
4764 +pcap.o : $(pcap-objs)
4766 +mconsole.o : $(mconsole-objs)
4768 +net.o : $(net-objs)
4770 +hostaudio.o : $(hostaudio-objs)
4772 +ubd.o : $(ubd-objs)
4774 +port.o : $(port-objs)
4776 +harddog.o : $(harddog-objs)
4778 +$(list-multi) : # This doesn't work, but should : '%.o : $(%-objs)'
4779 + $(LD) -r -o $@ $($(patsubst %.o,%,$@)-objs) $($(patsubst %.o,%,$@)-libs)
4780 diff -Naur -X ../exclude-files orig/arch/um/drivers/mcast.h um/arch/um/drivers/mcast.h
4781 --- orig/arch/um/drivers/mcast.h 1969-12-31 19:00:00.000000000 -0500
4782 +++ um/arch/um/drivers/mcast.h 2003-10-21 03:26:06.000000000 -0400
4785 + * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
4786 + * Licensed under the GPL
4789 +#include "net_user.h"
4791 +struct mcast_data {
4793 + unsigned short port;
4799 +extern struct net_user_info mcast_user_info;
4801 +extern int mcast_user_write(int fd, void *buf, int len,
4802 + struct mcast_data *pri);
4805 + * Overrides for Emacs so that we follow Linus's tabbing style.
4806 + * Emacs will notice this stuff at the end of the file and automatically
4807 + * adjust the settings for this buffer only. This must remain at the end
4809 + * ---------------------------------------------------------------------------
4810 + * Local variables:
4811 + * c-file-style: "linux"
4814 diff -Naur -X ../exclude-files orig/arch/um/drivers/mcast_kern.c um/arch/um/drivers/mcast_kern.c
4815 --- orig/arch/um/drivers/mcast_kern.c 1969-12-31 19:00:00.000000000 -0500
4816 +++ um/arch/um/drivers/mcast_kern.c 2003-10-21 03:26:06.000000000 -0400
4819 + * user-mode-linux networking multicast transport
4820 + * Copyright (C) 2001 by Harald Welte <laforge@gnumonks.org>
4822 + * based on the existing uml-networking code, which is
4823 + * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
4824 + * James Leu (jleu@mindspring.net).
4825 + * Copyright (C) 2001 by various other people who didn't put their name here.
4827 + * Licensed under the GPL.
4830 +#include "linux/kernel.h"
4831 +#include "linux/init.h"
4832 +#include "linux/netdevice.h"
4833 +#include "linux/etherdevice.h"
4834 +#include "linux/in.h"
4835 +#include "linux/inet.h"
4836 +#include "net_kern.h"
4837 +#include "net_user.h"
4840 +struct mcast_init {
4846 +void mcast_init(struct net_device *dev, void *data)
4848 + struct uml_net_private *pri;
4849 + struct mcast_data *dpri;
4850 + struct mcast_init *init = data;
4852 + init_etherdev(dev, 0);
4854 + dpri = (struct mcast_data *) pri->user;
4855 + *dpri = ((struct mcast_data)
4856 + { .addr = init->addr,
4857 + .port = init->port,
4859 + .mcast_addr = NULL,
4861 + printk("mcast backend ");
4862 + printk("multicast adddress: %s:%u, TTL:%u ",
4863 + dpri->addr, dpri->port, dpri->ttl);
4868 +static int mcast_read(int fd, struct sk_buff **skb, struct uml_net_private *lp)
4870 + *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER);
4871 + if(*skb == NULL) return(-ENOMEM);
4872 + return(net_recvfrom(fd, (*skb)->mac.raw,
4873 + (*skb)->dev->mtu + ETH_HEADER_OTHER));
4876 +static int mcast_write(int fd, struct sk_buff **skb,
4877 + struct uml_net_private *lp)
4879 + return mcast_user_write(fd, (*skb)->data, (*skb)->len,
4880 + (struct mcast_data *) &lp->user);
4883 +static struct net_kern_info mcast_kern_info = {
4884 + .init = mcast_init,
4885 + .protocol = eth_protocol,
4886 + .read = mcast_read,
4887 + .write = mcast_write,
4890 +int mcast_setup(char *str, char **mac_out, void *data)
4892 + struct mcast_init *init = data;
4893 + char *port_str = NULL, *ttl_str = NULL, *remain;
4897 + *init = ((struct mcast_init)
4898 + { .addr = "239.192.168.1",
4902 + remain = split_if_spec(str, mac_out, &init->addr, &port_str, &ttl_str,
4904 + if(remain != NULL){
4905 + printk(KERN_ERR "mcast_setup - Extra garbage on "
4906 + "specification : '%s'\n", remain);
4910 + if(port_str != NULL){
4911 + n = simple_strtoul(port_str, &last, 10);
4912 + if((*last != '\0') || (last == port_str)){
4913 + printk(KERN_ERR "mcast_setup - Bad port : '%s'\n",
4917 + init->port = htons(n);
4920 + if(ttl_str != NULL){
4921 + init->ttl = simple_strtoul(ttl_str, &last, 10);
4922 + if((*last != '\0') || (last == ttl_str)){
4923 + printk(KERN_ERR "mcast_setup - Bad ttl : '%s'\n",
4929 + printk(KERN_INFO "Configured mcast device: %s:%u-%u\n", init->addr,
4930 + init->port, init->ttl);
4935 +static struct transport mcast_transport = {
4936 + .list = LIST_HEAD_INIT(mcast_transport.list),
4938 + .setup = mcast_setup,
4939 + .user = &mcast_user_info,
4940 + .kern = &mcast_kern_info,
4941 + .private_size = sizeof(struct mcast_data),
4942 + .setup_size = sizeof(struct mcast_init),
4945 +static int register_mcast(void)
4947 + register_transport(&mcast_transport);
4951 +__initcall(register_mcast);
4954 + * Overrides for Emacs so that we follow Linus's tabbing style.
4955 + * Emacs will notice this stuff at the end of the file and automatically
4956 + * adjust the settings for this buffer only. This must remain at the end
4958 + * ---------------------------------------------------------------------------
4959 + * Local variables:
4960 + * c-file-style: "linux"
4963 diff -Naur -X ../exclude-files orig/arch/um/drivers/mcast_user.c um/arch/um/drivers/mcast_user.c
4964 --- orig/arch/um/drivers/mcast_user.c 1969-12-31 19:00:00.000000000 -0500
4965 +++ um/arch/um/drivers/mcast_user.c 2003-10-21 03:26:06.000000000 -0400
4968 + * user-mode-linux networking multicast transport
4969 + * Copyright (C) 2001 by Harald Welte <laforge@gnumonks.org>
4971 + * based on the existing uml-networking code, which is
4972 + * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
4973 + * James Leu (jleu@mindspring.net).
4974 + * Copyright (C) 2001 by various other people who didn't put their name here.
4976 + * Licensed under the GPL.
4981 +#include <unistd.h>
4982 +#include <linux/inet.h>
4983 +#include <sys/socket.h>
4984 +#include <sys/un.h>
4985 +#include <sys/time.h>
4986 +#include <netinet/in.h>
4987 +#include "net_user.h"
4989 +#include "kern_util.h"
4990 +#include "user_util.h"
4994 +#define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER)
4996 +static struct sockaddr_in *new_addr(char *addr, unsigned short port)
4998 + struct sockaddr_in *sin;
5000 + sin = um_kmalloc(sizeof(struct sockaddr_in));
5002 + printk("new_addr: allocation of sockaddr_in failed\n");
5005 + sin->sin_family = AF_INET;
5006 + sin->sin_addr.s_addr = in_aton(addr);
5007 + sin->sin_port = port;
5011 +static void mcast_user_init(void *data, void *dev)
5013 + struct mcast_data *pri = data;
5015 + pri->mcast_addr = new_addr(pri->addr, pri->port);
5019 +static int mcast_open(void *data)
5021 + struct mcast_data *pri = data;
5022 + struct sockaddr_in *sin = pri->mcast_addr;
5023 + struct ip_mreq mreq;
5027 + if ((sin->sin_addr.s_addr == 0) || (sin->sin_port == 0)) {
5032 + fd = socket(AF_INET, SOCK_DGRAM, 0);
5034 + printk("mcast_open : data socket failed, errno = %d\n",
5040 + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) {
5041 + printk("mcast_open: SO_REUSEADDR failed, errno = %d\n",
5043 + os_close_file(fd);
5048 + /* set ttl according to config */
5049 + if (setsockopt(fd, SOL_IP, IP_MULTICAST_TTL, &pri->ttl,
5050 + sizeof(pri->ttl)) < 0) {
5051 + printk("mcast_open: IP_MULTICAST_TTL failed, error = %d\n",
5053 + os_close_file(fd);
5058 + /* set LOOP, so data does get fed back to local sockets */
5059 + if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) {
5060 + printk("mcast_open: IP_MULTICAST_LOOP failed, error = %d\n",
5062 + os_close_file(fd);
5067 + /* bind socket to mcast address */
5068 + if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) {
5069 + printk("mcast_open : data bind failed, errno = %d\n", errno);
5070 + os_close_file(fd);
5075 + /* subscribe to the multicast group */
5076 + mreq.imr_multiaddr.s_addr = sin->sin_addr.s_addr;
5077 + mreq.imr_interface.s_addr = 0;
5078 + if (setsockopt(fd, SOL_IP, IP_ADD_MEMBERSHIP,
5079 + &mreq, sizeof(mreq)) < 0) {
5080 + printk("mcast_open: IP_ADD_MEMBERSHIP failed, error = %d\n",
5082 + printk("There appears not to be a multicast-capable network "
5083 + "interface on the host.\n");
5084 + printk("eth0 should be configured in order to use the "
5085 + "multicast transport.\n");
5086 + os_close_file(fd);
5094 +static void mcast_close(int fd, void *data)
5096 + struct ip_mreq mreq;
5097 + struct mcast_data *pri = data;
5098 + struct sockaddr_in *sin = pri->mcast_addr;
5100 + mreq.imr_multiaddr.s_addr = sin->sin_addr.s_addr;
5101 + mreq.imr_interface.s_addr = 0;
5102 + if (setsockopt(fd, SOL_IP, IP_DROP_MEMBERSHIP,
5103 + &mreq, sizeof(mreq)) < 0) {
5104 + printk("mcast_open: IP_DROP_MEMBERSHIP failed, error = %d\n",
5108 + os_close_file(fd);
5111 +int mcast_user_write(int fd, void *buf, int len, struct mcast_data *pri)
5113 + struct sockaddr_in *data_addr = pri->mcast_addr;
5115 + return(net_sendto(fd, buf, len, data_addr, sizeof(*data_addr)));
5118 +static int mcast_set_mtu(int mtu, void *data)
5123 +struct net_user_info mcast_user_info = {
5124 + .init = mcast_user_init,
5125 + .open = mcast_open,
5126 + .close = mcast_close,
5128 + .set_mtu = mcast_set_mtu,
5129 + .add_address = NULL,
5130 + .delete_address = NULL,
5131 + .max_packet = MAX_PACKET - ETH_HEADER_OTHER
5135 + * Overrides for Emacs so that we follow Linus's tabbing style.
5136 + * Emacs will notice this stuff at the end of the file and automatically
5137 + * adjust the settings for this buffer only. This must remain at the end
5139 + * ---------------------------------------------------------------------------
5140 + * Local variables:
5141 + * c-file-style: "linux"
5144 diff -Naur -X ../exclude-files orig/arch/um/drivers/mconsole_kern.c um/arch/um/drivers/mconsole_kern.c
5145 --- orig/arch/um/drivers/mconsole_kern.c 1969-12-31 19:00:00.000000000 -0500
5146 +++ um/arch/um/drivers/mconsole_kern.c 2004-02-12 03:09:12.000000000 -0500
5149 + * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org)
5150 + * Copyright (C) 2001 - 2003 Jeff Dike (jdike@addtoit.com)
5151 + * Licensed under the GPL
5154 +#include "linux/kernel.h"
5155 +#include "linux/slab.h"
5156 +#include "linux/init.h"
5157 +#include "linux/notifier.h"
5158 +#include "linux/reboot.h"
5159 +#include "linux/utsname.h"
5160 +#include "linux/ctype.h"
5161 +#include "linux/interrupt.h"
5162 +#include "linux/sysrq.h"
5163 +#include "linux/tqueue.h"
5164 +#include "linux/module.h"
5165 +#include "linux/file.h"
5166 +#include "linux/fs.h"
5167 +#include "linux/proc_fs.h"
5168 +#include "asm/irq.h"
5169 +#include "asm/uaccess.h"
5170 +#include "user_util.h"
5171 +#include "kern_util.h"
5173 +#include "mconsole.h"
5174 +#include "mconsole_kern.h"
5175 +#include "irq_user.h"
5179 +#include "irq_kern.h"
5181 +static int do_unlink_socket(struct notifier_block *notifier,
5182 + unsigned long what, void *data)
5184 + return(mconsole_unlink_socket());
5188 +static struct notifier_block reboot_notifier = {
5189 + .notifier_call = do_unlink_socket,
5193 +/* Safe without explicit locking for now. Tasklets provide their own
5194 + * locking, and the interrupt handler is safe because it can't interrupt
5195 + * itself and it can only happen on CPU 0.
5198 +LIST_HEAD(mc_requests);
5200 +void mc_task_proc(void *unused)
5202 + struct mconsole_entry *req;
5203 + unsigned long flags;
5207 + save_flags(flags);
5208 + req = list_entry(mc_requests.next, struct mconsole_entry,
5210 + list_del(&req->list);
5211 + done = list_empty(&mc_requests);
5212 + restore_flags(flags);
5213 + req->request.cmd->handler(&req->request);
5218 +struct tq_struct mconsole_task = {
5219 + .routine = mc_task_proc,
5223 +void mconsole_interrupt(int irq, void *dev_id, struct pt_regs *regs)
5226 + struct mconsole_entry *new;
5227 + struct mc_request req;
5229 + fd = (int) dev_id;
5230 + while (mconsole_get_request(fd, &req)){
5231 + if(req.cmd->context == MCONSOLE_INTR)
5232 + (*req.cmd->handler)(&req);
5234 + new = kmalloc(sizeof(*new), GFP_ATOMIC);
5236 + mconsole_reply(&req, "Out of memory", 1, 0);
5238 + new->request = req;
5239 + list_add(&new->list, &mc_requests);
5243 + if(!list_empty(&mc_requests)) schedule_task(&mconsole_task);
5244 + reactivate_fd(fd, MCONSOLE_IRQ);
5247 +void mconsole_version(struct mc_request *req)
5249 + char version[256];
5251 + sprintf(version, "%s %s %s %s %s", system_utsname.sysname,
5252 + system_utsname.nodename, system_utsname.release,
5253 + system_utsname.version, system_utsname.machine);
5254 + mconsole_reply(req, version, 0, 0);
5257 +void mconsole_log(struct mc_request *req)
5260 + char *ptr = req->request.data;
5262 + ptr += strlen("log ");
5264 + len = req->len - (ptr - req->request.data);
5265 + printk("%.*s", len, ptr);
5266 + mconsole_reply(req, "", 0, 0);
5269 +void mconsole_proc(struct mc_request *req)
5271 + struct nameidata nd;
5272 + struct file_system_type *proc;
5273 + struct super_block *super;
5274 + struct file *file;
5276 + char *ptr = req->request.data, *buf;
5278 + ptr += strlen("proc");
5279 + while(isspace(*ptr)) ptr++;
5281 + proc = get_fs_type("proc");
5283 + mconsole_reply(req, "procfs not registered", 1, 0);
5287 + super = get_anon_super(proc, NULL, NULL);
5288 + if(super == NULL){
5289 + mconsole_reply(req, "Failed to get procfs superblock", 1, 0);
5293 + if(super->s_root == NULL){
5294 + super = (*proc->read_super)(super, NULL, 0);
5295 + if(super == NULL){
5296 + mconsole_reply(req, "Failed to read superblock", 1, 0);
5300 + up_write(&super->s_umount);
5302 + nd.dentry = super->s_root;
5304 + nd.flags = O_RDONLY + 1;
5305 + nd.last_type = LAST_ROOT;
5307 + err = link_path_walk(ptr, &nd);
5309 + mconsole_reply(req, "Failed to look up file", 1, 0);
5313 + file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
5315 + mconsole_reply(req, "Failed to open file", 1, 0);
5319 + buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
5321 + mconsole_reply(req, "Failed to allocate buffer", 1, 0);
5325 + if((file->f_op != NULL) && (file->f_op->read != NULL)){
5327 + n = (*file->f_op->read)(file, buf, PAGE_SIZE - 1,
5331 + mconsole_reply(req, buf, 0, (n > 0));
5334 + mconsole_reply(req, "Read of file failed",
5340 + else mconsole_reply(req, "", 0, 0);
5347 + kill_super(super);
5349 + /* put_filesystem(proc); */
5353 +#define UML_MCONSOLE_HELPTEXT \
5355 + version - Get kernel version \n\
5356 + help - Print this message \n\
5357 + halt - Halt UML \n\
5358 + reboot - Reboot UML \n\
5359 + config <dev>=<config> - Add a new device to UML; \n\
5360 + same syntax as command line \n\
5361 + config <dev> - Query the configuration of a device \n\
5362 + remove <dev> - Remove a device from UML \n\
5363 + sysrq <letter> - Performs the SysRq action controlled by the letter \n\
5364 + cad - invoke the Ctl-Alt-Del handler \n\
5365 + stop - pause the UML; it will do nothing until it receives a 'go' \n\
5366 + go - continue the UML after a 'stop' \n\
5367 + log <string> - make UML enter <string> into the kernel log\n\
5368 + proc <file> - returns the contents of the UML's /proc/<file>\n\
5371 +void mconsole_help(struct mc_request *req)
5373 + mconsole_reply(req, UML_MCONSOLE_HELPTEXT, 0, 0);
5376 +void mconsole_halt(struct mc_request *req)
5378 + mconsole_reply(req, "", 0, 0);
5382 +void mconsole_reboot(struct mc_request *req)
5384 + mconsole_reply(req, "", 0, 0);
5385 + machine_restart(NULL);
5388 +extern void ctrl_alt_del(void);
5390 +void mconsole_cad(struct mc_request *req)
5392 + mconsole_reply(req, "", 0, 0);
5396 +void mconsole_go(struct mc_request *req)
5398 + mconsole_reply(req, "Not stopped", 1, 0);
5401 +void mconsole_stop(struct mc_request *req)
5403 + deactivate_fd(req->originating_fd, MCONSOLE_IRQ);
5404 + os_set_fd_block(req->originating_fd, 1);
5405 + mconsole_reply(req, "", 0, 0);
5406 + while(mconsole_get_request(req->originating_fd, req)){
5407 + if(req->cmd->handler == mconsole_go) break;
5408 + (*req->cmd->handler)(req);
5410 + os_set_fd_block(req->originating_fd, 0);
5411 + reactivate_fd(req->originating_fd, MCONSOLE_IRQ);
5412 + mconsole_reply(req, "", 0, 0);
5415 +/* This list is populated by __initcall routines. */
5417 +LIST_HEAD(mconsole_devices);
5419 +void mconsole_register_dev(struct mc_device *new)
5421 + list_add(&new->list, &mconsole_devices);
5424 +static struct mc_device *mconsole_find_dev(char *name)
5426 + struct list_head *ele;
5427 + struct mc_device *dev;
5429 + list_for_each(ele, &mconsole_devices){
5430 + dev = list_entry(ele, struct mc_device, list);
5431 + if(!strncmp(name, dev->name, strlen(dev->name)))
5437 +#define CONFIG_BUF_SIZE 64
5439 +static void mconsole_get_config(int (*get_config)(char *, char *, int,
5441 + struct mc_request *req, char *name)
5443 + char default_buf[CONFIG_BUF_SIZE], *error, *buf;
5446 + if(get_config == NULL){
5447 + mconsole_reply(req, "No get_config routine defined", 1, 0);
5452 + size = sizeof(default_buf)/sizeof(default_buf[0]);
5453 + buf = default_buf;
5456 + n = (*get_config)(name, buf, size, &error);
5457 + if(error != NULL){
5458 + mconsole_reply(req, error, 1, 0);
5463 + mconsole_reply(req, buf, 0, 0);
5467 + if(buf != default_buf)
5471 + buf = kmalloc(size, GFP_KERNEL);
5473 + mconsole_reply(req, "Failed to allocate buffer", 1, 0);
5478 + if(buf != default_buf)
5483 +void mconsole_config(struct mc_request *req)
5485 + struct mc_device *dev;
5486 + char *ptr = req->request.data, *name;
5489 + ptr += strlen("config");
5490 + while(isspace(*ptr)) ptr++;
5491 + dev = mconsole_find_dev(ptr);
5493 + mconsole_reply(req, "Bad configuration option", 1, 0);
5497 + name = &ptr[strlen(dev->name)];
5499 + while((*ptr != '=') && (*ptr != '\0'))
5503 + err = (*dev->config)(name);
5504 + mconsole_reply(req, "", err, 0);
5506 + else mconsole_get_config(dev->get_config, req, name);
5509 +void mconsole_remove(struct mc_request *req)
5511 + struct mc_device *dev;
5512 + char *ptr = req->request.data;
5515 + ptr += strlen("remove");
5516 + while(isspace(*ptr)) ptr++;
5517 + dev = mconsole_find_dev(ptr);
5519 + mconsole_reply(req, "Bad remove option", 1, 0);
5522 + err = (*dev->remove)(&ptr[strlen(dev->name)]);
5523 + mconsole_reply(req, "", err, 0);
5526 +#ifdef CONFIG_MAGIC_SYSRQ
5527 +void mconsole_sysrq(struct mc_request *req)
5529 + char *ptr = req->request.data;
5531 + ptr += strlen("sysrq");
5532 + while(isspace(*ptr)) ptr++;
5534 + mconsole_reply(req, "", 0, 0);
5535 + handle_sysrq(*ptr, ¤t->thread.regs, NULL, NULL);
5538 +void mconsole_sysrq(struct mc_request *req)
5540 + mconsole_reply(req, "Sysrq not compiled in", 1, 0);
5544 +/* Changed by mconsole_setup, which is __setup, and called before SMP is
5547 +static char *notify_socket = NULL;
5549 +int mconsole_init(void)
5554 + if(umid_file_name("mconsole", file, sizeof(file))) return(-1);
5555 + snprintf(mconsole_socket_name, sizeof(file), "%s", file);
5557 + sock = os_create_unix_socket(file, sizeof(file), 1);
5559 + printk("Failed to initialize management console\n");
5563 + register_reboot_notifier(&reboot_notifier);
5565 + err = um_request_irq(MCONSOLE_IRQ, sock, IRQ_READ, mconsole_interrupt,
5566 + SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM,
5567 + "mconsole", (void *)sock);
5569 + printk("Failed to get IRQ for management console\n");
5573 + if(notify_socket != NULL){
5574 + notify_socket = uml_strdup(notify_socket);
5575 + if(notify_socket != NULL)
5576 + mconsole_notify(notify_socket, MCONSOLE_SOCKET,
5577 + mconsole_socket_name,
5578 + strlen(mconsole_socket_name) + 1);
5579 + else printk(KERN_ERR "mconsole_setup failed to strdup "
5583 + printk("mconsole (version %d) initialized on %s\n",
5584 + MCONSOLE_VERSION, mconsole_socket_name);
5588 +__initcall(mconsole_init);
5590 +static int write_proc_mconsole(struct file *file, const char *buffer,
5591 + unsigned long count, void *data)
5595 + buf = kmalloc(count + 1, GFP_KERNEL);
5599 + if(copy_from_user(buf, buffer, count)){
5604 + buf[count] = '\0';
5606 + mconsole_notify(notify_socket, MCONSOLE_USER_NOTIFY, buf, count);
5612 +static int create_proc_mconsole(void)
5614 + struct proc_dir_entry *ent;
5616 + if(notify_socket == NULL) return(0);
5618 + ent = create_proc_entry("mconsole", S_IFREG | 0200, NULL);
5620 + printk("create_proc_mconsole : create_proc_entry failed\n");
5624 + ent->read_proc = NULL;
5625 + ent->write_proc = write_proc_mconsole;
5629 +static spinlock_t notify_spinlock = SPIN_LOCK_UNLOCKED;
5631 +void lock_notify(void)
5633 + spin_lock(¬ify_spinlock);
5636 +void unlock_notify(void)
5638 + spin_unlock(¬ify_spinlock);
5641 +__initcall(create_proc_mconsole);
5643 +#define NOTIFY "=notify:"
5645 +static int mconsole_setup(char *str)
5647 + if(!strncmp(str, NOTIFY, strlen(NOTIFY))){
5648 + str += strlen(NOTIFY);
5649 + notify_socket = str;
5651 + else printk(KERN_ERR "mconsole_setup : Unknown option - '%s'\n", str);
5655 +__setup("mconsole", mconsole_setup);
5657 +__uml_help(mconsole_setup,
5658 +"mconsole=notify:<socket>\n"
5659 +" Requests that the mconsole driver send a message to the named Unix\n"
5660 +" socket containing the name of the mconsole socket. This also serves\n"
5661 +" to notify outside processes when UML has booted far enough to respond\n"
5662 +" to mconsole requests.\n\n"
5665 +static int notify_panic(struct notifier_block *self, unsigned long unused1,
5668 + char *message = ptr;
5670 + if(notify_socket == NULL) return(0);
5672 + mconsole_notify(notify_socket, MCONSOLE_PANIC, message,
5673 + strlen(message) + 1);
5677 +static struct notifier_block panic_exit_notifier = {
5678 + .notifier_call = notify_panic,
5683 +static int add_notifier(void)
5685 + notifier_chain_register(&panic_notifier_list, &panic_exit_notifier);
5689 +__initcall(add_notifier);
5691 +char *mconsole_notify_socket(void)
5693 + return(notify_socket);
5696 +EXPORT_SYMBOL(mconsole_notify_socket);
5699 + * Overrides for Emacs so that we follow Linus's tabbing style.
5700 + * Emacs will notice this stuff at the end of the file and automatically
5701 + * adjust the settings for this buffer only. This must remain at the end
5703 + * ---------------------------------------------------------------------------
5704 + * Local variables:
5705 + * c-file-style: "linux"
5708 diff -Naur -X ../exclude-files orig/arch/um/drivers/mconsole_user.c um/arch/um/drivers/mconsole_user.c
5709 --- orig/arch/um/drivers/mconsole_user.c 1969-12-31 19:00:00.000000000 -0500
5710 +++ um/arch/um/drivers/mconsole_user.c 2003-10-21 03:26:06.000000000 -0400
5713 + * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org)
5714 + * Copyright (C) 2001 - 2003 Jeff Dike (jdike@addtoit.com)
5715 + * Licensed under the GPL
5719 +#include <stdlib.h>
5721 +#include <signal.h>
5722 +#include <sys/socket.h>
5723 +#include <sys/types.h>
5724 +#include <sys/uio.h>
5725 +#include <sys/un.h>
5726 +#include <unistd.h>
5728 +#include "mconsole.h"
5731 +static struct mconsole_command commands[] = {
5732 + { "version", mconsole_version, MCONSOLE_INTR },
5733 + { "halt", mconsole_halt, MCONSOLE_PROC },
5734 + { "reboot", mconsole_reboot, MCONSOLE_PROC },
5735 + { "config", mconsole_config, MCONSOLE_PROC },
5736 + { "remove", mconsole_remove, MCONSOLE_PROC },
5737 + { "sysrq", mconsole_sysrq, MCONSOLE_INTR },
5738 + { "help", mconsole_help, MCONSOLE_INTR },
5739 + { "cad", mconsole_cad, MCONSOLE_INTR },
5740 + { "stop", mconsole_stop, MCONSOLE_PROC },
5741 + { "go", mconsole_go, MCONSOLE_INTR },
5742 + { "log", mconsole_log, MCONSOLE_INTR },
5743 + { "proc", mconsole_proc, MCONSOLE_PROC },
5746 +/* Initialized in mconsole_init, which is an initcall */
5747 +char mconsole_socket_name[256];
5749 +int mconsole_reply_v0(struct mc_request *req, char *reply)
5752 + struct msghdr msg;
5754 + iov.iov_base = reply;
5755 + iov.iov_len = strlen(reply);
5757 + msg.msg_name = &(req->origin);
5758 + msg.msg_namelen = req->originlen;
5759 + msg.msg_iov = &iov;
5760 + msg.msg_iovlen = 1;
5761 + msg.msg_control = NULL;
5762 + msg.msg_controllen = 0;
5763 + msg.msg_flags = 0;
5765 + return sendmsg(req->originating_fd, &msg, 0);
5768 +static struct mconsole_command *mconsole_parse(struct mc_request *req)
5770 + struct mconsole_command *cmd;
5773 + for(i=0;i<sizeof(commands)/sizeof(commands[0]);i++){
5774 + cmd = &commands[i];
5775 + if(!strncmp(req->request.data, cmd->command,
5776 + strlen(cmd->command))){
5783 +#define MIN(a,b) ((a)<(b) ? (a):(b))
5785 +#define STRINGX(x) #x
5786 +#define STRING(x) STRINGX(x)
5788 +int mconsole_get_request(int fd, struct mc_request *req)
5792 + req->originlen = sizeof(req->origin);
5793 + req->len = recvfrom(fd, &req->request, sizeof(req->request), 0,
5794 + (struct sockaddr *) req->origin, &req->originlen);
5798 + req->originating_fd = fd;
5800 + if(req->request.magic != MCONSOLE_MAGIC){
5801 + /* Unversioned request */
5802 + len = MIN(sizeof(req->request.data) - 1,
5803 + strlen((char *) &req->request));
5804 + memmove(req->request.data, &req->request, len);
5805 + req->request.data[len] = '\0';
5807 + req->request.magic = MCONSOLE_MAGIC;
5808 + req->request.version = 0;
5809 + req->request.len = len;
5811 + mconsole_reply_v0(req, "ERR Version 0 mconsole clients are "
5812 + "not supported by this driver");
5816 + if(req->request.len >= MCONSOLE_MAX_DATA){
5817 + mconsole_reply(req, "Request too large", 1, 0);
5820 + if(req->request.version != MCONSOLE_VERSION){
5821 + mconsole_reply(req, "This driver only supports version "
5822 + STRING(MCONSOLE_VERSION) " clients", 1, 0);
5825 + req->request.data[req->request.len] = '\0';
5826 + req->cmd = mconsole_parse(req);
5827 + if(req->cmd == NULL){
5828 + mconsole_reply(req, "Unknown command", 1, 0);
5835 +int mconsole_reply(struct mc_request *req, char *str, int err, int more)
5837 + struct mconsole_reply reply;
5838 + int total, len, n;
5840 + total = strlen(str);
5844 + /* err can only be true on the first packet */
5847 + len = MIN(total, MCONSOLE_MAX_DATA - 1);
5849 + if(len == total) reply.more = more;
5850 + else reply.more = 1;
5852 + memcpy(reply.data, str, len);
5853 + reply.data[len] = '\0';
5856 + reply.len = len + 1;
5858 + len = sizeof(reply) + reply.len - sizeof(reply.data);
5860 + n = sendto(req->originating_fd, &reply, len, 0,
5861 + (struct sockaddr *) req->origin, req->originlen);
5863 + if(n < 0) return(-errno);
5864 + } while(total > 0);
5868 +int mconsole_unlink_socket(void)
5870 + unlink(mconsole_socket_name);
5874 +static int notify_sock = -1;
5876 +int mconsole_notify(char *sock_name, int type, const void *data, int len)
5878 + struct sockaddr_un target;
5879 + struct mconsole_notify packet;
5883 + if(notify_sock < 0){
5884 + notify_sock = socket(PF_UNIX, SOCK_DGRAM, 0);
5885 + if(notify_sock < 0){
5886 + printk("mconsole_notify - socket failed, errno = %d\n",
5896 + target.sun_family = AF_UNIX;
5897 + strcpy(target.sun_path, sock_name);
5899 + packet.magic = MCONSOLE_MAGIC;
5900 + packet.version = MCONSOLE_VERSION;
5901 + packet.type = type;
5902 + len = (len > sizeof(packet.data)) ? sizeof(packet.data) : len;
5904 + memcpy(packet.data, data, len);
5907 + len = sizeof(packet) + packet.len - sizeof(packet.data);
5908 + n = sendto(notify_sock, &packet, len, 0, (struct sockaddr *) &target,
5911 + printk("mconsole_notify - sendto failed, errno = %d\n", errno);
5918 + * Overrides for Emacs so that we follow Linus's tabbing style.
5919 + * Emacs will notice this stuff at the end of the file and automatically
5920 + * adjust the settings for this buffer only. This must remain at the end
5922 + * ---------------------------------------------------------------------------
5923 + * Local variables:
5924 + * c-file-style: "linux"
5927 diff -Naur -X ../exclude-files orig/arch/um/drivers/mmapper_kern.c um/arch/um/drivers/mmapper_kern.c
5928 --- orig/arch/um/drivers/mmapper_kern.c 1969-12-31 19:00:00.000000000 -0500
5929 +++ um/arch/um/drivers/mmapper_kern.c 2003-10-21 03:26:06.000000000 -0400
5932 + * arch/um/drivers/mmapper_kern.c
5934 + * BRIEF MODULE DESCRIPTION
5936 + * Copyright (C) 2000 RidgeRun, Inc.
5937 + * Author: RidgeRun, Inc.
5938 + * Greg Lonnon glonnon@ridgerun.com or info@ridgerun.com
5941 +#include <linux/kdev_t.h>
5942 +#include <linux/time.h>
5943 +#include <linux/devfs_fs_kernel.h>
5944 +#include <linux/module.h>
5945 +#include <linux/mm.h>
5946 +#include <linux/slab.h>
5947 +#include <linux/init.h>
5948 +#include <asm/uaccess.h>
5949 +#include <asm/irq.h>
5950 +#include <asm/smplock.h>
5951 +#include <asm/pgtable.h>
5952 +#include "mem_user.h"
5953 +#include "user_util.h"
5955 +/* These are set in mmapper_init, which is called at boot time */
5956 +static unsigned long mmapper_size;
5957 +static unsigned long p_buf = 0;
5958 +static char *v_buf = NULL;
5961 +mmapper_read(struct file *file, char *buf, size_t count, loff_t *ppos)
5963 + if(*ppos > mmapper_size)
5966 + if(count + *ppos > mmapper_size)
5967 + count = count + *ppos - mmapper_size;
5972 + copy_to_user(buf,&v_buf[*ppos],count);
5978 +mmapper_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
5980 + if(*ppos > mmapper_size)
5983 + if(count + *ppos > mmapper_size)
5984 + count = count + *ppos - mmapper_size;
5989 + copy_from_user(&v_buf[*ppos],buf,count);
5995 +mmapper_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
5996 + unsigned long arg)
5998 + return(-ENOIOCTLCMD);
6002 +mmapper_mmap(struct file *file, struct vm_area_struct * vma)
6004 + int ret = -EINVAL;
6008 + if (vma->vm_pgoff != 0)
6011 + size = vma->vm_end - vma->vm_start;
6012 + if(size > mmapper_size) return(-EFAULT);
6014 + /* XXX A comment above remap_page_range says it should only be
6015 + * called when the mm semaphore is held
6017 + if (remap_page_range(vma->vm_start, p_buf, size, vma->vm_page_prot))
6026 +mmapper_open(struct inode *inode, struct file *file)
6032 +mmapper_release(struct inode *inode, struct file *file)
6037 +static struct file_operations mmapper_fops = {
6038 + .owner = THIS_MODULE,
6039 + .read = mmapper_read,
6040 + .write = mmapper_write,
6041 + .ioctl = mmapper_ioctl,
6042 + .mmap = mmapper_mmap,
6043 + .open = mmapper_open,
6044 + .release = mmapper_release,
6047 +static int __init mmapper_init(void)
6049 + printk(KERN_INFO "Mapper v0.1\n");
6051 + v_buf = (char *) find_iomem("mmapper", &mmapper_size);
6052 + if(mmapper_size == 0){
6053 + printk(KERN_ERR "mmapper_init - find_iomem failed\n");
6057 + p_buf = __pa(v_buf);
6059 + devfs_register (NULL, "mmapper", DEVFS_FL_DEFAULT,
6060 + 30, 0, S_IFCHR | S_IRUGO | S_IWUGO,
6061 + &mmapper_fops, NULL);
6062 + devfs_mk_symlink(NULL, "mmapper0", DEVFS_FL_DEFAULT, "mmapper",
6067 +static void mmapper_exit(void)
6071 +module_init(mmapper_init);
6072 +module_exit(mmapper_exit);
6074 +MODULE_AUTHOR("Greg Lonnon <glonnon@ridgerun.com>");
6075 +MODULE_DESCRIPTION("DSPLinux simulator mmapper driver");
6077 + * ---------------------------------------------------------------------------
6078 + * Local variables:
6079 + * c-file-style: "linux"
6082 diff -Naur -X ../exclude-files orig/arch/um/drivers/net_kern.c um/arch/um/drivers/net_kern.c
6083 --- orig/arch/um/drivers/net_kern.c 1969-12-31 19:00:00.000000000 -0500
6084 +++ um/arch/um/drivers/net_kern.c 2003-10-21 03:26:06.000000000 -0400
6087 + * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
6088 + * James Leu (jleu@mindspring.net).
6089 + * Copyright (C) 2001 by various other people who didn't put their name here.
6090 + * Licensed under the GPL.
6093 +#include "linux/config.h"
6094 +#include "linux/kernel.h"
6095 +#include "linux/netdevice.h"
6096 +#include "linux/rtnetlink.h"
6097 +#include "linux/skbuff.h"
6098 +#include "linux/socket.h"
6099 +#include "linux/spinlock.h"
6100 +#include "linux/module.h"
6101 +#include "linux/init.h"
6102 +#include "linux/etherdevice.h"
6103 +#include "linux/list.h"
6104 +#include "linux/inetdevice.h"
6105 +#include "linux/ctype.h"
6106 +#include "linux/bootmem.h"
6107 +#include "user_util.h"
6108 +#include "kern_util.h"
6109 +#include "net_kern.h"
6110 +#include "net_user.h"
6111 +#include "mconsole_kern.h"
6113 +#include "irq_user.h"
6114 +#include "irq_kern.h"
6116 +static spinlock_t opened_lock = SPIN_LOCK_UNLOCKED;
6119 +static int uml_net_rx(struct net_device *dev)
6121 + struct uml_net_private *lp = dev->priv;
6123 + struct sk_buff *skb;
6125 + /* If we can't allocate memory, try again next round. */
6126 + skb = dev_alloc_skb(dev->mtu);
6127 + if (skb == NULL) {
6128 + lp->stats.rx_dropped++;
6133 + skb_put(skb, dev->mtu);
6134 + skb->mac.raw = skb->data;
6135 + pkt_len = (*lp->read)(lp->fd, &skb, lp);
6137 + if (pkt_len > 0) {
6138 + skb_trim(skb, pkt_len);
6139 + skb->protocol = (*lp->protocol)(skb);
6142 + lp->stats.rx_bytes += skb->len;
6143 + lp->stats.rx_packets++;
6151 +void uml_net_interrupt(int irq, void *dev_id, struct pt_regs *regs)
6153 + struct net_device *dev = dev_id;
6154 + struct uml_net_private *lp = dev->priv;
6157 + if(!netif_running(dev))
6160 + spin_lock(&lp->lock);
6161 + while((err = uml_net_rx(dev)) > 0) ;
6164 + "Device '%s' read returned %d, shutting it down\n",
6169 + reactivate_fd(lp->fd, UM_ETH_IRQ);
6172 + spin_unlock(&lp->lock);
6175 +static int uml_net_open(struct net_device *dev)
6177 + struct uml_net_private *lp = dev->priv;
6178 + char addr[sizeof("255.255.255.255\0")];
6181 + spin_lock(&lp->lock);
6188 + if(!lp->have_mac){
6189 + dev_ip_addr(dev, addr, &lp->mac[2]);
6190 + set_ether_mac(dev, lp->mac);
6193 + lp->fd = (*lp->open)(&lp->user);
6199 + err = um_request_irq(dev->irq, lp->fd, IRQ_READ, uml_net_interrupt,
6200 + SA_INTERRUPT | SA_SHIRQ, dev->name, dev);
6202 + printk(KERN_ERR "uml_net_open: failed to get irq(%d)\n", err);
6203 + if(lp->close != NULL) (*lp->close)(lp->fd, &lp->user);
6205 + err = -ENETUNREACH;
6208 + lp->tl.data = (unsigned long) &lp->user;
6209 + netif_start_queue(dev);
6211 + spin_lock(&opened_lock);
6212 + list_add(&lp->list, &opened);
6213 + spin_unlock(&opened_lock);
6214 + MOD_INC_USE_COUNT;
6216 + spin_unlock(&lp->lock);
6220 +static int uml_net_close(struct net_device *dev)
6222 + struct uml_net_private *lp = dev->priv;
6224 + netif_stop_queue(dev);
6225 + spin_lock(&lp->lock);
6227 + free_irq(dev->irq, dev);
6228 + if(lp->close != NULL) (*lp->close)(lp->fd, &lp->user);
6230 + spin_lock(&opened_lock);
6231 + list_del(&lp->list);
6232 + spin_unlock(&opened_lock);
6234 + MOD_DEC_USE_COUNT;
6235 + spin_unlock(&lp->lock);
6239 +static int uml_net_start_xmit(struct sk_buff *skb, struct net_device *dev)
6241 + struct uml_net_private *lp = dev->priv;
6242 + unsigned long flags;
6245 + netif_stop_queue(dev);
6247 + spin_lock_irqsave(&lp->lock, flags);
6249 + len = (*lp->write)(lp->fd, &skb, lp);
6251 + if(len == skb->len) {
6252 + lp->stats.tx_packets++;
6253 + lp->stats.tx_bytes += skb->len;
6254 + dev->trans_start = jiffies;
6255 + netif_start_queue(dev);
6257 + /* this is normally done in the interrupt when tx finishes */
6258 + netif_wake_queue(dev);
6260 + else if(len == 0){
6261 + netif_start_queue(dev);
6262 + lp->stats.tx_dropped++;
6265 + netif_start_queue(dev);
6266 + printk(KERN_ERR "uml_net_start_xmit: failed(%d)\n", len);
6269 + spin_unlock_irqrestore(&lp->lock, flags);
6271 + dev_kfree_skb(skb);
6276 +static struct net_device_stats *uml_net_get_stats(struct net_device *dev)
6278 + struct uml_net_private *lp = dev->priv;
6279 + return &lp->stats;
6282 +static void uml_net_set_multicast_list(struct net_device *dev)
6284 + if (dev->flags & IFF_PROMISC) return;
6285 + else if (dev->mc_count) dev->flags |= IFF_ALLMULTI;
6286 + else dev->flags &= ~IFF_ALLMULTI;
6289 +static void uml_net_tx_timeout(struct net_device *dev)
6291 + dev->trans_start = jiffies;
6292 + netif_wake_queue(dev);
6295 +static int uml_net_set_mac(struct net_device *dev, void *addr)
6297 + struct uml_net_private *lp = dev->priv;
6298 + struct sockaddr *hwaddr = addr;
6300 + spin_lock(&lp->lock);
6301 + memcpy(dev->dev_addr, hwaddr->sa_data, ETH_ALEN);
6302 + spin_unlock(&lp->lock);
6307 +static int uml_net_change_mtu(struct net_device *dev, int new_mtu)
6309 + struct uml_net_private *lp = dev->priv;
6312 + spin_lock(&lp->lock);
6314 + new_mtu = (*lp->set_mtu)(new_mtu, &lp->user);
6320 + dev->mtu = new_mtu;
6323 + spin_unlock(&lp->lock);
6327 +static int uml_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
6332 +void uml_net_user_timer_expire(unsigned long _conn)
6335 + struct connection *conn = (struct connection *)_conn;
6337 + dprintk(KERN_INFO "uml_net_user_timer_expire [%p]\n", conn);
6343 + * default do nothing hard header packet routines for struct net_device init.
6344 + * real ethernet transports will overwrite with real routines.
6346 +static int uml_net_hard_header(struct sk_buff *skb, struct net_device *dev,
6347 + unsigned short type, void *daddr, void *saddr, unsigned len)
6349 + return(0); /* no change */
6352 +static int uml_net_rebuild_header(struct sk_buff *skb)
6354 + return(0); /* ignore */
6357 +static int uml_net_header_cache(struct neighbour *neigh, struct hh_cache *hh)
6359 + return(-1); /* fail */
6362 +static void uml_net_header_cache_update(struct hh_cache *hh,
6363 + struct net_device *dev, unsigned char * haddr)
6368 +static int uml_net_header_parse(struct sk_buff *skb, unsigned char *haddr)
6370 + return(0); /* nothing */
6373 +static spinlock_t devices_lock = SPIN_LOCK_UNLOCKED;
6374 +static struct list_head devices = LIST_HEAD_INIT(devices);
6376 +static int eth_configure(int n, void *init, char *mac,
6377 + struct transport *transport)
6379 + struct uml_net *device;
6380 + struct net_device *dev;
6381 + struct uml_net_private *lp;
6382 + int save, err, size;
6384 + size = transport->private_size + sizeof(struct uml_net_private) +
6385 + sizeof(((struct uml_net_private *) 0)->user);
6387 + device = kmalloc(sizeof(*device), GFP_KERNEL);
6388 + if(device == NULL){
6389 + printk(KERN_ERR "eth_configure failed to allocate uml_net\n");
6393 + *device = ((struct uml_net) { .list = LIST_HEAD_INIT(device->list),
6396 + .mac = { [ 0 ... 5 ] = 0 },
6399 + spin_lock(&devices_lock);
6400 + list_add(&device->list, &devices);
6401 + spin_unlock(&devices_lock);
6403 + if(setup_etheraddr(mac, device->mac))
6404 + device->have_mac = 1;
6406 + printk(KERN_INFO "Netdevice %d ", n);
6407 + if(device->have_mac) printk("(%02x:%02x:%02x:%02x:%02x:%02x) ",
6408 + device->mac[0], device->mac[1],
6409 + device->mac[2], device->mac[3],
6410 + device->mac[4], device->mac[5]);
6412 + dev = kmalloc(sizeof(*dev) + size, GFP_KERNEL);
6414 + printk(KERN_ERR "eth_configure: failed to allocate device\n");
6417 + memset(dev, 0, sizeof(*dev) + size);
6419 + snprintf(dev->name, sizeof(dev->name), "eth%d", n);
6420 + dev->priv = (void *) &dev[1];
6421 + device->dev = dev;
6423 + dev->hard_header = uml_net_hard_header;
6424 + dev->rebuild_header = uml_net_rebuild_header;
6425 + dev->hard_header_cache = uml_net_header_cache;
6426 + dev->header_cache_update= uml_net_header_cache_update;
6427 + dev->hard_header_parse = uml_net_header_parse;
6429 + (*transport->kern->init)(dev, init);
6431 + dev->mtu = transport->user->max_packet;
6432 + dev->open = uml_net_open;
6433 + dev->hard_start_xmit = uml_net_start_xmit;
6434 + dev->stop = uml_net_close;
6435 + dev->get_stats = uml_net_get_stats;
6436 + dev->set_multicast_list = uml_net_set_multicast_list;
6437 + dev->tx_timeout = uml_net_tx_timeout;
6438 + dev->set_mac_address = uml_net_set_mac;
6439 + dev->change_mtu = uml_net_change_mtu;
6440 + dev->do_ioctl = uml_net_ioctl;
6441 + dev->watchdog_timeo = (HZ >> 1);
6442 + dev->irq = UM_ETH_IRQ;
6445 + err = register_netdevice(dev);
6451 + /* lp.user is the first four bytes of the transport data, which
6452 + * has already been initialized. This structure assignment will
6453 + * overwrite that, so we make sure that .user gets overwritten with
6454 + * what it already has.
6456 + save = lp->user[0];
6457 + *lp = ((struct uml_net_private)
6458 + { .list = LIST_HEAD_INIT(lp->list),
6459 + .lock = SPIN_LOCK_UNLOCKED,
6462 + .mac = { 0xfe, 0xfd, 0x0, 0x0, 0x0, 0x0},
6463 + .have_mac = device->have_mac,
6464 + .protocol = transport->kern->protocol,
6465 + .open = transport->user->open,
6466 + .close = transport->user->close,
6467 + .remove = transport->user->remove,
6468 + .read = transport->kern->read,
6469 + .write = transport->kern->write,
6470 + .add_address = transport->user->add_address,
6471 + .delete_address = transport->user->delete_address,
6472 + .set_mtu = transport->user->set_mtu,
6473 + .user = { save } });
6474 + init_timer(&lp->tl);
6475 + lp->tl.function = uml_net_user_timer_expire;
6476 + memset(&lp->stats, 0, sizeof(lp->stats));
6477 + if(lp->have_mac) memcpy(lp->mac, device->mac, sizeof(lp->mac));
6479 + if(transport->user->init)
6480 + (*transport->user->init)(&lp->user, dev);
6482 + if(device->have_mac)
6483 + set_ether_mac(dev, device->mac);
6487 +static struct uml_net *find_device(int n)
6489 + struct uml_net *device;
6490 + struct list_head *ele;
6492 + spin_lock(&devices_lock);
6493 + list_for_each(ele, &devices){
6494 + device = list_entry(ele, struct uml_net, list);
6495 + if(device->index == n)
6500 + spin_unlock(&devices_lock);
6504 +static int eth_parse(char *str, int *index_out, char **str_out)
6509 + n = simple_strtoul(str, &end, 0);
6511 + printk(KERN_ERR "eth_setup: Failed to parse '%s'\n", str);
6515 + printk(KERN_ERR "eth_setup: device %d is negative\n", n);
6521 + "eth_setup: expected '=' after device number\n");
6525 + if(find_device(n)){
6526 + printk(KERN_ERR "eth_setup: Device %d already configured\n",
6530 + if(index_out) *index_out = n;
6536 + struct list_head list;
6541 +/* Filled in at boot time. Will need locking if the transports become
6544 +struct list_head transports = LIST_HEAD_INIT(transports);
6546 +/* Filled in during early boot */
6547 +struct list_head eth_cmd_line = LIST_HEAD_INIT(eth_cmd_line);
6549 +static int check_transport(struct transport *transport, char *eth, int n,
6550 + void **init_out, char **mac_out)
6554 + len = strlen(transport->name);
6555 + if(strncmp(eth, transport->name, len))
6561 + else if(*eth != '\0')
6564 + *init_out = kmalloc(transport->setup_size, GFP_KERNEL);
6565 + if(*init_out == NULL)
6568 + if(!transport->setup(eth, mac_out, *init_out)){
6575 +void register_transport(struct transport *new)
6577 + struct list_head *ele, *next;
6578 + struct eth_init *eth;
6583 + list_add(&new->list, &transports);
6585 + list_for_each_safe(ele, next, ð_cmd_line){
6586 + eth = list_entry(ele, struct eth_init, list);
6587 + match = check_transport(new, eth->init, eth->index, &init,
6591 + else if(init != NULL){
6592 + eth_configure(eth->index, init, mac, new);
6595 + list_del(ð->list);
6599 +static int eth_setup_common(char *str, int index)
6601 + struct list_head *ele;
6602 + struct transport *transport;
6606 + list_for_each(ele, &transports){
6607 + transport = list_entry(ele, struct transport, list);
6608 + if(!check_transport(transport, str, index, &init, &mac))
6611 + eth_configure(index, init, mac, transport);
6619 +static int eth_setup(char *str)
6621 + struct eth_init *new;
6624 + err = eth_parse(str, &n, &str);
6625 + if(err) return(1);
6627 + new = alloc_bootmem(sizeof(new));
6629 + printk("eth_init : alloc_bootmem failed\n");
6632 + *new = ((struct eth_init) { .list = LIST_HEAD_INIT(new->list),
6635 + list_add_tail(&new->list, ð_cmd_line);
6639 +__setup("eth", eth_setup);
6640 +__uml_help(eth_setup,
6641 +"eth[0-9]+=<transport>,<options>\n"
6642 +" Configure a network device.\n\n"
6645 +static int eth_init(void)
6647 + struct list_head *ele, *next;
6648 + struct eth_init *eth;
6650 + list_for_each_safe(ele, next, ð_cmd_line){
6651 + eth = list_entry(ele, struct eth_init, list);
6653 + if(eth_setup_common(eth->init, eth->index))
6654 + list_del(ð->list);
6660 +__initcall(eth_init);
6662 +static int net_config(char *str)
6666 + err = eth_parse(str, &n, &str);
6667 + if(err) return(err);
6669 + str = uml_strdup(str);
6671 + printk(KERN_ERR "net_config failed to strdup string\n");
6674 + err = !eth_setup_common(str, n);
6680 +static int net_remove(char *str)
6682 + struct uml_net *device;
6683 + struct net_device *dev;
6684 + struct uml_net_private *lp;
6688 + n = simple_strtoul(str, &end, 0);
6689 + if((*end != '\0') || (end == str))
6692 + device = find_device(n);
6693 + if(device == NULL)
6696 + dev = device->dev;
6698 + if(lp->fd > 0) return(-1);
6699 + if(lp->remove != NULL) (*lp->remove)(&lp->user);
6700 + unregister_netdev(dev);
6702 + list_del(&device->list);
6707 +static struct mc_device net_mc = {
6709 + .config = net_config,
6710 + .get_config = NULL,
6711 + .remove = net_remove,
6714 +static int uml_inetaddr_event(struct notifier_block *this, unsigned long event,
6717 + struct in_ifaddr *ifa = ptr;
6718 + u32 addr = ifa->ifa_address;
6719 + u32 netmask = ifa->ifa_mask;
6720 + struct net_device *dev = ifa->ifa_dev->dev;
6721 + struct uml_net_private *lp;
6722 + void (*proc)(unsigned char *, unsigned char *, void *);
6723 + unsigned char addr_buf[4], netmask_buf[4];
6725 + if(dev->open != uml_net_open) return(NOTIFY_DONE);
6732 + proc = lp->add_address;
6735 + proc = lp->delete_address;
6739 + addr_buf[0] = addr & 0xff;
6740 + addr_buf[1] = (addr >> 8) & 0xff;
6741 + addr_buf[2] = (addr >> 16) & 0xff;
6742 + addr_buf[3] = addr >> 24;
6743 + netmask_buf[0] = netmask & 0xff;
6744 + netmask_buf[1] = (netmask >> 8) & 0xff;
6745 + netmask_buf[2] = (netmask >> 16) & 0xff;
6746 + netmask_buf[3] = netmask >> 24;
6747 + (*proc)(addr_buf, netmask_buf, &lp->user);
6749 + return(NOTIFY_DONE);
6752 +struct notifier_block uml_inetaddr_notifier = {
6753 + .notifier_call = uml_inetaddr_event,
6756 +static int uml_net_init(void)
6758 + struct list_head *ele;
6759 + struct uml_net_private *lp;
6760 + struct in_device *ip;
6761 + struct in_ifaddr *in;
6763 + mconsole_register_dev(&net_mc);
6764 + register_inetaddr_notifier(¨_inetaddr_notifier);
6766 + /* Devices may have been opened already, so the uml_inetaddr_notifier
6767 + * didn't get a chance to run for them. This fakes it so that
6768 + * addresses which have already been set up get handled properly.
6770 + list_for_each(ele, &opened){
6771 + lp = list_entry(ele, struct uml_net_private, list);
6772 + ip = lp->dev->ip_ptr;
6773 + if(ip == NULL) continue;
6774 + in = ip->ifa_list;
6775 + while(in != NULL){
6776 + uml_inetaddr_event(NULL, NETDEV_UP, in);
6777 + in = in->ifa_next;
6784 +__initcall(uml_net_init);
6786 +static void close_devices(void)
6788 + struct list_head *ele;
6789 + struct uml_net_private *lp;
6791 + list_for_each(ele, &opened){
6792 + lp = list_entry(ele, struct uml_net_private, list);
6793 + if(lp->close != NULL) (*lp->close)(lp->fd, &lp->user);
6794 + if(lp->remove != NULL) (*lp->remove)(&lp->user);
6798 +__uml_exitcall(close_devices);
6800 +int setup_etheraddr(char *str, unsigned char *addr)
6808 + addr[i] = simple_strtoul(str, &end, 16);
6809 + if((end == str) ||
6810 + ((*end != ':') && (*end != ',') && (*end != '\0'))){
6812 + "setup_etheraddr: failed to parse '%s' "
6813 + "as an ethernet address\n", str);
6820 + "Attempt to assign a broadcast ethernet address to a "
6821 + "device disallowed\n");
6827 +void dev_ip_addr(void *d, char *buf, char *bin_buf)
6829 + struct net_device *dev = d;
6830 + struct in_device *ip = dev->ip_ptr;
6831 + struct in_ifaddr *in;
6834 + if((ip == NULL) || ((in = ip->ifa_list) == NULL)){
6835 + printk(KERN_WARNING "dev_ip_addr - device not assigned an "
6839 + addr = in->ifa_address;
6840 + sprintf(buf, "%d.%d.%d.%d", addr & 0xff, (addr >> 8) & 0xff,
6841 + (addr >> 16) & 0xff, addr >> 24);
6843 + bin_buf[0] = addr & 0xff;
6844 + bin_buf[1] = (addr >> 8) & 0xff;
6845 + bin_buf[2] = (addr >> 16) & 0xff;
6846 + bin_buf[3] = addr >> 24;
6850 +void set_ether_mac(void *d, unsigned char *addr)
6852 + struct net_device *dev = d;
6854 + memcpy(dev->dev_addr, addr, ETH_ALEN);
6857 +struct sk_buff *ether_adjust_skb(struct sk_buff *skb, int extra)
6859 + if((skb != NULL) && (skb_tailroom(skb) < extra)){
6860 + struct sk_buff *skb2;
6862 + skb2 = skb_copy_expand(skb, 0, extra, GFP_ATOMIC);
6863 + dev_kfree_skb(skb);
6866 + if(skb != NULL) skb_put(skb, extra);
6870 +void iter_addresses(void *d, void (*cb)(unsigned char *, unsigned char *,
6874 + struct net_device *dev = d;
6875 + struct in_device *ip = dev->ip_ptr;
6876 + struct in_ifaddr *in;
6877 + unsigned char address[4], netmask[4];
6879 + if(ip == NULL) return;
6880 + in = ip->ifa_list;
6881 + while(in != NULL){
6882 + address[0] = in->ifa_address & 0xff;
6883 + address[1] = (in->ifa_address >> 8) & 0xff;
6884 + address[2] = (in->ifa_address >> 16) & 0xff;
6885 + address[3] = in->ifa_address >> 24;
6886 + netmask[0] = in->ifa_mask & 0xff;
6887 + netmask[1] = (in->ifa_mask >> 8) & 0xff;
6888 + netmask[2] = (in->ifa_mask >> 16) & 0xff;
6889 + netmask[3] = in->ifa_mask >> 24;
6890 + (*cb)(address, netmask, arg);
6891 + in = in->ifa_next;
6895 +int dev_netmask(void *d, void *m)
6897 + struct net_device *dev = d;
6898 + struct in_device *ip = dev->ip_ptr;
6899 + struct in_ifaddr *in;
6900 + __u32 *mask_out = m;
6905 + in = ip->ifa_list;
6909 + *mask_out = in->ifa_mask;
6913 +void *get_output_buffer(int *len_out)
6917 + ret = (void *) __get_free_pages(GFP_KERNEL, 0);
6918 + if(ret) *len_out = PAGE_SIZE;
6919 + else *len_out = 0;
6923 +void free_output_buffer(void *buffer)
6925 + free_pages((unsigned long) buffer, 0);
6928 +int tap_setup_common(char *str, char *type, char **dev_name, char **mac_out,
6933 + remain = split_if_spec(str, dev_name, mac_out, gate_addr, NULL);
6934 + if(remain != NULL){
6935 + printk("tap_setup_common - Extra garbage on specification : "
6936 + "'%s'\n", remain);
6943 +unsigned short eth_protocol(struct sk_buff *skb)
6945 + return(eth_type_trans(skb, skb->dev));
6949 + * Overrides for Emacs so that we follow Linus's tabbing style.
6950 + * Emacs will notice this stuff at the end of the file and automatically
6951 + * adjust the settings for this buffer only. This must remain at the end
6953 + * ---------------------------------------------------------------------------
6954 + * Local variables:
6955 + * c-file-style: "linux"
6958 diff -Naur -X ../exclude-files orig/arch/um/drivers/net_user.c um/arch/um/drivers/net_user.c
6959 --- orig/arch/um/drivers/net_user.c 1969-12-31 19:00:00.000000000 -0500
6960 +++ um/arch/um/drivers/net_user.c 2003-10-21 03:26:06.000000000 -0400
6963 + * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
6964 + * Licensed under the GPL
6967 +#include <stddef.h>
6968 +#include <stdarg.h>
6969 +#include <unistd.h>
6972 +#include <stdlib.h>
6973 +#include <string.h>
6974 +#include <sys/socket.h>
6975 +#include <sys/wait.h>
6977 +#include "user_util.h"
6978 +#include "kern_util.h"
6979 +#include "net_user.h"
6980 +#include "helper.h"
6983 +int tap_open_common(void *dev, char *gate_addr)
6987 + if(gate_addr == NULL) return(0);
6988 + if(sscanf(gate_addr, "%d.%d.%d.%d", &tap_addr[0],
6989 + &tap_addr[1], &tap_addr[2], &tap_addr[3]) != 4){
6990 + printk("Invalid tap IP address - '%s'\n", gate_addr);
6996 +void tap_check_ips(char *gate_addr, char *eth_addr)
7000 + if((gate_addr != NULL) &&
7001 + (sscanf(gate_addr, "%d.%d.%d.%d", &tap_addr[0],
7002 + &tap_addr[1], &tap_addr[2], &tap_addr[3]) == 4) &&
7003 + (eth_addr[0] == tap_addr[0]) &&
7004 + (eth_addr[1] == tap_addr[1]) &&
7005 + (eth_addr[2] == tap_addr[2]) &&
7006 + (eth_addr[3] == tap_addr[3])){
7007 + printk("The tap IP address and the UML eth IP address"
7008 + " must be different\n");
7012 +void read_output(int fd, char *output, int len)
7014 + int remain, n, actual;
7017 + if(output == NULL){
7023 + n = os_read_file(fd, &remain, sizeof(remain));
7024 + if(n != sizeof(remain)){
7025 + printk("read_output - read of length failed, err = %d\n", -n);
7029 + while(remain != 0){
7030 + n = (remain < len) ? remain : len;
7031 + actual = os_read_file(fd, output, n);
7033 + printk("read_output - read of data failed, "
7034 + "err = %d\n", -actual);
7042 +int net_read(int fd, void *buf, int len)
7046 + n = os_read_file(fd, buf, len);
7051 + return(-ENOTCONN);
7055 +int net_recvfrom(int fd, void *buf, int len)
7059 + while(((n = recvfrom(fd, buf, len, 0, NULL, NULL)) < 0) &&
7060 + (errno == EINTR)) ;
7063 + if(errno == EAGAIN) return(0);
7066 + else if(n == 0) return(-ENOTCONN);
7070 +int net_write(int fd, void *buf, int len)
7074 + n = os_write_file(fd, buf, len);
7079 + return(-ENOTCONN);
7083 +int net_send(int fd, void *buf, int len)
7087 + while(((n = send(fd, buf, len, 0)) < 0) && (errno == EINTR)) ;
7089 + if(errno == EAGAIN) return(0);
7092 + else if(n == 0) return(-ENOTCONN);
7096 +int net_sendto(int fd, void *buf, int len, void *to, int sock_len)
7100 + while(((n = sendto(fd, buf, len, 0, (struct sockaddr *) to,
7101 + sock_len)) < 0) && (errno == EINTR)) ;
7103 + if(errno == EAGAIN) return(0);
7106 + else if(n == 0) return(-ENOTCONN);
7110 +struct change_pre_exec_data {
7115 +static void change_pre_exec(void *arg)
7117 + struct change_pre_exec_data *data = arg;
7119 + os_close_file(data->close_me);
7120 + dup2(data->stdout, 1);
7123 +static int change_tramp(char **argv, char *output, int output_len)
7125 + int pid, fds[2], err;
7126 + struct change_pre_exec_data pe_data;
7128 + err = os_pipe(fds, 1, 0);
7130 + printk("change_tramp - pipe failed, err = %d\n", -err);
7133 + pe_data.close_me = fds[0];
7134 + pe_data.stdout = fds[1];
7135 + pid = run_helper(change_pre_exec, &pe_data, argv, NULL);
7137 + os_close_file(fds[1]);
7138 + read_output(fds[0], output, output_len);
7139 + waitpid(pid, NULL, 0);
7143 +static void change(char *dev, char *what, unsigned char *addr,
7144 + unsigned char *netmask)
7146 + char addr_buf[sizeof("255.255.255.255\0")];
7147 + char netmask_buf[sizeof("255.255.255.255\0")];
7148 + char version[sizeof("nnnnn\0")];
7149 + char *argv[] = { "uml_net", version, what, dev, addr_buf,
7150 + netmask_buf, NULL };
7152 + int output_len, pid;
7154 + sprintf(version, "%d", UML_NET_VERSION);
7155 + sprintf(addr_buf, "%d.%d.%d.%d", addr[0], addr[1], addr[2], addr[3]);
7156 + sprintf(netmask_buf, "%d.%d.%d.%d", netmask[0], netmask[1],
7157 + netmask[2], netmask[3]);
7159 + output_len = page_size();
7160 + output = um_kmalloc(output_len);
7161 + if(output == NULL)
7162 + printk("change : failed to allocate output buffer\n");
7164 + pid = change_tramp(argv, output, output_len);
7165 + if(pid < 0) return;
7167 + if(output != NULL){
7168 + printk("%s", output);
7173 +void open_addr(unsigned char *addr, unsigned char *netmask, void *arg)
7175 + change(arg, "add", addr, netmask);
7178 +void close_addr(unsigned char *addr, unsigned char *netmask, void *arg)
7180 + change(arg, "del", addr, netmask);
7183 +char *split_if_spec(char *str, ...)
7188 + va_start(ap, str);
7189 + while((arg = va_arg(ap, char **)) != NULL){
7192 + end = strchr(str, ',');
7205 + * Overrides for Emacs so that we follow Linus's tabbing style.
7206 + * Emacs will notice this stuff at the end of the file and automatically
7207 + * adjust the settings for this buffer only. This must remain at the end
7209 + * ---------------------------------------------------------------------------
7210 + * Local variables:
7211 + * c-file-style: "linux"
7214 diff -Naur -X ../exclude-files orig/arch/um/drivers/null.c um/arch/um/drivers/null.c
7215 --- orig/arch/um/drivers/null.c 1969-12-31 19:00:00.000000000 -0500
7216 +++ um/arch/um/drivers/null.c 2003-10-21 03:26:06.000000000 -0400
7219 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
7220 + * Licensed under the GPL
7223 +#include <stdlib.h>
7225 +#include "chan_user.h"
7228 +static int null_chan;
7230 +void *null_init(char *str, int device, struct chan_opts *opts)
7232 + return(&null_chan);
7235 +int null_open(int input, int output, int primary, void *d, char **dev_out)
7238 + return(os_open_file(DEV_NULL, of_rdwr(OPENFLAGS()), 0));
7241 +int null_read(int fd, char *c_out, void *unused)
7246 +void null_free(void *data)
7250 +struct chan_ops null_ops = {
7252 + .init = null_init,
7253 + .open = null_open,
7254 + .close = generic_close,
7255 + .read = null_read,
7256 + .write = generic_write,
7257 + .console_write = generic_console_write,
7258 + .window_size = generic_window_size,
7259 + .free = null_free,
7264 + * Overrides for Emacs so that we follow Linus's tabbing style.
7265 + * Emacs will notice this stuff at the end of the file and automatically
7266 + * adjust the settings for this buffer only. This must remain at the end
7268 + * ---------------------------------------------------------------------------
7269 + * Local variables:
7270 + * c-file-style: "linux"
7273 diff -Naur -X ../exclude-files orig/arch/um/drivers/pcap_kern.c um/arch/um/drivers/pcap_kern.c
7274 --- orig/arch/um/drivers/pcap_kern.c 1969-12-31 19:00:00.000000000 -0500
7275 +++ um/arch/um/drivers/pcap_kern.c 2003-10-21 03:26:06.000000000 -0400
7278 + * Copyright (C) 2002 Jeff Dike <jdike@karaya.com>
7279 + * Licensed under the GPL.
7282 +#include "linux/init.h"
7283 +#include "linux/netdevice.h"
7284 +#include "linux/etherdevice.h"
7285 +#include "net_kern.h"
7286 +#include "net_user.h"
7287 +#include "pcap_user.h"
7296 +void pcap_init(struct net_device *dev, void *data)
7298 + struct uml_net_private *pri;
7299 + struct pcap_data *ppri;
7300 + struct pcap_init *init = data;
7302 + init_etherdev(dev, 0);
7304 + ppri = (struct pcap_data *) pri->user;
7305 + *ppri = ((struct pcap_data)
7306 + { .host_if = init->host_if,
7307 + .promisc = init->promisc,
7308 + .optimize = init->optimize,
7309 + .filter = init->filter,
7314 +static int pcap_read(int fd, struct sk_buff **skb,
7315 + struct uml_net_private *lp)
7317 + *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER);
7318 + if(*skb == NULL) return(-ENOMEM);
7319 + return(pcap_user_read(fd, (*skb)->mac.raw,
7320 + (*skb)->dev->mtu + ETH_HEADER_OTHER,
7321 + (struct pcap_data *) &lp->user));
7324 +static int pcap_write(int fd, struct sk_buff **skb, struct uml_net_private *lp)
7329 +static struct net_kern_info pcap_kern_info = {
7330 + .init = pcap_init,
7331 + .protocol = eth_protocol,
7332 + .read = pcap_read,
7333 + .write = pcap_write,
7336 +int pcap_setup(char *str, char **mac_out, void *data)
7338 + struct pcap_init *init = data;
7339 + char *remain, *host_if = NULL, *options[2] = { NULL, NULL };
7342 + *init = ((struct pcap_init)
7343 + { .host_if = "eth0",
7346 + .filter = NULL });
7348 + remain = split_if_spec(str, &host_if, &init->filter,
7349 + &options[0], &options[1], NULL);
7350 + if(remain != NULL){
7351 + printk(KERN_ERR "pcap_setup - Extra garbage on "
7352 + "specification : '%s'\n", remain);
7356 + if(host_if != NULL)
7357 + init->host_if = host_if;
7359 + for(i = 0; i < sizeof(options)/sizeof(options[0]); i++){
7360 + if(options[i] == NULL)
7362 + if(!strcmp(options[i], "promisc"))
7363 + init->promisc = 1;
7364 + else if(!strcmp(options[i], "nopromisc"))
7365 + init->promisc = 0;
7366 + else if(!strcmp(options[i], "optimize"))
7367 + init->optimize = 1;
7368 + else if(!strcmp(options[i], "nooptimize"))
7369 + init->optimize = 0;
7370 + else printk("pcap_setup : bad option - '%s'\n", options[i]);
7376 +static struct transport pcap_transport = {
7377 + .list = LIST_HEAD_INIT(pcap_transport.list),
7379 + .setup = pcap_setup,
7380 + .user = &pcap_user_info,
7381 + .kern = &pcap_kern_info,
7382 + .private_size = sizeof(struct pcap_data),
7383 + .setup_size = sizeof(struct pcap_init),
7386 +static int register_pcap(void)
7388 + register_transport(&pcap_transport);
7392 +__initcall(register_pcap);
7395 + * Overrides for Emacs so that we follow Linus's tabbing style.
7396 + * Emacs will notice this stuff at the end of the file and automatically
7397 + * adjust the settings for this buffer only. This must remain at the end
7399 + * ---------------------------------------------------------------------------
7400 + * Local variables:
7401 + * c-file-style: "linux"
7404 diff -Naur -X ../exclude-files orig/arch/um/drivers/pcap_user.c um/arch/um/drivers/pcap_user.c
7405 --- orig/arch/um/drivers/pcap_user.c 1969-12-31 19:00:00.000000000 -0500
7406 +++ um/arch/um/drivers/pcap_user.c 2003-10-21 03:26:06.000000000 -0400
7409 + * Copyright (C) 2002 Jeff Dike <jdike@karaya.com>
7410 + * Licensed under the GPL.
7413 +#include <unistd.h>
7414 +#include <stdlib.h>
7415 +#include <string.h>
7418 +#include <asm/types.h>
7419 +#include "net_user.h"
7420 +#include "pcap_user.h"
7423 +#define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER)
7425 +#define PCAP_FD(p) (*(int *)(p))
7427 +static void pcap_user_init(void *data, void *dev)
7429 + struct pcap_data *pri = data;
7431 + char errors[PCAP_ERRBUF_SIZE];
7433 + p = pcap_open_live(pri->host_if, MAX_PACKET, pri->promisc, 0, errors);
7435 + printk("pcap_user_init : pcap_open_live failed - '%s'\n",
7444 +static int pcap_open(void *data)
7446 + struct pcap_data *pri = data;
7450 + if(pri->pcap == NULL)
7453 + if(pri->filter != NULL){
7454 + err = dev_netmask(pri->dev, &netmask);
7456 + printk("pcap_open : dev_netmask failed\n");
7460 + pri->compiled = um_kmalloc(sizeof(struct bpf_program));
7461 + if(pri->compiled == NULL){
7462 + printk("pcap_open : kmalloc failed\n");
7466 + err = pcap_compile(pri->pcap,
7467 + (struct bpf_program *) pri->compiled,
7468 + pri->filter, pri->optimize, netmask);
7470 + printk("pcap_open : pcap_compile failed - '%s'\n",
7471 + pcap_geterr(pri->pcap));
7475 + err = pcap_setfilter(pri->pcap, pri->compiled);
7477 + printk("pcap_open : pcap_setfilter failed - '%s'\n",
7478 + pcap_geterr(pri->pcap));
7483 + return(PCAP_FD(pri->pcap));
7486 +static void pcap_remove(void *data)
7488 + struct pcap_data *pri = data;
7490 + if(pri->compiled != NULL)
7491 + pcap_freecode(pri->compiled);
7493 + pcap_close(pri->pcap);
7496 +struct pcap_handler_data {
7501 +static void handler(u_char *data, const struct pcap_pkthdr *header,
7502 + const u_char *packet)
7506 + struct pcap_handler_data *hdata = (struct pcap_handler_data *) data;
7508 + len = hdata->len < header->caplen ? hdata->len : header->caplen;
7509 + memcpy(hdata->buffer, packet, len);
7513 +int pcap_user_read(int fd, void *buffer, int len, struct pcap_data *pri)
7515 + struct pcap_handler_data hdata = ((struct pcap_handler_data)
7516 + { .buffer = buffer,
7520 + n = pcap_dispatch(pri->pcap, 1, handler, (u_char *) &hdata);
7522 + printk("pcap_dispatch failed - %s\n", pcap_geterr(pri->pcap));
7527 + return(hdata.len);
7530 +struct net_user_info pcap_user_info = {
7531 + .init = pcap_user_init,
7532 + .open = pcap_open,
7534 + .remove = pcap_remove,
7536 + .add_address = NULL,
7537 + .delete_address = NULL,
7538 + .max_packet = MAX_PACKET - ETH_HEADER_OTHER
7542 + * Overrides for Emacs so that we follow Linus's tabbing style.
7543 + * Emacs will notice this stuff at the end of the file and automatically
7544 + * adjust the settings for this buffer only. This must remain at the end
7546 + * ---------------------------------------------------------------------------
7547 + * Local variables:
7548 + * c-file-style: "linux"
7551 diff -Naur -X ../exclude-files orig/arch/um/drivers/pcap_user.h um/arch/um/drivers/pcap_user.h
7552 --- orig/arch/um/drivers/pcap_user.h 1969-12-31 19:00:00.000000000 -0500
7553 +++ um/arch/um/drivers/pcap_user.h 2003-10-21 03:26:06.000000000 -0400
7556 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
7557 + * Licensed under the GPL
7560 +#include "net_user.h"
7572 +extern struct net_user_info pcap_user_info;
7574 +extern int pcap_user_read(int fd, void *buf, int len, struct pcap_data *pri);
7577 + * Overrides for Emacs so that we follow Linus's tabbing style.
7578 + * Emacs will notice this stuff at the end of the file and automatically
7579 + * adjust the settings for this buffer only. This must remain at the end
7581 + * ---------------------------------------------------------------------------
7582 + * Local variables:
7583 + * c-file-style: "linux"
7586 diff -Naur -X ../exclude-files orig/arch/um/drivers/port.h um/arch/um/drivers/port.h
7587 --- orig/arch/um/drivers/port.h 1969-12-31 19:00:00.000000000 -0500
7588 +++ um/arch/um/drivers/port.h 2003-10-21 03:26:06.000000000 -0400
7591 + * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
7592 + * Licensed under the GPL
7598 +extern void *port_data(int port);
7599 +extern int port_wait(void *data);
7600 +extern void port_kern_close(void *d);
7601 +extern int port_connection(int fd, int *socket_out, int *pid_out);
7602 +extern int port_listen_fd(int port);
7603 +extern void port_read(int fd, void *data);
7604 +extern void port_kern_free(void *d);
7605 +extern int port_rcv_fd(int fd);
7606 +extern void port_remove_dev(void *d);
7611 + * Overrides for Emacs so that we follow Linus's tabbing style.
7612 + * Emacs will notice this stuff at the end of the file and automatically
7613 + * adjust the settings for this buffer only. This must remain at the end
7615 + * ---------------------------------------------------------------------------
7616 + * Local variables:
7617 + * c-file-style: "linux"
7620 diff -Naur -X ../exclude-files orig/arch/um/drivers/port_kern.c um/arch/um/drivers/port_kern.c
7621 --- orig/arch/um/drivers/port_kern.c 1969-12-31 19:00:00.000000000 -0500
7622 +++ um/arch/um/drivers/port_kern.c 2004-01-10 06:18:49.000000000 -0500
7625 + * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
7626 + * Licensed under the GPL
7629 +#include "linux/list.h"
7630 +#include "linux/sched.h"
7631 +#include "linux/slab.h"
7632 +#include "linux/irq.h"
7633 +#include "linux/spinlock.h"
7634 +#include "linux/errno.h"
7635 +#include "asm/semaphore.h"
7636 +#include "asm/errno.h"
7637 +#include "kern_util.h"
7639 +#include "irq_user.h"
7640 +#include "irq_kern.h"
7646 + struct list_head list;
7647 + int has_connection;
7648 + struct semaphore sem;
7652 + struct list_head pending;
7653 + struct list_head connections;
7657 + struct port_list *port;
7662 +struct connection {
7663 + struct list_head list;
7668 + struct port_list *port;
7671 +static void pipe_interrupt(int irq, void *data, struct pt_regs *regs)
7673 + struct connection *conn = data;
7676 + fd = os_rcv_fd(conn->socket[0], &conn->helper_pid);
7681 + printk(KERN_ERR "pipe_interrupt : os_rcv_fd returned %d\n",
7683 + os_close_file(conn->fd);
7686 + list_del(&conn->list);
7689 + list_add(&conn->list, &conn->port->connections);
7691 + up(&conn->port->sem);
7694 +static int port_accept(struct port_list *port)
7696 + struct connection *conn;
7697 + int fd, socket[2], pid, ret = 0;
7699 + fd = port_connection(port->fd, socket, &pid);
7702 + printk(KERN_ERR "port_accept : port_connection "
7703 + "returned %d\n", -fd);
7707 + conn = kmalloc(sizeof(*conn), GFP_ATOMIC);
7709 + printk(KERN_ERR "port_accept : failed to allocate "
7713 + *conn = ((struct connection)
7714 + { .list = LIST_HEAD_INIT(conn->list),
7716 + .socket = { socket[0], socket[1] },
7717 + .telnetd_pid = pid,
7720 + if(um_request_irq(TELNETD_IRQ, socket[0], IRQ_READ, pipe_interrupt,
7721 + SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM,
7722 + "telnetd", conn)){
7723 + printk(KERN_ERR "port_accept : failed to get IRQ for "
7728 + list_add(&conn->list, &port->pending);
7734 + os_close_file(fd);
7736 + os_kill_process(pid, 1);
7741 +DECLARE_MUTEX(ports_sem);
7742 +struct list_head ports = LIST_HEAD_INIT(ports);
7744 +void port_task_proc(void *unused)
7746 + struct port_list *port;
7747 + struct list_head *ele;
7748 + unsigned long flags;
7750 + save_flags(flags);
7751 + list_for_each(ele, &ports){
7752 + port = list_entry(ele, struct port_list, list);
7753 + if(!port->has_connection)
7755 + reactivate_fd(port->fd, ACCEPT_IRQ);
7756 + while(port_accept(port)) ;
7757 + port->has_connection = 0;
7759 + restore_flags(flags);
7762 +struct tq_struct port_task = {
7763 + .routine = port_task_proc,
7767 +static void port_interrupt(int irq, void *data, struct pt_regs *regs)
7769 + struct port_list *port = data;
7771 + port->has_connection = 1;
7772 + schedule_task(&port_task);
7775 +void *port_data(int port_num)
7777 + struct list_head *ele;
7778 + struct port_list *port;
7779 + struct port_dev *dev = NULL;
7783 + list_for_each(ele, &ports){
7784 + port = list_entry(ele, struct port_list, list);
7785 + if(port->port == port_num) goto found;
7787 + port = kmalloc(sizeof(struct port_list), GFP_KERNEL);
7789 + printk(KERN_ERR "Allocation of port list failed\n");
7793 + fd = port_listen_fd(port_num);
7795 + printk(KERN_ERR "binding to port %d failed, errno = %d\n",
7799 + if(um_request_irq(ACCEPT_IRQ, fd, IRQ_READ, port_interrupt,
7800 + SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM, "port",
7802 + printk(KERN_ERR "Failed to get IRQ for port %d\n", port_num);
7806 + *port = ((struct port_list)
7807 + { .list = LIST_HEAD_INIT(port->list),
7808 + .has_connection = 0,
7809 + .sem = __SEMAPHORE_INITIALIZER(port->sem,
7811 + .lock = SPIN_LOCK_UNLOCKED,
7814 + .pending = LIST_HEAD_INIT(port->pending),
7815 + .connections = LIST_HEAD_INIT(port->connections) });
7816 + list_add(&port->list, &ports);
7819 + dev = kmalloc(sizeof(struct port_dev), GFP_KERNEL);
7821 + printk(KERN_ERR "Allocation of port device entry failed\n");
7825 + *dev = ((struct port_dev) { .port = port,
7827 + .telnetd_pid = -1 });
7833 + os_close_file(fd);
7839 +int port_wait(void *data)
7841 + struct port_dev *dev = data;
7842 + struct connection *conn;
7843 + struct port_list *port = dev->port;
7847 + if(down_interruptible(&port->sem))
7848 + return(-ERESTARTSYS);
7850 + spin_lock(&port->lock);
7852 + conn = list_entry(port->connections.next, struct connection,
7854 + list_del(&conn->list);
7855 + spin_unlock(&port->lock);
7857 + os_shutdown_socket(conn->socket[0], 1, 1);
7858 + os_close_file(conn->socket[0]);
7859 + os_shutdown_socket(conn->socket[1], 1, 1);
7860 + os_close_file(conn->socket[1]);
7862 + /* This is done here because freeing an IRQ can't be done
7863 + * within the IRQ handler. So, pipe_interrupt always ups
7864 + * the semaphore regardless of whether it got a successful
7865 + * connection. Then we loop here throwing out failed
7866 + * connections until a good one is found.
7868 + free_irq(TELNETD_IRQ, conn);
7870 + if(conn->fd >= 0) break;
7871 + os_close_file(conn->fd);
7876 + dev->helper_pid = conn->helper_pid;
7877 + dev->telnetd_pid = conn->telnetd_pid;
7883 +void port_remove_dev(void *d)
7885 + struct port_dev *dev = d;
7887 + if(dev->helper_pid != -1)
7888 + os_kill_process(dev->helper_pid, 0);
7889 + if(dev->telnetd_pid != -1)
7890 + os_kill_process(dev->telnetd_pid, 1);
7891 + dev->helper_pid = -1;
7892 + dev->telnetd_pid = -1;
7895 +void port_kern_free(void *d)
7897 + struct port_dev *dev = d;
7899 + port_remove_dev(dev);
7903 +static void free_port(void)
7905 + struct list_head *ele;
7906 + struct port_list *port;
7908 + list_for_each(ele, &ports){
7909 + port = list_entry(ele, struct port_list, list);
7910 + free_irq_by_fd(port->fd);
7911 + os_close_file(port->fd);
7915 +__uml_exitcall(free_port);
7918 + * Overrides for Emacs so that we follow Linus's tabbing style.
7919 + * Emacs will notice this stuff at the end of the file and automatically
7920 + * adjust the settings for this buffer only. This must remain at the end
7922 + * ---------------------------------------------------------------------------
7923 + * Local variables:
7924 + * c-file-style: "linux"
7927 diff -Naur -X ../exclude-files orig/arch/um/drivers/port_user.c um/arch/um/drivers/port_user.c
7928 --- orig/arch/um/drivers/port_user.c 1969-12-31 19:00:00.000000000 -0500
7929 +++ um/arch/um/drivers/port_user.c 2003-10-21 03:26:06.000000000 -0400
7932 + * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
7933 + * Licensed under the GPL
7937 +#include <stddef.h>
7938 +#include <stdlib.h>
7939 +#include <string.h>
7941 +#include <unistd.h>
7942 +#include <termios.h>
7943 +#include <sys/socket.h>
7944 +#include <sys/un.h>
7945 +#include <netinet/in.h>
7946 +#include "user_util.h"
7947 +#include "kern_util.h"
7949 +#include "chan_user.h"
7951 +#include "helper.h"
7956 + struct termios tt;
7957 + void *kernel_data;
7958 + char dev[sizeof("32768\0")];
7961 +void *port_init(char *str, int device, struct chan_opts *opts)
7963 + struct port_chan *data;
7969 + printk("port_init : channel type 'port' must specify a "
7974 + port = strtoul(str, &end, 0);
7975 + if((*end != '\0') || (end == str)){
7976 + printk("port_init : couldn't parse port '%s'\n", str);
7980 + kern_data = port_data(port);
7981 + if(kern_data == NULL)
7984 + data = um_kmalloc(sizeof(*data));
7988 + *data = ((struct port_chan) { .raw = opts->raw,
7989 + .kernel_data = kern_data });
7990 + sprintf(data->dev, "%d", port);
7994 + port_kern_free(kern_data);
7998 +void port_free(void *d)
8000 + struct port_chan *data = d;
8002 + port_kern_free(data->kernel_data);
8006 +int port_open(int input, int output, int primary, void *d, char **dev_out)
8008 + struct port_chan *data = d;
8011 + fd = port_wait(data->kernel_data);
8012 + if((fd >= 0) && data->raw){
8013 + tcgetattr(fd, &data->tt);
8016 + *dev_out = data->dev;
8020 +void port_close(int fd, void *d)
8022 + struct port_chan *data = d;
8024 + port_remove_dev(data->kernel_data);
8025 + os_close_file(fd);
8028 +int port_console_write(int fd, const char *buf, int n, void *d)
8030 + struct port_chan *data = d;
8032 + return(generic_console_write(fd, buf, n, &data->tt));
8035 +struct chan_ops port_ops = {
8037 + .init = port_init,
8038 + .open = port_open,
8039 + .close = port_close,
8040 + .read = generic_read,
8041 + .write = generic_write,
8042 + .console_write = port_console_write,
8043 + .window_size = generic_window_size,
8044 + .free = port_free,
8048 +int port_listen_fd(int port)
8050 + struct sockaddr_in addr;
8053 + fd = socket(PF_INET, SOCK_STREAM, 0);
8057 + addr.sin_family = AF_INET;
8058 + addr.sin_port = htons(port);
8059 + addr.sin_addr.s_addr = htonl(INADDR_ANY);
8060 + if(bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0){
8065 + if(listen(fd, 1) < 0){
8070 + err = os_set_fd_block(fd, 0);
8076 + os_close_file(fd);
8080 +struct port_pre_exec_data {
8085 +void port_pre_exec(void *arg)
8087 + struct port_pre_exec_data *data = arg;
8089 + dup2(data->sock_fd, 0);
8090 + dup2(data->sock_fd, 1);
8091 + dup2(data->sock_fd, 2);
8092 + os_close_file(data->sock_fd);
8093 + dup2(data->pipe_fd, 3);
8094 + os_shutdown_socket(3, 1, 0);
8095 + os_close_file(data->pipe_fd);
8098 +int port_connection(int fd, int *socket, int *pid_out)
8101 + char *argv[] = { "/usr/sbin/in.telnetd", "-L",
8102 + "/usr/lib/uml/port-helper", NULL };
8103 + struct port_pre_exec_data data;
8105 + new = os_accept_connection(fd);
8109 + err = os_pipe(socket, 0, 0);
8113 + data = ((struct port_pre_exec_data)
8115 + .pipe_fd = socket[1] });
8117 + err = run_helper(port_pre_exec, &data, argv, NULL);
8119 + goto out_shutdown;
8125 + os_shutdown_socket(socket[0], 1, 1);
8126 + os_close_file(socket[0]);
8127 + os_shutdown_socket(socket[1], 1, 1);
8128 + os_close_file(socket[1]);
8130 + os_close_file(new);
8135 + * Overrides for Emacs so that we follow Linus's tabbing style.
8136 + * Emacs will notice this stuff at the end of the file and automatically
8137 + * adjust the settings for this buffer only. This must remain at the end
8139 + * ---------------------------------------------------------------------------
8140 + * Local variables:
8141 + * c-file-style: "linux"
8144 diff -Naur -X ../exclude-files orig/arch/um/drivers/pty.c um/arch/um/drivers/pty.c
8145 --- orig/arch/um/drivers/pty.c 1969-12-31 19:00:00.000000000 -0500
8146 +++ um/arch/um/drivers/pty.c 2003-10-21 03:26:06.000000000 -0400
8149 + * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
8150 + * Licensed under the GPL
8154 +#include <unistd.h>
8155 +#include <string.h>
8157 +#include <termios.h>
8158 +#include "chan_user.h"
8160 +#include "user_util.h"
8161 +#include "kern_util.h"
8165 + void (*announce)(char *dev_name, int dev);
8168 + struct termios tt;
8169 + char dev_name[sizeof("/dev/pts/0123456\0")];
8172 +void *pty_chan_init(char *str, int device, struct chan_opts *opts)
8174 + struct pty_chan *data;
8176 + data = um_kmalloc(sizeof(*data));
8177 + if(data == NULL) return(NULL);
8178 + *data = ((struct pty_chan) { .announce = opts->announce,
8180 + .raw = opts->raw });
8184 +int pts_open(int input, int output, int primary, void *d, char **dev_out)
8186 + struct pty_chan *data = d;
8192 + printk("open_pts : Failed to open pts\n");
8196 + tcgetattr(fd, &data->tt);
8200 + dev = ptsname(fd);
8201 + sprintf(data->dev_name, "%s", dev);
8202 + *dev_out = data->dev_name;
8203 + if(data->announce) (*data->announce)(dev, data->dev);
8207 +int getmaster(char *line)
8209 + char *pty, *bank, *cp;
8212 + pty = &line[strlen("/dev/ptyp")];
8213 + for (bank = "pqrs"; *bank; bank++) {
8214 + line[strlen("/dev/pty")] = *bank;
8216 + if (os_stat_file(line, NULL) < 0)
8218 + for (cp = "0123456789abcdef"; *cp; cp++) {
8220 + master = os_open_file(line, of_rdwr(OPENFLAGS()), 0);
8221 + if (master >= 0) {
8222 + char *tp = &line[strlen("/dev/")];
8224 + /* verify slave side is usable */
8226 + err = os_access(line, OS_ACC_RW_OK);
8228 + if(err == 0) return(master);
8229 + (void) os_close_file(master);
8236 +int pty_open(int input, int output, int primary, void *d, char **dev_out)
8238 + struct pty_chan *data = d;
8240 + char dev[sizeof("/dev/ptyxx\0")] = "/dev/ptyxx";
8242 + fd = getmaster(dev);
8243 + if(fd < 0) return(-errno);
8245 + if(data->raw) raw(fd, 0);
8246 + if(data->announce) (*data->announce)(dev, data->dev);
8248 + sprintf(data->dev_name, "%s", dev);
8249 + *dev_out = data->dev_name;
8253 +int pty_console_write(int fd, const char *buf, int n, void *d)
8255 + struct pty_chan *data = d;
8257 + return(generic_console_write(fd, buf, n, &data->tt));
8260 +struct chan_ops pty_ops = {
8262 + .init = pty_chan_init,
8264 + .close = generic_close,
8265 + .read = generic_read,
8266 + .write = generic_write,
8267 + .console_write = pty_console_write,
8268 + .window_size = generic_window_size,
8269 + .free = generic_free,
8273 +struct chan_ops pts_ops = {
8275 + .init = pty_chan_init,
8277 + .close = generic_close,
8278 + .read = generic_read,
8279 + .write = generic_write,
8280 + .console_write = pty_console_write,
8281 + .window_size = generic_window_size,
8282 + .free = generic_free,
8287 + * Overrides for Emacs so that we follow Linus's tabbing style.
8288 + * Emacs will notice this stuff at the end of the file and automatically
8289 + * adjust the settings for this buffer only. This must remain at the end
8291 + * ---------------------------------------------------------------------------
8292 + * Local variables:
8293 + * c-file-style: "linux"
8296 diff -Naur -X ../exclude-files orig/arch/um/drivers/slip.h um/arch/um/drivers/slip.h
8297 --- orig/arch/um/drivers/slip.h 1969-12-31 19:00:00.000000000 -0500
8298 +++ um/arch/um/drivers/slip.h 2003-10-21 03:26:06.000000000 -0400
8300 +#ifndef __UM_SLIP_H
8301 +#define __UM_SLIP_H
8303 +#define BUF_SIZE 1500
8304 + /* two bytes each for a (pathological) max packet of escaped chars + *
8305 + * terminating END char + initial END char */
8306 +#define ENC_BUF_SIZE (2 * BUF_SIZE + 2)
8310 + char name[sizeof("slnnnnn\0")];
8314 + char ibuf[ENC_BUF_SIZE];
8315 + char obuf[ENC_BUF_SIZE];
8316 + int more; /* more data: do not read fd until ibuf has been drained */
8321 +extern struct net_user_info slip_user_info;
8323 +extern int set_umn_addr(int fd, char *addr, char *ptp_addr);
8324 +extern int slip_user_read(int fd, void *buf, int len, struct slip_data *pri);
8325 +extern int slip_user_write(int fd, void *buf, int len, struct slip_data *pri);
8330 + * Overrides for Emacs so that we follow Linus's tabbing style.
8331 + * Emacs will notice this stuff at the end of the file and automatically
8332 + * adjust the settings for this buffer only. This must remain at the end
8334 + * ---------------------------------------------------------------------------
8335 + * Local variables:
8336 + * c-file-style: "linux"
8339 diff -Naur -X ../exclude-files orig/arch/um/drivers/slip_kern.c um/arch/um/drivers/slip_kern.c
8340 --- orig/arch/um/drivers/slip_kern.c 1969-12-31 19:00:00.000000000 -0500
8341 +++ um/arch/um/drivers/slip_kern.c 2003-10-21 03:26:06.000000000 -0400
8343 +#include "linux/config.h"
8344 +#include "linux/kernel.h"
8345 +#include "linux/stddef.h"
8346 +#include "linux/init.h"
8347 +#include "linux/netdevice.h"
8348 +#include "linux/if_arp.h"
8349 +#include "net_kern.h"
8350 +#include "net_user.h"
8358 +void slip_init(struct net_device *dev, void *data)
8360 + struct uml_net_private *private;
8361 + struct slip_data *spri;
8362 + struct slip_init *init = data;
8364 + private = dev->priv;
8365 + spri = (struct slip_data *) private->user;
8366 + *spri = ((struct slip_data)
8367 + { .name = { '\0' },
8369 + .gate_addr = init->gate_addr,
8378 + dev->hard_header_len = 0;
8379 + dev->addr_len = 4;
8380 + dev->type = ARPHRD_ETHER;
8381 + dev->tx_queue_len = 256;
8382 + dev->flags = IFF_NOARP;
8383 + printk("SLIP backend - SLIP IP = %s\n", spri->gate_addr);
8386 +static unsigned short slip_protocol(struct sk_buff *skbuff)
8388 + return(htons(ETH_P_IP));
8391 +static int slip_read(int fd, struct sk_buff **skb,
8392 + struct uml_net_private *lp)
8394 + return(slip_user_read(fd, (*skb)->mac.raw, (*skb)->dev->mtu,
8395 + (struct slip_data *) &lp->user));
8398 +static int slip_write(int fd, struct sk_buff **skb,
8399 + struct uml_net_private *lp)
8401 + return(slip_user_write(fd, (*skb)->data, (*skb)->len,
8402 + (struct slip_data *) &lp->user));
8405 +struct net_kern_info slip_kern_info = {
8406 + .init = slip_init,
8407 + .protocol = slip_protocol,
8408 + .read = slip_read,
8409 + .write = slip_write,
8412 +static int slip_setup(char *str, char **mac_out, void *data)
8414 + struct slip_init *init = data;
8416 + *init = ((struct slip_init)
8417 + { .gate_addr = NULL });
8419 + if(str[0] != '\0')
8420 + init->gate_addr = str;
8424 +static struct transport slip_transport = {
8425 + .list = LIST_HEAD_INIT(slip_transport.list),
8427 + .setup = slip_setup,
8428 + .user = &slip_user_info,
8429 + .kern = &slip_kern_info,
8430 + .private_size = sizeof(struct slip_data),
8431 + .setup_size = sizeof(struct slip_init),
8434 +static int register_slip(void)
8436 + register_transport(&slip_transport);
8440 +__initcall(register_slip);
8443 + * Overrides for Emacs so that we follow Linus's tabbing style.
8444 + * Emacs will notice this stuff at the end of the file and automatically
8445 + * adjust the settings for this buffer only. This must remain at the end
8447 + * ---------------------------------------------------------------------------
8448 + * Local variables:
8449 + * c-file-style: "linux"
8452 diff -Naur -X ../exclude-files orig/arch/um/drivers/slip_proto.h um/arch/um/drivers/slip_proto.h
8453 --- orig/arch/um/drivers/slip_proto.h 1969-12-31 19:00:00.000000000 -0500
8454 +++ um/arch/um/drivers/slip_proto.h 2003-10-21 03:26:06.000000000 -0400
8457 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
8458 + * Licensed under the GPL
8461 +#ifndef __UM_SLIP_PROTO_H__
8462 +#define __UM_SLIP_PROTO_H__
8464 +/* SLIP protocol characters. */
8465 +#define SLIP_END 0300 /* indicates end of frame */
8466 +#define SLIP_ESC 0333 /* indicates byte stuffing */
8467 +#define SLIP_ESC_END 0334 /* ESC ESC_END means END 'data' */
8468 +#define SLIP_ESC_ESC 0335 /* ESC ESC_ESC means ESC 'data' */
8470 +static inline int slip_unesc(unsigned char c,char *buf,int *pos, int *esc)
8483 + case SLIP_ESC_ESC:
8489 + case SLIP_ESC_END:
8496 + buf[(*pos)++] = c;
8500 +static inline int slip_esc(unsigned char *s, unsigned char *d, int len)
8502 + unsigned char *ptr = d;
8506 + * Send an initial END character to flush out any
8507 + * data that may have accumulated in the receiver
8508 + * due to line noise.
8511 + *ptr++ = SLIP_END;
8514 + * For each byte in the packet, send the appropriate
8515 + * character sequence, according to the SLIP protocol.
8518 + while (len-- > 0) {
8519 + switch(c = *s++) {
8521 + *ptr++ = SLIP_ESC;
8522 + *ptr++ = SLIP_ESC_END;
8525 + *ptr++ = SLIP_ESC;
8526 + *ptr++ = SLIP_ESC_ESC;
8533 + *ptr++ = SLIP_END;
8540 + * Overrides for Emacs so that we follow Linus's tabbing style.
8541 + * Emacs will notice this stuff at the end of the file and automatically
8542 + * adjust the settings for this buffer only. This must remain at the end
8544 + * ---------------------------------------------------------------------------
8545 + * Local variables:
8546 + * c-file-style: "linux"
8549 diff -Naur -X ../exclude-files orig/arch/um/drivers/slip_user.c um/arch/um/drivers/slip_user.c
8550 --- orig/arch/um/drivers/slip_user.c 1969-12-31 19:00:00.000000000 -0500
8551 +++ um/arch/um/drivers/slip_user.c 2003-10-21 03:26:06.000000000 -0400
8554 +#include <stdlib.h>
8555 +#include <unistd.h>
8556 +#include <stddef.h>
8558 +#include <string.h>
8559 +#include <sys/errno.h>
8560 +#include <sys/termios.h>
8561 +#include <sys/wait.h>
8562 +#include <sys/signal.h>
8563 +#include "user_util.h"
8564 +#include "kern_util.h"
8566 +#include "net_user.h"
8568 +#include "slip_proto.h"
8569 +#include "helper.h"
8572 +void slip_user_init(void *data, void *dev)
8574 + struct slip_data *pri = data;
8579 +static int set_up_tty(int fd)
8582 + struct termios tios;
8584 + if (tcgetattr(fd, &tios) < 0) {
8585 + printk("could not get initial terminal attributes\n");
8589 + tios.c_cflag = CS8 | CREAD | HUPCL | CLOCAL;
8590 + tios.c_iflag = IGNBRK | IGNPAR;
8593 + for (i = 0; i < NCCS; i++)
8595 + tios.c_cc[VMIN] = 1;
8596 + tios.c_cc[VTIME] = 0;
8598 + cfsetospeed(&tios, B38400);
8599 + cfsetispeed(&tios, B38400);
8601 + if (tcsetattr(fd, TCSAFLUSH, &tios) < 0) {
8602 + printk("failed to set terminal attributes\n");
8608 +struct slip_pre_exec_data {
8614 +static void slip_pre_exec(void *arg)
8616 + struct slip_pre_exec_data *data = arg;
8618 + if(data->stdin >= 0) dup2(data->stdin, 0);
8619 + dup2(data->stdout, 1);
8620 + if(data->close_me >= 0) os_close_file(data->close_me);
8623 +static int slip_tramp(char **argv, int fd)
8625 + struct slip_pre_exec_data pe_data;
8627 + int status, pid, fds[2], err, output_len;
8629 + err = os_pipe(fds, 1, 0);
8631 + printk("slip_tramp : pipe failed, err = %d\n", -err);
8636 + pe_data.stdin = fd;
8637 + pe_data.stdout = fds[1];
8638 + pe_data.close_me = fds[0];
8639 + pid = run_helper(slip_pre_exec, &pe_data, argv, NULL);
8641 + if(pid < 0) err = pid;
8643 + output_len = page_size();
8644 + output = um_kmalloc(output_len);
8645 + if(output == NULL)
8646 + printk("slip_tramp : failed to allocate output "
8649 + os_close_file(fds[1]);
8650 + read_output(fds[0], output, output_len);
8651 + if(output != NULL){
8652 + printk("%s", output);
8655 + if(waitpid(pid, &status, 0) < 0) err = errno;
8656 + else if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)){
8657 + printk("'%s' didn't exit with status 0\n", argv[0]);
8664 +static int slip_open(void *data)
8666 + struct slip_data *pri = data;
8667 + char version_buf[sizeof("nnnnn\0")];
8668 + char gate_buf[sizeof("nnn.nnn.nnn.nnn\0")];
8669 + char *argv[] = { "uml_net", version_buf, "slip", "up", gate_buf,
8671 + int sfd, mfd, err;
8675 + printk("umn : Failed to open pty, err = %d\n", -mfd);
8678 + sfd = os_open_file(ptsname(mfd), of_rdwr(OPENFLAGS()), 0);
8680 + printk("Couldn't open tty for slip line, err = %d\n", -sfd);
8683 + if(set_up_tty(sfd)) return(-1);
8687 + if(pri->gate_addr != NULL){
8688 + sprintf(version_buf, "%d", UML_NET_VERSION);
8689 + strcpy(gate_buf, pri->gate_addr);
8691 + err = slip_tramp(argv, sfd);
8694 + printk("slip_tramp failed - err = %d\n", -err);
8697 + err = os_get_ifname(pri->slave, pri->name);
8699 + printk("get_ifname failed, err = %d\n", -err);
8702 + iter_addresses(pri->dev, open_addr, pri->name);
8705 + err = os_set_slip(sfd);
8707 + printk("Failed to set slip discipline encapsulation - "
8708 + "err = %d\n", -err);
8715 +static void slip_close(int fd, void *data)
8717 + struct slip_data *pri = data;
8718 + char version_buf[sizeof("nnnnn\0")];
8719 + char *argv[] = { "uml_net", version_buf, "slip", "down", pri->name,
8723 + if(pri->gate_addr != NULL)
8724 + iter_addresses(pri->dev, close_addr, pri->name);
8726 + sprintf(version_buf, "%d", UML_NET_VERSION);
8728 + err = slip_tramp(argv, -1);
8731 + printk("slip_tramp failed - errno = %d\n", -err);
8732 + os_close_file(fd);
8733 + os_close_file(pri->slave);
8737 +int slip_user_read(int fd, void *buf, int len, struct slip_data *pri)
8739 + int i, n, size, start;
8743 + while(i < pri->more) {
8744 + size = slip_unesc(pri->ibuf[i++],
8745 + pri->ibuf, &pri->pos, &pri->esc);
8747 + memcpy(buf, pri->ibuf, size);
8748 + memmove(pri->ibuf, &pri->ibuf[i], pri->more-i);
8749 + pri->more=pri->more-i;
8756 + n = net_read(fd, &pri->ibuf[pri->pos], sizeof(pri->ibuf) - pri->pos);
8757 + if(n <= 0) return(n);
8760 + for(i = 0; i < n; i++){
8761 + size = slip_unesc(pri->ibuf[start + i],
8762 + pri->ibuf, &pri->pos, &pri->esc);
8764 + memcpy(buf, pri->ibuf, size);
8765 + memmove(pri->ibuf, &pri->ibuf[start+i+1], n-(i+1));
8766 + pri->more=n-(i+1);
8773 +int slip_user_write(int fd, void *buf, int len, struct slip_data *pri)
8777 + actual = slip_esc(buf, pri->obuf, len);
8778 + n = net_write(fd, pri->obuf, actual);
8779 + if(n < 0) return(n);
8783 +static int slip_set_mtu(int mtu, void *data)
8788 +static void slip_add_addr(unsigned char *addr, unsigned char *netmask,
8791 + struct slip_data *pri = data;
8793 + if(pri->slave < 0) return;
8794 + open_addr(addr, netmask, pri->name);
8797 +static void slip_del_addr(unsigned char *addr, unsigned char *netmask,
8800 + struct slip_data *pri = data;
8802 + if(pri->slave < 0) return;
8803 + close_addr(addr, netmask, pri->name);
8806 +struct net_user_info slip_user_info = {
8807 + .init = slip_user_init,
8808 + .open = slip_open,
8809 + .close = slip_close,
8811 + .set_mtu = slip_set_mtu,
8812 + .add_address = slip_add_addr,
8813 + .delete_address = slip_del_addr,
8814 + .max_packet = BUF_SIZE
8818 + * Overrides for Emacs so that we follow Linus's tabbing style.
8819 + * Emacs will notice this stuff at the end of the file and automatically
8820 + * adjust the settings for this buffer only. This must remain at the end
8822 + * ---------------------------------------------------------------------------
8823 + * Local variables:
8824 + * c-file-style: "linux"
8827 diff -Naur -X ../exclude-files orig/arch/um/drivers/slirp.h um/arch/um/drivers/slirp.h
8828 --- orig/arch/um/drivers/slirp.h 1969-12-31 19:00:00.000000000 -0500
8829 +++ um/arch/um/drivers/slirp.h 2003-10-21 03:26:06.000000000 -0400
8831 +#ifndef __UM_SLIRP_H
8832 +#define __UM_SLIRP_H
8834 +#define BUF_SIZE 1500
8835 + /* two bytes each for a (pathological) max packet of escaped chars + *
8836 + * terminating END char + initial END char */
8837 +#define ENC_BUF_SIZE (2 * BUF_SIZE + 2)
8839 +#define SLIRP_MAX_ARGS 100
8841 + * XXX this next definition is here because I don't understand why this
8842 + * initializer doesn't work in slirp_kern.c:
8844 + * argv : { init->argv[ 0 ... SLIRP_MAX_ARGS-1 ] },
8846 + * or why I can't typecast like this:
8848 + * argv : (char* [SLIRP_MAX_ARGS])(init->argv),
8850 +struct arg_list_dummy_wrapper { char *argv[SLIRP_MAX_ARGS]; };
8852 +struct slirp_data {
8854 + struct arg_list_dummy_wrapper argw;
8857 + char ibuf[ENC_BUF_SIZE];
8858 + char obuf[ENC_BUF_SIZE];
8859 + int more; /* more data: do not read fd until ibuf has been drained */
8864 +extern struct net_user_info slirp_user_info;
8866 +extern int set_umn_addr(int fd, char *addr, char *ptp_addr);
8867 +extern int slirp_user_read(int fd, void *buf, int len, struct slirp_data *pri);
8868 +extern int slirp_user_write(int fd, void *buf, int len, struct slirp_data *pri);
8873 + * Overrides for Emacs so that we follow Linus's tabbing style.
8874 + * Emacs will notice this stuff at the end of the file and automatically
8875 + * adjust the settings for this buffer only. This must remain at the end
8877 + * ---------------------------------------------------------------------------
8878 + * Local variables:
8879 + * c-file-style: "linux"
8882 diff -Naur -X ../exclude-files orig/arch/um/drivers/slirp_kern.c um/arch/um/drivers/slirp_kern.c
8883 --- orig/arch/um/drivers/slirp_kern.c 1969-12-31 19:00:00.000000000 -0500
8884 +++ um/arch/um/drivers/slirp_kern.c 2003-10-21 03:26:06.000000000 -0400
8886 +#include "linux/kernel.h"
8887 +#include "linux/stddef.h"
8888 +#include "linux/init.h"
8889 +#include "linux/netdevice.h"
8890 +#include "linux/if_arp.h"
8891 +#include "net_kern.h"
8892 +#include "net_user.h"
8896 +struct slirp_init {
8897 + struct arg_list_dummy_wrapper argw; /* XXX should be simpler... */
8900 +void slirp_init(struct net_device *dev, void *data)
8902 + struct uml_net_private *private;
8903 + struct slirp_data *spri;
8904 + struct slirp_init *init = data;
8907 + private = dev->priv;
8908 + spri = (struct slirp_data *) private->user;
8909 + *spri = ((struct slirp_data)
8910 + { .argw = init->argw,
8920 + dev->hard_header_len = 0;
8921 + dev->addr_len = 4;
8922 + dev->type = ARPHRD_ETHER;
8923 + dev->tx_queue_len = 256;
8924 + dev->flags = IFF_NOARP;
8925 + printk("SLIRP backend - command line:");
8926 + for(i=0;spri->argw.argv[i]!=NULL;i++) {
8927 + printk(" '%s'",spri->argw.argv[i]);
8932 +static unsigned short slirp_protocol(struct sk_buff *skbuff)
8934 + return(htons(ETH_P_IP));
8937 +static int slirp_read(int fd, struct sk_buff **skb,
8938 + struct uml_net_private *lp)
8940 + return(slirp_user_read(fd, (*skb)->mac.raw, (*skb)->dev->mtu,
8941 + (struct slirp_data *) &lp->user));
8944 +static int slirp_write(int fd, struct sk_buff **skb,
8945 + struct uml_net_private *lp)
8947 + return(slirp_user_write(fd, (*skb)->data, (*skb)->len,
8948 + (struct slirp_data *) &lp->user));
8951 +struct net_kern_info slirp_kern_info = {
8952 + .init = slirp_init,
8953 + .protocol = slirp_protocol,
8954 + .read = slirp_read,
8955 + .write = slirp_write,
8958 +static int slirp_setup(char *str, char **mac_out, void *data)
8960 + struct slirp_init *init = data;
8963 + *init = ((struct slirp_init)
8964 + { argw : { { "slirp", NULL } } });
8966 + str = split_if_spec(str, mac_out, NULL);
8968 + if(str == NULL) { /* no command line given after MAC addr */
8973 + if(i>=SLIRP_MAX_ARGS-1) {
8974 + printk("slirp_setup: truncating slirp arguments\n");
8977 + init->argw.argv[i++] = str;
8978 + while(*str && *str!=',') {
8979 + if(*str=='_') *str=' ';
8986 + init->argw.argv[i]=NULL;
8990 +static struct transport slirp_transport = {
8991 + .list = LIST_HEAD_INIT(slirp_transport.list),
8993 + .setup = slirp_setup,
8994 + .user = &slirp_user_info,
8995 + .kern = &slirp_kern_info,
8996 + .private_size = sizeof(struct slirp_data),
8997 + .setup_size = sizeof(struct slirp_init),
9000 +static int register_slirp(void)
9002 + register_transport(&slirp_transport);
9006 +__initcall(register_slirp);
9009 + * Overrides for Emacs so that we follow Linus's tabbing style.
9010 + * Emacs will notice this stuff at the end of the file and automatically
9011 + * adjust the settings for this buffer only. This must remain at the end
9013 + * ---------------------------------------------------------------------------
9014 + * Local variables:
9015 + * c-file-style: "linux"
9018 diff -Naur -X ../exclude-files orig/arch/um/drivers/slirp_user.c um/arch/um/drivers/slirp_user.c
9019 --- orig/arch/um/drivers/slirp_user.c 1969-12-31 19:00:00.000000000 -0500
9020 +++ um/arch/um/drivers/slirp_user.c 2003-10-21 03:26:06.000000000 -0400
9023 +#include <stdlib.h>
9024 +#include <unistd.h>
9025 +#include <stddef.h>
9027 +#include <string.h>
9028 +#include <sys/errno.h>
9029 +#include <sys/wait.h>
9030 +#include <sys/signal.h>
9031 +#include "user_util.h"
9032 +#include "kern_util.h"
9034 +#include "net_user.h"
9036 +#include "slip_proto.h"
9037 +#include "helper.h"
9040 +void slirp_user_init(void *data, void *dev)
9042 + struct slirp_data *pri = data;
9047 +struct slirp_pre_exec_data {
9052 +static void slirp_pre_exec(void *arg)
9054 + struct slirp_pre_exec_data *data = arg;
9056 + if(data->stdin != -1) dup2(data->stdin, 0);
9057 + if(data->stdout != -1) dup2(data->stdout, 1);
9060 +static int slirp_tramp(char **argv, int fd)
9062 + struct slirp_pre_exec_data pe_data;
9065 + pe_data.stdin = fd;
9066 + pe_data.stdout = fd;
9067 + pid = run_helper(slirp_pre_exec, &pe_data, argv, NULL);
9072 +/* XXX This is just a trivial wrapper around os_pipe */
9073 +static int slirp_datachan(int *mfd, int *sfd)
9077 + err = os_pipe(fds, 1, 1);
9079 + printk("slirp_datachan: Failed to open pipe, err = %d\n", -err);
9088 +static int slirp_open(void *data)
9090 + struct slirp_data *pri = data;
9091 + int sfd, mfd, pid, err;
9093 + err = slirp_datachan(&mfd, &sfd);
9097 + pid = slirp_tramp(pri->argw.argv, sfd);
9100 + printk("slirp_tramp failed - errno = %d\n", -pid);
9101 + os_close_file(sfd);
9102 + os_close_file(mfd);
9115 +static void slirp_close(int fd, void *data)
9117 + struct slirp_data *pri = data;
9120 + os_close_file(fd);
9121 + os_close_file(pri->slave);
9126 + printk("slirp_close: no child process to shut down\n");
9131 + if(kill(pri->pid, SIGHUP)<0) {
9132 + printk("slirp_close: sending hangup to %d failed (%d)\n",
9137 + err = waitpid(pri->pid, &status, WNOHANG);
9139 + printk("slirp_close: waitpid returned %d\n", errno);
9144 + printk("slirp_close: process %d has not exited\n");
9151 +int slirp_user_read(int fd, void *buf, int len, struct slirp_data *pri)
9153 + int i, n, size, start;
9157 + while(i < pri->more) {
9158 + size = slip_unesc(pri->ibuf[i++],
9159 + pri->ibuf,&pri->pos,&pri->esc);
9161 + memcpy(buf, pri->ibuf, size);
9162 + memmove(pri->ibuf, &pri->ibuf[i], pri->more-i);
9163 + pri->more=pri->more-i;
9170 + n = net_read(fd, &pri->ibuf[pri->pos], sizeof(pri->ibuf) - pri->pos);
9171 + if(n <= 0) return(n);
9174 + for(i = 0; i < n; i++){
9175 + size = slip_unesc(pri->ibuf[start + i],
9176 + pri->ibuf,&pri->pos,&pri->esc);
9178 + memcpy(buf, pri->ibuf, size);
9179 + memmove(pri->ibuf, &pri->ibuf[start+i+1], n-(i+1));
9180 + pri->more=n-(i+1);
9187 +int slirp_user_write(int fd, void *buf, int len, struct slirp_data *pri)
9191 + actual = slip_esc(buf, pri->obuf, len);
9192 + n = net_write(fd, pri->obuf, actual);
9193 + if(n < 0) return(n);
9197 +static int slirp_set_mtu(int mtu, void *data)
9202 +struct net_user_info slirp_user_info = {
9203 + .init = slirp_user_init,
9204 + .open = slirp_open,
9205 + .close = slirp_close,
9207 + .set_mtu = slirp_set_mtu,
9208 + .add_address = NULL,
9209 + .delete_address = NULL,
9210 + .max_packet = BUF_SIZE
9214 + * Overrides for Emacs so that we follow Linus's tabbing style.
9215 + * Emacs will notice this stuff at the end of the file and automatically
9216 + * adjust the settings for this buffer only. This must remain at the end
9218 + * ---------------------------------------------------------------------------
9219 + * Local variables:
9220 + * c-file-style: "linux"
9223 diff -Naur -X ../exclude-files orig/arch/um/drivers/ssl.c um/arch/um/drivers/ssl.c
9224 --- orig/arch/um/drivers/ssl.c 1969-12-31 19:00:00.000000000 -0500
9225 +++ um/arch/um/drivers/ssl.c 2004-01-10 06:20:17.000000000 -0500
9228 + * Copyright (C) 2000, 2002 Jeff Dike (jdike@karaya.com)
9229 + * Licensed under the GPL
9232 +#include "linux/config.h"
9233 +#include "linux/fs.h"
9234 +#include "linux/tty.h"
9235 +#include "linux/tty_driver.h"
9236 +#include "linux/major.h"
9237 +#include "linux/mm.h"
9238 +#include "linux/init.h"
9239 +#include "linux/console.h"
9240 +#include "asm/termbits.h"
9241 +#include "asm/irq.h"
9244 +#include "chan_kern.h"
9245 +#include "user_util.h"
9246 +#include "kern_util.h"
9249 +#include "irq_user.h"
9250 +#include "mconsole_kern.h"
9251 +#include "2_5compat.h"
9253 +static int ssl_version = 1;
9255 +/* Referenced only by tty_driver below - presumably it's locked correctly
9256 + * by the tty driver.
9258 +static int ssl_refcount = 0;
9260 +static struct tty_driver ssl_driver;
9262 +#define NR_PORTS 64
9264 +void ssl_announce(char *dev_name, int dev)
9266 + printk(KERN_INFO "Serial line %d assigned device '%s'\n", dev,
9270 +static struct chan_opts opts = {
9271 + .announce = ssl_announce,
9272 + .xterm_title = "Serial Line #%d",
9278 +static int ssl_config(char *str);
9279 +static int ssl_get_config(char *dev, char *str, int size, char **error_out);
9280 +static int ssl_remove(char *str);
9282 +static struct line_driver driver = {
9283 + .name = "UML serial line",
9284 + .devfs_name = "tts/%d",
9285 + .major = TTY_MAJOR,
9286 + .minor_start = 64,
9287 + .type = TTY_DRIVER_TYPE_SERIAL,
9289 + .read_irq = SSL_IRQ,
9290 + .read_irq_name = "ssl",
9291 + .write_irq = SSL_WRITE_IRQ,
9292 + .write_irq_name = "ssl-write",
9293 + .symlink_from = "serial",
9294 + .symlink_to = "tts",
9297 + .config = ssl_config,
9298 + .get_config = ssl_get_config,
9299 + .remove = ssl_remove,
9303 +/* The array is initialized by line_init, which is an initcall. The
9304 + * individual elements are protected by individual semaphores.
9306 +static struct line serial_lines[NR_PORTS] =
9307 + { [0 ... NR_PORTS - 1] = LINE_INIT(CONFIG_SSL_CHAN, &driver) };
9309 +static struct lines lines = LINES_INIT(NR_PORTS);
9311 +static int ssl_config(char *str)
9313 + return(line_config(serial_lines,
9314 + sizeof(serial_lines)/sizeof(serial_lines[0]), str));
9317 +static int ssl_get_config(char *dev, char *str, int size, char **error_out)
9319 + return(line_get_config(dev, serial_lines,
9320 + sizeof(serial_lines)/sizeof(serial_lines[0]),
9321 + str, size, error_out));
9324 +static int ssl_remove(char *str)
9326 + return(line_remove(serial_lines,
9327 + sizeof(serial_lines)/sizeof(serial_lines[0]), str));
9330 +int ssl_open(struct tty_struct *tty, struct file *filp)
9332 + return(line_open(serial_lines, tty, &opts));
9335 +static void ssl_close(struct tty_struct *tty, struct file * filp)
9337 + line_close(serial_lines, tty);
9340 +static int ssl_write(struct tty_struct * tty, int from_user,
9341 + const unsigned char *buf, int count)
9343 + return(line_write(serial_lines, tty, from_user, buf, count));
9346 +static void ssl_put_char(struct tty_struct *tty, unsigned char ch)
9348 + line_write(serial_lines, tty, 0, &ch, sizeof(ch));
9351 +static void ssl_flush_chars(struct tty_struct *tty)
9356 +static int ssl_chars_in_buffer(struct tty_struct *tty)
9361 +static void ssl_flush_buffer(struct tty_struct *tty)
9366 +static int ssl_ioctl(struct tty_struct *tty, struct file * file,
9367 + unsigned int cmd, unsigned long arg)
9383 + ret = -ENOIOCTLCMD;
9387 + "Unimplemented ioctl in ssl_ioctl : 0x%x\n", cmd);
9388 + ret = -ENOIOCTLCMD;
9394 +static void ssl_throttle(struct tty_struct * tty)
9396 + printk(KERN_ERR "Someone should implement ssl_throttle\n");
9399 +static void ssl_unthrottle(struct tty_struct * tty)
9401 + printk(KERN_ERR "Someone should implement ssl_unthrottle\n");
9404 +static void ssl_set_termios(struct tty_struct *tty,
9405 + struct termios *old_termios)
9409 +static void ssl_stop(struct tty_struct *tty)
9411 + printk(KERN_ERR "Someone should implement ssl_stop\n");
9414 +static void ssl_start(struct tty_struct *tty)
9416 + printk(KERN_ERR "Someone should implement ssl_start\n");
9419 +void ssl_hangup(struct tty_struct *tty)
9423 +static struct tty_driver ssl_driver = {
9424 + .refcount = &ssl_refcount,
9426 + .close = ssl_close,
9427 + .write = ssl_write,
9428 + .put_char = ssl_put_char,
9429 + .flush_chars = ssl_flush_chars,
9430 + .chars_in_buffer = ssl_chars_in_buffer,
9431 + .flush_buffer = ssl_flush_buffer,
9432 + .ioctl = ssl_ioctl,
9433 + .throttle = ssl_throttle,
9434 + .unthrottle = ssl_unthrottle,
9435 + .set_termios = ssl_set_termios,
9437 + .start = ssl_start,
9438 + .hangup = ssl_hangup
9441 +/* Changed by ssl_init and referenced by ssl_exit, which are both serialized
9442 + * by being an initcall and exitcall, respectively.
9444 +static int ssl_init_done = 0;
9446 +static void ssl_console_write(struct console *c, const char *string,
9449 + struct line *line = &serial_lines[c->index];
9452 + console_write_chan(&line->chan_list, string, len);
9457 +static kdev_t ssl_console_device(struct console *c)
9459 + return mk_kdev(TTY_MAJOR, c->index);
9462 +static int ssl_console_setup(struct console *co, char *options)
9467 +static struct console ssl_cons = {
9469 + write: ssl_console_write,
9470 + device: ssl_console_device,
9471 + setup: ssl_console_setup,
9472 + flags: CON_PRINTBUFFER,
9480 + printk(KERN_INFO "Initializing software serial port version %d\n",
9483 + line_register_devfs(&lines, &driver, &ssl_driver, serial_lines,
9484 + sizeof(serial_lines)/sizeof(serial_lines[0]));
9486 + lines_init(serial_lines, sizeof(serial_lines)/sizeof(serial_lines[0]));
9488 + new_title = add_xterm_umid(opts.xterm_title);
9489 + if(new_title != NULL) opts.xterm_title = new_title;
9491 + register_console(&ssl_cons);
9492 + ssl_init_done = 1;
9496 +__initcall(ssl_init);
9498 +static int ssl_chan_setup(char *str)
9500 + return(line_setup(serial_lines,
9501 + sizeof(serial_lines)/sizeof(serial_lines[0]),
9505 +__setup("ssl", ssl_chan_setup);
9506 +__channel_help(ssl_chan_setup, "ssl");
9508 +static void ssl_exit(void)
9510 + if(!ssl_init_done) return;
9511 + close_lines(serial_lines,
9512 + sizeof(serial_lines)/sizeof(serial_lines[0]));
9515 +__uml_exitcall(ssl_exit);
9518 + * Overrides for Emacs so that we follow Linus's tabbing style.
9519 + * Emacs will notice this stuff at the end of the file and automatically
9520 + * adjust the settings for this buffer only. This must remain at the end
9522 + * ---------------------------------------------------------------------------
9523 + * Local variables:
9524 + * c-file-style: "linux"
9527 diff -Naur -X ../exclude-files orig/arch/um/drivers/ssl.h um/arch/um/drivers/ssl.h
9528 --- orig/arch/um/drivers/ssl.h 1969-12-31 19:00:00.000000000 -0500
9529 +++ um/arch/um/drivers/ssl.h 2003-10-21 03:26:06.000000000 -0400
9532 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
9533 + * Licensed under the GPL
9539 +extern int ssl_read(int fd, int line);
9540 +extern void ssl_receive_char(int line, char ch);
9545 + * Overrides for Emacs so that we follow Linus's tabbing style.
9546 + * Emacs will notice this stuff at the end of the file and automatically
9547 + * adjust the settings for this buffer only. This must remain at the end
9549 + * ---------------------------------------------------------------------------
9550 + * Local variables:
9551 + * c-file-style: "linux"
9554 diff -Naur -X ../exclude-files orig/arch/um/drivers/stdio_console.c um/arch/um/drivers/stdio_console.c
9555 --- orig/arch/um/drivers/stdio_console.c 1969-12-31 19:00:00.000000000 -0500
9556 +++ um/arch/um/drivers/stdio_console.c 2003-11-07 03:03:03.000000000 -0500
9559 + * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
9560 + * Licensed under the GPL
9563 +#include "linux/config.h"
9564 +#include "linux/posix_types.h"
9565 +#include "linux/tty.h"
9566 +#include "linux/tty_flip.h"
9567 +#include "linux/types.h"
9568 +#include "linux/major.h"
9569 +#include "linux/kdev_t.h"
9570 +#include "linux/console.h"
9571 +#include "linux/string.h"
9572 +#include "linux/sched.h"
9573 +#include "linux/list.h"
9574 +#include "linux/init.h"
9575 +#include "linux/interrupt.h"
9576 +#include "linux/slab.h"
9577 +#include "asm/current.h"
9578 +#include "asm/softirq.h"
9579 +#include "asm/hardirq.h"
9580 +#include "asm/irq.h"
9581 +#include "stdio_console.h"
9583 +#include "chan_kern.h"
9584 +#include "user_util.h"
9585 +#include "kern_util.h"
9586 +#include "irq_user.h"
9587 +#include "mconsole_kern.h"
9589 +#include "2_5compat.h"
9591 +#define MAX_TTYS (8)
9593 +/* Referenced only by tty_driver below - presumably it's locked correctly
9594 + * by the tty driver.
9597 +static struct tty_driver console_driver;
9599 +static int console_refcount = 0;
9601 +static struct chan_ops init_console_ops = {
9602 + .type = "you shouldn't see this",
9608 + .console_write = generic_write,
9609 + .window_size = NULL,
9614 +static struct chan init_console_chan = {
9621 + .pri = INIT_STATIC,
9622 + .ops = &init_console_ops,
9626 +void stdio_announce(char *dev_name, int dev)
9628 + printk(KERN_INFO "Virtual console %d assigned device '%s'\n", dev,
9632 +static struct chan_opts opts = {
9633 + .announce = stdio_announce,
9634 + .xterm_title = "Virtual Console #%d",
9640 +static int con_config(char *str);
9641 +static int con_get_config(char *dev, char *str, int size, char **error_out);
9642 +static int con_remove(char *str);
9644 +static struct line_driver driver = {
9645 + .name = "UML console",
9646 + .devfs_name = "vc/%d",
9647 + .major = TTY_MAJOR,
9649 + .type = TTY_DRIVER_TYPE_CONSOLE,
9650 + .subtype = SYSTEM_TYPE_CONSOLE,
9651 + .read_irq = CONSOLE_IRQ,
9652 + .read_irq_name = "console",
9653 + .write_irq = CONSOLE_WRITE_IRQ,
9654 + .write_irq_name = "console-write",
9655 + .symlink_from = "ttys",
9656 + .symlink_to = "vc",
9659 + .config = con_config,
9660 + .get_config = con_get_config,
9661 + .remove = con_remove,
9665 +static struct lines console_lines = LINES_INIT(MAX_TTYS);
9667 +/* The array is initialized by line_init, which is an initcall. The
9668 + * individual elements are protected by individual semaphores.
9670 +struct line vts[MAX_TTYS] = { LINE_INIT(CONFIG_CON_ZERO_CHAN, &driver),
9671 + [ 1 ... MAX_TTYS - 1 ] =
9672 + LINE_INIT(CONFIG_CON_CHAN, &driver) };
9674 +static int con_config(char *str)
9676 + return(line_config(vts, sizeof(vts)/sizeof(vts[0]), str));
9679 +static int con_get_config(char *dev, char *str, int size, char **error_out)
9681 + return(line_get_config(dev, vts, sizeof(vts)/sizeof(vts[0]), str,
9682 + size, error_out));
9685 +static int con_remove(char *str)
9687 + return(line_remove(vts, sizeof(vts)/sizeof(vts[0]), str));
9690 +static int open_console(struct tty_struct *tty)
9692 + return(line_open(vts, tty, &opts));
9695 +static int con_open(struct tty_struct *tty, struct file *filp)
9697 + return(open_console(tty));
9700 +static void con_close(struct tty_struct *tty, struct file *filp)
9702 + line_close(vts, tty);
9705 +static int con_write(struct tty_struct *tty, int from_user,
9706 + const unsigned char *buf, int count)
9708 + return(line_write(vts, tty, from_user, buf, count));
9711 +static void set_termios(struct tty_struct *tty, struct termios * old)
9715 +static int chars_in_buffer(struct tty_struct *tty)
9720 +static int con_init_done = 0;
9722 +int stdio_init(void)
9726 + printk(KERN_INFO "Initializing stdio console driver\n");
9728 + line_register_devfs(&console_lines, &driver, &console_driver, vts,
9729 + sizeof(vts)/sizeof(vts[0]));
9731 + lines_init(vts, sizeof(vts)/sizeof(vts[0]));
9733 + new_title = add_xterm_umid(opts.xterm_title);
9734 + if(new_title != NULL) opts.xterm_title = new_title;
9736 + open_console(NULL);
9737 + con_init_done = 1;
9741 +__initcall(stdio_init);
9743 +static void console_write(struct console *console, const char *string,
9746 + struct line *line = &vts[console->index];
9750 + console_write_chan(&line->chan_list, string, len);
9755 +static struct tty_driver console_driver = {
9756 + .refcount = &console_refcount,
9758 + .close = con_close,
9759 + .write = con_write,
9760 + .chars_in_buffer = chars_in_buffer,
9761 + .set_termios = set_termios
9764 +static kdev_t console_device(struct console *c)
9766 + return mk_kdev(TTY_MAJOR, c->index);
9769 +static int console_setup(struct console *co, char *options)
9774 +static struct console stdiocons = {
9776 + write: console_write,
9777 + device: console_device,
9778 + setup: console_setup,
9779 + flags: CON_PRINTBUFFER,
9783 +void stdio_console_init(void)
9785 + INIT_LIST_HEAD(&vts[0].chan_list);
9786 + list_add(&init_console_chan.list, &vts[0].chan_list);
9787 + register_console(&stdiocons);
9790 +static int console_chan_setup(char *str)
9792 + return(line_setup(vts, sizeof(vts)/sizeof(vts[0]), str, 1));
9795 +__setup("con", console_chan_setup);
9796 +__channel_help(console_chan_setup, "con");
9798 +static void console_exit(void)
9800 + if(!con_init_done) return;
9801 + close_lines(vts, sizeof(vts)/sizeof(vts[0]));
9804 +__uml_exitcall(console_exit);
9807 + * Overrides for Emacs so that we follow Linus's tabbing style.
9808 + * Emacs will notice this stuff at the end of the file and automatically
9809 + * adjust the settings for this buffer only. This must remain at the end
9811 + * ---------------------------------------------------------------------------
9812 + * Local variables:
9813 + * c-file-style: "linux"
9816 diff -Naur -X ../exclude-files orig/arch/um/drivers/stdio_console.h um/arch/um/drivers/stdio_console.h
9817 --- orig/arch/um/drivers/stdio_console.h 1969-12-31 19:00:00.000000000 -0500
9818 +++ um/arch/um/drivers/stdio_console.h 2003-10-21 03:26:06.000000000 -0400
9821 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
9822 + * Licensed under the GPL
9825 +#ifndef __STDIO_CONSOLE_H
9826 +#define __STDIO_CONSOLE_H
9828 +extern void save_console_flags(void);
9832 + * Overrides for Emacs so that we follow Linus's tabbing style.
9833 + * Emacs will notice this stuff at the end of the file and automatically
9834 + * adjust the settings for this buffer only. This must remain at the end
9836 + * ---------------------------------------------------------------------------
9837 + * Local variables:
9838 + * c-file-style: "linux"
9841 diff -Naur -X ../exclude-files orig/arch/um/drivers/tty.c um/arch/um/drivers/tty.c
9842 --- orig/arch/um/drivers/tty.c 1969-12-31 19:00:00.000000000 -0500
9843 +++ um/arch/um/drivers/tty.c 2003-10-21 03:26:06.000000000 -0400
9846 + * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
9847 + * Licensed under the GPL
9851 +#include <termios.h>
9853 +#include <unistd.h>
9854 +#include "chan_user.h"
9855 +#include "user_util.h"
9862 + struct termios tt;
9865 +void *tty_chan_init(char *str, int device, struct chan_opts *opts)
9867 + struct tty_chan *data;
9870 + printk("tty_init : channel type 'tty' must specify "
9876 + data = um_kmalloc(sizeof(*data));
9879 + *data = ((struct tty_chan) { .dev = str,
9880 + .raw = opts->raw });
9885 +int tty_open(int input, int output, int primary, void *d, char **dev_out)
9887 + struct tty_chan *data = d;
9890 + fd = os_open_file(data->dev, of_set_rw(OPENFLAGS(), input, output), 0);
9891 + if(fd < 0) return(fd);
9893 + tcgetattr(fd, &data->tt);
9897 + *dev_out = data->dev;
9901 +int tty_console_write(int fd, const char *buf, int n, void *d)
9903 + struct tty_chan *data = d;
9905 + return(generic_console_write(fd, buf, n, &data->tt));
9908 +struct chan_ops tty_ops = {
9910 + .init = tty_chan_init,
9912 + .close = generic_close,
9913 + .read = generic_read,
9914 + .write = generic_write,
9915 + .console_write = tty_console_write,
9916 + .window_size = generic_window_size,
9917 + .free = generic_free,
9922 + * Overrides for Emacs so that we follow Linus's tabbing style.
9923 + * Emacs will notice this stuff at the end of the file and automatically
9924 + * adjust the settings for this buffer only. This must remain at the end
9926 + * ---------------------------------------------------------------------------
9927 + * Local variables:
9928 + * c-file-style: "linux"
9931 diff -Naur -X ../exclude-files orig/arch/um/drivers/ubd_kern.c um/arch/um/drivers/ubd_kern.c
9932 --- orig/arch/um/drivers/ubd_kern.c 1969-12-31 19:00:00.000000000 -0500
9933 +++ um/arch/um/drivers/ubd_kern.c 2004-01-21 01:28:43.000000000 -0500
9936 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
9937 + * Licensed under the GPL
9940 +/* 2001-09-28...2002-04-17
9941 + * Partition stuff by James_McMechan@hotmail.com
9942 + * old style ubd by setting UBD_SHIFT to 0
9945 +#define MAJOR_NR UBD_MAJOR
9946 +#define UBD_SHIFT 4
9948 +#include "linux/config.h"
9949 +#include "linux/blk.h"
9950 +#include "linux/blkdev.h"
9951 +#include "linux/hdreg.h"
9952 +#include "linux/init.h"
9953 +#include "linux/devfs_fs_kernel.h"
9954 +#include "linux/cdrom.h"
9955 +#include "linux/proc_fs.h"
9956 +#include "linux/ctype.h"
9957 +#include "linux/capability.h"
9958 +#include "linux/mm.h"
9959 +#include "linux/vmalloc.h"
9960 +#include "linux/blkpg.h"
9961 +#include "linux/genhd.h"
9962 +#include "linux/spinlock.h"
9963 +#include "asm/segment.h"
9964 +#include "asm/uaccess.h"
9965 +#include "asm/irq.h"
9966 +#include "asm/types.h"
9967 +#include "user_util.h"
9968 +#include "mem_user.h"
9969 +#include "kern_util.h"
9971 +#include "mconsole_kern.h"
9973 +#include "irq_user.h"
9974 +#include "irq_kern.h"
9975 +#include "ubd_user.h"
9976 +#include "2_5compat.h"
9979 +#include "mem_kern.h"
9981 +static int ubd_open(struct inode * inode, struct file * filp);
9982 +static int ubd_release(struct inode * inode, struct file * file);
9983 +static int ubd_ioctl(struct inode * inode, struct file * file,
9984 + unsigned int cmd, unsigned long arg);
9985 +static int ubd_revalidate(kdev_t rdev);
9986 +static int ubd_revalidate1(kdev_t rdev);
9988 +#define MAX_DEV (8)
9989 +#define MAX_MINOR (MAX_DEV << UBD_SHIFT)
9991 +/* Changed in early boot */
9992 +static int ubd_do_mmap = 0;
9993 +#define UBD_MMAP_BLOCK_SIZE PAGE_SIZE
9995 +/* Not modified by this driver */
9996 +static int blk_sizes[MAX_MINOR] = { [ 0 ... MAX_MINOR - 1 ] = BLOCK_SIZE };
9997 +static int hardsect_sizes[MAX_MINOR] = { [ 0 ... MAX_MINOR - 1 ] = 512 };
9999 +/* Protected by ubd_lock */
10000 +static int sizes[MAX_MINOR] = { [ 0 ... MAX_MINOR - 1 ] = 0 };
10002 +static struct block_device_operations ubd_blops = {
10003 + .open = ubd_open,
10004 + .release = ubd_release,
10005 + .ioctl = ubd_ioctl,
10006 + .revalidate = ubd_revalidate,
10009 +/* Protected by ubd_lock, except in prepare_request and ubd_ioctl because
10010 + * the block layer should ensure that the device is idle before closing it.
10012 +static struct hd_struct ubd_part[MAX_MINOR] =
10013 + { [ 0 ... MAX_MINOR - 1 ] = { 0, 0, 0 } };
10015 +/* Protected by io_request_lock */
10016 +static request_queue_t *ubd_queue;
10018 +/* Protected by ubd_lock */
10019 +static int fake_major = MAJOR_NR;
10021 +static spinlock_t ubd_lock = SPIN_LOCK_UNLOCKED;
10023 +#define INIT_GENDISK(maj, name, parts, shift, bsizes, max, blops) \
10026 + .major_name = name, \
10027 + .minor_shift = shift, \
10028 + .max_p = 1 << shift, \
10030 + .sizes = bsizes, \
10031 + .nr_real = max, \
10032 + .real_devices = NULL, \
10035 + .de_arr = NULL, \
10039 +static struct gendisk ubd_gendisk = INIT_GENDISK(MAJOR_NR, "ubd", ubd_part,
10040 + UBD_SHIFT, sizes, MAX_DEV,
10042 +static struct gendisk fake_gendisk = INIT_GENDISK(0, "ubd", ubd_part,
10043 + UBD_SHIFT, sizes, MAX_DEV,
10046 +#ifdef CONFIG_BLK_DEV_UBD_SYNC
10047 +#define OPEN_FLAGS ((struct openflags) { .r = 1, .w = 1, .s = 1, .c = 0, \
10050 +#define OPEN_FLAGS ((struct openflags) { .r = 1, .w = 1, .s = 0, .c = 0, \
10054 +/* Not protected - changed only in ubd_setup_common and then only to
10055 + * to enable O_SYNC.
10057 +static struct openflags global_openflags = OPEN_FLAGS;
10062 + unsigned long *bitmap;
10063 + unsigned long bitmap_len;
10064 + int bitmap_offset;
10073 + struct openflags boot_openflags;
10074 + struct openflags openflags;
10075 + devfs_handle_t devfs;
10081 + int nomap_writes;
10086 +#define DEFAULT_COW { \
10089 + .bitmap = NULL, \
10090 + .bitmap_offset = 0, \
10091 + .data_offset = 0, \
10094 +#define DEFAULT_UBD { \
10099 + .boot_openflags = OPEN_FLAGS, \
10100 + .openflags = OPEN_FLAGS, \
10103 + .cow = DEFAULT_COW, \
10104 + .map_writes = 0, \
10105 + .map_reads = 0, \
10106 + .nomap_writes = 0, \
10107 + .nomap_reads = 0, \
10108 + .write_maps = 0, \
10111 +struct ubd ubd_dev[MAX_DEV] = { [ 0 ... MAX_DEV - 1 ] = DEFAULT_UBD };
10113 +static int ubd0_init(void)
10115 + struct ubd *dev = &ubd_dev[0];
10117 + if(dev->file == NULL)
10118 + dev->file = "root_fs";
10122 +__initcall(ubd0_init);
10124 +/* Only changed by fake_ide_setup which is a setup */
10125 +static int fake_ide = 0;
10126 +static struct proc_dir_entry *proc_ide_root = NULL;
10127 +static struct proc_dir_entry *proc_ide = NULL;
10129 +static void make_proc_ide(void)
10131 + proc_ide_root = proc_mkdir("ide", 0);
10132 + proc_ide = proc_mkdir("ide0", proc_ide_root);
10135 +static int proc_ide_read_media(char *page, char **start, off_t off, int count,
10136 + int *eof, void *data)
10140 + strcpy(page, "disk\n");
10141 + len = strlen("disk\n");
10143 + if (len < count){
10145 + if (len <= 0) return 0;
10147 + else len = count;
10148 + *start = page + off;
10152 +static void make_ide_entries(char *dev_name)
10154 + struct proc_dir_entry *dir, *ent;
10157 + if(!fake_ide) return;
10159 + /* Without locking this could race if a UML was booted with no
10160 + * disks and then two mconsole requests which add disks came in
10161 + * at the same time.
10163 + spin_lock(&ubd_lock);
10164 + if(proc_ide_root == NULL) make_proc_ide();
10165 + spin_unlock(&ubd_lock);
10167 + dir = proc_mkdir(dev_name, proc_ide);
10170 + ent = create_proc_entry("media", S_IFREG|S_IRUGO, dir);
10173 + ent->data = NULL;
10174 + ent->read_proc = proc_ide_read_media;
10175 + ent->write_proc = NULL;
10176 + sprintf(name,"ide0/%s", dev_name);
10177 + proc_symlink(dev_name, proc_ide_root, name);
10180 +static int fake_ide_setup(char *str)
10186 +__setup("fake_ide", fake_ide_setup);
10188 +__uml_help(fake_ide_setup,
10190 +" Create ide0 entries that map onto ubd devices.\n\n"
10193 +static int parse_unit(char **ptr)
10195 + char *str = *ptr, *end;
10198 + if(isdigit(*str)) {
10199 + n = simple_strtoul(str, &end, 0);
10204 + else if (('a' <= *str) && (*str <= 'h')) {
10212 +static int ubd_setup_common(char *str, int *index_out)
10214 + struct openflags flags = global_openflags;
10216 + char *backing_file;
10219 + if(index_out) *index_out = -1;
10226 + if(!strcmp(str, "mmap")){
10227 + CHOOSE_MODE(printk("mmap not supported by the ubd "
10228 + "driver in tt mode\n"),
10229 + ubd_do_mmap = 1);
10233 + if(!strcmp(str, "sync")){
10234 + global_openflags.s = 1;
10237 + major = simple_strtoul(str, &end, 0);
10238 + if((*end != '\0') || (end == str)){
10240 + "ubd_setup : didn't parse major number\n");
10245 + spin_lock(&ubd_lock);
10246 + if(fake_major != MAJOR_NR){
10247 + printk(KERN_ERR "Can't assign a fake major twice\n");
10251 + fake_gendisk.major = major;
10252 + fake_major = major;
10254 + printk(KERN_INFO "Setting extra ubd major number to %d\n",
10258 + spin_unlock(&ubd_lock);
10262 + n = parse_unit(&str);
10264 + printk(KERN_ERR "ubd_setup : couldn't parse unit number "
10269 + if(n >= MAX_DEV){
10270 + printk(KERN_ERR "ubd_setup : index %d out of range "
10271 + "(%d devices)\n", n, MAX_DEV);
10276 + spin_lock(&ubd_lock);
10278 + dev = &ubd_dev[n];
10279 + if(dev->file != NULL){
10280 + printk(KERN_ERR "ubd_setup : device already configured\n");
10284 + if(index_out) *index_out = n;
10299 + if(*str++ != '='){
10300 + printk(KERN_ERR "ubd_setup : Expected '='\n");
10305 + backing_file = strchr(str, ',');
10306 + if(backing_file){
10308 + printk(KERN_ERR "Can't specify both 'd' and a "
10311 + *backing_file = '\0';
10316 + dev->cow.file = backing_file;
10317 + dev->boot_openflags = flags;
10319 + spin_unlock(&ubd_lock);
10323 +static int ubd_setup(char *str)
10325 + ubd_setup_common(str, NULL);
10329 +__setup("ubd", ubd_setup);
10330 +__uml_help(ubd_setup,
10331 +"ubd<n>=<filename>\n"
10332 +" This is used to associate a device with a file in the underlying\n"
10333 +" filesystem. Usually, there is a filesystem in the file, but \n"
10334 +" that's not required. Swap devices containing swap files can be\n"
10335 +" specified like this. Also, a file which doesn't contain a\n"
10336 +" filesystem can have its contents read in the virtual \n"
10337 +" machine by running dd on the device. n must be in the range\n"
10338 +" 0 to 7. Appending an 'r' to the number will cause that device\n"
10339 +" to be mounted read-only. For example ubd1r=./ext_fs. Appending\n"
10340 +" an 's' (has to be _after_ 'r', if there is one) will cause data\n"
10341 +" to be written to disk on the host immediately.\n\n"
10344 +static int fakehd(char *str)
10347 + "fakehd : Changing ubd_gendisk.major_name to \"hd\".\n");
10348 + ubd_gendisk.major_name = "hd";
10352 +__setup("fakehd", fakehd);
10353 +__uml_help(fakehd,
10355 +" Change the ubd device name to \"hd\".\n\n"
10358 +static void do_ubd_request(request_queue_t * q);
10360 +/* Only changed by ubd_init, which is an initcall. */
10361 +int thread_fd = -1;
10363 +/* Changed by ubd_handler, which is serialized because interrupts only
10364 + * happen on CPU 0.
10366 +int intr_count = 0;
10368 +static void ubd_finish(int error)
10376 + nsect = CURRENT->current_nr_sectors;
10377 + CURRENT->sector += nsect;
10378 + CURRENT->buffer += nsect << 9;
10379 + CURRENT->errors = 0;
10380 + CURRENT->nr_sectors -= nsect;
10381 + CURRENT->current_nr_sectors = 0;
10385 +static void ubd_handler(void)
10387 + struct io_thread_req req;
10390 + DEVICE_INTR = NULL;
10392 + n = read_ubd_fs(thread_fd, &req, sizeof(req));
10393 + if(n != sizeof(req)){
10394 + printk(KERN_ERR "Pid %d - spurious interrupt in ubd_handler, "
10395 + "err = %d\n", os_getpid(), -n);
10396 + spin_lock(&io_request_lock);
10398 + spin_unlock(&io_request_lock);
10402 + if((req.op != UBD_MMAP) &&
10403 + ((req.offset != ((__u64) (CURRENT->sector)) << 9) ||
10404 + (req.length != (CURRENT->current_nr_sectors) << 9)))
10405 + panic("I/O op mismatch");
10407 + if(req.map_fd != -1){
10408 + err = physmem_subst_mapping(req.buffer, req.map_fd,
10409 + req.map_offset, 1);
10411 + printk("ubd_handler - physmem_subst_mapping failed, "
10412 + "err = %d\n", -err);
10415 + spin_lock(&io_request_lock);
10416 + ubd_finish(req.error);
10417 + reactivate_fd(thread_fd, UBD_IRQ);
10418 + do_ubd_request(ubd_queue);
10419 + spin_unlock(&io_request_lock);
10422 +static void ubd_intr(int irq, void *dev, struct pt_regs *unused)
10427 +/* Only changed by ubd_init, which is an initcall. */
10428 +static int io_pid = -1;
10430 +void kill_io_thread(void)
10433 + os_kill_process(io_pid, 1);
10436 +__uml_exitcall(kill_io_thread);
10438 +/* Initialized in an initcall, and unchanged thereafter */
10439 +devfs_handle_t ubd_dir_handle;
10441 +static int ubd_add(int n)
10443 + struct ubd *dev = &ubd_dev[n];
10444 + char name[sizeof("nnnnnn\0")], dev_name[sizeof("ubd0x")];
10445 + int err = -EISDIR;
10447 + if(dev->file == NULL)
10450 + err = ubd_revalidate1(MKDEV(MAJOR_NR, n << UBD_SHIFT));
10454 + if(dev->cow.file == NULL)
10455 + blk_sizes[n] = UBD_MMAP_BLOCK_SIZE;
10457 + sprintf(name, "%d", n);
10458 + dev->devfs = devfs_register(ubd_dir_handle, name, DEVFS_FL_REMOVABLE,
10459 + MAJOR_NR, n << UBD_SHIFT, S_IFBLK |
10460 + S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
10461 + &ubd_blops, NULL);
10463 +#if 0 /* 2.5 ... */
10464 + sprintf(disk->disk_name, "ubd%c", 'a' + unit);
10467 + sprintf(dev_name, "%s%c", ubd_gendisk.major_name,
10470 + make_ide_entries(dev_name);
10477 +static int ubd_config(char *str)
10481 + str = uml_strdup(str);
10483 + printk(KERN_ERR "ubd_config failed to strdup string\n");
10486 + err = ubd_setup_common(str, &n);
10491 + if(n == -1) return(0);
10493 + spin_lock(&ubd_lock);
10494 + err = ubd_add(n);
10496 + ubd_dev[n].file = NULL;
10497 + spin_unlock(&ubd_lock);
10502 +static int ubd_get_config(char *name, char *str, int size, char **error_out)
10508 + n = simple_strtoul(name, &end, 0);
10509 + if((*end != '\0') || (end == name)){
10510 + *error_out = "ubd_get_config : didn't parse device number";
10514 + if((n >= MAX_DEV) || (n < 0)){
10515 + *error_out = "ubd_get_config : device number out of range";
10519 + dev = &ubd_dev[n];
10520 + spin_lock(&ubd_lock);
10522 + if(dev->file == NULL){
10523 + CONFIG_CHUNK(str, size, len, "", 1);
10527 + CONFIG_CHUNK(str, size, len, dev->file, 0);
10529 + if(dev->cow.file != NULL){
10530 + CONFIG_CHUNK(str, size, len, ",", 0);
10531 + CONFIG_CHUNK(str, size, len, dev->cow.file, 1);
10533 + else CONFIG_CHUNK(str, size, len, "", 1);
10536 + spin_unlock(&ubd_lock);
10540 +static int ubd_remove(char *str)
10543 + int n, err = -ENODEV;
10545 + if(isdigit(*str)){
10547 + n = simple_strtoul(str, &end, 0);
10548 + if ((*end != '\0') || (end == str))
10551 + else if (('a' <= *str) && (*str <= 'h'))
10554 + return(err); /* it should be a number 0-7/a-h */
10556 + if((n < 0) || (n >= MAX_DEV))
10559 + dev = &ubd_dev[n];
10561 + spin_lock(&ubd_lock);
10563 + if(dev->file == NULL)
10566 + if(dev->count > 0)
10568 + if(dev->devfs != NULL)
10569 + devfs_unregister(dev->devfs);
10571 + *dev = ((struct ubd) DEFAULT_UBD);
10574 + spin_unlock(&ubd_lock);
10578 +static struct mc_device ubd_mc = {
10580 + .config = ubd_config,
10581 + .get_config = ubd_get_config,
10582 + .remove = ubd_remove,
10585 +static int ubd_mc_init(void)
10587 + mconsole_register_dev(&ubd_mc);
10591 +__initcall(ubd_mc_init);
10593 +static request_queue_t *ubd_get_queue(kdev_t device)
10595 + return(ubd_queue);
10598 +int ubd_init(void)
10600 + unsigned long stack;
10603 + ubd_dir_handle = devfs_mk_dir (NULL, "ubd", NULL);
10604 + if (devfs_register_blkdev(MAJOR_NR, "ubd", &ubd_blops)) {
10605 + printk(KERN_ERR "ubd: unable to get major %d\n", MAJOR_NR);
10608 + read_ahead[MAJOR_NR] = 8; /* 8 sector (4kB) read-ahead */
10609 + blksize_size[MAJOR_NR] = blk_sizes;
10610 + blk_size[MAJOR_NR] = sizes;
10611 + INIT_HARDSECT(hardsect_size, MAJOR_NR, hardsect_sizes);
10613 + ubd_queue = BLK_DEFAULT_QUEUE(MAJOR_NR);
10614 + blk_init_queue(ubd_queue, DEVICE_REQUEST);
10615 + INIT_ELV(ubd_queue, &ubd_queue->elevator);
10617 + add_gendisk(&ubd_gendisk);
10618 + if (fake_major != MAJOR_NR){
10619 + /* major number 0 is used to auto select */
10620 + err = devfs_register_blkdev(fake_major, "fake", &ubd_blops);
10621 + if(fake_major == 0){
10622 + /* auto device number case */
10623 + fake_major = err;
10628 + /* not auto so normal error */
10629 + printk(KERN_ERR "ubd: error %d getting major %d\n",
10630 + -err, fake_major);
10634 + blk_dev[fake_major].queue = ubd_get_queue;
10635 + read_ahead[fake_major] = 8; /* 8 sector (4kB) read-ahead */
10636 + blksize_size[fake_major] = blk_sizes;
10637 + blk_size[fake_major] = sizes;
10638 + INIT_HARDSECT(hardsect_size, fake_major, hardsect_sizes);
10639 + add_gendisk(&fake_gendisk);
10642 + for(i=0;i<MAX_DEV;i++)
10645 + if(global_openflags.s){
10646 + printk(KERN_INFO "ubd : Synchronous mode\n");
10649 + stack = alloc_stack(0, 0);
10650 + io_pid = start_io_thread(stack + PAGE_SIZE - sizeof(void *),
10655 + "ubd : Failed to start I/O thread (errno = %d) - "
10656 + "falling back to synchronous I/O\n", -io_pid);
10659 + err = um_request_irq(UBD_IRQ, thread_fd, IRQ_READ, ubd_intr,
10660 + SA_INTERRUPT, "ubd", ubd_dev);
10662 + printk(KERN_ERR "um_request_irq failed - errno = %d\n", -err);
10666 +__initcall(ubd_init);
10668 +static void ubd_close(struct ubd *dev)
10671 + physmem_forget_descriptor(dev->fd);
10672 + os_close_file(dev->fd);
10673 + if(dev->cow.file != NULL)
10677 + physmem_forget_descriptor(dev->cow.fd);
10678 + os_close_file(dev->cow.fd);
10679 + vfree(dev->cow.bitmap);
10680 + dev->cow.bitmap = NULL;
10683 +static int ubd_open_dev(struct ubd *dev)
10685 + struct openflags flags;
10687 + int err, create_cow, *create_ptr;
10689 + dev->openflags = dev->boot_openflags;
10691 + create_ptr = (dev->cow.file != NULL) ? &create_cow : NULL;
10692 + back_ptr = dev->no_cow ? NULL : &dev->cow.file;
10693 + dev->fd = open_ubd_file(dev->file, &dev->openflags, back_ptr,
10694 + &dev->cow.bitmap_offset, &dev->cow.bitmap_len,
10695 + &dev->cow.data_offset, create_ptr);
10697 + if((dev->fd == -ENOENT) && create_cow){
10698 + dev->fd = create_cow_file(dev->file, dev->cow.file,
10699 + dev->openflags, 1 << 9, PAGE_SIZE,
10700 + &dev->cow.bitmap_offset,
10701 + &dev->cow.bitmap_len,
10702 + &dev->cow.data_offset);
10703 + if(dev->fd >= 0){
10704 + printk(KERN_INFO "Creating \"%s\" as COW file for "
10705 + "\"%s\"\n", dev->file, dev->cow.file);
10709 + if(dev->fd < 0) return(dev->fd);
10711 + if(dev->cow.file != NULL){
10713 + dev->cow.bitmap = (void *) vmalloc(dev->cow.bitmap_len);
10714 + if(dev->cow.bitmap == NULL){
10715 + printk(KERN_ERR "Failed to vmalloc COW bitmap\n");
10718 + flush_tlb_kernel_vm();
10720 + err = read_cow_bitmap(dev->fd, dev->cow.bitmap,
10721 + dev->cow.bitmap_offset,
10722 + dev->cow.bitmap_len);
10726 + flags = dev->openflags;
10728 + err = open_ubd_file(dev->cow.file, &flags, NULL, NULL, NULL,
10730 + if(err < 0) goto error;
10731 + dev->cow.fd = err;
10735 + os_close_file(dev->fd);
10739 +static int ubd_file_size(struct ubd *dev, __u64 *size_out)
10743 + file = dev->cow.file ? dev->cow.file : dev->file;
10744 + return(os_file_size(file, size_out));
10747 +static int ubd_open(struct inode *inode, struct file *filp)
10750 + int n, offset, err = 0;
10752 + n = DEVICE_NR(inode->i_rdev);
10753 + dev = &ubd_dev[n];
10757 + spin_lock(&ubd_lock);
10758 + offset = n << UBD_SHIFT;
10760 + if(dev->count == 0){
10761 + err = ubd_open_dev(dev);
10763 + printk(KERN_ERR "ubd%d: Can't open \"%s\": "
10764 + "errno = %d\n", n, dev->file, -err);
10767 + err = ubd_file_size(dev, &dev->size);
10770 + sizes[offset] = dev->size / BLOCK_SIZE;
10771 + ubd_part[offset].nr_sects = dev->size / hardsect_sizes[offset];
10774 + if((filp->f_mode & FMODE_WRITE) && !dev->openflags.w){
10775 + if(--dev->count == 0) ubd_close(dev);
10779 + spin_unlock(&ubd_lock);
10783 +static int ubd_release(struct inode * inode, struct file * file)
10787 + n = DEVICE_NR(inode->i_rdev);
10788 + offset = n << UBD_SHIFT;
10792 + spin_lock(&ubd_lock);
10793 + if(--ubd_dev[n].count == 0)
10794 + ubd_close(&ubd_dev[n]);
10795 + spin_unlock(&ubd_lock);
10800 +static void cowify_bitmap(__u64 io_offset, int length, unsigned long *cow_mask,
10801 + __u64 *cow_offset, unsigned long *bitmap,
10802 + __u64 bitmap_offset, unsigned long *bitmap_words,
10803 + __u64 bitmap_len)
10805 + __u64 sector = io_offset >> 9;
10806 + int i, update_bitmap = 0;
10808 + for(i = 0; i < length >> 9; i++){
10809 + if(cow_mask != NULL)
10810 + ubd_set_bit(i, (unsigned char *) cow_mask);
10811 + if(ubd_test_bit(sector + i, (unsigned char *) bitmap))
10814 + update_bitmap = 1;
10815 + ubd_set_bit(sector + i, (unsigned char *) bitmap);
10818 + if(!update_bitmap)
10821 + *cow_offset = sector / (sizeof(unsigned long) * 8);
10823 + /* This takes care of the case where we're exactly at the end of the
10824 + * device, and *cow_offset + 1 is off the end. So, just back it up
10825 + * by one word. Thanks to Lynn Kerby for the fix and James McMechan
10826 + * for the original diagnosis.
10828 + if(*cow_offset == ((bitmap_len + sizeof(unsigned long) - 1) /
10829 + sizeof(unsigned long) - 1))
10832 + bitmap_words[0] = bitmap[*cow_offset];
10833 + bitmap_words[1] = bitmap[*cow_offset + 1];
10835 + *cow_offset *= sizeof(unsigned long);
10836 + *cow_offset += bitmap_offset;
10839 +static void cowify_req(struct io_thread_req *req, unsigned long *bitmap,
10840 + __u64 bitmap_offset, __u64 bitmap_len)
10842 + __u64 sector = req->offset >> 9;
10845 + if(req->length > (sizeof(req->sector_mask) * 8) << 9)
10846 + panic("Operation too long");
10848 + if(req->op == UBD_READ) {
10849 + for(i = 0; i < req->length >> 9; i++){
10850 + if(ubd_test_bit(sector + i, (unsigned char *) bitmap)){
10851 + ubd_set_bit(i, (unsigned char *)
10852 + &req->sector_mask);
10856 + else cowify_bitmap(req->offset, req->length, &req->sector_mask,
10857 + &req->cow_offset, bitmap, bitmap_offset,
10858 + req->bitmap_words, bitmap_len);
10861 +static int mmap_fd(struct request *req, struct ubd *dev, __u64 offset)
10864 + unsigned char *bitmap;
10867 + /* mmap must have been requested on the command line */
10871 + /* The buffer must be page aligned */
10872 + if(((unsigned long) req->buffer % UBD_MMAP_BLOCK_SIZE) != 0)
10875 + /* The request must be a page long */
10876 + if((req->current_nr_sectors << 9) != PAGE_SIZE)
10879 + if(dev->cow.file == NULL)
10882 + sector = offset >> 9;
10883 + bitmap = (unsigned char *) dev->cow.bitmap;
10884 + bit = ubd_test_bit(sector, bitmap);
10886 + for(i = 1; i < req->current_nr_sectors; i++){
10887 + if(ubd_test_bit(sector + i, bitmap) != bit)
10891 + if(bit || (req->cmd == WRITE))
10892 + offset += dev->cow.data_offset;
10894 + /* The data on disk must be page aligned */
10895 + if((offset % UBD_MMAP_BLOCK_SIZE) != 0)
10898 + return(bit ? dev->fd : dev->cow.fd);
10901 +static int prepare_mmap_request(struct ubd *dev, int fd, __u64 offset,
10902 + struct request *req,
10903 + struct io_thread_req *io_req)
10907 + if(req->cmd == WRITE){
10908 + /* Writes are almost no-ops since the new data is already in the
10909 + * host page cache
10911 + dev->map_writes++;
10912 + if(dev->cow.file != NULL)
10913 + cowify_bitmap(io_req->offset, io_req->length,
10914 + &io_req->sector_mask, &io_req->cow_offset,
10915 + dev->cow.bitmap, dev->cow.bitmap_offset,
10916 + io_req->bitmap_words,
10917 + dev->cow.bitmap_len);
10922 + if((dev->cow.file != NULL) && (fd == dev->cow.fd))
10924 + else w = dev->openflags.w;
10926 + if((dev->cow.file != NULL) && (fd == dev->fd))
10927 + offset += dev->cow.data_offset;
10929 + err = physmem_subst_mapping(req->buffer, fd, offset, w);
10931 + printk("physmem_subst_mapping failed, err = %d\n",
10935 + dev->map_reads++;
10937 + io_req->op = UBD_MMAP;
10938 + io_req->buffer = req->buffer;
10942 +static int prepare_request(struct request *req, struct io_thread_req *io_req)
10946 + int minor, n, len, fd;
10948 + if(req->rq_status == RQ_INACTIVE) return(1);
10950 + minor = MINOR(req->rq_dev);
10951 + n = minor >> UBD_SHIFT;
10952 + dev = &ubd_dev[n];
10954 + if(IS_WRITE(req) && !dev->openflags.w){
10955 + printk("Write attempted on readonly ubd device %d\n", n);
10960 + req->sector += ubd_part[minor].start_sect;
10961 + offset = ((__u64) req->sector) << 9;
10962 + len = req->current_nr_sectors << 9;
10964 + io_req->fds[0] = (dev->cow.file != NULL) ? dev->cow.fd : dev->fd;
10965 + io_req->fds[1] = dev->fd;
10966 + io_req->map_fd = -1;
10967 + io_req->cow_offset = -1;
10968 + io_req->offset = offset;
10969 + io_req->length = len;
10970 + io_req->error = 0;
10971 + io_req->sector_mask = 0;
10973 + fd = mmap_fd(req, dev, io_req->offset);
10975 + /* If mmapping is otherwise OK, but the first access to the
10976 + * page is a write, then it's not mapped in yet. So we have
10977 + * to write the data to disk first, then we can map the disk
10978 + * page in and continue normally from there.
10980 + if((req->cmd == WRITE) && !is_remapped(req->buffer)){
10981 + io_req->map_fd = dev->fd;
10982 + io_req->map_offset = io_req->offset +
10983 + dev->cow.data_offset;
10984 + dev->write_maps++;
10986 + else return(prepare_mmap_request(dev, fd, io_req->offset, req,
10990 + if(req->cmd == READ)
10991 + dev->nomap_reads++;
10992 + else dev->nomap_writes++;
10994 + io_req->op = (req->cmd == READ) ? UBD_READ : UBD_WRITE;
10995 + io_req->offsets[0] = 0;
10996 + io_req->offsets[1] = dev->cow.data_offset;
10997 + io_req->buffer = req->buffer;
10998 + io_req->sectorsize = 1 << 9;
11000 + if(dev->cow.file != NULL)
11001 + cowify_req(io_req, dev->cow.bitmap, dev->cow.bitmap_offset,
11002 + dev->cow.bitmap_len);
11006 +static void do_ubd_request(request_queue_t *q)
11008 + struct io_thread_req io_req;
11009 + struct request *req;
11012 + if(thread_fd == -1){
11013 + while(!list_empty(&q->queue_head)){
11014 + req = blkdev_entry_next_request(&q->queue_head);
11015 + err = prepare_request(req, &io_req);
11018 + ubd_finish(io_req.error);
11023 + if(DEVICE_INTR || list_empty(&q->queue_head)) return;
11024 + req = blkdev_entry_next_request(&q->queue_head);
11025 + err = prepare_request(req, &io_req);
11027 + SET_INTR(ubd_handler);
11028 + n = write_ubd_fs(thread_fd, (char *) &io_req,
11030 + if(n != sizeof(io_req))
11031 + printk("write to io thread failed, "
11032 + "errno = %d\n", -n);
11037 +static int ubd_ioctl(struct inode * inode, struct file * file,
11038 + unsigned int cmd, unsigned long arg)
11040 + struct hd_geometry *loc = (struct hd_geometry *) arg;
11042 + int n, minor, err;
11043 + struct hd_driveid ubd_id = {
11049 + if(!inode) return(-EINVAL);
11050 + minor = MINOR(inode->i_rdev);
11051 + n = minor >> UBD_SHIFT;
11054 + dev = &ubd_dev[n];
11056 + struct hd_geometry g;
11057 + struct cdrom_volctrl volume;
11058 + case HDIO_GETGEO:
11059 + if(!loc) return(-EINVAL);
11062 + g.cylinders = dev->size / (128 * 32 * hardsect_sizes[minor]);
11063 + g.start = ubd_part[minor].start_sect;
11064 + return(copy_to_user(loc, &g, sizeof(g)) ? -EFAULT : 0);
11065 + case BLKGETSIZE: /* Return device size */
11066 + if(!arg) return(-EINVAL);
11067 + err = verify_area(VERIFY_WRITE, (long *) arg, sizeof(long));
11070 + put_user(ubd_part[minor].nr_sects, (long *) arg);
11072 + case BLKRRPART: /* Re-read partition tables */
11073 + return(ubd_revalidate(inode->i_rdev));
11075 + case HDIO_SET_UNMASKINTR:
11076 + if(!capable(CAP_SYS_ADMIN)) return(-EACCES);
11077 + if((arg > 1) || (minor & 0x3F)) return(-EINVAL);
11080 + case HDIO_GET_UNMASKINTR:
11081 + if(!arg) return(-EINVAL);
11082 + err = verify_area(VERIFY_WRITE, (long *) arg, sizeof(long));
11087 + case HDIO_GET_MULTCOUNT:
11088 + if(!arg) return(-EINVAL);
11089 + err = verify_area(VERIFY_WRITE, (long *) arg, sizeof(long));
11094 + case HDIO_SET_MULTCOUNT:
11095 + if(!capable(CAP_SYS_ADMIN)) return(-EACCES);
11096 + if(MINOR(inode->i_rdev) & 0x3F) return(-EINVAL);
11099 + case HDIO_GET_IDENTITY:
11100 + ubd_id.cyls = dev->size / (128 * 32 * hardsect_sizes[minor]);
11101 + if(copy_to_user((char *) arg, (char *) &ubd_id,
11106 + case CDROMVOLREAD:
11107 + if(copy_from_user(&volume, (char *) arg, sizeof(volume)))
11109 + volume.channel0 = 255;
11110 + volume.channel1 = 255;
11111 + volume.channel2 = 255;
11112 + volume.channel3 = 255;
11113 + if(copy_to_user((char *) arg, &volume, sizeof(volume)))
11118 + return blk_ioctl(inode->i_rdev, cmd, arg);
11122 +static int ubd_revalidate1(kdev_t rdev)
11124 + int i, n, offset, err = 0, pcount = 1 << UBD_SHIFT;
11126 + struct hd_struct *part;
11128 + n = DEVICE_NR(rdev);
11129 + offset = n << UBD_SHIFT;
11130 + dev = &ubd_dev[n];
11132 + part = &ubd_part[offset];
11134 + /* clear all old partition counts */
11135 + for(i = 1; i < pcount; i++) {
11136 + part[i].start_sect = 0;
11137 + part[i].nr_sects = 0;
11140 + /* If it already has been opened we can check the partitions
11144 + part->start_sect = 0;
11145 + register_disk(&ubd_gendisk, MKDEV(MAJOR_NR, offset), pcount,
11146 + &ubd_blops, part->nr_sects);
11148 + else if(dev->file){
11149 + err = ubd_open_dev(dev);
11151 + printk(KERN_ERR "unable to open %s for validation\n",
11156 + /* have to recompute sizes since we opened it */
11157 + err = ubd_file_size(dev, &dev->size);
11162 + part->start_sect = 0;
11163 + part->nr_sects = dev->size / hardsect_sizes[offset];
11164 + register_disk(&ubd_gendisk, MKDEV(MAJOR_NR, offset), pcount,
11165 + &ubd_blops, part->nr_sects);
11167 + /* we are done so close it */
11170 + else err = -ENODEV;
11175 +static int ubd_revalidate(kdev_t rdev)
11179 + spin_lock(&ubd_lock);
11180 + err = ubd_revalidate1(rdev);
11181 + spin_unlock(&ubd_lock);
11185 +static int ubd_check_remapped(int fd, unsigned long address, int is_write,
11188 + __u64 bitmap_offset;
11189 + unsigned long new_bitmap[2];
11192 + /* If it's not a write access, we can't do anything about it */
11196 + /* We have a write */
11197 + for(i = 0; i < sizeof(ubd_dev) / sizeof(ubd_dev[0]); i++){
11198 + struct ubd *dev = &ubd_dev[i];
11200 + if((dev->fd != fd) && (dev->cow.fd != fd))
11203 + /* It's a write to a ubd device */
11205 + if(!dev->openflags.w){
11206 + /* It's a write access on a read-only device - probably
11207 + * shouldn't happen. If the kernel is trying to change
11208 + * something with no intention of writing it back out,
11209 + * then this message will clue us in that this needs
11212 + printk("Write access to mapped page from readonly ubd "
11213 + "device %d\n", i);
11217 + /* It's a write to a writeable ubd device - it must be COWed
11218 + * because, otherwise, the page would have been mapped in
11222 + if(!dev->cow.file)
11223 + panic("Write fault on writeable non-COW ubd device %d",
11226 + /* It should also be an access to the backing file since the
11227 + * COW pages should be mapped in read-write
11230 + if(fd == dev->fd)
11231 + panic("Write fault on a backing page of ubd "
11232 + "device %d\n", i);
11234 + /* So, we do the write, copying the backing data to the COW
11238 + err = os_seek_file(dev->fd, offset + dev->cow.data_offset);
11240 + panic("Couldn't seek to %lld in COW file of ubd "
11241 + "device %d, err = %d",
11242 + offset + dev->cow.data_offset, i, -err);
11244 + n = os_write_file(dev->fd, (void *) address, PAGE_SIZE);
11245 + if(n != PAGE_SIZE)
11246 + panic("Couldn't copy data to COW file of ubd "
11247 + "device %d, err = %d", i, -n);
11249 + /* ... updating the COW bitmap... */
11251 + cowify_bitmap(offset, PAGE_SIZE, NULL, &bitmap_offset,
11252 + dev->cow.bitmap, dev->cow.bitmap_offset,
11253 + new_bitmap, dev->cow.bitmap_len);
11255 + err = os_seek_file(dev->fd, bitmap_offset);
11257 + panic("Couldn't seek to %lld in COW file of ubd "
11258 + "device %d, err = %d", bitmap_offset, i, -err);
11260 + n = os_write_file(dev->fd, new_bitmap, sizeof(new_bitmap));
11261 + if(n != sizeof(new_bitmap))
11262 + panic("Couldn't update bitmap of ubd device %d, "
11263 + "err = %d", i, -n);
11265 + /* Maybe we can map the COW page in, and maybe we can't. If
11266 + * it is a pre-V3 COW file, we can't, since the alignment will
11267 + * be wrong. If it is a V3 or later COW file which has been
11268 + * moved to a system with a larger page size, then maybe we
11269 + * can't, depending on the exact location of the page.
11272 + offset += dev->cow.data_offset;
11274 + /* Remove the remapping, putting the original anonymous page
11275 + * back. If the COW file can be mapped in, that is done.
11276 + * Otherwise, the COW page is read in.
11279 + if(!physmem_remove_mapping((void *) address))
11280 + panic("Address 0x%lx not remapped by ubd device %d",
11282 + if((offset % UBD_MMAP_BLOCK_SIZE) == 0)
11283 + physmem_subst_mapping((void *) address, dev->fd,
11286 + err = os_seek_file(dev->fd, offset);
11288 + panic("Couldn't seek to %lld in COW file of "
11289 + "ubd device %d, err = %d", offset, i,
11292 + n = os_read_file(dev->fd, (void *) address, PAGE_SIZE);
11293 + if(n != PAGE_SIZE)
11294 + panic("Failed to read page from offset %llx of "
11295 + "COW file of ubd device %d, err = %d",
11302 + /* It's not a write on a ubd device */
11306 +static struct remapper ubd_remapper = {
11307 + .list = LIST_HEAD_INIT(ubd_remapper.list),
11308 + .proc = ubd_check_remapped,
11311 +static int ubd_remapper_setup(void)
11314 + register_remapper(&ubd_remapper);
11319 +__initcall(ubd_remapper_setup);
11322 + * Overrides for Emacs so that we follow Linus's tabbing style.
11323 + * Emacs will notice this stuff at the end of the file and automatically
11324 + * adjust the settings for this buffer only. This must remain at the end
11326 + * ---------------------------------------------------------------------------
11327 + * Local variables:
11328 + * c-file-style: "linux"
11331 diff -Naur -X ../exclude-files orig/arch/um/drivers/ubd_user.c um/arch/um/drivers/ubd_user.c
11332 --- orig/arch/um/drivers/ubd_user.c 1969-12-31 19:00:00.000000000 -0500
11333 +++ um/arch/um/drivers/ubd_user.c 2004-01-10 06:24:52.000000000 -0500
11336 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
11337 + * Copyright (C) 2001 Ridgerun,Inc (glonnon@ridgerun.com)
11338 + * Licensed under the GPL
11341 +#include <stddef.h>
11342 +#include <unistd.h>
11343 +#include <errno.h>
11344 +#include <sched.h>
11345 +#include <signal.h>
11346 +#include <string.h>
11347 +#include <netinet/in.h>
11348 +#include <sys/time.h>
11349 +#include <sys/socket.h>
11350 +#include <sys/mman.h>
11351 +#include <sys/param.h>
11352 +#include "asm/types.h"
11353 +#include "user_util.h"
11354 +#include "kern_util.h"
11356 +#include "ubd_user.h"
11360 +#include <endian.h>
11361 +#include <byteswap.h>
11363 +static int same_backing_files(char *from_cmdline, char *from_cow, char *cow)
11365 + struct uml_stat buf1, buf2;
11368 + if(from_cmdline == NULL) return(1);
11369 + if(!strcmp(from_cmdline, from_cow)) return(1);
11371 + err = os_stat_file(from_cmdline, &buf1);
11373 + printk("Couldn't stat '%s', err = %d\n", from_cmdline, -err);
11376 + err = os_stat_file(from_cow, &buf2);
11378 + printk("Couldn't stat '%s', err = %d\n", from_cow, -err);
11381 + if((buf1.ust_dev == buf2.ust_dev) && (buf1.ust_ino == buf2.ust_ino))
11384 + printk("Backing file mismatch - \"%s\" requested,\n"
11385 + "\"%s\" specified in COW header of \"%s\"\n",
11386 + from_cmdline, from_cow, cow);
11390 +static int backing_file_mismatch(char *file, __u64 size, time_t mtime)
11392 + unsigned long modtime;
11393 + long long actual;
11396 + err = os_file_modtime(file, &modtime);
11398 + printk("Failed to get modification time of backing file "
11399 + "\"%s\", err = %d\n", file, -err);
11403 + err = os_file_size(file, &actual);
11405 + printk("Failed to get size of backing file \"%s\", "
11406 + "err = %d\n", file, -err);
11410 + if(actual != size){
11411 + printk("Size mismatch (%ld vs %ld) of COW header vs backing "
11412 + "file\n", size, actual);
11415 + if(modtime != mtime){
11416 + printk("mtime mismatch (%ld vs %ld) of COW header vs backing "
11417 + "file\n", mtime, modtime);
11423 +int read_cow_bitmap(int fd, void *buf, int offset, int len)
11427 + err = os_seek_file(fd, offset);
11431 + err = os_read_file(fd, buf, len);
11438 +int open_ubd_file(char *file, struct openflags *openflags,
11439 + char **backing_file_out, int *bitmap_offset_out,
11440 + unsigned long *bitmap_len_out, int *data_offset_out,
11441 + int *create_cow_out)
11445 + __u32 version, align;
11446 + char *backing_file;
11447 + int fd, err, sectorsize, same, mode = 0644;
11449 + fd = os_open_file(file, *openflags, mode);
11451 + if((fd == -ENOENT) && (create_cow_out != NULL))
11452 + *create_cow_out = 1;
11453 + if(!openflags->w ||
11454 + ((errno != EROFS) && (errno != EACCES))) return(-errno);
11455 + openflags->w = 0;
11456 + fd = os_open_file(file, *openflags, mode);
11461 + err = os_lock_file(fd, openflags->w);
11463 + printk("Failed to lock '%s', err = %d\n", file, -err);
11467 + if(backing_file_out == NULL) return(fd);
11469 + err = read_cow_header(file_reader, &fd, &version, &backing_file, &mtime,
11470 + &size, §orsize, &align, bitmap_offset_out);
11471 + if(err && (*backing_file_out != NULL)){
11472 + printk("Failed to read COW header from COW file \"%s\", "
11473 + "errno = %d\n", file, -err);
11476 + if(err) return(fd);
11478 + if(backing_file_out == NULL) return(fd);
11480 + same = same_backing_files(*backing_file_out, backing_file, file);
11482 + if(!same && !backing_file_mismatch(*backing_file_out, size, mtime)){
11483 + printk("Switching backing file to '%s'\n", *backing_file_out);
11484 + err = write_cow_header(file, fd, *backing_file_out,
11485 + sectorsize, align, &size);
11487 + printk("Switch failed, errno = %d\n", -err);
11492 + *backing_file_out = backing_file;
11493 + err = backing_file_mismatch(*backing_file_out, size, mtime);
11494 + if(err) goto out_close;
11497 + cow_sizes(version, size, sectorsize, align, *bitmap_offset_out,
11498 + bitmap_len_out, data_offset_out);
11502 + os_close_file(fd);
11506 +int create_cow_file(char *cow_file, char *backing_file, struct openflags flags,
11507 + int sectorsize, int alignment, int *bitmap_offset_out,
11508 + unsigned long *bitmap_len_out, int *data_offset_out)
11513 + fd = open_ubd_file(cow_file, &flags, NULL, NULL, NULL, NULL, NULL);
11516 + printk("Open of COW file '%s' failed, errno = %d\n", cow_file,
11521 + err = init_cow_file(fd, cow_file, backing_file, sectorsize, alignment,
11522 + bitmap_offset_out, bitmap_len_out,
11523 + data_offset_out);
11527 + os_close_file(fd);
11532 +/* XXX Just trivial wrappers around os_read_file and os_write_file */
11533 +int read_ubd_fs(int fd, void *buffer, int len)
11535 + return(os_read_file(fd, buffer, len));
11538 +int write_ubd_fs(int fd, char *buffer, int len)
11540 + return(os_write_file(fd, buffer, len));
11543 +static int update_bitmap(struct io_thread_req *req)
11547 + if(req->cow_offset == -1)
11550 + n = os_seek_file(req->fds[1], req->cow_offset);
11552 + printk("do_io - bitmap lseek failed : err = %d\n", -n);
11556 + n = os_write_file(req->fds[1], &req->bitmap_words,
11557 + sizeof(req->bitmap_words));
11558 + if(n != sizeof(req->bitmap_words)){
11559 + printk("do_io - bitmap update failed, err = %d fd = %d\n", -n,
11567 +void do_io(struct io_thread_req *req)
11570 + unsigned long len;
11571 + int n, nsectors, start, end, bit;
11575 + if(req->op == UBD_MMAP){
11576 + /* Touch the page to force the host to do any necessary IO to
11577 + * get it into memory
11579 + n = *((volatile int *) req->buffer);
11580 + req->error = update_bitmap(req);
11584 + nsectors = req->length / req->sectorsize;
11587 + bit = ubd_test_bit(start, (unsigned char *) &req->sector_mask);
11589 + while((end < nsectors) &&
11590 + (ubd_test_bit(end, (unsigned char *)
11591 + &req->sector_mask) == bit))
11594 + off = req->offset + req->offsets[bit] +
11595 + start * req->sectorsize;
11596 + len = (end - start) * req->sectorsize;
11597 + buf = &req->buffer[start * req->sectorsize];
11599 + err = os_seek_file(req->fds[bit], off);
11601 + printk("do_io - lseek failed : err = %d\n", -err);
11605 + if(req->op == UBD_READ){
11610 + n = os_read_file(req->fds[bit], buf, len);
11612 + printk("do_io - read failed, err = %d "
11613 + "fd = %d\n", -n, req->fds[bit]);
11617 + } while((n < len) && (n != 0));
11618 + if (n < len) memset(&buf[n], 0, len - n);
11621 + n = os_write_file(req->fds[bit], buf, len);
11623 + printk("do_io - write failed err = %d "
11624 + "fd = %d\n", -n, req->fds[bit]);
11631 + } while(start < nsectors);
11633 + req->error = update_bitmap(req);
11636 +/* Changed in start_io_thread, which is serialized by being called only
11637 + * from ubd_init, which is an initcall.
11639 +int kernel_fd = -1;
11641 +/* Only changed by the io thread */
11644 +int io_thread(void *arg)
11646 + struct io_thread_req req;
11649 + signal(SIGWINCH, SIG_IGN);
11651 + n = os_read_file(kernel_fd, &req, sizeof(req));
11652 + if(n != sizeof(req)){
11654 + printk("io_thread - read failed, fd = %d, "
11655 + "err = %d\n", kernel_fd, -n);
11657 + printk("io_thread - short read, fd = %d, "
11658 + "length = %d\n", kernel_fd, n);
11664 + n = os_write_file(kernel_fd, &req, sizeof(req));
11665 + if(n != sizeof(req))
11666 + printk("io_thread - write failed, fd = %d, err = %d\n",
11671 +int start_io_thread(unsigned long sp, int *fd_out)
11673 + int pid, fds[2], err;
11675 + err = os_pipe(fds, 1, 1);
11677 + printk("start_io_thread - os_pipe failed, err = %d\n", -err);
11681 + kernel_fd = fds[0];
11682 + *fd_out = fds[1];
11684 + pid = clone(io_thread, (void *) sp, CLONE_FILES | CLONE_VM | SIGCHLD,
11687 + printk("start_io_thread - clone failed : errno = %d\n", errno);
11694 + os_close_file(fds[0]);
11695 + os_close_file(fds[1]);
11703 + * Overrides for Emacs so that we follow Linus's tabbing style.
11704 + * Emacs will notice this stuff at the end of the file and automatically
11705 + * adjust the settings for this buffer only. This must remain at the end
11707 + * ---------------------------------------------------------------------------
11708 + * Local variables:
11709 + * c-file-style: "linux"
11712 diff -Naur -X ../exclude-files orig/arch/um/drivers/xterm.c um/arch/um/drivers/xterm.c
11713 --- orig/arch/um/drivers/xterm.c 1969-12-31 19:00:00.000000000 -0500
11714 +++ um/arch/um/drivers/xterm.c 2003-10-21 03:26:06.000000000 -0400
11717 + * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
11718 + * Licensed under the GPL
11721 +#include <stdio.h>
11722 +#include <stdlib.h>
11723 +#include <unistd.h>
11724 +#include <string.h>
11725 +#include <errno.h>
11726 +#include <termios.h>
11727 +#include <signal.h>
11728 +#include <sched.h>
11729 +#include <sys/socket.h>
11730 +#include "kern_util.h"
11731 +#include "chan_user.h"
11732 +#include "helper.h"
11733 +#include "user_util.h"
11736 +#include "xterm.h"
11738 +struct xterm_chan {
11744 + struct termios tt;
11745 + unsigned long stack;
11749 +void *xterm_init(char *str, int device, struct chan_opts *opts)
11751 + struct xterm_chan *data;
11753 + data = malloc(sizeof(*data));
11754 + if(data == NULL) return(NULL);
11755 + *data = ((struct xterm_chan) { .pid = -1,
11756 + .helper_pid = -1,
11757 + .device = device,
11758 + .title = opts->xterm_title,
11759 + .raw = opts->raw,
11760 + .stack = opts->tramp_stack,
11761 + .direct_rcv = !opts->in_kernel } );
11765 +/* Only changed by xterm_setup, which is a setup */
11766 +static char *terminal_emulator = "xterm";
11767 +static char *title_switch = "-T";
11768 +static char *exec_switch = "-e";
11770 +static int __init xterm_setup(char *line, int *add)
11773 + terminal_emulator = line;
11775 + line = strchr(line, ',');
11776 + if(line == NULL) return(0);
11778 + if(*line) title_switch = line;
11780 + line = strchr(line, ',');
11781 + if(line == NULL) return(0);
11783 + if(*line) exec_switch = line;
11788 +__uml_setup("xterm=", xterm_setup,
11789 +"xterm=<terminal emulator>,<title switch>,<exec switch>\n"
11790 +" Specifies an alternate terminal emulator to use for the debugger,\n"
11791 +" consoles, and serial lines when they are attached to the xterm channel.\n"
11792 +" The values are the terminal emulator binary, the switch it uses to set\n"
11793 +" its title, and the switch it uses to execute a subprocess,\n"
11794 +" respectively. The title switch must have the form '<switch> title',\n"
11795 +" not '<switch>=title'. Similarly, the exec switch must have the form\n"
11796 +" '<switch> command arg1 arg2 ...'.\n"
11797 +" The default values are 'xterm=xterm,-T,-e'. Values for gnome-terminal\n"
11798 +" are 'xterm=gnome-terminal,-t,-x'.\n\n"
11801 +int xterm_open(int input, int output, int primary, void *d, char **dev_out)
11803 + struct xterm_chan *data = d;
11804 + unsigned long stack;
11805 + int pid, fd, new, err;
11806 + char title[256], file[] = "/tmp/xterm-pipeXXXXXX";
11807 + char *argv[] = { terminal_emulator, title_switch, title, exec_switch,
11808 + "/usr/lib/uml/port-helper", "-uml-socket",
11811 + if(os_access(argv[4], OS_ACC_X_OK) < 0)
11812 + argv[4] = "port-helper";
11814 + fd = mkstemp(file);
11816 + printk("xterm_open : mkstemp failed, errno = %d\n", errno);
11820 + if(unlink(file)){
11821 + printk("xterm_open : unlink failed, errno = %d\n", errno);
11824 + os_close_file(fd);
11826 + fd = os_create_unix_socket(file, sizeof(file), 1);
11828 + printk("xterm_open : create_unix_socket failed, errno = %d\n",
11833 + sprintf(title, data->title, data->device);
11834 + stack = data->stack;
11835 + pid = run_helper(NULL, NULL, argv, &stack);
11837 + printk("xterm_open : run_helper failed, errno = %d\n", -pid);
11841 + if(data->stack == 0) free_stack(stack, 0);
11843 + if(data->direct_rcv)
11844 + new = os_rcv_fd(fd, &data->helper_pid);
11846 + err = os_set_fd_block(fd, 0);
11848 + printk("xterm_open : failed to set descriptor "
11849 + "non-blocking, err = %d\n", -err);
11852 + new = xterm_fd(fd, &data->helper_pid);
11855 + printk("xterm_open : os_rcv_fd failed, err = %d\n", -new);
11859 + tcgetattr(new, &data->tt);
11860 + if(data->raw) raw(new, 0);
11869 +void xterm_close(int fd, void *d)
11871 + struct xterm_chan *data = d;
11873 + if(data->pid != -1)
11874 + os_kill_process(data->pid, 1);
11876 + if(data->helper_pid != -1)
11877 + os_kill_process(data->helper_pid, 0);
11878 + data->helper_pid = -1;
11879 + os_close_file(fd);
11882 +void xterm_free(void *d)
11887 +int xterm_console_write(int fd, const char *buf, int n, void *d)
11889 + struct xterm_chan *data = d;
11891 + return(generic_console_write(fd, buf, n, &data->tt));
11894 +struct chan_ops xterm_ops = {
11896 + .init = xterm_init,
11897 + .open = xterm_open,
11898 + .close = xterm_close,
11899 + .read = generic_read,
11900 + .write = generic_write,
11901 + .console_write = xterm_console_write,
11902 + .window_size = generic_window_size,
11903 + .free = xterm_free,
11908 + * Overrides for Emacs so that we follow Linus's tabbing style.
11909 + * Emacs will notice this stuff at the end of the file and automatically
11910 + * adjust the settings for this buffer only. This must remain at the end
11912 + * ---------------------------------------------------------------------------
11913 + * Local variables:
11914 + * c-file-style: "linux"
11917 diff -Naur -X ../exclude-files orig/arch/um/drivers/xterm.h um/arch/um/drivers/xterm.h
11918 --- orig/arch/um/drivers/xterm.h 1969-12-31 19:00:00.000000000 -0500
11919 +++ um/arch/um/drivers/xterm.h 2003-10-21 03:26:06.000000000 -0400
11922 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
11923 + * Licensed under the GPL
11926 +#ifndef __XTERM_H__
11927 +#define __XTERM_H__
11929 +extern int xterm_fd(int socket, int *pid_out);
11934 + * Overrides for Emacs so that we follow Linus's tabbing style.
11935 + * Emacs will notice this stuff at the end of the file and automatically
11936 + * adjust the settings for this buffer only. This must remain at the end
11938 + * ---------------------------------------------------------------------------
11939 + * Local variables:
11940 + * c-file-style: "linux"
11943 diff -Naur -X ../exclude-files orig/arch/um/drivers/xterm_kern.c um/arch/um/drivers/xterm_kern.c
11944 --- orig/arch/um/drivers/xterm_kern.c 1969-12-31 19:00:00.000000000 -0500
11945 +++ um/arch/um/drivers/xterm_kern.c 2003-10-21 03:26:06.000000000 -0400
11948 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
11949 + * Licensed under the GPL
11952 +#include "linux/errno.h"
11953 +#include "linux/slab.h"
11954 +#include "asm/semaphore.h"
11955 +#include "asm/irq.h"
11956 +#include "irq_user.h"
11957 +#include "irq_kern.h"
11958 +#include "kern_util.h"
11960 +#include "xterm.h"
11962 +struct xterm_wait {
11963 + struct semaphore sem;
11969 +static void xterm_interrupt(int irq, void *data, struct pt_regs *regs)
11971 + struct xterm_wait *xterm = data;
11974 + fd = os_rcv_fd(xterm->fd, &xterm->pid);
11975 + if(fd == -EAGAIN)
11978 + xterm->new_fd = fd;
11982 +int xterm_fd(int socket, int *pid_out)
11984 + struct xterm_wait *data;
11987 + data = kmalloc(sizeof(*data), GFP_KERNEL);
11988 + if(data == NULL){
11989 + printk(KERN_ERR "xterm_fd : failed to allocate xterm_wait\n");
11992 + *data = ((struct xterm_wait)
11993 + { .sem = __SEMAPHORE_INITIALIZER(data->sem, 0),
11998 + err = um_request_irq(XTERM_IRQ, socket, IRQ_READ, xterm_interrupt,
11999 + SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM,
12002 + printk(KERN_ERR "xterm_fd : failed to get IRQ for xterm, "
12003 + "err = %d\n", err);
12007 + down(&data->sem);
12009 + free_irq(XTERM_IRQ, data);
12011 + ret = data->new_fd;
12012 + *pid_out = data->pid;
12020 + * Overrides for Emacs so that we follow Linus's tabbing style.
12021 + * Emacs will notice this stuff at the end of the file and automatically
12022 + * adjust the settings for this buffer only. This must remain at the end
12024 + * ---------------------------------------------------------------------------
12025 + * Local variables:
12026 + * c-file-style: "linux"
12029 diff -Naur -X ../exclude-files orig/arch/um/dyn_link.ld.in um/arch/um/dyn_link.ld.in
12030 --- orig/arch/um/dyn_link.ld.in 1969-12-31 19:00:00.000000000 -0500
12031 +++ um/arch/um/dyn_link.ld.in 2004-01-10 04:28:44.000000000 -0500
12033 +OUTPUT_FORMAT("ELF_FORMAT")
12034 +OUTPUT_ARCH(ELF_ARCH)
12036 +SEARCH_DIR("/usr/local/i686-pc-linux-gnu/lib"); SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");
12037 +/* Do we need any of these for elf?
12038 + __DYNAMIC = 0; */
12041 + . = START() + SIZEOF_HEADERS;
12042 + .interp : { *(.interp) }
12043 + __binary_start = .;
12044 + . = ALIGN(4096); /* Init code and data */
12046 + __init_begin = .;
12047 + .text.init : { *(.text.init) }
12051 + /* Read-only sections, merged into text segment: */
12052 + .hash : { *(.hash) }
12053 + .dynsym : { *(.dynsym) }
12054 + .dynstr : { *(.dynstr) }
12055 + .gnu.version : { *(.gnu.version) }
12056 + .gnu.version_d : { *(.gnu.version_d) }
12057 + .gnu.version_r : { *(.gnu.version_r) }
12058 + .rel.init : { *(.rel.init) }
12059 + .rela.init : { *(.rela.init) }
12060 + .rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
12061 + .rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
12062 + .rel.fini : { *(.rel.fini) }
12063 + .rela.fini : { *(.rela.fini) }
12064 + .rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
12065 + .rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
12066 + .rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
12067 + .rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
12068 + .rel.tdata : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
12069 + .rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
12070 + .rel.tbss : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
12071 + .rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
12072 + .rel.ctors : { *(.rel.ctors) }
12073 + .rela.ctors : { *(.rela.ctors) }
12074 + .rel.dtors : { *(.rel.dtors) }
12075 + .rela.dtors : { *(.rela.dtors) }
12076 + .rel.got : { *(.rel.got) }
12077 + .rela.got : { *(.rela.got) }
12078 + .rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
12079 + .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
12080 + .rel.plt : { *(.rel.plt) }
12081 + .rela.plt : { *(.rela.plt) }
12085 + .plt : { *(.plt) }
12087 + *(.text .stub .text.* .gnu.linkonce.t.*)
12088 + /* .gnu.warning sections are handled specially by elf32.em. */
12095 + PROVIDE (__etext = .);
12096 + PROVIDE (_etext = .);
12097 + PROVIDE (etext = .);
12098 + .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
12099 + .rodata1 : { *(.rodata1) }
12100 + .eh_frame_hdr : { *(.eh_frame_hdr) }
12104 + PROVIDE (_sdata = .);
12106 +include(`arch/um/common.ld.in')
12108 + /* Ensure the __preinit_array_start label is properly aligned. We
12109 + could instead move the label definition inside the section, but
12110 + the linker would then create the section even if it turns out to
12111 + be empty, which isn't pretty. */
12112 + . = ALIGN(32 / 8);
12113 + .preinit_array : { *(.preinit_array) }
12114 + .init_array : { *(.init_array) }
12115 + .fini_array : { *(.fini_array) }
12117 + . = ALIGN(KERNEL_STACK_SIZE); /* init_task */
12118 + *(.data.init_task)
12119 + *(.data .data.* .gnu.linkonce.d.*)
12120 + SORT(CONSTRUCTORS)
12122 + .data1 : { *(.data1) }
12123 + .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
12124 + .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
12125 + .eh_frame : { KEEP (*(.eh_frame)) }
12126 + .gcc_except_table : { *(.gcc_except_table) }
12127 + .dynamic : { *(.dynamic) }
12129 + /* gcc uses crtbegin.o to find the start of
12130 + the constructors, so we make sure it is
12131 + first. Because this is a wildcard, it
12132 + doesn't matter if the user does not
12133 + actually link against crtbegin.o; the
12134 + linker won't look for a file to match a
12135 + wildcard. The wildcard also means that it
12136 + doesn't matter which directory crtbegin.o
12138 + KEEP (*crtbegin.o(.ctors))
12139 + /* We don't want to include the .ctor section from
12140 + from the crtend.o file until after the sorted ctors.
12141 + The .ctor section from the crtend file contains the
12142 + end of ctors marker and it must be last */
12143 + KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
12144 + KEEP (*(SORT(.ctors.*)))
12148 + KEEP (*crtbegin.o(.dtors))
12149 + KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
12150 + KEEP (*(SORT(.dtors.*)))
12153 + .jcr : { KEEP (*(.jcr)) }
12154 + .got : { *(.got.plt) *(.got) }
12156 + PROVIDE (edata = .);
12160 + *(.bss .bss.* .gnu.linkonce.b.*)
12162 + /* Align here to ensure that the .bss section occupies space up to
12163 + _end. Align after .bss to ensure correct alignment even if the
12164 + .bss section disappears because there are no input sections. */
12165 + . = ALIGN(32 / 8);
12166 + . = ALIGN(32 / 8);
12169 + PROVIDE (end = .);
12170 + /* Stabs debugging sections. */
12171 + .stab 0 : { *(.stab) }
12172 + .stabstr 0 : { *(.stabstr) }
12173 + .stab.excl 0 : { *(.stab.excl) }
12174 + .stab.exclstr 0 : { *(.stab.exclstr) }
12175 + .stab.index 0 : { *(.stab.index) }
12176 + .stab.indexstr 0 : { *(.stab.indexstr) }
12177 + .comment 0 : { *(.comment) }
12178 + /* DWARF debug sections.
12179 + Symbols in the DWARF debugging sections are relative to the beginning
12180 + of the section so we begin them at 0. */
12182 + .debug 0 : { *(.debug) }
12183 + .line 0 : { *(.line) }
12184 + /* GNU DWARF 1 extensions */
12185 + .debug_srcinfo 0 : { *(.debug_srcinfo) }
12186 + .debug_sfnames 0 : { *(.debug_sfnames) }
12187 + /* DWARF 1.1 and DWARF 2 */
12188 + .debug_aranges 0 : { *(.debug_aranges) }
12189 + .debug_pubnames 0 : { *(.debug_pubnames) }
12191 + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
12192 + .debug_abbrev 0 : { *(.debug_abbrev) }
12193 + .debug_line 0 : { *(.debug_line) }
12194 + .debug_frame 0 : { *(.debug_frame) }
12195 + .debug_str 0 : { *(.debug_str) }
12196 + .debug_loc 0 : { *(.debug_loc) }
12197 + .debug_macinfo 0 : { *(.debug_macinfo) }
12198 + /* SGI/MIPS DWARF 2 extensions */
12199 + .debug_weaknames 0 : { *(.debug_weaknames) }
12200 + .debug_funcnames 0 : { *(.debug_funcnames) }
12201 + .debug_typenames 0 : { *(.debug_typenames) }
12202 + .debug_varnames 0 : { *(.debug_varnames) }
12204 diff -Naur -X ../exclude-files orig/arch/um/fs/hostfs/hostfs.h um/arch/um/fs/hostfs/hostfs.h
12205 --- orig/arch/um/fs/hostfs/hostfs.h 1969-12-31 19:00:00.000000000 -0500
12206 +++ um/arch/um/fs/hostfs/hostfs.h 2003-12-17 10:52:50.000000000 -0500
12208 +#ifndef __UM_FS_HOSTFS
12209 +#define __UM_FS_HOSTFS
12213 +/* These are exactly the same definitions as in fs.h, but the names are
12214 + * changed so that this file can be included in both kernel and user files.
12217 +#define HOSTFS_ATTR_MODE 1
12218 +#define HOSTFS_ATTR_UID 2
12219 +#define HOSTFS_ATTR_GID 4
12220 +#define HOSTFS_ATTR_SIZE 8
12221 +#define HOSTFS_ATTR_ATIME 16
12222 +#define HOSTFS_ATTR_MTIME 32
12223 +#define HOSTFS_ATTR_CTIME 64
12224 +#define HOSTFS_ATTR_ATIME_SET 128
12225 +#define HOSTFS_ATTR_MTIME_SET 256
12226 +#define HOSTFS_ATTR_FORCE 512 /* Not a change, but a change it */
12227 +#define HOSTFS_ATTR_ATTR_FLAG 1024
12229 +struct hostfs_iattr {
12230 + unsigned int ia_valid;
12238 + unsigned int ia_attr_flags;
12241 +extern int stat_file(const char *path, int *dev_out,
12242 + unsigned long long *inode_out, int *mode_out,
12243 + int *nlink_out, int *uid_out, int *gid_out,
12244 + unsigned long long *size_out, unsigned long *atime_out,
12245 + unsigned long *mtime_out, unsigned long *ctime_out,
12246 + int *blksize_out, unsigned long long *blocks_out);
12247 +extern int access_file(char *path, int r, int w, int x);
12248 +extern int open_file(char *path, int r, int w, int append);
12249 +extern int file_type(const char *path, int *rdev);
12250 +extern void *open_dir(char *path, int *err_out);
12251 +extern char *read_dir(void *stream, unsigned long long *pos,
12252 + unsigned long long *ino_out, int *len_out);
12253 +extern void close_file(void *stream);
12254 +extern void close_dir(void *stream);
12255 +extern int read_file(int fd, unsigned long long *offset, char *buf, int len);
12256 +extern int write_file(int fd, unsigned long long *offset, const char *buf,
12258 +extern int lseek_file(int fd, long long offset, int whence);
12259 +extern int file_create(char *name, int ur, int uw, int ux, int gr,
12260 + int gw, int gx, int or, int ow, int ox);
12261 +extern int set_attr(const char *file, struct hostfs_iattr *attrs);
12262 +extern int make_symlink(const char *from, const char *to);
12263 +extern int unlink_file(const char *file);
12264 +extern int do_mkdir(const char *file, int mode);
12265 +extern int do_rmdir(const char *file);
12266 +extern int do_mknod(const char *file, int mode, int dev);
12267 +extern int link_file(const char *from, const char *to);
12268 +extern int do_readlink(char *file, char *buf, int size);
12269 +extern int rename_file(char *from, char *to);
12270 +extern int do_statfs(char *root, long *bsize_out, long long *blocks_out,
12271 + long long *bfree_out, long long *bavail_out,
12272 + long long *files_out, long long *ffree_out,
12273 + void *fsid_out, int fsid_size, long *namelen_out,
12274 + long *spare_out);
12277 diff -Naur -X ../exclude-files orig/arch/um/fs/hostfs/hostfs_kern.c um/arch/um/fs/hostfs/hostfs_kern.c
12278 --- orig/arch/um/fs/hostfs/hostfs_kern.c 1969-12-31 19:00:00.000000000 -0500
12279 +++ um/arch/um/fs/hostfs/hostfs_kern.c 2003-10-21 03:26:06.000000000 -0400
12282 + * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
12283 + * Licensed under the GPL
12286 +#include <linux/stddef.h>
12287 +#include <linux/fs.h>
12288 +#include <linux/version.h>
12289 +#include <linux/module.h>
12290 +#include <linux/init.h>
12291 +#include <linux/slab.h>
12292 +#include <linux/pagemap.h>
12293 +#include <linux/blkdev.h>
12294 +#include <asm/uaccess.h>
12295 +#include "hostfs.h"
12296 +#include "kern_util.h"
12298 +#include "user_util.h"
12299 +#include "2_5compat.h"
12302 +#define file_hostfs_i(file) (&(file)->f_dentry->d_inode->u.hostfs_i)
12304 +int hostfs_d_delete(struct dentry *dentry)
12309 +struct dentry_operations hostfs_dentry_ops = {
12310 + .d_delete = hostfs_d_delete,
12313 +#define DEFAULT_ROOT "/"
12315 +/* Changed in hostfs_args before the kernel starts running */
12316 +static char *jail_dir = NULL;
12317 +static int append = 0;
12319 +#define HOSTFS_SUPER_MAGIC 0x00c0ffee
12321 +static struct inode_operations hostfs_iops;
12322 +static struct inode_operations hostfs_dir_iops;
12323 +static struct address_space_operations hostfs_link_aops;
12325 +static int __init hostfs_args(char *options, int *add)
12329 + ptr = strchr(options, ',');
12332 + if(*options != '\0')
12333 + jail_dir = options;
12337 + ptr = strchr(options, ',');
12340 + if(*options != '\0'){
12341 + if(!strcmp(options, "append"))
12343 + else printf("hostfs_args - unsupported option - %s\n",
12351 +__uml_setup("hostfs=", hostfs_args,
12352 +"hostfs=<root dir>,<flags>,...\n"
12353 +" This is used to set hostfs parameters. The root directory argument\n"
12354 +" is used to confine all hostfs mounts to within the specified directory\n"
12355 +" tree on the host. If this isn't specified, then a user inside UML can\n"
12356 +" mount anything on the host that's accessible to the user that's running\n"
12358 +" The only flag currently supported is 'append', which specifies that all\n"
12359 +" files opened by hostfs will be opened in append mode.\n\n"
12362 +static char *dentry_name(struct dentry *dentry, int extra)
12364 + struct dentry *parent;
12365 + char *root, *name;
12370 + while(parent->d_parent != parent){
12371 + len += parent->d_name.len + 1;
12372 + parent = parent->d_parent;
12375 + root = parent->d_inode->u.hostfs_i.host_filename;
12376 + len += strlen(root);
12377 + name = kmalloc(len + extra + 1, GFP_KERNEL);
12378 + if(name == NULL) return(NULL);
12380 + name[len] = '\0';
12382 + while(parent->d_parent != parent){
12383 + len -= parent->d_name.len + 1;
12385 + strncpy(&name[len + 1], parent->d_name.name,
12386 + parent->d_name.len);
12387 + parent = parent->d_parent;
12389 + strncpy(name, root, strlen(root));
12393 +static char *inode_name(struct inode *ino, int extra)
12395 + struct dentry *dentry;
12397 + dentry = list_entry(ino->i_dentry.next, struct dentry, d_alias);
12398 + return(dentry_name(dentry, extra));
12401 +static int read_name(struct inode *ino, char *name)
12403 + /* The non-int inode fields are copied into ints by stat_file and
12404 + * then copied into the inode because passing the actual pointers
12405 + * in and having them treated as int * breaks on big-endian machines
12408 + int i_dev, i_mode, i_nlink, i_blksize;
12409 + unsigned long long i_size;
12410 + unsigned long long i_ino;
12411 + unsigned long long i_blocks;
12412 + err = stat_file(name, &i_dev, &i_ino, &i_mode, &i_nlink,
12413 + &ino->i_uid, &ino->i_gid, &i_size, &ino->i_atime,
12414 + &ino->i_mtime, &ino->i_ctime, &i_blksize, &i_blocks);
12415 + if(err) return(err);
12416 + ino->i_ino = i_ino;
12417 + ino->i_dev = i_dev;
12418 + ino->i_mode = i_mode;
12419 + ino->i_nlink = i_nlink;
12420 + ino->i_size = i_size;
12421 + ino->i_blksize = i_blksize;
12422 + ino->i_blocks = i_blocks;
12423 + if(kdev_same(ino->i_sb->s_dev, ROOT_DEV) && (ino->i_uid == getuid()))
12428 +static char *follow_link(char *link)
12431 + char *name, *resolved, *end;
12436 + name = kmalloc(len, GFP_KERNEL);
12440 + n = do_readlink(link, name, len);
12452 + end = strrchr(link, '/');
12456 + *(end + 1) = '\0';
12457 + len = strlen(link) + strlen(name) + 1;
12459 + resolved = kmalloc(len, GFP_KERNEL);
12460 + if(resolved == NULL){
12465 + sprintf(resolved, "%s%s", link, name);
12468 + return(resolved);
12473 + return(ERR_PTR(n));
12476 +static int read_inode(struct inode *ino)
12482 + name = inode_name(ino, 0);
12486 + if(file_type(name, NULL) == OS_TYPE_SYMLINK){
12487 + name = follow_link(name);
12488 + if(IS_ERR(name)){
12489 + err = PTR_ERR(name);
12494 + err = read_name(ino, name);
12500 +void hostfs_delete_inode(struct inode *ino)
12502 + if(ino->u.hostfs_i.host_filename)
12503 + kfree(ino->u.hostfs_i.host_filename);
12504 + ino->u.hostfs_i.host_filename = NULL;
12506 + if(ino->u.hostfs_i.fd != -1)
12507 + close_file(&ino->u.hostfs_i.fd);
12509 + ino->u.hostfs_i.mode = 0;
12510 + clear_inode(ino);
12513 +int hostfs_statfs(struct super_block *sb, struct statfs *sf)
12515 + /* do_statfs uses struct statfs64 internally, but the linux kernel
12516 + * struct statfs still has 32-bit versions for most of these fields,
12517 + * so we convert them here
12520 + long long f_blocks;
12521 + long long f_bfree;
12522 + long long f_bavail;
12523 + long long f_files;
12524 + long long f_ffree;
12526 + err = do_statfs(sb->s_root->d_inode->u.hostfs_i.host_filename,
12527 + &sf->f_bsize, &f_blocks, &f_bfree, &f_bavail, &f_files,
12528 + &f_ffree, &sf->f_fsid, sizeof(sf->f_fsid),
12529 + &sf->f_namelen, sf->f_spare);
12530 + if(err) return(err);
12531 + sf->f_blocks = f_blocks;
12532 + sf->f_bfree = f_bfree;
12533 + sf->f_bavail = f_bavail;
12534 + sf->f_files = f_files;
12535 + sf->f_ffree = f_ffree;
12536 + sf->f_type = HOSTFS_SUPER_MAGIC;
12540 +static struct super_operations hostfs_sbops = {
12541 + .put_inode = force_delete,
12542 + .delete_inode = hostfs_delete_inode,
12543 + .statfs = hostfs_statfs,
12546 +int hostfs_readdir(struct file *file, void *ent, filldir_t filldir)
12550 + unsigned long long next, ino;
12553 + name = dentry_name(file->f_dentry, 0);
12554 + if(name == NULL) return(-ENOMEM);
12555 + dir = open_dir(name, &error);
12557 + if(dir == NULL) return(-error);
12558 + next = file->f_pos;
12559 + while((name = read_dir(dir, &next, &ino, &len)) != NULL){
12560 + error = (*filldir)(ent, name, len, file->f_pos,
12561 + ino, DT_UNKNOWN);
12563 + file->f_pos = next;
12569 +int hostfs_file_open(struct inode *ino, struct file *file)
12572 + int mode = 0, r = 0, w = 0, fd;
12574 + mode = file->f_mode & (FMODE_READ | FMODE_WRITE);
12575 + if((mode & ino->u.hostfs_i.mode) == mode)
12578 + /* The file may already have been opened, but with the wrong access,
12579 + * so this resets things and reopens the file with the new access.
12581 + if(ino->u.hostfs_i.fd != -1){
12582 + close_file(&ino->u.hostfs_i.fd);
12583 + ino->u.hostfs_i.fd = -1;
12586 + ino->u.hostfs_i.mode |= mode;
12587 + if(ino->u.hostfs_i.mode & FMODE_READ)
12589 + if(ino->u.hostfs_i.mode & FMODE_WRITE)
12594 + name = dentry_name(file->f_dentry, 0);
12598 + fd = open_file(name, r, w, append);
12600 + if(fd < 0) return(fd);
12601 + file_hostfs_i(file)->fd = fd;
12606 +int hostfs_dir_open(struct inode *ino, struct file *file)
12611 +int hostfs_dir_release(struct inode *ino, struct file *file)
12616 +int hostfs_fsync(struct file *file, struct dentry *dentry, int datasync)
12621 +static struct file_operations hostfs_file_fops = {
12623 + .read = generic_file_read,
12624 + .write = generic_file_write,
12625 + .mmap = generic_file_mmap,
12626 + .open = hostfs_file_open,
12628 + .fsync = hostfs_fsync,
12631 +static struct file_operations hostfs_dir_fops = {
12633 + .readdir = hostfs_readdir,
12634 + .open = hostfs_dir_open,
12635 + .release = hostfs_dir_release,
12636 + .fsync = hostfs_fsync,
12639 +int hostfs_writepage(struct page *page)
12641 + struct address_space *mapping = page->mapping;
12642 + struct inode *inode = mapping->host;
12644 + unsigned long long base;
12645 + int count = PAGE_CACHE_SIZE;
12646 + int end_index = inode->i_size >> PAGE_CACHE_SHIFT;
12649 + if (page->index >= end_index)
12650 + count = inode->i_size & (PAGE_CACHE_SIZE-1);
12652 + buffer = kmap(page);
12653 + base = ((unsigned long long) page->index) << PAGE_CACHE_SHIFT;
12655 + err = write_file(inode->u.hostfs_i.fd, &base, buffer, count);
12656 + if(err != count){
12657 + ClearPageUptodate(page);
12661 + if (base > inode->i_size)
12662 + inode->i_size = base;
12664 + if (PageError(page))
12665 + ClearPageError(page);
12671 + UnlockPage(page);
12675 +int hostfs_readpage(struct file *file, struct page *page)
12681 + start = (long long) page->index << PAGE_CACHE_SHIFT;
12682 + buffer = kmap(page);
12683 + err = read_file(file_hostfs_i(file)->fd, &start, buffer,
12684 + PAGE_CACHE_SIZE);
12685 + if(err < 0) goto out;
12687 + memset(&buffer[err], 0, PAGE_CACHE_SIZE - err);
12689 + flush_dcache_page(page);
12690 + SetPageUptodate(page);
12691 + if (PageError(page)) ClearPageError(page);
12695 + UnlockPage(page);
12699 +int hostfs_prepare_write(struct file *file, struct page *page,
12700 + unsigned int from, unsigned int to)
12703 + long long start, tmp;
12706 + start = (long long) page->index << PAGE_CACHE_SHIFT;
12707 + buffer = kmap(page);
12710 + err = read_file(file_hostfs_i(file)->fd, &tmp, buffer,
12712 + if(err < 0) goto out;
12714 + if(to != PAGE_CACHE_SIZE){
12716 + err = read_file(file_hostfs_i(file)->fd, &start, buffer + to,
12717 + PAGE_CACHE_SIZE - to);
12718 + if(err < 0) goto out;
12726 +int hostfs_commit_write(struct file *file, struct page *page, unsigned from,
12729 + struct address_space *mapping = page->mapping;
12730 + struct inode *inode = mapping->host;
12735 + start = (long long) (page->index << PAGE_CACHE_SHIFT) + from;
12736 + buffer = kmap(page);
12737 + err = write_file(file_hostfs_i(file)->fd, &start, buffer + from,
12739 + if(err > 0) err = 0;
12740 + if(!err && (start > inode->i_size))
12741 + inode->i_size = start;
12747 +static struct address_space_operations hostfs_aops = {
12748 + .writepage = hostfs_writepage,
12749 + .readpage = hostfs_readpage,
12750 +/* .set_page_dirty = __set_page_dirty_nobuffers, */
12751 + .prepare_write = hostfs_prepare_write,
12752 + .commit_write = hostfs_commit_write
12755 +static struct inode *get_inode(struct super_block *sb, struct dentry *dentry,
12758 + struct inode *inode;
12760 + int type, err = -ENOMEM, rdev;
12762 + inode = new_inode(sb);
12763 + if(inode == NULL)
12766 + inode->u.hostfs_i.host_filename = NULL;
12767 + inode->u.hostfs_i.fd = -1;
12768 + inode->u.hostfs_i.mode = 0;
12769 + insert_inode_hash(inode);
12771 + name = dentry_name(dentry, 0);
12772 + if(name == NULL){
12776 + type = file_type(name, &rdev);
12779 + else type = OS_TYPE_DIR;
12780 + inode->i_sb = sb;
12783 + if(type == OS_TYPE_SYMLINK)
12784 + inode->i_op = &page_symlink_inode_operations;
12785 + else if(type == OS_TYPE_DIR)
12786 + inode->i_op = &hostfs_dir_iops;
12787 + else inode->i_op = &hostfs_iops;
12789 + if(type == OS_TYPE_DIR) inode->i_fop = &hostfs_dir_fops;
12790 + else inode->i_fop = &hostfs_file_fops;
12792 + if(type == OS_TYPE_SYMLINK)
12793 + inode->i_mapping->a_ops = &hostfs_link_aops;
12794 + else inode->i_mapping->a_ops = &hostfs_aops;
12797 + case OS_TYPE_CHARDEV:
12798 + init_special_inode(inode, S_IFCHR, rdev);
12800 + case OS_TYPE_BLOCKDEV:
12801 + init_special_inode(inode, S_IFBLK, rdev);
12803 + case OS_TYPE_FIFO:
12804 + init_special_inode(inode, S_IFIFO, 0);
12806 + case OS_TYPE_SOCK:
12807 + init_special_inode(inode, S_IFSOCK, 0);
12811 + if(error) *error = err;
12814 + make_bad_inode(inode);
12817 + if(error) *error = err;
12821 +int hostfs_create(struct inode *dir, struct dentry *dentry, int mode)
12823 + struct inode *inode;
12827 + inode = get_inode(dir->i_sb, dentry, &error);
12828 + if(error) return(error);
12829 + name = dentry_name(dentry, 0);
12830 + if(name == NULL){
12834 + fd = file_create(name,
12835 + mode & S_IRUSR, mode & S_IWUSR, mode & S_IXUSR,
12836 + mode & S_IRGRP, mode & S_IWGRP, mode & S_IXGRP,
12837 + mode & S_IROTH, mode & S_IWOTH, mode & S_IXOTH);
12840 + else error = read_name(inode, name);
12847 + inode->u.hostfs_i.fd = fd;
12848 + inode->u.hostfs_i.mode = FMODE_READ | FMODE_WRITE;
12849 + d_instantiate(dentry, inode);
12853 +struct dentry *hostfs_lookup(struct inode *ino, struct dentry *dentry)
12855 + struct inode *inode;
12859 + inode = get_inode(ino->i_sb, dentry, &error);
12860 + if(error != 0) return(ERR_PTR(error));
12861 + name = dentry_name(dentry, 0);
12862 + if(name == NULL) return(ERR_PTR(-ENOMEM));
12863 + error = read_name(inode, name);
12867 + if(error == -ENOENT) inode = NULL;
12868 + else return(ERR_PTR(error));
12870 + d_add(dentry, inode);
12871 + dentry->d_op = &hostfs_dentry_ops;
12875 +static char *inode_dentry_name(struct inode *ino, struct dentry *dentry)
12880 + file = inode_name(ino, dentry->d_name.len + 1);
12881 + if(file == NULL) return(NULL);
12882 + strcat(file, "/");
12883 + len = strlen(file);
12884 + strncat(file, dentry->d_name.name, dentry->d_name.len);
12885 + file[len + dentry->d_name.len] = '\0';
12889 +int hostfs_link(struct dentry *to, struct inode *ino, struct dentry *from)
12891 + char *from_name, *to_name;
12894 + from_name = inode_dentry_name(ino, from);
12895 + if(from_name == NULL)
12897 + to_name = dentry_name(to, 0);
12898 + if(to_name == NULL){
12899 + kfree(from_name);
12902 + err = link_file(to_name, from_name);
12903 + kfree(from_name);
12908 +int hostfs_unlink(struct inode *ino, struct dentry *dentry)
12913 + file = inode_dentry_name(ino, dentry);
12914 + if(file == NULL) return(-ENOMEM);
12918 + err = unlink_file(file);
12923 +int hostfs_symlink(struct inode *ino, struct dentry *dentry, const char *to)
12928 + file = inode_dentry_name(ino, dentry);
12929 + if(file == NULL) return(-ENOMEM);
12930 + err = make_symlink(file, to);
12935 +int hostfs_mkdir(struct inode *ino, struct dentry *dentry, int mode)
12940 + file = inode_dentry_name(ino, dentry);
12941 + if(file == NULL) return(-ENOMEM);
12942 + err = do_mkdir(file, mode);
12947 +int hostfs_rmdir(struct inode *ino, struct dentry *dentry)
12952 + file = inode_dentry_name(ino, dentry);
12953 + if(file == NULL) return(-ENOMEM);
12954 + err = do_rmdir(file);
12959 +int hostfs_mknod(struct inode *dir, struct dentry *dentry, int mode, int dev)
12961 + struct inode *inode;
12965 + inode = get_inode(dir->i_sb, dentry, &error);
12966 + if(error) return(error);
12967 + name = dentry_name(dentry, 0);
12968 + if(name == NULL){
12972 + init_special_inode(inode, mode, dev);
12973 + error = do_mknod(name, mode, dev);
12974 + if(!error) error = read_name(inode, name);
12980 + d_instantiate(dentry, inode);
12984 +int hostfs_rename(struct inode *from_ino, struct dentry *from,
12985 + struct inode *to_ino, struct dentry *to)
12987 + char *from_name, *to_name;
12990 + from_name = inode_dentry_name(from_ino, from);
12991 + if(from_name == NULL)
12993 + to_name = inode_dentry_name(to_ino, to);
12994 + if(to_name == NULL){
12995 + kfree(from_name);
12998 + err = rename_file(from_name, to_name);
12999 + kfree(from_name);
13004 +void hostfs_truncate(struct inode *ino)
13006 + not_implemented();
13009 +int hostfs_permission(struct inode *ino, int desired)
13012 + int r = 0, w = 0, x = 0, err;
13014 + if(desired & MAY_READ) r = 1;
13015 + if(desired & MAY_WRITE) w = 1;
13016 + if(desired & MAY_EXEC) x = 1;
13017 + name = inode_name(ino, 0);
13018 + if(name == NULL) return(-ENOMEM);
13019 + err = access_file(name, r, w, x);
13021 + if(!err) err = vfs_permission(ino, desired);
13025 +int hostfs_setattr(struct dentry *dentry, struct iattr *attr)
13027 + struct hostfs_iattr attrs;
13032 + attr->ia_valid &= ~ATTR_SIZE;
13034 + attrs.ia_valid = 0;
13035 + if(attr->ia_valid & ATTR_MODE){
13036 + attrs.ia_valid |= HOSTFS_ATTR_MODE;
13037 + attrs.ia_mode = attr->ia_mode;
13039 + if(attr->ia_valid & ATTR_UID){
13040 + if(kdev_same(dentry->d_inode->i_sb->s_dev, ROOT_DEV) &&
13041 + (attr->ia_uid == 0))
13042 + attr->ia_uid = getuid();
13043 + attrs.ia_valid |= HOSTFS_ATTR_UID;
13044 + attrs.ia_uid = attr->ia_uid;
13046 + if(attr->ia_valid & ATTR_GID){
13047 + if(kdev_same(dentry->d_inode->i_sb->s_dev, ROOT_DEV) &&
13048 + (attr->ia_gid == 0))
13049 + attr->ia_gid = getuid();
13050 + attrs.ia_valid |= HOSTFS_ATTR_GID;
13051 + attrs.ia_gid = attr->ia_gid;
13053 + if(attr->ia_valid & ATTR_SIZE){
13054 + attrs.ia_valid |= HOSTFS_ATTR_SIZE;
13055 + attrs.ia_size = attr->ia_size;
13057 + if(attr->ia_valid & ATTR_ATIME){
13058 + attrs.ia_valid |= HOSTFS_ATTR_ATIME;
13059 + attrs.ia_atime = attr->ia_atime;
13061 + if(attr->ia_valid & ATTR_MTIME){
13062 + attrs.ia_valid |= HOSTFS_ATTR_MTIME;
13063 + attrs.ia_mtime = attr->ia_mtime;
13065 + if(attr->ia_valid & ATTR_CTIME){
13066 + attrs.ia_valid |= HOSTFS_ATTR_CTIME;
13067 + attrs.ia_ctime = attr->ia_ctime;
13069 + if(attr->ia_valid & ATTR_ATIME_SET){
13070 + attrs.ia_valid |= HOSTFS_ATTR_ATIME_SET;
13072 + if(attr->ia_valid & ATTR_MTIME_SET){
13073 + attrs.ia_valid |= HOSTFS_ATTR_MTIME_SET;
13075 + name = dentry_name(dentry, 0);
13076 + if(name == NULL) return(-ENOMEM);
13077 + err = set_attr(name, &attrs);
13082 + return(inode_setattr(dentry->d_inode, attr));
13085 +int hostfs_getattr(struct dentry *dentry, struct iattr *attr)
13087 + not_implemented();
13091 +static struct inode_operations hostfs_iops = {
13092 + .create = hostfs_create,
13093 + .link = hostfs_link,
13094 + .unlink = hostfs_unlink,
13095 + .symlink = hostfs_symlink,
13096 + .mkdir = hostfs_mkdir,
13097 + .rmdir = hostfs_rmdir,
13098 + .mknod = hostfs_mknod,
13099 + .rename = hostfs_rename,
13100 + .truncate = hostfs_truncate,
13101 + .permission = hostfs_permission,
13102 + .setattr = hostfs_setattr,
13103 + .getattr = hostfs_getattr,
13106 +static struct inode_operations hostfs_dir_iops = {
13107 + .create = hostfs_create,
13108 + .lookup = hostfs_lookup,
13109 + .link = hostfs_link,
13110 + .unlink = hostfs_unlink,
13111 + .symlink = hostfs_symlink,
13112 + .mkdir = hostfs_mkdir,
13113 + .rmdir = hostfs_rmdir,
13114 + .mknod = hostfs_mknod,
13115 + .rename = hostfs_rename,
13116 + .truncate = hostfs_truncate,
13117 + .permission = hostfs_permission,
13118 + .setattr = hostfs_setattr,
13119 + .getattr = hostfs_getattr,
13122 +int hostfs_link_readpage(struct file *file, struct page *page)
13124 + char *buffer, *name;
13128 + start = page->index << PAGE_CACHE_SHIFT;
13129 + buffer = kmap(page);
13130 + name = inode_name(page->mapping->host, 0);
13131 + if(name == NULL) return(-ENOMEM);
13132 + err = do_readlink(name, buffer, PAGE_CACHE_SIZE);
13134 + if(err == PAGE_CACHE_SIZE)
13136 + else if(err > 0){
13137 + flush_dcache_page(page);
13138 + SetPageUptodate(page);
13139 + if (PageError(page)) ClearPageError(page);
13143 + UnlockPage(page);
13147 +static struct address_space_operations hostfs_link_aops = {
13148 + .readpage = hostfs_link_readpage,
13151 +static char *get_root(char *mount_arg)
13153 + char *root, *slash = "";
13156 + if(jail_dir != NULL){
13157 + len += strlen(jail_dir);
13158 + if((*jail_dir == '\0') ||
13159 + (jail_dir[strlen(jail_dir) - 1] != '/'))
13161 + len += strlen(slash);
13164 + if((mount_arg == NULL) || (*mount_arg == '\0'))
13165 + mount_arg = DEFAULT_ROOT;
13167 + len += strlen(mount_arg) + 1;
13169 + root = kmalloc(len, GFP_KERNEL);
13173 + if(jail_dir != NULL)
13174 + sprintf(root, "%s%s%s", jail_dir, slash, mount_arg);
13176 + strcpy(root, mount_arg);
13181 +struct super_block *hostfs_read_super(struct super_block *sb, void *data,
13184 + struct inode *root_inode;
13187 + sb->s_blocksize = 1024;
13188 + sb->s_blocksize_bits = 10;
13189 + sb->s_magic = HOSTFS_SUPER_MAGIC;
13190 + sb->s_op = &hostfs_sbops;
13192 + root_inode = get_inode(sb, NULL, NULL);
13193 + if(root_inode == NULL)
13196 + root_dir = get_root(data);
13197 + if(root_dir == NULL)
13200 + root_inode->u.hostfs_i.host_filename = root_dir;
13201 + sb->s_root = d_alloc_root(root_inode);
13202 + if(sb->s_root == NULL)
13205 + if(read_inode(root_inode))
13210 + dput(sb->s_root);
13214 + make_bad_inode(root_inode);
13215 + iput(root_inode);
13220 +DECLARE_FSTYPE(hostfs_type, "hostfs", hostfs_read_super, 0);
13222 +static int __init init_hostfs(void)
13224 + return(register_filesystem(&hostfs_type));
13227 +static void __exit exit_hostfs(void)
13229 + unregister_filesystem(&hostfs_type);
13232 +module_init(init_hostfs)
13233 +module_exit(exit_hostfs)
13234 +MODULE_LICENSE("GPL");
13237 + * Overrides for Emacs so that we follow Linus's tabbing style.
13238 + * Emacs will notice this stuff at the end of the file and automatically
13239 + * adjust the settings for this buffer only. This must remain at the end
13241 + * ---------------------------------------------------------------------------
13242 + * Local variables:
13243 + * c-file-style: "linux"
13246 diff -Naur -X ../exclude-files orig/arch/um/fs/hostfs/hostfs_user.c um/arch/um/fs/hostfs/hostfs_user.c
13247 --- orig/arch/um/fs/hostfs/hostfs_user.c 1969-12-31 19:00:00.000000000 -0500
13248 +++ um/arch/um/fs/hostfs/hostfs_user.c 2003-11-14 08:51:20.000000000 -0500
13251 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
13252 + * Licensed under the GPL
13255 +#include <unistd.h>
13256 +#include <stdio.h>
13257 +#include <fcntl.h>
13258 +#include <dirent.h>
13259 +#include <errno.h>
13260 +#include <utime.h>
13261 +#include <string.h>
13262 +#include <sys/stat.h>
13263 +#include <sys/time.h>
13264 +#include <sys/vfs.h>
13265 +#include "hostfs.h"
13266 +#include "kern_util.h"
13269 +int stat_file(const char *path, int *dev_out, unsigned long long *inode_out,
13270 + int *mode_out, int *nlink_out, int *uid_out, int *gid_out,
13271 + unsigned long long *size_out, unsigned long *atime_out,
13272 + unsigned long *mtime_out, unsigned long *ctime_out,
13273 + int *blksize_out, unsigned long long *blocks_out)
13275 + struct stat64 buf;
13277 + if(lstat64(path, &buf) < 0)
13279 + if(dev_out != NULL) *dev_out = buf.st_dev;
13281 + /* See the Makefile for why STAT64_INO_FIELD is passed in
13284 + if(inode_out != NULL) *inode_out = buf.STAT64_INO_FIELD;
13285 + if(mode_out != NULL) *mode_out = buf.st_mode;
13286 + if(nlink_out != NULL) *nlink_out = buf.st_nlink;
13287 + if(uid_out != NULL) *uid_out = buf.st_uid;
13288 + if(gid_out != NULL) *gid_out = buf.st_gid;
13289 + if(size_out != NULL) *size_out = buf.st_size;
13290 + if(atime_out != NULL) *atime_out = buf.st_atime;
13291 + if(mtime_out != NULL) *mtime_out = buf.st_mtime;
13292 + if(ctime_out != NULL) *ctime_out = buf.st_ctime;
13293 + if(blksize_out != NULL) *blksize_out = buf.st_blksize;
13294 + if(blocks_out != NULL) *blocks_out = buf.st_blocks;
13298 +int file_type(const char *path, int *rdev)
13300 + struct stat64 buf;
13302 + if(lstat64(path, &buf) < 0)
13305 + *rdev = buf.st_rdev;
13307 + if(S_ISDIR(buf.st_mode)) return(OS_TYPE_DIR);
13308 + else if(S_ISLNK(buf.st_mode)) return(OS_TYPE_SYMLINK);
13309 + else if(S_ISCHR(buf.st_mode)) return(OS_TYPE_CHARDEV);
13310 + else if(S_ISBLK(buf.st_mode)) return(OS_TYPE_BLOCKDEV);
13311 + else if(S_ISFIFO(buf.st_mode))return(OS_TYPE_FIFO);
13312 + else if(S_ISSOCK(buf.st_mode))return(OS_TYPE_SOCK);
13313 + else return(OS_TYPE_FILE);
13316 +int access_file(char *path, int r, int w, int x)
13320 + if(r) mode = R_OK;
13321 + if(w) mode |= W_OK;
13322 + if(x) mode |= X_OK;
13323 + if(access(path, mode) != 0) return(-errno);
13327 +int open_file(char *path, int r, int w, int append)
13329 + int mode = 0, fd;
13337 + else panic("Impossible mode in open_file");
13340 + mode |= O_APPEND;
13341 + fd = open64(path, mode);
13342 + if(fd < 0) return(-errno);
13346 +void *open_dir(char *path, int *err_out)
13350 + dir = opendir(path);
13351 + *err_out = errno;
13352 + if(dir == NULL) return(NULL);
13356 +char *read_dir(void *stream, unsigned long long *pos,
13357 + unsigned long long *ino_out, int *len_out)
13359 + DIR *dir = stream;
13360 + struct dirent *ent;
13362 + seekdir(dir, *pos);
13363 + ent = readdir(dir);
13364 + if(ent == NULL) return(NULL);
13365 + *len_out = strlen(ent->d_name);
13366 + *ino_out = ent->d_ino;
13367 + *pos = telldir(dir);
13368 + return(ent->d_name);
13371 +int read_file(int fd, unsigned long long *offset, char *buf, int len)
13375 + err = os_seek_file(fd, *offset);
13379 + n = os_read_file(fd, buf, len);
13387 +int write_file(int fd, unsigned long long *offset, const char *buf, int len)
13391 + err = os_seek_file(fd, *offset);
13395 + n = os_write_file(fd, buf, len);
13403 +int lseek_file(int fd, long long offset, int whence)
13407 + ret = lseek64(fd, offset, whence);
13408 + if(ret < 0) return(-errno);
13412 +void close_file(void *stream)
13414 + close(*((int *) stream));
13417 +void close_dir(void *stream)
13419 + closedir(stream);
13422 +int file_create(char *name, int ur, int uw, int ux, int gr,
13423 + int gw, int gx, int or, int ow, int ox)
13428 + mode |= ur ? S_IRUSR : 0;
13429 + mode |= uw ? S_IWUSR : 0;
13430 + mode |= ux ? S_IXUSR : 0;
13431 + mode |= gr ? S_IRGRP : 0;
13432 + mode |= gw ? S_IWGRP : 0;
13433 + mode |= gx ? S_IXGRP : 0;
13434 + mode |= or ? S_IROTH : 0;
13435 + mode |= ow ? S_IWOTH : 0;
13436 + mode |= ox ? S_IXOTH : 0;
13437 + fd = open64(name, O_CREAT | O_RDWR, mode);
13443 +int set_attr(const char *file, struct hostfs_iattr *attrs)
13445 + struct utimbuf buf;
13448 + if(attrs->ia_valid & HOSTFS_ATTR_MODE){
13449 + if(chmod(file, attrs->ia_mode) != 0) return(-errno);
13451 + if(attrs->ia_valid & HOSTFS_ATTR_UID){
13452 + if(chown(file, attrs->ia_uid, -1)) return(-errno);
13454 + if(attrs->ia_valid & HOSTFS_ATTR_GID){
13455 + if(chown(file, -1, attrs->ia_gid)) return(-errno);
13457 + if(attrs->ia_valid & HOSTFS_ATTR_SIZE){
13458 + if(truncate(file, attrs->ia_size)) return(-errno);
13460 + ma = HOSTFS_ATTR_ATIME_SET | HOSTFS_ATTR_MTIME_SET;
13461 + if((attrs->ia_valid & ma) == ma){
13462 + buf.actime = attrs->ia_atime;
13463 + buf.modtime = attrs->ia_mtime;
13464 + if(utime(file, &buf) != 0) return(-errno);
13467 + if(attrs->ia_valid & HOSTFS_ATTR_ATIME_SET){
13468 + err = stat_file(file, NULL, NULL, NULL, NULL, NULL,
13469 + NULL, NULL, NULL, &buf.modtime, NULL,
13471 + if(err != 0) return(err);
13472 + buf.actime = attrs->ia_atime;
13473 + if(utime(file, &buf) != 0) return(-errno);
13475 + if(attrs->ia_valid & HOSTFS_ATTR_MTIME_SET){
13476 + err = stat_file(file, NULL, NULL, NULL, NULL, NULL,
13477 + NULL, NULL, &buf.actime, NULL, NULL,
13479 + if(err != 0) return(err);
13480 + buf.modtime = attrs->ia_mtime;
13481 + if(utime(file, &buf) != 0) return(-errno);
13484 + if(attrs->ia_valid & HOSTFS_ATTR_CTIME) ;
13485 + if(attrs->ia_valid & (HOSTFS_ATTR_ATIME | HOSTFS_ATTR_MTIME)){
13486 + err = stat_file(file, NULL, NULL, NULL, NULL, NULL,
13487 + NULL, NULL, &attrs->ia_atime, &attrs->ia_mtime,
13488 + NULL, NULL, NULL);
13489 + if(err != 0) return(err);
13494 +int make_symlink(const char *from, const char *to)
13498 + err = symlink(to, from);
13499 + if(err) return(-errno);
13503 +int unlink_file(const char *file)
13507 + err = unlink(file);
13508 + if(err) return(-errno);
13512 +int do_mkdir(const char *file, int mode)
13516 + err = mkdir(file, mode);
13517 + if(err) return(-errno);
13521 +int do_rmdir(const char *file)
13525 + err = rmdir(file);
13526 + if(err) return(-errno);
13530 +int do_mknod(const char *file, int mode, int dev)
13534 + err = mknod(file, mode, dev);
13535 + if(err) return(-errno);
13539 +int link_file(const char *to, const char *from)
13543 + err = link(to, from);
13544 + if(err) return(-errno);
13548 +int do_readlink(char *file, char *buf, int size)
13552 + n = readlink(file, buf, size);
13560 +int rename_file(char *from, char *to)
13564 + err = rename(from, to);
13565 + if(err < 0) return(-errno);
13569 +int do_statfs(char *root, long *bsize_out, long long *blocks_out,
13570 + long long *bfree_out, long long *bavail_out,
13571 + long long *files_out, long long *ffree_out,
13572 + void *fsid_out, int fsid_size, long *namelen_out,
13575 + struct statfs64 buf;
13578 + err = statfs64(root, &buf);
13579 + if(err < 0) return(-errno);
13580 + *bsize_out = buf.f_bsize;
13581 + *blocks_out = buf.f_blocks;
13582 + *bfree_out = buf.f_bfree;
13583 + *bavail_out = buf.f_bavail;
13584 + *files_out = buf.f_files;
13585 + *ffree_out = buf.f_ffree;
13586 + memcpy(fsid_out, &buf.f_fsid,
13587 + sizeof(buf.f_fsid) > fsid_size ? fsid_size :
13588 + sizeof(buf.f_fsid));
13589 + *namelen_out = buf.f_namelen;
13590 + spare_out[0] = buf.f_spare[0];
13591 + spare_out[1] = buf.f_spare[1];
13592 + spare_out[2] = buf.f_spare[2];
13593 + spare_out[3] = buf.f_spare[3];
13594 + spare_out[4] = buf.f_spare[4];
13595 + spare_out[5] = buf.f_spare[5];
13600 + * Overrides for Emacs so that we follow Linus's tabbing style.
13601 + * Emacs will notice this stuff at the end of the file and automatically
13602 + * adjust the settings for this buffer only. This must remain at the end
13604 + * ---------------------------------------------------------------------------
13605 + * Local variables:
13606 + * c-file-style: "linux"
13609 diff -Naur -X ../exclude-files orig/arch/um/fs/hostfs/Makefile um/arch/um/fs/hostfs/Makefile
13610 --- orig/arch/um/fs/hostfs/Makefile 1969-12-31 19:00:00.000000000 -0500
13611 +++ um/arch/um/fs/hostfs/Makefile 2003-10-21 03:26:06.000000000 -0400
13614 +# Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
13615 +# Licensed under the GPL
13618 +# struct stat64 changed the inode field name between 2.2 and 2.4 from st_ino
13619 +# to __st_ino. It stayed in the same place, so as long as the correct name
13620 +# is used, hostfs compiled on 2.2 should work on 2.4 and vice versa.
13622 +STAT64_INO_FIELD := $(shell grep -q __st_ino /usr/include/bits/stat.h && \
13625 +USER_CFLAGS := $(USER_CFLAGS) -DSTAT64_INO_FIELD=$(STAT64_INO_FIELD)
13627 +O_TARGET := hostfs.o
13628 +obj-y = hostfs_kern.o hostfs_user.o
13629 +obj-m = $(O_TARGET)
13631 +USER_OBJS = $(filter %_user.o,$(obj-y))
13633 +include $(TOPDIR)/Rules.make
13635 +$(USER_OBJS) : %.o: %.c
13636 + $(CC) $(CFLAGS_$@) $(USER_CFLAGS) -c -o $@ $<
13637 diff -Naur -X ../exclude-files orig/arch/um/fs/hppfs/hppfs_kern.c um/arch/um/fs/hppfs/hppfs_kern.c
13638 --- orig/arch/um/fs/hppfs/hppfs_kern.c 1969-12-31 19:00:00.000000000 -0500
13639 +++ um/arch/um/fs/hppfs/hppfs_kern.c 2004-01-08 23:35:58.000000000 -0500
13642 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
13643 + * Licensed under the GPL
13646 +#include <linux/fs.h>
13647 +#include <linux/module.h>
13648 +#include <linux/slab.h>
13649 +#include <linux/list.h>
13650 +#include <linux/kernel.h>
13651 +#include <linux/ctype.h>
13652 +#include <asm/uaccess.h>
13655 +struct hppfs_data {
13656 + struct list_head list;
13657 + char contents[PAGE_SIZE - sizeof(struct list_head)];
13660 +struct hppfs_private {
13661 + struct file proc_file;
13664 + struct hppfs_data *contents;
13667 +#define HPPFS_SUPER_MAGIC 0xb00000ee
13669 +static struct super_operations hppfs_sbops;
13671 +static struct inode *get_inode(struct super_block *sb, struct dentry *dentry,
13674 +static int is_pid(struct dentry *dentry)
13676 + struct super_block *sb;
13679 + sb = dentry->d_sb;
13680 + if((sb->s_op != &hppfs_sbops) || (dentry->d_parent != sb->s_root))
13683 + for(i = 0; i < dentry->d_name.len; i++){
13684 + if(!isdigit(dentry->d_name.name[i]))
13690 +static char *dentry_name(struct dentry *dentry, int extra)
13692 + struct dentry *parent;
13693 + char *root, *name;
13694 + const char *seg_name;
13695 + int len, seg_len;
13699 + while(parent->d_parent != parent){
13700 + if(is_pid(parent))
13701 + len += strlen("pid") + 1;
13702 + else len += parent->d_name.len + 1;
13703 + parent = parent->d_parent;
13707 + len += strlen(root);
13708 + name = kmalloc(len + extra + 1, GFP_KERNEL);
13709 + if(name == NULL) return(NULL);
13711 + name[len] = '\0';
13713 + while(parent->d_parent != parent){
13714 + if(is_pid(parent)){
13715 + seg_name = "pid";
13716 + seg_len = strlen("pid");
13719 + seg_name = parent->d_name.name;
13720 + seg_len = parent->d_name.len;
13723 + len -= seg_len + 1;
13725 + strncpy(&name[len + 1], seg_name, seg_len);
13726 + parent = parent->d_parent;
13728 + strncpy(name, root, strlen(root));
13732 +struct dentry_operations hppfs_dentry_ops = {
13735 +static int file_removed(struct dentry *dentry, const char *file)
13741 + if(file != NULL) extra += strlen(file) + 1;
13743 + host_file = dentry_name(dentry, extra + strlen("/remove"));
13744 + if(host_file == NULL){
13745 + printk("file_removed : allocation failed\n");
13749 + if(file != NULL){
13750 + strcat(host_file, "/");
13751 + strcat(host_file, file);
13753 + strcat(host_file, "/remove");
13755 + fd = os_open_file(host_file, of_read(OPENFLAGS()), 0);
13756 + kfree(host_file);
13758 + os_close_file(fd);
13764 +static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry)
13766 + struct dentry *proc_dentry;
13767 + struct inode *inode;
13768 + int err, deleted;
13770 + deleted = file_removed(dentry, NULL);
13772 + return(ERR_PTR(deleted));
13774 + return(ERR_PTR(-ENOENT));
13776 + proc_dentry = lookup_hash(&dentry->d_name, ino->u.hppfs_i.proc_dentry);
13777 + if(IS_ERR(proc_dentry))
13778 + return(proc_dentry);
13780 + inode = get_inode(ino->i_sb, proc_dentry, &err);
13782 + return(ERR_PTR(err));
13784 + d_add(dentry, inode);
13785 + dentry->d_op = &hppfs_dentry_ops;
13789 +static struct inode_operations hppfs_file_iops = {
13792 +static struct inode_operations hppfs_dir_iops = {
13793 + .lookup = hppfs_lookup,
13796 +static ssize_t read_proc(struct file *file, char *buf, ssize_t count,
13797 + loff_t *ppos, int is_user)
13799 + ssize_t (*read)(struct file *, char *, size_t, loff_t *);
13802 + read = file->f_dentry->d_inode->i_fop->read;
13804 + return(-EOPNOTSUPP);
13807 + set_fs(KERNEL_DS);
13809 + n = (*read)(file, buf, count, &file->f_pos);
13814 + if(ppos) *ppos = file->f_pos;
13818 +static ssize_t hppfs_read_file(int fd, char *buf, ssize_t count)
13825 + new_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
13826 + if(new_buf == NULL){
13827 + printk("hppfs_read_file : kmalloc failed\n");
13831 + while(count > 0){
13832 + cur = min_t(ssize_t, count, PAGE_SIZE);
13833 + err = os_read_file(fd, new_buf, cur);
13835 + printk("hppfs_read : read failed, err = %d\n", -err);
13839 + else if(err == 0)
13842 + if(copy_to_user(buf, new_buf, err)){
13855 +static ssize_t hppfs_read(struct file *file, char *buf, size_t count,
13858 + struct hppfs_private *hppfs = file->private_data;
13859 + struct hppfs_data *data;
13863 + if(hppfs->contents != NULL){
13864 + if(*ppos >= hppfs->len) return(0);
13866 + data = hppfs->contents;
13868 + while(off >= sizeof(data->contents)){
13869 + data = list_entry(data->list.next, struct hppfs_data,
13871 + off -= sizeof(data->contents);
13874 + if(off + count > hppfs->len)
13875 + count = hppfs->len - off;
13876 + copy_to_user(buf, &data->contents[off], count);
13879 + else if(hppfs->host_fd != -1){
13880 + err = os_seek_file(hppfs->host_fd, *ppos);
13882 + printk("hppfs_read : seek failed, err = %d\n", -err);
13885 + count = hppfs_read_file(hppfs->host_fd, buf, count);
13889 + else count = read_proc(&hppfs->proc_file, buf, count, ppos, 1);
13894 +static ssize_t hppfs_write(struct file *file, const char *buf, size_t len,
13897 + struct hppfs_private *data = file->private_data;
13898 + struct file *proc_file = &data->proc_file;
13899 + ssize_t (*write)(struct file *, const char *, size_t, loff_t *);
13902 + write = proc_file->f_dentry->d_inode->i_fop->write;
13903 + if(write == NULL)
13904 + return(-EOPNOTSUPP);
13906 + proc_file->f_pos = file->f_pos;
13907 + err = (*write)(proc_file, buf, len, &proc_file->f_pos);
13908 + file->f_pos = proc_file->f_pos;
13913 +static int open_host_sock(char *host_file, int *filter_out)
13918 + end = &host_file[strlen(host_file)];
13919 + strcpy(end, "/rw");
13921 + fd = os_connect_socket(host_file);
13925 + strcpy(end, "/r");
13927 + fd = os_connect_socket(host_file);
13931 +static void free_contents(struct hppfs_data *head)
13933 + struct hppfs_data *data;
13934 + struct list_head *ele, *next;
13936 + if(head == NULL) return;
13938 + list_for_each_safe(ele, next, &head->list){
13939 + data = list_entry(ele, struct hppfs_data, list);
13945 +static struct hppfs_data *hppfs_get_data(int fd, int filter,
13946 + struct file *proc_file,
13947 + struct file *hppfs_file,
13948 + loff_t *size_out)
13950 + struct hppfs_data *data, *new, *head;
13954 + data = kmalloc(sizeof(*data), GFP_KERNEL);
13955 + if(data == NULL){
13956 + printk("hppfs_get_data : head allocation failed\n");
13960 + INIT_LIST_HEAD(&data->list);
13966 + while((n = read_proc(proc_file, data->contents,
13967 + sizeof(data->contents), NULL, 0)) > 0) {
13968 + err = os_write_file(fd, data->contents, n);
13970 + printk("hppfs_get_data : failed to write out "
13971 + "%d bytes, err = %d\n", n, -err);
13973 + err = os_shutdown_socket(fd, 0, 1);
13975 + printk("hppfs_get_data : failed to shut down "
13977 + goto failed_free;
13981 + n = os_read_file(fd, data->contents, sizeof(data->contents));
13984 + printk("hppfs_get_data : read failed, err = %d\n", -n);
13985 + goto failed_free;
13992 + if(n < sizeof(data->contents))
13995 + new = kmalloc(sizeof(*data), GFP_KERNEL);
13997 + printk("hppfs_get_data : data allocation failed\n");
13999 + goto failed_free;
14002 + INIT_LIST_HEAD(&new->list);
14003 + list_add(&new->list, &data->list);
14009 + free_contents(head);
14011 + return(ERR_PTR(err));
14014 +static struct hppfs_private *hppfs_data(void)
14016 + struct hppfs_private *data;
14018 + data = kmalloc(sizeof(*data), GFP_KERNEL);
14022 + *data = ((struct hppfs_private ) { .host_fd = -1,
14024 + .contents = NULL } );
14028 +static int hppfs_open(struct inode *inode, struct file *file)
14030 + struct hppfs_private *data;
14031 + struct dentry *proc_dentry;
14033 + int err, fd, type, filter;
14036 + data = hppfs_data();
14040 + host_file = dentry_name(file->f_dentry, strlen("/rw"));
14041 + if(host_file == NULL)
14044 + proc_dentry = inode->u.hppfs_i.proc_dentry;
14045 + err = init_private_file(&data->proc_file, proc_dentry, file->f_mode);
14049 + type = os_file_type(host_file);
14050 + if(type == OS_TYPE_FILE){
14051 + fd = os_open_file(host_file, of_read(OPENFLAGS()), 0);
14053 + data->host_fd = fd;
14054 + else printk("hppfs_open : failed to open '%s', err = %d\n",
14057 + data->contents = NULL;
14059 + else if(type == OS_TYPE_DIR){
14060 + fd = open_host_sock(host_file, &filter);
14062 + data->contents = hppfs_get_data(fd, filter,
14063 + &data->proc_file,
14064 + file, &data->len);
14065 + if(!IS_ERR(data->contents))
14066 + data->host_fd = fd;
14068 + else printk("hppfs_open : failed to open a socket in "
14069 + "'%s', err = %d\n", host_file, -fd);
14071 + kfree(host_file);
14073 + file->private_data = data;
14077 + kfree(host_file);
14079 + free_contents(data->contents);
14085 +static int hppfs_dir_open(struct inode *inode, struct file *file)
14087 + struct hppfs_private *data;
14088 + struct dentry *proc_dentry;
14092 + data = hppfs_data();
14096 + proc_dentry = inode->u.hppfs_i.proc_dentry;
14097 + err = init_private_file(&data->proc_file, proc_dentry, file->f_mode);
14101 + file->private_data = data;
14110 +static loff_t hppfs_llseek(struct file *file, loff_t off, int where)
14112 + struct hppfs_private *data = file->private_data;
14113 + struct file *proc_file = &data->proc_file;
14114 + loff_t (*llseek)(struct file *, loff_t, int);
14117 + llseek = proc_file->f_dentry->d_inode->i_fop->llseek;
14118 + if(llseek != NULL){
14119 + ret = (*llseek)(proc_file, off, where);
14124 + return(default_llseek(file, off, where));
14127 +struct hppfs_dirent {
14128 + void *vfs_dirent;
14129 + filldir_t filldir;
14130 + struct dentry *dentry;
14133 +static int hppfs_filldir(void *d, const char *name, int size,
14134 + loff_t offset, ino_t inode, unsigned int type)
14136 + struct hppfs_dirent *dirent = d;
14138 + if(file_removed(dirent->dentry, name))
14141 + return((*dirent->filldir)(dirent->vfs_dirent, name, size, offset,
14145 +static int hppfs_readdir(struct file *file, void *ent, filldir_t filldir)
14147 + struct hppfs_private *data = file->private_data;
14148 + struct file *proc_file = &data->proc_file;
14149 + int (*readdir)(struct file *, void *, filldir_t);
14150 + struct hppfs_dirent dirent = ((struct hppfs_dirent)
14151 + { .vfs_dirent = ent,
14152 + .filldir = filldir,
14153 + .dentry = file->f_dentry } );
14156 + readdir = proc_file->f_dentry->d_inode->i_fop->readdir;
14157 + if(readdir == NULL)
14158 + return(-EOPNOTSUPP);
14160 + proc_file->f_pos = file->f_pos;
14161 + err = (*readdir)(proc_file, &dirent, hppfs_filldir);
14162 + file->f_pos = proc_file->f_pos;
14167 +static int hppfs_fsync(struct file *file, struct dentry *dentry, int datasync)
14172 +static struct file_operations hppfs_file_fops = {
14174 + .llseek = hppfs_llseek,
14175 + .read = hppfs_read,
14176 + .write = hppfs_write,
14177 + .open = hppfs_open,
14180 +static struct file_operations hppfs_dir_fops = {
14182 + .readdir = hppfs_readdir,
14183 + .open = hppfs_dir_open,
14184 + .fsync = hppfs_fsync,
14187 +static int hppfs_statfs(struct super_block *sb, struct statfs *sf)
14189 + sf->f_blocks = 0;
14191 + sf->f_bavail = 0;
14194 + sf->f_type = HPPFS_SUPER_MAGIC;
14198 +static struct super_operations hppfs_sbops = {
14199 + .put_inode = force_delete,
14200 + .delete_inode = NULL,
14201 + .statfs = hppfs_statfs,
14204 +static int hppfs_readlink(struct dentry *dentry, char *buffer, int buflen)
14206 + struct file proc_file;
14207 + struct dentry *proc_dentry;
14208 + int (*readlink)(struct dentry *, char *, int);
14211 + proc_dentry = dentry->d_inode->u.hppfs_i.proc_dentry;
14212 + err = init_private_file(&proc_file, proc_dentry, FMODE_READ);
14216 + readlink = proc_dentry->d_inode->i_op->readlink;
14217 + if(readlink == NULL)
14218 + return(-EOPNOTSUPP);
14219 + n = (*readlink)(proc_dentry, buffer, buflen);
14221 + if(proc_file.f_op->release)
14222 + (*proc_file.f_op->release)(proc_dentry->d_inode, &proc_file);
14227 +static int hppfs_follow_link(struct dentry *dentry, struct nameidata *nd)
14229 + struct file proc_file;
14230 + struct dentry *proc_dentry;
14231 + int (*follow_link)(struct dentry *, struct nameidata *);
14234 + proc_dentry = dentry->d_inode->u.hppfs_i.proc_dentry;
14235 + err = init_private_file(&proc_file, proc_dentry, FMODE_READ);
14239 + follow_link = proc_dentry->d_inode->i_op->follow_link;
14240 + if(follow_link == NULL)
14241 + return(-EOPNOTSUPP);
14242 + n = (*follow_link)(proc_dentry, nd);
14244 + if(proc_file.f_op->release)
14245 + (*proc_file.f_op->release)(proc_dentry->d_inode, &proc_file);
14250 +static struct inode_operations hppfs_link_iops = {
14251 + .readlink = hppfs_readlink,
14252 + .follow_link = hppfs_follow_link,
14255 +static void read_inode(struct inode *ino)
14257 + struct inode *proc_ino;
14259 + proc_ino = ino->u.hppfs_i.proc_dentry->d_inode;
14260 + ino->i_uid = proc_ino->i_uid;
14261 + ino->i_gid = proc_ino->i_gid;
14262 + ino->i_atime = proc_ino->i_atime;
14263 + ino->i_mtime = proc_ino->i_mtime;
14264 + ino->i_ctime = proc_ino->i_ctime;
14265 + ino->i_ino = proc_ino->i_ino;
14266 + ino->i_dev = proc_ino->i_dev;
14267 + ino->i_mode = proc_ino->i_mode;
14268 + ino->i_nlink = proc_ino->i_nlink;
14269 + ino->i_size = proc_ino->i_size;
14270 + ino->i_blksize = proc_ino->i_blksize;
14271 + ino->i_blocks = proc_ino->i_blocks;
14274 +static struct inode *get_inode(struct super_block *sb, struct dentry *dentry,
14277 + struct inode *inode;
14278 + int err = -ENOMEM;
14280 + inode = new_inode(sb);
14281 + if(inode == NULL)
14284 + insert_inode_hash(inode);
14285 + if(S_ISDIR(dentry->d_inode->i_mode)){
14286 + inode->i_op = &hppfs_dir_iops;
14287 + inode->i_fop = &hppfs_dir_fops;
14289 + else if(S_ISLNK(dentry->d_inode->i_mode)){
14290 + inode->i_op = &hppfs_link_iops;
14291 + inode->i_fop = &hppfs_file_fops;
14294 + inode->i_op = &hppfs_file_iops;
14295 + inode->i_fop = &hppfs_file_fops;
14298 + inode->i_sb = sb;
14299 + inode->u.hppfs_i.proc_dentry = dentry;
14301 + read_inode(inode);
14304 + if(error) *error = err;
14307 + if(error) *error = err;
14311 +static struct super_block *hppfs_read_super(struct super_block *sb, void *d,
14314 + struct inode *root_inode;
14315 + struct file_system_type *procfs;
14316 + struct super_block *proc_sb;
14318 + procfs = get_fs_type("proc");
14319 + if(procfs == NULL)
14322 + if(list_empty(&procfs->fs_supers))
14325 + proc_sb = list_entry(procfs->fs_supers.next, struct super_block,
14328 + sb->s_blocksize = 1024;
14329 + sb->s_blocksize_bits = 10;
14330 + sb->s_magic = HPPFS_SUPER_MAGIC;
14331 + sb->s_op = &hppfs_sbops;
14333 + dget(proc_sb->s_root);
14334 + root_inode = get_inode(sb, proc_sb->s_root, NULL);
14335 + if(root_inode == NULL)
14338 + sb->s_root = d_alloc_root(root_inode);
14339 + if(sb->s_root == NULL)
14345 + iput(root_inode);
14347 + dput(proc_sb->s_root);
14352 +DECLARE_FSTYPE(hppfs_type, "hppfs", hppfs_read_super, 0);
14354 +static int __init init_hppfs(void)
14356 + return(register_filesystem(&hppfs_type));
14359 +static void __exit exit_hppfs(void)
14361 + unregister_filesystem(&hppfs_type);
14364 +module_init(init_hppfs)
14365 +module_exit(exit_hppfs)
14366 +MODULE_LICENSE("GPL");
14369 + * Overrides for Emacs so that we follow Linus's tabbing style.
14370 + * Emacs will notice this stuff at the end of the file and automatically
14371 + * adjust the settings for this buffer only. This must remain at the end
14373 + * ---------------------------------------------------------------------------
14374 + * Local variables:
14375 + * c-file-style: "linux"
14378 diff -Naur -X ../exclude-files orig/arch/um/fs/hppfs/Makefile um/arch/um/fs/hppfs/Makefile
14379 --- orig/arch/um/fs/hppfs/Makefile 1969-12-31 19:00:00.000000000 -0500
14380 +++ um/arch/um/fs/hppfs/Makefile 2003-10-21 03:26:06.000000000 -0400
14382 +O_TARGET := hppfs.o
14383 +obj-y = hppfs_kern.o #hppfs_user.o
14384 +obj-m = $(O_TARGET)
14386 +CFLAGS_hppfs_kern.o := $(CFLAGS)
14387 +#CFLAGS_hppfs_user.o := $(USER_CFLAGS)
14391 +include $(TOPDIR)/Rules.make
14392 diff -Naur -X ../exclude-files orig/arch/um/fs/Makefile um/arch/um/fs/Makefile
14393 --- orig/arch/um/fs/Makefile 1969-12-31 19:00:00.000000000 -0500
14394 +++ um/arch/um/fs/Makefile 2003-10-21 03:26:06.000000000 -0400
14397 +# Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
14398 +# Licensed under the GPL
14401 +O_TARGET := built-in.o
14406 +subdir-$(CONFIG_HOSTFS) += hostfs
14407 +subdir-$(CONFIG_HPPFS) += hppfs
14409 +obj-y += $(join $(subdir-y),$(subdir-y:%=/%.o))
14410 +obj-m += $(join $(subdir-m),$(subdir-m:%=/%.o))
14412 +include $(TOPDIR)/Rules.make
14419 diff -Naur -X ../exclude-files orig/arch/um/include/2_5compat.h um/arch/um/include/2_5compat.h
14420 --- orig/arch/um/include/2_5compat.h 1969-12-31 19:00:00.000000000 -0500
14421 +++ um/arch/um/include/2_5compat.h 2003-11-07 02:49:26.000000000 -0500
14424 + * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
14425 + * Licensed under the GPL
14428 +#ifndef __2_5_COMPAT_H__
14429 +#define __2_5_COMPAT_H__
14431 +#include "linux/version.h"
14433 +#define INIT_ELV(queue, elv) elevator_init(elv, ELV_NOOP)
14435 +#define ELV_NOOP ELEVATOR_NOOP
14437 +#define INIT_HARDSECT(arr, maj, sizes) arr[maj] = sizes
14439 +#define IS_WRITE(req) ((req)->cmd == WRITE)
14441 +#define SET_PRI(task) \
14442 + do { (task)->nice = 20; (task)->counter = -100; } while(0);
14447 + * Overrides for Emacs so that we follow Linus's tabbing style.
14448 + * Emacs will notice this stuff at the end of the file and automatically
14449 + * adjust the settings for this buffer only. This must remain at the end
14451 + * ---------------------------------------------------------------------------
14452 + * Local variables:
14453 + * c-file-style: "linux"
14456 diff -Naur -X ../exclude-files orig/arch/um/include/chan_kern.h um/arch/um/include/chan_kern.h
14457 --- orig/arch/um/include/chan_kern.h 1969-12-31 19:00:00.000000000 -0500
14458 +++ um/arch/um/include/chan_kern.h 2003-10-21 03:26:06.000000000 -0400
14461 + * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
14462 + * Licensed under the GPL
14465 +#ifndef __CHAN_KERN_H__
14466 +#define __CHAN_KERN_H__
14468 +#include "linux/tty.h"
14469 +#include "linux/list.h"
14470 +#include "chan_user.h"
14473 + struct list_head list;
14475 + unsigned int primary:1;
14476 + unsigned int input:1;
14477 + unsigned int output:1;
14478 + unsigned int opened:1;
14480 + enum chan_init_pri pri;
14481 + struct chan_ops *ops;
14485 +extern void chan_interrupt(struct list_head *chans, struct tq_struct *task,
14486 + struct tty_struct *tty, int irq, void *dev);
14487 +extern int parse_chan_pair(char *str, struct list_head *chans, int pri,
14488 + int device, struct chan_opts *opts);
14489 +extern int open_chan(struct list_head *chans);
14490 +extern int write_chan(struct list_head *chans, const char *buf, int len,
14492 +extern int console_write_chan(struct list_head *chans, const char *buf,
14494 +extern void close_chan(struct list_head *chans);
14495 +extern void chan_enable_winch(struct list_head *chans, void *line);
14496 +extern void enable_chan(struct list_head *chans, void *data);
14497 +extern int chan_window_size(struct list_head *chans,
14498 + unsigned short *rows_out,
14499 + unsigned short *cols_out);
14500 +extern int chan_out_fd(struct list_head *chans);
14501 +extern int chan_config_string(struct list_head *chans, char *str, int size,
14502 + char **error_out);
14507 + * Overrides for Emacs so that we follow Linus's tabbing style.
14508 + * Emacs will notice this stuff at the end of the file and automatically
14509 + * adjust the settings for this buffer only. This must remain at the end
14511 + * ---------------------------------------------------------------------------
14512 + * Local variables:
14513 + * c-file-style: "linux"
14516 diff -Naur -X ../exclude-files orig/arch/um/include/chan_user.h um/arch/um/include/chan_user.h
14517 --- orig/arch/um/include/chan_user.h 1969-12-31 19:00:00.000000000 -0500
14518 +++ um/arch/um/include/chan_user.h 2003-10-21 03:26:06.000000000 -0400
14521 + * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
14522 + * Licensed under the GPL
14525 +#ifndef __CHAN_USER_H__
14526 +#define __CHAN_USER_H__
14530 +struct chan_opts {
14531 + void (*announce)(char *dev_name, int dev);
14532 + char *xterm_title;
14534 + unsigned long tramp_stack;
14538 +enum chan_init_pri { INIT_STATIC, INIT_ALL, INIT_ONE };
14542 + void *(*init)(char *, int, struct chan_opts *);
14543 + int (*open)(int, int, int, void *, char **);
14544 + void (*close)(int, void *);
14545 + int (*read)(int, char *, void *);
14546 + int (*write)(int, const char *, int, void *);
14547 + int (*console_write)(int, const char *, int, void *);
14548 + int (*window_size)(int, void *, unsigned short *, unsigned short *);
14549 + void (*free)(void *);
14553 +extern struct chan_ops fd_ops, null_ops, port_ops, pts_ops, pty_ops, tty_ops,
14556 +extern void generic_close(int fd, void *unused);
14557 +extern int generic_read(int fd, char *c_out, void *unused);
14558 +extern int generic_write(int fd, const char *buf, int n, void *unused);
14559 +extern int generic_console_write(int fd, const char *buf, int n, void *state);
14560 +extern int generic_window_size(int fd, void *unused, unsigned short *rows_out,
14561 + unsigned short *cols_out);
14562 +extern void generic_free(void *data);
14564 +extern void register_winch(int fd, void *device_data);
14565 +extern void register_winch_irq(int fd, int tty_fd, int pid, void *line);
14567 +#define __channel_help(fn, prefix) \
14568 +__uml_help(fn, prefix "[0-9]*=<channel description>\n" \
14569 +" Attach a console or serial line to a host channel. See\n" \
14570 +" http://user-mode-linux.sourceforge.net/input.html for a complete\n" \
14571 +" description of this switch.\n\n" \
14577 + * Overrides for Emacs so that we follow Linus's tabbing style.
14578 + * Emacs will notice this stuff at the end of the file and automatically
14579 + * adjust the settings for this buffer only. This must remain at the end
14581 + * ---------------------------------------------------------------------------
14582 + * Local variables:
14583 + * c-file-style: "linux"
14586 diff -Naur -X ../exclude-files orig/arch/um/include/choose-mode.h um/arch/um/include/choose-mode.h
14587 --- orig/arch/um/include/choose-mode.h 1969-12-31 19:00:00.000000000 -0500
14588 +++ um/arch/um/include/choose-mode.h 2003-10-21 03:26:06.000000000 -0400
14591 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
14592 + * Licensed under the GPL
14595 +#ifndef __CHOOSE_MODE_H__
14596 +#define __CHOOSE_MODE_H__
14598 +#include "uml-config.h"
14600 +#if defined(UML_CONFIG_MODE_TT) && defined(UML_CONFIG_MODE_SKAS)
14601 +#define CHOOSE_MODE(tt, skas) (mode_tt ? (tt) : (skas))
14603 +#elif defined(UML_CONFIG_MODE_SKAS)
14604 +#define CHOOSE_MODE(tt, skas) (skas)
14606 +#elif defined(UML_CONFIG_MODE_TT)
14607 +#define CHOOSE_MODE(tt, skas) (tt)
14610 +#define CHOOSE_MODE_PROC(tt, skas, args...) \
14611 + CHOOSE_MODE(tt(args), skas(args))
14616 + * Overrides for Emacs so that we follow Linus's tabbing style.
14617 + * Emacs will notice this stuff at the end of the file and automatically
14618 + * adjust the settings for this buffer only. This must remain at the end
14620 + * ---------------------------------------------------------------------------
14621 + * Local variables:
14622 + * c-file-style: "linux"
14625 diff -Naur -X ../exclude-files orig/arch/um/include/frame.h um/arch/um/include/frame.h
14626 --- orig/arch/um/include/frame.h 1969-12-31 19:00:00.000000000 -0500
14627 +++ um/arch/um/include/frame.h 2003-10-21 03:26:06.000000000 -0400
14630 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
14631 + * Licensed under the GPL
14634 +#ifndef __FRAME_H_
14635 +#define __FRAME_H_
14637 +#include "sysdep/frame.h"
14639 +struct frame_common {
14646 + struct arch_frame_data arch;
14650 + struct frame_common common;
14654 +extern struct sc_frame signal_frame_sc;
14656 +extern struct sc_frame signal_frame_sc_sr;
14659 + struct frame_common common;
14666 +extern struct si_frame signal_frame_si;
14668 +extern void capture_signal_stack(void);
14673 + * Overrides for Emacs so that we follow Linus's tabbing style.
14674 + * Emacs will notice this stuff at the end of the file and automatically
14675 + * adjust the settings for this buffer only. This must remain at the end
14677 + * ---------------------------------------------------------------------------
14678 + * Local variables:
14679 + * c-file-style: "linux"
14682 diff -Naur -X ../exclude-files orig/arch/um/include/frame_kern.h um/arch/um/include/frame_kern.h
14683 --- orig/arch/um/include/frame_kern.h 1969-12-31 19:00:00.000000000 -0500
14684 +++ um/arch/um/include/frame_kern.h 2003-10-21 03:26:06.000000000 -0400
14687 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
14688 + * Licensed under the GPL
14691 +#ifndef __FRAME_KERN_H_
14692 +#define __FRAME_KERN_H_
14694 +#include "frame.h"
14695 +#include "sysdep/frame_kern.h"
14697 +extern int setup_signal_stack_sc(unsigned long stack_top, int sig,
14698 + unsigned long handler,
14699 + void (*restorer)(void),
14700 + struct pt_regs *regs,
14702 +extern int setup_signal_stack_si(unsigned long stack_top, int sig,
14703 + unsigned long handler,
14704 + void (*restorer)(void),
14705 + struct pt_regs *regs, siginfo_t *info,
14711 + * Overrides for Emacs so that we follow Linus's tabbing style.
14712 + * Emacs will notice this stuff at the end of the file and automatically
14713 + * adjust the settings for this buffer only. This must remain at the end
14715 + * ---------------------------------------------------------------------------
14716 + * Local variables:
14717 + * c-file-style: "linux"
14720 diff -Naur -X ../exclude-files orig/arch/um/include/frame_user.h um/arch/um/include/frame_user.h
14721 --- orig/arch/um/include/frame_user.h 1969-12-31 19:00:00.000000000 -0500
14722 +++ um/arch/um/include/frame_user.h 2003-10-21 03:26:06.000000000 -0400
14725 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
14726 + * Licensed under the GPL
14729 +#ifndef __FRAME_USER_H_
14730 +#define __FRAME_USER_H_
14732 +#include "sysdep/frame_user.h"
14733 +#include "frame.h"
14738 + * Overrides for Emacs so that we follow Linus's tabbing style.
14739 + * Emacs will notice this stuff at the end of the file and automatically
14740 + * adjust the settings for this buffer only. This must remain at the end
14742 + * ---------------------------------------------------------------------------
14743 + * Local variables:
14744 + * c-file-style: "linux"
14747 diff -Naur -X ../exclude-files orig/arch/um/include/helper.h um/arch/um/include/helper.h
14748 --- orig/arch/um/include/helper.h 1969-12-31 19:00:00.000000000 -0500
14749 +++ um/arch/um/include/helper.h 2003-10-21 03:26:06.000000000 -0400
14752 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
14753 + * Licensed under the GPL
14756 +#ifndef __HELPER_H__
14757 +#define __HELPER_H__
14759 +extern int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv,
14760 + unsigned long *stack_out);
14761 +extern int run_helper_thread(int (*proc)(void *), void *arg,
14762 + unsigned int flags, unsigned long *stack_out,
14763 + int stack_order);
14764 +extern int helper_wait(int pid);
14769 + * Overrides for Emacs so that we follow Linus's tabbing style.
14770 + * Emacs will notice this stuff at the end of the file and automatically
14771 + * adjust the settings for this buffer only. This must remain at the end
14773 + * ---------------------------------------------------------------------------
14774 + * Local variables:
14775 + * c-file-style: "linux"
14778 diff -Naur -X ../exclude-files orig/arch/um/include/init.h um/arch/um/include/init.h
14779 --- orig/arch/um/include/init.h 1969-12-31 19:00:00.000000000 -0500
14780 +++ um/arch/um/include/init.h 2003-10-21 03:26:06.000000000 -0400
14782 +#ifndef _LINUX_UML_INIT_H
14783 +#define _LINUX_UML_INIT_H
14785 +/* These macros are used to mark some functions or
14786 + * initialized data (doesn't apply to uninitialized data)
14787 + * as `initialization' functions. The kernel can take this
14788 + * as hint that the function is used only during the initialization
14789 + * phase and free up used memory resources after
14794 + * You should add __init immediately before the function name, like:
14796 + * static void __init initme(int x, int y)
14798 + * extern int z; z = x * y;
14801 + * If the function has a prototype somewhere, you can also add
14802 + * __init between closing brace of the prototype and semicolon:
14804 + * extern int initialize_foobar_device(int, int, int) __init;
14806 + * For initialized data:
14807 + * You should insert __initdata between the variable name and equal
14808 + * sign followed by value, e.g.:
14810 + * static int init_variable __initdata = 0;
14811 + * static char linux_logo[] __initdata = { 0x32, 0x36, ... };
14813 + * Don't forget to initialize data not at file scope, i.e. within a function,
14814 + * as gcc otherwise puts the data into the bss section and not into the init
14817 + * Also note, that this data cannot be "const".
14820 +#ifndef _LINUX_INIT_H
14821 +typedef int (*initcall_t)(void);
14822 +typedef void (*exitcall_t)(void);
14824 +#define __init __attribute__ ((__section__ (".text.init")))
14825 +#define __exit __attribute__ ((unused, __section__(".text.exit")))
14826 +#define __initdata __attribute__ ((__section__ (".data.init")))
14831 +struct uml_param {
14833 + int (*setup_func)(char *, int *);
14836 +extern initcall_t __uml_initcall_start, __uml_initcall_end;
14837 +extern initcall_t __uml_postsetup_start, __uml_postsetup_end;
14838 +extern const char *__uml_help_start, *__uml_help_end;
14841 +#define __uml_initcall(fn) \
14842 + static initcall_t __uml_initcall_##fn __uml_init_call = fn
14844 +#define __uml_exitcall(fn) \
14845 + static exitcall_t __uml_exitcall_##fn __uml_exit_call = fn
14847 +extern struct uml_param __uml_setup_start, __uml_setup_end;
14849 +#define __uml_postsetup(fn) \
14850 + static initcall_t __uml_postsetup_##fn __uml_postsetup_call = fn
14852 +#define __non_empty_string(dummyname,string) \
14853 + struct __uml_non_empty_string_struct_##dummyname \
14855 + char _string[sizeof(string)-2]; \
14859 +#define __uml_setup(str, fn, help...) \
14860 + __non_empty_string(fn ##_setup, str); \
14861 + __uml_help(fn, help); \
14862 + static char __uml_setup_str_##fn[] __initdata = str; \
14863 + static struct uml_param __uml_setup_##fn __uml_init_setup = { __uml_setup_str_##fn, fn }
14865 +#define __uml_setup(str, fn, help...) \
14869 +#define __uml_help(fn, help...) \
14870 + __non_empty_string(fn ##__help, help); \
14871 + static char __uml_help_str_##fn[] __initdata = help; \
14872 + static const char *__uml_help_##fn __uml_setup_help = __uml_help_str_##fn
14875 + * Mark functions and data as being only used at initialization
14878 +#define __uml_init_setup __attribute__ ((unused,__section__ (".uml.setup.init")))
14879 +#define __uml_setup_help __attribute__ ((unused,__section__ (".uml.help.init")))
14880 +#define __uml_init_call __attribute__ ((unused,__section__ (".uml.initcall.init")))
14881 +#define __uml_postsetup_call __attribute__ ((unused,__section__ (".uml.postsetup.init")))
14882 +#define __uml_exit_call __attribute__ ((unused,__section__ (".uml.exitcall.exit")))
14884 +#endif /* _LINUX_UML_INIT_H */
14887 + * Overrides for Emacs so that we follow Linus's tabbing style.
14888 + * Emacs will notice this stuff at the end of the file and automatically
14889 + * adjust the settings for this buffer only. This must remain at the end
14891 + * ---------------------------------------------------------------------------
14892 + * Local variables:
14893 + * c-file-style: "linux"
14896 diff -Naur -X ../exclude-files orig/arch/um/include/initrd.h um/arch/um/include/initrd.h
14897 --- orig/arch/um/include/initrd.h 1969-12-31 19:00:00.000000000 -0500
14898 +++ um/arch/um/include/initrd.h 2003-10-21 03:26:06.000000000 -0400
14901 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
14902 + * Licensed under the GPL
14905 +#ifndef __INITRD_USER_H__
14906 +#define __INITRD_USER_H__
14908 +extern int load_initrd(char *filename, void *buf, int size);
14913 + * Overrides for Emacs so that we follow Linus's tabbing style.
14914 + * Emacs will notice this stuff at the end of the file and automatically
14915 + * adjust the settings for this buffer only. This must remain at the end
14917 + * ---------------------------------------------------------------------------
14918 + * Local variables:
14919 + * c-file-style: "linux"
14922 diff -Naur -X ../exclude-files orig/arch/um/include/irq_kern.h um/arch/um/include/irq_kern.h
14923 --- orig/arch/um/include/irq_kern.h 1969-12-31 19:00:00.000000000 -0500
14924 +++ um/arch/um/include/irq_kern.h 2003-10-21 03:26:06.000000000 -0400
14927 + * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
14928 + * Licensed under the GPL
14931 +#ifndef __IRQ_KERN_H__
14932 +#define __IRQ_KERN_H__
14934 +#include "linux/interrupt.h"
14936 +extern int um_request_irq(unsigned int irq, int fd, int type,
14937 + void (*handler)(int, void *, struct pt_regs *),
14938 + unsigned long irqflags, const char * devname,
14944 + * Overrides for Emacs so that we follow Linus's tabbing style.
14945 + * Emacs will notice this stuff at the end of the file and automatically
14946 + * adjust the settings for this buffer only. This must remain at the end
14948 + * ---------------------------------------------------------------------------
14949 + * Local variables:
14950 + * c-file-style: "linux"
14953 diff -Naur -X ../exclude-files orig/arch/um/include/irq_user.h um/arch/um/include/irq_user.h
14954 --- orig/arch/um/include/irq_user.h 1969-12-31 19:00:00.000000000 -0500
14955 +++ um/arch/um/include/irq_user.h 2003-10-21 03:26:06.000000000 -0400
14958 + * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
14959 + * Licensed under the GPL
14962 +#ifndef __IRQ_USER_H__
14963 +#define __IRQ_USER_H__
14965 +enum { IRQ_READ, IRQ_WRITE };
14967 +extern void sigio_handler(int sig, union uml_pt_regs *regs);
14968 +extern int activate_fd(int irq, int fd, int type, void *dev_id);
14969 +extern void free_irq_by_irq_and_dev(int irq, void *dev_id);
14970 +extern void free_irq_by_fd(int fd);
14971 +extern void reactivate_fd(int fd, int irqnum);
14972 +extern void deactivate_fd(int fd, int irqnum);
14973 +extern void forward_interrupts(int pid);
14974 +extern void init_irq_signals(int on_sigstack);
14975 +extern void forward_ipi(int fd, int pid);
14976 +extern void free_irq_later(int irq, void *dev_id);
14977 +extern int activate_ipi(int fd, int pid);
14978 +extern unsigned long irq_lock(void);
14979 +extern void irq_unlock(unsigned long flags);
14983 + * Overrides for Emacs so that we follow Linus's tabbing style.
14984 + * Emacs will notice this stuff at the end of the file and automatically
14985 + * adjust the settings for this buffer only. This must remain at the end
14987 + * ---------------------------------------------------------------------------
14988 + * Local variables:
14989 + * c-file-style: "linux"
14992 diff -Naur -X ../exclude-files orig/arch/um/include/kern.h um/arch/um/include/kern.h
14993 --- orig/arch/um/include/kern.h 1969-12-31 19:00:00.000000000 -0500
14994 +++ um/arch/um/include/kern.h 2003-10-21 03:26:06.000000000 -0400
14997 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
14998 + * Licensed under the GPL
15001 +#ifndef __KERN_H__
15002 +#define __KERN_H__
15004 +/* These are all user-mode things which are convenient to call directly
15005 + * from kernel code and for which writing a wrapper is too much of a pain.
15006 + * The regular include files can't be included because this file is included
15007 + * only into kernel code, and user-space includes conflict with kernel
15013 +extern int clone(int (*proc)(void *), void *sp, int flags, void *data);
15014 +extern int sleep(int);
15015 +extern int printf(char *fmt, ...);
15016 +extern char *strerror(int errnum);
15017 +extern char *ptsname(int __fd);
15018 +extern int munmap(void *, int);
15019 +extern void *sbrk(int increment);
15020 +extern void *malloc(int size);
15021 +extern void perror(char *err);
15022 +extern int kill(int pid, int sig);
15023 +extern int getuid(void);
15024 +extern int pause(void);
15025 +extern int write(int, const void *, int);
15026 +extern int exit(int);
15027 +extern int close(int);
15028 +extern int read(unsigned int, char *, int);
15029 +extern int pipe(int *);
15030 +extern int sched_yield(void);
15031 +extern int ptrace(int op, int pid, long addr, long data);
15035 + * Overrides for Emacs so that we follow Linus's tabbing style.
15036 + * Emacs will notice this stuff at the end of the file and automatically
15037 + * adjust the settings for this buffer only. This must remain at the end
15039 + * ---------------------------------------------------------------------------
15040 + * Local variables:
15041 + * c-file-style: "linux"
15044 diff -Naur -X ../exclude-files orig/arch/um/include/kern_util.h um/arch/um/include/kern_util.h
15045 --- orig/arch/um/include/kern_util.h 1969-12-31 19:00:00.000000000 -0500
15046 +++ um/arch/um/include/kern_util.h 2003-11-10 00:58:10.000000000 -0500
15049 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
15050 + * Licensed under the GPL
15053 +#ifndef __KERN_UTIL_H__
15054 +#define __KERN_UTIL_H__
15056 +#include "sysdep/ptrace.h"
15059 +extern char *linux_prog;
15060 +extern char *gdb_init;
15061 +extern int kmalloc_ok;
15062 +extern int timer_irq_inited;
15064 +extern int nsyscalls;
15066 +#define UML_ROUND_DOWN(addr) ((void *)(((unsigned long) addr) & PAGE_MASK))
15067 +#define UML_ROUND_UP(addr) \
15068 + UML_ROUND_DOWN(((unsigned long) addr) + PAGE_SIZE - 1)
15070 +extern int kernel_fork(unsigned long flags, int (*fn)(void *), void * arg);
15071 +extern unsigned long stack_sp(unsigned long page);
15072 +extern int kernel_thread_proc(void *data);
15073 +extern void syscall_segv(int sig);
15074 +extern int current_pid(void);
15075 +extern unsigned long alloc_stack(int order, int atomic);
15076 +extern int do_signal(int error);
15077 +extern int is_stack_fault(unsigned long sp);
15078 +extern unsigned long segv(unsigned long address, unsigned long ip,
15079 + int is_write, int is_user, void *sc);
15080 +extern unsigned long handle_page_fault(unsigned long address, unsigned long ip,
15081 + int is_write, int is_user,
15083 +extern void syscall_ready(void);
15084 +extern int segv_syscall(void);
15085 +extern void kern_finish_exec(void *task, int new_pid, unsigned long stack);
15086 +extern int page_size(void);
15087 +extern int page_mask(void);
15088 +extern int need_finish_fork(void);
15089 +extern void free_stack(unsigned long stack, int order);
15090 +extern void add_input_request(int op, void (*proc)(int), void *arg);
15091 +extern int sys_execve(char *file, char **argv, char **env);
15092 +extern char *current_cmd(void);
15093 +extern void timer_handler(int sig, union uml_pt_regs *regs);
15094 +extern int set_signals(int enable);
15095 +extern void force_sigbus(void);
15096 +extern int pid_to_processor_id(int pid);
15097 +extern void block_signals(void);
15098 +extern void unblock_signals(void);
15099 +extern void deliver_signals(void *t);
15100 +extern int next_syscall_index(int max);
15101 +extern int next_trap_index(int max);
15102 +extern void cpu_idle(void);
15103 +extern void finish_fork(void);
15104 +extern void paging_init(void);
15105 +extern void init_flush_vm(void);
15106 +extern void *syscall_sp(void *t);
15107 +extern void syscall_trace(void);
15108 +extern int hz(void);
15109 +extern void idle_timer(void);
15110 +extern unsigned int do_IRQ(int irq, union uml_pt_regs *regs);
15111 +extern int external_pid(void *t);
15112 +extern void boot_timer_handler(int sig);
15113 +extern void interrupt_end(void);
15114 +extern void initial_thread_cb(void (*proc)(void *), void *arg);
15115 +extern int debugger_signal(int status, int pid);
15116 +extern void debugger_parent_signal(int status, int pid);
15117 +extern void child_signal(int pid, int status);
15118 +extern int init_ptrace_proxy(int idle_pid, int startup, int stop);
15119 +extern int init_parent_proxy(int pid);
15120 +extern void check_stack_overflow(void *ptr);
15121 +extern void relay_signal(int sig, union uml_pt_regs *regs);
15122 +extern void not_implemented(void);
15123 +extern int user_context(unsigned long sp);
15124 +extern void timer_irq(union uml_pt_regs *regs);
15125 +extern void unprotect_stack(unsigned long stack);
15126 +extern void do_uml_exitcalls(void);
15127 +extern int attach_debugger(int idle_pid, int pid, int stop);
15128 +extern void bad_segv(unsigned long address, unsigned long ip, int is_write);
15129 +extern int config_gdb(char *str);
15130 +extern int remove_gdb(void);
15131 +extern char *uml_strdup(char *string);
15132 +extern void unprotect_kernel_mem(void);
15133 +extern void protect_kernel_mem(void);
15134 +extern void set_kmem_end(unsigned long);
15135 +extern void uml_cleanup(void);
15136 +extern void set_current(void *t);
15137 +extern void lock_signalled_task(void *t);
15138 +extern void IPI_handler(int cpu);
15139 +extern int jail_setup(char *line, int *add);
15140 +extern void *get_init_task(void);
15141 +extern int clear_user_proc(void *buf, int size);
15142 +extern int copy_to_user_proc(void *to, void *from, int size);
15143 +extern int copy_from_user_proc(void *to, void *from, int size);
15144 +extern int strlen_user_proc(char *str);
15145 +extern void bus_handler(int sig, union uml_pt_regs *regs);
15146 +extern void winch(int sig, union uml_pt_regs *regs);
15147 +extern long execute_syscall(void *r);
15148 +extern int smp_sigio_handler(void);
15149 +extern void *get_current(void);
15150 +extern struct task_struct *get_task(int pid, int require);
15151 +extern void machine_halt(void);
15152 +extern int is_syscall(unsigned long addr);
15153 +extern void arch_switch(void);
15154 +extern void free_irq(unsigned int, void *);
15155 +extern int um_in_interrupt(void);
15156 +extern int cpu(void);
15157 +extern unsigned long long time_stamp(void);
15162 + * Overrides for Emacs so that we follow Linus's tabbing style.
15163 + * Emacs will notice this stuff at the end of the file and automatically
15164 + * adjust the settings for this buffer only. This must remain at the end
15166 + * ---------------------------------------------------------------------------
15167 + * Local variables:
15168 + * c-file-style: "linux"
15171 diff -Naur -X ../exclude-files orig/arch/um/include/line.h um/arch/um/include/line.h
15172 --- orig/arch/um/include/line.h 1969-12-31 19:00:00.000000000 -0500
15173 +++ um/arch/um/include/line.h 2003-11-07 02:25:37.000000000 -0500
15176 + * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
15177 + * Licensed under the GPL
15180 +#ifndef __LINE_H__
15181 +#define __LINE_H__
15183 +#include "linux/list.h"
15184 +#include "linux/tqueue.h"
15185 +#include "linux/tty.h"
15186 +#include "asm/semaphore.h"
15187 +#include "chan_user.h"
15188 +#include "mconsole_kern.h"
15190 +struct line_driver {
15192 + char *devfs_name;
15194 + short minor_start;
15198 + char *read_irq_name;
15200 + char *write_irq_name;
15201 + char *symlink_from;
15202 + char *symlink_to;
15203 + struct mc_device mc;
15209 + struct list_head chan_list;
15212 + struct tty_struct *tty;
15213 + struct semaphore sem;
15218 + struct tq_struct task;
15219 + struct line_driver *driver;
15223 +#define LINE_INIT(str, d) \
15224 + { init_str : str, \
15225 + init_pri : INIT_STATIC, \
15226 + chan_list : { }, \
15242 +#define LINES_INIT(n) { num : n }
15244 +extern void line_close(struct line *lines, struct tty_struct *tty);
15245 +extern int line_open(struct line *lines, struct tty_struct *tty,
15246 + struct chan_opts *opts);
15247 +extern int line_setup(struct line *lines, int num, char *init,
15248 + int all_allowed);
15249 +extern int line_write(struct line *line, struct tty_struct *tty, int from_user,
15250 + const char *buf, int len);
15251 +extern char *add_xterm_umid(char *base);
15252 +extern int line_setup_irq(int fd, int input, int output, void *data);
15253 +extern void line_close_chan(struct line *line);
15254 +extern void line_disable(struct line *line, int current_irq);
15255 +extern void line_register_devfs(struct lines *set,
15256 + struct line_driver *line_driver,
15257 + struct tty_driver *driver, struct line *lines,
15259 +extern void lines_init(struct line *lines, int nlines);
15260 +extern void close_lines(struct line *lines, int nlines);
15261 +extern int line_config(struct line *lines, int num, char *str);
15262 +extern int line_remove(struct line *lines, int num, char *str);
15263 +extern int line_get_config(char *dev, struct line *lines, int num, char *str,
15264 + int size, char **error_out);
15269 + * Overrides for Emacs so that we follow Linus's tabbing style.
15270 + * Emacs will notice this stuff at the end of the file and automatically
15271 + * adjust the settings for this buffer only. This must remain at the end
15273 + * ---------------------------------------------------------------------------
15274 + * Local variables:
15275 + * c-file-style: "linux"
15278 diff -Naur -X ../exclude-files orig/arch/um/include/Makefile um/arch/um/include/Makefile
15279 --- orig/arch/um/include/Makefile 1969-12-31 19:00:00.000000000 -0500
15280 +++ um/arch/um/include/Makefile 2003-10-21 03:26:06.000000000 -0400
15284 +sc.h : ../util/mk_sc
15285 + ../util/mk_sc > $@
15288 + $(MAKE) -C ../util mk_sc
15289 diff -Naur -X ../exclude-files orig/arch/um/include/mconsole.h um/arch/um/include/mconsole.h
15290 --- orig/arch/um/include/mconsole.h 1969-12-31 19:00:00.000000000 -0500
15291 +++ um/arch/um/include/mconsole.h 2003-10-21 03:26:06.000000000 -0400
15294 + * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org)
15295 + * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
15296 + * Licensed under the GPL
15299 +#ifndef __MCONSOLE_H__
15300 +#define __MCONSOLE_H__
15302 +#ifndef __KERNEL__
15303 +#include <stdint.h>
15304 +#define u32 uint32_t
15307 +#define MCONSOLE_MAGIC (0xcafebabe)
15308 +#define MCONSOLE_MAX_DATA (512)
15309 +#define MCONSOLE_VERSION 2
15311 +struct mconsole_request {
15315 + char data[MCONSOLE_MAX_DATA];
15318 +struct mconsole_reply {
15322 + char data[MCONSOLE_MAX_DATA];
15325 +struct mconsole_notify {
15328 + enum { MCONSOLE_SOCKET, MCONSOLE_PANIC, MCONSOLE_HANG,
15329 + MCONSOLE_USER_NOTIFY } type;
15331 + char data[MCONSOLE_MAX_DATA];
15334 +struct mc_request;
15336 +enum mc_context { MCONSOLE_INTR, MCONSOLE_PROC };
15338 +struct mconsole_command
15341 + void (*handler)(struct mc_request *req);
15342 + enum mc_context context;
15348 + int as_interrupt;
15350 + int originating_fd;
15352 + unsigned char origin[128]; /* sockaddr_un */
15354 + struct mconsole_request request;
15355 + struct mconsole_command *cmd;
15358 +extern char mconsole_socket_name[];
15360 +extern int mconsole_unlink_socket(void);
15361 +extern int mconsole_reply(struct mc_request *req, char *reply, int err,
15364 +extern void mconsole_version(struct mc_request *req);
15365 +extern void mconsole_help(struct mc_request *req);
15366 +extern void mconsole_halt(struct mc_request *req);
15367 +extern void mconsole_reboot(struct mc_request *req);
15368 +extern void mconsole_config(struct mc_request *req);
15369 +extern void mconsole_remove(struct mc_request *req);
15370 +extern void mconsole_sysrq(struct mc_request *req);
15371 +extern void mconsole_cad(struct mc_request *req);
15372 +extern void mconsole_stop(struct mc_request *req);
15373 +extern void mconsole_go(struct mc_request *req);
15374 +extern void mconsole_log(struct mc_request *req);
15375 +extern void mconsole_proc(struct mc_request *req);
15377 +extern int mconsole_get_request(int fd, struct mc_request *req);
15378 +extern int mconsole_notify(char *sock_name, int type, const void *data,
15380 +extern char *mconsole_notify_socket(void);
15381 +extern void lock_notify(void);
15382 +extern void unlock_notify(void);
15387 + * Overrides for Emacs so that we follow Linus's tabbing style.
15388 + * Emacs will notice this stuff at the end of the file and automatically
15389 + * adjust the settings for this buffer only. This must remain at the end
15391 + * ---------------------------------------------------------------------------
15392 + * Local variables:
15393 + * c-file-style: "linux"
15396 diff -Naur -X ../exclude-files orig/arch/um/include/mconsole_kern.h um/arch/um/include/mconsole_kern.h
15397 --- orig/arch/um/include/mconsole_kern.h 1969-12-31 19:00:00.000000000 -0500
15398 +++ um/arch/um/include/mconsole_kern.h 2003-10-21 03:26:06.000000000 -0400
15401 + * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
15402 + * Licensed under the GPL
15405 +#ifndef __MCONSOLE_KERN_H__
15406 +#define __MCONSOLE_KERN_H__
15408 +#include "linux/config.h"
15409 +#include "linux/list.h"
15410 +#include "mconsole.h"
15412 +struct mconsole_entry {
15413 + struct list_head list;
15414 + struct mc_request request;
15417 +struct mc_device {
15418 + struct list_head list;
15420 + int (*config)(char *);
15421 + int (*get_config)(char *, char *, int, char **);
15422 + int (*remove)(char *);
15425 +#define CONFIG_CHUNK(str, size, current, chunk, end) \
15427 + current += strlen(chunk); \
15428 + if(current >= size) \
15430 + if(str != NULL){ \
15431 + strcpy(str, chunk); \
15432 + str += strlen(chunk); \
15438 +#ifdef CONFIG_MCONSOLE
15440 +extern void mconsole_register_dev(struct mc_device *new);
15444 +static inline void mconsole_register_dev(struct mc_device *new)
15453 + * Overrides for Emacs so that we follow Linus's tabbing style.
15454 + * Emacs will notice this stuff at the end of the file and automatically
15455 + * adjust the settings for this buffer only. This must remain at the end
15457 + * ---------------------------------------------------------------------------
15458 + * Local variables:
15459 + * c-file-style: "linux"
15462 diff -Naur -X ../exclude-files orig/arch/um/include/mem.h um/arch/um/include/mem.h
15463 --- orig/arch/um/include/mem.h 1969-12-31 19:00:00.000000000 -0500
15464 +++ um/arch/um/include/mem.h 2004-01-16 11:14:38.000000000 -0500
15467 + * Copyright (C) 2002, 2003 Jeff Dike (jdike@addtoit.com)
15468 + * Licensed under the GPL
15474 +#include "linux/types.h"
15476 +extern void set_kmem_end(unsigned long new);
15477 +extern int phys_mapping(unsigned long phys, __u64 *offset_out);
15478 +extern int physmem_subst_mapping(void *virt, int fd, __u64 offset, int w);
15479 +extern int is_remapped(void *virt);
15480 +extern int physmem_remove_mapping(void *virt);
15481 +extern void physmem_forget_descriptor(int fd);
15486 + * Overrides for Emacs so that we follow Linus's tabbing style.
15487 + * Emacs will notice this stuff at the end of the file and automatically
15488 + * adjust the settings for this buffer only. This must remain at the end
15490 + * ---------------------------------------------------------------------------
15491 + * Local variables:
15492 + * c-file-style: "linux"
15495 diff -Naur -X ../exclude-files orig/arch/um/include/mem_kern.h um/arch/um/include/mem_kern.h
15496 --- orig/arch/um/include/mem_kern.h 1969-12-31 19:00:00.000000000 -0500
15497 +++ um/arch/um/include/mem_kern.h 2003-10-21 03:26:06.000000000 -0400
15500 + * Copyright (C) 2003 Jeff Dike (jdike@addtoit.com)
15501 + * Licensed under the GPL
15504 +#ifndef __MEM_KERN_H__
15505 +#define __MEM_KERN_H__
15507 +#include "linux/list.h"
15508 +#include "linux/types.h"
15511 + struct list_head list;
15512 + int (*proc)(int, unsigned long, int, __u64);
15515 +extern void register_remapper(struct remapper *info);
15520 + * Overrides for Emacs so that we follow Linus's tabbing style.
15521 + * Emacs will notice this stuff at the end of the file and automatically
15522 + * adjust the settings for this buffer only. This must remain at the end
15524 + * ---------------------------------------------------------------------------
15525 + * Local variables:
15526 + * c-file-style: "linux"
15529 diff -Naur -X ../exclude-files orig/arch/um/include/mem_user.h um/arch/um/include/mem_user.h
15530 --- orig/arch/um/include/mem_user.h 1969-12-31 19:00:00.000000000 -0500
15531 +++ um/arch/um/include/mem_user.h 2004-01-10 00:11:06.000000000 -0500
15534 + * arch/um/include/mem_user.h
15536 + * BRIEF MODULE DESCRIPTION
15537 + * user side memory interface for support IO memory inside user mode linux
15539 + * Copyright (C) 2001 RidgeRun, Inc.
15540 + * Author: RidgeRun, Inc.
15541 + * Greg Lonnon glonnon@ridgerun.com or info@ridgerun.com
15543 + * This program is free software; you can redistribute it and/or modify it
15544 + * under the terms of the GNU General Public License as published by the
15545 + * Free Software Foundation; either version 2 of the License, or (at your
15546 + * option) any later version.
15548 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
15549 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
15550 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
15551 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
15552 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
15553 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
15554 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
15555 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
15556 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
15557 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15559 + * You should have received a copy of the GNU General Public License along
15560 + * with this program; if not, write to the Free Software Foundation, Inc.,
15561 + * 675 Mass Ave, Cambridge, MA 02139, USA.
15564 +#ifndef _MEM_USER_H
15565 +#define _MEM_USER_H
15567 +struct iomem_region {
15568 + struct iomem_region *next;
15572 + unsigned long phys;
15573 + unsigned long virt;
15576 +extern struct iomem_region *iomem_regions;
15577 +extern int iomem_size;
15579 +#define ROUND_4M(n) ((((unsigned long) (n)) + (1 << 22)) & ~((1 << 22) - 1))
15581 +extern unsigned long host_task_size;
15582 +extern unsigned long task_size;
15584 +extern int init_mem_user(void);
15585 +extern int create_mem_file(unsigned long len);
15586 +extern void setup_memory(void *entry);
15587 +extern unsigned long find_iomem(char *driver, unsigned long *len_out);
15588 +extern int init_maps(unsigned long physmem, unsigned long iomem,
15589 + unsigned long highmem);
15590 +extern unsigned long get_vm(unsigned long len);
15591 +extern void setup_physmem(unsigned long start, unsigned long usable,
15592 + unsigned long len, unsigned long highmem);
15593 +extern void add_iomem(char *name, int fd, unsigned long size);
15594 +extern unsigned long phys_offset(unsigned long phys);
15595 +extern void unmap_physmem(void);
15596 +extern void map_memory(unsigned long virt, unsigned long phys,
15597 + unsigned long len, int r, int w, int x);
15598 +extern int protect_memory(unsigned long addr, unsigned long len,
15599 + int r, int w, int x, int must_succeed);
15600 +extern unsigned long get_kmem_end(void);
15605 + * Overrides for Emacs so that we follow Linus's tabbing style.
15606 + * Emacs will notice this stuff at the end of the file and automatically
15607 + * adjust the settings for this buffer only. This must remain at the end
15609 + * ---------------------------------------------------------------------------
15610 + * Local variables:
15611 + * c-file-style: "linux"
15614 diff -Naur -X ../exclude-files orig/arch/um/include/mode.h um/arch/um/include/mode.h
15615 --- orig/arch/um/include/mode.h 1969-12-31 19:00:00.000000000 -0500
15616 +++ um/arch/um/include/mode.h 2003-10-21 03:26:06.000000000 -0400
15619 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
15620 + * Licensed under the GPL
15623 +#ifndef __MODE_H__
15624 +#define __MODE_H__
15626 +#include "uml-config.h"
15628 +#ifdef UML_CONFIG_MODE_TT
15629 +#include "../kernel/tt/include/mode.h"
15632 +#ifdef UML_CONFIG_MODE_SKAS
15633 +#include "../kernel/skas/include/mode.h"
15639 + * Overrides for Emacs so that we follow Linus's tabbing style.
15640 + * Emacs will notice this stuff at the end of the file and automatically
15641 + * adjust the settings for this buffer only. This must remain at the end
15643 + * ---------------------------------------------------------------------------
15644 + * Local variables:
15645 + * c-file-style: "linux"
15648 diff -Naur -X ../exclude-files orig/arch/um/include/mode_kern.h um/arch/um/include/mode_kern.h
15649 --- orig/arch/um/include/mode_kern.h 1969-12-31 19:00:00.000000000 -0500
15650 +++ um/arch/um/include/mode_kern.h 2003-10-21 03:26:06.000000000 -0400
15653 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
15654 + * Licensed under the GPL
15657 +#ifndef __MODE_KERN_H__
15658 +#define __MODE_KERN_H__
15660 +#include "linux/config.h"
15662 +#ifdef CONFIG_MODE_TT
15663 +#include "../kernel/tt/include/mode_kern.h"
15666 +#ifdef CONFIG_MODE_SKAS
15667 +#include "../kernel/skas/include/mode_kern.h"
15673 + * Overrides for Emacs so that we follow Linus's tabbing style.
15674 + * Emacs will notice this stuff at the end of the file and automatically
15675 + * adjust the settings for this buffer only. This must remain at the end
15677 + * ---------------------------------------------------------------------------
15678 + * Local variables:
15679 + * c-file-style: "linux"
15682 diff -Naur -X ../exclude-files orig/arch/um/include/net_kern.h um/arch/um/include/net_kern.h
15683 --- orig/arch/um/include/net_kern.h 1969-12-31 19:00:00.000000000 -0500
15684 +++ um/arch/um/include/net_kern.h 2003-10-21 03:26:06.000000000 -0400
15687 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
15688 + * Licensed under the GPL
15691 +#ifndef __UM_NET_KERN_H
15692 +#define __UM_NET_KERN_H
15694 +#include "linux/netdevice.h"
15695 +#include "linux/skbuff.h"
15696 +#include "linux/socket.h"
15697 +#include "linux/list.h"
15700 + struct list_head list;
15701 + struct net_device *dev;
15703 + unsigned char mac[ETH_ALEN];
15707 +struct uml_net_private {
15708 + struct list_head list;
15710 + struct net_device *dev;
15711 + struct timer_list tl;
15712 + struct net_device_stats stats;
15714 + unsigned char mac[ETH_ALEN];
15716 + unsigned short (*protocol)(struct sk_buff *);
15717 + int (*open)(void *);
15718 + void (*close)(int, void *);
15719 + void (*remove)(void *);
15720 + int (*read)(int, struct sk_buff **skb, struct uml_net_private *);
15721 + int (*write)(int, struct sk_buff **skb, struct uml_net_private *);
15723 + void (*add_address)(unsigned char *, unsigned char *, void *);
15724 + void (*delete_address)(unsigned char *, unsigned char *, void *);
15725 + int (*set_mtu)(int mtu, void *);
15729 +struct net_kern_info {
15730 + void (*init)(struct net_device *, void *);
15731 + unsigned short (*protocol)(struct sk_buff *);
15732 + int (*read)(int, struct sk_buff **skb, struct uml_net_private *);
15733 + int (*write)(int, struct sk_buff **skb, struct uml_net_private *);
15736 +struct transport {
15737 + struct list_head list;
15739 + int (*setup)(char *, char **, void *);
15740 + struct net_user_info *user;
15741 + struct net_kern_info *kern;
15742 + int private_size;
15746 +extern struct net_device *ether_init(int);
15747 +extern unsigned short ether_protocol(struct sk_buff *);
15748 +extern int setup_etheraddr(char *str, unsigned char *addr);
15749 +extern struct sk_buff *ether_adjust_skb(struct sk_buff *skb, int extra);
15750 +extern int tap_setup_common(char *str, char *type, char **dev_name,
15751 + char **mac_out, char **gate_addr);
15752 +extern void register_transport(struct transport *new);
15753 +extern unsigned short eth_protocol(struct sk_buff *skb);
15758 + * Overrides for Emacs so that we follow Linus's tabbing style.
15759 + * Emacs will notice this stuff at the end of the file and automatically
15760 + * adjust the settings for this buffer only. This must remain at the end
15762 + * ---------------------------------------------------------------------------
15763 + * Local variables:
15764 + * c-file-style: "linux"
15767 diff -Naur -X ../exclude-files orig/arch/um/include/net_user.h um/arch/um/include/net_user.h
15768 --- orig/arch/um/include/net_user.h 1969-12-31 19:00:00.000000000 -0500
15769 +++ um/arch/um/include/net_user.h 2003-10-21 03:26:06.000000000 -0400
15772 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
15773 + * Licensed under the GPL
15776 +#ifndef __UM_NET_USER_H__
15777 +#define __UM_NET_USER_H__
15779 +#define ETH_ADDR_LEN (6)
15780 +#define ETH_HEADER_ETHERTAP (16)
15781 +#define ETH_HEADER_OTHER (14)
15782 +#define ETH_MAX_PACKET (1500)
15784 +#define UML_NET_VERSION (4)
15786 +struct net_user_info {
15787 + void (*init)(void *, void *);
15788 + int (*open)(void *);
15789 + void (*close)(int, void *);
15790 + void (*remove)(void *);
15791 + int (*set_mtu)(int mtu, void *);
15792 + void (*add_address)(unsigned char *, unsigned char *, void *);
15793 + void (*delete_address)(unsigned char *, unsigned char *, void *);
15797 +extern void ether_user_init(void *data, void *dev);
15798 +extern void dev_ip_addr(void *d, char *buf, char *bin_buf);
15799 +extern void set_ether_mac(void *d, unsigned char *addr);
15800 +extern void iter_addresses(void *d, void (*cb)(unsigned char *,
15801 + unsigned char *, void *),
15804 +extern void *get_output_buffer(int *len_out);
15805 +extern void free_output_buffer(void *buffer);
15807 +extern int tap_open_common(void *dev, char *gate_addr);
15808 +extern void tap_check_ips(char *gate_addr, char *eth_addr);
15810 +extern void read_output(int fd, char *output_out, int len);
15812 +extern int net_read(int fd, void *buf, int len);
15813 +extern int net_recvfrom(int fd, void *buf, int len);
15814 +extern int net_write(int fd, void *buf, int len);
15815 +extern int net_send(int fd, void *buf, int len);
15816 +extern int net_sendto(int fd, void *buf, int len, void *to, int sock_len);
15818 +extern void open_addr(unsigned char *addr, unsigned char *netmask, void *arg);
15819 +extern void close_addr(unsigned char *addr, unsigned char *netmask, void *arg);
15821 +extern char *split_if_spec(char *str, ...);
15823 +extern int dev_netmask(void *d, void *m);
15828 + * Overrides for Emacs so that we follow Linus's tabbing style.
15829 + * Emacs will notice this stuff at the end of the file and automatically
15830 + * adjust the settings for this buffer only. This must remain at the end
15832 + * ---------------------------------------------------------------------------
15833 + * Local variables:
15834 + * c-file-style: "linux"
15837 diff -Naur -X ../exclude-files orig/arch/um/include/os.h um/arch/um/include/os.h
15838 --- orig/arch/um/include/os.h 1969-12-31 19:00:00.000000000 -0500
15839 +++ um/arch/um/include/os.h 2003-12-17 10:48:12.000000000 -0500
15842 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
15843 + * Licensed under the GPL
15849 +#include "asm/types.h"
15850 +#include "../os/include/file.h"
15852 +#define OS_TYPE_FILE 1
15853 +#define OS_TYPE_DIR 2
15854 +#define OS_TYPE_SYMLINK 3
15855 +#define OS_TYPE_CHARDEV 4
15856 +#define OS_TYPE_BLOCKDEV 5
15857 +#define OS_TYPE_FIFO 6
15858 +#define OS_TYPE_SOCK 7
15860 +/* os_access() flags */
15861 +#define OS_ACC_F_OK 0 /* Test for existence. */
15862 +#define OS_ACC_X_OK 1 /* Test for execute permission. */
15863 +#define OS_ACC_W_OK 2 /* Test for write permission. */
15864 +#define OS_ACC_R_OK 4 /* Test for read permission. */
15865 +#define OS_ACC_RW_OK (OS_ACC_W_OK | OS_ACC_R_OK) /* Test for RW permission */
15868 + * types taken from stat_file() in hostfs_user.c
15869 + * (if they are wrong here, they are wrong there...).
15872 + int ust_dev; /* device */
15873 + unsigned long long ust_ino; /* inode */
15874 + int ust_mode; /* protection */
15875 + int ust_nlink; /* number of hard links */
15876 + int ust_uid; /* user ID of owner */
15877 + int ust_gid; /* group ID of owner */
15878 + unsigned long long ust_size; /* total size, in bytes */
15879 + int ust_blksize; /* blocksize for filesystem I/O */
15880 + unsigned long long ust_blocks; /* number of blocks allocated */
15881 + unsigned long ust_atime; /* time of last access */
15882 + unsigned long ust_mtime; /* time of last modification */
15883 + unsigned long ust_ctime; /* time of last change */
15886 +struct openflags {
15887 + unsigned int r : 1;
15888 + unsigned int w : 1;
15889 + unsigned int s : 1; /* O_SYNC */
15890 + unsigned int c : 1; /* O_CREAT */
15891 + unsigned int t : 1; /* O_TRUNC */
15892 + unsigned int a : 1; /* O_APPEND */
15893 + unsigned int e : 1; /* O_EXCL */
15894 + unsigned int cl : 1; /* FD_CLOEXEC */
15897 +#define OPENFLAGS() ((struct openflags) { .r = 0, .w = 0, .s = 0, .c = 0, \
15898 + .t = 0, .a = 0, .e = 0, .cl = 0 })
15900 +static inline struct openflags of_read(struct openflags flags)
15906 +static inline struct openflags of_write(struct openflags flags)
15912 +static inline struct openflags of_rdwr(struct openflags flags)
15914 + return(of_read(of_write(flags)));
15917 +static inline struct openflags of_set_rw(struct openflags flags, int r, int w)
15924 +static inline struct openflags of_sync(struct openflags flags)
15930 +static inline struct openflags of_create(struct openflags flags)
15936 +static inline struct openflags of_trunc(struct openflags flags)
15942 +static inline struct openflags of_append(struct openflags flags)
15948 +static inline struct openflags of_excl(struct openflags flags)
15954 +static inline struct openflags of_cloexec(struct openflags flags)
15960 +extern int os_stat_file(const char *file_name, struct uml_stat *buf);
15961 +extern int os_stat_fd(const int fd, struct uml_stat *buf);
15962 +extern int os_access(const char *file, int mode);
15963 +extern void os_print_error(int error, const char* str);
15964 +extern int os_get_exec_close(int fd, int *close_on_exec);
15965 +extern int os_set_exec_close(int fd, int close_on_exec);
15966 +extern int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg);
15967 +extern int os_window_size(int fd, int *rows, int *cols);
15968 +extern int os_new_tty_pgrp(int fd, int pid);
15969 +extern int os_get_ifname(int fd, char *namebuf);
15970 +extern int os_set_slip(int fd);
15971 +extern int os_set_owner(int fd, int pid);
15972 +extern int os_sigio_async(int master, int slave);
15973 +extern int os_mode_fd(int fd, int mode);
15975 +extern int os_seek_file(int fd, __u64 offset);
15976 +extern int os_open_file(char *file, struct openflags flags, int mode);
15977 +extern int os_read_file(int fd, void *buf, int len);
15978 +extern int os_write_file(int fd, const void *buf, int count);
15979 +extern int os_file_size(char *file, long long *size_out);
15980 +extern int os_file_modtime(char *file, unsigned long *modtime);
15981 +extern int os_pipe(int *fd, int stream, int close_on_exec);
15982 +extern int os_set_fd_async(int fd, int owner);
15983 +extern int os_set_fd_block(int fd, int blocking);
15984 +extern int os_accept_connection(int fd);
15985 +extern int os_create_unix_socket(char *file, int len, int close_on_exec);
15986 +extern int os_shutdown_socket(int fd, int r, int w);
15987 +extern void os_close_file(int fd);
15988 +extern int os_rcv_fd(int fd, int *helper_pid_out);
15989 +extern int create_unix_socket(char *file, int len, int close_on_exec);
15990 +extern int os_connect_socket(char *name);
15991 +extern int os_file_type(char *file);
15992 +extern int os_file_mode(char *file, struct openflags *mode_out);
15993 +extern int os_lock_file(int fd, int excl);
15995 +extern unsigned long os_process_pc(int pid);
15996 +extern int os_process_parent(int pid);
15997 +extern void os_stop_process(int pid);
15998 +extern void os_kill_process(int pid, int reap_child);
15999 +extern void os_usr1_process(int pid);
16000 +extern int os_getpid(void);
16002 +extern int os_map_memory(void *virt, int fd, unsigned long long off,
16003 + unsigned long len, int r, int w, int x);
16004 +extern int os_protect_memory(void *addr, unsigned long len,
16005 + int r, int w, int x);
16006 +extern int os_unmap_memory(void *addr, int len);
16007 +extern void os_flush_stdout(void);
16012 + * Overrides for Emacs so that we follow Linus's tabbing style.
16013 + * Emacs will notice this stuff at the end of the file and automatically
16014 + * adjust the settings for this buffer only. This must remain at the end
16016 + * ---------------------------------------------------------------------------
16017 + * Local variables:
16018 + * c-file-style: "linux"
16021 diff -Naur -X ../exclude-files orig/arch/um/include/process.h um/arch/um/include/process.h
16022 --- orig/arch/um/include/process.h 1969-12-31 19:00:00.000000000 -0500
16023 +++ um/arch/um/include/process.h 2003-10-21 03:26:06.000000000 -0400
16026 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
16027 + * Licensed under the GPL
16030 +#ifndef __PROCESS_H__
16031 +#define __PROCESS_H__
16033 +#include <asm/sigcontext.h>
16035 +extern void sig_handler(int sig, struct sigcontext sc);
16036 +extern void alarm_handler(int sig, struct sigcontext sc);
16041 + * Overrides for Emacs so that we follow Linus's tabbing style.
16042 + * Emacs will notice this stuff at the end of the file and automatically
16043 + * adjust the settings for this buffer only. This must remain at the end
16045 + * ---------------------------------------------------------------------------
16046 + * Local variables:
16047 + * c-file-style: "linux"
16050 diff -Naur -X ../exclude-files orig/arch/um/include/ptrace_user.h um/arch/um/include/ptrace_user.h
16051 --- orig/arch/um/include/ptrace_user.h 1969-12-31 19:00:00.000000000 -0500
16052 +++ um/arch/um/include/ptrace_user.h 2003-10-21 03:26:06.000000000 -0400
16055 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
16056 + * Licensed under the GPL
16059 +#ifndef __PTRACE_USER_H__
16060 +#define __PTRACE_USER_H__
16062 +#include "sysdep/ptrace_user.h"
16064 +extern int ptrace_getregs(long pid, unsigned long *regs_out);
16065 +extern int ptrace_setregs(long pid, unsigned long *regs_in);
16066 +extern int ptrace_getfpregs(long pid, unsigned long *regs_out);
16067 +extern void arch_enter_kernel(void *task, int pid);
16068 +extern void arch_leave_kernel(void *task, int pid);
16069 +extern void ptrace_pokeuser(unsigned long addr, unsigned long data);
16072 diff -Naur -X ../exclude-files orig/arch/um/include/sigcontext.h um/arch/um/include/sigcontext.h
16073 --- orig/arch/um/include/sigcontext.h 1969-12-31 19:00:00.000000000 -0500
16074 +++ um/arch/um/include/sigcontext.h 2003-10-21 03:26:06.000000000 -0400
16077 + * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
16078 + * Licensed under the GPL
16081 +#ifndef __UML_SIGCONTEXT_H__
16082 +#define __UML_SIGCONTEXT_H__
16084 +#include "sysdep/sigcontext.h"
16086 +extern int sc_size(void *data);
16087 +extern void sc_to_sc(void *to_ptr, void *from_ptr);
16092 + * Overrides for Emacs so that we follow Linus's tabbing style.
16093 + * Emacs will notice this stuff at the end of the file and automatically
16094 + * adjust the settings for this buffer only. This must remain at the end
16096 + * ---------------------------------------------------------------------------
16097 + * Local variables:
16098 + * c-file-style: "linux"
16101 diff -Naur -X ../exclude-files orig/arch/um/include/sigio.h um/arch/um/include/sigio.h
16102 --- orig/arch/um/include/sigio.h 1969-12-31 19:00:00.000000000 -0500
16103 +++ um/arch/um/include/sigio.h 2003-10-21 03:26:06.000000000 -0400
16106 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
16107 + * Licensed under the GPL
16110 +#ifndef __SIGIO_H__
16111 +#define __SIGIO_H__
16113 +extern int write_sigio_irq(int fd);
16114 +extern int register_sigio_fd(int fd);
16115 +extern int read_sigio_fd(int fd);
16116 +extern int add_sigio_fd(int fd, int read);
16117 +extern int ignore_sigio_fd(int fd);
16118 +extern void sigio_lock(void);
16119 +extern void sigio_unlock(void);
16124 + * Overrides for Emacs so that we follow Linus's tabbing style.
16125 + * Emacs will notice this stuff at the end of the file and automatically
16126 + * adjust the settings for this buffer only. This must remain at the end
16128 + * ---------------------------------------------------------------------------
16129 + * Local variables:
16130 + * c-file-style: "linux"
16133 diff -Naur -X ../exclude-files orig/arch/um/include/signal_kern.h um/arch/um/include/signal_kern.h
16134 --- orig/arch/um/include/signal_kern.h 1969-12-31 19:00:00.000000000 -0500
16135 +++ um/arch/um/include/signal_kern.h 2003-10-21 03:26:06.000000000 -0400
16138 + * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
16139 + * Licensed under the GPL
16142 +#ifndef __SIGNAL_KERN_H__
16143 +#define __SIGNAL_KERN_H__
16145 +extern int have_signals(void *t);
16150 + * Overrides for Emacs so that we follow Linus's tabbing style.
16151 + * Emacs will notice this stuff at the end of the file and automatically
16152 + * adjust the settings for this buffer only. This must remain at the end
16154 + * ---------------------------------------------------------------------------
16155 + * Local variables:
16156 + * c-file-style: "linux"
16159 diff -Naur -X ../exclude-files orig/arch/um/include/signal_user.h um/arch/um/include/signal_user.h
16160 --- orig/arch/um/include/signal_user.h 1969-12-31 19:00:00.000000000 -0500
16161 +++ um/arch/um/include/signal_user.h 2003-10-21 03:26:06.000000000 -0400
16164 + * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
16165 + * Licensed under the GPL
16168 +#ifndef __SIGNAL_USER_H__
16169 +#define __SIGNAL_USER_H__
16171 +extern int signal_stack_size;
16173 +extern int change_sig(int signal, int on);
16174 +extern void set_sigstack(void *stack, int size);
16175 +extern void set_handler(int sig, void (*handler)(int), int flags, ...);
16180 + * Overrides for Emacs so that we follow Linus's tabbing style.
16181 + * Emacs will notice this stuff at the end of the file and automatically
16182 + * adjust the settings for this buffer only. This must remain at the end
16184 + * ---------------------------------------------------------------------------
16185 + * Local variables:
16186 + * c-file-style: "linux"
16189 diff -Naur -X ../exclude-files orig/arch/um/include/skas_ptrace.h um/arch/um/include/skas_ptrace.h
16190 --- orig/arch/um/include/skas_ptrace.h 1969-12-31 19:00:00.000000000 -0500
16191 +++ um/arch/um/include/skas_ptrace.h 2003-10-21 03:26:06.000000000 -0400
16194 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
16195 + * Licensed under the GPL
16198 +#ifndef __SKAS_PTRACE_H
16199 +#define __SKAS_PTRACE_H
16201 +struct ptrace_faultinfo {
16203 + unsigned long addr;
16206 +struct ptrace_ldt {
16209 + unsigned long bytecount;
16212 +#define PTRACE_FAULTINFO 52
16213 +#define PTRACE_SIGPENDING 53
16214 +#define PTRACE_LDT 54
16215 +#define PTRACE_SWITCH_MM 55
16220 + * Overrides for Emacs so that we follow Linus's tabbing style.
16221 + * Emacs will notice this stuff at the end of the file and automatically
16222 + * adjust the settings for this buffer only. This must remain at the end
16224 + * ---------------------------------------------------------------------------
16225 + * Local variables:
16226 + * c-file-style: "linux"
16229 diff -Naur -X ../exclude-files orig/arch/um/include/syscall_user.h um/arch/um/include/syscall_user.h
16230 --- orig/arch/um/include/syscall_user.h 1969-12-31 19:00:00.000000000 -0500
16231 +++ um/arch/um/include/syscall_user.h 2003-10-21 03:26:06.000000000 -0400
16234 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
16235 + * Licensed under the GPL
16238 +#ifndef __SYSCALL_USER_H
16239 +#define __SYSCALL_USER_H
16241 +extern int record_syscall_start(int syscall);
16242 +extern void record_syscall_end(int index, int result);
16247 + * Overrides for Emacs so that we follow Linus's tabbing style.
16248 + * Emacs will notice this stuff at the end of the file and automatically
16249 + * adjust the settings for this buffer only. This must remain at the end
16251 + * ---------------------------------------------------------------------------
16252 + * Local variables:
16253 + * c-file-style: "linux"
16256 diff -Naur -X ../exclude-files orig/arch/um/include/sysdep-i386/checksum.h um/arch/um/include/sysdep-i386/checksum.h
16257 --- orig/arch/um/include/sysdep-i386/checksum.h 1969-12-31 19:00:00.000000000 -0500
16258 +++ um/arch/um/include/sysdep-i386/checksum.h 2004-01-13 23:40:05.000000000 -0500
16261 + * Licensed under the GPL
16264 +#ifndef __UM_SYSDEP_CHECKSUM_H
16265 +#define __UM_SYSDEP_CHECKSUM_H
16267 +#include "linux/string.h"
16268 +#include "asm/uaccess.h"
16271 + * computes the checksum of a memory block at buff, length len,
16272 + * and adds in "sum" (32-bit)
16274 + * returns a 32-bit number suitable for feeding into itself
16275 + * or csum_tcpudp_magic
16277 + * this function must be called with even lengths, except
16278 + * for the last fragment, which may be odd
16280 + * it's best to have buff aligned on a 32-bit boundary
16282 +unsigned int csum_partial(const unsigned char * buff, int len,
16283 + unsigned int sum);
16286 + * the same as csum_partial, but copies from src while it
16287 + * checksums, and handles user-space pointer exceptions correctly, when needed.
16289 + * here even more important to align src and dst on a 32-bit (or even
16290 + * better 64-bit) boundary
16293 +unsigned int csum_partial_copy_to(const char *src, char *dst, int len,
16294 + int sum, int *err_ptr);
16295 +unsigned int csum_partial_copy_from(const char *src, char *dst, int len,
16296 + int sum, int *err_ptr);
16299 + * Note: when you get a NULL pointer exception here this means someone
16300 + * passed in an incorrect kernel address to one of these functions.
16302 + * If you use these functions directly please don't forget the
16307 +unsigned int csum_partial_copy_nocheck(const char *src, char *dst,
16308 + int len, int sum)
16310 + memcpy(dst, src, len);
16311 + return(csum_partial(dst, len, sum));
16315 +unsigned int csum_partial_copy_from_user(const char *src, char *dst,
16316 + int len, int sum, int *err_ptr)
16318 + return csum_partial_copy_from(src, dst, len, sum, err_ptr);
16322 + * These are the old (and unsafe) way of doing checksums, a warning message
16323 + * will be printed if they are used and an exception occurs.
16325 + * these functions should go away after some time.
16328 +#define csum_partial_copy_fromuser csum_partial_copy_from_user
16329 +unsigned int csum_partial_copy( const char *src, char *dst, int len, int sum);
16332 + * This is a version of ip_compute_csum() optimized for IP headers,
16333 + * which always checksum on 4 octet boundaries.
16335 + * By Jorge Cwik <jorge@laser.satlink.net>, adapted for linux by
16336 + * Arnt Gulbrandsen.
16338 +static inline unsigned short ip_fast_csum(unsigned char * iph,
16339 + unsigned int ihl)
16341 + unsigned int sum;
16343 + __asm__ __volatile__(
16344 + "movl (%1), %0 ;\n"
16345 + "subl $4, %2 ;\n"
16347 + "addl 4(%1), %0 ;\n"
16348 + "adcl 8(%1), %0 ;\n"
16349 + "adcl 12(%1), %0 ;\n"
16350 +"1: adcl 16(%1), %0 ;\n"
16351 + "lea 4(%1), %1 ;\n"
16354 + "adcl $0, %0 ;\n"
16355 + "movl %0, %2 ;\n"
16356 + "shrl $16, %0 ;\n"
16357 + "addw %w2, %w0 ;\n"
16358 + "adcl $0, %0 ;\n"
16361 + /* Since the input registers which are loaded with iph and ipl
16362 + are modified, we must also specify them as outputs, or gcc
16363 + will assume they contain their original values. */
16364 + : "=r" (sum), "=r" (iph), "=r" (ihl)
16365 + : "1" (iph), "2" (ihl));
16370 + * Fold a partial checksum
16373 +static inline unsigned int csum_fold(unsigned int sum)
16376 + "addl %1, %0 ;\n"
16377 + "adcl $0xffff, %0 ;\n"
16379 + : "r" (sum << 16), "0" (sum & 0xffff0000)
16381 + return (~sum) >> 16;
16384 +static inline unsigned long csum_tcpudp_nofold(unsigned long saddr,
16385 + unsigned long daddr,
16386 + unsigned short len,
16387 + unsigned short proto,
16388 + unsigned int sum)
16391 + "addl %1, %0 ;\n"
16392 + "adcl %2, %0 ;\n"
16393 + "adcl %3, %0 ;\n"
16394 + "adcl $0, %0 ;\n"
16396 + : "g" (daddr), "g"(saddr), "g"((ntohs(len)<<16)+proto*256), "0"(sum));
16401 + * computes the checksum of the TCP/UDP pseudo-header
16402 + * returns a 16-bit checksum, already complemented
16404 +static inline unsigned short int csum_tcpudp_magic(unsigned long saddr,
16405 + unsigned long daddr,
16406 + unsigned short len,
16407 + unsigned short proto,
16408 + unsigned int sum)
16410 + return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
16414 + * this routine is used for miscellaneous IP-like checksums, mainly
16418 +static inline unsigned short ip_compute_csum(unsigned char * buff, int len)
16420 + return csum_fold (csum_partial(buff, len, 0));
16423 +#define _HAVE_ARCH_IPV6_CSUM
16424 +static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
16425 + struct in6_addr *daddr,
16427 + unsigned short proto,
16428 + unsigned int sum)
16431 + "addl 0(%1), %0 ;\n"
16432 + "adcl 4(%1), %0 ;\n"
16433 + "adcl 8(%1), %0 ;\n"
16434 + "adcl 12(%1), %0 ;\n"
16435 + "adcl 0(%2), %0 ;\n"
16436 + "adcl 4(%2), %0 ;\n"
16437 + "adcl 8(%2), %0 ;\n"
16438 + "adcl 12(%2), %0 ;\n"
16439 + "adcl %3, %0 ;\n"
16440 + "adcl %4, %0 ;\n"
16441 + "adcl $0, %0 ;\n"
16443 + : "r" (saddr), "r" (daddr),
16444 + "r"(htonl(len)), "r"(htonl(proto)), "0"(sum));
16446 + return csum_fold(sum);
16450 + * Copy and checksum to user
16452 +#define HAVE_CSUM_COPY_USER
16453 +static __inline__ unsigned int csum_and_copy_to_user(const char *src,
16454 + char *dst, int len,
16455 + int sum, int *err_ptr)
16457 + if (access_ok(VERIFY_WRITE, dst, len))
16458 + return(csum_partial_copy_to(src, dst, len, sum, err_ptr));
16461 + *err_ptr = -EFAULT;
16463 + return -1; /* invalid checksum */
16469 + * Overrides for Emacs so that we follow Linus's tabbing style.
16470 + * Emacs will notice this stuff at the end of the file and automatically
16471 + * adjust the settings for this buffer only. This must remain at the end
16473 + * ---------------------------------------------------------------------------
16474 + * Local variables:
16475 + * c-file-style: "linux"
16478 diff -Naur -X ../exclude-files orig/arch/um/include/sysdep-i386/frame.h um/arch/um/include/sysdep-i386/frame.h
16479 --- orig/arch/um/include/sysdep-i386/frame.h 1969-12-31 19:00:00.000000000 -0500
16480 +++ um/arch/um/include/sysdep-i386/frame.h 2003-10-21 03:26:06.000000000 -0400
16483 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
16484 + * Licensed under the GPL
16487 +#ifndef __FRAME_I386_H
16488 +#define __FRAME_I386_H
16490 +struct arch_frame_data_raw {
16491 + unsigned long fp_start;
16492 + unsigned long sr;
16495 +struct arch_frame_data {
16496 + int fpstate_size;
16502 + * Overrides for Emacs so that we follow Linus's tabbing style.
16503 + * Emacs will notice this stuff at the end of the file and automatically
16504 + * adjust the settings for this buffer only. This must remain at the end
16506 + * ---------------------------------------------------------------------------
16507 + * Local variables:
16508 + * c-file-style: "linux"
16511 diff -Naur -X ../exclude-files orig/arch/um/include/sysdep-i386/frame_kern.h um/arch/um/include/sysdep-i386/frame_kern.h
16512 --- orig/arch/um/include/sysdep-i386/frame_kern.h 1969-12-31 19:00:00.000000000 -0500
16513 +++ um/arch/um/include/sysdep-i386/frame_kern.h 2003-10-21 03:26:06.000000000 -0400
16516 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
16517 + * Licensed under the GPL
16520 +#ifndef __FRAME_KERN_I386_H
16521 +#define __FRAME_KERN_I386_H
16523 +/* This is called from sys_sigreturn. It takes the sp at the point of the
16524 + * sigreturn system call and returns the address of the sigcontext struct
16528 +static inline void *sp_to_sc(unsigned long sp)
16530 + return((void *) sp);
16533 +static inline void *sp_to_uc(unsigned long sp)
16535 + unsigned long uc;
16537 + uc = sp + signal_frame_si.uc_index -
16538 + signal_frame_si.common.sp_index - 4;
16539 + return((void *) uc);
16542 +static inline void *sp_to_rt_sc(unsigned long sp)
16544 + unsigned long sc;
16546 + sc = sp - signal_frame_si.common.sp_index +
16547 + signal_frame_si.common.len - 4;
16548 + return((void *) sc);
16551 +static inline void *sp_to_mask(unsigned long sp)
16553 + unsigned long mask;
16555 + mask = sp - signal_frame_sc.common.sp_index +
16556 + signal_frame_sc.common.len - 8;
16557 + return((void *) mask);
16560 +extern int sc_size(void *data);
16562 +static inline void *sp_to_rt_mask(unsigned long sp)
16564 + unsigned long mask;
16566 + mask = sp - signal_frame_si.common.sp_index +
16567 + signal_frame_si.common.len +
16568 + sc_size(&signal_frame_si.common.arch) - 4;
16569 + return((void *) mask);
16575 + * Overrides for Emacs so that we follow Linus's tabbing style.
16576 + * Emacs will notice this stuff at the end of the file and automatically
16577 + * adjust the settings for this buffer only. This must remain at the end
16579 + * ---------------------------------------------------------------------------
16580 + * Local variables:
16581 + * c-file-style: "linux"
16584 diff -Naur -X ../exclude-files orig/arch/um/include/sysdep-i386/frame_user.h um/arch/um/include/sysdep-i386/frame_user.h
16585 --- orig/arch/um/include/sysdep-i386/frame_user.h 1969-12-31 19:00:00.000000000 -0500
16586 +++ um/arch/um/include/sysdep-i386/frame_user.h 2004-01-14 03:54:47.000000000 -0500
16589 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
16590 + * Licensed under the GPL
16593 +#ifndef __FRAME_USER_I386_H
16594 +#define __FRAME_USER_I386_H
16596 +#include <asm/page.h>
16597 +#include "sysdep/frame.h"
16599 +/* This stuff is to calculate the size of the fp state struct at runtime
16600 + * because it has changed between 2.2 and 2.4 and it would be good for a
16601 + * UML compiled on one to work on the other.
16602 + * So, setup_arch_frame_raw fills in the arch struct with the raw data, which
16603 + * just contains the address of the end of the sigcontext. This is invoked
16604 + * from the signal handler.
16605 + * setup_arch_frame uses that data to figure out what
16606 + * arch_frame_data.fpstate_size should be. It really has no idea, since it's
16607 + * not allowed to do sizeof(struct fpstate) but it's safe to consider that it's
16608 + * everything from the end of the sigcontext up to the top of the stack. So,
16609 + * it masks off the page number to get the offset within the page and subtracts
16610 + * that from the page size, and that's how big the fpstate struct will be
16611 + * considered to be.
16614 +static inline void setup_arch_frame_raw(struct arch_frame_data_raw *data,
16615 + void *end, unsigned long srp)
16617 + unsigned long sr = *((unsigned long *) srp);
16619 + data->fp_start = (unsigned long) end;
16620 + if((sr & PAGE_MASK) == ((unsigned long) end & PAGE_MASK))
16622 + else data->sr = 0;
16625 +static inline void setup_arch_frame(struct arch_frame_data_raw *in,
16626 + struct arch_frame_data *out)
16628 + unsigned long fpstate_start = in->fp_start;
16631 + fpstate_start &= ~PAGE_MASK;
16632 + out->fpstate_size = PAGE_SIZE - fpstate_start;
16635 + out->fpstate_size = in->sr - fpstate_start;
16639 +/* This figures out where on the stack the SA_RESTORER function address
16640 + * is stored. For i386, it's the signal handler return address, so it's
16641 + * located next to the frame pointer.
16642 + * This is inlined, so __builtin_frame_address(0) is correct. Otherwise,
16643 + * it would have to be __builtin_frame_address(1).
16646 +#define frame_restorer() \
16648 + unsigned long *fp; \
16650 + fp = __builtin_frame_address(0); \
16651 + ((unsigned long) (fp + 1)); \
16654 +/* Similarly, this returns the value of sp when the handler was first
16655 + * entered. This is used to calculate the proper sp when delivering
16659 +#define frame_sp() \
16661 + unsigned long *fp; \
16663 + fp = __builtin_frame_address(0); \
16664 + ((unsigned long) (fp + 1)); \
16670 + * Overrides for Emacs so that we follow Linus's tabbing style.
16671 + * Emacs will notice this stuff at the end of the file and automatically
16672 + * adjust the settings for this buffer only. This must remain at the end
16674 + * ---------------------------------------------------------------------------
16675 + * Local variables:
16676 + * c-file-style: "linux"
16679 diff -Naur -X ../exclude-files orig/arch/um/include/sysdep-i386/ptrace.h um/arch/um/include/sysdep-i386/ptrace.h
16680 --- orig/arch/um/include/sysdep-i386/ptrace.h 1969-12-31 19:00:00.000000000 -0500
16681 +++ um/arch/um/include/sysdep-i386/ptrace.h 2003-10-21 03:26:06.000000000 -0400
16684 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
16685 + * Licensed under the GPL
16688 +#ifndef __SYSDEP_I386_PTRACE_H
16689 +#define __SYSDEP_I386_PTRACE_H
16691 +#include "uml-config.h"
16693 +#ifdef UML_CONFIG_MODE_TT
16694 +#include "ptrace-tt.h"
16697 +#ifdef UML_CONFIG_MODE_SKAS
16698 +#include "ptrace-skas.h"
16701 +#include "choose-mode.h"
16703 +union uml_pt_regs {
16704 +#ifdef UML_CONFIG_MODE_TT
16710 +#ifdef UML_CONFIG_MODE_SKAS
16711 + struct skas_regs {
16712 + unsigned long regs[HOST_FRAME_SIZE];
16713 + unsigned long fp[HOST_FP_SIZE];
16714 + unsigned long xfp[HOST_XFP_SIZE];
16715 + unsigned long fault_addr;
16716 + unsigned long fault_type;
16717 + unsigned long trap_type;
16724 +#define EMPTY_UML_PT_REGS { }
16726 +extern int mode_tt;
16728 +#define UPT_SC(r) ((r)->tt.sc)
16729 +#define UPT_IP(r) \
16730 + CHOOSE_MODE(SC_IP(UPT_SC(r)), REGS_IP((r)->skas.regs))
16731 +#define UPT_SP(r) \
16732 + CHOOSE_MODE(SC_SP(UPT_SC(r)), REGS_SP((r)->skas.regs))
16733 +#define UPT_EFLAGS(r) \
16734 + CHOOSE_MODE(SC_EFLAGS(UPT_SC(r)), REGS_EFLAGS((r)->skas.regs))
16735 +#define UPT_EAX(r) \
16736 + CHOOSE_MODE(SC_EAX(UPT_SC(r)), REGS_EAX((r)->skas.regs))
16737 +#define UPT_EBX(r) \
16738 + CHOOSE_MODE(SC_EBX(UPT_SC(r)), REGS_EBX((r)->skas.regs))
16739 +#define UPT_ECX(r) \
16740 + CHOOSE_MODE(SC_ECX(UPT_SC(r)), REGS_ECX((r)->skas.regs))
16741 +#define UPT_EDX(r) \
16742 + CHOOSE_MODE(SC_EDX(UPT_SC(r)), REGS_EDX((r)->skas.regs))
16743 +#define UPT_ESI(r) \
16744 + CHOOSE_MODE(SC_ESI(UPT_SC(r)), REGS_ESI((r)->skas.regs))
16745 +#define UPT_EDI(r) \
16746 + CHOOSE_MODE(SC_EDI(UPT_SC(r)), REGS_EDI((r)->skas.regs))
16747 +#define UPT_EBP(r) \
16748 + CHOOSE_MODE(SC_EBP(UPT_SC(r)), REGS_EBP((r)->skas.regs))
16749 +#define UPT_ORIG_EAX(r) \
16750 + CHOOSE_MODE((r)->tt.syscall, (r)->skas.syscall)
16751 +#define UPT_CS(r) \
16752 + CHOOSE_MODE(SC_CS(UPT_SC(r)), REGS_CS((r)->skas.regs))
16753 +#define UPT_SS(r) \
16754 + CHOOSE_MODE(SC_SS(UPT_SC(r)), REGS_SS((r)->skas.regs))
16755 +#define UPT_DS(r) \
16756 + CHOOSE_MODE(SC_DS(UPT_SC(r)), REGS_DS((r)->skas.regs))
16757 +#define UPT_ES(r) \
16758 + CHOOSE_MODE(SC_ES(UPT_SC(r)), REGS_ES((r)->skas.regs))
16759 +#define UPT_FS(r) \
16760 + CHOOSE_MODE(SC_FS(UPT_SC(r)), REGS_FS((r)->skas.regs))
16761 +#define UPT_GS(r) \
16762 + CHOOSE_MODE(SC_GS(UPT_SC(r)), REGS_GS((r)->skas.regs))
16764 +#define UPT_SYSCALL_ARG1(r) UPT_EBX(r)
16765 +#define UPT_SYSCALL_ARG2(r) UPT_ECX(r)
16766 +#define UPT_SYSCALL_ARG3(r) UPT_EDX(r)
16767 +#define UPT_SYSCALL_ARG4(r) UPT_ESI(r)
16768 +#define UPT_SYSCALL_ARG5(r) UPT_EDI(r)
16769 +#define UPT_SYSCALL_ARG6(r) UPT_EBP(r)
16771 +extern int user_context(unsigned long sp);
16773 +#define UPT_IS_USER(r) \
16774 + CHOOSE_MODE(user_context(UPT_SP(r)), (r)->skas.is_user)
16776 +struct syscall_args {
16777 + unsigned long args[6];
16780 +#define SYSCALL_ARGS(r) ((struct syscall_args) \
16781 + { .args = { UPT_SYSCALL_ARG1(r), \
16782 + UPT_SYSCALL_ARG2(r), \
16783 + UPT_SYSCALL_ARG3(r), \
16784 + UPT_SYSCALL_ARG4(r), \
16785 + UPT_SYSCALL_ARG5(r), \
16786 + UPT_SYSCALL_ARG6(r) } } )
16788 +#define UPT_REG(regs, reg) \
16789 + ({ unsigned long val; \
16791 + case EIP: val = UPT_IP(regs); break; \
16792 + case UESP: val = UPT_SP(regs); break; \
16793 + case EAX: val = UPT_EAX(regs); break; \
16794 + case EBX: val = UPT_EBX(regs); break; \
16795 + case ECX: val = UPT_ECX(regs); break; \
16796 + case EDX: val = UPT_EDX(regs); break; \
16797 + case ESI: val = UPT_ESI(regs); break; \
16798 + case EDI: val = UPT_EDI(regs); break; \
16799 + case EBP: val = UPT_EBP(regs); break; \
16800 + case ORIG_EAX: val = UPT_ORIG_EAX(regs); break; \
16801 + case CS: val = UPT_CS(regs); break; \
16802 + case SS: val = UPT_SS(regs); break; \
16803 + case DS: val = UPT_DS(regs); break; \
16804 + case ES: val = UPT_ES(regs); break; \
16805 + case FS: val = UPT_FS(regs); break; \
16806 + case GS: val = UPT_GS(regs); break; \
16807 + case EFL: val = UPT_EFLAGS(regs); break; \
16809 + panic("Bad register in UPT_REG : %d\n", reg); \
16816 +#define UPT_SET(regs, reg, val) \
16819 + case EIP: UPT_IP(regs) = val; break; \
16820 + case UESP: UPT_SP(regs) = val; break; \
16821 + case EAX: UPT_EAX(regs) = val; break; \
16822 + case EBX: UPT_EBX(regs) = val; break; \
16823 + case ECX: UPT_ECX(regs) = val; break; \
16824 + case EDX: UPT_EDX(regs) = val; break; \
16825 + case ESI: UPT_ESI(regs) = val; break; \
16826 + case EDI: UPT_EDI(regs) = val; break; \
16827 + case EBP: UPT_EBP(regs) = val; break; \
16828 + case ORIG_EAX: UPT_ORIG_EAX(regs) = val; break; \
16829 + case CS: UPT_CS(regs) = val; break; \
16830 + case SS: UPT_SS(regs) = val; break; \
16831 + case DS: UPT_DS(regs) = val; break; \
16832 + case ES: UPT_ES(regs) = val; break; \
16833 + case FS: UPT_FS(regs) = val; break; \
16834 + case GS: UPT_GS(regs) = val; break; \
16835 + case EFL: UPT_EFLAGS(regs) = val; break; \
16837 + panic("Bad register in UPT_SET : %d\n", reg); \
16842 +#define UPT_SET_SYSCALL_RETURN(r, res) \
16843 + CHOOSE_MODE(SC_SET_SYSCALL_RETURN(UPT_SC(r), (res)), \
16844 + REGS_SET_SYSCALL_RETURN((r)->skas.regs, (res)))
16846 +#define UPT_RESTART_SYSCALL(r) \
16847 + CHOOSE_MODE(SC_RESTART_SYSCALL(UPT_SC(r)), \
16848 + REGS_RESTART_SYSCALL((r)->skas.regs))
16850 +#define UPT_ORIG_SYSCALL(r) UPT_EAX(r)
16851 +#define UPT_SYSCALL_NR(r) UPT_ORIG_EAX(r)
16852 +#define UPT_SYSCALL_RET(r) UPT_EAX(r)
16854 +#define UPT_SEGV_IS_FIXABLE(r) \
16855 + CHOOSE_MODE(SC_SEGV_IS_FIXABLE(UPT_SC(r)), \
16856 + REGS_SEGV_IS_FIXABLE(&r->skas))
16858 +#define UPT_FAULT_ADDR(r) \
16859 + CHOOSE_MODE(SC_FAULT_ADDR(UPT_SC(r)), REGS_FAULT_ADDR(&r->skas))
16861 +#define UPT_FAULT_WRITE(r) \
16862 + CHOOSE_MODE(SC_FAULT_WRITE(UPT_SC(r)), REGS_FAULT_WRITE(&r->skas))
16867 + * Overrides for Emacs so that we follow Linus's tabbing style.
16868 + * Emacs will notice this stuff at the end of the file and automatically
16869 + * adjust the settings for this buffer only. This must remain at the end
16871 + * ---------------------------------------------------------------------------
16872 + * Local variables:
16873 + * c-file-style: "linux"
16876 diff -Naur -X ../exclude-files orig/arch/um/include/sysdep-i386/ptrace_user.h um/arch/um/include/sysdep-i386/ptrace_user.h
16877 --- orig/arch/um/include/sysdep-i386/ptrace_user.h 1969-12-31 19:00:00.000000000 -0500
16878 +++ um/arch/um/include/sysdep-i386/ptrace_user.h 2003-10-21 03:26:06.000000000 -0400
16881 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
16882 + * Licensed under the GPL
16885 +#ifndef __SYSDEP_I386_PTRACE_USER_H__
16886 +#define __SYSDEP_I386_PTRACE_USER_H__
16888 +#include <asm/ptrace.h>
16890 +#define PT_OFFSET(r) ((r) * sizeof(long))
16892 +#define PT_SYSCALL_NR(regs) ((regs)[ORIG_EAX])
16893 +#define PT_SYSCALL_NR_OFFSET PT_OFFSET(ORIG_EAX)
16895 +#define PT_SYSCALL_ARG1_OFFSET PT_OFFSET(EBX)
16896 +#define PT_SYSCALL_ARG2_OFFSET PT_OFFSET(ECX)
16897 +#define PT_SYSCALL_ARG3_OFFSET PT_OFFSET(EDX)
16898 +#define PT_SYSCALL_ARG4_OFFSET PT_OFFSET(ESI)
16899 +#define PT_SYSCALL_ARG5_OFFSET PT_OFFSET(EDI)
16901 +#define PT_SYSCALL_RET_OFFSET PT_OFFSET(EAX)
16903 +#define PT_IP_OFFSET PT_OFFSET(EIP)
16904 +#define PT_IP(regs) ((regs)[EIP])
16905 +#define PT_SP(regs) ((regs)[UESP])
16907 +#ifndef FRAME_SIZE
16908 +#define FRAME_SIZE (17)
16910 +#define FRAME_SIZE_OFFSET (FRAME_SIZE * sizeof(unsigned long))
16912 +#define FP_FRAME_SIZE (27)
16913 +#define FPX_FRAME_SIZE (128)
16915 +#ifdef PTRACE_GETREGS
16916 +#define UM_HAVE_GETREGS
16919 +#ifdef PTRACE_SETREGS
16920 +#define UM_HAVE_SETREGS
16923 +#ifdef PTRACE_GETFPREGS
16924 +#define UM_HAVE_GETFPREGS
16927 +#ifdef PTRACE_SETFPREGS
16928 +#define UM_HAVE_SETFPREGS
16931 +#ifdef PTRACE_GETFPXREGS
16932 +#define UM_HAVE_GETFPXREGS
16935 +#ifdef PTRACE_SETFPXREGS
16936 +#define UM_HAVE_SETFPXREGS
16939 +extern void update_debugregs(int seq);
16942 diff -Naur -X ../exclude-files orig/arch/um/include/sysdep-i386/sigcontext.h um/arch/um/include/sysdep-i386/sigcontext.h
16943 --- orig/arch/um/include/sysdep-i386/sigcontext.h 1969-12-31 19:00:00.000000000 -0500
16944 +++ um/arch/um/include/sysdep-i386/sigcontext.h 2003-10-21 03:26:06.000000000 -0400
16947 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
16948 + * Licensed under the GPL
16951 +#ifndef __SYS_SIGCONTEXT_I386_H
16952 +#define __SYS_SIGCONTEXT_I386_H
16956 +#define IP_RESTART_SYSCALL(ip) ((ip) -= 2)
16958 +#define SC_RESTART_SYSCALL(sc) IP_RESTART_SYSCALL(SC_IP(sc))
16959 +#define SC_SET_SYSCALL_RETURN(sc, result) SC_EAX(sc) = (result)
16961 +#define SC_FAULT_ADDR(sc) SC_CR2(sc)
16962 +#define SC_FAULT_TYPE(sc) SC_ERR(sc)
16964 +#define FAULT_WRITE(err) (err & 2)
16965 +#define TO_SC_ERR(is_write) ((is_write) ? 2 : 0)
16967 +#define SC_FAULT_WRITE(sc) (FAULT_WRITE(SC_ERR(sc)))
16969 +#define SC_TRAP_TYPE(sc) SC_TRAPNO(sc)
16971 +/* ptrace expects that, at the start of a system call, %eax contains
16972 + * -ENOSYS, so this makes it so.
16974 +#define SC_START_SYSCALL(sc) do SC_EAX(sc) = -ENOSYS; while(0)
16976 +/* This is Page Fault */
16977 +#define SEGV_IS_FIXABLE(trap) (trap == 14)
16979 +#define SC_SEGV_IS_FIXABLE(sc) (SEGV_IS_FIXABLE(SC_TRAPNO(sc)))
16981 +extern unsigned long *sc_sigmask(void *sc_ptr);
16982 +extern int sc_get_fpregs(unsigned long buf, void *sc_ptr);
16986 + * Overrides for Emacs so that we follow Linus's tabbing style.
16987 + * Emacs will notice this stuff at the end of the file and automatically
16988 + * adjust the settings for this buffer only. This must remain at the end
16990 + * ---------------------------------------------------------------------------
16991 + * Local variables:
16992 + * c-file-style: "linux"
16995 diff -Naur -X ../exclude-files orig/arch/um/include/sysdep-i386/syscalls.h um/arch/um/include/sysdep-i386/syscalls.h
16996 --- orig/arch/um/include/sysdep-i386/syscalls.h 1969-12-31 19:00:00.000000000 -0500
16997 +++ um/arch/um/include/sysdep-i386/syscalls.h 2003-10-21 03:26:06.000000000 -0400
17000 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
17001 + * Licensed under the GPL
17004 +#include "asm/unistd.h"
17005 +#include "sysdep/ptrace.h"
17007 +typedef long syscall_handler_t(struct pt_regs);
17009 +#define EXECUTE_SYSCALL(syscall, regs) \
17010 + ((long (*)(struct syscall_args)) (*sys_call_table[syscall]))(SYSCALL_ARGS(®s->regs))
17012 +extern syscall_handler_t sys_modify_ldt;
17013 +extern syscall_handler_t old_mmap_i386;
17014 +extern syscall_handler_t old_select;
17015 +extern syscall_handler_t sys_ni_syscall;
17017 +#define ARCH_SYSCALLS \
17018 + [ __NR_mmap ] = old_mmap_i386, \
17019 + [ __NR_select ] = old_select, \
17020 + [ __NR_vm86old ] = sys_ni_syscall, \
17021 + [ __NR_modify_ldt ] = sys_modify_ldt, \
17022 + [ __NR_lchown32 ] = sys_lchown, \
17023 + [ __NR_getuid32 ] = sys_getuid, \
17024 + [ __NR_getgid32 ] = sys_getgid, \
17025 + [ __NR_geteuid32 ] = sys_geteuid, \
17026 + [ __NR_getegid32 ] = sys_getegid, \
17027 + [ __NR_setreuid32 ] = sys_setreuid, \
17028 + [ __NR_setregid32 ] = sys_setregid, \
17029 + [ __NR_getgroups32 ] = sys_getgroups, \
17030 + [ __NR_setgroups32 ] = sys_setgroups, \
17031 + [ __NR_fchown32 ] = sys_fchown, \
17032 + [ __NR_setresuid32 ] = sys_setresuid, \
17033 + [ __NR_getresuid32 ] = sys_getresuid, \
17034 + [ __NR_setresgid32 ] = sys_setresgid, \
17035 + [ __NR_getresgid32 ] = sys_getresgid, \
17036 + [ __NR_chown32 ] = sys_chown, \
17037 + [ __NR_setuid32 ] = sys_setuid, \
17038 + [ __NR_setgid32 ] = sys_setgid, \
17039 + [ __NR_setfsuid32 ] = sys_setfsuid, \
17040 + [ __NR_setfsgid32 ] = sys_setfsgid, \
17041 + [ __NR_pivot_root ] = sys_pivot_root, \
17042 + [ __NR_mincore ] = sys_mincore, \
17043 + [ __NR_madvise ] = sys_madvise, \
17044 + [ 222 ] = sys_ni_syscall,
17046 +/* 222 doesn't yet have a name in include/asm-i386/unistd.h */
17048 +#define LAST_ARCH_SYSCALL 222
17051 + * Overrides for Emacs so that we follow Linus's tabbing style.
17052 + * Emacs will notice this stuff at the end of the file and automatically
17053 + * adjust the settings for this buffer only. This must remain at the end
17055 + * ---------------------------------------------------------------------------
17056 + * Local variables:
17057 + * c-file-style: "linux"
17060 diff -Naur -X ../exclude-files orig/arch/um/include/sysdep-ia64/ptrace.h um/arch/um/include/sysdep-ia64/ptrace.h
17061 --- orig/arch/um/include/sysdep-ia64/ptrace.h 1969-12-31 19:00:00.000000000 -0500
17062 +++ um/arch/um/include/sysdep-ia64/ptrace.h 2003-10-21 03:26:06.000000000 -0400
17065 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
17066 + * Licensed under the GPL
17069 +#ifndef __SYSDEP_IA64_PTRACE_H
17070 +#define __SYSDEP_IA64_PTRACE_H
17072 +struct sys_pt_regs {
17076 +#define EMPTY_REGS { 0 }
17081 + * Overrides for Emacs so that we follow Linus's tabbing style.
17082 + * Emacs will notice this stuff at the end of the file and automatically
17083 + * adjust the settings for this buffer only. This must remain at the end
17085 + * ---------------------------------------------------------------------------
17086 + * Local variables:
17087 + * c-file-style: "linux"
17090 diff -Naur -X ../exclude-files orig/arch/um/include/sysdep-ia64/sigcontext.h um/arch/um/include/sysdep-ia64/sigcontext.h
17091 --- orig/arch/um/include/sysdep-ia64/sigcontext.h 1969-12-31 19:00:00.000000000 -0500
17092 +++ um/arch/um/include/sysdep-ia64/sigcontext.h 2003-10-21 03:26:06.000000000 -0400
17095 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
17096 + * Licensed under the GPL
17099 +#ifndef __SYSDEP_IA64_SIGCONTEXT_H
17100 +#define __SYSDEP_IA64_SIGCONTEXT_H
17105 + * Overrides for Emacs so that we follow Linus's tabbing style.
17106 + * Emacs will notice this stuff at the end of the file and automatically
17107 + * adjust the settings for this buffer only. This must remain at the end
17109 + * ---------------------------------------------------------------------------
17110 + * Local variables:
17111 + * c-file-style: "linux"
17114 diff -Naur -X ../exclude-files orig/arch/um/include/sysdep-ia64/syscalls.h um/arch/um/include/sysdep-ia64/syscalls.h
17115 --- orig/arch/um/include/sysdep-ia64/syscalls.h 1969-12-31 19:00:00.000000000 -0500
17116 +++ um/arch/um/include/sysdep-ia64/syscalls.h 2003-10-21 03:26:06.000000000 -0400
17119 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
17120 + * Licensed under the GPL
17123 +#ifndef __SYSDEP_IA64_SYSCALLS_H
17124 +#define __SYSDEP_IA64_SYSCALLS_H
17129 + * Overrides for Emacs so that we follow Linus's tabbing style.
17130 + * Emacs will notice this stuff at the end of the file and automatically
17131 + * adjust the settings for this buffer only. This must remain at the end
17133 + * ---------------------------------------------------------------------------
17134 + * Local variables:
17135 + * c-file-style: "linux"
17138 diff -Naur -X ../exclude-files orig/arch/um/include/sysdep-ppc/ptrace.h um/arch/um/include/sysdep-ppc/ptrace.h
17139 --- orig/arch/um/include/sysdep-ppc/ptrace.h 1969-12-31 19:00:00.000000000 -0500
17140 +++ um/arch/um/include/sysdep-ppc/ptrace.h 2003-10-21 03:26:06.000000000 -0400
17143 + * Licensed under the GPL
17146 +#ifndef __SYS_PTRACE_PPC_H
17147 +#define __SYS_PTRACE_PPC_H
17149 +#include "linux/config.h"
17150 +#include "linux/types.h"
17152 +/* the following taken from <asm-ppc/ptrace.h> */
17154 +#ifdef CONFIG_PPC64
17155 +#define PPC_REG unsigned long /*long*/
17157 +#define PPC_REG unsigned long
17159 +struct sys_pt_regs_s {
17163 + PPC_REG orig_gpr3; /* Used for restarting system calls */
17168 + PPC_REG mq; /* 601 only (not used at present) */
17169 + /* Used on APUS to hold IPL value. */
17170 + PPC_REG trap; /* Reason for being here */
17171 + PPC_REG dar; /* Fault registers */
17173 + PPC_REG result; /* Result of a system call */
17176 +#define NUM_REGS (sizeof(struct sys_pt_regs_s) / sizeof(PPC_REG))
17178 +struct sys_pt_regs {
17179 + PPC_REG regs[sizeof(struct sys_pt_regs_s) / sizeof(PPC_REG)];
17182 +#define UM_MAX_REG (PT_FPR0)
17183 +#define UM_MAX_REG_OFFSET (UM_MAX_REG * sizeof(PPC_REG))
17185 +#define EMPTY_REGS { { [ 0 ... NUM_REGS - 1] = 0 } }
17187 +#define UM_REG(r, n) ((r)->regs[n])
17189 +#define UM_SYSCALL_RET(r) UM_REG(r, PT_R3)
17190 +#define UM_SP(r) UM_REG(r, PT_R1)
17191 +#define UM_IP(r) UM_REG(r, PT_NIP)
17192 +#define UM_ELF_ZERO(r) UM_REG(r, PT_FPSCR)
17193 +#define UM_SYSCALL_NR(r) UM_REG(r, PT_R0)
17194 +#define UM_SYSCALL_ARG1(r) UM_REG(r, PT_ORIG_R3)
17195 +#define UM_SYSCALL_ARG2(r) UM_REG(r, PT_R4)
17196 +#define UM_SYSCALL_ARG3(r) UM_REG(r, PT_R5)
17197 +#define UM_SYSCALL_ARG4(r) UM_REG(r, PT_R6)
17198 +#define UM_SYSCALL_ARG5(r) UM_REG(r, PT_R7)
17199 +#define UM_SYSCALL_ARG6(r) UM_REG(r, PT_R8)
17201 +#define UM_SYSCALL_NR_OFFSET (PT_R0 * sizeof(PPC_REG))
17202 +#define UM_SYSCALL_RET_OFFSET (PT_R3 * sizeof(PPC_REG))
17203 +#define UM_SYSCALL_ARG1_OFFSET (PT_R3 * sizeof(PPC_REG))
17204 +#define UM_SYSCALL_ARG2_OFFSET (PT_R4 * sizeof(PPC_REG))
17205 +#define UM_SYSCALL_ARG3_OFFSET (PT_R5 * sizeof(PPC_REG))
17206 +#define UM_SYSCALL_ARG4_OFFSET (PT_R6 * sizeof(PPC_REG))
17207 +#define UM_SYSCALL_ARG5_OFFSET (PT_R7 * sizeof(PPC_REG))
17208 +#define UM_SYSCALL_ARG6_OFFSET (PT_R8 * sizeof(PPC_REG))
17209 +#define UM_SP_OFFSET (PT_R1 * sizeof(PPC_REG))
17210 +#define UM_IP_OFFSET (PT_NIP * sizeof(PPC_REG))
17211 +#define UM_ELF_ZERO_OFFSET (PT_R3 * sizeof(PPC_REG))
17213 +#define UM_SET_SYSCALL_RETURN(_regs, result) \
17215 + if (result < 0) { \
17216 + (_regs)->regs[PT_CCR] |= 0x10000000; \
17217 + UM_SYSCALL_RET((_regs)) = -result; \
17219 + UM_SYSCALL_RET((_regs)) = result; \
17223 +extern void shove_aux_table(unsigned long sp);
17224 +#define UM_FIX_EXEC_STACK(sp) shove_aux_table(sp);
17226 +/* These aren't actually defined. The undefs are just to make sure
17227 + * everyone's clear on the concept.
17229 +#undef UML_HAVE_GETREGS
17230 +#undef UML_HAVE_GETFPREGS
17231 +#undef UML_HAVE_SETREGS
17232 +#undef UML_HAVE_SETFPREGS
17237 + * Overrides for Emacs so that we follow Linus's tabbing style.
17238 + * Emacs will notice this stuff at the end of the file and automatically
17239 + * adjust the settings for this buffer only. This must remain at the end
17241 + * ---------------------------------------------------------------------------
17242 + * Local variables:
17243 + * c-file-style: "linux"
17246 diff -Naur -X ../exclude-files orig/arch/um/include/sysdep-ppc/sigcontext.h um/arch/um/include/sysdep-ppc/sigcontext.h
17247 --- orig/arch/um/include/sysdep-ppc/sigcontext.h 1969-12-31 19:00:00.000000000 -0500
17248 +++ um/arch/um/include/sysdep-ppc/sigcontext.h 2003-10-21 03:26:06.000000000 -0400
17251 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
17252 + * Licensed under the GPL
17255 +#ifndef __SYS_SIGCONTEXT_PPC_H
17256 +#define __SYS_SIGCONTEXT_PPC_H
17258 +#define DSISR_WRITE 0x02000000
17260 +#define SC_FAULT_ADDR(sc) ({ \
17261 + struct sigcontext *_sc = (sc); \
17262 + long retval = -1; \
17263 + switch (_sc->regs->trap) { \
17265 + /* data exception */ \
17266 + retval = _sc->regs->dar; \
17269 + /* instruction exception */ \
17270 + retval = _sc->regs->nip; \
17273 + panic("SC_FAULT_ADDR: unhandled trap type\n"); \
17278 +#define SC_FAULT_WRITE(sc) ({ \
17279 + struct sigcontext *_sc = (sc); \
17280 + long retval = -1; \
17281 + switch (_sc->regs->trap) { \
17283 + /* data exception */ \
17284 + retval = !!(_sc->regs->dsisr & DSISR_WRITE); \
17287 + /* instruction exception: not a write */ \
17291 + panic("SC_FAULT_ADDR: unhandled trap type\n"); \
17296 +#define SC_IP(sc) ((sc)->regs->nip)
17297 +#define SC_SP(sc) ((sc)->regs->gpr[1])
17298 +#define SEGV_IS_FIXABLE(sc) (1)
17303 + * Overrides for Emacs so that we follow Linus's tabbing style.
17304 + * Emacs will notice this stuff at the end of the file and automatically
17305 + * adjust the settings for this buffer only. This must remain at the end
17307 + * ---------------------------------------------------------------------------
17308 + * Local variables:
17309 + * c-file-style: "linux"
17312 diff -Naur -X ../exclude-files orig/arch/um/include/sysdep-ppc/syscalls.h um/arch/um/include/sysdep-ppc/syscalls.h
17313 --- orig/arch/um/include/sysdep-ppc/syscalls.h 1969-12-31 19:00:00.000000000 -0500
17314 +++ um/arch/um/include/sysdep-ppc/syscalls.h 2003-10-21 03:26:06.000000000 -0400
17317 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
17318 + * Licensed under the GPL
17321 +typedef long syscall_handler_t(unsigned long arg1, unsigned long arg2,
17322 + unsigned long arg3, unsigned long arg4,
17323 + unsigned long arg5, unsigned long arg6);
17325 +#define EXECUTE_SYSCALL(syscall, regs) \
17326 + (*sys_call_table[syscall])(UM_SYSCALL_ARG1(®s), \
17327 + UM_SYSCALL_ARG2(®s), \
17328 + UM_SYSCALL_ARG3(®s), \
17329 + UM_SYSCALL_ARG4(®s), \
17330 + UM_SYSCALL_ARG5(®s), \
17331 + UM_SYSCALL_ARG6(®s))
17333 +extern syscall_handler_t sys_mincore;
17334 +extern syscall_handler_t sys_madvise;
17336 +/* old_mmap needs the correct prototype since syscall_kern.c includes
17339 +int old_mmap(unsigned long addr, unsigned long len,
17340 + unsigned long prot, unsigned long flags,
17341 + unsigned long fd, unsigned long offset);
17343 +#define ARCH_SYSCALLS \
17344 + [ __NR_modify_ldt ] = sys_ni_syscall, \
17345 + [ __NR_pciconfig_read ] = sys_ni_syscall, \
17346 + [ __NR_pciconfig_write ] = sys_ni_syscall, \
17347 + [ __NR_pciconfig_iobase ] = sys_ni_syscall, \
17348 + [ __NR_pivot_root ] = sys_ni_syscall, \
17349 + [ __NR_multiplexer ] = sys_ni_syscall, \
17350 + [ __NR_mmap ] = old_mmap, \
17351 + [ __NR_madvise ] = sys_madvise, \
17352 + [ __NR_mincore ] = sys_mincore,
17354 +#define LAST_ARCH_SYSCALL __NR_mincore
17357 + * Overrides for Emacs so that we follow Linus's tabbing style.
17358 + * Emacs will notice this stuff at the end of the file and automatically
17359 + * adjust the settings for this buffer only. This must remain at the end
17361 + * ---------------------------------------------------------------------------
17362 + * Local variables:
17363 + * c-file-style: "linux"
17366 diff -Naur -X ../exclude-files orig/arch/um/include/sysrq.h um/arch/um/include/sysrq.h
17367 --- orig/arch/um/include/sysrq.h 1969-12-31 19:00:00.000000000 -0500
17368 +++ um/arch/um/include/sysrq.h 2003-10-21 03:26:06.000000000 -0400
17370 +#ifndef __UM_SYSRQ_H
17371 +#define __UM_SYSRQ_H
17373 +extern void show_trace(unsigned long *stack);
17376 diff -Naur -X ../exclude-files orig/arch/um/include/tempfile.h um/arch/um/include/tempfile.h
17377 --- orig/arch/um/include/tempfile.h 1969-12-31 19:00:00.000000000 -0500
17378 +++ um/arch/um/include/tempfile.h 2003-10-21 03:26:06.000000000 -0400
17381 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
17382 + * Licensed under the GPL
17385 +#ifndef __TEMPFILE_H__
17386 +#define __TEMPFILE_H__
17388 +extern int make_tempfile(const char *template, char **tempname, int do_unlink);
17392 + * Overrides for Emacs so that we follow Linus's tabbing style.
17393 + * Emacs will notice this stuff at the end of the file and automatically
17394 + * adjust the settings for this buffer only. This must remain at the end
17396 + * ---------------------------------------------------------------------------
17397 + * Local variables:
17398 + * c-file-style: "linux"
17401 diff -Naur -X ../exclude-files orig/arch/um/include/time_user.h um/arch/um/include/time_user.h
17402 --- orig/arch/um/include/time_user.h 1969-12-31 19:00:00.000000000 -0500
17403 +++ um/arch/um/include/time_user.h 2003-10-21 03:26:06.000000000 -0400
17406 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
17407 + * Licensed under the GPL
17410 +#ifndef __TIME_USER_H__
17411 +#define __TIME_USER_H__
17413 +extern void timer(void);
17414 +extern void switch_timers(int to_real);
17415 +extern void set_interval(int timer_type);
17416 +extern void idle_sleep(int secs);
17417 +extern void enable_timer(void);
17418 +extern unsigned long time_lock(void);
17419 +extern void time_unlock(unsigned long);
17422 diff -Naur -X ../exclude-files orig/arch/um/include/tlb.h um/arch/um/include/tlb.h
17423 --- orig/arch/um/include/tlb.h 1969-12-31 19:00:00.000000000 -0500
17424 +++ um/arch/um/include/tlb.h 2003-10-21 03:26:06.000000000 -0400
17427 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
17428 + * Licensed under the GPL
17434 +extern void mprotect_kernel_vm(int w);
17435 +extern void force_flush_all(void);
17440 + * Overrides for Emacs so that we follow Linus's tabbing style.
17441 + * Emacs will notice this stuff at the end of the file and automatically
17442 + * adjust the settings for this buffer only. This must remain at the end
17444 + * ---------------------------------------------------------------------------
17445 + * Local variables:
17446 + * c-file-style: "linux"
17449 diff -Naur -X ../exclude-files orig/arch/um/include/ubd_user.h um/arch/um/include/ubd_user.h
17450 --- orig/arch/um/include/ubd_user.h 1969-12-31 19:00:00.000000000 -0500
17451 +++ um/arch/um/include/ubd_user.h 2003-10-21 03:26:06.000000000 -0400
17454 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
17455 + * Copyright (C) 2001 RidgeRun, Inc (glonnon@ridgerun.com)
17456 + * Licensed under the GPL
17459 +#ifndef __UM_UBD_USER_H
17460 +#define __UM_UBD_USER_H
17464 +enum ubd_req { UBD_READ, UBD_WRITE, UBD_MMAP };
17466 +struct io_thread_req {
17469 + unsigned long offsets[2];
17470 + unsigned long long offset;
17471 + unsigned long length;
17474 + unsigned long sector_mask;
17475 + unsigned long long cow_offset;
17476 + unsigned long bitmap_words[2];
17478 + unsigned long long map_offset;
17482 +extern int open_ubd_file(char *file, struct openflags *openflags,
17483 + char **backing_file_out, int *bitmap_offset_out,
17484 + unsigned long *bitmap_len_out, int *data_offset_out,
17485 + int *create_cow_out);
17486 +extern int create_cow_file(char *cow_file, char *backing_file,
17487 + struct openflags flags, int sectorsize,
17488 + int alignment, int *bitmap_offset_out,
17489 + unsigned long *bitmap_len_out,
17490 + int *data_offset_out);
17491 +extern int read_cow_bitmap(int fd, void *buf, int offset, int len);
17492 +extern int read_ubd_fs(int fd, void *buffer, int len);
17493 +extern int write_ubd_fs(int fd, char *buffer, int len);
17494 +extern int start_io_thread(unsigned long sp, int *fds_out);
17495 +extern void do_io(struct io_thread_req *req);
17497 +static inline int ubd_test_bit(__u64 bit, unsigned char *data)
17502 + bits = sizeof(data[0]) * 8;
17504 + off = bit % bits;
17505 + return((data[n] & (1 << off)) != 0);
17508 +static inline void ubd_set_bit(__u64 bit, unsigned char *data)
17513 + bits = sizeof(data[0]) * 8;
17515 + off = bit % bits;
17516 + data[n] |= (1 << off);
17523 + * Overrides for Emacs so that we follow Linus's tabbing style.
17524 + * Emacs will notice this stuff at the end of the file and automatically
17525 + * adjust the settings for this buffer only. This must remain at the end
17527 + * ---------------------------------------------------------------------------
17528 + * Local variables:
17529 + * c-file-style: "linux"
17532 diff -Naur -X ../exclude-files orig/arch/um/include/umid.h um/arch/um/include/umid.h
17533 --- orig/arch/um/include/umid.h 1969-12-31 19:00:00.000000000 -0500
17534 +++ um/arch/um/include/umid.h 2003-10-21 03:26:06.000000000 -0400
17537 + * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
17538 + * Licensed under the GPL
17541 +#ifndef __UMID_H__
17542 +#define __UMID_H__
17544 +extern int umid_file_name(char *name, char *buf, int len);
17549 + * Overrides for Emacs so that we follow Linus's tabbing style.
17550 + * Emacs will notice this stuff at the end of the file and automatically
17551 + * adjust the settings for this buffer only. This must remain at the end
17553 + * ---------------------------------------------------------------------------
17554 + * Local variables:
17555 + * c-file-style: "linux"
17558 diff -Naur -X ../exclude-files orig/arch/um/include/uml_uaccess.h um/arch/um/include/uml_uaccess.h
17559 --- orig/arch/um/include/uml_uaccess.h 1969-12-31 19:00:00.000000000 -0500
17560 +++ um/arch/um/include/uml_uaccess.h 2003-10-21 03:26:06.000000000 -0400
17563 + * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
17564 + * Licensed under the GPL
17567 +#ifndef __UML_UACCESS_H__
17568 +#define __UML_UACCESS_H__
17570 +extern int __do_copy_to_user(void *to, const void *from, int n,
17571 + void **fault_addr, void **fault_catcher);
17572 +extern unsigned long __do_user_copy(void *to, const void *from, int n,
17573 + void **fault_addr, void **fault_catcher,
17574 + void (*op)(void *to, const void *from,
17575 + int n), int *faulted_out);
17576 +void __do_copy(void *to, const void *from, int n);
17581 + * Overrides for Emacs so that we follow Linus's tabbing style.
17582 + * Emacs will notice this stuff at the end of the file and automatically
17583 + * adjust the settings for this buffer only. This must remain at the end
17585 + * ---------------------------------------------------------------------------
17586 + * Local variables:
17587 + * c-file-style: "linux"
17590 diff -Naur -X ../exclude-files orig/arch/um/include/um_mmu.h um/arch/um/include/um_mmu.h
17591 --- orig/arch/um/include/um_mmu.h 1969-12-31 19:00:00.000000000 -0500
17592 +++ um/arch/um/include/um_mmu.h 2003-10-21 03:26:06.000000000 -0400
17595 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
17596 + * Licensed under the GPL
17599 +#ifndef __ARCH_UM_MMU_H
17600 +#define __ARCH_UM_MMU_H
17602 +#include "linux/config.h"
17603 +#include "choose-mode.h"
17605 +#ifdef CONFIG_MODE_TT
17606 +#include "../kernel/tt/include/mmu.h"
17609 +#ifdef CONFIG_MODE_SKAS
17610 +#include "../kernel/skas/include/mmu.h"
17614 +#ifdef CONFIG_MODE_TT
17615 + struct mmu_context_tt tt;
17617 +#ifdef CONFIG_MODE_SKAS
17618 + struct mmu_context_skas skas;
17625 + * Overrides for Emacs so that we follow Linus's tabbing style.
17626 + * Emacs will notice this stuff at the end of the file and automatically
17627 + * adjust the settings for this buffer only. This must remain at the end
17629 + * ---------------------------------------------------------------------------
17630 + * Local variables:
17631 + * c-file-style: "linux"
17634 diff -Naur -X ../exclude-files orig/arch/um/include/umn.h um/arch/um/include/umn.h
17635 --- orig/arch/um/include/umn.h 1969-12-31 19:00:00.000000000 -0500
17636 +++ um/arch/um/include/umn.h 2003-10-21 03:26:06.000000000 -0400
17639 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
17640 + * Licensed under the GPL
17646 +extern int open_umn_tty(int *slave_out, int *slipno_out);
17647 +extern void close_umn_tty(int master, int slave);
17648 +extern int umn_send_packet(int fd, void *data, int len);
17649 +extern int set_umn_addr(int fd, char *addr, char *ptp_addr);
17650 +extern void slip_unesc(unsigned char s);
17651 +extern void umn_read(int fd);
17656 + * Overrides for Emacs so that we follow Linus's tabbing style.
17657 + * Emacs will notice this stuff at the end of the file and automatically
17658 + * adjust the settings for this buffer only. This must remain at the end
17660 + * ---------------------------------------------------------------------------
17661 + * Local variables:
17662 + * c-file-style: "linux"
17665 diff -Naur -X ../exclude-files orig/arch/um/include/um_uaccess.h um/arch/um/include/um_uaccess.h
17666 --- orig/arch/um/include/um_uaccess.h 1969-12-31 19:00:00.000000000 -0500
17667 +++ um/arch/um/include/um_uaccess.h 2003-10-21 03:26:06.000000000 -0400
17670 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
17671 + * Licensed under the GPL
17674 +#ifndef __ARCH_UM_UACCESS_H
17675 +#define __ARCH_UM_UACCESS_H
17677 +#include "linux/config.h"
17678 +#include "choose-mode.h"
17680 +#ifdef CONFIG_MODE_TT
17681 +#include "../kernel/tt/include/uaccess.h"
17684 +#ifdef CONFIG_MODE_SKAS
17685 +#include "../kernel/skas/include/uaccess.h"
17688 +#define access_ok(type, addr, size) \
17689 + CHOOSE_MODE_PROC(access_ok_tt, access_ok_skas, type, addr, size)
17691 +static inline int verify_area(int type, const void * addr, unsigned long size)
17693 + return(CHOOSE_MODE_PROC(verify_area_tt, verify_area_skas, type, addr,
17697 +static inline int copy_from_user(void *to, const void *from, int n)
17699 + return(CHOOSE_MODE_PROC(copy_from_user_tt, copy_from_user_skas, to,
17703 +static inline int copy_to_user(void *to, const void *from, int n)
17705 + return(CHOOSE_MODE_PROC(copy_to_user_tt, copy_to_user_skas, to,
17710 + * strncpy_from_user: - Copy a NUL terminated string from userspace.
17711 + * @dst: Destination address, in kernel space. This buffer must be at
17712 + * least @count bytes long.
17713 + * @src: Source address, in user space.
17714 + * @count: Maximum number of bytes to copy, including the trailing NUL.
17716 + * Copies a NUL-terminated string from userspace to kernel space.
17718 + * On success, returns the length of the string (not including the trailing
17721 + * If access to userspace fails, returns -EFAULT (some data may have been
17724 + * If @count is smaller than the length of the string, copies @count bytes
17725 + * and returns @count.
17728 +static inline int strncpy_from_user(char *dst, const char *src, int count)
17730 + return(CHOOSE_MODE_PROC(strncpy_from_user_tt, strncpy_from_user_skas,
17731 + dst, src, count));
17735 + * __clear_user: - Zero a block of memory in user space, with less checking.
17736 + * @to: Destination address, in user space.
17737 + * @n: Number of bytes to zero.
17739 + * Zero a block of memory in user space. Caller must check
17740 + * the specified block with access_ok() before calling this function.
17742 + * Returns number of bytes that could not be cleared.
17743 + * On success, this will be zero.
17745 +static inline int __clear_user(void *mem, int len)
17747 + return(CHOOSE_MODE_PROC(__clear_user_tt, __clear_user_skas, mem, len));
17751 + * clear_user: - Zero a block of memory in user space.
17752 + * @to: Destination address, in user space.
17753 + * @n: Number of bytes to zero.
17755 + * Zero a block of memory in user space.
17757 + * Returns number of bytes that could not be cleared.
17758 + * On success, this will be zero.
17760 +static inline int clear_user(void *mem, int len)
17762 + return(CHOOSE_MODE_PROC(clear_user_tt, clear_user_skas, mem, len));
17766 + * strlen_user: - Get the size of a string in user space.
17767 + * @str: The string to measure.
17768 + * @n: The maximum valid length
17770 + * Get the size of a NUL-terminated string in user space.
17772 + * Returns the size of the string INCLUDING the terminating NUL.
17773 + * On exception, returns 0.
17774 + * If the string is too long, returns a value greater than @n.
17776 +static inline int strnlen_user(const void *str, int len)
17778 + return(CHOOSE_MODE_PROC(strnlen_user_tt, strnlen_user_skas, str, len));
17784 + * Overrides for Emacs so that we follow Linus's tabbing style.
17785 + * Emacs will notice this stuff at the end of the file and automatically
17786 + * adjust the settings for this buffer only. This must remain at the end
17788 + * ---------------------------------------------------------------------------
17789 + * Local variables:
17790 + * c-file-style: "linux"
17793 diff -Naur -X ../exclude-files orig/arch/um/include/user.h um/arch/um/include/user.h
17794 --- orig/arch/um/include/user.h 1969-12-31 19:00:00.000000000 -0500
17795 +++ um/arch/um/include/user.h 2003-10-21 03:26:06.000000000 -0400
17798 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
17799 + * Licensed under the GPL
17802 +#ifndef __USER_H__
17803 +#define __USER_H__
17805 +extern void panic(const char *fmt, ...);
17806 +extern int printk(const char *fmt, ...);
17807 +extern void schedule(void);
17808 +extern void *um_kmalloc(int size);
17809 +extern void *um_kmalloc_atomic(int size);
17810 +extern void kfree(void *ptr);
17811 +extern int in_aton(char *str);
17812 +extern int open_gdb_chan(void);
17817 + * Overrides for Emacs so that we follow Linus's tabbing style.
17818 + * Emacs will notice this stuff at the end of the file and automatically
17819 + * adjust the settings for this buffer only. This must remain at the end
17821 + * ---------------------------------------------------------------------------
17822 + * Local variables:
17823 + * c-file-style: "linux"
17826 diff -Naur -X ../exclude-files orig/arch/um/include/user_util.h um/arch/um/include/user_util.h
17827 --- orig/arch/um/include/user_util.h 1969-12-31 19:00:00.000000000 -0500
17828 +++ um/arch/um/include/user_util.h 2003-11-09 11:36:31.000000000 -0500
17831 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
17832 + * Licensed under the GPL
17835 +#ifndef __USER_UTIL_H__
17836 +#define __USER_UTIL_H__
17838 +#include "sysdep/ptrace.h"
17840 +extern int mode_tt;
17842 +extern int grantpt(int __fd);
17843 +extern int unlockpt(int __fd);
17844 +extern char *ptsname(int __fd);
17851 +extern struct cpu_task cpu_tasks[];
17853 +struct signal_info {
17854 + void (*handler)(int, union uml_pt_regs *);
17858 +extern struct signal_info sig_info[];
17860 +extern unsigned long low_physmem;
17861 +extern unsigned long high_physmem;
17862 +extern unsigned long uml_physmem;
17863 +extern unsigned long uml_reserved;
17864 +extern unsigned long end_vm;
17865 +extern unsigned long start_vm;
17866 +extern unsigned long highmem;
17868 +extern char host_info[];
17870 +extern char saved_command_line[];
17871 +extern char command_line[];
17873 +extern char *tempdir;
17875 +extern unsigned long _stext, _etext, _sdata, _edata, __bss_start, _end;
17876 +extern unsigned long _unprotected_end;
17877 +extern unsigned long brk_start;
17879 +extern int pty_output_sigio;
17880 +extern int pty_close_sigio;
17882 +extern void stop(void);
17883 +extern void stack_protections(unsigned long address);
17884 +extern void task_protections(unsigned long address);
17885 +extern int wait_for_stop(int pid, int sig, int cont_type, void *relay);
17886 +extern void *add_signal_handler(int sig, void (*handler)(int));
17887 +extern int start_fork_tramp(void *arg, unsigned long temp_stack,
17888 + int clone_flags, int (*tramp)(void *));
17889 +extern int linux_main(int argc, char **argv);
17890 +extern void set_cmdline(char *cmd);
17891 +extern void input_cb(void (*proc)(void *), void *arg, int arg_len);
17892 +extern int get_pty(void);
17893 +extern void *um_kmalloc(int size);
17894 +extern int raw(int fd, int complain);
17895 +extern int switcheroo(int fd, int prot, void *from, void *to, int size);
17896 +extern void setup_machinename(char *machine_out);
17897 +extern void setup_hostinfo(void);
17898 +extern void add_arg(char *cmd_line, char *arg);
17899 +extern void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int));
17900 +extern void init_new_thread_signals(int altstack);
17901 +extern void do_exec(int old_pid, int new_pid);
17902 +extern void tracer_panic(char *msg, ...);
17903 +extern char *get_umid(int only_if_set);
17904 +extern void do_longjmp(void *p, int val);
17905 +extern void suspend_new_thread(int fd);
17906 +extern int detach(int pid, int sig);
17907 +extern int attach(int pid);
17908 +extern void kill_child_dead(int pid);
17909 +extern int cont(int pid);
17910 +extern void check_ptrace(void);
17911 +extern void check_sigio(void);
17912 +extern int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr);
17913 +extern void write_sigio_workaround(void);
17914 +extern void arch_check_bugs(void);
17915 +extern int cpu_feature(char *what, char *buf, int len);
17916 +extern int arch_handle_signal(int sig, union uml_pt_regs *regs);
17917 +extern int arch_fixup(unsigned long address, void *sc_ptr);
17918 +extern int can_do_skas(void);
17919 +extern void arch_init_thread(void);
17924 + * Overrides for Emacs so that we follow Linus's tabbing style.
17925 + * Emacs will notice this stuff at the end of the file and automatically
17926 + * adjust the settings for this buffer only. This must remain at the end
17928 + * ---------------------------------------------------------------------------
17929 + * Local variables:
17930 + * c-file-style: "linux"
17933 diff -Naur -X ../exclude-files orig/arch/um/kernel/checksum.c um/arch/um/kernel/checksum.c
17934 --- orig/arch/um/kernel/checksum.c 1969-12-31 19:00:00.000000000 -0500
17935 +++ um/arch/um/kernel/checksum.c 2003-10-21 03:26:06.000000000 -0400
17937 +#include "asm/uaccess.h"
17938 +#include "linux/errno.h"
17940 +extern unsigned int arch_csum_partial(const char *buff, int len, int sum);
17942 +extern unsigned int csum_partial(char *buff, int len, int sum)
17944 + return(arch_csum_partial(buff, len, sum));
17947 +unsigned int csum_partial_copy_to(const char *src, char *dst, int len,
17948 + int sum, int *err_ptr)
17950 + if(copy_to_user(dst, src, len)){
17951 + *err_ptr = -EFAULT;
17955 + return(arch_csum_partial(src, len, sum));
17958 +unsigned int csum_partial_copy_from(const char *src, char *dst, int len,
17959 + int sum, int *err_ptr)
17961 + if(copy_from_user(dst, src, len)){
17962 + *err_ptr = -EFAULT;
17966 + return(arch_csum_partial(dst, len, sum));
17970 + * Overrides for Emacs so that we follow Linus's tabbing style.
17971 + * Emacs will notice this stuff at the end of the file and automatically
17972 + * adjust the settings for this buffer only. This must remain at the end
17974 + * ---------------------------------------------------------------------------
17975 + * Local variables:
17976 + * c-file-style: "linux"
17979 diff -Naur -X ../exclude-files orig/arch/um/kernel/config.c.in um/arch/um/kernel/config.c.in
17980 --- orig/arch/um/kernel/config.c.in 1969-12-31 19:00:00.000000000 -0500
17981 +++ um/arch/um/kernel/config.c.in 2003-10-21 03:26:06.000000000 -0400
17984 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
17985 + * Licensed under the GPL
17988 +#include <stdio.h>
17989 +#include <stdlib.h>
17992 +static __initdata char *config = "CONFIG";
17994 +static int __init print_config(char *line, int *add)
17996 + printf("%s", config);
18000 +__uml_setup("--showconfig", print_config,
18002 +" Prints the config file that this UML binary was generated from.\n\n"
18006 + * Overrides for Emacs so that we follow Linus's tabbing style.
18007 + * Emacs will notice this stuff at the end of the file and automatically
18008 + * adjust the settings for this buffer only. This must remain at the end
18010 + * ---------------------------------------------------------------------------
18011 + * Local variables:
18012 + * c-file-style: "linux"
18015 diff -Naur -X ../exclude-files orig/arch/um/kernel/exec_kern.c um/arch/um/kernel/exec_kern.c
18016 --- orig/arch/um/kernel/exec_kern.c 1969-12-31 19:00:00.000000000 -0500
18017 +++ um/arch/um/kernel/exec_kern.c 2003-10-21 03:26:06.000000000 -0400
18020 + * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
18021 + * Licensed under the GPL
18024 +#include "linux/slab.h"
18025 +#include "linux/smp_lock.h"
18026 +#include "asm/ptrace.h"
18027 +#include "asm/pgtable.h"
18028 +#include "asm/pgalloc.h"
18029 +#include "asm/uaccess.h"
18030 +#include "user_util.h"
18031 +#include "kern_util.h"
18032 +#include "mem_user.h"
18034 +#include "irq_user.h"
18036 +#include "2_5compat.h"
18038 +#include "time_user.h"
18039 +#include "choose-mode.h"
18040 +#include "mode_kern.h"
18042 +void flush_thread(void)
18044 + CHOOSE_MODE(flush_thread_tt(), flush_thread_skas());
18047 +void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
18049 + CHOOSE_MODE_PROC(start_thread_tt, start_thread_skas, regs, eip, esp);
18052 +extern void log_exec(char **argv, void *tty);
18054 +static int execve1(char *file, char **argv, char **env)
18058 +#ifdef CONFIG_TTY_LOG
18059 + log_exec(argv, current->tty);
18061 + error = do_execve(file, argv, env, ¤t->thread.regs);
18063 + current->ptrace &= ~PT_DTRACE;
18064 + set_cmdline(current_cmd());
18069 +int um_execve(char *file, char **argv, char **env)
18073 + err = execve1(file, argv, env);
18075 + do_longjmp(current->thread.exec_buf, 1);
18079 +int sys_execve(char *file, char **argv, char **env)
18085 + filename = getname((char *) file);
18086 + error = PTR_ERR(filename);
18087 + if (IS_ERR(filename)) goto out;
18088 + error = execve1(filename, argv, env);
18089 + putname(filename);
18096 + * Overrides for Emacs so that we follow Linus's tabbing style.
18097 + * Emacs will notice this stuff at the end of the file and automatically
18098 + * adjust the settings for this buffer only. This must remain at the end
18100 + * ---------------------------------------------------------------------------
18101 + * Local variables:
18102 + * c-file-style: "linux"
18105 diff -Naur -X ../exclude-files orig/arch/um/kernel/exitcode.c um/arch/um/kernel/exitcode.c
18106 --- orig/arch/um/kernel/exitcode.c 1969-12-31 19:00:00.000000000 -0500
18107 +++ um/arch/um/kernel/exitcode.c 2003-10-21 03:26:06.000000000 -0400
18110 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
18111 + * Licensed under the GPL
18114 +#include "linux/init.h"
18115 +#include "linux/ctype.h"
18116 +#include "linux/proc_fs.h"
18117 +#include "asm/uaccess.h"
18119 +/* If read and write race, the read will still atomically read a valid
18122 +int uml_exitcode = 0;
18124 +static int read_proc_exitcode(char *page, char **start, off_t off,
18125 + int count, int *eof, void *data)
18129 + len = sprintf(page, "%d\n", uml_exitcode);
18131 + if(len <= off+count) *eof = 1;
18132 + *start = page + off;
18133 + if(len > count) len = count;
18134 + if(len < 0) len = 0;
18138 +static int write_proc_exitcode(struct file *file, const char *buffer,
18139 + unsigned long count, void *data)
18141 + char *end, buf[sizeof("nnnnn\0")];
18144 + if(copy_from_user(buf, buffer, count))
18146 + tmp = simple_strtol(buf, &end, 0);
18147 + if((*end != '\0') && !isspace(*end))
18149 + uml_exitcode = tmp;
18153 +static int make_proc_exitcode(void)
18155 + struct proc_dir_entry *ent;
18157 + ent = create_proc_entry("exitcode", 0600, &proc_root);
18159 + printk("make_proc_exitcode : Failed to register "
18160 + "/proc/exitcode\n");
18164 + ent->read_proc = read_proc_exitcode;
18165 + ent->write_proc = write_proc_exitcode;
18170 +__initcall(make_proc_exitcode);
18173 + * Overrides for Emacs so that we follow Linus's tabbing style.
18174 + * Emacs will notice this stuff at the end of the file and automatically
18175 + * adjust the settings for this buffer only. This must remain at the end
18177 + * ---------------------------------------------------------------------------
18178 + * Local variables:
18179 + * c-file-style: "linux"
18182 diff -Naur -X ../exclude-files orig/arch/um/kernel/frame.c um/arch/um/kernel/frame.c
18183 --- orig/arch/um/kernel/frame.c 1969-12-31 19:00:00.000000000 -0500
18184 +++ um/arch/um/kernel/frame.c 2003-10-21 03:26:06.000000000 -0400
18187 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
18188 + * Licensed under the GPL
18191 +#include <stdio.h>
18192 +#include <stdlib.h>
18193 +#include <unistd.h>
18194 +#include <string.h>
18195 +#include <signal.h>
18197 +#include <sched.h>
18198 +#include <errno.h>
18199 +#include <sys/ptrace.h>
18200 +#include <sys/syscall.h>
18201 +#include <sys/mman.h>
18202 +#include <asm/page.h>
18203 +#include <asm/ptrace.h>
18204 +#include <asm/sigcontext.h>
18205 +#include "sysdep/ptrace.h"
18206 +#include "sysdep/sigcontext.h"
18207 +#include "frame_user.h"
18208 +#include "kern_util.h"
18209 +#include "ptrace_user.h"
18212 +static int capture_stack(int (*child)(void *arg), void *arg, void *sp,
18213 + unsigned long top, void **data_out)
18215 + unsigned long regs[FRAME_SIZE];
18216 + int pid, status, n, len;
18218 + /* Start the child as a thread */
18219 + pid = clone(child, sp, CLONE_VM | SIGCHLD, arg);
18221 + printf("capture_stack : clone failed - errno = %d\n", errno);
18225 + /* Wait for it to stop itself and continue it with a SIGUSR1 to force
18226 + * it into the signal handler.
18228 + n = waitpid(pid, &status, WUNTRACED);
18230 + printf("capture_stack : waitpid failed - errno = %d\n", errno);
18233 + if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP)){
18234 + fprintf(stderr, "capture_stack : Expected SIGSTOP, "
18235 + "got status = 0x%x\n", status);
18238 + if(ptrace(PTRACE_CONT, pid, 0, SIGUSR1) < 0){
18239 + printf("capture_stack : PTRACE_CONT failed - errno = %d\n",
18244 + /* Wait for it to stop itself again and grab its registers again.
18245 + * At this point, the handler has stuffed the addresses of
18246 + * sig, sc, and SA_RESTORER in raw.
18248 + n = waitpid(pid, &status, WUNTRACED);
18250 + printf("capture_stack : waitpid failed - errno = %d\n", errno);
18253 + if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP)){
18254 + fprintf(stderr, "capture_stack : Expected SIGSTOP, "
18255 + "got status = 0x%x\n", status);
18258 + if(ptrace(PTRACE_GETREGS, pid, 0, regs) < 0){
18259 + printf("capture_stack : PTRACE_GETREGS failed - errno = %d\n",
18264 + /* It has outlived its usefulness, so continue it so it can exit */
18265 + if(ptrace(PTRACE_CONT, pid, 0, 0) < 0){
18266 + printf("capture_stack : PTRACE_CONT failed - errno = %d\n",
18270 + if(waitpid(pid, &status, 0) < 0){
18271 + printf("capture_stack : waitpid failed - errno = %d\n", errno);
18274 + if(!WIFSIGNALED(status) || (WTERMSIG(status) != 9)){
18275 + printf("capture_stack : Expected exit signal 9, "
18276 + "got status = 0x%x\n", status);
18280 + /* The frame that we want is the top of the signal stack */
18282 + len = top - PT_SP(regs);
18283 + *data_out = malloc(len);
18284 + if(*data_out == NULL){
18285 + printf("capture_stack : malloc failed - errno = %d\n", errno);
18288 + memcpy(*data_out, (void *) PT_SP(regs), len);
18293 +struct common_raw {
18296 + unsigned long sig;
18297 + unsigned long sr;
18298 + unsigned long sp;
18299 + struct arch_frame_data_raw arch;
18302 +#define SA_RESTORER (0x04000000)
18304 +typedef unsigned long old_sigset_t;
18306 +struct old_sigaction {
18307 + __sighandler_t handler;
18308 + old_sigset_t sa_mask;
18309 + unsigned long sa_flags;
18310 + void (*sa_restorer)(void);
18313 +static void child_common(struct common_raw *common, sighandler_t handler,
18314 + int restorer, int flags)
18316 + stack_t ss = ((stack_t) { .ss_sp = common->stack,
18318 + .ss_size = common->size });
18321 + if(ptrace(PTRACE_TRACEME, 0, 0, 0) < 0){
18322 + printf("PTRACE_TRACEME failed, errno = %d\n", errno);
18324 + if(sigaltstack(&ss, NULL) < 0){
18325 + printf("sigaltstack failed - errno = %d\n", errno);
18326 + kill(getpid(), SIGKILL);
18330 + struct sigaction sa;
18332 + sa.sa_handler = handler;
18333 + sigemptyset(&sa.sa_mask);
18334 + sa.sa_flags = SA_ONSTACK | flags;
18335 + err = sigaction(SIGUSR1, &sa, NULL);
18338 + struct old_sigaction sa;
18340 + sa.handler = handler;
18342 + sa.sa_flags = (SA_ONSTACK | flags) & ~SA_RESTORER;
18343 + err = syscall(__NR_sigaction, SIGUSR1, &sa, NULL);
18347 + printf("sigaction failed - errno = %d\n", errno);
18348 + kill(getpid(), SIGKILL);
18351 + os_stop_process(os_getpid());
18354 +/* Changed only during early boot */
18355 +struct sc_frame signal_frame_sc;
18357 +struct sc_frame signal_frame_sc_sr;
18359 +struct sc_frame_raw {
18360 + struct common_raw common;
18361 + unsigned long sc;
18365 +/* Changed only during early boot */
18366 +static struct sc_frame_raw *raw_sc = NULL;
18368 +static void sc_handler(int sig, struct sigcontext sc)
18370 + raw_sc->common.sig = (unsigned long) &sig;
18371 + raw_sc->common.sr = frame_restorer();
18372 + raw_sc->common.sp = frame_sp();
18373 + raw_sc->sc = (unsigned long) ≻
18374 + setup_arch_frame_raw(&raw_sc->common.arch, &sc + 1, raw_sc->common.sr);
18376 + os_stop_process(os_getpid());
18377 + kill(getpid(), SIGKILL);
18380 +static int sc_child(void *arg)
18383 + child_common(&raw_sc->common, (sighandler_t) sc_handler,
18384 + raw_sc->restorer, 0);
18388 +/* Changed only during early boot */
18389 +struct si_frame signal_frame_si;
18391 +struct si_frame_raw {
18392 + struct common_raw common;
18393 + unsigned long sip;
18394 + unsigned long si;
18395 + unsigned long ucp;
18396 + unsigned long uc;
18399 +/* Changed only during early boot */
18400 +static struct si_frame_raw *raw_si = NULL;
18402 +static void si_handler(int sig, siginfo_t *si, struct ucontext *ucontext)
18404 + raw_si->common.sig = (unsigned long) &sig;
18405 + raw_si->common.sr = frame_restorer();
18406 + raw_si->common.sp = frame_sp();
18407 + raw_si->sip = (unsigned long) &si;
18408 + raw_si->si = (unsigned long) si;
18409 + raw_si->ucp = (unsigned long) &ucontext;
18410 + raw_si->uc = (unsigned long) ucontext;
18411 + setup_arch_frame_raw(&raw_si->common.arch,
18412 + ucontext->uc_mcontext.fpregs, raw_si->common.sr);
18414 + os_stop_process(os_getpid());
18415 + kill(getpid(), SIGKILL);
18418 +static int si_child(void *arg)
18421 + child_common(&raw_si->common, (sighandler_t) si_handler, 1,
18426 +static int relative_sr(unsigned long sr, int sr_index, void *stack,
18429 + unsigned long *srp = (unsigned long *) sr;
18430 + unsigned long frame = (unsigned long) framep;
18432 + if((*srp & PAGE_MASK) == (unsigned long) stack){
18434 + *((unsigned long *) (frame + sr_index)) = *srp;
18440 +static unsigned long capture_stack_common(int (*proc)(void *), void *arg,
18441 + struct common_raw *common_in,
18442 + void *top, void *sigstack,
18444 + struct frame_common *common_out)
18446 + unsigned long sig_top = (unsigned long) sigstack + stack_len, base;
18448 + common_in->stack = (void *) sigstack;
18449 + common_in->size = stack_len;
18450 + common_out->len = capture_stack(proc, arg, top, sig_top,
18451 + &common_out->data);
18452 + base = sig_top - common_out->len;
18453 + common_out->sig_index = common_in->sig - base;
18454 + common_out->sp_index = common_in->sp - base;
18455 + common_out->sr_index = common_in->sr - base;
18456 + common_out->sr_relative = relative_sr(common_in->sr,
18457 + common_out->sr_index, sigstack,
18458 + common_out->data);
18462 +void capture_signal_stack(void)
18464 + struct sc_frame_raw raw_sc;
18465 + struct si_frame_raw raw_si;
18466 + void *stack, *sigstack;
18467 + unsigned long top, base;
18469 + stack = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC,
18470 + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
18471 + sigstack = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC,
18472 + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
18473 + if((stack == MAP_FAILED) || (sigstack == MAP_FAILED)){
18474 + printf("capture_signal_stack : mmap failed - errno = %d\n",
18479 + top = (unsigned long) stack + PAGE_SIZE - sizeof(void *);
18481 + /* Get the sigcontext, no sigrestorer layout */
18482 + raw_sc.restorer = 0;
18483 + base = capture_stack_common(sc_child, &raw_sc, &raw_sc.common,
18484 + (void *) top, sigstack, PAGE_SIZE,
18485 + &signal_frame_sc.common);
18487 + signal_frame_sc.sc_index = raw_sc.sc - base;
18488 + setup_arch_frame(&raw_sc.common.arch, &signal_frame_sc.common.arch);
18490 + /* Ditto for the sigcontext, sigrestorer layout */
18491 + raw_sc.restorer = 1;
18492 + base = capture_stack_common(sc_child, &raw_sc, &raw_sc.common,
18493 + (void *) top, sigstack, PAGE_SIZE,
18494 + &signal_frame_sc_sr.common);
18495 + signal_frame_sc_sr.sc_index = raw_sc.sc - base;
18496 + setup_arch_frame(&raw_sc.common.arch, &signal_frame_sc_sr.common.arch);
18498 + /* And the siginfo layout */
18500 + base = capture_stack_common(si_child, &raw_si, &raw_si.common,
18501 + (void *) top, sigstack, PAGE_SIZE,
18502 + &signal_frame_si.common);
18503 + signal_frame_si.sip_index = raw_si.sip - base;
18504 + signal_frame_si.si_index = raw_si.si - base;
18505 + signal_frame_si.ucp_index = raw_si.ucp - base;
18506 + signal_frame_si.uc_index = raw_si.uc - base;
18507 + setup_arch_frame(&raw_si.common.arch, &signal_frame_si.common.arch);
18509 + if((munmap(stack, PAGE_SIZE) < 0) ||
18510 + (munmap(sigstack, PAGE_SIZE) < 0)){
18511 + printf("capture_signal_stack : munmap failed - errno = %d\n",
18518 + * Overrides for Emacs so that we follow Linus's tabbing style.
18519 + * Emacs will notice this stuff at the end of the file and automatically
18520 + * adjust the settings for this buffer only. This must remain at the end
18522 + * ---------------------------------------------------------------------------
18523 + * Local variables:
18524 + * c-file-style: "linux"
18527 diff -Naur -X ../exclude-files orig/arch/um/kernel/frame_kern.c um/arch/um/kernel/frame_kern.c
18528 --- orig/arch/um/kernel/frame_kern.c 1969-12-31 19:00:00.000000000 -0500
18529 +++ um/arch/um/kernel/frame_kern.c 2003-11-19 03:32:43.000000000 -0500
18532 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
18533 + * Licensed under the GPL
18536 +#include "asm/ptrace.h"
18537 +#include "asm/uaccess.h"
18538 +#include "asm/signal.h"
18539 +#include "asm/uaccess.h"
18540 +#include "asm/ucontext.h"
18541 +#include "frame_kern.h"
18542 +#include "sigcontext.h"
18543 +#include "sysdep/ptrace.h"
18544 +#include "choose-mode.h"
18547 +int copy_siginfo_to_user(siginfo_t *to, siginfo_t *from)
18549 + if (!access_ok (VERIFY_WRITE, to, sizeof(siginfo_t)))
18551 + if (from->si_code < 0)
18552 + return __copy_to_user(to, from, sizeof(siginfo_t));
18556 + /* If you change siginfo_t structure, please be sure
18557 + this code is fixed accordingly.
18558 + It should never copy any pad contained in the structure
18559 + to avoid security leaks, but must copy the generic
18560 + 3 ints plus the relevant union member. */
18561 + err = __put_user(from->si_signo, &to->si_signo);
18562 + err |= __put_user(from->si_errno, &to->si_errno);
18563 + err |= __put_user((short)from->si_code, &to->si_code);
18564 + /* First 32bits of unions are always present. */
18565 + err |= __put_user(from->si_pid, &to->si_pid);
18566 + switch (from->si_code >> 16) {
18567 + case __SI_FAULT >> 16:
18569 + case __SI_CHLD >> 16:
18570 + err |= __put_user(from->si_utime, &to->si_utime);
18571 + err |= __put_user(from->si_stime, &to->si_stime);
18572 + err |= __put_user(from->si_status, &to->si_status);
18574 + err |= __put_user(from->si_uid, &to->si_uid);
18581 +static int copy_restorer(void (*restorer)(void), unsigned long start,
18582 + unsigned long sr_index, int sr_relative)
18584 + unsigned long sr;
18587 + sr = (unsigned long) restorer;
18588 + sr += start + sr_index;
18589 + restorer = (void (*)(void)) sr;
18592 + return(copy_to_user((void *) (start + sr_index), &restorer,
18593 + sizeof(restorer)));
18596 +extern int userspace_pid[];
18598 +static int copy_sc_to_user(void *to, void *fp, struct pt_regs *from,
18599 + struct arch_frame_data *arch)
18601 + return(CHOOSE_MODE(copy_sc_to_user_tt(to, fp, UPT_SC(&from->regs),
18603 + copy_sc_to_user_skas(userspace_pid[0], to, fp,
18605 + current->thread.cr2,
18606 + current->thread.err)));
18609 +static int copy_ucontext_to_user(struct ucontext *uc, void *fp, sigset_t *set,
18610 + unsigned long sp)
18614 + err |= put_user(current->sas_ss_sp, &uc->uc_stack.ss_sp);
18615 + err |= put_user(sas_ss_flags(sp), &uc->uc_stack.ss_flags);
18616 + err |= put_user(current->sas_ss_size, &uc->uc_stack.ss_size);
18617 + err |= copy_sc_to_user(&uc->uc_mcontext, fp, ¤t->thread.regs,
18618 + &signal_frame_si.common.arch);
18619 + err |= copy_to_user(&uc->uc_sigmask, set, sizeof(*set));
18623 +int setup_signal_stack_si(unsigned long stack_top, int sig,
18624 + unsigned long handler, void (*restorer)(void),
18625 + struct pt_regs *regs, siginfo_t *info,
18628 + unsigned long start;
18629 + void *sip, *ucp, *fp;
18631 + start = stack_top - signal_frame_si.common.len;
18632 + sip = (void *) (start + signal_frame_si.si_index);
18633 + ucp = (void *) (start + signal_frame_si.uc_index);
18634 + fp = (void *) (((unsigned long) ucp) + sizeof(struct ucontext));
18636 + if(restorer == NULL)
18637 + panic("setup_signal_stack_si - no restorer");
18639 + if(copy_to_user((void *) start, signal_frame_si.common.data,
18640 + signal_frame_si.common.len) ||
18641 + copy_to_user((void *) (start + signal_frame_si.common.sig_index),
18642 + &sig, sizeof(sig)) ||
18643 + copy_siginfo_to_user(sip, info) ||
18644 + copy_to_user((void *) (start + signal_frame_si.sip_index), &sip,
18646 + copy_ucontext_to_user(ucp, fp, mask, PT_REGS_SP(regs)) ||
18647 + copy_to_user((void *) (start + signal_frame_si.ucp_index), &ucp,
18649 + copy_restorer(restorer, start, signal_frame_si.common.sr_index,
18650 + signal_frame_si.common.sr_relative))
18653 + PT_REGS_IP(regs) = handler;
18654 + PT_REGS_SP(regs) = start + signal_frame_si.common.sp_index;
18658 +int setup_signal_stack_sc(unsigned long stack_top, int sig,
18659 + unsigned long handler, void (*restorer)(void),
18660 + struct pt_regs *regs, sigset_t *mask)
18662 + struct frame_common *frame = &signal_frame_sc_sr.common;
18664 + int sig_size = (_NSIG_WORDS - 1) * sizeof(unsigned long);
18665 + unsigned long sigs, sr;
18666 + unsigned long start = stack_top - frame->len - sig_size;
18668 + user_sc = (void *) (start + signal_frame_sc_sr.sc_index);
18669 + if(restorer == NULL){
18670 + frame = &signal_frame_sc.common;
18671 + user_sc = (void *) (start + signal_frame_sc.sc_index);
18672 + sr = (unsigned long) frame->data;
18673 + sr += frame->sr_index;
18674 + sr = *((unsigned long *) sr);
18675 + restorer = ((void (*)(void)) sr);
18678 + sigs = start + frame->len;
18679 + if(copy_to_user((void *) start, frame->data, frame->len) ||
18680 + copy_to_user((void *) (start + frame->sig_index), &sig,
18682 + copy_sc_to_user(user_sc, NULL, regs,
18683 + &signal_frame_sc.common.arch) ||
18684 + copy_to_user(sc_sigmask(user_sc), mask, sizeof(mask->sig[0])) ||
18685 + copy_to_user((void *) sigs, &mask->sig[1], sig_size) ||
18686 + copy_restorer(restorer, start, frame->sr_index, frame->sr_relative))
18689 + PT_REGS_IP(regs) = handler;
18690 + PT_REGS_SP(regs) = start + frame->sp_index;
18696 + * Overrides for Emacs so that we follow Linus's tabbing style.
18697 + * Emacs will notice this stuff at the end of the file and automatically
18698 + * adjust the settings for this buffer only. This must remain at the end
18700 + * ---------------------------------------------------------------------------
18701 + * Local variables:
18702 + * c-file-style: "linux"
18705 diff -Naur -X ../exclude-files orig/arch/um/kernel/gmon_syms.c um/arch/um/kernel/gmon_syms.c
18706 --- orig/arch/um/kernel/gmon_syms.c 1969-12-31 19:00:00.000000000 -0500
18707 +++ um/arch/um/kernel/gmon_syms.c 2003-10-21 03:26:06.000000000 -0400
18710 + * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
18711 + * Licensed under the GPL
18714 +#include "linux/module.h"
18716 +extern void __bb_init_func(void *);
18717 +EXPORT_SYMBOL(__bb_init_func);
18720 + * Overrides for Emacs so that we follow Linus's tabbing style.
18721 + * Emacs will notice this stuff at the end of the file and automatically
18722 + * adjust the settings for this buffer only. This must remain at the end
18724 + * ---------------------------------------------------------------------------
18725 + * Local variables:
18726 + * c-file-style: "linux"
18729 diff -Naur -X ../exclude-files orig/arch/um/kernel/gprof_syms.c um/arch/um/kernel/gprof_syms.c
18730 --- orig/arch/um/kernel/gprof_syms.c 1969-12-31 19:00:00.000000000 -0500
18731 +++ um/arch/um/kernel/gprof_syms.c 2003-10-21 03:26:06.000000000 -0400
18734 + * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
18735 + * Licensed under the GPL
18738 +#include "linux/module.h"
18740 +extern void mcount(void);
18741 +EXPORT_SYMBOL(mcount);
18744 + * Overrides for Emacs so that we follow Linus's tabbing style.
18745 + * Emacs will notice this stuff at the end of the file and automatically
18746 + * adjust the settings for this buffer only. This must remain at the end
18748 + * ---------------------------------------------------------------------------
18749 + * Local variables:
18750 + * c-file-style: "linux"
18753 diff -Naur -X ../exclude-files orig/arch/um/kernel/helper.c um/arch/um/kernel/helper.c
18754 --- orig/arch/um/kernel/helper.c 1969-12-31 19:00:00.000000000 -0500
18755 +++ um/arch/um/kernel/helper.c 2003-11-08 07:41:30.000000000 -0500
18758 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
18759 + * Licensed under the GPL
18762 +#include <stdio.h>
18763 +#include <stdlib.h>
18764 +#include <unistd.h>
18765 +#include <errno.h>
18766 +#include <sched.h>
18767 +#include <sys/signal.h>
18768 +#include <sys/wait.h>
18770 +#include "kern_util.h"
18773 +struct helper_data {
18774 + void (*pre_exec)(void*);
18780 +/* Debugging aid, changed only from gdb */
18781 +int helper_pause = 0;
18783 +static void helper_hup(int sig)
18787 +static int helper_child(void *arg)
18789 + struct helper_data *data = arg;
18790 + char **argv = data->argv;
18793 + if(helper_pause){
18794 + signal(SIGHUP, helper_hup);
18797 + if(data->pre_exec != NULL)
18798 + (*data->pre_exec)(data->pre_data);
18799 + execvp(argv[0], argv);
18801 + printk("execvp of '%s' failed - errno = %d\n", argv[0], errno);
18802 + os_write_file(data->fd, &errval, sizeof(errval));
18803 + os_kill_process(os_getpid(), 0);
18807 +/* XXX The alloc_stack here breaks if this is called in the tracing thread */
18809 +int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv,
18810 + unsigned long *stack_out)
18812 + struct helper_data data;
18813 + unsigned long stack, sp;
18814 + int pid, fds[2], err, n;
18816 + if((stack_out != NULL) && (*stack_out != 0))
18817 + stack = *stack_out;
18818 + else stack = alloc_stack(0, um_in_interrupt());
18822 + err = os_pipe(fds, 1, 0);
18824 + printk("run_helper : pipe failed, err = %d\n", -err);
18828 + err = os_set_exec_close(fds[1], 1);
18830 + printk("run_helper : setting FD_CLOEXEC failed, err = %d\n",
18835 + sp = stack + page_size() - sizeof(void *);
18836 + data.pre_exec = pre_exec;
18837 + data.pre_data = pre_data;
18838 + data.argv = argv;
18839 + data.fd = fds[1];
18840 + pid = clone(helper_child, (void *) sp, CLONE_VM | SIGCHLD, &data);
18842 + printk("run_helper : clone failed, errno = %d\n", errno);
18847 + os_close_file(fds[1]);
18848 + n = os_read_file(fds[0], &err, sizeof(err));
18850 + printk("run_helper : read on pipe failed, err = %d\n", -n);
18855 + waitpid(pid, NULL, 0);
18859 + if(stack_out == NULL) free_stack(stack, 0);
18860 + else *stack_out = stack;
18864 + os_kill_process(pid, 1);
18866 + os_close_file(fds[0]);
18867 + os_close_file(fds[1]);
18869 + free_stack(stack, 0);
18873 +int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags,
18874 + unsigned long *stack_out, int stack_order)
18876 + unsigned long stack, sp;
18879 + stack = alloc_stack(stack_order, um_in_interrupt());
18880 + if(stack == 0) return(-ENOMEM);
18882 + sp = stack + (page_size() << stack_order) - sizeof(void *);
18883 + pid = clone(proc, (void *) sp, flags | SIGCHLD, arg);
18885 + printk("run_helper_thread : clone failed, errno = %d\n",
18889 + if(stack_out == NULL){
18890 + pid = waitpid(pid, &status, 0);
18892 + printk("run_helper_thread - wait failed, errno = %d\n",
18896 + if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0))
18897 + printk("run_helper_thread - thread returned status "
18898 + "0x%x\n", status);
18899 + free_stack(stack, stack_order);
18901 + else *stack_out = stack;
18905 +int helper_wait(int pid, int block)
18909 + ret = waitpid(pid, NULL, WNOHANG);
18911 + printk("helper_wait : waitpid failed, errno = %d\n", errno);
18918 + * Overrides for Emacs so that we follow Linus's tabbing style.
18919 + * Emacs will notice this stuff at the end of the file and automatically
18920 + * adjust the settings for this buffer only. This must remain at the end
18922 + * ---------------------------------------------------------------------------
18923 + * Local variables:
18924 + * c-file-style: "linux"
18927 diff -Naur -X ../exclude-files orig/arch/um/kernel/initrd_kern.c um/arch/um/kernel/initrd_kern.c
18928 --- orig/arch/um/kernel/initrd_kern.c 1969-12-31 19:00:00.000000000 -0500
18929 +++ um/arch/um/kernel/initrd_kern.c 2003-10-21 03:26:06.000000000 -0400
18932 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
18933 + * Licensed under the GPL
18936 +#include "linux/init.h"
18937 +#include "linux/bootmem.h"
18938 +#include "linux/blk.h"
18939 +#include "asm/types.h"
18940 +#include "user_util.h"
18941 +#include "kern_util.h"
18942 +#include "initrd.h"
18946 +/* Changed by uml_initrd_setup, which is a setup */
18947 +static char *initrd __initdata = NULL;
18949 +static int __init read_initrd(void)
18955 + if(initrd == NULL) return 0;
18956 + err = os_file_size(initrd, &size);
18957 + if(err) return 0;
18958 + area = alloc_bootmem(size);
18959 + if(area == NULL) return 0;
18960 + if(load_initrd(initrd, area, size) == -1) return 0;
18961 + initrd_start = (unsigned long) area;
18962 + initrd_end = initrd_start + size;
18966 +__uml_postsetup(read_initrd);
18968 +static int __init uml_initrd_setup(char *line, int *add)
18974 +__uml_setup("initrd=", uml_initrd_setup,
18975 +"initrd=<initrd image>\n"
18976 +" This is used to boot UML from an initrd image. The argument is the\n"
18977 +" name of the file containing the image.\n\n"
18981 + * Overrides for Emacs so that we follow Linus's tabbing style.
18982 + * Emacs will notice this stuff at the end of the file and automatically
18983 + * adjust the settings for this buffer only. This must remain at the end
18985 + * ---------------------------------------------------------------------------
18986 + * Local variables:
18987 + * c-file-style: "linux"
18990 diff -Naur -X ../exclude-files orig/arch/um/kernel/initrd_user.c um/arch/um/kernel/initrd_user.c
18991 --- orig/arch/um/kernel/initrd_user.c 1969-12-31 19:00:00.000000000 -0500
18992 +++ um/arch/um/kernel/initrd_user.c 2003-10-21 03:26:06.000000000 -0400
18995 + * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
18996 + * Licensed under the GPL
18999 +#include <unistd.h>
19000 +#include <sys/types.h>
19001 +#include <sys/stat.h>
19002 +#include <errno.h>
19004 +#include "user_util.h"
19005 +#include "kern_util.h"
19007 +#include "initrd.h"
19010 +int load_initrd(char *filename, void *buf, int size)
19014 + fd = os_open_file(filename, of_read(OPENFLAGS()), 0);
19016 + printk("Opening '%s' failed - err = %d\n", filename, -fd);
19019 + n = os_read_file(fd, buf, size);
19021 + printk("Read of %d bytes from '%s' failed, err = %d\n", size,
19029 + * Overrides for Emacs so that we follow Linus's tabbing style.
19030 + * Emacs will notice this stuff at the end of the file and automatically
19031 + * adjust the settings for this buffer only. This must remain at the end
19033 + * ---------------------------------------------------------------------------
19034 + * Local variables:
19035 + * c-file-style: "linux"
19038 diff -Naur -X ../exclude-files orig/arch/um/kernel/init_task.c um/arch/um/kernel/init_task.c
19039 --- orig/arch/um/kernel/init_task.c 1969-12-31 19:00:00.000000000 -0500
19040 +++ um/arch/um/kernel/init_task.c 2003-10-21 03:26:06.000000000 -0400
19043 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
19044 + * Licensed under the GPL
19047 +#include "linux/config.h"
19048 +#include "linux/mm.h"
19049 +#include "linux/sched.h"
19050 +#include "linux/version.h"
19051 +#include "asm/uaccess.h"
19052 +#include "asm/pgtable.h"
19053 +#include "user_util.h"
19054 +#include "mem_user.h"
19056 +static struct fs_struct init_fs = INIT_FS;
19057 +static struct files_struct init_files = INIT_FILES;
19058 +static struct signal_struct init_signals = INIT_SIGNALS;
19059 +struct mm_struct init_mm = INIT_MM(init_mm);
19062 + * Initial task structure.
19064 + * We need to make sure that this is 16384-byte aligned due to the
19065 + * way process stacks are handled. This is done by having a special
19066 + * "init_task" linker map entry..
19069 +union task_union init_task_union
19070 +__attribute__((__section__(".data.init_task"))) =
19071 +{ INIT_TASK(init_task_union.task) };
19073 +struct task_struct *alloc_task_struct(void)
19075 + return((struct task_struct *)
19076 + __get_free_pages(GFP_KERNEL, CONFIG_KERNEL_STACK_ORDER));
19079 +void unprotect_stack(unsigned long stack)
19081 + protect_memory(stack, (1 << CONFIG_KERNEL_STACK_ORDER) * PAGE_SIZE,
19085 +void free_task_struct(struct task_struct *task)
19087 + /* free_pages decrements the page counter and only actually frees
19088 + * the pages if they are now not accessed by anything.
19090 + free_pages((unsigned long) task, CONFIG_KERNEL_STACK_ORDER);
19094 + * Overrides for Emacs so that we follow Linus's tabbing style.
19095 + * Emacs will notice this stuff at the end of the file and automatically
19096 + * adjust the settings for this buffer only. This must remain at the end
19098 + * ---------------------------------------------------------------------------
19099 + * Local variables:
19100 + * c-file-style: "linux"
19103 diff -Naur -X ../exclude-files orig/arch/um/kernel/irq.c um/arch/um/kernel/irq.c
19104 --- orig/arch/um/kernel/irq.c 1969-12-31 19:00:00.000000000 -0500
19105 +++ um/arch/um/kernel/irq.c 2003-12-16 22:45:27.000000000 -0500
19108 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
19109 + * Licensed under the GPL
19110 + * Derived (i.e. mostly copied) from arch/i386/kernel/irq.c:
19111 + * Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
19114 +#include "linux/config.h"
19115 +#include "linux/kernel.h"
19116 +#include "linux/smp.h"
19117 +#include "linux/irq.h"
19118 +#include "linux/kernel_stat.h"
19119 +#include "linux/interrupt.h"
19120 +#include "linux/random.h"
19121 +#include "linux/slab.h"
19122 +#include "linux/file.h"
19123 +#include "linux/proc_fs.h"
19124 +#include "linux/init.h"
19125 +#include "linux/seq_file.h"
19126 +#include "asm/irq.h"
19127 +#include "asm/hw_irq.h"
19128 +#include "asm/hardirq.h"
19129 +#include "asm/atomic.h"
19130 +#include "asm/signal.h"
19131 +#include "asm/system.h"
19132 +#include "asm/errno.h"
19133 +#include "asm/uaccess.h"
19134 +#include "user_util.h"
19135 +#include "kern_util.h"
19136 +#include "irq_user.h"
19137 +#include "irq_kern.h"
19139 +static void register_irq_proc (unsigned int irq);
19141 +irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned =
19142 + { [0 ... NR_IRQS-1] = { 0, &no_irq_type, NULL, 0, SPIN_LOCK_UNLOCKED}};
19145 + * Generic no controller code
19148 +static void enable_none(unsigned int irq) { }
19149 +static unsigned int startup_none(unsigned int irq) { return 0; }
19150 +static void disable_none(unsigned int irq) { }
19151 +static void ack_none(unsigned int irq)
19154 + * 'what should we do if we get a hw irq event on an illegal vector'.
19155 + * each architecture has to answer this themselves, it doesnt deserve
19156 + * a generic callback i think.
19159 + printk(KERN_ERR "unexpected IRQ trap at vector %02x\n", irq);
19160 +#ifdef CONFIG_X86_LOCAL_APIC
19162 + * Currently unexpected vectors happen only on SMP and APIC.
19163 + * We _must_ ack these because every local APIC has only N
19164 + * irq slots per priority level, and a 'hanging, unacked' IRQ
19165 + * holds up an irq slot - in excessive cases (when multiple
19166 + * unexpected vectors occur) that might lock up the APIC
19174 +/* startup is the same as "enable", shutdown is same as "disable" */
19175 +#define shutdown_none disable_none
19176 +#define end_none enable_none
19178 +struct hw_interrupt_type no_irq_type = {
19189 + * Generic, controller-independent functions:
19192 +int get_irq_list(char *buf)
19195 + unsigned long flags;
19196 + struct irqaction * action;
19199 + p += sprintf(p, " ");
19200 + for (j=0; j<smp_num_cpus; j++)
19201 + p += sprintf(p, "CPU%d ",j);
19204 + for (i = 0 ; i < NR_IRQS ; i++) {
19205 + spin_lock_irqsave(&irq_desc[i].lock, flags);
19206 + action = irq_desc[i].action;
19209 + p += sprintf(p, "%3d: ",i);
19210 +#ifndef CONFIG_SMP
19211 + p += sprintf(p, "%10u ", kstat_irqs(i));
19213 + for (j = 0; j < smp_num_cpus; j++)
19214 + p += sprintf(p, "%10u ",
19215 + kstat.irqs[cpu_logical_map(j)][i]);
19217 + p += sprintf(p, " %14s", irq_desc[i].handler->typename);
19218 + p += sprintf(p, " %s", action->name);
19220 + for (action=action->next; action; action = action->next)
19221 + p += sprintf(p, ", %s", action->name);
19224 + spin_unlock_irqrestore(&irq_desc[i].lock, flags);
19226 + p += sprintf(p, "\n");
19229 + p += sprintf(p, "LOC: ");
19230 + for (j = 0; j < smp_num_cpus; j++)
19231 + p += sprintf(p, "%10u ",
19232 + apic_timer_irqs[cpu_logical_map(j)]);
19233 + p += sprintf(p, "\n");
19236 + p += sprintf(p, "ERR: %10lu\n", 0L);
19241 + * This should really return information about whether
19242 + * we should do bottom half handling etc. Right now we
19243 + * end up _always_ checking the bottom half, which is a
19244 + * waste of time and is not what some drivers would
19247 +int handle_IRQ_event(unsigned int irq, struct pt_regs * regs,
19248 + struct irqaction * action)
19251 + int cpu = smp_processor_id();
19253 + irq_enter(cpu, irq);
19255 + status = 1; /* Force the "do bottom halves" bit */
19257 + if (!(action->flags & SA_INTERRUPT))
19261 + status |= action->flags;
19262 + action->handler(irq, action->dev_id, regs);
19263 + action = action->next;
19264 + } while (action);
19265 + if (status & SA_SAMPLE_RANDOM)
19266 + add_interrupt_randomness(irq);
19269 + irq_exit(cpu, irq);
19275 + * Generic enable/disable code: this just calls
19276 + * down into the PIC-specific version for the actual
19277 + * hardware disable after having gotten the irq
19278 + * controller lock.
19282 + * disable_irq_nosync - disable an irq without waiting
19283 + * @irq: Interrupt to disable
19285 + * Disable the selected interrupt line. Disables of an interrupt
19286 + * stack. Unlike disable_irq(), this function does not ensure existing
19287 + * instances of the IRQ handler have completed before returning.
19289 + * This function may be called from IRQ context.
19292 +void inline disable_irq_nosync(unsigned int irq)
19294 + irq_desc_t *desc = irq_desc + irq;
19295 + unsigned long flags;
19297 + spin_lock_irqsave(&desc->lock, flags);
19298 + if (!desc->depth++) {
19299 + desc->status |= IRQ_DISABLED;
19300 + desc->handler->disable(irq);
19302 + spin_unlock_irqrestore(&desc->lock, flags);
19306 + * disable_irq - disable an irq and wait for completion
19307 + * @irq: Interrupt to disable
19309 + * Disable the selected interrupt line. Disables of an interrupt
19310 + * stack. That is for two disables you need two enables. This
19311 + * function waits for any pending IRQ handlers for this interrupt
19312 + * to complete before returning. If you use this function while
19313 + * holding a resource the IRQ handler may need you will deadlock.
19315 + * This function may be called - with care - from IRQ context.
19318 +void disable_irq(unsigned int irq)
19320 + disable_irq_nosync(irq);
19322 + if (!local_irq_count(smp_processor_id())) {
19325 + } while (irq_desc[irq].status & IRQ_INPROGRESS);
19330 + * enable_irq - enable interrupt handling on an irq
19331 + * @irq: Interrupt to enable
19333 + * Re-enables the processing of interrupts on this IRQ line
19334 + * providing no disable_irq calls are now in effect.
19336 + * This function may be called from IRQ context.
19339 +void enable_irq(unsigned int irq)
19341 + irq_desc_t *desc = irq_desc + irq;
19342 + unsigned long flags;
19344 + spin_lock_irqsave(&desc->lock, flags);
19345 + switch (desc->depth) {
19347 + unsigned int status = desc->status & ~IRQ_DISABLED;
19348 + desc->status = status;
19349 + if ((status & (IRQ_PENDING | IRQ_REPLAY)) == IRQ_PENDING) {
19350 + desc->status = status | IRQ_REPLAY;
19351 + hw_resend_irq(desc->handler,irq);
19353 + desc->handler->enable(irq);
19354 + /* fall-through */
19360 + printk(KERN_ERR "enable_irq() unbalanced from %p\n",
19361 + __builtin_return_address(0));
19363 + spin_unlock_irqrestore(&desc->lock, flags);
19367 + * do_IRQ handles all normal device IRQ's (the special
19368 + * SMP cross-CPU interrupts have their own specific
19371 +unsigned int do_IRQ(int irq, union uml_pt_regs *regs)
19374 + * 0 return value means that this irq is already being
19375 + * handled by some other CPU. (or is disabled)
19377 + int cpu = smp_processor_id();
19378 + irq_desc_t *desc = irq_desc + irq;
19379 + struct irqaction * action;
19380 + unsigned int status;
19382 + kstat.irqs[cpu][irq]++;
19383 + spin_lock(&desc->lock);
19384 + desc->handler->ack(irq);
19386 + REPLAY is when Linux resends an IRQ that was dropped earlier
19387 + WAITING is used by probe to mark irqs that are being tested
19389 + status = desc->status & ~(IRQ_REPLAY | IRQ_WAITING);
19390 + status |= IRQ_PENDING; /* we _want_ to handle it */
19393 + * If the IRQ is disabled for whatever reason, we cannot
19394 + * use the action we have.
19397 + if (!(status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
19398 + action = desc->action;
19399 + status &= ~IRQ_PENDING; /* we commit to handling */
19400 + status |= IRQ_INPROGRESS; /* we are handling it */
19402 + desc->status = status;
19405 + * If there is no IRQ handler or it was disabled, exit early.
19406 + Since we set PENDING, if another processor is handling
19407 + a different instance of this same irq, the other processor
19408 + will take care of it.
19414 + * Edge triggered interrupts need to remember
19415 + * pending events.
19416 + * This applies to any hw interrupts that allow a second
19417 + * instance of the same irq to arrive while we are in do_IRQ
19418 + * or in the handler. But the code here only handles the _second_
19419 + * instance of the irq, not the third or fourth. So it is mostly
19420 + * useful for irq hardware that does not mask cleanly in an
19421 + * SMP environment.
19424 + spin_unlock(&desc->lock);
19425 + handle_IRQ_event(irq, (struct pt_regs *) regs, action);
19426 + spin_lock(&desc->lock);
19428 + if (!(desc->status & IRQ_PENDING))
19430 + desc->status &= ~IRQ_PENDING;
19432 + desc->status &= ~IRQ_INPROGRESS;
19435 + * The ->end() handler has to deal with interrupts which got
19436 + * disabled while the handler was running.
19438 + desc->handler->end(irq);
19439 + spin_unlock(&desc->lock);
19441 + if (softirq_pending(cpu))
19447 + * request_irq - allocate an interrupt line
19448 + * @irq: Interrupt line to allocate
19449 + * @handler: Function to be called when the IRQ occurs
19450 + * @irqflags: Interrupt type flags
19451 + * @devname: An ascii name for the claiming device
19452 + * @dev_id: A cookie passed back to the handler function
19454 + * This call allocates interrupt resources and enables the
19455 + * interrupt line and IRQ handling. From the point this
19456 + * call is made your handler function may be invoked. Since
19457 + * your handler function must clear any interrupt the board
19458 + * raises, you must take care both to initialise your hardware
19459 + * and to set up the interrupt handler in the right order.
19461 + * Dev_id must be globally unique. Normally the address of the
19462 + * device data structure is used as the cookie. Since the handler
19463 + * receives this value it makes sense to use it.
19465 + * If your interrupt is shared you must pass a non NULL dev_id
19466 + * as this is required when freeing the interrupt.
19470 + * SA_SHIRQ Interrupt is shared
19472 + * SA_INTERRUPT Disable local interrupts while processing
19474 + * SA_SAMPLE_RANDOM The interrupt can be used for entropy
19478 +int request_irq(unsigned int irq,
19479 + void (*handler)(int, void *, struct pt_regs *),
19480 + unsigned long irqflags,
19481 + const char * devname,
19485 + struct irqaction * action;
19489 + * Sanity-check: shared interrupts should REALLY pass in
19490 + * a real dev-ID, otherwise we'll have trouble later trying
19491 + * to figure out which interrupt is which (messes up the
19492 + * interrupt freeing logic etc).
19494 + if (irqflags & SA_SHIRQ) {
19496 + printk(KERN_ERR "Bad boy: %s (at 0x%x) called us "
19497 + "without a dev_id!\n", devname, (&irq)[-1]);
19501 + if (irq >= NR_IRQS)
19506 + action = (struct irqaction *)
19507 + kmalloc(sizeof(struct irqaction), GFP_KERNEL);
19511 + action->handler = handler;
19512 + action->flags = irqflags;
19513 + action->mask = 0;
19514 + action->name = devname;
19515 + action->next = NULL;
19516 + action->dev_id = dev_id;
19518 + retval = setup_irq(irq, action);
19524 +int um_request_irq(unsigned int irq, int fd, int type,
19525 + void (*handler)(int, void *, struct pt_regs *),
19526 + unsigned long irqflags, const char * devname,
19531 + err = request_irq(irq, handler, irqflags, devname, dev_id);
19536 + err = activate_fd(irq, fd, type, dev_id);
19540 +/* this was setup_x86_irq but it seems pretty generic */
19541 +int setup_irq(unsigned int irq, struct irqaction * new)
19544 + unsigned long flags;
19545 + struct irqaction *old, **p;
19546 + irq_desc_t *desc = irq_desc + irq;
19549 + * Some drivers like serial.c use request_irq() heavily,
19550 + * so we have to be careful not to interfere with a
19551 + * running system.
19553 + if (new->flags & SA_SAMPLE_RANDOM) {
19555 + * This function might sleep, we want to call it first,
19556 + * outside of the atomic block.
19557 + * Yes, this might clear the entropy pool if the wrong
19558 + * driver is attempted to be loaded, without actually
19559 + * installing a new handler, but is this really a problem,
19560 + * only the sysadmin is able to do this.
19562 + rand_initialize_irq(irq);
19566 + * The following block of code has to be executed atomically
19568 + spin_lock_irqsave(&desc->lock,flags);
19569 + p = &desc->action;
19571 + if (old != NULL) {
19572 + /* Can't share interrupts unless both agree to */
19573 + if (!(old->flags & new->flags & SA_SHIRQ)) {
19574 + spin_unlock_irqrestore(&desc->lock,flags);
19578 + /* add new interrupt at end of irq queue */
19590 + desc->status &= ~IRQ_DISABLED;
19591 + desc->handler->startup(irq);
19593 + spin_unlock_irqrestore(&desc->lock,flags);
19595 + register_irq_proc(irq);
19600 + * free_irq - free an interrupt
19601 + * @irq: Interrupt line to free
19602 + * @dev_id: Device identity to free
19604 + * Remove an interrupt handler. The handler is removed and if the
19605 + * interrupt line is no longer in use by any driver it is disabled.
19606 + * On a shared IRQ the caller must ensure the interrupt is disabled
19607 + * on the card it drives before calling this function. The function
19608 + * does not return until any executing interrupts for this IRQ
19609 + * have completed.
19611 + * This function may be called from interrupt context.
19613 + * Bugs: Attempting to free an irq in a handler for the same irq hangs
19617 +void free_irq(unsigned int irq, void *dev_id)
19619 + irq_desc_t *desc;
19620 + struct irqaction **p;
19621 + unsigned long flags;
19623 + if (irq >= NR_IRQS)
19626 + desc = irq_desc + irq;
19627 + spin_lock_irqsave(&desc->lock,flags);
19628 + p = &desc->action;
19630 + struct irqaction * action = *p;
19632 + struct irqaction **pp = p;
19633 + p = &action->next;
19634 + if (action->dev_id != dev_id)
19637 + /* Found it - now remove it from the list of entries */
19638 + *pp = action->next;
19639 + if (!desc->action) {
19640 + desc->status |= IRQ_DISABLED;
19641 + desc->handler->shutdown(irq);
19643 + free_irq_by_irq_and_dev(irq, dev_id);
19644 + spin_unlock_irqrestore(&desc->lock,flags);
19647 + /* Wait to make sure it's not being used on another CPU */
19648 + while (desc->status & IRQ_INPROGRESS)
19654 + printk(KERN_ERR "Trying to free free IRQ%d\n",irq);
19655 + spin_unlock_irqrestore(&desc->lock,flags);
19660 +/* These are initialized by sysctl_init, which is called from init/main.c */
19661 +static struct proc_dir_entry * root_irq_dir;
19662 +static struct proc_dir_entry * irq_dir [NR_IRQS];
19663 +static struct proc_dir_entry * smp_affinity_entry [NR_IRQS];
19665 +/* These are read and written as longs, so a read won't see a partial write
19666 + * even during a race.
19668 +static unsigned long irq_affinity [NR_IRQS] = { [0 ... NR_IRQS-1] = ~0UL };
19670 +#define HEX_DIGITS 8
19672 +static int irq_affinity_read_proc (char *page, char **start, off_t off,
19673 + int count, int *eof, void *data)
19675 + if (count < HEX_DIGITS+1)
19677 + return sprintf (page, "%08lx\n", irq_affinity[(long)data]);
19680 +static unsigned int parse_hex_value (const char *buffer,
19681 + unsigned long count, unsigned long *ret)
19683 + unsigned char hexnum [HEX_DIGITS];
19684 + unsigned long value;
19689 + if (count > HEX_DIGITS)
19690 + count = HEX_DIGITS;
19691 + if (copy_from_user(hexnum, buffer, count))
19695 + * Parse the first HEX_DIGITS characters as a hex string, any non-hex
19696 + * char is end-of-string. '00e1', 'e1', '00E1', 'E1' are all the same.
19700 + for (i = 0; i < count; i++) {
19701 + unsigned int c = hexnum[i];
19704 + case '0' ... '9': c -= '0'; break;
19705 + case 'a' ... 'f': c -= 'a'-10; break;
19706 + case 'A' ... 'F': c -= 'A'-10; break;
19710 + value = (value << 4) | c;
19717 +static int irq_affinity_write_proc (struct file *file, const char *buffer,
19718 + unsigned long count, void *data)
19720 + int irq = (long) data, full_count = count, err;
19721 + unsigned long new_value;
19723 + if (!irq_desc[irq].handler->set_affinity)
19726 + err = parse_hex_value(buffer, count, &new_value);
19730 + * Do not allow disabling IRQs completely - it's a too easy
19731 + * way to make the system unusable accidentally :-) At least
19732 + * one online CPU still has to be targeted.
19734 + if (!(new_value & cpu_online_map))
19738 + irq_affinity[irq] = new_value;
19739 + irq_desc[irq].handler->set_affinity(irq, new_value);
19741 + return full_count;
19744 +static int prof_cpu_mask_read_proc (char *page, char **start, off_t off,
19745 + int count, int *eof, void *data)
19747 + unsigned long *mask = (unsigned long *) data;
19748 + if (count < HEX_DIGITS+1)
19750 + return sprintf (page, "%08lx\n", *mask);
19753 +static int prof_cpu_mask_write_proc (struct file *file, const char *buffer,
19754 + unsigned long count, void *data)
19756 + unsigned long *mask = (unsigned long *) data, full_count = count, err;
19757 + unsigned long new_value;
19759 + err = parse_hex_value(buffer, count, &new_value);
19763 + *mask = new_value;
19764 + return full_count;
19767 +#define MAX_NAMELEN 10
19769 +static void register_irq_proc (unsigned int irq)
19771 + struct proc_dir_entry *entry;
19772 + char name [MAX_NAMELEN];
19774 + if (!root_irq_dir || (irq_desc[irq].handler == &no_irq_type) ||
19778 + memset(name, 0, MAX_NAMELEN);
19779 + sprintf(name, "%d", irq);
19781 + /* create /proc/irq/1234 */
19782 + irq_dir[irq] = proc_mkdir(name, root_irq_dir);
19784 + /* create /proc/irq/1234/smp_affinity */
19785 + entry = create_proc_entry("smp_affinity", 0600, irq_dir[irq]);
19787 + entry->nlink = 1;
19788 + entry->data = (void *)(long)irq;
19789 + entry->read_proc = irq_affinity_read_proc;
19790 + entry->write_proc = irq_affinity_write_proc;
19792 + smp_affinity_entry[irq] = entry;
19795 +/* Read and written as a long */
19796 +unsigned long prof_cpu_mask = -1;
19798 +void __init init_irq_proc (void)
19800 + struct proc_dir_entry *entry;
19803 + /* create /proc/irq */
19804 + root_irq_dir = proc_mkdir("irq", 0);
19806 + /* create /proc/irq/prof_cpu_mask */
19807 + entry = create_proc_entry("prof_cpu_mask", 0600, root_irq_dir);
19809 + entry->nlink = 1;
19810 + entry->data = (void *)&prof_cpu_mask;
19811 + entry->read_proc = prof_cpu_mask_read_proc;
19812 + entry->write_proc = prof_cpu_mask_write_proc;
19815 + * Create entries for all existing IRQs.
19817 + for (i = 0; i < NR_IRQS; i++)
19818 + register_irq_proc(i);
19821 +static spinlock_t irq_spinlock = SPIN_LOCK_UNLOCKED;
19823 +unsigned long irq_lock(void)
19825 + unsigned long flags;
19827 + spin_lock_irqsave(&irq_spinlock, flags);
19831 +void irq_unlock(unsigned long flags)
19833 + spin_unlock_irqrestore(&irq_spinlock, flags);
19836 +unsigned long probe_irq_on(void)
19841 +int probe_irq_off(unsigned long val)
19846 +static unsigned int startup_SIGIO_irq(unsigned int irq)
19851 +static void shutdown_SIGIO_irq(unsigned int irq)
19855 +static void enable_SIGIO_irq(unsigned int irq)
19859 +static void disable_SIGIO_irq(unsigned int irq)
19863 +static void mask_and_ack_SIGIO(unsigned int irq)
19867 +static void end_SIGIO_irq(unsigned int irq)
19871 +static unsigned int startup_SIGVTALRM_irq(unsigned int irq)
19876 +static void shutdown_SIGVTALRM_irq(unsigned int irq)
19880 +static void enable_SIGVTALRM_irq(unsigned int irq)
19884 +static void disable_SIGVTALRM_irq(unsigned int irq)
19888 +static void mask_and_ack_SIGVTALRM(unsigned int irq)
19892 +static void end_SIGVTALRM_irq(unsigned int irq)
19896 +static struct hw_interrupt_type SIGIO_irq_type = {
19898 + startup_SIGIO_irq,
19899 + shutdown_SIGIO_irq,
19900 + enable_SIGIO_irq,
19901 + disable_SIGIO_irq,
19902 + mask_and_ack_SIGIO,
19907 +static struct hw_interrupt_type SIGVTALRM_irq_type = {
19909 + startup_SIGVTALRM_irq,
19910 + shutdown_SIGVTALRM_irq,
19911 + enable_SIGVTALRM_irq,
19912 + disable_SIGVTALRM_irq,
19913 + mask_and_ack_SIGVTALRM,
19914 + end_SIGVTALRM_irq,
19918 +void __init init_IRQ(void)
19922 + irq_desc[TIMER_IRQ].status = IRQ_DISABLED;
19923 + irq_desc[TIMER_IRQ].action = 0;
19924 + irq_desc[TIMER_IRQ].depth = 1;
19925 + irq_desc[TIMER_IRQ].handler = &SIGVTALRM_irq_type;
19926 + enable_irq(TIMER_IRQ);
19927 + for(i=1;i<NR_IRQS;i++){
19928 + irq_desc[i].status = IRQ_DISABLED;
19929 + irq_desc[i].action = 0;
19930 + irq_desc[i].depth = 1;
19931 + irq_desc[i].handler = &SIGIO_irq_type;
19934 + init_irq_signals(0);
19938 + * Overrides for Emacs so that we follow Linus's tabbing style.
19939 + * Emacs will notice this stuff at the end of the file and automatically
19940 + * adjust the settings for this buffer only. This must remain at the end
19942 + * ---------------------------------------------------------------------------
19943 + * Local variables:
19944 + * c-file-style: "linux"
19947 diff -Naur -X ../exclude-files orig/arch/um/kernel/irq_user.c um/arch/um/kernel/irq_user.c
19948 --- orig/arch/um/kernel/irq_user.c 1969-12-31 19:00:00.000000000 -0500
19949 +++ um/arch/um/kernel/irq_user.c 2003-10-21 03:26:06.000000000 -0400
19952 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
19953 + * Licensed under the GPL
19956 +#include <stdlib.h>
19957 +#include <unistd.h>
19958 +#include <errno.h>
19959 +#include <signal.h>
19960 +#include <string.h>
19961 +#include <sys/poll.h>
19962 +#include <sys/types.h>
19963 +#include <sys/time.h>
19964 +#include "user_util.h"
19965 +#include "kern_util.h"
19967 +#include "process.h"
19968 +#include "signal_user.h"
19969 +#include "sigio.h"
19970 +#include "irq_user.h"
19974 + struct irq_fd *next;
19981 + int current_events;
19985 +static struct irq_fd *active_fds = NULL;
19986 +static struct irq_fd **last_irq_ptr = &active_fds;
19988 +static struct pollfd *pollfds = NULL;
19989 +static int pollfds_num = 0;
19990 +static int pollfds_size = 0;
19992 +extern int io_count, intr_count;
19994 +void sigio_handler(int sig, union uml_pt_regs *regs)
19996 + struct irq_fd *irq_fd, *next;
19999 + if(smp_sigio_handler()) return;
20001 + n = poll(pollfds, pollfds_num, 0);
20003 + if(errno == EINTR) continue;
20004 + printk("sigio_handler : poll returned %d, "
20005 + "errno = %d\n", n, errno);
20008 + if(n == 0) break;
20010 + irq_fd = active_fds;
20011 + for(i = 0; i < pollfds_num; i++){
20012 + if(pollfds[i].revents != 0){
20013 + irq_fd->current_events = pollfds[i].revents;
20014 + pollfds[i].fd = -1;
20016 + irq_fd = irq_fd->next;
20019 + for(irq_fd = active_fds; irq_fd != NULL; irq_fd = next){
20020 + next = irq_fd->next;
20021 + if(irq_fd->current_events != 0){
20022 + irq_fd->current_events = 0;
20023 + do_IRQ(irq_fd->irq, regs);
20025 + /* This is here because the next irq may be
20026 + * freed in the handler. If a console goes
20027 + * away, both the read and write irqs will be
20028 + * freed. After do_IRQ, ->next will point to
20030 + * Irqs can't be freed inside their handlers,
20031 + * so the next best thing is to have them
20032 + * marked as needing freeing, so that they
20033 + * can be freed here.
20035 + next = irq_fd->next;
20036 + if(irq_fd->freed)
20037 + free_irq(irq_fd->irq, irq_fd->id);
20043 +int activate_ipi(int fd, int pid)
20045 + return(os_set_fd_async(fd, pid));
20048 +static void maybe_sigio_broken(int fd, int type)
20051 + if((type == IRQ_WRITE) && !pty_output_sigio){
20052 + write_sigio_workaround();
20053 + add_sigio_fd(fd, 0);
20055 + else if((type == IRQ_READ) && !pty_close_sigio){
20056 + write_sigio_workaround();
20057 + add_sigio_fd(fd, 1);
20062 +int activate_fd(int irq, int fd, int type, void *dev_id)
20064 + struct pollfd *tmp_pfd;
20065 + struct irq_fd *new_fd, *irq_fd;
20066 + unsigned long flags;
20067 + int pid, events, err, n, size;
20069 + pid = os_getpid();
20070 + err = os_set_fd_async(fd, pid);
20074 + new_fd = um_kmalloc(sizeof(*new_fd));
20076 + if(new_fd == NULL)
20079 + if(type == IRQ_READ) events = POLLIN | POLLPRI;
20080 + else events = POLLOUT;
20081 + *new_fd = ((struct irq_fd) { .next = NULL,
20087 + .events = events,
20088 + .current_events = 0,
20091 + /* Critical section - locked by a spinlock because this stuff can
20092 + * be changed from interrupt handlers. The stuff above is done
20093 + * outside the lock because it allocates memory.
20096 + /* Actually, it only looks like it can be called from interrupt
20097 + * context. The culprit is reactivate_fd, which calls
20098 + * maybe_sigio_broken, which calls write_sigio_workaround,
20099 + * which calls activate_fd. However, write_sigio_workaround should
20100 + * only be called once, at boot time. That would make it clear that
20101 + * this is called only from process context, and can be locked with
20104 + flags = irq_lock();
20105 + for(irq_fd = active_fds; irq_fd != NULL; irq_fd = irq_fd->next){
20106 + if((irq_fd->fd == fd) && (irq_fd->type == type)){
20107 + printk("Registering fd %d twice\n", fd);
20108 + printk("Irqs : %d, %d\n", irq_fd->irq, irq);
20109 + printk("Ids : 0x%x, 0x%x\n", irq_fd->id, dev_id);
20115 + if(n == pollfds_size){
20117 + /* Here we have to drop the lock in order to call
20118 + * kmalloc, which might sleep. If something else
20119 + * came in and changed the pollfds array, we free
20120 + * the buffer and try again.
20122 + irq_unlock(flags);
20123 + size = (pollfds_num + 1) * sizeof(pollfds[0]);
20124 + tmp_pfd = um_kmalloc(size);
20125 + flags = irq_lock();
20126 + if(tmp_pfd == NULL)
20128 + if(n == pollfds_size)
20132 + if(pollfds != NULL){
20133 + memcpy(tmp_pfd, pollfds,
20134 + sizeof(pollfds[0]) * pollfds_size);
20137 + pollfds = tmp_pfd;
20141 + if(type == IRQ_WRITE)
20144 + pollfds[pollfds_num] = ((struct pollfd) { .fd = fd,
20145 + .events = events,
20149 + *last_irq_ptr = new_fd;
20150 + last_irq_ptr = &new_fd->next;
20152 + irq_unlock(flags);
20154 + /* This calls activate_fd, so it has to be outside the critical
20157 + maybe_sigio_broken(fd, type);
20162 + irq_unlock(flags);
20168 +static void free_irq_by_cb(int (*test)(struct irq_fd *, void *), void *arg)
20170 + struct irq_fd **prev;
20171 + unsigned long flags;
20174 + flags = irq_lock();
20175 + prev = &active_fds;
20176 + while(*prev != NULL){
20177 + if((*test)(*prev, arg)){
20178 + struct irq_fd *old_fd = *prev;
20179 + if((pollfds[i].fd != -1) &&
20180 + (pollfds[i].fd != (*prev)->fd)){
20181 + printk("free_irq_by_cb - mismatch between "
20182 + "active_fds and pollfds, fd %d vs %d\n",
20183 + (*prev)->fd, pollfds[i].fd);
20186 + memcpy(&pollfds[i], &pollfds[i + 1],
20187 + (pollfds_num - i - 1) * sizeof(pollfds[0]));
20189 + if(last_irq_ptr == &old_fd->next)
20190 + last_irq_ptr = prev;
20191 + *prev = (*prev)->next;
20192 + if(old_fd->type == IRQ_WRITE)
20193 + ignore_sigio_fd(old_fd->fd);
20197 + prev = &(*prev)->next;
20201 + irq_unlock(flags);
20204 +struct irq_and_dev {
20209 +static int same_irq_and_dev(struct irq_fd *irq, void *d)
20211 + struct irq_and_dev *data = d;
20213 + return((irq->irq == data->irq) && (irq->id == data->dev));
20216 +void free_irq_by_irq_and_dev(int irq, void *dev)
20218 + struct irq_and_dev data = ((struct irq_and_dev) { .irq = irq,
20221 + free_irq_by_cb(same_irq_and_dev, &data);
20224 +static int same_fd(struct irq_fd *irq, void *fd)
20226 + return(irq->fd == *((int *) fd));
20229 +void free_irq_by_fd(int fd)
20231 + free_irq_by_cb(same_fd, &fd);
20234 +static struct irq_fd *find_irq_by_fd(int fd, int irqnum, int *index_out)
20236 + struct irq_fd *irq;
20239 + for(irq=active_fds; irq != NULL; irq = irq->next){
20240 + if((irq->fd == fd) && (irq->irq == irqnum)) break;
20244 + printk("find_irq_by_fd doesn't have descriptor %d\n", fd);
20247 + if((pollfds[i].fd != -1) && (pollfds[i].fd != fd)){
20248 + printk("find_irq_by_fd - mismatch between active_fds and "
20249 + "pollfds, fd %d vs %d, need %d\n", irq->fd,
20250 + pollfds[i].fd, fd);
20259 +void free_irq_later(int irq, void *dev_id)
20261 + struct irq_fd *irq_fd;
20262 + unsigned long flags;
20264 + flags = irq_lock();
20265 + for(irq_fd = active_fds; irq_fd != NULL; irq_fd = irq_fd->next){
20266 + if((irq_fd->irq == irq) && (irq_fd->id == dev_id))
20269 + if(irq_fd == NULL){
20270 + printk("free_irq_later found no irq, irq = %d, "
20271 + "dev_id = 0x%p\n", irq, dev_id);
20274 + irq_fd->freed = 1;
20276 + irq_unlock(flags);
20279 +void reactivate_fd(int fd, int irqnum)
20281 + struct irq_fd *irq;
20282 + unsigned long flags;
20285 + flags = irq_lock();
20286 + irq = find_irq_by_fd(fd, irqnum, &i);
20288 + irq_unlock(flags);
20292 + pollfds[i].fd = irq->fd;
20294 + irq_unlock(flags);
20296 + /* This calls activate_fd, so it has to be outside the critical
20299 + maybe_sigio_broken(fd, irq->type);
20302 +void deactivate_fd(int fd, int irqnum)
20304 + struct irq_fd *irq;
20305 + unsigned long flags;
20308 + flags = irq_lock();
20309 + irq = find_irq_by_fd(fd, irqnum, &i);
20312 + pollfds[i].fd = -1;
20314 + irq_unlock(flags);
20317 +void forward_ipi(int fd, int pid)
20321 + err = os_set_owner(fd, pid);
20323 + printk("forward_ipi: set_owner failed, fd = %d, me = %d, "
20324 + "target = %d, err = %d\n", fd, os_getpid(), pid, -err);
20327 +void forward_interrupts(int pid)
20329 + struct irq_fd *irq;
20330 + unsigned long flags;
20333 + flags = irq_lock();
20334 + for(irq=active_fds;irq != NULL;irq = irq->next){
20335 + err = os_set_owner(irq->fd, pid);
20337 + /* XXX Just remove the irq rather than
20338 + * print out an infinite stream of these
20340 + printk("Failed to forward %d to pid %d, err = %d\n",
20341 + irq->fd, pid, -err);
20346 + irq_unlock(flags);
20349 +void init_irq_signals(int on_sigstack)
20351 + __sighandler_t h;
20354 + flags = on_sigstack ? SA_ONSTACK : 0;
20355 + if(timer_irq_inited) h = (__sighandler_t) alarm_handler;
20356 + else h = boot_timer_handler;
20358 + set_handler(SIGVTALRM, h, flags | SA_RESTART,
20359 + SIGUSR1, SIGIO, SIGWINCH, SIGALRM, -1);
20360 + set_handler(SIGIO, (__sighandler_t) sig_handler, flags | SA_RESTART,
20361 + SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
20362 + signal(SIGWINCH, SIG_IGN);
20366 + * Overrides for Emacs so that we follow Linus's tabbing style.
20367 + * Emacs will notice this stuff at the end of the file and automatically
20368 + * adjust the settings for this buffer only. This must remain at the end
20370 + * ---------------------------------------------------------------------------
20371 + * Local variables:
20372 + * c-file-style: "linux"
20375 diff -Naur -X ../exclude-files orig/arch/um/kernel/ksyms.c um/arch/um/kernel/ksyms.c
20376 --- orig/arch/um/kernel/ksyms.c 1969-12-31 19:00:00.000000000 -0500
20377 +++ um/arch/um/kernel/ksyms.c 2004-01-23 00:44:09.000000000 -0500
20380 + * Copyright (C) 2001 - 2003 Jeff Dike (jdike@addtoit.com)
20381 + * Licensed under the GPL
20384 +#include "linux/config.h"
20385 +#include "linux/module.h"
20386 +#include "linux/string.h"
20387 +#include "linux/smp_lock.h"
20388 +#include "linux/spinlock.h"
20389 +#include "asm/current.h"
20390 +#include "asm/delay.h"
20391 +#include "asm/processor.h"
20392 +#include "asm/unistd.h"
20393 +#include "asm/pgalloc.h"
20394 +#include "asm/pgtable.h"
20395 +#include "asm/page.h"
20396 +#include "kern_util.h"
20397 +#include "user_util.h"
20399 +#include "helper.h"
20401 +EXPORT_SYMBOL(stop);
20402 +EXPORT_SYMBOL(strtok);
20403 +EXPORT_SYMBOL(uml_physmem);
20404 +EXPORT_SYMBOL(set_signals);
20405 +EXPORT_SYMBOL(get_signals);
20406 +EXPORT_SYMBOL(kernel_thread);
20407 +EXPORT_SYMBOL(__const_udelay);
20408 +EXPORT_SYMBOL(__udelay);
20409 +EXPORT_SYMBOL(sys_waitpid);
20410 +EXPORT_SYMBOL(task_size);
20411 +EXPORT_SYMBOL(flush_tlb_range);
20412 +EXPORT_SYMBOL(host_task_size);
20413 +EXPORT_SYMBOL(arch_validate);
20414 +EXPORT_SYMBOL(get_kmem_end);
20416 +EXPORT_SYMBOL(high_physmem);
20417 +EXPORT_SYMBOL(empty_zero_page);
20418 +EXPORT_SYMBOL(um_virt_to_phys);
20419 +EXPORT_SYMBOL(__virt_to_page);
20420 +EXPORT_SYMBOL(to_phys);
20421 +EXPORT_SYMBOL(to_virt);
20422 +EXPORT_SYMBOL(mode_tt);
20423 +EXPORT_SYMBOL(handle_page_fault);
20425 +#ifdef CONFIG_MODE_TT
20426 +EXPORT_SYMBOL(copy_from_user_tt);
20427 +EXPORT_SYMBOL(copy_to_user_tt);
20430 +#ifdef CONFIG_MODE_SKAS
20431 +EXPORT_SYMBOL(copy_to_user_skas);
20432 +EXPORT_SYMBOL(copy_from_user_skas);
20435 +EXPORT_SYMBOL(os_stat_fd);
20436 +EXPORT_SYMBOL(os_stat_file);
20437 +EXPORT_SYMBOL(os_access);
20438 +EXPORT_SYMBOL(os_print_error);
20439 +EXPORT_SYMBOL(os_get_exec_close);
20440 +EXPORT_SYMBOL(os_set_exec_close);
20441 +EXPORT_SYMBOL(os_getpid);
20442 +EXPORT_SYMBOL(os_open_file);
20443 +EXPORT_SYMBOL(os_read_file);
20444 +EXPORT_SYMBOL(os_write_file);
20445 +EXPORT_SYMBOL(os_seek_file);
20446 +EXPORT_SYMBOL(os_lock_file);
20447 +EXPORT_SYMBOL(os_pipe);
20448 +EXPORT_SYMBOL(os_file_type);
20449 +EXPORT_SYMBOL(os_file_mode);
20450 +EXPORT_SYMBOL(os_file_size);
20451 +EXPORT_SYMBOL(os_flush_stdout);
20452 +EXPORT_SYMBOL(os_close_file);
20453 +EXPORT_SYMBOL(os_set_fd_async);
20454 +EXPORT_SYMBOL(os_set_fd_block);
20455 +EXPORT_SYMBOL(helper_wait);
20456 +EXPORT_SYMBOL(os_shutdown_socket);
20457 +EXPORT_SYMBOL(os_create_unix_socket);
20458 +EXPORT_SYMBOL(os_connect_socket);
20459 +EXPORT_SYMBOL(os_accept_connection);
20460 +EXPORT_SYMBOL(os_ioctl_generic);
20461 +EXPORT_SYMBOL(os_rcv_fd);
20462 +EXPORT_SYMBOL(run_helper);
20463 +EXPORT_SYMBOL(start_thread);
20464 +EXPORT_SYMBOL(dump_thread);
20466 +/* This is here because UML expands open to sys_open, not to a system
20467 + * call instruction.
20469 +EXPORT_SYMBOL(sys_open);
20470 +EXPORT_SYMBOL(sys_lseek);
20471 +EXPORT_SYMBOL(sys_read);
20472 +EXPORT_SYMBOL(sys_wait4);
20476 +/* required for SMP */
20478 +extern void FASTCALL( __write_lock_failed(rwlock_t *rw));
20479 +EXPORT_SYMBOL_NOVERS(__write_lock_failed);
20481 +extern void FASTCALL( __read_lock_failed(rwlock_t *rw));
20482 +EXPORT_SYMBOL_NOVERS(__read_lock_failed);
20484 +EXPORT_SYMBOL(kernel_flag_cacheline);
20485 +EXPORT_SYMBOL(smp_num_cpus);
20490 + * Overrides for Emacs so that we follow Linus's tabbing style.
20491 + * Emacs will notice this stuff at the end of the file and automatically
20492 + * adjust the settings for this buffer only. This must remain at the end
20494 + * ---------------------------------------------------------------------------
20495 + * Local variables:
20496 + * c-file-style: "linux"
20499 diff -Naur -X ../exclude-files orig/arch/um/kernel/Makefile um/arch/um/kernel/Makefile
20500 --- orig/arch/um/kernel/Makefile 1969-12-31 19:00:00.000000000 -0500
20501 +++ um/arch/um/kernel/Makefile 2003-10-21 03:26:06.000000000 -0400
20504 +# Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
20505 +# Licensed under the GPL
20508 +O_TARGET = built-in.o
20510 +obj-y = config.o checksum.o exec_kern.o exitcode.o frame_kern.o frame.o \
20511 + helper.o init_task.o irq.o irq_user.o ksyms.o mem.o mem_user.o \
20512 + physmem.o process.o process_kern.o ptrace.o reboot.o resource.o \
20513 + sigio_user.o sigio_kern.o signal_kern.o signal_user.o smp.o \
20514 + syscall_kern.o syscall_user.o sysrq.o sys_call_table.o tempfile.o \
20515 + time.o time_kern.o tlb.o trap_kern.o trap_user.o uaccess_user.o \
20516 + um_arch.o umid.o user_syms.o user_util.o
20518 +obj-$(CONFIG_BLK_DEV_INITRD) += initrd_kern.o initrd_user.o
20519 +obj-$(CONFIG_GPROF) += gprof_syms.o
20520 +obj-$(CONFIG_GCOV) += gmon_syms.o
20521 +obj-$(CONFIG_TTY_LOG) += tty_log.o
20523 +subdir-$(CONFIG_MODE_TT) += tt
20524 +subdir-$(CONFIG_MODE_SKAS) += skas
20526 +user-objs-$(CONFIG_TTY_LOG) += tty_log.o
20528 +obj-y += $(join $(subdir-y),$(subdir-y:%=/%.o))
20530 +# user_syms.o not included here because Rules.make has its own ideas about
20531 +# building anything in export-objs
20533 +USER_OBJS = $(filter %_user.o,$(obj-y)) $(user-objs-y) config.o helper.o \
20534 + process.o tempfile.o time.o umid.o user_util.o
20536 +DMODULES-$(CONFIG_MODULES) = -D__CONFIG_MODULES__
20537 +DMODVERSIONS-$(CONFIG_MODVERSIONS) = -D__CONFIG_MODVERSIONS__
20539 +export-objs-$(CONFIG_GPROF) += gprof_syms.o
20540 +export-objs-$(CONFIG_GCOV) += gmon_syms.o
20542 +export-objs = ksyms.o process_kern.o signal_kern.o user_syms.o $(export-objs-y)
20544 +CFLAGS_user_syms.o = -D__AUTOCONF_INCLUDED__ $(DMODULES-y) $(DMODVERSIONS-y) \
20545 + -I/usr/include -I../include
20547 +CFLAGS_frame.o := $(patsubst -fomit-frame-pointer,,$(USER_CFLAGS))
20549 +include $(TOPDIR)/Rules.make
20551 +$(USER_OBJS) : %.o: %.c
20552 + $(CC) $(CFLAGS_$@) $(USER_CFLAGS) -c -o $@ $<
20554 +# This has to be separate because it needs be compiled with frame pointers
20555 +# regardless of how the rest of the kernel is built.
20558 + $(CC) $(CFLAGS_$@) -c -o $@ $<
20560 +QUOTE = 'my $$config=`cat $(TOPDIR)/.config`; $$config =~ s/"/\\"/g ; $$config =~ s/\n/\\n"\n"/g ; while(<STDIN>) { $$_ =~ s/CONFIG/$$config/; print $$_ }'
20562 +config.c : config.c.in $(TOPDIR)/.config
20563 + $(PERL) -e $(QUOTE) < config.c.in > $@
20567 + for dir in $(subdir-y) ; do $(MAKE) -C $$dir clean; done
20575 +archmrproper: clean
20576 diff -Naur -X ../exclude-files orig/arch/um/kernel/mem.c um/arch/um/kernel/mem.c
20577 --- orig/arch/um/kernel/mem.c 1969-12-31 19:00:00.000000000 -0500
20578 +++ um/arch/um/kernel/mem.c 2003-12-22 01:25:00.000000000 -0500
20581 + * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
20582 + * Licensed under the GPL
20585 +#include "linux/stddef.h"
20586 +#include "linux/kernel.h"
20587 +#include "linux/mm.h"
20588 +#include "linux/bootmem.h"
20589 +#include "linux/highmem.h"
20590 +#include "asm/page.h"
20591 +#include "asm/fixmap.h"
20592 +#include "asm/pgalloc.h"
20593 +#include "user_util.h"
20594 +#include "kern_util.h"
20596 +#include "mem_user.h"
20597 +#include "uml_uaccess.h"
20600 +extern char __binary_start;
20602 +/* Changed during early boot */
20603 +unsigned long *empty_zero_page = NULL;
20604 +unsigned long *empty_bad_page = NULL;
20605 +pgd_t swapper_pg_dir[1024];
20606 +unsigned long highmem;
20607 +int kmalloc_ok = 0;
20609 +static unsigned long brk_end;
20610 +static unsigned long totalram_pages = 0;
20612 +void unmap_physmem(void)
20614 + os_unmap_memory((void *) brk_end, uml_reserved - brk_end);
20617 +static void map_cb(void *unused)
20619 + map_memory(brk_end, __pa(brk_end), uml_reserved - brk_end, 1, 1, 0);
20622 +#ifdef CONFIG_HIGHMEM
20623 +static void setup_highmem(unsigned long highmem_start,
20624 + unsigned long highmem_len)
20626 + struct page *page;
20627 + unsigned long highmem_pfn;
20630 + highmem_start_page = virt_to_page(highmem_start);
20632 + highmem_pfn = __pa(highmem_start) >> PAGE_SHIFT;
20633 + for(i = 0; i < highmem_len >> PAGE_SHIFT; i++){
20634 + page = &mem_map[highmem_pfn + i];
20635 + ClearPageReserved(page);
20636 + set_bit(PG_highmem, &page->flags);
20637 + atomic_set(&page->count, 1);
20638 + __free_page(page);
20643 +void mem_init(void)
20645 + unsigned long start;
20647 + /* clear the zero-page */
20648 + memset((void *) empty_zero_page, 0, PAGE_SIZE);
20650 + /* Map in the area just after the brk now that kmalloc is about
20651 + * to be turned on.
20653 + brk_end = (unsigned long) UML_ROUND_UP(sbrk(0));
20655 + initial_thread_cb(map_cb, NULL);
20656 + free_bootmem(__pa(brk_end), uml_reserved - brk_end);
20657 + uml_reserved = brk_end;
20659 + /* Fill in any hole at the start of the binary */
20660 + start = (unsigned long) &__binary_start;
20661 + if(uml_physmem != start){
20662 + map_memory(uml_physmem, __pa(uml_physmem), start - uml_physmem,
20666 + /* this will put all low memory onto the freelists */
20667 + totalram_pages = free_all_bootmem();
20668 + totalram_pages += highmem >> PAGE_SHIFT;
20669 + num_physpages = totalram_pages;
20670 + printk(KERN_INFO "Memory: %luk available\n",
20671 + (unsigned long) nr_free_pages() << (PAGE_SHIFT-10));
20674 +#ifdef CONFIG_HIGHMEM
20675 + setup_highmem(end_iomem, highmem);
20679 +static void __init fixrange_init(unsigned long start, unsigned long end,
20686 + unsigned long vaddr;
20689 + i = __pgd_offset(vaddr);
20690 + j = __pmd_offset(vaddr);
20691 + pgd = pgd_base + i;
20693 + for ( ; (i < PTRS_PER_PGD) && (vaddr < end); pgd++, i++) {
20694 + pmd = (pmd_t *)pgd;
20695 + for (; (j < PTRS_PER_PMD) && (vaddr != end); pmd++, j++) {
20696 + if (pmd_none(*pmd)) {
20697 + pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
20698 + set_pmd(pmd, __pmd(_KERNPG_TABLE +
20699 + (unsigned long) __pa(pte)));
20700 + if (pte != pte_offset(pmd, 0))
20703 + vaddr += PMD_SIZE;
20709 +#ifdef CONFIG_HIGHMEM
20711 +pgprot_t kmap_prot;
20713 +#define kmap_get_fixmap_pte(vaddr) \
20714 + pte_offset(pmd_offset(pgd_offset_k(vaddr), (vaddr)), (vaddr))
20716 +void __init kmap_init(void)
20718 + unsigned long kmap_vstart;
20720 + /* cache the first kmap pte */
20721 + kmap_vstart = __fix_to_virt(FIX_KMAP_BEGIN);
20722 + kmap_pte = kmap_get_fixmap_pte(kmap_vstart);
20724 + kmap_prot = PAGE_KERNEL;
20727 +static void init_highmem(void)
20732 + unsigned long vaddr;
20735 + * Permanent kmaps:
20737 + vaddr = PKMAP_BASE;
20738 + fixrange_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, swapper_pg_dir);
20740 + pgd = swapper_pg_dir + __pgd_offset(vaddr);
20741 + pmd = pmd_offset(pgd, vaddr);
20742 + pte = pte_offset(pmd, vaddr);
20743 + pkmap_page_table = pte;
20748 +#endif /* CONFIG_HIGHMEM */
20750 +void paging_init(void)
20752 + unsigned long zones_size[MAX_NR_ZONES], vaddr;
20755 + empty_zero_page = (unsigned long *) alloc_bootmem_low_pages(PAGE_SIZE);
20756 + empty_bad_page = (unsigned long *) alloc_bootmem_low_pages(PAGE_SIZE);
20757 + for(i=0;i<sizeof(zones_size)/sizeof(zones_size[0]);i++)
20758 + zones_size[i] = 0;
20759 + zones_size[0] = (end_iomem >> PAGE_SHIFT) - (uml_physmem >> PAGE_SHIFT);
20760 + zones_size[2] = highmem >> PAGE_SHIFT;
20761 + free_area_init(zones_size);
20764 + * Fixed mappings, only the page table structure has to be
20765 + * created - mappings will be set by set_fixmap():
20767 + vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK;
20768 + fixrange_init(vaddr, FIXADDR_TOP, swapper_pg_dir);
20770 +#if CONFIG_HIGHMEM
20775 +struct page *arch_validate(struct page *page, int mask, int order)
20777 + unsigned long addr, zero = 0;
20781 + if(page == NULL) return(page);
20782 + if(PageHighMem(page)) return(page);
20784 + addr = (unsigned long) page_address(page);
20785 + for(i = 0; i < (1 << order); i++){
20786 + current->thread.fault_addr = (void *) addr;
20787 + if(__do_copy_to_user((void *) addr, &zero,
20789 + ¤t->thread.fault_addr,
20790 + ¤t->thread.fault_catcher)){
20791 + if(!(mask & __GFP_WAIT)) return(NULL);
20794 + addr += PAGE_SIZE;
20796 + if(i == (1 << order)) return(page);
20797 + page = _alloc_pages(mask, order);
20801 +/* This can't do anything because nothing in the kernel image can be freed
20802 + * since it's not in kernel physical memory.
20805 +void free_initmem(void)
20809 +#ifdef CONFIG_BLK_DEV_INITRD
20811 +void free_initrd_mem(unsigned long start, unsigned long end)
20814 + printk ("Freeing initrd memory: %ldk freed\n",
20815 + (end - start) >> 10);
20816 + for (; start < end; start += PAGE_SIZE) {
20817 + ClearPageReserved(virt_to_page(start));
20818 + set_page_count(virt_to_page(start), 1);
20819 + free_page(start);
20820 + totalram_pages++;
20826 +int do_check_pgt_cache(int low, int high)
20829 + if(pgtable_cache_size > high) {
20831 + if (pgd_quicklist) {
20832 + free_pgd_slow(get_pgd_fast());
20835 + if (pmd_quicklist) {
20836 + pmd_free_slow(pmd_alloc_one_fast(NULL, 0));
20839 + if (pte_quicklist) {
20840 + pte_free_slow(pte_alloc_one_fast(NULL, 0));
20843 + } while(pgtable_cache_size > low);
20848 +void show_mem(void)
20850 + int i, total = 0, reserved = 0;
20851 + int shared = 0, cached = 0;
20854 + printk("Mem-info:\n");
20855 + show_free_areas();
20856 + printk("Free swap: %6dkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
20860 + if(PageHighMem(mem_map + i))
20862 + if(PageReserved(mem_map + i))
20864 + else if(PageSwapCache(mem_map + i))
20866 + else if(page_count(mem_map + i))
20867 + shared += page_count(mem_map + i) - 1;
20869 + printk("%d pages of RAM\n", total);
20870 + printk("%d pages of HIGHMEM\n", highmem);
20871 + printk("%d reserved pages\n", reserved);
20872 + printk("%d pages shared\n", shared);
20873 + printk("%d pages swap cached\n", cached);
20874 + printk("%ld pages in page table cache\n", pgtable_cache_size);
20878 +/* Changed by meminfo_compat, which is a setup */
20879 +static int meminfo_22 = 0;
20881 +static int meminfo_compat(char *str)
20887 +__setup("22_meminfo", meminfo_compat);
20889 +void si_meminfo(struct sysinfo *val)
20891 + val->totalram = totalram_pages;
20892 + val->sharedram = 0;
20893 + val->freeram = nr_free_pages();
20894 + val->bufferram = atomic_read(&buffermem_pages);
20895 + val->totalhigh = highmem >> PAGE_SHIFT;
20896 + val->freehigh = nr_free_highpages();
20897 + val->mem_unit = PAGE_SIZE;
20899 + val->freeram <<= PAGE_SHIFT;
20900 + val->bufferram <<= PAGE_SHIFT;
20901 + val->totalram <<= PAGE_SHIFT;
20902 + val->sharedram <<= PAGE_SHIFT;
20907 + * Overrides for Emacs so that we follow Linus's tabbing style.
20908 + * Emacs will notice this stuff at the end of the file and automatically
20909 + * adjust the settings for this buffer only. This must remain at the end
20911 + * ---------------------------------------------------------------------------
20912 + * Local variables:
20913 + * c-file-style: "linux"
20916 diff -Naur -X ../exclude-files orig/arch/um/kernel/mem_user.c um/arch/um/kernel/mem_user.c
20917 --- orig/arch/um/kernel/mem_user.c 1969-12-31 19:00:00.000000000 -0500
20918 +++ um/arch/um/kernel/mem_user.c 2004-01-10 00:19:09.000000000 -0500
20921 + * arch/um/kernel/mem_user.c
20923 + * BRIEF MODULE DESCRIPTION
20924 + * user side memory routines for supporting IO memory inside user mode linux
20926 + * Copyright (C) 2001 RidgeRun, Inc.
20927 + * Author: RidgeRun, Inc.
20928 + * Greg Lonnon glonnon@ridgerun.com or info@ridgerun.com
20930 + * This program is free software; you can redistribute it and/or modify it
20931 + * under the terms of the GNU General Public License as published by the
20932 + * Free Software Foundation; either version 2 of the License, or (at your
20933 + * option) any later version.
20935 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
20936 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20937 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
20938 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20939 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20940 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
20941 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20942 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20943 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
20944 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20946 + * You should have received a copy of the GNU General Public License along
20947 + * with this program; if not, write to the Free Software Foundation, Inc.,
20948 + * 675 Mass Ave, Cambridge, MA 02139, USA.
20951 +#include <stdio.h>
20952 +#include <stdlib.h>
20953 +#include <stddef.h>
20954 +#include <stdarg.h>
20955 +#include <unistd.h>
20956 +#include <errno.h>
20957 +#include <string.h>
20958 +#include <fcntl.h>
20959 +#include <sys/types.h>
20960 +#include <sys/mman.h>
20961 +#include "kern_util.h"
20963 +#include "user_util.h"
20964 +#include "mem_user.h"
20967 +#include "tempfile.h"
20968 +#include "kern_constants.h"
20970 +extern struct mem_region physmem_region;
20972 +#define TEMPNAME_TEMPLATE "vm_file-XXXXXX"
20974 +static int create_tmp_file(unsigned long len)
20979 + fd = make_tempfile(TEMPNAME_TEMPLATE, NULL, 1);
20981 + os_print_error(fd, "make_tempfile");
20985 + err = os_mode_fd(fd, 0777);
20987 + os_print_error(err, "os_mode_fd");
20990 + err = os_seek_file(fd, len);
20992 + os_print_error(err, "os_seek_file");
20996 + err = os_write_file(fd, &zero, 1);
20998 + os_print_error(err, "os_write_file");
21005 +static int have_devanon(void)
21009 + printk("Checking for /dev/anon on the host...");
21010 + fd = open("/dev/anon", O_RDWR);
21012 + printk("Not available (open failed with errno %d)\n", errno);
21020 +static int create_anon_file(unsigned long len)
21025 + fd = open("/dev/anon", O_RDWR);
21027 + os_print_error(fd, "opening /dev/anon");
21031 + addr = mmap(NULL, len, PROT_READ | PROT_WRITE , MAP_PRIVATE, fd, 0);
21032 + if(addr == MAP_FAILED){
21033 + os_print_error((int) addr, "mapping physmem file");
21036 + munmap(addr, len);
21041 +int create_mem_file(unsigned long len)
21045 + if(have_devanon())
21046 + fd = create_anon_file(len);
21047 + else fd = create_tmp_file(len);
21049 + err = os_set_exec_close(fd, 1);
21051 + os_print_error(err, "exec_close");
21055 +struct iomem_region *iomem_regions = NULL;
21056 +int iomem_size = 0;
21058 +static int __init parse_iomem(char *str, int *add)
21060 + struct iomem_region *new;
21061 + struct uml_stat buf;
21062 + char *file, *driver;
21066 + file = strchr(str,',');
21067 + if(file == NULL){
21068 + printf("parse_iomem : failed to parse iomem\n");
21073 + fd = os_open_file(file, of_rdwr(OPENFLAGS()), 0);
21075 + os_print_error(fd, "parse_iomem - Couldn't open io file");
21079 + err = os_stat_fd(fd, &buf);
21081 + os_print_error(err, "parse_iomem - cannot stat_fd file");
21085 + new = malloc(sizeof(*new));
21087 + perror("Couldn't allocate iomem_region struct");
21091 + *new = ((struct iomem_region) { .next = iomem_regions,
21092 + .driver = driver,
21094 + .size = buf.ust_size,
21097 + iomem_regions = new;
21098 + iomem_size += new->size + UM_KERN_PAGE_SIZE;
21102 + os_close_file(fd);
21107 +__uml_setup("iomem=", parse_iomem,
21108 +"iomem=<name>,<file>\n"
21109 +" Configure <file> as an IO memory region named <name>.\n\n"
21112 +int protect_memory(unsigned long addr, unsigned long len, int r, int w, int x,
21113 + int must_succeed)
21117 + err = os_protect_memory((void *) addr, len, r, w, x);
21120 + panic("protect failed, err = %d", -err);
21121 + else return(err);
21127 + * Overrides for Emacs so that we follow Linus's tabbing style.
21128 + * Emacs will notice this stuff at the end of the file and automatically
21129 + * adjust the settings for this buffer only. This must remain at the end
21131 + * ---------------------------------------------------------------------------
21132 + * Local variables:
21133 + * c-file-style: "linux"
21136 diff -Naur -X ../exclude-files orig/arch/um/kernel/mprot.h um/arch/um/kernel/mprot.h
21137 --- orig/arch/um/kernel/mprot.h 1969-12-31 19:00:00.000000000 -0500
21138 +++ um/arch/um/kernel/mprot.h 2003-10-21 03:26:06.000000000 -0400
21140 +#ifndef __MPROT_H__
21141 +#define __MPROT_H__
21143 +extern void no_access(unsigned long addr, unsigned int len);
21146 diff -Naur -X ../exclude-files orig/arch/um/kernel/physmem.c um/arch/um/kernel/physmem.c
21147 --- orig/arch/um/kernel/physmem.c 1969-12-31 19:00:00.000000000 -0500
21148 +++ um/arch/um/kernel/physmem.c 2004-01-16 23:38:02.000000000 -0500
21151 + * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
21152 + * Licensed under the GPL
21155 +#include "linux/mm.h"
21156 +#include "linux/ghash.h"
21157 +#include "linux/slab.h"
21158 +#include "linux/vmalloc.h"
21159 +#include "linux/bootmem.h"
21160 +#include "asm/types.h"
21161 +#include "asm/pgtable.h"
21162 +#include "kern_util.h"
21163 +#include "user_util.h"
21164 +#include "mode_kern.h"
21166 +#include "mem_user.h"
21171 +#define PHYS_HASHSIZE (8192)
21175 +DEF_HASH_STRUCTS(virtmem, PHYS_HASHSIZE, struct phys_desc);
21177 +struct phys_desc {
21178 + struct virtmem_ptrs virt_ptrs;
21182 + unsigned long phys;
21183 + struct list_head list;
21186 +struct virtmem_table virtmem_hash;
21188 +static int virt_cmp(void *virt1, void *virt2)
21190 + return(virt1 != virt2);
21193 +static int virt_hash(void *virt)
21195 + unsigned long addr = ((unsigned long) virt) >> PAGE_SHIFT;
21196 + return(addr % PHYS_HASHSIZE);
21199 +DEF_HASH(static, virtmem, struct phys_desc, virt_ptrs, void *, virt, virt_cmp,
21202 +LIST_HEAD(descriptor_mappings);
21204 +struct desc_mapping {
21206 + struct list_head list;
21207 + struct list_head pages;
21210 +static struct desc_mapping *find_mapping(int fd)
21212 + struct desc_mapping *desc;
21213 + struct list_head *ele;
21215 + list_for_each(ele, &descriptor_mappings){
21216 + desc = list_entry(ele, struct desc_mapping, list);
21217 + if(desc->fd == fd)
21224 +static struct desc_mapping *descriptor_mapping(int fd)
21226 + struct desc_mapping *desc;
21228 + desc = find_mapping(fd);
21232 + desc = kmalloc(sizeof(*desc), GFP_ATOMIC);
21236 + *desc = ((struct desc_mapping)
21238 + .list = LIST_HEAD_INIT(desc->list),
21239 + .pages = LIST_HEAD_INIT(desc->pages) });
21240 + list_add(&desc->list, &descriptor_mappings);
21245 +int physmem_subst_mapping(void *virt, int fd, __u64 offset, int w)
21247 + struct desc_mapping *fd_maps;
21248 + struct phys_desc *desc;
21249 + unsigned long phys;
21252 + fd_maps = descriptor_mapping(fd);
21253 + if(fd_maps == NULL)
21256 + phys = __pa(virt);
21257 + if(find_virtmem_hash(&virtmem_hash, virt) != NULL)
21258 + panic("Address 0x%p is already substituted\n", virt);
21261 + desc = kmalloc(sizeof(*desc), GFP_ATOMIC);
21265 + *desc = ((struct phys_desc)
21266 + { .virt_ptrs = { NULL, NULL },
21268 + .offset = offset,
21270 + .phys = __pa(virt),
21271 + .list = LIST_HEAD_INIT(desc->list) });
21272 + insert_virtmem_hash(&virtmem_hash, desc);
21274 + list_add(&desc->list, &fd_maps->pages);
21276 + virt = (void *) ((unsigned long) virt & PAGE_MASK);
21277 + err = os_map_memory(virt, fd, offset, PAGE_SIZE, 1, w, 0);
21281 + remove_virtmem_hash(&virtmem_hash, desc);
21287 +static int physmem_fd = -1;
21289 +static void remove_mapping(struct phys_desc *desc)
21291 + void *virt = desc->virt;
21294 + remove_virtmem_hash(&virtmem_hash, desc);
21295 + list_del(&desc->list);
21298 + err = os_map_memory(virt, physmem_fd, __pa(virt), PAGE_SIZE, 1, 1, 0);
21300 + panic("Failed to unmap block device page from physical memory, "
21301 + "errno = %d", -err);
21304 +int physmem_remove_mapping(void *virt)
21306 + struct phys_desc *desc;
21308 + virt = (void *) ((unsigned long) virt & PAGE_MASK);
21309 + desc = find_virtmem_hash(&virtmem_hash, virt);
21313 + remove_mapping(desc);
21317 +void physmem_forget_descriptor(int fd)
21319 + struct desc_mapping *desc;
21320 + struct phys_desc *page;
21321 + struct list_head *ele, *next;
21326 + desc = find_mapping(fd);
21330 + list_for_each_safe(ele, next, &desc->pages){
21331 + page = list_entry(ele, struct phys_desc, list);
21332 + offset = page->offset;
21333 + addr = page->virt;
21334 + remove_mapping(page);
21335 + err = os_seek_file(fd, offset);
21337 + panic("physmem_forget_descriptor - failed to seek "
21338 + "to %lld in fd %d, error = %d\n",
21339 + offset, fd, -err);
21340 + err = os_read_file(fd, addr, PAGE_SIZE);
21342 + panic("physmem_forget_descriptor - failed to read "
21343 + "from fd %d to 0x%p, error = %d\n",
21347 + list_del(&desc->list);
21351 +void arch_free_page(struct page *page, int order)
21356 + for(i = 0; i < (1 << order); i++){
21357 + virt = __va(page_to_phys(page + i));
21358 + physmem_remove_mapping(virt);
21362 +int is_remapped(void *virt)
21364 + return(find_virtmem_hash(&virtmem_hash, virt) != NULL);
21367 +/* Changed during early boot */
21368 +unsigned long high_physmem;
21370 +extern unsigned long physmem_size;
21372 +void *to_virt(unsigned long phys)
21374 + return((void *) uml_physmem + phys);
21377 +unsigned long to_phys(void *virt)
21379 + return(((unsigned long) virt) - uml_physmem);
21382 +int init_maps(unsigned long physmem, unsigned long iomem, unsigned long highmem)
21384 + struct page *p, *map;
21385 + unsigned long phys_len, phys_pages, highmem_len, highmem_pages;
21386 + unsigned long iomem_len, iomem_pages, total_len, total_pages;
21389 + phys_pages = physmem >> PAGE_SHIFT;
21390 + phys_len = phys_pages * sizeof(struct page);
21392 + iomem_pages = iomem >> PAGE_SHIFT;
21393 + iomem_len = iomem_pages * sizeof(struct page);
21395 + highmem_pages = highmem >> PAGE_SHIFT;
21396 + highmem_len = highmem_pages * sizeof(struct page);
21398 + total_pages = phys_pages + iomem_pages + highmem_pages;
21399 + total_len = phys_len + iomem_pages + highmem_len;
21402 + map = kmalloc(total_len, GFP_KERNEL);
21404 + map = vmalloc(total_len);
21406 + else map = alloc_bootmem_low_pages(total_len);
21411 + for(i = 0; i < total_pages; i++){
21413 + set_page_count(p, 0);
21414 + SetPageReserved(p);
21415 + INIT_LIST_HEAD(&p->list);
21419 + max_mapnr = total_pages;
21423 +struct page *phys_to_page(const unsigned long phys)
21425 + return(&mem_map[phys >> PAGE_SHIFT]);
21428 +struct page *__virt_to_page(const unsigned long virt)
21430 + return(&mem_map[__pa(virt) >> PAGE_SHIFT]);
21433 +unsigned long page_to_phys(struct page *page)
21435 + return((page - mem_map) << PAGE_SHIFT);
21438 +pte_t mk_pte(struct page *page, pgprot_t pgprot)
21442 + pte_val(pte) = page_to_phys(page) + pgprot_val(pgprot);
21443 + if(pte_present(pte)) pte_mknewprot(pte_mknewpage(pte));
21447 +/* Changed during early boot */
21448 +static unsigned long kmem_top = 0;
21450 +unsigned long get_kmem_end(void)
21452 + if(kmem_top == 0)
21453 + kmem_top = CHOOSE_MODE(kmem_end_tt, kmem_end_skas);
21454 + return(kmem_top);
21457 +void map_memory(unsigned long virt, unsigned long phys, unsigned long len,
21458 + int r, int w, int x)
21463 + fd = phys_mapping(phys, &offset);
21464 + err = os_map_memory((void *) virt, fd, offset, len, r, w, x);
21466 + panic("map_memory(0x%lx, %d, 0x%llx, %ld, %d, %d, %d) failed, "
21467 + "err = %d\n", virt, fd, offset, len, r, w, x, err);
21470 +#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
21472 +void setup_physmem(unsigned long start, unsigned long reserve_end,
21473 + unsigned long len, unsigned long highmem)
21475 + unsigned long reserve = reserve_end - start;
21476 + int pfn = PFN_UP(__pa(reserve_end));
21477 + int delta = (len - reserve) >> PAGE_SHIFT;
21478 + int err, offset, bootmap_size;
21480 + physmem_fd = create_mem_file(len + highmem);
21482 + offset = uml_reserved - uml_physmem;
21483 + err = os_map_memory((void *) uml_reserved, physmem_fd, offset,
21484 + len - offset, 1, 1, 0);
21486 + os_print_error(err, "Mapping memory");
21490 + bootmap_size = init_bootmem(pfn, pfn + delta);
21491 + free_bootmem(__pa(reserve_end) + bootmap_size,
21492 + len - bootmap_size - reserve);
21495 +int phys_mapping(unsigned long phys, __u64 *offset_out)
21497 + struct phys_desc *desc = find_virtmem_hash(&virtmem_hash,
21498 + __va(phys & PAGE_MASK));
21501 + if(desc != NULL){
21503 + *offset_out = desc->offset;
21505 + else if(phys < physmem_size){
21507 + *offset_out = phys;
21509 + else if(phys < __pa(end_iomem)){
21510 + struct iomem_region *region = iomem_regions;
21512 + while(region != NULL){
21513 + if((phys >= region->phys) &&
21514 + (phys < region->phys + region->size)){
21516 + *offset_out = phys - region->phys;
21519 + region = region->next;
21522 + else if(phys < __pa(end_iomem) + highmem){
21524 + *offset_out = phys - iomem_size;
21530 +static int __init uml_mem_setup(char *line, int *add)
21533 + physmem_size = memparse(line,&retptr);
21536 +__uml_setup("mem=", uml_mem_setup,
21537 +"mem=<Amount of desired ram>\n"
21538 +" This controls how much \"physical\" memory the kernel allocates\n"
21539 +" for the system. The size is specified as a number followed by\n"
21540 +" one of 'k', 'K', 'm', 'M', which have the obvious meanings.\n"
21541 +" This is not related to the amount of memory in the host. It can\n"
21542 +" be more, and the excess, if it's ever used, will just be swapped out.\n"
21543 +" Example: mem=64M\n\n"
21546 +unsigned long find_iomem(char *driver, unsigned long *len_out)
21548 + struct iomem_region *region = iomem_regions;
21550 + while(region != NULL){
21551 + if(!strcmp(region->driver, driver)){
21552 + *len_out = region->size;
21553 + return(region->virt);
21560 +int setup_iomem(void)
21562 + struct iomem_region *region = iomem_regions;
21563 + unsigned long iomem_start = high_physmem + PAGE_SIZE;
21566 + while(region != NULL){
21567 + err = os_map_memory((void *) iomem_start, region->fd, 0,
21568 + region->size, 1, 1, 0);
21570 + printk("Mapping iomem region for driver '%s' failed, "
21571 + "errno = %d\n", region->driver, -err);
21573 + region->virt = iomem_start;
21574 + region->phys = __pa(region->virt);
21577 + iomem_start += region->size + PAGE_SIZE;
21578 + region = region->next;
21584 +__initcall(setup_iomem);
21587 + * Overrides for Emacs so that we follow Linus's tabbing style.
21588 + * Emacs will notice this stuff at the end of the file and automatically
21589 + * adjust the settings for this buffer only. This must remain at the end
21591 + * ---------------------------------------------------------------------------
21592 + * Local variables:
21593 + * c-file-style: "linux"
21596 diff -Naur -X ../exclude-files orig/arch/um/kernel/process.c um/arch/um/kernel/process.c
21597 --- orig/arch/um/kernel/process.c 1969-12-31 19:00:00.000000000 -0500
21598 +++ um/arch/um/kernel/process.c 2004-01-31 02:47:57.000000000 -0500
21601 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
21602 + * Licensed under the GPL
21605 +#include <stdio.h>
21606 +#include <unistd.h>
21607 +#include <signal.h>
21608 +#include <sched.h>
21609 +#include <errno.h>
21610 +#include <stdarg.h>
21611 +#include <stdlib.h>
21612 +#include <setjmp.h>
21613 +#include <sys/time.h>
21614 +#include <sys/ptrace.h>
21615 +#include <sys/wait.h>
21616 +#include <sys/mman.h>
21617 +#include <asm/ptrace.h>
21618 +#include <asm/sigcontext.h>
21619 +#include <asm/unistd.h>
21620 +#include <asm/page.h>
21621 +#include "user_util.h"
21622 +#include "kern_util.h"
21624 +#include "process.h"
21625 +#include "signal_kern.h"
21626 +#include "signal_user.h"
21627 +#include "sysdep/ptrace.h"
21628 +#include "sysdep/sigcontext.h"
21629 +#include "irq_user.h"
21630 +#include "ptrace_user.h"
21631 +#include "time_user.h"
21634 +#include "uml-config.h"
21635 +#include "choose-mode.h"
21637 +#ifdef UML_CONFIG_MODE_SKAS
21639 +#include "skas_ptrace.h"
21642 +void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int))
21644 + int flags = 0, pages;
21646 + if(sig_stack != NULL){
21647 + pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER) - 2;
21648 + set_sigstack(sig_stack, pages * page_size());
21649 + flags = SA_ONSTACK;
21651 + if(usr1_handler) set_handler(SIGUSR1, usr1_handler, flags, -1);
21654 +void init_new_thread_signals(int altstack)
21656 + int flags = altstack ? SA_ONSTACK : 0;
21658 + /* NODEFER is set here because SEGV isn't turned back on when the
21659 + * handler is ready to receive signals. This causes any segfault
21660 + * during a copy_user to kill the process because the fault is blocked.
21662 + set_handler(SIGSEGV, (__sighandler_t) sig_handler, flags | SA_NODEFER,
21663 + SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
21664 + set_handler(SIGTRAP, (__sighandler_t) sig_handler, flags,
21665 + SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
21666 + set_handler(SIGFPE, (__sighandler_t) sig_handler, flags,
21667 + SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
21668 + set_handler(SIGILL, (__sighandler_t) sig_handler, flags,
21669 + SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
21670 + set_handler(SIGBUS, (__sighandler_t) sig_handler, flags,
21671 + SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
21672 + set_handler(SIGWINCH, (__sighandler_t) sig_handler, flags,
21673 + SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
21674 + set_handler(SIGUSR2, (__sighandler_t) sig_handler,
21675 + SA_NOMASK | flags, -1);
21676 + signal(SIGHUP, SIG_IGN);
21678 + init_irq_signals(altstack);
21682 + int (*tramp)(void *);
21683 + void *tramp_data;
21684 + unsigned long temp_stack;
21689 +/* See above for why sigkill is here */
21691 +int sigkill = SIGKILL;
21693 +int outer_tramp(void *arg)
21696 + int sig = sigkill;
21699 + t->pid = clone(t->tramp, (void *) t->temp_stack + page_size()/2,
21700 + t->flags, t->tramp_data);
21701 + if(t->pid > 0) wait_for_stop(t->pid, SIGSTOP, PTRACE_CONT, NULL);
21702 + kill(os_getpid(), sig);
21706 +int start_fork_tramp(void *thread_arg, unsigned long temp_stack,
21707 + int clone_flags, int (*tramp)(void *))
21709 + struct tramp arg;
21710 + unsigned long sp;
21711 + int new_pid, status, err;
21713 + /* The trampoline will run on the temporary stack */
21714 + sp = stack_sp(temp_stack);
21716 + clone_flags |= CLONE_FILES | SIGCHLD;
21718 + arg.tramp = tramp;
21719 + arg.tramp_data = thread_arg;
21720 + arg.temp_stack = temp_stack;
21721 + arg.flags = clone_flags;
21723 + /* Start the process and wait for it to kill itself */
21724 + new_pid = clone(outer_tramp, (void *) sp, clone_flags, &arg);
21725 + if(new_pid < 0) return(-errno);
21726 + while(((err = waitpid(new_pid, &status, 0)) < 0) && (errno == EINTR)) ;
21727 + if(err < 0) panic("Waiting for outer trampoline failed - errno = %d",
21729 + if(!WIFSIGNALED(status) || (WTERMSIG(status) != SIGKILL))
21730 + panic("outer trampoline didn't exit with SIGKILL, "
21731 + "status = %d", status);
21736 +void suspend_new_thread(int fd)
21740 + os_stop_process(os_getpid());
21742 + if(os_read_file(fd, &c, sizeof(c)) != sizeof(c))
21743 + panic("read failed in suspend_new_thread");
21746 +static int ptrace_child(void *arg)
21748 + int pid = os_getpid();
21750 + if(ptrace(PTRACE_TRACEME, 0, 0, 0) < 0){
21751 + perror("ptrace");
21752 + os_kill_process(pid, 0);
21754 + os_stop_process(pid);
21755 + _exit(os_getpid() == pid);
21758 +static int start_ptraced_child(void **stack_out)
21761 + unsigned long sp;
21762 + int pid, n, status;
21764 + stack = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC,
21765 + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
21766 + if(stack == MAP_FAILED)
21767 + panic("check_ptrace : mmap failed, errno = %d", errno);
21768 + sp = (unsigned long) stack + PAGE_SIZE - sizeof(void *);
21769 + pid = clone(ptrace_child, (void *) sp, SIGCHLD, NULL);
21771 + panic("check_ptrace : clone failed, errno = %d", errno);
21772 + n = waitpid(pid, &status, WUNTRACED);
21774 + panic("check_ptrace : wait failed, errno = %d", errno);
21775 + if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP))
21776 + panic("check_ptrace : expected SIGSTOP, got status = %d",
21779 + *stack_out = stack;
21783 +static void stop_ptraced_child(int pid, void *stack, int exitcode)
21787 + if(ptrace(PTRACE_CONT, pid, 0, 0) < 0)
21788 + panic("check_ptrace : ptrace failed, errno = %d", errno);
21789 + n = waitpid(pid, &status, 0);
21790 + if(!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode))
21791 + panic("check_ptrace : child exited with status 0x%x", status);
21793 + if(munmap(stack, PAGE_SIZE) < 0)
21794 + panic("check_ptrace : munmap failed, errno = %d", errno);
21797 +void __init check_ptrace(void)
21800 + int pid, syscall, n, status;
21802 + printk("Checking that ptrace can change system call numbers...");
21803 + pid = start_ptraced_child(&stack);
21806 + if(ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0)
21807 + panic("check_ptrace : ptrace failed, errno = %d",
21809 + n = waitpid(pid, &status, WUNTRACED);
21811 + panic("check_ptrace : wait failed, errno = %d", errno);
21812 + if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP))
21813 + panic("check_ptrace : expected SIGTRAP, "
21814 + "got status = %d", status);
21816 + syscall = ptrace(PTRACE_PEEKUSER, pid, PT_SYSCALL_NR_OFFSET,
21818 + if(syscall == __NR_getpid){
21819 + n = ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_NR_OFFSET,
21822 + panic("check_ptrace : failed to modify system "
21823 + "call, errno = %d", errno);
21827 + stop_ptraced_child(pid, stack, 0);
21831 +int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr)
21837 + n = sigsetjmp(buf, 1);
21844 +int can_do_skas(void)
21846 +#ifdef UML_CONFIG_MODE_SKAS
21847 + struct ptrace_faultinfo fi;
21849 + int pid, n, ret = 1;
21851 + printf("Checking for the skas3 patch in the host...");
21852 + pid = start_ptraced_child(&stack);
21854 + n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi);
21857 + printf("not found\n");
21858 + else printf("No (unexpected errno - %d)\n", errno);
21861 + else printf("found\n");
21863 + init_registers(pid);
21864 + stop_ptraced_child(pid, stack, 1);
21866 + printf("Checking for /proc/mm...");
21867 + if(os_access("/proc/mm", OS_ACC_W_OK) < 0){
21868 + printf("not found\n");
21871 + else printf("found\n");
21880 + * Overrides for Emacs so that we follow Linus's tabbing style.
21881 + * Emacs will notice this stuff at the end of the file and automatically
21882 + * adjust the settings for this buffer only. This must remain at the end
21884 + * ---------------------------------------------------------------------------
21885 + * Local variables:
21886 + * c-file-style: "linux"
21889 diff -Naur -X ../exclude-files orig/arch/um/kernel/process_kern.c um/arch/um/kernel/process_kern.c
21890 --- orig/arch/um/kernel/process_kern.c 1969-12-31 19:00:00.000000000 -0500
21891 +++ um/arch/um/kernel/process_kern.c 2003-11-08 08:37:04.000000000 -0500
21894 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
21895 + * Licensed under the GPL
21898 +#include "linux/config.h"
21899 +#include "linux/kernel.h"
21900 +#include "linux/sched.h"
21901 +#include "linux/interrupt.h"
21902 +#include "linux/mm.h"
21903 +#include "linux/slab.h"
21904 +#include "linux/utsname.h"
21905 +#include "linux/fs.h"
21906 +#include "linux/utime.h"
21907 +#include "linux/smp_lock.h"
21908 +#include "linux/module.h"
21909 +#include "linux/init.h"
21910 +#include "linux/capability.h"
21911 +#include "asm/unistd.h"
21912 +#include "asm/mman.h"
21913 +#include "asm/segment.h"
21914 +#include "asm/stat.h"
21915 +#include "asm/pgtable.h"
21916 +#include "asm/processor.h"
21917 +#include "asm/pgalloc.h"
21918 +#include "asm/spinlock.h"
21919 +#include "asm/uaccess.h"
21920 +#include "asm/user.h"
21921 +#include "user_util.h"
21922 +#include "kern_util.h"
21924 +#include "signal_kern.h"
21925 +#include "signal_user.h"
21927 +#include "irq_user.h"
21928 +#include "mem_user.h"
21929 +#include "time_user.h"
21931 +#include "frame_kern.h"
21932 +#include "sigcontext.h"
21933 +#include "2_5compat.h"
21936 +#include "mode_kern.h"
21937 +#include "choose-mode.h"
21939 +/* This is a per-cpu array. A processor only modifies its entry and it only
21940 + * cares about its entry, so it's OK if another processor is modifying its
21943 +struct cpu_task cpu_tasks[NR_CPUS] = { [0 ... NR_CPUS - 1] = { -1, NULL } };
21945 +struct task_struct *get_task(int pid, int require)
21947 + struct task_struct *ret;
21949 + read_lock(&tasklist_lock);
21950 + ret = find_task_by_pid(pid);
21951 + read_unlock(&tasklist_lock);
21953 + if(require && (ret == NULL)) panic("get_task couldn't find a task\n");
21957 +int external_pid(void *t)
21959 + struct task_struct *task = t ? t : current;
21961 + return(CHOOSE_MODE_PROC(external_pid_tt, external_pid_skas, task));
21964 +int pid_to_processor_id(int pid)
21968 + for(i = 0; i < smp_num_cpus; i++){
21969 + if(cpu_tasks[i].pid == pid) return(i);
21974 +void free_stack(unsigned long stack, int order)
21976 + free_pages(stack, order);
21979 +unsigned long alloc_stack(int order, int atomic)
21981 + unsigned long page;
21982 + int flags = GFP_KERNEL;
21984 + if(atomic) flags |= GFP_ATOMIC;
21985 + page = __get_free_pages(flags, order);
21988 + stack_protections(page);
21992 +int arch_kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
21996 + current->thread.request.u.thread.proc = fn;
21997 + current->thread.request.u.thread.arg = arg;
21998 + pid = do_fork(CLONE_VM | flags, 0, NULL, 0);
21999 +#if 0 /* CLONE_UNTRACED for 2.6 */
22000 + pid = do_fork(CLONE_VM | CLONE_UNTRACED | flags, 0, NULL, 0);
22003 + panic("do_fork failed in kernel_thread, errno = %d", pid);
22007 +void switch_mm(struct mm_struct *prev, struct mm_struct *next,
22008 + struct task_struct *tsk, unsigned cpu)
22010 + if (prev != next)
22011 + clear_bit(cpu, &prev->cpu_vm_mask);
22012 + set_bit(cpu, &next->cpu_vm_mask);
22015 +void set_current(void *t)
22017 + struct task_struct *task = t;
22019 + cpu_tasks[task->processor] = ((struct cpu_task)
22020 + { external_pid(task), task });
22023 +void *_switch_to(void *prev, void *next)
22025 + return(CHOOSE_MODE(_switch_to_tt(prev, next),
22026 + _switch_to_skas(prev, next)));
22029 +void interrupt_end(void)
22031 + if(current->need_resched) schedule();
22032 + if(current->sigpending != 0) do_signal(0);
22035 +void release_thread(struct task_struct *task)
22037 + CHOOSE_MODE(release_thread_tt(task), release_thread_skas(task));
22040 +void exit_thread(void)
22042 + CHOOSE_MODE(exit_thread_tt(), exit_thread_skas());
22043 + unprotect_stack((unsigned long) current);
22046 +void *get_current(void)
22051 +int copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
22052 + unsigned long stack_top, struct task_struct * p,
22053 + struct pt_regs *regs)
22055 + p->thread = (struct thread_struct) INIT_THREAD;
22056 + p->thread.kernel_stack = (unsigned long) p + 2 * PAGE_SIZE;
22058 + return(CHOOSE_MODE_PROC(copy_thread_tt, copy_thread_skas, nr,
22059 + clone_flags, sp, stack_top, p, regs));
22062 +void initial_thread_cb(void (*proc)(void *), void *arg)
22064 + int save_kmalloc_ok = kmalloc_ok;
22067 + CHOOSE_MODE_PROC(initial_thread_cb_tt, initial_thread_cb_skas, proc,
22069 + kmalloc_ok = save_kmalloc_ok;
22072 +unsigned long stack_sp(unsigned long page)
22074 + return(page + PAGE_SIZE - sizeof(void *));
22077 +int current_pid(void)
22079 + return(current->pid);
22082 +void cpu_idle(void)
22084 + CHOOSE_MODE(init_idle_tt(), init_idle_skas());
22086 + atomic_inc(&init_mm.mm_count);
22087 + current->mm = &init_mm;
22088 + current->active_mm = &init_mm;
22091 + /* endless idle loop with no priority at all */
22092 + SET_PRI(current);
22095 + * although we are an idle CPU, we do not want to
22096 + * get into the scheduler unnecessarily.
22098 + if (current->need_resched) {
22100 + check_pgt_cache();
22106 +int page_size(void)
22108 + return(PAGE_SIZE);
22111 +int page_mask(void)
22113 + return(PAGE_MASK);
22116 +void *um_virt_to_phys(struct task_struct *task, unsigned long addr,
22123 + if(task->mm == NULL)
22124 + return(ERR_PTR(-EINVAL));
22125 + pgd = pgd_offset(task->mm, addr);
22126 + pmd = pmd_offset(pgd, addr);
22127 + if(!pmd_present(*pmd))
22128 + return(ERR_PTR(-EINVAL));
22129 + pte = pte_offset(pmd, addr);
22130 + if(!pte_present(*pte))
22131 + return(ERR_PTR(-EINVAL));
22132 + if(pte_out != NULL)
22134 + return((void *) (pte_val(*pte) & PAGE_MASK) + (addr & ~PAGE_MASK));
22137 +char *current_cmd(void)
22139 +#if defined(CONFIG_SMP) || defined(CONFIG_HIGHMEM)
22140 + return("(Unknown)");
22142 + void *addr = um_virt_to_phys(current, current->mm->arg_start, NULL);
22143 + return IS_ERR(addr) ? "(Unknown)": __va((unsigned long) addr);
22147 +void force_sigbus(void)
22149 + printk(KERN_ERR "Killing pid %d because of a lack of memory\n",
22152 + sigaddset(¤t->pending.signal, SIGBUS);
22153 + recalc_sigpending(current);
22154 + current->flags |= PF_SIGNALED;
22155 + do_exit(SIGBUS | 0x80);
22158 +void dump_thread(struct pt_regs *regs, struct user *u)
22162 +void enable_hlt(void)
22164 + panic("enable_hlt");
22167 +void disable_hlt(void)
22169 + panic("disable_hlt");
22172 +extern int signal_frame_size;
22174 +void *um_kmalloc(int size)
22176 + return(kmalloc(size, GFP_KERNEL));
22179 +void *um_kmalloc_atomic(int size)
22181 + return(kmalloc(size, GFP_ATOMIC));
22184 +unsigned long get_fault_addr(void)
22186 + return((unsigned long) current->thread.fault_addr);
22189 +EXPORT_SYMBOL(get_fault_addr);
22191 +void not_implemented(void)
22193 + printk(KERN_DEBUG "Something isn't implemented in here\n");
22196 +EXPORT_SYMBOL(not_implemented);
22198 +int user_context(unsigned long sp)
22200 + unsigned long stack;
22202 + stack = sp & (PAGE_MASK << CONFIG_KERNEL_STACK_ORDER);
22203 + stack += 2 * PAGE_SIZE;
22204 + return(stack != current->thread.kernel_stack);
22207 +extern void remove_umid_dir(void);
22209 +__uml_exitcall(remove_umid_dir);
22211 +extern exitcall_t __uml_exitcall_begin, __uml_exitcall_end;
22213 +void do_uml_exitcalls(void)
22215 + exitcall_t *call;
22217 + call = &__uml_exitcall_end;
22218 + while (--call >= &__uml_exitcall_begin)
22222 +char *uml_strdup(char *string)
22226 + new = kmalloc(strlen(string) + 1, GFP_KERNEL);
22227 + if(new == NULL) return(NULL);
22228 + strcpy(new, string);
22232 +void *get_init_task(void)
22234 + return(&init_task_union.task);
22237 +int copy_to_user_proc(void *to, void *from, int size)
22239 + return(copy_to_user(to, from, size));
22242 +int copy_from_user_proc(void *to, void *from, int size)
22244 + return(copy_from_user(to, from, size));
22247 +int clear_user_proc(void *buf, int size)
22249 + return(clear_user(buf, size));
22252 +int strlen_user_proc(char *str)
22254 + return(strlen_user(str));
22257 +int smp_sigio_handler(void)
22260 + int cpu = current->processor;
22262 + IPI_handler(cpu);
22269 +int um_in_interrupt(void)
22271 + return(in_interrupt());
22276 + return(current->processor);
22280 + * Overrides for Emacs so that we follow Linus's tabbing style.
22281 + * Emacs will notice this stuff at the end of the file and automatically
22282 + * adjust the settings for this buffer only. This must remain at the end
22284 + * ---------------------------------------------------------------------------
22285 + * Local variables:
22286 + * c-file-style: "linux"
22289 diff -Naur -X ../exclude-files orig/arch/um/kernel/ptrace.c um/arch/um/kernel/ptrace.c
22290 --- orig/arch/um/kernel/ptrace.c 1969-12-31 19:00:00.000000000 -0500
22291 +++ um/arch/um/kernel/ptrace.c 2003-10-21 03:26:06.000000000 -0400
22294 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
22295 + * Licensed under the GPL
22298 +#include "linux/sched.h"
22299 +#include "linux/mm.h"
22300 +#include "linux/errno.h"
22301 +#include "linux/smp_lock.h"
22302 +#ifdef CONFIG_PROC_MM
22303 +#include "linux/proc_mm.h"
22305 +#include "asm/ptrace.h"
22306 +#include "asm/uaccess.h"
22307 +#include "kern_util.h"
22308 +#include "ptrace_user.h"
22311 + * Called by kernel/ptrace.c when detaching..
22313 +void ptrace_disable(struct task_struct *child)
22317 +extern long do_mmap2(struct task_struct *task, unsigned long addr,
22318 + unsigned long len, unsigned long prot,
22319 + unsigned long flags, unsigned long fd,
22320 + unsigned long pgoff);
22322 +int sys_ptrace(long request, long pid, long addr, long data)
22324 + struct task_struct *child;
22329 + if (request == PTRACE_TRACEME) {
22330 + /* are we already being traced? */
22331 + if (current->ptrace & PT_PTRACED)
22333 + /* set the ptrace bit in the process flags. */
22334 + current->ptrace |= PT_PTRACED;
22339 + read_lock(&tasklist_lock);
22340 + child = find_task_by_pid(pid);
22342 + get_task_struct(child);
22343 + read_unlock(&tasklist_lock);
22348 + if (pid == 1) /* you may not mess with init */
22351 + if (request == PTRACE_ATTACH) {
22352 + ret = ptrace_attach(child);
22356 + ret = ptrace_check_attach(child, request == PTRACE_KILL);
22360 + switch (request) {
22361 + /* when I and D space are separate, these will need to be fixed. */
22362 + case PTRACE_PEEKTEXT: /* read word at location addr. */
22363 + case PTRACE_PEEKDATA: {
22364 + unsigned long tmp;
22368 + copied = access_process_vm(child, addr, &tmp, sizeof(tmp), 0);
22369 + if (copied != sizeof(tmp))
22371 + ret = put_user(tmp,(unsigned long *) data);
22375 + /* read the word at location addr in the USER area. */
22376 + case PTRACE_PEEKUSR: {
22377 + unsigned long tmp;
22380 + if ((addr & 3) || addr < 0)
22383 + tmp = 0; /* Default return condition */
22384 + if(addr < FRAME_SIZE_OFFSET){
22385 + tmp = getreg(child, addr);
22387 + else if((addr >= offsetof(struct user, u_debugreg[0])) &&
22388 + (addr <= offsetof(struct user, u_debugreg[7]))){
22389 + addr -= offsetof(struct user, u_debugreg[0]);
22390 + addr = addr >> 2;
22391 + tmp = child->thread.arch.debugregs[addr];
22393 + ret = put_user(tmp, (unsigned long *) data);
22397 + /* when I and D space are separate, this will have to be fixed. */
22398 + case PTRACE_POKETEXT: /* write the word at location addr. */
22399 + case PTRACE_POKEDATA:
22401 + if (access_process_vm(child, addr, &data, sizeof(data),
22402 + 1) != sizeof(data))
22407 + case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
22409 + if ((addr & 3) || addr < 0)
22412 + if (addr < FRAME_SIZE_OFFSET) {
22413 + ret = putreg(child, addr, data);
22416 + else if((addr >= offsetof(struct user, u_debugreg[0])) &&
22417 + (addr <= offsetof(struct user, u_debugreg[7]))){
22418 + addr -= offsetof(struct user, u_debugreg[0]);
22419 + addr = addr >> 2;
22420 + if((addr == 4) || (addr == 5)) break;
22421 + child->thread.arch.debugregs[addr] = data;
22427 + case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
22428 + case PTRACE_CONT: { /* restart after signal. */
22430 + if ((unsigned long) data > _NSIG)
22432 + if (request == PTRACE_SYSCALL)
22433 + child->ptrace |= PT_TRACESYS;
22435 + child->ptrace &= ~PT_TRACESYS;
22436 + child->exit_code = data;
22437 + wake_up_process(child);
22443 + * make the child exit. Best I can do is send it a sigkill.
22444 + * perhaps it should be put in the status that it wants to
22447 + case PTRACE_KILL: {
22449 + if (child->state == TASK_ZOMBIE) /* already dead */
22451 + child->exit_code = SIGKILL;
22452 + wake_up_process(child);
22456 + case PTRACE_SINGLESTEP: { /* set the trap flag. */
22458 + if ((unsigned long) data > _NSIG)
22460 + child->ptrace &= ~PT_TRACESYS;
22461 + child->ptrace |= PT_DTRACE;
22462 + child->exit_code = data;
22463 + /* give it a chance to run. */
22464 + wake_up_process(child);
22469 + case PTRACE_DETACH:
22470 + /* detach a process that was attached. */
22471 + ret = ptrace_detach(child, data);
22474 +#ifdef PTRACE_GETREGS
22475 + case PTRACE_GETREGS: { /* Get all gp regs from the child. */
22476 + if (!access_ok(VERIFY_WRITE, (unsigned long *)data,
22477 + FRAME_SIZE_OFFSET)) {
22481 + for ( i = 0; i < FRAME_SIZE_OFFSET; i += sizeof(long) ) {
22482 + __put_user(getreg(child, i), (unsigned long *) data);
22483 + data += sizeof(long);
22489 +#ifdef PTRACE_SETREGS
22490 + case PTRACE_SETREGS: { /* Set all gp regs in the child. */
22491 + unsigned long tmp = 0;
22492 + if (!access_ok(VERIFY_READ, (unsigned *)data,
22493 + FRAME_SIZE_OFFSET)) {
22497 + for ( i = 0; i < FRAME_SIZE_OFFSET; i += sizeof(long) ) {
22498 + __get_user(tmp, (unsigned long *) data);
22499 + putreg(child, i, tmp);
22500 + data += sizeof(long);
22506 +#ifdef PTRACE_GETFPREGS
22507 + case PTRACE_GETFPREGS: /* Get the child FPU state. */
22508 + ret = get_fpregs(data, child);
22511 +#ifdef PTRACE_SETFPREGS
22512 + case PTRACE_SETFPREGS: /* Set the child FPU state. */
22513 + ret = set_fpregs(data, child);
22516 +#ifdef PTRACE_GETFPXREGS
22517 + case PTRACE_GETFPXREGS: /* Get the child FPU state. */
22518 + ret = get_fpxregs(data, child);
22521 +#ifdef PTRACE_SETFPXREGS
22522 + case PTRACE_SETFPXREGS: /* Set the child FPU state. */
22523 + ret = set_fpxregs(data, child);
22526 + case PTRACE_FAULTINFO: {
22527 + struct ptrace_faultinfo fault;
22529 + fault = ((struct ptrace_faultinfo)
22530 + { .is_write = child->thread.err,
22531 + .addr = child->thread.cr2 });
22532 + ret = copy_to_user((unsigned long *) data, &fault,
22538 + case PTRACE_SIGPENDING:
22539 + ret = copy_to_user((unsigned long *) data,
22540 + &child->pending.signal,
22541 + sizeof(child->pending.signal));
22544 + case PTRACE_LDT: {
22545 + struct ptrace_ldt ldt;
22547 + if(copy_from_user(&ldt, (unsigned long *) data,
22553 + /* This one is confusing, so just punt and return -EIO for
22559 +#ifdef CONFIG_PROC_MM
22560 + case PTRACE_SWITCH_MM: {
22561 + struct mm_struct *old = child->mm;
22562 + struct mm_struct *new = proc_mm_get_mm(data);
22565 + ret = PTR_ERR(new);
22569 + atomic_inc(&new->mm_users);
22571 + child->active_mm = new;
22582 + free_task_struct(child);
22588 +void syscall_trace(void)
22590 + if ((current->ptrace & (PT_PTRACED|PT_TRACESYS))
22591 + != (PT_PTRACED|PT_TRACESYS))
22593 + current->exit_code = SIGTRAP;
22594 + current->state = TASK_STOPPED;
22595 + notify_parent(current, SIGCHLD);
22598 + * this isn't the same as continuing with a signal, but it will do
22599 + * for normal use. strace only continues with a signal if the
22600 + * stopping signal is not SIGTRAP. -brl
22602 + if (current->exit_code) {
22603 + send_sig(current->exit_code, current, 1);
22604 + current->exit_code = 0;
22609 + * Overrides for Emacs so that we follow Linus's tabbing style.
22610 + * Emacs will notice this stuff at the end of the file and automatically
22611 + * adjust the settings for this buffer only. This must remain at the end
22613 + * ---------------------------------------------------------------------------
22614 + * Local variables:
22615 + * c-file-style: "linux"
22618 diff -Naur -X ../exclude-files orig/arch/um/kernel/reboot.c um/arch/um/kernel/reboot.c
22619 --- orig/arch/um/kernel/reboot.c 1969-12-31 19:00:00.000000000 -0500
22620 +++ um/arch/um/kernel/reboot.c 2003-10-21 03:26:06.000000000 -0400
22623 + * Copyright (C) 2000, 2002 Jeff Dike (jdike@karaya.com)
22624 + * Licensed under the GPL
22627 +#include "linux/sched.h"
22628 +#include "user_util.h"
22629 +#include "kern_util.h"
22633 +#include "choose-mode.h"
22636 +static void kill_idlers(int me)
22638 +#ifdef CONFIG_MODE_TT
22639 + struct task_struct *p;
22642 + for(i = 0; i < sizeof(init_tasks)/sizeof(init_tasks[0]); i++){
22643 + p = init_tasks[i];
22644 + if((p != NULL) && (p->thread.mode.tt.extern_pid != me) &&
22645 + (p->thread.mode.tt.extern_pid != -1))
22646 + os_kill_process(p->thread.mode.tt.extern_pid, 0);
22652 +static void kill_off_processes(void)
22654 + CHOOSE_MODE(kill_off_processes_tt(), kill_off_processes_skas());
22656 + kill_idlers(os_getpid());
22660 +void uml_cleanup(void)
22662 + kill_off_processes();
22663 + do_uml_exitcalls();
22666 +void machine_restart(char * __unused)
22668 + do_uml_exitcalls();
22669 + kill_off_processes();
22670 + CHOOSE_MODE(reboot_tt(), reboot_skas());
22673 +void machine_power_off(void)
22675 + do_uml_exitcalls();
22676 + kill_off_processes();
22677 + CHOOSE_MODE(halt_tt(), halt_skas());
22680 +void machine_halt(void)
22682 + machine_power_off();
22686 + * Overrides for Emacs so that we follow Linus's tabbing style.
22687 + * Emacs will notice this stuff at the end of the file and automatically
22688 + * adjust the settings for this buffer only. This must remain at the end
22690 + * ---------------------------------------------------------------------------
22691 + * Local variables:
22692 + * c-file-style: "linux"
22695 diff -Naur -X ../exclude-files orig/arch/um/kernel/resource.c um/arch/um/kernel/resource.c
22696 --- orig/arch/um/kernel/resource.c 1969-12-31 19:00:00.000000000 -0500
22697 +++ um/arch/um/kernel/resource.c 2003-10-21 03:26:06.000000000 -0400
22700 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
22701 + * Licensed under the GPL
22704 +#include "linux/pci.h"
22706 +unsigned long resource_fixup(struct pci_dev * dev, struct resource * res,
22707 + unsigned long start, unsigned long size)
22713 + * Overrides for Emacs so that we follow Linus's tabbing style.
22714 + * Emacs will notice this stuff at the end of the file and automatically
22715 + * adjust the settings for this buffer only. This must remain at the end
22717 + * ---------------------------------------------------------------------------
22718 + * Local variables:
22719 + * c-file-style: "linux"
22722 diff -Naur -X ../exclude-files orig/arch/um/kernel/sigio_kern.c um/arch/um/kernel/sigio_kern.c
22723 --- orig/arch/um/kernel/sigio_kern.c 1969-12-31 19:00:00.000000000 -0500
22724 +++ um/arch/um/kernel/sigio_kern.c 2003-10-21 03:26:07.000000000 -0400
22727 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
22728 + * Licensed under the GPL
22731 +#include "linux/kernel.h"
22732 +#include "linux/list.h"
22733 +#include "linux/slab.h"
22734 +#include "asm/irq.h"
22736 +#include "sigio.h"
22737 +#include "irq_user.h"
22738 +#include "irq_kern.h"
22740 +/* Protected by sigio_lock() called from write_sigio_workaround */
22741 +static int sigio_irq_fd = -1;
22743 +void sigio_interrupt(int irq, void *data, struct pt_regs *unused)
22745 + read_sigio_fd(sigio_irq_fd);
22746 + reactivate_fd(sigio_irq_fd, SIGIO_WRITE_IRQ);
22749 +int write_sigio_irq(int fd)
22751 + if(um_request_irq(SIGIO_WRITE_IRQ, fd, IRQ_READ, sigio_interrupt,
22752 + SA_INTERRUPT | SA_SAMPLE_RANDOM, "write sigio",
22754 + printk("write_sigio_irq : um_request_irq failed\n");
22757 + sigio_irq_fd = fd;
22761 +static spinlock_t sigio_spinlock = SPIN_LOCK_UNLOCKED;
22763 +void sigio_lock(void)
22765 + spin_lock(&sigio_spinlock);
22768 +void sigio_unlock(void)
22770 + spin_unlock(&sigio_spinlock);
22774 + * Overrides for Emacs so that we follow Linus's tabbing style.
22775 + * Emacs will notice this stuff at the end of the file and automatically
22776 + * adjust the settings for this buffer only. This must remain at the end
22778 + * ---------------------------------------------------------------------------
22779 + * Local variables:
22780 + * c-file-style: "linux"
22783 diff -Naur -X ../exclude-files orig/arch/um/kernel/sigio_user.c um/arch/um/kernel/sigio_user.c
22784 --- orig/arch/um/kernel/sigio_user.c 1969-12-31 19:00:00.000000000 -0500
22785 +++ um/arch/um/kernel/sigio_user.c 2003-11-07 01:41:13.000000000 -0500
22788 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
22789 + * Licensed under the GPL
22792 +#include <unistd.h>
22793 +#include <stdlib.h>
22794 +#include <termios.h>
22796 +#include <signal.h>
22797 +#include <errno.h>
22798 +#include <string.h>
22799 +#include <sched.h>
22800 +#include <sys/socket.h>
22801 +#include <sys/poll.h>
22804 +#include "kern_util.h"
22805 +#include "sigio.h"
22806 +#include "helper.h"
22809 +/* Changed during early boot */
22810 +int pty_output_sigio = 0;
22811 +int pty_close_sigio = 0;
22813 +/* Used as a flag during SIGIO testing early in boot */
22814 +static volatile int got_sigio = 0;
22816 +void __init handler(int sig)
22821 +struct openpty_arg {
22827 +static void openpty_cb(void *arg)
22829 + struct openpty_arg *info = arg;
22832 + if(openpty(&info->master, &info->slave, NULL, NULL, NULL))
22833 + info->err = -errno;
22836 +void __init check_one_sigio(void (*proc)(int, int))
22838 + struct sigaction old, new;
22839 + struct termios tt;
22840 + struct openpty_arg pty = { .master = -1, .slave = -1 };
22841 + int master, slave, err;
22843 + initial_thread_cb(openpty_cb, &pty);
22845 + printk("openpty failed, errno = %d\n", -pty.err);
22849 + master = pty.master;
22850 + slave = pty.slave;
22852 + if((master == -1) || (slave == -1)){
22853 + printk("openpty failed to allocate a pty\n");
22857 + /* XXX These can fail with EINTR */
22858 + if(tcgetattr(master, &tt) < 0)
22859 + panic("check_sigio : tcgetattr failed, errno = %d\n", errno);
22861 + if(tcsetattr(master, TCSADRAIN, &tt) < 0)
22862 + panic("check_sigio : tcsetattr failed, errno = %d\n", errno);
22864 + err = os_sigio_async(master, slave);
22866 + panic("tty_fds : sigio_async failed, err = %d\n", -err);
22868 + if(sigaction(SIGIO, NULL, &old) < 0)
22869 + panic("check_sigio : sigaction 1 failed, errno = %d\n", errno);
22871 + new.sa_handler = handler;
22872 + if(sigaction(SIGIO, &new, NULL) < 0)
22873 + panic("check_sigio : sigaction 2 failed, errno = %d\n", errno);
22876 + (*proc)(master, slave);
22878 + os_close_file(master);
22879 + os_close_file(slave);
22881 + if(sigaction(SIGIO, &old, NULL) < 0)
22882 + panic("check_sigio : sigaction 3 failed, errno = %d\n", errno);
22885 +static void tty_output(int master, int slave)
22890 + printk("Checking that host ptys support output SIGIO...");
22892 + memset(buf, 0, sizeof(buf));
22894 + while(os_write_file(master, buf, sizeof(buf)) > 0) ;
22895 + if(errno != EAGAIN)
22896 + panic("check_sigio : write failed, errno = %d\n", errno);
22897 + while(((n = os_read_file(slave, buf, sizeof(buf))) > 0) && !got_sigio) ;
22901 + pty_output_sigio = 1;
22903 + else if(n == -EAGAIN) printk("No, enabling workaround\n");
22904 + else panic("check_sigio : read failed, err = %d\n", n);
22907 +static void tty_close(int master, int slave)
22909 + printk("Checking that host ptys support SIGIO on close...");
22911 + os_close_file(slave);
22914 + pty_close_sigio = 1;
22916 + else printk("No, enabling workaround\n");
22919 +void __init check_sigio(void)
22921 + if((os_access("/dev/ptmx", OS_ACC_R_OK) < 0) &&
22922 + (os_access("/dev/ptyp0", OS_ACC_R_OK) < 0)){
22923 + printk("No pseudo-terminals available - skipping pty SIGIO "
22927 + check_one_sigio(tty_output);
22928 + check_one_sigio(tty_close);
22931 +/* Protected by sigio_lock(), also used by sigio_cleanup, which is an
22934 +static int write_sigio_pid = -1;
22936 +/* These arrays are initialized before the sigio thread is started, and
22937 + * the descriptors closed after it is killed. So, it can't see them change.
22938 + * On the UML side, they are changed under the sigio_lock.
22940 +static int write_sigio_fds[2] = { -1, -1 };
22941 +static int sigio_private[2] = { -1, -1 };
22944 + struct pollfd *poll;
22949 +/* Protected by sigio_lock(). Used by the sigio thread, but the UML thread
22950 + * synchronizes with it.
22952 +struct pollfds current_poll = {
22958 +struct pollfds next_poll = {
22964 +static int write_sigio_thread(void *unused)
22966 + struct pollfds *fds, tmp;
22967 + struct pollfd *p;
22968 + int i, n, respond_fd;
22971 + fds = ¤t_poll;
22973 + n = poll(fds->poll, fds->used, -1);
22975 + if(errno == EINTR) continue;
22976 + printk("write_sigio_thread : poll returned %d, "
22977 + "errno = %d\n", n, errno);
22979 + for(i = 0; i < fds->used; i++){
22980 + p = &fds->poll[i];
22981 + if(p->revents == 0) continue;
22982 + if(p->fd == sigio_private[1]){
22983 + n = os_read_file(sigio_private[1], &c, sizeof(c));
22984 + if(n != sizeof(c))
22985 + printk("write_sigio_thread : "
22986 + "read failed, err = %d\n", -n);
22987 + tmp = current_poll;
22988 + current_poll = next_poll;
22990 + respond_fd = sigio_private[1];
22993 + respond_fd = write_sigio_fds[1];
22995 + memmove(&fds->poll[i], &fds->poll[i + 1],
22996 + (fds->used - i) * sizeof(*fds->poll));
22999 + n = os_write_file(respond_fd, &c, sizeof(c));
23000 + if(n != sizeof(c))
23001 + printk("write_sigio_thread : write failed, "
23002 + "err = %d\n", -n);
23007 +static int need_poll(int n)
23009 + if(n <= next_poll.size){
23010 + next_poll.used = n;
23013 + if(next_poll.poll != NULL) kfree(next_poll.poll);
23014 + next_poll.poll = um_kmalloc_atomic(n * sizeof(struct pollfd));
23015 + if(next_poll.poll == NULL){
23016 + printk("need_poll : failed to allocate new pollfds\n");
23017 + next_poll.size = 0;
23018 + next_poll.used = 0;
23021 + next_poll.size = n;
23022 + next_poll.used = n;
23026 +static void update_thread(void)
23028 + unsigned long flags;
23032 + flags = set_signals(0);
23033 + n = os_write_file(sigio_private[0], &c, sizeof(c));
23034 + if(n != sizeof(c)){
23035 + printk("update_thread : write failed, err = %d\n", -n);
23039 + n = os_read_file(sigio_private[0], &c, sizeof(c));
23040 + if(n != sizeof(c)){
23041 + printk("update_thread : read failed, err = %d\n", -n);
23045 + set_signals(flags);
23049 + if(write_sigio_pid != -1)
23050 + os_kill_process(write_sigio_pid, 1);
23051 + write_sigio_pid = -1;
23052 + os_close_file(sigio_private[0]);
23053 + os_close_file(sigio_private[1]);
23054 + os_close_file(write_sigio_fds[0]);
23055 + os_close_file(write_sigio_fds[1]);
23057 + set_signals(flags);
23060 +int add_sigio_fd(int fd, int read)
23062 + int err = 0, i, n, events;
23065 + for(i = 0; i < current_poll.used; i++){
23066 + if(current_poll.poll[i].fd == fd)
23070 + n = current_poll.used + 1;
23071 + err = need_poll(n);
23075 + for(i = 0; i < current_poll.used; i++)
23076 + next_poll.poll[i] = current_poll.poll[i];
23078 + if(read) events = POLLIN;
23079 + else events = POLLOUT;
23081 + next_poll.poll[n - 1] = ((struct pollfd) { .fd = fd,
23082 + .events = events,
23090 +int ignore_sigio_fd(int fd)
23092 + struct pollfd *p;
23093 + int err = 0, i, n = 0;
23096 + for(i = 0; i < current_poll.used; i++){
23097 + if(current_poll.poll[i].fd == fd) break;
23099 + if(i == current_poll.used)
23102 + err = need_poll(current_poll.used - 1);
23106 + for(i = 0; i < current_poll.used; i++){
23107 + p = ¤t_poll.poll[i];
23108 + if(p->fd != fd) next_poll.poll[n++] = current_poll.poll[i];
23111 + printk("ignore_sigio_fd : fd %d not found\n", fd);
23122 +static int setup_initial_poll(int fd)
23124 + struct pollfd *p;
23126 + p = um_kmalloc(sizeof(struct pollfd));
23128 + printk("setup_initial_poll : failed to allocate poll\n");
23131 + *p = ((struct pollfd) { .fd = fd,
23132 + .events = POLLIN,
23134 + current_poll = ((struct pollfds) { .poll = p,
23140 +void write_sigio_workaround(void)
23142 + unsigned long stack;
23146 + if(write_sigio_pid != -1)
23149 + err = os_pipe(write_sigio_fds, 1, 1);
23151 + printk("write_sigio_workaround - os_pipe 1 failed, "
23152 + "err = %d\n", -err);
23155 + err = os_pipe(sigio_private, 1, 1);
23157 + printk("write_sigio_workaround - os_pipe 2 failed, "
23158 + "err = %d\n", -err);
23161 + if(setup_initial_poll(sigio_private[1]))
23164 + write_sigio_pid = run_helper_thread(write_sigio_thread, NULL,
23165 + CLONE_FILES | CLONE_VM, &stack, 0);
23167 + if(write_sigio_pid < 0) goto out_close2;
23169 + if(write_sigio_irq(write_sigio_fds[0]))
23177 + os_kill_process(write_sigio_pid, 1);
23178 + write_sigio_pid = -1;
23180 + os_close_file(sigio_private[0]);
23181 + os_close_file(sigio_private[1]);
23183 + os_close_file(write_sigio_fds[0]);
23184 + os_close_file(write_sigio_fds[1]);
23188 +int read_sigio_fd(int fd)
23193 + n = os_read_file(fd, &c, sizeof(c));
23194 + if(n != sizeof(c)){
23196 + printk("read_sigio_fd - read failed, err = %d\n", -n);
23200 + printk("read_sigio_fd - short read, bytes = %d\n", n);
23207 +static void sigio_cleanup(void)
23209 + if(write_sigio_pid != -1)
23210 + os_kill_process(write_sigio_pid, 1);
23213 +__uml_exitcall(sigio_cleanup);
23216 + * Overrides for Emacs so that we follow Linus's tabbing style.
23217 + * Emacs will notice this stuff at the end of the file and automatically
23218 + * adjust the settings for this buffer only. This must remain at the end
23220 + * ---------------------------------------------------------------------------
23221 + * Local variables:
23222 + * c-file-style: "linux"
23225 diff -Naur -X ../exclude-files orig/arch/um/kernel/signal_kern.c um/arch/um/kernel/signal_kern.c
23226 --- orig/arch/um/kernel/signal_kern.c 1969-12-31 19:00:00.000000000 -0500
23227 +++ um/arch/um/kernel/signal_kern.c 2003-11-19 03:50:58.000000000 -0500
23230 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
23231 + * Licensed under the GPL
23234 +#include "linux/config.h"
23235 +#include "linux/stddef.h"
23236 +#include "linux/sys.h"
23237 +#include "linux/sched.h"
23238 +#include "linux/wait.h"
23239 +#include "linux/kernel.h"
23240 +#include "linux/smp_lock.h"
23241 +#include "linux/module.h"
23242 +#include "linux/slab.h"
23243 +#include "asm/signal.h"
23244 +#include "asm/uaccess.h"
23245 +#include "asm/ucontext.h"
23246 +#include "user_util.h"
23247 +#include "kern_util.h"
23248 +#include "signal_kern.h"
23249 +#include "signal_user.h"
23251 +#include "frame_kern.h"
23252 +#include "sigcontext.h"
23255 +EXPORT_SYMBOL(block_signals);
23256 +EXPORT_SYMBOL(unblock_signals);
23258 +static void force_segv(int sig)
23260 + if(sig == SIGSEGV){
23261 + struct k_sigaction *ka;
23263 + ka = ¤t->sig->action[SIGSEGV - 1];
23264 + ka->sa.sa_handler = SIG_DFL;
23266 + force_sig(SIGSEGV, current);
23269 +#define _S(nr) (1<<((nr)-1))
23271 +#define _BLOCKABLE (~(_S(SIGKILL) | _S(SIGSTOP)))
23274 + * OK, we're invoking a handler
23276 +static int handle_signal(struct pt_regs *regs, unsigned long signr,
23277 + struct k_sigaction *ka, siginfo_t *info,
23278 + sigset_t *oldset, int error)
23280 + __sighandler_t handler;
23281 + void (*restorer)(void);
23282 + unsigned long sp;
23288 + case -ERESTARTNOHAND:
23292 + case -ERESTARTSYS:
23293 + if (!(ka->sa.sa_flags & SA_RESTART)) {
23297 + /* fallthrough */
23298 + case -ERESTARTNOINTR:
23299 + PT_REGS_RESTART_SYSCALL(regs);
23300 + PT_REGS_ORIG_SYSCALL(regs) = PT_REGS_SYSCALL_NR(regs);
23302 + /* This is because of the UM_SET_SYSCALL_RETURN and the fact
23303 + * that on i386 the system call number and return value are
23304 + * in the same register. When the system call restarts, %eax
23305 + * had better have the system call number in it. Since the
23306 + * return value doesn't matter (except that it shouldn't be
23307 + * -ERESTART*), we'll stick the system call number there.
23309 + ret = PT_REGS_SYSCALL_NR(regs);
23313 + handler = ka->sa.sa_handler;
23316 + if (ka->sa.sa_flags & SA_ONESHOT)
23317 + ka->sa.sa_handler = SIG_DFL;
23319 + if (!(ka->sa.sa_flags & SA_NODEFER)) {
23320 + spin_lock_irq(¤t->sigmask_lock);
23321 + sigorsets(¤t->blocked, ¤t->blocked,
23322 + &ka->sa.sa_mask);
23323 + sigaddset(¤t->blocked, signr);
23324 + recalc_sigpending(current);
23325 + spin_unlock_irq(¤t->sigmask_lock);
23328 + sp = PT_REGS_SP(regs);
23330 + if((ka->sa.sa_flags & SA_ONSTACK) && (sas_ss_flags(sp) == 0))
23331 + sp = current->sas_ss_sp + current->sas_ss_size;
23333 + if(error != 0) PT_REGS_SET_SYSCALL_RETURN(regs, ret);
23335 + if (ka->sa.sa_flags & SA_RESTORER) restorer = ka->sa.sa_restorer;
23336 + else restorer = NULL;
23338 + if(ka->sa.sa_flags & SA_SIGINFO)
23339 + err = setup_signal_stack_si(sp, signr, (unsigned long) handler,
23340 + restorer, regs, info, &save);
23342 + err = setup_signal_stack_sc(sp, signr, (unsigned long) handler,
23343 + restorer, regs, &save);
23344 + if(err) goto segv;
23348 + force_segv(signr);
23353 + * Note that 'init' is a special process: it doesn't get signals it doesn't
23354 + * want to handle. Thus you cannot kill init even with a SIGKILL even by
23358 +static int kern_do_signal(struct pt_regs *regs, sigset_t *oldset, int error)
23361 + struct k_sigaction *ka;
23365 + oldset = ¤t->blocked;
23368 + unsigned long signr;
23370 + spin_lock_irq(¤t->sigmask_lock);
23371 + signr = dequeue_signal(¤t->blocked, &info);
23372 + spin_unlock_irq(¤t->sigmask_lock);
23377 + if ((current->ptrace & PT_PTRACED) && signr != SIGKILL) {
23378 + /* Let the debugger run. */
23379 + current->exit_code = signr;
23380 + current->state = TASK_STOPPED;
23381 + notify_parent(current, SIGCHLD);
23384 + /* We're back. Did the debugger cancel the sig? */
23385 + signr = current->exit_code;
23388 + current->exit_code = 0;
23390 + /* The debugger continued. Ignore SIGSTOP. */
23391 + if (signr == SIGSTOP)
23394 + /* Update the siginfo structure. Is this good? */
23395 + if (signr != info.si_signo) {
23396 + info.si_signo = signr;
23397 + info.si_errno = 0;
23398 + info.si_code = SI_USER;
23399 + info.si_pid = current->p_pptr->pid;
23400 + info.si_uid = current->p_pptr->uid;
23403 + /* If the (new) signal is now blocked, requeue it. */
23404 + if (sigismember(¤t->blocked, signr)) {
23405 + send_sig_info(signr, &info, current);
23410 + ka = ¤t->sig->action[signr-1];
23411 + if (ka->sa.sa_handler == SIG_IGN) {
23412 + if (signr != SIGCHLD)
23414 + /* Check for SIGCHLD: it's special. */
23415 + while (sys_wait4(-1, NULL, WNOHANG, NULL) > 0)
23420 + if (ka->sa.sa_handler == SIG_DFL) {
23421 + int exit_code = signr;
23423 + /* Init gets no signals it doesn't want. */
23424 + if (current->pid == 1)
23428 + case SIGCONT: case SIGCHLD: case SIGWINCH: case SIGURG:
23431 + case SIGTSTP: case SIGTTIN: case SIGTTOU:
23432 + if (is_orphaned_pgrp(current->pgrp))
23437 + struct signal_struct *sig;
23438 + current->state = TASK_STOPPED;
23439 + current->exit_code = signr;
23440 + sig = current->p_pptr->sig;
23441 + if (sig && !(sig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP))
23442 + notify_parent(current, SIGCHLD);
23446 + case SIGQUIT: case SIGILL: case SIGTRAP:
23447 + case SIGABRT: case SIGFPE: case SIGSEGV:
23448 + case SIGBUS: case SIGSYS: case SIGXCPU: case SIGXFSZ:
23449 + if (do_coredump(signr, ¤t->thread.regs))
23450 + exit_code |= 0x80;
23454 + sig_exit(signr, exit_code, &info);
23459 + /* Whee! Actually deliver the signal. */
23460 + err = handle_signal(regs, signr, ka, &info, oldset, error);
23461 + if(!err) return(1);
23464 + /* Did we come from a system call? */
23465 + if(PT_REGS_SYSCALL_NR(regs) >= 0){
23466 + /* Restart the system call - no handlers present */
23467 + if(PT_REGS_SYSCALL_RET(regs) == -ERESTARTNOHAND ||
23468 + PT_REGS_SYSCALL_RET(regs) == -ERESTARTSYS ||
23469 + PT_REGS_SYSCALL_RET(regs) == -ERESTARTNOINTR){
23470 + PT_REGS_ORIG_SYSCALL(regs) = PT_REGS_SYSCALL_NR(regs);
23471 + PT_REGS_RESTART_SYSCALL(regs);
23475 + /* This closes a way to execute a system call on the host. If
23476 + * you set a breakpoint on a system call instruction and singlestep
23477 + * from it, the tracing thread used to PTRACE_SINGLESTEP the process
23478 + * rather than PTRACE_SYSCALL it, allowing the system call to execute
23479 + * on the host. The tracing thread will check this flag and
23480 + * PTRACE_SYSCALL if necessary.
23482 + if((current->ptrace & PT_DTRACE) &&
23483 + is_syscall(PT_REGS_IP(¤t->thread.regs)))
23484 + (void) CHOOSE_MODE(current->thread.mode.tt.singlestep_syscall = 1, 0);
23489 +int do_signal(int error)
23491 + return(kern_do_signal(¤t->thread.regs, NULL, error));
23495 + * Atomically swap in the new signal mask, and wait for a signal.
23497 +int sys_sigsuspend(int history0, int history1, old_sigset_t mask)
23499 + sigset_t saveset;
23501 + mask &= _BLOCKABLE;
23502 + spin_lock_irq(¤t->sigmask_lock);
23503 + saveset = current->blocked;
23504 + siginitset(¤t->blocked, mask);
23505 + recalc_sigpending(current);
23506 + spin_unlock_irq(¤t->sigmask_lock);
23509 + current->state = TASK_INTERRUPTIBLE;
23511 + if(kern_do_signal(¤t->thread.regs, &saveset, -EINTR))
23516 +int sys_rt_sigsuspend(sigset_t *unewset, size_t sigsetsize)
23518 + sigset_t saveset, newset;
23520 + /* XXX: Don't preclude handling different sized sigset_t's. */
23521 + if (sigsetsize != sizeof(sigset_t))
23524 + if (copy_from_user(&newset, unewset, sizeof(newset)))
23526 + sigdelsetmask(&newset, ~_BLOCKABLE);
23528 + spin_lock_irq(¤t->sigmask_lock);
23529 + saveset = current->blocked;
23530 + current->blocked = newset;
23531 + recalc_sigpending(current);
23532 + spin_unlock_irq(¤t->sigmask_lock);
23535 + current->state = TASK_INTERRUPTIBLE;
23537 + if (kern_do_signal(¤t->thread.regs, &saveset, -EINTR))
23542 +extern int userspace_pid[];
23544 +static int copy_sc_from_user(struct pt_regs *to, void *from,
23545 + struct arch_frame_data *arch)
23549 + ret = CHOOSE_MODE(copy_sc_from_user_tt(UPT_SC(&to->regs), from, arch),
23550 + copy_sc_from_user_skas(userspace_pid[0],
23551 + &to->regs, from));
23555 +int sys_sigreturn(struct pt_regs regs)
23557 + void *sc = sp_to_sc(PT_REGS_SP(¤t->thread.regs));
23558 + void *mask = sp_to_mask(PT_REGS_SP(¤t->thread.regs));
23559 + int sig_size = (_NSIG_WORDS - 1) * sizeof(unsigned long);
23561 + spin_lock_irq(¤t->sigmask_lock);
23562 + copy_from_user(¤t->blocked.sig[0], sc_sigmask(sc),
23563 + sizeof(current->blocked.sig[0]));
23564 + copy_from_user(¤t->blocked.sig[1], mask, sig_size);
23565 + sigdelsetmask(¤t->blocked, ~_BLOCKABLE);
23566 + recalc_sigpending(current);
23567 + spin_unlock_irq(¤t->sigmask_lock);
23568 + copy_sc_from_user(¤t->thread.regs, sc,
23569 + &signal_frame_sc.common.arch);
23570 + return(PT_REGS_SYSCALL_RET(¤t->thread.regs));
23573 +int sys_rt_sigreturn(struct pt_regs regs)
23575 + struct ucontext *uc = sp_to_uc(PT_REGS_SP(¤t->thread.regs));
23576 + int sig_size = _NSIG_WORDS * sizeof(unsigned long);
23578 + spin_lock_irq(¤t->sigmask_lock);
23579 + copy_from_user(¤t->blocked, &uc->uc_sigmask, sig_size);
23580 + sigdelsetmask(¤t->blocked, ~_BLOCKABLE);
23581 + recalc_sigpending(current);
23582 + spin_unlock_irq(¤t->sigmask_lock);
23583 + copy_sc_from_user(¤t->thread.regs, &uc->uc_mcontext,
23584 + &signal_frame_si.common.arch);
23585 + return(PT_REGS_SYSCALL_RET(¤t->thread.regs));
23589 + * Overrides for Emacs so that we follow Linus's tabbing style.
23590 + * Emacs will notice this stuff at the end of the file and automatically
23591 + * adjust the settings for this buffer only. This must remain at the end
23593 + * ---------------------------------------------------------------------------
23594 + * Local variables:
23595 + * c-file-style: "linux"
23598 diff -Naur -X ../exclude-files orig/arch/um/kernel/signal_user.c um/arch/um/kernel/signal_user.c
23599 --- orig/arch/um/kernel/signal_user.c 1969-12-31 19:00:00.000000000 -0500
23600 +++ um/arch/um/kernel/signal_user.c 2003-10-21 03:26:07.000000000 -0400
23603 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
23604 + * Licensed under the GPL
23607 +#include <stdio.h>
23608 +#include <unistd.h>
23609 +#include <stdlib.h>
23610 +#include <signal.h>
23611 +#include <errno.h>
23612 +#include <stdarg.h>
23613 +#include <string.h>
23614 +#include <sys/mman.h>
23615 +#include "user_util.h"
23616 +#include "kern_util.h"
23618 +#include "signal_user.h"
23619 +#include "signal_kern.h"
23620 +#include "sysdep/sigcontext.h"
23621 +#include "sigcontext.h"
23623 +void set_sigstack(void *sig_stack, int size)
23625 + stack_t stack = ((stack_t) { .ss_flags = 0,
23626 + .ss_sp = (__ptr_t) sig_stack,
23627 + .ss_size = size - sizeof(void *) });
23629 + if(sigaltstack(&stack, NULL) != 0)
23630 + panic("enabling signal stack failed, errno = %d\n", errno);
23633 +void set_handler(int sig, void (*handler)(int), int flags, ...)
23635 + struct sigaction action;
23639 + va_start(ap, flags);
23640 + action.sa_handler = handler;
23641 + sigemptyset(&action.sa_mask);
23642 + while((mask = va_arg(ap, int)) != -1){
23643 + sigaddset(&action.sa_mask, mask);
23645 + action.sa_flags = flags;
23646 + action.sa_restorer = NULL;
23647 + if(sigaction(sig, &action, NULL) < 0)
23648 + panic("sigaction failed");
23651 +int change_sig(int signal, int on)
23653 + sigset_t sigset, old;
23655 + sigemptyset(&sigset);
23656 + sigaddset(&sigset, signal);
23657 + sigprocmask(on ? SIG_UNBLOCK : SIG_BLOCK, &sigset, &old);
23658 + return(!sigismember(&old, signal));
23661 +static void change_signals(int type)
23665 + sigemptyset(&mask);
23666 + sigaddset(&mask, SIGVTALRM);
23667 + sigaddset(&mask, SIGALRM);
23668 + sigaddset(&mask, SIGIO);
23669 + sigaddset(&mask, SIGPROF);
23670 + if(sigprocmask(type, &mask, NULL) < 0)
23671 + panic("Failed to change signal mask - errno = %d", errno);
23674 +void block_signals(void)
23676 + change_signals(SIG_BLOCK);
23679 +void unblock_signals(void)
23681 + change_signals(SIG_UNBLOCK);
23684 +#define SIGIO_BIT 0
23685 +#define SIGVTALRM_BIT 1
23687 +static int enable_mask(sigset_t *mask)
23691 + sigs = sigismember(mask, SIGIO) ? 0 : 1 << SIGIO_BIT;
23692 + sigs |= sigismember(mask, SIGVTALRM) ? 0 : 1 << SIGVTALRM_BIT;
23693 + sigs |= sigismember(mask, SIGALRM) ? 0 : 1 << SIGVTALRM_BIT;
23697 +int get_signals(void)
23701 + if(sigprocmask(SIG_SETMASK, NULL, &mask) < 0)
23702 + panic("Failed to get signal mask");
23703 + return(enable_mask(&mask));
23706 +int set_signals(int enable)
23711 + sigemptyset(&mask);
23712 + if(enable & (1 << SIGIO_BIT))
23713 + sigaddset(&mask, SIGIO);
23714 + if(enable & (1 << SIGVTALRM_BIT)){
23715 + sigaddset(&mask, SIGVTALRM);
23716 + sigaddset(&mask, SIGALRM);
23718 + if(sigprocmask(SIG_UNBLOCK, &mask, &mask) < 0)
23719 + panic("Failed to enable signals");
23720 + ret = enable_mask(&mask);
23721 + sigemptyset(&mask);
23722 + if((enable & (1 << SIGIO_BIT)) == 0)
23723 + sigaddset(&mask, SIGIO);
23724 + if((enable & (1 << SIGVTALRM_BIT)) == 0){
23725 + sigaddset(&mask, SIGVTALRM);
23726 + sigaddset(&mask, SIGALRM);
23728 + if(sigprocmask(SIG_BLOCK, &mask, NULL) < 0)
23729 + panic("Failed to block signals");
23735 + * Overrides for Emacs so that we follow Linus's tabbing style.
23736 + * Emacs will notice this stuff at the end of the file and automatically
23737 + * adjust the settings for this buffer only. This must remain at the end
23739 + * ---------------------------------------------------------------------------
23740 + * Local variables:
23741 + * c-file-style: "linux"
23744 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/exec_kern.c um/arch/um/kernel/skas/exec_kern.c
23745 --- orig/arch/um/kernel/skas/exec_kern.c 1969-12-31 19:00:00.000000000 -0500
23746 +++ um/arch/um/kernel/skas/exec_kern.c 2003-10-21 03:26:07.000000000 -0400
23749 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
23750 + * Licensed under the GPL
23753 +#include "linux/kernel.h"
23754 +#include "asm/current.h"
23755 +#include "asm/page.h"
23756 +#include "asm/signal.h"
23757 +#include "asm/ptrace.h"
23758 +#include "asm/uaccess.h"
23759 +#include "asm/mmu_context.h"
23765 +void flush_thread_skas(void)
23767 + force_flush_all();
23768 + switch_mm_skas(current->mm->context.skas.mm_fd);
23771 +void start_thread_skas(struct pt_regs *regs, unsigned long eip,
23772 + unsigned long esp)
23775 + PT_REGS_IP(regs) = eip;
23776 + PT_REGS_SP(regs) = esp;
23780 + * Overrides for Emacs so that we follow Linus's tabbing style.
23781 + * Emacs will notice this stuff at the end of the file and automatically
23782 + * adjust the settings for this buffer only. This must remain at the end
23784 + * ---------------------------------------------------------------------------
23785 + * Local variables:
23786 + * c-file-style: "linux"
23789 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/exec_user.c um/arch/um/kernel/skas/exec_user.c
23790 --- orig/arch/um/kernel/skas/exec_user.c 1969-12-31 19:00:00.000000000 -0500
23791 +++ um/arch/um/kernel/skas/exec_user.c 2003-10-21 03:26:07.000000000 -0400
23794 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
23795 + * Licensed under the GPL
23798 +#include <stdlib.h>
23799 +#include <errno.h>
23800 +#include <signal.h>
23801 +#include <sched.h>
23802 +#include <sys/wait.h>
23803 +#include <sys/ptrace.h>
23805 +#include "kern_util.h"
23807 +#include "time_user.h"
23809 +static int user_thread_tramp(void *arg)
23811 + if(ptrace(PTRACE_TRACEME, 0, 0, 0) < 0)
23812 + panic("user_thread_tramp - PTRACE_TRACEME failed, "
23813 + "errno = %d\n", errno);
23815 + os_stop_process(os_getpid());
23819 +int user_thread(unsigned long stack, int flags)
23823 + pid = clone(user_thread_tramp, (void *) stack_sp(stack),
23824 + flags | CLONE_FILES | SIGCHLD, NULL);
23826 + printk("user_thread - clone failed, errno = %d\n", errno);
23830 + if(waitpid(pid, &status, WUNTRACED) < 0){
23831 + printk("user_thread - waitpid failed, errno = %d\n", errno);
23835 + if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP)){
23836 + printk("user_thread - trampoline didn't stop, status = %d\n",
23845 + * Overrides for Emacs so that we follow Linus's tabbing style.
23846 + * Emacs will notice this stuff at the end of the file and automatically
23847 + * adjust the settings for this buffer only. This must remain at the end
23849 + * ---------------------------------------------------------------------------
23850 + * Local variables:
23851 + * c-file-style: "linux"
23854 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/include/mmu.h um/arch/um/kernel/skas/include/mmu.h
23855 --- orig/arch/um/kernel/skas/include/mmu.h 1969-12-31 19:00:00.000000000 -0500
23856 +++ um/arch/um/kernel/skas/include/mmu.h 2003-10-21 03:26:07.000000000 -0400
23859 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
23860 + * Licensed under the GPL
23863 +#ifndef __SKAS_MMU_H
23864 +#define __SKAS_MMU_H
23866 +#include "linux/list.h"
23867 +#include "linux/spinlock.h"
23869 +struct mmu_context_skas {
23876 + * Overrides for Emacs so that we follow Linus's tabbing style.
23877 + * Emacs will notice this stuff at the end of the file and automatically
23878 + * adjust the settings for this buffer only. This must remain at the end
23880 + * ---------------------------------------------------------------------------
23881 + * Local variables:
23882 + * c-file-style: "linux"
23885 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/include/mode.h um/arch/um/kernel/skas/include/mode.h
23886 --- orig/arch/um/kernel/skas/include/mode.h 1969-12-31 19:00:00.000000000 -0500
23887 +++ um/arch/um/kernel/skas/include/mode.h 2003-11-19 03:27:36.000000000 -0500
23890 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
23891 + * Licensed under the GPL
23894 +#ifndef __MODE_SKAS_H__
23895 +#define __MODE_SKAS_H__
23897 +extern unsigned long exec_regs[];
23898 +extern unsigned long exec_fp_regs[];
23899 +extern unsigned long exec_fpx_regs[];
23900 +extern int have_fpx_regs;
23902 +extern void user_time_init_skas(void);
23903 +extern int copy_sc_from_user_skas(int pid, union uml_pt_regs *regs,
23905 +extern int copy_sc_to_user_skas(int pid, void *to_ptr, void *fp,
23906 + union uml_pt_regs *regs,
23907 + unsigned long fault_addr, int fault_type);
23908 +extern void sig_handler_common_skas(int sig, void *sc_ptr);
23909 +extern void halt_skas(void);
23910 +extern void reboot_skas(void);
23911 +extern void kill_off_processes_skas(void);
23912 +extern int is_skas_winch(int pid, int fd, void *data);
23917 + * Overrides for Emacs so that we follow Linus's tabbing style.
23918 + * Emacs will notice this stuff at the end of the file and automatically
23919 + * adjust the settings for this buffer only. This must remain at the end
23921 + * ---------------------------------------------------------------------------
23922 + * Local variables:
23923 + * c-file-style: "linux"
23926 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/include/mode_kern.h um/arch/um/kernel/skas/include/mode_kern.h
23927 --- orig/arch/um/kernel/skas/include/mode_kern.h 1969-12-31 19:00:00.000000000 -0500
23928 +++ um/arch/um/kernel/skas/include/mode_kern.h 2003-10-21 03:26:07.000000000 -0400
23931 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
23932 + * Licensed under the GPL
23935 +#ifndef __SKAS_MODE_KERN_H__
23936 +#define __SKAS_MODE_KERN_H__
23938 +#include "linux/sched.h"
23939 +#include "asm/page.h"
23940 +#include "asm/ptrace.h"
23942 +extern void flush_thread_skas(void);
23943 +extern void *_switch_to_skas(void *prev, void *next);
23944 +extern void start_thread_skas(struct pt_regs *regs, unsigned long eip,
23945 + unsigned long esp);
23946 +extern int copy_thread_skas(int nr, unsigned long clone_flags,
23947 + unsigned long sp, unsigned long stack_top,
23948 + struct task_struct *p, struct pt_regs *regs);
23949 +extern void release_thread_skas(struct task_struct *task);
23950 +extern void exit_thread_skas(void);
23951 +extern void initial_thread_cb_skas(void (*proc)(void *), void *arg);
23952 +extern void init_idle_skas(void);
23953 +extern void flush_tlb_kernel_vm_skas(void);
23954 +extern void __flush_tlb_one_skas(unsigned long addr);
23955 +extern void flush_tlb_range_skas(struct mm_struct *mm, unsigned long start,
23956 + unsigned long end);
23957 +extern void flush_tlb_mm_skas(struct mm_struct *mm);
23958 +extern void force_flush_all_skas(void);
23959 +extern long execute_syscall_skas(void *r);
23960 +extern void before_mem_skas(unsigned long unused);
23961 +extern unsigned long set_task_sizes_skas(int arg, unsigned long *host_size_out,
23962 + unsigned long *task_size_out);
23963 +extern int start_uml_skas(void);
23964 +extern int external_pid_skas(struct task_struct *task);
23965 +extern int thread_pid_skas(struct thread_struct *thread);
23967 +#define kmem_end_skas (host_task_size - 1024 * 1024)
23972 + * Overrides for Emacs so that we follow Linus's tabbing style.
23973 + * Emacs will notice this stuff at the end of the file and automatically
23974 + * adjust the settings for this buffer only. This must remain at the end
23976 + * ---------------------------------------------------------------------------
23977 + * Local variables:
23978 + * c-file-style: "linux"
23981 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/include/proc_mm.h um/arch/um/kernel/skas/include/proc_mm.h
23982 --- orig/arch/um/kernel/skas/include/proc_mm.h 1969-12-31 19:00:00.000000000 -0500
23983 +++ um/arch/um/kernel/skas/include/proc_mm.h 2003-10-21 03:26:07.000000000 -0400
23986 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
23987 + * Licensed under the GPL
23990 +#ifndef __SKAS_PROC_MM_H
23991 +#define __SKAS_PROC_MM_H
23993 +#define MM_MMAP 54
23994 +#define MM_MUNMAP 55
23995 +#define MM_MPROTECT 56
23996 +#define MM_COPY_SEGMENTS 57
23999 + unsigned long addr;
24000 + unsigned long len;
24001 + unsigned long prot;
24002 + unsigned long flags;
24003 + unsigned long fd;
24004 + unsigned long offset;
24007 +struct mm_munmap {
24008 + unsigned long addr;
24009 + unsigned long len;
24012 +struct mm_mprotect {
24013 + unsigned long addr;
24014 + unsigned long len;
24015 + unsigned int prot;
24018 +struct proc_mm_op {
24021 + struct mm_mmap mmap;
24022 + struct mm_munmap munmap;
24023 + struct mm_mprotect mprotect;
24024 + int copy_segments;
24031 + * Overrides for Emacs so that we follow Linus's tabbing style.
24032 + * Emacs will notice this stuff at the end of the file and automatically
24033 + * adjust the settings for this buffer only. This must remain at the end
24035 + * ---------------------------------------------------------------------------
24036 + * Local variables:
24037 + * c-file-style: "linux"
24040 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/include/ptrace-skas.h um/arch/um/kernel/skas/include/ptrace-skas.h
24041 --- orig/arch/um/kernel/skas/include/ptrace-skas.h 1969-12-31 19:00:00.000000000 -0500
24042 +++ um/arch/um/kernel/skas/include/ptrace-skas.h 2003-10-21 03:26:07.000000000 -0400
24045 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
24046 + * Licensed under the GPL
24049 +#ifndef __PTRACE_SKAS_H
24050 +#define __PTRACE_SKAS_H
24052 +#include "uml-config.h"
24054 +#ifdef UML_CONFIG_MODE_SKAS
24056 +#include "skas_ptregs.h"
24058 +#define HOST_FRAME_SIZE 17
24060 +#define REGS_IP(r) ((r)[HOST_IP])
24061 +#define REGS_SP(r) ((r)[HOST_SP])
24062 +#define REGS_EFLAGS(r) ((r)[HOST_EFLAGS])
24063 +#define REGS_EAX(r) ((r)[HOST_EAX])
24064 +#define REGS_EBX(r) ((r)[HOST_EBX])
24065 +#define REGS_ECX(r) ((r)[HOST_ECX])
24066 +#define REGS_EDX(r) ((r)[HOST_EDX])
24067 +#define REGS_ESI(r) ((r)[HOST_ESI])
24068 +#define REGS_EDI(r) ((r)[HOST_EDI])
24069 +#define REGS_EBP(r) ((r)[HOST_EBP])
24070 +#define REGS_CS(r) ((r)[HOST_CS])
24071 +#define REGS_SS(r) ((r)[HOST_SS])
24072 +#define REGS_DS(r) ((r)[HOST_DS])
24073 +#define REGS_ES(r) ((r)[HOST_ES])
24074 +#define REGS_FS(r) ((r)[HOST_FS])
24075 +#define REGS_GS(r) ((r)[HOST_GS])
24077 +#define REGS_SET_SYSCALL_RETURN(r, res) REGS_EAX(r) = (res)
24079 +#define REGS_RESTART_SYSCALL(r) IP_RESTART_SYSCALL(REGS_IP(r))
24081 +#define REGS_SEGV_IS_FIXABLE(r) SEGV_IS_FIXABLE((r)->trap_type)
24083 +#define REGS_FAULT_ADDR(r) ((r)->fault_addr)
24085 +#define REGS_FAULT_WRITE(r) FAULT_WRITE((r)->fault_type)
24092 + * Overrides for Emacs so that we follow Linus's tabbing style.
24093 + * Emacs will notice this stuff at the end of the file and automatically
24094 + * adjust the settings for this buffer only. This must remain at the end
24096 + * ---------------------------------------------------------------------------
24097 + * Local variables:
24098 + * c-file-style: "linux"
24101 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/include/skas.h um/arch/um/kernel/skas/include/skas.h
24102 --- orig/arch/um/kernel/skas/include/skas.h 1969-12-31 19:00:00.000000000 -0500
24103 +++ um/arch/um/kernel/skas/include/skas.h 2003-11-19 03:00:51.000000000 -0500
24106 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
24107 + * Licensed under the GPL
24113 +#include "sysdep/ptrace.h"
24115 +extern int userspace_pid[];
24117 +extern void switch_threads(void *me, void *next);
24118 +extern void thread_wait(void *sw, void *fb);
24119 +extern void new_thread(void *stack, void **switch_buf_ptr, void **fork_buf_ptr,
24120 + void (*handler)(int));
24121 +extern int start_idle_thread(void *stack, void *switch_buf_ptr,
24122 + void **fork_buf_ptr);
24123 +extern int user_thread(unsigned long stack, int flags);
24124 +extern void userspace(union uml_pt_regs *regs);
24125 +extern void new_thread_proc(void *stack, void (*handler)(int sig));
24126 +extern void remove_sigstack(void);
24127 +extern void new_thread_handler(int sig);
24128 +extern void handle_syscall(union uml_pt_regs *regs);
24129 +extern void map(int fd, unsigned long virt, unsigned long phys,
24130 + unsigned long len, int r, int w, int x);
24131 +extern int unmap(int fd, void *addr, int len);
24132 +extern int protect(int fd, unsigned long addr, unsigned long len,
24133 + int r, int w, int x, int must_succeed);
24134 +extern void user_signal(int sig, union uml_pt_regs *regs);
24135 +extern int singlestepping_skas(void);
24136 +extern int new_mm(int from);
24137 +extern void save_registers(union uml_pt_regs *regs);
24138 +extern void restore_registers(union uml_pt_regs *regs);
24139 +extern void start_userspace(int cpu);
24140 +extern void init_registers(int pid);
24145 + * Overrides for Emacs so that we follow Linus's tabbing style.
24146 + * Emacs will notice this stuff at the end of the file and automatically
24147 + * adjust the settings for this buffer only. This must remain at the end
24149 + * ---------------------------------------------------------------------------
24150 + * Local variables:
24151 + * c-file-style: "linux"
24154 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/include/uaccess.h um/arch/um/kernel/skas/include/uaccess.h
24155 --- orig/arch/um/kernel/skas/include/uaccess.h 1969-12-31 19:00:00.000000000 -0500
24156 +++ um/arch/um/kernel/skas/include/uaccess.h 2004-01-17 06:35:41.000000000 -0500
24159 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
24160 + * Licensed under the GPL
24163 +#ifndef __SKAS_UACCESS_H
24164 +#define __SKAS_UACCESS_H
24166 +#include "asm/errno.h"
24168 +#define access_ok_skas(type, addr, size) \
24169 + ((segment_eq(get_fs(), KERNEL_DS)) || \
24170 + (((unsigned long) (addr) < TASK_SIZE) && \
24171 + ((unsigned long) (addr) + (size) <= TASK_SIZE)))
24173 +static inline int verify_area_skas(int type, const void * addr,
24174 + unsigned long size)
24176 + return(access_ok_skas(type, addr, size) ? 0 : -EFAULT);
24179 +extern int copy_from_user_skas(void *to, const void *from, int n);
24180 +extern int copy_to_user_skas(void *to, const void *from, int n);
24181 +extern int strncpy_from_user_skas(char *dst, const char *src, int count);
24182 +extern int __clear_user_skas(void *mem, int len);
24183 +extern int clear_user_skas(void *mem, int len);
24184 +extern int strnlen_user_skas(const void *str, int len);
24189 + * Overrides for Emacs so that we follow Linus's tabbing style.
24190 + * Emacs will notice this stuff at the end of the file and automatically
24191 + * adjust the settings for this buffer only. This must remain at the end
24193 + * ---------------------------------------------------------------------------
24194 + * Local variables:
24195 + * c-file-style: "linux"
24198 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/Makefile um/arch/um/kernel/skas/Makefile
24199 --- orig/arch/um/kernel/skas/Makefile 1969-12-31 19:00:00.000000000 -0500
24200 +++ um/arch/um/kernel/skas/Makefile 2003-11-11 06:36:12.000000000 -0500
24203 +# Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
24204 +# Licensed under the GPL
24209 +obj-y = exec_kern.o exec_user.o mem.o mem_user.o mmu.o process.o \
24210 + process_kern.o syscall_kern.o syscall_user.o time.o tlb.o trap_user.o \
24213 +subdir-y = sys-$(SUBARCH)
24215 +obj-y += $(join $(subdir-y),$(subdir-y:%=/%.o))
24217 +USER_OBJS = $(filter %_user.o,$(obj-y)) process.o time.o
24219 +include $(TOPDIR)/Rules.make
24221 +include/skas_ptregs.h : util/mk_ptregs
24222 + util/mk_ptregs > $@
24227 +$(USER_OBJS) : %.o: %.c
24228 + $(CC) $(CFLAGS_$@) $(USER_CFLAGS) -c -o $@ $<
24231 + $(MAKE) -C util clean
24232 + $(RM) -f include/skas_ptregs.h
24233 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/mem.c um/arch/um/kernel/skas/mem.c
24234 --- orig/arch/um/kernel/skas/mem.c 1969-12-31 19:00:00.000000000 -0500
24235 +++ um/arch/um/kernel/skas/mem.c 2003-10-21 03:26:07.000000000 -0400
24238 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
24239 + * Licensed under the GPL
24242 +#include "linux/config.h"
24243 +#include "linux/mm.h"
24244 +#include "mem_user.h"
24246 +unsigned long set_task_sizes_skas(int arg, unsigned long *host_size_out,
24247 + unsigned long *task_size_out)
24249 + /* Round up to the nearest 4M */
24250 + unsigned long top = ROUND_4M((unsigned long) &arg);
24252 + *host_size_out = top;
24253 + *task_size_out = top;
24254 + return(((unsigned long) set_task_sizes_skas) & ~0xffffff);
24258 + * Overrides for Emacs so that we follow Linus's tabbing style.
24259 + * Emacs will notice this stuff at the end of the file and automatically
24260 + * adjust the settings for this buffer only. This must remain at the end
24262 + * ---------------------------------------------------------------------------
24263 + * Local variables:
24264 + * c-file-style: "linux"
24267 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/mem_user.c um/arch/um/kernel/skas/mem_user.c
24268 --- orig/arch/um/kernel/skas/mem_user.c 1969-12-31 19:00:00.000000000 -0500
24269 +++ um/arch/um/kernel/skas/mem_user.c 2003-10-21 03:26:07.000000000 -0400
24272 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
24273 + * Licensed under the GPL
24276 +#include <errno.h>
24277 +#include <sys/mman.h>
24278 +#include <sys/ptrace.h>
24279 +#include "mem_user.h"
24283 +#include "proc_mm.h"
24285 +void map(int fd, unsigned long virt, unsigned long phys, unsigned long len,
24286 + int r, int w, int x)
24288 + struct proc_mm_op map;
24290 + int prot, n, phys_fd;
24292 + prot = (r ? PROT_READ : 0) | (w ? PROT_WRITE : 0) |
24293 + (x ? PROT_EXEC : 0);
24294 + phys_fd = phys_mapping(phys, &offset);
24296 + map = ((struct proc_mm_op) { .op = MM_MMAP,
24302 + .flags = MAP_SHARED |
24307 + n = os_write_file(fd, &map, sizeof(map));
24308 + if(n != sizeof(map))
24309 + printk("map : /proc/mm map failed, err = %d\n", -n);
24312 +int unmap(int fd, void *addr, int len)
24314 + struct proc_mm_op unmap;
24317 + unmap = ((struct proc_mm_op) { .op = MM_MUNMAP,
24320 + { .addr = (unsigned long) addr,
24321 + .len = len } } } );
24322 + n = os_write_file(fd, &unmap, sizeof(unmap));
24323 + if(n != sizeof(unmap)) {
24333 +int protect(int fd, unsigned long addr, unsigned long len, int r, int w,
24334 + int x, int must_succeed)
24336 + struct proc_mm_op protect;
24339 + prot = (r ? PROT_READ : 0) | (w ? PROT_WRITE : 0) |
24340 + (x ? PROT_EXEC : 0);
24342 + protect = ((struct proc_mm_op) { .op = MM_MPROTECT,
24345 + { .addr = (unsigned long) addr,
24347 + .prot = prot } } } );
24349 + n = os_write_file(fd, &protect, sizeof(protect));
24350 + if(n != sizeof(protect)) {
24351 + if(n == 0) return(0);
24354 + panic("protect failed, err = %d", -n);
24362 +void before_mem_skas(unsigned long unused)
24367 + * Overrides for Emacs so that we follow Linus's tabbing style.
24368 + * Emacs will notice this stuff at the end of the file and automatically
24369 + * adjust the settings for this buffer only. This must remain at the end
24371 + * ---------------------------------------------------------------------------
24372 + * Local variables:
24373 + * c-file-style: "linux"
24376 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/mmu.c um/arch/um/kernel/skas/mmu.c
24377 --- orig/arch/um/kernel/skas/mmu.c 1969-12-31 19:00:00.000000000 -0500
24378 +++ um/arch/um/kernel/skas/mmu.c 2003-11-15 22:25:20.000000000 -0500
24381 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
24382 + * Licensed under the GPL
24385 +#include "linux/list.h"
24386 +#include "linux/spinlock.h"
24387 +#include "linux/slab.h"
24388 +#include "asm/segment.h"
24389 +#include "asm/mmu.h"
24393 +int init_new_context_skas(struct task_struct *task, struct mm_struct *mm)
24397 + if((current->mm != NULL) && (current->mm != &init_mm))
24398 + from = current->mm->context.skas.mm_fd;
24401 + mm->context.skas.mm_fd = new_mm(from);
24402 + if(mm->context.skas.mm_fd < 0){
24403 + printk("init_new_context_skas - new_mm failed, errno = %d\n",
24404 + mm->context.skas.mm_fd);
24405 + return(mm->context.skas.mm_fd);
24411 +void destroy_context_skas(struct mm_struct *mm)
24413 + os_close_file(mm->context.skas.mm_fd);
24417 + * Overrides for Emacs so that we follow Linus's tabbing style.
24418 + * Emacs will notice this stuff at the end of the file and automatically
24419 + * adjust the settings for this buffer only. This must remain at the end
24421 + * ---------------------------------------------------------------------------
24422 + * Local variables:
24423 + * c-file-style: "linux"
24426 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/process.c um/arch/um/kernel/skas/process.c
24427 --- orig/arch/um/kernel/skas/process.c 1969-12-31 19:00:00.000000000 -0500
24428 +++ um/arch/um/kernel/skas/process.c 2004-01-31 02:49:36.000000000 -0500
24431 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
24432 + * Licensed under the GPL
24435 +#include <stdlib.h>
24436 +#include <unistd.h>
24437 +#include <errno.h>
24438 +#include <signal.h>
24439 +#include <setjmp.h>
24440 +#include <sched.h>
24441 +#include <sys/wait.h>
24442 +#include <sys/ptrace.h>
24443 +#include <sys/mman.h>
24444 +#include <sys/user.h>
24445 +#include <asm/unistd.h>
24447 +#include "ptrace_user.h"
24448 +#include "time_user.h"
24449 +#include "sysdep/ptrace.h"
24450 +#include "user_util.h"
24451 +#include "kern_util.h"
24453 +#include "sysdep/sigcontext.h"
24455 +#include "proc_mm.h"
24456 +#include "skas_ptrace.h"
24457 +#include "chan_user.h"
24459 +int is_skas_winch(int pid, int fd, void *data)
24461 + if(pid != getpid())
24464 + register_winch_irq(-1, fd, -1, data);
24468 +/* These are set once at boot time and not changed thereafter */
24470 +unsigned long exec_regs[FRAME_SIZE];
24471 +unsigned long exec_fp_regs[HOST_FP_SIZE];
24472 +unsigned long exec_fpx_regs[HOST_XFP_SIZE];
24473 +int have_fpx_regs = 1;
24475 +static void handle_segv(int pid)
24477 + struct ptrace_faultinfo fault;
24480 + err = ptrace(PTRACE_FAULTINFO, pid, 0, &fault);
24482 + panic("handle_segv - PTRACE_FAULTINFO failed, errno = %d\n",
24485 + segv(fault.addr, 0, FAULT_WRITE(fault.is_write), 1, NULL);
24488 +static void handle_trap(int pid, union uml_pt_regs *regs)
24490 + int err, syscall_nr, status;
24492 + syscall_nr = PT_SYSCALL_NR(regs->skas.regs);
24493 + UPT_SYSCALL_NR(regs) = syscall_nr;
24494 + if(syscall_nr < 1){
24495 + relay_signal(SIGTRAP, regs);
24499 + err = ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_NR_OFFSET, __NR_getpid);
24501 + panic("handle_trap - nullifying syscall failed errno = %d\n",
24504 + err = ptrace(PTRACE_SYSCALL, pid, 0, 0);
24506 + panic("handle_trap - continuing to end of syscall failed, "
24507 + "errno = %d\n", errno);
24509 + err = waitpid(pid, &status, WUNTRACED);
24510 + if((err < 0) || !WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP))
24511 + panic("handle_trap - failed to wait at end of syscall, "
24512 + "errno = %d, status = %d\n", errno, status);
24514 + handle_syscall(regs);
24517 +static int userspace_tramp(void *arg)
24519 + init_new_thread_signals(0);
24521 + ptrace(PTRACE_TRACEME, 0, 0, 0);
24522 + os_stop_process(os_getpid());
24526 +/* Each element set once, and only accessed by a single processor anyway */
24528 +int userspace_pid[NR_CPUS];
24530 +void start_userspace(int cpu)
24533 + unsigned long sp;
24534 + int pid, status, n;
24536 + stack = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC,
24537 + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
24538 + if(stack == MAP_FAILED)
24539 + panic("start_userspace : mmap failed, errno = %d", errno);
24540 + sp = (unsigned long) stack + PAGE_SIZE - sizeof(void *);
24542 + pid = clone(userspace_tramp, (void *) sp,
24543 + CLONE_FILES | CLONE_VM | SIGCHLD, NULL);
24545 + panic("start_userspace : clone failed, errno = %d", errno);
24548 + n = waitpid(pid, &status, WUNTRACED);
24550 + panic("start_userspace : wait failed, errno = %d",
24552 + } while(WIFSTOPPED(status) && (WSTOPSIG(status) == SIGVTALRM));
24554 + if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP))
24555 + panic("start_userspace : expected SIGSTOP, got status = %d",
24558 + if(munmap(stack, PAGE_SIZE) < 0)
24559 + panic("start_userspace : munmap failed, errno = %d\n", errno);
24561 + userspace_pid[cpu] = pid;
24564 +void userspace(union uml_pt_regs *regs)
24566 + int err, status, op, pid = userspace_pid[0];
24568 + restore_registers(regs);
24570 + err = ptrace(PTRACE_SYSCALL, pid, 0, 0);
24572 + panic("userspace - PTRACE_SYSCALL failed, errno = %d\n",
24575 + err = waitpid(pid, &status, WUNTRACED);
24577 + panic("userspace - waitpid failed, errno = %d\n",
24580 + regs->skas.is_user = 1;
24581 + save_registers(regs);
24583 + if(WIFSTOPPED(status)){
24584 + switch(WSTOPSIG(status)){
24586 + handle_segv(pid);
24589 + handle_trap(pid, regs);
24597 + user_signal(WSTOPSIG(status), regs);
24600 + printk("userspace - child stopped with signal "
24601 + "%d\n", WSTOPSIG(status));
24606 + restore_registers(regs);
24608 + op = singlestepping_skas() ? PTRACE_SINGLESTEP :
24610 + err = ptrace(op, pid, 0, 0);
24612 + panic("userspace - PTRACE_SYSCALL failed, "
24613 + "errno = %d\n", errno);
24617 +void new_thread(void *stack, void **switch_buf_ptr, void **fork_buf_ptr,
24618 + void (*handler)(int))
24620 + sigjmp_buf switch_buf, fork_buf;
24622 + *switch_buf_ptr = &switch_buf;
24623 + *fork_buf_ptr = &fork_buf;
24625 + if(sigsetjmp(fork_buf, 1) == 0)
24626 + new_thread_proc(stack, handler);
24628 + remove_sigstack();
24631 +void thread_wait(void *sw, void *fb)
24633 + sigjmp_buf buf, **switch_buf = sw, *fork_buf;
24635 + *switch_buf = &buf;
24637 + if(sigsetjmp(buf, 1) == 0)
24638 + siglongjmp(*fork_buf, 1);
24641 +static int move_registers(int pid, int int_op, int fp_op,
24642 + union uml_pt_regs *regs, unsigned long *fp_regs)
24644 + if(ptrace(int_op, pid, 0, regs->skas.regs) < 0)
24646 + if(ptrace(fp_op, pid, 0, fp_regs) < 0)
24651 +void save_registers(union uml_pt_regs *regs)
24653 + unsigned long *fp_regs;
24656 + if(have_fpx_regs){
24657 + fp_op = PTRACE_GETFPXREGS;
24658 + fp_regs = regs->skas.xfp;
24661 + fp_op = PTRACE_GETFPREGS;
24662 + fp_regs = regs->skas.fp;
24665 + err = move_registers(userspace_pid[0], PTRACE_GETREGS, fp_op, regs,
24668 + panic("save_registers - saving registers failed, errno = %d\n",
24672 +void restore_registers(union uml_pt_regs *regs)
24674 + unsigned long *fp_regs;
24677 + if(have_fpx_regs){
24678 + fp_op = PTRACE_SETFPXREGS;
24679 + fp_regs = regs->skas.xfp;
24682 + fp_op = PTRACE_SETFPREGS;
24683 + fp_regs = regs->skas.fp;
24686 + err = move_registers(userspace_pid[0], PTRACE_SETREGS, fp_op, regs,
24689 + panic("restore_registers - saving registers failed, "
24690 + "errno = %d\n", -err);
24693 +void switch_threads(void *me, void *next)
24695 + sigjmp_buf my_buf, **me_ptr = me, *next_buf = next;
24697 + *me_ptr = &my_buf;
24698 + if(sigsetjmp(my_buf, 1) == 0)
24699 + siglongjmp(*next_buf, 1);
24702 +static sigjmp_buf initial_jmpbuf;
24704 +/* XXX Make these percpu */
24705 +static void (*cb_proc)(void *arg);
24706 +static void *cb_arg;
24707 +static sigjmp_buf *cb_back;
24709 +int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr)
24711 + sigjmp_buf **switch_buf = switch_buf_ptr;
24714 + *fork_buf_ptr = &initial_jmpbuf;
24715 + n = sigsetjmp(initial_jmpbuf, 1);
24717 + new_thread_proc((void *) stack, new_thread_handler);
24719 + remove_sigstack();
24721 + (*cb_proc)(cb_arg);
24722 + siglongjmp(*cb_back, 1);
24732 + siglongjmp(**switch_buf, 1);
24735 +void remove_sigstack(void)
24737 + stack_t stack = ((stack_t) { .ss_flags = SS_DISABLE,
24741 + if(sigaltstack(&stack, NULL) != 0)
24742 + panic("disabling signal stack failed, errno = %d\n", errno);
24745 +void initial_thread_cb_skas(void (*proc)(void *), void *arg)
24754 + if(sigsetjmp(here, 1) == 0)
24755 + siglongjmp(initial_jmpbuf, 2);
24756 + unblock_signals();
24763 +void halt_skas(void)
24766 + siglongjmp(initial_jmpbuf, 3);
24769 +void reboot_skas(void)
24772 + siglongjmp(initial_jmpbuf, 4);
24775 +int new_mm(int from)
24777 + struct proc_mm_op copy;
24778 + int n, fd = os_open_file("/proc/mm",
24779 + of_cloexec(of_write(OPENFLAGS())), 0);
24785 + copy = ((struct proc_mm_op) { .op = MM_COPY_SEGMENTS,
24787 + { .copy_segments = from } } );
24788 + n = os_write_file(fd, ©, sizeof(copy));
24789 + if(n != sizeof(copy))
24790 + printk("new_mm : /proc/mm copy_segments failed, "
24791 + "err = %d\n", -n);
24797 +void switch_mm_skas(int mm_fd)
24801 +#warning need cpu pid in switch_mm_skas
24802 + err = ptrace(PTRACE_SWITCH_MM, userspace_pid[0], 0, mm_fd);
24804 + panic("switch_mm_skas - PTRACE_SWITCH_MM failed, errno = %d\n",
24808 +void kill_off_processes_skas(void)
24810 +#warning need to loop over userspace_pids in kill_off_processes_skas
24811 + os_kill_process(userspace_pid[0], 1);
24814 +void init_registers(int pid)
24818 + if(ptrace(PTRACE_GETREGS, pid, 0, exec_regs) < 0)
24819 + panic("check_ptrace : PTRACE_GETREGS failed, errno = %d",
24822 + err = ptrace(PTRACE_GETFPXREGS, pid, 0, exec_fpx_regs);
24826 + have_fpx_regs = 0;
24828 + panic("check_ptrace : PTRACE_GETFPXREGS failed, errno = %d",
24831 + err = ptrace(PTRACE_GETFPREGS, pid, 0, exec_fp_regs);
24833 + panic("check_ptrace : PTRACE_GETFPREGS failed, errno = %d",
24838 + * Overrides for Emacs so that we follow Linus's tabbing style.
24839 + * Emacs will notice this stuff at the end of the file and automatically
24840 + * adjust the settings for this buffer only. This must remain at the end
24842 + * ---------------------------------------------------------------------------
24843 + * Local variables:
24844 + * c-file-style: "linux"
24847 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/process_kern.c um/arch/um/kernel/skas/process_kern.c
24848 --- orig/arch/um/kernel/skas/process_kern.c 1969-12-31 19:00:00.000000000 -0500
24849 +++ um/arch/um/kernel/skas/process_kern.c 2003-11-19 03:18:25.000000000 -0500
24852 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
24853 + * Licensed under the GPL
24856 +#include "linux/sched.h"
24857 +#include "linux/slab.h"
24858 +#include "kern_util.h"
24859 +#include "time_user.h"
24860 +#include "signal_user.h"
24863 +#include "user_util.h"
24865 +#include "frame.h"
24869 +int singlestepping_skas(void)
24871 + int ret = current->ptrace & PT_DTRACE;
24873 + current->ptrace &= ~PT_DTRACE;
24877 +void *_switch_to_skas(void *prev, void *next)
24879 + struct task_struct *from, *to;
24884 + /* XXX need to check runqueues[cpu].idle */
24885 + if(current->pid == 0)
24886 + switch_timers(0);
24888 + to->thread.prev_sched = from;
24891 + switch_threads(&from->thread.mode.skas.switch_buf,
24892 + to->thread.mode.skas.switch_buf);
24894 + if(current->pid == 0)
24895 + switch_timers(1);
24897 + return(current->thread.prev_sched);
24900 +extern void schedule_tail(struct task_struct *prev);
24902 +void new_thread_handler(int sig)
24904 + int (*fn)(void *), n;
24907 + fn = current->thread.request.u.thread.proc;
24908 + arg = current->thread.request.u.thread.arg;
24909 + change_sig(SIGUSR1, 1);
24910 + thread_wait(¤t->thread.mode.skas.switch_buf,
24911 + current->thread.mode.skas.fork_buf);
24913 + if(current->thread.prev_sched != NULL)
24914 + schedule_tail(current->thread.prev_sched);
24915 + current->thread.prev_sched = NULL;
24917 + /* The return value is 1 if the kernel thread execs a process,
24918 + * 0 if it just exits
24920 + n = run_kernel_thread(fn, arg, ¤t->thread.exec_buf);
24922 + userspace(¤t->thread.regs.regs);
24926 +void new_thread_proc(void *stack, void (*handler)(int sig))
24928 + init_new_thread_stack(stack, handler);
24929 + os_usr1_process(os_getpid());
24932 +void release_thread_skas(struct task_struct *task)
24936 +void exit_thread_skas(void)
24940 +void fork_handler(int sig)
24942 + change_sig(SIGUSR1, 1);
24943 + thread_wait(¤t->thread.mode.skas.switch_buf,
24944 + current->thread.mode.skas.fork_buf);
24946 + force_flush_all();
24947 + if(current->thread.prev_sched != NULL)
24948 + schedule_tail(current->thread.prev_sched);
24949 + current->thread.prev_sched = NULL;
24950 + unblock_signals();
24952 + userspace(¤t->thread.regs.regs);
24955 +int copy_thread_skas(int nr, unsigned long clone_flags, unsigned long sp,
24956 + unsigned long stack_top, struct task_struct * p,
24957 + struct pt_regs *regs)
24959 + void (*handler)(int);
24961 + if(current->thread.forking){
24962 + memcpy(&p->thread.regs.regs.skas,
24963 + ¤t->thread.regs.regs.skas,
24964 + sizeof(p->thread.regs.regs.skas));
24965 + REGS_SET_SYSCALL_RETURN(p->thread.regs.regs.skas.regs, 0);
24966 + if(sp != 0) REGS_SP(p->thread.regs.regs.skas.regs) = sp;
24968 + handler = fork_handler;
24971 + memcpy(p->thread.regs.regs.skas.regs, exec_regs,
24972 + sizeof(p->thread.regs.regs.skas.regs));
24973 + memcpy(p->thread.regs.regs.skas.fp, exec_fp_regs,
24974 + sizeof(p->thread.regs.regs.skas.fp));
24975 + memcpy(p->thread.regs.regs.skas.xfp, exec_fpx_regs,
24976 + sizeof(p->thread.regs.regs.skas.xfp));
24977 + p->thread.request.u.thread = current->thread.request.u.thread;
24978 + handler = new_thread_handler;
24981 + new_thread((void *) p->thread.kernel_stack,
24982 + &p->thread.mode.skas.switch_buf,
24983 + &p->thread.mode.skas.fork_buf, handler);
24987 +void init_idle_skas(void)
24989 + cpu_tasks[current->processor].pid = os_getpid();
24992 +extern void start_kernel(void);
24994 +static int start_kernel_proc(void *unused)
24999 + pid = os_getpid();
25001 + cpu_tasks[0].pid = pid;
25002 + cpu_tasks[0].task = current;
25004 + cpu_online_map = 1;
25010 +int start_uml_skas(void)
25012 + start_userspace(0);
25013 + capture_signal_stack();
25016 + init_new_thread_signals(1);
25018 + init_task.thread.request.u.thread.proc = start_kernel_proc;
25019 + init_task.thread.request.u.thread.arg = NULL;
25020 + return(start_idle_thread((void *) init_task.thread.kernel_stack,
25021 + &init_task.thread.mode.skas.switch_buf,
25022 + &init_task.thread.mode.skas.fork_buf));
25025 +int external_pid_skas(struct task_struct *task)
25027 +#warning Need to look up userspace_pid by cpu
25028 + return(userspace_pid[0]);
25031 +int thread_pid_skas(struct thread_struct *thread)
25033 +#warning Need to look up userspace_pid by cpu
25034 + return(userspace_pid[0]);
25038 + * Overrides for Emacs so that we follow Linus's tabbing style.
25039 + * Emacs will notice this stuff at the end of the file and automatically
25040 + * adjust the settings for this buffer only. This must remain at the end
25042 + * ---------------------------------------------------------------------------
25043 + * Local variables:
25044 + * c-file-style: "linux"
25047 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/syscall_kern.c um/arch/um/kernel/skas/syscall_kern.c
25048 --- orig/arch/um/kernel/skas/syscall_kern.c 1969-12-31 19:00:00.000000000 -0500
25049 +++ um/arch/um/kernel/skas/syscall_kern.c 2004-01-04 08:20:29.000000000 -0500
25052 + * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com)
25053 + * Licensed under the GPL
25056 +#include "linux/sys.h"
25057 +#include "asm/errno.h"
25058 +#include "asm/unistd.h"
25059 +#include "asm/ptrace.h"
25060 +#include "asm/current.h"
25061 +#include "sysdep/syscalls.h"
25062 +#include "kern_util.h"
25064 +extern syscall_handler_t *sys_call_table[];
25066 +long execute_syscall_skas(void *r)
25068 + struct pt_regs *regs = r;
25072 + current->thread.nsyscalls++;
25074 + syscall = UPT_SYSCALL_NR(®s->regs);
25076 + if((syscall >= NR_syscalls) || (syscall < 1))
25078 + else res = EXECUTE_SYSCALL(syscall, regs);
25084 + * Overrides for Emacs so that we follow Linus's tabbing style.
25085 + * Emacs will notice this stuff at the end of the file and automatically
25086 + * adjust the settings for this buffer only. This must remain at the end
25088 + * ---------------------------------------------------------------------------
25089 + * Local variables:
25090 + * c-file-style: "linux"
25093 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/syscall_user.c um/arch/um/kernel/skas/syscall_user.c
25094 --- orig/arch/um/kernel/skas/syscall_user.c 1969-12-31 19:00:00.000000000 -0500
25095 +++ um/arch/um/kernel/skas/syscall_user.c 2003-10-21 03:26:07.000000000 -0400
25098 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
25099 + * Licensed under the GPL
25102 +#include <stdlib.h>
25103 +#include <signal.h>
25104 +#include "kern_util.h"
25105 +#include "syscall_user.h"
25106 +#include "sysdep/ptrace.h"
25107 +#include "sysdep/sigcontext.h"
25110 +#define ERESTARTSYS 512
25111 +#define ERESTARTNOINTR 513
25112 +#define ERESTARTNOHAND 514
25114 +void handle_syscall(union uml_pt_regs *regs)
25119 + index = record_syscall_start(UPT_SYSCALL_NR(regs));
25122 + result = execute_syscall(regs);
25124 + REGS_SET_SYSCALL_RETURN(regs->skas.regs, result);
25125 + if((result == -ERESTARTNOHAND) || (result == -ERESTARTSYS) ||
25126 + (result == -ERESTARTNOINTR))
25127 + do_signal(result);
25130 + record_syscall_end(index, result);
25134 + * Overrides for Emacs so that we follow Linus's tabbing style.
25135 + * Emacs will notice this stuff at the end of the file and automatically
25136 + * adjust the settings for this buffer only. This must remain at the end
25138 + * ---------------------------------------------------------------------------
25139 + * Local variables:
25140 + * c-file-style: "linux"
25143 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/sys-i386/Makefile um/arch/um/kernel/skas/sys-i386/Makefile
25144 --- orig/arch/um/kernel/skas/sys-i386/Makefile 1969-12-31 19:00:00.000000000 -0500
25145 +++ um/arch/um/kernel/skas/sys-i386/Makefile 2003-10-21 03:26:07.000000000 -0400
25148 +# Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
25149 +# Licensed under the GPL
25152 +O_TARGET = sys-i386.o
25154 +obj-y = sigcontext.o
25156 +USER_OBJS = sigcontext.o
25158 +include $(TOPDIR)/Rules.make
25160 +$(USER_OBJS) : %.o: %.c
25161 + $(CC) $(CFLAGS_$@) $(USER_CFLAGS) -c -o $@ $<
25164 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/sys-i386/sigcontext.c um/arch/um/kernel/skas/sys-i386/sigcontext.c
25165 --- orig/arch/um/kernel/skas/sys-i386/sigcontext.c 1969-12-31 19:00:00.000000000 -0500
25166 +++ um/arch/um/kernel/skas/sys-i386/sigcontext.c 2003-11-19 03:27:43.000000000 -0500
25169 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
25170 + * Licensed under the GPL
25173 +#include <errno.h>
25174 +#include <asm/sigcontext.h>
25175 +#include <sys/ptrace.h>
25176 +#include <linux/ptrace.h>
25177 +#include "sysdep/ptrace.h"
25178 +#include "sysdep/ptrace_user.h"
25179 +#include "kern_util.h"
25181 +#include "sigcontext.h"
25184 +int copy_sc_from_user_skas(int pid, union uml_pt_regs *regs, void *from_ptr)
25186 + struct sigcontext sc, *from = from_ptr;
25187 + unsigned long fpregs[FP_FRAME_SIZE];
25190 + err = copy_from_user_proc(&sc, from, sizeof(sc));
25191 + err |= copy_from_user_proc(fpregs, sc.fpstate, sizeof(fpregs));
25195 + regs->skas.regs[GS] = sc.gs;
25196 + regs->skas.regs[FS] = sc.fs;
25197 + regs->skas.regs[ES] = sc.es;
25198 + regs->skas.regs[DS] = sc.ds;
25199 + regs->skas.regs[EDI] = sc.edi;
25200 + regs->skas.regs[ESI] = sc.esi;
25201 + regs->skas.regs[EBP] = sc.ebp;
25202 + regs->skas.regs[UESP] = sc.esp;
25203 + regs->skas.regs[EBX] = sc.ebx;
25204 + regs->skas.regs[EDX] = sc.edx;
25205 + regs->skas.regs[ECX] = sc.ecx;
25206 + regs->skas.regs[EAX] = sc.eax;
25207 + regs->skas.regs[EIP] = sc.eip;
25208 + regs->skas.regs[CS] = sc.cs;
25209 + regs->skas.regs[EFL] = sc.eflags;
25210 + regs->skas.regs[SS] = sc.ss;
25211 + regs->skas.fault_addr = sc.cr2;
25212 + regs->skas.fault_type = FAULT_WRITE(sc.err);
25213 + regs->skas.trap_type = sc.trapno;
25215 + err = ptrace(PTRACE_SETFPREGS, pid, 0, fpregs);
25217 + printk("copy_sc_to_user - PTRACE_SETFPREGS failed, "
25218 + "errno = %d\n", errno);
25225 +int copy_sc_to_user_skas(int pid, void *to_ptr, void *fp,
25226 + union uml_pt_regs *regs, unsigned long fault_addr,
25229 + struct sigcontext sc, *to = to_ptr;
25230 + struct _fpstate *to_fp;
25231 + unsigned long fpregs[FP_FRAME_SIZE];
25234 + sc.gs = regs->skas.regs[GS];
25235 + sc.fs = regs->skas.regs[FS];
25236 + sc.es = regs->skas.regs[ES];
25237 + sc.ds = regs->skas.regs[DS];
25238 + sc.edi = regs->skas.regs[EDI];
25239 + sc.esi = regs->skas.regs[ESI];
25240 + sc.ebp = regs->skas.regs[EBP];
25241 + sc.esp = regs->skas.regs[UESP];
25242 + sc.ebx = regs->skas.regs[EBX];
25243 + sc.edx = regs->skas.regs[EDX];
25244 + sc.ecx = regs->skas.regs[ECX];
25245 + sc.eax = regs->skas.regs[EAX];
25246 + sc.eip = regs->skas.regs[EIP];
25247 + sc.cs = regs->skas.regs[CS];
25248 + sc.eflags = regs->skas.regs[EFL];
25249 + sc.esp_at_signal = regs->skas.regs[UESP];
25250 + sc.ss = regs->skas.regs[SS];
25251 + sc.cr2 = fault_addr;
25252 + sc.err = TO_SC_ERR(fault_type);
25253 + sc.trapno = regs->skas.trap_type;
25255 + err = ptrace(PTRACE_GETFPREGS, pid, 0, fpregs);
25257 + printk("copy_sc_to_user - PTRACE_GETFPREGS failed, "
25258 + "errno = %d\n", errno);
25261 + to_fp = (struct _fpstate *)
25262 + (fp ? (unsigned long) fp : ((unsigned long) to + sizeof(*to)));
25263 + sc.fpstate = to_fp;
25268 + return(copy_to_user_proc(to, &sc, sizeof(sc)) ||
25269 + copy_to_user_proc(to_fp, fpregs, sizeof(fpregs)));
25273 + * Overrides for Emacs so that we follow Linus's tabbing style.
25274 + * Emacs will notice this stuff at the end of the file and automatically
25275 + * adjust the settings for this buffer only. This must remain at the end
25277 + * ---------------------------------------------------------------------------
25278 + * Local variables:
25279 + * c-file-style: "linux"
25282 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/time.c um/arch/um/kernel/skas/time.c
25283 --- orig/arch/um/kernel/skas/time.c 1969-12-31 19:00:00.000000000 -0500
25284 +++ um/arch/um/kernel/skas/time.c 2003-10-21 03:26:07.000000000 -0400
25287 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
25288 + * Licensed under the GPL
25291 +#include <sys/signal.h>
25292 +#include <sys/time.h>
25293 +#include "time_user.h"
25294 +#include "process.h"
25297 +void user_time_init_skas(void)
25299 + if(signal(SIGALRM, (__sighandler_t) alarm_handler) == SIG_ERR)
25300 + panic("Couldn't set SIGALRM handler");
25301 + if(signal(SIGVTALRM, (__sighandler_t) alarm_handler) == SIG_ERR)
25302 + panic("Couldn't set SIGVTALRM handler");
25303 + set_interval(ITIMER_VIRTUAL);
25307 + * Overrides for Emacs so that we follow Linus's tabbing style.
25308 + * Emacs will notice this stuff at the end of the file and automatically
25309 + * adjust the settings for this buffer only. This must remain at the end
25311 + * ---------------------------------------------------------------------------
25312 + * Local variables:
25313 + * c-file-style: "linux"
25316 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/tlb.c um/arch/um/kernel/skas/tlb.c
25317 --- orig/arch/um/kernel/skas/tlb.c 1969-12-31 19:00:00.000000000 -0500
25318 +++ um/arch/um/kernel/skas/tlb.c 2003-10-21 03:26:07.000000000 -0400
25321 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
25322 + * Licensed under the GPL
25325 +#include "linux/stddef.h"
25326 +#include "linux/sched.h"
25327 +#include "asm/page.h"
25328 +#include "asm/pgtable.h"
25329 +#include "asm/mmu.h"
25330 +#include "user_util.h"
25331 +#include "mem_user.h"
25335 +static void fix_range(struct mm_struct *mm, unsigned long start_addr,
25336 + unsigned long end_addr, int force)
25341 + unsigned long addr;
25342 + int r, w, x, err, fd;
25344 + if(mm == NULL) return;
25345 + fd = mm->context.skas.mm_fd;
25346 + for(addr = start_addr; addr < end_addr;){
25347 + npgd = pgd_offset(mm, addr);
25348 + npmd = pmd_offset(npgd, addr);
25349 + if(pmd_present(*npmd)){
25350 + npte = pte_offset(npmd, addr);
25351 + r = pte_read(*npte);
25352 + w = pte_write(*npte);
25353 + x = pte_exec(*npte);
25354 + if(!pte_dirty(*npte)) w = 0;
25355 + if(!pte_young(*npte)){
25359 + if(force || pte_newpage(*npte)){
25360 + err = unmap(fd, (void *) addr, PAGE_SIZE);
25362 + panic("munmap failed, errno = %d\n",
25364 + if(pte_present(*npte))
25366 + pte_val(*npte) & PAGE_MASK,
25367 + PAGE_SIZE, r, w, x);
25369 + else if(pte_newprot(*npte)){
25370 + protect(fd, addr, PAGE_SIZE, r, w, x, 1);
25372 + *npte = pte_mkuptodate(*npte);
25373 + addr += PAGE_SIZE;
25376 + if(force || pmd_newpage(*npmd)){
25377 + err = unmap(fd, (void *) addr, PMD_SIZE);
25379 + panic("munmap failed, errno = %d\n",
25381 + pmd_mkuptodate(*npmd);
25383 + addr += PMD_SIZE;
25388 +static void flush_kernel_vm_range(unsigned long start, unsigned long end)
25390 + struct mm_struct *mm;
25394 + unsigned long addr;
25395 + int updated = 0, err;
25398 + for(addr = start_vm; addr < end_vm;){
25399 + pgd = pgd_offset(mm, addr);
25400 + pmd = pmd_offset(pgd, addr);
25401 + if(pmd_present(*pmd)){
25402 + pte = pte_offset(pmd, addr);
25403 + if(!pte_present(*pte) || pte_newpage(*pte)){
25405 + err = os_unmap_memory((void *) addr,
25408 + panic("munmap failed, errno = %d\n",
25410 + if(pte_present(*pte))
25412 + pte_val(*pte) & PAGE_MASK,
25413 + PAGE_SIZE, 1, 1, 1);
25415 + else if(pte_newprot(*pte)){
25417 + protect_memory(addr, PAGE_SIZE, 1, 1, 1, 1);
25419 + addr += PAGE_SIZE;
25422 + if(pmd_newpage(*pmd)){
25424 + err = os_unmap_memory((void *) addr, PMD_SIZE);
25426 + panic("munmap failed, errno = %d\n",
25429 + addr += PMD_SIZE;
25434 +void flush_tlb_kernel_vm_skas(void)
25436 + flush_kernel_vm_range(start_vm, end_vm);
25439 +void __flush_tlb_one_skas(unsigned long addr)
25441 + flush_kernel_vm_range(addr, addr + PAGE_SIZE);
25444 +void flush_tlb_range_skas(struct mm_struct *mm, unsigned long start,
25445 + unsigned long end)
25448 + flush_kernel_vm_range(start, end);
25449 + else fix_range(mm, start, end, 0);
25452 +void flush_tlb_mm_skas(struct mm_struct *mm)
25454 + flush_tlb_kernel_vm_skas();
25455 + fix_range(mm, 0, host_task_size, 0);
25458 +void force_flush_all_skas(void)
25460 + fix_range(current->mm, 0, host_task_size, 1);
25464 + * Overrides for Emacs so that we follow Linus's tabbing style.
25465 + * Emacs will notice this stuff at the end of the file and automatically
25466 + * adjust the settings for this buffer only. This must remain at the end
25468 + * ---------------------------------------------------------------------------
25469 + * Local variables:
25470 + * c-file-style: "linux"
25473 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/trap_user.c um/arch/um/kernel/skas/trap_user.c
25474 --- orig/arch/um/kernel/skas/trap_user.c 1969-12-31 19:00:00.000000000 -0500
25475 +++ um/arch/um/kernel/skas/trap_user.c 2004-01-21 01:17:05.000000000 -0500
25478 + * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com)
25479 + * Licensed under the GPL
25482 +#include <signal.h>
25483 +#include <errno.h>
25484 +#include <asm/sigcontext.h>
25485 +#include "sysdep/ptrace.h"
25486 +#include "signal_user.h"
25487 +#include "user_util.h"
25488 +#include "kern_util.h"
25490 +#include "sigcontext.h"
25492 +void sig_handler_common_skas(int sig, void *sc_ptr)
25494 + struct sigcontext *sc = sc_ptr;
25495 + struct skas_regs *r;
25496 + struct signal_info *info;
25497 + int save_errno = errno;
25500 + r = &TASK_REGS(get_current())->skas;
25501 + save_user = r->is_user;
25503 + r->fault_addr = SC_FAULT_ADDR(sc);
25504 + r->fault_type = SC_FAULT_TYPE(sc);
25505 + r->trap_type = SC_TRAP_TYPE(sc);
25507 + change_sig(SIGUSR1, 1);
25508 + info = &sig_info[sig];
25509 + if(!info->is_irq) unblock_signals();
25511 + (*info->handler)(sig, (union uml_pt_regs *) r);
25513 + errno = save_errno;
25514 + r->is_user = save_user;
25517 +extern int missed_ticks[];
25519 +void user_signal(int sig, union uml_pt_regs *regs)
25521 + struct signal_info *info;
25523 + regs->skas.is_user = 1;
25524 + regs->skas.fault_addr = 0;
25525 + regs->skas.fault_type = 0;
25526 + regs->skas.trap_type = 0;
25527 + info = &sig_info[sig];
25528 + (*info->handler)(sig, regs);
25530 + unblock_signals();
25534 + * Overrides for Emacs so that we follow Linus's tabbing style.
25535 + * Emacs will notice this stuff at the end of the file and automatically
25536 + * adjust the settings for this buffer only. This must remain at the end
25538 + * ---------------------------------------------------------------------------
25539 + * Local variables:
25540 + * c-file-style: "linux"
25543 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/uaccess.c um/arch/um/kernel/skas/uaccess.c
25544 --- orig/arch/um/kernel/skas/uaccess.c 1969-12-31 19:00:00.000000000 -0500
25545 +++ um/arch/um/kernel/skas/uaccess.c 2003-12-22 01:30:09.000000000 -0500
25548 + * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com)
25549 + * Licensed under the GPL
25552 +#include "linux/stddef.h"
25553 +#include "linux/kernel.h"
25554 +#include "linux/string.h"
25555 +#include "linux/fs.h"
25556 +#include "linux/highmem.h"
25557 +#include "asm/page.h"
25558 +#include "asm/pgtable.h"
25559 +#include "asm/uaccess.h"
25560 +#include "kern_util.h"
25562 +extern void *um_virt_to_phys(struct task_struct *task, unsigned long addr,
25565 +static unsigned long maybe_map(unsigned long virt, int is_write)
25569 + void *phys = um_virt_to_phys(current, virt, &pte);
25572 + if(IS_ERR(phys) || (is_write && !pte_write(pte))){
25573 + if(!handle_page_fault(virt, 0, is_write, 0, &dummy_code))
25575 + phys = um_virt_to_phys(current, virt, NULL);
25577 + return((unsigned long) phys);
25580 +static int do_op(unsigned long addr, int len, int is_write,
25581 + int (*op)(unsigned long addr, int len, void *arg), void *arg)
25583 + struct page *page;
25586 + addr = maybe_map(addr, is_write);
25590 + page = phys_to_page(addr);
25591 + addr = (unsigned long) kmap(page) + (addr & ~PAGE_MASK);
25592 + n = (*op)(addr, len, arg);
25598 +static int buffer_op(unsigned long addr, int len, int is_write,
25599 + int (*op)(unsigned long addr, int len, void *arg),
25602 + int size = min(PAGE_ALIGN(addr) - addr, (unsigned long) len);
25603 + int remain = len, n;
25605 + n = do_op(addr, size, is_write, op, arg);
25607 + return(n < 0 ? remain : 0);
25614 + while(addr < ((addr + remain) & PAGE_MASK)){
25615 + n = do_op(addr, PAGE_SIZE, is_write, op, arg);
25617 + return(n < 0 ? remain : 0);
25619 + addr += PAGE_SIZE;
25620 + remain -= PAGE_SIZE;
25625 + n = do_op(addr, remain, is_write, op, arg);
25627 + return(n < 0 ? remain : 0);
25631 +static int copy_chunk_from_user(unsigned long from, int len, void *arg)
25633 + unsigned long *to_ptr = arg, to = *to_ptr;
25635 + memcpy((void *) to, (void *) from, len);
25640 +int copy_from_user_skas(void *to, const void *from, int n)
25642 + if(segment_eq(get_fs(), KERNEL_DS)){
25643 + memcpy(to, from, n);
25647 + return(access_ok_skas(VERIFY_READ, from, n) ?
25648 + buffer_op((unsigned long) from, n, 0, copy_chunk_from_user, &to):
25652 +static int copy_chunk_to_user(unsigned long to, int len, void *arg)
25654 + unsigned long *from_ptr = arg, from = *from_ptr;
25656 + memcpy((void *) to, (void *) from, len);
25657 + *from_ptr += len;
25661 +int copy_to_user_skas(void *to, const void *from, int n)
25663 + if(segment_eq(get_fs(), KERNEL_DS)){
25664 + memcpy(to, from, n);
25668 + return(access_ok_skas(VERIFY_WRITE, to, n) ?
25669 + buffer_op((unsigned long) to, n, 1, copy_chunk_to_user, &from) :
25673 +static int strncpy_chunk_from_user(unsigned long from, int len, void *arg)
25675 + char **to_ptr = arg, *to = *to_ptr;
25678 + strncpy(to, (void *) from, len);
25679 + n = strnlen(to, len);
25687 +int strncpy_from_user_skas(char *dst, const char *src, int count)
25692 + if(segment_eq(get_fs(), KERNEL_DS)){
25693 + strncpy(dst, src, count);
25694 + return(strnlen(dst, count));
25697 + if(!access_ok_skas(VERIFY_READ, src, 1))
25700 + n = buffer_op((unsigned long) src, count, 0, strncpy_chunk_from_user,
25704 + return(strnlen(dst, count));
25707 +static int clear_chunk(unsigned long addr, int len, void *unused)
25709 + memset((void *) addr, 0, len);
25713 +int __clear_user_skas(void *mem, int len)
25715 + return(buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL));
25718 +int clear_user_skas(void *mem, int len)
25720 + if(segment_eq(get_fs(), KERNEL_DS)){
25721 + memset(mem, 0, len);
25725 + return(access_ok_skas(VERIFY_WRITE, mem, len) ?
25726 + buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL) : len);
25729 +static int strnlen_chunk(unsigned long str, int len, void *arg)
25731 + int *len_ptr = arg, n;
25733 + n = strnlen((void *) str, len);
25741 +int strnlen_user_skas(const void *str, int len)
25743 + int count = 0, n;
25745 + if(segment_eq(get_fs(), KERNEL_DS))
25746 + return(strnlen(str, len) + 1);
25748 + n = buffer_op((unsigned long) str, len, 0, strnlen_chunk, &count);
25750 + return(count + 1);
25755 + * Overrides for Emacs so that we follow Linus's tabbing style.
25756 + * Emacs will notice this stuff at the end of the file and automatically
25757 + * adjust the settings for this buffer only. This must remain at the end
25759 + * ---------------------------------------------------------------------------
25760 + * Local variables:
25761 + * c-file-style: "linux"
25764 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/util/Makefile um/arch/um/kernel/skas/util/Makefile
25765 --- orig/arch/um/kernel/skas/util/Makefile 1969-12-31 19:00:00.000000000 -0500
25766 +++ um/arch/um/kernel/skas/util/Makefile 2003-11-08 02:52:22.000000000 -0500
25770 +mk_ptregs : mk_ptregs.o
25771 + $(HOSTCC) -o mk_ptregs mk_ptregs.o
25773 +mk_ptregs.o : mk_ptregs.c
25777 + $(RM) -f mk_ptregs *.o *~
25778 diff -Naur -X ../exclude-files orig/arch/um/kernel/skas/util/mk_ptregs.c um/arch/um/kernel/skas/util/mk_ptregs.c
25779 --- orig/arch/um/kernel/skas/util/mk_ptregs.c 1969-12-31 19:00:00.000000000 -0500
25780 +++ um/arch/um/kernel/skas/util/mk_ptregs.c 2003-12-22 01:31:11.000000000 -0500
25782 +#include <stdio.h>
25783 +#include <asm/ptrace.h>
25784 +#include <asm/user.h>
25786 +#define PRINT_REG(name, val) printf("#define HOST_%s %d\n", (name), (val))
25788 +int main(int argc, char **argv)
25790 + printf("/* Automatically generated by "
25791 + "arch/um/kernel/skas/util/mk_ptregs */\n");
25793 + printf("#ifndef __SKAS_PT_REGS_\n");
25794 + printf("#define __SKAS_PT_REGS_\n");
25796 + printf("#define HOST_FRAME_SIZE %d\n", FRAME_SIZE);
25797 + printf("#define HOST_FP_SIZE %d\n",
25798 + sizeof(struct user_i387_struct) / sizeof(unsigned long));
25799 + printf("#define HOST_XFP_SIZE %d\n",
25800 + sizeof(struct user_fxsr_struct) / sizeof(unsigned long));
25802 + PRINT_REG("IP", EIP);
25803 + PRINT_REG("SP", UESP);
25804 + PRINT_REG("EFLAGS", EFL);
25805 + PRINT_REG("EAX", EAX);
25806 + PRINT_REG("EBX", EBX);
25807 + PRINT_REG("ECX", ECX);
25808 + PRINT_REG("EDX", EDX);
25809 + PRINT_REG("ESI", ESI);
25810 + PRINT_REG("EDI", EDI);
25811 + PRINT_REG("EBP", EBP);
25812 + PRINT_REG("CS", CS);
25813 + PRINT_REG("SS", SS);
25814 + PRINT_REG("DS", DS);
25815 + PRINT_REG("FS", FS);
25816 + PRINT_REG("ES", ES);
25817 + PRINT_REG("GS", GS);
25819 + printf("#endif\n");
25824 + * Overrides for Emacs so that we follow Linus's tabbing style.
25825 + * Emacs will notice this stuff at the end of the file and automatically
25826 + * adjust the settings for this buffer only. This must remain at the end
25828 + * ---------------------------------------------------------------------------
25829 + * Local variables:
25830 + * c-file-style: "linux"
25833 diff -Naur -X ../exclude-files orig/arch/um/kernel/smp.c um/arch/um/kernel/smp.c
25834 --- orig/arch/um/kernel/smp.c 1969-12-31 19:00:00.000000000 -0500
25835 +++ um/arch/um/kernel/smp.c 2003-11-15 02:59:25.000000000 -0500
25838 + * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
25839 + * Licensed under the GPL
25842 +#include "linux/config.h"
25846 +#include "linux/sched.h"
25847 +#include "linux/threads.h"
25848 +#include "linux/interrupt.h"
25849 +#include "asm/smp.h"
25850 +#include "asm/processor.h"
25851 +#include "asm/spinlock.h"
25852 +#include "asm/softirq.h"
25853 +#include "asm/hardirq.h"
25854 +#include "asm/tlb.h"
25855 +#include "user_util.h"
25856 +#include "kern_util.h"
25857 +#include "irq_user.h"
25861 +/* Total count of live CPUs, set by smp_boot_cpus */
25862 +int smp_num_cpus = 1;
25864 +/* The 'big kernel lock' */
25865 +spinlock_cacheline_t kernel_flag_cacheline = {SPIN_LOCK_UNLOCKED};
25867 +/* Per CPU bogomips and other parameters */
25869 +/* The only piece used here is the ipi pipe, which is set before SMP is
25870 + * started and never changed.
25872 +struct cpuinfo_um cpu_data[NR_CPUS];
25874 +/* CPU online map, set by smp_boot_cpus */
25875 +unsigned long cpu_online_map;
25877 +atomic_t global_bh_count;
25879 +/* Set when the idlers are all forked */
25880 +int smp_threads_ready = 0;
25882 +/* Not used by UML */
25883 +unsigned char global_irq_holder = 0;
25884 +unsigned volatile long global_irq_lock;
25886 +/* A statistic, can be a little off */
25887 +static int num_reschedules_sent = 0;
25889 +mmu_gather_t mmu_gathers[NR_CPUS];
25891 +void smp_send_reschedule(int cpu)
25893 + os_write_file(cpu_data[cpu].ipi_pipe[1], "R", 1);
25894 + num_reschedules_sent++;
25897 +static void show(char * str)
25899 + int cpu = smp_processor_id();
25901 + printk(KERN_INFO "\n%s, CPU %d:\n", str, cpu);
25904 +#define MAXCOUNT 100000000
25906 +static inline void wait_on_bh(void)
25908 + int count = MAXCOUNT;
25911 + show("wait_on_bh");
25914 + /* nothing .. wait for the other bh's to go away */
25915 + } while (atomic_read(&global_bh_count) != 0);
25919 + * This is called when we want to synchronize with
25920 + * bottom half handlers. We need to wait until
25921 + * no other CPU is executing any bottom half handler.
25923 + * Don't wait if we're already running in an interrupt
25924 + * context or are inside a bh handler.
25926 +void synchronize_bh(void)
25928 + if (atomic_read(&global_bh_count) && !in_interrupt())
25932 +void smp_send_stop(void)
25936 + printk(KERN_INFO "Stopping all CPUs...");
25937 + for(i = 0; i < ncpus; i++){
25938 + if(i == current->processor)
25940 + os_write_file(cpu_data[i].ipi_pipe[1], "S", 1);
25942 + printk("done\n");
25946 +static atomic_t smp_commenced = ATOMIC_INIT(0);
25947 +static volatile unsigned long smp_callin_map = 0;
25949 +void smp_commence(void)
25951 + printk("All CPUs are go!\n");
25954 + atomic_set(&smp_commenced, 1);
25957 +static int idle_proc(void *unused)
25961 + set_current(current);
25962 + del_from_runqueue(current);
25963 + unhash_process(current);
25965 + cpu = current->processor;
25966 + err = os_pipe(cpu_data[cpu].ipi_pipe, 1, 1);
25968 + panic("CPU#%d failed to create IPI pipe, err = %d", cpu, -err);
25970 + activate_ipi(cpu_data[cpu].ipi_pipe[0],
25971 + current->thread.mode.tt.extern_pid);
25974 + if (test_and_set_bit(current->processor, &smp_callin_map)) {
25975 + printk("huh, CPU#%d already present??\n", current->processor);
25979 + while (!atomic_read(&smp_commenced))
25987 +static int idle_thread(int (*fn)(void *), int cpu)
25989 + struct task_struct *new_task;
25993 + current->thread.request.u.thread.proc = fn;
25994 + current->thread.request.u.thread.arg = NULL;
25995 + pid = do_fork(CLONE_VM | CLONE_PID, 0, NULL, 0);
25997 + panic("do_fork failed in idle_thread");
25998 + new_task = get_task(pid, 1);
26000 + cpu_tasks[cpu] = ((struct cpu_task)
26001 + { .pid = new_task->thread.mode.tt.extern_pid,
26002 + .task = new_task } );
26003 + init_tasks[cpu] = new_task;
26004 + new_task->processor = cpu;
26005 + new_task->cpus_allowed = 1 << cpu;
26006 + new_task->cpus_runnable = new_task->cpus_allowed;
26007 + CHOOSE_MODE(os_write_file(new_task->thread.mode.tt.switch_pipe[1], &c,
26009 + ({ panic("skas mode doesn't support SMP"); }));
26010 + return(new_task->thread.mode.tt.extern_pid);
26013 +void smp_boot_cpus(void)
26017 + set_bit(0, &cpu_online_map);
26018 + set_bit(0, &smp_callin_map);
26020 + err = os_pipe(cpu_data[0].ipi_pipe, 1, 1);
26022 + panic("CPU#0 failed to create IPI pipe, err = %d", -err);
26024 + activate_ipi(cpu_data[0].ipi_pipe[0],
26025 + current->thread.mode.tt.extern_pid);
26028 + printk(KERN_INFO "ncpus set to 1\n");
26031 + else if(ncpus > NR_CPUS){
26033 + "ncpus can't be greater than NR_CPUS, set to %d\n",
26041 + printk(KERN_INFO "Starting up other processors:\n");
26042 + for(i=1;i<ncpus;i++){
26045 + /* Do this early, for hard_smp_processor_id() */
26046 + cpu_tasks[i].pid = -1;
26047 + set_bit(i, &cpu_online_map);
26050 + pid = idle_thread(idle_proc, i);
26051 + printk(KERN_INFO "\t#%d - idle thread pid = %d.. ",
26054 + waittime = 200000000;
26055 + while (waittime-- && !test_bit(i, &smp_callin_map))
26058 + if (test_bit(i, &smp_callin_map))
26059 + printk("online\n");
26061 + printk("failed\n");
26062 + clear_bit(i, &cpu_online_map);
26068 +int setup_profiling_timer(unsigned int multiplier)
26070 + printk(KERN_INFO "setup_profiling_timer\n");
26074 +void smp_call_function_slave(int cpu);
26076 +void IPI_handler(int cpu)
26081 + fd = cpu_data[cpu].ipi_pipe[0];
26082 + while (os_read_file(fd, &c, 1) == 1) {
26085 + smp_call_function_slave(cpu);
26089 + current->need_resched = 1;
26093 + printk("CPU#%d stopping\n", cpu);
26099 + printk("CPU#%d received unknown IPI [%c]!\n", cpu, c);
26105 +int hard_smp_processor_id(void)
26107 + return(pid_to_processor_id(os_getpid()));
26110 +static spinlock_t call_lock = SPIN_LOCK_UNLOCKED;
26111 +static atomic_t scf_started;
26112 +static atomic_t scf_finished;
26113 +static void (*func)(void *info);
26114 +static void *info;
26116 +void smp_call_function_slave(int cpu)
26118 + atomic_inc(&scf_started);
26120 + atomic_inc(&scf_finished);
26123 +int smp_call_function(void (*_func)(void *info), void *_info, int nonatomic,
26126 + int cpus = smp_num_cpus - 1;
26132 + spin_lock_bh(&call_lock);
26133 + atomic_set(&scf_started, 0);
26134 + atomic_set(&scf_finished, 0);
26138 + for (i=0;i<NR_CPUS;i++)
26139 + if (i != current->processor && test_bit(i, &cpu_online_map))
26140 + os_write_file(cpu_data[i].ipi_pipe[1], "C", 1);
26142 + while (atomic_read(&scf_started) != cpus)
26146 + while (atomic_read(&scf_finished) != cpus)
26149 + spin_unlock_bh(&call_lock);
26156 + * Overrides for Emacs so that we follow Linus's tabbing style.
26157 + * Emacs will notice this stuff at the end of the file and automatically
26158 + * adjust the settings for this buffer only. This must remain at the end
26160 + * ---------------------------------------------------------------------------
26161 + * Local variables:
26162 + * c-file-style: "linux"
26165 diff -Naur -X ../exclude-files orig/arch/um/kernel/syscall_kern.c um/arch/um/kernel/syscall_kern.c
26166 --- orig/arch/um/kernel/syscall_kern.c 1969-12-31 19:00:00.000000000 -0500
26167 +++ um/arch/um/kernel/syscall_kern.c 2004-01-10 06:37:46.000000000 -0500
26170 + * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
26171 + * Licensed under the GPL
26174 +#include "linux/sched.h"
26175 +#include "linux/file.h"
26176 +#include "linux/smp_lock.h"
26177 +#include "linux/mm.h"
26178 +#include "linux/utsname.h"
26179 +#include "linux/msg.h"
26180 +#include "linux/shm.h"
26181 +#include "linux/sys.h"
26182 +#include "linux/unistd.h"
26183 +#include "linux/slab.h"
26184 +#include "linux/utime.h"
26185 +#include "asm/mman.h"
26186 +#include "asm/uaccess.h"
26187 +#include "asm/ipc.h"
26188 +#include "kern_util.h"
26189 +#include "user_util.h"
26190 +#include "sysdep/syscalls.h"
26191 +#include "mode_kern.h"
26192 +#include "choose-mode.h"
26194 +/* Unlocked, I don't care if this is a bit off */
26195 +int nsyscalls = 0;
26197 +long um_mount(char * dev_name, char * dir_name, char * type,
26198 + unsigned long new_flags, void * data)
26200 + if(type == NULL) type = "";
26201 + return(sys_mount(dev_name, dir_name, type, new_flags, data));
26204 +long sys_fork(void)
26208 + current->thread.forking = 1;
26209 + ret = do_fork(SIGCHLD, 0, NULL, 0);
26210 + current->thread.forking = 0;
26214 +long sys_clone(unsigned long clone_flags, unsigned long newsp)
26218 + current->thread.forking = 1;
26219 + ret = do_fork(clone_flags, newsp, NULL, 0);
26220 + current->thread.forking = 0;
26224 +long sys_vfork(void)
26228 + current->thread.forking = 1;
26229 + ret = do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0, NULL, 0);
26230 + current->thread.forking = 0;
26234 +/* common code for old and new mmaps */
26235 +long do_mmap2(struct mm_struct *mm, unsigned long addr, unsigned long len,
26236 + unsigned long prot, unsigned long flags, unsigned long fd,
26237 + unsigned long pgoff)
26239 + int error = -EBADF;
26240 + struct file * file = NULL;
26242 + flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
26243 + if (!(flags & MAP_ANONYMOUS)) {
26249 + down_write(&mm->mmap_sem);
26250 + error = do_mmap_pgoff(mm, file, addr, len, prot, flags, pgoff);
26251 + up_write(&mm->mmap_sem);
26259 +long sys_mmap2(unsigned long addr, unsigned long len,
26260 + unsigned long prot, unsigned long flags,
26261 + unsigned long fd, unsigned long pgoff)
26263 + return do_mmap2(current->mm, addr, len, prot, flags, fd, pgoff);
26267 + * Perform the select(nd, in, out, ex, tv) and mmap() system
26268 + * calls. Linux/i386 didn't use to be able to handle more than
26269 + * 4 system call parameters, so these system calls used a memory
26270 + * block for parameter passing..
26273 +struct mmap_arg_struct {
26274 + unsigned long addr;
26275 + unsigned long len;
26276 + unsigned long prot;
26277 + unsigned long flags;
26278 + unsigned long fd;
26279 + unsigned long offset;
26282 +int old_mmap(unsigned long addr, unsigned long len,
26283 + unsigned long prot, unsigned long flags,
26284 + unsigned long fd, unsigned long offset)
26286 + int err = -EINVAL;
26287 + if (offset & ~PAGE_MASK)
26290 + err = do_mmap2(current->mm, addr, len, prot, flags, fd,
26291 + offset >> PAGE_SHIFT);
26296 + * sys_pipe() is the normal C calling standard for creating
26297 + * a pipe. It's not the way unix traditionally does this, though.
26299 +int sys_pipe(unsigned long * fildes)
26304 + error = do_pipe(fd);
26306 + if (copy_to_user(fildes, fd, sizeof(fd)))
26312 +int sys_pause(void)
26314 + current->state = TASK_INTERRUPTIBLE;
26316 + return -ERESTARTNOHAND;
26319 +int sys_sigaction(int sig, const struct old_sigaction *act,
26320 + struct old_sigaction *oact)
26322 + struct k_sigaction new_ka, old_ka;
26326 + old_sigset_t mask;
26327 + if (verify_area(VERIFY_READ, act, sizeof(*act)) ||
26328 + __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
26329 + __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
26331 + __get_user(new_ka.sa.sa_flags, &act->sa_flags);
26332 + __get_user(mask, &act->sa_mask);
26333 + siginitset(&new_ka.sa.sa_mask, mask);
26336 + ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
26338 + if (!ret && oact) {
26339 + if (verify_area(VERIFY_WRITE, oact, sizeof(*oact)) ||
26340 + __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
26341 + __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
26343 + __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
26344 + __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
26351 + * sys_ipc() is the de-multiplexer for the SysV IPC calls..
26353 + * This is really horribly ugly.
26355 +int sys_ipc (uint call, int first, int second,
26356 + int third, void *ptr, long fifth)
26358 + int version, ret;
26360 + version = call >> 16; /* hack for backward compatibility */
26365 + return sys_semop (first, (struct sembuf *)ptr, second);
26367 + return sys_semget (first, second, third);
26369 + union semun fourth;
26372 + if (get_user(fourth.__pad, (void **) ptr))
26374 + return sys_semctl (first, second, third, fourth);
26378 + return sys_msgsnd (first, (struct msgbuf *) ptr,
26381 + switch (version) {
26383 + struct ipc_kludge tmp;
26387 + if (copy_from_user(&tmp,
26388 + (struct ipc_kludge *) ptr,
26391 + return sys_msgrcv (first, tmp.msgp, second,
26392 + tmp.msgtyp, third);
26395 + panic("msgrcv with version != 0");
26396 + return sys_msgrcv (first,
26397 + (struct msgbuf *) ptr,
26398 + second, fifth, third);
26401 + return sys_msgget ((key_t) first, second);
26403 + return sys_msgctl (first, second, (struct msqid_ds *) ptr);
26406 + switch (version) {
26409 + ret = sys_shmat (first, (char *) ptr, second, &raddr);
26412 + return put_user (raddr, (ulong *) third);
26414 + case 1: /* iBCS2 emulator entry point */
26415 + if (!segment_eq(get_fs(), get_ds()))
26417 + return sys_shmat (first, (char *) ptr, second, (ulong *) third);
26420 + return sys_shmdt ((char *)ptr);
26422 + return sys_shmget (first, second, third);
26424 + return sys_shmctl (first, second,
26425 + (struct shmid_ds *) ptr);
26431 +int sys_uname(struct old_utsname * name)
26436 + down_read(&uts_sem);
26437 + err=copy_to_user(name, &system_utsname, sizeof (*name));
26438 + up_read(&uts_sem);
26439 + return err?-EFAULT:0;
26442 +int sys_olduname(struct oldold_utsname * name)
26448 + if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname)))
26451 + down_read(&uts_sem);
26453 + error = __copy_to_user(&name->sysname,&system_utsname.sysname,
26455 + error |= __put_user(0,name->sysname+__OLD_UTS_LEN);
26456 + error |= __copy_to_user(&name->nodename,&system_utsname.nodename,
26458 + error |= __put_user(0,name->nodename+__OLD_UTS_LEN);
26459 + error |= __copy_to_user(&name->release,&system_utsname.release,
26461 + error |= __put_user(0,name->release+__OLD_UTS_LEN);
26462 + error |= __copy_to_user(&name->version,&system_utsname.version,
26464 + error |= __put_user(0,name->version+__OLD_UTS_LEN);
26465 + error |= __copy_to_user(&name->machine,&system_utsname.machine,
26467 + error |= __put_user(0,name->machine+__OLD_UTS_LEN);
26469 + up_read(&uts_sem);
26471 + error = error ? -EFAULT : 0;
26476 +int sys_sigaltstack(const stack_t *uss, stack_t *uoss)
26478 + return(do_sigaltstack(uss, uoss, PT_REGS_SP(¤t->thread.regs)));
26481 +long execute_syscall(void *r)
26483 + return(CHOOSE_MODE_PROC(execute_syscall_tt, execute_syscall_skas, r));
26486 +spinlock_t syscall_lock = SPIN_LOCK_UNLOCKED;
26488 +static int syscall_index = 0;
26490 +int next_syscall_index(int limit)
26494 + spin_lock(&syscall_lock);
26495 + ret = syscall_index;
26496 + if(++syscall_index == limit)
26497 + syscall_index = 0;
26498 + spin_unlock(&syscall_lock);
26503 + * Overrides for Emacs so that we follow Linus's tabbing style.
26504 + * Emacs will notice this stuff at the end of the file and automatically
26505 + * adjust the settings for this buffer only. This must remain at the end
26507 + * ---------------------------------------------------------------------------
26508 + * Local variables:
26509 + * c-file-style: "linux"
26512 diff -Naur -X ../exclude-files orig/arch/um/kernel/sys_call_table.c um/arch/um/kernel/sys_call_table.c
26513 --- orig/arch/um/kernel/sys_call_table.c 1969-12-31 19:00:00.000000000 -0500
26514 +++ um/arch/um/kernel/sys_call_table.c 2003-10-21 03:26:07.000000000 -0400
26517 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
26518 + * Licensed under the GPL
26521 +#include "linux/unistd.h"
26522 +#include "linux/version.h"
26523 +#include "linux/sys.h"
26524 +#include "asm/signal.h"
26525 +#include "sysdep/syscalls.h"
26526 +#include "kern_util.h"
26528 +extern syscall_handler_t sys_ni_syscall;
26529 +extern syscall_handler_t sys_exit;
26530 +extern syscall_handler_t sys_fork;
26531 +extern syscall_handler_t sys_creat;
26532 +extern syscall_handler_t sys_link;
26533 +extern syscall_handler_t sys_unlink;
26534 +extern syscall_handler_t sys_chdir;
26535 +extern syscall_handler_t sys_mknod;
26536 +extern syscall_handler_t sys_chmod;
26537 +extern syscall_handler_t sys_lchown16;
26538 +extern syscall_handler_t sys_ni_syscall;
26539 +extern syscall_handler_t sys_stat;
26540 +extern syscall_handler_t sys_getpid;
26541 +extern syscall_handler_t sys_oldumount;
26542 +extern syscall_handler_t sys_setuid16;
26543 +extern syscall_handler_t sys_getuid16;
26544 +extern syscall_handler_t sys_ptrace;
26545 +extern syscall_handler_t sys_alarm;
26546 +extern syscall_handler_t sys_fstat;
26547 +extern syscall_handler_t sys_pause;
26548 +extern syscall_handler_t sys_utime;
26549 +extern syscall_handler_t sys_ni_syscall;
26550 +extern syscall_handler_t sys_ni_syscall;
26551 +extern syscall_handler_t sys_access;
26552 +extern syscall_handler_t sys_nice;
26553 +extern syscall_handler_t sys_ni_syscall;
26554 +extern syscall_handler_t sys_sync;
26555 +extern syscall_handler_t sys_kill;
26556 +extern syscall_handler_t sys_rename;
26557 +extern syscall_handler_t sys_mkdir;
26558 +extern syscall_handler_t sys_rmdir;
26559 +extern syscall_handler_t sys_pipe;
26560 +extern syscall_handler_t sys_times;
26561 +extern syscall_handler_t sys_ni_syscall;
26562 +extern syscall_handler_t sys_brk;
26563 +extern syscall_handler_t sys_setgid16;
26564 +extern syscall_handler_t sys_getgid16;
26565 +extern syscall_handler_t sys_signal;
26566 +extern syscall_handler_t sys_geteuid16;
26567 +extern syscall_handler_t sys_getegid16;
26568 +extern syscall_handler_t sys_acct;
26569 +extern syscall_handler_t sys_umount;
26570 +extern syscall_handler_t sys_ni_syscall;
26571 +extern syscall_handler_t sys_ioctl;
26572 +extern syscall_handler_t sys_fcntl;
26573 +extern syscall_handler_t sys_ni_syscall;
26574 +extern syscall_handler_t sys_setpgid;
26575 +extern syscall_handler_t sys_ni_syscall;
26576 +extern syscall_handler_t sys_olduname;
26577 +extern syscall_handler_t sys_umask;
26578 +extern syscall_handler_t sys_chroot;
26579 +extern syscall_handler_t sys_ustat;
26580 +extern syscall_handler_t sys_dup2;
26581 +extern syscall_handler_t sys_getppid;
26582 +extern syscall_handler_t sys_getpgrp;
26583 +extern syscall_handler_t sys_sigaction;
26584 +extern syscall_handler_t sys_sgetmask;
26585 +extern syscall_handler_t sys_ssetmask;
26586 +extern syscall_handler_t sys_setreuid16;
26587 +extern syscall_handler_t sys_setregid16;
26588 +extern syscall_handler_t sys_sigsuspend;
26589 +extern syscall_handler_t sys_sigpending;
26590 +extern syscall_handler_t sys_sethostname;
26591 +extern syscall_handler_t sys_setrlimit;
26592 +extern syscall_handler_t sys_old_getrlimit;
26593 +extern syscall_handler_t sys_getrusage;
26594 +extern syscall_handler_t sys_gettimeofday;
26595 +extern syscall_handler_t sys_settimeofday;
26596 +extern syscall_handler_t sys_getgroups16;
26597 +extern syscall_handler_t sys_setgroups16;
26598 +extern syscall_handler_t sys_symlink;
26599 +extern syscall_handler_t sys_lstat;
26600 +extern syscall_handler_t sys_readlink;
26601 +extern syscall_handler_t sys_uselib;
26602 +extern syscall_handler_t sys_swapon;
26603 +extern syscall_handler_t sys_reboot;
26604 +extern syscall_handler_t old_readdir;
26605 +extern syscall_handler_t sys_munmap;
26606 +extern syscall_handler_t sys_truncate;
26607 +extern syscall_handler_t sys_ftruncate;
26608 +extern syscall_handler_t sys_fchmod;
26609 +extern syscall_handler_t sys_fchown16;
26610 +extern syscall_handler_t sys_getpriority;
26611 +extern syscall_handler_t sys_setpriority;
26612 +extern syscall_handler_t sys_ni_syscall;
26613 +extern syscall_handler_t sys_statfs;
26614 +extern syscall_handler_t sys_fstatfs;
26615 +extern syscall_handler_t sys_ni_syscall;
26616 +extern syscall_handler_t sys_socketcall;
26617 +extern syscall_handler_t sys_syslog;
26618 +extern syscall_handler_t sys_setitimer;
26619 +extern syscall_handler_t sys_getitimer;
26620 +extern syscall_handler_t sys_newstat;
26621 +extern syscall_handler_t sys_newlstat;
26622 +extern syscall_handler_t sys_newfstat;
26623 +extern syscall_handler_t sys_uname;
26624 +extern syscall_handler_t sys_ni_syscall;
26625 +extern syscall_handler_t sys_vhangup;
26626 +extern syscall_handler_t sys_ni_syscall;
26627 +extern syscall_handler_t sys_ni_syscall;
26628 +extern syscall_handler_t sys_swapoff;
26629 +extern syscall_handler_t sys_sysinfo;
26630 +extern syscall_handler_t sys_ipc;
26631 +extern syscall_handler_t sys_fsync;
26632 +extern syscall_handler_t sys_sigreturn;
26633 +extern syscall_handler_t sys_rt_sigreturn;
26634 +extern syscall_handler_t sys_clone;
26635 +extern syscall_handler_t sys_setdomainname;
26636 +extern syscall_handler_t sys_newuname;
26637 +extern syscall_handler_t sys_ni_syscall;
26638 +extern syscall_handler_t sys_adjtimex;
26639 +extern syscall_handler_t sys_mprotect;
26640 +extern syscall_handler_t sys_sigprocmask;
26641 +extern syscall_handler_t sys_create_module;
26642 +extern syscall_handler_t sys_init_module;
26643 +extern syscall_handler_t sys_delete_module;
26644 +extern syscall_handler_t sys_get_kernel_syms;
26645 +extern syscall_handler_t sys_quotactl;
26646 +extern syscall_handler_t sys_getpgid;
26647 +extern syscall_handler_t sys_fchdir;
26648 +extern syscall_handler_t sys_bdflush;
26649 +extern syscall_handler_t sys_sysfs;
26650 +extern syscall_handler_t sys_personality;
26651 +extern syscall_handler_t sys_ni_syscall;
26652 +extern syscall_handler_t sys_setfsuid16;
26653 +extern syscall_handler_t sys_setfsgid16;
26654 +extern syscall_handler_t sys_llseek;
26655 +extern syscall_handler_t sys_getdents;
26656 +extern syscall_handler_t sys_flock;
26657 +extern syscall_handler_t sys_msync;
26658 +extern syscall_handler_t sys_readv;
26659 +extern syscall_handler_t sys_writev;
26660 +extern syscall_handler_t sys_getsid;
26661 +extern syscall_handler_t sys_fdatasync;
26662 +extern syscall_handler_t sys_sysctl;
26663 +extern syscall_handler_t sys_mlock;
26664 +extern syscall_handler_t sys_munlock;
26665 +extern syscall_handler_t sys_mlockall;
26666 +extern syscall_handler_t sys_munlockall;
26667 +extern syscall_handler_t sys_sched_setparam;
26668 +extern syscall_handler_t sys_sched_getparam;
26669 +extern syscall_handler_t sys_sched_setscheduler;
26670 +extern syscall_handler_t sys_sched_getscheduler;
26671 +extern syscall_handler_t sys_sched_get_priority_max;
26672 +extern syscall_handler_t sys_sched_get_priority_min;
26673 +extern syscall_handler_t sys_sched_rr_get_interval;
26674 +extern syscall_handler_t sys_nanosleep;
26675 +extern syscall_handler_t sys_mremap;
26676 +extern syscall_handler_t sys_setresuid16;
26677 +extern syscall_handler_t sys_getresuid16;
26678 +extern syscall_handler_t sys_ni_syscall;
26679 +extern syscall_handler_t sys_query_module;
26680 +extern syscall_handler_t sys_poll;
26681 +extern syscall_handler_t sys_nfsservctl;
26682 +extern syscall_handler_t sys_setresgid16;
26683 +extern syscall_handler_t sys_getresgid16;
26684 +extern syscall_handler_t sys_prctl;
26685 +extern syscall_handler_t sys_ni_syscall;
26686 +extern syscall_handler_t sys_rt_sigaction;
26687 +extern syscall_handler_t sys_rt_sigprocmask;
26688 +extern syscall_handler_t sys_rt_sigpending;
26689 +extern syscall_handler_t sys_rt_sigtimedwait;
26690 +extern syscall_handler_t sys_rt_sigqueueinfo;
26691 +extern syscall_handler_t sys_rt_sigsuspend;
26692 +extern syscall_handler_t sys_pread;
26693 +extern syscall_handler_t sys_pwrite;
26694 +extern syscall_handler_t sys_chown16;
26695 +extern syscall_handler_t sys_getcwd;
26696 +extern syscall_handler_t sys_capget;
26697 +extern syscall_handler_t sys_capset;
26698 +extern syscall_handler_t sys_sigaltstack;
26699 +extern syscall_handler_t sys_sendfile;
26700 +extern syscall_handler_t sys_ni_syscall;
26701 +extern syscall_handler_t sys_ni_syscall;
26702 +extern syscall_handler_t sys_vfork;
26703 +extern syscall_handler_t sys_getrlimit;
26704 +extern syscall_handler_t sys_mmap2;
26705 +extern syscall_handler_t sys_truncate64;
26706 +extern syscall_handler_t sys_ftruncate64;
26707 +extern syscall_handler_t sys_stat64;
26708 +extern syscall_handler_t sys_lstat64;
26709 +extern syscall_handler_t sys_fstat64;
26710 +extern syscall_handler_t sys_lchown;
26711 +extern syscall_handler_t sys_getuid;
26712 +extern syscall_handler_t sys_getgid;
26713 +extern syscall_handler_t sys_geteuid;
26714 +extern syscall_handler_t sys_getegid;
26715 +extern syscall_handler_t sys_setreuid;
26716 +extern syscall_handler_t sys_setregid;
26717 +extern syscall_handler_t sys_getgroups;
26718 +extern syscall_handler_t sys_setgroups;
26719 +extern syscall_handler_t sys_fchown;
26720 +extern syscall_handler_t sys_setresuid;
26721 +extern syscall_handler_t sys_getresuid;
26722 +extern syscall_handler_t sys_setresgid;
26723 +extern syscall_handler_t sys_getresgid;
26724 +extern syscall_handler_t sys_chown;
26725 +extern syscall_handler_t sys_setuid;
26726 +extern syscall_handler_t sys_setgid;
26727 +extern syscall_handler_t sys_setfsuid;
26728 +extern syscall_handler_t sys_setfsgid;
26729 +extern syscall_handler_t sys_pivot_root;
26730 +extern syscall_handler_t sys_mincore;
26731 +extern syscall_handler_t sys_madvise;
26732 +extern syscall_handler_t sys_fcntl64;
26733 +extern syscall_handler_t sys_getdents64;
26734 +extern syscall_handler_t sys_gettid;
26735 +extern syscall_handler_t sys_readahead;
26736 +extern syscall_handler_t sys_tkill;
26737 +extern syscall_handler_t sys_setxattr;
26738 +extern syscall_handler_t sys_lsetxattr;
26739 +extern syscall_handler_t sys_fsetxattr;
26740 +extern syscall_handler_t sys_getxattr;
26741 +extern syscall_handler_t sys_lgetxattr;
26742 +extern syscall_handler_t sys_fgetxattr;
26743 +extern syscall_handler_t sys_listxattr;
26744 +extern syscall_handler_t sys_llistxattr;
26745 +extern syscall_handler_t sys_flistxattr;
26746 +extern syscall_handler_t sys_removexattr;
26747 +extern syscall_handler_t sys_lremovexattr;
26748 +extern syscall_handler_t sys_fremovexattr;
26749 +extern syscall_handler_t sys_sendfile64;
26751 +extern syscall_handler_t um_mount;
26752 +extern syscall_handler_t um_time;
26753 +extern syscall_handler_t um_stime;
26755 +#define LAST_GENERIC_SYSCALL __NR_exit_group
26757 +#if LAST_GENERIC_SYSCALL > LAST_ARCH_SYSCALL
26758 +#define LAST_SYSCALL LAST_GENERIC_SYSCALL
26760 +#define LAST_SYSCALL LAST_ARCH_SYSCALL
26763 +syscall_handler_t *sys_call_table[] = {
26764 + [ 0 ] = sys_ni_syscall,
26765 + [ __NR_exit ] = sys_exit,
26766 + [ __NR_fork ] = sys_fork,
26767 + [ __NR_read ] = (syscall_handler_t *) sys_read,
26768 + [ __NR_write ] = (syscall_handler_t *) sys_write,
26770 + /* These three are declared differently in asm/unistd.h */
26771 + [ __NR_open ] = (syscall_handler_t *) sys_open,
26772 + [ __NR_close ] = (syscall_handler_t *) sys_close,
26773 + [ __NR_waitpid ] = (syscall_handler_t *) sys_waitpid,
26774 + [ __NR_creat ] = sys_creat,
26775 + [ __NR_link ] = sys_link,
26776 + [ __NR_unlink ] = sys_unlink,
26778 + /* declared differently in kern_util.h */
26779 + [ __NR_execve ] = (syscall_handler_t *) sys_execve,
26780 + [ __NR_chdir ] = sys_chdir,
26781 + [ __NR_time ] = um_time,
26782 + [ __NR_mknod ] = sys_mknod,
26783 + [ __NR_chmod ] = sys_chmod,
26784 + [ __NR_lchown ] = sys_lchown16,
26785 + [ __NR_break ] = sys_ni_syscall,
26786 + [ __NR_oldstat ] = sys_stat,
26787 + [ __NR_lseek ] = (syscall_handler_t *) sys_lseek,
26788 + [ __NR_getpid ] = sys_getpid,
26789 + [ __NR_mount ] = um_mount,
26790 + [ __NR_umount ] = sys_oldumount,
26791 + [ __NR_setuid ] = sys_setuid16,
26792 + [ __NR_getuid ] = sys_getuid16,
26793 + [ __NR_stime ] = um_stime,
26794 + [ __NR_ptrace ] = sys_ptrace,
26795 + [ __NR_alarm ] = sys_alarm,
26796 + [ __NR_oldfstat ] = sys_fstat,
26797 + [ __NR_pause ] = sys_pause,
26798 + [ __NR_utime ] = sys_utime,
26799 + [ __NR_stty ] = sys_ni_syscall,
26800 + [ __NR_gtty ] = sys_ni_syscall,
26801 + [ __NR_access ] = sys_access,
26802 + [ __NR_nice ] = sys_nice,
26803 + [ __NR_ftime ] = sys_ni_syscall,
26804 + [ __NR_sync ] = sys_sync,
26805 + [ __NR_kill ] = sys_kill,
26806 + [ __NR_rename ] = sys_rename,
26807 + [ __NR_mkdir ] = sys_mkdir,
26808 + [ __NR_rmdir ] = sys_rmdir,
26810 + /* Declared differently in asm/unistd.h */
26811 + [ __NR_dup ] = (syscall_handler_t *) sys_dup,
26812 + [ __NR_pipe ] = sys_pipe,
26813 + [ __NR_times ] = sys_times,
26814 + [ __NR_prof ] = sys_ni_syscall,
26815 + [ __NR_brk ] = sys_brk,
26816 + [ __NR_setgid ] = sys_setgid16,
26817 + [ __NR_getgid ] = sys_getgid16,
26818 + [ __NR_signal ] = sys_signal,
26819 + [ __NR_geteuid ] = sys_geteuid16,
26820 + [ __NR_getegid ] = sys_getegid16,
26821 + [ __NR_acct ] = sys_acct,
26822 + [ __NR_umount2 ] = sys_umount,
26823 + [ __NR_lock ] = sys_ni_syscall,
26824 + [ __NR_ioctl ] = sys_ioctl,
26825 + [ __NR_fcntl ] = sys_fcntl,
26826 + [ __NR_mpx ] = sys_ni_syscall,
26827 + [ __NR_setpgid ] = sys_setpgid,
26828 + [ __NR_ulimit ] = sys_ni_syscall,
26829 + [ __NR_oldolduname ] = sys_olduname,
26830 + [ __NR_umask ] = sys_umask,
26831 + [ __NR_chroot ] = sys_chroot,
26832 + [ __NR_ustat ] = sys_ustat,
26833 + [ __NR_dup2 ] = sys_dup2,
26834 + [ __NR_getppid ] = sys_getppid,
26835 + [ __NR_getpgrp ] = sys_getpgrp,
26836 + [ __NR_setsid ] = (syscall_handler_t *) sys_setsid,
26837 + [ __NR_sigaction ] = sys_sigaction,
26838 + [ __NR_sgetmask ] = sys_sgetmask,
26839 + [ __NR_ssetmask ] = sys_ssetmask,
26840 + [ __NR_setreuid ] = sys_setreuid16,
26841 + [ __NR_setregid ] = sys_setregid16,
26842 + [ __NR_sigsuspend ] = sys_sigsuspend,
26843 + [ __NR_sigpending ] = sys_sigpending,
26844 + [ __NR_sethostname ] = sys_sethostname,
26845 + [ __NR_setrlimit ] = sys_setrlimit,
26846 + [ __NR_getrlimit ] = sys_old_getrlimit,
26847 + [ __NR_getrusage ] = sys_getrusage,
26848 + [ __NR_gettimeofday ] = sys_gettimeofday,
26849 + [ __NR_settimeofday ] = sys_settimeofday,
26850 + [ __NR_getgroups ] = sys_getgroups16,
26851 + [ __NR_setgroups ] = sys_setgroups16,
26852 + [ __NR_symlink ] = sys_symlink,
26853 + [ __NR_oldlstat ] = sys_lstat,
26854 + [ __NR_readlink ] = sys_readlink,
26855 + [ __NR_uselib ] = sys_uselib,
26856 + [ __NR_swapon ] = sys_swapon,
26857 + [ __NR_reboot ] = sys_reboot,
26858 + [ __NR_readdir ] = old_readdir,
26859 + [ __NR_munmap ] = sys_munmap,
26860 + [ __NR_truncate ] = sys_truncate,
26861 + [ __NR_ftruncate ] = sys_ftruncate,
26862 + [ __NR_fchmod ] = sys_fchmod,
26863 + [ __NR_fchown ] = sys_fchown16,
26864 + [ __NR_getpriority ] = sys_getpriority,
26865 + [ __NR_setpriority ] = sys_setpriority,
26866 + [ __NR_profil ] = sys_ni_syscall,
26867 + [ __NR_statfs ] = sys_statfs,
26868 + [ __NR_fstatfs ] = sys_fstatfs,
26869 + [ __NR_ioperm ] = sys_ni_syscall,
26870 + [ __NR_socketcall ] = sys_socketcall,
26871 + [ __NR_syslog ] = sys_syslog,
26872 + [ __NR_setitimer ] = sys_setitimer,
26873 + [ __NR_getitimer ] = sys_getitimer,
26874 + [ __NR_stat ] = sys_newstat,
26875 + [ __NR_lstat ] = sys_newlstat,
26876 + [ __NR_fstat ] = sys_newfstat,
26877 + [ __NR_olduname ] = sys_uname,
26878 + [ __NR_iopl ] = sys_ni_syscall,
26879 + [ __NR_vhangup ] = sys_vhangup,
26880 + [ __NR_idle ] = sys_ni_syscall,
26881 + [ __NR_wait4 ] = (syscall_handler_t *) sys_wait4,
26882 + [ __NR_swapoff ] = sys_swapoff,
26883 + [ __NR_sysinfo ] = sys_sysinfo,
26884 + [ __NR_ipc ] = sys_ipc,
26885 + [ __NR_fsync ] = sys_fsync,
26886 + [ __NR_sigreturn ] = sys_sigreturn,
26887 + [ __NR_clone ] = sys_clone,
26888 + [ __NR_setdomainname ] = sys_setdomainname,
26889 + [ __NR_uname ] = sys_newuname,
26890 + [ __NR_adjtimex ] = sys_adjtimex,
26891 + [ __NR_mprotect ] = sys_mprotect,
26892 + [ __NR_sigprocmask ] = sys_sigprocmask,
26893 + [ __NR_create_module ] = sys_create_module,
26894 + [ __NR_init_module ] = sys_init_module,
26895 + [ __NR_delete_module ] = sys_delete_module,
26896 + [ __NR_get_kernel_syms ] = sys_get_kernel_syms,
26897 + [ __NR_quotactl ] = sys_quotactl,
26898 + [ __NR_getpgid ] = sys_getpgid,
26899 + [ __NR_fchdir ] = sys_fchdir,
26900 + [ __NR_bdflush ] = sys_bdflush,
26901 + [ __NR_sysfs ] = sys_sysfs,
26902 + [ __NR_personality ] = sys_personality,
26903 + [ __NR_afs_syscall ] = sys_ni_syscall,
26904 + [ __NR_setfsuid ] = sys_setfsuid16,
26905 + [ __NR_setfsgid ] = sys_setfsgid16,
26906 + [ __NR__llseek ] = sys_llseek,
26907 + [ __NR_getdents ] = sys_getdents,
26908 + [ __NR__newselect ] = (syscall_handler_t *) sys_select,
26909 + [ __NR_flock ] = sys_flock,
26910 + [ __NR_msync ] = sys_msync,
26911 + [ __NR_readv ] = sys_readv,
26912 + [ __NR_writev ] = sys_writev,
26913 + [ __NR_getsid ] = sys_getsid,
26914 + [ __NR_fdatasync ] = sys_fdatasync,
26915 + [ __NR__sysctl ] = sys_sysctl,
26916 + [ __NR_mlock ] = sys_mlock,
26917 + [ __NR_munlock ] = sys_munlock,
26918 + [ __NR_mlockall ] = sys_mlockall,
26919 + [ __NR_munlockall ] = sys_munlockall,
26920 + [ __NR_sched_setparam ] = sys_sched_setparam,
26921 + [ __NR_sched_getparam ] = sys_sched_getparam,
26922 + [ __NR_sched_setscheduler ] = sys_sched_setscheduler,
26923 + [ __NR_sched_getscheduler ] = sys_sched_getscheduler,
26924 + [ __NR_sched_yield ] = (syscall_handler_t *) yield,
26925 + [ __NR_sched_get_priority_max ] = sys_sched_get_priority_max,
26926 + [ __NR_sched_get_priority_min ] = sys_sched_get_priority_min,
26927 + [ __NR_sched_rr_get_interval ] = sys_sched_rr_get_interval,
26928 + [ __NR_nanosleep ] = sys_nanosleep,
26929 + [ __NR_mremap ] = sys_mremap,
26930 + [ __NR_setresuid ] = sys_setresuid16,
26931 + [ __NR_getresuid ] = sys_getresuid16,
26932 + [ __NR_vm86 ] = sys_ni_syscall,
26933 + [ __NR_query_module ] = sys_query_module,
26934 + [ __NR_poll ] = sys_poll,
26935 + [ __NR_nfsservctl ] = sys_nfsservctl,
26936 + [ __NR_setresgid ] = sys_setresgid16,
26937 + [ __NR_getresgid ] = sys_getresgid16,
26938 + [ __NR_prctl ] = sys_prctl,
26939 + [ __NR_rt_sigreturn ] = sys_rt_sigreturn,
26940 + [ __NR_rt_sigaction ] = sys_rt_sigaction,
26941 + [ __NR_rt_sigprocmask ] = sys_rt_sigprocmask,
26942 + [ __NR_rt_sigpending ] = sys_rt_sigpending,
26943 + [ __NR_rt_sigtimedwait ] = sys_rt_sigtimedwait,
26944 + [ __NR_rt_sigqueueinfo ] = sys_rt_sigqueueinfo,
26945 + [ __NR_rt_sigsuspend ] = sys_rt_sigsuspend,
26946 + [ __NR_pread ] = sys_pread,
26947 + [ __NR_pwrite ] = sys_pwrite,
26948 + [ __NR_chown ] = sys_chown16,
26949 + [ __NR_getcwd ] = sys_getcwd,
26950 + [ __NR_capget ] = sys_capget,
26951 + [ __NR_capset ] = sys_capset,
26952 + [ __NR_sigaltstack ] = sys_sigaltstack,
26953 + [ __NR_sendfile ] = sys_sendfile,
26954 + [ __NR_getpmsg ] = sys_ni_syscall,
26955 + [ __NR_putpmsg ] = sys_ni_syscall,
26956 + [ __NR_vfork ] = sys_vfork,
26957 + [ __NR_ugetrlimit ] = sys_getrlimit,
26958 + [ __NR_mmap2 ] = sys_mmap2,
26959 + [ __NR_truncate64 ] = sys_truncate64,
26960 + [ __NR_ftruncate64 ] = sys_ftruncate64,
26961 + [ __NR_stat64 ] = sys_stat64,
26962 + [ __NR_lstat64 ] = sys_lstat64,
26963 + [ __NR_fstat64 ] = sys_fstat64,
26964 + [ __NR_fcntl64 ] = sys_fcntl64,
26965 + [ __NR_getdents64 ] = sys_getdents64,
26966 + [ __NR_security ] = sys_ni_syscall,
26967 + [ __NR_gettid ] = sys_gettid,
26968 + [ __NR_readahead ] = sys_readahead,
26969 + [ __NR_setxattr ] = sys_setxattr,
26970 + [ __NR_lsetxattr ] = sys_lsetxattr,
26971 + [ __NR_fsetxattr ] = sys_fsetxattr,
26972 + [ __NR_getxattr ] = sys_getxattr,
26973 + [ __NR_lgetxattr ] = sys_lgetxattr,
26974 + [ __NR_fgetxattr ] = sys_fgetxattr,
26975 + [ __NR_listxattr ] = sys_listxattr,
26976 + [ __NR_llistxattr ] = sys_llistxattr,
26977 + [ __NR_flistxattr ] = sys_flistxattr,
26978 + [ __NR_removexattr ] = sys_removexattr,
26979 + [ __NR_lremovexattr ] = sys_lremovexattr,
26980 + [ __NR_fremovexattr ] = sys_fremovexattr,
26981 + [ __NR_tkill ] = sys_tkill,
26982 + [ __NR_sendfile64 ] = sys_sendfile64,
26983 + [ __NR_futex ] = sys_ni_syscall,
26984 + [ __NR_sched_setaffinity ] = sys_ni_syscall,
26985 + [ __NR_sched_getaffinity ] = sys_ni_syscall,
26986 + [ __NR_set_thread_area ] = sys_ni_syscall,
26987 + [ __NR_get_thread_area ] = sys_ni_syscall,
26988 + [ __NR_io_setup ] = sys_ni_syscall,
26989 + [ __NR_io_destroy ] = sys_ni_syscall,
26990 + [ __NR_io_getevents ] = sys_ni_syscall,
26991 + [ __NR_io_submit ] = sys_ni_syscall,
26992 + [ __NR_io_cancel ] = sys_ni_syscall,
26993 + [ __NR_alloc_hugepages ] = sys_ni_syscall,
26994 + [ __NR_free_hugepages ] = sys_ni_syscall,
26995 + [ __NR_exit_group ] = sys_ni_syscall,
26998 + [ LAST_SYSCALL + 1 ... NR_syscalls ] =
26999 + (syscall_handler_t *) sys_ni_syscall
27003 + * Overrides for Emacs so that we follow Linus's tabbing style.
27004 + * Emacs will notice this stuff at the end of the file and automatically
27005 + * adjust the settings for this buffer only. This must remain at the end
27007 + * ---------------------------------------------------------------------------
27008 + * Local variables:
27009 + * c-file-style: "linux"
27012 diff -Naur -X ../exclude-files orig/arch/um/kernel/syscall_user.c um/arch/um/kernel/syscall_user.c
27013 --- orig/arch/um/kernel/syscall_user.c 1969-12-31 19:00:00.000000000 -0500
27014 +++ um/arch/um/kernel/syscall_user.c 2003-12-22 01:32:48.000000000 -0500
27017 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
27018 + * Licensed under the GPL
27021 +#include <stdlib.h>
27022 +#include <sys/time.h>
27023 +#include "kern_util.h"
27024 +#include "syscall_user.h"
27030 + struct timeval start;
27031 + struct timeval end;
27032 +} syscall_record[1024];
27034 +int record_syscall_start(int syscall)
27038 + max = sizeof(syscall_record)/sizeof(syscall_record[0]);
27039 + index = next_syscall_index(max);
27041 + syscall_record[index].syscall = syscall;
27042 + syscall_record[index].pid = current_pid();
27043 + syscall_record[index].result = 0xdeadbeef;
27044 + gettimeofday(&syscall_record[index].start, NULL);
27048 +void record_syscall_end(int index, int result)
27050 + syscall_record[index].result = result;
27051 + gettimeofday(&syscall_record[index].end, NULL);
27055 + * Overrides for Emacs so that we follow Linus's tabbing style.
27056 + * Emacs will notice this stuff at the end of the file and automatically
27057 + * adjust the settings for this buffer only. This must remain at the end
27059 + * ---------------------------------------------------------------------------
27060 + * Local variables:
27061 + * c-file-style: "linux"
27064 diff -Naur -X ../exclude-files orig/arch/um/kernel/sysrq.c um/arch/um/kernel/sysrq.c
27065 --- orig/arch/um/kernel/sysrq.c 1969-12-31 19:00:00.000000000 -0500
27066 +++ um/arch/um/kernel/sysrq.c 2003-10-21 03:26:07.000000000 -0400
27069 + * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
27070 + * Licensed under the GPL
27073 +#include "linux/sched.h"
27074 +#include "linux/kernel.h"
27075 +#include "linux/module.h"
27076 +#include "asm/page.h"
27077 +#include "asm/processor.h"
27078 +#include "sysrq.h"
27079 +#include "user_util.h"
27082 + * If the address is either in the .text section of the
27083 + * kernel, or in the vmalloc'ed module regions, it *may*
27084 + * be the address of a calling routine
27087 +#ifdef CONFIG_MODULES
27089 +extern struct module *module_list;
27090 +extern struct module kernel_module;
27092 +static inline int kernel_text_address(unsigned long addr)
27095 + struct module *mod;
27097 + if (addr >= (unsigned long) &_stext &&
27098 + addr <= (unsigned long) &_etext)
27101 + for (mod = module_list; mod != &kernel_module; mod = mod->next) {
27102 + /* mod_bound tests for addr being inside the vmalloc'ed
27103 + * module area. Of course it'd be better to test only
27104 + * for the .text subset... */
27105 + if (mod_bound(addr, 0, mod)) {
27116 +static inline int kernel_text_address(unsigned long addr)
27118 + return (addr >= (unsigned long) &_stext &&
27119 + addr <= (unsigned long) &_etext);
27124 +void show_trace(unsigned long * stack)
27127 + unsigned long addr;
27130 + stack = (unsigned long*) &stack;
27132 + printk("Call Trace: ");
27134 + while (((long) stack & (THREAD_SIZE-1)) != 0) {
27136 + if (kernel_text_address(addr)) {
27137 + if (i && ((i % 6) == 0))
27139 + printk("[<%08lx>] ", addr);
27146 +void show_trace_task(struct task_struct *tsk)
27148 + unsigned long esp = PT_REGS_SP(&tsk->thread.regs);
27150 + /* User space on another CPU? */
27151 + if ((esp ^ (unsigned long)tsk) & (PAGE_MASK<<1))
27153 + show_trace((unsigned long *)esp);
27157 + * Overrides for Emacs so that we follow Linus's tabbing style.
27158 + * Emacs will notice this stuff at the end of the file and automatically
27159 + * adjust the settings for this buffer only. This must remain at the end
27161 + * ---------------------------------------------------------------------------
27162 + * Local variables:
27163 + * c-file-style: "linux"
27166 diff -Naur -X ../exclude-files orig/arch/um/kernel/tempfile.c um/arch/um/kernel/tempfile.c
27167 --- orig/arch/um/kernel/tempfile.c 1969-12-31 19:00:00.000000000 -0500
27168 +++ um/arch/um/kernel/tempfile.c 2003-12-22 01:33:38.000000000 -0500
27171 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
27172 + * Licensed under the GPL
27175 +#include <stdio.h>
27176 +#include <stdlib.h>
27177 +#include <unistd.h>
27178 +#include <string.h>
27179 +#include <errno.h>
27180 +#include <sys/param.h>
27183 +/* Modified from create_mem_file and start_debugger */
27184 +static char *tempdir = NULL;
27186 +static void __init find_tempdir(void)
27188 + char *dirs[] = { "TMP", "TEMP", "TMPDIR", NULL };
27190 + char *dir = NULL;
27192 + if(tempdir != NULL) return; /* We've already been called */
27193 + for(i = 0; dirs[i]; i++){
27194 + dir = getenv(dirs[i]);
27195 + if((dir != NULL) && (*dir != '\0'))
27198 + if((dir == NULL) || (*dir == '\0'))
27201 + tempdir = malloc(strlen(dir) + 2);
27202 + if(tempdir == NULL){
27203 + fprintf(stderr, "Failed to malloc tempdir, "
27204 + "errno = %d\n", errno);
27207 + strcpy(tempdir, dir);
27208 + strcat(tempdir, "/");
27211 +int make_tempfile(const char *template, char **out_tempname, int do_unlink)
27213 + char tempname[MAXPATHLEN];
27217 + if (*template != '/')
27218 + strcpy(tempname, tempdir);
27221 + strcat(tempname, template);
27222 + fd = mkstemp(tempname);
27224 + fprintf(stderr, "open - cannot create %s: %s\n", tempname,
27225 + strerror(errno));
27228 + if(do_unlink && (unlink(tempname) < 0)){
27229 + perror("unlink");
27232 + if(out_tempname){
27233 + *out_tempname = strdup(tempname);
27234 + if(*out_tempname == NULL){
27235 + perror("strdup");
27243 + * Overrides for Emacs so that we follow Linus's tabbing style.
27244 + * Emacs will notice this stuff at the end of the file and automatically
27245 + * adjust the settings for this buffer only. This must remain at the end
27247 + * ---------------------------------------------------------------------------
27248 + * Local variables:
27249 + * c-file-style: "linux"
27252 diff -Naur -X ../exclude-files orig/arch/um/kernel/time.c um/arch/um/kernel/time.c
27253 --- orig/arch/um/kernel/time.c 1969-12-31 19:00:00.000000000 -0500
27254 +++ um/arch/um/kernel/time.c 2004-02-12 07:09:48.000000000 -0500
27257 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
27258 + * Licensed under the GPL
27261 +#include <stdio.h>
27262 +#include <stdlib.h>
27263 +#include <unistd.h>
27265 +#include <sys/time.h>
27266 +#include <signal.h>
27267 +#include <errno.h>
27268 +#include "user_util.h"
27269 +#include "kern_util.h"
27271 +#include "process.h"
27272 +#include "signal_user.h"
27273 +#include "time_user.h"
27275 +extern struct timeval xtime;
27277 +struct timeval local_offset = { 0, 0 };
27281 + gettimeofday(&xtime, NULL);
27282 + timeradd(&xtime, &local_offset, &xtime);
27285 +void set_interval(int timer_type)
27287 + int usec = 1000000/hz();
27288 + struct itimerval interval = ((struct itimerval) { { 0, usec },
27291 + if(setitimer(timer_type, &interval, NULL) == -1)
27292 + panic("setitimer failed - errno = %d\n", errno);
27295 +void enable_timer(void)
27297 + int usec = 1000000/hz();
27298 + struct itimerval enable = ((struct itimerval) { { 0, usec },
27300 + if(setitimer(ITIMER_VIRTUAL, &enable, NULL))
27301 + printk("enable_timer - setitimer failed, errno = %d\n",
27305 +void switch_timers(int to_real)
27307 + struct itimerval disable = ((struct itimerval) { { 0, 0 }, { 0, 0 }});
27308 + struct itimerval enable = ((struct itimerval) { { 0, 1000000/hz() },
27309 + { 0, 1000000/hz() }});
27313 + old = ITIMER_VIRTUAL;
27314 + new = ITIMER_REAL;
27317 + old = ITIMER_REAL;
27318 + new = ITIMER_VIRTUAL;
27321 + if((setitimer(old, &disable, NULL) < 0) ||
27322 + (setitimer(new, &enable, NULL)))
27323 + printk("switch_timers - setitimer failed, errno = %d\n",
27327 +void idle_timer(void)
27329 + if(signal(SIGVTALRM, SIG_IGN) == SIG_ERR)
27330 + panic("Couldn't unset SIGVTALRM handler");
27332 + set_handler(SIGALRM, (__sighandler_t) alarm_handler,
27333 + SA_RESTART, SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1);
27334 + set_interval(ITIMER_REAL);
27337 +static unsigned long long get_host_hz(void)
27339 + char mhzline[16], *end;
27340 + unsigned long long mhz;
27341 + int ret, mult, rest, len;
27343 + ret = cpu_feature("cpu MHz", mhzline,
27344 + sizeof(mhzline) / sizeof(mhzline[0]));
27346 + panic ("Could not get host MHZ");
27348 + mhz = strtoul(mhzline, &end, 10);
27350 + /* This business is to parse a floating point number without using
27351 + * floating types.
27358 + len = strlen(end);
27363 + rest = strtoul(end, NULL, 10);
27364 + while(mult-- > 0)
27368 + return(1000000 * mhz + rest);
27371 +unsigned long long host_hz = 0;
27373 +void time_init(void)
27375 + /* XXX This is to fill xtime with something real - otherwise by the
27376 + * time /proc is mounted, no timers have fired, and xtime is still 0,
27377 + * meaning it shows times of Jan 1 1970. The real fix is to figure
27378 + * out why no timers have happened by then.
27382 + host_hz = get_host_hz();
27383 + if(signal(SIGVTALRM, boot_timer_handler) == SIG_ERR)
27384 + panic("Couldn't set SIGVTALRM handler");
27385 + set_interval(ITIMER_VIRTUAL);
27388 +void do_gettimeofday(struct timeval *tv)
27390 + unsigned long flags;
27392 + flags = time_lock();
27393 + gettimeofday(tv, NULL);
27394 + timeradd(tv, &local_offset, tv);
27395 + time_unlock(flags);
27398 +void do_settimeofday(struct timeval *tv)
27400 + struct timeval now;
27401 + unsigned long flags;
27403 + flags = time_lock();
27404 + gettimeofday(&now, NULL);
27405 + timersub(tv, &now, &local_offset);
27406 + time_unlock(flags);
27409 +void idle_sleep(int secs)
27411 + struct timespec ts;
27413 + ts.tv_sec = secs;
27415 + nanosleep(&ts, NULL);
27419 + * Overrides for Emacs so that we follow Linus's tabbing style.
27420 + * Emacs will notice this stuff at the end of the file and automatically
27421 + * adjust the settings for this buffer only. This must remain at the end
27423 + * ---------------------------------------------------------------------------
27424 + * Local variables:
27425 + * c-file-style: "linux"
27428 diff -Naur -X ../exclude-files orig/arch/um/kernel/time_kern.c um/arch/um/kernel/time_kern.c
27429 --- orig/arch/um/kernel/time_kern.c 1969-12-31 19:00:00.000000000 -0500
27430 +++ um/arch/um/kernel/time_kern.c 2004-02-14 06:51:31.000000000 -0500
27433 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
27434 + * Licensed under the GPL
27437 +#include "linux/kernel.h"
27438 +#include "linux/unistd.h"
27439 +#include "linux/stddef.h"
27440 +#include "linux/spinlock.h"
27441 +#include "linux/sched.h"
27442 +#include "linux/interrupt.h"
27443 +#include "linux/init.h"
27444 +#include "linux/delay.h"
27445 +#include "asm/irq.h"
27446 +#include "asm/param.h"
27447 +#include "asm/current.h"
27448 +#include "kern_util.h"
27449 +#include "user_util.h"
27450 +#include "time_user.h"
27453 +extern rwlock_t xtime_lock;
27460 +/* Changed at early boot */
27461 +int timer_irq_inited = 0;
27463 +/* missed_ticks will be modified after kernel memory has been
27464 + * write-protected, so this puts it in a section which will be left
27467 +int __attribute__ ((__section__ (".unprotected"))) missed_ticks[NR_CPUS];
27469 +static int first_tick;
27470 +static unsigned long long prev_tsc;
27471 +static long long delta; /* Deviation per interval */
27473 +extern unsigned long long host_hz;
27475 +void timer_irq(union uml_pt_regs *regs)
27477 + unsigned long long ticks = 0;
27479 + if(!timer_irq_inited){
27480 + /* This is to ensure that ticks don't pile up when
27481 + * the timer handler is suspended */
27487 +#if defined(CONFIG_UML_REAL_TIME_CLOCK)
27488 + unsigned long long tsc;
27489 + /* We've had 1 tick */
27490 + tsc = time_stamp();
27492 + delta += tsc - prev_tsc;
27495 + ticks += (delta * HZ) / host_hz;
27496 + delta -= (ticks * host_hz) / HZ;
27502 + prev_tsc = time_stamp();
27506 + while(ticks > 0){
27507 + do_IRQ(TIMER_IRQ, regs);
27512 +void boot_timer_handler(int sig)
27514 + struct pt_regs regs;
27516 + CHOOSE_MODE((void)
27517 + (UPT_SC(®s.regs) = (struct sigcontext *) (&sig + 1)),
27518 + (void) (regs.regs.skas.is_user = 0));
27522 +void um_timer(int irq, void *dev, struct pt_regs *regs)
27525 + write_lock(&xtime_lock);
27529 + write_unlock(&xtime_lock);
27532 +long um_time(int * tloc)
27534 + struct timeval now;
27536 + do_gettimeofday(&now);
27538 + if (put_user(now.tv_sec,tloc))
27539 + now.tv_sec = -EFAULT;
27541 + return now.tv_sec;
27544 +long um_stime(int * tptr)
27547 + struct timeval new;
27549 + if (get_user(value, tptr))
27551 + new.tv_sec = value;
27553 + do_settimeofday(&new);
27557 +/* XXX Needs to be moved under sys-i386 */
27558 +void __delay(um_udelay_t time)
27560 + /* Stolen from the i386 __loop_delay */
27562 + __asm__ __volatile__(
27567 + "2:\tdecl %0\n\tjns 2b"
27572 +void __udelay(um_udelay_t usecs)
27576 + n = (loops_per_jiffy * HZ * usecs) / 1000000;
27577 + for(i=0;i<n;i++) ;
27580 +void __const_udelay(um_udelay_t usecs)
27584 + n = (loops_per_jiffy * HZ * usecs) / 1000000;
27585 + for(i=0;i<n;i++) ;
27588 +void timer_handler(int sig, union uml_pt_regs *regs)
27591 + update_process_times(user_context(UPT_SP(regs)));
27593 + if(current->processor == 0)
27597 +static spinlock_t timer_spinlock = SPIN_LOCK_UNLOCKED;
27599 +unsigned long time_lock(void)
27601 + unsigned long flags;
27603 + spin_lock_irqsave(&timer_spinlock, flags);
27607 +void time_unlock(unsigned long flags)
27609 + spin_unlock_irqrestore(&timer_spinlock, flags);
27612 +int __init timer_init(void)
27616 + CHOOSE_MODE(user_time_init_tt(), user_time_init_skas());
27617 + err = request_irq(TIMER_IRQ, um_timer, SA_INTERRUPT, "timer", NULL);
27619 + printk(KERN_ERR "timer_init : request_irq failed - "
27620 + "errno = %d\n", -err);
27621 + timer_irq_inited = 1;
27625 +__initcall(timer_init);
27628 + * Overrides for Emacs so that we follow Linus's tabbing style.
27629 + * Emacs will notice this stuff at the end of the file and automatically
27630 + * adjust the settings for this buffer only. This must remain at the end
27632 + * ---------------------------------------------------------------------------
27633 + * Local variables:
27634 + * c-file-style: "linux"
27637 diff -Naur -X ../exclude-files orig/arch/um/kernel/tlb.c um/arch/um/kernel/tlb.c
27638 --- orig/arch/um/kernel/tlb.c 1969-12-31 19:00:00.000000000 -0500
27639 +++ um/arch/um/kernel/tlb.c 2003-10-21 03:26:07.000000000 -0400
27642 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
27643 + * Licensed under the GPL
27646 +#include "linux/mm.h"
27647 +#include "asm/page.h"
27648 +#include "asm/pgalloc.h"
27649 +#include "choose-mode.h"
27650 +#include "mode_kern.h"
27652 +void flush_tlb_page(struct vm_area_struct *vma, unsigned long address)
27654 + address &= PAGE_MASK;
27655 + flush_tlb_range(vma->vm_mm, address, address + PAGE_SIZE);
27658 +void flush_tlb_all(void)
27660 + flush_tlb_mm(current->mm);
27663 +void flush_tlb_kernel_vm(void)
27665 + CHOOSE_MODE(flush_tlb_kernel_vm_tt(), flush_tlb_kernel_vm_skas());
27668 +void __flush_tlb_one(unsigned long addr)
27670 + CHOOSE_MODE_PROC(__flush_tlb_one_tt, __flush_tlb_one_skas, addr);
27673 +void flush_tlb_range(struct mm_struct *mm, unsigned long start,
27674 + unsigned long end)
27676 + CHOOSE_MODE_PROC(flush_tlb_range_tt, flush_tlb_range_skas, mm, start,
27680 +void flush_tlb_mm(struct mm_struct *mm)
27682 + CHOOSE_MODE_PROC(flush_tlb_mm_tt, flush_tlb_mm_skas, mm);
27685 +void force_flush_all(void)
27687 + CHOOSE_MODE(force_flush_all_tt(), force_flush_all_skas());
27691 +pgd_t *pgd_offset_proc(struct mm_struct *mm, unsigned long address)
27693 + return(pgd_offset(mm, address));
27696 +pmd_t *pmd_offset_proc(pgd_t *pgd, unsigned long address)
27698 + return(pmd_offset(pgd, address));
27701 +pte_t *pte_offset_proc(pmd_t *pmd, unsigned long address)
27703 + return(pte_offset(pmd, address));
27706 +pte_t *addr_pte(struct task_struct *task, unsigned long addr)
27708 + return(pte_offset(pmd_offset(pgd_offset(task->mm, addr), addr), addr));
27712 + * Overrides for Emacs so that we follow Linus's tabbing style.
27713 + * Emacs will notice this stuff at the end of the file and automatically
27714 + * adjust the settings for this buffer only. This must remain at the end
27716 + * ---------------------------------------------------------------------------
27717 + * Local variables:
27718 + * c-file-style: "linux"
27721 diff -Naur -X ../exclude-files orig/arch/um/kernel/trap_kern.c um/arch/um/kernel/trap_kern.c
27722 --- orig/arch/um/kernel/trap_kern.c 1969-12-31 19:00:00.000000000 -0500
27723 +++ um/arch/um/kernel/trap_kern.c 2003-12-22 22:48:41.000000000 -0500
27726 + * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
27727 + * Licensed under the GPL
27730 +#include "linux/kernel.h"
27731 +#include "linux/sched.h"
27732 +#include "linux/mm.h"
27733 +#include "linux/spinlock.h"
27734 +#include "linux/config.h"
27735 +#include "linux/init.h"
27736 +#include "asm/semaphore.h"
27737 +#include "asm/pgtable.h"
27738 +#include "asm/pgalloc.h"
27739 +#include "asm/a.out.h"
27740 +#include "asm/current.h"
27741 +#include "asm/irq.h"
27742 +#include "user_util.h"
27743 +#include "kern_util.h"
27745 +#include "chan_kern.h"
27746 +#include "mconsole_kern.h"
27747 +#include "2_5compat.h"
27749 +#include "mem_kern.h"
27751 +unsigned long handle_page_fault(unsigned long address, unsigned long ip,
27752 + int is_write, int is_user, int *code_out)
27754 + struct mm_struct *mm = current->mm;
27755 + struct vm_area_struct *vma;
27759 + unsigned long page;
27762 + *code_out = SEGV_MAPERR;
27763 + down_read(&mm->mmap_sem);
27764 + vma = find_vma(mm, address);
27767 + else if(vma->vm_start <= address)
27769 + else if(!(vma->vm_flags & VM_GROWSDOWN))
27771 + else if(expand_stack(vma, address))
27775 + *code_out = SEGV_ACCERR;
27776 + if(is_write && !(vma->vm_flags & VM_WRITE))
27778 + page = address & PAGE_MASK;
27779 + if(page == (unsigned long) current + PAGE_SIZE)
27780 + panic("Kernel stack overflow");
27781 + pgd = pgd_offset(mm, page);
27782 + pmd = pmd_offset(pgd, page);
27785 + switch (handle_mm_fault(mm, vma, address, is_write)) {
27787 + current->min_flt++;
27790 + current->maj_flt++;
27793 + if (current->pid == 1) {
27794 + up_read(&mm->mmap_sem);
27796 + down_read(&mm->mmap_sem);
27799 + /* Fall through to bad area case */
27803 + pte = pte_offset(pmd, page);
27804 + } while(!pte_present(*pte));
27806 + *pte = pte_mkyoung(*pte);
27807 + if(pte_write(*pte)) *pte = pte_mkdirty(*pte);
27808 + flush_tlb_page(vma, page);
27810 + up_read(&mm->mmap_sem);
27814 +LIST_HEAD(physmem_remappers);
27816 +void register_remapper(struct remapper *info)
27818 + list_add(&info->list, &physmem_remappers);
27821 +static int check_remapped_addr(unsigned long address, int is_write)
27823 + struct remapper *remapper;
27824 + struct list_head *ele;
27828 + fd = phys_mapping(__pa(address), &offset);
27832 + list_for_each(ele, &physmem_remappers){
27833 + remapper = list_entry(ele, struct remapper, list);
27834 + if((*remapper->proc)(fd, address, is_write, offset))
27841 +unsigned long segv(unsigned long address, unsigned long ip, int is_write,
27842 + int is_user, void *sc)
27844 + struct siginfo si;
27848 + if(!is_user && (address >= start_vm) && (address < end_vm)){
27849 + flush_tlb_kernel_vm();
27852 + else if(check_remapped_addr(address & PAGE_MASK, is_write))
27854 + else if(current->mm == NULL)
27855 + panic("Segfault with no mm");
27857 + handled = handle_page_fault(address, ip, is_write, is_user,
27860 + catcher = current->thread.fault_catcher;
27863 + else if(catcher != NULL){
27864 + current->thread.fault_addr = (void *) address;
27865 + do_longjmp(catcher, 1);
27867 + else if(current->thread.fault_addr != NULL)
27868 + panic("fault_addr set but no fault catcher");
27869 + else if(arch_fixup(ip, sc))
27873 + panic("Kernel mode fault at addr 0x%lx, ip 0x%lx",
27875 + si.si_signo = SIGSEGV;
27876 + si.si_addr = (void *) address;
27877 + current->thread.cr2 = address;
27878 + current->thread.err = is_write;
27879 + force_sig_info(SIGSEGV, &si, current);
27883 +void bad_segv(unsigned long address, unsigned long ip, int is_write)
27885 + struct siginfo si;
27887 + si.si_signo = SIGSEGV;
27888 + si.si_code = SEGV_ACCERR;
27889 + si.si_addr = (void *) address;
27890 + current->thread.cr2 = address;
27891 + current->thread.err = is_write;
27892 + force_sig_info(SIGSEGV, &si, current);
27895 +void relay_signal(int sig, union uml_pt_regs *regs)
27897 + if(arch_handle_signal(sig, regs)) return;
27898 + if(!UPT_IS_USER(regs))
27899 + panic("Kernel mode signal %d", sig);
27900 + force_sig(sig, current);
27903 +void bus_handler(int sig, union uml_pt_regs *regs)
27905 + if(current->thread.fault_catcher != NULL)
27906 + do_longjmp(current->thread.fault_catcher, 1);
27907 + else relay_signal(sig, regs);
27910 +void winch(int sig, union uml_pt_regs *regs)
27912 + do_IRQ(WINCH_IRQ, regs);
27915 +void trap_init(void)
27919 +spinlock_t trap_lock = SPIN_LOCK_UNLOCKED;
27921 +static int trap_index = 0;
27923 +int next_trap_index(int limit)
27927 + spin_lock(&trap_lock);
27928 + ret = trap_index;
27929 + if(++trap_index == limit)
27931 + spin_unlock(&trap_lock);
27936 + * Overrides for Emacs so that we follow Linus's tabbing style.
27937 + * Emacs will notice this stuff at the end of the file and automatically
27938 + * adjust the settings for this buffer only. This must remain at the end
27940 + * ---------------------------------------------------------------------------
27941 + * Local variables:
27942 + * c-file-style: "linux"
27945 diff -Naur -X ../exclude-files orig/arch/um/kernel/trap_user.c um/arch/um/kernel/trap_user.c
27946 --- orig/arch/um/kernel/trap_user.c 1969-12-31 19:00:00.000000000 -0500
27947 +++ um/arch/um/kernel/trap_user.c 2004-01-31 02:47:39.000000000 -0500
27950 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
27951 + * Licensed under the GPL
27954 +#include <stdlib.h>
27955 +#include <errno.h>
27956 +#include <setjmp.h>
27957 +#include <signal.h>
27958 +#include <sys/time.h>
27959 +#include <sys/ptrace.h>
27960 +#include <sys/wait.h>
27961 +#include <asm/page.h>
27962 +#include <asm/unistd.h>
27963 +#include <asm/ptrace.h>
27965 +#include "sysdep/ptrace.h"
27966 +#include "sigcontext.h"
27967 +#include "sysdep/sigcontext.h"
27968 +#include "irq_user.h"
27969 +#include "frame_user.h"
27970 +#include "signal_user.h"
27971 +#include "time_user.h"
27974 +#include "choose-mode.h"
27975 +#include "kern_util.h"
27976 +#include "user_util.h"
27979 +void kill_child_dead(int pid)
27981 + kill(pid, SIGKILL);
27982 + kill(pid, SIGCONT);
27983 + while(waitpid(pid, NULL, 0) > 0) kill(pid, SIGCONT);
27986 +/* Unlocked - don't care if this is a bit off */
27987 +int nsegfaults = 0;
27990 + unsigned long address;
27993 + unsigned long sp;
27995 +} segfault_record[1024];
27997 +void segv_handler(int sig, union uml_pt_regs *regs)
28001 + if(UPT_IS_USER(regs) && !UPT_SEGV_IS_FIXABLE(regs)){
28002 + bad_segv(UPT_FAULT_ADDR(regs), UPT_IP(regs),
28003 + UPT_FAULT_WRITE(regs));
28006 + max = sizeof(segfault_record)/sizeof(segfault_record[0]);
28007 + index = next_trap_index(max);
28010 + segfault_record[index].address = UPT_FAULT_ADDR(regs);
28011 + segfault_record[index].pid = os_getpid();
28012 + segfault_record[index].is_write = UPT_FAULT_WRITE(regs);
28013 + segfault_record[index].sp = UPT_SP(regs);
28014 + segfault_record[index].is_user = UPT_IS_USER(regs);
28015 + segv(UPT_FAULT_ADDR(regs), UPT_IP(regs), UPT_FAULT_WRITE(regs),
28016 + UPT_IS_USER(regs), regs);
28019 +void usr2_handler(int sig, union uml_pt_regs *regs)
28021 + CHOOSE_MODE(syscall_handler_tt(sig, regs), (void) 0);
28024 +struct signal_info sig_info[] = {
28025 + [ SIGTRAP ] { .handler = relay_signal,
28027 + [ SIGFPE ] { .handler = relay_signal,
28029 + [ SIGILL ] { .handler = relay_signal,
28031 + [ SIGWINCH ] { .handler = winch,
28033 + [ SIGBUS ] { .handler = bus_handler,
28035 + [ SIGSEGV] { .handler = segv_handler,
28037 + [ SIGIO ] { .handler = sigio_handler,
28039 + [ SIGVTALRM ] { .handler = timer_handler,
28041 + [ SIGALRM ] { .handler = timer_handler,
28043 + [ SIGUSR2 ] { .handler = usr2_handler,
28047 +void sig_handler(int sig, struct sigcontext sc)
28049 + CHOOSE_MODE_PROC(sig_handler_common_tt, sig_handler_common_skas,
28053 +extern int timer_irq_inited, missed_ticks[];
28055 +void alarm_handler(int sig, struct sigcontext sc)
28057 + if(!timer_irq_inited) return;
28058 + missed_ticks[cpu()]++;
28060 + if(sig == SIGALRM)
28061 + switch_timers(0);
28063 + CHOOSE_MODE_PROC(sig_handler_common_tt, sig_handler_common_skas,
28066 + if(sig == SIGALRM)
28067 + switch_timers(1);
28070 +void do_longjmp(void *b, int val)
28072 + sigjmp_buf *buf = b;
28074 + siglongjmp(*buf, val);
28078 + * Overrides for Emacs so that we follow Linus's tabbing style.
28079 + * Emacs will notice this stuff at the end of the file and automatically
28080 + * adjust the settings for this buffer only. This must remain at the end
28082 + * ---------------------------------------------------------------------------
28083 + * Local variables:
28084 + * c-file-style: "linux"
28087 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/exec_kern.c um/arch/um/kernel/tt/exec_kern.c
28088 --- orig/arch/um/kernel/tt/exec_kern.c 1969-12-31 19:00:00.000000000 -0500
28089 +++ um/arch/um/kernel/tt/exec_kern.c 2003-11-07 02:23:10.000000000 -0500
28092 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
28093 + * Licensed under the GPL
28096 +#include "linux/kernel.h"
28097 +#include "linux/mm.h"
28098 +#include "asm/signal.h"
28099 +#include "asm/ptrace.h"
28100 +#include "asm/uaccess.h"
28101 +#include "asm/pgalloc.h"
28102 +#include "user_util.h"
28103 +#include "kern_util.h"
28104 +#include "irq_user.h"
28105 +#include "time_user.h"
28106 +#include "mem_user.h"
28111 +static int exec_tramp(void *sig_stack)
28113 + init_new_thread_stack(sig_stack, NULL);
28114 + init_new_thread_signals(1);
28115 + os_stop_process(os_getpid());
28119 +void flush_thread_tt(void)
28121 + unsigned long stack;
28124 + stack = alloc_stack(0, 0);
28127 + "flush_thread : failed to allocate temporary stack\n");
28128 + do_exit(SIGKILL);
28131 + new_pid = start_fork_tramp((void *) current->thread.kernel_stack,
28132 + stack, 0, exec_tramp);
28135 + "flush_thread : new thread failed, errno = %d\n",
28137 + do_exit(SIGKILL);
28140 + if(current->processor == 0)
28141 + forward_interrupts(new_pid);
28142 + current->thread.request.op = OP_EXEC;
28143 + current->thread.request.u.exec.pid = new_pid;
28144 + unprotect_stack((unsigned long) current);
28145 + os_usr1_process(os_getpid());
28148 + free_page(stack);
28149 + protect_memory(uml_reserved, high_physmem - uml_reserved, 1, 1, 0, 1);
28150 + task_protections((unsigned long) current);
28151 + force_flush_all();
28152 + unblock_signals();
28155 +void start_thread_tt(struct pt_regs *regs, unsigned long eip,
28156 + unsigned long esp)
28159 + flush_tlb_mm(current->mm);
28160 + PT_REGS_IP(regs) = eip;
28161 + PT_REGS_SP(regs) = esp;
28162 + PT_FIX_EXEC_STACK(esp);
28166 + * Overrides for Emacs so that we follow Linus's tabbing style.
28167 + * Emacs will notice this stuff at the end of the file and automatically
28168 + * adjust the settings for this buffer only. This must remain at the end
28170 + * ---------------------------------------------------------------------------
28171 + * Local variables:
28172 + * c-file-style: "linux"
28175 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/exec_user.c um/arch/um/kernel/tt/exec_user.c
28176 --- orig/arch/um/kernel/tt/exec_user.c 1969-12-31 19:00:00.000000000 -0500
28177 +++ um/arch/um/kernel/tt/exec_user.c 2003-10-21 03:26:07.000000000 -0400
28180 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
28181 + * Licensed under the GPL
28184 +#include <stdio.h>
28185 +#include <unistd.h>
28186 +#include <stdlib.h>
28187 +#include <sched.h>
28188 +#include <errno.h>
28189 +#include <sys/wait.h>
28190 +#include <sys/ptrace.h>
28191 +#include <signal.h>
28192 +#include "user_util.h"
28193 +#include "kern_util.h"
28195 +#include "ptrace_user.h"
28197 +void do_exec(int old_pid, int new_pid)
28199 + unsigned long regs[FRAME_SIZE];
28201 + if((ptrace(PTRACE_ATTACH, new_pid, 0, 0) < 0) ||
28202 + (ptrace(PTRACE_CONT, new_pid, 0, 0) < 0) ||
28203 + (waitpid(new_pid, 0, WUNTRACED) < 0))
28204 + tracer_panic("do_exec failed to attach proc - errno = %d",
28207 + if(ptrace_getregs(old_pid, regs) < 0)
28208 + tracer_panic("do_exec failed to get registers - errno = %d",
28211 + kill(old_pid, SIGKILL);
28213 + if(ptrace_setregs(new_pid, regs) < 0)
28214 + tracer_panic("do_exec failed to start new proc - errno = %d",
28219 + * Overrides for Emacs so that we follow Linus's tabbing style.
28220 + * Emacs will notice this stuff at the end of the file and automatically
28221 + * adjust the settings for this buffer only. This must remain at the end
28223 + * ---------------------------------------------------------------------------
28224 + * Local variables:
28225 + * c-file-style: "linux"
28228 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/gdb.c um/arch/um/kernel/tt/gdb.c
28229 --- orig/arch/um/kernel/tt/gdb.c 1969-12-31 19:00:00.000000000 -0500
28230 +++ um/arch/um/kernel/tt/gdb.c 2003-10-21 03:26:07.000000000 -0400
28233 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
28234 + * Licensed under the GPL
28237 +#include <stdio.h>
28238 +#include <stdlib.h>
28239 +#include <errno.h>
28240 +#include <string.h>
28241 +#include <signal.h>
28242 +#include <sys/ptrace.h>
28243 +#include <sys/types.h>
28244 +#include "uml-config.h"
28245 +#include "kern_constants.h"
28246 +#include "chan_user.h"
28249 +#include "debug.h"
28250 +#include "kern_util.h"
28251 +#include "user_util.h"
28253 +#include "sysdep/thread.h"
28255 +extern int debugger_pid;
28256 +extern int debugger_fd;
28257 +extern int debugger_parent;
28259 +int detach(int pid, int sig)
28261 + return(ptrace(PTRACE_DETACH, pid, 0, sig));
28264 +int attach(int pid)
28268 + err = ptrace(PTRACE_ATTACH, pid, 0, 0);
28269 + if(err < 0) return(-errno);
28270 + else return(err);
28275 + return(ptrace(PTRACE_CONT, pid, 0, 0));
28278 +#ifdef UML_CONFIG_PT_PROXY
28280 +int debugger_signal(int status, pid_t pid)
28282 + return(debugger_proxy(status, pid));
28285 +void child_signal(pid_t pid, int status)
28287 + child_proxy(pid, status);
28290 +static void gdb_announce(char *dev_name, int dev)
28292 + printf("gdb assigned device '%s'\n", dev_name);
28295 +static struct chan_opts opts = {
28296 + .announce = gdb_announce,
28297 + .xterm_title = "UML kernel debugger",
28299 + .tramp_stack = 0,
28303 +/* Accessed by the tracing thread, which automatically serializes access */
28304 +static void *xterm_data;
28305 +static int xterm_fd;
28307 +extern void *xterm_init(char *, int, struct chan_opts *);
28308 +extern int xterm_open(int, int, int, void *, char **);
28309 +extern void xterm_close(int, void *);
28311 +int open_gdb_chan(void)
28313 + char stack[UM_KERN_PAGE_SIZE], *dummy;
28315 + opts.tramp_stack = (unsigned long) stack;
28316 + xterm_data = xterm_init("", 0, &opts);
28317 + xterm_fd = xterm_open(1, 1, 1, xterm_data, &dummy);
28318 + return(xterm_fd);
28321 +static void exit_debugger_cb(void *unused)
28323 + if(debugger_pid != -1){
28324 + if(gdb_pid != -1){
28325 + fake_child_exit();
28328 + else kill_child_dead(debugger_pid);
28329 + debugger_pid = -1;
28330 + if(debugger_parent != -1)
28331 + detach(debugger_parent, SIGINT);
28333 + if(xterm_data != NULL) xterm_close(xterm_fd, xterm_data);
28336 +static void exit_debugger(void)
28338 + initial_thread_cb(exit_debugger_cb, NULL);
28341 +__uml_exitcall(exit_debugger);
28348 +static void config_gdb_cb(void *arg)
28350 + struct gdb_data *data = arg;
28355 + if(debugger_pid != -1) exit_debugger_cb(NULL);
28356 + if(!strncmp(data->str, "pid,", strlen("pid,"))){
28357 + data->str += strlen("pid,");
28358 + pid = strtoul(data->str, NULL, 0);
28359 + task = cpu_tasks[0].task;
28360 + debugger_pid = attach_debugger(TASK_EXTERN_PID(task), pid, 0);
28361 + if(debugger_pid != -1){
28368 + debugger_pid = start_debugger(linux_prog, 0, 0, &debugger_fd);
28369 + init_proxy(debugger_pid, 0, 0);
28372 +int gdb_config(char *str)
28374 + struct gdb_data data;
28376 + if(*str++ != '=') return(-1);
28378 + initial_thread_cb(config_gdb_cb, &data);
28379 + return(data.err);
28382 +void remove_gdb_cb(void *unused)
28384 + exit_debugger_cb(NULL);
28387 +int gdb_remove(char *unused)
28389 + initial_thread_cb(remove_gdb_cb, NULL);
28393 +void signal_usr1(int sig)
28395 + if(debugger_pid != -1){
28396 + printk(UM_KERN_ERR "The debugger is already running\n");
28399 + debugger_pid = start_debugger(linux_prog, 0, 0, &debugger_fd);
28400 + init_proxy(debugger_pid, 0, 0);
28403 +int init_ptrace_proxy(int idle_pid, int startup, int stop)
28407 + pid = start_debugger(linux_prog, startup, stop, &debugger_fd);
28408 + status = wait_for_stop(idle_pid, SIGSTOP, PTRACE_CONT, NULL);
28413 + init_proxy(pid, 1, status);
28417 +int attach_debugger(int idle_pid, int pid, int stop)
28419 + int status = 0, err;
28421 + err = attach(pid);
28423 + printf("Failed to attach pid %d, errno = %d\n", pid, -err);
28426 + if(stop) status = wait_for_stop(idle_pid, SIGSTOP, PTRACE_CONT, NULL);
28427 + init_proxy(pid, 1, status);
28431 +#ifdef notdef /* Put this back in when it does something useful */
28432 +static int __init uml_gdb_init_setup(char *line, int *add)
28434 + gdb_init = uml_strdup(line);
28438 +__uml_setup("gdb=", uml_gdb_init_setup,
28439 +"gdb=<channel description>\n\n"
28443 +static int __init uml_gdb_pid_setup(char *line, int *add)
28445 + gdb_pid = strtoul(line, NULL, 0);
28450 +__uml_setup("gdb-pid=", uml_gdb_pid_setup,
28452 +" gdb-pid is used to attach an external debugger to UML. This may be\n"
28453 +" an already-running gdb or a debugger-like process like strace.\n\n"
28458 +int debugger_signal(int status, pid_t pid){ return(0); }
28459 +void child_signal(pid_t pid, int status){ }
28460 +int init_ptrace_proxy(int idle_pid, int startup, int stop)
28462 + printk(UM_KERN_ERR "debug requested when CONFIG_PT_PROXY is off\n");
28463 + kill_child_dead(idle_pid);
28467 +void signal_usr1(int sig)
28469 + printk(UM_KERN_ERR "debug requested when CONFIG_PT_PROXY is off\n");
28472 +int attach_debugger(int idle_pid, int pid, int stop)
28474 + printk(UM_KERN_ERR "attach_debugger called when CONFIG_PT_PROXY "
28479 +int config_gdb(char *str)
28484 +int remove_gdb(void)
28489 +int init_parent_proxy(int pid)
28494 +void debugger_parent_signal(int status, int pid)
28501 + * Overrides for Emacs so that we follow Linus's tabbing style.
28502 + * Emacs will notice this stuff at the end of the file and automatically
28503 + * adjust the settings for this buffer only. This must remain at the end
28505 + * ---------------------------------------------------------------------------
28506 + * Local variables:
28507 + * c-file-style: "linux"
28510 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/gdb_kern.c um/arch/um/kernel/tt/gdb_kern.c
28511 --- orig/arch/um/kernel/tt/gdb_kern.c 1969-12-31 19:00:00.000000000 -0500
28512 +++ um/arch/um/kernel/tt/gdb_kern.c 2003-10-21 03:26:07.000000000 -0400
28515 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
28516 + * Licensed under the GPL
28519 +#include "linux/init.h"
28520 +#include "linux/config.h"
28521 +#include "mconsole_kern.h"
28523 +#ifdef CONFIG_MCONSOLE
28525 +extern int gdb_config(char *str);
28526 +extern int gdb_remove(char *unused);
28528 +static struct mc_device gdb_mc = {
28530 + .config = gdb_config,
28531 + .remove = gdb_remove,
28534 +int gdb_mc_init(void)
28536 + mconsole_register_dev(&gdb_mc);
28540 +__initcall(gdb_mc_init);
28545 + * Overrides for Emacs so that we follow Linus's tabbing style.
28546 + * Emacs will notice this stuff at the end of the file and automatically
28547 + * adjust the settings for this buffer only. This must remain at the end
28549 + * ---------------------------------------------------------------------------
28550 + * Local variables:
28551 + * c-file-style: "linux"
28554 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/include/debug.h um/arch/um/kernel/tt/include/debug.h
28555 --- orig/arch/um/kernel/tt/include/debug.h 1969-12-31 19:00:00.000000000 -0500
28556 +++ um/arch/um/kernel/tt/include/debug.h 2003-10-21 03:26:07.000000000 -0400
28559 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) and
28560 + * Lars Brinkhoff.
28561 + * Licensed under the GPL
28567 +extern int debugger_proxy(int status, pid_t pid);
28568 +extern void child_proxy(pid_t pid, int status);
28569 +extern void init_proxy (pid_t pid, int waiting, int status);
28570 +extern int start_debugger(char *prog, int startup, int stop, int *debugger_fd);
28571 +extern void fake_child_exit(void);
28572 +extern int gdb_config(char *str);
28573 +extern int gdb_remove(char *unused);
28578 + * Overrides for Emacs so that we follow Linus's tabbing style.
28579 + * Emacs will notice this stuff at the end of the file and automatically
28580 + * adjust the settings for this buffer only. This must remain at the end
28582 + * ---------------------------------------------------------------------------
28583 + * Local variables:
28584 + * c-file-style: "linux"
28587 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/include/mmu.h um/arch/um/kernel/tt/include/mmu.h
28588 --- orig/arch/um/kernel/tt/include/mmu.h 1969-12-31 19:00:00.000000000 -0500
28589 +++ um/arch/um/kernel/tt/include/mmu.h 2003-10-21 03:26:07.000000000 -0400
28592 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
28593 + * Licensed under the GPL
28596 +#ifndef __TT_MMU_H
28597 +#define __TT_MMU_H
28599 +struct mmu_context_tt {
28605 + * Overrides for Emacs so that we follow Linus's tabbing style.
28606 + * Emacs will notice this stuff at the end of the file and automatically
28607 + * adjust the settings for this buffer only. This must remain at the end
28609 + * ---------------------------------------------------------------------------
28610 + * Local variables:
28611 + * c-file-style: "linux"
28614 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/include/mode.h um/arch/um/kernel/tt/include/mode.h
28615 --- orig/arch/um/kernel/tt/include/mode.h 1969-12-31 19:00:00.000000000 -0500
28616 +++ um/arch/um/kernel/tt/include/mode.h 2003-11-07 01:42:09.000000000 -0500
28619 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
28620 + * Licensed under the GPL
28623 +#ifndef __MODE_TT_H__
28624 +#define __MODE_TT_H__
28626 +#include "sysdep/ptrace.h"
28628 +enum { OP_NONE, OP_EXEC, OP_FORK, OP_TRACE_ON, OP_REBOOT, OP_HALT, OP_CB };
28630 +extern int tracing_pid;
28632 +extern int tracer(int (*init_proc)(void *), void *sp);
28633 +extern void user_time_init_tt(void);
28634 +extern int copy_sc_from_user_tt(void *to_ptr, void *from_ptr, void *data);
28635 +extern int copy_sc_to_user_tt(void *to_ptr, void *fp, void *from_ptr,
28637 +extern void sig_handler_common_tt(int sig, void *sc);
28638 +extern void syscall_handler_tt(int sig, union uml_pt_regs *regs);
28639 +extern void reboot_tt(void);
28640 +extern void halt_tt(void);
28641 +extern int is_tracer_winch(int pid, int fd, void *data);
28642 +extern void kill_off_processes_tt(void);
28647 + * Overrides for Emacs so that we follow Linus's tabbing style.
28648 + * Emacs will notice this stuff at the end of the file and automatically
28649 + * adjust the settings for this buffer only. This must remain at the end
28651 + * ---------------------------------------------------------------------------
28652 + * Local variables:
28653 + * c-file-style: "linux"
28656 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/include/mode_kern.h um/arch/um/kernel/tt/include/mode_kern.h
28657 --- orig/arch/um/kernel/tt/include/mode_kern.h 1969-12-31 19:00:00.000000000 -0500
28658 +++ um/arch/um/kernel/tt/include/mode_kern.h 2003-10-21 03:26:07.000000000 -0400
28661 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
28662 + * Licensed under the GPL
28665 +#ifndef __TT_MODE_KERN_H__
28666 +#define __TT_MODE_KERN_H__
28668 +#include "linux/sched.h"
28669 +#include "asm/page.h"
28670 +#include "asm/ptrace.h"
28671 +#include "asm/uaccess.h"
28673 +extern void *_switch_to_tt(void *prev, void *next);
28674 +extern void flush_thread_tt(void);
28675 +extern void start_thread_tt(struct pt_regs *regs, unsigned long eip,
28676 + unsigned long esp);
28677 +extern int copy_thread_tt(int nr, unsigned long clone_flags, unsigned long sp,
28678 + unsigned long stack_top, struct task_struct *p,
28679 + struct pt_regs *regs);
28680 +extern void release_thread_tt(struct task_struct *task);
28681 +extern void exit_thread_tt(void);
28682 +extern void initial_thread_cb_tt(void (*proc)(void *), void *arg);
28683 +extern void init_idle_tt(void);
28684 +extern void flush_tlb_kernel_vm_tt(void);
28685 +extern void __flush_tlb_one_tt(unsigned long addr);
28686 +extern void flush_tlb_range_tt(struct mm_struct *mm, unsigned long start,
28687 + unsigned long end);
28688 +extern void flush_tlb_mm_tt(struct mm_struct *mm);
28689 +extern void force_flush_all_tt(void);
28690 +extern long execute_syscall_tt(void *r);
28691 +extern void before_mem_tt(unsigned long brk_start);
28692 +extern unsigned long set_task_sizes_tt(int arg, unsigned long *host_size_out,
28693 + unsigned long *task_size_out);
28694 +extern int start_uml_tt(void);
28695 +extern int external_pid_tt(struct task_struct *task);
28696 +extern int thread_pid_tt(struct thread_struct *thread);
28698 +#define kmem_end_tt (host_task_size - ABOVE_KMEM)
28703 + * Overrides for Emacs so that we follow Linus's tabbing style.
28704 + * Emacs will notice this stuff at the end of the file and automatically
28705 + * adjust the settings for this buffer only. This must remain at the end
28707 + * ---------------------------------------------------------------------------
28708 + * Local variables:
28709 + * c-file-style: "linux"
28712 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/include/ptrace-tt.h um/arch/um/kernel/tt/include/ptrace-tt.h
28713 --- orig/arch/um/kernel/tt/include/ptrace-tt.h 1969-12-31 19:00:00.000000000 -0500
28714 +++ um/arch/um/kernel/tt/include/ptrace-tt.h 2003-10-21 03:26:07.000000000 -0400
28717 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
28718 + * Licensed under the GPL
28721 +#ifndef __PTRACE_TT_H
28722 +#define __PTRACE_TT_H
28724 +#include "uml-config.h"
28726 +#ifdef UML_CONFIG_MODE_TT
28727 +#include "sysdep/sc.h"
28733 + * Overrides for Emacs so that we follow Linus's tabbing style.
28734 + * Emacs will notice this stuff at the end of the file and automatically
28735 + * adjust the settings for this buffer only. This must remain at the end
28737 + * ---------------------------------------------------------------------------
28738 + * Local variables:
28739 + * c-file-style: "linux"
28742 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/include/tt.h um/arch/um/kernel/tt/include/tt.h
28743 --- orig/arch/um/kernel/tt/include/tt.h 1969-12-31 19:00:00.000000000 -0500
28744 +++ um/arch/um/kernel/tt/include/tt.h 2003-10-21 03:26:07.000000000 -0400
28747 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
28748 + * Licensed under the GPL
28754 +#include "sysdep/ptrace.h"
28756 +extern int gdb_pid;
28758 +extern int debug_stop;
28759 +extern int debug_trace;
28761 +extern int honeypot;
28763 +extern int fork_tramp(void *sig_stack);
28764 +extern int do_proc_op(void *t, int proc_id);
28765 +extern int tracer(int (*init_proc)(void *), void *sp);
28766 +extern void attach_process(int pid);
28767 +extern void tracer_panic(char *format, ...);
28768 +extern void set_init_pid(int pid);
28769 +extern int set_user_mode(void *task);
28770 +extern void set_tracing(void *t, int tracing);
28771 +extern int is_tracing(void *task);
28772 +extern int singlestepping_tt(void *t);
28773 +extern void clear_singlestep(void *t);
28774 +extern void syscall_handler(int sig, union uml_pt_regs *regs);
28775 +extern void exit_kernel(int pid, void *task);
28776 +extern int do_syscall(void *task, int pid);
28777 +extern int is_valid_pid(int pid);
28778 +extern void remap_data(void *segment_start, void *segment_end, int w);
28783 + * Overrides for Emacs so that we follow Linus's tabbing style.
28784 + * Emacs will notice this stuff at the end of the file and automatically
28785 + * adjust the settings for this buffer only. This must remain at the end
28787 + * ---------------------------------------------------------------------------
28788 + * Local variables:
28789 + * c-file-style: "linux"
28792 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/include/uaccess.h um/arch/um/kernel/tt/include/uaccess.h
28793 --- orig/arch/um/kernel/tt/include/uaccess.h 1969-12-31 19:00:00.000000000 -0500
28794 +++ um/arch/um/kernel/tt/include/uaccess.h 2003-11-12 08:37:20.000000000 -0500
28797 + * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
28798 + * Licensed under the GPL
28801 +#ifndef __TT_UACCESS_H
28802 +#define __TT_UACCESS_H
28804 +#include "linux/string.h"
28805 +#include "linux/sched.h"
28806 +#include "asm/processor.h"
28807 +#include "asm/errno.h"
28808 +#include "asm/current.h"
28809 +#include "asm/a.out.h"
28810 +#include "uml_uaccess.h"
28812 +#define ABOVE_KMEM (16 * 1024 * 1024)
28814 +extern unsigned long end_vm;
28815 +extern unsigned long uml_physmem;
28817 +#define under_task_size(addr, size) \
28818 + (((unsigned long) (addr) < TASK_SIZE) && \
28819 + (((unsigned long) (addr) + (size)) < TASK_SIZE))
28821 +#define is_stack(addr, size) \
28822 + (((unsigned long) (addr) < STACK_TOP) && \
28823 + ((unsigned long) (addr) >= STACK_TOP - ABOVE_KMEM) && \
28824 + (((unsigned long) (addr) + (size)) <= STACK_TOP))
28826 +#define access_ok_tt(type, addr, size) \
28827 + ((type == VERIFY_READ) || (segment_eq(get_fs(), KERNEL_DS)) || \
28828 + (((unsigned long) (addr) <= ((unsigned long) (addr) + (size))) && \
28829 + (under_task_size(addr, size) || is_stack(addr, size))))
28831 +static inline int verify_area_tt(int type, const void * addr,
28832 + unsigned long size)
28834 + return(access_ok_tt(type, addr, size) ? 0 : -EFAULT);
28837 +extern unsigned long get_fault_addr(void);
28839 +extern int __do_copy_from_user(void *to, const void *from, int n,
28840 + void **fault_addr, void **fault_catcher);
28841 +extern int __do_strncpy_from_user(char *dst, const char *src, size_t n,
28842 + void **fault_addr, void **fault_catcher);
28843 +extern int __do_clear_user(void *mem, size_t len, void **fault_addr,
28844 + void **fault_catcher);
28845 +extern int __do_strnlen_user(const char *str, unsigned long n,
28846 + void **fault_addr, void **fault_catcher);
28848 +extern int copy_from_user_tt(void *to, const void *from, int n);
28849 +extern int copy_to_user_tt(void *to, const void *from, int n);
28850 +extern int strncpy_from_user_tt(char *dst, const char *src, int count);
28851 +extern int __clear_user_tt(void *mem, int len);
28852 +extern int clear_user_tt(void *mem, int len);
28853 +extern int strnlen_user_tt(const void *str, int len);
28858 + * Overrides for Emacs so that we follow Linus's tabbing style.
28859 + * Emacs will notice this stuff at the end of the file and automatically
28860 + * adjust the settings for this buffer only. This must remain at the end
28862 + * ---------------------------------------------------------------------------
28863 + * Local variables:
28864 + * c-file-style: "linux"
28867 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/ksyms.c um/arch/um/kernel/tt/ksyms.c
28868 --- orig/arch/um/kernel/tt/ksyms.c 1969-12-31 19:00:00.000000000 -0500
28869 +++ um/arch/um/kernel/tt/ksyms.c 2003-10-21 03:26:07.000000000 -0400
28872 + * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
28873 + * Licensed under the GPL
28876 +#include "linux/module.h"
28877 +#include "asm/uaccess.h"
28880 +EXPORT_SYMBOL(__do_copy_from_user);
28881 +EXPORT_SYMBOL(__do_copy_to_user);
28882 +EXPORT_SYMBOL(__do_strncpy_from_user);
28883 +EXPORT_SYMBOL(__do_strnlen_user);
28884 +EXPORT_SYMBOL(__do_clear_user);
28886 +EXPORT_SYMBOL(tracing_pid);
28887 +EXPORT_SYMBOL(honeypot);
28890 + * Overrides for Emacs so that we follow Linus's tabbing style.
28891 + * Emacs will notice this stuff at the end of the file and automatically
28892 + * adjust the settings for this buffer only. This must remain at the end
28894 + * ---------------------------------------------------------------------------
28895 + * Local variables:
28896 + * c-file-style: "linux"
28899 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/Makefile um/arch/um/kernel/tt/Makefile
28900 --- orig/arch/um/kernel/tt/Makefile 1969-12-31 19:00:00.000000000 -0500
28901 +++ um/arch/um/kernel/tt/Makefile 2003-11-12 08:34:27.000000000 -0500
28904 +# Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com)
28905 +# Licensed under the GPL
28910 +obj-y = exec_kern.o exec_user.o gdb.o ksyms.o mem.o mem_user.o process_kern.o \
28911 + syscall_kern.o syscall_user.o time.o tlb.o tracer.o trap_user.o \
28912 + uaccess.o uaccess_user.o
28914 +obj-$(CONFIG_PT_PROXY) += gdb_kern.o
28916 +subdir-y = sys-$(SUBARCH)
28917 +subdir-$(CONFIG_PT_PROXY) += ptproxy
28919 +obj-y += $(join $(subdir-y),$(subdir-y:%=/%.o))
28921 +export-objs = ksyms.o
28923 +USER_OBJS = $(filter %_user.o,$(obj-y)) gdb.o time.o tracer.o
28925 +UNMAP_CFLAGS := $(patsubst -pg -DPROFILING,,$(USER_CFLAGS))
28926 +UNMAP_CFLAGS := $(patsubst -fprofile-arcs -ftest-coverage,,$(UNMAP_CFLAGS))
28928 +include $(TOPDIR)/Rules.make
28930 +$(USER_OBJS) : %.o: %.c
28931 + $(CC) $(CFLAGS_$@) $(USER_CFLAGS) -c -o $@ $<
28933 +$(O_TARGET) : unmap_fin.o
28936 + $(CC) $(UNMAP_CFLAGS) -c -o $@ $<
28938 +unmap_fin.o : unmap.o
28939 + ld -r -o $@ $< -lc -L/usr/lib
28942 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/mem.c um/arch/um/kernel/tt/mem.c
28943 --- orig/arch/um/kernel/tt/mem.c 1969-12-31 19:00:00.000000000 -0500
28944 +++ um/arch/um/kernel/tt/mem.c 2004-01-31 02:38:28.000000000 -0500
28947 + * Copyright (C) 2002 - 2004 Jeff Dike (jdike@karaya.com)
28948 + * Licensed under the GPL
28951 +#include "linux/stddef.h"
28952 +#include "linux/config.h"
28953 +#include "linux/mm.h"
28954 +#include "asm/uaccess.h"
28955 +#include "mem_user.h"
28956 +#include "kern_util.h"
28957 +#include "user_util.h"
28961 +void before_mem_tt(unsigned long brk_start)
28963 + if(!jail || debug)
28964 + remap_data(UML_ROUND_DOWN(&_stext), UML_ROUND_UP(&_etext), 1);
28965 + remap_data(UML_ROUND_DOWN(&_sdata), UML_ROUND_UP(&_edata), 1);
28966 + remap_data(UML_ROUND_DOWN(&__bss_start), UML_ROUND_UP(&_end), 1);
28969 +#ifdef CONFIG_HOST_2G_2G
28970 +#define TOP 0x80000000
28972 +#define TOP 0xc0000000
28975 +#define SIZE ((CONFIG_NEST_LEVEL + CONFIG_KERNEL_HALF_GIGS) * 0x20000000)
28976 +#define START (TOP - SIZE)
28978 +unsigned long set_task_sizes_tt(int arg, unsigned long *host_size_out,
28979 + unsigned long *task_size_out)
28981 + /* Round up to the nearest 4M */
28982 + *host_size_out = ROUND_4M((unsigned long) &arg);
28983 + *task_size_out = START;
28988 + * Overrides for Emacs so that we follow Linus's tabbing style.
28989 + * Emacs will notice this stuff at the end of the file and automatically
28990 + * adjust the settings for this buffer only. This must remain at the end
28992 + * ---------------------------------------------------------------------------
28993 + * Local variables:
28994 + * c-file-style: "linux"
28997 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/mem_user.c um/arch/um/kernel/tt/mem_user.c
28998 --- orig/arch/um/kernel/tt/mem_user.c 1969-12-31 19:00:00.000000000 -0500
28999 +++ um/arch/um/kernel/tt/mem_user.c 2003-10-21 03:26:07.000000000 -0400
29002 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
29003 + * Licensed under the GPL
29006 +#include <stdlib.h>
29007 +#include <stdio.h>
29008 +#include <unistd.h>
29009 +#include <string.h>
29010 +#include <errno.h>
29011 +#include <sys/mman.h>
29013 +#include "mem_user.h"
29014 +#include "user_util.h"
29016 +void remap_data(void *segment_start, void *segment_end, int w)
29019 + unsigned long size;
29022 + if(w) prot = PROT_WRITE;
29024 + prot |= PROT_READ | PROT_EXEC;
29025 + size = (unsigned long) segment_end -
29026 + (unsigned long) segment_start;
29027 + data = create_mem_file(size);
29028 + addr = mmap(NULL, size, PROT_WRITE | PROT_READ, MAP_SHARED, data, 0);
29029 + if(addr == MAP_FAILED){
29030 + perror("mapping new data segment");
29033 + memcpy(addr, segment_start, size);
29034 + if(switcheroo(data, prot, addr, segment_start, size) < 0){
29035 + printf("switcheroo failed\n");
29041 + * Overrides for Emacs so that we follow Linus's tabbing style.
29042 + * Emacs will notice this stuff at the end of the file and automatically
29043 + * adjust the settings for this buffer only. This must remain at the end
29045 + * ---------------------------------------------------------------------------
29046 + * Local variables:
29047 + * c-file-style: "linux"
29050 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/process_kern.c um/arch/um/kernel/tt/process_kern.c
29051 --- orig/arch/um/kernel/tt/process_kern.c 1969-12-31 19:00:00.000000000 -0500
29052 +++ um/arch/um/kernel/tt/process_kern.c 2004-01-31 02:39:08.000000000 -0500
29055 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
29056 + * Licensed under the GPL
29059 +#include "linux/sched.h"
29060 +#include "linux/signal.h"
29061 +#include "linux/kernel.h"
29062 +#include "asm/system.h"
29063 +#include "asm/pgalloc.h"
29064 +#include "asm/ptrace.h"
29065 +#include "irq_user.h"
29066 +#include "signal_user.h"
29067 +#include "kern_util.h"
29068 +#include "user_util.h"
29071 +#include "sigcontext.h"
29072 +#include "time_user.h"
29073 +#include "mem_user.h"
29079 +void *_switch_to_tt(void *prev, void *next)
29081 + struct task_struct *from, *to;
29082 + unsigned long flags;
29083 + int err, vtalrm, alrm, prof, cpu;
29085 + /* jailing and SMP are incompatible, so this doesn't need to be
29088 + static int reading;
29093 + to->thread.prev_sched = from;
29095 + cpu = from->processor;
29097 + forward_interrupts(to->thread.mode.tt.extern_pid);
29099 + forward_ipi(cpu_data[cpu].ipi_pipe[0], to->thread.mode.tt.extern_pid);
29101 + local_irq_save(flags);
29103 + vtalrm = change_sig(SIGVTALRM, 0);
29104 + alrm = change_sig(SIGALRM, 0);
29105 + prof = change_sig(SIGPROF, 0);
29111 + err = os_write_file(to->thread.mode.tt.switch_pipe[1], &c, sizeof(c));
29112 + if(err != sizeof(c))
29113 + panic("write of switch_pipe failed, err = %d", -err);
29116 + if(from->state == TASK_ZOMBIE)
29117 + os_kill_process(os_getpid(), 0);
29119 + err = os_read_file(from->thread.mode.tt.switch_pipe[0], &c, sizeof(c));
29120 + if(err != sizeof(c))
29121 + panic("read of switch_pipe failed, errno = %d", -err);
29123 + /* This works around a nasty race with 'jail'. If we are switching
29124 + * between two threads of a threaded app and the incoming process
29125 + * runs before the outgoing process reaches the read, and it makes
29126 + * it all the way out to userspace, then it will have write-protected
29127 + * the outgoing process stack. Then, when the outgoing process
29128 + * returns from the write, it will segfault because it can no longer
29129 + * write its own stack. So, in order to avoid that, the incoming
29130 + * thread sits in a loop yielding until 'reading' is set. This
29131 + * isn't entirely safe, since there may be a reschedule from a timer
29132 + * happening between setting 'reading' and sleeping in read. But,
29133 + * it should get a whole quantum in which to reach the read and sleep,
29134 + * which should be enough.
29138 + while(!reading) sched_yield();
29141 + change_sig(SIGVTALRM, vtalrm);
29142 + change_sig(SIGALRM, alrm);
29143 + change_sig(SIGPROF, prof);
29148 + local_irq_restore(flags);
29150 + return(current->thread.prev_sched);
29153 +void release_thread_tt(struct task_struct *task)
29155 + os_kill_process(task->thread.mode.tt.extern_pid, 0);
29158 +void exit_thread_tt(void)
29160 + os_close_file(current->thread.mode.tt.switch_pipe[0]);
29161 + os_close_file(current->thread.mode.tt.switch_pipe[1]);
29164 +extern void schedule_tail(struct task_struct *prev);
29166 +static void new_thread_handler(int sig)
29168 + unsigned long disable;
29169 + int (*fn)(void *);
29172 + fn = current->thread.request.u.thread.proc;
29173 + arg = current->thread.request.u.thread.arg;
29175 + UPT_SC(¤t->thread.regs.regs) = (void *) (&sig + 1);
29176 + disable = (1 << (SIGVTALRM - 1)) | (1 << (SIGALRM - 1)) |
29177 + (1 << (SIGIO - 1)) | (1 << (SIGPROF - 1));
29178 + SC_SIGMASK(UPT_SC(¤t->thread.regs.regs)) &= ~disable;
29180 + suspend_new_thread(current->thread.mode.tt.switch_pipe[0]);
29182 + init_new_thread_signals(1);
29184 + free_page(current->thread.temp_stack);
29185 + set_cmdline("(kernel thread)");
29186 + force_flush_all();
29188 + if(current->thread.prev_sched != NULL)
29189 + schedule_tail(current->thread.prev_sched);
29190 + current->thread.prev_sched = NULL;
29192 + change_sig(SIGUSR1, 1);
29193 + change_sig(SIGVTALRM, 1);
29194 + change_sig(SIGPROF, 1);
29196 + if(!run_kernel_thread(fn, arg, ¤t->thread.exec_buf))
29200 +static int new_thread_proc(void *stack)
29202 + /* cli is needed to block out signals until this thread is properly
29203 + * scheduled. Otherwise, the tracing thread will get mighty upset
29204 + * about any signals that arrive before that.
29205 + * This has the complication that it sets the saved signal mask in
29206 + * the sigcontext to block signals. This gets restored when this
29207 + * thread (or a descendant, since they get a copy of this sigcontext)
29208 + * returns to userspace.
29209 + * So, this is compensated for elsewhere.
29210 + * XXX There is still a small window until cli() actually finishes
29211 + * where signals are possible - shouldn't be a problem in practice
29212 + * since SIGIO hasn't been forwarded here yet, and the cli should
29213 + * finish before a SIGVTALRM has time to be delivered.
29216 + init_new_thread_stack(stack, new_thread_handler);
29217 + os_usr1_process(os_getpid());
29221 +/* Signal masking - signals are blocked at the start of fork_tramp. They
29222 + * are re-enabled when finish_fork_handler is entered by fork_tramp hitting
29223 + * itself with a SIGUSR1. set_user_mode has to be run with SIGUSR1 off,
29224 + * so it is blocked before it's called. They are re-enabled on sigreturn
29225 + * despite the fact that they were blocked when the SIGUSR1 was issued because
29226 + * copy_thread copies the parent's sigcontext, including the signal mask
29227 + * onto the signal frame.
29230 +static void finish_fork_handler(int sig)
29232 + UPT_SC(¤t->thread.regs.regs) = (void *) (&sig + 1);
29233 + suspend_new_thread(current->thread.mode.tt.switch_pipe[0]);
29235 + init_new_thread_signals(1);
29238 + force_flush_all();
29239 + if(current->mm != current->p_pptr->mm)
29240 + protect_memory(uml_reserved, high_physmem - uml_reserved, 1,
29242 + task_protections((unsigned long) current);
29244 + if(current->thread.prev_sched != NULL)
29245 + schedule_tail(current->thread.prev_sched);
29246 + current->thread.prev_sched = NULL;
29248 + free_page(current->thread.temp_stack);
29250 + change_sig(SIGUSR1, 0);
29251 + set_user_mode(current);
29254 +int fork_tramp(void *stack)
29257 + arch_init_thread();
29258 + init_new_thread_stack(stack, finish_fork_handler);
29259 + os_usr1_process(os_getpid());
29263 +int copy_thread_tt(int nr, unsigned long clone_flags, unsigned long sp,
29264 + unsigned long stack_top, struct task_struct * p,
29265 + struct pt_regs *regs)
29267 + int (*tramp)(void *);
29268 + int new_pid, err;
29269 + unsigned long stack;
29271 + if(current->thread.forking)
29272 + tramp = fork_tramp;
29274 + tramp = new_thread_proc;
29275 + p->thread.request.u.thread = current->thread.request.u.thread;
29278 + err = os_pipe(p->thread.mode.tt.switch_pipe, 1, 1);
29280 + printk("copy_thread : pipe failed, err = %d\n", -err);
29284 + stack = alloc_stack(0, 0);
29286 + printk(KERN_ERR "copy_thread : failed to allocate "
29287 + "temporary stack\n");
29291 + clone_flags &= CLONE_VM;
29292 + p->thread.temp_stack = stack;
29293 + new_pid = start_fork_tramp((void *) p->thread.kernel_stack, stack,
29294 + clone_flags, tramp);
29296 + printk(KERN_ERR "copy_thread : clone failed - errno = %d\n",
29301 + if(current->thread.forking){
29302 + sc_to_sc(UPT_SC(&p->thread.regs.regs),
29303 + UPT_SC(¤t->thread.regs.regs));
29304 + SC_SET_SYSCALL_RETURN(UPT_SC(&p->thread.regs.regs), 0);
29305 + if(sp != 0) SC_SP(UPT_SC(&p->thread.regs.regs)) = sp;
29307 + p->thread.mode.tt.extern_pid = new_pid;
29309 + current->thread.request.op = OP_FORK;
29310 + current->thread.request.u.fork.pid = new_pid;
29311 + os_usr1_process(os_getpid());
29315 +void reboot_tt(void)
29317 + current->thread.request.op = OP_REBOOT;
29318 + os_usr1_process(os_getpid());
29321 +void halt_tt(void)
29323 + current->thread.request.op = OP_HALT;
29324 + os_usr1_process(os_getpid());
29327 +void kill_off_processes_tt(void)
29329 + struct task_struct *p;
29332 + me = os_getpid();
29333 + for_each_task(p){
29334 + int pid = p->thread.mode.tt.extern_pid;
29335 + if((pid != me) && (pid != -1))
29336 + os_kill_process(p->thread.mode.tt.extern_pid, 0);
29338 + if((init_task.thread.mode.tt.extern_pid != me) &&
29339 + (init_task.thread.mode.tt.extern_pid != -1))
29340 + os_kill_process(init_task.thread.mode.tt.extern_pid, 0);
29343 +void initial_thread_cb_tt(void (*proc)(void *), void *arg)
29345 + if(os_getpid() == tracing_pid){
29349 + current->thread.request.op = OP_CB;
29350 + current->thread.request.u.cb.proc = proc;
29351 + current->thread.request.u.cb.arg = arg;
29352 + os_usr1_process(os_getpid());
29356 +int do_proc_op(void *t, int proc_id)
29358 + struct task_struct *task;
29359 + struct thread_struct *thread;
29363 + thread = &task->thread;
29364 + op = thread->request.op;
29367 + case OP_TRACE_ON:
29370 + pid = thread->request.u.exec.pid;
29371 + do_exec(thread->mode.tt.extern_pid, pid);
29372 + thread->mode.tt.extern_pid = pid;
29373 + cpu_tasks[task->processor].pid = pid;
29376 + attach_process(thread->request.u.fork.pid);
29379 + (*thread->request.u.cb.proc)(thread->request.u.cb.arg);
29385 + tracer_panic("Bad op in do_proc_op");
29388 + thread->request.op = OP_NONE;
29392 +void init_idle_tt(void)
29397 +/* Changed by jail_setup, which is a setup */
29400 +int __init jail_setup(char *line, int *add)
29404 + if(jail) return(0);
29406 + printf("'jail' may not used used in a kernel with CONFIG_SMP "
29410 +#ifdef CONFIG_HOSTFS
29411 + printf("'jail' may not used used in a kernel with CONFIG_HOSTFS "
29415 +#ifdef CONFIG_MODULES
29416 + printf("'jail' may not used used in a kernel with CONFIG_MODULES "
29422 + /* CAP_SYS_RAWIO controls the ability to open /dev/mem and /dev/kmem.
29423 + * Removing it from the bounding set eliminates the ability of anything
29424 + * to acquire it, and thus read or write kernel memory.
29426 + cap_lower(cap_bset, CAP_SYS_RAWIO);
29431 +__uml_setup("jail", jail_setup,
29433 +" Enables the protection of kernel memory from processes.\n\n"
29436 +static void mprotect_kernel_mem(int w)
29438 + unsigned long start, end;
29441 + if(!jail || (current == &init_task)) return;
29443 + pages = (1 << CONFIG_KERNEL_STACK_ORDER);
29445 + start = (unsigned long) current + PAGE_SIZE;
29446 + end = (unsigned long) current + PAGE_SIZE * pages;
29447 + protect_memory(uml_reserved, start - uml_reserved, 1, w, 1, 1);
29448 + protect_memory(end, high_physmem - end, 1, w, 1, 1);
29450 + start = (unsigned long) UML_ROUND_DOWN(&_stext);
29451 + end = (unsigned long) UML_ROUND_UP(&_etext);
29452 + protect_memory(start, end - start, 1, w, 1, 1);
29454 + start = (unsigned long) UML_ROUND_DOWN(&_unprotected_end);
29455 + end = (unsigned long) UML_ROUND_UP(&_edata);
29456 + protect_memory(start, end - start, 1, w, 1, 1);
29458 + start = (unsigned long) UML_ROUND_DOWN(&__bss_start);
29459 + end = (unsigned long) UML_ROUND_UP(&_end);
29460 + protect_memory(start, end - start, 1, w, 1, 1);
29462 + mprotect_kernel_vm(w);
29465 +void unprotect_kernel_mem(void)
29467 + mprotect_kernel_mem(1);
29470 +void protect_kernel_mem(void)
29472 + mprotect_kernel_mem(0);
29475 +extern void start_kernel(void);
29477 +static int start_kernel_proc(void *unused)
29482 + pid = os_getpid();
29484 + cpu_tasks[0].pid = pid;
29485 + cpu_tasks[0].task = current;
29487 + cpu_online_map = 1;
29489 + if(debug) os_stop_process(pid);
29494 +void set_tracing(void *task, int tracing)
29496 + ((struct task_struct *) task)->thread.mode.tt.tracing = tracing;
29499 +int is_tracing(void *t)
29501 + return (((struct task_struct *) t)->thread.mode.tt.tracing);
29504 +int set_user_mode(void *t)
29506 + struct task_struct *task;
29508 + task = t ? t : current;
29509 + if(task->thread.mode.tt.tracing)
29511 + task->thread.request.op = OP_TRACE_ON;
29512 + os_usr1_process(os_getpid());
29516 +void set_init_pid(int pid)
29520 + init_task.thread.mode.tt.extern_pid = pid;
29521 + err = os_pipe(init_task.thread.mode.tt.switch_pipe, 1, 1);
29523 + panic("Can't create switch pipe for init_task, errno = %d",
29527 +int singlestepping_tt(void *t)
29529 + struct task_struct *task = t;
29531 + if(task->thread.mode.tt.singlestep_syscall)
29533 + return(task->ptrace & PT_DTRACE);
29536 +void clear_singlestep(void *t)
29538 + struct task_struct *task = t;
29540 + task->ptrace &= ~PT_DTRACE;
29543 +int start_uml_tt(void)
29548 + pages = (1 << CONFIG_KERNEL_STACK_ORDER) - 2;
29549 + sp = (void *) init_task.thread.kernel_stack + pages * PAGE_SIZE -
29550 + sizeof(unsigned long);
29551 + return(tracer(start_kernel_proc, sp));
29554 +int external_pid_tt(struct task_struct *task)
29556 + return(task->thread.mode.tt.extern_pid);
29559 +int thread_pid_tt(struct thread_struct *thread)
29561 + return(thread->mode.tt.extern_pid);
29564 +int is_valid_pid(int pid)
29566 + struct task_struct *task;
29568 + read_lock(&tasklist_lock);
29569 + for_each_task(task){
29570 + if(task->thread.mode.tt.extern_pid == pid){
29571 + read_unlock(&tasklist_lock);
29575 + read_unlock(&tasklist_lock);
29580 + * Overrides for Emacs so that we follow Linus's tabbing style.
29581 + * Emacs will notice this stuff at the end of the file and automatically
29582 + * adjust the settings for this buffer only. This must remain at the end
29584 + * ---------------------------------------------------------------------------
29585 + * Local variables:
29586 + * c-file-style: "linux"
29589 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/ptproxy/Makefile um/arch/um/kernel/tt/ptproxy/Makefile
29590 --- orig/arch/um/kernel/tt/ptproxy/Makefile 1969-12-31 19:00:00.000000000 -0500
29591 +++ um/arch/um/kernel/tt/ptproxy/Makefile 2003-10-21 03:26:07.000000000 -0400
29593 +O_TARGET = ptproxy.o
29595 +obj-y = proxy.o ptrace.o sysdep.o wait.o
29597 +USER_OBJS = $(obj-y)
29599 +include $(TOPDIR)/Rules.make
29601 +$(USER_OBJS) : %.o: %.c
29602 + $(CC) $(CFLAGS_$@) $(USER_CFLAGS) -c -o $@ $<
29605 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/ptproxy/proxy.c um/arch/um/kernel/tt/ptproxy/proxy.c
29606 --- orig/arch/um/kernel/tt/ptproxy/proxy.c 1969-12-31 19:00:00.000000000 -0500
29607 +++ um/arch/um/kernel/tt/ptproxy/proxy.c 2003-10-21 03:26:07.000000000 -0400
29609 +/**********************************************************************
29612 +Copyright (C) 1999 Lars Brinkhoff. See the file COPYING for licensing
29613 +terms and conditions.
29615 +Jeff Dike (jdike@karaya.com) : Modified for integration into uml
29616 +**********************************************************************/
29618 +/* XXX This file shouldn't refer to CONFIG_* */
29620 +#include <errno.h>
29621 +#include <stdio.h>
29622 +#include <stdlib.h>
29623 +#include <unistd.h>
29624 +#include <signal.h>
29625 +#include <string.h>
29626 +#include <termios.h>
29627 +#include <sys/wait.h>
29628 +#include <sys/types.h>
29629 +#include <sys/ptrace.h>
29630 +#include <sys/ioctl.h>
29631 +#include <asm/unistd.h>
29633 +#include "ptproxy.h"
29634 +#include "sysdep.h"
29637 +#include "user_util.h"
29640 +#include "tempfile.h"
29642 +static int debugger_wait(debugger_state *debugger, int *status, int options,
29643 + int (*syscall)(debugger_state *debugger, pid_t child),
29644 + int (*normal_return)(debugger_state *debugger,
29646 + int (*wait_return)(debugger_state *debugger,
29649 + if(debugger->real_wait){
29650 + debugger->handle_trace = normal_return;
29651 + syscall_continue(debugger->pid);
29652 + debugger->real_wait = 0;
29655 + debugger->wait_status_ptr = status;
29656 + debugger->wait_options = options;
29657 + if((debugger->debugee != NULL) && debugger->debugee->event){
29658 + syscall_continue(debugger->pid);
29659 + wait_for_stop(debugger->pid, SIGTRAP, PTRACE_SYSCALL,
29661 + (*wait_return)(debugger, -1);
29664 + else if(debugger->wait_options & WNOHANG){
29665 + syscall_cancel(debugger->pid, 0);
29666 + debugger->handle_trace = syscall;
29670 + syscall_pause(debugger->pid);
29671 + debugger->handle_trace = wait_return;
29672 + debugger->waiting = 1;
29678 + * Handle debugger trap, i.e. syscall.
29681 +int debugger_syscall(debugger_state *debugger, pid_t child)
29683 + long arg1, arg2, arg3, arg4, arg5, result;
29684 + int syscall, ret = 0;
29686 + syscall = get_syscall(debugger->pid, &arg1, &arg2, &arg3, &arg4,
29690 + case __NR_execve:
29691 + /* execve never returns */
29692 + debugger->handle_trace = debugger_syscall;
29695 + case __NR_ptrace:
29696 + if(debugger->debugee->pid != 0) arg2 = debugger->debugee->pid;
29697 + if(!debugger->debugee->in_context)
29698 + child = debugger->debugee->pid;
29699 + result = proxy_ptrace(debugger, arg1, arg2, arg3, arg4, child,
29701 + syscall_cancel(debugger->pid, result);
29702 + debugger->handle_trace = debugger_syscall;
29705 + case __NR_waitpid:
29707 + if(!debugger_wait(debugger, (int *) arg2, arg3,
29708 + debugger_syscall, debugger_normal_return,
29709 + proxy_wait_return))
29714 + if(!debugger->debugee->in_context)
29715 + child = debugger->debugee->pid;
29716 + if(arg1 == debugger->debugee->pid){
29717 + result = kill(child, arg2);
29718 + syscall_cancel(debugger->pid, result);
29719 + debugger->handle_trace = debugger_syscall;
29722 + else debugger->handle_trace = debugger_normal_return;
29726 + debugger->handle_trace = debugger_normal_return;
29729 + syscall_continue(debugger->pid);
29733 +/* Used by the tracing thread */
29734 +static debugger_state parent;
29735 +static int parent_syscall(debugger_state *debugger, int pid);
29737 +int init_parent_proxy(int pid)
29739 + parent = ((debugger_state) { .pid = pid,
29740 + .wait_options = 0,
29741 + .wait_status_ptr = NULL,
29744 + .expecting_child = 0,
29745 + .handle_trace = parent_syscall,
29746 + .debugee = NULL } );
29750 +int parent_normal_return(debugger_state *debugger, pid_t unused)
29752 + debugger->handle_trace = parent_syscall;
29753 + syscall_continue(debugger->pid);
29757 +static int parent_syscall(debugger_state *debugger, int pid)
29759 + long arg1, arg2, arg3, arg4, arg5;
29762 + syscall = get_syscall(pid, &arg1, &arg2, &arg3, &arg4, &arg5);
29764 + if((syscall == __NR_waitpid) || (syscall == __NR_wait4)){
29765 + debugger_wait(&parent, (int *) arg2, arg3, parent_syscall,
29766 + parent_normal_return, parent_wait_return);
29768 + else ptrace(PTRACE_SYSCALL, pid, 0, 0);
29772 +int debugger_normal_return(debugger_state *debugger, pid_t unused)
29774 + debugger->handle_trace = debugger_syscall;
29775 + syscall_continue(debugger->pid);
29779 +void debugger_cancelled_return(debugger_state *debugger, int result)
29781 + debugger->handle_trace = debugger_syscall;
29782 + syscall_set_result(debugger->pid, result);
29783 + syscall_continue(debugger->pid);
29786 +/* Used by the tracing thread */
29787 +static debugger_state debugger;
29788 +static debugee_state debugee;
29790 +void init_proxy (pid_t debugger_pid, int stopped, int status)
29792 + debugger.pid = debugger_pid;
29793 + debugger.handle_trace = debugger_syscall;
29794 + debugger.debugee = &debugee;
29795 + debugger.waiting = 0;
29796 + debugger.real_wait = 0;
29797 + debugger.expecting_child = 0;
29800 + debugee.traced = 0;
29801 + debugee.stopped = stopped;
29802 + debugee.event = 0;
29803 + debugee.zombie = 0;
29804 + debugee.died = 0;
29805 + debugee.wait_status = status;
29806 + debugee.in_context = 1;
29809 +int debugger_proxy(int status, int pid)
29811 + int ret = 0, sig;
29813 + if(WIFSTOPPED(status)){
29814 + sig = WSTOPSIG(status);
29815 + if (sig == SIGTRAP)
29816 + ret = (*debugger.handle_trace)(&debugger, pid);
29818 + else if(sig == SIGCHLD){
29819 + if(debugger.expecting_child){
29820 + ptrace(PTRACE_SYSCALL, debugger.pid, 0, sig);
29821 + debugger.expecting_child = 0;
29823 + else if(debugger.waiting)
29824 + real_wait_return(&debugger);
29826 + ptrace(PTRACE_SYSCALL, debugger.pid, 0, sig);
29827 + debugger.real_wait = 1;
29830 + else ptrace(PTRACE_SYSCALL, debugger.pid, 0, sig);
29832 + else if(WIFEXITED(status)){
29833 + tracer_panic("debugger (pid %d) exited with status %d",
29834 + debugger.pid, WEXITSTATUS(status));
29836 + else if(WIFSIGNALED(status)){
29837 + tracer_panic("debugger (pid %d) exited with signal %d",
29838 + debugger.pid, WTERMSIG(status));
29841 + tracer_panic("proxy got unknown status (0x%x) on debugger "
29842 + "(pid %d)", status, debugger.pid);
29847 +void child_proxy(pid_t pid, int status)
29849 + debugee.event = 1;
29850 + debugee.wait_status = status;
29852 + if(WIFSTOPPED(status)){
29853 + debugee.stopped = 1;
29854 + debugger.expecting_child = 1;
29855 + kill(debugger.pid, SIGCHLD);
29857 + else if(WIFEXITED(status) || WIFSIGNALED(status)){
29858 + debugee.zombie = 1;
29859 + debugger.expecting_child = 1;
29860 + kill(debugger.pid, SIGCHLD);
29862 + else panic("proxy got unknown status (0x%x) on child (pid %d)",
29866 +void debugger_parent_signal(int status, int pid)
29870 + if(WIFSTOPPED(status)){
29871 + sig = WSTOPSIG(status);
29872 + if(sig == SIGTRAP) (*parent.handle_trace)(&parent, pid);
29873 + else ptrace(PTRACE_SYSCALL, pid, 0, sig);
29877 +void fake_child_exit(void)
29881 + child_proxy(1, W_EXITCODE(0, 0));
29882 + while(debugger.waiting == 1){
29883 + pid = waitpid(debugger.pid, &status, WUNTRACED);
29884 + if(pid != debugger.pid){
29885 + printk("fake_child_exit - waitpid failed, "
29886 + "errno = %d\n", errno);
29889 + debugger_proxy(status, debugger.pid);
29891 + pid = waitpid(debugger.pid, &status, WUNTRACED);
29892 + if(pid != debugger.pid){
29893 + printk("fake_child_exit - waitpid failed, "
29894 + "errno = %d\n", errno);
29897 + if(ptrace(PTRACE_DETACH, debugger.pid, 0, SIGCONT) < 0)
29898 + printk("fake_child_exit - PTRACE_DETACH failed, errno = %d\n",
29902 +char gdb_init_string[] =
29906 +handle SIGWINCH nostop noprint pass \n\
29909 +int start_debugger(char *prog, int startup, int stop, int *fd_out)
29911 + int slave, child;
29913 + slave = open_gdb_chan();
29916 + char *tempname = NULL;
29919 + if(setsid() < 0) perror("setsid");
29920 + if((dup2(slave, 0) < 0) || (dup2(slave, 1) < 0) ||
29921 + (dup2(slave, 2) < 0)){
29922 + printk("start_debugger : dup2 failed, errno = %d\n",
29926 + if(ioctl(0, TIOCSCTTY, 0) < 0){
29927 + printk("start_debugger : TIOCSCTTY failed, "
29928 + "errno = %d\n", errno);
29931 + if(tcsetpgrp (1, os_getpid()) < 0){
29932 + printk("start_debugger : tcsetpgrp failed, "
29933 + "errno = %d\n", errno);
29938 + fd = make_tempfile("/tmp/gdb_init-XXXXXX", &tempname, 0);
29940 + printk("start_debugger : make_tempfile failed,"
29941 + "err = %d\n", -fd);
29944 + os_write_file(fd, gdb_init_string, sizeof(gdb_init_string) - 1);
29947 + os_write_file(fd, "b start_kernel\n",
29948 + strlen("b start_kernel\n"));
29950 + os_write_file(fd, "c\n", strlen("c\n"));
29952 + if(ptrace(PTRACE_TRACEME, 0, 0, 0) < 0){
29953 + printk("start_debugger : PTRACE_TRACEME failed, "
29954 + "errno = %d\n", errno);
29957 + execlp("gdb", "gdb", "--command", tempname, prog, NULL);
29958 + printk("start_debugger : exec of gdb failed, errno = %d\n",
29962 + printk("start_debugger : fork for gdb failed, errno = %d\n",
29971 + * Overrides for Emacs so that we follow Linus's tabbing style.
29972 + * Emacs will notice this stuff at the end of the file and automatically
29973 + * adjust the settings for this buffer only. This must remain at the end
29975 + * ---------------------------------------------------------------------------
29976 + * Local variables:
29977 + * c-file-style: "linux"
29980 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/ptproxy/ptproxy.h um/arch/um/kernel/tt/ptproxy/ptproxy.h
29981 --- orig/arch/um/kernel/tt/ptproxy/ptproxy.h 1969-12-31 19:00:00.000000000 -0500
29982 +++ um/arch/um/kernel/tt/ptproxy/ptproxy.h 2003-10-21 03:26:07.000000000 -0400
29984 +/**********************************************************************
29987 +Copyright (C) 1999 Lars Brinkhoff. See the file COPYING for licensing
29988 +terms and conditions.
29989 +**********************************************************************/
29991 +#ifndef __PTPROXY_H
29992 +#define __PTPROXY_H
29994 +#include <sys/types.h>
29996 +typedef struct debugger debugger_state;
29997 +typedef struct debugee debugee_state;
30002 + int wait_options;
30003 + int *wait_status_ptr;
30004 + unsigned int waiting : 1;
30005 + unsigned int real_wait : 1;
30006 + unsigned int expecting_child : 1;
30007 + int (*handle_trace) (debugger_state *, pid_t);
30009 + debugee_state *debugee;
30016 + unsigned int died : 1;
30017 + unsigned int event : 1;
30018 + unsigned int stopped : 1;
30019 + unsigned int trace_singlestep : 1;
30020 + unsigned int trace_syscall : 1;
30021 + unsigned int traced : 1;
30022 + unsigned int zombie : 1;
30023 + unsigned int in_context : 1;
30026 +extern int debugger_syscall(debugger_state *debugger, pid_t pid);
30027 +extern int debugger_normal_return (debugger_state *debugger, pid_t unused);
30029 +extern long proxy_ptrace (struct debugger *, int, pid_t, long, long, pid_t,
30030 + int *strace_out);
30031 +extern void debugger_cancelled_return(debugger_state *debugger, int result);
30036 + * Overrides for Emacs so that we follow Linus's tabbing style.
30037 + * Emacs will notice this stuff at the end of the file and automatically
30038 + * adjust the settings for this buffer only. This must remain at the end
30040 + * ---------------------------------------------------------------------------
30041 + * Local variables:
30042 + * c-file-style: "linux"
30045 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/ptproxy/ptrace.c um/arch/um/kernel/tt/ptproxy/ptrace.c
30046 --- orig/arch/um/kernel/tt/ptproxy/ptrace.c 1969-12-31 19:00:00.000000000 -0500
30047 +++ um/arch/um/kernel/tt/ptproxy/ptrace.c 2003-10-21 03:26:07.000000000 -0400
30049 +/**********************************************************************
30052 +Copyright (C) 1999 Lars Brinkhoff. See the file COPYING for licensing
30053 +terms and conditions.
30055 +Jeff Dike (jdike@karaya.com) : Modified for integration into uml
30056 +**********************************************************************/
30058 +#include <errno.h>
30059 +#include <unistd.h>
30060 +#include <signal.h>
30061 +#include <sys/types.h>
30062 +#include <sys/time.h>
30063 +#include <sys/ptrace.h>
30064 +#include <sys/wait.h>
30065 +#include <asm/ptrace.h>
30067 +#include "ptproxy.h"
30068 +#include "debug.h"
30069 +#include "user_util.h"
30070 +#include "kern_util.h"
30071 +#include "ptrace_user.h"
30074 +long proxy_ptrace(struct debugger *debugger, int arg1, pid_t arg2,
30075 + long arg3, long arg4, pid_t child, int *ret)
30082 + if(debugger->debugee->died) return(-ESRCH);
30085 + case PTRACE_ATTACH:
30086 + if(debugger->debugee->traced) return(-EPERM);
30088 + debugger->debugee->pid = arg2;
30089 + debugger->debugee->traced = 1;
30091 + if(is_valid_pid(arg2) && (arg2 != child)){
30092 + debugger->debugee->in_context = 0;
30093 + kill(arg2, SIGSTOP);
30094 + debugger->debugee->event = 1;
30095 + debugger->debugee->wait_status = W_STOPCODE(SIGSTOP);
30098 + debugger->debugee->in_context = 1;
30099 + if(debugger->debugee->stopped)
30100 + child_proxy(child, W_STOPCODE(SIGSTOP));
30101 + else kill(child, SIGSTOP);
30106 + case PTRACE_DETACH:
30107 + if(!debugger->debugee->traced) return(-EPERM);
30109 + debugger->debugee->traced = 0;
30110 + debugger->debugee->pid = 0;
30111 + if(!debugger->debugee->in_context)
30112 + kill(child, SIGCONT);
30116 + case PTRACE_CONT:
30117 + if(!debugger->debugee->in_context) return(-EPERM);
30118 + *ret = PTRACE_CONT;
30119 + return(ptrace(PTRACE_CONT, child, arg3, arg4));
30121 +#ifdef UM_HAVE_GETFPREGS
30122 + case PTRACE_GETFPREGS:
30124 + long regs[FP_FRAME_SIZE];
30127 + result = ptrace(PTRACE_GETFPREGS, child, 0, regs);
30128 + if(result == -1) return(-errno);
30130 + for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++)
30131 + ptrace(PTRACE_POKEDATA, debugger->pid, arg4 + 4 * i,
30137 +#ifdef UM_HAVE_GETFPXREGS
30138 + case PTRACE_GETFPXREGS:
30140 + long regs[FPX_FRAME_SIZE];
30143 + result = ptrace(PTRACE_GETFPXREGS, child, 0, regs);
30144 + if(result == -1) return(-errno);
30146 + for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++)
30147 + ptrace(PTRACE_POKEDATA, debugger->pid, arg4 + 4 * i,
30153 +#ifdef UM_HAVE_GETREGS
30154 + case PTRACE_GETREGS:
30156 + long regs[FRAME_SIZE];
30159 + result = ptrace(PTRACE_GETREGS, child, 0, regs);
30160 + if(result == -1) return(-errno);
30162 + for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++)
30163 + ptrace (PTRACE_POKEDATA, debugger->pid,
30164 + arg4 + 4 * i, regs[i]);
30170 + case PTRACE_KILL:
30171 + result = ptrace(PTRACE_KILL, child, arg3, arg4);
30172 + if(result == -1) return(-errno);
30176 + case PTRACE_PEEKDATA:
30177 + case PTRACE_PEEKTEXT:
30178 + case PTRACE_PEEKUSER:
30179 + /* The value being read out could be -1, so we have to
30180 + * check errno to see if there's an error, and zero it
30181 + * beforehand so we're not faked out by an old error
30185 + result = ptrace(arg1, child, arg3, 0);
30186 + if((result == -1) && (errno != 0)) return(-errno);
30188 + result = ptrace(PTRACE_POKEDATA, debugger->pid, arg4, result);
30189 + if(result == -1) return(-errno);
30193 + case PTRACE_POKEDATA:
30194 + case PTRACE_POKETEXT:
30195 + case PTRACE_POKEUSER:
30196 + result = ptrace(arg1, child, arg3, arg4);
30197 + if(result == -1) return(-errno);
30199 + if(arg1 == PTRACE_POKEUSER) ptrace_pokeuser(arg3, arg4);
30202 +#ifdef UM_HAVE_SETFPREGS
30203 + case PTRACE_SETFPREGS:
30205 + long regs[FP_FRAME_SIZE];
30208 + for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++)
30209 + regs[i] = ptrace (PTRACE_PEEKDATA, debugger->pid,
30210 + arg4 + 4 * i, 0);
30211 + result = ptrace(PTRACE_SETFPREGS, child, 0, regs);
30212 + if(result == -1) return(-errno);
30218 +#ifdef UM_HAVE_SETFPXREGS
30219 + case PTRACE_SETFPXREGS:
30221 + long regs[FPX_FRAME_SIZE];
30224 + for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++)
30225 + regs[i] = ptrace (PTRACE_PEEKDATA, debugger->pid,
30226 + arg4 + 4 * i, 0);
30227 + result = ptrace(PTRACE_SETFPXREGS, child, 0, regs);
30228 + if(result == -1) return(-errno);
30234 +#ifdef UM_HAVE_SETREGS
30235 + case PTRACE_SETREGS:
30237 + long regs[FRAME_SIZE];
30240 + for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++)
30241 + regs[i] = ptrace(PTRACE_PEEKDATA, debugger->pid,
30242 + arg4 + 4 * i, 0);
30243 + result = ptrace(PTRACE_SETREGS, child, 0, regs);
30244 + if(result == -1) return(-errno);
30250 + case PTRACE_SINGLESTEP:
30251 + if(!debugger->debugee->in_context) return(-EPERM);
30252 + sigemptyset(&relay);
30253 + sigaddset(&relay, SIGSEGV);
30254 + sigaddset(&relay, SIGILL);
30255 + sigaddset(&relay, SIGBUS);
30256 + result = ptrace(PTRACE_SINGLESTEP, child, arg3, arg4);
30257 + if(result == -1) return(-errno);
30259 + status = wait_for_stop(child, SIGTRAP, PTRACE_SINGLESTEP,
30261 + child_proxy(child, status);
30264 + case PTRACE_SYSCALL:
30265 + if(!debugger->debugee->in_context) return(-EPERM);
30266 + result = ptrace(PTRACE_SYSCALL, child, arg3, arg4);
30267 + if(result == -1) return(-errno);
30269 + *ret = PTRACE_SYSCALL;
30272 + case PTRACE_TRACEME:
30279 + * Overrides for Emacs so that we follow Linus's tabbing style.
30280 + * Emacs will notice this stuff at the end of the file and automatically
30281 + * adjust the settings for this buffer only. This must remain at the end
30283 + * ---------------------------------------------------------------------------
30284 + * Local variables:
30285 + * c-file-style: "linux"
30288 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/ptproxy/sysdep.c um/arch/um/kernel/tt/ptproxy/sysdep.c
30289 --- orig/arch/um/kernel/tt/ptproxy/sysdep.c 1969-12-31 19:00:00.000000000 -0500
30290 +++ um/arch/um/kernel/tt/ptproxy/sysdep.c 2003-10-21 03:26:07.000000000 -0400
30292 +/**********************************************************************
30295 +Copyright (C) 1999 Lars Brinkhoff. See the file COPYING for licensing
30296 +terms and conditions.
30297 +**********************************************************************/
30299 +#include <stdio.h>
30300 +#include <string.h>
30301 +#include <stdlib.h>
30302 +#include <signal.h>
30303 +#include <errno.h>
30304 +#include <sys/types.h>
30305 +#include <sys/ptrace.h>
30306 +#include <asm/ptrace.h>
30307 +#include <linux/unistd.h>
30308 +#include "ptrace_user.h"
30309 +#include "user_util.h"
30312 +int get_syscall(pid_t pid, long *arg1, long *arg2, long *arg3, long *arg4,
30315 + *arg1 = ptrace(PTRACE_PEEKUSER, pid, PT_SYSCALL_ARG1_OFFSET, 0);
30316 + *arg2 = ptrace(PTRACE_PEEKUSER, pid, PT_SYSCALL_ARG2_OFFSET, 0);
30317 + *arg3 = ptrace(PTRACE_PEEKUSER, pid, PT_SYSCALL_ARG3_OFFSET, 0);
30318 + *arg4 = ptrace(PTRACE_PEEKUSER, pid, PT_SYSCALL_ARG4_OFFSET, 0);
30319 + *arg5 = ptrace(PTRACE_PEEKUSER, pid, PT_SYSCALL_ARG5_OFFSET, 0);
30320 + return(ptrace(PTRACE_PEEKUSER, pid, PT_SYSCALL_NR_OFFSET, 0));
30323 +void syscall_cancel(pid_t pid, int result)
30325 + if((ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_NR_OFFSET,
30326 + __NR_getpid) < 0) ||
30327 + (ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0) ||
30328 + (wait_for_stop(pid, SIGTRAP, PTRACE_SYSCALL, NULL) < 0) ||
30329 + (ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_RET_OFFSET, result) < 0) ||
30330 + (ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0))
30331 + printk("ptproxy: couldn't cancel syscall: errno = %d\n",
30335 +void syscall_set_result(pid_t pid, long result)
30337 + ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_RET_OFFSET, result);
30340 +void syscall_continue(pid_t pid)
30342 + ptrace(PTRACE_SYSCALL, pid, 0, 0);
30345 +int syscall_pause(pid_t pid)
30347 + if(ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_NR_OFFSET, __NR_pause) < 0){
30348 + printk("syscall_change - ptrace failed, errno = %d\n", errno);
30355 + * Overrides for Emacs so that we follow Linus's tabbing style.
30356 + * Emacs will notice this stuff at the end of the file and automatically
30357 + * adjust the settings for this buffer only. This must remain at the end
30359 + * ---------------------------------------------------------------------------
30360 + * Local variables:
30361 + * c-file-style: "linux"
30364 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/ptproxy/sysdep.h um/arch/um/kernel/tt/ptproxy/sysdep.h
30365 --- orig/arch/um/kernel/tt/ptproxy/sysdep.h 1969-12-31 19:00:00.000000000 -0500
30366 +++ um/arch/um/kernel/tt/ptproxy/sysdep.h 2003-10-21 03:26:07.000000000 -0400
30368 +/**********************************************************************
30371 +Copyright (C) 1999 Lars Brinkhoff.
30372 +Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
30373 +See the file COPYING for licensing terms and conditions.
30374 +**********************************************************************/
30376 +extern int get_syscall(pid_t pid, long *arg1, long *arg2, long *arg3,
30377 + long *arg4, long *arg5);
30378 +extern void syscall_cancel (pid_t pid, long result);
30379 +extern void syscall_set_result (pid_t pid, long result);
30380 +extern void syscall_continue (pid_t pid);
30381 +extern int syscall_pause(pid_t pid);
30384 + * Overrides for Emacs so that we follow Linus's tabbing style.
30385 + * Emacs will notice this stuff at the end of the file and automatically
30386 + * adjust the settings for this buffer only. This must remain at the end
30388 + * ---------------------------------------------------------------------------
30389 + * Local variables:
30390 + * c-file-style: "linux"
30393 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/ptproxy/wait.c um/arch/um/kernel/tt/ptproxy/wait.c
30394 --- orig/arch/um/kernel/tt/ptproxy/wait.c 1969-12-31 19:00:00.000000000 -0500
30395 +++ um/arch/um/kernel/tt/ptproxy/wait.c 2004-01-17 05:27:18.000000000 -0500
30397 +/**********************************************************************
30400 +Copyright (C) 1999 Lars Brinkhoff. See the file COPYING for licensing
30401 +terms and conditions.
30403 +**********************************************************************/
30405 +#include <errno.h>
30406 +#include <signal.h>
30407 +#include <sys/wait.h>
30408 +#include <sys/ptrace.h>
30409 +#include <asm/ptrace.h>
30411 +#include "ptproxy.h"
30412 +#include "sysdep.h"
30414 +#include "user_util.h"
30415 +#include "sysdep/ptrace.h"
30416 +#include "sysdep/ptrace_user.h"
30417 +#include "sysdep/sigcontext.h"
30419 +int proxy_wait_return(struct debugger *debugger, pid_t unused)
30421 + debugger->waiting = 0;
30423 + if(debugger->debugee->died || (debugger->wait_options & __WCLONE)){
30424 + debugger_cancelled_return(debugger, -ECHILD);
30428 + if(debugger->debugee->zombie && debugger->debugee->event)
30429 + debugger->debugee->died = 1;
30431 + if(debugger->debugee->event){
30432 + debugger->debugee->event = 0;
30433 + ptrace(PTRACE_POKEDATA, debugger->pid,
30434 + debugger->wait_status_ptr,
30435 + debugger->debugee->wait_status);
30437 + ptrace (PTRACE_POKEDATA, pid, rusage_ptr, ...); */
30438 + debugger_cancelled_return(debugger, debugger->debugee->pid);
30442 + /* pause will return -EINTR, which happens to be right for wait */
30443 + debugger_normal_return(debugger, -1);
30447 +int parent_wait_return(struct debugger *debugger, pid_t unused)
30449 + return(debugger_normal_return(debugger, -1));
30452 +int real_wait_return(struct debugger *debugger)
30454 + unsigned long ip;
30457 + pid = debugger->pid;
30459 + ip = ptrace(PTRACE_PEEKUSER, pid, PT_IP_OFFSET, 0);
30460 + IP_RESTART_SYSCALL(ip);
30462 + if(ptrace(PTRACE_POKEUSER, pid, PT_IP_OFFSET, ip) < 0)
30463 + tracer_panic("real_wait_return : Failed to restart system "
30464 + "call, errno = %d\n", errno);
30466 + if((ptrace(PTRACE_SYSCALL, debugger->pid, 0, SIGCHLD) < 0) ||
30467 + (ptrace(PTRACE_SYSCALL, debugger->pid, 0, 0) < 0) ||
30468 + (ptrace(PTRACE_SYSCALL, debugger->pid, 0, 0) < 0) ||
30469 + debugger_normal_return(debugger, -1))
30470 + tracer_panic("real_wait_return : gdb failed to wait, "
30471 + "errno = %d\n", errno);
30476 + * Overrides for Emacs so that we follow Linus's tabbing style.
30477 + * Emacs will notice this stuff at the end of the file and automatically
30478 + * adjust the settings for this buffer only. This must remain at the end
30480 + * ---------------------------------------------------------------------------
30481 + * Local variables:
30482 + * c-file-style: "linux"
30485 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/ptproxy/wait.h um/arch/um/kernel/tt/ptproxy/wait.h
30486 --- orig/arch/um/kernel/tt/ptproxy/wait.h 1969-12-31 19:00:00.000000000 -0500
30487 +++ um/arch/um/kernel/tt/ptproxy/wait.h 2003-10-21 03:26:07.000000000 -0400
30489 +/**********************************************************************
30492 +Copyright (C) 1999 Lars Brinkhoff. See the file COPYING for licensing
30493 +terms and conditions.
30494 +**********************************************************************/
30496 +#ifndef __PTPROXY_WAIT_H
30497 +#define __PTPROXY_WAIT_H
30499 +extern int proxy_wait_return(struct debugger *debugger, pid_t unused);
30500 +extern int real_wait_return(struct debugger *debugger);
30501 +extern int parent_wait_return(struct debugger *debugger, pid_t unused);
30504 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/syscall_kern.c um/arch/um/kernel/tt/syscall_kern.c
30505 --- orig/arch/um/kernel/tt/syscall_kern.c 1969-12-31 19:00:00.000000000 -0500
30506 +++ um/arch/um/kernel/tt/syscall_kern.c 2003-10-21 03:26:07.000000000 -0400
30509 + * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
30510 + * Licensed under the GPL
30513 +#include "linux/types.h"
30514 +#include "linux/utime.h"
30515 +#include "linux/sys.h"
30516 +#include "asm/unistd.h"
30517 +#include "asm/ptrace.h"
30518 +#include "asm/uaccess.h"
30519 +#include "sysdep/syscalls.h"
30520 +#include "kern_util.h"
30522 +static inline int check_area(void *ptr, int size)
30524 + return(verify_area(VERIFY_WRITE, ptr, size));
30527 +static int check_readlink(struct pt_regs *regs)
30529 + return(check_area((void *) UPT_SYSCALL_ARG1(®s->regs),
30530 + UPT_SYSCALL_ARG2(®s->regs)));
30533 +static int check_utime(struct pt_regs *regs)
30535 + return(check_area((void *) UPT_SYSCALL_ARG1(®s->regs),
30536 + sizeof(struct utimbuf)));
30539 +static int check_oldstat(struct pt_regs *regs)
30541 + return(check_area((void *) UPT_SYSCALL_ARG1(®s->regs),
30542 + sizeof(struct __old_kernel_stat)));
30545 +static int check_stat(struct pt_regs *regs)
30547 + return(check_area((void *) UPT_SYSCALL_ARG1(®s->regs),
30548 + sizeof(struct stat)));
30551 +static int check_stat64(struct pt_regs *regs)
30553 + return(check_area((void *) UPT_SYSCALL_ARG1(®s->regs),
30554 + sizeof(struct stat64)));
30559 + int (*check_params)(struct pt_regs *);
30562 +struct bogus this_is_bogus[256] = {
30563 + [ __NR_mknod ] = { 1, NULL },
30564 + [ __NR_mkdir ] = { 1, NULL },
30565 + [ __NR_rmdir ] = { 1, NULL },
30566 + [ __NR_unlink ] = { 1, NULL },
30567 + [ __NR_symlink ] = { 1, NULL },
30568 + [ __NR_link ] = { 1, NULL },
30569 + [ __NR_rename ] = { 1, NULL },
30570 + [ __NR_umount ] = { 1, NULL },
30571 + [ __NR_mount ] = { 1, NULL },
30572 + [ __NR_pivot_root ] = { 1, NULL },
30573 + [ __NR_chdir ] = { 1, NULL },
30574 + [ __NR_chroot ] = { 1, NULL },
30575 + [ __NR_open ] = { 1, NULL },
30576 + [ __NR_quotactl ] = { 1, NULL },
30577 + [ __NR_sysfs ] = { 1, NULL },
30578 + [ __NR_readlink ] = { 1, check_readlink },
30579 + [ __NR_acct ] = { 1, NULL },
30580 + [ __NR_execve ] = { 1, NULL },
30581 + [ __NR_uselib ] = { 1, NULL },
30582 + [ __NR_statfs ] = { 1, NULL },
30583 + [ __NR_truncate ] = { 1, NULL },
30584 + [ __NR_access ] = { 1, NULL },
30585 + [ __NR_chmod ] = { 1, NULL },
30586 + [ __NR_chown ] = { 1, NULL },
30587 + [ __NR_lchown ] = { 1, NULL },
30588 + [ __NR_utime ] = { 1, check_utime },
30589 + [ __NR_oldlstat ] = { 1, check_oldstat },
30590 + [ __NR_oldstat ] = { 1, check_oldstat },
30591 + [ __NR_stat ] = { 1, check_stat },
30592 + [ __NR_lstat ] = { 1, check_stat },
30593 + [ __NR_stat64 ] = { 1, check_stat64 },
30594 + [ __NR_lstat64 ] = { 1, check_stat64 },
30595 + [ __NR_chown32 ] = { 1, NULL },
30600 +static int check_bogosity(struct pt_regs *regs)
30602 + struct bogus *bogon = &this_is_bogus[UPT_SYSCALL_NR(®s->regs)];
30604 + if(!bogon->kernel_ds) return(0);
30605 + if(bogon->check_params && (*bogon->check_params)(regs))
30607 + set_fs(KERNEL_DS);
30611 +extern syscall_handler_t *sys_call_table[];
30613 +long execute_syscall_tt(void *r)
30615 + struct pt_regs *regs = r;
30619 + current->thread.nsyscalls++;
30621 + syscall = UPT_SYSCALL_NR(®s->regs);
30623 + if((syscall >= NR_syscalls) || (syscall < 0))
30625 + else if(honeypot && check_bogosity(regs))
30627 + else res = EXECUTE_SYSCALL(syscall, regs);
30631 + if(current->thread.mode.tt.singlestep_syscall){
30632 + current->thread.mode.tt.singlestep_syscall = 0;
30633 + current->ptrace &= ~PT_DTRACE;
30634 + force_sig(SIGTRAP, current);
30641 + * Overrides for Emacs so that we follow Linus's tabbing style.
30642 + * Emacs will notice this stuff at the end of the file and automatically
30643 + * adjust the settings for this buffer only. This must remain at the end
30645 + * ---------------------------------------------------------------------------
30646 + * Local variables:
30647 + * c-file-style: "linux"
30650 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/syscall_user.c um/arch/um/kernel/tt/syscall_user.c
30651 --- orig/arch/um/kernel/tt/syscall_user.c 1969-12-31 19:00:00.000000000 -0500
30652 +++ um/arch/um/kernel/tt/syscall_user.c 2003-10-21 03:26:07.000000000 -0400
30655 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
30656 + * Licensed under the GPL
30659 +#include <unistd.h>
30660 +#include <signal.h>
30661 +#include <errno.h>
30662 +#include <sys/ptrace.h>
30663 +#include <asm/unistd.h>
30664 +#include "sysdep/ptrace.h"
30665 +#include "sigcontext.h"
30666 +#include "ptrace_user.h"
30668 +#include "user_util.h"
30669 +#include "kern_util.h"
30670 +#include "syscall_user.h"
30674 +#define ERESTARTSYS 512
30675 +#define ERESTARTNOINTR 513
30676 +#define ERESTARTNOHAND 514
30678 +void syscall_handler_tt(int sig, union uml_pt_regs *regs)
30682 + int index, syscall;
30684 + syscall = UPT_SYSCALL_NR(regs);
30685 + sc = UPT_SC(regs);
30686 + SC_START_SYSCALL(sc);
30688 + index = record_syscall_start(syscall);
30690 + result = execute_syscall(regs);
30692 + /* regs->sc may have changed while the system call ran (there may
30693 + * have been an interrupt or segfault), so it needs to be refreshed.
30695 + UPT_SC(regs) = sc;
30697 + SC_SET_SYSCALL_RETURN(sc, result);
30698 + if((result == -ERESTARTNOHAND) || (result == -ERESTARTSYS) ||
30699 + (result == -ERESTARTNOINTR))
30700 + do_signal(result);
30703 + record_syscall_end(index, result);
30706 +int do_syscall(void *task, int pid)
30708 + unsigned long proc_regs[FRAME_SIZE];
30709 + union uml_pt_regs *regs;
30712 + if(ptrace_getregs(pid, proc_regs) < 0)
30713 + tracer_panic("Couldn't read registers");
30714 + syscall = PT_SYSCALL_NR(proc_regs);
30716 + regs = TASK_REGS(task);
30717 + UPT_SYSCALL_NR(regs) = syscall;
30719 + if(syscall < 1) return(0);
30721 + if((syscall != __NR_sigreturn) &&
30722 + ((unsigned long *) PT_IP(proc_regs) >= &_stext) &&
30723 + ((unsigned long *) PT_IP(proc_regs) <= &_etext))
30724 + tracer_panic("I'm tracing myself and I can't get out");
30726 + if(ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_NR_OFFSET,
30727 + __NR_getpid) < 0)
30728 + tracer_panic("do_syscall : Nullifying syscall failed, "
30729 + "errno = %d", errno);
30734 + * Overrides for Emacs so that we follow Linus's tabbing style.
30735 + * Emacs will notice this stuff at the end of the file and automatically
30736 + * adjust the settings for this buffer only. This must remain at the end
30738 + * ---------------------------------------------------------------------------
30739 + * Local variables:
30740 + * c-file-style: "linux"
30743 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/sys-i386/Makefile um/arch/um/kernel/tt/sys-i386/Makefile
30744 --- orig/arch/um/kernel/tt/sys-i386/Makefile 1969-12-31 19:00:00.000000000 -0500
30745 +++ um/arch/um/kernel/tt/sys-i386/Makefile 2003-10-21 03:26:07.000000000 -0400
30748 +# Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
30749 +# Licensed under the GPL
30752 +O_TARGET = sys-i386.o
30754 +obj-y = sigcontext.o
30756 +USER_OBJS = sigcontext.o
30758 +include $(TOPDIR)/Rules.make
30760 +$(USER_OBJS) : %.o: %.c
30761 + $(CC) $(CFLAGS_$@) $(USER_CFLAGS) -c -o $@ $<
30764 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/sys-i386/sigcontext.c um/arch/um/kernel/tt/sys-i386/sigcontext.c
30765 --- orig/arch/um/kernel/tt/sys-i386/sigcontext.c 1969-12-31 19:00:00.000000000 -0500
30766 +++ um/arch/um/kernel/tt/sys-i386/sigcontext.c 2003-10-21 03:26:07.000000000 -0400
30769 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
30770 + * Licensed under the GPL
30773 +#include <stdlib.h>
30774 +#include <asm/sigcontext.h>
30775 +#include "kern_util.h"
30776 +#include "sysdep/frame.h"
30778 +int copy_sc_from_user_tt(void *to_ptr, void *from_ptr, void *data)
30780 + struct arch_frame_data *arch = data;
30781 + struct sigcontext *to = to_ptr, *from = from_ptr;
30782 + struct _fpstate *to_fp, *from_fp;
30783 + unsigned long sigs;
30786 + to_fp = to->fpstate;
30787 + from_fp = from->fpstate;
30788 + sigs = to->oldmask;
30789 + err = copy_from_user_proc(to, from, sizeof(*to));
30790 + to->oldmask = sigs;
30791 + if(to_fp != NULL){
30792 + err |= copy_from_user_proc(&to->fpstate, &to_fp,
30793 + sizeof(to->fpstate));
30794 + err |= copy_from_user_proc(to_fp, from_fp, arch->fpstate_size);
30799 +int copy_sc_to_user_tt(void *to_ptr, void *fp, void *from_ptr, void *data)
30801 + struct arch_frame_data *arch = data;
30802 + struct sigcontext *to = to_ptr, *from = from_ptr;
30803 + struct _fpstate *to_fp, *from_fp;
30806 + to_fp = (struct _fpstate *)
30807 + (fp ? (unsigned long) fp : ((unsigned long) to + sizeof(*to)));
30808 + from_fp = from->fpstate;
30809 + err = copy_to_user_proc(to, from, sizeof(*to));
30810 + if(from_fp != NULL){
30811 + err |= copy_to_user_proc(&to->fpstate, &to_fp,
30812 + sizeof(to->fpstate));
30813 + err |= copy_to_user_proc(to_fp, from_fp, arch->fpstate_size);
30819 + * Overrides for Emacs so that we follow Linus's tabbing style.
30820 + * Emacs will notice this stuff at the end of the file and automatically
30821 + * adjust the settings for this buffer only. This must remain at the end
30823 + * ---------------------------------------------------------------------------
30824 + * Local variables:
30825 + * c-file-style: "linux"
30828 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/time.c um/arch/um/kernel/tt/time.c
30829 --- orig/arch/um/kernel/tt/time.c 1969-12-31 19:00:00.000000000 -0500
30830 +++ um/arch/um/kernel/tt/time.c 2003-10-21 03:26:07.000000000 -0400
30833 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
30834 + * Licensed under the GPL
30837 +#include <signal.h>
30838 +#include <sys/time.h>
30839 +#include <time_user.h>
30840 +#include "process.h"
30843 +void user_time_init_tt(void)
30845 + if(signal(SIGVTALRM, (__sighandler_t) alarm_handler) == SIG_ERR)
30846 + panic("Couldn't set SIGVTALRM handler");
30847 + set_interval(ITIMER_VIRTUAL);
30851 + * Overrides for Emacs so that we follow Linus's tabbing style.
30852 + * Emacs will notice this stuff at the end of the file and automatically
30853 + * adjust the settings for this buffer only. This must remain at the end
30855 + * ---------------------------------------------------------------------------
30856 + * Local variables:
30857 + * c-file-style: "linux"
30860 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/tlb.c um/arch/um/kernel/tt/tlb.c
30861 --- orig/arch/um/kernel/tt/tlb.c 1969-12-31 19:00:00.000000000 -0500
30862 +++ um/arch/um/kernel/tt/tlb.c 2003-11-13 00:40:57.000000000 -0500
30865 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
30866 + * Licensed under the GPL
30869 +#include "linux/stddef.h"
30870 +#include "linux/kernel.h"
30871 +#include "linux/sched.h"
30872 +#include "asm/page.h"
30873 +#include "asm/pgtable.h"
30874 +#include "asm/uaccess.h"
30875 +#include "user_util.h"
30876 +#include "mem_user.h"
30879 +static void fix_range(struct mm_struct *mm, unsigned long start_addr,
30880 + unsigned long end_addr, int force)
30885 + unsigned long addr;
30886 + int r, w, x, err;
30888 + if((current->thread.mode.tt.extern_pid != -1) &&
30889 + (current->thread.mode.tt.extern_pid != os_getpid()))
30890 + panic("fix_range fixing wrong address space, current = 0x%p",
30892 + if(mm == NULL) return;
30893 + for(addr=start_addr;addr<end_addr;){
30894 + if(addr == TASK_SIZE){
30895 + /* Skip over kernel text, kernel data, and physical
30896 + * memory, which don't have ptes, plus kernel virtual
30897 + * memory, which is flushed separately, and remap
30898 + * the process stack. The only way to get here is
30899 + * if (end_addr == STACK_TOP) > TASK_SIZE, which is
30900 + * only true in the honeypot case.
30902 + addr = STACK_TOP - ABOVE_KMEM;
30905 + npgd = pgd_offset(mm, addr);
30906 + npmd = pmd_offset(npgd, addr);
30907 + if(pmd_present(*npmd)){
30908 + npte = pte_offset(npmd, addr);
30909 + r = pte_read(*npte);
30910 + w = pte_write(*npte);
30911 + x = pte_exec(*npte);
30912 + if(!pte_dirty(*npte)) w = 0;
30913 + if(!pte_young(*npte)){
30917 + if(force || pte_newpage(*npte)){
30918 + err = os_unmap_memory((void *) addr,
30921 + panic("munmap failed, errno = %d\n",
30923 + if(pte_present(*npte))
30925 + pte_val(*npte) & PAGE_MASK,
30926 + PAGE_SIZE, r, w, x);
30928 + else if(pte_newprot(*npte)){
30929 + protect_memory(addr, PAGE_SIZE, r, w, x, 1);
30931 + *npte = pte_mkuptodate(*npte);
30932 + addr += PAGE_SIZE;
30935 + if(force || pmd_newpage(*npmd)){
30936 + err = os_unmap_memory((void *) addr, PMD_SIZE);
30938 + panic("munmap failed, errno = %d\n",
30940 + pmd_mkuptodate(*npmd);
30942 + addr += PMD_SIZE;
30947 +atomic_t vmchange_seq = ATOMIC_INIT(1);
30949 +static void flush_kernel_vm_range(unsigned long start, unsigned long end,
30952 + struct mm_struct *mm;
30956 + unsigned long addr;
30957 + int updated = 0, err;
30960 + for(addr = start; addr < end;){
30961 + pgd = pgd_offset(mm, addr);
30962 + pmd = pmd_offset(pgd, addr);
30963 + if(pmd_present(*pmd)){
30964 + pte = pte_offset(pmd, addr);
30965 + if(!pte_present(*pte) || pte_newpage(*pte)){
30967 + err = os_unmap_memory((void *) addr,
30970 + panic("munmap failed, errno = %d\n",
30972 + if(pte_present(*pte))
30974 + pte_val(*pte) & PAGE_MASK,
30975 + PAGE_SIZE, 1, 1, 1);
30977 + else if(pte_newprot(*pte)){
30979 + protect_memory(addr, PAGE_SIZE, 1, 1, 1, 1);
30981 + addr += PAGE_SIZE;
30984 + if(pmd_newpage(*pmd)){
30986 + err = os_unmap_memory((void *) addr, PMD_SIZE);
30988 + panic("munmap failed, errno = %d\n",
30991 + addr += PMD_SIZE;
30994 + if(updated && update_seq) atomic_inc(&vmchange_seq);
30997 +static void protect_vm_page(unsigned long addr, int w, int must_succeed)
31001 + err = protect_memory(addr, PAGE_SIZE, 1, w, 1, must_succeed);
31002 + if(err == 0) return;
31003 + else if((err == -EFAULT) || (err == -ENOMEM)){
31004 + flush_kernel_vm_range(addr, addr + PAGE_SIZE, 1);
31005 + protect_vm_page(addr, w, 1);
31007 + else panic("protect_vm_page : protect failed, errno = %d\n", err);
31010 +void mprotect_kernel_vm(int w)
31012 + struct mm_struct *mm;
31016 + unsigned long addr;
31019 + for(addr = start_vm; addr < end_vm;){
31020 + pgd = pgd_offset(mm, addr);
31021 + pmd = pmd_offset(pgd, addr);
31022 + if(pmd_present(*pmd)){
31023 + pte = pte_offset(pmd, addr);
31024 + if(pte_present(*pte)) protect_vm_page(addr, w, 0);
31025 + addr += PAGE_SIZE;
31027 + else addr += PMD_SIZE;
31031 +void flush_tlb_kernel_vm_tt(void)
31033 + flush_kernel_vm_range(start_vm, end_vm, 1);
31036 +void __flush_tlb_one_tt(unsigned long addr)
31038 + flush_kernel_vm_range(addr, addr + PAGE_SIZE, 1);
31041 +void flush_tlb_range_tt(struct mm_struct *mm, unsigned long start,
31042 + unsigned long end)
31044 + if(mm != current->mm) return;
31046 + /* Assumes that the range start ... end is entirely within
31047 + * either process memory or kernel vm
31049 + if((start >= start_vm) && (start < end_vm))
31050 + flush_kernel_vm_range(start, end, 1);
31051 + else fix_range(mm, start, end, 0);
31054 +void flush_tlb_mm_tt(struct mm_struct *mm)
31056 + unsigned long seq;
31058 + if(mm != current->mm) return;
31060 + fix_range(mm, 0, STACK_TOP, 0);
31062 + seq = atomic_read(&vmchange_seq);
31063 + if(current->thread.mode.tt.vm_seq == seq) return;
31064 + current->thread.mode.tt.vm_seq = seq;
31065 + flush_kernel_vm_range(start_vm, end_vm, 0);
31068 +void force_flush_all_tt(void)
31070 + fix_range(current->mm, 0, STACK_TOP, 1);
31071 + flush_kernel_vm_range(start_vm, end_vm, 0);
31075 + * Overrides for Emacs so that we follow Linus's tabbing style.
31076 + * Emacs will notice this stuff at the end of the file and automatically
31077 + * adjust the settings for this buffer only. This must remain at the end
31079 + * ---------------------------------------------------------------------------
31080 + * Local variables:
31081 + * c-file-style: "linux"
31084 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/tracer.c um/arch/um/kernel/tt/tracer.c
31085 --- orig/arch/um/kernel/tt/tracer.c 1969-12-31 19:00:00.000000000 -0500
31086 +++ um/arch/um/kernel/tt/tracer.c 2003-10-21 03:26:07.000000000 -0400
31089 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
31090 + * Licensed under the GPL
31093 +#include <stdio.h>
31094 +#include <stdlib.h>
31095 +#include <stdarg.h>
31096 +#include <unistd.h>
31097 +#include <signal.h>
31098 +#include <errno.h>
31099 +#include <sched.h>
31100 +#include <string.h>
31101 +#include <sys/mman.h>
31102 +#include <sys/ptrace.h>
31103 +#include <sys/time.h>
31104 +#include <sys/wait.h>
31106 +#include "sysdep/ptrace.h"
31107 +#include "sigcontext.h"
31108 +#include "sysdep/sigcontext.h"
31110 +#include "signal_user.h"
31111 +#include "user_util.h"
31112 +#include "mem_user.h"
31113 +#include "process.h"
31114 +#include "kern_util.h"
31115 +#include "frame.h"
31116 +#include "chan_user.h"
31117 +#include "ptrace_user.h"
31121 +static int tracer_winch[2];
31123 +int is_tracer_winch(int pid, int fd, void *data)
31125 + if(pid != tracing_pid)
31128 + register_winch_irq(tracer_winch[0], fd, -1, data);
31132 +static void tracer_winch_handler(int sig)
31137 + n = os_write_file(tracer_winch[1], &c, sizeof(c));
31138 + if(n != sizeof(c))
31139 + printk("tracer_winch_handler - write failed, err = %d\n", -n);
31142 +/* Called only by the tracing thread during initialization */
31144 +static void setup_tracer_winch(void)
31148 + err = os_pipe(tracer_winch, 1, 1);
31150 + printk("setup_tracer_winch : os_pipe failed, err = %d\n", -err);
31153 + signal(SIGWINCH, tracer_winch_handler);
31156 +void attach_process(int pid)
31158 + if((ptrace(PTRACE_ATTACH, pid, 0, 0) < 0) ||
31159 + (ptrace(PTRACE_CONT, pid, 0, 0) < 0))
31160 + tracer_panic("OP_FORK failed to attach pid");
31161 + wait_for_stop(pid, SIGSTOP, PTRACE_CONT, NULL);
31162 + if(ptrace(PTRACE_CONT, pid, 0, 0) < 0)
31163 + tracer_panic("OP_FORK failed to continue process");
31166 +void tracer_panic(char *format, ...)
31170 + va_start(ap, format);
31171 + vprintf(format, ap);
31173 + while(1) pause();
31176 +static void tracer_segv(int sig, struct sigcontext sc)
31178 + printf("Tracing thread segfault at address 0x%lx, ip 0x%lx\n",
31179 + SC_FAULT_ADDR(&sc), SC_IP(&sc));
31184 +/* Changed early in boot, and then only read */
31186 +int debug_stop = 1;
31187 +int debug_parent = 0;
31190 +static int signal_tramp(void *arg)
31192 + int (*proc)(void *);
31194 + if(honeypot && munmap((void *) (host_task_size - 0x10000000),
31196 + panic("Unmapping stack failed");
31197 + if(ptrace(PTRACE_TRACEME, 0, 0, 0) < 0)
31198 + panic("ptrace PTRACE_TRACEME failed");
31199 + os_stop_process(os_getpid());
31200 + change_sig(SIGWINCH, 0);
31201 + signal(SIGUSR1, SIG_IGN);
31202 + change_sig(SIGCHLD, 0);
31203 + signal(SIGSEGV, (__sighandler_t) sig_handler);
31204 + set_cmdline("(idle thread)");
31205 + set_init_pid(os_getpid());
31207 + return((*proc)(NULL));
31210 +static void sleeping_process_signal(int pid, int sig)
31213 + /* These two result from UML being ^Z-ed and bg-ed. PTRACE_CONT is
31214 + * right because the process must be in the kernel already.
31218 + if(ptrace(PTRACE_CONT, pid, 0, sig) < 0)
31219 + tracer_panic("sleeping_process_signal : Failed to "
31220 + "continue pid %d, signal = %d, "
31221 + "errno = %d\n", pid, sig, errno);
31224 + /* This happens when the debugger (e.g. strace) is doing system call
31225 + * tracing on the kernel. During a context switch, the current task
31226 + * will be set to the incoming process and the outgoing process will
31227 + * hop into write and then read. Since it's not the current process
31228 + * any more, the trace of those will land here. So, we need to just
31229 + * PTRACE_SYSCALL it.
31232 + if(ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0)
31233 + tracer_panic("sleeping_process_signal : Failed to "
31234 + "PTRACE_SYSCALL pid %d, errno = %d\n",
31240 + tracer_panic("sleeping process %d got unexpected "
31241 + "signal : %d\n", pid, sig);
31246 +/* Accessed only by the tracing thread */
31247 +int debugger_pid = -1;
31248 +int debugger_parent = -1;
31249 +int debugger_fd = -1;
31255 + unsigned long addr;
31256 + struct timeval time;
31257 +} signal_record[1024][32];
31259 +int signal_index[32];
31261 +int debug_trace = 0;
31262 +extern int io_nsignals, io_count, intr_count;
31264 +extern void signal_usr1(int sig);
31266 +int tracing_pid = -1;
31268 +int tracer(int (*init_proc)(void *), void *sp)
31270 + void *task = NULL;
31271 + unsigned long eip = 0;
31272 + int status, pid = 0, sig = 0, cont_type, tracing = 0, op = 0;
31273 + int last_index, proc_id = 0, n, err, old_tracing = 0, strace = 0;
31275 + capture_signal_stack();
31276 + signal(SIGPIPE, SIG_IGN);
31277 + setup_tracer_winch();
31278 + tracing_pid = os_getpid();
31279 + printf("tracing thread pid = %d\n", tracing_pid);
31281 + pid = clone(signal_tramp, sp, CLONE_FILES | SIGCHLD, init_proc);
31282 + n = waitpid(pid, &status, WUNTRACED);
31284 + printf("waitpid on idle thread failed, errno = %d\n", errno);
31287 + if((ptrace(PTRACE_CONT, pid, 0, 0) < 0)){
31288 + printf("Failed to continue idle thread, errno = %d\n", errno);
31292 + signal(SIGSEGV, (sighandler_t) tracer_segv);
31293 + signal(SIGUSR1, signal_usr1);
31295 + printf("Tracing thread pausing to be attached\n");
31299 + if(gdb_pid != -1)
31300 + debugger_pid = attach_debugger(pid, gdb_pid, 1);
31301 + else debugger_pid = init_ptrace_proxy(pid, 1, debug_stop);
31302 + if(debug_parent){
31303 + debugger_parent = os_process_parent(debugger_pid);
31304 + init_parent_proxy(debugger_parent);
31305 + err = attach(debugger_parent);
31307 + printf("Failed to attach debugger parent %d, "
31308 + "errno = %d\n", debugger_parent, -err);
31309 + debugger_parent = -1;
31312 + if(ptrace(PTRACE_SYSCALL, debugger_parent,
31314 + printf("Failed to continue debugger "
31315 + "parent, errno = %d\n", errno);
31316 + debugger_parent = -1;
31321 + set_cmdline("(tracing thread)");
31323 + pid = waitpid(-1, &status, WUNTRACED);
31325 + if(errno != ECHILD){
31326 + printf("wait failed - errno = %d\n", errno);
31330 + if(pid == debugger_pid){
31333 + if(WIFEXITED(status) || WIFSIGNALED(status))
31334 + debugger_pid = -1;
31335 + /* XXX Figure out how to deal with gdb and SMP */
31336 + else cont = debugger_signal(status, cpu_tasks[0].pid);
31337 + if(cont == PTRACE_SYSCALL) strace = 1;
31340 + else if(pid == debugger_parent){
31341 + debugger_parent_signal(status, pid);
31345 + if(WIFEXITED(status)) ;
31348 + printf("Child %d exited with status %d\n", pid,
31349 + WEXITSTATUS(status));
31352 + else if(WIFSIGNALED(status)){
31353 + sig = WTERMSIG(status);
31355 + printf("Child %d exited with signal %d\n", pid,
31359 + else if(WIFSTOPPED(status)){
31360 + proc_id = pid_to_processor_id(pid);
31361 + sig = WSTOPSIG(status);
31362 + if(signal_index[proc_id] == 1024){
31363 + signal_index[proc_id] = 0;
31364 + last_index = 1023;
31366 + else last_index = signal_index[proc_id] - 1;
31367 + if(((sig == SIGPROF) || (sig == SIGVTALRM) ||
31368 + (sig == SIGALRM)) &&
31369 + (signal_record[proc_id][last_index].signal == sig)&&
31370 + (signal_record[proc_id][last_index].pid == pid))
31371 + signal_index[proc_id] = last_index;
31372 + signal_record[proc_id][signal_index[proc_id]].pid = pid;
31373 + gettimeofday(&signal_record[proc_id][signal_index[proc_id]].time, NULL);
31374 + eip = ptrace(PTRACE_PEEKUSER, pid, PT_IP_OFFSET, 0);
31375 + signal_record[proc_id][signal_index[proc_id]].addr = eip;
31376 + signal_record[proc_id][signal_index[proc_id]++].signal = sig;
31378 + if(proc_id == -1){
31379 + sleeping_process_signal(pid, sig);
31383 + task = cpu_tasks[proc_id].task;
31384 + tracing = is_tracing(task);
31385 + old_tracing = tracing;
31390 + op = do_proc_op(task, proc_id);
31392 + case OP_TRACE_ON:
31393 + arch_leave_kernel(task, pid);
31400 + ptrace(PTRACE_KILL, pid, 0, 0);
31401 + return(op == OP_REBOOT);
31403 + printf("Detaching pid %d\n", pid);
31404 + detach(pid, SIGSTOP);
31409 + /* OP_EXEC switches host processes on us,
31410 + * we want to continue the new one.
31412 + pid = cpu_tasks[proc_id].pid;
31415 + if(!tracing && (debugger_pid != -1)){
31416 + child_signal(pid, status);
31420 + if(do_syscall(task, pid)) sig = SIGUSR2;
31421 + else clear_singlestep(task);
31424 + if(tracing) sig = 0;
31442 + set_tracing(task, tracing);
31444 + if(!tracing && old_tracing)
31445 + arch_enter_kernel(task, pid);
31447 + if(!tracing && (debugger_pid != -1) && (sig != 0) &&
31448 + (sig != SIGALRM) && (sig != SIGVTALRM) &&
31449 + (sig != SIGSEGV) && (sig != SIGTRAP) &&
31450 + (sig != SIGUSR2) && (sig != SIGIO) &&
31451 + (sig != SIGFPE)){
31452 + child_signal(pid, status);
31457 + if(singlestepping_tt(task))
31458 + cont_type = PTRACE_SINGLESTEP;
31459 + else cont_type = PTRACE_SYSCALL;
31461 + else cont_type = PTRACE_CONT;
31463 + if((cont_type == PTRACE_CONT) &&
31464 + (debugger_pid != -1) && strace)
31465 + cont_type = PTRACE_SYSCALL;
31467 + if(ptrace(cont_type, pid, 0, sig) != 0){
31468 + tracer_panic("ptrace failed to continue "
31469 + "process - errno = %d\n",
31477 +static int __init uml_debug_setup(char *line, int *add)
31483 + if(*line != '=') return(0);
31486 + while(line != NULL){
31487 + next = strchr(line, ',');
31488 + if(next) *next++ = '\0';
31490 + if(!strcmp(line, "go")) debug_stop = 0;
31491 + else if(!strcmp(line, "parent")) debug_parent = 1;
31492 + else printf("Unknown debug option : '%s'\n", line);
31499 +__uml_setup("debug", uml_debug_setup,
31501 +" Starts up the kernel under the control of gdb. See the \n"
31502 +" kernel debugging tutorial and the debugging session pages\n"
31503 +" at http://user-mode-linux.sourceforge.net/ for more information.\n\n"
31506 +static int __init uml_debugtrace_setup(char *line, int *add)
31511 +__uml_setup("debugtrace", uml_debugtrace_setup,
31513 +" Causes the tracing thread to pause until it is attached by a\n"
31514 +" debugger and continued. This is mostly for debugging crashes\n"
31515 +" early during boot, and should be pretty much obsoleted by\n"
31516 +" the debug switch.\n\n"
31519 +static int __init uml_honeypot_setup(char *line, int *add)
31521 + jail_setup("", add);
31525 +__uml_setup("honeypot", uml_honeypot_setup,
31527 +" This makes UML put process stacks in the same location as they are\n"
31528 +" on the host, allowing expoits such as stack smashes to work against\n"
31529 +" UML. This implies 'jail'.\n\n"
31533 + * Overrides for Emacs so that we follow Linus's tabbing style.
31534 + * Emacs will notice this stuff at the end of the file and automatically
31535 + * adjust the settings for this buffer only. This must remain at the end
31537 + * ---------------------------------------------------------------------------
31538 + * Local variables:
31539 + * c-file-style: "linux"
31542 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/trap_user.c um/arch/um/kernel/tt/trap_user.c
31543 --- orig/arch/um/kernel/tt/trap_user.c 1969-12-31 19:00:00.000000000 -0500
31544 +++ um/arch/um/kernel/tt/trap_user.c 2003-10-21 03:26:07.000000000 -0400
31547 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
31548 + * Licensed under the GPL
31551 +#include <stdlib.h>
31552 +#include <errno.h>
31553 +#include <signal.h>
31554 +#include <asm/sigcontext.h>
31555 +#include "sysdep/ptrace.h"
31556 +#include "signal_user.h"
31557 +#include "user_util.h"
31558 +#include "kern_util.h"
31562 +void sig_handler_common_tt(int sig, void *sc_ptr)
31564 + struct sigcontext *sc = sc_ptr;
31565 + struct tt_regs save_regs, *r;
31566 + struct signal_info *info;
31567 + int save_errno = errno, is_user;
31569 + unprotect_kernel_mem();
31571 + r = &TASK_REGS(get_current())->tt;
31573 + is_user = user_context(SC_SP(sc));
31575 + if(sig != SIGUSR2)
31578 + change_sig(SIGUSR1, 1);
31579 + info = &sig_info[sig];
31580 + if(!info->is_irq) unblock_signals();
31582 + (*info->handler)(sig, (union uml_pt_regs *) r);
31587 + change_sig(SIGUSR1, 0);
31588 + set_user_mode(NULL);
31591 + errno = save_errno;
31592 + if(is_user) protect_kernel_mem();
31596 + * Overrides for Emacs so that we follow Linus's tabbing style.
31597 + * Emacs will notice this stuff at the end of the file and automatically
31598 + * adjust the settings for this buffer only. This must remain at the end
31600 + * ---------------------------------------------------------------------------
31601 + * Local variables:
31602 + * c-file-style: "linux"
31605 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/uaccess.c um/arch/um/kernel/tt/uaccess.c
31606 --- orig/arch/um/kernel/tt/uaccess.c 1969-12-31 19:00:00.000000000 -0500
31607 +++ um/arch/um/kernel/tt/uaccess.c 2003-11-13 00:12:45.000000000 -0500
31610 + * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
31611 + * Licensed under the GPL
31614 +#include "linux/sched.h"
31615 +#include "asm/uaccess.h"
31617 +int copy_from_user_tt(void *to, const void *from, int n)
31619 + if(!access_ok_tt(VERIFY_READ, from, n))
31622 + return(__do_copy_from_user(to, from, n, ¤t->thread.fault_addr,
31623 + ¤t->thread.fault_catcher));
31626 +int copy_to_user_tt(void *to, const void *from, int n)
31628 + if(!access_ok_tt(VERIFY_WRITE, to, n))
31631 + return(__do_copy_to_user(to, from, n, ¤t->thread.fault_addr,
31632 + ¤t->thread.fault_catcher));
31635 +int strncpy_from_user_tt(char *dst, const char *src, int count)
31639 + if(!access_ok_tt(VERIFY_READ, src, 1))
31642 + n = __do_strncpy_from_user(dst, src, count,
31643 + ¤t->thread.fault_addr,
31644 + ¤t->thread.fault_catcher);
31645 + if(n < 0) return(-EFAULT);
31649 +int __clear_user_tt(void *mem, int len)
31651 + return(__do_clear_user(mem, len,
31652 + ¤t->thread.fault_addr,
31653 + ¤t->thread.fault_catcher));
31656 +int clear_user_tt(void *mem, int len)
31658 + if(!access_ok_tt(VERIFY_WRITE, mem, len))
31661 + return(__do_clear_user(mem, len, ¤t->thread.fault_addr,
31662 + ¤t->thread.fault_catcher));
31665 +int strnlen_user_tt(const void *str, int len)
31667 + return(__do_strnlen_user(str, len,
31668 + ¤t->thread.fault_addr,
31669 + ¤t->thread.fault_catcher));
31673 + * Overrides for Emacs so that we follow Linus's tabbing style.
31674 + * Emacs will notice this stuff at the end of the file and automatically
31675 + * adjust the settings for this buffer only. This must remain at the end
31677 + * ---------------------------------------------------------------------------
31678 + * Local variables:
31679 + * c-file-style: "linux"
31682 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/uaccess_user.c um/arch/um/kernel/tt/uaccess_user.c
31683 --- orig/arch/um/kernel/tt/uaccess_user.c 1969-12-31 19:00:00.000000000 -0500
31684 +++ um/arch/um/kernel/tt/uaccess_user.c 2004-01-31 02:48:29.000000000 -0500
31687 + * Copyright (C) 2001 Chris Emerson (cemerson@chiark.greenend.org.uk)
31688 + * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
31689 + * Licensed under the GPL
31692 +#include <setjmp.h>
31693 +#include <string.h>
31694 +#include "user_util.h"
31695 +#include "uml_uaccess.h"
31697 +#include "kern_util.h"
31699 +int __do_copy_from_user(void *to, const void *from, int n,
31700 + void **fault_addr, void **fault_catcher)
31702 + struct tt_regs save = TASK_REGS(get_current())->tt;
31703 + unsigned long fault;
31706 + fault = __do_user_copy(to, from, n, fault_addr, fault_catcher,
31707 + __do_copy, &faulted);
31708 + TASK_REGS(get_current())->tt = save;
31710 + if(!faulted) return(0);
31711 + else return(n - (fault - (unsigned long) from));
31714 +static void __do_strncpy(void *dst, const void *src, int count)
31716 + strncpy(dst, src, count);
31719 +int __do_strncpy_from_user(char *dst, const char *src, unsigned long count,
31720 + void **fault_addr, void **fault_catcher)
31722 + struct tt_regs save = TASK_REGS(get_current())->tt;
31723 + unsigned long fault;
31726 + fault = __do_user_copy(dst, src, count, fault_addr, fault_catcher,
31727 + __do_strncpy, &faulted);
31728 + TASK_REGS(get_current())->tt = save;
31730 + if(!faulted) return(strlen(dst));
31734 +static void __do_clear(void *to, const void *from, int n)
31736 + memset(to, 0, n);
31739 +int __do_clear_user(void *mem, unsigned long len,
31740 + void **fault_addr, void **fault_catcher)
31742 + struct tt_regs save = TASK_REGS(get_current())->tt;
31743 + unsigned long fault;
31746 + fault = __do_user_copy(mem, NULL, len, fault_addr, fault_catcher,
31747 + __do_clear, &faulted);
31748 + TASK_REGS(get_current())->tt = save;
31750 + if(!faulted) return(0);
31751 + else return(len - (fault - (unsigned long) mem));
31754 +int __do_strnlen_user(const char *str, unsigned long n,
31755 + void **fault_addr, void **fault_catcher)
31757 + struct tt_regs save = TASK_REGS(get_current())->tt;
31759 + unsigned long *faddrp = (unsigned long *)fault_addr;
31762 + *fault_catcher = &jbuf;
31763 + if(sigsetjmp(jbuf, 1) == 0)
31764 + ret = strlen(str) + 1;
31765 + else ret = *faddrp - (unsigned long) str;
31767 + *fault_addr = NULL;
31768 + *fault_catcher = NULL;
31770 + TASK_REGS(get_current())->tt = save;
31775 + * Overrides for Emacs so that we follow Linus's tabbing style.
31776 + * Emacs will notice this stuff at the end of the file and automatically
31777 + * adjust the settings for this buffer only. This must remain at the end
31779 + * ---------------------------------------------------------------------------
31780 + * Local variables:
31781 + * c-file-style: "linux"
31784 diff -Naur -X ../exclude-files orig/arch/um/kernel/tt/unmap.c um/arch/um/kernel/tt/unmap.c
31785 --- orig/arch/um/kernel/tt/unmap.c 1969-12-31 19:00:00.000000000 -0500
31786 +++ um/arch/um/kernel/tt/unmap.c 2003-10-21 03:26:07.000000000 -0400
31789 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
31790 + * Licensed under the GPL
31793 +#include <sys/mman.h>
31795 +int switcheroo(int fd, int prot, void *from, void *to, int size)
31797 + if(munmap(to, size) < 0){
31800 + if(mmap(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) != to){
31803 + if(munmap(from, size) < 0){
31810 + * Overrides for Emacs so that we follow Linus's tabbing style.
31811 + * Emacs will notice this stuff at the end of the file and automatically
31812 + * adjust the settings for this buffer only. This must remain at the end
31814 + * ---------------------------------------------------------------------------
31815 + * Local variables:
31816 + * c-file-style: "linux"
31819 diff -Naur -X ../exclude-files orig/arch/um/kernel/tty_log.c um/arch/um/kernel/tty_log.c
31820 --- orig/arch/um/kernel/tty_log.c 1969-12-31 19:00:00.000000000 -0500
31821 +++ um/arch/um/kernel/tty_log.c 2003-10-21 03:26:07.000000000 -0400
31824 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) and
31825 + * geoffrey hing <ghing@net.ohio-state.edu>
31826 + * Licensed under the GPL
31829 +#include <errno.h>
31830 +#include <string.h>
31831 +#include <stdio.h>
31832 +#include <stdlib.h>
31833 +#include <unistd.h>
31834 +#include <sys/time.h>
31837 +#include "kern_util.h"
31840 +#define TTY_LOG_DIR "./"
31842 +/* Set early in boot and then unchanged */
31843 +static char *tty_log_dir = TTY_LOG_DIR;
31844 +static int tty_log_fd = -1;
31846 +#define TTY_LOG_OPEN 1
31847 +#define TTY_LOG_CLOSE 2
31848 +#define TTY_LOG_WRITE 3
31849 +#define TTY_LOG_EXEC 4
31851 +#define TTY_READ 1
31852 +#define TTY_WRITE 2
31854 +struct tty_log_buf {
31856 + unsigned long tty;
31859 + unsigned long sec;
31860 + unsigned long usec;
31863 +int open_tty_log(void *tty, void *current_tty)
31865 + struct timeval tv;
31866 + struct tty_log_buf data;
31867 + char buf[strlen(tty_log_dir) + sizeof("01234567890-01234567\0")];
31870 + gettimeofday(&tv, NULL);
31871 + if(tty_log_fd != -1){
31872 + data = ((struct tty_log_buf) { .what = TTY_LOG_OPEN,
31873 + .tty = (unsigned long) tty,
31874 + .len = sizeof(current_tty),
31876 + .sec = tv.tv_sec,
31877 + .usec = tv.tv_usec } );
31878 + os_write_file(tty_log_fd, &data, sizeof(data));
31879 + os_write_file(tty_log_fd, ¤t_tty, data.len);
31880 + return(tty_log_fd);
31883 + sprintf(buf, "%s/%0u-%0u", tty_log_dir, (unsigned int) tv.tv_sec,
31884 + (unsigned int) tv.tv_usec);
31886 + fd = os_open_file(buf, of_append(of_create(of_rdwr(OPENFLAGS()))),
31889 + printk("open_tty_log : couldn't open '%s', errno = %d\n",
31895 +void close_tty_log(int fd, void *tty)
31897 + struct tty_log_buf data;
31898 + struct timeval tv;
31900 + if(tty_log_fd != -1){
31901 + gettimeofday(&tv, NULL);
31902 + data = ((struct tty_log_buf) { .what = TTY_LOG_CLOSE,
31903 + .tty = (unsigned long) tty,
31906 + .sec = tv.tv_sec,
31907 + .usec = tv.tv_usec } );
31908 + os_write_file(tty_log_fd, &data, sizeof(data));
31911 + os_close_file(fd);
31914 +static int log_chunk(int fd, const char *buf, int len)
31916 + int total = 0, try, missed, n;
31920 + try = (len > sizeof(chunk)) ? sizeof(chunk) : len;
31921 + missed = copy_from_user_proc(chunk, (char *) buf, try);
31923 + n = os_write_file(fd, chunk, try);
31940 +int write_tty_log(int fd, const char *buf, int len, void *tty, int is_read)
31942 + struct timeval tv;
31943 + struct tty_log_buf data;
31946 + if(fd == tty_log_fd){
31947 + gettimeofday(&tv, NULL);
31948 + direction = is_read ? TTY_READ : TTY_WRITE;
31949 + data = ((struct tty_log_buf) { .what = TTY_LOG_WRITE,
31950 + .tty = (unsigned long) tty,
31952 + .direction = direction,
31953 + .sec = tv.tv_sec,
31954 + .usec = tv.tv_usec } );
31955 + os_write_file(tty_log_fd, &data, sizeof(data));
31958 + return(log_chunk(fd, buf, len));
31961 +void log_exec(char **argv, void *tty)
31963 + struct timeval tv;
31964 + struct tty_log_buf data;
31968 + if(tty_log_fd == -1) return;
31970 + gettimeofday(&tv, NULL);
31973 + for(ptr = argv; ; ptr++){
31974 + if(copy_from_user_proc(&arg, ptr, sizeof(arg)))
31976 + if(arg == NULL) break;
31977 + len += strlen_user_proc(arg);
31980 + data = ((struct tty_log_buf) { .what = TTY_LOG_EXEC,
31981 + .tty = (unsigned long) tty,
31984 + .sec = tv.tv_sec,
31985 + .usec = tv.tv_usec } );
31986 + os_write_file(tty_log_fd, &data, sizeof(data));
31988 + for(ptr = argv; ; ptr++){
31989 + if(copy_from_user_proc(&arg, ptr, sizeof(arg)))
31991 + if(arg == NULL) break;
31992 + log_chunk(tty_log_fd, arg, strlen_user_proc(arg));
31996 +extern void register_tty_logger(int (*opener)(void *, void *),
31997 + int (*writer)(int, const char *, int,
31999 + void (*closer)(int, void *));
32001 +static int register_logger(void)
32003 + register_tty_logger(open_tty_log, write_tty_log, close_tty_log);
32007 +__uml_initcall(register_logger);
32009 +static int __init set_tty_log_dir(char *name, int *add)
32011 + tty_log_dir = name;
32015 +__uml_setup("tty_log_dir=", set_tty_log_dir,
32016 +"tty_log_dir=<directory>\n"
32017 +" This is used to specify the directory where the logs of all pty\n"
32018 +" data from this UML machine will be written.\n\n"
32021 +static int __init set_tty_log_fd(char *name, int *add)
32025 + tty_log_fd = strtoul(name, &end, 0);
32026 + if((*end != '\0') || (end == name)){
32027 + printf("set_tty_log_fd - strtoul failed on '%s'\n", name);
32033 +__uml_setup("tty_log_fd=", set_tty_log_fd,
32034 +"tty_log_fd=<fd>\n"
32035 +" This is used to specify a preconfigured file descriptor to which all\n"
32036 +" tty data will be written. Preconfigure the descriptor with something\n"
32037 +" like '10>tty_log tty_log_fd=10'.\n\n"
32042 + * Overrides for Emacs so that we follow Linus's tabbing style.
32043 + * Emacs will notice this stuff at the end of the file and automatically
32044 + * adjust the settings for this buffer only. This must remain at the end
32046 + * ---------------------------------------------------------------------------
32047 + * Local variables:
32048 + * c-file-style: "linux"
32051 diff -Naur -X ../exclude-files orig/arch/um/kernel/uaccess_user.c um/arch/um/kernel/uaccess_user.c
32052 --- orig/arch/um/kernel/uaccess_user.c 1969-12-31 19:00:00.000000000 -0500
32053 +++ um/arch/um/kernel/uaccess_user.c 2004-01-31 02:48:08.000000000 -0500
32056 + * Copyright (C) 2001 Chris Emerson (cemerson@chiark.greenend.org.uk)
32057 + * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
32058 + * Licensed under the GPL
32061 +#include <setjmp.h>
32062 +#include <string.h>
32064 +/* These are here rather than tt/uaccess.c because skas mode needs them in
32065 + * order to do SIGBUS recovery when a tmpfs mount runs out of room.
32068 +unsigned long __do_user_copy(void *to, const void *from, int n,
32069 + void **fault_addr, void **fault_catcher,
32070 + void (*op)(void *to, const void *from,
32071 + int n), int *faulted_out)
32073 + unsigned long *faddrp = (unsigned long *) fault_addr, ret;
32076 + *fault_catcher = &jbuf;
32077 + if(sigsetjmp(jbuf, 1) == 0){
32078 + (*op)(to, from, n);
32080 + *faulted_out = 0;
32084 + *faulted_out = 1;
32086 + *fault_addr = NULL;
32087 + *fault_catcher = NULL;
32091 +void __do_copy(void *to, const void *from, int n)
32093 + memcpy(to, from, n);
32097 +int __do_copy_to_user(void *to, const void *from, int n,
32098 + void **fault_addr, void **fault_catcher)
32100 + unsigned long fault;
32103 + fault = __do_user_copy(to, from, n, fault_addr, fault_catcher,
32104 + __do_copy, &faulted);
32105 + if(!faulted) return(0);
32106 + else return(n - (fault - (unsigned long) to));
32110 + * Overrides for Emacs so that we follow Linus's tabbing style.
32111 + * Emacs will notice this stuff at the end of the file and automatically
32112 + * adjust the settings for this buffer only. This must remain at the end
32114 + * ---------------------------------------------------------------------------
32115 + * Local variables:
32116 + * c-file-style: "linux"
32119 diff -Naur -X ../exclude-files orig/arch/um/kernel/um_arch.c um/arch/um/kernel/um_arch.c
32120 --- orig/arch/um/kernel/um_arch.c 1969-12-31 19:00:00.000000000 -0500
32121 +++ um/arch/um/kernel/um_arch.c 2004-01-10 00:11:09.000000000 -0500
32124 + * Copyright (C) 2000, 2002 Jeff Dike (jdike@karaya.com)
32125 + * Licensed under the GPL
32128 +#include "linux/config.h"
32129 +#include "linux/kernel.h"
32130 +#include "linux/sched.h"
32131 +#include "linux/notifier.h"
32132 +#include "linux/mm.h"
32133 +#include "linux/types.h"
32134 +#include "linux/tty.h"
32135 +#include "linux/init.h"
32136 +#include "linux/bootmem.h"
32137 +#include "linux/spinlock.h"
32138 +#include "linux/utsname.h"
32139 +#include "linux/sysrq.h"
32140 +#include "linux/seq_file.h"
32141 +#include "linux/delay.h"
32142 +#include "asm/page.h"
32143 +#include "asm/pgtable.h"
32144 +#include "asm/ptrace.h"
32145 +#include "asm/elf.h"
32146 +#include "asm/user.h"
32147 +#include "ubd_user.h"
32148 +#include "asm/current.h"
32149 +#include "user_util.h"
32150 +#include "kern_util.h"
32152 +#include "mprot.h"
32153 +#include "mem_user.h"
32156 +#include "initrd.h"
32159 +#include "choose-mode.h"
32160 +#include "mode_kern.h"
32163 +#define DEFAULT_COMMAND_LINE "root=/dev/ubd0"
32165 +struct cpuinfo_um boot_cpu_data = {
32166 + .loops_per_jiffy = 0,
32167 + .pgd_quick = NULL,
32168 + .pmd_quick = NULL,
32169 + .pte_quick = NULL,
32170 + .pgtable_cache_sz = 0,
32171 + .ipi_pipe = { -1, -1 }
32174 +unsigned long thread_saved_pc(struct thread_struct *thread)
32176 + return(os_process_pc(CHOOSE_MODE_PROC(thread_pid_tt, thread_pid_skas,
32180 +static int show_cpuinfo(struct seq_file *m, void *v)
32185 + index = (struct cpuinfo_um *)v - cpu_data;
32186 + if (!(cpu_online_map & (1 << index)))
32190 + seq_printf(m, "processor\t: %d\n", index);
32191 + seq_printf(m, "vendor_id\t: User Mode Linux\n");
32192 + seq_printf(m, "model name\t: UML\n");
32193 + seq_printf(m, "mode\t\t: %s\n", CHOOSE_MODE("tt", "skas"));
32194 + seq_printf(m, "host\t\t: %s\n", host_info);
32195 + seq_printf(m, "bogomips\t: %lu.%02lu\n\n",
32196 + loops_per_jiffy/(500000/HZ),
32197 + (loops_per_jiffy/(5000/HZ)) % 100);
32202 +static void *c_start(struct seq_file *m, loff_t *pos)
32204 + return *pos < NR_CPUS ? cpu_data + *pos : NULL;
32207 +static void *c_next(struct seq_file *m, void *v, loff_t *pos)
32210 + return c_start(m, pos);
32213 +static void c_stop(struct seq_file *m, void *v)
32217 +struct seq_operations cpuinfo_op = {
32218 + .start = c_start,
32221 + .show = show_cpuinfo,
32224 +pte_t * __bad_pagetable(void)
32226 + panic("Someone should implement __bad_pagetable");
32230 +/* Set in linux_main */
32231 +unsigned long host_task_size;
32232 +unsigned long task_size;
32233 +unsigned long uml_start;
32235 +/* Set in early boot */
32236 +unsigned long uml_physmem;
32237 +unsigned long uml_reserved;
32238 +unsigned long start_vm;
32239 +unsigned long end_vm;
32242 +#ifdef CONFIG_MODE_TT
32243 +/* Pointer set in linux_main, the array itself is private to each thread,
32244 + * and changed at address space creation time so this poses no concurrency
32247 +static char *argv1_begin = NULL;
32248 +static char *argv1_end = NULL;
32251 +/* Set in early boot */
32252 +static int have_root __initdata = 0;
32253 +long physmem_size = 32 * 1024 * 1024;
32255 +void set_cmdline(char *cmd)
32257 +#ifdef CONFIG_MODE_TT
32258 + char *umid, *ptr;
32260 + if(CHOOSE_MODE(honeypot, 0)) return;
32262 + umid = get_umid(1);
32263 + if(umid != NULL){
32264 + snprintf(argv1_begin,
32265 + (argv1_end - argv1_begin) * sizeof(*ptr),
32267 + ptr = &argv1_begin[strlen(argv1_begin)];
32269 + else ptr = argv1_begin;
32271 + snprintf(ptr, (argv1_end - ptr) * sizeof(*ptr), "[%s]", cmd);
32272 + memset(argv1_begin + strlen(argv1_begin), '\0',
32273 + argv1_end - argv1_begin - strlen(argv1_begin));
32277 +static char *usage_string =
32278 +"User Mode Linux v%s\n"
32279 +" available at http://user-mode-linux.sourceforge.net/\n\n";
32281 +static int __init uml_version_setup(char *line, int *add)
32283 + printf("%s\n", system_utsname.release);
32287 +__uml_setup("--version", uml_version_setup,
32289 +" Prints the version number of the kernel.\n\n"
32292 +static int __init uml_root_setup(char *line, int *add)
32298 +__uml_setup("root=", uml_root_setup,
32299 +"root=<file containing the root fs>\n"
32300 +" This is actually used by the generic kernel in exactly the same\n"
32301 +" way as in any other kernel. If you configure a number of block\n"
32302 +" devices and want to boot off something other than ubd0, you \n"
32303 +" would use something like:\n"
32304 +" root=/dev/ubd5\n\n"
32308 +static int __init uml_ncpus_setup(char *line, int *add)
32310 + if (!sscanf(line, "%d", &ncpus)) {
32311 + printf("Couldn't parse [%s]\n", line);
32318 +__uml_setup("ncpus=", uml_ncpus_setup,
32319 +"ncpus=<# of desired CPUs>\n"
32320 +" This tells an SMP kernel how many virtual processors to start.\n\n"
32326 +#if defined(CONFIG_MODE_TT) && defined(CONFIG_MODE_SKAS)
32327 +#define DEFAULT_TT 0
32329 +static int __init mode_tt_setup(char *line, int *add)
32336 +#ifdef CONFIG_MODE_SKAS
32338 +#define DEFAULT_TT 0
32340 +static int __init mode_tt_setup(char *line, int *add)
32342 + printf("CONFIG_MODE_TT disabled - 'mode=tt' ignored\n");
32347 +#ifdef CONFIG_MODE_TT
32349 +#define DEFAULT_TT 1
32351 +static int __init mode_tt_setup(char *line, int *add)
32353 + printf("CONFIG_MODE_SKAS disabled - 'mode=tt' redundant\n");
32359 +#error Either CONFIG_MODE_TT or CONFIG_MODE_SKAS must be enabled
32365 +__uml_setup("mode=tt", mode_tt_setup,
32367 +" When both CONFIG_MODE_TT and CONFIG_MODE_SKAS are enabled, this option\n"
32368 +" forces UML to run in tt (tracing thread) mode. It is not the default\n"
32369 +" because it's slower and less secure than skas mode.\n\n"
32372 +int mode_tt = DEFAULT_TT;
32374 +static int __init Usage(char *line, int *add)
32378 + printf(usage_string, system_utsname.release);
32379 + p = &__uml_help_start;
32380 + while (p < &__uml_help_end) {
32381 + printf("%s", *p);
32387 +__uml_setup("--help", Usage,
32389 +" Prints this message.\n\n"
32392 +static int __init uml_checksetup(char *line, int *add)
32394 + struct uml_param *p;
32396 + p = &__uml_setup_start;
32397 + while(p < &__uml_setup_end) {
32400 + n = strlen(p->str);
32401 + if(!strncmp(line, p->str, n)){
32402 + if (p->setup_func(line + n, add)) return 1;
32409 +static void __init uml_postsetup(void)
32413 + p = &__uml_postsetup_start;
32414 + while(p < &__uml_postsetup_end){
32421 +/* Set during early boot */
32422 +unsigned long brk_start;
32423 +unsigned long end_iomem;
32425 +#define MIN_VMALLOC (32 * 1024 * 1024)
32427 +int linux_main(int argc, char **argv)
32429 + unsigned long avail;
32430 + unsigned long virtmem_size, max_physmem;
32431 + unsigned int i, add;
32433 + for (i = 1; i < argc; i++){
32434 + if((i == 1) && (argv[i][0] == ' ')) continue;
32436 + uml_checksetup(argv[i], &add);
32437 + if(add) add_arg(saved_command_line, argv[i]);
32439 + if(have_root == 0) add_arg(saved_command_line, DEFAULT_COMMAND_LINE);
32441 + mode_tt = force_tt ? 1 : !can_do_skas();
32442 + uml_start = CHOOSE_MODE_PROC(set_task_sizes_tt, set_task_sizes_skas, 0,
32443 + &host_task_size, &task_size);
32445 + brk_start = (unsigned long) sbrk(0);
32446 + CHOOSE_MODE_PROC(before_mem_tt, before_mem_skas, brk_start);
32448 + uml_physmem = uml_start;
32450 + /* Reserve up to 4M after the current brk */
32451 + uml_reserved = ROUND_4M(brk_start) + (1 << 22);
32453 + setup_machinename(system_utsname.machine);
32455 +#ifdef CONFIG_MODE_TT
32456 + argv1_begin = argv[1];
32457 + argv1_end = &argv[1][strlen(argv[1])];
32461 + iomem_size = (iomem_size + PAGE_SIZE - 1) & PAGE_MASK;
32462 + max_physmem = get_kmem_end() - uml_physmem - iomem_size - MIN_VMALLOC;
32464 + /* Zones have to begin on a 1 << MAX_ORDER page boundary,
32465 + * so this makes sure that's true for highmem
32467 + max_physmem &= ~((1 << (PAGE_SHIFT + MAX_ORDER)) - 1);
32468 + if(physmem_size + iomem_size > max_physmem){
32469 + highmem = physmem_size + iomem_size - max_physmem;
32470 + physmem_size -= highmem;
32471 +#ifndef CONFIG_HIGHMEM
32473 + printf("CONFIG_HIGHMEM not enabled - physical memory shrunk "
32474 + "to %ld bytes\n", physmem_size);
32478 + high_physmem = uml_physmem + physmem_size;
32479 + end_iomem = high_physmem + iomem_size;
32480 + high_memory = (void *) end_iomem;
32482 + start_vm = VMALLOC_START;
32484 + setup_physmem(uml_physmem, uml_reserved, physmem_size, highmem);
32485 + if(init_maps(physmem_size, iomem_size, highmem)){
32486 + printf("Failed to allocate mem_map for %ld bytes of physical "
32487 + "memory and %ld bytes of highmem\n", physmem_size,
32492 + virtmem_size = physmem_size;
32493 + avail = get_kmem_end() - start_vm;
32494 + if(physmem_size > avail) virtmem_size = avail;
32495 + end_vm = start_vm + virtmem_size;
32497 + if(virtmem_size < physmem_size)
32498 + printf("Kernel virtual memory size shrunk to %ld bytes\n",
32503 + init_task.thread.kernel_stack = (unsigned long) &init_task +
32506 + task_protections((unsigned long) &init_task);
32507 + os_flush_stdout();
32509 + return(CHOOSE_MODE(start_uml_tt(), start_uml_skas()));
32512 +static int panic_exit(struct notifier_block *self, unsigned long unused1,
32515 +#ifdef CONFIG_SYSRQ
32516 + handle_sysrq('p', ¤t->thread.regs, NULL, NULL);
32522 +static struct notifier_block panic_exit_notifier = {
32523 + .notifier_call = panic_exit,
32528 +void __init setup_arch(char **cmdline_p)
32530 + notifier_chain_register(&panic_notifier_list, &panic_exit_notifier);
32532 + strcpy(command_line, saved_command_line);
32533 + *cmdline_p = command_line;
32534 + setup_hostinfo();
32537 +void __init check_bugs(void)
32539 + arch_check_bugs();
32545 + * Overrides for Emacs so that we follow Linus's tabbing style.
32546 + * Emacs will notice this stuff at the end of the file and automatically
32547 + * adjust the settings for this buffer only. This must remain at the end
32549 + * ---------------------------------------------------------------------------
32550 + * Local variables:
32551 + * c-file-style: "linux"
32554 diff -Naur -X ../exclude-files orig/arch/um/kernel/umid.c um/arch/um/kernel/umid.c
32555 --- orig/arch/um/kernel/umid.c 1969-12-31 19:00:00.000000000 -0500
32556 +++ um/arch/um/kernel/umid.c 2004-01-26 10:13:01.000000000 -0500
32559 + * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
32560 + * Licensed under the GPL
32563 +#include <stdio.h>
32564 +#include <unistd.h>
32565 +#include <errno.h>
32566 +#include <string.h>
32567 +#include <stdlib.h>
32568 +#include <dirent.h>
32569 +#include <signal.h>
32570 +#include <sys/stat.h>
32571 +#include <sys/param.h>
32576 +#include "user_util.h"
32577 +#include "choose-mode.h"
32579 +#define UMID_LEN 64
32580 +#define UML_DIR "~/.uml/"
32582 +/* Changed by set_umid and make_umid, which are run early in boot */
32583 +static char umid[UMID_LEN] = { 0 };
32585 +/* Changed by set_uml_dir and make_uml_dir, which are run early in boot */
32586 +static char *uml_dir = UML_DIR;
32588 +/* Changed by set_umid */
32589 +static int umid_is_random = 1;
32590 +static int umid_inited = 0;
32592 +static int make_umid(int (*printer)(const char *fmt, ...));
32594 +static int __init set_umid(char *name, int is_random,
32595 + int (*printer)(const char *fmt, ...))
32598 + (*printer)("Unique machine name can't be set twice\n");
32602 + if(strlen(name) > UMID_LEN - 1)
32603 + (*printer)("Unique machine name is being truncated to %s "
32604 + "characters\n", UMID_LEN);
32605 + strncpy(umid, name, UMID_LEN - 1);
32606 + umid[UMID_LEN - 1] = '\0';
32608 + umid_is_random = is_random;
32613 +static int __init set_umid_arg(char *name, int *add)
32615 + return(set_umid(name, 0, printf));
32618 +__uml_setup("umid=", set_umid_arg,
32620 +" This is used to assign a unique identity to this UML machine and\n"
32621 +" is used for naming the pid file and management console socket.\n\n"
32624 +int __init umid_file_name(char *name, char *buf, int len)
32628 + if(!umid_inited && make_umid(printk)) return(-1);
32630 + n = strlen(uml_dir) + strlen(umid) + strlen(name) + 1;
32632 + printk("umid_file_name : buffer too short\n");
32636 + sprintf(buf, "%s%s/%s", uml_dir, umid, name);
32640 +extern int tracing_pid;
32642 +static int __init create_pid_file(void)
32644 + char file[strlen(uml_dir) + UMID_LEN + sizeof("/pid\0")];
32645 + char pid[sizeof("nnnnn\0")];
32648 + if(umid_file_name("pid", file, sizeof(file))) return 0;
32650 + fd = os_open_file(file, of_create(of_excl(of_rdwr(OPENFLAGS()))),
32653 + printf("Open of machine pid file \"%s\" failed - "
32654 + "err = %d\n", file, -fd);
32658 + sprintf(pid, "%d\n", os_getpid());
32659 + n = os_write_file(fd, pid, strlen(pid));
32660 + if(n != strlen(pid))
32661 + printf("Write of pid file failed - err = %d\n", -n);
32662 + os_close_file(fd);
32666 +static int actually_do_remove(char *dir)
32669 + struct dirent *ent;
32673 + directory = opendir(dir);
32674 + if(directory == NULL){
32675 + printk("actually_do_remove : couldn't open directory '%s', "
32676 + "errno = %d\n", dir, errno);
32679 + while((ent = readdir(directory)) != NULL){
32680 + if(!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, ".."))
32682 + len = strlen(dir) + sizeof("/") + strlen(ent->d_name) + 1;
32683 + if(len > sizeof(file)){
32684 + printk("Not deleting '%s' from '%s' - name too long\n",
32685 + ent->d_name, dir);
32688 + sprintf(file, "%s/%s", dir, ent->d_name);
32689 + if(unlink(file) < 0){
32690 + printk("actually_do_remove : couldn't remove '%s' "
32691 + "from '%s', errno = %d\n", ent->d_name, dir,
32696 + if(rmdir(dir) < 0){
32697 + printk("actually_do_remove : couldn't rmdir '%s', "
32698 + "errno = %d\n", dir, errno);
32704 +void remove_umid_dir(void)
32706 + char dir[strlen(uml_dir) + UMID_LEN + 1];
32707 + if(!umid_inited) return;
32709 + sprintf(dir, "%s%s", uml_dir, umid);
32710 + actually_do_remove(dir);
32713 +char *get_umid(int only_if_set)
32715 + if(only_if_set && umid_is_random) return(NULL);
32719 +int not_dead_yet(char *dir)
32721 + char file[strlen(uml_dir) + UMID_LEN + sizeof("/pid\0")];
32722 + char pid[sizeof("nnnnn\0")], *end;
32723 + int dead, fd, p, n;
32725 + sprintf(file, "%s/pid", dir);
32727 + fd = os_open_file(file, of_read(OPENFLAGS()), 0);
32729 + if(fd != -ENOENT){
32730 + printk("not_dead_yet : couldn't open pid file '%s', "
32731 + "err = %d\n", file, -fd);
32737 + n = os_read_file(fd, pid, sizeof(pid));
32739 + printk("not_dead_yet : couldn't read pid file '%s', "
32740 + "err = %d\n", file, -n);
32743 + p = strtoul(pid, &end, 0);
32745 + printk("not_dead_yet : couldn't parse pid file '%s', "
32746 + "errno = %d\n", file, errno);
32749 + if(((kill(p, 0) < 0) && (errno == ESRCH)) ||
32750 + (p == CHOOSE_MODE(tracing_pid, os_getpid())))
32753 + if(!dead) return(1);
32754 + return(actually_do_remove(dir));
32757 +static int __init set_uml_dir(char *name, int *add)
32759 + if((strlen(name) > 0) && (name[strlen(name) - 1] != '/')){
32760 + uml_dir = malloc(strlen(name) + 1);
32761 + if(uml_dir == NULL){
32762 + printf("Failed to malloc uml_dir - error = %d\n",
32765 + /* Return 0 here because do_initcalls doesn't look at
32766 + * the return value.
32770 + sprintf(uml_dir, "%s/", name);
32772 + else uml_dir = name;
32776 +static int __init make_uml_dir(void)
32778 + char dir[MAXPATHLEN + 1] = { '\0' };
32781 + if(*uml_dir == '~'){
32782 + char *home = getenv("HOME");
32784 + if(home == NULL){
32785 + printf("make_uml_dir : no value in environment for "
32789 + strncpy(dir, home, sizeof(dir));
32792 + len = strlen(dir);
32793 + strncat(dir, uml_dir, sizeof(dir) - len);
32794 + len = strlen(dir);
32795 + if((len > 0) && (len < sizeof(dir) - 1) && (dir[len - 1] != '/')){
32797 + dir[len + 1] = '\0';
32800 + uml_dir = malloc(strlen(dir) + 1);
32801 + if(uml_dir == NULL){
32802 + printf("make_uml_dir : malloc failed, errno = %d\n", errno);
32805 + strcpy(uml_dir, dir);
32807 + if((mkdir(uml_dir, 0777) < 0) && (errno != EEXIST)){
32808 + printf("Failed to mkdir %s - errno = %i\n", uml_dir, errno);
32814 +static int __init make_umid(int (*printer)(const char *fmt, ...))
32817 + char tmp[strlen(uml_dir) + UMID_LEN + 1];
32819 + strncpy(tmp, uml_dir, sizeof(tmp) - 1);
32820 + tmp[sizeof(tmp) - 1] = '\0';
32822 + if(!umid_inited){
32823 + strcat(tmp, "XXXXXX");
32824 + fd = mkstemp(tmp);
32826 + (*printer)("make_umid - mkstemp failed, errno = %d\n",
32831 + os_close_file(fd);
32832 + /* There's a nice tiny little race between this unlink and
32833 + * the mkdir below. It'd be nice if there were a mkstemp
32834 + * for directories.
32837 + set_umid(&tmp[strlen(uml_dir)], 1, printer);
32840 + sprintf(tmp, "%s%s", uml_dir, umid);
32842 + err = mkdir(tmp, 0777);
32844 + if(errno == EEXIST){
32845 + if(not_dead_yet(tmp)){
32846 + (*printer)("umid '%s' is in use\n", umid);
32849 + err = mkdir(tmp, 0777);
32853 + (*printer)("Failed to create %s - errno = %d\n", umid, errno);
32860 +__uml_setup("uml_dir=", set_uml_dir,
32861 +"uml_dir=<directory>\n"
32862 +" The location to place the pid and umid files.\n\n"
32865 +__uml_postsetup(make_uml_dir);
32867 +static int __init make_umid_setup(void)
32869 + return(make_umid(printf));
32872 +__uml_postsetup(make_umid_setup);
32873 +__uml_postsetup(create_pid_file);
32876 + * Overrides for Emacs so that we follow Linus's tabbing style.
32877 + * Emacs will notice this stuff at the end of the file and automatically
32878 + * adjust the settings for this buffer only. This must remain at the end
32880 + * ---------------------------------------------------------------------------
32881 + * Local variables:
32882 + * c-file-style: "linux"
32885 diff -Naur -X ../exclude-files orig/arch/um/kernel/user_syms.c um/arch/um/kernel/user_syms.c
32886 --- orig/arch/um/kernel/user_syms.c 1969-12-31 19:00:00.000000000 -0500
32887 +++ um/arch/um/kernel/user_syms.c 2004-01-23 00:44:09.000000000 -0500
32889 +#include <stdio.h>
32890 +#include <unistd.h>
32891 +#include <dirent.h>
32892 +#include <fcntl.h>
32893 +#include <errno.h>
32894 +#include <utime.h>
32895 +#include <string.h>
32896 +#include <sys/stat.h>
32897 +#include <sys/vfs.h>
32898 +#include <sys/ioctl.h>
32899 +#include "user_util.h"
32900 +#include "mem_user.h"
32902 +/* XXX All the __CONFIG_* stuff is broken because this file can't include
32906 +/* Had to steal this from linux/module.h because that file can't be included
32907 + * since this includes various user-level headers.
32910 +struct module_symbol
32912 + unsigned long value;
32913 + const char *name;
32916 +/* Indirect stringification. */
32918 +#define __MODULE_STRING_1(x) #x
32919 +#define __MODULE_STRING(x) __MODULE_STRING_1(x)
32921 +#if !defined(__AUTOCONF_INCLUDED__)
32923 +#define __EXPORT_SYMBOL(sym,str) error config_must_be_included_before_module
32924 +#define EXPORT_SYMBOL(var) error config_must_be_included_before_module
32925 +#define EXPORT_SYMBOL_NOVERS(var) error config_must_be_included_before_module
32927 +#elif !defined(__CONFIG_MODULES__)
32929 +#define __EXPORT_SYMBOL(sym,str)
32930 +#define EXPORT_SYMBOL(var)
32931 +#define EXPORT_SYMBOL_NOVERS(var)
32935 +#define __EXPORT_SYMBOL(sym, str) \
32936 +const char __kstrtab_##sym[] \
32937 +__attribute__((section(".kstrtab"))) = str; \
32938 +const struct module_symbol __ksymtab_##sym \
32939 +__attribute__((section("__ksymtab"))) = \
32940 +{ (unsigned long)&sym, __kstrtab_##sym }
32942 +#if defined(__MODVERSIONS__) || !defined(__CONFIG_MODVERSIONS__)
32943 +#define EXPORT_SYMBOL(var) __EXPORT_SYMBOL(var, __MODULE_STRING(var))
32945 +#define EXPORT_SYMBOL(var) __EXPORT_SYMBOL(var, __MODULE_STRING(__VERSIONED_SYMBOL(var)))
32948 +#define EXPORT_SYMBOL_NOVERS(var) __EXPORT_SYMBOL(var, __MODULE_STRING(var))
32952 +EXPORT_SYMBOL(__errno_location);
32954 +EXPORT_SYMBOL(access);
32955 +EXPORT_SYMBOL(open);
32956 +EXPORT_SYMBOL(open64);
32957 +EXPORT_SYMBOL(close);
32958 +EXPORT_SYMBOL(read);
32959 +EXPORT_SYMBOL(write);
32960 +EXPORT_SYMBOL(dup2);
32961 +EXPORT_SYMBOL(__xstat);
32962 +EXPORT_SYMBOL(__lxstat);
32963 +EXPORT_SYMBOL(__lxstat64);
32964 +EXPORT_SYMBOL(lseek);
32965 +EXPORT_SYMBOL(lseek64);
32966 +EXPORT_SYMBOL(chown);
32967 +EXPORT_SYMBOL(truncate);
32968 +EXPORT_SYMBOL(utime);
32969 +EXPORT_SYMBOL(chmod);
32970 +EXPORT_SYMBOL(rename);
32971 +EXPORT_SYMBOL(__xmknod);
32973 +EXPORT_SYMBOL(symlink);
32974 +EXPORT_SYMBOL(link);
32975 +EXPORT_SYMBOL(unlink);
32976 +EXPORT_SYMBOL(readlink);
32978 +EXPORT_SYMBOL(mkdir);
32979 +EXPORT_SYMBOL(rmdir);
32980 +EXPORT_SYMBOL(opendir);
32981 +EXPORT_SYMBOL(readdir);
32982 +EXPORT_SYMBOL(closedir);
32983 +EXPORT_SYMBOL(seekdir);
32984 +EXPORT_SYMBOL(telldir);
32986 +EXPORT_SYMBOL(ioctl);
32988 +extern ssize_t pread64 (int __fd, void *__buf, size_t __nbytes,
32989 + __off64_t __offset);
32990 +extern ssize_t pwrite64 (int __fd, __const void *__buf, size_t __n,
32991 + __off64_t __offset);
32992 +EXPORT_SYMBOL(pread64);
32993 +EXPORT_SYMBOL(pwrite64);
32995 +EXPORT_SYMBOL(statfs);
32996 +EXPORT_SYMBOL(statfs64);
32998 +EXPORT_SYMBOL(memcpy);
32999 +EXPORT_SYMBOL(getuid);
33001 +EXPORT_SYMBOL(memset);
33002 +EXPORT_SYMBOL(strstr);
33003 +EXPORT_SYMBOL(strlen);
33004 +EXPORT_SYMBOL(printf);
33006 +EXPORT_SYMBOL(find_iomem);
33007 diff -Naur -X ../exclude-files orig/arch/um/kernel/user_util.c um/arch/um/kernel/user_util.c
33008 --- orig/arch/um/kernel/user_util.c 1969-12-31 19:00:00.000000000 -0500
33009 +++ um/arch/um/kernel/user_util.c 2003-10-21 03:26:07.000000000 -0400
33012 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
33013 + * Licensed under the GPL
33016 +#include <stdio.h>
33017 +#include <stdlib.h>
33018 +#include <unistd.h>
33019 +#include <limits.h>
33020 +#include <sys/mman.h>
33021 +#include <sys/stat.h>
33022 +#include <sys/ptrace.h>
33023 +#include <sys/utsname.h>
33024 +#include <sys/param.h>
33025 +#include <sys/time.h>
33026 +#include "asm/types.h"
33027 +#include <ctype.h>
33028 +#include <signal.h>
33030 +#include <errno.h>
33031 +#include <stdarg.h>
33032 +#include <sched.h>
33033 +#include <termios.h>
33034 +#include <string.h>
33035 +#include "user_util.h"
33036 +#include "kern_util.h"
33038 +#include "mem_user.h"
33040 +#include "helper.h"
33041 +#include "uml-config.h"
33043 +#define COMMAND_LINE_SIZE _POSIX_ARG_MAX
33045 +/* Changed in linux_main and setup_arch, which run before SMP is started */
33046 +char saved_command_line[COMMAND_LINE_SIZE] = { 0 };
33047 +char command_line[COMMAND_LINE_SIZE] = { 0 };
33049 +void add_arg(char *cmd_line, char *arg)
33051 + if (strlen(cmd_line) + strlen(arg) + 1 > COMMAND_LINE_SIZE) {
33052 + printf("add_arg: Too much command line!\n");
33055 + if(strlen(cmd_line) > 0) strcat(cmd_line, " ");
33056 + strcat(cmd_line, arg);
33061 + while(1) sleep(1000000);
33064 +void stack_protections(unsigned long address)
33066 + int prot = PROT_READ | PROT_WRITE | PROT_EXEC;
33068 + if(mprotect((void *) address, page_size(), prot) < 0)
33069 + panic("protecting stack failed, errno = %d", errno);
33072 +void task_protections(unsigned long address)
33074 + unsigned long guard = address + page_size();
33075 + unsigned long stack = guard + page_size();
33076 + int prot = 0, pages;
33078 + if(mprotect((void *) guard, page_size(), prot) < 0)
33079 + panic("protecting guard page failed, errno = %d", errno);
33081 + pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER) - 2;
33082 + prot = PROT_READ | PROT_WRITE | PROT_EXEC;
33083 + if(mprotect((void *) stack, pages * page_size(), prot) < 0)
33084 + panic("protecting stack failed, errno = %d", errno);
33087 +int wait_for_stop(int pid, int sig, int cont_type, void *relay)
33089 + sigset_t *relay_signals = relay;
33093 + ret = waitpid(pid, &status, WUNTRACED);
33095 + !WIFSTOPPED(status) || (WSTOPSIG(status) != sig)){
33097 + if(errno == EINTR) continue;
33098 + printk("wait failed, errno = %d\n",
33101 + else if(WIFEXITED(status))
33102 + printk("process exited with status %d\n",
33103 + WEXITSTATUS(status));
33104 + else if(WIFSIGNALED(status))
33105 + printk("process exited with signal %d\n",
33106 + WTERMSIG(status));
33107 + else if((WSTOPSIG(status) == SIGVTALRM) ||
33108 + (WSTOPSIG(status) == SIGALRM) ||
33109 + (WSTOPSIG(status) == SIGIO) ||
33110 + (WSTOPSIG(status) == SIGPROF) ||
33111 + (WSTOPSIG(status) == SIGCHLD) ||
33112 + (WSTOPSIG(status) == SIGWINCH) ||
33113 + (WSTOPSIG(status) == SIGINT)){
33114 + ptrace(cont_type, pid, 0, WSTOPSIG(status));
33117 + else if((relay_signals != NULL) &&
33118 + sigismember(relay_signals, WSTOPSIG(status))){
33119 + ptrace(cont_type, pid, 0, WSTOPSIG(status));
33122 + else printk("process stopped with signal %d\n",
33123 + WSTOPSIG(status));
33124 + panic("wait_for_stop failed to wait for %d to stop "
33125 + "with %d\n", pid, sig);
33131 +int raw(int fd, int complain)
33133 + struct termios tt;
33136 + tcgetattr(fd, &tt);
33138 + err = tcsetattr(fd, TCSANOW, &tt);
33139 + if((err < 0) && complain){
33140 + printk("tcsetattr failed, errno = %d\n", errno);
33146 +void setup_machinename(char *machine_out)
33148 + struct utsname host;
33151 + strcpy(machine_out, host.machine);
33154 +char host_info[(_UTSNAME_LENGTH + 1) * 4 + _UTSNAME_NODENAME_LENGTH + 1];
33156 +void setup_hostinfo(void)
33158 + struct utsname host;
33161 + sprintf(host_info, "%s %s %s %s %s", host.sysname, host.nodename,
33162 + host.release, host.version, host.machine);
33166 + * Overrides for Emacs so that we follow Linus's tabbing style.
33167 + * Emacs will notice this stuff at the end of the file and automatically
33168 + * adjust the settings for this buffer only. This must remain at the end
33170 + * ---------------------------------------------------------------------------
33171 + * Local variables:
33172 + * c-file-style: "linux"
33175 diff -Naur -X ../exclude-files orig/arch/um/link.ld.in um/arch/um/link.ld.in
33176 --- orig/arch/um/link.ld.in 1969-12-31 19:00:00.000000000 -0500
33177 +++ um/arch/um/link.ld.in 2003-10-21 03:26:07.000000000 -0400
33179 +OUTPUT_FORMAT("ELF_FORMAT")
33180 +OUTPUT_ARCH(ELF_ARCH)
33185 + . = START() + SIZEOF_HEADERS;
33187 + __binary_start = .;
33188 +ifdef(`MODE_TT', `
33189 + .thread_private : {
33190 + __start_thread_private = .;
33193 + arch/um/kernel/tt/unmap_fin.o (.data)
33194 + __end_thread_private = .;
33197 + .remap : { arch/um/kernel/tt/unmap_fin.o (.text) }
33199 + . = ALIGN(4096); /* Init code and data */
33201 + __init_begin = .;
33202 + .text.init : { *(.text.init) }
33207 + /* .gnu.warning sections are handled specially by elf32.em. */
33209 + *(.gnu.linkonce.t*)
33211 + .fini : { *(.fini) } =0x9090
33212 + .rodata : { *(.rodata) *(.gnu.linkonce.r*) }
33213 + .rodata1 : { *(.rodata1) }
33215 + PROVIDE (etext = .);
33218 + PROVIDE (_sdata = .);
33220 +include(`arch/um/common.ld.in')
33224 + . = ALIGN(KERNEL_STACK_SIZE); /* init_task */
33225 + *(.data.init_task)
33227 + *(.gnu.linkonce.d*)
33230 + .data1 : { *(.data1) }
33240 + .got : { *(.got.plt) *(.got) }
33241 + .dynamic : { *(.dynamic) }
33242 + /* We want the small data sections together, so single-instruction offsets
33243 + can access them all, and initialized data all before uninitialized, so
33244 + we can shorten the on-disk segment size. */
33245 + .sdata : { *(.sdata) }
33247 + PROVIDE (edata = .);
33248 + . = ALIGN(0x1000);
33252 + PROVIDE(_bss_start = .);
33263 + PROVIDE (end = .);
33264 + /* Stabs debugging sections. */
33265 + .stab 0 : { *(.stab) }
33266 + .stabstr 0 : { *(.stabstr) }
33267 + .stab.excl 0 : { *(.stab.excl) }
33268 + .stab.exclstr 0 : { *(.stab.exclstr) }
33269 + .stab.index 0 : { *(.stab.index) }
33270 + .stab.indexstr 0 : { *(.stab.indexstr) }
33271 + .comment 0 : { *(.comment) }
33273 diff -Naur -X ../exclude-files orig/arch/um/main.c um/arch/um/main.c
33274 --- orig/arch/um/main.c 1969-12-31 19:00:00.000000000 -0500
33275 +++ um/arch/um/main.c 2004-01-29 00:48:42.000000000 -0500
33278 + * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
33279 + * Licensed under the GPL
33282 +#include <unistd.h>
33283 +#include <stdio.h>
33284 +#include <stdlib.h>
33285 +#include <string.h>
33286 +#include <signal.h>
33287 +#include <errno.h>
33288 +#include <sys/resource.h>
33289 +#include <sys/mman.h>
33290 +#include <sys/user.h>
33291 +#include <asm/page.h>
33292 +#include "user_util.h"
33293 +#include "kern_util.h"
33294 +#include "mem_user.h"
33295 +#include "signal_user.h"
33299 +#include "choose-mode.h"
33300 +#include "uml-config.h"
33302 +/* Set in set_stklim, which is called from main and __wrap_malloc.
33303 + * __wrap_malloc only calls it if main hasn't started.
33305 +unsigned long stacksizelim;
33310 +#define PGD_BOUND (4 * 1024 * 1024)
33311 +#define STACKSIZE (8 * 1024 * 1024)
33312 +#define THREAD_NAME_LEN (256)
33314 +static void set_stklim(void)
33316 + struct rlimit lim;
33318 + if(getrlimit(RLIMIT_STACK, &lim) < 0){
33319 + perror("getrlimit");
33322 + if((lim.rlim_cur == RLIM_INFINITY) || (lim.rlim_cur > STACKSIZE)){
33323 + lim.rlim_cur = STACKSIZE;
33324 + if(setrlimit(RLIMIT_STACK, &lim) < 0){
33325 + perror("setrlimit");
33329 + stacksizelim = (lim.rlim_cur + PGD_BOUND - 1) & ~(PGD_BOUND - 1);
33332 +static __init void do_uml_initcalls(void)
33334 + initcall_t *call;
33336 + call = &__uml_initcall_start;
33337 + while (call < &__uml_initcall_end){;
33343 +static void last_ditch_exit(int sig)
33345 + CHOOSE_MODE(kmalloc_ok = 0, (void) 0);
33346 + signal(SIGINT, SIG_DFL);
33347 + signal(SIGTERM, SIG_DFL);
33348 + signal(SIGHUP, SIG_DFL);
33353 +extern int uml_exitcode;
33355 +int main(int argc, char **argv, char **envp)
33361 + /* Enable all signals except SIGIO - in some environments, we can
33362 + * enter with some signals blocked
33365 + sigemptyset(&mask);
33366 + sigaddset(&mask, SIGIO);
33367 + if(sigprocmask(SIG_SETMASK, &mask, NULL) < 0){
33368 + perror("sigprocmask");
33372 +#ifdef UML_CONFIG_MODE_TT
33373 + /* Allocate memory for thread command lines */
33374 + if(argc < 2 || strlen(argv[1]) < THREAD_NAME_LEN - 1){
33376 + char padding[THREAD_NAME_LEN] = {
33377 + [ 0 ... THREAD_NAME_LEN - 2] = ' ', '\0'
33380 + new_argv = malloc((argc + 2) * sizeof(char*));
33382 + perror("Allocating extended argv");
33386 + new_argv[0] = argv[0];
33387 + new_argv[1] = padding;
33389 + for(i = 2; i <= argc; i++)
33390 + new_argv[i] = argv[i - 1];
33391 + new_argv[argc + 1] = NULL;
33393 + execvp(new_argv[0], new_argv);
33394 + perror("execing with extended args");
33399 + linux_prog = argv[0];
33403 + new_argv = malloc((argc + 1) * sizeof(char *));
33404 + if(new_argv == NULL){
33405 + perror("Mallocing argv");
33408 + for(i=0;i<argc;i++){
33409 + new_argv[i] = strdup(argv[i]);
33410 + if(new_argv[i] == NULL){
33411 + perror("Mallocing an arg");
33415 + new_argv[argc] = NULL;
33417 + set_handler(SIGINT, last_ditch_exit, SA_ONESHOT | SA_NODEFER, -1);
33418 + set_handler(SIGTERM, last_ditch_exit, SA_ONESHOT | SA_NODEFER, -1);
33419 + set_handler(SIGHUP, last_ditch_exit, SA_ONESHOT | SA_NODEFER, -1);
33421 + do_uml_initcalls();
33422 + ret = linux_main(argc, argv);
33428 + execvp(new_argv[0], new_argv);
33429 + perror("Failed to exec kernel");
33433 + return(uml_exitcode);
33436 +#define CAN_KMALLOC() \
33437 + (kmalloc_ok && CHOOSE_MODE((getpid() != tracing_pid), 1))
33439 +extern void *__real_malloc(int);
33441 +void *__wrap_malloc(int size)
33443 + if(CAN_KMALLOC())
33444 + return(um_kmalloc(size));
33446 + return(__real_malloc(size));
33449 +void *__wrap_calloc(int n, int size)
33451 + void *ptr = __wrap_malloc(n * size);
33453 + if(ptr == NULL) return(NULL);
33454 + memset(ptr, 0, n * size);
33458 +extern void __real_free(void *);
33460 +void __wrap_free(void *ptr)
33462 + if(CAN_KMALLOC()) kfree(ptr);
33463 + else __real_free(ptr);
33467 + * Overrides for Emacs so that we follow Linus's tabbing style.
33468 + * Emacs will notice this stuff at the end of the file and automatically
33469 + * adjust the settings for this buffer only. This must remain at the end
33471 + * ---------------------------------------------------------------------------
33472 + * Local variables:
33473 + * c-file-style: "linux"
33476 diff -Naur -X ../exclude-files orig/arch/um/Makefile um/arch/um/Makefile
33477 --- orig/arch/um/Makefile 1969-12-31 19:00:00.000000000 -0500
33478 +++ um/arch/um/Makefile 2004-02-14 06:26:41.000000000 -0500
33481 +# Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
33482 +# Licensed under the GPL
33485 +OS := $(shell uname -s)
33487 +ARCH_DIR = arch/um
33489 +core-y := kernel sys-$(SUBARCH) os-$(OS)
33490 +drivers-y := fs drivers
33491 +subdir-y := $(core-y) $(drivers-y)
33492 +SUBDIRS += $(foreach dir,$(subdir-y),$(ARCH_DIR)/$(dir))
33494 +CORE_FILES += $(foreach dir,$(core-y),$(ARCH_DIR)/$(dir)/built-in.o)
33495 +DRIVERS += $(foreach dir,$(drivers-y),$(ARCH_DIR)/$(dir)/built-in.o)
33497 +include $(ARCH_DIR)/Makefile-$(SUBARCH)
33498 +include $(ARCH_DIR)/Makefile-os-$(OS)
33500 +MAKEFILE-$(CONFIG_MODE_TT) += Makefile-tt
33501 +MAKEFILE-$(CONFIG_MODE_SKAS) += Makefile-skas
33503 +ifneq ($(MAKEFILE-y),)
33504 + include $(addprefix $(ARCH_DIR)/,$(MAKEFILE-y))
33507 +EXTRAVERSION := $(EXTRAVERSION)-1um
33509 +include/linux/version.h: arch/$(ARCH)/Makefile
33511 +# Recalculate MODLIB to reflect the EXTRAVERSION changes (via KERNELRELEASE)
33512 +# The way the toplevel Makefile is written EXTRAVERSION is not supposed
33513 +# to be changed outside the toplevel Makefile, but recalculating MODLIB is
33514 +# a sufficient workaround until we no longer need architecture dependent
33516 +MODLIB := $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
33518 +ifeq ($(CONFIG_DEBUGSYM),y)
33519 +CFLAGS := $(subst -fomit-frame-pointer,,$(CFLAGS))
33522 +CFLAGS-$(CONFIG_DEBUGSYM) += -g
33524 +ARCH_INCLUDE = -I$(TOPDIR)/$(ARCH_DIR)/include
33526 +# -Derrno=kernel_errno - This turns all kernel references to errno into
33527 +# kernel_errno to separate them from the libc errno. This allows -fno-common
33528 +# in CFLAGS. Otherwise, it would cause ld to complain about the two different
33531 +CFLAGS += $(ARCH_CFLAGS) $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \
33532 + -D_LARGEFILE64_SOURCE $(ARCH_INCLUDE) -Derrno=kernel_errno \
33537 +LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
33539 +# These are needed for clean and mrproper, since in that case .config is not
33540 +# included; the values here are meaningless
33542 +CONFIG_NEST_LEVEL ?= 0
33543 +CONFIG_KERNEL_HALF_GIGS ?= 0
33545 +SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000)
33547 +# These aren't in Makefile-tt because they are needed in the !CONFIG_MODE_TT +
33548 +# CONFIG_MODE_SKAS + CONFIG_STATIC_LINK case.
33551 +LD_SCRIPT_TT := link.ld
33553 +ifeq ($(CONFIG_STATIC_LINK),y)
33554 + LINK-y += $(LINK_TT)
33555 + LD_SCRIPT-y := $(LD_SCRIPT_TT)
33557 +ifeq ($(CONFIG_MODE_TT),y)
33558 + LINK-y += $(LINK_TT)
33559 + LD_SCRIPT-y := $(LD_SCRIPT_TT)
33561 +ifeq ($(CONFIG_MODE_SKAS),y)
33562 + LINK-y += $(LINK_SKAS)
33563 + LD_SCRIPT-y := $(LD_SCRIPT_SKAS)
33568 +LD_SCRIPT-y := $(ARCH_DIR)/$(LD_SCRIPT-y)
33569 +M4_MODE_TT := $(shell [ "$(CONFIG_MODE_TT)" = "y" ] && echo -DMODE_TT)
33571 +$(LD_SCRIPT-y): $(LD_SCRIPT-y).in
33572 + pages=$$(( 1 << $(CONFIG_KERNEL_STACK_ORDER) )) ; \
33573 + m4 -DSTART=$$(($(TOP_ADDR) - $(SIZE))) -DELF_ARCH=$(ELF_ARCH) \
33574 + -DELF_FORMAT=$(ELF_FORMAT) $(M4_MODE_TT) \
33575 + -DKERNEL_STACK_SIZE=$$(( 4096 * $$pages )) $< > $@
33577 +SYMLINK_HEADERS = archparam.h system.h sigcontext.h processor.h ptrace.h \
33579 +SYMLINK_HEADERS := $(foreach header,$(SYMLINK_HEADERS),include/asm-um/$(header))
33581 +ARCH_SYMLINKS = include/asm-um/arch arch/um/include/sysdep arch/um/os \
33582 + $(SYMLINK_HEADERS) $(ARCH_DIR)/include/uml-config.h
33584 +ifeq ($(CONFIG_MODE_SKAS), y)
33585 +$(SYS_HEADERS) : $(ARCH_DIR)/kernel/skas/include/skas_ptregs.h
33588 +GEN_HEADERS += $(ARCH_DIR)/include/task.h $(ARCH_DIR)/include/kern_constants.h
33590 +setup: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS)
33592 +linux: setup $(ARCH_DIR)/main.o vmlinux $(LD_SCRIPT-y)
33593 + mv vmlinux vmlinux.o
33594 + $(CC) -Wl,-T,$(LD_SCRIPT-y) $(LINK-y) $(LINK_WRAPS) \
33595 + -o linux $(ARCH_DIR)/main.o vmlinux.o -L/usr/lib -lutil
33597 +USER_CFLAGS := $(patsubst -I%,,$(CFLAGS))
33598 +USER_CFLAGS := $(patsubst -Derrno=kernel_errno,,$(USER_CFLAGS))
33599 +USER_CFLAGS := $(patsubst -D__KERNEL__,,$(USER_CFLAGS)) $(ARCH_INCLUDE) \
33602 +# To get a definition of F_SETSIG
33603 +USER_CFLAGS += -D_GNU_SOURCE
33605 +CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/link.ld $(ARCH_DIR)/dyn_link.ld \
33606 + $(GEN_HEADERS) $(ARCH_DIR)/include/uml-config.h
33608 +$(ARCH_DIR)/main.o: $(ARCH_DIR)/main.c
33609 + $(CC) $(USER_CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
33612 + rm -f $(SYMLINK_HEADERS) $(ARCH_SYMLINKS) include/asm \
33613 + $(LD_SCRIPT) $(addprefix $(ARCH_DIR)/kernel/,$(KERN_SYMLINKS))
33615 +archclean: sysclean
33616 + find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
33617 + -o -name '*.gcov' \) -type f -print | xargs rm -f
33618 + cd $(ARCH_DIR) ; \
33619 + for dir in $(subdir-y) util ; do $(MAKE) -C $$dir clean; done
33623 +$(SYMLINK_HEADERS):
33624 + cd $(TOPDIR)/$(dir $@) ; \
33625 + ln -sf $(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $(notdir $@)
33627 +include/asm-um/arch:
33628 + cd $(TOPDIR)/include/asm-um && ln -sf ../asm-$(SUBARCH) arch
33630 +arch/um/include/sysdep:
33631 + cd $(TOPDIR)/arch/um/include && ln -sf sysdep-$(SUBARCH) sysdep
33634 + cd $(ARCH_DIR) && ln -sf os-$(OS) os
33636 +$(ARCH_DIR)/include/task.h : $(ARCH_DIR)/util/mk_task
33639 +$(ARCH_DIR)/include/kern_constants.h : $(ARCH_DIR)/util/mk_constants
33642 +$(ARCH_DIR)/include/uml-config.h : $(TOPDIR)/include/linux/autoconf.h
33643 + sed 's/ CONFIG/ UML_CONFIG/' $(TOPDIR)/include/linux/autoconf.h > $@
33645 +$(ARCH_DIR)/util/mk_task : $(ARCH_DIR)/util/mk_task_user.c \
33646 + $(ARCH_DIR)/util/mk_task_kern.c $(SYS_HEADERS)
33647 + $(MAKE) $(MFLAGS) -C $(ARCH_DIR)/util mk_task
33649 +$(ARCH_DIR)/util/mk_constants : $(ARCH_DIR)/util/mk_constants_user.c \
33650 + $(ARCH_DIR)/util/mk_constants_kern.c
33651 + $(MAKE) $(MFLAGS) -C $(ARCH_DIR)/util mk_constants
33653 +export SUBARCH USER_CFLAGS OS
33654 diff -Naur -X ../exclude-files orig/arch/um/Makefile-i386 um/arch/um/Makefile-i386
33655 --- orig/arch/um/Makefile-i386 1969-12-31 19:00:00.000000000 -0500
33656 +++ um/arch/um/Makefile-i386 2003-10-21 03:26:07.000000000 -0400
33658 +ifeq ($(CONFIG_HOST_2G_2G), y)
33659 +TOP_ADDR = 0x80000000
33661 +TOP_ADDR = 0xc0000000
33664 +ARCH_CFLAGS = -U__$(SUBARCH)__ -U$(SUBARCH) -DUM_FASTCALL
33665 +ELF_ARCH = $(SUBARCH)
33666 +ELF_FORMAT = elf32-$(SUBARCH)
33668 +I386_H = $(ARCH_DIR)/include/sysdep-i386
33669 +SYS = $(ARCH_DIR)/sys-i386
33670 +UTIL = $(SYS)/util
33671 +SUBDIRS += $(UTIL)
33673 +SYS_HEADERS = $(I386_H)/sc.h $(I386_H)/thread.h
33675 +$(I386_H)/sc.h : $(UTIL)/mk_sc
33676 + $(UTIL)/mk_sc > $@
33678 +$(I386_H)/thread.h : $(UTIL)/mk_thread
33679 + $(UTIL)/mk_thread > $@
33681 +$(UTIL)/mk_sc : $(UTIL)/mk_sc.c
33682 + $(MAKE) -C $(UTIL) mk_sc
33684 +$(UTIL)/mk_thread : $(UTIL)/mk_thread_user.c $(UTIL)/mk_thread_kern.c \
33686 + $(MAKE) -C $(UTIL) mk_thread
33689 + rm -f $(SYS_HEADERS)
33690 + $(MAKE) -C $(UTIL) clean
33691 + $(MAKE) -C $(SYS) clean
33693 diff -Naur -X ../exclude-files orig/arch/um/Makefile-ia64 um/arch/um/Makefile-ia64
33694 --- orig/arch/um/Makefile-ia64 1969-12-31 19:00:00.000000000 -0500
33695 +++ um/arch/um/Makefile-ia64 2003-10-21 03:26:07.000000000 -0400
33697 +START_ADDR = 0x1000000000000000
33698 diff -Naur -X ../exclude-files orig/arch/um/Makefile-os-Linux um/arch/um/Makefile-os-Linux
33699 --- orig/arch/um/Makefile-os-Linux 1969-12-31 19:00:00.000000000 -0500
33700 +++ um/arch/um/Makefile-os-Linux 2003-10-21 03:26:07.000000000 -0400
33703 +# Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
33704 +# Licensed under the GPL
33707 +SUBDIRS += $(ARCH_DIR)/os-$(OS)/drivers
33708 +DRIVERS += $(ARCH_DIR)/os-$(OS)/drivers/drivers.o
33709 diff -Naur -X ../exclude-files orig/arch/um/Makefile-ppc um/arch/um/Makefile-ppc
33710 --- orig/arch/um/Makefile-ppc 1969-12-31 19:00:00.000000000 -0500
33711 +++ um/arch/um/Makefile-ppc 2003-10-21 03:26:07.000000000 -0400
33713 +ifeq ($(CONFIG_HOST_2G_2G), y)
33714 +START_ADDR = 0x80000000
33716 +START_ADDR = 0xc0000000
33718 +ARCH_CFLAGS = -U__powerpc__ -D__UM_PPC__
33720 +# The arch is ppc, but the elf32 name is powerpc
33721 +ELF_SUBARCH = powerpc
33722 diff -Naur -X ../exclude-files orig/arch/um/Makefile-skas um/arch/um/Makefile-skas
33723 --- orig/arch/um/Makefile-skas 1969-12-31 19:00:00.000000000 -0500
33724 +++ um/arch/um/Makefile-skas 2003-10-21 03:26:07.000000000 -0400
33727 +# Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
33728 +# Licensed under the GPL
33733 +CFLAGS-$(CONFIG_GCOV) += -fprofile-arcs -ftest-coverage
33734 +CFLAGS-$(CONFIG_GPROF) += $(PROFILE)
33735 +LINK-$(CONFIG_GPROF) += $(PROFILE)
33737 +MODE_INCLUDE += -I$(TOPDIR)/$(ARCH_DIR)/kernel/skas/include
33739 +LINK_SKAS = -Wl,-rpath,/lib
33740 +LD_SCRIPT_SKAS = dyn_link.ld
33742 +GEN_HEADERS += $(ARCH_DIR)/kernel/skas/include/skas_ptregs.h
33744 +$(ARCH_DIR)/kernel/skas/include/skas_ptregs.h :
33745 + $(MAKE) -C $(ARCH_DIR)/kernel/skas include/skas_ptregs.h
33746 diff -Naur -X ../exclude-files orig/arch/um/Makefile-tt um/arch/um/Makefile-tt
33747 --- orig/arch/um/Makefile-tt 1969-12-31 19:00:00.000000000 -0500
33748 +++ um/arch/um/Makefile-tt 2003-10-21 03:26:07.000000000 -0400
33751 +# Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
33752 +# Licensed under the GPL
33755 +MODE_INCLUDE += -I$(TOPDIR)/$(ARCH_DIR)/kernel/tt/include
33757 diff -Naur -X ../exclude-files orig/arch/um/os-Linux/drivers/etap.h um/arch/um/os-Linux/drivers/etap.h
33758 --- orig/arch/um/os-Linux/drivers/etap.h 1969-12-31 19:00:00.000000000 -0500
33759 +++ um/arch/um/os-Linux/drivers/etap.h 2003-10-21 03:26:07.000000000 -0400
33762 + * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
33763 + * Licensed under the GPL
33766 +#include "net_user.h"
33768 +struct ethertap_data {
33776 +extern struct net_user_info ethertap_user_info;
33779 + * Overrides for Emacs so that we follow Linus's tabbing style.
33780 + * Emacs will notice this stuff at the end of the file and automatically
33781 + * adjust the settings for this buffer only. This must remain at the end
33783 + * ---------------------------------------------------------------------------
33784 + * Local variables:
33785 + * c-file-style: "linux"
33788 diff -Naur -X ../exclude-files orig/arch/um/os-Linux/drivers/ethertap_kern.c um/arch/um/os-Linux/drivers/ethertap_kern.c
33789 --- orig/arch/um/os-Linux/drivers/ethertap_kern.c 1969-12-31 19:00:00.000000000 -0500
33790 +++ um/arch/um/os-Linux/drivers/ethertap_kern.c 2003-10-21 03:26:07.000000000 -0400
33793 + * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
33794 + * James Leu (jleu@mindspring.net).
33795 + * Copyright (C) 2001 by various other people who didn't put their name here.
33796 + * Licensed under the GPL.
33799 +#include "linux/init.h"
33800 +#include "linux/netdevice.h"
33801 +#include "linux/etherdevice.h"
33802 +#include "linux/init.h"
33803 +#include "net_kern.h"
33804 +#include "net_user.h"
33807 +struct ethertap_init {
33812 +static void etap_init(struct net_device *dev, void *data)
33814 + struct uml_net_private *pri;
33815 + struct ethertap_data *epri;
33816 + struct ethertap_init *init = data;
33818 + init_etherdev(dev, 0);
33820 + epri = (struct ethertap_data *) pri->user;
33821 + *epri = ((struct ethertap_data)
33822 + { .dev_name = init->dev_name,
33823 + .gate_addr = init->gate_addr,
33825 + .control_fd = -1,
33828 + printk("ethertap backend - %s", epri->dev_name);
33829 + if(epri->gate_addr != NULL)
33830 + printk(", IP = %s", epri->gate_addr);
33834 +static int etap_read(int fd, struct sk_buff **skb, struct uml_net_private *lp)
33838 + *skb = ether_adjust_skb(*skb, ETH_HEADER_ETHERTAP);
33839 + if(*skb == NULL) return(-ENOMEM);
33840 + len = net_recvfrom(fd, (*skb)->mac.raw,
33841 + (*skb)->dev->mtu + 2 * ETH_HEADER_ETHERTAP);
33842 + if(len <= 0) return(len);
33843 + skb_pull(*skb, 2);
33848 +static int etap_write(int fd, struct sk_buff **skb, struct uml_net_private *lp)
33850 + if(skb_headroom(*skb) < 2){
33851 + struct sk_buff *skb2;
33853 + skb2 = skb_realloc_headroom(*skb, 2);
33854 + dev_kfree_skb(*skb);
33855 + if (skb2 == NULL) return(-ENOMEM);
33858 + skb_push(*skb, 2);
33859 + return(net_send(fd, (*skb)->data, (*skb)->len));
33862 +struct net_kern_info ethertap_kern_info = {
33863 + .init = etap_init,
33864 + .protocol = eth_protocol,
33865 + .read = etap_read,
33866 + .write = etap_write,
33869 +int ethertap_setup(char *str, char **mac_out, void *data)
33871 + struct ethertap_init *init = data;
33873 + *init = ((struct ethertap_init)
33874 + { .dev_name = NULL,
33875 + .gate_addr = NULL });
33876 + if(tap_setup_common(str, "ethertap", &init->dev_name, mac_out,
33877 + &init->gate_addr))
33879 + if(init->dev_name == NULL){
33880 + printk("ethertap_setup : Missing tap device name\n");
33887 +static struct transport ethertap_transport = {
33888 + .list = LIST_HEAD_INIT(ethertap_transport.list),
33889 + .name = "ethertap",
33890 + .setup = ethertap_setup,
33891 + .user = ðertap_user_info,
33892 + .kern = ðertap_kern_info,
33893 + .private_size = sizeof(struct ethertap_data),
33896 +static int register_ethertap(void)
33898 + register_transport(ðertap_transport);
33902 +__initcall(register_ethertap);
33905 + * Overrides for Emacs so that we follow Linus's tabbing style.
33906 + * Emacs will notice this stuff at the end of the file and automatically
33907 + * adjust the settings for this buffer only. This must remain at the end
33909 + * ---------------------------------------------------------------------------
33910 + * Local variables:
33911 + * c-file-style: "linux"
33914 diff -Naur -X ../exclude-files orig/arch/um/os-Linux/drivers/ethertap_user.c um/arch/um/os-Linux/drivers/ethertap_user.c
33915 --- orig/arch/um/os-Linux/drivers/ethertap_user.c 1969-12-31 19:00:00.000000000 -0500
33916 +++ um/arch/um/os-Linux/drivers/ethertap_user.c 2003-10-21 03:26:07.000000000 -0400
33919 + * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
33920 + * James Leu (jleu@mindspring.net).
33921 + * Copyright (C) 2001 by various other people who didn't put their name here.
33922 + * Licensed under the GPL.
33925 +#include <stdio.h>
33926 +#include <unistd.h>
33927 +#include <stddef.h>
33928 +#include <stdlib.h>
33929 +#include <sys/errno.h>
33930 +#include <sys/socket.h>
33931 +#include <sys/wait.h>
33932 +#include <sys/un.h>
33933 +#include <net/if.h>
33935 +#include "kern_util.h"
33936 +#include "net_user.h"
33938 +#include "helper.h"
33941 +#define MAX_PACKET ETH_MAX_PACKET
33943 +void etap_user_init(void *data, void *dev)
33945 + struct ethertap_data *pri = data;
33950 +struct addr_change {
33951 + enum { ADD_ADDR, DEL_ADDR } what;
33952 + unsigned char addr[4];
33953 + unsigned char netmask[4];
33956 +static void etap_change(int op, unsigned char *addr, unsigned char *netmask,
33959 + struct addr_change change;
33963 + change.what = op;
33964 + memcpy(change.addr, addr, sizeof(change.addr));
33965 + memcpy(change.netmask, netmask, sizeof(change.netmask));
33966 + n = os_write_file(fd, &change, sizeof(change));
33967 + if(n != sizeof(change))
33968 + printk("etap_change - request failed, err = %d\n", -n);
33969 + output = um_kmalloc(page_size());
33970 + if(output == NULL)
33971 + printk("etap_change : Failed to allocate output buffer\n");
33972 + read_output(fd, output, page_size());
33973 + if(output != NULL){
33974 + printk("%s", output);
33979 +static void etap_open_addr(unsigned char *addr, unsigned char *netmask,
33982 + etap_change(ADD_ADDR, addr, netmask, *((int *) arg));
33985 +static void etap_close_addr(unsigned char *addr, unsigned char *netmask,
33988 + etap_change(DEL_ADDR, addr, netmask, *((int *) arg));
33991 +struct etap_pre_exec_data {
33992 + int control_remote;
33997 +static void etap_pre_exec(void *arg)
33999 + struct etap_pre_exec_data *data = arg;
34001 + dup2(data->control_remote, 1);
34002 + os_close_file(data->data_me);
34003 + os_close_file(data->control_me);
34006 +static int etap_tramp(char *dev, char *gate, int control_me,
34007 + int control_remote, int data_me, int data_remote)
34009 + struct etap_pre_exec_data pe_data;
34010 + int pid, status, err, n;
34011 + char version_buf[sizeof("nnnnn\0")];
34012 + char data_fd_buf[sizeof("nnnnnn\0")];
34013 + char gate_buf[sizeof("nnn.nnn.nnn.nnn\0")];
34014 + char *setup_args[] = { "uml_net", version_buf, "ethertap", dev,
34015 + data_fd_buf, gate_buf, NULL };
34016 + char *nosetup_args[] = { "uml_net", version_buf, "ethertap",
34017 + dev, data_fd_buf, NULL };
34020 + sprintf(data_fd_buf, "%d", data_remote);
34021 + sprintf(version_buf, "%d", UML_NET_VERSION);
34022 + if(gate != NULL){
34023 + strcpy(gate_buf, gate);
34024 + args = setup_args;
34026 + else args = nosetup_args;
34029 + pe_data.control_remote = control_remote;
34030 + pe_data.control_me = control_me;
34031 + pe_data.data_me = data_me;
34032 + pid = run_helper(etap_pre_exec, &pe_data, args, NULL);
34034 + if(pid < 0) err = pid;
34035 + os_close_file(data_remote);
34036 + os_close_file(control_remote);
34037 + n = os_read_file(control_me, &c, sizeof(c));
34038 + if(n != sizeof(c)){
34039 + printk("etap_tramp : read of status failed, err = %d\n", -n);
34043 + printk("etap_tramp : uml_net failed\n");
34045 + if(waitpid(pid, &status, 0) < 0)
34047 + else if(!WIFEXITED(status) || (WEXITSTATUS(status) != 1))
34048 + printk("uml_net didn't exit with status 1\n");
34053 +static int etap_open(void *data)
34055 + struct ethertap_data *pri = data;
34057 + int data_fds[2], control_fds[2], err, output_len;
34059 + err = tap_open_common(pri->dev, pri->gate_addr);
34060 + if(err) return(err);
34062 + err = os_pipe(data_fds, 0, 0);
34064 + printk("data os_pipe failed - err = %d\n", -err);
34068 + err = os_pipe(control_fds, 1, 0);
34070 + printk("control os_pipe failed - err = %d\n", -err);
34074 + err = etap_tramp(pri->dev_name, pri->gate_addr, control_fds[0],
34075 + control_fds[1], data_fds[0], data_fds[1]);
34076 + output_len = page_size();
34077 + output = um_kmalloc(output_len);
34078 + read_output(control_fds[0], output, output_len);
34080 + if(output == NULL)
34081 + printk("etap_open : failed to allocate output buffer\n");
34083 + printk("%s", output);
34088 + printk("etap_tramp failed - err = %d\n", -err);
34092 + pri->data_fd = data_fds[0];
34093 + pri->control_fd = control_fds[0];
34094 + iter_addresses(pri->dev, etap_open_addr, &pri->control_fd);
34095 + return(data_fds[0]);
34098 +static void etap_close(int fd, void *data)
34100 + struct ethertap_data *pri = data;
34102 + iter_addresses(pri->dev, etap_close_addr, &pri->control_fd);
34103 + os_close_file(fd);
34104 + os_shutdown_socket(pri->data_fd, 1, 1);
34105 + os_close_file(pri->data_fd);
34106 + pri->data_fd = -1;
34107 + os_close_file(pri->control_fd);
34108 + pri->control_fd = -1;
34111 +static int etap_set_mtu(int mtu, void *data)
34116 +static void etap_add_addr(unsigned char *addr, unsigned char *netmask,
34119 + struct ethertap_data *pri = data;
34121 + tap_check_ips(pri->gate_addr, addr);
34122 + if(pri->control_fd == -1) return;
34123 + etap_open_addr(addr, netmask, &pri->control_fd);
34126 +static void etap_del_addr(unsigned char *addr, unsigned char *netmask,
34129 + struct ethertap_data *pri = data;
34131 + if(pri->control_fd == -1) return;
34132 + etap_close_addr(addr, netmask, &pri->control_fd);
34135 +struct net_user_info ethertap_user_info = {
34136 + .init = etap_user_init,
34137 + .open = etap_open,
34138 + .close = etap_close,
34140 + .set_mtu = etap_set_mtu,
34141 + .add_address = etap_add_addr,
34142 + .delete_address = etap_del_addr,
34143 + .max_packet = MAX_PACKET - ETH_HEADER_ETHERTAP
34147 + * Overrides for Emacs so that we follow Linus's tabbing style.
34148 + * Emacs will notice this stuff at the end of the file and automatically
34149 + * adjust the settings for this buffer only. This must remain at the end
34151 + * ---------------------------------------------------------------------------
34152 + * Local variables:
34153 + * c-file-style: "linux"
34156 diff -Naur -X ../exclude-files orig/arch/um/os-Linux/drivers/Makefile um/arch/um/os-Linux/drivers/Makefile
34157 --- orig/arch/um/os-Linux/drivers/Makefile 1969-12-31 19:00:00.000000000 -0500
34158 +++ um/arch/um/os-Linux/drivers/Makefile 2003-10-21 03:26:07.000000000 -0400
34161 +# Copyright (C) 2000, 2002 Jeff Dike (jdike@karaya.com)
34162 +# Licensed under the GPL
34165 +O_TARGET := drivers.o
34167 +list-multi := tuntap.o ethertap.o
34169 +ethertap-objs := ethertap_kern.o ethertap_user.o
34170 +tuntap-objs := tuntap_kern.o tuntap_user.o
34173 +obj-$(CONFIG_UML_NET_ETHERTAP) += ethertap.o
34174 +obj-$(CONFIG_UML_NET_TUNTAP) += tuntap.o
34176 +USER_SINGLE_OBJS = $(foreach f,$(patsubst %.o,%,$(obj-y)),$($(f)-objs))
34178 +USER_OBJS = $(filter %_user.o,$(obj-y) $(USER_SINGLE_OBJS))
34180 +include $(TOPDIR)/Rules.make
34182 +$(USER_OBJS) : %.o: %.c
34183 + $(CC) $(CFLAGS_$@) $(USER_CFLAGS) -c -o $@ $<
34185 +ethertap.o : $(ethertap-objs)
34187 +tuntap.o : $(tuntap-objs)
34189 +$(list-multi) : # This doesn't work, but should : '%.o : $(%-objs)'
34190 + $(LD) $(LD_RFLAG) -r -o $@ $($(patsubst %.o,%,$@)-objs)
34191 diff -Naur -X ../exclude-files orig/arch/um/os-Linux/drivers/tuntap.h um/arch/um/os-Linux/drivers/tuntap.h
34192 --- orig/arch/um/os-Linux/drivers/tuntap.h 1969-12-31 19:00:00.000000000 -0500
34193 +++ um/arch/um/os-Linux/drivers/tuntap.h 2003-10-21 03:26:07.000000000 -0400
34196 + * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
34197 + * Licensed under the GPL
34200 +#ifndef __UM_TUNTAP_H
34201 +#define __UM_TUNTAP_H
34203 +#include "net_user.h"
34205 +struct tuntap_data {
34207 + int fixed_config;
34213 +extern struct net_user_info tuntap_user_info;
34218 + * Overrides for Emacs so that we follow Linus's tabbing style.
34219 + * Emacs will notice this stuff at the end of the file and automatically
34220 + * adjust the settings for this buffer only. This must remain at the end
34222 + * ---------------------------------------------------------------------------
34223 + * Local variables:
34224 + * c-file-style: "linux"
34227 diff -Naur -X ../exclude-files orig/arch/um/os-Linux/drivers/tuntap_kern.c um/arch/um/os-Linux/drivers/tuntap_kern.c
34228 --- orig/arch/um/os-Linux/drivers/tuntap_kern.c 1969-12-31 19:00:00.000000000 -0500
34229 +++ um/arch/um/os-Linux/drivers/tuntap_kern.c 2003-10-21 03:26:07.000000000 -0400
34232 + * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
34233 + * Licensed under the GPL
34236 +#include "linux/stddef.h"
34237 +#include "linux/netdevice.h"
34238 +#include "linux/etherdevice.h"
34239 +#include "linux/skbuff.h"
34240 +#include "linux/init.h"
34241 +#include "asm/errno.h"
34242 +#include "net_kern.h"
34243 +#include "net_user.h"
34244 +#include "tuntap.h"
34246 +struct tuntap_init {
34251 +static void tuntap_init(struct net_device *dev, void *data)
34253 + struct uml_net_private *pri;
34254 + struct tuntap_data *tpri;
34255 + struct tuntap_init *init = data;
34257 + init_etherdev(dev, 0);
34259 + tpri = (struct tuntap_data *) pri->user;
34260 + *tpri = ((struct tuntap_data)
34261 + { .dev_name = init->dev_name,
34262 + .fixed_config = (init->dev_name != NULL),
34263 + .gate_addr = init->gate_addr,
34266 + printk("TUN/TAP backend - ");
34267 + if(tpri->gate_addr != NULL)
34268 + printk("IP = %s", tpri->gate_addr);
34272 +static int tuntap_read(int fd, struct sk_buff **skb,
34273 + struct uml_net_private *lp)
34275 + *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER);
34276 + if(*skb == NULL) return(-ENOMEM);
34277 + return(net_read(fd, (*skb)->mac.raw,
34278 + (*skb)->dev->mtu + ETH_HEADER_OTHER));
34281 +static int tuntap_write(int fd, struct sk_buff **skb,
34282 + struct uml_net_private *lp)
34284 + return(net_write(fd, (*skb)->data, (*skb)->len));
34287 +struct net_kern_info tuntap_kern_info = {
34288 + .init = tuntap_init,
34289 + .protocol = eth_protocol,
34290 + .read = tuntap_read,
34291 + .write = tuntap_write,
34294 +int tuntap_setup(char *str, char **mac_out, void *data)
34296 + struct tuntap_init *init = data;
34298 + *init = ((struct tuntap_init)
34299 + { .dev_name = NULL,
34300 + .gate_addr = NULL });
34301 + if(tap_setup_common(str, "tuntap", &init->dev_name, mac_out,
34302 + &init->gate_addr))
34308 +static struct transport tuntap_transport = {
34309 + .list = LIST_HEAD_INIT(tuntap_transport.list),
34310 + .name = "tuntap",
34311 + .setup = tuntap_setup,
34312 + .user = &tuntap_user_info,
34313 + .kern = &tuntap_kern_info,
34314 + .private_size = sizeof(struct tuntap_data),
34315 + .setup_size = sizeof(struct tuntap_init),
34318 +static int register_tuntap(void)
34320 + register_transport(&tuntap_transport);
34324 +__initcall(register_tuntap);
34327 + * Overrides for Emacs so that we follow Linus's tabbing style.
34328 + * Emacs will notice this stuff at the end of the file and automatically
34329 + * adjust the settings for this buffer only. This must remain at the end
34331 + * ---------------------------------------------------------------------------
34332 + * Local variables:
34333 + * c-file-style: "linux"
34336 diff -Naur -X ../exclude-files orig/arch/um/os-Linux/drivers/tuntap_user.c um/arch/um/os-Linux/drivers/tuntap_user.c
34337 --- orig/arch/um/os-Linux/drivers/tuntap_user.c 1969-12-31 19:00:00.000000000 -0500
34338 +++ um/arch/um/os-Linux/drivers/tuntap_user.c 2003-11-12 00:02:30.000000000 -0500
34341 + * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
34342 + * Licensed under the GPL
34345 +#include <stdio.h>
34346 +#include <stddef.h>
34347 +#include <stdlib.h>
34348 +#include <unistd.h>
34349 +#include <errno.h>
34350 +#include <sys/wait.h>
34351 +#include <sys/socket.h>
34352 +#include <sys/un.h>
34353 +#include <sys/uio.h>
34354 +#include <sys/ioctl.h>
34355 +#include <net/if.h>
34356 +#include <linux/if_tun.h>
34357 +#include "net_user.h"
34358 +#include "tuntap.h"
34359 +#include "kern_util.h"
34361 +#include "helper.h"
34364 +#define MAX_PACKET ETH_MAX_PACKET
34366 +void tuntap_user_init(void *data, void *dev)
34368 + struct tuntap_data *pri = data;
34373 +static void tuntap_add_addr(unsigned char *addr, unsigned char *netmask,
34376 + struct tuntap_data *pri = data;
34378 + tap_check_ips(pri->gate_addr, addr);
34379 + if((pri->fd == -1) || pri->fixed_config) return;
34380 + open_addr(addr, netmask, pri->dev_name);
34383 +static void tuntap_del_addr(unsigned char *addr, unsigned char *netmask,
34386 + struct tuntap_data *pri = data;
34388 + if((pri->fd == -1) || pri->fixed_config) return;
34389 + close_addr(addr, netmask, pri->dev_name);
34392 +struct tuntap_pre_exec_data {
34397 +static void tuntap_pre_exec(void *arg)
34399 + struct tuntap_pre_exec_data *data = arg;
34401 + dup2(data->stdout, 1);
34402 + os_close_file(data->close_me);
34405 +static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote,
34406 + char *buffer, int buffer_len, int *used_out)
34408 + struct tuntap_pre_exec_data data;
34409 + char version_buf[sizeof("nnnnn\0")];
34410 + char *argv[] = { "uml_net", version_buf, "tuntap", "up", gate,
34412 + char buf[CMSG_SPACE(sizeof(*fd_out))];
34413 + struct msghdr msg;
34414 + struct cmsghdr *cmsg;
34415 + struct iovec iov;
34418 + sprintf(version_buf, "%d", UML_NET_VERSION);
34420 + data.stdout = remote;
34421 + data.close_me = me;
34423 + pid = run_helper(tuntap_pre_exec, &data, argv, NULL);
34425 + if(pid < 0) return(-pid);
34427 + os_close_file(remote);
34429 + msg.msg_name = NULL;
34430 + msg.msg_namelen = 0;
34431 + if(buffer != NULL){
34432 + iov = ((struct iovec) { buffer, buffer_len });
34433 + msg.msg_iov = &iov;
34434 + msg.msg_iovlen = 1;
34437 + msg.msg_iov = NULL;
34438 + msg.msg_iovlen = 0;
34440 + msg.msg_control = buf;
34441 + msg.msg_controllen = sizeof(buf);
34442 + msg.msg_flags = 0;
34443 + n = recvmsg(me, &msg, 0);
34446 + printk("tuntap_open_tramp : recvmsg failed - errno = %d\n",
34450 + waitpid(pid, NULL, 0);
34452 + cmsg = CMSG_FIRSTHDR(&msg);
34453 + if(cmsg == NULL){
34454 + printk("tuntap_open_tramp : didn't receive a message\n");
34457 + if((cmsg->cmsg_level != SOL_SOCKET) ||
34458 + (cmsg->cmsg_type != SCM_RIGHTS)){
34459 + printk("tuntap_open_tramp : didn't receive a descriptor\n");
34462 + *fd_out = ((int *) CMSG_DATA(cmsg))[0];
34466 +static int tuntap_open(void *data)
34468 + struct ifreq ifr;
34469 + struct tuntap_data *pri = data;
34470 + char *output, *buffer;
34471 + int err, fds[2], len, used;
34473 + err = tap_open_common(pri->dev, pri->gate_addr);
34477 + if(pri->fixed_config){
34478 + pri->fd = os_open_file("/dev/net/tun", of_rdwr(OPENFLAGS()), 0);
34480 + printk("Failed to open /dev/net/tun, err = %d\n",
34484 + memset(&ifr, 0, sizeof(ifr));
34485 + ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
34486 + strncpy(ifr.ifr_name, pri->dev_name, sizeof(ifr.ifr_name) - 1);
34487 + if(ioctl(pri->fd, TUNSETIFF, (void *) &ifr) < 0){
34488 + printk("TUNSETIFF failed, errno = %d\n", errno);
34489 + os_close_file(pri->fd);
34494 + err = os_pipe(fds, 0, 0);
34496 + printk("tuntap_open : os_pipe failed - err = %d\n",
34501 + buffer = get_output_buffer(&len);
34502 + if(buffer != NULL) len--;
34505 + err = tuntap_open_tramp(pri->gate_addr, &pri->fd, fds[0],
34506 + fds[1], buffer, len, &used);
34510 + printk("%s", output);
34511 + free_output_buffer(buffer);
34512 + printk("tuntap_open_tramp failed - err = %d\n", -err);
34516 + pri->dev_name = uml_strdup(buffer);
34517 + output += IFNAMSIZ;
34518 + printk("%s", output);
34519 + free_output_buffer(buffer);
34521 + os_close_file(fds[0]);
34522 + iter_addresses(pri->dev, open_addr, pri->dev_name);
34528 +static void tuntap_close(int fd, void *data)
34530 + struct tuntap_data *pri = data;
34532 + if(!pri->fixed_config)
34533 + iter_addresses(pri->dev, close_addr, pri->dev_name);
34534 + os_close_file(fd);
34538 +static int tuntap_set_mtu(int mtu, void *data)
34543 +struct net_user_info tuntap_user_info = {
34544 + .init = tuntap_user_init,
34545 + .open = tuntap_open,
34546 + .close = tuntap_close,
34548 + .set_mtu = tuntap_set_mtu,
34549 + .add_address = tuntap_add_addr,
34550 + .delete_address = tuntap_del_addr,
34551 + .max_packet = MAX_PACKET
34555 + * Overrides for Emacs so that we follow Linus's tabbing style.
34556 + * Emacs will notice this stuff at the end of the file and automatically
34557 + * adjust the settings for this buffer only. This must remain at the end
34559 + * ---------------------------------------------------------------------------
34560 + * Local variables:
34561 + * c-file-style: "linux"
34564 diff -Naur -X ../exclude-files orig/arch/um/os-Linux/file.c um/arch/um/os-Linux/file.c
34565 --- orig/arch/um/os-Linux/file.c 1969-12-31 19:00:00.000000000 -0500
34566 +++ um/arch/um/os-Linux/file.c 2004-01-10 06:52:24.000000000 -0500
34569 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
34570 + * Licensed under the GPL
34573 +#include <stdio.h>
34574 +#include <unistd.h>
34575 +#include <errno.h>
34576 +#include <fcntl.h>
34577 +#include <signal.h>
34578 +#include <sys/types.h>
34579 +#include <sys/stat.h>
34580 +#include <sys/socket.h>
34581 +#include <sys/un.h>
34582 +#include <sys/ioctl.h>
34583 +#include <sys/mount.h>
34584 +#include <sys/uio.h>
34587 +#include "kern_util.h"
34589 +static void copy_stat(struct uml_stat *dst, struct stat64 *src)
34591 + *dst = ((struct uml_stat) {
34592 + .ust_dev = src->st_dev, /* device */
34593 + .ust_ino = src->st_ino, /* inode */
34594 + .ust_mode = src->st_mode, /* protection */
34595 + .ust_nlink = src->st_nlink, /* number of hard links */
34596 + .ust_uid = src->st_uid, /* user ID of owner */
34597 + .ust_gid = src->st_gid, /* group ID of owner */
34598 + .ust_size = src->st_size, /* total size, in bytes */
34599 + .ust_blksize = src->st_blksize, /* blocksize for filesys I/O */
34600 + .ust_blocks = src->st_blocks, /* number of blocks allocated */
34601 + .ust_atime = src->st_atime, /* time of last access */
34602 + .ust_mtime = src->st_mtime, /* time of last modification */
34603 + .ust_ctime = src->st_ctime, /* time of last change */
34607 +int os_stat_fd(const int fd, struct uml_stat *ubuf)
34609 + struct stat64 sbuf;
34613 + err = fstat64(fd, &sbuf);
34614 + } while((err < 0) && (errno == EINTR)) ;
34620 + copy_stat(ubuf, &sbuf);
34624 +int os_stat_file(const char *file_name, struct uml_stat *ubuf)
34626 + struct stat64 sbuf;
34630 + err = stat64(file_name, &sbuf);
34631 + } while((err < 0) && (errno == EINTR)) ;
34637 + copy_stat(ubuf, &sbuf);
34641 +int os_access(const char* file, int mode)
34645 + amode=(mode&OS_ACC_R_OK ? R_OK : 0) | (mode&OS_ACC_W_OK ? W_OK : 0) |
34646 + (mode&OS_ACC_X_OK ? X_OK : 0) | (mode&OS_ACC_F_OK ? F_OK : 0) ;
34648 + err = access(file, amode);
34655 +void os_print_error(int error, const char* str)
34657 + errno = error < 0 ? -error : error;
34662 +/* FIXME? required only by hostaudio (because it passes ioctls verbatim) */
34663 +int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg)
34667 + err = ioctl(fd, cmd, arg);
34674 +int os_window_size(int fd, int *rows, int *cols)
34676 + struct winsize size;
34678 + if(ioctl(fd, TIOCGWINSZ, &size) < 0)
34681 + *rows = size.ws_row;
34682 + *cols = size.ws_col;
34687 +int os_new_tty_pgrp(int fd, int pid)
34689 + if(ioctl(fd, TIOCSCTTY, 0) < 0){
34690 + printk("TIOCSCTTY failed, errno = %d\n", errno);
34694 + if(tcsetpgrp(fd, pid) < 0){
34695 + printk("tcsetpgrp failed, errno = %d\n", errno);
34702 +/* FIXME: ensure namebuf in os_get_if_name is big enough */
34703 +int os_get_ifname(int fd, char* namebuf)
34705 + if(ioctl(fd, SIOCGIFNAME, namebuf) < 0)
34711 +int os_set_slip(int fd)
34713 + int disc, sencap;
34716 + if(ioctl(fd, TIOCSETD, &disc) < 0){
34717 + printk("Failed to set slip line discipline - "
34718 + "errno = %d\n", errno);
34723 + if(ioctl(fd, SIOCSIFENCAP, &sencap) < 0){
34724 + printk("Failed to set slip encapsulation - "
34725 + "errno = %d\n", errno);
34732 +int os_set_owner(int fd, int pid)
34734 + if(fcntl(fd, F_SETOWN, pid) < 0){
34735 + int save_errno = errno;
34737 + if(fcntl(fd, F_GETOWN, 0) != pid)
34738 + return(-save_errno);
34744 +/* FIXME? moved wholesale from sigio_user.c to get fcntls out of that file */
34745 +int os_sigio_async(int master, int slave)
34749 + flags = fcntl(master, F_GETFL);
34751 + printk("fcntl F_GETFL failed, errno = %d\n", errno);
34755 + if((fcntl(master, F_SETFL, flags | O_NONBLOCK | O_ASYNC) < 0) ||
34756 + (fcntl(master, F_SETOWN, os_getpid()) < 0)){
34757 + printk("fcntl F_SETFL or F_SETOWN failed, errno = %d\n", errno);
34761 + if((fcntl(slave, F_SETFL, flags | O_NONBLOCK) < 0)){
34762 + printk("fcntl F_SETFL failed, errno = %d\n", errno);
34769 +int os_mode_fd(int fd, int mode)
34774 + err = fchmod(fd, mode);
34775 + } while((err < 0) && (errno==EINTR)) ;
34783 +int os_file_type(char *file)
34785 + struct uml_stat buf;
34788 + err = os_stat_file(file, &buf);
34792 + if(S_ISDIR(buf.ust_mode)) return(OS_TYPE_DIR);
34793 + else if(S_ISLNK(buf.ust_mode)) return(OS_TYPE_SYMLINK);
34794 + else if(S_ISCHR(buf.ust_mode)) return(OS_TYPE_CHARDEV);
34795 + else if(S_ISBLK(buf.ust_mode)) return(OS_TYPE_BLOCKDEV);
34796 + else if(S_ISFIFO(buf.ust_mode)) return(OS_TYPE_FIFO);
34797 + else if(S_ISSOCK(buf.ust_mode)) return(OS_TYPE_SOCK);
34798 + else return(OS_TYPE_FILE);
34801 +int os_file_mode(char *file, struct openflags *mode_out)
34805 + *mode_out = OPENFLAGS();
34807 + err = os_access(file, OS_ACC_W_OK);
34808 + if((err < 0) && (err != -EACCES))
34811 + *mode_out = of_write(*mode_out);
34813 + err = os_access(file, OS_ACC_R_OK);
34814 + if((err < 0) && (err != -EACCES))
34817 + *mode_out = of_read(*mode_out);
34822 +int os_open_file(char *file, struct openflags flags, int mode)
34826 + if(flags.r && flags.w) f = O_RDWR;
34827 + else if(flags.r) f = O_RDONLY;
34828 + else if(flags.w) f = O_WRONLY;
34831 + if(flags.s) f |= O_SYNC;
34832 + if(flags.c) f |= O_CREAT;
34833 + if(flags.t) f |= O_TRUNC;
34834 + if(flags.e) f |= O_EXCL;
34836 + fd = open64(file, f, mode);
34840 + if(flags.cl && fcntl(fd, F_SETFD, 1)){
34841 + os_close_file(fd);
34848 +int os_connect_socket(char *name)
34850 + struct sockaddr_un sock;
34853 + sock.sun_family = AF_UNIX;
34854 + snprintf(sock.sun_path, sizeof(sock.sun_path), "%s", name);
34856 + fd = socket(AF_UNIX, SOCK_STREAM, 0);
34860 + err = connect(fd, (struct sockaddr *) &sock, sizeof(sock));
34867 +void os_close_file(int fd)
34872 +int os_seek_file(int fd, __u64 offset)
34876 + actual = lseek64(fd, offset, SEEK_SET);
34877 + if(actual != offset) return(-errno);
34881 +static int fault_buffer(void *start, int len,
34882 + int (*copy_proc)(void *addr, void *buf, int len))
34884 + int page = getpagesize(), i;
34887 + for(i = 0; i < len; i += page){
34888 + if((*copy_proc)(start + i, &c, sizeof(c)))
34891 + if((len % page) != 0){
34892 + if((*copy_proc)(start + len - 1, &c, sizeof(c)))
34898 +static int file_io(int fd, void *buf, int len,
34899 + int (*io_proc)(int fd, void *buf, int len),
34900 + int (*copy_user_proc)(void *addr, void *buf, int len))
34905 + n = (*io_proc)(fd, buf, len);
34906 + if((n < 0) && (errno == EFAULT)){
34907 + err = fault_buffer(buf, len, copy_user_proc);
34910 + n = (*io_proc)(fd, buf, len);
34912 + } while((n < 0) && (errno == EINTR));
34919 +int os_read_file(int fd, void *buf, int len)
34921 + return(file_io(fd, buf, len, (int (*)(int, void *, int)) read,
34922 + copy_from_user_proc));
34925 +int os_write_file(int fd, const void *buf, int len)
34927 + return(file_io(fd, (void *) buf, len,
34928 + (int (*)(int, void *, int)) write, copy_to_user_proc));
34931 +int os_file_size(char *file, long long *size_out)
34933 + struct uml_stat buf;
34936 + err = os_stat_file(file, &buf);
34938 + printk("Couldn't stat \"%s\" : err = %d\n", file, -err);
34942 + if(S_ISBLK(buf.ust_mode)){
34945 + fd = os_open_file(file, of_read(OPENFLAGS()), 0);
34947 + printk("Couldn't open \"%s\", errno = %d\n", file, -fd);
34950 + if(ioctl(fd, BLKGETSIZE, &blocks) < 0){
34951 + printk("Couldn't get the block size of \"%s\", "
34952 + "errno = %d\n", file, errno);
34954 + os_close_file(fd);
34957 + *size_out = ((long long) blocks) * 512;
34958 + os_close_file(fd);
34961 + *size_out = buf.ust_size;
34965 +int os_file_modtime(char *file, unsigned long *modtime)
34967 + struct uml_stat buf;
34970 + err = os_stat_file(file, &buf);
34972 + printk("Couldn't stat \"%s\" : err = %d\n", file, -err);
34976 + *modtime = buf.ust_mtime;
34980 +int os_get_exec_close(int fd, int* close_on_exec)
34985 + ret = fcntl(fd, F_GETFD);
34986 + } while((ret < 0) && (errno == EINTR)) ;
34991 + *close_on_exec = (ret&FD_CLOEXEC) ? 1 : 0;
34995 +int os_set_exec_close(int fd, int close_on_exec)
34999 + if(close_on_exec) flag = FD_CLOEXEC;
35003 + err = fcntl(fd, F_SETFD, flag);
35004 + } while((err < 0) && (errno == EINTR)) ;
35011 +int os_pipe(int *fds, int stream, int close_on_exec)
35013 + int err, type = stream ? SOCK_STREAM : SOCK_DGRAM;
35015 + err = socketpair(AF_UNIX, type, 0, fds);
35019 + if(!close_on_exec)
35022 + err = os_set_exec_close(fds[0], 1);
35026 + err = os_set_exec_close(fds[1], 1);
35033 + printk("os_pipe : Setting FD_CLOEXEC failed, err = %d\n", -err);
35034 + os_close_file(fds[1]);
35035 + os_close_file(fds[0]);
35039 +int os_set_fd_async(int fd, int owner)
35041 + /* XXX This should do F_GETFL first */
35042 + if(fcntl(fd, F_SETFL, O_ASYNC | O_NONBLOCK) < 0){
35043 + printk("os_set_fd_async : failed to set O_ASYNC and "
35044 + "O_NONBLOCK on fd # %d, errno = %d\n", fd, errno);
35048 + if(fcntl(fd, F_SETFD, 1) < 0){
35049 + printk("os_set_fd_async : Setting FD_CLOEXEC failed, "
35050 + "errno = %d\n", errno);
35054 + if((fcntl(fd, F_SETSIG, SIGIO) < 0) ||
35055 + (fcntl(fd, F_SETOWN, owner) < 0)){
35056 + printk("os_set_fd_async : Failed to fcntl F_SETOWN "
35057 + "(or F_SETSIG) fd %d to pid %d, errno = %d\n", fd,
35065 +int os_set_fd_block(int fd, int blocking)
35069 + flags = fcntl(fd, F_GETFL);
35071 + if(blocking) flags &= ~O_NONBLOCK;
35072 + else flags |= O_NONBLOCK;
35074 + if(fcntl(fd, F_SETFL, flags) < 0){
35075 + printk("Failed to change blocking on fd # %d, errno = %d\n",
35082 +int os_accept_connection(int fd)
35086 + new = accept(fd, NULL, 0);
35101 +#define SHUT_RDWR 2
35104 +int os_shutdown_socket(int fd, int r, int w)
35108 + if(r && w) what = SHUT_RDWR;
35109 + else if(r) what = SHUT_RD;
35110 + else if(w) what = SHUT_WR;
35112 + printk("os_shutdown_socket : neither r or w was set\n");
35115 + err = shutdown(fd, what);
35121 +int os_rcv_fd(int fd, int *helper_pid_out)
35124 + char buf[CMSG_SPACE(sizeof(new))];
35125 + struct msghdr msg;
35126 + struct cmsghdr *cmsg;
35127 + struct iovec iov;
35129 + msg.msg_name = NULL;
35130 + msg.msg_namelen = 0;
35131 + iov = ((struct iovec) { .iov_base = helper_pid_out,
35132 + .iov_len = sizeof(*helper_pid_out) });
35133 + msg.msg_iov = &iov;
35134 + msg.msg_iovlen = 1;
35135 + msg.msg_control = buf;
35136 + msg.msg_controllen = sizeof(buf);
35137 + msg.msg_flags = 0;
35139 + n = recvmsg(fd, &msg, 0);
35143 + else if(n != sizeof(iov.iov_len))
35144 + *helper_pid_out = -1;
35146 + cmsg = CMSG_FIRSTHDR(&msg);
35147 + if(cmsg == NULL){
35148 + printk("rcv_fd didn't receive anything, error = %d\n", errno);
35151 + if((cmsg->cmsg_level != SOL_SOCKET) ||
35152 + (cmsg->cmsg_type != SCM_RIGHTS)){
35153 + printk("rcv_fd didn't receive a descriptor\n");
35157 + new = ((int *) CMSG_DATA(cmsg))[0];
35161 +int os_create_unix_socket(char *file, int len, int close_on_exec)
35163 + struct sockaddr_un addr;
35166 + sock = socket(PF_UNIX, SOCK_DGRAM, 0);
35168 + printk("create_unix_socket - socket failed, errno = %d\n",
35173 + if(close_on_exec) {
35174 + err = os_set_exec_close(sock, 1);
35176 + printk("create_unix_socket : close_on_exec failed, "
35177 + "err = %d", -err);
35180 + addr.sun_family = AF_UNIX;
35182 + /* XXX Be more careful about overflow */
35183 + snprintf(addr.sun_path, len, "%s", file);
35185 + err = bind(sock, (struct sockaddr *) &addr, sizeof(addr));
35187 + printk("create_listening_socket at '%s' - bind failed, "
35188 + "errno = %d\n", file, errno);
35195 +void os_flush_stdout(void)
35200 +int os_lock_file(int fd, int excl)
35202 + int type = excl ? F_WRLCK : F_RDLCK;
35203 + struct flock lock = ((struct flock) { .l_type = type,
35204 + .l_whence = SEEK_SET,
35209 + err = fcntl(fd, F_SETLK, &lock);
35214 + err = fcntl(fd, F_GETLK, &lock);
35220 + printk("F_SETLK failed, file already locked by pid %d\n", lock.l_pid);
35227 + * Overrides for Emacs so that we follow Linus's tabbing style.
35228 + * Emacs will notice this stuff at the end of the file and automatically
35229 + * adjust the settings for this buffer only. This must remain at the end
35231 + * ---------------------------------------------------------------------------
35232 + * Local variables:
35233 + * c-file-style: "linux"
35236 diff -Naur -X ../exclude-files orig/arch/um/os-Linux/include/file.h um/arch/um/os-Linux/include/file.h
35237 --- orig/arch/um/os-Linux/include/file.h 1969-12-31 19:00:00.000000000 -0500
35238 +++ um/arch/um/os-Linux/include/file.h 2003-10-21 03:26:07.000000000 -0400
35241 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
35242 + * Licensed under the GPL
35245 +#ifndef __OS_FILE_H__
35246 +#define __OS_FILE_H__
35248 +#define DEV_NULL "/dev/null"
35253 + * Overrides for Emacs so that we follow Linus's tabbing style.
35254 + * Emacs will notice this stuff at the end of the file and automatically
35255 + * adjust the settings for this buffer only. This must remain at the end
35257 + * ---------------------------------------------------------------------------
35258 + * Local variables:
35259 + * c-file-style: "linux"
35262 diff -Naur -X ../exclude-files orig/arch/um/os-Linux/Makefile um/arch/um/os-Linux/Makefile
35263 --- orig/arch/um/os-Linux/Makefile 1969-12-31 19:00:00.000000000 -0500
35264 +++ um/arch/um/os-Linux/Makefile 2003-10-21 03:26:07.000000000 -0400
35267 +# Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
35268 +# Licensed under the GPL
35271 +O_TARGET = built-in.o
35273 +obj-y = file.o process.o tty.o
35275 +include $(TOPDIR)/Rules.make
35277 +$(obj-y) : %.o: %.c
35278 + $(CC) $(CFLAGS_$@) $(USER_CFLAGS) -c -o $@ $<
35283 diff -Naur -X ../exclude-files orig/arch/um/os-Linux/process.c um/arch/um/os-Linux/process.c
35284 --- orig/arch/um/os-Linux/process.c 1969-12-31 19:00:00.000000000 -0500
35285 +++ um/arch/um/os-Linux/process.c 2004-01-10 06:53:44.000000000 -0500
35288 + * Copyright (C) 2002 Jeff Dike (jdike@addtoit.com)
35289 + * Licensed under the GPL
35292 +#include <unistd.h>
35293 +#include <stdio.h>
35294 +#include <errno.h>
35295 +#include <signal.h>
35296 +#include <sys/mman.h>
35297 +#include <sys/wait.h>
35301 +#define ARBITRARY_ADDR -1
35302 +#define FAILURE_PID -1
35304 +unsigned long os_process_pc(int pid)
35306 + char proc_stat[sizeof("/proc/#####/stat\0")], buf[256];
35307 + unsigned long pc;
35310 + sprintf(proc_stat, "/proc/%d/stat", pid);
35311 + fd = os_open_file(proc_stat, of_read(OPENFLAGS()), 0);
35313 + printk("os_process_pc - couldn't open '%s', err = %d\n",
35315 + return(ARBITRARY_ADDR);
35317 + err = os_read_file(fd, buf, sizeof(buf));
35319 + printk("os_process_pc - couldn't read '%s', err = %d\n",
35320 + proc_stat, -err);
35321 + os_close_file(fd);
35322 + return(ARBITRARY_ADDR);
35324 + os_close_file(fd);
35325 + pc = ARBITRARY_ADDR;
35326 + if(sscanf(buf, "%*d %*s %*c %*d %*d %*d %*d %*d %*d %*d %*d "
35327 + "%*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d "
35328 + "%*d %*d %*d %*d %ld", &pc) != 1){
35329 + printk("os_process_pc - couldn't find pc in '%s'\n", buf);
35334 +int os_process_parent(int pid)
35336 + char stat[sizeof("/proc/nnnnn/stat\0")];
35338 + int parent, n, fd;
35340 + if(pid == -1) return(-1);
35342 + snprintf(stat, sizeof(stat), "/proc/%d/stat", pid);
35343 + fd = os_open_file(stat, of_read(OPENFLAGS()), 0);
35345 + printk("Couldn't open '%s', err = %d\n", stat, -fd);
35346 + return(FAILURE_PID);
35349 + n = os_read_file(fd, data, sizeof(data));
35350 + os_close_file(fd);
35353 + printk("Couldn't read '%s', err = %d\n", stat, -n);
35354 + return(FAILURE_PID);
35357 + parent = FAILURE_PID;
35358 + /* XXX This will break if there is a space in the command */
35359 + n = sscanf(data, "%*d %*s %*c %d", &parent);
35361 + printk("Failed to scan '%s'\n", data);
35366 +void os_stop_process(int pid)
35368 + kill(pid, SIGSTOP);
35371 +void os_kill_process(int pid, int reap_child)
35373 + kill(pid, SIGKILL);
35375 + waitpid(pid, NULL, 0);
35379 +void os_usr1_process(int pid)
35381 + kill(pid, SIGUSR1);
35384 +int os_getpid(void)
35386 + return(getpid());
35389 +int os_map_memory(void *virt, int fd, unsigned long long off, unsigned long len,
35390 + int r, int w, int x)
35395 + prot = (r ? PROT_READ : 0) | (w ? PROT_WRITE : 0) |
35396 + (x ? PROT_EXEC : 0);
35398 + loc = mmap64((void *) virt, len, prot, MAP_SHARED | MAP_FIXED,
35400 + if(loc == MAP_FAILED)
35405 +int os_protect_memory(void *addr, unsigned long len, int r, int w, int x)
35407 + int prot = ((r ? PROT_READ : 0) | (w ? PROT_WRITE : 0) |
35408 + (x ? PROT_EXEC : 0));
35410 + if(mprotect(addr, len, prot) < 0)
35415 +int os_unmap_memory(void *addr, int len)
35419 + err = munmap(addr, len);
35426 + * Overrides for Emacs so that we follow Linus's tabbing style.
35427 + * Emacs will notice this stuff at the end of the file and automatically
35428 + * adjust the settings for this buffer only. This must remain at the end
35430 + * ---------------------------------------------------------------------------
35431 + * Local variables:
35432 + * c-file-style: "linux"
35435 diff -Naur -X ../exclude-files orig/arch/um/os-Linux/tty.c um/arch/um/os-Linux/tty.c
35436 --- orig/arch/um/os-Linux/tty.c 1969-12-31 19:00:00.000000000 -0500
35437 +++ um/arch/um/os-Linux/tty.c 2003-10-21 03:26:07.000000000 -0400
35440 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
35441 + * Licensed under the GPL
35444 +#include <stdlib.h>
35445 +#include <errno.h>
35448 +#include "kern_util.h"
35450 +struct grantpt_info {
35456 +static void grantpt_cb(void *arg)
35458 + struct grantpt_info *info = arg;
35460 + info->res = grantpt(info->fd);
35461 + info->err = errno;
35466 + struct grantpt_info info;
35469 + fd = os_open_file("/dev/ptmx", of_rdwr(OPENFLAGS()), 0);
35471 + printk("get_pty : Couldn't open /dev/ptmx - err = %d\n", -fd);
35476 + initial_thread_cb(grantpt_cb, &info);
35478 + if(info.res < 0){
35479 + printk("get_pty : Couldn't grant pty - errno = %d\n",
35483 + if(unlockpt(fd) < 0){
35484 + printk("get_pty : Couldn't unlock pty - errno = %d\n", errno);
35491 + * Overrides for Emacs so that we follow Linus's tabbing style.
35492 + * Emacs will notice this stuff at the end of the file and automatically
35493 + * adjust the settings for this buffer only. This must remain at the end
35495 + * ---------------------------------------------------------------------------
35496 + * Local variables:
35497 + * c-file-style: "linux"
35500 diff -Naur -X ../exclude-files orig/arch/um/sys-i386/bugs.c um/arch/um/sys-i386/bugs.c
35501 --- orig/arch/um/sys-i386/bugs.c 1969-12-31 19:00:00.000000000 -0500
35502 +++ um/arch/um/sys-i386/bugs.c 2004-01-21 22:42:39.000000000 -0500
35505 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
35506 + * Licensed under the GPL
35509 +#include <unistd.h>
35510 +#include <errno.h>
35511 +#include <string.h>
35512 +#include <sys/signal.h>
35513 +#include <asm/ldt.h>
35514 +#include "kern_util.h"
35516 +#include "sysdep/ptrace.h"
35520 +#define MAXTOKEN 64
35522 +/* Set during early boot */
35523 +int host_has_cmov = 1;
35524 +int host_has_xmm = 0;
35526 +static char token(int fd, char *buf, int len, char stop)
35529 + char *ptr, *end, c;
35534 + n = os_read_file(fd, ptr, sizeof(*ptr));
35536 + if(n != sizeof(*ptr)){
35537 + if(n == 0) return(0);
35538 + printk("Reading /proc/cpuinfo failed, err = %d\n", -n);
35544 + } while((c != '\n') && (c != stop) && (ptr < end));
35547 + printk("Failed to find '%c' in /proc/cpuinfo\n", stop);
35550 + *(ptr - 1) = '\0';
35554 +static int find_cpuinfo_line(int fd, char *key, char *scratch, int len)
35559 + scratch[len - 1] = '\0';
35561 + c = token(fd, scratch, len - 1, ':');
35564 + else if(c != ':'){
35565 + printk("Failed to find ':' in /proc/cpuinfo\n");
35569 + if(!strncmp(scratch, key, strlen(key)))
35573 + n = os_read_file(fd, &c, sizeof(c));
35574 + if(n != sizeof(c)){
35575 + printk("Failed to find newline in "
35576 + "/proc/cpuinfo, err = %d\n", -n);
35579 + } while(c != '\n');
35584 +int cpu_feature(char *what, char *buf, int len)
35588 + fd = os_open_file("/proc/cpuinfo", of_read(OPENFLAGS()), 0);
35590 + printk("Couldn't open /proc/cpuinfo, err = %d\n", -fd);
35594 + if(!find_cpuinfo_line(fd, what, buf, len)){
35595 + printk("Couldn't find '%s' line in /proc/cpuinfo\n", what);
35599 + token(fd, buf, len, '\n');
35603 + os_close_file(fd);
35607 +static int check_cpu_flag(char *feature, int *have_it)
35609 + char buf[MAXTOKEN], c;
35610 + int fd, len = sizeof(buf)/sizeof(buf[0]);
35612 + printk("Checking for host processor %s support...", feature);
35613 + fd = os_open_file("/proc/cpuinfo", of_read(OPENFLAGS()), 0);
35615 + printk("Couldn't open /proc/cpuinfo, err = %d\n", -fd);
35620 + if(!find_cpuinfo_line(fd, "flags", buf, sizeof(buf) / sizeof(buf[0])))
35623 + c = token(fd, buf, len - 1, ' ');
35624 + if(c < 0) goto out;
35625 + else if(c != ' '){
35626 + printk("Failed to find ' ' in /proc/cpuinfo\n");
35631 + c = token(fd, buf, len - 1, ' ');
35632 + if(c < 0) goto out;
35633 + else if(c == '\n') break;
35635 + if(!strcmp(buf, feature)){
35641 + if(*have_it == 0) printk("No\n");
35642 + else if(*have_it == 1) printk("Yes\n");
35643 + os_close_file(fd);
35647 +#if 0 /* This doesn't work in tt mode, plus it's causing compilation problems
35648 + * for some people.
35650 +static void disable_lcall(void)
35652 + struct modify_ldt_ldt_s ldt;
35655 + bzero(&ldt, sizeof(ldt));
35656 + ldt.entry_number = 7;
35657 + ldt.base_addr = 0;
35659 + err = modify_ldt(1, &ldt, sizeof(ldt));
35661 + printk("Failed to disable lcall7 - errno = %d\n", errno);
35665 +void arch_init_thread(void)
35672 +void arch_check_bugs(void)
35676 + if(os_access("/proc/cpuinfo", OS_ACC_R_OK) < 0){
35677 + printk("/proc/cpuinfo not available - skipping CPU capability "
35681 + if(check_cpu_flag("cmov", &have_it))
35682 + host_has_cmov = have_it;
35683 + if(check_cpu_flag("xmm", &have_it))
35684 + host_has_xmm = have_it;
35687 +int arch_handle_signal(int sig, union uml_pt_regs *regs)
35689 + unsigned char tmp[2];
35691 + /* This is testing for a cmov (0x0f 0x4x) instruction causing a
35692 + * SIGILL in init.
35694 + if((sig != SIGILL) || (TASK_PID(get_current()) != 1)) return(0);
35696 + if (copy_from_user_proc(tmp, (void *) UPT_IP(regs), 2))
35697 + panic("SIGILL in init, could not read instructions!\n");
35698 + if((tmp[0] != 0x0f) || ((tmp[1] & 0xf0) != 0x40))
35701 + if(host_has_cmov == 0)
35702 + panic("SIGILL caused by cmov, which this processor doesn't "
35703 + "implement, boot a filesystem compiled for older "
35705 + else if(host_has_cmov == 1)
35706 + panic("SIGILL caused by cmov, which this processor claims to "
35708 + else if(host_has_cmov == -1)
35709 + panic("SIGILL caused by cmov, couldn't tell if this processor "
35710 + "implements it, boot a filesystem compiled for older "
35712 + else panic("Bad value for host_has_cmov (%d)", host_has_cmov);
35717 + * Overrides for Emacs so that we follow Linus's tabbing style.
35718 + * Emacs will notice this stuff at the end of the file and automatically
35719 + * adjust the settings for this buffer only. This must remain at the end
35721 + * ---------------------------------------------------------------------------
35722 + * Local variables:
35723 + * c-file-style: "linux"
35726 diff -Naur -X ../exclude-files orig/arch/um/sys-i386/checksum.S um/arch/um/sys-i386/checksum.S
35727 --- orig/arch/um/sys-i386/checksum.S 1969-12-31 19:00:00.000000000 -0500
35728 +++ um/arch/um/sys-i386/checksum.S 2003-10-21 03:26:07.000000000 -0400
35731 + * INET An implementation of the TCP/IP protocol suite for the LINUX
35732 + * operating system. INET is implemented using the BSD Socket
35733 + * interface as the means of communication with the user level.
35735 + * IP/TCP/UDP checksumming routines
35737 + * Authors: Jorge Cwik, <jorge@laser.satlink.net>
35738 + * Arnt Gulbrandsen, <agulbra@nvg.unit.no>
35739 + * Tom May, <ftom@netcom.com>
35740 + * Pentium Pro/II routines:
35741 + * Alexander Kjeldaas <astor@guardian.no>
35742 + * Finn Arne Gangstad <finnag@guardian.no>
35743 + * Lots of code moved from tcp.c and ip.c; see those files
35744 + * for more names.
35746 + * Changes: Ingo Molnar, converted csum_partial_copy() to 2.1 exception
35748 + * Andi Kleen, add zeroing on error
35749 + * converted to pure assembler
35751 + * This program is free software; you can redistribute it and/or
35752 + * modify it under the terms of the GNU General Public License
35753 + * as published by the Free Software Foundation; either version
35754 + * 2 of the License, or (at your option) any later version.
35757 +#include <linux/config.h>
35758 +#include <asm/errno.h>
35761 + * computes a partial checksum, e.g. for TCP/UDP fragments
35765 +unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum)
35770 +.globl arch_csum_partial
35772 +#ifndef CONFIG_X86_USE_PPRO_CHECKSUM
35775 + * Experiments with Ethernet and SLIP connections show that buff
35776 + * is aligned on either a 2-byte or 4-byte boundary. We get at
35777 + * least a twofold speedup on 486 and Pentium if it is 4-byte aligned.
35778 + * Fortunately, it is easy to convert 2-byte alignment to 4-byte
35779 + * alignment for the unrolled loop.
35781 +arch_csum_partial:
35784 + movl 20(%esp),%eax # Function arg: unsigned int sum
35785 + movl 16(%esp),%ecx # Function arg: int len
35786 + movl 12(%esp),%esi # Function arg: unsigned char *buff
35787 + testl $2, %esi # Check alignment.
35788 + jz 2f # Jump if alignment is ok.
35789 + subl $2, %ecx # Alignment uses up two bytes.
35790 + jae 1f # Jump if we had at least two bytes.
35791 + addl $2, %ecx # ecx was < 2. Deal with it.
35793 +1: movw (%esi), %bx
35802 +1: movl (%esi), %ebx
35804 + movl 4(%esi), %ebx
35806 + movl 8(%esi), %ebx
35808 + movl 12(%esi), %ebx
35810 + movl 16(%esi), %ebx
35812 + movl 20(%esi), %ebx
35814 + movl 24(%esi), %ebx
35816 + movl 28(%esi), %ebx
35818 + lea 32(%esi), %esi
35822 +2: movl %edx, %ecx
35825 + shrl $2, %edx # This clears CF
35826 +3: adcl (%esi), %eax
35827 + lea 4(%esi), %esi
35836 + leal 2(%esi),%esi
35839 +5: movb (%esi),%cl
35849 +/* Version for PentiumII/PPro */
35851 +arch_csum_partial:
35854 + movl 20(%esp),%eax # Function arg: unsigned int sum
35855 + movl 16(%esp),%ecx # Function arg: int len
35856 + movl 12(%esp),%esi # Function arg: const unsigned char *buf
35868 + lea 45f(%ebx,%ebx,2), %ebx
35872 + # Handle 2-byte-aligned regions
35873 +20: addw (%esi), %ax
35874 + lea 2(%esi), %esi
35881 + movzbl (%esi),%ebx # csumming 1 byte, 2-aligned
35886 + addw (%esi), %ax # csumming 2 bytes, 2-aligned
35891 + addl -128(%esi), %eax
35892 + adcl -124(%esi), %eax
35893 + adcl -120(%esi), %eax
35894 + adcl -116(%esi), %eax
35895 + adcl -112(%esi), %eax
35896 + adcl -108(%esi), %eax
35897 + adcl -104(%esi), %eax
35898 + adcl -100(%esi), %eax
35899 + adcl -96(%esi), %eax
35900 + adcl -92(%esi), %eax
35901 + adcl -88(%esi), %eax
35902 + adcl -84(%esi), %eax
35903 + adcl -80(%esi), %eax
35904 + adcl -76(%esi), %eax
35905 + adcl -72(%esi), %eax
35906 + adcl -68(%esi), %eax
35907 + adcl -64(%esi), %eax
35908 + adcl -60(%esi), %eax
35909 + adcl -56(%esi), %eax
35910 + adcl -52(%esi), %eax
35911 + adcl -48(%esi), %eax
35912 + adcl -44(%esi), %eax
35913 + adcl -40(%esi), %eax
35914 + adcl -36(%esi), %eax
35915 + adcl -32(%esi), %eax
35916 + adcl -28(%esi), %eax
35917 + adcl -24(%esi), %eax
35918 + adcl -20(%esi), %eax
35919 + adcl -16(%esi), %eax
35920 + adcl -12(%esi), %eax
35921 + adcl -8(%esi), %eax
35922 + adcl -4(%esi), %eax
35924 + lea 128(%esi), %esi
35932 + # Handle the last 1-3 bytes without jumping
35933 + notl %ecx # 1->2, 2->1, 3->0, higher bits are masked
35934 + movl $0xffffff,%ebx # by the shll and shrl instructions
35937 + andl -128(%esi),%ebx # esi is 4-aligned so should be ok
35948 +unsigned int csum_partial_copy_generic (const char *src, char *dst,
35949 + int len, int sum, int *src_err_ptr, int *dst_err_ptr)
35953 + * Copy from ds while checksumming, otherwise like csum_partial
35955 + * The macros SRC and DST specify the type of access for the instruction.
35956 + * thus we can call a custom exception handler for all access types.
35958 + * FIXME: could someone double-check whether I haven't mixed up some SRC and
35959 + * DST definitions? It's damn hard to trigger all cases. I hope I got
35960 + * them all but there's no guarantee.
35963 +#define SRC(y...) \
35965 + .section __ex_table, "a"; \
35966 + .long 9999b, 6001f ; \
35969 +#define DST(y...) \
35971 + .section __ex_table, "a"; \
35972 + .long 9999b, 6002f ; \
35976 +.globl csum_partial_copy_generic_i386
35978 +#ifndef CONFIG_X86_USE_PPRO_CHECKSUM
35980 +#define ARGBASE 16
35983 +csum_partial_copy_generic_i386:
35988 + movl ARGBASE+16(%esp),%eax # sum
35989 + movl ARGBASE+12(%esp),%ecx # len
35990 + movl ARGBASE+4(%esp),%esi # src
35991 + movl ARGBASE+8(%esp),%edi # dst
35993 + testl $2, %edi # Check alignment.
35994 + jz 2f # Jump if alignment is ok.
35995 + subl $2, %ecx # Alignment uses up two bytes.
35996 + jae 1f # Jump if we had at least two bytes.
35997 + addl $2, %ecx # ecx was < 2. Deal with it.
35999 +SRC(1: movw (%esi), %bx )
36001 +DST( movw %bx, (%edi) )
36006 + movl %ecx, FP(%esp)
36010 +SRC(1: movl (%esi), %ebx )
36011 +SRC( movl 4(%esi), %edx )
36013 +DST( movl %ebx, (%edi) )
36015 +DST( movl %edx, 4(%edi) )
36017 +SRC( movl 8(%esi), %ebx )
36018 +SRC( movl 12(%esi), %edx )
36020 +DST( movl %ebx, 8(%edi) )
36022 +DST( movl %edx, 12(%edi) )
36024 +SRC( movl 16(%esi), %ebx )
36025 +SRC( movl 20(%esi), %edx )
36027 +DST( movl %ebx, 16(%edi) )
36029 +DST( movl %edx, 20(%edi) )
36031 +SRC( movl 24(%esi), %ebx )
36032 +SRC( movl 28(%esi), %edx )
36034 +DST( movl %ebx, 24(%edi) )
36036 +DST( movl %edx, 28(%edi) )
36038 + lea 32(%esi), %esi
36039 + lea 32(%edi), %edi
36043 +2: movl FP(%esp), %edx
36047 + shrl $2, %edx # This clears CF
36048 +SRC(3: movl (%esi), %ebx )
36050 +DST( movl %ebx, (%edi) )
36051 + lea 4(%esi), %esi
36052 + lea 4(%edi), %edi
36060 +SRC( movw (%esi), %cx )
36061 + leal 2(%esi), %esi
36062 +DST( movw %cx, (%edi) )
36063 + leal 2(%edi), %edi
36066 +SRC(5: movb (%esi), %cl )
36067 +DST( movb %cl, (%edi) )
36068 +6: addl %ecx, %eax
36073 +# Exception handler:
36074 +.section .fixup, "ax"
36077 + movl ARGBASE+20(%esp), %ebx # src_err_ptr
36078 + movl $-EFAULT, (%ebx)
36080 + # zero the complete destination - computing the rest
36081 + # is too much work
36082 + movl ARGBASE+8(%esp), %edi # dst
36083 + movl ARGBASE+12(%esp), %ecx # len
36090 + movl ARGBASE+24(%esp), %ebx # dst_err_ptr
36091 + movl $-EFAULT,(%ebx)
36099 + popl %ecx # equivalent to addl $4,%esp
36104 +/* Version for PentiumII/PPro */
36106 +#define ROUND1(x) \
36107 + SRC(movl x(%esi), %ebx ) ; \
36108 + addl %ebx, %eax ; \
36109 + DST(movl %ebx, x(%edi) ) ;
36111 +#define ROUND(x) \
36112 + SRC(movl x(%esi), %ebx ) ; \
36113 + adcl %ebx, %eax ; \
36114 + DST(movl %ebx, x(%edi) ) ;
36116 +#define ARGBASE 12
36118 +csum_partial_copy_generic_i386:
36122 + movl ARGBASE+4(%esp),%esi #src
36123 + movl ARGBASE+8(%esp),%edi #dst
36124 + movl ARGBASE+12(%esp),%ecx #len
36125 + movl ARGBASE+16(%esp),%eax #sum
36134 + lea -1(%esi),%edx
36136 + lea 3f(%ebx,%ebx), %ebx
36141 + SRC(movb -32(%edx),%bl) ; SRC(movb (%edx),%bl)
36142 + ROUND1(-64) ROUND(-60) ROUND(-56) ROUND(-52)
36143 + ROUND (-48) ROUND(-44) ROUND(-40) ROUND(-36)
36144 + ROUND (-32) ROUND(-28) ROUND(-24) ROUND(-20)
36145 + ROUND (-16) ROUND(-12) ROUND(-8) ROUND(-4)
36150 +4: movl ARGBASE+12(%esp),%edx #len
36155 +SRC( movw (%esi), %dx )
36156 + leal 2(%esi), %esi
36157 +DST( movw %dx, (%edi) )
36158 + leal 2(%edi), %edi
36162 +SRC( movb (%esi), %dl )
36163 +DST( movb %dl, (%edi) )
36164 +6: addl %edx, %eax
36167 +.section .fixup, "ax"
36168 +6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
36169 + movl $-EFAULT, (%ebx)
36170 + # zero the complete destination (computing the rest is too much work)
36171 + movl ARGBASE+8(%esp),%edi # dst
36172 + movl ARGBASE+12(%esp),%ecx # len
36176 +6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
36177 + movl $-EFAULT, (%ebx)
36190 diff -Naur -X ../exclude-files orig/arch/um/sys-i386/fault.c um/arch/um/sys-i386/fault.c
36191 --- orig/arch/um/sys-i386/fault.c 1969-12-31 19:00:00.000000000 -0500
36192 +++ um/arch/um/sys-i386/fault.c 2003-10-21 03:26:07.000000000 -0400
36195 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
36196 + * Licensed under the GPL
36199 +#include <signal.h>
36200 +#include "sysdep/ptrace.h"
36201 +#include "sysdep/sigcontext.h"
36203 +extern unsigned long search_exception_table(unsigned long addr);
36205 +int arch_fixup(unsigned long address, void *sc_ptr)
36207 + struct sigcontext *sc = sc_ptr;
36208 + unsigned long fixup;
36210 + fixup = search_exception_table(address);
36219 + * Overrides for Emacs so that we follow Linus's tabbing style.
36220 + * Emacs will notice this stuff at the end of the file and automatically
36221 + * adjust the settings for this buffer only. This must remain at the end
36223 + * ---------------------------------------------------------------------------
36224 + * Local variables:
36225 + * c-file-style: "linux"
36228 diff -Naur -X ../exclude-files orig/arch/um/sys-i386/ksyms.c um/arch/um/sys-i386/ksyms.c
36229 --- orig/arch/um/sys-i386/ksyms.c 1969-12-31 19:00:00.000000000 -0500
36230 +++ um/arch/um/sys-i386/ksyms.c 2003-10-21 03:26:07.000000000 -0400
36232 +#include "linux/module.h"
36233 +#include "linux/in6.h"
36234 +#include "linux/rwsem.h"
36235 +#include "asm/byteorder.h"
36236 +#include "asm/semaphore.h"
36237 +#include "asm/uaccess.h"
36238 +#include "asm/checksum.h"
36239 +#include "asm/errno.h"
36241 +EXPORT_SYMBOL(__down_failed);
36242 +EXPORT_SYMBOL(__down_failed_interruptible);
36243 +EXPORT_SYMBOL(__down_failed_trylock);
36244 +EXPORT_SYMBOL(__up_wakeup);
36246 +/* Networking helper routines. */
36247 +EXPORT_SYMBOL(csum_partial_copy_from);
36248 +EXPORT_SYMBOL(csum_partial_copy_to);
36249 diff -Naur -X ../exclude-files orig/arch/um/sys-i386/ldt.c um/arch/um/sys-i386/ldt.c
36250 --- orig/arch/um/sys-i386/ldt.c 1969-12-31 19:00:00.000000000 -0500
36251 +++ um/arch/um/sys-i386/ldt.c 2004-01-19 04:01:11.000000000 -0500
36254 + * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
36255 + * Licensed under the GPL
36258 +#include "linux/config.h"
36259 +#include "linux/slab.h"
36260 +#include "asm/uaccess.h"
36261 +#include "asm/ptrace.h"
36262 +#include "choose-mode.h"
36265 +#ifdef CONFIG_MODE_TT
36266 +extern int modify_ldt(int func, void *ptr, unsigned long bytecount);
36268 +/* XXX this needs copy_to_user and copy_from_user */
36270 +int sys_modify_ldt_tt(int func, void *ptr, unsigned long bytecount)
36272 + if(verify_area(VERIFY_READ, ptr, bytecount)) return(-EFAULT);
36273 + return(modify_ldt(func, ptr, bytecount));
36277 +#ifdef CONFIG_MODE_SKAS
36278 +extern int userspace_pid;
36280 +int sys_modify_ldt_skas(int func, void *ptr, unsigned long bytecount)
36282 + struct ptrace_ldt ldt;
36286 + buf = kmalloc(bytecount, GFP_KERNEL);
36295 + res = copy_from_user(buf, ptr, bytecount);
36304 + ldt = ((struct ptrace_ldt) { .func = func,
36306 + .bytecount = bytecount });
36307 + res = ptrace(PTRACE_LDT, userspace_pid, 0, (unsigned long) &ldt);
36315 + res = copy_to_user(ptr, buf, n);
36329 +int sys_modify_ldt(int func, void *ptr, unsigned long bytecount)
36331 + return(CHOOSE_MODE_PROC(sys_modify_ldt_tt, sys_modify_ldt_skas, func,
36332 + ptr, bytecount));
36338 + * Overrides for Emacs so that we follow Linus's tabbing style.
36339 + * Emacs will notice this stuff at the end of the file and automatically
36340 + * adjust the settings for this buffer only. This must remain at the end
36342 + * ---------------------------------------------------------------------------
36343 + * Local variables:
36344 + * c-file-style: "linux"
36347 diff -Naur -X ../exclude-files orig/arch/um/sys-i386/Makefile um/arch/um/sys-i386/Makefile
36348 --- orig/arch/um/sys-i386/Makefile 1969-12-31 19:00:00.000000000 -0500
36349 +++ um/arch/um/sys-i386/Makefile 2003-11-09 11:55:24.000000000 -0500
36352 +# Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
36353 +# Licensed under the GPL
36356 +O_TARGET = built-in.o
36358 +obj-y = bugs.o checksum.o extable.o fault.o ksyms.o ldt.o ptrace.o \
36359 + ptrace_user.o semaphore.o sigcontext.o syscalls.o sysrq.o time.o
36360 +export-objs = ksyms.o
36362 +USER_OBJS = bugs.o ptrace_user.o sigcontext.o fault.o
36364 +SYMLINKS = semaphore.c extable.c
36366 +semaphore.c-dir = kernel
36367 +extable.c-dir = mm
36369 +include $(TOPDIR)/Rules.make
36371 +$(USER_OBJS) : %.o: %.c
36372 + $(CC) $(CFLAGS_$@) $(USER_CFLAGS) -c -o $@ $<
36376 + ln -sf $(TOPDIR)/arch/i386/$($1-dir)/$1 $1
36380 + $(call make_link,$@)
36383 + $(MAKE) -C util clean
36384 + rm -f $(SYMLINKS)
36397 diff -Naur -X ../exclude-files orig/arch/um/sys-i386/ptrace.c um/arch/um/sys-i386/ptrace.c
36398 --- orig/arch/um/sys-i386/ptrace.c 1969-12-31 19:00:00.000000000 -0500
36399 +++ um/arch/um/sys-i386/ptrace.c 2003-10-21 03:26:07.000000000 -0400
36402 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
36403 + * Licensed under the GPL
36406 +#include "linux/sched.h"
36407 +#include "asm/elf.h"
36408 +#include "asm/ptrace.h"
36409 +#include "asm/uaccess.h"
36410 +#include "ptrace_user.h"
36411 +#include "sysdep/sigcontext.h"
36412 +#include "sysdep/sc.h"
36414 +void arch_switch(void)
36416 + update_debugregs(current->thread.arch.debugregs_seq);
36419 +int is_syscall(unsigned long addr)
36421 + unsigned short instr;
36424 + n = copy_from_user(&instr, (void *) addr, sizeof(instr));
36426 + printk("is_syscall : failed to read instruction from 0x%lu\n",
36430 + return(instr == 0x80cd);
36433 +/* determines which flags the user has access to. */
36434 +/* 1 = access 0 = no access */
36435 +#define FLAG_MASK 0x00044dd5
36437 +int putreg(struct task_struct *child, int regno, unsigned long value)
36442 + if (value && (value & 3) != 3)
36444 + PT_REGS_FS(&child->thread.regs) = value;
36447 + if (value && (value & 3) != 3)
36449 + PT_REGS_GS(&child->thread.regs) = value;
36453 + if (value && (value & 3) != 3)
36459 + if ((value & 3) != 3)
36464 + value &= FLAG_MASK;
36465 + value |= PT_REGS_EFLAGS(&child->thread.regs);
36468 + PT_REGS_SET(&child->thread.regs, regno, value);
36472 +unsigned long getreg(struct task_struct *child, int regno)
36474 + unsigned long retval = ~0UL;
36485 + /* fall through */
36487 + retval &= PT_REG(&child->thread.regs, regno);
36492 +struct i387_fxsave_struct {
36493 + unsigned short cwd;
36494 + unsigned short swd;
36495 + unsigned short twd;
36496 + unsigned short fop;
36503 + long st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
36504 + long xmm_space[32]; /* 8*16 bytes for each XMM-reg = 128 bytes */
36505 + long padding[56];
36509 + * FPU tag word conversions.
36512 +static inline unsigned short twd_i387_to_fxsr( unsigned short twd )
36514 + unsigned int tmp; /* to avoid 16 bit prefixes in the code */
36516 + /* Transform each pair of bits into 01 (valid) or 00 (empty) */
36518 + tmp = (tmp | (tmp>>1)) & 0x5555; /* 0V0V0V0V0V0V0V0V */
36519 + /* and move the valid bits to the lower byte. */
36520 + tmp = (tmp | (tmp >> 1)) & 0x3333; /* 00VV00VV00VV00VV */
36521 + tmp = (tmp | (tmp >> 2)) & 0x0f0f; /* 0000VVVV0000VVVV */
36522 + tmp = (tmp | (tmp >> 4)) & 0x00ff; /* 00000000VVVVVVVV */
36526 +static inline unsigned long twd_fxsr_to_i387( struct i387_fxsave_struct *fxsave )
36528 + struct _fpxreg *st = NULL;
36529 + unsigned long twd = (unsigned long) fxsave->twd;
36530 + unsigned long tag;
36531 + unsigned long ret = 0xffff0000;
36534 +#define FPREG_ADDR(f, n) ((char *)&(f)->st_space + (n) * 16);
36536 + for ( i = 0 ; i < 8 ; i++ ) {
36537 + if ( twd & 0x1 ) {
36538 + st = (struct _fpxreg *) FPREG_ADDR( fxsave, i );
36540 + switch ( st->exponent & 0x7fff ) {
36542 + tag = 2; /* Special */
36545 + if ( !st->significand[0] &&
36546 + !st->significand[1] &&
36547 + !st->significand[2] &&
36548 + !st->significand[3] ) {
36549 + tag = 1; /* Zero */
36551 + tag = 2; /* Special */
36555 + if ( st->significand[3] & 0x8000 ) {
36556 + tag = 0; /* Valid */
36558 + tag = 2; /* Special */
36563 + tag = 3; /* Empty */
36565 + ret |= (tag << (2 * i));
36572 + * FXSR floating point environment conversions.
36575 +#ifdef CONFIG_MODE_TT
36576 +static inline int convert_fxsr_to_user_tt(struct _fpstate *buf,
36577 + struct pt_regs *regs)
36579 + struct i387_fxsave_struct *fxsave = SC_FXSR_ENV(PT_REGS_SC(regs));
36580 + unsigned long env[7];
36581 + struct _fpreg *to;
36582 + struct _fpxreg *from;
36585 + env[0] = (unsigned long)fxsave->cwd | 0xffff0000;
36586 + env[1] = (unsigned long)fxsave->swd | 0xffff0000;
36587 + env[2] = twd_fxsr_to_i387(fxsave);
36588 + env[3] = fxsave->fip;
36589 + env[4] = fxsave->fcs | ((unsigned long)fxsave->fop << 16);
36590 + env[5] = fxsave->foo;
36591 + env[6] = fxsave->fos;
36593 + if ( __copy_to_user( buf, env, 7 * sizeof(unsigned long) ) )
36596 + to = &buf->_st[0];
36597 + from = (struct _fpxreg *) &fxsave->st_space[0];
36598 + for ( i = 0 ; i < 8 ; i++, to++, from++ ) {
36599 + if ( __copy_to_user( to, from, sizeof(*to) ) )
36606 +static inline int convert_fxsr_to_user(struct _fpstate *buf,
36607 + struct pt_regs *regs)
36609 + return(CHOOSE_MODE(convert_fxsr_to_user_tt(buf, regs), 0));
36612 +#ifdef CONFIG_MODE_TT
36613 +static inline int convert_fxsr_from_user_tt(struct pt_regs *regs,
36614 + struct _fpstate *buf)
36616 + struct i387_fxsave_struct *fxsave = SC_FXSR_ENV(PT_REGS_SC(regs));
36617 + unsigned long env[7];
36618 + struct _fpxreg *to;
36619 + struct _fpreg *from;
36622 + if ( __copy_from_user( env, buf, 7 * sizeof(long) ) )
36625 + fxsave->cwd = (unsigned short)(env[0] & 0xffff);
36626 + fxsave->swd = (unsigned short)(env[1] & 0xffff);
36627 + fxsave->twd = twd_i387_to_fxsr((unsigned short)(env[2] & 0xffff));
36628 + fxsave->fip = env[3];
36629 + fxsave->fop = (unsigned short)((env[4] & 0xffff0000) >> 16);
36630 + fxsave->fcs = (env[4] & 0xffff);
36631 + fxsave->foo = env[5];
36632 + fxsave->fos = env[6];
36634 + to = (struct _fpxreg *) &fxsave->st_space[0];
36635 + from = &buf->_st[0];
36636 + for ( i = 0 ; i < 8 ; i++, to++, from++ ) {
36637 + if ( __copy_from_user( to, from, sizeof(*from) ) )
36644 +static inline int convert_fxsr_from_user(struct pt_regs *regs,
36645 + struct _fpstate *buf)
36647 + return(CHOOSE_MODE(convert_fxsr_from_user_tt(regs, buf), 0));
36650 +int get_fpregs(unsigned long buf, struct task_struct *child)
36654 + err = convert_fxsr_to_user((struct _fpstate *) buf,
36655 + &child->thread.regs);
36656 + if(err) return(-EFAULT);
36660 +int set_fpregs(unsigned long buf, struct task_struct *child)
36664 + err = convert_fxsr_from_user(&child->thread.regs,
36665 + (struct _fpstate *) buf);
36666 + if(err) return(-EFAULT);
36670 +#ifdef CONFIG_MODE_TT
36671 +int get_fpxregs_tt(unsigned long buf, struct task_struct *tsk)
36673 + struct pt_regs *regs = &tsk->thread.regs;
36674 + struct i387_fxsave_struct *fxsave = SC_FXSR_ENV(PT_REGS_SC(regs));
36677 + err = __copy_to_user((void *) buf, fxsave,
36678 + sizeof(struct user_fxsr_struct));
36679 + if(err) return -EFAULT;
36684 +int get_fpxregs(unsigned long buf, struct task_struct *tsk)
36686 + return(CHOOSE_MODE(get_fpxregs_tt(buf, tsk), 0));
36689 +#ifdef CONFIG_MODE_TT
36690 +int set_fpxregs_tt(unsigned long buf, struct task_struct *tsk)
36692 + struct pt_regs *regs = &tsk->thread.regs;
36693 + struct i387_fxsave_struct *fxsave = SC_FXSR_ENV(PT_REGS_SC(regs));
36696 + err = __copy_from_user(fxsave, (void *) buf,
36697 + sizeof(struct user_fxsr_struct) );
36698 + if(err) return -EFAULT;
36703 +int set_fpxregs(unsigned long buf, struct task_struct *tsk)
36705 + return(CHOOSE_MODE(set_fpxregs_tt(buf, tsk), 0));
36709 +int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
36711 + fpu->cwd = (((SC_FP_CW(PT_REGS_SC(regs)) & 0xffff) << 16) |
36712 + (SC_FP_SW(PT_REGS_SC(regs)) & 0xffff));
36713 + fpu->swd = SC_FP_CSSEL(PT_REGS_SC(regs)) & 0xffff;
36714 + fpu->twd = SC_FP_IPOFF(PT_REGS_SC(regs));
36715 + fpu->fip = SC_FP_CSSEL(PT_REGS_SC(regs)) & 0xffff;
36716 + fpu->fcs = SC_FP_DATAOFF(PT_REGS_SC(regs));
36717 + fpu->foo = SC_FP_DATASEL(PT_REGS_SC(regs));
36719 + memcpy(fpu->st_space, (void *) SC_FP_ST(PT_REGS_SC(regs)),
36720 + sizeof(fpu->st_space));
36725 +#ifdef CONFIG_MODE_TT
36726 +static inline void copy_fpu_fxsave_tt(struct pt_regs *regs,
36727 + struct user_i387_struct *buf)
36729 + struct i387_fxsave_struct *fpu = SC_FXSR_ENV(PT_REGS_SC(regs));
36730 + unsigned short *to;
36731 + unsigned short *from;
36734 + memcpy( buf, fpu, 7 * sizeof(long) );
36736 + to = (unsigned short *) &buf->st_space[0];
36737 + from = (unsigned short *) &fpu->st_space[0];
36738 + for ( i = 0 ; i < 8 ; i++, to += 5, from += 8 ) {
36739 + memcpy( to, from, 5 * sizeof(unsigned short) );
36744 +static inline void copy_fpu_fxsave(struct pt_regs *regs,
36745 + struct user_i387_struct *buf)
36747 + (void) CHOOSE_MODE(copy_fpu_fxsave_tt(regs, buf), 0);
36750 +int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu )
36752 + copy_fpu_fxsave(regs, (struct user_i387_struct *) fpu);
36757 + * Overrides for Emacs so that we follow Linus's tabbing style.
36758 + * Emacs will notice this stuff at the end of the file and automatically
36759 + * adjust the settings for this buffer only. This must remain at the end
36761 + * ---------------------------------------------------------------------------
36762 + * Local variables:
36763 + * c-file-style: "linux"
36766 diff -Naur -X ../exclude-files orig/arch/um/sys-i386/ptrace_user.c um/arch/um/sys-i386/ptrace_user.c
36767 --- orig/arch/um/sys-i386/ptrace_user.c 1969-12-31 19:00:00.000000000 -0500
36768 +++ um/arch/um/sys-i386/ptrace_user.c 2003-12-17 01:33:17.000000000 -0500
36771 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
36772 + * Licensed under the GPL
36775 +#include <stdio.h>
36776 +#include <errno.h>
36777 +#include <unistd.h>
36778 +#include <linux/stddef.h>
36779 +#include <sys/ptrace.h>
36780 +#include <asm/ptrace.h>
36781 +#include <asm/user.h>
36782 +#include "kern_util.h"
36783 +#include "sysdep/thread.h"
36787 +int ptrace_getregs(long pid, unsigned long *regs_out)
36789 + return(ptrace(PTRACE_GETREGS, pid, 0, regs_out));
36792 +int ptrace_setregs(long pid, unsigned long *regs)
36794 + return(ptrace(PTRACE_SETREGS, pid, 0, regs));
36797 +int ptrace_getfpregs(long pid, unsigned long *regs)
36799 + return(ptrace(PTRACE_GETFPREGS, pid, 0, regs));
36802 +static void write_debugregs(int pid, unsigned long *regs)
36804 + struct user *dummy;
36808 + nregs = sizeof(dummy->u_debugreg)/sizeof(dummy->u_debugreg[0]);
36809 + for(i = 0; i < nregs; i++){
36810 + if((i == 4) || (i == 5)) continue;
36811 + if(ptrace(PTRACE_POKEUSER, pid, &dummy->u_debugreg[i],
36813 + printk("write_debugregs - ptrace failed on "
36814 + "register %d, errno = %d\n", errno);
36818 +static void read_debugregs(int pid, unsigned long *regs)
36820 + struct user *dummy;
36824 + nregs = sizeof(dummy->u_debugreg)/sizeof(dummy->u_debugreg[0]);
36825 + for(i = 0; i < nregs; i++){
36826 + regs[i] = ptrace(PTRACE_PEEKUSER, pid,
36827 + &dummy->u_debugreg[i], 0);
36831 +/* Accessed only by the tracing thread */
36832 +static unsigned long kernel_debugregs[8] = { [ 0 ... 7 ] = 0 };
36833 +static int debugregs_seq = 0;
36835 +void arch_enter_kernel(void *task, int pid)
36837 + read_debugregs(pid, TASK_DEBUGREGS(task));
36838 + write_debugregs(pid, kernel_debugregs);
36841 +void arch_leave_kernel(void *task, int pid)
36843 + read_debugregs(pid, kernel_debugregs);
36844 + write_debugregs(pid, TASK_DEBUGREGS(task));
36847 +void ptrace_pokeuser(unsigned long addr, unsigned long data)
36849 + if((addr < offsetof(struct user, u_debugreg[0])) ||
36850 + (addr > offsetof(struct user, u_debugreg[7])))
36852 + addr -= offsetof(struct user, u_debugreg[0]);
36853 + addr = addr >> 2;
36854 + if(kernel_debugregs[addr] == data) return;
36856 + kernel_debugregs[addr] = data;
36860 +static void update_debugregs_cb(void *arg)
36862 + int pid = *((int *) arg);
36864 + write_debugregs(pid, kernel_debugregs);
36867 +void update_debugregs(int seq)
36871 + if(seq == debugregs_seq) return;
36873 + me = os_getpid();
36874 + initial_thread_cb(update_debugregs_cb, &me);
36878 + * Overrides for Emacs so that we follow Linus's tabbing style.
36879 + * Emacs will notice this stuff at the end of the file and automatically
36880 + * adjust the settings for this buffer only. This must remain at the end
36882 + * ---------------------------------------------------------------------------
36883 + * Local variables:
36884 + * c-file-style: "linux"
36887 diff -Naur -X ../exclude-files orig/arch/um/sys-i386/sigcontext.c um/arch/um/sys-i386/sigcontext.c
36888 --- orig/arch/um/sys-i386/sigcontext.c 1969-12-31 19:00:00.000000000 -0500
36889 +++ um/arch/um/sys-i386/sigcontext.c 2003-10-21 03:26:07.000000000 -0400
36892 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
36893 + * Licensed under the GPL
36896 +#include <stddef.h>
36897 +#include <string.h>
36898 +#include <asm/ptrace.h>
36899 +#include <asm/sigcontext.h>
36900 +#include "sysdep/ptrace.h"
36901 +#include "kern_util.h"
36902 +#include "frame_user.h"
36904 +int sc_size(void *data)
36906 + struct arch_frame_data *arch = data;
36908 + return(sizeof(struct sigcontext) + arch->fpstate_size);
36911 +void sc_to_sc(void *to_ptr, void *from_ptr)
36913 + struct sigcontext *to = to_ptr, *from = from_ptr;
36914 + int size = sizeof(*to) + signal_frame_sc.common.arch.fpstate_size;
36916 + memcpy(to, from, size);
36917 + if(from->fpstate != NULL) to->fpstate = (struct _fpstate *) (to + 1);
36920 +unsigned long *sc_sigmask(void *sc_ptr)
36922 + struct sigcontext *sc = sc_ptr;
36924 + return(&sc->oldmask);
36927 +int sc_get_fpregs(unsigned long buf, void *sc_ptr)
36929 + struct sigcontext *sc = sc_ptr;
36930 + struct _fpstate *from = sc->fpstate, *to = (struct _fpstate *) buf;
36933 + if(from == NULL){
36934 + err |= clear_user_proc(&to->cw, sizeof(to->cw));
36935 + err |= clear_user_proc(&to->sw, sizeof(to->sw));
36936 + err |= clear_user_proc(&to->tag, sizeof(to->tag));
36937 + err |= clear_user_proc(&to->ipoff, sizeof(to->ipoff));
36938 + err |= clear_user_proc(&to->cssel, sizeof(to->cssel));
36939 + err |= clear_user_proc(&to->dataoff, sizeof(to->dataoff));
36940 + err |= clear_user_proc(&to->datasel, sizeof(to->datasel));
36941 + err |= clear_user_proc(&to->_st, sizeof(to->_st));
36944 + err |= copy_to_user_proc(&to->cw, &from->cw, sizeof(to->cw));
36945 + err |= copy_to_user_proc(&to->sw, &from->sw, sizeof(to->sw));
36946 + err |= copy_to_user_proc(&to->tag, &from->tag,
36947 + sizeof(to->tag));
36948 + err |= copy_to_user_proc(&to->ipoff, &from->ipoff,
36949 + sizeof(to->ipoff));
36950 + err |= copy_to_user_proc(&to->cssel,& from->cssel,
36951 + sizeof(to->cssel));
36952 + err |= copy_to_user_proc(&to->dataoff, &from->dataoff,
36953 + sizeof(to->dataoff));
36954 + err |= copy_to_user_proc(&to->datasel, &from->datasel,
36955 + sizeof(to->datasel));
36956 + err |= copy_to_user_proc(to->_st, from->_st, sizeof(to->_st));
36962 + * Overrides for Emacs so that we follow Linus's tabbing style.
36963 + * Emacs will notice this stuff at the end of the file and automatically
36964 + * adjust the settings for this buffer only. This must remain at the end
36966 + * ---------------------------------------------------------------------------
36967 + * Local variables:
36968 + * c-file-style: "linux"
36971 diff -Naur -X ../exclude-files orig/arch/um/sys-i386/syscalls.c um/arch/um/sys-i386/syscalls.c
36972 --- orig/arch/um/sys-i386/syscalls.c 1969-12-31 19:00:00.000000000 -0500
36973 +++ um/arch/um/sys-i386/syscalls.c 2003-10-21 03:26:07.000000000 -0400
36976 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
36977 + * Licensed under the GPL
36980 +#include "asm/mman.h"
36981 +#include "asm/uaccess.h"
36982 +#include "asm/unistd.h"
36985 + * Perform the select(nd, in, out, ex, tv) and mmap() system
36986 + * calls. Linux/i386 didn't use to be able to handle more than
36987 + * 4 system call parameters, so these system calls used a memory
36988 + * block for parameter passing..
36991 +struct mmap_arg_struct {
36992 + unsigned long addr;
36993 + unsigned long len;
36994 + unsigned long prot;
36995 + unsigned long flags;
36996 + unsigned long fd;
36997 + unsigned long offset;
37000 +extern int old_mmap(unsigned long addr, unsigned long len,
37001 + unsigned long prot, unsigned long flags,
37002 + unsigned long fd, unsigned long offset);
37004 +int old_mmap_i386(struct mmap_arg_struct *arg)
37006 + struct mmap_arg_struct a;
37007 + int err = -EFAULT;
37009 + if (copy_from_user(&a, arg, sizeof(a)))
37012 + err = old_mmap(a.addr, a.len, a.prot, a.flags, a.fd, a.offset);
37017 +struct sel_arg_struct {
37019 + fd_set *inp, *outp, *exp;
37020 + struct timeval *tvp;
37023 +int old_select(struct sel_arg_struct *arg)
37025 + struct sel_arg_struct a;
37027 + if (copy_from_user(&a, arg, sizeof(a)))
37029 + /* sys_select() does the appropriate kernel locking */
37030 + return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
37034 + * Overrides for Emacs so that we follow Linus's tabbing style.
37035 + * Emacs will notice this stuff at the end of the file and automatically
37036 + * adjust the settings for this buffer only. This must remain at the end
37038 + * ---------------------------------------------------------------------------
37039 + * Local variables:
37040 + * c-file-style: "linux"
37043 diff -Naur -X ../exclude-files orig/arch/um/sys-i386/sysrq.c um/arch/um/sys-i386/sysrq.c
37044 --- orig/arch/um/sys-i386/sysrq.c 1969-12-31 19:00:00.000000000 -0500
37045 +++ um/arch/um/sys-i386/sysrq.c 2003-10-21 03:26:07.000000000 -0400
37047 +#include "linux/kernel.h"
37048 +#include "linux/smp.h"
37049 +#include "linux/sched.h"
37050 +#include "asm/ptrace.h"
37051 +#include "sysrq.h"
37053 +void show_regs(struct pt_regs *regs)
37056 + printk("EIP: %04lx:[<%08lx>] CPU: %d %s",
37057 + 0xffff & PT_REGS_CS(regs), PT_REGS_IP(regs),
37058 + smp_processor_id(), print_tainted());
37059 + if (PT_REGS_CS(regs) & 3)
37060 + printk(" ESP: %04lx:%08lx", 0xffff & PT_REGS_SS(regs),
37061 + PT_REGS_SP(regs));
37062 + printk(" EFLAGS: %08lx\n %s\n", PT_REGS_EFLAGS(regs),
37063 + print_tainted());
37064 + printk("EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
37065 + PT_REGS_EAX(regs), PT_REGS_EBX(regs),
37066 + PT_REGS_ECX(regs),
37067 + PT_REGS_EDX(regs));
37068 + printk("ESI: %08lx EDI: %08lx EBP: %08lx",
37069 + PT_REGS_ESI(regs), PT_REGS_EDI(regs),
37070 + PT_REGS_EBP(regs));
37071 + printk(" DS: %04lx ES: %04lx\n",
37072 + 0xffff & PT_REGS_DS(regs),
37073 + 0xffff & PT_REGS_ES(regs));
37075 + show_trace((unsigned long *) ®s);
37077 diff -Naur -X ../exclude-files orig/arch/um/sys-i386/time.c um/arch/um/sys-i386/time.c
37078 --- orig/arch/um/sys-i386/time.c 1969-12-31 19:00:00.000000000 -0500
37079 +++ um/arch/um/sys-i386/time.c 2003-11-10 01:46:49.000000000 -0500
37082 + * sys-i386/time.c
37083 + * Created 25.9.2002 Sapan Bhatia
37087 +unsigned long long time_stamp(void)
37089 + unsigned long low, high;
37091 + asm("rdtsc" : "=a" (low), "=d" (high));
37092 + return((((unsigned long long) high) << 32) + low);
37096 + * Overrides for Emacs so that we follow Linus's tabbing style.
37097 + * Emacs will notice this stuff at the end of the file and automatically
37098 + * adjust the settings for this buffer only. This must remain at the end
37100 + * ---------------------------------------------------------------------------
37101 + * Local variables:
37102 + * c-file-style: "linux"
37105 diff -Naur -X ../exclude-files orig/arch/um/sys-i386/util/Makefile um/arch/um/sys-i386/util/Makefile
37106 --- orig/arch/um/sys-i386/util/Makefile 1969-12-31 19:00:00.000000000 -0500
37107 +++ um/arch/um/sys-i386/util/Makefile 2003-11-08 08:26:40.000000000 -0500
37109 +EXE = mk_sc mk_thread
37111 +include $(TOPDIR)/Rules.make
37116 + $(HOSTCC) -o mk_sc mk_sc.o
37121 +mk_thread : mk_thread_user.o mk_thread_kern.o
37122 + $(HOSTCC) -o mk_thread mk_thread_user.o mk_thread_kern.o
37124 +mk_thread_user.o : mk_thread_user.c
37127 +mk_thread_kern.o : mk_thread_kern.c
37128 + $(HOSTCC) $(CFLAGS) -c $<
37133 +archmrproper : clean
37137 diff -Naur -X ../exclude-files orig/arch/um/sys-i386/util/mk_sc.c um/arch/um/sys-i386/util/mk_sc.c
37138 --- orig/arch/um/sys-i386/util/mk_sc.c 1969-12-31 19:00:00.000000000 -0500
37139 +++ um/arch/um/sys-i386/util/mk_sc.c 2003-10-21 03:26:07.000000000 -0400
37141 +#include <stdio.h>
37142 +#include <signal.h>
37143 +#include <linux/stddef.h>
37145 +#define SC_OFFSET(name, field) \
37146 + printf("#define " name "(sc) *((unsigned long *) &(((char *) (sc))[%d]))\n",\
37147 + offsetof(struct sigcontext, field))
37149 +#define SC_FP_OFFSET(name, field) \
37150 + printf("#define " name \
37151 + "(sc) *((unsigned long *) &(((char *) (SC_FPSTATE(sc)))[%d]))\n",\
37152 + offsetof(struct _fpstate, field))
37154 +#define SC_FP_OFFSET_PTR(name, field, type) \
37155 + printf("#define " name \
37156 + "(sc) ((" type " *) &(((char *) (SC_FPSTATE(sc)))[%d]))\n",\
37157 + offsetof(struct _fpstate, field))
37159 +int main(int argc, char **argv)
37161 + SC_OFFSET("SC_IP", eip);
37162 + SC_OFFSET("SC_SP", esp);
37163 + SC_OFFSET("SC_FS", fs);
37164 + SC_OFFSET("SC_GS", gs);
37165 + SC_OFFSET("SC_DS", ds);
37166 + SC_OFFSET("SC_ES", es);
37167 + SC_OFFSET("SC_SS", ss);
37168 + SC_OFFSET("SC_CS", cs);
37169 + SC_OFFSET("SC_EFLAGS", eflags);
37170 + SC_OFFSET("SC_EAX", eax);
37171 + SC_OFFSET("SC_EBX", ebx);
37172 + SC_OFFSET("SC_ECX", ecx);
37173 + SC_OFFSET("SC_EDX", edx);
37174 + SC_OFFSET("SC_EDI", edi);
37175 + SC_OFFSET("SC_ESI", esi);
37176 + SC_OFFSET("SC_EBP", ebp);
37177 + SC_OFFSET("SC_TRAPNO", trapno);
37178 + SC_OFFSET("SC_ERR", err);
37179 + SC_OFFSET("SC_CR2", cr2);
37180 + SC_OFFSET("SC_FPSTATE", fpstate);
37181 + SC_OFFSET("SC_SIGMASK", oldmask);
37182 + SC_FP_OFFSET("SC_FP_CW", cw);
37183 + SC_FP_OFFSET("SC_FP_SW", sw);
37184 + SC_FP_OFFSET("SC_FP_TAG", tag);
37185 + SC_FP_OFFSET("SC_FP_IPOFF", ipoff);
37186 + SC_FP_OFFSET("SC_FP_CSSEL", cssel);
37187 + SC_FP_OFFSET("SC_FP_DATAOFF", dataoff);
37188 + SC_FP_OFFSET("SC_FP_DATASEL", datasel);
37189 + SC_FP_OFFSET_PTR("SC_FP_ST", _st, "struct _fpstate");
37190 + SC_FP_OFFSET_PTR("SC_FXSR_ENV", _fxsr_env, "void");
37193 diff -Naur -X ../exclude-files orig/arch/um/sys-i386/util/mk_thread_kern.c um/arch/um/sys-i386/util/mk_thread_kern.c
37194 --- orig/arch/um/sys-i386/util/mk_thread_kern.c 1969-12-31 19:00:00.000000000 -0500
37195 +++ um/arch/um/sys-i386/util/mk_thread_kern.c 2003-10-21 03:26:07.000000000 -0400
37197 +#include "linux/config.h"
37198 +#include "linux/stddef.h"
37199 +#include "linux/sched.h"
37201 +extern void print_head(void);
37202 +extern void print_constant_ptr(char *name, int value);
37203 +extern void print_constant(char *name, char *type, int value);
37204 +extern void print_tail(void);
37206 +#define THREAD_OFFSET(field) offsetof(struct task_struct, thread.field)
37208 +int main(int argc, char **argv)
37211 + print_constant_ptr("TASK_DEBUGREGS", THREAD_OFFSET(arch.debugregs));
37212 +#ifdef CONFIG_MODE_TT
37213 + print_constant("TASK_EXTERN_PID", "int", THREAD_OFFSET(mode.tt.extern_pid));
37219 diff -Naur -X ../exclude-files orig/arch/um/sys-i386/util/mk_thread_user.c um/arch/um/sys-i386/util/mk_thread_user.c
37220 --- orig/arch/um/sys-i386/util/mk_thread_user.c 1969-12-31 19:00:00.000000000 -0500
37221 +++ um/arch/um/sys-i386/util/mk_thread_user.c 2003-10-21 03:26:07.000000000 -0400
37223 +#include <stdio.h>
37225 +void print_head(void)
37228 + printf(" * Generated by mk_thread\n");
37231 + printf("#ifndef __UM_THREAD_H\n");
37232 + printf("#define __UM_THREAD_H\n");
37236 +void print_constant_ptr(char *name, int value)
37238 + printf("#define %s(task) ((unsigned long *) "
37239 + "&(((char *) (task))[%d]))\n", name, value);
37242 +void print_constant(char *name, char *type, int value)
37244 + printf("#define %s(task) *((%s *) &(((char *) (task))[%d]))\n", name, type,
37248 +void print_tail(void)
37251 + printf("#endif\n");
37253 diff -Naur -X ../exclude-files orig/arch/um/sys-ia64/Makefile um/arch/um/sys-ia64/Makefile
37254 --- orig/arch/um/sys-ia64/Makefile 1969-12-31 19:00:00.000000000 -0500
37255 +++ um/arch/um/sys-ia64/Makefile 2003-10-21 03:26:07.000000000 -0400
37265 + $(LD) $(LINKFLAGS) --start-group $^ --end-group -o $@
37275 + @$(MAKEBOOT) clean
37282 +include $(TOPDIR)/Rules.make
37283 diff -Naur -X ../exclude-files orig/arch/um/sys-ppc/Makefile um/arch/um/sys-ppc/Makefile
37284 --- orig/arch/um/sys-ppc/Makefile 1969-12-31 19:00:00.000000000 -0500
37285 +++ um/arch/um/sys-ppc/Makefile 2003-10-21 03:26:07.000000000 -0400
37290 + $(CC) $(AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o
37292 +OBJS = ptrace.o sigcontext.o semaphore.o checksum.o miscthings.o misc.o \
37293 + ptrace_user.o sysrq.o
37295 +EXTRA_AFLAGS := -DCONFIG_ALL_PPC -I. -I$(TOPDIR)/arch/ppc/kernel
37301 + $(LD) $(LINKFLAGS) --start-group $^ --end-group -o $@
37303 +ptrace_user.o: ptrace_user.c
37304 + $(CC) -D__KERNEL__ $(USER_CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
37306 +sigcontext.o: sigcontext.c
37307 + $(CC) $(USER_CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
37311 + ln -s $(TOPDIR)/arch/ppc/kernel/$@ $@
37315 + ln -s $(TOPDIR)/arch/ppc/lib/$@ $@
37319 + ln -s $(TOPDIR)/arch/ppc/kernel/$@ $@
37323 + ln -s $(TOPDIR)/arch/ppc/kernel/$@ $@
37325 +ppc_defs.h: mk_defs.c ppc_defs.head \
37326 + $(TOPDIR)/include/asm-ppc/mmu.h \
37327 + $(TOPDIR)/include/asm-ppc/processor.h \
37328 + $(TOPDIR)/include/asm-ppc/pgtable.h \
37329 + $(TOPDIR)/include/asm-ppc/ptrace.h
37330 +# $(CC) $(CFLAGS) -S mk_defs.c
37331 + cp ppc_defs.head ppc_defs.h
37332 +# for bk, this way we can write to the file even if it's not checked out
37333 + echo '#define THREAD 608' >> ppc_defs.h
37334 + echo '#define PT_REGS 8' >> ppc_defs.h
37335 + echo '#define CLONE_VM 256' >> ppc_defs.h
37336 +# chmod u+w ppc_defs.h
37337 +# grep '^#define' mk_defs.s >> ppc_defs.h
37340 +# the asm link is horrible, and breaks the other targets. This is also
37341 +# not going to work with parallel makes.
37343 +checksum.o: checksum.S
37345 + ln -s $(TOPDIR)/include/asm-ppc asm
37346 + $(CC) $(EXTRA_AFLAGS) $(AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o
37349 +misc.o: misc.S ppc_defs.h
37351 + ln -s $(TOPDIR)/include/asm-ppc asm
37352 + $(CC) $(EXTRA_AFLAGS) $(AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o
37358 + rm -f checksum.S semaphore.c mk_defs.c
37366 +include $(TOPDIR)/Rules.make
37367 diff -Naur -X ../exclude-files orig/arch/um/sys-ppc/misc.S um/arch/um/sys-ppc/misc.S
37368 --- orig/arch/um/sys-ppc/misc.S 1969-12-31 19:00:00.000000000 -0500
37369 +++ um/arch/um/sys-ppc/misc.S 2003-10-21 03:26:07.000000000 -0400
37372 + * This file contains miscellaneous low-level functions.
37373 + * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
37375 + * Largely rewritten by Cort Dougan (cort@cs.nmt.edu)
37376 + * and Paul Mackerras.
37378 + * A couple of functions stolen from arch/ppc/kernel/misc.S for UML
37379 + * by Chris Emerson.
37381 + * This program is free software; you can redistribute it and/or
37382 + * modify it under the terms of the GNU General Public License
37383 + * as published by the Free Software Foundation; either version
37384 + * 2 of the License, or (at your option) any later version.
37388 +#include <linux/config.h>
37389 +#include <asm/processor.h>
37390 +#include "ppc_asm.h"
37392 +#if defined(CONFIG_4xx) || defined(CONFIG_8xx)
37393 +#define CACHE_LINE_SIZE 16
37394 +#define LG_CACHE_LINE_SIZE 4
37395 +#define MAX_COPY_PREFETCH 1
37396 +#elif !defined(CONFIG_PPC64BRIDGE)
37397 +#define CACHE_LINE_SIZE 32
37398 +#define LG_CACHE_LINE_SIZE 5
37399 +#define MAX_COPY_PREFETCH 4
37401 +#define CACHE_LINE_SIZE 128
37402 +#define LG_CACHE_LINE_SIZE 7
37403 +#define MAX_COPY_PREFETCH 1
37404 +#endif /* CONFIG_4xx || CONFIG_8xx */
37409 + * Clear a page using the dcbz instruction, which doesn't cause any
37410 + * memory traffic (except to write out any cache lines which get
37411 + * displaced). This only works on cacheable memory.
37413 +_GLOBAL(clear_page)
37414 + li r0,4096/CACHE_LINE_SIZE
37425 + addi r3,r3,CACHE_LINE_SIZE
37430 + * Copy a whole page. We use the dcbz instruction on the destination
37431 + * to reduce memory traffic (it eliminates the unnecessary reads of
37432 + * the destination into cache). This requires that the destination
37435 +#define COPY_16_BYTES \
37439 + lwzu r9,16(r4); \
37445 +_GLOBAL(copy_page)
37450 +#ifndef CONFIG_8xx
37451 +#if MAX_COPY_PREFETCH > 1
37452 + li r0,MAX_COPY_PREFETCH
37456 + addi r11,r11,CACHE_LINE_SIZE
37458 +#else /* MAX_COPY_PREFETCH == 1 */
37460 + li r11,CACHE_LINE_SIZE+4
37461 +#endif /* MAX_COPY_PREFETCH */
37462 +#endif /* CONFIG_8xx */
37464 + li r0,4096/CACHE_LINE_SIZE
37467 +#ifndef CONFIG_8xx
37472 +#if CACHE_LINE_SIZE >= 32
37474 +#if CACHE_LINE_SIZE >= 64
37477 +#if CACHE_LINE_SIZE >= 128
37487 diff -Naur -X ../exclude-files orig/arch/um/sys-ppc/miscthings.c um/arch/um/sys-ppc/miscthings.c
37488 --- orig/arch/um/sys-ppc/miscthings.c 1969-12-31 19:00:00.000000000 -0500
37489 +++ um/arch/um/sys-ppc/miscthings.c 2003-10-21 03:26:07.000000000 -0400
37491 +#include "linux/threads.h"
37492 +#include "linux/stddef.h" // for NULL
37493 +#include "linux/elf.h" // for AT_NULL
37495 +/* The following function nicked from arch/ppc/kernel/process.c and
37496 + * adapted slightly */
37498 + * XXX ld.so expects the auxiliary table to start on
37499 + * a 16-byte boundary, so we have to find it and
37500 + * move it up. :-(
37502 +void shove_aux_table(unsigned long sp)
37507 + unsigned long aux_start, offset;
37509 + argc = *(int *)sp;
37510 + sp += sizeof(int) + (argc + 1) * sizeof(char *);
37511 + /* skip over the environment pointers */
37513 + p = *(char **)sp;
37514 + sp += sizeof(char *);
37515 + } while (p != NULL);
37517 + /* skip to the end of the auxiliary table */
37519 + e = *(unsigned long *)sp;
37520 + sp += 2 * sizeof(unsigned long);
37521 + } while (e != AT_NULL);
37522 + offset = ((aux_start + 15) & ~15) - aux_start;
37523 + if (offset != 0) {
37525 + sp -= sizeof(unsigned long);
37526 + e = *(unsigned long *)sp;
37527 + *(unsigned long *)(sp + offset) = e;
37528 + } while (sp > aux_start);
37531 +/* END stuff taken from arch/ppc/kernel/process.c */
37535 + * Overrides for Emacs so that we follow Linus's tabbing style.
37536 + * Emacs will notice this stuff at the end of the file and automatically
37537 + * adjust the settings for this buffer only. This must remain at the end
37539 + * ---------------------------------------------------------------------------
37540 + * Local variables:
37541 + * c-file-style: "linux"
37544 diff -Naur -X ../exclude-files orig/arch/um/sys-ppc/ptrace.c um/arch/um/sys-ppc/ptrace.c
37545 --- orig/arch/um/sys-ppc/ptrace.c 1969-12-31 19:00:00.000000000 -0500
37546 +++ um/arch/um/sys-ppc/ptrace.c 2003-10-21 03:26:07.000000000 -0400
37548 +#include "linux/sched.h"
37549 +#include "asm/ptrace.h"
37551 +int putreg(struct task_struct *child, unsigned long regno,
37552 + unsigned long value)
37554 + child->thread.process_regs.regs[regno >> 2] = value;
37558 +unsigned long getreg(struct task_struct *child, unsigned long regno)
37560 + unsigned long retval = ~0UL;
37562 + retval &= child->thread.process_regs.regs[regno >> 2];
37567 + * Overrides for Emacs so that we follow Linus's tabbing style.
37568 + * Emacs will notice this stuff at the end of the file and automatically
37569 + * adjust the settings for this buffer only. This must remain at the end
37571 + * ---------------------------------------------------------------------------
37572 + * Local variables:
37573 + * c-file-style: "linux"
37576 diff -Naur -X ../exclude-files orig/arch/um/sys-ppc/ptrace_user.c um/arch/um/sys-ppc/ptrace_user.c
37577 --- orig/arch/um/sys-ppc/ptrace_user.c 1969-12-31 19:00:00.000000000 -0500
37578 +++ um/arch/um/sys-ppc/ptrace_user.c 2003-10-21 03:26:07.000000000 -0400
37580 +#include <sys/ptrace.h>
37581 +#include <errno.h>
37582 +#include <asm/ptrace.h>
37583 +#include "sysdep/ptrace.h"
37585 +int ptrace_getregs(long pid, unsigned long *regs_out)
37588 + for (i=0; i < sizeof(struct sys_pt_regs)/sizeof(PPC_REG); ++i) {
37590 + regs_out->regs[i] = ptrace(PTRACE_PEEKUSER, pid, i*4, 0);
37598 +int ptrace_setregs(long pid, unsigned long *regs_in)
37601 + for (i=0; i < sizeof(struct sys_pt_regs)/sizeof(PPC_REG); ++i) {
37602 + if (i != 34 /* FIXME: PT_ORIG_R3 */ && i <= PT_MQ) {
37603 + if (ptrace(PTRACE_POKEUSER, pid, i*4, regs_in->regs[i]) < 0) {
37611 + * Overrides for Emacs so that we follow Linus's tabbing style.
37612 + * Emacs will notice this stuff at the end of the file and automatically
37613 + * adjust the settings for this buffer only. This must remain at the end
37615 + * ---------------------------------------------------------------------------
37616 + * Local variables:
37617 + * c-file-style: "linux"
37620 diff -Naur -X ../exclude-files orig/arch/um/sys-ppc/sigcontext.c um/arch/um/sys-ppc/sigcontext.c
37621 --- orig/arch/um/sys-ppc/sigcontext.c 1969-12-31 19:00:00.000000000 -0500
37622 +++ um/arch/um/sys-ppc/sigcontext.c 2003-10-21 03:26:07.000000000 -0400
37624 +#include "asm/ptrace.h"
37625 +#include "asm/sigcontext.h"
37626 +#include "sysdep/ptrace.h"
37627 +#include "user_util.h"
37630 + * Overrides for Emacs so that we follow Linus's tabbing style.
37631 + * Emacs will notice this stuff at the end of the file and automatically
37632 + * adjust the settings for this buffer only. This must remain at the end
37634 + * ---------------------------------------------------------------------------
37635 + * Local variables:
37636 + * c-file-style: "linux"
37639 diff -Naur -X ../exclude-files orig/arch/um/sys-ppc/sysrq.c um/arch/um/sys-ppc/sysrq.c
37640 --- orig/arch/um/sys-ppc/sysrq.c 1969-12-31 19:00:00.000000000 -0500
37641 +++ um/arch/um/sys-ppc/sysrq.c 2003-10-21 03:26:07.000000000 -0400
37644 + * Copyright (C) 2001 Chris Emerson (cemerson@chiark.greenend.org.uk)
37645 + * Licensed under the GPL
37648 +#include "linux/kernel.h"
37649 +#include "linux/smp.h"
37650 +#include "asm/ptrace.h"
37651 +#include "sysrq.h"
37653 +void show_regs(struct pt_regs_subarch *regs)
37656 + printk("show_regs(): insert regs here.\n");
37659 + printk("EIP: %04x:[<%08lx>] CPU: %d",0xffff & regs->xcs, regs->eip,
37660 + smp_processor_id());
37661 + if (regs->xcs & 3)
37662 + printk(" ESP: %04x:%08lx",0xffff & regs->xss, regs->esp);
37663 + printk(" EFLAGS: %08lx\n", regs->eflags);
37664 + printk("EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
37665 + regs->eax, regs->ebx, regs->ecx, regs->edx);
37666 + printk("ESI: %08lx EDI: %08lx EBP: %08lx",
37667 + regs->esi, regs->edi, regs->ebp);
37668 + printk(" DS: %04x ES: %04x\n",
37669 + 0xffff & regs->xds, 0xffff & regs->xes);
37672 + show_trace(®s->gpr[1]);
37677 + * Overrides for Emacs so that we follow Linus's tabbing style.
37678 + * Emacs will notice this stuff at the end of the file and automatically
37679 + * adjust the settings for this buffer only. This must remain at the end
37681 + * ---------------------------------------------------------------------------
37682 + * Local variables:
37683 + * c-file-style: "linux"
37686 diff -Naur -X ../exclude-files orig/arch/um/util/Makefile um/arch/um/util/Makefile
37687 --- orig/arch/um/util/Makefile 1969-12-31 19:00:00.000000000 -0500
37688 +++ um/arch/um/util/Makefile 2003-11-08 02:51:30.000000000 -0500
37690 +ALL = mk_task mk_constants
37694 +mk_task : mk_task_user.o mk_task_kern.o
37695 + $(HOSTCC) -o mk_task mk_task_user.o mk_task_kern.o
37697 +mk_task_user.o : mk_task_user.c
37700 +mk_task_kern.o : mk_task_kern.c
37701 + $(HOSTCC) $(CFLAGS) -c $<
37703 +mk_constants : mk_constants_user.o mk_constants_kern.o
37704 + $(HOSTCC) -o mk_constants mk_constants_user.o mk_constants_kern.o
37706 +mk_constants_user.o : mk_constants_user.c
37709 +mk_constants_kern.o : mk_constants_kern.c
37710 + $(HOSTCC) $(CFLAGS) -c $<
37713 + $(RM) $(ALL) *.o *~
37715 +archmrproper : clean
37716 diff -Naur -X ../exclude-files orig/arch/um/util/mk_constants_kern.c um/arch/um/util/mk_constants_kern.c
37717 --- orig/arch/um/util/mk_constants_kern.c 1969-12-31 19:00:00.000000000 -0500
37718 +++ um/arch/um/util/mk_constants_kern.c 2004-01-10 06:54:51.000000000 -0500
37720 +#include "linux/kernel.h"
37721 +#include "linux/stringify.h"
37722 +#include "asm/page.h"
37724 +extern void print_head(void);
37725 +extern void print_constant_str(char *name, char *value);
37726 +extern void print_constant_int(char *name, int value);
37727 +extern void print_tail(void);
37729 +int main(int argc, char **argv)
37732 + print_constant_int("UM_KERN_PAGE_SIZE", PAGE_SIZE);
37734 + print_constant_str("UM_KERN_EMERG", KERN_EMERG);
37735 + print_constant_str("UM_KERN_ALERT", KERN_ALERT);
37736 + print_constant_str("UM_KERN_CRIT", KERN_CRIT);
37737 + print_constant_str("UM_KERN_ERR", KERN_ERR);
37738 + print_constant_str("UM_KERN_WARNING", KERN_WARNING);
37739 + print_constant_str("UM_KERN_NOTICE", KERN_NOTICE);
37740 + print_constant_str("UM_KERN_INFO", KERN_INFO);
37741 + print_constant_str("UM_KERN_DEBUG", KERN_DEBUG);
37745 diff -Naur -X ../exclude-files orig/arch/um/util/mk_constants_user.c um/arch/um/util/mk_constants_user.c
37746 --- orig/arch/um/util/mk_constants_user.c 1969-12-31 19:00:00.000000000 -0500
37747 +++ um/arch/um/util/mk_constants_user.c 2003-10-21 03:26:07.000000000 -0400
37749 +#include <stdio.h>
37751 +void print_head(void)
37754 + printf(" * Generated by mk_constants\n");
37757 + printf("#ifndef __UM_CONSTANTS_H\n");
37758 + printf("#define __UM_CONSTANTS_H\n");
37762 +void print_constant_str(char *name, char *value)
37764 + printf("#define %s \"%s\"\n", name, value);
37767 +void print_constant_int(char *name, int value)
37769 + printf("#define %s %d\n", name, value);
37772 +void print_tail(void)
37775 + printf("#endif\n");
37777 diff -Naur -X ../exclude-files orig/arch/um/util/mk_task_kern.c um/arch/um/util/mk_task_kern.c
37778 --- orig/arch/um/util/mk_task_kern.c 1969-12-31 19:00:00.000000000 -0500
37779 +++ um/arch/um/util/mk_task_kern.c 2003-10-21 03:26:07.000000000 -0400
37781 +#include "linux/sched.h"
37782 +#include "linux/stddef.h"
37784 +extern void print(char *name, char *type, int offset);
37785 +extern void print_ptr(char *name, char *type, int offset);
37786 +extern void print_head(void);
37787 +extern void print_tail(void);
37789 +int main(int argc, char **argv)
37792 + print_ptr("TASK_REGS", "union uml_pt_regs",
37793 + offsetof(struct task_struct, thread.regs));
37794 + print("TASK_PID", "int", offsetof(struct task_struct, pid));
37798 diff -Naur -X ../exclude-files orig/arch/um/util/mk_task_user.c um/arch/um/util/mk_task_user.c
37799 --- orig/arch/um/util/mk_task_user.c 1969-12-31 19:00:00.000000000 -0500
37800 +++ um/arch/um/util/mk_task_user.c 2003-10-21 03:26:07.000000000 -0400
37802 +#include <stdio.h>
37804 +void print(char *name, char *type, int offset)
37806 + printf("#define %s(task) *((%s *) &(((char *) (task))[%d]))\n", name, type,
37810 +void print_ptr(char *name, char *type, int offset)
37812 + printf("#define %s(task) ((%s *) &(((char *) (task))[%d]))\n", name, type,
37816 +void print_head(void)
37819 + printf(" * Generated by mk_task\n");
37822 + printf("#ifndef __TASK_H\n");
37823 + printf("#define __TASK_H\n");
37827 +void print_tail(void)
37830 + printf("#endif\n");
37832 diff -Naur -X ../exclude-files orig/CREDITS um/CREDITS
37833 --- orig/CREDITS 2003-12-16 22:16:23.000000000 -0500
37834 +++ um/CREDITS 2003-12-16 22:17:22.000000000 -0500
37835 @@ -434,6 +434,7 @@
37837 W: http://lars.nocrew.org/
37838 D: dsp56k device driver
37839 +D: ptrace proxy in user mode kernel port
37843 @@ -719,7 +720,7 @@
37844 E: jdike@karaya.com
37845 W: http://user-mode-linux.sourceforge.net
37846 D: User mode kernel port
37848 +S: 375 Tubbs Hill Rd
37849 S: Deering NH 03244
37852 diff -Naur -X ../exclude-files orig/Documentation/Configure.help um/Documentation/Configure.help
37853 --- orig/Documentation/Configure.help 2003-12-16 22:16:23.000000000 -0500
37854 +++ um/Documentation/Configure.help 2003-12-16 22:17:22.000000000 -0500
37855 @@ -15821,6 +15821,63 @@
37856 The module will be called speedtch.o. If you want to compile it as
37857 a module, say M here and read <file:Documentation/modules.txt>.
37859 +Support for /proc/mm
37861 + Enables support for address space separation through /proc/mm.
37862 + A host kernel needs to have this enabled in order for UML to
37863 + run in skas mode. UML kernels do not need to have this option
37864 + unless they will host sub-UMLs.
37866 + If you don't know what this does just say Y.
37868 +Separate Kernel Address Space support
37870 + This option controls whether skas (separate kernel address space)
37871 + support is compiled in. If you have applied the skas patch to the
37872 + host and enabled support for /proc/mm in the host kernel, then you
37873 + certainly want to say Y here (and consider saying N to
37874 + CONFIG_MODE_TT). Otherwise, it is safe to say Y. Disabling this
37875 + option will shrink the UML binary slightly.
37877 +Tracing thread support
37879 + This option controls whether tracing thread support is compiled
37880 + into UML. Normally, this should be set to Y. If you intend to
37881 + use only skas mode (and the host has the skas patch applied to it),
37882 + then it is OK to say N here.
37884 +Force a static link
37885 +CONFIG_STATIC_LINK
37886 + If CONFIG_MODE_TT is disabled, then this option gives you the ability
37887 + to force a static link of UML. Normally, if only skas mode is built
37888 + in to UML, it will be linked as a shared binary. This is inconvenient
37889 + for use in a chroot jail. So, if you intend to run UML inside a
37890 + chroot, and you disable CONFIG_MODE_TT, you probably want to say Y
37893 +2G/2G host address space split
37895 + Most Linux machines are configured so that the kernel occupies the
37896 + upper 1G of the 4G address space and processes use the lower 3G.
37897 + However, some machine are configured with a 2G/2G split, with the
37898 + kernel occupying the upper 2G and processes using the lower 2G.
37900 + To allow UML to run on a such host you have to say Y here. N should be
37901 + a safe choice most of the time.
37903 +Kernel stack size order
37904 +CONFIG_KERNEL_STACK_ORDER
37905 + This option determines the size of UML kernel stacks. They will
37906 + be 1 << order pages. The default is OK unless you're running Valgrind
37907 + on UML, in which case, set this to 3.
37909 +UML ubd block driver
37910 +CONFIG_BLK_DEV_UBD
37911 + The User-Mode Linux port includes a driver called UBD which will let
37912 + you access arbitrary files on the host computer as block devices.
37913 + Unless you know that you do not need such virtual block devices say
37917 USB is a master/slave protocol, organized with one master
37918 host (such as a PC) controlling up to 127 peripheral devices.
37919 @@ -15905,17 +15962,15 @@
37921 Always do synchronous disk IO for UBD
37922 CONFIG_BLK_DEV_UBD_SYNC
37923 - The User-Mode Linux port includes a driver called UBD which will let
37924 - you access arbitrary files on the host computer as block devices.
37925 - Writes to such a block device are not immediately written to the
37926 - host's disk; this may cause problems if, for example, the User-Mode
37927 - Linux 'Virtual Machine' uses a journalling file system and the host
37928 - computer crashes.
37929 + Writes to the virtual block device are not immediately written to the host's
37930 + disk; this may cause problems if, for example, the User-Mode Linux
37931 + 'Virtual Machine' uses a journalling filesystem and the host computer
37934 Synchronous operation (i.e. always writing data to the host's disk
37935 immediately) is configurable on a per-UBD basis by using a special
37936 kernel command line option. Alternatively, you can say Y here to
37937 - turn on synchronous operation by default for all block.
37938 + turn on synchronous operation by default for all block devices.
37940 If you're running a journalling file system (like reiserfs, for
37941 example) in your virtual machine, you will want to say Y here. If
37942 @@ -15927,6 +15982,7 @@
37944 This option enables a debugging interface which allows gdb to debug
37945 the kernel without needing to actually attach to kernel threads.
37946 + CONFIG_XTERM_CHAN must be enabled in order to enable CONFIG_PT_PROXY.
37947 If you want to do kernel debugging, say Y here; otherwise say N.
37950 @@ -15959,7 +16015,7 @@
37951 This option allows developers to retrieve coverage data from a UML
37954 - See <http://user-mode-linux.sourceforge.net/gcov.html> for more
37955 + See <http://user-mode-linux.sourceforge.net/gprof.html> for more
37958 If you're involved in UML kernel development and want to use gcov,
37959 @@ -15996,6 +16052,19 @@
37960 If you'd like to be able to work with files stored on the host,
37961 say Y or M here; otherwise say N.
37965 + hppfs (HoneyPot ProcFS) is a filesystem which allows UML /proc
37966 + entries to be overridden, removed, or fabricated from the host.
37967 + Its purpose is to allow a UML to appear to be a physical machine
37968 + by removing or changing anything in /proc which gives away the
37969 + identity of a UML.
37971 + See <http://user-mode-linux.sf.net/hppfs.html> for more information.
37973 + You only need this if you are setting up a UML honeypot. Otherwise,
37974 + it is safe to say 'N' here.
37976 Example IO Memory driver
37978 The User-Mode Linux port can provide support for IO Memory
37979 @@ -16011,6 +16080,21 @@
37980 If you'd like to be able to provide a simulated IO port space for
37981 User-Mode Linux processes, say Y. If unsure, say N.
37983 +Anonymous Memory support
37985 + Don't ask. Just say Y.
37987 +Support for software watchdog inside UML
37988 +CONFIG_UML_WATCHDOG
37989 + Support for a virtual hardware watchdog. It's safe to say N here.
37993 + This is a layered driver which sits above two other block devices.
37994 + One is read-only, and the other is a read-write layer which stores
37995 + all changes. This provides the illusion that the read-only layer
37996 + can be mounted read-write and changed.
37998 Virtual Serial Line
38000 The User-Mode Linux environment allows you to create virtual serial
38001 @@ -16121,26 +16205,197 @@
38004 CONFIG_UML_NET_SLIP
38005 - The Slip User-Mode Linux network transport allows a running UML to
38006 + The slip User-Mode Linux network transport allows a running UML to
38007 network with its host over a point-to-point link. Unlike Ethertap,
38008 which can carry any Ethernet frame (and hence even non-IP packets),
38009 - the Slip transport can only carry IP packets.
38010 + the slip transport can only carry IP packets.
38012 - To use this, your host must support Slip devices.
38013 + To use this, your host must support slip devices.
38015 For more information, see
38016 <http://user-mode-linux.sourceforge.net/networking.html>. That site
38017 - has examples of the UML command line to use to enable Slip
38018 + has examples of the UML command line to use to enable slip
38019 networking, and details of a few quirks with it.
38021 - The Ethertap Transport is preferred over Slip because of its
38022 - limitation. If you prefer Slip, however, say Y here. Otherwise
38023 + The Ethertap Transport is preferred over slip because of its
38024 + limitations. If you prefer slip, however, say Y here. Otherwise
38025 choose the Multicast transport (to network multiple UMLs on
38026 multiple hosts), Ethertap (to network with the host and the
38027 outside world), and/or the Daemon transport (to network multiple
38028 UMLs on a single host). You may choose more than one without
38029 conflict. If you don't need UML networking, say N.
38032 +CONFIG_UML_NET_SLIRP
38033 + The SLiRP User-Mode Linux network transport allows a running UML
38034 + to network by invoking a program that can handle SLIP encapsulated
38035 + packets. This is commonly (but not limited to) the application
38036 + known as SLiRP, a program that can re-socket IP packets back onto
38037 + the host on which it is run. Only IP packets are supported,
38038 + unlike other network transports that can handle all Ethernet
38039 + frames. In general, slirp allows the UML the same IP connectivity
38040 + to the outside world that the host user is permitted, and unlike
38041 + other transports, SLiRP works without the need of root level
38042 + privleges, setuid binaries, or SLIP devices on the host. This
38043 + also means not every type of connection is possible, but most
38044 + situations can be accomodated with carefully crafted slirp
38045 + commands that can be passed along as part of the network device's
38046 + setup string. The effect of this transport on the UML is similar
38047 + that of a host behind a firewall that masquerades all network
38048 + connections passing through it (but is less secure).
38050 + To use this you should first have slirp compiled somewhere
38051 + accessible on the host, and have read its documentation. If you
38052 + don't need UML networking, say N.
38054 + Startup example: "eth0=slirp,FE:FD:01:02:03:04,/usr/local/bin/slirp"
38057 +CONFIG_UML_NET_PCAP
38058 + The pcap transport makes a pcap packet stream on the host look
38059 + like an ethernet device inside UML. This is useful for making
38060 + UML act as a network monitor for the host. You must have libcap
38061 + installed in order to build the pcap transport into UML.
38063 + For more information, see
38064 + <http://user-mode-linux.sourceforge.net/networking.html> That site
38065 + has examples of the UML command line to use to enable this option.
38067 + If you intend to use UML as a network monitor for the host, say
38068 + Y here. Otherwise, say N.
38070 +Default main console channel initialization
38071 +CONFIG_CON_ZERO_CHAN
38072 + This is the string describing the channel to which the main console
38073 + will be attached by default. This value can be overridden from the
38074 + command line. The default value is "fd:0,fd:1", which attaches the
38075 + main console to stdin and stdout.
38076 + It is safe to leave this unchanged.
38078 +Default console channel initialization
38080 + This is the string describing the channel to which all consoles
38081 + except the main console will be attached by default. This value can
38082 + be overridden from the command line. The default value is "xterm",
38083 + which brings them up in xterms.
38084 + It is safe to leave this unchanged, although you may wish to change
38085 + this if you expect the UML that you build to be run in environments
38086 + which don't have X or xterm available.
38088 +Default serial line channel initialization
38090 + This is the string describing the channel to which the serial lines
38091 + will be attached by default. This value can be overridden from the
38092 + command line. The default value is "pty", which attaches them to
38093 + traditional pseudo-terminals.
38094 + It is safe to leave this unchanged, although you may wish to change
38095 + this if you expect the UML that you build to be run in environments
38096 + which don't have a set of /dev/pty* devices.
38100 + This is set to the number of layers of UMLs that this UML will be run
38101 + in. Normally, this is zero, meaning that it will run directly on the
38102 + host. Setting it to one will build a UML that can run inside a UML
38103 + that is running on the host. Generally, if you intend this UML to run
38104 + inside another UML, set CONFIG_NEST_LEVEL to one more than the host UML.
38105 + Note that if the hosting UML has its CONFIG_KERNEL_HALF_GIGS set to
38106 + greater than one, then the guest UML should have its CONFIG_NEST_LEVEL
38107 + set to the host's CONFIG_NEST_LEVEL + CONFIG_KERNEL_HALF_GIGS.
38108 + Only change this if you are running nested UMLs.
38110 +Kernel address space size (in .5G units)
38111 +CONFIG_KERNEL_HALF_GIGS
38112 + This determines the amount of address space that UML will allocate for
38113 + its own, measured in half Gigabyte units. The default is 1.
38114 + Change this only if you need to boot UML with an unusually large amount
38115 + of physical memory.
38119 + This option enables UML sound support. If enabled, it will pull in
38120 + soundcore and the UML hostaudio relay, which acts as a intermediary
38121 + between the host's dsp and mixer devices and the UML sound system.
38122 + It is safe to say 'Y' here.
38126 + This option enables UML SMP support. UML implements virtual SMP by
38127 + allowing as many processes to run simultaneously on the host as
38128 + there are virtual processors configured. Obviously, if the host is
38129 + a uniprocessor, those processes will timeshare, but, inside UML,
38130 + will appear to be running simultaneously. If the host is a
38131 + multiprocessor, then UML processes may run simultaneously, depending
38132 + on the host scheduler.
38133 + CONFIG_SMP will be set to whatever this option is set to.
38134 + It is safe to leave this unchanged.
38136 +file descriptor channel support
38138 + This option enables support for attaching UML consoles and serial
38139 + lines to already set up file descriptors. Generally, the main
38140 + console is attached to file descriptors 0 and 1 (stdin and stdout),
38141 + so it would be wise to leave this enabled unless you intend to
38142 + attach it to some other host device.
38144 +null device channel support
38146 + This option enables support for attaching UML consoles and serial
38147 + lines to a device similar to /dev/null. Data written to it disappears
38148 + and there is never any data to be read.
38150 +port channel support
38152 + This option enables support for attaching UML consoles and serial
38153 + lines to host portals. They may be accessed with 'telnet <host>
38154 + <port number>'. Any number of consoles and serial lines may be
38155 + attached to a single portal, although what UML device you get when
38156 + you telnet to that portal will be unpredictable.
38157 + It is safe to say 'Y' here.
38159 +pty channel support
38161 + This option enables support for attaching UML consoles and serial
38162 + lines to host pseudo-terminals. Access to both traditional
38163 + pseudo-terminals (/dev/pty*) and pts pseudo-terminals are controlled
38164 + with this option. The assignment of UML devices to host devices
38165 + will be announced in the kernel message log.
38166 + It is safe to say 'Y' here.
38168 +tty channel support
38170 + This option enables support for attaching UML consoles and serial
38171 + lines to host terminals. Access to both virtual consoles
38172 + (/dev/tty*) and the slave side of pseudo-terminals (/dev/ttyp* and
38173 + /dev/pts/*) are controlled by this option.
38174 + It is safe to say 'Y' here.
38176 +xterm channel support
38178 + This option enables support for attaching UML consoles and serial
38179 + lines to xterms. Each UML device so assigned will be brought up in
38181 + If you disable this option, then CONFIG_PT_PROXY will be disabled as
38182 + well, since UML's gdb currently requires an xterm.
38183 + It is safe to say 'Y' here.
38187 + This option enables logging of all data going through pseudo-terminals
38188 + to the host. This is primarily useful for honeypots, where you want
38189 + secure keystroke logging that can't be detected or disabled by root.
38190 + Say 'N' unless you are setting up a UML honeypot or otherwise know that
38191 + you want this option.
38193 +UML real-time clock support
38194 +CONFIG_UML_REAL_TIME_CLOCK
38195 + This option ties the UML clock to the host clock, so that time passes at
38196 + the same rate as on the host, regardless of how much CPU time the UML is
38197 + getting. This should normally be enabled. The exception would be if you're
38198 + debugging UML. In this case, time spent staring at the debugger with UML
38199 + stopped will cause lots of timer ticks to be backed up, and UML will spent
38200 + lots of time calling the timer when it is finally continued.
38202 Microtek USB scanner support
38203 CONFIG_USB_MICROTEK
38204 Say Y here if you want support for the Microtek X6USB and
38205 diff -Naur -X ../exclude-files orig/drivers/char/Makefile um/drivers/char/Makefile
38206 --- orig/drivers/char/Makefile 2003-12-16 22:16:26.000000000 -0500
38207 +++ um/drivers/char/Makefile 2003-12-16 22:17:25.000000000 -0500
38208 @@ -109,6 +109,12 @@
38221 diff -Naur -X ../exclude-files orig/drivers/char/mem.c um/drivers/char/mem.c
38222 --- orig/drivers/char/mem.c 2003-12-16 22:16:27.000000000 -0500
38223 +++ um/drivers/char/mem.c 2004-01-05 11:23:32.000000000 -0500
38224 @@ -220,7 +220,8 @@
38227 char * kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
38230 + p = (unsigned long) __va(p);
38231 if (p < (unsigned long) high_memory) {
38233 if (count > (unsigned long) high_memory - p)
38234 @@ -269,7 +270,7 @@
38236 free_page((unsigned long)kbuf);
38239 + *ppos = __pa((void *) p);
38240 return virtr + read;
38243 @@ -664,6 +665,8 @@
38247 +extern struct file_operations anon_file_operations;
38249 static int memory_open(struct inode * inode, struct file * filp)
38251 switch (MINOR(inode->i_rdev)) {
38252 @@ -693,6 +696,9 @@
38254 filp->f_op = &urandom_fops;
38257 + filp->f_op = &anon_file_operations;
38262 @@ -719,7 +725,8 @@
38263 {5, "zero", S_IRUGO | S_IWUGO, &zero_fops},
38264 {7, "full", S_IRUGO | S_IWUGO, &full_fops},
38265 {8, "random", S_IRUGO | S_IWUSR, &random_fops},
38266 - {9, "urandom", S_IRUGO | S_IWUSR, &urandom_fops}
38267 + {9, "urandom", S_IRUGO | S_IWUSR, &urandom_fops},
38268 + {10, "anon", S_IRUGO | S_IWUSR, &anon_file_operations},
38272 diff -Naur -X ../exclude-files orig/drivers/char/tty_io.c um/drivers/char/tty_io.c
38273 --- orig/drivers/char/tty_io.c 2003-12-16 22:16:27.000000000 -0500
38274 +++ um/drivers/char/tty_io.c 2003-12-16 22:17:25.000000000 -0500
38275 @@ -649,6 +649,23 @@
38276 wake_up_interruptible(&tty->write_wait);
38279 +#ifdef CONFIG_TTY_LOG
38281 +int (*open_log)(void *, void *) = NULL;
38282 +int (*write_log)(int, const char *, int, void *, int) = NULL;
38283 +void (*close_log)(int, void *) = NULL;
38285 +void register_tty_logger(int (*opener)(void *, void *),
38286 + int (*writer)(int, const char *, int, void *, int),
38287 + void (*closer)(int, void *))
38289 + open_log = opener;
38290 + write_log = writer;
38291 + close_log = closer;
38296 static ssize_t tty_read(struct file * file, char * buf, size_t count,
38299 @@ -689,8 +706,13 @@
38305 inode->i_atime = CURRENT_TIME;
38306 +#ifdef CONFIG_TTY_LOG
38307 + if((tty->log_fd >= 0) && (write_log != NULL))
38308 + (*write_log)(tty->log_fd, buf, i, tty, 1);
38314 @@ -744,6 +766,10 @@
38316 file->f_dentry->d_inode->i_mtime = CURRENT_TIME;
38318 +#ifdef CONFIG_TTY_LOG
38319 + if((tty->log_fd >= 0) && (write_log != NULL))
38320 + (*write_log)(tty->log_fd, buf - ret, ret, tty, 0);
38323 up(&tty->atomic_write);
38325 @@ -971,6 +997,7 @@
38326 goto release_mem_out;
38333 @@ -1290,6 +1317,11 @@
38334 run_task_queue(&tq_timer);
38335 flush_scheduled_tasks();
38337 +#ifdef CONFIG_TTY_LOG
38338 + if((tty->log_fd >= 0) && (close_log != NULL))
38339 + (*close_log)(tty->log_fd, tty);
38343 * The release_mem function takes care of the details of clearing
38344 * the slots and preserving the termios structure.
38345 @@ -1448,6 +1480,11 @@
38350 +#ifdef CONFIG_TTY_LOG
38351 + if((tty->log_fd < 0) && (open_log != NULL))
38352 + tty->log_fd = (*open_log)(tty, current->tty);
38357 @@ -2047,6 +2084,9 @@
38358 spin_lock_init(&tty->read_lock);
38359 INIT_LIST_HEAD(&tty->tty_files);
38360 INIT_TQUEUE(&tty->SAK_tq, 0, 0);
38361 +#ifdef CONFIG_TTY_LOG
38362 + tty->log_fd = -1;
38367 diff -Naur -X ../exclude-files orig/drivers/net/setup.c um/drivers/net/setup.c
38368 --- orig/drivers/net/setup.c 2002-09-15 12:13:19.000000000 -0400
38369 +++ um/drivers/net/setup.c 2003-10-21 03:26:07.000000000 -0400
38371 extern int lmc_setup(void);
38373 extern int madgemc_probe(void);
38374 -extern int uml_net_probe(void);
38376 /* Pad device name to IFNAMSIZ=16. F.e. __PAD6 is string of 9 zeros. */
38377 #define __PAD6 "\0\0\0\0\0\0\0\0\0"
38378 @@ -103,9 +102,6 @@
38379 #ifdef CONFIG_MADGEMC
38380 {madgemc_probe, 0},
38382 -#ifdef CONFIG_UML_NET
38383 - {uml_net_probe, 0},
38388 diff -Naur -X ../exclude-files orig/fs/bad_inode.c um/fs/bad_inode.c
38389 --- orig/fs/bad_inode.c 2002-08-21 11:47:27.000000000 -0400
38390 +++ um/fs/bad_inode.c 2003-10-21 03:26:07.000000000 -0400
38393 void make_bad_inode(struct inode * inode)
38395 + inode->i_state = 0;
38396 inode->i_mode = S_IFREG;
38397 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
38398 inode->i_op = &bad_inode_ops;
38399 diff -Naur -X ../exclude-files orig/include/asm-i386/hardirq.h um/include/asm-i386/hardirq.h
38400 --- orig/include/asm-i386/hardirq.h 2004-01-11 22:46:12.000000000 -0500
38401 +++ um/include/asm-i386/hardirq.h 2004-02-14 06:28:59.000000000 -0500
38403 #include <linux/config.h>
38404 #include <linux/threads.h>
38405 #include <linux/irq.h>
38406 +#include <asm/processor.h> /* for cpu_relax */
38408 /* assembly code in softirq.h is sensitive to the offsets of these fields */
38410 diff -Naur -X ../exclude-files orig/include/asm-um/a.out.h um/include/asm-um/a.out.h
38411 --- orig/include/asm-um/a.out.h 1969-12-31 19:00:00.000000000 -0500
38412 +++ um/include/asm-um/a.out.h 2003-10-21 03:26:07.000000000 -0400
38414 +#ifndef __UM_A_OUT_H
38415 +#define __UM_A_OUT_H
38417 +#include "linux/config.h"
38418 +#include "asm/arch/a.out.h"
38419 +#include "choose-mode.h"
38423 +extern unsigned long stacksizelim;
38425 +extern unsigned long host_task_size;
38427 +#define STACK_ROOM (stacksizelim)
38429 +extern int honeypot;
38430 +#define STACK_TOP \
38431 + CHOOSE_MODE((honeypot ? host_task_size : task_size), task_size)
38434 diff -Naur -X ../exclude-files orig/include/asm-um/archparam-i386.h um/include/asm-um/archparam-i386.h
38435 --- orig/include/asm-um/archparam-i386.h 1969-12-31 19:00:00.000000000 -0500
38436 +++ um/include/asm-um/archparam-i386.h 2003-12-16 08:50:39.000000000 -0500
38439 + * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
38440 + * Licensed under the GPL
38443 +#ifndef __UM_ARCHPARAM_I386_H
38444 +#define __UM_ARCHPARAM_I386_H
38446 +/********* Bits for asm-um/elf.h ************/
38450 +#define ELF_PLATFORM "i586"
38452 +#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
38454 +typedef struct user_i387_struct elf_fpregset_t;
38455 +typedef unsigned long elf_greg_t;
38457 +#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
38458 +typedef elf_greg_t elf_gregset_t[ELF_NGREG];
38460 +#define ELF_DATA ELFDATA2LSB
38461 +#define ELF_ARCH EM_386
38463 +#define ELF_PLAT_INIT(regs, load_addr) do { \
38464 + PT_REGS_EBX(regs) = 0; \
38465 + PT_REGS_ECX(regs) = 0; \
38466 + PT_REGS_EDX(regs) = 0; \
38467 + PT_REGS_ESI(regs) = 0; \
38468 + PT_REGS_EDI(regs) = 0; \
38469 + PT_REGS_EBP(regs) = 0; \
38470 + PT_REGS_EAX(regs) = 0; \
38473 +/* Shamelessly stolen from include/asm-i386/elf.h */
38475 +#define ELF_CORE_COPY_REGS(pr_reg, regs) do { \
38476 + pr_reg[0] = PT_REGS_EBX(regs); \
38477 + pr_reg[1] = PT_REGS_ECX(regs); \
38478 + pr_reg[2] = PT_REGS_EDX(regs); \
38479 + pr_reg[3] = PT_REGS_ESI(regs); \
38480 + pr_reg[4] = PT_REGS_EDI(regs); \
38481 + pr_reg[5] = PT_REGS_EBP(regs); \
38482 + pr_reg[6] = PT_REGS_EAX(regs); \
38483 + pr_reg[7] = PT_REGS_DS(regs); \
38484 + pr_reg[8] = PT_REGS_ES(regs); \
38485 + /* fake once used fs and gs selectors? */ \
38486 + pr_reg[9] = PT_REGS_DS(regs); \
38487 + pr_reg[10] = PT_REGS_DS(regs); \
38488 + pr_reg[11] = PT_REGS_SYSCALL_NR(regs); \
38489 + pr_reg[12] = PT_REGS_IP(regs); \
38490 + pr_reg[13] = PT_REGS_CS(regs); \
38491 + pr_reg[14] = PT_REGS_EFLAGS(regs); \
38492 + pr_reg[15] = PT_REGS_SP(regs); \
38493 + pr_reg[16] = PT_REGS_SS(regs); \
38496 +/********* Bits for asm-um/delay.h **********/
38498 +typedef unsigned long um_udelay_t;
38500 +/********* Nothing for asm-um/hardirq.h **********/
38502 +/********* Nothing for asm-um/hw_irq.h **********/
38504 +/********* Nothing for asm-um/string.h **********/
38509 + * Overrides for Emacs so that we follow Linus's tabbing style.
38510 + * Emacs will notice this stuff at the end of the file and automatically
38511 + * adjust the settings for this buffer only. This must remain at the end
38513 + * ---------------------------------------------------------------------------
38514 + * Local variables:
38515 + * c-file-style: "linux"
38518 diff -Naur -X ../exclude-files orig/include/asm-um/archparam-ppc.h um/include/asm-um/archparam-ppc.h
38519 --- orig/include/asm-um/archparam-ppc.h 1969-12-31 19:00:00.000000000 -0500
38520 +++ um/include/asm-um/archparam-ppc.h 2003-10-21 03:26:07.000000000 -0400
38522 +#ifndef __UM_ARCHPARAM_PPC_H
38523 +#define __UM_ARCHPARAM_PPC_H
38525 +/********* Bits for asm-um/elf.h ************/
38527 +#define ELF_PLATFORM (0)
38529 +#define ELF_ET_DYN_BASE (0x08000000)
38531 +/* the following stolen from asm-ppc/elf.h */
38532 +#define ELF_NGREG 48 /* includes nip, msr, lr, etc. */
38533 +#define ELF_NFPREG 33 /* includes fpscr */
38534 +/* General registers */
38535 +typedef unsigned long elf_greg_t;
38536 +typedef elf_greg_t elf_gregset_t[ELF_NGREG];
38538 +/* Floating point registers */
38539 +typedef double elf_fpreg_t;
38540 +typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
38542 +#define ELF_DATA ELFDATA2MSB
38543 +#define ELF_ARCH EM_PPC
38545 +/********* Bits for asm-um/delay.h **********/
38547 +typedef unsigned int um_udelay_t;
38549 +/********* Bits for asm-um/hw_irq.h **********/
38551 +struct hw_interrupt_type;
38553 +/********* Bits for asm-um/hardirq.h **********/
38555 +#define irq_enter(cpu, irq) hardirq_enter(cpu)
38556 +#define irq_exit(cpu, irq) hardirq_exit(cpu)
38558 +/********* Bits for asm-um/string.h **********/
38560 +#define __HAVE_ARCH_STRRCHR
38563 diff -Naur -X ../exclude-files orig/include/asm-um/arch-signal-i386.h um/include/asm-um/arch-signal-i386.h
38564 --- orig/include/asm-um/arch-signal-i386.h 1969-12-31 19:00:00.000000000 -0500
38565 +++ um/include/asm-um/arch-signal-i386.h 2003-10-21 03:26:07.000000000 -0400
38568 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
38569 + * Licensed under the GPL
38572 +#ifndef __UM_ARCH_SIGNAL_I386_H
38573 +#define __UM_ARCH_SIGNAL_I386_H
38575 +struct arch_signal_context {
38576 + unsigned long extrasigs[_NSIG_WORDS];
38582 + * Overrides for Emacs so that we follow Linus's tabbing style.
38583 + * Emacs will notice this stuff at the end of the file and automatically
38584 + * adjust the settings for this buffer only. This must remain at the end
38586 + * ---------------------------------------------------------------------------
38587 + * Local variables:
38588 + * c-file-style: "linux"
38591 diff -Naur -X ../exclude-files orig/include/asm-um/atomic.h um/include/asm-um/atomic.h
38592 --- orig/include/asm-um/atomic.h 1969-12-31 19:00:00.000000000 -0500
38593 +++ um/include/asm-um/atomic.h 2004-02-14 06:28:59.000000000 -0500
38595 +#ifndef __UM_ATOMIC_H
38596 +#define __UM_ATOMIC_H
38598 +#include "asm/arch/atomic.h"
38601 diff -Naur -X ../exclude-files orig/include/asm-um/bitops.h um/include/asm-um/bitops.h
38602 --- orig/include/asm-um/bitops.h 1969-12-31 19:00:00.000000000 -0500
38603 +++ um/include/asm-um/bitops.h 2004-02-14 06:28:59.000000000 -0500
38605 +#ifndef __UM_BITOPS_H
38606 +#define __UM_BITOPS_H
38608 +#include "asm/arch/bitops.h"
38611 diff -Naur -X ../exclude-files orig/include/asm-um/boot.h um/include/asm-um/boot.h
38612 --- orig/include/asm-um/boot.h 1969-12-31 19:00:00.000000000 -0500
38613 +++ um/include/asm-um/boot.h 2003-10-21 03:26:07.000000000 -0400
38615 +#ifndef __UM_BOOT_H
38616 +#define __UM_BOOT_H
38618 +#include "asm/arch/boot.h"
38621 diff -Naur -X ../exclude-files orig/include/asm-um/bugs.h um/include/asm-um/bugs.h
38622 --- orig/include/asm-um/bugs.h 1969-12-31 19:00:00.000000000 -0500
38623 +++ um/include/asm-um/bugs.h 2003-10-21 03:26:07.000000000 -0400
38625 +#ifndef __UM_BUGS_H
38626 +#define __UM_BUGS_H
38628 +void check_bugs(void);
38631 diff -Naur -X ../exclude-files orig/include/asm-um/byteorder.h um/include/asm-um/byteorder.h
38632 --- orig/include/asm-um/byteorder.h 1969-12-31 19:00:00.000000000 -0500
38633 +++ um/include/asm-um/byteorder.h 2004-01-16 03:32:58.000000000 -0500
38635 +#ifndef __UM_BYTEORDER_H
38636 +#define __UM_BYTEORDER_H
38638 +#include "asm/arch/byteorder.h"
38641 diff -Naur -X ../exclude-files orig/include/asm-um/cache.h um/include/asm-um/cache.h
38642 --- orig/include/asm-um/cache.h 1969-12-31 19:00:00.000000000 -0500
38643 +++ um/include/asm-um/cache.h 2003-10-21 03:26:07.000000000 -0400
38645 +#ifndef __UM_CACHE_H
38646 +#define __UM_CACHE_H
38648 +#define L1_CACHE_BYTES 32
38651 diff -Naur -X ../exclude-files orig/include/asm-um/checksum.h um/include/asm-um/checksum.h
38652 --- orig/include/asm-um/checksum.h 1969-12-31 19:00:00.000000000 -0500
38653 +++ um/include/asm-um/checksum.h 2003-10-21 03:26:07.000000000 -0400
38655 +#ifndef __UM_CHECKSUM_H
38656 +#define __UM_CHECKSUM_H
38658 +#include "sysdep/checksum.h"
38661 diff -Naur -X ../exclude-files orig/include/asm-um/cobalt.h um/include/asm-um/cobalt.h
38662 --- orig/include/asm-um/cobalt.h 1969-12-31 19:00:00.000000000 -0500
38663 +++ um/include/asm-um/cobalt.h 2003-10-21 03:26:07.000000000 -0400
38665 +#ifndef __UM_COBALT_H
38666 +#define __UM_COBALT_H
38668 +#include "asm/arch/cobalt.h"
38671 diff -Naur -X ../exclude-files orig/include/asm-um/current.h um/include/asm-um/current.h
38672 --- orig/include/asm-um/current.h 1969-12-31 19:00:00.000000000 -0500
38673 +++ um/include/asm-um/current.h 2004-02-14 06:28:59.000000000 -0500
38676 + * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
38677 + * Licensed under the GPL
38680 +#ifndef __UM_CURRENT_H
38681 +#define __UM_CURRENT_H
38683 +#ifndef __ASSEMBLY__
38685 +#include "linux/config.h"
38686 +#include "asm/page.h"
38688 +struct task_struct;
38690 +#define CURRENT_TASK(dummy) (((unsigned long) &dummy) & \
38691 + (PAGE_MASK << CONFIG_KERNEL_STACK_ORDER))
38693 +#define current ({ int dummy; (struct task_struct *) CURRENT_TASK(dummy); })
38695 +#endif /* __ASSEMBLY__ */
38700 + * Overrides for Emacs so that we follow Linus's tabbing style.
38701 + * Emacs will notice this stuff at the end of the file and automatically
38702 + * adjust the settings for this buffer only. This must remain at the end
38704 + * ---------------------------------------------------------------------------
38705 + * Local variables:
38706 + * c-file-style: "linux"
38709 diff -Naur -X ../exclude-files orig/include/asm-um/delay.h um/include/asm-um/delay.h
38710 --- orig/include/asm-um/delay.h 1969-12-31 19:00:00.000000000 -0500
38711 +++ um/include/asm-um/delay.h 2003-12-16 22:26:58.000000000 -0500
38713 +#ifndef __UM_DELAY_H
38714 +#define __UM_DELAY_H
38716 +#include "asm/arch/delay.h"
38717 +#include "asm/archparam.h"
38720 diff -Naur -X ../exclude-files orig/include/asm-um/desc.h um/include/asm-um/desc.h
38721 --- orig/include/asm-um/desc.h 1969-12-31 19:00:00.000000000 -0500
38722 +++ um/include/asm-um/desc.h 2003-10-21 03:26:07.000000000 -0400
38724 +#ifndef __UM_DESC_H
38725 +#define __UM_DESC_H
38727 +#include "asm/arch/desc.h"
38730 diff -Naur -X ../exclude-files orig/include/asm-um/div64.h um/include/asm-um/div64.h
38731 --- orig/include/asm-um/div64.h 1969-12-31 19:00:00.000000000 -0500
38732 +++ um/include/asm-um/div64.h 2003-10-21 03:26:07.000000000 -0400
38734 +#ifndef _UM_DIV64_H
38735 +#define _UM_DIV64_H
38737 +#include "asm/arch/div64.h"
38740 diff -Naur -X ../exclude-files orig/include/asm-um/dma.h um/include/asm-um/dma.h
38741 --- orig/include/asm-um/dma.h 1969-12-31 19:00:00.000000000 -0500
38742 +++ um/include/asm-um/dma.h 2004-01-16 03:32:59.000000000 -0500
38744 +#ifndef __UM_DMA_H
38745 +#define __UM_DMA_H
38747 +#include "asm/io.h"
38749 +extern unsigned long uml_physmem;
38751 +#define MAX_DMA_ADDRESS (uml_physmem)
38754 diff -Naur -X ../exclude-files orig/include/asm-um/elf.h um/include/asm-um/elf.h
38755 --- orig/include/asm-um/elf.h 1969-12-31 19:00:00.000000000 -0500
38756 +++ um/include/asm-um/elf.h 2003-12-16 22:29:20.000000000 -0500
38758 +#ifndef __UM_ELF_H
38759 +#define __UM_ELF_H
38761 +#include "asm/archparam.h"
38763 +#define ELF_HWCAP (0)
38765 +#define SET_PERSONALITY(ex, ibcs2) do ; while(0)
38767 +#define ELF_EXEC_PAGESIZE 4096
38769 +#define elf_check_arch(x) (1)
38771 +#define ELF_CLASS ELFCLASS32
38773 +#define USE_ELF_CORE_DUMP
38776 diff -Naur -X ../exclude-files orig/include/asm-um/errno.h um/include/asm-um/errno.h
38777 --- orig/include/asm-um/errno.h 1969-12-31 19:00:00.000000000 -0500
38778 +++ um/include/asm-um/errno.h 2003-10-21 03:26:07.000000000 -0400
38780 +#ifndef __UM_ERRNO_H
38781 +#define __UM_ERRNO_H
38783 +#include "asm/arch/errno.h"
38786 diff -Naur -X ../exclude-files orig/include/asm-um/fcntl.h um/include/asm-um/fcntl.h
38787 --- orig/include/asm-um/fcntl.h 1969-12-31 19:00:00.000000000 -0500
38788 +++ um/include/asm-um/fcntl.h 2003-10-21 03:26:07.000000000 -0400
38790 +#ifndef __UM_FCNTL_H
38791 +#define __UM_FCNTL_H
38793 +#include "asm/arch/fcntl.h"
38796 diff -Naur -X ../exclude-files orig/include/asm-um/fixmap.h um/include/asm-um/fixmap.h
38797 --- orig/include/asm-um/fixmap.h 1969-12-31 19:00:00.000000000 -0500
38798 +++ um/include/asm-um/fixmap.h 2004-02-14 06:29:00.000000000 -0500
38800 +#ifndef __UM_FIXMAP_H
38801 +#define __UM_FIXMAP_H
38803 +#include <linux/config.h>
38804 +#include <asm/kmap_types.h>
38807 + * Here we define all the compile-time 'special' virtual
38808 + * addresses. The point is to have a constant address at
38809 + * compile time, but to set the physical address only
38810 + * in the boot process. We allocate these special addresses
38811 + * from the end of virtual memory (0xfffff000) backwards.
38812 + * Also this lets us do fail-safe vmalloc(), we
38813 + * can guarantee that these special addresses and
38814 + * vmalloc()-ed addresses never overlap.
38816 + * these 'compile-time allocated' memory buffers are
38817 + * fixed-size 4k pages. (or larger if used with an increment
38818 + * highger than 1) use fixmap_set(idx,phys) to associate
38819 + * physical memory with fixmap indices.
38821 + * TLB entries of such buffers will not be flushed across
38826 + * on UP currently we will have no trace of the fixmap mechanizm,
38827 + * no page table allocations, etc. This might change in the
38828 + * future, say framebuffers for the console driver(s) could be
38831 +enum fixed_addresses {
38832 +#ifdef CONFIG_HIGHMEM
38833 + FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
38834 + FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
38836 + __end_of_fixed_addresses
38839 +extern void __set_fixmap (enum fixed_addresses idx,
38840 + unsigned long phys, pgprot_t flags);
38842 +#define set_fixmap(idx, phys) \
38843 + __set_fixmap(idx, phys, PAGE_KERNEL)
38845 + * Some hardware wants to get fixmapped without caching.
38847 +#define set_fixmap_nocache(idx, phys) \
38848 + __set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE)
38850 + * used by vmalloc.c.
38852 + * Leave one empty page between vmalloc'ed areas and
38853 + * the start of the fixmap, and leave one page empty
38854 + * at the top of mem..
38856 +extern unsigned long get_kmem_end(void);
38858 +#define FIXADDR_TOP (get_kmem_end() - 0x2000)
38859 +#define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
38860 +#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
38862 +#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
38864 +extern void __this_fixmap_does_not_exist(void);
38867 + * 'index to address' translation. If anyone tries to use the idx
38868 + * directly without tranlation, we catch the bug with a NULL-deference
38869 + * kernel oops. Illegal ranges of incoming indices are caught too.
38871 +static inline unsigned long fix_to_virt(const unsigned int idx)
38874 + * this branch gets completely eliminated after inlining,
38875 + * except when someone tries to use fixaddr indices in an
38876 + * illegal way. (such as mixing up address types or using
38877 + * out-of-range indices).
38879 + * If it doesn't get removed, the linker will complain
38880 + * loudly with a reasonably clear error message..
38882 + if (idx >= __end_of_fixed_addresses)
38883 + __this_fixmap_does_not_exist();
38885 + return __fix_to_virt(idx);
38889 diff -Naur -X ../exclude-files orig/include/asm-um/floppy.h um/include/asm-um/floppy.h
38890 --- orig/include/asm-um/floppy.h 1969-12-31 19:00:00.000000000 -0500
38891 +++ um/include/asm-um/floppy.h 2003-10-21 03:26:07.000000000 -0400
38893 +#ifndef __UM_FLOPPY_H
38894 +#define __UM_FLOPPY_H
38896 +#include "asm/arch/floppy.h"
38899 diff -Naur -X ../exclude-files orig/include/asm-um/hardirq.h um/include/asm-um/hardirq.h
38900 --- orig/include/asm-um/hardirq.h 1969-12-31 19:00:00.000000000 -0500
38901 +++ um/include/asm-um/hardirq.h 2004-02-14 06:28:59.000000000 -0500
38903 +#ifndef __UM_HARDIRQ_H
38904 +#define __UM_HARDIRQ_H
38906 +#include "asm/arch/hardirq.h"
38909 diff -Naur -X ../exclude-files orig/include/asm-um/hdreg.h um/include/asm-um/hdreg.h
38910 --- orig/include/asm-um/hdreg.h 1969-12-31 19:00:00.000000000 -0500
38911 +++ um/include/asm-um/hdreg.h 2003-10-21 03:26:07.000000000 -0400
38913 +#ifndef __UM_HDREG_H
38914 +#define __UM_HDREG_H
38916 +#include "asm/arch/hdreg.h"
38919 diff -Naur -X ../exclude-files orig/include/asm-um/highmem.h um/include/asm-um/highmem.h
38920 --- orig/include/asm-um/highmem.h 1969-12-31 19:00:00.000000000 -0500
38921 +++ um/include/asm-um/highmem.h 2004-02-14 06:29:00.000000000 -0500
38923 +#ifndef __UM_HIGHMEM_H
38924 +#define __UM_HIGHMEM_H
38926 +#include "asm/page.h"
38927 +#include "asm/fixmap.h"
38928 +#include "asm/arch/highmem.h"
38932 +#define PKMAP_BASE ((FIXADDR_START - LAST_PKMAP * PAGE_SIZE) & PMD_MASK)
38935 diff -Naur -X ../exclude-files orig/include/asm-um/hw_irq.h um/include/asm-um/hw_irq.h
38936 --- orig/include/asm-um/hw_irq.h 1969-12-31 19:00:00.000000000 -0500
38937 +++ um/include/asm-um/hw_irq.h 2003-12-16 22:26:55.000000000 -0500
38939 +#ifndef _ASM_UM_HW_IRQ_H
38940 +#define _ASM_UM_HW_IRQ_H
38942 +#include "asm/irq.h"
38943 +#include "asm/archparam.h"
38945 +static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i)
38949 diff -Naur -X ../exclude-files orig/include/asm-um/ide.h um/include/asm-um/ide.h
38950 --- orig/include/asm-um/ide.h 1969-12-31 19:00:00.000000000 -0500
38951 +++ um/include/asm-um/ide.h 2004-01-16 23:40:52.000000000 -0500
38953 +#ifndef __UM_IDE_H
38954 +#define __UM_IDE_H
38956 +#include "asm/arch/ide.h"
38959 diff -Naur -X ../exclude-files orig/include/asm-um/init.h um/include/asm-um/init.h
38960 --- orig/include/asm-um/init.h 1969-12-31 19:00:00.000000000 -0500
38961 +++ um/include/asm-um/init.h 2003-10-21 03:26:07.000000000 -0400
38963 +#ifndef _UM_INIT_H
38964 +#define _UM_INIT_H
38968 +#define __initdata
38969 +#define __initfunc(__arginit) __arginit
38970 +#define __cacheline_aligned
38974 diff -Naur -X ../exclude-files orig/include/asm-um/ioctl.h um/include/asm-um/ioctl.h
38975 --- orig/include/asm-um/ioctl.h 1969-12-31 19:00:00.000000000 -0500
38976 +++ um/include/asm-um/ioctl.h 2003-10-21 03:26:07.000000000 -0400
38978 +#ifndef __UM_IOCTL_H
38979 +#define __UM_IOCTL_H
38981 +#include "asm/arch/ioctl.h"
38984 diff -Naur -X ../exclude-files orig/include/asm-um/ioctls.h um/include/asm-um/ioctls.h
38985 --- orig/include/asm-um/ioctls.h 1969-12-31 19:00:00.000000000 -0500
38986 +++ um/include/asm-um/ioctls.h 2003-11-07 02:10:43.000000000 -0500
38988 +#ifndef __UM_IOCTLS_H
38989 +#define __UM_IOCTLS_H
38991 +#include "asm/arch/ioctls.h"
38994 diff -Naur -X ../exclude-files orig/include/asm-um/io.h um/include/asm-um/io.h
38995 --- orig/include/asm-um/io.h 1969-12-31 19:00:00.000000000 -0500
38996 +++ um/include/asm-um/io.h 2004-01-16 03:32:59.000000000 -0500
39001 +#include "asm/page.h"
39003 +#define IO_SPACE_LIMIT 0xdeadbeef /* Sure hope nothing uses this */
39005 +static inline int inb(unsigned long i) { return(0); }
39006 +static inline void outb(char c, unsigned long i) { }
39009 + * Change virtual addresses to physical addresses and vv.
39010 + * These are pretty trivial
39012 +static inline unsigned long virt_to_phys(volatile void * address)
39014 + return __pa((void *) address);
39017 +static inline void * phys_to_virt(unsigned long address)
39019 + return __va(address);
39023 diff -Naur -X ../exclude-files orig/include/asm-um/ipcbuf.h um/include/asm-um/ipcbuf.h
39024 --- orig/include/asm-um/ipcbuf.h 1969-12-31 19:00:00.000000000 -0500
39025 +++ um/include/asm-um/ipcbuf.h 2003-10-21 03:26:07.000000000 -0400
39027 +#ifndef __UM_IPCBUF_H
39028 +#define __UM_IPCBUF_H
39030 +#include "asm/arch/ipcbuf.h"
39033 diff -Naur -X ../exclude-files orig/include/asm-um/ipc.h um/include/asm-um/ipc.h
39034 --- orig/include/asm-um/ipc.h 1969-12-31 19:00:00.000000000 -0500
39035 +++ um/include/asm-um/ipc.h 2003-10-21 03:26:07.000000000 -0400
39037 +#ifndef __UM_IPC_H
39038 +#define __UM_IPC_H
39040 +#include "asm/arch/ipc.h"
39043 diff -Naur -X ../exclude-files orig/include/asm-um/irq.h um/include/asm-um/irq.h
39044 --- orig/include/asm-um/irq.h 1969-12-31 19:00:00.000000000 -0500
39045 +++ um/include/asm-um/irq.h 2003-10-21 03:26:07.000000000 -0400
39047 +#ifndef __UM_IRQ_H
39048 +#define __UM_IRQ_H
39050 +#define TIMER_IRQ 0
39052 +#define CONSOLE_IRQ 2
39053 +#define CONSOLE_WRITE_IRQ 3
39055 +#define UM_ETH_IRQ 5
39057 +#define SSL_WRITE_IRQ 7
39058 +#define ACCEPT_IRQ 8
39059 +#define MCONSOLE_IRQ 9
39060 +#define WINCH_IRQ 10
39061 +#define SIGIO_WRITE_IRQ 11
39062 +#define TELNETD_IRQ 12
39063 +#define XTERM_IRQ 13
39065 +#define LAST_IRQ XTERM_IRQ
39066 +#define NR_IRQS (LAST_IRQ + 1)
39069 diff -Naur -X ../exclude-files orig/include/asm-um/keyboard.h um/include/asm-um/keyboard.h
39070 --- orig/include/asm-um/keyboard.h 1969-12-31 19:00:00.000000000 -0500
39071 +++ um/include/asm-um/keyboard.h 2003-10-21 03:26:07.000000000 -0400
39073 +#ifndef __UM_KEYBOARD_H
39074 +#define __UM_KEYBOARD_H
39076 +#include "asm/arch/keyboard.h"
39079 diff -Naur -X ../exclude-files orig/include/asm-um/kmap_types.h um/include/asm-um/kmap_types.h
39080 --- orig/include/asm-um/kmap_types.h 1969-12-31 19:00:00.000000000 -0500
39081 +++ um/include/asm-um/kmap_types.h 2003-10-21 03:26:07.000000000 -0400
39084 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
39085 + * Licensed under the GPL
39088 +#ifndef __UM_KMAP_TYPES_H
39089 +#define __UM_KMAP_TYPES_H
39091 +#include "asm/arch/kmap_types.h"
39094 diff -Naur -X ../exclude-files orig/include/asm-um/linux_logo.h um/include/asm-um/linux_logo.h
39095 --- orig/include/asm-um/linux_logo.h 1969-12-31 19:00:00.000000000 -0500
39096 +++ um/include/asm-um/linux_logo.h 2003-10-21 03:26:07.000000000 -0400
39098 +#ifndef __UM_LINUX_LOGO_H
39099 +#define __UM_LINUX_LOGO_H
39101 +#include "asm/arch/linux_logo.h"
39104 diff -Naur -X ../exclude-files orig/include/asm-um/locks.h um/include/asm-um/locks.h
39105 --- orig/include/asm-um/locks.h 1969-12-31 19:00:00.000000000 -0500
39106 +++ um/include/asm-um/locks.h 2003-10-21 03:26:07.000000000 -0400
39108 +#ifndef __UM_LOCKS_H
39109 +#define __UM_LOCKS_H
39111 +#include "asm/arch/locks.h"
39114 diff -Naur -X ../exclude-files orig/include/asm-um/mca_dma.h um/include/asm-um/mca_dma.h
39115 --- orig/include/asm-um/mca_dma.h 1969-12-31 19:00:00.000000000 -0500
39116 +++ um/include/asm-um/mca_dma.h 2003-10-21 03:26:07.000000000 -0400
39118 +#ifndef mca___UM_DMA_H
39119 +#define mca___UM_DMA_H
39121 +#include "asm/arch/mca_dma.h"
39124 diff -Naur -X ../exclude-files orig/include/asm-um/mman.h um/include/asm-um/mman.h
39125 --- orig/include/asm-um/mman.h 1969-12-31 19:00:00.000000000 -0500
39126 +++ um/include/asm-um/mman.h 2003-10-21 03:26:07.000000000 -0400
39128 +#ifndef __UM_MMAN_H
39129 +#define __UM_MMAN_H
39131 +#include "asm/arch/mman.h"
39134 diff -Naur -X ../exclude-files orig/include/asm-um/mmu_context.h um/include/asm-um/mmu_context.h
39135 --- orig/include/asm-um/mmu_context.h 1969-12-31 19:00:00.000000000 -0500
39136 +++ um/include/asm-um/mmu_context.h 2004-02-14 06:28:59.000000000 -0500
39139 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
39140 + * Licensed under the GPL
39143 +#ifndef __UM_MMU_CONTEXT_H
39144 +#define __UM_MMU_CONTEXT_H
39146 +#include "linux/sched.h"
39147 +#include "choose-mode.h"
39149 +#define get_mmu_context(task) do ; while(0)
39150 +#define activate_context(tsk) do ; while(0)
39152 +static inline void activate_mm(struct mm_struct *old, struct mm_struct *new)
39156 +extern void switch_mm_skas(int mm_fd);
39158 +static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
39159 + struct task_struct *tsk, unsigned cpu)
39161 + if(prev != next){
39162 + clear_bit(cpu, &prev->cpu_vm_mask);
39163 + set_bit(cpu, &next->cpu_vm_mask);
39164 + if(next != &init_mm)
39165 + CHOOSE_MODE((void) 0,
39166 + switch_mm_skas(next->context.skas.mm_fd));
39170 +static inline void enter_lazy_tlb(struct mm_struct *mm,
39171 + struct task_struct *tsk, unsigned cpu)
39175 +extern int init_new_context_skas(struct task_struct *task,
39176 + struct mm_struct *mm);
39178 +static inline int init_new_context_tt(struct task_struct *task,
39179 + struct mm_struct *mm)
39184 +static inline int init_new_context(struct task_struct *task,
39185 + struct mm_struct *mm)
39187 + return(CHOOSE_MODE_PROC(init_new_context_tt, init_new_context_skas,
39191 +extern void destroy_context_skas(struct mm_struct *mm);
39193 +static inline void destroy_context(struct mm_struct *mm)
39195 + CHOOSE_MODE((void) 0, destroy_context_skas(mm));
39201 + * Overrides for Emacs so that we follow Linus's tabbing style.
39202 + * Emacs will notice this stuff at the end of the file and automatically
39203 + * adjust the settings for this buffer only. This must remain at the end
39205 + * ---------------------------------------------------------------------------
39206 + * Local variables:
39207 + * c-file-style: "linux"
39210 diff -Naur -X ../exclude-files orig/include/asm-um/mmu.h um/include/asm-um/mmu.h
39211 --- orig/include/asm-um/mmu.h 1969-12-31 19:00:00.000000000 -0500
39212 +++ um/include/asm-um/mmu.h 2003-10-21 03:26:07.000000000 -0400
39215 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
39216 + * Licensed under the GPL
39222 +#include "um_mmu.h"
39227 + * Overrides for Emacs so that we follow Linus's tabbing style.
39228 + * Emacs will notice this stuff at the end of the file and automatically
39229 + * adjust the settings for this buffer only. This must remain at the end
39231 + * ---------------------------------------------------------------------------
39232 + * Local variables:
39233 + * c-file-style: "linux"
39236 diff -Naur -X ../exclude-files orig/include/asm-um/module.h um/include/asm-um/module.h
39237 --- orig/include/asm-um/module.h 1969-12-31 19:00:00.000000000 -0500
39238 +++ um/include/asm-um/module.h 2003-10-21 03:26:07.000000000 -0400
39240 +#ifndef __UM_MODULE_H
39241 +#define __UM_MODULE_H
39243 +#include "asm/arch/module.h"
39246 diff -Naur -X ../exclude-files orig/include/asm-um/msgbuf.h um/include/asm-um/msgbuf.h
39247 --- orig/include/asm-um/msgbuf.h 1969-12-31 19:00:00.000000000 -0500
39248 +++ um/include/asm-um/msgbuf.h 2003-10-21 03:26:07.000000000 -0400
39250 +#ifndef __UM_MSGBUF_H
39251 +#define __UM_MSGBUF_H
39253 +#include "asm/arch/msgbuf.h"
39256 diff -Naur -X ../exclude-files orig/include/asm-um/mtrr.h um/include/asm-um/mtrr.h
39257 --- orig/include/asm-um/mtrr.h 1969-12-31 19:00:00.000000000 -0500
39258 +++ um/include/asm-um/mtrr.h 2004-02-12 05:46:29.000000000 -0500
39260 +#ifndef __UM_MTRR_H
39261 +#define __UM_MTRR_H
39263 +#include "asm/arch/mtrr.h"
39266 diff -Naur -X ../exclude-files orig/include/asm-um/namei.h um/include/asm-um/namei.h
39267 --- orig/include/asm-um/namei.h 1969-12-31 19:00:00.000000000 -0500
39268 +++ um/include/asm-um/namei.h 2003-10-21 03:26:07.000000000 -0400
39270 +#ifndef __UM_NAMEI_H
39271 +#define __UM_NAMEI_H
39273 +#include "asm/arch/namei.h"
39276 diff -Naur -X ../exclude-files orig/include/asm-um/page.h um/include/asm-um/page.h
39277 --- orig/include/asm-um/page.h 1969-12-31 19:00:00.000000000 -0500
39278 +++ um/include/asm-um/page.h 2004-01-16 03:32:58.000000000 -0500
39281 + * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
39282 + * Licensed under the GPL
39285 +#ifndef __UM_PAGE_H
39286 +#define __UM_PAGE_H
39290 +#include "asm/arch/page.h"
39296 +#undef virt_to_page
39298 +#undef PAGE_OFFSET
39301 +extern unsigned long uml_physmem;
39303 +#define PAGE_OFFSET (uml_physmem)
39304 +#define KERNELBASE PAGE_OFFSET
39306 +#ifndef __ASSEMBLY__
39308 +extern void stop(void);
39310 +#define BUG() do { \
39311 + panic("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
39314 +#define PAGE_BUG(page) do { \
39318 +#endif /* __ASSEMBLY__ */
39320 +#define __va_space (8*1024*1024)
39322 +extern unsigned long to_phys(void *virt);
39323 +extern void *to_virt(unsigned long phys);
39325 +#define __pa(virt) to_phys((void *) virt)
39326 +#define __va(phys) to_virt((unsigned long) phys)
39328 +#define VALID_PAGE(page) ((page - mem_map) < max_mapnr)
39330 +extern struct page *arch_validate(struct page *page, int mask, int order);
39331 +#define HAVE_ARCH_VALIDATE
39333 +extern void arch_free_page(struct page *page, int order);
39334 +#define HAVE_ARCH_FREE_PAGE
39339 + * Overrides for Emacs so that we follow Linus's tabbing style.
39340 + * Emacs will notice this stuff at the end of the file and automatically
39341 + * adjust the settings for this buffer only. This must remain at the end
39343 + * ---------------------------------------------------------------------------
39344 + * Local variables:
39345 + * c-file-style: "linux"
39348 diff -Naur -X ../exclude-files orig/include/asm-um/page_offset.h um/include/asm-um/page_offset.h
39349 --- orig/include/asm-um/page_offset.h 1969-12-31 19:00:00.000000000 -0500
39350 +++ um/include/asm-um/page_offset.h 2003-10-21 03:26:07.000000000 -0400
39352 +#define PAGE_OFFSET_RAW (uml_physmem)
39353 diff -Naur -X ../exclude-files orig/include/asm-um/param.h um/include/asm-um/param.h
39354 --- orig/include/asm-um/param.h 1969-12-31 19:00:00.000000000 -0500
39355 +++ um/include/asm-um/param.h 2004-02-13 02:26:52.000000000 -0500
39357 +#ifndef _UM_PARAM_H
39358 +#define _UM_PARAM_H
39362 +#define EXEC_PAGESIZE 4096
39365 +#define NGROUPS 32
39369 +#define NOGROUP (-1)
39372 +#define MAXHOSTNAMELEN 64 /* max length of hostname */
39375 +# define CLOCKS_PER_SEC 100 /* frequency at which times() counts */
39379 diff -Naur -X ../exclude-files orig/include/asm-um/pci.h um/include/asm-um/pci.h
39380 --- orig/include/asm-um/pci.h 1969-12-31 19:00:00.000000000 -0500
39381 +++ um/include/asm-um/pci.h 2003-10-21 03:26:07.000000000 -0400
39383 +#ifndef __UM_PCI_H
39384 +#define __UM_PCI_H
39386 +#define PCI_DMA_BUS_IS_PHYS (1)
39389 diff -Naur -X ../exclude-files orig/include/asm-um/pgalloc.h um/include/asm-um/pgalloc.h
39390 --- orig/include/asm-um/pgalloc.h 1969-12-31 19:00:00.000000000 -0500
39391 +++ um/include/asm-um/pgalloc.h 2004-02-14 06:29:00.000000000 -0500
39394 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
39395 + * Derived from include/asm-i386/pgalloc.h and include/asm-i386/pgtable.h
39396 + * Licensed under the GPL
39399 +#ifndef __UM_PGALLOC_H
39400 +#define __UM_PGALLOC_H
39402 +#include "linux/config.h"
39403 +#include "linux/mm.h"
39404 +#include "asm/fixmap.h"
39405 +#include "choose-mode.h"
39407 +#define pgd_quicklist (current_cpu_data.pgd_quick)
39408 +#define pmd_quicklist (current_cpu_data.pmd_quick)
39409 +#define pte_quicklist (current_cpu_data.pte_quick)
39410 +#define pgtable_cache_size (current_cpu_data.pgtable_cache_sz)
39412 +#define pmd_populate(mm, pmd, pte) set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte)))
39415 + * Allocate and free page tables.
39418 +static inline pgd_t *get_pgd_slow_tt(void)
39420 + pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL);
39423 + memset(pgd, 0, USER_PTRS_PER_PGD * sizeof(pgd_t));
39424 + memcpy(pgd + USER_PTRS_PER_PGD,
39425 + swapper_pg_dir + USER_PTRS_PER_PGD,
39426 + (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
39431 +static inline pgd_t *get_pgd_slow_skas(void)
39433 + pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL);
39436 + memset(pgd, 0, USER_PTRS_PER_PGD * sizeof(pgd_t));
39440 +static inline pgd_t *get_pgd_slow(void)
39442 + return(CHOOSE_MODE(get_pgd_slow_tt(), get_pgd_slow_skas()));
39445 +static inline pgd_t *get_pgd_fast(void)
39447 + unsigned long *ret;
39449 + ret = pgd_quicklist;
39450 + if (ret != NULL) {
39451 + pgd_quicklist = (unsigned long *)(*ret);
39453 + pgtable_cache_size--;
39455 + ret = (unsigned long *)get_pgd_slow();
39456 + return (pgd_t *)ret;
39459 +static inline void free_pgd_fast(pgd_t *pgd)
39461 + *(unsigned long *)pgd = (unsigned long) pgd_quicklist;
39462 + pgd_quicklist = (unsigned long *) pgd;
39463 + pgtable_cache_size++;
39466 +static inline void free_pgd_slow(pgd_t *pgd)
39468 + free_page((unsigned long)pgd);
39471 +static inline pte_t *pte_alloc_one(struct mm_struct *mm, unsigned long address)
39475 + pte = (pte_t *) __get_free_page(GFP_KERNEL);
39481 +static inline pte_t *pte_alloc_one_fast(struct mm_struct *mm, unsigned long address)
39483 + unsigned long *ret;
39485 + ret = (unsigned long *)pte_quicklist;
39486 + if (ret != NULL) {
39487 + pte_quicklist = (unsigned long *)(*ret);
39489 + pgtable_cache_size--;
39491 + return (pte_t *)ret;
39494 +static inline void pte_free_fast(pte_t *pte)
39496 + *(unsigned long *)pte = (unsigned long) pte_quicklist;
39497 + pte_quicklist = (unsigned long *) pte;
39498 + pgtable_cache_size++;
39501 +static inline void pte_free_slow(pte_t *pte)
39503 + free_page((unsigned long)pte);
39506 +#define pte_free(pte) pte_free_fast(pte)
39507 +#define pgd_free(pgd) free_pgd_slow(pgd)
39508 +#define pgd_alloc(mm) get_pgd_fast()
39511 + * allocating and freeing a pmd is trivial: the 1-entry pmd is
39512 + * inside the pgd, so has no extra memory associated with it.
39515 +#define pmd_alloc_one_fast(mm, addr) ({ BUG(); ((pmd_t *)1); })
39516 +#define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
39517 +#define pmd_free_slow(x) do { } while (0)
39518 +#define pmd_free_fast(x) do { } while (0)
39519 +#define pmd_free(x) do { } while (0)
39520 +#define pgd_populate(mm, pmd, pte) BUG()
39525 + * - flush_tlb() flushes the current mm struct TLBs
39526 + * - flush_tlb_all() flushes all processes TLBs
39527 + * - flush_tlb_mm(mm) flushes the specified mm context TLB's
39528 + * - flush_tlb_page(vma, vmaddr) flushes one page
39529 + * - flush_tlb_kernel_vm() flushes the kernel vm area
39530 + * - flush_tlb_range(mm, start, end) flushes a range of pages
39531 + * - flush_tlb_pgtables(mm, start, end) flushes a range of page tables
39534 +extern void flush_tlb_all(void);
39535 +extern void flush_tlb_mm(struct mm_struct *mm);
39536 +extern void flush_tlb_range(struct mm_struct *mm, unsigned long start,
39537 + unsigned long end);
39538 +extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
39539 +extern void flush_tlb_kernel_vm(void);
39541 +static inline void flush_tlb_pgtables(struct mm_struct *mm,
39542 + unsigned long start, unsigned long end)
39548 + * Overrides for Emacs so that we follow Linus's tabbing style.
39549 + * Emacs will notice this stuff at the end of the file and automatically
39550 + * adjust the settings for this buffer only. This must remain at the end
39552 + * ---------------------------------------------------------------------------
39553 + * Local variables:
39554 + * c-file-style: "linux"
39557 diff -Naur -X ../exclude-files orig/include/asm-um/pgtable.h um/include/asm-um/pgtable.h
39558 --- orig/include/asm-um/pgtable.h 1969-12-31 19:00:00.000000000 -0500
39559 +++ um/include/asm-um/pgtable.h 2004-02-14 06:28:59.000000000 -0500
39562 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
39563 + * Derived from include/asm-i386/pgtable.h
39564 + * Licensed under the GPL
39567 +#ifndef __UM_PGTABLE_H
39568 +#define __UM_PGTABLE_H
39570 +#include "linux/sched.h"
39571 +#include "asm/processor.h"
39572 +#include "asm/page.h"
39574 +extern pgd_t swapper_pg_dir[1024];
39576 +#define flush_cache_all() do ; while (0)
39577 +#define flush_cache_mm(mm) do ; while (0)
39578 +#define flush_cache_range(vma, start, end) do ; while (0)
39579 +#define flush_cache_page(vma, vmaddr) do ; while (0)
39580 +#define flush_page_to_ram(page) do ; while (0)
39581 +#define flush_dcache_page(page) do ; while (0)
39582 +#define flush_icache_range(from, to) do ; while (0)
39583 +#define flush_icache_page(vma,pg) do ; while (0)
39584 +#define flush_icache_user_range(vma,pg,adr,len) do ; while (0)
39586 +extern void __flush_tlb_one(unsigned long addr);
39588 +extern void pte_free(pte_t *pte);
39590 +extern void pgd_free(pgd_t *pgd);
39592 +extern int do_check_pgt_cache(int, int);
39594 +extern void *um_virt_to_phys(struct task_struct *task, unsigned long virt,
39597 +/* zero page used for uninitialized stuff */
39598 +extern unsigned long *empty_zero_page;
39600 +#define pgtable_cache_init() do ; while (0)
39602 +/* PMD_SHIFT determines the size of the area a second-level page table can map */
39603 +#define PMD_SHIFT 22
39604 +#define PMD_SIZE (1UL << PMD_SHIFT)
39605 +#define PMD_MASK (~(PMD_SIZE-1))
39607 +/* PGDIR_SHIFT determines what a third-level page table entry can map */
39608 +#define PGDIR_SHIFT 22
39609 +#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
39610 +#define PGDIR_MASK (~(PGDIR_SIZE-1))
39613 + * entries per page directory level: the i386 is two-level, so
39614 + * we don't really have any PMD directory physically.
39616 +#define PTRS_PER_PTE 1024
39617 +#define PTRS_PER_PMD 1
39618 +#define PTRS_PER_PGD 1024
39619 +#define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE)
39620 +#define FIRST_USER_PGD_NR 0
39622 +#define pte_ERROR(e) \
39623 + printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))
39624 +#define pmd_ERROR(e) \
39625 + printk("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pmd_val(e))
39626 +#define pgd_ERROR(e) \
39627 + printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
39630 + * pgd entries used up by user/kernel:
39633 +#define USER_PGD_PTRS (TASK_SIZE >> PGDIR_SHIFT)
39634 +#define KERNEL_PGD_PTRS (PTRS_PER_PGD-USER_PGD_PTRS)
39636 +#ifndef __ASSEMBLY__
39637 +/* Just any arbitrary offset to the start of the vmalloc VM area: the
39638 + * current 8MB value just means that there will be a 8MB "hole" after the
39639 + * physical memory until the kernel virtual memory starts. That means that
39640 + * any out-of-bounds memory accesses will hopefully be caught.
39641 + * The vmalloc() routines leaves a hole of 4kB between each vmalloced
39642 + * area for the same reason. ;)
39645 +extern unsigned long end_iomem;
39647 +#define VMALLOC_OFFSET (__va_space)
39648 +#define VMALLOC_START ((end_iomem + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
39649 +#define VMALLOC_VMADDR(x) ((unsigned long)(x))
39651 +#if CONFIG_HIGHMEM
39652 +# define VMALLOC_END (PKMAP_BASE-2*PAGE_SIZE)
39654 +# define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE)
39657 +#define _PAGE_PRESENT 0x001
39658 +#define _PAGE_NEWPAGE 0x002
39659 +#define _PAGE_PROTNONE 0x004 /* If not present */
39660 +#define _PAGE_RW 0x008
39661 +#define _PAGE_USER 0x010
39662 +#define _PAGE_ACCESSED 0x020
39663 +#define _PAGE_DIRTY 0x040
39664 +#define _PAGE_NEWPROT 0x080
39666 +#define REGION_MASK 0xf0000000
39667 +#define REGION_SHIFT 28
39669 +#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY)
39670 +#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY)
39671 +#define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY)
39673 +#define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED)
39674 +#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED)
39675 +#define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
39676 +#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
39677 +#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED)
39678 +#define PAGE_KERNEL_RO __pgprot(_PAGE_PRESENT | _PAGE_DIRTY | _PAGE_ACCESSED)
39681 + * The i386 can't do page protection for execute, and considers that the same are read.
39682 + * Also, write permissions imply read permissions. This is the closest we can get..
39684 +#define __P000 PAGE_NONE
39685 +#define __P001 PAGE_READONLY
39686 +#define __P010 PAGE_COPY
39687 +#define __P011 PAGE_COPY
39688 +#define __P100 PAGE_READONLY
39689 +#define __P101 PAGE_READONLY
39690 +#define __P110 PAGE_COPY
39691 +#define __P111 PAGE_COPY
39693 +#define __S000 PAGE_NONE
39694 +#define __S001 PAGE_READONLY
39695 +#define __S010 PAGE_SHARED
39696 +#define __S011 PAGE_SHARED
39697 +#define __S100 PAGE_READONLY
39698 +#define __S101 PAGE_READONLY
39699 +#define __S110 PAGE_SHARED
39700 +#define __S111 PAGE_SHARED
39703 + * Define this if things work differently on an i386 and an i486:
39704 + * it will (on an i486) warn about kernel memory accesses that are
39705 + * done without a 'verify_area(VERIFY_WRITE,..)'
39707 +#undef TEST_VERIFY_AREA
39709 +/* page table for 0-4MB for everybody */
39710 +extern unsigned long pg0[1024];
39713 + * BAD_PAGETABLE is used when we need a bogus page-table, while
39714 + * BAD_PAGE is used for a bogus page.
39716 + * ZERO_PAGE is a global shared page that is always zero: used
39717 + * for zero-mapped memory areas etc..
39719 +extern pte_t __bad_page(void);
39720 +extern pte_t * __bad_pagetable(void);
39722 +#define BAD_PAGETABLE __bad_pagetable()
39723 +#define BAD_PAGE __bad_page()
39725 +#define ZERO_PAGE(vaddr) virt_to_page(empty_zero_page)
39727 +/* number of bits that fit into a memory pointer */
39728 +#define BITS_PER_PTR (8*sizeof(unsigned long))
39730 +/* to align the pointer to a pointer address */
39731 +#define PTR_MASK (~(sizeof(void*)-1))
39733 +/* sizeof(void*)==1<<SIZEOF_PTR_LOG2 */
39734 +/* 64-bit machines, beware! SRB. */
39735 +#define SIZEOF_PTR_LOG2 2
39737 +/* to find an entry in a page-table */
39738 +#define PAGE_PTR(address) \
39739 +((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)&PTR_MASK&~PAGE_MASK)
39741 +#define pte_none(x) !(pte_val(x) & ~_PAGE_NEWPAGE)
39742 +#define pte_present(x) (pte_val(x) & (_PAGE_PRESENT | _PAGE_PROTNONE))
39744 +#define pte_clear(xp) do { pte_val(*(xp)) = _PAGE_NEWPAGE; } while (0)
39746 +#define pmd_none(x) (!(pmd_val(x) & ~_PAGE_NEWPAGE))
39747 +#define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE)
39748 +#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT)
39749 +#define pmd_clear(xp) do { pmd_val(*(xp)) = _PAGE_NEWPAGE; } while (0)
39751 +#define pmd_newpage(x) (pmd_val(x) & _PAGE_NEWPAGE)
39752 +#define pmd_mkuptodate(x) (pmd_val(x) &= ~_PAGE_NEWPAGE)
39755 + * The "pgd_xxx()" functions here are trivial for a folded two-level
39756 + * setup: the pgd is never bad, and a pmd always exists (as it's folded
39757 + * into the pgd entry)
39759 +static inline int pgd_none(pgd_t pgd) { return 0; }
39760 +static inline int pgd_bad(pgd_t pgd) { return 0; }
39761 +static inline int pgd_present(pgd_t pgd) { return 1; }
39762 +static inline void pgd_clear(pgd_t * pgdp) { }
39764 +#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))
39766 +#define pte_page(pte) virt_to_page(__va(pte_val(pte)))
39767 +#define pmd_page(pmd) ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
39769 +extern struct page *phys_to_page(const unsigned long phys);
39770 +extern struct page *__virt_to_page(const unsigned long virt);
39771 +#define virt_to_page(addr) __virt_to_page((const unsigned long) addr)
39773 +static inline pte_t pte_mknewprot(pte_t pte)
39775 + pte_val(pte) |= _PAGE_NEWPROT;
39779 +static inline pte_t pte_mknewpage(pte_t pte)
39781 + pte_val(pte) |= _PAGE_NEWPAGE;
39785 +static inline void set_pte(pte_t *pteptr, pte_t pteval)
39787 + /* If it's a swap entry, it needs to be marked _PAGE_NEWPAGE so
39788 + * fix_range knows to unmap it. _PAGE_NEWPROT is specific to
39791 + *pteptr = pte_mknewpage(pteval);
39792 + if(pte_present(*pteptr)) *pteptr = pte_mknewprot(*pteptr);
39796 + * (pmds are folded into pgds so this doesnt get actually called,
39797 + * but the define is needed for a generic inline function.)
39799 +#define set_pmd(pmdptr, pmdval) (*(pmdptr) = pmdval)
39800 +#define set_pgd(pgdptr, pgdval) (*(pgdptr) = pgdval)
39803 + * The following only work if pte_present() is true.
39804 + * Undefined behaviour if not..
39806 +static inline int pte_read(pte_t pte)
39808 + return((pte_val(pte) & _PAGE_USER) &&
39809 + !(pte_val(pte) & _PAGE_PROTNONE));
39812 +static inline int pte_exec(pte_t pte){
39813 + return((pte_val(pte) & _PAGE_USER) &&
39814 + !(pte_val(pte) & _PAGE_PROTNONE));
39817 +static inline int pte_write(pte_t pte)
39819 + return((pte_val(pte) & _PAGE_RW) &&
39820 + !(pte_val(pte) & _PAGE_PROTNONE));
39823 +static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; }
39824 +static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
39825 +static inline int pte_newpage(pte_t pte) { return pte_val(pte) & _PAGE_NEWPAGE; }
39826 +static inline int pte_newprot(pte_t pte)
39828 + return(pte_present(pte) && (pte_val(pte) & _PAGE_NEWPROT));
39831 +static inline pte_t pte_rdprotect(pte_t pte)
39833 + pte_val(pte) &= ~_PAGE_USER;
39834 + return(pte_mknewprot(pte));
39837 +static inline pte_t pte_exprotect(pte_t pte)
39839 + pte_val(pte) &= ~_PAGE_USER;
39840 + return(pte_mknewprot(pte));
39843 +static inline pte_t pte_mkclean(pte_t pte)
39845 + pte_val(pte) &= ~_PAGE_DIRTY;
39849 +static inline pte_t pte_mkold(pte_t pte)
39851 + pte_val(pte) &= ~_PAGE_ACCESSED;
39855 +static inline pte_t pte_wrprotect(pte_t pte)
39857 + pte_val(pte) &= ~_PAGE_RW;
39858 + return(pte_mknewprot(pte));
39861 +static inline pte_t pte_mkread(pte_t pte)
39863 + pte_val(pte) |= _PAGE_USER;
39864 + return(pte_mknewprot(pte));
39867 +static inline pte_t pte_mkexec(pte_t pte)
39869 + pte_val(pte) |= _PAGE_USER;
39870 + return(pte_mknewprot(pte));
39873 +static inline pte_t pte_mkdirty(pte_t pte)
39875 + pte_val(pte) |= _PAGE_DIRTY;
39879 +static inline pte_t pte_mkyoung(pte_t pte)
39881 + pte_val(pte) |= _PAGE_ACCESSED;
39885 +static inline pte_t pte_mkwrite(pte_t pte)
39887 + pte_val(pte) |= _PAGE_RW;
39888 + return(pte_mknewprot(pte));
39891 +static inline pte_t pte_mkuptodate(pte_t pte)
39893 + pte_val(pte) &= ~_PAGE_NEWPAGE;
39894 + if(pte_present(pte)) pte_val(pte) &= ~_PAGE_NEWPROT;
39898 +extern unsigned long page_to_phys(struct page *page);
39901 + * Conversion functions: convert a page and protection to a page entry,
39902 + * and a page entry and page directory to the page they refer to.
39905 +extern pte_t mk_pte(struct page *page, pgprot_t pgprot);
39907 +/* This takes a physical page address that is used by the remapping
39910 +#define mk_pte_phys(phys, pgprot) \
39911 + (pte_mknewpage(mk_pte(virt_to_page(__va(phys)), pgprot)))
39913 +static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
39915 + pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot);
39916 + if(pte_present(pte)) pte = pte_mknewpage(pte_mknewprot(pte));
39920 +/* to find an entry in a page-table-directory. */
39921 +#define pgd_index(address) ((address >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
39922 +#define __pgd_offset(address) pgd_index(address)
39924 +/* to find an entry in a page-table-directory */
39925 +#define pgd_offset(mm, address) \
39926 +((mm)->pgd + ((address) >> PGDIR_SHIFT))
39928 +/* to find an entry in a kernel page-table-directory */
39929 +#define pgd_offset_k(address) pgd_offset(&init_mm, address)
39931 +#define __pmd_offset(address) \
39932 + (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
39934 +/* Find an entry in the second-level page table.. */
39935 +static inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address)
39937 + return (pmd_t *) dir;
39940 +/* Find an entry in the third-level page table.. */
39941 +#define pte_offset(pmd, address) \
39942 + ((pte_t *) (pmd_page(*pmd) + ((address>>10) & ((PTRS_PER_PTE-1)<<2))))
39944 +#define update_mmu_cache(vma,address,pte) do ; while (0)
39946 +/* Encode and de-code a swap entry */
39947 +#define SWP_TYPE(x) (((x).val >> 3) & 0x7f)
39948 +#define SWP_OFFSET(x) ((x).val >> 10)
39950 +#define SWP_ENTRY(type, offset) \
39951 + ((swp_entry_t) { ((type) << 3) | ((offset) << 10) })
39952 +#define pte_to_swp_entry(pte) \
39953 + ((swp_entry_t) { pte_val(pte_mkuptodate(pte)) })
39954 +#define swp_entry_to_pte(x) ((pte_t) { (x).val })
39956 +#define PageSkip(x) (0)
39957 +#define kern_addr_valid(addr) (1)
39959 +#include <asm-generic/pgtable.h>
39965 + * Overrides for Emacs so that we follow Linus's tabbing style.
39966 + * Emacs will notice this stuff at the end of the file and automatically
39967 + * adjust the settings for this buffer only. This must remain at the end
39969 + * ---------------------------------------------------------------------------
39970 + * Local variables:
39971 + * c-file-style: "linux"
39974 diff -Naur -X ../exclude-files orig/include/asm-um/poll.h um/include/asm-um/poll.h
39975 --- orig/include/asm-um/poll.h 1969-12-31 19:00:00.000000000 -0500
39976 +++ um/include/asm-um/poll.h 2003-10-21 03:26:07.000000000 -0400
39978 +#ifndef __UM_POLL_H
39979 +#define __UM_POLL_H
39981 +#include "asm/arch/poll.h"
39984 diff -Naur -X ../exclude-files orig/include/asm-um/posix_types.h um/include/asm-um/posix_types.h
39985 --- orig/include/asm-um/posix_types.h 1969-12-31 19:00:00.000000000 -0500
39986 +++ um/include/asm-um/posix_types.h 2003-10-21 03:26:07.000000000 -0400
39988 +#ifndef __UM_POSIX_TYPES_H
39989 +#define __UM_POSIX_TYPES_H
39991 +#include "asm/arch/posix_types.h"
39994 diff -Naur -X ../exclude-files orig/include/asm-um/processor-generic.h um/include/asm-um/processor-generic.h
39995 --- orig/include/asm-um/processor-generic.h 1969-12-31 19:00:00.000000000 -0500
39996 +++ um/include/asm-um/processor-generic.h 2004-02-14 06:28:59.000000000 -0500
39999 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
40000 + * Licensed under the GPL
40003 +#ifndef __UM_PROCESSOR_GENERIC_H
40004 +#define __UM_PROCESSOR_GENERIC_H
40008 +struct task_struct;
40010 +#include "linux/config.h"
40011 +#include "linux/signal.h"
40012 +#include "asm/ptrace.h"
40013 +#include "asm/siginfo.h"
40014 +#include "choose-mode.h"
40018 +#define current_text_addr() ((void *) 0)
40020 +#define cpu_relax() do ; while (0)
40022 +struct thread_struct {
40024 + unsigned long kernel_stack;
40026 + struct pt_regs regs;
40027 + unsigned long cr2;
40029 + unsigned long trap_no;
40030 + void *fault_addr;
40031 + void *fault_catcher;
40032 + struct task_struct *prev_sched;
40033 + unsigned long temp_stack;
40035 + struct arch_thread arch;
40037 +#ifdef CONFIG_MODE_TT
40041 + int switch_pipe[2];
40042 + int singlestep_syscall;
40046 +#ifdef CONFIG_MODE_SKAS
40048 + void *switch_buf;
40061 + int (*proc)(void *);
40065 + void (*proc)(void *);
40072 +#define INIT_THREAD \
40075 + .kernel_stack = 0, \
40076 + .nsyscalls = 0, \
40077 + .regs = EMPTY_REGS, \
40080 + .fault_addr = NULL, \
40081 + .prev_sched = NULL, \
40082 + .temp_stack = 0, \
40083 + .exec_buf = NULL, \
40084 + .arch = INIT_ARCH_THREAD, \
40085 + .request = { 0 } \
40088 +#define THREAD_SIZE ((1 << CONFIG_KERNEL_STACK_ORDER) * PAGE_SIZE)
40091 + unsigned long seg;
40094 +extern struct task_struct *alloc_task_struct(void);
40095 +extern void free_task_struct(struct task_struct *task);
40097 +#define get_task_struct(tsk) atomic_inc(&virt_to_page(tsk)->count)
40099 +extern void release_thread(struct task_struct *);
40100 +extern int arch_kernel_thread(int (*fn)(void *), void * arg,
40101 + unsigned long flags);
40102 +extern void dump_thread(struct pt_regs *regs, struct user *u);
40104 +extern unsigned long thread_saved_pc(struct thread_struct *t);
40106 +static inline void mm_copy_segments(struct mm_struct *from_mm,
40107 + struct mm_struct *new_mm)
40111 +static inline void copy_segments(struct task_struct *p,
40112 + struct mm_struct *new_mm)
40116 +static inline void release_segments(struct mm_struct *mm)
40120 +#define init_task (init_task_union.task)
40121 +#define init_stack (init_task_union.stack)
40124 + * User space process size: 3GB (default).
40126 +extern unsigned long task_size;
40128 +#define TASK_SIZE (task_size)
40130 +/* This decides where the kernel will search for a free chunk of vm
40131 + * space during mmap's.
40133 +#define TASK_UNMAPPED_BASE (0x40000000)
40135 +extern void start_thread(struct pt_regs *regs, unsigned long entry,
40136 + unsigned long stack);
40138 +struct cpuinfo_um {
40139 + unsigned long loops_per_jiffy;
40140 + unsigned long *pgd_quick;
40141 + unsigned long *pmd_quick;
40142 + unsigned long *pte_quick;
40143 + unsigned long pgtable_cache_sz;
40147 +extern struct cpuinfo_um boot_cpu_data;
40149 +#define my_cpu_data cpu_data[smp_processor_id()]
40152 +extern struct cpuinfo_um cpu_data[];
40153 +#define current_cpu_data cpu_data[smp_processor_id()]
40155 +#define cpu_data (&boot_cpu_data)
40156 +#define current_cpu_data boot_cpu_data
40159 +#define KSTK_EIP(tsk) (PT_REGS_IP(&tsk->thread.regs))
40160 +#define KSTK_ESP(tsk) (PT_REGS_SP(&tsk->thread.regs))
40161 +#define get_wchan(p) (0)
40166 + * Overrides for Emacs so that we follow Linus's tabbing style.
40167 + * Emacs will notice this stuff at the end of the file and automatically
40168 + * adjust the settings for this buffer only. This must remain at the end
40170 + * ---------------------------------------------------------------------------
40171 + * Local variables:
40172 + * c-file-style: "linux"
40175 diff -Naur -X ../exclude-files orig/include/asm-um/processor-i386.h um/include/asm-um/processor-i386.h
40176 --- orig/include/asm-um/processor-i386.h 1969-12-31 19:00:00.000000000 -0500
40177 +++ um/include/asm-um/processor-i386.h 2004-02-14 06:28:59.000000000 -0500
40180 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
40181 + * Licensed under the GPL
40184 +#ifndef __UM_PROCESSOR_I386_H
40185 +#define __UM_PROCESSOR_I386_H
40187 +extern int cpu_has_xmm;
40188 +extern int cpu_has_cmov;
40190 +struct arch_thread {
40191 + unsigned long debugregs[8];
40192 + int debugregs_seq;
40195 +#define INIT_ARCH_THREAD { .debugregs = { [ 0 ... 7 ] = 0 }, \
40196 + .debugregs_seq = 0 }
40198 +#include "asm/arch/user.h"
40200 +#include "asm/processor-generic.h"
40205 + * Overrides for Emacs so that we follow Linus's tabbing style.
40206 + * Emacs will notice this stuff at the end of the file and automatically
40207 + * adjust the settings for this buffer only. This must remain at the end
40209 + * ---------------------------------------------------------------------------
40210 + * Local variables:
40211 + * c-file-style: "linux"
40214 diff -Naur -X ../exclude-files orig/include/asm-um/processor-ppc.h um/include/asm-um/processor-ppc.h
40215 --- orig/include/asm-um/processor-ppc.h 1969-12-31 19:00:00.000000000 -0500
40216 +++ um/include/asm-um/processor-ppc.h 2003-10-21 03:26:07.000000000 -0400
40218 +#ifndef __UM_PROCESSOR_PPC_H
40219 +#define __UM_PROCESSOR_PPC_H
40221 +#if defined(__ASSEMBLY__)
40223 +#define CONFIG_ALL_PPC
40224 +#include "arch/processor.h"
40228 +#include "asm/processor-generic.h"
40233 diff -Naur -X ../exclude-files orig/include/asm-um/ptrace-generic.h um/include/asm-um/ptrace-generic.h
40234 --- orig/include/asm-um/ptrace-generic.h 1969-12-31 19:00:00.000000000 -0500
40235 +++ um/include/asm-um/ptrace-generic.h 2004-02-14 06:28:59.000000000 -0500
40238 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
40239 + * Licensed under the GPL
40242 +#ifndef __UM_PTRACE_GENERIC_H
40243 +#define __UM_PTRACE_GENERIC_H
40245 +#ifndef __ASSEMBLY__
40247 +#include "linux/config.h"
40249 +#include "asm/current.h"
40251 +#define pt_regs pt_regs_subarch
40252 +#define show_regs show_regs_subarch
40254 +#include "asm/arch/ptrace.h"
40259 +#undef instruction_pointer
40261 +#include "sysdep/ptrace.h"
40262 +#include "skas_ptrace.h"
40265 + union uml_pt_regs regs;
40268 +#define EMPTY_REGS { regs : EMPTY_UML_PT_REGS }
40270 +#define PT_REGS_IP(r) UPT_IP(&(r)->regs)
40271 +#define PT_REGS_SP(r) UPT_SP(&(r)->regs)
40273 +#define PT_REG(r, reg) UPT_REG(&(r)->regs, reg)
40274 +#define PT_REGS_SET(r, reg, val) UPT_SET(&(r)->regs, reg, val)
40276 +#define PT_REGS_SET_SYSCALL_RETURN(r, res) \
40277 + UPT_SET_SYSCALL_RETURN(&(r)->regs, res)
40278 +#define PT_REGS_RESTART_SYSCALL(r) UPT_RESTART_SYSCALL(&(r)->regs)
40280 +#define PT_REGS_SYSCALL_NR(r) UPT_SYSCALL_NR(&(r)->regs)
40282 +#define PT_REGS_SC(r) UPT_SC(&(r)->regs)
40284 +struct task_struct;
40286 +extern unsigned long getreg(struct task_struct *child, int regno);
40287 +extern int putreg(struct task_struct *child, int regno, unsigned long value);
40288 +extern int get_fpregs(unsigned long buf, struct task_struct *child);
40289 +extern int set_fpregs(unsigned long buf, struct task_struct *child);
40290 +extern int get_fpxregs(unsigned long buf, struct task_struct *child);
40291 +extern int set_fpxregs(unsigned long buf, struct task_struct *tsk);
40293 +extern void show_regs(struct pt_regs *regs);
40295 +#define INIT_TASK_SIZE ((1 << CONFIG_KERNEL_STACK_ORDER) * PAGE_SIZE)
40302 + * Overrides for Emacs so that we follow Linus's tabbing style.
40303 + * Emacs will notice this stuff at the end of the file and automatically
40304 + * adjust the settings for this buffer only. This must remain at the end
40306 + * ---------------------------------------------------------------------------
40307 + * Local variables:
40308 + * c-file-style: "linux"
40311 diff -Naur -X ../exclude-files orig/include/asm-um/ptrace-i386.h um/include/asm-um/ptrace-i386.h
40312 --- orig/include/asm-um/ptrace-i386.h 1969-12-31 19:00:00.000000000 -0500
40313 +++ um/include/asm-um/ptrace-i386.h 2004-02-14 06:28:59.000000000 -0500
40316 + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
40317 + * Licensed under the GPL
40320 +#ifndef __UM_PTRACE_I386_H
40321 +#define __UM_PTRACE_I386_H
40323 +#include "sysdep/ptrace.h"
40324 +#include "asm/ptrace-generic.h"
40326 +#define PT_REGS_EAX(r) UPT_EAX(&(r)->regs)
40327 +#define PT_REGS_EBX(r) UPT_EBX(&(r)->regs)
40328 +#define PT_REGS_ECX(r) UPT_ECX(&(r)->regs)
40329 +#define PT_REGS_EDX(r) UPT_EDX(&(r)->regs)
40330 +#define PT_REGS_ESI(r) UPT_ESI(&(r)->regs)
40331 +#define PT_REGS_EDI(r) UPT_EDI(&(r)->regs)
40332 +#define PT_REGS_EBP(r) UPT_EBP(&(r)->regs)
40334 +#define PT_REGS_CS(r) UPT_CS(&(r)->regs)
40335 +#define PT_REGS_SS(r) UPT_SS(&(r)->regs)
40336 +#define PT_REGS_DS(r) UPT_DS(&(r)->regs)
40337 +#define PT_REGS_ES(r) UPT_ES(&(r)->regs)
40338 +#define PT_REGS_FS(r) UPT_FS(&(r)->regs)
40339 +#define PT_REGS_GS(r) UPT_GS(&(r)->regs)
40341 +#define PT_REGS_EFLAGS(r) UPT_EFLAGS(&(r)->regs)
40343 +#define PT_REGS_ORIG_SYSCALL(r) PT_REGS_EAX(r)
40344 +#define PT_REGS_SYSCALL_RET(r) PT_REGS_EAX(r)
40345 +#define PT_FIX_EXEC_STACK(sp) do ; while(0)
40347 +#define user_mode(r) UPT_IS_USER(&(r)->regs)
40352 + * Overrides for Emacs so that we follow Linus's tabbing style.
40353 + * Emacs will notice this stuff at the end of the file and automatically
40354 + * adjust the settings for this buffer only. This must remain at the end
40356 + * ---------------------------------------------------------------------------
40357 + * Local variables:
40358 + * c-file-style: "linux"
40361 diff -Naur -X ../exclude-files orig/include/asm-um/resource.h um/include/asm-um/resource.h
40362 --- orig/include/asm-um/resource.h 1969-12-31 19:00:00.000000000 -0500
40363 +++ um/include/asm-um/resource.h 2003-10-21 03:26:07.000000000 -0400
40365 +#ifndef __UM_RESOURCE_H
40366 +#define __UM_RESOURCE_H
40368 +#include "asm/arch/resource.h"
40371 diff -Naur -X ../exclude-files orig/include/asm-um/rwlock.h um/include/asm-um/rwlock.h
40372 --- orig/include/asm-um/rwlock.h 1969-12-31 19:00:00.000000000 -0500
40373 +++ um/include/asm-um/rwlock.h 2003-10-21 03:26:07.000000000 -0400
40375 +#ifndef __UM_RWLOCK_H
40376 +#define __UM_RWLOCK_H
40378 +#include "asm/arch/rwlock.h"
40381 diff -Naur -X ../exclude-files orig/include/asm-um/rwsem.h um/include/asm-um/rwsem.h
40382 --- orig/include/asm-um/rwsem.h 1969-12-31 19:00:00.000000000 -0500
40383 +++ um/include/asm-um/rwsem.h 2004-02-14 06:28:59.000000000 -0500
40385 +#ifndef __UM_RWSEM_H__
40386 +#define __UM_RWSEM_H__
40388 +#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
40389 +#define __builtin_expect(exp,c) (exp)
40392 +#include "asm/arch/rwsem.h"
40395 diff -Naur -X ../exclude-files orig/include/asm-um/scatterlist.h um/include/asm-um/scatterlist.h
40396 --- orig/include/asm-um/scatterlist.h 1969-12-31 19:00:00.000000000 -0500
40397 +++ um/include/asm-um/scatterlist.h 2003-10-21 03:26:07.000000000 -0400
40399 +#ifndef __UM_SCATTERLIST_H
40400 +#define __UM_SCATTERLIST_H
40402 +#include "asm/arch/scatterlist.h"
40405 diff -Naur -X ../exclude-files orig/include/asm-um/segment.h um/include/asm-um/segment.h
40406 --- orig/include/asm-um/segment.h 1969-12-31 19:00:00.000000000 -0500
40407 +++ um/include/asm-um/segment.h 2003-10-21 03:26:07.000000000 -0400
40409 +#ifndef __UM_SEGMENT_H
40410 +#define __UM_SEGMENT_H
40413 diff -Naur -X ../exclude-files orig/include/asm-um/semaphore.h um/include/asm-um/semaphore.h
40414 --- orig/include/asm-um/semaphore.h 1969-12-31 19:00:00.000000000 -0500
40415 +++ um/include/asm-um/semaphore.h 2004-02-14 06:28:59.000000000 -0500
40417 +#ifndef __UM_SEMAPHORE_H
40418 +#define __UM_SEMAPHORE_H
40420 +#include "asm/arch/semaphore.h"
40423 diff -Naur -X ../exclude-files orig/include/asm-um/sembuf.h um/include/asm-um/sembuf.h
40424 --- orig/include/asm-um/sembuf.h 1969-12-31 19:00:00.000000000 -0500
40425 +++ um/include/asm-um/sembuf.h 2003-10-21 03:26:07.000000000 -0400
40427 +#ifndef __UM_SEMBUF_H
40428 +#define __UM_SEMBUF_H
40430 +#include "asm/arch/sembuf.h"
40433 diff -Naur -X ../exclude-files orig/include/asm-um/serial.h um/include/asm-um/serial.h
40434 --- orig/include/asm-um/serial.h 1969-12-31 19:00:00.000000000 -0500
40435 +++ um/include/asm-um/serial.h 2003-10-21 03:26:07.000000000 -0400
40437 +#ifndef __UM_SERIAL_H
40438 +#define __UM_SERIAL_H
40440 +#include "asm/arch/serial.h"
40443 diff -Naur -X ../exclude-files orig/include/asm-um/shmbuf.h um/include/asm-um/shmbuf.h
40444 --- orig/include/asm-um/shmbuf.h 1969-12-31 19:00:00.000000000 -0500
40445 +++ um/include/asm-um/shmbuf.h 2003-10-21 03:26:07.000000000 -0400
40447 +#ifndef __UM_SHMBUF_H
40448 +#define __UM_SHMBUF_H
40450 +#include "asm/arch/shmbuf.h"
40453 diff -Naur -X ../exclude-files orig/include/asm-um/shmparam.h um/include/asm-um/shmparam.h
40454 --- orig/include/asm-um/shmparam.h 1969-12-31 19:00:00.000000000 -0500
40455 +++ um/include/asm-um/shmparam.h 2003-10-21 03:26:07.000000000 -0400
40457 +#ifndef __UM_SHMPARAM_H
40458 +#define __UM_SHMPARAM_H
40460 +#include "asm/arch/shmparam.h"
40463 diff -Naur -X ../exclude-files orig/include/asm-um/sigcontext-generic.h um/include/asm-um/sigcontext-generic.h
40464 --- orig/include/asm-um/sigcontext-generic.h 1969-12-31 19:00:00.000000000 -0500
40465 +++ um/include/asm-um/sigcontext-generic.h 2003-10-21 03:26:07.000000000 -0400
40467 +#ifndef __UM_SIGCONTEXT_GENERIC_H
40468 +#define __UM_SIGCONTEXT_GENERIC_H
40470 +#include "asm/arch/sigcontext.h"
40473 diff -Naur -X ../exclude-files orig/include/asm-um/sigcontext-i386.h um/include/asm-um/sigcontext-i386.h
40474 --- orig/include/asm-um/sigcontext-i386.h 1969-12-31 19:00:00.000000000 -0500
40475 +++ um/include/asm-um/sigcontext-i386.h 2003-10-21 03:26:07.000000000 -0400
40477 +#ifndef __UM_SIGCONTEXT_I386_H
40478 +#define __UM_SIGCONTEXT_I386_H
40480 +#include "asm/sigcontext-generic.h"
40483 diff -Naur -X ../exclude-files orig/include/asm-um/sigcontext-ppc.h um/include/asm-um/sigcontext-ppc.h
40484 --- orig/include/asm-um/sigcontext-ppc.h 1969-12-31 19:00:00.000000000 -0500
40485 +++ um/include/asm-um/sigcontext-ppc.h 2003-10-21 03:26:07.000000000 -0400
40487 +#ifndef __UM_SIGCONTEXT_PPC_H
40488 +#define __UM_SIGCONTEXT_PPC_H
40490 +#define pt_regs sys_pt_regs
40492 +#include "asm/sigcontext-generic.h"
40497 diff -Naur -X ../exclude-files orig/include/asm-um/siginfo.h um/include/asm-um/siginfo.h
40498 --- orig/include/asm-um/siginfo.h 1969-12-31 19:00:00.000000000 -0500
40499 +++ um/include/asm-um/siginfo.h 2004-02-14 06:28:59.000000000 -0500
40501 +#ifndef __UM_SIGINFO_H
40502 +#define __UM_SIGINFO_H
40504 +#include "asm/arch/siginfo.h"
40507 diff -Naur -X ../exclude-files orig/include/asm-um/signal.h um/include/asm-um/signal.h
40508 --- orig/include/asm-um/signal.h 1969-12-31 19:00:00.000000000 -0500
40509 +++ um/include/asm-um/signal.h 2004-02-14 06:28:59.000000000 -0500
40512 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
40513 + * Licensed under the GPL
40516 +#ifndef __UM_SIGNAL_H
40517 +#define __UM_SIGNAL_H
40519 +#include "asm/arch/signal.h"
40524 + * Overrides for Emacs so that we follow Linus's tabbing style.
40525 + * Emacs will notice this stuff at the end of the file and automatically
40526 + * adjust the settings for this buffer only. This must remain at the end
40528 + * ---------------------------------------------------------------------------
40529 + * Local variables:
40530 + * c-file-style: "linux"
40533 diff -Naur -X ../exclude-files orig/include/asm-um/smp.h um/include/asm-um/smp.h
40534 --- orig/include/asm-um/smp.h 1969-12-31 19:00:00.000000000 -0500
40535 +++ um/include/asm-um/smp.h 2004-02-14 06:28:59.000000000 -0500
40537 +#ifndef __UM_SMP_H
40538 +#define __UM_SMP_H
40542 +#include "linux/config.h"
40543 +#include "asm/current.h"
40545 +#define smp_processor_id() (current->processor)
40546 +#define cpu_logical_map(n) (n)
40547 +#define cpu_number_map(n) (n)
40548 +#define PROC_CHANGE_PENALTY 15 /* Pick a number, any number */
40549 +extern int hard_smp_processor_id(void);
40550 +extern unsigned long cpu_online_map;
40551 +#define NO_PROC_ID -1
40556 diff -Naur -X ../exclude-files orig/include/asm-um/smplock.h um/include/asm-um/smplock.h
40557 --- orig/include/asm-um/smplock.h 1969-12-31 19:00:00.000000000 -0500
40558 +++ um/include/asm-um/smplock.h 2004-02-14 06:28:59.000000000 -0500
40560 +#ifndef __UM_SMPLOCK_H
40561 +#define __UM_SMPLOCK_H
40563 +#include "asm/arch/smplock.h"
40566 diff -Naur -X ../exclude-files orig/include/asm-um/socket.h um/include/asm-um/socket.h
40567 --- orig/include/asm-um/socket.h 1969-12-31 19:00:00.000000000 -0500
40568 +++ um/include/asm-um/socket.h 2003-11-07 02:10:43.000000000 -0500
40570 +#ifndef __UM_SOCKET_H
40571 +#define __UM_SOCKET_H
40573 +#include "asm/arch/socket.h"
40576 diff -Naur -X ../exclude-files orig/include/asm-um/sockios.h um/include/asm-um/sockios.h
40577 --- orig/include/asm-um/sockios.h 1969-12-31 19:00:00.000000000 -0500
40578 +++ um/include/asm-um/sockios.h 2003-10-21 03:26:07.000000000 -0400
40580 +#ifndef __UM_SOCKIOS_H
40581 +#define __UM_SOCKIOS_H
40583 +#include "asm/arch/sockios.h"
40586 diff -Naur -X ../exclude-files orig/include/asm-um/softirq.h um/include/asm-um/softirq.h
40587 --- orig/include/asm-um/softirq.h 1969-12-31 19:00:00.000000000 -0500
40588 +++ um/include/asm-um/softirq.h 2004-02-14 06:28:59.000000000 -0500
40590 +#ifndef __UM_SOFTIRQ_H
40591 +#define __UM_SOFTIRQ_H
40593 +#include "linux/smp.h"
40594 +#include "asm/system.h"
40595 +#include "asm/processor.h"
40597 +/* A gratuitous name change */
40598 +#define i386_bh_lock um_bh_lock
40599 +#include "asm/arch/softirq.h"
40600 +#undef i386_bh_lock
40603 diff -Naur -X ../exclude-files orig/include/asm-um/spinlock.h um/include/asm-um/spinlock.h
40604 --- orig/include/asm-um/spinlock.h 1969-12-31 19:00:00.000000000 -0500
40605 +++ um/include/asm-um/spinlock.h 2004-02-14 06:28:59.000000000 -0500
40607 +#ifndef __UM_SPINLOCK_H
40608 +#define __UM_SPINLOCK_H
40610 +#include "linux/config.h"
40613 +#include "asm/arch/spinlock.h"
40617 diff -Naur -X ../exclude-files orig/include/asm-um/statfs.h um/include/asm-um/statfs.h
40618 --- orig/include/asm-um/statfs.h 1969-12-31 19:00:00.000000000 -0500
40619 +++ um/include/asm-um/statfs.h 2004-02-14 06:28:59.000000000 -0500
40621 +#ifndef _UM_STATFS_H
40622 +#define _UM_STATFS_H
40624 +#include "asm/arch/statfs.h"
40627 diff -Naur -X ../exclude-files orig/include/asm-um/stat.h um/include/asm-um/stat.h
40628 --- orig/include/asm-um/stat.h 1969-12-31 19:00:00.000000000 -0500
40629 +++ um/include/asm-um/stat.h 2003-10-21 03:26:07.000000000 -0400
40631 +#ifndef __UM_STAT_H
40632 +#define __UM_STAT_H
40634 +#include "asm/arch/stat.h"
40637 diff -Naur -X ../exclude-files orig/include/asm-um/string.h um/include/asm-um/string.h
40638 --- orig/include/asm-um/string.h 1969-12-31 19:00:00.000000000 -0500
40639 +++ um/include/asm-um/string.h 2004-01-16 03:32:58.000000000 -0500
40641 +#ifndef __UM_STRING_H
40642 +#define __UM_STRING_H
40644 +#include "asm/arch/string.h"
40645 +#include "asm/archparam.h"
40648 diff -Naur -X ../exclude-files orig/include/asm-um/system-generic.h um/include/asm-um/system-generic.h
40649 --- orig/include/asm-um/system-generic.h 1969-12-31 19:00:00.000000000 -0500
40650 +++ um/include/asm-um/system-generic.h 2004-02-14 06:28:59.000000000 -0500
40652 +#ifndef __UM_SYSTEM_GENERIC_H
40653 +#define __UM_SYSTEM_GENERIC_H
40655 +#include "asm/arch/system.h"
40657 +#undef prepare_to_switch
40659 +#undef __save_flags
40661 +#undef __restore_flags
40662 +#undef restore_flags
40667 +#undef local_irq_save
40668 +#undef local_irq_restore
40669 +#undef local_irq_disable
40670 +#undef local_irq_enable
40672 +#define prepare_to_switch() do ; while(0)
40674 +void *_switch_to(void *prev, void *next);
40676 +#define switch_to(prev, next, last) prev = _switch_to(prev, next)
40678 +extern int get_signals(void);
40679 +extern int set_signals(int enable);
40680 +extern void block_signals(void);
40681 +extern void unblock_signals(void);
40683 +#define local_irq_save(flags) do { (flags) = set_signals(0); } while(0)
40685 +#define local_irq_restore(flags) do { set_signals(flags); } while(0)
40687 +#define local_irq_enable() unblock_signals()
40688 +#define local_irq_disable() block_signals()
40690 +#define __sti() unblock_signals()
40691 +#define sti() unblock_signals()
40692 +#define __cli() block_signals()
40693 +#define cli() block_signals()
40695 +#define __save_flags(x) do { (x) = get_signals(); } while(0)
40696 +#define save_flags(x) __save_flags(x)
40698 +#define __restore_flags(x) local_irq_restore(x)
40699 +#define restore_flags(x) __restore_flags(x)
40702 diff -Naur -X ../exclude-files orig/include/asm-um/system-i386.h um/include/asm-um/system-i386.h
40703 --- orig/include/asm-um/system-i386.h 1969-12-31 19:00:00.000000000 -0500
40704 +++ um/include/asm-um/system-i386.h 2004-02-14 06:28:59.000000000 -0500
40706 +#ifndef __UM_SYSTEM_I386_H
40707 +#define __UM_SYSTEM_I386_H
40709 +#include "asm/system-generic.h"
40711 +#define __HAVE_ARCH_CMPXCHG 1
40713 +static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
40714 + unsigned long new, int size)
40716 + unsigned long prev;
40719 + __asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
40721 + : "q"(new), "m"(*__xg(ptr)), "0"(old)
40725 + __asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
40727 + : "q"(new), "m"(*__xg(ptr)), "0"(old)
40731 + __asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
40733 + : "q"(new), "m"(*__xg(ptr)), "0"(old)
40740 +#define cmpxchg(ptr,o,n)\
40741 + ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\
40742 + (unsigned long)(n),sizeof(*(ptr))))
40745 diff -Naur -X ../exclude-files orig/include/asm-um/system-ppc.h um/include/asm-um/system-ppc.h
40746 --- orig/include/asm-um/system-ppc.h 1969-12-31 19:00:00.000000000 -0500
40747 +++ um/include/asm-um/system-ppc.h 2003-10-21 03:26:07.000000000 -0400
40749 +#ifndef __UM_SYSTEM_PPC_H
40750 +#define __UM_SYSTEM_PPC_H
40752 +#define _switch_to _ppc_switch_to
40754 +#include "asm/arch/system.h"
40758 +#include "asm/system-generic.h"
40761 diff -Naur -X ../exclude-files orig/include/asm-um/termbits.h um/include/asm-um/termbits.h
40762 --- orig/include/asm-um/termbits.h 1969-12-31 19:00:00.000000000 -0500
40763 +++ um/include/asm-um/termbits.h 2003-11-07 02:10:43.000000000 -0500
40765 +#ifndef __UM_TERMBITS_H
40766 +#define __UM_TERMBITS_H
40768 +#include "asm/arch/termbits.h"
40771 diff -Naur -X ../exclude-files orig/include/asm-um/termios.h um/include/asm-um/termios.h
40772 --- orig/include/asm-um/termios.h 1969-12-31 19:00:00.000000000 -0500
40773 +++ um/include/asm-um/termios.h 2003-12-16 22:26:55.000000000 -0500
40775 +#ifndef __UM_TERMIOS_H
40776 +#define __UM_TERMIOS_H
40778 +#include "asm/arch/termios.h"
40781 diff -Naur -X ../exclude-files orig/include/asm-um/timex.h um/include/asm-um/timex.h
40782 --- orig/include/asm-um/timex.h 1969-12-31 19:00:00.000000000 -0500
40783 +++ um/include/asm-um/timex.h 2004-02-14 06:28:59.000000000 -0500
40785 +#ifndef __UM_TIMEX_H
40786 +#define __UM_TIMEX_H
40788 +#include "linux/time.h"
40790 +typedef unsigned long cycles_t;
40792 +#define cacheflush_time (0)
40794 +static inline cycles_t get_cycles (void)
40799 +#define vxtime_lock() do ; while (0)
40800 +#define vxtime_unlock() do ; while (0)
40803 diff -Naur -X ../exclude-files orig/include/asm-um/tlb.h um/include/asm-um/tlb.h
40804 --- orig/include/asm-um/tlb.h 1969-12-31 19:00:00.000000000 -0500
40805 +++ um/include/asm-um/tlb.h 2003-10-21 03:26:07.000000000 -0400
40807 +#include <asm-generic/tlb.h>
40808 diff -Naur -X ../exclude-files orig/include/asm-um/types.h um/include/asm-um/types.h
40809 --- orig/include/asm-um/types.h 1969-12-31 19:00:00.000000000 -0500
40810 +++ um/include/asm-um/types.h 2004-01-16 03:32:58.000000000 -0500
40812 +#ifndef __UM_TYPES_H
40813 +#define __UM_TYPES_H
40815 +#include "asm/arch/types.h"
40818 diff -Naur -X ../exclude-files orig/include/asm-um/uaccess.h um/include/asm-um/uaccess.h
40819 --- orig/include/asm-um/uaccess.h 1969-12-31 19:00:00.000000000 -0500
40820 +++ um/include/asm-um/uaccess.h 2004-02-14 06:28:59.000000000 -0500
40823 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
40824 + * Licensed under the GPL
40827 +#ifndef __UM_UACCESS_H
40828 +#define __UM_UACCESS_H
40830 +#include "linux/sched.h"
40832 +#define VERIFY_READ 0
40833 +#define VERIFY_WRITE 1
40836 + * The fs value determines whether argument validity checking should be
40837 + * performed or not. If get_fs() == USER_DS, checking is performed, with
40838 + * get_fs() == KERNEL_DS, checking is bypassed.
40840 + * For historical reasons, these macros are grossly misnamed.
40843 +#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
40845 +#define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF)
40846 +#define USER_DS MAKE_MM_SEG(TASK_SIZE)
40848 +#define get_ds() (KERNEL_DS)
40849 +#define get_fs() (current->addr_limit)
40850 +#define set_fs(x) (current->addr_limit = (x))
40852 +#define segment_eq(a, b) ((a).seg == (b).seg)
40854 +#include "um_uaccess.h"
40856 +#define __copy_from_user(to, from, n) copy_from_user(to, from, n)
40858 +#define __copy_to_user(to, from, n) copy_to_user(to, from, n)
40860 +#define __get_user(x, ptr) \
40862 + const __typeof__(ptr) __private_ptr = ptr; \
40863 + __typeof__(*(__private_ptr)) __private_val; \
40864 + int __private_ret = -EFAULT; \
40866 + if (__copy_from_user(&__private_val, (__private_ptr), \
40867 + sizeof(*(__private_ptr))) == 0) {\
40868 + (x) = (__typeof__(*(__private_ptr))) __private_val; \
40869 + __private_ret = 0; \
40874 +#define get_user(x, ptr) \
40876 + const __typeof__((*ptr)) *private_ptr = (ptr); \
40877 + (access_ok(VERIFY_READ, private_ptr, sizeof(*private_ptr)) ? \
40878 + __get_user(x, private_ptr) : ((x) = 0, -EFAULT)); \
40881 +#define __put_user(x, ptr) \
40883 + __typeof__(ptr) __private_ptr = ptr; \
40884 + __typeof__(*(__private_ptr)) __private_val; \
40885 + int __private_ret = -EFAULT; \
40886 + __private_val = (__typeof__(*(__private_ptr))) (x); \
40887 + if (__copy_to_user((__private_ptr), &__private_val, \
40888 + sizeof(*(__private_ptr))) == 0) { \
40889 + __private_ret = 0; \
40894 +#define put_user(x, ptr) \
40896 + __typeof__(*(ptr)) *private_ptr = (ptr); \
40897 + (access_ok(VERIFY_WRITE, private_ptr, sizeof(*private_ptr)) ? \
40898 + __put_user(x, private_ptr) : -EFAULT); \
40901 +#define strlen_user(str) strnlen_user(str, ~0UL >> 1)
40903 +struct exception_table_entry
40905 + unsigned long insn;
40906 + unsigned long fixup;
40912 + * Overrides for Emacs so that we follow Linus's tabbing style.
40913 + * Emacs will notice this stuff at the end of the file and automatically
40914 + * adjust the settings for this buffer only. This must remain at the end
40916 + * ---------------------------------------------------------------------------
40917 + * Local variables:
40918 + * c-file-style: "linux"
40921 diff -Naur -X ../exclude-files orig/include/asm-um/ucontext.h um/include/asm-um/ucontext.h
40922 --- orig/include/asm-um/ucontext.h 1969-12-31 19:00:00.000000000 -0500
40923 +++ um/include/asm-um/ucontext.h 2003-10-21 03:26:07.000000000 -0400
40925 +#ifndef _ASM_UM_UCONTEXT_H
40926 +#define _ASM_UM_UCONTEXT_H
40928 +#include "asm/arch/ucontext.h"
40931 diff -Naur -X ../exclude-files orig/include/asm-um/unaligned.h um/include/asm-um/unaligned.h
40932 --- orig/include/asm-um/unaligned.h 1969-12-31 19:00:00.000000000 -0500
40933 +++ um/include/asm-um/unaligned.h 2003-10-21 03:26:07.000000000 -0400
40935 +#ifndef __UM_UNALIGNED_H
40936 +#define __UM_UNALIGNED_H
40938 +#include "asm/arch/unaligned.h"
40941 diff -Naur -X ../exclude-files orig/include/asm-um/unistd.h um/include/asm-um/unistd.h
40942 --- orig/include/asm-um/unistd.h 1969-12-31 19:00:00.000000000 -0500
40943 +++ um/include/asm-um/unistd.h 2004-02-14 06:29:00.000000000 -0500
40946 + * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
40947 + * Licensed under the GPL
40950 +#ifndef _UM_UNISTD_H_
40951 +#define _UM_UNISTD_H_
40953 +#include "linux/resource.h"
40954 +#include "asm/uaccess.h"
40956 +extern long sys_open(const char *filename, int flags, int mode);
40957 +extern long sys_dup(unsigned int fildes);
40958 +extern long sys_close(unsigned int fd);
40959 +extern int um_execve(const char *file, char *const argv[], char *const env[]);
40960 +extern long sys_setsid(void);
40961 +extern long sys_waitpid(pid_t pid, unsigned int * stat_addr, int options);
40962 +extern long sys_wait4(pid_t pid,unsigned int *stat_addr, int options,
40963 + struct rusage *ru);
40964 +extern long sys_mount(char *dev_name, char *dir_name, char *type,
40965 + unsigned long flags, void *data);
40966 +extern long sys_select(int n, fd_set *inp, fd_set *outp, fd_set *exp,
40967 + struct timeval *tvp);
40968 +extern long sys_lseek(unsigned int fildes, unsigned long offset, int whence);
40969 +extern long sys_read(unsigned int fildes, char *buf, int len);
40970 +extern long sys_write(unsigned int fildes, char *buf, int len);
40972 +#ifdef __KERNEL_SYSCALLS__
40974 +#define KERNEL_CALL(ret_t, sys, args...) \
40975 + mm_segment_t fs = get_fs(); \
40977 + set_fs(KERNEL_DS); \
40978 + ret = sys(args); \
40982 + errno = -(long)ret; \
40985 +static inline long open(const char *pathname, int flags, int mode)
40987 + KERNEL_CALL(int, sys_open, pathname, flags, mode)
40990 +static inline long dup(unsigned int fd)
40992 + KERNEL_CALL(int, sys_dup, fd);
40995 +static inline long close(unsigned int fd)
40997 + KERNEL_CALL(int, sys_close, fd);
41000 +static inline int execve(const char *filename, char *const argv[],
41001 + char *const envp[])
41003 + KERNEL_CALL(int, um_execve, filename, argv, envp);
41006 +static inline long waitpid(pid_t pid, unsigned int *status, int options)
41008 + KERNEL_CALL(pid_t, sys_wait4, pid, status, options, NULL)
41011 +static inline pid_t wait(int *status)
41013 + KERNEL_CALL(pid_t, sys_wait4, -1, status, 0, NULL)
41016 +static inline pid_t setsid(void)
41018 + KERNEL_CALL(pid_t, sys_setsid)
41021 +static inline long lseek(unsigned int fd, off_t offset, unsigned int whence)
41023 + KERNEL_CALL(long, sys_lseek, fd, offset, whence)
41026 +static inline int read(unsigned int fd, char * buf, int len)
41028 + KERNEL_CALL(int, sys_read, fd, buf, len)
41031 +static inline int write(unsigned int fd, char * buf, int len)
41033 + KERNEL_CALL(int, sys_write, fd, buf, len)
41038 +/* Save the value of __KERNEL_SYSCALLS__, undefine it, include the underlying
41039 + * arch's unistd.h for the system call numbers, and restore the old
41040 + * __KERNEL_SYSCALLS__.
41043 +#ifdef __KERNEL_SYSCALLS__
41044 +#define __SAVE_KERNEL_SYSCALLS__ __KERNEL_SYSCALLS__
41047 +#undef __KERNEL_SYSCALLS__
41048 +#include "asm/arch/unistd.h"
41050 +#ifdef __KERNEL_SYSCALLS__
41051 +#define __KERNEL_SYSCALLS__ __SAVE_KERNEL_SYSCALLS__
41057 + * Overrides for Emacs so that we follow Linus's tabbing style.
41058 + * Emacs will notice this stuff at the end of the file and automatically
41059 + * adjust the settings for this buffer only. This must remain at the end
41061 + * ---------------------------------------------------------------------------
41062 + * Local variables:
41063 + * c-file-style: "linux"
41066 diff -Naur -X ../exclude-files orig/include/asm-um/user.h um/include/asm-um/user.h
41067 --- orig/include/asm-um/user.h 1969-12-31 19:00:00.000000000 -0500
41068 +++ um/include/asm-um/user.h 2004-02-14 06:31:38.000000000 -0500
41070 +#ifndef __UM_USER_H
41071 +#define __UM_USER_H
41073 +#include "asm/arch/user.h"
41076 diff -Naur -X ../exclude-files orig/include/asm-um/vga.h um/include/asm-um/vga.h
41077 --- orig/include/asm-um/vga.h 1969-12-31 19:00:00.000000000 -0500
41078 +++ um/include/asm-um/vga.h 2003-10-21 03:26:07.000000000 -0400
41080 +#ifndef __UM_VGA_H
41081 +#define __UM_VGA_H
41083 +#include "asm/arch/vga.h"
41086 diff -Naur -X ../exclude-files orig/include/asm-um/xor.h um/include/asm-um/xor.h
41087 --- orig/include/asm-um/xor.h 1969-12-31 19:00:00.000000000 -0500
41088 +++ um/include/asm-um/xor.h 2003-10-21 03:26:07.000000000 -0400
41090 +#ifndef __UM_XOR_H
41091 +#define __UM_XOR_H
41093 +#include "asm-generic/xor.h"
41096 diff -Naur -X ../exclude-files orig/include/linux/blk.h um/include/linux/blk.h
41097 --- orig/include/linux/blk.h 2004-01-11 22:46:30.000000000 -0500
41098 +++ um/include/linux/blk.h 2004-02-14 06:29:18.000000000 -0500
41099 @@ -320,6 +320,24 @@
41100 #define DEVICE_REQUEST do_ida_request
41101 #define DEVICE_NR(device) (MINOR(device) >> 4)
41103 +#elif (MAJOR_NR == UBD_MAJOR)
41105 +#define DEVICE_NAME "User-mode block device"
41106 +#define DEVICE_INTR do_ubd
41107 +#define DEVICE_REQUEST do_ubd_request
41108 +#define DEVICE_NR(device) (MINOR(device) >> UBD_SHIFT)
41109 +#define DEVICE_ON(device)
41110 +#define DEVICE_OFF(device)
41112 +#elif (MAJOR_NR == COW_MAJOR)
41114 +#define DEVICE_NAME "COW device"
41115 +#define DEVICE_INTR do_cow
41116 +#define DEVICE_REQUEST do_cow_request
41117 +#define DEVICE_NR(device) (MINOR(device) >> COW_SHIFT)
41118 +#define DEVICE_ON(device)
41119 +#define DEVICE_OFF(device)
41121 #endif /* MAJOR_NR == whatever */
41123 /* provide DEVICE_xxx defaults, if not explicitly defined
41124 diff -Naur -X ../exclude-files orig/include/linux/fs.h um/include/linux/fs.h
41125 --- orig/include/linux/fs.h 2003-12-16 22:16:36.000000000 -0500
41126 +++ um/include/linux/fs.h 2004-02-14 06:28:59.000000000 -0500
41127 @@ -320,6 +320,8 @@
41128 #include <linux/ncp_fs_i.h>
41129 #include <linux/proc_fs_i.h>
41130 #include <linux/usbdev_fs_i.h>
41131 +#include <linux/hostfs_fs_i.h>
41132 +#include <linux/hppfs_fs_i.h>
41133 #include <linux/jffs2_fs_i.h>
41134 #include <linux/cramfs_fs_sb.h>
41136 @@ -516,7 +518,9 @@
41137 struct proc_inode_info proc_i;
41138 struct socket socket_i;
41139 struct usbdev_inode_info usbdev_i;
41140 - struct jffs2_inode_info jffs2_i;
41141 + struct hostfs_inode_info hostfs_i;
41142 + struct hppfs_inode_info hppfs_i;
41143 + struct jffs2_inode_info jffs2_i;
41147 @@ -864,6 +868,8 @@
41148 unsigned int (*poll) (struct file *, struct poll_table_struct *);
41149 int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
41150 int (*mmap) (struct file *, struct vm_area_struct *);
41151 + void (*munmap) (struct file *, struct vm_area_struct *,
41152 + unsigned long start, unsigned long len);
41153 int (*open) (struct inode *, struct file *);
41154 int (*flush) (struct file *);
41155 int (*release) (struct inode *, struct file *);
41156 diff -Naur -X ../exclude-files orig/include/linux/ghash.h um/include/linux/ghash.h
41157 --- orig/include/linux/ghash.h 1997-07-07 11:24:28.000000000 -0400
41158 +++ um/include/linux/ghash.h 2003-10-21 03:26:07.000000000 -0400
41159 @@ -153,6 +153,26 @@
41163 +/* LINKAGE - empty or "static", depending on whether you want the definitions to
41164 + * be public or not
41165 + * NAME - a string to stick in names to make this hash table type distinct from
41167 + * HASHSIZE - number of buckets
41168 + * TYPE - type of data contained in the buckets - must be a structure, one
41169 + * field is of type NAME_ptrs, another is the hash key
41170 + * PTRS - TYPE must contain a field of type NAME_ptrs, PTRS is the name of that
41172 + * KEYTYPE - type of the key field within TYPE
41173 + * KEY - name of the key field within TYPE
41174 + * KEYCMP - pointer to function that compares KEYTYPEs to each other - the
41175 + * prototype is int KEYCMP(KEYTYPE, KEYTYPE), it returns zero for equal,
41176 + * non-zero for not equal
41177 + * HASHFN - the hash function - the prototype is int HASHFN(KEYTYPE),
41178 + * it returns a number in the range 0 ... HASHSIZE - 1
41179 + * Call DEF_HASH_STRUCTS, define your hash table as a NAME_table, then call
41183 #define DEF_HASH_STRUCTS(NAME,HASHSIZE,TYPE) \
41185 struct NAME##_table {\
41186 @@ -165,7 +185,7 @@
41190 -#define DEF_HASH(LINKAGE,NAME,HASHSIZE,TYPE,PTRS,KEYTYPE,KEY,KEYCMP,KEYEQ,HASHFN)\
41191 +#define DEF_HASH(LINKAGE,NAME,TYPE,PTRS,KEYTYPE,KEY,KEYCMP,HASHFN)\
41193 LINKAGE void insert_##NAME##_hash(struct NAME##_table * tbl, TYPE * elem)\
41195 @@ -206,12 +226,10 @@
41197 LINKAGE TYPE * find_##NAME##_hash(struct NAME##_table * tbl, KEYTYPE pos)\
41199 - int ix = hashfn(pos);\
41200 + int ix = HASHFN(pos);\
41201 TYPE * ptr = tbl->hashtable[ix];\
41202 while(ptr && KEYCMP(ptr->KEY, pos))\
41203 ptr = ptr->PTRS.next_hash;\
41204 - if(ptr && !KEYEQ(ptr->KEY, pos))\
41209 diff -Naur -X ../exclude-files orig/include/linux/hostfs_fs_i.h um/include/linux/hostfs_fs_i.h
41210 --- orig/include/linux/hostfs_fs_i.h 1969-12-31 19:00:00.000000000 -0500
41211 +++ um/include/linux/hostfs_fs_i.h 2003-10-21 03:26:07.000000000 -0400
41213 +#ifndef _HOSTFS_FS_I
41214 +#define _HOSTFS_FS_I
41216 +struct hostfs_inode_info {
41217 + char *host_filename;
41225 + * Overrides for Emacs so that we follow Linus's tabbing style.
41226 + * Emacs will notice this stuff at the end of the file and automatically
41227 + * adjust the settings for this buffer only. This must remain at the end
41229 + * ---------------------------------------------------------------------------
41230 + * Local variables:
41231 + * c-file-style: "linux"
41234 diff -Naur -X ../exclude-files orig/include/linux/hppfs_fs_i.h um/include/linux/hppfs_fs_i.h
41235 --- orig/include/linux/hppfs_fs_i.h 1969-12-31 19:00:00.000000000 -0500
41236 +++ um/include/linux/hppfs_fs_i.h 2003-10-21 03:26:07.000000000 -0400
41238 +#ifndef _HPPFS_FS_I
41239 +#define _HPPFS_FS_I
41241 +struct hppfs_inode_info {
41242 + struct dentry *proc_dentry;
41248 + * Overrides for Emacs so that we follow Linus's tabbing style.
41249 + * Emacs will notice this stuff at the end of the file and automatically
41250 + * adjust the settings for this buffer only. This must remain at the end
41252 + * ---------------------------------------------------------------------------
41253 + * Local variables:
41254 + * c-file-style: "linux"
41257 diff -Naur -X ../exclude-files orig/include/linux/kernel.h um/include/linux/kernel.h
41258 --- orig/include/linux/kernel.h 2004-01-11 22:46:12.000000000 -0500
41259 +++ um/include/linux/kernel.h 2004-02-14 06:28:59.000000000 -0500
41261 # define ATTRIB_NORET __attribute__((noreturn))
41262 # define NORET_AND noreturn,
41265 +#if defined(__i386__) || defined(UM_FASTCALL)
41266 #define FASTCALL(x) x __attribute__((regparm(3)))
41268 #define FASTCALL(x) x
41269 diff -Naur -X ../exclude-files orig/include/linux/kernel_stat.h um/include/linux/kernel_stat.h
41270 --- orig/include/linux/kernel_stat.h 2004-01-11 22:46:12.000000000 -0500
41271 +++ um/include/linux/kernel_stat.h 2004-02-14 06:28:59.000000000 -0500
41273 * used by rstatd/perfmeter
41276 -#define DK_MAX_MAJOR 16
41277 +#define DK_MAX_MAJOR 99
41278 #define DK_MAX_DISK 16
41280 struct kernel_stat {
41281 diff -Naur -X ../exclude-files orig/include/linux/mm.h um/include/linux/mm.h
41282 --- orig/include/linux/mm.h 2003-12-16 22:16:36.000000000 -0500
41283 +++ um/include/linux/mm.h 2004-02-14 06:28:59.000000000 -0500
41284 @@ -438,6 +438,18 @@
41285 extern struct page * FASTCALL(__alloc_pages(unsigned int gfp_mask, unsigned int order, zonelist_t *zonelist));
41286 extern struct page * alloc_pages_node(int nid, unsigned int gfp_mask, unsigned int order);
41288 +#ifndef HAVE_ARCH_VALIDATE
41289 +static inline struct page *arch_validate(struct page *page,
41290 + unsigned int gfp_mask, int order)
41296 +#ifndef HAVE_ARCH_FREE_PAGE
41297 +static inline void arch_free_page(struct page *page, int order) { }
41300 static inline struct page * alloc_pages(unsigned int gfp_mask, unsigned int order)
41303 @@ -445,7 +457,7 @@
41305 if (order >= MAX_ORDER)
41307 - return _alloc_pages(gfp_mask, order);
41308 + return arch_validate(_alloc_pages(gfp_mask, order), gfp_mask, order);
41311 #define alloc_page(gfp_mask) alloc_pages(gfp_mask, 0)
41312 @@ -505,6 +517,9 @@
41313 int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start,
41314 int len, int write, int force, struct page **pages, struct vm_area_struct **vmas);
41316 +extern long do_mprotect(struct mm_struct *mm, unsigned long start,
41317 + size_t len, unsigned long prot);
41320 * On a two-level page table, this ends up being trivial. Thus the
41321 * inlining and the symmetry break with pte_alloc() that does all
41322 @@ -552,9 +567,10 @@
41324 extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
41326 -extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
41327 - unsigned long len, unsigned long prot,
41328 - unsigned long flag, unsigned long pgoff);
41329 +extern unsigned long do_mmap_pgoff(struct mm_struct *mm, struct file *file,
41330 + unsigned long addr, unsigned long len,
41331 + unsigned long prot, unsigned long flag,
41332 + unsigned long pgoff);
41334 static inline unsigned long do_mmap(struct file *file, unsigned long addr,
41335 unsigned long len, unsigned long prot,
41336 @@ -564,7 +580,8 @@
41337 if ((offset + PAGE_ALIGN(len)) < offset)
41339 if (!(offset & ~PAGE_MASK))
41340 - ret = do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT);
41341 + ret = do_mmap_pgoff(current->mm, file, addr, len, prot, flag,
41342 + offset >> PAGE_SHIFT);
41346 diff -Naur -X ../exclude-files orig/include/linux/proc_mm.h um/include/linux/proc_mm.h
41347 --- orig/include/linux/proc_mm.h 1969-12-31 19:00:00.000000000 -0500
41348 +++ um/include/linux/proc_mm.h 2004-02-14 06:30:22.000000000 -0500
41351 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
41352 + * Licensed under the GPL
41355 +#ifndef __PROC_MM_H
41356 +#define __PROC_MM_H
41358 +#include "linux/sched.h"
41360 +#define MM_MMAP 54
41361 +#define MM_MUNMAP 55
41362 +#define MM_MPROTECT 56
41363 +#define MM_COPY_SEGMENTS 57
41366 + unsigned long addr;
41367 + unsigned long len;
41368 + unsigned long prot;
41369 + unsigned long flags;
41370 + unsigned long fd;
41371 + unsigned long offset;
41374 +struct mm_munmap {
41375 + unsigned long addr;
41376 + unsigned long len;
41379 +struct mm_mprotect {
41380 + unsigned long addr;
41381 + unsigned long len;
41382 + unsigned int prot;
41385 +struct proc_mm_op {
41388 + struct mm_mmap mmap;
41389 + struct mm_munmap munmap;
41390 + struct mm_mprotect mprotect;
41391 + int copy_segments;
41395 +extern struct mm_struct *proc_mm_get_mm(int fd);
41398 diff -Naur -X ../exclude-files orig/include/linux/shmem_fs.h um/include/linux/shmem_fs.h
41399 --- orig/include/linux/shmem_fs.h 2003-09-02 15:44:03.000000000 -0400
41400 +++ um/include/linux/shmem_fs.h 2003-12-09 00:03:31.000000000 -0500
41402 unsigned long next_index;
41403 swp_entry_t i_direct[SHMEM_NR_DIRECT]; /* for the first blocks */
41404 void **i_indirect; /* indirect blocks */
41405 + unsigned long map_direct[SHMEM_NR_DIRECT];
41406 + void **map_indirect;
41407 unsigned long swapped; /* data pages assigned to swap */
41408 unsigned long flags;
41409 struct list_head list;
41410 diff -Naur -X ../exclude-files orig/include/linux/tty.h um/include/linux/tty.h
41411 --- orig/include/linux/tty.h 2004-01-11 22:46:12.000000000 -0500
41412 +++ um/include/linux/tty.h 2004-02-14 06:28:59.000000000 -0500
41413 @@ -309,6 +309,9 @@
41414 spinlock_t read_lock;
41415 /* If the tty has a pending do_SAK, queue it here - akpm */
41416 struct tq_struct SAK_tq;
41417 +#ifdef CONFIG_TTY_LOG
41422 /* tty magic number */
41423 @@ -365,6 +368,7 @@
41424 extern int specialix_init(void);
41425 extern int espserial_init(void);
41426 extern int macserial_init(void);
41427 +extern int stdio_init(void);
41428 extern int a2232board_init(void);
41430 extern int tty_paranoia_check(struct tty_struct *tty, kdev_t device,
41431 @@ -420,5 +424,7 @@
41432 extern int vt_ioctl(struct tty_struct *tty, struct file * file,
41433 unsigned int cmd, unsigned long arg);
41435 +extern void stdio_console_init(void);
41437 #endif /* __KERNEL__ */
41439 diff -Naur -X ../exclude-files orig/init/do_mounts.c um/init/do_mounts.c
41440 --- orig/init/do_mounts.c 2003-12-16 22:16:36.000000000 -0500
41441 +++ um/init/do_mounts.c 2003-12-16 22:17:32.000000000 -0500
41442 @@ -154,6 +154,22 @@
41444 { "apblock", APBLOCK_MAJOR << 8},
41445 { "ddv", DDV_MAJOR << 8},
41446 + { "ubd0", UBD_MAJOR << 8 | 0 << 4},
41447 + { "ubda", UBD_MAJOR << 8 | 0 << 4},
41448 + { "ubd1", UBD_MAJOR << 8 | 1 << 4},
41449 + { "ubdb", UBD_MAJOR << 8 | 1 << 4},
41450 + { "ubd2", UBD_MAJOR << 8 | 2 << 4},
41451 + { "ubdc", UBD_MAJOR << 8 | 2 << 4},
41452 + { "ubd3", UBD_MAJOR << 8 | 3 << 4},
41453 + { "ubdd", UBD_MAJOR << 8 | 3 << 4},
41454 + { "ubd4", UBD_MAJOR << 8 | 4 << 4},
41455 + { "ubde", UBD_MAJOR << 8 | 4 << 4},
41456 + { "ubd5", UBD_MAJOR << 8 | 5 << 4},
41457 + { "ubdf", UBD_MAJOR << 8 | 5 << 4},
41458 + { "ubd6", UBD_MAJOR << 8 | 6 << 4},
41459 + { "ubdg", UBD_MAJOR << 8 | 6 << 4},
41460 + { "ubd7", UBD_MAJOR << 8 | 7 << 4},
41461 + { "ubdh", UBD_MAJOR << 8 | 7 << 4},
41462 { "jsfd", JSFD_MAJOR << 8},
41463 #if defined(CONFIG_ARCH_S390)
41464 { "dasda", (DASD_MAJOR << MINORBITS) },
41465 diff -Naur -X ../exclude-files orig/kernel/panic.c um/kernel/panic.c
41466 --- orig/kernel/panic.c 2003-12-16 22:16:36.000000000 -0500
41467 +++ um/kernel/panic.c 2003-12-16 22:17:32.000000000 -0500
41472 - notifier_call_chain(&panic_notifier_list, 0, NULL);
41473 + notifier_call_chain(&panic_notifier_list, 0, buf);
41475 if (panic_timeout > 0)
41477 diff -Naur -X ../exclude-files orig/MAINTAINERS um/MAINTAINERS
41478 --- orig/MAINTAINERS 2003-12-16 22:16:23.000000000 -0500
41479 +++ um/MAINTAINERS 2003-12-16 22:17:22.000000000 -0500
41480 @@ -2055,6 +2055,14 @@
41481 L: linux-usb-devel@lists.sourceforge.net
41482 W: http://usb.in.tum.de
41487 +M: jdike@karaya.com
41488 +L: user-mode-linux-devel@lists.sourceforge.net
41489 +L: user-mode-linux-user@lists.sourceforge.net
41490 +W: http://user-mode-linux.sourceforge.net
41493 USB "USBNET" DRIVER
41495 diff -Naur -X ../exclude-files orig/Makefile um/Makefile
41496 --- orig/Makefile 2004-02-14 06:26:12.000000000 -0500
41497 +++ um/Makefile 2004-02-14 06:26:19.000000000 -0500
41500 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
41502 -ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
41503 +# SUBARCH tells the usermode build what the underlying arch is. That is set
41504 +# first, and if a usermode build is happening, the "ARCH=um" on the command
41505 +# line overrides the setting of ARCH below. If a native build is happening,
41506 +# then ARCH is assigned, getting whatever value it gets normally, and
41507 +# SUBARCH is subsequently ignored.
41509 +SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
41510 +ARCH := $(SUBARCH)
41512 KERNELPATH=kernel-$(shell echo $(KERNELRELEASE) | sed -e "s/-//g")
41514 CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
41515 diff -Naur -X ../exclude-files orig/mm/Makefile um/mm/Makefile
41516 --- orig/mm/Makefile 2002-08-21 11:47:43.000000000 -0400
41517 +++ um/mm/Makefile 2003-10-21 03:26:08.000000000 -0400
41521 obj-$(CONFIG_HIGHMEM) += highmem.o
41522 +obj-$(CONFIG_PROC_MM) += proc_mm.o
41524 include $(TOPDIR)/Rules.make
41525 diff -Naur -X ../exclude-files orig/mm/mmap.c um/mm/mmap.c
41526 --- orig/mm/mmap.c 2003-12-16 22:16:36.000000000 -0500
41527 +++ um/mm/mmap.c 2003-12-16 22:17:32.000000000 -0500
41528 @@ -390,10 +390,11 @@
41532 -unsigned long do_mmap_pgoff(struct file * file, unsigned long addr, unsigned long len,
41533 - unsigned long prot, unsigned long flags, unsigned long pgoff)
41534 +unsigned long do_mmap_pgoff(struct mm_struct *mm, struct file * file,
41535 + unsigned long addr, unsigned long len,
41536 + unsigned long prot, unsigned long flags,
41537 + unsigned long pgoff)
41539 - struct mm_struct * mm = current->mm;
41540 struct vm_area_struct * vma, * prev;
41541 unsigned int vm_flags;
41542 int correct_wcount = 0;
41543 @@ -994,6 +995,11 @@
41544 remove_shared_vm_struct(mpnt);
41547 + if((mpnt->vm_file != NULL) && (mpnt->vm_file->f_op != NULL) &&
41548 + (mpnt->vm_file->f_op->munmap != NULL))
41549 + mpnt->vm_file->f_op->munmap(mpnt->vm_file, mpnt, st,
41552 zap_page_range(mm, st, size);
41555 diff -Naur -X ../exclude-files orig/mm/mprotect.c um/mm/mprotect.c
41556 --- orig/mm/mprotect.c 2003-12-16 22:16:36.000000000 -0500
41557 +++ um/mm/mprotect.c 2003-12-16 22:17:32.000000000 -0500
41558 @@ -264,7 +264,8 @@
41562 -asmlinkage long sys_mprotect(unsigned long start, size_t len, unsigned long prot)
41563 +long do_mprotect(struct mm_struct *mm, unsigned long start, size_t len,
41564 + unsigned long prot)
41566 unsigned long nstart, end, tmp;
41567 struct vm_area_struct * vma, * next, * prev;
41568 @@ -281,9 +282,9 @@
41572 - down_write(¤t->mm->mmap_sem);
41573 + down_write(&mm->mmap_sem);
41575 - vma = find_vma_prev(current->mm, start, &prev);
41576 + vma = find_vma_prev(mm, start, &prev);
41578 if (!vma || vma->vm_start > start)
41580 @@ -332,6 +333,11 @@
41581 prev->vm_mm->map_count--;
41584 - up_write(¤t->mm->mmap_sem);
41585 + up_write(&mm->mmap_sem);
41589 +asmlinkage long sys_mprotect(unsigned long start, size_t len, unsigned long prot)
41591 + return(do_mprotect(current->mm, start, len, prot));
41593 diff -Naur -X ../exclude-files orig/mm/page_alloc.c um/mm/page_alloc.c
41594 --- orig/mm/page_alloc.c 2003-12-16 22:16:36.000000000 -0500
41595 +++ um/mm/page_alloc.c 2003-12-16 22:17:32.000000000 -0500
41600 + arch_free_page(page, order);
41602 * Yes, think what happens when other parts of the kernel take
41603 * a reference to a page in order to pin it for io. -ben
41604 diff -Naur -X ../exclude-files orig/mm/proc_mm.c um/mm/proc_mm.c
41605 --- orig/mm/proc_mm.c 1969-12-31 19:00:00.000000000 -0500
41606 +++ um/mm/proc_mm.c 2003-10-21 03:26:08.000000000 -0400
41609 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
41610 + * Licensed under the GPL
41613 +#include "linux/init.h"
41614 +#include "linux/proc_fs.h"
41615 +#include "linux/proc_mm.h"
41616 +#include "linux/file.h"
41617 +#include "asm/uaccess.h"
41618 +#include "asm/mmu_context.h"
41620 +static struct file_operations proc_mm_fops;
41622 +struct mm_struct *proc_mm_get_mm(int fd)
41624 + struct mm_struct *ret = ERR_PTR(-EBADF);
41625 + struct file *file;
41631 + ret = ERR_PTR(-EINVAL);
41632 + if(file->f_op != &proc_mm_fops)
41635 + ret = file->private_data;
41642 +extern long do_mmap2(struct mm_struct *mm, unsigned long addr,
41643 + unsigned long len, unsigned long prot,
41644 + unsigned long flags, unsigned long fd,
41645 + unsigned long pgoff);
41647 +static ssize_t write_proc_mm(struct file *file, const char *buffer,
41648 + size_t count, loff_t *ppos)
41650 + struct mm_struct *mm = file->private_data;
41651 + struct proc_mm_op req;
41654 + if(count > sizeof(req))
41657 + n = copy_from_user(&req, buffer, count);
41664 + struct mm_mmap *map = &req.u.mmap;
41666 + ret = do_mmap2(mm, map->addr, map->len, map->prot,
41667 + map->flags, map->fd, map->offset >> PAGE_SHIFT);
41668 + if((ret & ~PAGE_MASK) == 0)
41673 + case MM_MUNMAP: {
41674 + struct mm_munmap *unmap = &req.u.munmap;
41676 + down_write(&mm->mmap_sem);
41677 + ret = do_munmap(mm, unmap->addr, unmap->len);
41678 + up_write(&mm->mmap_sem);
41684 + case MM_MPROTECT: {
41685 + struct mm_mprotect *protect = &req.u.mprotect;
41687 + ret = do_mprotect(mm, protect->addr, protect->len,
41694 + case MM_COPY_SEGMENTS: {
41695 + struct mm_struct *from = proc_mm_get_mm(req.u.copy_segments);
41697 + if(IS_ERR(from)){
41698 + ret = PTR_ERR(from);
41702 + mm_copy_segments(from, mm);
41713 +static int open_proc_mm(struct inode *inode, struct file *file)
41715 + struct mm_struct *mm = mm_alloc();
41722 + ret = init_new_context(current, mm);
41726 + spin_lock(&mmlist_lock);
41727 + list_add(&mm->mmlist, ¤t->mm->mmlist);
41729 + spin_unlock(&mmlist_lock);
41731 + file->private_data = mm;
41741 +static int release_proc_mm(struct inode *inode, struct file *file)
41743 + struct mm_struct *mm = file->private_data;
41749 +static struct file_operations proc_mm_fops = {
41750 + .open = open_proc_mm,
41751 + .release = release_proc_mm,
41752 + .write = write_proc_mm,
41755 +static int make_proc_mm(void)
41757 + struct proc_dir_entry *ent;
41759 + ent = create_proc_entry("mm", 0222, &proc_root);
41761 + printk("make_proc_mm : Failed to register /proc/mm\n");
41764 + ent->proc_fops = &proc_mm_fops;
41769 +__initcall(make_proc_mm);
41772 + * Overrides for Emacs so that we follow Linus's tabbing style.
41773 + * Emacs will notice this stuff at the end of the file and automatically
41774 + * adjust the settings for this buffer only. This must remain at the end
41776 + * ---------------------------------------------------------------------------
41777 + * Local variables:
41778 + * c-file-style: "linux"
41781 diff -Naur -X ../exclude-files orig/mm/shmem.c um/mm/shmem.c
41782 --- orig/mm/shmem.c 2003-12-16 22:16:36.000000000 -0500
41783 +++ um/mm/shmem.c 2003-12-16 22:17:32.000000000 -0500
41784 @@ -128,16 +128,17 @@
41788 -static swp_entry_t *shmem_swp_entry(struct shmem_inode_info *info, unsigned long index, unsigned long *page)
41789 +static void *shmem_block(unsigned long index, unsigned long *page,
41790 + unsigned long *direct, void ***indirect)
41792 unsigned long offset;
41795 if (index < SHMEM_NR_DIRECT)
41796 - return info->i_direct+index;
41797 - if (!info->i_indirect) {
41798 + return direct+index;
41799 + if (!*indirect) {
41801 - info->i_indirect = (void **) *page;
41802 + *indirect = (void **) *page;
41805 return NULL; /* need another page */
41806 @@ -146,7 +147,7 @@
41807 index -= SHMEM_NR_DIRECT;
41808 offset = index % ENTRIES_PER_PAGE;
41809 index /= ENTRIES_PER_PAGE;
41810 - dir = info->i_indirect;
41813 if (index >= ENTRIES_PER_PAGE/2) {
41814 index -= ENTRIES_PER_PAGE/2;
41815 @@ -169,7 +170,21 @@
41816 *dir = (void *) *page;
41819 - return (swp_entry_t *) *dir + offset;
41820 + return (unsigned long **) *dir + offset;
41823 +static swp_entry_t *shmem_swp_entry(struct shmem_inode_info *info, unsigned long index, unsigned long *page)
41825 + return((swp_entry_t *) shmem_block(index, page,
41826 + (unsigned long *) info->i_direct,
41827 + &info->i_indirect));
41830 +static unsigned long *shmem_map_count(struct shmem_inode_info *info,
41831 + unsigned long index, unsigned long *page)
41833 + return((unsigned long *) shmem_block(index, page, info->map_direct,
41834 + &info->map_indirect));
41838 @@ -838,6 +853,7 @@
41839 ops = &shmem_vm_ops;
41840 if (!S_ISREG(inode->i_mode))
41843 UPDATE_ATIME(inode);
41846 @@ -1723,4 +1739,125 @@
41850 +static int adjust_map_counts(struct shmem_inode_info *info,
41851 + unsigned long offset, unsigned long len,
41854 + unsigned long idx, i, *count, page = 0;
41856 + spin_lock(&info->lock);
41857 + offset >>= PAGE_SHIFT;
41858 + len >>= PAGE_SHIFT;
41859 + for(i = 0; i < len; i++){
41860 + idx = (i + offset) >> (PAGE_CACHE_SHIFT - PAGE_SHIFT);
41862 + while((count = shmem_map_count(info, idx, &page)) == NULL){
41863 + spin_unlock(&info->lock);
41864 + page = get_zeroed_page(GFP_KERNEL);
41867 + spin_lock(&info->lock);
41873 + *count += adjust;
41875 + spin_unlock(&info->lock);
41879 EXPORT_SYMBOL(shmem_file_setup);
41881 +struct file_operations anon_file_operations;
41883 +static int anon_mmap(struct file *file, struct vm_area_struct *vma)
41885 + struct file *new;
41886 + struct inode *inode;
41887 + loff_t size = vma->vm_end - vma->vm_start;
41890 + if(file->private_data == NULL){
41891 + new = shmem_file_setup("dev/anon", size);
41893 + return(PTR_ERR(new));
41895 + new->f_op = &anon_file_operations;
41896 + file->private_data = new;
41899 + if (vma->vm_file)
41900 + fput(vma->vm_file);
41901 + vma->vm_file = file->private_data;
41902 + get_file(vma->vm_file);
41904 + inode = vma->vm_file->f_dentry->d_inode;
41905 + err = adjust_map_counts(SHMEM_I(inode), vma->vm_pgoff, size, 1);
41909 + vma->vm_ops = &shmem_vm_ops;
41913 +static void anon_munmap(struct file *file, struct vm_area_struct *vma,
41914 + unsigned long start, unsigned long len)
41916 + struct inode *inode = file->f_dentry->d_inode;
41917 + struct shmem_inode_info *info = SHMEM_I(inode);
41921 + struct page *page;
41922 + unsigned long addr, idx, *count;
41924 + for(addr = start; addr < start + len; addr += PAGE_SIZE){
41925 + idx = (addr - vma->vm_start + vma->vm_pgoff);
41926 + idx >>= PAGE_CACHE_SHIFT;
41928 + count = shmem_map_count(info, idx, NULL);
41929 + BUG_ON(count == NULL);
41935 + pgd = pgd_offset(vma->vm_mm, addr);
41936 + if(pgd_none(*pgd))
41939 + pmd = pmd_offset(pgd, addr);
41940 + if(pmd_none(*pmd))
41943 + pte = pte_offset(pmd, addr);
41944 + if(!pte_present(*pte)) /* XXX need to handle swapped pages */
41947 + *pte = pte_mkclean(*pte);
41949 + page = pte_page(*pte);
41951 + lru_cache_del(page);
41952 + ClearPageDirty(page);
41953 + remove_inode_page(page);
41954 + UnlockPage(page);
41956 + page_cache_release(page);
41960 +int anon_release(struct inode *inode, struct file *file)
41962 + if(file->private_data != NULL)
41963 + fput(file->private_data);
41967 +struct file_operations anon_file_operations = {
41968 + .mmap = anon_mmap,
41969 + .munmap = anon_munmap,
41970 + .release = anon_release,