aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-07-21 09:05:58 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-21 09:05:58 -0400
commit1c29dd9a9e2f83ffb02e50bb3619c3b9db8fd526 (patch)
treeb5691dd5aa48ac32fdbaef44afcbcc92f01592d3 /arch
parent32172561889868c0ea422ea8570f0413963a815f (diff)
parent14b395e35d1afdd8019d11b92e28041fad591b71 (diff)
Merge branch 'linus' into x86/paravirt-spinlocks
Diffstat (limited to 'arch')
-rw-r--r--arch/blackfin/mach-bf527/boards/ezkit.c7
-rw-r--r--arch/blackfin/mach-bf533/boards/H8606.c7
-rw-r--r--arch/blackfin/mach-bf537/boards/generic_board.c7
-rw-r--r--arch/cris/arch-v10/boot/Makefile1
-rw-r--r--arch/cris/arch-v10/boot/compressed/Makefile14
-rw-r--r--arch/cris/arch-v10/boot/compressed/decompress.ld3
-rw-r--r--arch/cris/arch-v10/boot/compressed/head.S98
-rw-r--r--arch/cris/arch-v10/boot/compressed/misc.c144
-rw-r--r--arch/cris/arch-v10/boot/rescue/Makefile9
-rw-r--r--arch/cris/arch-v10/drivers/pcf8563.c2
-rw-r--r--arch/cris/arch-v10/kernel/debugport.c20
-rw-r--r--arch/cris/arch-v32/boot/Makefile1
-rw-r--r--arch/cris/arch-v32/boot/compressed/Makefile6
-rw-r--r--arch/cris/arch-v32/boot/rescue/Makefile3
-rw-r--r--arch/cris/arch-v32/drivers/pcf8563.c2
-rw-r--r--arch/ia64/hp/sim/simserial.c46
-rw-r--r--arch/ia64/kvm/Makefile3
-rw-r--r--arch/ia64/kvm/kvm-ia64.c20
-rw-r--r--arch/m68k/Kconfig36
-rw-r--r--arch/m68k/Makefile2
-rw-r--r--arch/m68k/amiga/config.c22
-rw-r--r--arch/m68k/atari/debug.c37
-rw-r--r--arch/m68k/fpsp040/Makefile1
-rw-r--r--arch/m68k/ifpsp060/Makefile1
-rw-r--r--arch/m68k/kernel/Makefile2
-rw-r--r--arch/m68k/kernel/setup.c9
-rw-r--r--arch/m68k/kernel/vmlinux-std.lds3
-rw-r--r--arch/m68k/kernel/vmlinux-sun3.lds7
-rw-r--r--arch/m68k/lib/Makefile2
-rw-r--r--arch/m68k/mac/Makefile2
-rw-r--r--arch/m68k/mac/baboon.c26
-rw-r--r--arch/m68k/mac/bootparse.c122
-rw-r--r--arch/m68k/mac/config.c11
-rw-r--r--arch/m68k/mac/debug.c41
-rw-r--r--arch/m68k/mac/oss.c8
-rw-r--r--arch/m68k/mac/psc.c4
-rw-r--r--arch/m68k/mac/via.c2
-rw-r--r--arch/m68k/math-emu/Makefile2
-rw-r--r--arch/m68k/mm/motorola.c1
-rw-r--r--arch/m68k/mm/sun3mmu.c1
-rw-r--r--arch/m68k/q40/config.c26
-rw-r--r--arch/m68k/sun3/Makefile2
-rw-r--r--arch/m68k/sun3/config.c7
-rw-r--r--arch/m68k/sun3/dvma.c2
-rw-r--r--arch/m68k/sun3/idprom.c4
-rw-r--r--arch/m68k/sun3/mmu_emu.c2
-rw-r--r--arch/m68k/sun3/prom/Makefile1
-rw-r--r--arch/m68k/sun3/prom/console.c6
-rw-r--r--arch/m68k/sun3/prom/init.c11
-rw-r--r--arch/m68k/sun3/prom/misc.c2
-rw-r--r--arch/m68k/sun3/prom/printf.c7
-rw-r--r--arch/m68k/sun3/sbus.c27
-rw-r--r--arch/m68k/sun3/sun3dvma.c2
-rw-r--r--arch/m68k/sun3/sun3ints.c2
-rw-r--r--arch/mips/Kconfig22
-rw-r--r--arch/mips/Makefile7
-rw-r--r--arch/mips/cobalt/setup.c4
-rw-r--r--arch/mips/configs/rb532_defconfig1314
-rw-r--r--arch/mips/kernel/linux32.c17
-rw-r--r--arch/mips/kernel/scall32-o32.S2
-rw-r--r--arch/mips/kernel/scall64-64.S2
-rw-r--r--arch/mips/kernel/scall64-n32.S2
-rw-r--r--arch/mips/kernel/scall64-o32.S2
-rw-r--r--arch/mips/kernel/syscall.c9
-rw-r--r--arch/mips/math-emu/kernel_linkage.c1
-rw-r--r--arch/mips/pci/Makefile1
-rw-r--r--arch/mips/pci/fixup-rc32434.c69
-rw-r--r--arch/mips/pci/ops-rc32434.c207
-rw-r--r--arch/mips/pci/pci-rc32434.c221
-rw-r--r--arch/mips/pci/pci.c2
-rw-r--r--arch/mips/rb532/Makefile7
-rw-r--r--arch/mips/rb532/devices.c331
-rw-r--r--arch/mips/rb532/gpio.c220
-rw-r--r--arch/mips/rb532/irq.c209
-rw-r--r--arch/mips/rb532/prom.c158
-rw-r--r--arch/mips/rb532/serial.c53
-rw-r--r--arch/mips/rb532/setup.c79
-rw-r--r--arch/mips/rb532/time.c67
-rw-r--r--arch/mips/sgi-ip22/ip22-platform.c3
-rw-r--r--arch/mips/sgi-ip22/ip28-berr.c4
-rw-r--r--arch/mips/sgi-ip32/ip32-platform.c13
-rw-r--r--arch/mips/txx9/Kconfig2
-rw-r--r--arch/mips/txx9/generic/Makefile4
-rw-r--r--arch/mips/txx9/generic/irq_tx4927.c2
-rw-r--r--arch/mips/txx9/generic/irq_tx4938.c2
-rw-r--r--arch/mips/txx9/generic/mem_tx4927.c94
-rw-r--r--arch/mips/txx9/generic/mem_tx4938.c124
-rw-r--r--arch/mips/txx9/generic/setup.c38
-rw-r--r--arch/mips/txx9/generic/setup_tx4927.c194
-rw-r--r--arch/mips/txx9/generic/setup_tx4938.c259
-rw-r--r--arch/mips/txx9/jmr3927/setup.c8
-rw-r--r--arch/mips/txx9/rbtx4927/irq.c12
-rw-r--r--arch/mips/txx9/rbtx4927/prom.c6
-rw-r--r--arch/mips/txx9/rbtx4927/setup.c89
-rw-r--r--arch/mips/txx9/rbtx4938/prom.c6
-rw-r--r--arch/mips/txx9/rbtx4938/setup.c231
-rw-r--r--arch/mn10300/kernel/mn10300-serial.c2
-rw-r--r--arch/powerpc/kvm/Makefile2
-rw-r--r--arch/powerpc/kvm/powerpc.c11
-rw-r--r--arch/s390/kvm/interrupt.c32
-rw-r--r--arch/s390/kvm/kvm-s390.c21
-rw-r--r--arch/s390/kvm/priv.c2
-rw-r--r--arch/s390/kvm/sigp.c20
-rw-r--r--arch/x86/kernel/kvmclock.c2
-rw-r--r--arch/x86/kvm/Makefile3
-rw-r--r--arch/x86/kvm/i8254.c24
-rw-r--r--arch/x86/kvm/i8259.c9
-rw-r--r--arch/x86/kvm/irq.h2
-rw-r--r--arch/x86/kvm/lapic.c14
-rw-r--r--arch/x86/kvm/lapic.h1
-rw-r--r--arch/x86/kvm/mmu.c62
-rw-r--r--arch/x86/kvm/mmu.h3
-rw-r--r--arch/x86/kvm/paging_tmpl.h28
-rw-r--r--arch/x86/kvm/svm.c131
-rw-r--r--arch/x86/kvm/vmx.c230
-rw-r--r--arch/x86/kvm/vmx.h12
-rw-r--r--arch/x86/kvm/x86.c299
-rw-r--r--arch/x86/kvm/x86_emulate.c257
118 files changed, 4554 insertions, 1546 deletions
diff --git a/arch/blackfin/mach-bf527/boards/ezkit.c b/arch/blackfin/mach-bf527/boards/ezkit.c
index 5958eecefcf1..689b69c98ee4 100644
--- a/arch/blackfin/mach-bf527/boards/ezkit.c
+++ b/arch/blackfin/mach-bf527/boards/ezkit.c
@@ -323,10 +323,15 @@ static struct platform_device smc91x_device = {
323static struct resource dm9000_resources[] = { 323static struct resource dm9000_resources[] = {
324 [0] = { 324 [0] = {
325 .start = 0x203FB800, 325 .start = 0x203FB800,
326 .end = 0x203FB800 + 8, 326 .end = 0x203FB800 + 1,
327 .flags = IORESOURCE_MEM, 327 .flags = IORESOURCE_MEM,
328 }, 328 },
329 [1] = { 329 [1] = {
330 .start = 0x203FB800 + 4,
331 .end = 0x203FB800 + 5,
332 .flags = IORESOURCE_MEM,
333 },
334 [2] = {
330 .start = IRQ_PF9, 335 .start = IRQ_PF9,
331 .end = IRQ_PF9, 336 .end = IRQ_PF9,
332 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE), 337 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
diff --git a/arch/blackfin/mach-bf533/boards/H8606.c b/arch/blackfin/mach-bf533/boards/H8606.c
index 7cc4864f6aaf..4103a97c1a70 100644
--- a/arch/blackfin/mach-bf533/boards/H8606.c
+++ b/arch/blackfin/mach-bf533/boards/H8606.c
@@ -65,10 +65,15 @@ static struct platform_device rtc_device = {
65static struct resource dm9000_resources[] = { 65static struct resource dm9000_resources[] = {
66 [0] = { 66 [0] = {
67 .start = 0x20300000, 67 .start = 0x20300000,
68 .end = 0x20300000 + 8, 68 .end = 0x20300000 + 1,
69 .flags = IORESOURCE_MEM, 69 .flags = IORESOURCE_MEM,
70 }, 70 },
71 [1] = { 71 [1] = {
72 .start = 0x20300000 + 4,
73 .end = 0x20300000 + 5,
74 .flags = IORESOURCE_MEM,
75 },
76 [2] = {
72 .start = IRQ_PF10, 77 .start = IRQ_PF10,
73 .end = IRQ_PF10, 78 .end = IRQ_PF10,
74 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE), 79 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
diff --git a/arch/blackfin/mach-bf537/boards/generic_board.c b/arch/blackfin/mach-bf537/boards/generic_board.c
index 7d250828dad8..01b63e2ec18f 100644
--- a/arch/blackfin/mach-bf537/boards/generic_board.c
+++ b/arch/blackfin/mach-bf537/boards/generic_board.c
@@ -166,10 +166,15 @@ static struct platform_device smc91x_device = {
166static struct resource dm9000_resources[] = { 166static struct resource dm9000_resources[] = {
167 [0] = { 167 [0] = {
168 .start = 0x203FB800, 168 .start = 0x203FB800,
169 .end = 0x203FB800 + 8, 169 .end = 0x203FB800 + 1,
170 .flags = IORESOURCE_MEM, 170 .flags = IORESOURCE_MEM,
171 }, 171 },
172 [1] = { 172 [1] = {
173 .start = 0x203FB800 + 4,
174 .end = 0x203FB800 + 5,
175 .flags = IORESOURCE_MEM,
176 },
177 [2] = {
173 .start = IRQ_PF9, 178 .start = IRQ_PF9,
174 .end = IRQ_PF9, 179 .end = IRQ_PF9,
175 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE), 180 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
diff --git a/arch/cris/arch-v10/boot/Makefile b/arch/cris/arch-v10/boot/Makefile
index 20c83a53caf3..217203014433 100644
--- a/arch/cris/arch-v10/boot/Makefile
+++ b/arch/cris/arch-v10/boot/Makefile
@@ -2,7 +2,6 @@
2# arch/cris/arch-v10/boot/Makefile 2# arch/cris/arch-v10/boot/Makefile
3# 3#
4 4
5OBJCOPY = objcopy-cris
6OBJCOPYFLAGS = -O binary --remove-section=.bss 5OBJCOPYFLAGS = -O binary --remove-section=.bss
7 6
8subdir- := compressed rescue 7subdir- := compressed rescue
diff --git a/arch/cris/arch-v10/boot/compressed/Makefile b/arch/cris/arch-v10/boot/compressed/Makefile
index 4a031cb27eb9..08d943ce4be7 100644
--- a/arch/cris/arch-v10/boot/compressed/Makefile
+++ b/arch/cris/arch-v10/boot/compressed/Makefile
@@ -2,12 +2,10 @@
2# arch/cris/arch-v10/boot/compressed/Makefile 2# arch/cris/arch-v10/boot/compressed/Makefile
3# 3#
4 4
5CC = gcc-cris -melf $(LINUXINCLUDE) 5asflags-y += $(LINUXINCLUDE)
6ccflags-y += -O2 6ccflags-y += -O2 $(LINUXINCLUDE)
7LD = ld-cris 7ldflags-y += -T $(srctree)/$(obj)/decompress.ld
8ldflags-y += -T $(obj)/decompress.ld
9OBJECTS = $(obj)/head.o $(obj)/misc.o 8OBJECTS = $(obj)/head.o $(obj)/misc.o
10OBJCOPY = objcopy-cris
11OBJCOPYFLAGS = -O binary --remove-section=.bss 9OBJCOPYFLAGS = -O binary --remove-section=.bss
12 10
13quiet_cmd_image = BUILD $@ 11quiet_cmd_image = BUILD $@
@@ -21,12 +19,6 @@ $(obj)/decompress.o: $(OBJECTS) FORCE
21$(obj)/decompress.bin: $(obj)/decompress.o FORCE 19$(obj)/decompress.bin: $(obj)/decompress.o FORCE
22 $(call if_changed,objcopy) 20 $(call if_changed,objcopy)
23 21
24$(obj)/head.o: $(obj)/head.S .config
25 @$(CC) -D__ASSEMBLY__ -traditional -c $< -o $@
26
27$(obj)/misc.o: $(obj)/misc.c .config
28 @$(CC) -D__KERNEL__ -c $< -o $@
29
30$(obj)/vmlinux: $(obj)/piggy.gz $(obj)/decompress.bin FORCE 22$(obj)/vmlinux: $(obj)/piggy.gz $(obj)/decompress.bin FORCE
31 $(call if_changed,image) 23 $(call if_changed,image)
32 24
diff --git a/arch/cris/arch-v10/boot/compressed/decompress.ld b/arch/cris/arch-v10/boot/compressed/decompress.ld
index 0b0a14fe6177..e80f4594d543 100644
--- a/arch/cris/arch-v10/boot/compressed/decompress.ld
+++ b/arch/cris/arch-v10/boot/compressed/decompress.ld
@@ -1,4 +1,5 @@
1OUTPUT_FORMAT(elf32-us-cris) 1/* OUTPUT_FORMAT(elf32-us-cris) */
2OUTPUT_FORMAT(elf32-cris)
2 3
3MEMORY 4MEMORY
4 { 5 {
diff --git a/arch/cris/arch-v10/boot/compressed/head.S b/arch/cris/arch-v10/boot/compressed/head.S
index 610bdb237553..981fbae84959 100644
--- a/arch/cris/arch-v10/boot/compressed/head.S
+++ b/arch/cris/arch-v10/boot/compressed/head.S
@@ -15,77 +15,77 @@
15#define COMMAND_LINE_MAGIC 0x87109563 15#define COMMAND_LINE_MAGIC 0x87109563
16 16
17 ;; Exported symbols 17 ;; Exported symbols
18
19 .globl _input_data
20 18
21 19 .globl input_data
20
21
22 .text 22 .text
23 23
24 nop 24 nop
25 di 25 di
26 26
27;; We need to initialze DRAM registers before we start using the DRAM 27;; We need to initialze DRAM registers before we start using the DRAM
28 28
29 cmp.d RAM_INIT_MAGIC, r8 ; Already initialized? 29 cmp.d RAM_INIT_MAGIC, $r8 ; Already initialized?
30 beq dram_init_finished 30 beq dram_init_finished
31 nop 31 nop
32 32
33#include "../../lib/dram_init.S" 33#include "../../lib/dram_init.S"
34 34
35dram_init_finished: 35dram_init_finished:
36 36
37 ;; Initiate the PA and PB ports 37 ;; Initiate the PA and PB ports
38 38
39 move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, r0 39 move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r0
40 move.b r0, [R_PORT_PA_DATA] 40 move.b $r0, [R_PORT_PA_DATA]
41 41
42 move.b CONFIG_ETRAX_DEF_R_PORT_PA_DIR, r0 42 move.b CONFIG_ETRAX_DEF_R_PORT_PA_DIR, $r0
43 move.b r0, [R_PORT_PA_DIR] 43 move.b $r0, [R_PORT_PA_DIR]
44 44
45 move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, r0 45 move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r0
46 move.b r0, [R_PORT_PB_DATA] 46 move.b $r0, [R_PORT_PB_DATA]
47 47
48 move.b CONFIG_ETRAX_DEF_R_PORT_PB_DIR, r0 48 move.b CONFIG_ETRAX_DEF_R_PORT_PB_DIR, $r0
49 move.b r0, [R_PORT_PB_DIR] 49 move.b $r0, [R_PORT_PB_DIR]
50 50
51 ;; Setup the stack to a suitably high address. 51 ;; Setup the stack to a suitably high address.
52 ;; We assume 8 MB is the minimum DRAM in an eLinux 52 ;; We assume 8 MB is the minimum DRAM in an eLinux
53 ;; product and put the sp at the top for now. 53 ;; product and put the sp at the top for now.
54 54
55 move.d 0x40800000, sp 55 move.d 0x40800000, $sp
56 56
57 ;; Figure out where the compressed piggyback image is 57 ;; Figure out where the compressed piggyback image is
58 ;; in the flash (since we wont try to copy it to DRAM 58 ;; in the flash (since we wont try to copy it to DRAM
59 ;; before unpacking). It is at _edata, but in flash. 59 ;; before unpacking). It is at _edata, but in flash.
60 ;; Use (_edata - basse) as offset to the current PC. 60 ;; Use (_edata - basse) as offset to the current PC.
61 61
62basse: move.d pc, r5 62basse: move.d $pc, $r5
63 and.d 0x7fffffff, r5 ; strip any non-cache bit 63 and.d 0x7fffffff, $r5 ; strip any non-cache bit
64 subq 2, r5 ; compensate for the move.d pc instr 64 subq 2, $r5 ; compensate for the move.d $pc instr
65 move.d r5, r0 ; save for later - flash address of 'basse' 65 move.d $r5, $r0 ; save for later - flash address of 'basse'
66 add.d _edata, r5 66 add.d _edata, $r5
67 sub.d basse, r5 ; r5 = flash address of '_edata' 67 sub.d basse, $r5 ; $r5 = flash address of '_edata'
68 68
69 ;; Copy text+data to DRAM 69 ;; Copy text+data to DRAM
70 70
71 move.d basse, r1 ; destination 71 move.d basse, $r1 ; destination
72 move.d _edata, r2 ; end destination 72 move.d _edata, $r2 ; end destination
731: move.w [r0+], r3 731: move.w [$r0+], $r3
74 move.w r3, [r1+] 74 move.w $r3, [$r1+]
75 cmp.d r2, r1 75 cmp.d $r2, $r1
76 bcs 1b 76 bcs 1b
77 nop 77 nop
78 78
79 move.d r5, [_input_data] ; for the decompressor 79 move.d $r5, [input_data] ; for the decompressor
80 80
81 81
82 ;; Clear the decompressors BSS (between _edata and _end) 82 ;; Clear the decompressors BSS (between _edata and _end)
83 83
84 moveq 0, r0 84 moveq 0, $r0
85 move.d _edata, r1 85 move.d _edata, $r1
86 move.d _end, r2 86 move.d _end, $r2
871: move.w r0, [r1+] 871: move.w $r0, [$r1+]
88 cmp.d r2, r1 88 cmp.d $r2, $r1
89 bcs 1b 89 bcs 1b
90 nop 90 nop
91 91
@@ -94,16 +94,16 @@ basse: move.d pc, r5
94 move.d $r10, [$r12] 94 move.d $r10, [$r12]
95 move.d _cmd_line_addr, $r12 95 move.d _cmd_line_addr, $r12
96 move.d $r11, [$r12] 96 move.d $r11, [$r12]
97
98 ;; Do the decompression and save compressed size in _inptr
99 97
100 jsr _decompress_kernel 98 ;; Do the decompression and save compressed size in inptr
101 99
102 ;; Put start address of root partition in r9 so the kernel can use it 100 jsr decompress_kernel
101
102 ;; Put start address of root partition in $r9 so the kernel can use it
103 ;; when mounting from flash 103 ;; when mounting from flash
104 104
105 move.d [_input_data], r9 ; flash address of compressed kernel 105 move.d [input_data], $r9 ; flash address of compressed kernel
106 add.d [_inptr], r9 ; size of compressed kernel 106 add.d [inptr], $r9 ; size of compressed kernel
107 107
108 ;; Restore command line magic and address. 108 ;; Restore command line magic and address.
109 move.d _cmd_line_magic, $r10 109 move.d _cmd_line_magic, $r10
@@ -112,12 +112,12 @@ basse: move.d pc, r5
112 move.d [$r11], $r11 112 move.d [$r11], $r11
113 113
114 ;; Enter the decompressed kernel 114 ;; Enter the decompressed kernel
115 move.d RAM_INIT_MAGIC, r8 ; Tell kernel that DRAM is initialized 115 move.d RAM_INIT_MAGIC, $r8 ; Tell kernel that DRAM is initialized
116 jump 0x40004000 ; kernel is linked to this address 116 jump 0x40004000 ; kernel is linked to this address
117 117
118 .data 118 .data
119 119
120_input_data: 120input_data:
121 .dword 0 ; used by the decompressor 121 .dword 0 ; used by the decompressor
122_cmd_line_magic: 122_cmd_line_magic:
123 .dword 0 123 .dword 0
diff --git a/arch/cris/arch-v10/boot/compressed/misc.c b/arch/cris/arch-v10/boot/compressed/misc.c
index 9a43ab19391e..18e13bce1400 100644
--- a/arch/cris/arch-v10/boot/compressed/misc.c
+++ b/arch/cris/arch-v10/boot/compressed/misc.c
@@ -29,12 +29,10 @@
29#define OF(args) args 29#define OF(args) args
30#define STATIC static 30#define STATIC static
31 31
32void* memset(void* s, int c, size_t n); 32void *memset(void *s, int c, size_t n);
33void* memcpy(void* __dest, __const void* __src, 33void *memcpy(void *__dest, __const void *__src, size_t __n);
34 size_t __n);
35
36#define memzero(s, n) memset ((s), 0, (n))
37 34
35#define memzero(s, n) memset((s), 0, (n))
38 36
39typedef unsigned char uch; 37typedef unsigned char uch;
40typedef unsigned short ush; 38typedef unsigned short ush;
@@ -62,57 +60,69 @@ static unsigned outcnt = 0; /* bytes in output buffer */
62#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */ 60#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
63#define RESERVED 0xC0 /* bit 6,7: reserved */ 61#define RESERVED 0xC0 /* bit 6,7: reserved */
64 62
65#define get_byte() inbuf[inptr++] 63#define get_byte() (inbuf[inptr++])
66 64
67/* Diagnostic functions */ 65/* Diagnostic functions */
68#ifdef DEBUG 66#ifdef DEBUG
69# define Assert(cond,msg) {if(!(cond)) error(msg);} 67# define Assert(cond, msg) do { \
68 if (!(cond)) \
69 error(msg); \
70 } while (0)
70# define Trace(x) fprintf x 71# define Trace(x) fprintf x
71# define Tracev(x) {if (verbose) fprintf x ;} 72# define Tracev(x) do { \
72# define Tracevv(x) {if (verbose>1) fprintf x ;} 73 if (verbose) \
73# define Tracec(c,x) {if (verbose && (c)) fprintf x ;} 74 fprintf x; \
74# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;} 75 } while (0)
76# define Tracevv(x) do { \
77 if (verbose > 1) \
78 fprintf x; \
79 } while (0)
80# define Tracec(c, x) do { \
81 if (verbose && (c)) \
82 fprintf x; \
83 } while (0)
84# define Tracecv(c, x) do { \
85 if (verbose > 1 && (c)) \
86 fprintf x; \
87 } while (0)
75#else 88#else
76# define Assert(cond,msg) 89# define Assert(cond, msg)
77# define Trace(x) 90# define Trace(x)
78# define Tracev(x) 91# define Tracev(x)
79# define Tracevv(x) 92# define Tracevv(x)
80# define Tracec(c,x) 93# define Tracec(c, x)
81# define Tracecv(c,x) 94# define Tracecv(c, x)
82#endif 95#endif
83 96
84static int fill_inbuf(void);
85static void flush_window(void); 97static void flush_window(void);
86static void error(char *m); 98static void error(char *m);
87static void gzip_mark(void **);
88static void gzip_release(void **);
89 99
90extern char *input_data; /* lives in head.S */ 100extern char *input_data; /* lives in head.S */
91 101
92static long bytes_out = 0; 102static long bytes_out = 0;
93static uch *output_data; 103static uch *output_data;
94static unsigned long output_ptr = 0; 104static unsigned long output_ptr = 0;
95 105
96static void *malloc(int size); 106static void *malloc(int size);
97static void free(void *where); 107static void free(void *where);
98static void error(char *m);
99static void gzip_mark(void **); 108static void gzip_mark(void **);
100static void gzip_release(void **); 109static void gzip_release(void **);
101 110
102static void puts(const char *); 111static void puts(const char *);
103 112
104/* the "heap" is put directly after the BSS ends, at end */ 113/* the "heap" is put directly after the BSS ends, at end */
105 114
106extern int end; 115extern int _end;
107static long free_mem_ptr = (long)&end; 116static long free_mem_ptr = (long)&_end;
108 117
109#include "../../../../../lib/inflate.c" 118#include "../../../../../lib/inflate.c"
110 119
111static void *malloc(int size) 120static void *malloc(int size)
112{ 121{
113 void *p; 122 void *p;
114 123
115 if (size <0) error("Malloc error"); 124 if (size < 0)
125 error("Malloc error");
116 126
117 free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */ 127 free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */
118 128
@@ -142,44 +152,47 @@ static void
142puts(const char *s) 152puts(const char *s)
143{ 153{
144#ifndef CONFIG_ETRAX_DEBUG_PORT_NULL 154#ifndef CONFIG_ETRAX_DEBUG_PORT_NULL
145 while(*s) { 155 while (*s) {
146#ifdef CONFIG_ETRAX_DEBUG_PORT0 156#ifdef CONFIG_ETRAX_DEBUG_PORT0
147 while(!(*R_SERIAL0_STATUS & (1 << 5))) ; 157 while (!(*R_SERIAL0_STATUS & (1 << 5))) ;
148 *R_SERIAL0_TR_DATA = *s++; 158 *R_SERIAL0_TR_DATA = *s++;
149#endif 159#endif
150#ifdef CONFIG_ETRAX_DEBUG_PORT1 160#ifdef CONFIG_ETRAX_DEBUG_PORT1
151 while(!(*R_SERIAL1_STATUS & (1 << 5))) ; 161 while (!(*R_SERIAL1_STATUS & (1 << 5))) ;
152 *R_SERIAL1_TR_DATA = *s++; 162 *R_SERIAL1_TR_DATA = *s++;
153#endif 163#endif
154#ifdef CONFIG_ETRAX_DEBUG_PORT2 164#ifdef CONFIG_ETRAX_DEBUG_PORT2
155 while(!(*R_SERIAL2_STATUS & (1 << 5))) ; 165 while (!(*R_SERIAL2_STATUS & (1 << 5))) ;
156 *R_SERIAL2_TR_DATA = *s++; 166 *R_SERIAL2_TR_DATA = *s++;
157#endif 167#endif
158#ifdef CONFIG_ETRAX_DEBUG_PORT3 168#ifdef CONFIG_ETRAX_DEBUG_PORT3
159 while(!(*R_SERIAL3_STATUS & (1 << 5))) ; 169 while (!(*R_SERIAL3_STATUS & (1 << 5))) ;
160 *R_SERIAL3_TR_DATA = *s++; 170 *R_SERIAL3_TR_DATA = *s++;
161#endif 171#endif
162 } 172 }
163#endif 173#endif
164} 174}
165 175
166void* 176void *memset(void *s, int c, size_t n)
167memset(void* s, int c, size_t n)
168{ 177{
169 int i; 178 int i;
170 char *ss = (char*)s; 179 char *ss = (char *)s;
180
181 for (i = 0; i < n; i++)
182 ss[i] = c;
171 183
172 for (i=0;i<n;i++) ss[i] = c; 184 return s;
173} 185}
174 186
175void* 187void *memcpy(void *__dest, __const void *__src, size_t __n)
176memcpy(void* __dest, __const void* __src,
177 size_t __n)
178{ 188{
179 int i; 189 int i;
180 char *d = (char *)__dest, *s = (char *)__src; 190 char *d = (char *)__dest, *s = (char *)__src;
181 191
182 for (i=0;i<__n;i++) d[i] = s[i]; 192 for (i = 0; i < __n; i++)
193 d[i] = s[i];
194
195 return __dest;
183} 196}
184 197
185/* =========================================================================== 198/* ===========================================================================
@@ -187,46 +200,44 @@ memcpy(void* __dest, __const void* __src,
187 * (Used for the decompressed data only.) 200 * (Used for the decompressed data only.)
188 */ 201 */
189 202
190static void 203static void flush_window(void)
191flush_window()
192{ 204{
193 ulg c = crc; /* temporary variable */ 205 ulg c = crc; /* temporary variable */
194 unsigned n; 206 unsigned n;
195 uch *in, *out, ch; 207 uch *in, *out, ch;
196 208
197 in = window; 209 in = window;
198 out = &output_data[output_ptr]; 210 out = &output_data[output_ptr];
199 for (n = 0; n < outcnt; n++) { 211 for (n = 0; n < outcnt; n++) {
200 ch = *out++ = *in++; 212 ch = *out = *in;
201 c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8); 213 out++;
202 } 214 in++;
203 crc = c; 215 c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
204 bytes_out += (ulg)outcnt; 216 }
205 output_ptr += (ulg)outcnt; 217 crc = c;
206 outcnt = 0; 218 bytes_out += (ulg)outcnt;
219 output_ptr += (ulg)outcnt;
220 outcnt = 0;
207} 221}
208 222
209static void 223static void error(char *x)
210error(char *x)
211{ 224{
212 puts("\n\n"); 225 puts("\n\n");
213 puts(x); 226 puts(x);
214 puts("\n\n -- System halted\n"); 227 puts("\n\n -- System halted\n");
215 228
216 while(1); /* Halt */ 229 while (1); /* Halt */
217} 230}
218 231
219void 232void setup_normal_output_buffer(void)
220setup_normal_output_buffer()
221{ 233{
222 output_data = (char *)KERNEL_LOAD_ADR; 234 output_data = (char *)KERNEL_LOAD_ADR;
223} 235}
224 236
225void 237void decompress_kernel(void)
226decompress_kernel()
227{ 238{
228 char revision; 239 char revision;
229 240
230 /* input_data is set in head.S */ 241 /* input_data is set in head.S */
231 inbuf = input_data; 242 inbuf = input_data;
232 243
@@ -257,11 +268,10 @@ decompress_kernel()
257 268
258 makecrc(); 269 makecrc();
259 270
260 __asm__ volatile ("move vr,%0" : "=rm" (revision)); 271 __asm__ volatile ("move $vr,%0" : "=rm" (revision));
261 if (revision < 10) 272 if (revision < 10) {
262 {
263 puts("You need an ETRAX 100LX to run linux 2.6\n"); 273 puts("You need an ETRAX 100LX to run linux 2.6\n");
264 while(1); 274 while (1);
265 } 275 }
266 276
267 puts("Uncompressing Linux...\n"); 277 puts("Uncompressing Linux...\n");
diff --git a/arch/cris/arch-v10/boot/rescue/Makefile b/arch/cris/arch-v10/boot/rescue/Makefile
index 2e5045b9e19c..07688da92708 100644
--- a/arch/cris/arch-v10/boot/rescue/Makefile
+++ b/arch/cris/arch-v10/boot/rescue/Makefile
@@ -2,12 +2,9 @@
2# Makefile for rescue (bootstrap) code 2# Makefile for rescue (bootstrap) code
3# 3#
4 4
5CC = gcc-cris -mlinux $(LINUXINCLUDE) 5ccflags-y += -O2 $(LINUXINCLUDE)
6ccflags-y += -O2 6asflags-y += $(LINUXINCLUDE)
7asflags-y += -traditional 7ldflags-y += -T $(srctree)/$(obj)/rescue.ld
8LD = gcc-cris -mlinux -nostdlib
9ldflags-y += -T $(obj)/rescue.ld
10OBJCOPY = objcopy-cris
11OBJCOPYFLAGS = -O binary --remove-section=.bss 8OBJCOPYFLAGS = -O binary --remove-section=.bss
12obj-$(CONFIG_ETRAX_AXISFLASHMAP) = head.o 9obj-$(CONFIG_ETRAX_AXISFLASHMAP) = head.o
13OBJECT := $(obj)/head.o 10OBJECT := $(obj)/head.o
diff --git a/arch/cris/arch-v10/drivers/pcf8563.c b/arch/cris/arch-v10/drivers/pcf8563.c
index 52103d16dc6c..8769dc914073 100644
--- a/arch/cris/arch-v10/drivers/pcf8563.c
+++ b/arch/cris/arch-v10/drivers/pcf8563.c
@@ -233,7 +233,7 @@ int pcf8563_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
233 233
234 if (copy_to_user((struct rtc_time *) arg, &tm, 234 if (copy_to_user((struct rtc_time *) arg, &tm,
235 sizeof tm)) { 235 sizeof tm)) {
236 spin_unlock(&rtc_lock); 236 mutex_unlock(&rtc_lock);
237 return -EFAULT; 237 return -EFAULT;
238 } 238 }
239 239
diff --git a/arch/cris/arch-v10/kernel/debugport.c b/arch/cris/arch-v10/kernel/debugport.c
index 04d5eee2c90c..3dc6e91ba39e 100644
--- a/arch/cris/arch-v10/kernel/debugport.c
+++ b/arch/cris/arch-v10/kernel/debugport.c
@@ -426,12 +426,18 @@ static int dummy_write(struct tty_struct * tty,
426 return count; 426 return count;
427} 427}
428 428
429static int 429static int dummy_write_room(struct tty_struct *tty)
430dummy_write_room(struct tty_struct *tty)
431{ 430{
432 return 8192; 431 return 8192;
433} 432}
434 433
434static const struct tty_operations dummy_ops = {
435 .open = dummy_open,
436 .close = dummy_close,
437 .write = dummy_write,
438 .write_room = dummy_write_room,
439};
440
435void __init 441void __init
436init_dummy_console(void) 442init_dummy_console(void)
437{ 443{
@@ -444,14 +450,14 @@ init_dummy_console(void)
444 dummy_driver.type = TTY_DRIVER_TYPE_SERIAL; 450 dummy_driver.type = TTY_DRIVER_TYPE_SERIAL;
445 dummy_driver.subtype = SERIAL_TYPE_NORMAL; 451 dummy_driver.subtype = SERIAL_TYPE_NORMAL;
446 dummy_driver.init_termios = tty_std_termios; 452 dummy_driver.init_termios = tty_std_termios;
453 /* Normally B9600 default... */
447 dummy_driver.init_termios.c_cflag = 454 dummy_driver.init_termios.c_cflag =
448 B115200 | CS8 | CREAD | HUPCL | CLOCAL; /* is normally B9600 default... */ 455 B115200 | CS8 | CREAD | HUPCL | CLOCAL;
449 dummy_driver.flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; 456 dummy_driver.flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
457 dummy_driver.init_termios.c_ispeed = 115200;
458 dummy_driver.init_termios.c_ospeed = 115200;
450 459
451 dummy_driver.open = dummy_open; 460 dummy_driver.ops = &dummy_ops;
452 dummy_driver.close = dummy_close;
453 dummy_driver.write = dummy_write;
454 dummy_driver.write_room = dummy_write_room;
455 if (tty_register_driver(&dummy_driver)) 461 if (tty_register_driver(&dummy_driver))
456 panic("Couldn't register dummy serial driver\n"); 462 panic("Couldn't register dummy serial driver\n");
457} 463}
diff --git a/arch/cris/arch-v32/boot/Makefile b/arch/cris/arch-v32/boot/Makefile
index 3f91349c5f12..99896ad60b30 100644
--- a/arch/cris/arch-v32/boot/Makefile
+++ b/arch/cris/arch-v32/boot/Makefile
@@ -2,7 +2,6 @@
2# arch/cris/arch-v32/boot/Makefile 2# arch/cris/arch-v32/boot/Makefile
3# 3#
4 4
5OBJCOPY = objcopy-cris
6OBJCOPYFLAGS = -O binary -R .note -R .comment 5OBJCOPYFLAGS = -O binary -R .note -R .comment
7 6
8subdir- := compressed rescue 7subdir- := compressed rescue
diff --git a/arch/cris/arch-v32/boot/compressed/Makefile b/arch/cris/arch-v32/boot/compressed/Makefile
index 2c8c2c3039c5..d6335f26083b 100644
--- a/arch/cris/arch-v32/boot/compressed/Makefile
+++ b/arch/cris/arch-v32/boot/compressed/Makefile
@@ -2,14 +2,10 @@
2# arch/cris/arch-v32/boot/compressed/Makefile 2# arch/cris/arch-v32/boot/compressed/Makefile
3# 3#
4 4
5CC = gcc-cris -mlinux -march=v32 $(LINUXINCLUDE)
6asflags-y += -I $(srctree)/include/asm/mach/ -I $(srctree)/include/asm/arch 5asflags-y += -I $(srctree)/include/asm/mach/ -I $(srctree)/include/asm/arch
7ccflags-y += -O2 -I $(srctree)/include/asm/mach/ -I $(srctree)/include/asm/arch 6ccflags-y += -O2 -I $(srctree)/include/asm/mach/ -I $(srctree)/include/asm/arch
8LD = gcc-cris -mlinux -march=v32 -nostdlib 7ldflags-y += -T $(srctree)/$(obj)/decompress.ld
9ldflags-y += -T $(obj)/decompress.ld
10obj-y = head.o misc.o
11OBJECTS = $(obj)/head.o $(obj)/misc.o 8OBJECTS = $(obj)/head.o $(obj)/misc.o
12OBJCOPY = objcopy-cris
13OBJCOPYFLAGS = -O binary --remove-section=.bss 9OBJCOPYFLAGS = -O binary --remove-section=.bss
14 10
15quiet_cmd_image = BUILD $@ 11quiet_cmd_image = BUILD $@
diff --git a/arch/cris/arch-v32/boot/rescue/Makefile b/arch/cris/arch-v32/boot/rescue/Makefile
index c0987795dcb7..44ae0ad61f90 100644
--- a/arch/cris/arch-v32/boot/rescue/Makefile
+++ b/arch/cris/arch-v32/boot/rescue/Makefile
@@ -7,9 +7,8 @@ ccflags-y += -O2 -I $(srctree)/include/asm/arch/mach/ \
7 -I $(srctree)/include/asm/arch 7 -I $(srctree)/include/asm/arch
8asflags-y += -I $(srctree)/include/asm/arch/mach/ -I $(srctree)/include/asm/arch 8asflags-y += -I $(srctree)/include/asm/arch/mach/ -I $(srctree)/include/asm/arch
9LD = gcc-cris -mlinux -march=v32 -nostdlib 9LD = gcc-cris -mlinux -march=v32 -nostdlib
10ldflags-y += -T $(obj)/rescue.ld 10ldflags-y += -T $(srctree)/$(obj)/rescue.ld
11LDPOSTFLAGS = -lgcc 11LDPOSTFLAGS = -lgcc
12OBJCOPY = objcopy-cris
13OBJCOPYFLAGS = -O binary --remove-section=.bss 12OBJCOPYFLAGS = -O binary --remove-section=.bss
14obj-$(CONFIG_ETRAX_AXISFLASHMAP) = head.o 13obj-$(CONFIG_ETRAX_AXISFLASHMAP) = head.o
15OBJECT := $(obj)/head.o 14OBJECT := $(obj)/head.o
diff --git a/arch/cris/arch-v32/drivers/pcf8563.c b/arch/cris/arch-v32/drivers/pcf8563.c
index 53db3870ba04..f263ab571221 100644
--- a/arch/cris/arch-v32/drivers/pcf8563.c
+++ b/arch/cris/arch-v32/drivers/pcf8563.c
@@ -229,7 +229,7 @@ int pcf8563_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
229 229
230 if (copy_to_user((struct rtc_time *) arg, &tm, 230 if (copy_to_user((struct rtc_time *) arg, &tm,
231 sizeof tm)) { 231 sizeof tm)) {
232 spin_unlock(&rtc_lock); 232 mutex_unlock(&rtc_lock);
233 return -EFAULT; 233 return -EFAULT;
234 } 234 }
235 235
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 23cafc80d2a4..24b1ad5334cb 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -193,18 +193,6 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
193 * ------------------------------------------------------------------- 193 * -------------------------------------------------------------------
194 */ 194 */
195 195
196#if 0
197/*
198 * not really used in our situation so keep them commented out for now
199 */
200static DECLARE_TASK_QUEUE(tq_serial); /* used to be at the top of the file */
201static void do_serial_bh(void)
202{
203 run_task_queue(&tq_serial);
204 printk(KERN_ERR "do_serial_bh: called\n");
205}
206#endif
207
208static void do_softint(struct work_struct *private_) 196static void do_softint(struct work_struct *private_)
209{ 197{
210 printk(KERN_ERR "simserial: do_softint called\n"); 198 printk(KERN_ERR "simserial: do_softint called\n");
@@ -351,11 +339,7 @@ static void rs_flush_buffer(struct tty_struct *tty)
351 info->xmit.head = info->xmit.tail = 0; 339 info->xmit.head = info->xmit.tail = 0;
352 local_irq_restore(flags); 340 local_irq_restore(flags);
353 341
354 wake_up_interruptible(&tty->write_wait); 342 tty_wakeup(tty);
355
356 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
357 tty->ldisc.write_wakeup)
358 (tty->ldisc.write_wakeup)(tty);
359} 343}
360 344
361/* 345/*
@@ -404,12 +388,6 @@ static void rs_unthrottle(struct tty_struct * tty)
404 printk(KERN_INFO "simrs_unthrottle called\n"); 388 printk(KERN_INFO "simrs_unthrottle called\n");
405} 389}
406 390
407/*
408 * rs_break() --- routine which turns the break handling on or off
409 */
410static void rs_break(struct tty_struct *tty, int break_state)
411{
412}
413 391
414static int rs_ioctl(struct tty_struct *tty, struct file * file, 392static int rs_ioctl(struct tty_struct *tty, struct file * file,
415 unsigned int cmd, unsigned long arg) 393 unsigned int cmd, unsigned long arg)
@@ -422,14 +400,6 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
422 } 400 }
423 401
424 switch (cmd) { 402 switch (cmd) {
425 case TIOCMGET:
426 printk(KERN_INFO "rs_ioctl: TIOCMGET called\n");
427 return -EINVAL;
428 case TIOCMBIS:
429 case TIOCMBIC:
430 case TIOCMSET:
431 printk(KERN_INFO "rs_ioctl: TIOCMBIS/BIC/SET called\n");
432 return -EINVAL;
433 case TIOCGSERIAL: 403 case TIOCGSERIAL:
434 printk(KERN_INFO "simrs_ioctl TIOCGSERIAL called\n"); 404 printk(KERN_INFO "simrs_ioctl TIOCGSERIAL called\n");
435 return 0; 405 return 0;
@@ -488,14 +458,6 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
488 458
489static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) 459static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
490{ 460{
491 unsigned int cflag = tty->termios->c_cflag;
492
493 if ( (cflag == old_termios->c_cflag)
494 && ( RELEVANT_IFLAG(tty->termios->c_iflag)
495 == RELEVANT_IFLAG(old_termios->c_iflag)))
496 return;
497
498
499 /* Handle turning off CRTSCTS */ 461 /* Handle turning off CRTSCTS */
500 if ((old_termios->c_cflag & CRTSCTS) && 462 if ((old_termios->c_cflag & CRTSCTS) &&
501 !(tty->termios->c_cflag & CRTSCTS)) { 463 !(tty->termios->c_cflag & CRTSCTS)) {
@@ -623,9 +585,8 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
623 * the line discipline to only process XON/XOFF characters. 585 * the line discipline to only process XON/XOFF characters.
624 */ 586 */
625 shutdown(info); 587 shutdown(info);
626 if (tty->ops->flush_buffer) 588 rs_flush_buffer(tty);
627 tty->ops->flush_buffer(tty); 589 tty_ldisc_flush(tty);
628 if (tty->ldisc.flush_buffer) tty->ldisc.flush_buffer(tty);
629 info->event = 0; 590 info->event = 0;
630 info->tty = NULL; 591 info->tty = NULL;
631 if (info->blocked_open) { 592 if (info->blocked_open) {
@@ -955,7 +916,6 @@ static const struct tty_operations hp_ops = {
955 .stop = rs_stop, 916 .stop = rs_stop,
956 .start = rs_start, 917 .start = rs_start,
957 .hangup = rs_hangup, 918 .hangup = rs_hangup,
958 .break_ctl = rs_break,
959 .wait_until_sent = rs_wait_until_sent, 919 .wait_until_sent = rs_wait_until_sent,
960 .read_proc = rs_read_proc, 920 .read_proc = rs_read_proc,
961}; 921};
diff --git a/arch/ia64/kvm/Makefile b/arch/ia64/kvm/Makefile
index 112791dd2542..bf22fb9e6dcf 100644
--- a/arch/ia64/kvm/Makefile
+++ b/arch/ia64/kvm/Makefile
@@ -43,7 +43,8 @@ $(obj)/$(offsets-file): arch/ia64/kvm/asm-offsets.s
43EXTRA_CFLAGS += -Ivirt/kvm -Iarch/ia64/kvm/ 43EXTRA_CFLAGS += -Ivirt/kvm -Iarch/ia64/kvm/
44EXTRA_AFLAGS += -Ivirt/kvm -Iarch/ia64/kvm/ 44EXTRA_AFLAGS += -Ivirt/kvm -Iarch/ia64/kvm/
45 45
46common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o) 46common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \
47 coalesced_mmio.o)
47 48
48kvm-objs := $(common-objs) kvm-ia64.o kvm_fw.o 49kvm-objs := $(common-objs) kvm-ia64.o kvm_fw.o
49obj-$(CONFIG_KVM) += kvm.o 50obj-$(CONFIG_KVM) += kvm.o
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index 68c978be9a51..2672f4d278ac 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -187,6 +187,9 @@ int kvm_dev_ioctl_check_extension(long ext)
187 187
188 r = 1; 188 r = 1;
189 break; 189 break;
190 case KVM_CAP_COALESCED_MMIO:
191 r = KVM_COALESCED_MMIO_PAGE_OFFSET;
192 break;
190 default: 193 default:
191 r = 0; 194 r = 0;
192 } 195 }
@@ -195,11 +198,11 @@ int kvm_dev_ioctl_check_extension(long ext)
195} 198}
196 199
197static struct kvm_io_device *vcpu_find_mmio_dev(struct kvm_vcpu *vcpu, 200static struct kvm_io_device *vcpu_find_mmio_dev(struct kvm_vcpu *vcpu,
198 gpa_t addr) 201 gpa_t addr, int len, int is_write)
199{ 202{
200 struct kvm_io_device *dev; 203 struct kvm_io_device *dev;
201 204
202 dev = kvm_io_bus_find_dev(&vcpu->kvm->mmio_bus, addr); 205 dev = kvm_io_bus_find_dev(&vcpu->kvm->mmio_bus, addr, len, is_write);
203 206
204 return dev; 207 return dev;
205} 208}
@@ -231,7 +234,7 @@ static int handle_mmio(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
231 kvm_run->exit_reason = KVM_EXIT_MMIO; 234 kvm_run->exit_reason = KVM_EXIT_MMIO;
232 return 0; 235 return 0;
233mmio: 236mmio:
234 mmio_dev = vcpu_find_mmio_dev(vcpu, p->addr); 237 mmio_dev = vcpu_find_mmio_dev(vcpu, p->addr, p->size, !p->dir);
235 if (mmio_dev) { 238 if (mmio_dev) {
236 if (!p->dir) 239 if (!p->dir)
237 kvm_iodevice_write(mmio_dev, p->addr, p->size, 240 kvm_iodevice_write(mmio_dev, p->addr, p->size,
@@ -1035,14 +1038,6 @@ static void kvm_free_vmm_area(void)
1035 } 1038 }
1036} 1039}
1037 1040
1038/*
1039 * Make sure that a cpu that is being hot-unplugged does not have any vcpus
1040 * cached on it. Leave it as blank for IA64.
1041 */
1042void decache_vcpus_on_cpu(int cpu)
1043{
1044}
1045
1046static void vti_vcpu_load(struct kvm_vcpu *vcpu, int cpu) 1041static void vti_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
1047{ 1042{
1048} 1043}
@@ -1460,6 +1455,9 @@ int kvm_arch_set_memory_region(struct kvm *kvm,
1460 return 0; 1455 return 0;
1461} 1456}
1462 1457
1458void kvm_arch_flush_shadow(struct kvm *kvm)
1459{
1460}
1463 1461
1464long kvm_arch_dev_ioctl(struct file *filp, 1462long kvm_arch_dev_ioctl(struct file *filp,
1465 unsigned int ioctl, unsigned long arg) 1463 unsigned int ioctl, unsigned long arg)
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 55ea52fe6aca..8c5e1de68fcb 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -490,28 +490,6 @@ config ATARI_MFPSER
490 Note for Falcon users: You also have an MFP port, it's just not 490 Note for Falcon users: You also have an MFP port, it's just not
491 wired to the outside... But you could use the port under Linux. 491 wired to the outside... But you could use the port under Linux.
492 492
493config ATARI_SCC
494 tristate "Atari SCC serial support"
495 depends on ATARI
496 ---help---
497 If you have serial ports based on a Zilog SCC chip (Modem2, Serial2,
498 LAN) and like to use them under Linux, say Y. All built-in SCC's are
499 supported (TT, MegaSTE, Falcon), and also the ST-ESCC. If you have
500 two connectors for channel A (Serial2 and LAN), they are visible as
501 two separate devices.
502
503 To compile this driver as a module, choose M here.
504
505config ATARI_SCC_DMA
506 bool "Atari SCC serial DMA support"
507 depends on ATARI_SCC
508 help
509 This enables DMA support for receiving data on channel A of the SCC.
510 If you have a TT you may say Y here and read
511 drivers/char/atari_SCC.README. All other users should say N here,
512 because only the TT has SCC-DMA, even if your machine keeps claiming
513 so at boot time.
514
515config ATARI_MIDI 493config ATARI_MIDI
516 tristate "Atari MIDI serial support" 494 tristate "Atari MIDI serial support"
517 depends on ATARI 495 depends on ATARI
@@ -578,18 +556,6 @@ config MAC_HID
578 depends on INPUT_ADBHID 556 depends on INPUT_ADBHID
579 default y 557 default y
580 558
581config ADB_KEYBOARD
582 bool "Support for ADB keyboard (old driver)"
583 depends on MAC && !INPUT_ADBHID
584 help
585 This option allows you to use an ADB keyboard attached to your
586 machine. Note that this disables any other (ie. PS/2) keyboard
587 support, even if your machine is physically capable of using both at
588 the same time.
589
590 If you use an ADB keyboard (4 pin connector), say Y here.
591 If you use a PS/2 keyboard (6 pin connector), say N here.
592
593config HPDCA 559config HPDCA
594 tristate "HP DCA serial support" 560 tristate "HP DCA serial support"
595 depends on DIO && SERIAL_8250 561 depends on DIO && SERIAL_8250
@@ -640,7 +606,7 @@ config DN_SERIAL
640 606
641config SERIAL_CONSOLE 607config SERIAL_CONSOLE
642 bool "Support for serial port console" 608 bool "Support for serial port console"
643 depends on (AMIGA || ATARI || MAC || SUN3 || SUN3X || VME || APOLLO) && (ATARI_MFPSER=y || ATARI_SCC=y || ATARI_MIDI=y || MAC_SCC=y || AMIGA_BUILTIN_SERIAL=y || GVPIOEXT=y || MULTIFACE_III_TTY=y || SERIAL=y || MVME147_SCC || SERIAL167 || MVME162_SCC || BVME6000_SCC || DN_SERIAL) 609 depends on (AMIGA || ATARI || MAC || SUN3 || SUN3X || VME || APOLLO) && (ATARI_MFPSER=y || ATARI_MIDI=y || MAC_SCC=y || AMIGA_BUILTIN_SERIAL=y || GVPIOEXT=y || MULTIFACE_III_TTY=y || SERIAL=y || MVME147_SCC || SERIAL167 || MVME162_SCC || BVME6000_SCC || DN_SERIAL)
644 ---help--- 610 ---help---
645 If you say Y here, it will be possible to use a serial port as the 611 If you say Y here, it will be possible to use a serial port as the
646 system console (the system console is the device which receives all 612 system console (the system console is the device which receives all
diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
index b15173f28a23..8133dbc44964 100644
--- a/arch/m68k/Makefile
+++ b/arch/m68k/Makefile
@@ -13,7 +13,7 @@
13# Copyright (C) 1994 by Hamish Macdonald 13# Copyright (C) 1994 by Hamish Macdonald
14# 14#
15 15
16KBUILD_DEFCONFIG := amiga_defconfig 16KBUILD_DEFCONFIG := multi_defconfig
17 17
18# override top level makefile 18# override top level makefile
19AS += -m68020 19AS += -m68020
diff --git a/arch/m68k/amiga/config.c b/arch/m68k/amiga/config.c
index 50f5daab46b7..df679d96b1cb 100644
--- a/arch/m68k/amiga/config.c
+++ b/arch/m68k/amiga/config.c
@@ -36,14 +36,11 @@
36#include <asm/machdep.h> 36#include <asm/machdep.h>
37#include <asm/io.h> 37#include <asm/io.h>
38 38
39unsigned long amiga_model; 39static unsigned long amiga_model;
40EXPORT_SYMBOL(amiga_model);
41 40
42unsigned long amiga_eclock; 41unsigned long amiga_eclock;
43EXPORT_SYMBOL(amiga_eclock); 42EXPORT_SYMBOL(amiga_eclock);
44 43
45unsigned long amiga_masterclock;
46
47unsigned long amiga_colorclock; 44unsigned long amiga_colorclock;
48EXPORT_SYMBOL(amiga_colorclock); 45EXPORT_SYMBOL(amiga_colorclock);
49 46
@@ -51,7 +48,9 @@ unsigned long amiga_chipset;
51EXPORT_SYMBOL(amiga_chipset); 48EXPORT_SYMBOL(amiga_chipset);
52 49
53unsigned char amiga_vblank; 50unsigned char amiga_vblank;
54unsigned char amiga_psfreq; 51EXPORT_SYMBOL(amiga_vblank);
52
53static unsigned char amiga_psfreq;
55 54
56struct amiga_hw_present amiga_hw_present; 55struct amiga_hw_present amiga_hw_present;
57EXPORT_SYMBOL(amiga_hw_present); 56EXPORT_SYMBOL(amiga_hw_present);
@@ -92,8 +91,6 @@ static char *amiga_models[] __initdata = {
92static char amiga_model_name[13] = "Amiga "; 91static char amiga_model_name[13] = "Amiga ";
93 92
94static void amiga_sched_init(irq_handler_t handler); 93static void amiga_sched_init(irq_handler_t handler);
95/* amiga specific irq functions */
96extern void amiga_init_IRQ(void);
97static void amiga_get_model(char *model); 94static void amiga_get_model(char *model);
98static int amiga_get_hardware_list(char *buffer); 95static int amiga_get_hardware_list(char *buffer);
99/* amiga specific timer functions */ 96/* amiga specific timer functions */
@@ -107,8 +104,6 @@ static void amiga_reset(void);
107extern void amiga_init_sound(void); 104extern void amiga_init_sound(void);
108static void amiga_mem_console_write(struct console *co, const char *b, 105static void amiga_mem_console_write(struct console *co, const char *b,
109 unsigned int count); 106 unsigned int count);
110void amiga_serial_console_write(struct console *co, const char *s,
111 unsigned int count);
112#ifdef CONFIG_HEARTBEAT 107#ifdef CONFIG_HEARTBEAT
113static void amiga_heartbeat(int on); 108static void amiga_heartbeat(int on);
114#endif 109#endif
@@ -418,8 +413,7 @@ void __init config_amiga(void)
418 mach_heartbeat = amiga_heartbeat; 413 mach_heartbeat = amiga_heartbeat;
419#endif 414#endif
420 415
421 /* Fill in the clock values (based on the 700 kHz E-Clock) */ 416 /* Fill in the clock value (based on the 700 kHz E-Clock) */
422 amiga_masterclock = 40*amiga_eclock; /* 28 MHz */
423 amiga_colorclock = 5*amiga_eclock; /* 3.5 MHz */ 417 amiga_colorclock = 5*amiga_eclock; /* 3.5 MHz */
424 418
425 /* clear all DMA bits */ 419 /* clear all DMA bits */
@@ -817,8 +811,8 @@ static void amiga_serial_putc(char c)
817 ; 811 ;
818} 812}
819 813
820void amiga_serial_console_write(struct console *co, const char *s, 814static void amiga_serial_console_write(struct console *co, const char *s,
821 unsigned int count) 815 unsigned int count)
822{ 816{
823 while (count--) { 817 while (count--) {
824 if (*s == '\n') 818 if (*s == '\n')
@@ -827,7 +821,7 @@ void amiga_serial_console_write(struct console *co, const char *s,
827 } 821 }
828} 822}
829 823
830#ifdef CONFIG_SERIAL_CONSOLE 824#if 0
831void amiga_serial_puts(const char *s) 825void amiga_serial_puts(const char *s)
832{ 826{
833 amiga_serial_console_write(NULL, s, strlen(s)); 827 amiga_serial_console_write(NULL, s, strlen(s));
diff --git a/arch/m68k/atari/debug.c b/arch/m68k/atari/debug.c
index 043ddbc61c7b..702b15ccfab7 100644
--- a/arch/m68k/atari/debug.c
+++ b/arch/m68k/atari/debug.c
@@ -20,14 +20,6 @@
20#include <asm/atarihw.h> 20#include <asm/atarihw.h>
21#include <asm/atariints.h> 21#include <asm/atariints.h>
22 22
23/* Flag that Modem1 port is already initialized and used */
24int atari_MFP_init_done;
25EXPORT_SYMBOL(atari_MFP_init_done);
26
27/* Flag that Modem1 port is already initialized and used */
28int atari_SCC_init_done;
29EXPORT_SYMBOL(atari_SCC_init_done);
30
31/* Can be set somewhere, if a SCC master reset has already be done and should 23/* Can be set somewhere, if a SCC master reset has already be done and should
32 * not be repeated; used by kgdb */ 24 * not be repeated; used by kgdb */
33int atari_SCC_reset_done; 25int atari_SCC_reset_done;
@@ -47,8 +39,8 @@ static inline void ata_mfp_out(char c)
47 mfp.usart_dta = c; 39 mfp.usart_dta = c;
48} 40}
49 41
50void atari_mfp_console_write(struct console *co, const char *str, 42static void atari_mfp_console_write(struct console *co, const char *str,
51 unsigned int count) 43 unsigned int count)
52{ 44{
53 while (count--) { 45 while (count--) {
54 if (*str == '\n') 46 if (*str == '\n')
@@ -66,8 +58,8 @@ static inline void ata_scc_out(char c)
66 scc.cha_b_data = c; 58 scc.cha_b_data = c;
67} 59}
68 60
69void atari_scc_console_write(struct console *co, const char *str, 61static void atari_scc_console_write(struct console *co, const char *str,
70 unsigned int count) 62 unsigned int count)
71{ 63{
72 while (count--) { 64 while (count--) {
73 if (*str == '\n') 65 if (*str == '\n')
@@ -83,8 +75,8 @@ static inline void ata_midi_out(char c)
83 acia.mid_data = c; 75 acia.mid_data = c;
84} 76}
85 77
86void atari_midi_console_write(struct console *co, const char *str, 78static void atari_midi_console_write(struct console *co, const char *str,
87 unsigned int count) 79 unsigned int count)
88{ 80{
89 while (count--) { 81 while (count--) {
90 if (*str == '\n') 82 if (*str == '\n')
@@ -136,7 +128,7 @@ static void atari_par_console_write(struct console *co, const char *str,
136 } 128 }
137} 129}
138 130
139#ifdef CONFIG_SERIAL_CONSOLE 131#if 0
140int atari_mfp_console_wait_key(struct console *co) 132int atari_mfp_console_wait_key(struct console *co)
141{ 133{
142 while (!(mfp.rcv_stat & 0x80)) /* wait for rx buf filled */ 134 while (!(mfp.rcv_stat & 0x80)) /* wait for rx buf filled */
@@ -166,11 +158,7 @@ int atari_midi_console_wait_key(struct console *co)
166 * SCC serial ports. They're used by the debugging interface, kgdb, and the 158 * SCC serial ports. They're used by the debugging interface, kgdb, and the
167 * serial console code. 159 * serial console code.
168 */ 160 */
169#ifndef CONFIG_SERIAL_CONSOLE
170static void __init atari_init_mfp_port(int cflag) 161static void __init atari_init_mfp_port(int cflag)
171#else
172void atari_init_mfp_port(int cflag)
173#endif
174{ 162{
175 /* 163 /*
176 * timer values for 1200...115200 bps; > 38400 select 110, 134, or 150 164 * timer values for 1200...115200 bps; > 38400 select 110, 134, or 150
@@ -193,8 +181,6 @@ void atari_init_mfp_port(int cflag)
193 mfp.tim_dt_d = baud_table[baud]; 181 mfp.tim_dt_d = baud_table[baud];
194 mfp.tim_ct_cd |= 0x01; /* start timer D, 1:4 */ 182 mfp.tim_ct_cd |= 0x01; /* start timer D, 1:4 */
195 mfp.trn_stat |= 0x01; /* enable TX */ 183 mfp.trn_stat |= 0x01; /* enable TX */
196
197 atari_MFP_init_done = 1;
198} 184}
199 185
200#define SCC_WRITE(reg, val) \ 186#define SCC_WRITE(reg, val) \
@@ -214,11 +200,7 @@ void atari_init_mfp_port(int cflag)
214 MFPDELAY(); \ 200 MFPDELAY(); \
215 } while (0) 201 } while (0)
216 202
217#ifndef CONFIG_SERIAL_CONSOLE
218static void __init atari_init_scc_port(int cflag) 203static void __init atari_init_scc_port(int cflag)
219#else
220void atari_init_scc_port(int cflag)
221#endif
222{ 204{
223 extern int atari_SCC_reset_done; 205 extern int atari_SCC_reset_done;
224 static int clksrc_table[9] = 206 static int clksrc_table[9] =
@@ -277,14 +259,9 @@ void atari_init_scc_port(int cflag)
277 SCC_WRITE(5, reg5 | 8); 259 SCC_WRITE(5, reg5 | 8);
278 260
279 atari_SCC_reset_done = 1; 261 atari_SCC_reset_done = 1;
280 atari_SCC_init_done = 1;
281} 262}
282 263
283#ifndef CONFIG_SERIAL_CONSOLE
284static void __init atari_init_midi_port(int cflag) 264static void __init atari_init_midi_port(int cflag)
285#else
286void atari_init_midi_port(int cflag)
287#endif
288{ 265{
289 int baud = cflag & CBAUD; 266 int baud = cflag & CBAUD;
290 int csize = ((cflag & CSIZE) == CS8) ? 0x10 : 0x00; 267 int csize = ((cflag & CSIZE) == CS8) ? 0x10 : 0x00;
diff --git a/arch/m68k/fpsp040/Makefile b/arch/m68k/fpsp040/Makefile
index 0214d2f6f8b0..9506d883ace5 100644
--- a/arch/m68k/fpsp040/Makefile
+++ b/arch/m68k/fpsp040/Makefile
@@ -10,7 +10,6 @@ obj-y := bindec.o binstr.o decbin.o do_func.o gen_except.o get_op.o \
10 x_bsun.o x_fline.o x_operr.o x_ovfl.o x_snan.o x_store.o \ 10 x_bsun.o x_fline.o x_operr.o x_ovfl.o x_snan.o x_store.o \
11 x_unfl.o x_unimp.o x_unsupp.o bugfix.o skeleton.o 11 x_unfl.o x_unimp.o x_unsupp.o bugfix.o skeleton.o
12 12
13EXTRA_AFLAGS := -traditional
14EXTRA_LDFLAGS := -x 13EXTRA_LDFLAGS := -x
15 14
16$(OS_OBJS): fpsp.h 15$(OS_OBJS): fpsp.h
diff --git a/arch/m68k/ifpsp060/Makefile b/arch/m68k/ifpsp060/Makefile
index 2fe8472cb5e3..43b435049452 100644
--- a/arch/m68k/ifpsp060/Makefile
+++ b/arch/m68k/ifpsp060/Makefile
@@ -6,5 +6,4 @@
6 6
7obj-y := fskeleton.o iskeleton.o os.o 7obj-y := fskeleton.o iskeleton.o os.o
8 8
9EXTRA_AFLAGS := -traditional
10EXTRA_LDFLAGS := -x 9EXTRA_LDFLAGS := -x
diff --git a/arch/m68k/kernel/Makefile b/arch/m68k/kernel/Makefile
index 7a62a718143b..3a7f62225504 100644
--- a/arch/m68k/kernel/Makefile
+++ b/arch/m68k/kernel/Makefile
@@ -16,5 +16,3 @@ devres-y = ../../../kernel/irq/devres.o
16 16
17obj-$(CONFIG_PCI) += bios32.o 17obj-$(CONFIG_PCI) += bios32.o
18obj-y$(CONFIG_MMU_SUN3) += dma.o # no, it's not a typo 18obj-y$(CONFIG_MMU_SUN3) += dma.o # no, it's not a typo
19
20EXTRA_AFLAGS := -traditional
diff --git a/arch/m68k/kernel/setup.c b/arch/m68k/kernel/setup.c
index a9fb83a8c180..ea1e44da19b9 100644
--- a/arch/m68k/kernel/setup.c
+++ b/arch/m68k/kernel/setup.c
@@ -26,6 +26,7 @@
26 26
27#include <asm/bootinfo.h> 27#include <asm/bootinfo.h>
28#include <asm/setup.h> 28#include <asm/setup.h>
29#include <asm/fpu.h>
29#include <asm/irq.h> 30#include <asm/irq.h>
30#include <asm/io.h> 31#include <asm/io.h>
31#include <asm/machdep.h> 32#include <asm/machdep.h>
@@ -40,6 +41,11 @@
40#include <asm/dvma.h> 41#include <asm/dvma.h>
41#endif 42#endif
42 43
44#if !FPSTATESIZE || !NR_IRQS
45#warning No CPU/platform type selected, your kernel will not work!
46#warning Are you building an allnoconfig kernel?
47#endif
48
43unsigned long m68k_machtype; 49unsigned long m68k_machtype;
44EXPORT_SYMBOL(m68k_machtype); 50EXPORT_SYMBOL(m68k_machtype);
45unsigned long m68k_cputype; 51unsigned long m68k_cputype;
@@ -116,6 +122,7 @@ extern int bvme6000_parse_bootinfo(const struct bi_record *);
116extern int mvme16x_parse_bootinfo(const struct bi_record *); 122extern int mvme16x_parse_bootinfo(const struct bi_record *);
117extern int mvme147_parse_bootinfo(const struct bi_record *); 123extern int mvme147_parse_bootinfo(const struct bi_record *);
118extern int hp300_parse_bootinfo(const struct bi_record *); 124extern int hp300_parse_bootinfo(const struct bi_record *);
125extern int apollo_parse_bootinfo(const struct bi_record *);
119 126
120extern void config_amiga(void); 127extern void config_amiga(void);
121extern void config_atari(void); 128extern void config_atari(void);
@@ -183,6 +190,8 @@ static void __init m68k_parse_bootinfo(const struct bi_record *record)
183 unknown = mvme147_parse_bootinfo(record); 190 unknown = mvme147_parse_bootinfo(record);
184 else if (MACH_IS_HP300) 191 else if (MACH_IS_HP300)
185 unknown = hp300_parse_bootinfo(record); 192 unknown = hp300_parse_bootinfo(record);
193 else if (MACH_IS_APOLLO)
194 unknown = apollo_parse_bootinfo(record);
186 else 195 else
187 unknown = 1; 196 unknown = 1;
188 } 197 }
diff --git a/arch/m68k/kernel/vmlinux-std.lds b/arch/m68k/kernel/vmlinux-std.lds
index 7537cc5e6159..99b0784c0552 100644
--- a/arch/m68k/kernel/vmlinux-std.lds
+++ b/arch/m68k/kernel/vmlinux-std.lds
@@ -1,6 +1,7 @@
1/* ld script to make m68k Linux kernel */ 1/* ld script to make m68k Linux kernel */
2 2
3#include <asm-generic/vmlinux.lds.h> 3#include <asm-generic/vmlinux.lds.h>
4#include <asm/page.h>
4 5
5OUTPUT_FORMAT("elf32-m68k", "elf32-m68k", "elf32-m68k") 6OUTPUT_FORMAT("elf32-m68k", "elf32-m68k", "elf32-m68k")
6OUTPUT_ARCH(m68k) 7OUTPUT_ARCH(m68k)
@@ -41,7 +42,7 @@ SECTIONS
41 _edata = .; /* End of data section */ 42 _edata = .; /* End of data section */
42 43
43 /* will be freed after init */ 44 /* will be freed after init */
44 . = ALIGN(4096); /* Init code and data */ 45 . = ALIGN(PAGE_SIZE); /* Init code and data */
45 __init_begin = .; 46 __init_begin = .;
46 .init.text : { 47 .init.text : {
47 _sinittext = .; 48 _sinittext = .;
diff --git a/arch/m68k/kernel/vmlinux-sun3.lds b/arch/m68k/kernel/vmlinux-sun3.lds
index cdc313e7c299..8a4919e4d36a 100644
--- a/arch/m68k/kernel/vmlinux-sun3.lds
+++ b/arch/m68k/kernel/vmlinux-sun3.lds
@@ -1,6 +1,7 @@
1/* ld script to make m68k Linux kernel */ 1/* ld script to make m68k Linux kernel */
2 2
3#include <asm-generic/vmlinux.lds.h> 3#include <asm-generic/vmlinux.lds.h>
4#include <asm/page.h>
4 5
5OUTPUT_FORMAT("elf32-m68k", "elf32-m68k", "elf32-m68k") 6OUTPUT_FORMAT("elf32-m68k", "elf32-m68k", "elf32-m68k")
6OUTPUT_ARCH(m68k) 7OUTPUT_ARCH(m68k)
@@ -34,7 +35,7 @@ SECTIONS
34 _edata = .; 35 _edata = .;
35 36
36 /* will be freed after init */ 37 /* will be freed after init */
37 . = ALIGN(8192); /* Init code and data */ 38 . = ALIGN(PAGE_SIZE); /* Init code and data */
38__init_begin = .; 39__init_begin = .;
39 .init.text : { 40 .init.text : {
40 _sinittext = .; 41 _sinittext = .;
@@ -61,12 +62,12 @@ __init_begin = .;
61 } 62 }
62 SECURITY_INIT 63 SECURITY_INIT
63#ifdef CONFIG_BLK_DEV_INITRD 64#ifdef CONFIG_BLK_DEV_INITRD
64 . = ALIGN(8192); 65 . = ALIGN(PAGE_SIZE);
65 __initramfs_start = .; 66 __initramfs_start = .;
66 .init.ramfs : { *(.init.ramfs) } 67 .init.ramfs : { *(.init.ramfs) }
67 __initramfs_end = .; 68 __initramfs_end = .;
68#endif 69#endif
69 . = ALIGN(8192); 70 . = ALIGN(PAGE_SIZE);
70 __init_end = .; 71 __init_end = .;
71 .data.init.task : { *(.data.init_task) } 72 .data.init.task : { *(.data.init_task) }
72 73
diff --git a/arch/m68k/lib/Makefile b/arch/m68k/lib/Makefile
index a18af095cd7c..af9abf8d9d98 100644
--- a/arch/m68k/lib/Makefile
+++ b/arch/m68k/lib/Makefile
@@ -2,7 +2,5 @@
2# Makefile for m68k-specific library files.. 2# Makefile for m68k-specific library files..
3# 3#
4 4
5EXTRA_AFLAGS := -traditional
6
7lib-y := ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \ 5lib-y := ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \
8 checksum.o string.o uaccess.o 6 checksum.o string.o uaccess.o
diff --git a/arch/m68k/mac/Makefile b/arch/m68k/mac/Makefile
index 1d265ba365ad..daebd80bdef0 100644
--- a/arch/m68k/mac/Makefile
+++ b/arch/m68k/mac/Makefile
@@ -2,5 +2,5 @@
2# Makefile for Linux arch/m68k/mac source directory 2# Makefile for Linux arch/m68k/mac source directory
3# 3#
4 4
5obj-y := config.o bootparse.o macints.o iop.o via.o oss.o psc.o \ 5obj-y := config.o macints.o iop.o via.o oss.o psc.o \
6 baboon.o macboing.o debug.o misc.o 6 baboon.o macboing.o debug.o misc.o
diff --git a/arch/m68k/mac/baboon.c b/arch/m68k/mac/baboon.c
index 673a1085984d..dae9c982aa89 100644
--- a/arch/m68k/mac/baboon.c
+++ b/arch/m68k/mac/baboon.c
@@ -23,9 +23,7 @@
23/* #define DEBUG_IRQS */ 23/* #define DEBUG_IRQS */
24 24
25int baboon_present; 25int baboon_present;
26volatile struct baboon *baboon; 26static volatile struct baboon *baboon;
27
28irqreturn_t baboon_irq(int, void *);
29 27
30#if 0 28#if 0
31extern int macide_ack_intr(struct ata_channel *); 29extern int macide_ack_intr(struct ata_channel *);
@@ -50,20 +48,10 @@ void __init baboon_init(void)
50} 48}
51 49
52/* 50/*
53 * Register the Baboon interrupt dispatcher on nubus slot $C.
54 */
55
56void __init baboon_register_interrupts(void)
57{
58 request_irq(IRQ_NUBUS_C, baboon_irq, IRQ_FLG_LOCK|IRQ_FLG_FAST,
59 "baboon", (void *) baboon);
60}
61
62/*
63 * Baboon interrupt handler. This works a lot like a VIA. 51 * Baboon interrupt handler. This works a lot like a VIA.
64 */ 52 */
65 53
66irqreturn_t baboon_irq(int irq, void *dev_id) 54static irqreturn_t baboon_irq(int irq, void *dev_id)
67{ 55{
68 int irq_bit, irq_num; 56 int irq_bit, irq_num;
69 unsigned char events; 57 unsigned char events;
@@ -95,6 +83,16 @@ irqreturn_t baboon_irq(int irq, void *dev_id)
95 return IRQ_HANDLED; 83 return IRQ_HANDLED;
96} 84}
97 85
86/*
87 * Register the Baboon interrupt dispatcher on nubus slot $C.
88 */
89
90void __init baboon_register_interrupts(void)
91{
92 request_irq(IRQ_NUBUS_C, baboon_irq, IRQ_FLG_LOCK|IRQ_FLG_FAST,
93 "baboon", (void *) baboon);
94}
95
98void baboon_irq_enable(int irq) { 96void baboon_irq_enable(int irq) {
99#ifdef DEBUG_IRQUSE 97#ifdef DEBUG_IRQUSE
100 printk("baboon_irq_enable(%d)\n", irq); 98 printk("baboon_irq_enable(%d)\n", irq);
diff --git a/arch/m68k/mac/bootparse.c b/arch/m68k/mac/bootparse.c
deleted file mode 100644
index 36d223609823..000000000000
--- a/arch/m68k/mac/bootparse.c
+++ /dev/null
@@ -1,122 +0,0 @@
1#include <linux/string.h>
2#include <linux/kernel.h>
3#include <linux/sched.h>
4#include <asm/irq.h>
5#include <asm/setup.h>
6#include <asm/bootinfo.h>
7#include <asm/macintosh.h>
8
9/*
10 * Booter vars
11 */
12
13int boothowto;
14int _boothowto;
15
16/*
17 * Called early to parse the environment (passed to us from the booter)
18 * into a bootinfo struct. Will die as soon as we have our own booter
19 */
20
21#define atol(x) simple_strtoul(x,NULL,0)
22
23void parse_booter(char *env)
24{
25 char *name;
26 char *value;
27#if 0
28 while(0 && *env)
29#else
30 while(*env)
31#endif
32 {
33 name=env;
34 value=name;
35 while(*value!='='&&*value)
36 value++;
37 if(*value=='=')
38 *value++=0;
39 env=value;
40 while(*env)
41 env++;
42 env++;
43#if 0
44 if(strcmp(name,"VIDEO_ADDR")==0)
45 mac_mch.videoaddr=atol(value);
46 if(strcmp(name,"ROW_BYTES")==0)
47 mac_mch.videorow=atol(value);
48 if(strcmp(name,"SCREEN_DEPTH")==0)
49 mac_mch.videodepth=atol(value);
50 if(strcmp(name,"DIMENSIONS")==0)
51 mac_mch.dimensions=atol(value);
52#endif
53 if(strcmp(name,"BOOTTIME")==0)
54 mac_bi_data.boottime=atol(value);
55 if(strcmp(name,"GMTBIAS")==0)
56 mac_bi_data.gmtbias=atol(value);
57 if(strcmp(name,"BOOTERVER")==0)
58 mac_bi_data.bootver=atol(value);
59 if(strcmp(name,"MACOS_VIDEO")==0)
60 mac_bi_data.videological=atol(value);
61 if(strcmp(name,"MACOS_SCC")==0)
62 mac_bi_data.sccbase=atol(value);
63 if(strcmp(name,"MACHINEID")==0)
64 mac_bi_data.id=atol(value);
65 if(strcmp(name,"MEMSIZE")==0)
66 mac_bi_data.memsize=atol(value);
67 if(strcmp(name,"SERIAL_MODEM_FLAGS")==0)
68 mac_bi_data.serialmf=atol(value);
69 if(strcmp(name,"SERIAL_MODEM_HSKICLK")==0)
70 mac_bi_data.serialhsk=atol(value);
71 if(strcmp(name,"SERIAL_MODEM_GPICLK")==0)
72 mac_bi_data.serialgpi=atol(value);
73 if(strcmp(name,"SERIAL_PRINT_FLAGS")==0)
74 mac_bi_data.printmf=atol(value);
75 if(strcmp(name,"SERIAL_PRINT_HSKICLK")==0)
76 mac_bi_data.printhsk=atol(value);
77 if(strcmp(name,"SERIAL_PRINT_GPICLK")==0)
78 mac_bi_data.printgpi=atol(value);
79 if(strcmp(name,"PROCESSOR")==0)
80 mac_bi_data.cpuid=atol(value);
81 if(strcmp(name,"ROMBASE")==0)
82 mac_bi_data.rombase=atol(value);
83 if(strcmp(name,"TIMEDBRA")==0)
84 mac_bi_data.timedbra=atol(value);
85 if(strcmp(name,"ADBDELAY")==0)
86 mac_bi_data.adbdelay=atol(value);
87 }
88#if 0 /* XXX: TODO with m68k_mach_* */
89 /* Fill in the base stuff */
90 boot_info.machtype=MACH_MAC;
91 /* Read this from the macinfo we got ! */
92/* boot_info.cputype=CPU_68020|FPUB_68881;*/
93/* boot_info.memory[0].addr=0;*/
94/* boot_info.memory[0].size=((mac_bi_data.id>>7)&31)<<20;*/
95 boot_info.num_memory=1; /* On a MacII */
96 boot_info.ramdisk_size=0; /* For now */
97 *boot_info.command_line=0;
98#endif
99 }
100
101
102void print_booter(char *env)
103{
104 char *name;
105 char *value;
106 while(*env)
107 {
108 name=env;
109 value=name;
110 while(*value!='='&&*value)
111 value++;
112 if(*value=='=')
113 *value++=0;
114 env=value;
115 while(*env)
116 env++;
117 env++;
118 printk("%s=%s\n", name,value);
119 }
120 }
121
122
diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c
index ad3e3bacae39..c45e18449f32 100644
--- a/arch/m68k/mac/config.c
+++ b/arch/m68k/mac/config.c
@@ -46,7 +46,6 @@
46/* Mac bootinfo struct */ 46/* Mac bootinfo struct */
47 47
48struct mac_booter_data mac_bi_data; 48struct mac_booter_data mac_bi_data;
49int mac_bisize = sizeof mac_bi_data;
50 49
51/* New m68k bootinfo stuff and videobase */ 50/* New m68k bootinfo stuff and videobase */
52 51
@@ -55,10 +54,8 @@ extern struct mem_info m68k_memory[NUM_MEMINFO];
55 54
56extern struct mem_info m68k_ramdisk; 55extern struct mem_info m68k_ramdisk;
57 56
58void *mac_env; /* Loaded by the boot asm */
59
60/* The phys. video addr. - might be bogus on some machines */ 57/* The phys. video addr. - might be bogus on some machines */
61unsigned long mac_orig_videoaddr; 58static unsigned long mac_orig_videoaddr;
62 59
63/* Mac specific timer functions */ 60/* Mac specific timer functions */
64extern unsigned long mac_gettimeoffset(void); 61extern unsigned long mac_gettimeoffset(void);
@@ -79,6 +76,8 @@ extern void mac_mksound(unsigned int, unsigned int);
79extern void nubus_sweep_video(void); 76extern void nubus_sweep_video(void);
80 77
81static void mac_get_model(char *str); 78static void mac_get_model(char *str);
79static void mac_identify(void);
80static void mac_report_hardware(void);
82 81
83static void __init mac_sched_init(irq_handler_t vector) 82static void __init mac_sched_init(irq_handler_t vector)
84{ 83{
@@ -765,7 +764,7 @@ static struct mac_model mac_data_table[] = {
765 } 764 }
766}; 765};
767 766
768void __init mac_identify(void) 767static void __init mac_identify(void)
769{ 768{
770 struct mac_model *m; 769 struct mac_model *m;
771 770
@@ -821,7 +820,7 @@ void __init mac_identify(void)
821 baboon_init(); 820 baboon_init();
822} 821}
823 822
824void __init mac_report_hardware(void) 823static void __init mac_report_hardware(void)
825{ 824{
826 printk(KERN_INFO "Apple Macintosh %s\n", macintosh_config->name); 825 printk(KERN_INFO "Apple Macintosh %s\n", macintosh_config->name);
827} 826}
diff --git a/arch/m68k/mac/debug.c b/arch/m68k/mac/debug.c
index e8a57138b4a6..2165740786a5 100644
--- a/arch/m68k/mac/debug.c
+++ b/arch/m68k/mac/debug.c
@@ -51,6 +51,8 @@ extern void mac_serial_print(const char *);
51static int peng, line; 51static int peng, line;
52#endif 52#endif
53 53
54#if 0
55
54void mac_debugging_short(int pos, short num) 56void mac_debugging_short(int pos, short num)
55{ 57{
56#ifdef DEBUG_SCREEN 58#ifdef DEBUG_SCREEN
@@ -125,6 +127,8 @@ void mac_debugging_long(int pos, long addr)
125#endif 127#endif
126} 128}
127 129
130#endif /* 0 */
131
128#ifdef DEBUG_SERIAL 132#ifdef DEBUG_SERIAL
129/* 133/*
130 * TODO: serial debug code 134 * TODO: serial debug code
@@ -142,12 +146,6 @@ struct mac_SCC {
142 146
143# define scc (*((volatile struct mac_SCC*)mac_bi_data.sccbase)) 147# define scc (*((volatile struct mac_SCC*)mac_bi_data.sccbase))
144 148
145/* Flag that serial port is already initialized and used */
146int mac_SCC_init_done;
147/* Can be set somewhere, if a SCC master reset has already be done and should
148 * not be repeated; used by kgdb */
149int mac_SCC_reset_done;
150
151static int scc_port = -1; 149static int scc_port = -1;
152 150
153static struct console mac_console_driver = { 151static struct console mac_console_driver = {
@@ -171,8 +169,8 @@ static struct console mac_console_driver = {
171 * this driver if Mac. 169 * this driver if Mac.
172 */ 170 */
173 171
174void mac_debug_console_write(struct console *co, const char *str, 172static void mac_debug_console_write(struct console *co, const char *str,
175 unsigned int count) 173 unsigned int count)
176{ 174{
177 mac_serial_print(str); 175 mac_serial_print(str);
178} 176}
@@ -209,8 +207,8 @@ static inline void mac_scca_out(char c)
209 scc.cha_a_data = c; 207 scc.cha_a_data = c;
210} 208}
211 209
212void mac_sccb_console_write(struct console *co, const char *str, 210static void mac_sccb_console_write(struct console *co, const char *str,
213 unsigned int count) 211 unsigned int count)
214{ 212{
215 while (count--) { 213 while (count--) {
216 if (*str == '\n') 214 if (*str == '\n')
@@ -219,8 +217,8 @@ void mac_sccb_console_write(struct console *co, const char *str,
219 } 217 }
220} 218}
221 219
222void mac_scca_console_write(struct console *co, const char *str, 220static void mac_scca_console_write(struct console *co, const char *str,
223 unsigned int count) 221 unsigned int count)
224{ 222{
225 while (count--) { 223 while (count--) {
226 if (*str == '\n') 224 if (*str == '\n')
@@ -265,14 +263,8 @@ void mac_scca_console_write(struct console *co, const char *str,
265 barrier(); \ 263 barrier(); \
266 } while(0) 264 } while(0)
267 265
268#ifndef CONFIG_SERIAL_CONSOLE
269static void __init mac_init_scc_port(int cflag, int port) 266static void __init mac_init_scc_port(int cflag, int port)
270#else
271void mac_init_scc_port(int cflag, int port)
272#endif
273{ 267{
274 extern int mac_SCC_reset_done;
275
276 /* 268 /*
277 * baud rates: 1200, 1800, 2400, 4800, 9600, 19.2k, 38.4k, 57.6k, 115.2k 269 * baud rates: 1200, 1800, 2400, 4800, 9600, 19.2k, 38.4k, 57.6k, 115.2k
278 */ 270 */
@@ -340,22 +332,9 @@ void mac_init_scc_port(int cflag, int port)
340 SCCA_WRITE(3, reg3 | 1); 332 SCCA_WRITE(3, reg3 | 1);
341 SCCA_WRITE(5, reg5 | 8); 333 SCCA_WRITE(5, reg5 | 8);
342 } 334 }
343
344 mac_SCC_reset_done = 1;
345 mac_SCC_init_done = 1;
346} 335}
347#endif /* DEBUG_SERIAL */ 336#endif /* DEBUG_SERIAL */
348 337
349void mac_init_scca_port(int cflag)
350{
351 mac_init_scc_port(cflag, 0);
352}
353
354void mac_init_sccb_port(int cflag)
355{
356 mac_init_scc_port(cflag, 1);
357}
358
359static int __init mac_debug_setup(char *arg) 338static int __init mac_debug_setup(char *arg)
360{ 339{
361 if (!MACH_IS_MAC) 340 if (!MACH_IS_MAC)
diff --git a/arch/m68k/mac/oss.c b/arch/m68k/mac/oss.c
index 3c943d2ec570..43d83e054b8e 100644
--- a/arch/m68k/mac/oss.c
+++ b/arch/m68k/mac/oss.c
@@ -30,8 +30,8 @@
30int oss_present; 30int oss_present;
31volatile struct mac_oss *oss; 31volatile struct mac_oss *oss;
32 32
33irqreturn_t oss_irq(int, void *); 33static irqreturn_t oss_irq(int, void *);
34irqreturn_t oss_nubus_irq(int, void *); 34static irqreturn_t oss_nubus_irq(int, void *);
35 35
36extern irqreturn_t via1_irq(int, void *); 36extern irqreturn_t via1_irq(int, void *);
37extern irqreturn_t mac_scc_dispatch(int, void *); 37extern irqreturn_t mac_scc_dispatch(int, void *);
@@ -92,7 +92,7 @@ void __init oss_nubus_init(void)
92 * and SCSI; everything else is routed to its own autovector IRQ. 92 * and SCSI; everything else is routed to its own autovector IRQ.
93 */ 93 */
94 94
95irqreturn_t oss_irq(int irq, void *dev_id) 95static irqreturn_t oss_irq(int irq, void *dev_id)
96{ 96{
97 int events; 97 int events;
98 98
@@ -126,7 +126,7 @@ irqreturn_t oss_irq(int irq, void *dev_id)
126 * Unlike the VIA/RBV this is on its own autovector interrupt level. 126 * Unlike the VIA/RBV this is on its own autovector interrupt level.
127 */ 127 */
128 128
129irqreturn_t oss_nubus_irq(int irq, void *dev_id) 129static irqreturn_t oss_nubus_irq(int irq, void *dev_id)
130{ 130{
131 int events, irq_bit, i; 131 int events, irq_bit, i;
132 132
diff --git a/arch/m68k/mac/psc.c b/arch/m68k/mac/psc.c
index d66f723b17c3..f84a4dd64f94 100644
--- a/arch/m68k/mac/psc.c
+++ b/arch/m68k/mac/psc.c
@@ -36,7 +36,7 @@ irqreturn_t psc_irq(int, void *);
36 * Debugging dump, used in various places to see what's going on. 36 * Debugging dump, used in various places to see what's going on.
37 */ 37 */
38 38
39void psc_debug_dump(void) 39static void psc_debug_dump(void)
40{ 40{
41 int i; 41 int i;
42 42
@@ -55,7 +55,7 @@ void psc_debug_dump(void)
55 * expanded to cover what I think are the other 7 channels. 55 * expanded to cover what I think are the other 7 channels.
56 */ 56 */
57 57
58void psc_dma_die_die_die(void) 58static void psc_dma_die_die_die(void)
59{ 59{
60 int i; 60 int i;
61 61
diff --git a/arch/m68k/mac/via.c b/arch/m68k/mac/via.c
index fa485df4160e..f3b27d04a31f 100644
--- a/arch/m68k/mac/via.c
+++ b/arch/m68k/mac/via.c
@@ -45,7 +45,7 @@ volatile long *via_memory_bogon=(long *)&via_memory_bogon;
45int rbv_present; 45int rbv_present;
46int via_alt_mapping; 46int via_alt_mapping;
47EXPORT_SYMBOL(via_alt_mapping); 47EXPORT_SYMBOL(via_alt_mapping);
48__u8 rbv_clear; 48static __u8 rbv_clear;
49 49
50/* 50/*
51 * Globals for accessing the VIA chip registers without having to 51 * Globals for accessing the VIA chip registers without having to
diff --git a/arch/m68k/math-emu/Makefile b/arch/m68k/math-emu/Makefile
index 539940401814..a0935bf98362 100644
--- a/arch/m68k/math-emu/Makefile
+++ b/arch/m68k/math-emu/Makefile
@@ -2,8 +2,6 @@
2# Makefile for the linux kernel. 2# Makefile for the linux kernel.
3# 3#
4 4
5EXTRA_AFLAGS := -traditional
6
7#EXTRA_AFLAGS += -DFPU_EMU_DEBUG 5#EXTRA_AFLAGS += -DFPU_EMU_DEBUG
8#EXTRA_CFLAGS += -DFPU_EMU_DEBUG 6#EXTRA_CFLAGS += -DFPU_EMU_DEBUG
9 7
diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c
index 30d34f285024..226795bdf355 100644
--- a/arch/m68k/mm/motorola.c
+++ b/arch/m68k/mm/motorola.c
@@ -285,7 +285,6 @@ void __init paging_init(void)
285 * to a couple of allocated pages 285 * to a couple of allocated pages
286 */ 286 */
287 empty_zero_page = alloc_bootmem_pages(PAGE_SIZE); 287 empty_zero_page = alloc_bootmem_pages(PAGE_SIZE);
288 memset(empty_zero_page, 0, PAGE_SIZE);
289 288
290 /* 289 /*
291 * Set up SFC/DFC registers 290 * Set up SFC/DFC registers
diff --git a/arch/m68k/mm/sun3mmu.c b/arch/m68k/mm/sun3mmu.c
index 6a6513aa1ce8..edceefc18870 100644
--- a/arch/m68k/mm/sun3mmu.c
+++ b/arch/m68k/mm/sun3mmu.c
@@ -53,7 +53,6 @@ void __init paging_init(void)
53 wp_works_ok = 0; 53 wp_works_ok = 0;
54#endif 54#endif
55 empty_zero_page = alloc_bootmem_pages(PAGE_SIZE); 55 empty_zero_page = alloc_bootmem_pages(PAGE_SIZE);
56 memset(empty_zero_page, 0, PAGE_SIZE);
57 56
58 address = PAGE_OFFSET; 57 address = PAGE_OFFSET;
59 pg_dir = swapper_pg_dir; 58 pg_dir = swapper_pg_dir;
diff --git a/arch/m68k/q40/config.c b/arch/m68k/q40/config.c
index 476e18eca758..be9de2f3dc48 100644
--- a/arch/m68k/q40/config.c
+++ b/arch/m68k/q40/config.c
@@ -41,14 +41,12 @@ static void q40_get_model(char *model);
41static int q40_get_hardware_list(char *buffer); 41static int q40_get_hardware_list(char *buffer);
42extern void q40_sched_init(irq_handler_t handler); 42extern void q40_sched_init(irq_handler_t handler);
43 43
44extern unsigned long q40_gettimeoffset(void); 44static unsigned long q40_gettimeoffset(void);
45extern int q40_hwclk(int, struct rtc_time *); 45static int q40_hwclk(int, struct rtc_time *);
46extern unsigned int q40_get_ss(void); 46static unsigned int q40_get_ss(void);
47extern int q40_set_clock_mmss(unsigned long); 47static int q40_set_clock_mmss(unsigned long);
48static int q40_get_rtc_pll(struct rtc_pll_info *pll); 48static int q40_get_rtc_pll(struct rtc_pll_info *pll);
49static int q40_set_rtc_pll(struct rtc_pll_info *pll); 49static int q40_set_rtc_pll(struct rtc_pll_info *pll);
50extern void q40_reset(void);
51void q40_halt(void);
52extern void q40_waitbut(void); 50extern void q40_waitbut(void);
53void q40_set_vectors(void); 51void q40_set_vectors(void);
54 52
@@ -127,7 +125,7 @@ static void q40_heartbeat(int on)
127} 125}
128#endif 126#endif
129 127
130void q40_reset(void) 128static void q40_reset(void)
131{ 129{
132 halted = 1; 130 halted = 1;
133 printk("\n\n*******************************************\n" 131 printk("\n\n*******************************************\n"
@@ -137,7 +135,8 @@ void q40_reset(void)
137 while (1) 135 while (1)
138 ; 136 ;
139} 137}
140void q40_halt(void) 138
139static void q40_halt(void)
141{ 140{
142 halted = 1; 141 halted = 1;
143 printk("\n\n*******************\n" 142 printk("\n\n*******************\n"
@@ -165,7 +164,8 @@ static unsigned int serports[] =
165{ 164{
166 0x3f8,0x2f8,0x3e8,0x2e8,0 165 0x3f8,0x2f8,0x3e8,0x2e8,0
167}; 166};
168void q40_disable_irqs(void) 167
168static void q40_disable_irqs(void)
169{ 169{
170 unsigned i, j; 170 unsigned i, j;
171 171
@@ -227,7 +227,7 @@ static inline unsigned char bin2bcd(unsigned char b)
227} 227}
228 228
229 229
230unsigned long q40_gettimeoffset(void) 230static unsigned long q40_gettimeoffset(void)
231{ 231{
232 return 5000 * (ql_ticks != 0); 232 return 5000 * (ql_ticks != 0);
233} 233}
@@ -248,7 +248,7 @@ unsigned long q40_gettimeoffset(void)
248 * }; 248 * };
249 */ 249 */
250 250
251int q40_hwclk(int op, struct rtc_time *t) 251static int q40_hwclk(int op, struct rtc_time *t)
252{ 252{
253 if (op) { 253 if (op) {
254 /* Write.... */ 254 /* Write.... */
@@ -285,7 +285,7 @@ int q40_hwclk(int op, struct rtc_time *t)
285 return 0; 285 return 0;
286} 286}
287 287
288unsigned int q40_get_ss(void) 288static unsigned int q40_get_ss(void)
289{ 289{
290 return bcd2bin(Q40_RTC_SECS); 290 return bcd2bin(Q40_RTC_SECS);
291} 291}
@@ -295,7 +295,7 @@ unsigned int q40_get_ss(void)
295 * clock is out by > 30 minutes. Logic lifted from atari code. 295 * clock is out by > 30 minutes. Logic lifted from atari code.
296 */ 296 */
297 297
298int q40_set_clock_mmss(unsigned long nowtime) 298static int q40_set_clock_mmss(unsigned long nowtime)
299{ 299{
300 int retval = 0; 300 int retval = 0;
301 short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60; 301 short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60;
diff --git a/arch/m68k/sun3/Makefile b/arch/m68k/sun3/Makefile
index be1a8470d636..38ba0e0cedad 100644
--- a/arch/m68k/sun3/Makefile
+++ b/arch/m68k/sun3/Makefile
@@ -2,6 +2,6 @@
2# Makefile for Linux arch/m68k/sun3 source directory 2# Makefile for Linux arch/m68k/sun3 source directory
3# 3#
4 4
5obj-y := sun3ints.o sun3dvma.o sbus.o idprom.o 5obj-y := sun3ints.o sun3dvma.o idprom.o
6 6
7obj-$(CONFIG_SUN3) += config.o mmu_emu.o leds.o dvma.o intersil.o 7obj-$(CONFIG_SUN3) += config.o mmu_emu.o leds.o dvma.o intersil.o
diff --git a/arch/m68k/sun3/config.c b/arch/m68k/sun3/config.c
index c0fbd278fbb1..732087d0735c 100644
--- a/arch/m68k/sun3/config.c
+++ b/arch/m68k/sun3/config.c
@@ -36,7 +36,7 @@ extern char _text, _end;
36char sun3_reserved_pmeg[SUN3_PMEGS_NUM]; 36char sun3_reserved_pmeg[SUN3_PMEGS_NUM];
37 37
38extern unsigned long sun3_gettimeoffset(void); 38extern unsigned long sun3_gettimeoffset(void);
39extern void sun3_sched_init(irq_handler_t handler); 39static void sun3_sched_init(irq_handler_t handler);
40extern void sun3_get_model (char* model); 40extern void sun3_get_model (char* model);
41extern void idprom_init (void); 41extern void idprom_init (void);
42extern int sun3_hwclk(int set, struct rtc_time *t); 42extern int sun3_hwclk(int set, struct rtc_time *t);
@@ -114,7 +114,8 @@ static void sun3_halt (void)
114 114
115/* sun3 bootmem allocation */ 115/* sun3 bootmem allocation */
116 116
117void __init sun3_bootmem_alloc(unsigned long memory_start, unsigned long memory_end) 117static void __init sun3_bootmem_alloc(unsigned long memory_start,
118 unsigned long memory_end)
118{ 119{
119 unsigned long start_page; 120 unsigned long start_page;
120 121
@@ -164,7 +165,7 @@ void __init config_sun3(void)
164 sun3_bootmem_alloc(memory_start, memory_end); 165 sun3_bootmem_alloc(memory_start, memory_end);
165} 166}
166 167
167void __init sun3_sched_init(irq_handler_t timer_routine) 168static void __init sun3_sched_init(irq_handler_t timer_routine)
168{ 169{
169 sun3_disable_interrupts(); 170 sun3_disable_interrupts();
170 intersil_clock->cmd_reg=(INTERSIL_RUN|INTERSIL_INT_DISABLE|INTERSIL_24H_MODE); 171 intersil_clock->cmd_reg=(INTERSIL_RUN|INTERSIL_INT_DISABLE|INTERSIL_24H_MODE);
diff --git a/arch/m68k/sun3/dvma.c b/arch/m68k/sun3/dvma.c
index d2b3093f2405..d522eaab4551 100644
--- a/arch/m68k/sun3/dvma.c
+++ b/arch/m68k/sun3/dvma.c
@@ -19,7 +19,7 @@
19 19
20static unsigned long ptelist[120]; 20static unsigned long ptelist[120];
21 21
22inline unsigned long dvma_page(unsigned long kaddr, unsigned long vaddr) 22static unsigned long dvma_page(unsigned long kaddr, unsigned long vaddr)
23{ 23{
24 unsigned long pte; 24 unsigned long pte;
25 unsigned long j; 25 unsigned long j;
diff --git a/arch/m68k/sun3/idprom.c b/arch/m68k/sun3/idprom.c
index dca6ab6a4ede..c86ac37d1983 100644
--- a/arch/m68k/sun3/idprom.c
+++ b/arch/m68k/sun3/idprom.c
@@ -1,4 +1,4 @@
1/* $Id: idprom.c,v 1.22 1996/11/13 05:09:25 davem Exp $ 1/*
2 * idprom.c: Routines to load the idprom into kernel addresses and 2 * idprom.c: Routines to load the idprom into kernel addresses and
3 * interpret the data contained within. 3 * interpret the data contained within.
4 * 4 *
@@ -25,7 +25,7 @@ static struct idprom idprom_buffer;
25 * of the Sparc CPU and have a meaningful IDPROM machtype value that we 25 * of the Sparc CPU and have a meaningful IDPROM machtype value that we
26 * know about. See asm-sparc/machines.h for empirical constants. 26 * know about. See asm-sparc/machines.h for empirical constants.
27 */ 27 */
28struct Sun_Machine_Models Sun_Machines[NUM_SUN_MACHINES] = { 28static struct Sun_Machine_Models Sun_Machines[NUM_SUN_MACHINES] = {
29/* First, Sun3's */ 29/* First, Sun3's */
30 { .name = "Sun 3/160 Series", .id_machtype = (SM_SUN3 | SM_3_160) }, 30 { .name = "Sun 3/160 Series", .id_machtype = (SM_SUN3 | SM_3_160) },
31 { .name = "Sun 3/50", .id_machtype = (SM_SUN3 | SM_3_50) }, 31 { .name = "Sun 3/50", .id_machtype = (SM_SUN3 | SM_3_50) },
diff --git a/arch/m68k/sun3/mmu_emu.c b/arch/m68k/sun3/mmu_emu.c
index fb0f6a20cc3c..60f9d4500d72 100644
--- a/arch/m68k/sun3/mmu_emu.c
+++ b/arch/m68k/sun3/mmu_emu.c
@@ -55,7 +55,7 @@ unsigned char pmeg_ctx[PMEGS_NUM];
55 55
56/* pointers to the mm structs for each task in each 56/* pointers to the mm structs for each task in each
57 context. 0xffffffff is a marker for kernel context */ 57 context. 0xffffffff is a marker for kernel context */
58struct mm_struct *ctx_alloc[CONTEXTS_NUM] = { 58static struct mm_struct *ctx_alloc[CONTEXTS_NUM] = {
59 [0] = (struct mm_struct *)0xffffffff 59 [0] = (struct mm_struct *)0xffffffff
60}; 60};
61 61
diff --git a/arch/m68k/sun3/prom/Makefile b/arch/m68k/sun3/prom/Makefile
index 6e48ae2a7175..da7eac06bca0 100644
--- a/arch/m68k/sun3/prom/Makefile
+++ b/arch/m68k/sun3/prom/Makefile
@@ -1,4 +1,3 @@
1# $Id: Makefile,v 1.5 1995/11/25 00:59:48 davem Exp $
2# Makefile for the Sun Boot PROM interface library under 1# Makefile for the Sun Boot PROM interface library under
3# Linux. 2# Linux.
4# 3#
diff --git a/arch/m68k/sun3/prom/console.c b/arch/m68k/sun3/prom/console.c
index 52c1427863de..2bcb6e4bfe54 100644
--- a/arch/m68k/sun3/prom/console.c
+++ b/arch/m68k/sun3/prom/console.c
@@ -1,4 +1,4 @@
1/* $Id: console.c,v 1.10 1996/12/18 06:46:54 tridge Exp $ 1/*
2 * console.c: Routines that deal with sending and receiving IO 2 * console.c: Routines that deal with sending and receiving IO
3 * to/from the current console device using the PROM. 3 * to/from the current console device using the PROM.
4 * 4 *
@@ -104,8 +104,6 @@ prom_query_input_device()
104 return PROMDEV_ITTYB; 104 return PROMDEV_ITTYB;
105 } 105 }
106 return PROMDEV_I_UNK; 106 return PROMDEV_I_UNK;
107 case PROM_AP1000:
108 return PROMDEV_I_UNK;
109 }; 107 };
110} 108}
111#endif 109#endif
@@ -166,8 +164,6 @@ prom_query_output_device()
166 }; 164 };
167 } 165 }
168 break; 166 break;
169 case PROM_AP1000:
170 return PROMDEV_I_UNK;
171 }; 167 };
172 return PROMDEV_O_UNK; 168 return PROMDEV_O_UNK;
173} 169}
diff --git a/arch/m68k/sun3/prom/init.c b/arch/m68k/sun3/prom/init.c
index 202adfcc316e..d8e6349336b4 100644
--- a/arch/m68k/sun3/prom/init.c
+++ b/arch/m68k/sun3/prom/init.c
@@ -1,4 +1,4 @@
1/* $Id: init.c,v 1.9 1996/12/18 06:46:55 tridge Exp $ 1/*
2 * init.c: Initialize internal variables used by the PROM 2 * init.c: Initialize internal variables used by the PROM
3 * library functions. 3 * library functions.
4 * 4 *
@@ -31,11 +31,6 @@ extern void prom_ranges_init(void);
31 31
32void __init prom_init(struct linux_romvec *rp) 32void __init prom_init(struct linux_romvec *rp)
33{ 33{
34#ifdef CONFIG_AP1000
35 extern struct linux_romvec *ap_prom_init(void);
36 rp = ap_prom_init();
37#endif
38
39 romvec = rp; 34 romvec = rp;
40#ifndef CONFIG_SUN3 35#ifndef CONFIG_SUN3
41 switch(romvec->pv_romvers) { 36 switch(romvec->pv_romvers) {
@@ -53,10 +48,6 @@ void __init prom_init(struct linux_romvec *rp)
53 prom_printf("PROMLIB: Sun IEEE Prom not supported yet\n"); 48 prom_printf("PROMLIB: Sun IEEE Prom not supported yet\n");
54 prom_halt(); 49 prom_halt();
55 break; 50 break;
56 case 42: /* why not :-) */
57 prom_vers = PROM_AP1000;
58 break;
59
60 default: 51 default:
61 prom_printf("PROMLIB: Bad PROM version %d\n", 52 prom_printf("PROMLIB: Bad PROM version %d\n",
62 romvec->pv_romvers); 53 romvec->pv_romvers);
diff --git a/arch/m68k/sun3/prom/misc.c b/arch/m68k/sun3/prom/misc.c
index b88716f2c68c..3d60e1337f75 100644
--- a/arch/m68k/sun3/prom/misc.c
+++ b/arch/m68k/sun3/prom/misc.c
@@ -1,4 +1,4 @@
1/* $Id: misc.c,v 1.15 1997/05/14 20:45:00 davem Exp $ 1/*
2 * misc.c: Miscellaneous prom functions that don't belong 2 * misc.c: Miscellaneous prom functions that don't belong
3 * anywhere else. 3 * anywhere else.
4 * 4 *
diff --git a/arch/m68k/sun3/prom/printf.c b/arch/m68k/sun3/prom/printf.c
index e7bfde377b5e..df85018f487a 100644
--- a/arch/m68k/sun3/prom/printf.c
+++ b/arch/m68k/sun3/prom/printf.c
@@ -1,4 +1,4 @@
1/* $Id: printf.c,v 1.5 1996/04/04 16:31:07 tridge Exp $ 1/*
2 * printf.c: Internal prom library printf facility. 2 * printf.c: Internal prom library printf facility.
3 * 3 *
4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) 4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
@@ -37,10 +37,6 @@ prom_printf(char *fmt, ...)
37 37
38 bptr = ppbuf; 38 bptr = ppbuf;
39 39
40#ifdef CONFIG_AP1000
41 ap_write(1,bptr,strlen(bptr));
42#else
43
44#ifdef CONFIG_KGDB 40#ifdef CONFIG_KGDB
45 if (kgdb_initialized) { 41 if (kgdb_initialized) {
46 printk("kgdb_initialized = %d\n", kgdb_initialized); 42 printk("kgdb_initialized = %d\n", kgdb_initialized);
@@ -54,7 +50,6 @@ prom_printf(char *fmt, ...)
54 prom_putchar(ch); 50 prom_putchar(ch);
55 } 51 }
56#endif 52#endif
57#endif
58 va_end(args); 53 va_end(args);
59 return; 54 return;
60} 55}
diff --git a/arch/m68k/sun3/sbus.c b/arch/m68k/sun3/sbus.c
deleted file mode 100644
index babdbfa3cda7..000000000000
--- a/arch/m68k/sun3/sbus.c
+++ /dev/null
@@ -1,27 +0,0 @@
1/*
2 * SBus helper functions
3 *
4 * Sun3 don't have a sbus, but many of the used devices are also
5 * used on Sparc machines with sbus. To avoid having a lot of
6 * duplicate code, we provide necessary glue stuff to make using
7 * of the sbus driver code possible.
8 *
9 * (C) 1999 Thomas Bogendoerfer (tsbogend@alpha.franken.de)
10 */
11
12#include <linux/types.h>
13#include <linux/compiler.h>
14#include <linux/init.h>
15
16int __init sbus_init(void)
17{
18 return 0;
19}
20
21void *sparc_alloc_io (u32 address, void *virtual, int len, char *name,
22 u32 bus_type, int rdonly)
23{
24 return (void *)address;
25}
26
27subsys_initcall(sbus_init);
diff --git a/arch/m68k/sun3/sun3dvma.c b/arch/m68k/sun3/sun3dvma.c
index 8709677fa025..f9277e8b4159 100644
--- a/arch/m68k/sun3/sun3dvma.c
+++ b/arch/m68k/sun3/sun3dvma.c
@@ -29,7 +29,7 @@ static inline void dvma_unmap_iommu(unsigned long a, int b)
29extern void sun3_dvma_init(void); 29extern void sun3_dvma_init(void);
30#endif 30#endif
31 31
32unsigned long iommu_use[IOMMU_TOTAL_ENTRIES]; 32static unsigned long iommu_use[IOMMU_TOTAL_ENTRIES];
33 33
34#define dvma_index(baddr) ((baddr - DVMA_START) >> DVMA_PAGE_SHIFT) 34#define dvma_index(baddr) ((baddr - DVMA_START) >> DVMA_PAGE_SHIFT)
35 35
diff --git a/arch/m68k/sun3/sun3ints.c b/arch/m68k/sun3/sun3ints.c
index cf93481adb1d..7364cd67455e 100644
--- a/arch/m68k/sun3/sun3ints.c
+++ b/arch/m68k/sun3/sun3ints.c
@@ -30,7 +30,7 @@ void sun3_enable_interrupts(void)
30 sun3_enable_irq(0); 30 sun3_enable_irq(0);
31} 31}
32 32
33int led_pattern[8] = { 33static int led_pattern[8] = {
34 ~(0x80), ~(0x01), 34 ~(0x80), ~(0x01),
35 ~(0x40), ~(0x02), 35 ~(0x40), ~(0x02),
36 ~(0x20), ~(0x04), 36 ~(0x20), ~(0x04),
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index d21df5f1b1f3..b9c754f4070c 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -330,6 +330,7 @@ config SGI_IP22
330 select SGI_HAS_DS1286 330 select SGI_HAS_DS1286
331 select SGI_HAS_I8042 331 select SGI_HAS_I8042
332 select SGI_HAS_INDYDOG 332 select SGI_HAS_INDYDOG
333 select SGI_HAS_HAL2
333 select SGI_HAS_SEEQ 334 select SGI_HAS_SEEQ
334 select SGI_HAS_WD93 335 select SGI_HAS_WD93
335 select SGI_HAS_ZILOG 336 select SGI_HAS_ZILOG
@@ -386,7 +387,6 @@ config SGI_IP28
386 select SGI_HAS_I8042 387 select SGI_HAS_I8042
387 select SGI_HAS_INDYDOG 388 select SGI_HAS_INDYDOG
388 select SGI_HAS_HAL2 389 select SGI_HAS_HAL2
389 select SGI_HAS_HAL2
390 select SGI_HAS_SEEQ 390 select SGI_HAS_SEEQ
391 select SGI_HAS_WD93 391 select SGI_HAS_WD93
392 select SGI_HAS_ZILOG 392 select SGI_HAS_ZILOG
@@ -558,6 +558,24 @@ config MACH_TX39XX
558config MACH_TX49XX 558config MACH_TX49XX
559 bool "Toshiba TX49 series based machines" 559 bool "Toshiba TX49 series based machines"
560 560
561config MIKROTIK_RB532
562 bool "Mikrotik RB532 boards"
563 select CEVT_R4K
564 select CSRC_R4K
565 select DMA_NONCOHERENT
566 select GENERIC_HARDIRQS_NO__DO_IRQ
567 select HW_HAS_PCI
568 select IRQ_CPU
569 select SYS_HAS_CPU_MIPS32_R1
570 select SYS_SUPPORTS_32BIT_KERNEL
571 select SYS_SUPPORTS_LITTLE_ENDIAN
572 select SWAP_IO_SPACE
573 select BOOT_RAW
574 select GENERIC_GPIO
575 help
576 Support the Mikrotik(tm) RouterBoard 532 series,
577 based on the IDT RC32434 SoC.
578
561config WR_PPMC 579config WR_PPMC
562 bool "Wind River PPMC board" 580 bool "Wind River PPMC board"
563 select CEVT_R4K 581 select CEVT_R4K
@@ -899,7 +917,7 @@ config BOOT_ELF32
899 917
900config MIPS_L1_CACHE_SHIFT 918config MIPS_L1_CACHE_SHIFT
901 int 919 int
902 default "4" if MACH_DECSTATION 920 default "4" if MACH_DECSTATION || MIKROTIK_RB532
903 default "7" if SGI_IP22 || SGI_IP27 || SGI_IP28 || SNI_RM 921 default "7" if SGI_IP22 || SGI_IP27 || SGI_IP28 || SNI_RM
904 default "4" if PMC_MSP4200_EVAL 922 default "4" if PMC_MSP4200_EVAL
905 default "5" 923 default "5"
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 356453322b49..9aab51caf16a 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -560,6 +560,13 @@ load-$(CONFIG_MACH_TX49XX) += 0xffffffff80100000
560core-$(CONFIG_TOSHIBA_JMR3927) += arch/mips/txx9/jmr3927/ 560core-$(CONFIG_TOSHIBA_JMR3927) += arch/mips/txx9/jmr3927/
561 561
562# 562#
563# Routerboard 532 board
564#
565core-$(CONFIG_MIKROTIK_RB532) += arch/mips/rb532/
566cflags-$(CONFIG_MIKROTIK_RB532) += -Iinclude/asm-mips/mach-rc32434
567load-$(CONFIG_MIKROTIK_RB532) += 0xffffffff80101000
568
569#
563# Toshiba RBTX4927 board or 570# Toshiba RBTX4927 board or
564# Toshiba RBTX4937 board 571# Toshiba RBTX4937 board
565# 572#
diff --git a/arch/mips/cobalt/setup.c b/arch/mips/cobalt/setup.c
index dd23beb8604f..b51644227241 100644
--- a/arch/mips/cobalt/setup.c
+++ b/arch/mips/cobalt/setup.c
@@ -81,8 +81,8 @@ void __init plat_mem_setup(void)
81 81
82 set_io_port_base(CKSEG1ADDR(GT_DEF_PCI0_IO_BASE)); 82 set_io_port_base(CKSEG1ADDR(GT_DEF_PCI0_IO_BASE));
83 83
84 /* I/O port resource must include LCD/buttons */ 84 /* I/O port resource */
85 ioport_resource.end = 0x0fffffff; 85 ioport_resource.end = 0x01ffffff;
86 86
87 /* These resources have been reserved by VIA SuperI/O chip. */ 87 /* These resources have been reserved by VIA SuperI/O chip. */
88 for (i = 0; i < ARRAY_SIZE(cobalt_reserved_resources); i++) 88 for (i = 0; i < ARRAY_SIZE(cobalt_reserved_resources); i++)
diff --git a/arch/mips/configs/rb532_defconfig b/arch/mips/configs/rb532_defconfig
new file mode 100644
index 000000000000..f28dc32974e5
--- /dev/null
+++ b/arch/mips/configs/rb532_defconfig
@@ -0,0 +1,1314 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.25
4# Mon Apr 28 12:24:17 2008
5#
6CONFIG_MIPS=y
7
8#
9# Machine selection
10#
11# CONFIG_MACH_ALCHEMY is not set
12# CONFIG_BASLER_EXCITE is not set
13# CONFIG_BCM47XX is not set
14# CONFIG_MIPS_COBALT is not set
15# CONFIG_MACH_DECSTATION is not set
16# CONFIG_MACH_JAZZ is not set
17# CONFIG_LASAT is not set
18# CONFIG_LEMOTE_FULONG is not set
19# CONFIG_MIPS_ATLAS is not set
20# CONFIG_MIPS_MALTA is not set
21# CONFIG_MIPS_SEAD is not set
22# CONFIG_MIPS_SIM is not set
23# CONFIG_MARKEINS is not set
24# CONFIG_MACH_VR41XX is not set
25# CONFIG_PNX8550_JBS is not set
26# CONFIG_PNX8550_STB810 is not set
27# CONFIG_PMC_MSP is not set
28# CONFIG_PMC_YOSEMITE is not set
29# CONFIG_SGI_IP22 is not set
30# CONFIG_SGI_IP27 is not set
31# CONFIG_SGI_IP28 is not set
32# CONFIG_SGI_IP32 is not set
33# CONFIG_SIBYTE_CRHINE is not set
34# CONFIG_SIBYTE_CARMEL is not set
35# CONFIG_SIBYTE_CRHONE is not set
36# CONFIG_SIBYTE_RHONE is not set
37# CONFIG_SIBYTE_SWARM is not set
38# CONFIG_SIBYTE_LITTLESUR is not set
39# CONFIG_SIBYTE_SENTOSA is not set
40# CONFIG_SIBYTE_BIGSUR is not set
41# CONFIG_SNI_RM is not set
42# CONFIG_TOSHIBA_JMR3927 is not set
43CONFIG_MIKROTIK_RB532=y
44# CONFIG_TOSHIBA_RBTX4927 is not set
45# CONFIG_TOSHIBA_RBTX4938 is not set
46# CONFIG_WR_PPMC is not set
47CONFIG_RWSEM_GENERIC_SPINLOCK=y
48# CONFIG_ARCH_HAS_ILOG2_U32 is not set
49# CONFIG_ARCH_HAS_ILOG2_U64 is not set
50CONFIG_ARCH_SUPPORTS_OPROFILE=y
51CONFIG_GENERIC_FIND_NEXT_BIT=y
52CONFIG_GENERIC_HWEIGHT=y
53CONFIG_GENERIC_CALIBRATE_DELAY=y
54CONFIG_GENERIC_CLOCKEVENTS=y
55CONFIG_GENERIC_TIME=y
56CONFIG_GENERIC_CMOS_UPDATE=y
57CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
58CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
59CONFIG_BOOT_RAW=y
60CONFIG_CEVT_R4K=y
61CONFIG_CSRC_R4K=y
62CONFIG_DMA_NONCOHERENT=y
63CONFIG_DMA_NEED_PCI_MAP_STATE=y
64# CONFIG_HOTPLUG_CPU is not set
65# CONFIG_NO_IOPORT is not set
66CONFIG_GENERIC_GPIO=y
67# CONFIG_CPU_BIG_ENDIAN is not set
68CONFIG_CPU_LITTLE_ENDIAN=y
69CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
70CONFIG_IRQ_CPU=y
71CONFIG_SWAP_IO_SPACE=y
72CONFIG_MIPS_L1_CACHE_SHIFT=4
73
74#
75# CPU selection
76#
77# CONFIG_CPU_LOONGSON2 is not set
78CONFIG_CPU_MIPS32_R1=y
79# CONFIG_CPU_MIPS32_R2 is not set
80# CONFIG_CPU_MIPS64_R1 is not set
81# CONFIG_CPU_MIPS64_R2 is not set
82# CONFIG_CPU_R3000 is not set
83# CONFIG_CPU_TX39XX is not set
84# CONFIG_CPU_VR41XX is not set
85# CONFIG_CPU_R4300 is not set
86# CONFIG_CPU_R4X00 is not set
87# CONFIG_CPU_TX49XX is not set
88# CONFIG_CPU_R5000 is not set
89# CONFIG_CPU_R5432 is not set
90# CONFIG_CPU_R6000 is not set
91# CONFIG_CPU_NEVADA is not set
92# CONFIG_CPU_R8000 is not set
93# CONFIG_CPU_R10000 is not set
94# CONFIG_CPU_RM7000 is not set
95# CONFIG_CPU_RM9000 is not set
96# CONFIG_CPU_SB1 is not set
97CONFIG_SYS_HAS_CPU_MIPS32_R1=y
98CONFIG_CPU_MIPS32=y
99CONFIG_CPU_MIPSR1=y
100CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
101CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
102
103#
104# Kernel type
105#
106CONFIG_32BIT=y
107# CONFIG_64BIT is not set
108CONFIG_PAGE_SIZE_4KB=y
109# CONFIG_PAGE_SIZE_8KB is not set
110# CONFIG_PAGE_SIZE_16KB is not set
111# CONFIG_PAGE_SIZE_64KB is not set
112CONFIG_CPU_HAS_PREFETCH=y
113CONFIG_MIPS_MT_DISABLED=y
114# CONFIG_MIPS_MT_SMP is not set
115# CONFIG_MIPS_MT_SMTC is not set
116CONFIG_CPU_HAS_LLSC=y
117CONFIG_CPU_HAS_SYNC=y
118CONFIG_GENERIC_HARDIRQS=y
119CONFIG_GENERIC_IRQ_PROBE=y
120CONFIG_CPU_SUPPORTS_HIGHMEM=y
121CONFIG_ARCH_FLATMEM_ENABLE=y
122CONFIG_ARCH_POPULATES_NODE_MAP=y
123CONFIG_SELECT_MEMORY_MODEL=y
124CONFIG_FLATMEM_MANUAL=y
125# CONFIG_DISCONTIGMEM_MANUAL is not set
126# CONFIG_SPARSEMEM_MANUAL is not set
127CONFIG_FLATMEM=y
128CONFIG_FLAT_NODE_MEM_MAP=y
129# CONFIG_SPARSEMEM_STATIC is not set
130# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
131CONFIG_SPLIT_PTLOCK_CPUS=4
132# CONFIG_RESOURCES_64BIT is not set
133CONFIG_ZONE_DMA_FLAG=0
134CONFIG_VIRT_TO_BUS=y
135CONFIG_TICK_ONESHOT=y
136CONFIG_NO_HZ=y
137CONFIG_HIGH_RES_TIMERS=y
138CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
139# CONFIG_HZ_48 is not set
140CONFIG_HZ_100=y
141# CONFIG_HZ_128 is not set
142# CONFIG_HZ_250 is not set
143# CONFIG_HZ_256 is not set
144# CONFIG_HZ_1000 is not set
145# CONFIG_HZ_1024 is not set
146CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
147CONFIG_HZ=100
148CONFIG_PREEMPT_NONE=y
149# CONFIG_PREEMPT_VOLUNTARY is not set
150# CONFIG_PREEMPT is not set
151# CONFIG_KEXEC is not set
152# CONFIG_SECCOMP is not set
153CONFIG_LOCKDEP_SUPPORT=y
154CONFIG_STACKTRACE_SUPPORT=y
155CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
156
157#
158# General setup
159#
160CONFIG_EXPERIMENTAL=y
161CONFIG_BROKEN_ON_SMP=y
162CONFIG_INIT_ENV_ARG_LIMIT=32
163CONFIG_LOCALVERSION=""
164# CONFIG_LOCALVERSION_AUTO is not set
165CONFIG_SWAP=y
166CONFIG_SYSVIPC=y
167CONFIG_SYSVIPC_SYSCTL=y
168# CONFIG_POSIX_MQUEUE is not set
169CONFIG_BSD_PROCESS_ACCT=y
170# CONFIG_BSD_PROCESS_ACCT_V3 is not set
171# CONFIG_TASKSTATS is not set
172# CONFIG_AUDIT is not set
173CONFIG_IKCONFIG=y
174CONFIG_IKCONFIG_PROC=y
175CONFIG_LOG_BUF_SHIFT=14
176# CONFIG_CGROUPS is not set
177CONFIG_GROUP_SCHED=y
178CONFIG_FAIR_GROUP_SCHED=y
179# CONFIG_RT_GROUP_SCHED is not set
180CONFIG_USER_SCHED=y
181# CONFIG_CGROUP_SCHED is not set
182CONFIG_SYSFS_DEPRECATED=y
183CONFIG_SYSFS_DEPRECATED_V2=y
184# CONFIG_RELAY is not set
185# CONFIG_NAMESPACES is not set
186CONFIG_BLK_DEV_INITRD=y
187CONFIG_INITRAMFS_SOURCE=""
188CONFIG_CC_OPTIMIZE_FOR_SIZE=y
189CONFIG_SYSCTL=y
190CONFIG_EMBEDDED=y
191CONFIG_SYSCTL_SYSCALL=y
192# CONFIG_KALLSYMS is not set
193CONFIG_HOTPLUG=y
194CONFIG_PRINTK=y
195CONFIG_BUG=y
196# CONFIG_ELF_CORE is not set
197CONFIG_COMPAT_BRK=y
198CONFIG_BASE_FULL=y
199CONFIG_FUTEX=y
200CONFIG_ANON_INODES=y
201CONFIG_EPOLL=y
202CONFIG_SIGNALFD=y
203CONFIG_TIMERFD=y
204CONFIG_EVENTFD=y
205CONFIG_SHMEM=y
206# CONFIG_VM_EVENT_COUNTERS is not set
207CONFIG_SLAB=y
208# CONFIG_SLUB is not set
209# CONFIG_SLOB is not set
210# CONFIG_PROFILING is not set
211# CONFIG_MARKERS is not set
212CONFIG_HAVE_OPROFILE=y
213# CONFIG_HAVE_KPROBES is not set
214# CONFIG_HAVE_KRETPROBES is not set
215CONFIG_PROC_PAGE_MONITOR=y
216CONFIG_SLABINFO=y
217CONFIG_RT_MUTEXES=y
218# CONFIG_TINY_SHMEM is not set
219CONFIG_BASE_SMALL=0
220CONFIG_MODULES=y
221CONFIG_MODULE_UNLOAD=y
222# CONFIG_MODULE_FORCE_UNLOAD is not set
223# CONFIG_MODVERSIONS is not set
224# CONFIG_MODULE_SRCVERSION_ALL is not set
225# CONFIG_KMOD is not set
226CONFIG_BLOCK=y
227# CONFIG_LBD is not set
228# CONFIG_BLK_DEV_IO_TRACE is not set
229# CONFIG_LSF is not set
230# CONFIG_BLK_DEV_BSG is not set
231
232#
233# IO Schedulers
234#
235CONFIG_IOSCHED_NOOP=y
236# CONFIG_IOSCHED_AS is not set
237CONFIG_IOSCHED_DEADLINE=y
238# CONFIG_IOSCHED_CFQ is not set
239# CONFIG_DEFAULT_AS is not set
240CONFIG_DEFAULT_DEADLINE=y
241# CONFIG_DEFAULT_CFQ is not set
242# CONFIG_DEFAULT_NOOP is not set
243CONFIG_DEFAULT_IOSCHED="deadline"
244CONFIG_CLASSIC_RCU=y
245
246#
247# Bus options (PCI, PCMCIA, EISA, ISA, TC)
248#
249CONFIG_HW_HAS_PCI=y
250CONFIG_PCI=y
251CONFIG_PCI_DOMAINS=y
252# CONFIG_ARCH_SUPPORTS_MSI is not set
253CONFIG_PCI_LEGACY=y
254CONFIG_MMU=y
255# CONFIG_PCCARD is not set
256# CONFIG_HOTPLUG_PCI is not set
257
258#
259# Executable file formats
260#
261CONFIG_BINFMT_ELF=y
262# CONFIG_BINFMT_MISC is not set
263CONFIG_TRAD_SIGNALS=y
264
265#
266# Power management options
267#
268CONFIG_ARCH_SUSPEND_POSSIBLE=y
269# CONFIG_PM is not set
270
271#
272# Networking
273#
274CONFIG_NET=y
275
276#
277# Networking options
278#
279CONFIG_PACKET=y
280CONFIG_PACKET_MMAP=y
281CONFIG_UNIX=y
282# CONFIG_NET_KEY is not set
283CONFIG_INET=y
284CONFIG_IP_MULTICAST=y
285CONFIG_IP_ADVANCED_ROUTER=y
286CONFIG_ASK_IP_FIB_HASH=y
287# CONFIG_IP_FIB_TRIE is not set
288CONFIG_IP_FIB_HASH=y
289CONFIG_IP_MULTIPLE_TABLES=y
290CONFIG_IP_ROUTE_MULTIPATH=y
291CONFIG_IP_ROUTE_VERBOSE=y
292# CONFIG_IP_PNP is not set
293# CONFIG_NET_IPIP is not set
294# CONFIG_NET_IPGRE is not set
295# CONFIG_IP_MROUTE is not set
296CONFIG_ARPD=y
297CONFIG_SYN_COOKIES=y
298# CONFIG_INET_AH is not set
299# CONFIG_INET_ESP is not set
300# CONFIG_INET_IPCOMP is not set
301# CONFIG_INET_XFRM_TUNNEL is not set
302# CONFIG_INET_TUNNEL is not set
303# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
304# CONFIG_INET_XFRM_MODE_TUNNEL is not set
305# CONFIG_INET_XFRM_MODE_BEET is not set
306# CONFIG_INET_LRO is not set
307CONFIG_INET_DIAG=m
308CONFIG_INET_TCP_DIAG=m
309CONFIG_TCP_CONG_ADVANCED=y
310CONFIG_TCP_CONG_BIC=m
311CONFIG_TCP_CONG_CUBIC=m
312CONFIG_TCP_CONG_WESTWOOD=m
313CONFIG_TCP_CONG_HTCP=m
314CONFIG_TCP_CONG_HSTCP=m
315CONFIG_TCP_CONG_HYBLA=m
316CONFIG_TCP_CONG_VEGAS=y
317CONFIG_TCP_CONG_SCALABLE=m
318CONFIG_TCP_CONG_LP=m
319CONFIG_TCP_CONG_VENO=m
320CONFIG_TCP_CONG_YEAH=m
321CONFIG_TCP_CONG_ILLINOIS=m
322# CONFIG_DEFAULT_BIC is not set
323# CONFIG_DEFAULT_CUBIC is not set
324# CONFIG_DEFAULT_HTCP is not set
325CONFIG_DEFAULT_VEGAS=y
326# CONFIG_DEFAULT_WESTWOOD is not set
327# CONFIG_DEFAULT_RENO is not set
328CONFIG_DEFAULT_TCP_CONG="vegas"
329# CONFIG_TCP_MD5SIG is not set
330# CONFIG_IP_VS is not set
331# CONFIG_IPV6 is not set
332# CONFIG_NETWORK_SECMARK is not set
333CONFIG_NETFILTER=y
334# CONFIG_NETFILTER_DEBUG is not set
335CONFIG_NETFILTER_ADVANCED=y
336# CONFIG_BRIDGE_NETFILTER is not set
337
338#
339# Core Netfilter Configuration
340#
341# CONFIG_NETFILTER_NETLINK_QUEUE is not set
342# CONFIG_NETFILTER_NETLINK_LOG is not set
343CONFIG_NF_CONNTRACK=y
344CONFIG_NF_CT_ACCT=y
345CONFIG_NF_CONNTRACK_MARK=y
346# CONFIG_NF_CONNTRACK_EVENTS is not set
347# CONFIG_NF_CT_PROTO_DCCP is not set
348# CONFIG_NF_CT_PROTO_SCTP is not set
349# CONFIG_NF_CT_PROTO_UDPLITE is not set
350# CONFIG_NF_CONNTRACK_AMANDA is not set
351CONFIG_NF_CONNTRACK_FTP=m
352# CONFIG_NF_CONNTRACK_H323 is not set
353CONFIG_NF_CONNTRACK_IRC=m
354# CONFIG_NF_CONNTRACK_NETBIOS_NS is not set
355# CONFIG_NF_CONNTRACK_PPTP is not set
356# CONFIG_NF_CONNTRACK_SANE is not set
357# CONFIG_NF_CONNTRACK_SIP is not set
358CONFIG_NF_CONNTRACK_TFTP=m
359# CONFIG_NF_CT_NETLINK is not set
360CONFIG_NETFILTER_XTABLES=y
361# CONFIG_NETFILTER_XT_TARGET_CLASSIFY is not set
362# CONFIG_NETFILTER_XT_TARGET_CONNMARK is not set
363# CONFIG_NETFILTER_XT_TARGET_DSCP is not set
364# CONFIG_NETFILTER_XT_TARGET_MARK is not set
365CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m
366CONFIG_NETFILTER_XT_TARGET_NFLOG=m
367# CONFIG_NETFILTER_XT_TARGET_NOTRACK is not set
368# CONFIG_NETFILTER_XT_TARGET_RATEEST is not set
369CONFIG_NETFILTER_XT_TARGET_TRACE=m
370# CONFIG_NETFILTER_XT_TARGET_TCPMSS is not set
371# CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP is not set
372CONFIG_NETFILTER_XT_MATCH_COMMENT=m
373# CONFIG_NETFILTER_XT_MATCH_CONNBYTES is not set
374CONFIG_NETFILTER_XT_MATCH_CONNLIMIT=m
375# CONFIG_NETFILTER_XT_MATCH_CONNMARK is not set
376# CONFIG_NETFILTER_XT_MATCH_CONNTRACK is not set
377CONFIG_NETFILTER_XT_MATCH_DCCP=m
378# CONFIG_NETFILTER_XT_MATCH_DSCP is not set
379# CONFIG_NETFILTER_XT_MATCH_ESP is not set
380# CONFIG_NETFILTER_XT_MATCH_HELPER is not set
381# CONFIG_NETFILTER_XT_MATCH_IPRANGE is not set
382# CONFIG_NETFILTER_XT_MATCH_LENGTH is not set
383CONFIG_NETFILTER_XT_MATCH_LIMIT=y
384# CONFIG_NETFILTER_XT_MATCH_MAC is not set
385# CONFIG_NETFILTER_XT_MATCH_MARK is not set
386# CONFIG_NETFILTER_XT_MATCH_OWNER is not set
387CONFIG_NETFILTER_XT_MATCH_MULTIPORT=y
388# CONFIG_NETFILTER_XT_MATCH_PKTTYPE is not set
389# CONFIG_NETFILTER_XT_MATCH_QUOTA is not set
390# CONFIG_NETFILTER_XT_MATCH_RATEEST is not set
391CONFIG_NETFILTER_XT_MATCH_REALM=m
392CONFIG_NETFILTER_XT_MATCH_SCTP=m
393CONFIG_NETFILTER_XT_MATCH_STATE=y
394# CONFIG_NETFILTER_XT_MATCH_STATISTIC is not set
395# CONFIG_NETFILTER_XT_MATCH_STRING is not set
396# CONFIG_NETFILTER_XT_MATCH_TCPMSS is not set
397# CONFIG_NETFILTER_XT_MATCH_TIME is not set
398CONFIG_NETFILTER_XT_MATCH_U32=m
399CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=m
400
401#
402# IP: Netfilter Configuration
403#
404CONFIG_NF_CONNTRACK_IPV4=y
405CONFIG_NF_CONNTRACK_PROC_COMPAT=y
406# CONFIG_IP_NF_QUEUE is not set
407CONFIG_IP_NF_IPTABLES=y
408# CONFIG_IP_NF_MATCH_RECENT is not set
409# CONFIG_IP_NF_MATCH_ECN is not set
410# CONFIG_IP_NF_MATCH_AH is not set
411# CONFIG_IP_NF_MATCH_TTL is not set
412CONFIG_IP_NF_MATCH_ADDRTYPE=m
413CONFIG_IP_NF_FILTER=y
414CONFIG_IP_NF_TARGET_REJECT=y
415# CONFIG_IP_NF_TARGET_LOG is not set
416# CONFIG_IP_NF_TARGET_ULOG is not set
417CONFIG_NF_NAT=y
418CONFIG_NF_NAT_NEEDED=y
419CONFIG_IP_NF_TARGET_MASQUERADE=y
420# CONFIG_IP_NF_TARGET_REDIRECT is not set
421# CONFIG_IP_NF_TARGET_NETMAP is not set
422# CONFIG_NF_NAT_SNMP_BASIC is not set
423CONFIG_NF_NAT_FTP=m
424CONFIG_NF_NAT_IRC=m
425CONFIG_NF_NAT_TFTP=m
426# CONFIG_NF_NAT_AMANDA is not set
427# CONFIG_NF_NAT_PPTP is not set
428# CONFIG_NF_NAT_H323 is not set
429# CONFIG_NF_NAT_SIP is not set
430CONFIG_IP_NF_MANGLE=y
431# CONFIG_IP_NF_TARGET_ECN is not set
432# CONFIG_IP_NF_TARGET_TTL is not set
433# CONFIG_IP_NF_TARGET_CLUSTERIP is not set
434CONFIG_IP_NF_RAW=m
435# CONFIG_IP_NF_ARPTABLES is not set
436# CONFIG_IP_DCCP is not set
437# CONFIG_IP_SCTP is not set
438# CONFIG_TIPC is not set
439# CONFIG_ATM is not set
440CONFIG_BRIDGE=y
441CONFIG_VLAN_8021Q=y
442# CONFIG_DECNET is not set
443CONFIG_LLC=y
444CONFIG_LLC2=m
445# CONFIG_IPX is not set
446# CONFIG_ATALK is not set
447# CONFIG_X25 is not set
448# CONFIG_LAPB is not set
449# CONFIG_ECONET is not set
450# CONFIG_WAN_ROUTER is not set
451CONFIG_NET_SCHED=y
452
453#
454# Queueing/Scheduling
455#
456CONFIG_NET_SCH_CBQ=m
457# CONFIG_NET_SCH_HTB is not set
458# CONFIG_NET_SCH_HFSC is not set
459CONFIG_NET_SCH_PRIO=m
460CONFIG_NET_SCH_RR=m
461# CONFIG_NET_SCH_RED is not set
462# CONFIG_NET_SCH_SFQ is not set
463# CONFIG_NET_SCH_TEQL is not set
464# CONFIG_NET_SCH_TBF is not set
465# CONFIG_NET_SCH_GRED is not set
466# CONFIG_NET_SCH_DSMARK is not set
467CONFIG_NET_SCH_NETEM=m
468# CONFIG_NET_SCH_INGRESS is not set
469
470#
471# Classification
472#
473CONFIG_NET_CLS=y
474CONFIG_NET_CLS_BASIC=m
475CONFIG_NET_CLS_TCINDEX=m
476CONFIG_NET_CLS_ROUTE4=m
477CONFIG_NET_CLS_ROUTE=y
478CONFIG_NET_CLS_FW=m
479CONFIG_NET_CLS_U32=m
480CONFIG_CLS_U32_PERF=y
481CONFIG_CLS_U32_MARK=y
482CONFIG_NET_CLS_RSVP=m
483CONFIG_NET_CLS_RSVP6=m
484# CONFIG_NET_CLS_FLOW is not set
485CONFIG_NET_EMATCH=y
486CONFIG_NET_EMATCH_STACK=32
487CONFIG_NET_EMATCH_CMP=m
488CONFIG_NET_EMATCH_NBYTE=m
489CONFIG_NET_EMATCH_U32=m
490CONFIG_NET_EMATCH_META=m
491CONFIG_NET_EMATCH_TEXT=m
492CONFIG_NET_CLS_ACT=y
493CONFIG_NET_ACT_POLICE=y
494CONFIG_NET_ACT_GACT=m
495CONFIG_GACT_PROB=y
496CONFIG_NET_ACT_MIRRED=m
497CONFIG_NET_ACT_IPT=m
498# CONFIG_NET_ACT_NAT is not set
499CONFIG_NET_ACT_PEDIT=m
500# CONFIG_NET_ACT_SIMP is not set
501CONFIG_NET_CLS_IND=y
502CONFIG_NET_SCH_FIFO=y
503
504#
505# Network testing
506#
507# CONFIG_NET_PKTGEN is not set
508CONFIG_HAMRADIO=y
509
510#
511# Packet Radio protocols
512#
513# CONFIG_AX25 is not set
514# CONFIG_CAN is not set
515# CONFIG_IRDA is not set
516# CONFIG_BT is not set
517# CONFIG_AF_RXRPC is not set
518CONFIG_FIB_RULES=y
519
520#
521# Wireless
522#
523# CONFIG_CFG80211 is not set
524CONFIG_WIRELESS_EXT=y
525# CONFIG_MAC80211 is not set
526# CONFIG_IEEE80211 is not set
527# CONFIG_RFKILL is not set
528# CONFIG_NET_9P is not set
529
530#
531# Device Drivers
532#
533
534#
535# Generic Driver Options
536#
537CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
538CONFIG_STANDALONE=y
539CONFIG_PREVENT_FIRMWARE_BUILD=y
540CONFIG_FW_LOADER=y
541# CONFIG_SYS_HYPERVISOR is not set
542# CONFIG_CONNECTOR is not set
543CONFIG_MTD=y
544# CONFIG_MTD_DEBUG is not set
545# CONFIG_MTD_CONCAT is not set
546CONFIG_MTD_PARTITIONS=y
547# CONFIG_MTD_REDBOOT_PARTS is not set
548# CONFIG_MTD_CMDLINE_PARTS is not set
549# CONFIG_MTD_AR7_PARTS is not set
550
551#
552# User Modules And Translation Layers
553#
554CONFIG_MTD_CHAR=y
555CONFIG_MTD_BLKDEVS=y
556CONFIG_MTD_BLOCK=y
557# CONFIG_FTL is not set
558# CONFIG_NFTL is not set
559# CONFIG_INFTL is not set
560# CONFIG_RFD_FTL is not set
561# CONFIG_SSFDC is not set
562# CONFIG_MTD_OOPS is not set
563
564#
565# RAM/ROM/Flash chip drivers
566#
567# CONFIG_MTD_CFI is not set
568# CONFIG_MTD_JEDECPROBE is not set
569CONFIG_MTD_MAP_BANK_WIDTH_1=y
570CONFIG_MTD_MAP_BANK_WIDTH_2=y
571CONFIG_MTD_MAP_BANK_WIDTH_4=y
572# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
573# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
574# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
575CONFIG_MTD_CFI_I1=y
576CONFIG_MTD_CFI_I2=y
577# CONFIG_MTD_CFI_I4 is not set
578# CONFIG_MTD_CFI_I8 is not set
579# CONFIG_MTD_RAM is not set
580# CONFIG_MTD_ROM is not set
581# CONFIG_MTD_ABSENT is not set
582
583#
584# Mapping drivers for chip access
585#
586# CONFIG_MTD_COMPLEX_MAPPINGS is not set
587# CONFIG_MTD_INTEL_VR_NOR is not set
588# CONFIG_MTD_PLATRAM is not set
589
590#
591# Self-contained MTD device drivers
592#
593# CONFIG_MTD_PMC551 is not set
594# CONFIG_MTD_SLRAM is not set
595# CONFIG_MTD_PHRAM is not set
596# CONFIG_MTD_MTDRAM is not set
597CONFIG_MTD_BLOCK2MTD=y
598
599#
600# Disk-On-Chip Device Drivers
601#
602# CONFIG_MTD_DOC2000 is not set
603# CONFIG_MTD_DOC2001 is not set
604# CONFIG_MTD_DOC2001PLUS is not set
605CONFIG_MTD_NAND=y
606CONFIG_MTD_NAND_VERIFY_WRITE=y
607# CONFIG_MTD_NAND_ECC_SMC is not set
608# CONFIG_MTD_NAND_MUSEUM_IDS is not set
609CONFIG_MTD_NAND_IDS=y
610# CONFIG_MTD_NAND_DISKONCHIP is not set
611# CONFIG_MTD_NAND_CAFE is not set
612# CONFIG_MTD_NAND_NANDSIM is not set
613CONFIG_MTD_NAND_PLATFORM=y
614# CONFIG_MTD_ONENAND is not set
615
616#
617# UBI - Unsorted block images
618#
619# CONFIG_MTD_UBI is not set
620# CONFIG_PARPORT is not set
621CONFIG_BLK_DEV=y
622# CONFIG_BLK_CPQ_DA is not set
623# CONFIG_BLK_CPQ_CISS_DA is not set
624# CONFIG_BLK_DEV_DAC960 is not set
625# CONFIG_BLK_DEV_UMEM is not set
626# CONFIG_BLK_DEV_COW_COMMON is not set
627# CONFIG_BLK_DEV_LOOP is not set
628# CONFIG_BLK_DEV_NBD is not set
629# CONFIG_BLK_DEV_SX8 is not set
630# CONFIG_BLK_DEV_RAM is not set
631# CONFIG_CDROM_PKTCDVD is not set
632# CONFIG_ATA_OVER_ETH is not set
633CONFIG_MISC_DEVICES=y
634# CONFIG_PHANTOM is not set
635# CONFIG_EEPROM_93CX6 is not set
636# CONFIG_SGI_IOC4 is not set
637# CONFIG_TIFM_CORE is not set
638# CONFIG_ENCLOSURE_SERVICES is not set
639CONFIG_HAVE_IDE=y
640# CONFIG_IDE is not set
641
642#
643# SCSI device support
644#
645# CONFIG_RAID_ATTRS is not set
646CONFIG_SCSI=y
647CONFIG_SCSI_DMA=y
648# CONFIG_SCSI_TGT is not set
649# CONFIG_SCSI_NETLINK is not set
650CONFIG_SCSI_PROC_FS=y
651
652#
653# SCSI support type (disk, tape, CD-ROM)
654#
655# CONFIG_BLK_DEV_SD is not set
656# CONFIG_CHR_DEV_ST is not set
657# CONFIG_CHR_DEV_OSST is not set
658# CONFIG_BLK_DEV_SR is not set
659# CONFIG_CHR_DEV_SG is not set
660# CONFIG_CHR_DEV_SCH is not set
661
662#
663# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
664#
665# CONFIG_SCSI_MULTI_LUN is not set
666# CONFIG_SCSI_CONSTANTS is not set
667# CONFIG_SCSI_LOGGING is not set
668# CONFIG_SCSI_SCAN_ASYNC is not set
669CONFIG_SCSI_WAIT_SCAN=m
670
671#
672# SCSI Transports
673#
674# CONFIG_SCSI_SPI_ATTRS is not set
675# CONFIG_SCSI_FC_ATTRS is not set
676# CONFIG_SCSI_ISCSI_ATTRS is not set
677# CONFIG_SCSI_SAS_LIBSAS is not set
678# CONFIG_SCSI_SRP_ATTRS is not set
679CONFIG_SCSI_LOWLEVEL=y
680# CONFIG_ISCSI_TCP is not set
681# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
682# CONFIG_SCSI_3W_9XXX is not set
683# CONFIG_SCSI_ACARD is not set
684# CONFIG_SCSI_AACRAID is not set
685# CONFIG_SCSI_AIC7XXX is not set
686# CONFIG_SCSI_AIC7XXX_OLD is not set
687# CONFIG_SCSI_AIC79XX is not set
688# CONFIG_SCSI_AIC94XX is not set
689# CONFIG_SCSI_DPT_I2O is not set
690# CONFIG_SCSI_ADVANSYS is not set
691# CONFIG_SCSI_ARCMSR is not set
692# CONFIG_MEGARAID_NEWGEN is not set
693# CONFIG_MEGARAID_LEGACY is not set
694# CONFIG_MEGARAID_SAS is not set
695# CONFIG_SCSI_HPTIOP is not set
696# CONFIG_SCSI_DMX3191D is not set
697# CONFIG_SCSI_FUTURE_DOMAIN is not set
698# CONFIG_SCSI_IPS is not set
699# CONFIG_SCSI_INITIO is not set
700# CONFIG_SCSI_INIA100 is not set
701# CONFIG_SCSI_MVSAS is not set
702# CONFIG_SCSI_STEX is not set
703# CONFIG_SCSI_SYM53C8XX_2 is not set
704# CONFIG_SCSI_IPR is not set
705# CONFIG_SCSI_QLOGIC_1280 is not set
706# CONFIG_SCSI_QLA_FC is not set
707# CONFIG_SCSI_QLA_ISCSI is not set
708# CONFIG_SCSI_LPFC is not set
709# CONFIG_SCSI_DC395x is not set
710# CONFIG_SCSI_DC390T is not set
711# CONFIG_SCSI_NSP32 is not set
712# CONFIG_SCSI_DEBUG is not set
713# CONFIG_SCSI_SRP is not set
714CONFIG_ATA=y
715# CONFIG_ATA_NONSTANDARD is not set
716# CONFIG_SATA_PMP is not set
717# CONFIG_SATA_AHCI is not set
718# CONFIG_SATA_SIL24 is not set
719CONFIG_ATA_SFF=y
720# CONFIG_SATA_SVW is not set
721# CONFIG_ATA_PIIX is not set
722# CONFIG_SATA_MV is not set
723# CONFIG_SATA_NV is not set
724# CONFIG_PDC_ADMA is not set
725# CONFIG_SATA_QSTOR is not set
726# CONFIG_SATA_PROMISE is not set
727# CONFIG_SATA_SX4 is not set
728# CONFIG_SATA_SIL is not set
729# CONFIG_SATA_SIS is not set
730# CONFIG_SATA_ULI is not set
731# CONFIG_SATA_VIA is not set
732# CONFIG_SATA_VITESSE is not set
733# CONFIG_SATA_INIC162X is not set
734# CONFIG_PATA_ALI is not set
735# CONFIG_PATA_AMD is not set
736# CONFIG_PATA_ARTOP is not set
737# CONFIG_PATA_ATIIXP is not set
738# CONFIG_PATA_CMD640_PCI is not set
739# CONFIG_PATA_CMD64X is not set
740# CONFIG_PATA_CS5520 is not set
741# CONFIG_PATA_CS5530 is not set
742# CONFIG_PATA_CYPRESS is not set
743# CONFIG_PATA_EFAR is not set
744# CONFIG_ATA_GENERIC is not set
745# CONFIG_PATA_HPT366 is not set
746# CONFIG_PATA_HPT37X is not set
747# CONFIG_PATA_HPT3X2N is not set
748# CONFIG_PATA_HPT3X3 is not set
749# CONFIG_PATA_IT821X is not set
750# CONFIG_PATA_IT8213 is not set
751# CONFIG_PATA_JMICRON is not set
752# CONFIG_PATA_TRIFLEX is not set
753# CONFIG_PATA_MARVELL is not set
754# CONFIG_PATA_MPIIX is not set
755# CONFIG_PATA_OLDPIIX is not set
756# CONFIG_PATA_NETCELL is not set
757# CONFIG_PATA_NINJA32 is not set
758# CONFIG_PATA_NS87410 is not set
759# CONFIG_PATA_NS87415 is not set
760# CONFIG_PATA_OPTI is not set
761# CONFIG_PATA_OPTIDMA is not set
762# CONFIG_PATA_PDC_OLD is not set
763# CONFIG_PATA_RADISYS is not set
764CONFIG_PATA_RB532=y
765# CONFIG_PATA_RZ1000 is not set
766# CONFIG_PATA_SC1200 is not set
767# CONFIG_PATA_SERVERWORKS is not set
768# CONFIG_PATA_PDC2027X is not set
769# CONFIG_PATA_SIL680 is not set
770# CONFIG_PATA_SIS is not set
771# CONFIG_PATA_VIA is not set
772# CONFIG_PATA_WINBOND is not set
773# CONFIG_PATA_PLATFORM is not set
774# CONFIG_MD is not set
775# CONFIG_FUSION is not set
776
777#
778# IEEE 1394 (FireWire) support
779#
780# CONFIG_FIREWIRE is not set
781# CONFIG_IEEE1394 is not set
782# CONFIG_I2O is not set
783CONFIG_NETDEVICES=y
784# CONFIG_NETDEVICES_MULTIQUEUE is not set
785CONFIG_IFB=m
786# CONFIG_DUMMY is not set
787# CONFIG_BONDING is not set
788# CONFIG_MACVLAN is not set
789# CONFIG_EQUALIZER is not set
790# CONFIG_TUN is not set
791# CONFIG_VETH is not set
792# CONFIG_ARCNET is not set
793# CONFIG_PHYLIB is not set
794CONFIG_NET_ETHERNET=y
795CONFIG_MII=y
796# CONFIG_AX88796 is not set
797CONFIG_KORINA=y
798# CONFIG_HAPPYMEAL is not set
799# CONFIG_SUNGEM is not set
800# CONFIG_CASSINI is not set
801# CONFIG_NET_VENDOR_3COM is not set
802# CONFIG_DM9000 is not set
803# CONFIG_NET_TULIP is not set
804# CONFIG_HP100 is not set
805# CONFIG_IBM_NEW_EMAC_ZMII is not set
806# CONFIG_IBM_NEW_EMAC_RGMII is not set
807# CONFIG_IBM_NEW_EMAC_TAH is not set
808# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
809CONFIG_NET_PCI=y
810# CONFIG_PCNET32 is not set
811# CONFIG_AMD8111_ETH is not set
812# CONFIG_ADAPTEC_STARFIRE is not set
813# CONFIG_B44 is not set
814# CONFIG_FORCEDETH is not set
815# CONFIG_TC35815 is not set
816# CONFIG_EEPRO100 is not set
817# CONFIG_E100 is not set
818# CONFIG_FEALNX is not set
819# CONFIG_NATSEMI is not set
820# CONFIG_NE2K_PCI is not set
821# CONFIG_8139CP is not set
822# CONFIG_8139TOO is not set
823# CONFIG_R6040 is not set
824# CONFIG_SIS900 is not set
825# CONFIG_EPIC100 is not set
826# CONFIG_SUNDANCE is not set
827# CONFIG_TLAN is not set
828CONFIG_VIA_RHINE=y
829# CONFIG_VIA_RHINE_MMIO is not set
830CONFIG_VIA_RHINE_NAPI=y
831# CONFIG_SC92031 is not set
832# CONFIG_NETDEV_1000 is not set
833# CONFIG_NETDEV_10000 is not set
834# CONFIG_TR is not set
835
836#
837# Wireless LAN
838#
839# CONFIG_WLAN_PRE80211 is not set
840CONFIG_WLAN_80211=y
841# CONFIG_IPW2100 is not set
842# CONFIG_IPW2200 is not set
843# CONFIG_LIBERTAS is not set
844# CONFIG_HERMES is not set
845CONFIG_ATMEL=m
846# CONFIG_PCI_ATMEL is not set
847# CONFIG_PRISM54 is not set
848# CONFIG_IWLWIFI_LEDS is not set
849# CONFIG_HOSTAP is not set
850# CONFIG_WAN is not set
851# CONFIG_FDDI is not set
852# CONFIG_HIPPI is not set
853CONFIG_PPP=m
854CONFIG_PPP_MULTILINK=y
855CONFIG_PPP_FILTER=y
856CONFIG_PPP_ASYNC=m
857# CONFIG_PPP_SYNC_TTY is not set
858CONFIG_PPP_DEFLATE=m
859CONFIG_PPP_BSDCOMP=m
860# CONFIG_PPP_MPPE is not set
861CONFIG_PPPOE=m
862CONFIG_PPPOL2TP=m
863# CONFIG_SLIP is not set
864CONFIG_SLHC=m
865# CONFIG_NET_FC is not set
866# CONFIG_NETCONSOLE is not set
867# CONFIG_NETPOLL is not set
868# CONFIG_NET_POLL_CONTROLLER is not set
869# CONFIG_ISDN is not set
870# CONFIG_PHONE is not set
871
872#
873# Input device support
874#
875CONFIG_INPUT=y
876# CONFIG_INPUT_FF_MEMLESS is not set
877# CONFIG_INPUT_POLLDEV is not set
878
879#
880# Userland interfaces
881#
882# CONFIG_INPUT_MOUSEDEV is not set
883# CONFIG_INPUT_JOYDEV is not set
884# CONFIG_INPUT_EVDEV is not set
885# CONFIG_INPUT_EVBUG is not set
886
887#
888# Input Device Drivers
889#
890CONFIG_INPUT_KEYBOARD=y
891# CONFIG_KEYBOARD_ATKBD is not set
892# CONFIG_KEYBOARD_SUNKBD is not set
893# CONFIG_KEYBOARD_LKKBD is not set
894# CONFIG_KEYBOARD_XTKBD is not set
895# CONFIG_KEYBOARD_NEWTON is not set
896# CONFIG_KEYBOARD_STOWAWAY is not set
897# CONFIG_KEYBOARD_GPIO is not set
898# CONFIG_INPUT_MOUSE is not set
899# CONFIG_INPUT_JOYSTICK is not set
900# CONFIG_INPUT_TABLET is not set
901# CONFIG_INPUT_TOUCHSCREEN is not set
902# CONFIG_INPUT_MISC is not set
903
904#
905# Hardware I/O ports
906#
907# CONFIG_SERIO is not set
908# CONFIG_GAMEPORT is not set
909
910#
911# Character devices
912#
913# CONFIG_VT is not set
914# CONFIG_SERIAL_NONSTANDARD is not set
915# CONFIG_NOZOMI is not set
916
917#
918# Serial drivers
919#
920CONFIG_SERIAL_8250=y
921CONFIG_SERIAL_8250_CONSOLE=y
922# CONFIG_SERIAL_8250_PCI is not set
923CONFIG_SERIAL_8250_NR_UARTS=2
924CONFIG_SERIAL_8250_RUNTIME_UARTS=2
925# CONFIG_SERIAL_8250_EXTENDED is not set
926
927#
928# Non-8250 serial port support
929#
930CONFIG_SERIAL_CORE=y
931CONFIG_SERIAL_CORE_CONSOLE=y
932# CONFIG_SERIAL_JSM is not set
933CONFIG_UNIX98_PTYS=y
934# CONFIG_LEGACY_PTYS is not set
935# CONFIG_IPMI_HANDLER is not set
936CONFIG_HW_RANDOM=y
937# CONFIG_RTC is not set
938# CONFIG_R3964 is not set
939# CONFIG_APPLICOM is not set
940# CONFIG_RAW_DRIVER is not set
941# CONFIG_TCG_TPM is not set
942CONFIG_DEVPORT=y
943# CONFIG_I2C is not set
944
945#
946# SPI support
947#
948# CONFIG_SPI is not set
949# CONFIG_SPI_MASTER is not set
950# CONFIG_W1 is not set
951# CONFIG_POWER_SUPPLY is not set
952# CONFIG_HWMON is not set
953# CONFIG_THERMAL is not set
954CONFIG_WATCHDOG=y
955# CONFIG_WATCHDOG_NOWAYOUT is not set
956
957#
958# Watchdog Device Drivers
959#
960# CONFIG_SOFT_WATCHDOG is not set
961
962#
963# PCI-based Watchdog Cards
964#
965# CONFIG_PCIPCWATCHDOG is not set
966# CONFIG_WDTPCI is not set
967
968#
969# Sonics Silicon Backplane
970#
971CONFIG_SSB_POSSIBLE=y
972# CONFIG_SSB is not set
973
974#
975# Multifunction device drivers
976#
977# CONFIG_MFD_SM501 is not set
978# CONFIG_HTC_PASIC3 is not set
979
980#
981# Multimedia devices
982#
983CONFIG_VIDEO_DEV=m
984CONFIG_VIDEO_V4L2_COMMON=m
985CONFIG_VIDEO_ALLOW_V4L1=y
986CONFIG_VIDEO_V4L1_COMPAT=y
987CONFIG_VIDEO_V4L2=m
988CONFIG_VIDEO_V4L1=m
989CONFIG_VIDEO_CAPTURE_DRIVERS=y
990# CONFIG_VIDEO_ADV_DEBUG is not set
991# CONFIG_VIDEO_HELPER_CHIPS_AUTO is not set
992
993#
994# Encoders/decoders and other helper chips
995#
996
997#
998# Audio decoders
999#
1000
1001#
1002# Video decoders
1003#
1004
1005#
1006# Video and audio decoders
1007#
1008
1009#
1010# MPEG video encoders
1011#
1012# CONFIG_VIDEO_CX2341X is not set
1013
1014#
1015# Video encoders
1016#
1017
1018#
1019# Video improvement chips
1020#
1021# CONFIG_VIDEO_VIVI is not set
1022# CONFIG_VIDEO_CPIA is not set
1023# CONFIG_VIDEO_STRADIS is not set
1024# CONFIG_SOC_CAMERA is not set
1025# CONFIG_RADIO_ADAPTERS is not set
1026# CONFIG_DVB_CORE is not set
1027# CONFIG_DAB is not set
1028
1029#
1030# Graphics support
1031#
1032# CONFIG_DRM is not set
1033# CONFIG_VGASTATE is not set
1034# CONFIG_VIDEO_OUTPUT_CONTROL is not set
1035# CONFIG_FB is not set
1036# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
1037
1038#
1039# Display device support
1040#
1041# CONFIG_DISPLAY_SUPPORT is not set
1042
1043#
1044# Sound
1045#
1046# CONFIG_SOUND is not set
1047CONFIG_HID_SUPPORT=y
1048# CONFIG_HID is not set
1049CONFIG_USB_SUPPORT=y
1050CONFIG_USB_ARCH_HAS_HCD=y
1051CONFIG_USB_ARCH_HAS_OHCI=y
1052CONFIG_USB_ARCH_HAS_EHCI=y
1053# CONFIG_USB is not set
1054# CONFIG_USB_OTG_WHITELIST is not set
1055# CONFIG_USB_OTG_BLACKLIST_HUB is not set
1056
1057#
1058# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
1059#
1060# CONFIG_USB_GADGET is not set
1061# CONFIG_MMC is not set
1062# CONFIG_MEMSTICK is not set
1063CONFIG_NEW_LEDS=y
1064CONFIG_LEDS_CLASS=y
1065
1066#
1067# LED drivers
1068#
1069# CONFIG_LEDS_GPIO is not set
1070
1071#
1072# LED Triggers
1073#
1074CONFIG_LEDS_TRIGGERS=y
1075CONFIG_LEDS_TRIGGER_TIMER=y
1076CONFIG_LEDS_TRIGGER_HEARTBEAT=y
1077# CONFIG_LEDS_TRIGGER_DEFAULT_ON is not set
1078# CONFIG_INFINIBAND is not set
1079CONFIG_RTC_LIB=y
1080# CONFIG_RTC_CLASS is not set
1081# CONFIG_UIO is not set
1082
1083#
1084# File systems
1085#
1086CONFIG_EXT2_FS=y
1087# CONFIG_EXT2_FS_XATTR is not set
1088# CONFIG_EXT2_FS_XIP is not set
1089# CONFIG_EXT3_FS is not set
1090# CONFIG_EXT4DEV_FS is not set
1091# CONFIG_REISERFS_FS is not set
1092# CONFIG_JFS_FS is not set
1093# CONFIG_FS_POSIX_ACL is not set
1094# CONFIG_XFS_FS is not set
1095# CONFIG_OCFS2_FS is not set
1096# CONFIG_DNOTIFY is not set
1097# CONFIG_INOTIFY is not set
1098# CONFIG_QUOTA is not set
1099# CONFIG_AUTOFS_FS is not set
1100# CONFIG_AUTOFS4_FS is not set
1101# CONFIG_FUSE_FS is not set
1102
1103#
1104# CD-ROM/DVD Filesystems
1105#
1106# CONFIG_ISO9660_FS is not set
1107# CONFIG_UDF_FS is not set
1108
1109#
1110# DOS/FAT/NT Filesystems
1111#
1112# CONFIG_MSDOS_FS is not set
1113# CONFIG_VFAT_FS is not set
1114# CONFIG_NTFS_FS is not set
1115
1116#
1117# Pseudo filesystems
1118#
1119CONFIG_PROC_FS=y
1120CONFIG_PROC_KCORE=y
1121CONFIG_PROC_SYSCTL=y
1122CONFIG_SYSFS=y
1123CONFIG_TMPFS=y
1124# CONFIG_TMPFS_POSIX_ACL is not set
1125# CONFIG_HUGETLB_PAGE is not set
1126CONFIG_CONFIGFS_FS=y
1127
1128#
1129# Miscellaneous filesystems
1130#
1131# CONFIG_ADFS_FS is not set
1132# CONFIG_AFFS_FS is not set
1133# CONFIG_HFS_FS is not set
1134# CONFIG_HFSPLUS_FS is not set
1135# CONFIG_BEFS_FS is not set
1136# CONFIG_BFS_FS is not set
1137# CONFIG_EFS_FS is not set
1138CONFIG_JFFS2_FS=y
1139CONFIG_JFFS2_FS_DEBUG=0
1140CONFIG_JFFS2_FS_WRITEBUFFER=y
1141# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
1142CONFIG_JFFS2_SUMMARY=y
1143# CONFIG_JFFS2_FS_XATTR is not set
1144CONFIG_JFFS2_COMPRESSION_OPTIONS=y
1145CONFIG_JFFS2_ZLIB=y
1146# CONFIG_JFFS2_LZO is not set
1147CONFIG_JFFS2_RTIME=y
1148# CONFIG_JFFS2_RUBIN is not set
1149# CONFIG_JFFS2_CMODE_NONE is not set
1150CONFIG_JFFS2_CMODE_PRIORITY=y
1151# CONFIG_JFFS2_CMODE_SIZE is not set
1152# CONFIG_JFFS2_CMODE_FAVOURLZO is not set
1153# CONFIG_CRAMFS is not set
1154# CONFIG_VXFS_FS is not set
1155# CONFIG_MINIX_FS is not set
1156# CONFIG_HPFS_FS is not set
1157# CONFIG_QNX4FS_FS is not set
1158# CONFIG_ROMFS_FS is not set
1159# CONFIG_SYSV_FS is not set
1160# CONFIG_UFS_FS is not set
1161CONFIG_NETWORK_FILESYSTEMS=y
1162# CONFIG_NFS_FS is not set
1163# CONFIG_NFSD is not set
1164# CONFIG_SMB_FS is not set
1165# CONFIG_CIFS is not set
1166# CONFIG_NCP_FS is not set
1167# CONFIG_CODA_FS is not set
1168# CONFIG_AFS_FS is not set
1169
1170#
1171# Partition Types
1172#
1173CONFIG_PARTITION_ADVANCED=y
1174# CONFIG_ACORN_PARTITION is not set
1175# CONFIG_OSF_PARTITION is not set
1176# CONFIG_AMIGA_PARTITION is not set
1177# CONFIG_ATARI_PARTITION is not set
1178CONFIG_MAC_PARTITION=y
1179CONFIG_MSDOS_PARTITION=y
1180CONFIG_BSD_DISKLABEL=y
1181# CONFIG_MINIX_SUBPARTITION is not set
1182# CONFIG_SOLARIS_X86_PARTITION is not set
1183# CONFIG_UNIXWARE_DISKLABEL is not set
1184# CONFIG_LDM_PARTITION is not set
1185# CONFIG_SGI_PARTITION is not set
1186# CONFIG_ULTRIX_PARTITION is not set
1187# CONFIG_SUN_PARTITION is not set
1188# CONFIG_KARMA_PARTITION is not set
1189# CONFIG_EFI_PARTITION is not set
1190# CONFIG_SYSV68_PARTITION is not set
1191# CONFIG_NLS is not set
1192# CONFIG_DLM is not set
1193
1194#
1195# Kernel hacking
1196#
1197CONFIG_TRACE_IRQFLAGS_SUPPORT=y
1198# CONFIG_PRINTK_TIME is not set
1199CONFIG_ENABLE_WARN_DEPRECATED=y
1200# CONFIG_ENABLE_MUST_CHECK is not set
1201CONFIG_FRAME_WARN=1024
1202# CONFIG_MAGIC_SYSRQ is not set
1203# CONFIG_UNUSED_SYMBOLS is not set
1204# CONFIG_DEBUG_FS is not set
1205# CONFIG_HEADERS_CHECK is not set
1206# CONFIG_DEBUG_KERNEL is not set
1207# CONFIG_SAMPLES is not set
1208CONFIG_CMDLINE=""
1209
1210#
1211# Security options
1212#
1213# CONFIG_KEYS is not set
1214# CONFIG_SECURITY is not set
1215# CONFIG_SECURITY_FILE_CAPABILITIES is not set
1216CONFIG_CRYPTO=y
1217
1218#
1219# Crypto core or helper
1220#
1221CONFIG_CRYPTO_ALGAPI=m
1222CONFIG_CRYPTO_AEAD=m
1223CONFIG_CRYPTO_BLKCIPHER=m
1224# CONFIG_CRYPTO_MANAGER is not set
1225# CONFIG_CRYPTO_GF128MUL is not set
1226# CONFIG_CRYPTO_NULL is not set
1227# CONFIG_CRYPTO_CRYPTD is not set
1228# CONFIG_CRYPTO_AUTHENC is not set
1229CONFIG_CRYPTO_TEST=m
1230
1231#
1232# Authenticated Encryption with Associated Data
1233#
1234# CONFIG_CRYPTO_CCM is not set
1235# CONFIG_CRYPTO_GCM is not set
1236# CONFIG_CRYPTO_SEQIV is not set
1237
1238#
1239# Block modes
1240#
1241# CONFIG_CRYPTO_CBC is not set
1242# CONFIG_CRYPTO_CTR is not set
1243# CONFIG_CRYPTO_CTS is not set
1244# CONFIG_CRYPTO_ECB is not set
1245# CONFIG_CRYPTO_LRW is not set
1246# CONFIG_CRYPTO_PCBC is not set
1247# CONFIG_CRYPTO_XTS is not set
1248
1249#
1250# Hash modes
1251#
1252# CONFIG_CRYPTO_HMAC is not set
1253# CONFIG_CRYPTO_XCBC is not set
1254
1255#
1256# Digest
1257#
1258# CONFIG_CRYPTO_CRC32C is not set
1259# CONFIG_CRYPTO_MD4 is not set
1260# CONFIG_CRYPTO_MD5 is not set
1261# CONFIG_CRYPTO_MICHAEL_MIC is not set
1262# CONFIG_CRYPTO_SHA1 is not set
1263# CONFIG_CRYPTO_SHA256 is not set
1264# CONFIG_CRYPTO_SHA512 is not set
1265# CONFIG_CRYPTO_TGR192 is not set
1266# CONFIG_CRYPTO_WP512 is not set
1267
1268#
1269# Ciphers
1270#
1271# CONFIG_CRYPTO_AES is not set
1272# CONFIG_CRYPTO_ANUBIS is not set
1273# CONFIG_CRYPTO_ARC4 is not set
1274# CONFIG_CRYPTO_BLOWFISH is not set
1275# CONFIG_CRYPTO_CAMELLIA is not set
1276# CONFIG_CRYPTO_CAST5 is not set
1277# CONFIG_CRYPTO_CAST6 is not set
1278# CONFIG_CRYPTO_DES is not set
1279# CONFIG_CRYPTO_FCRYPT is not set
1280# CONFIG_CRYPTO_KHAZAD is not set
1281# CONFIG_CRYPTO_SALSA20 is not set
1282# CONFIG_CRYPTO_SEED is not set
1283# CONFIG_CRYPTO_SERPENT is not set
1284# CONFIG_CRYPTO_TEA is not set
1285# CONFIG_CRYPTO_TWOFISH is not set
1286
1287#
1288# Compression
1289#
1290# CONFIG_CRYPTO_DEFLATE is not set
1291# CONFIG_CRYPTO_LZO is not set
1292# CONFIG_CRYPTO_HW is not set
1293
1294#
1295# Library routines
1296#
1297CONFIG_BITREVERSE=y
1298# CONFIG_GENERIC_FIND_FIRST_BIT is not set
1299CONFIG_CRC_CCITT=m
1300CONFIG_CRC16=m
1301# CONFIG_CRC_ITU_T is not set
1302CONFIG_CRC32=y
1303# CONFIG_CRC7 is not set
1304CONFIG_LIBCRC32C=m
1305CONFIG_ZLIB_INFLATE=y
1306CONFIG_ZLIB_DEFLATE=y
1307CONFIG_TEXTSEARCH=y
1308CONFIG_TEXTSEARCH_KMP=m
1309CONFIG_TEXTSEARCH_BM=m
1310CONFIG_TEXTSEARCH_FSM=m
1311CONFIG_PLIST=y
1312CONFIG_HAS_IOMEM=y
1313CONFIG_HAS_IOPORT=y
1314CONFIG_HAS_DMA=y
diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c
index 65af3cc90abb..c266211ed653 100644
--- a/arch/mips/kernel/linux32.c
+++ b/arch/mips/kernel/linux32.c
@@ -129,23 +129,6 @@ out:
129 return error; 129 return error;
130} 130}
131 131
132
133asmlinkage int sys_truncate64(const char __user *path, unsigned int high,
134 unsigned int low)
135{
136 if ((int)high < 0)
137 return -EINVAL;
138 return sys_truncate(path, ((long) high << 32) | low);
139}
140
141asmlinkage int sys_ftruncate64(unsigned int fd, unsigned int high,
142 unsigned int low)
143{
144 if ((int)high < 0)
145 return -EINVAL;
146 return sys_ftruncate(fd, ((long) high << 32) | low);
147}
148
149/* 132/*
150 * sys_execve() executes a new program. 133 * sys_execve() executes a new program.
151 */ 134 */
diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
index c058c0b61a2a..fc4fd4d705e2 100644
--- a/arch/mips/kernel/scall32-o32.S
+++ b/arch/mips/kernel/scall32-o32.S
@@ -354,7 +354,7 @@ einval: li v0, -EINVAL
354 sys sys_mkdir 2 354 sys sys_mkdir 2
355 sys sys_rmdir 1 /* 4040 */ 355 sys sys_rmdir 1 /* 4040 */
356 sys sys_dup 1 356 sys sys_dup 1
357 sys sys_pipe 0 357 sys sysm_pipe 0
358 sys sys_times 1 358 sys sys_times 1
359 sys sys_ni_syscall 0 359 sys sys_ni_syscall 0
360 sys sys_brk 1 /* 4045 */ 360 sys sys_brk 1 /* 4045 */
diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
index dc597b600c68..2b73fd1e4528 100644
--- a/arch/mips/kernel/scall64-64.S
+++ b/arch/mips/kernel/scall64-64.S
@@ -219,7 +219,7 @@ sys_call_table:
219 PTR sys_readv 219 PTR sys_readv
220 PTR sys_writev 220 PTR sys_writev
221 PTR sys_access /* 5020 */ 221 PTR sys_access /* 5020 */
222 PTR sys_pipe 222 PTR sysm_pipe
223 PTR sys_select 223 PTR sys_select
224 PTR sys_sched_yield 224 PTR sys_sched_yield
225 PTR sys_mremap 225 PTR sys_mremap
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index 12940eca7893..2654e75d2fef 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -141,7 +141,7 @@ EXPORT(sysn32_call_table)
141 PTR compat_sys_readv 141 PTR compat_sys_readv
142 PTR compat_sys_writev 142 PTR compat_sys_writev
143 PTR sys_access /* 6020 */ 143 PTR sys_access /* 6020 */
144 PTR sys_pipe 144 PTR sysm_pipe
145 PTR compat_sys_select 145 PTR compat_sys_select
146 PTR sys_sched_yield 146 PTR sys_sched_yield
147 PTR sys_mremap 147 PTR sys_mremap
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index 9a275efb4f04..76167bea5a70 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -247,7 +247,7 @@ sys_call_table:
247 PTR sys_mkdir 247 PTR sys_mkdir
248 PTR sys_rmdir /* 4040 */ 248 PTR sys_rmdir /* 4040 */
249 PTR sys_dup 249 PTR sys_dup
250 PTR sys_pipe 250 PTR sysm_pipe
251 PTR compat_sys_times 251 PTR compat_sys_times
252 PTR sys_ni_syscall 252 PTR sys_ni_syscall
253 PTR sys_brk /* 4045 */ 253 PTR sys_brk /* 4045 */
diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c
index af1bdc897488..3523c8d12eda 100644
--- a/arch/mips/kernel/syscall.c
+++ b/arch/mips/kernel/syscall.c
@@ -40,7 +40,14 @@
40#include <asm/sysmips.h> 40#include <asm/sysmips.h>
41#include <asm/uaccess.h> 41#include <asm/uaccess.h>
42 42
43asmlinkage int sys_pipe(nabi_no_regargs volatile struct pt_regs regs) 43/*
44 * For historic reasons the pipe(2) syscall on MIPS has an unusual calling
45 * convention. It returns results in registers $v0 / $v1 which means there
46 * is no need for it to do verify the validity of a userspace pointer
47 * argument. Historically that used to be expensive in Linux. These days
48 * the performance advantage is negligible.
49 */
50asmlinkage int sysm_pipe(nabi_no_regargs volatile struct pt_regs regs)
44{ 51{
45 int fd[2]; 52 int fd[2];
46 int error, res; 53 int error, res;
diff --git a/arch/mips/math-emu/kernel_linkage.c b/arch/mips/math-emu/kernel_linkage.c
index ed49ef01ac53..52e6c58c8de1 100644
--- a/arch/mips/math-emu/kernel_linkage.c
+++ b/arch/mips/math-emu/kernel_linkage.c
@@ -24,6 +24,7 @@
24#include <asm/signal.h> 24#include <asm/signal.h>
25#include <asm/uaccess.h> 25#include <asm/uaccess.h>
26 26
27#include <asm/fpu.h>
27#include <asm/fpu_emulator.h> 28#include <asm/fpu_emulator.h>
28 29
29#define SIGNALLING_NAN 0x7ff800007ff80000LL 30#define SIGNALLING_NAN 0x7ff800007ff80000LL
diff --git a/arch/mips/pci/Makefile b/arch/mips/pci/Makefile
index 57e34cafa497..15e01aec37fd 100644
--- a/arch/mips/pci/Makefile
+++ b/arch/mips/pci/Makefile
@@ -49,3 +49,4 @@ obj-$(CONFIG_TOSHIBA_RBTX4938) += fixup-rbtx4938.o
49obj-$(CONFIG_VICTOR_MPC30X) += fixup-mpc30x.o 49obj-$(CONFIG_VICTOR_MPC30X) += fixup-mpc30x.o
50obj-$(CONFIG_ZAO_CAPCELLA) += fixup-capcella.o 50obj-$(CONFIG_ZAO_CAPCELLA) += fixup-capcella.o
51obj-$(CONFIG_WR_PPMC) += fixup-wrppmc.o 51obj-$(CONFIG_WR_PPMC) += fixup-wrppmc.o
52obj-$(CONFIG_MIKROTIK_RB532) += pci-rc32434.o ops-rc32434.o fixup-rc32434.o
diff --git a/arch/mips/pci/fixup-rc32434.c b/arch/mips/pci/fixup-rc32434.c
new file mode 100644
index 000000000000..75b90dcb7a09
--- /dev/null
+++ b/arch/mips/pci/fixup-rc32434.c
@@ -0,0 +1,69 @@
1/*
2 * Copyright 2001 MontaVista Software Inc.
3 * Author: MontaVista Software, Inc.
4 * stevel@mvista.com or source@mvista.com
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
12 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
14 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
15 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
17 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
18 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
19 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
20 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 675 Mass Ave, Cambridge, MA 02139, USA.
25 */
26
27#include <linux/types.h>
28#include <linux/pci.h>
29#include <linux/kernel.h>
30#include <linux/init.h>
31
32#include <asm/mach-rc32434/rc32434.h>
33
34static int __devinitdata irq_map[2][12] = {
35 {0, 0, 2, 3, 2, 3, 0, 0, 0, 0, 0, 1},
36 {0, 0, 1, 3, 0, 2, 1, 3, 0, 2, 1, 3}
37};
38
39int __devinit pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
40{
41 int irq = 0;
42
43 if (dev->bus->number < 2 && PCI_SLOT(dev->devfn) < 12)
44 irq = irq_map[dev->bus->number][PCI_SLOT(dev->devfn)];
45
46 return irq + GROUP4_IRQ_BASE + 4;
47}
48
49static void rc32434_pci_early_fixup(struct pci_dev *dev)
50{
51 if (PCI_SLOT(dev->devfn) == 6 && dev->bus->number == 0) {
52 /* disable prefetched memory range */
53 pci_write_config_word(dev, PCI_PREF_MEMORY_LIMIT, 0);
54 pci_write_config_word(dev, PCI_PREF_MEMORY_BASE, 0x10);
55
56 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 4);
57 }
58}
59
60/*
61 * The fixup applies to both the IDT and VIA devices present on the board
62 */
63DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, rc32434_pci_early_fixup);
64
65/* Do platform specific device initialization at pci_enable_device() time */
66int pcibios_plat_dev_init(struct pci_dev *dev)
67{
68 return 0;
69}
diff --git a/arch/mips/pci/ops-rc32434.c b/arch/mips/pci/ops-rc32434.c
new file mode 100644
index 000000000000..d1f8fa210ca1
--- /dev/null
+++ b/arch/mips/pci/ops-rc32434.c
@@ -0,0 +1,207 @@
1/*
2 * BRIEF MODULE DESCRIPTION
3 * pci_ops for IDT EB434 board
4 *
5 * Copyright 2004 IDT Inc. (rischelp@idt.com)
6 * Copyright 2006 Felix Fietkau <nbd@openwrt.org>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
14 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
16 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
19 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 675 Mass Ave, Cambridge, MA 02139, USA.
27 */
28#include <linux/delay.h>
29#include <linux/init.h>
30#include <linux/io.h>
31#include <linux/pci.h>
32#include <linux/types.h>
33
34#include <asm/cpu.h>
35#include <asm/mach-rc32434/rc32434.h>
36#include <asm/mach-rc32434/pci.h>
37
38#define PCI_ACCESS_READ 0
39#define PCI_ACCESS_WRITE 1
40
41
42#define PCI_CFG_SET(bus, slot, func, off) \
43 (rc32434_pci->pcicfga = (0x80000000 | \
44 ((bus) << 16) | ((slot)<<11) | \
45 ((func)<<8) | (off)))
46
47static inline int config_access(unsigned char access_type,
48 struct pci_bus *bus, unsigned int devfn,
49 unsigned char where, u32 *data)
50{
51 unsigned int slot = PCI_SLOT(devfn);
52 u8 func = PCI_FUNC(devfn);
53
54 /* Setup address */
55 PCI_CFG_SET(bus->number, slot, func, where);
56 rc32434_sync();
57
58 if (access_type == PCI_ACCESS_WRITE)
59 rc32434_pci->pcicfgd = *data;
60 else
61 *data = rc32434_pci->pcicfgd;
62
63 rc32434_sync();
64
65 return 0;
66}
67
68
69/*
70 * We can't address 8 and 16 bit words directly. Instead we have to
71 * read/write a 32bit word and mask/modify the data we actually want.
72 */
73static int read_config_byte(struct pci_bus *bus, unsigned int devfn,
74 int where, u8 *val)
75{
76 u32 data;
77 int ret;
78
79 ret = config_access(PCI_ACCESS_READ, bus, devfn, where, &data);
80 *val = (data >> ((where & 3) << 3)) & 0xff;
81 return ret;
82}
83
84static int read_config_word(struct pci_bus *bus, unsigned int devfn,
85 int where, u16 *val)
86{
87 u32 data;
88 int ret;
89
90 ret = config_access(PCI_ACCESS_READ, bus, devfn, where, &data);
91 *val = (data >> ((where & 3) << 3)) & 0xffff;
92 return ret;
93}
94
95static int read_config_dword(struct pci_bus *bus, unsigned int devfn,
96 int where, u32 *val)
97{
98 int ret;
99 int delay = 1;
100
101 /*
102 * Don't scan too far, else there will be errors with plugged in
103 * daughterboard (rb564).
104 */
105 if (bus->number == 0 && PCI_SLOT(devfn) > 21)
106 return 0;
107
108retry:
109 ret = config_access(PCI_ACCESS_READ, bus, devfn, where, val);
110
111 /*
112 * Certain devices react delayed at device scan time, this
113 * gives them time to settle
114 */
115 if (where == PCI_VENDOR_ID) {
116 if (ret == 0xffffffff || ret == 0x00000000 ||
117 ret == 0x0000ffff || ret == 0xffff0000) {
118 if (delay > 4)
119 return 0;
120 delay *= 2;
121 msleep(delay);
122 goto retry;
123 }
124 }
125
126 return ret;
127}
128
129static int
130write_config_byte(struct pci_bus *bus, unsigned int devfn, int where,
131 u8 val)
132{
133 u32 data = 0;
134
135 if (config_access(PCI_ACCESS_READ, bus, devfn, where, &data))
136 return -1;
137
138 data = (data & ~(0xff << ((where & 3) << 3))) |
139 (val << ((where & 3) << 3));
140
141 if (config_access(PCI_ACCESS_WRITE, bus, devfn, where, &data))
142 return -1;
143
144 return PCIBIOS_SUCCESSFUL;
145}
146
147
148static int
149write_config_word(struct pci_bus *bus, unsigned int devfn, int where,
150 u16 val)
151{
152 u32 data = 0;
153
154 if (config_access(PCI_ACCESS_READ, bus, devfn, where, &data))
155 return -1;
156
157 data = (data & ~(0xffff << ((where & 3) << 3))) |
158 (val << ((where & 3) << 3));
159
160 if (config_access(PCI_ACCESS_WRITE, bus, devfn, where, &data))
161 return -1;
162
163
164 return PCIBIOS_SUCCESSFUL;
165}
166
167
168static int
169write_config_dword(struct pci_bus *bus, unsigned int devfn, int where,
170 u32 val)
171{
172 if (config_access(PCI_ACCESS_WRITE, bus, devfn, where, &val))
173 return -1;
174
175 return PCIBIOS_SUCCESSFUL;
176}
177
178static int pci_config_read(struct pci_bus *bus, unsigned int devfn,
179 int where, int size, u32 *val)
180{
181 switch (size) {
182 case 1:
183 return read_config_byte(bus, devfn, where, (u8 *) val);
184 case 2:
185 return read_config_word(bus, devfn, where, (u16 *) val);
186 default:
187 return read_config_dword(bus, devfn, where, val);
188 }
189}
190
191static int pci_config_write(struct pci_bus *bus, unsigned int devfn,
192 int where, int size, u32 val)
193{
194 switch (size) {
195 case 1:
196 return write_config_byte(bus, devfn, where, (u8) val);
197 case 2:
198 return write_config_word(bus, devfn, where, (u16) val);
199 default:
200 return write_config_dword(bus, devfn, where, val);
201 }
202}
203
204struct pci_ops rc32434_pci_ops = {
205 .read = pci_config_read,
206 .write = pci_config_write,
207};
diff --git a/arch/mips/pci/pci-rc32434.c b/arch/mips/pci/pci-rc32434.c
new file mode 100644
index 000000000000..1c2821e2f494
--- /dev/null
+++ b/arch/mips/pci/pci-rc32434.c
@@ -0,0 +1,221 @@
1/*
2 * BRIEF MODULE DESCRIPTION
3 * PCI initialization for IDT EB434 board
4 *
5 * Copyright 2004 IDT Inc. (rischelp@idt.com)
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
15 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
18 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
19 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 675 Mass Ave, Cambridge, MA 02139, USA.
26 */
27
28#include <linux/types.h>
29#include <linux/pci.h>
30#include <linux/kernel.h>
31#include <linux/init.h>
32
33#include <asm/mach-rc32434/rc32434.h>
34#include <asm/mach-rc32434/pci.h>
35
36#define PCI_ACCESS_READ 0
37#define PCI_ACCESS_WRITE 1
38
39/* define an unsigned array for the PCI registers */
40static unsigned int korina_cnfg_regs[25] = {
41 KORINA_CNFG1, KORINA_CNFG2, KORINA_CNFG3, KORINA_CNFG4,
42 KORINA_CNFG5, KORINA_CNFG6, KORINA_CNFG7, KORINA_CNFG8,
43 KORINA_CNFG9, KORINA_CNFG10, KORINA_CNFG11, KORINA_CNFG12,
44 KORINA_CNFG13, KORINA_CNFG14, KORINA_CNFG15, KORINA_CNFG16,
45 KORINA_CNFG17, KORINA_CNFG18, KORINA_CNFG19, KORINA_CNFG20,
46 KORINA_CNFG21, KORINA_CNFG22, KORINA_CNFG23, KORINA_CNFG24
47};
48static struct resource rc32434_res_pci_mem1;
49static struct resource rc32434_res_pci_mem2;
50
51static struct resource rc32434_res_pci_mem1 = {
52 .name = "PCI MEM1",
53 .start = 0x50000000,
54 .end = 0x5FFFFFFF,
55 .flags = IORESOURCE_MEM,
56 .parent = &rc32434_res_pci_mem1,
57 .sibling = NULL,
58 .child = &rc32434_res_pci_mem2
59};
60
61static struct resource rc32434_res_pci_mem2 = {
62 .name = "PCI Mem2",
63 .start = 0x60000000,
64 .end = 0x6FFFFFFF,
65 .flags = IORESOURCE_MEM,
66 .parent = &rc32434_res_pci_mem1,
67 .sibling = NULL,
68 .child = NULL
69};
70
71static struct resource rc32434_res_pci_io1 = {
72 .name = "PCI I/O1",
73 .start = 0x18800000,
74 .end = 0x188FFFFF,
75 .flags = IORESOURCE_IO,
76};
77
78extern struct pci_ops rc32434_pci_ops;
79
80#define PCI_MEM1_START PCI_ADDR_START
81#define PCI_MEM1_END (PCI_ADDR_START + CPUTOPCI_MEM_WIN - 1)
82#define PCI_MEM2_START (PCI_ADDR_START + CPUTOPCI_MEM_WIN)
83#define PCI_MEM2_END (PCI_ADDR_START + (2 * CPUTOPCI_MEM_WIN) - 1)
84#define PCI_IO1_START (PCI_ADDR_START + (2 * CPUTOPCI_MEM_WIN))
85#define PCI_IO1_END \
86 (PCI_ADDR_START + (2 * CPUTOPCI_MEM_WIN) + CPUTOPCI_IO_WIN - 1)
87#define PCI_IO2_START \
88 (PCI_ADDR_START + (2 * CPUTOPCI_MEM_WIN) + CPUTOPCI_IO_WIN)
89#define PCI_IO2_END \
90 (PCI_ADDR_START + (2 * CPUTOPCI_MEM_WIN) + (2 * CPUTOPCI_IO_WIN) - 1)
91
92struct pci_controller rc32434_controller2;
93
94struct pci_controller rc32434_controller = {
95 .pci_ops = &rc32434_pci_ops,
96 .mem_resource = &rc32434_res_pci_mem1,
97 .io_resource = &rc32434_res_pci_io1,
98 .mem_offset = 0,
99 .io_offset = 0,
100
101};
102
103#ifdef __MIPSEB__
104#define PCI_ENDIAN_FLAG PCILBAC_sb_m
105#else
106#define PCI_ENDIAN_FLAG 0
107#endif
108
109static int __init rc32434_pcibridge_init(void)
110{
111 unsigned int pcicvalue, pcicdata = 0;
112 unsigned int dummyread, pcicntlval;
113 int loopCount;
114 unsigned int pci_config_addr;
115
116 pcicvalue = rc32434_pci->pcic;
117 pcicvalue = (pcicvalue >> PCIM_SHFT) & PCIM_BIT_LEN;
118 if (!((pcicvalue == PCIM_H_EA) ||
119 (pcicvalue == PCIM_H_IA_FIX) ||
120 (pcicvalue == PCIM_H_IA_RR))) {
121 pr_err(KERN_ERR "PCI init error!!!\n");
122 /* Not in Host Mode, return ERROR */
123 return -1;
124 }
125 /* Enables the Idle Grant mode, Arbiter Parking */
126 pcicdata |= (PCI_CTL_IGM | PCI_CTL_EAP | PCI_CTL_EN);
127 rc32434_pci->pcic = pcicdata; /* Enable the PCI bus Interface */
128 /* Zero out the PCI status & PCI Status Mask */
129 for (;;) {
130 pcicdata = rc32434_pci->pcis;
131 if (!(pcicdata & PCI_STAT_RIP))
132 break;
133 }
134
135 rc32434_pci->pcis = 0;
136 rc32434_pci->pcism = 0xFFFFFFFF;
137 /* Zero out the PCI decoupled registers */
138 rc32434_pci->pcidac = 0; /*
139 * disable PCI decoupled accesses at
140 * initialization
141 */
142 rc32434_pci->pcidas = 0; /* clear the status */
143 rc32434_pci->pcidasm = 0x0000007F; /* Mask all the interrupts */
144 /* Mask PCI Messaging Interrupts */
145 rc32434_pci_msg->pciiic = 0;
146 rc32434_pci_msg->pciiim = 0xFFFFFFFF;
147 rc32434_pci_msg->pciioic = 0;
148 rc32434_pci_msg->pciioim = 0;
149
150
151 /* Setup PCILB0 as Memory Window */
152 rc32434_pci->pcilba[0].address = (unsigned int) (PCI_ADDR_START);
153
154 /* setup the PCI map address as same as the local address */
155
156 rc32434_pci->pcilba[0].mapping = (unsigned int) (PCI_ADDR_START);
157
158
159 /* Setup PCILBA1 as MEM */
160 rc32434_pci->pcilba[0].control =
161 (((SIZE_256MB & 0x1f) << PCI_LBAC_SIZE_BIT) | PCI_ENDIAN_FLAG);
162 dummyread = rc32434_pci->pcilba[0].control; /* flush the CPU write Buffers */
163 rc32434_pci->pcilba[1].address = 0x60000000;
164 rc32434_pci->pcilba[1].mapping = 0x60000000;
165
166 /* setup PCILBA2 as IO Window */
167 rc32434_pci->pcilba[1].control =
168 (((SIZE_256MB & 0x1f) << PCI_LBAC_SIZE_BIT) | PCI_ENDIAN_FLAG);
169 dummyread = rc32434_pci->pcilba[1].control; /* flush the CPU write Buffers */
170 rc32434_pci->pcilba[2].address = 0x18C00000;
171 rc32434_pci->pcilba[2].mapping = 0x18FFFFFF;
172
173 /* setup PCILBA2 as IO Window */
174 rc32434_pci->pcilba[2].control =
175 (((SIZE_4MB & 0x1f) << PCI_LBAC_SIZE_BIT) | PCI_ENDIAN_FLAG);
176 dummyread = rc32434_pci->pcilba[2].control; /* flush the CPU write Buffers */
177
178 /* Setup PCILBA3 as IO Window */
179 rc32434_pci->pcilba[3].address = 0x18800000;
180 rc32434_pci->pcilba[3].mapping = 0x18800000;
181 rc32434_pci->pcilba[3].control =
182 ((((SIZE_1MB & 0x1ff) << PCI_LBAC_SIZE_BIT) | PCI_LBAC_MSI) |
183 PCI_ENDIAN_FLAG);
184 dummyread = rc32434_pci->pcilba[3].control; /* flush the CPU write Buffers */
185
186 pci_config_addr = (unsigned int) (0x80000004);
187 for (loopCount = 0; loopCount < 24; loopCount++) {
188 rc32434_pci->pcicfga = pci_config_addr;
189 dummyread = rc32434_pci->pcicfga;
190 rc32434_pci->pcicfgd = korina_cnfg_regs[loopCount];
191 dummyread = rc32434_pci->pcicfgd;
192 pci_config_addr += 4;
193 }
194 rc32434_pci->pcitc =
195 (unsigned int) ((PCITC_RTIMER_VAL & 0xff) << PCI_TC_RTIMER_BIT) |
196 ((PCITC_DTIMER_VAL & 0xff) << PCI_TC_DTIMER_BIT);
197
198 pcicntlval = rc32434_pci->pcic;
199 pcicntlval &= ~PCI_CTL_TNR;
200 rc32434_pci->pcic = pcicntlval;
201 pcicntlval = rc32434_pci->pcic;
202
203 return 0;
204}
205
206static int __init rc32434_pci_init(void)
207{
208 pr_info("PCI: Initializing PCI\n");
209
210 ioport_resource.start = rc32434_res_pci_io1.start;
211 ioport_resource.end = rc32434_res_pci_io1.end;
212
213 rc32434_pcibridge_init();
214
215 register_pci_controller(&rc32434_controller);
216 rc32434_sync();
217
218 return 0;
219}
220
221arch_initcall(rc32434_pci_init);
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index d7d6cb063d26..77bd5b68dc43 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -204,7 +204,7 @@ static int pcibios_enable_resources(struct pci_dev *dev, int mask)
204 * If we set up a device for bus mastering, we need to check the latency 204 * If we set up a device for bus mastering, we need to check the latency
205 * timer as certain crappy BIOSes forget to set it properly. 205 * timer as certain crappy BIOSes forget to set it properly.
206 */ 206 */
207unsigned int pcibios_max_latency = 255; 207static unsigned int pcibios_max_latency = 255;
208 208
209void pcibios_set_master(struct pci_dev *dev) 209void pcibios_set_master(struct pci_dev *dev)
210{ 210{
diff --git a/arch/mips/rb532/Makefile b/arch/mips/rb532/Makefile
new file mode 100644
index 000000000000..8f0b6b6a1625
--- /dev/null
+++ b/arch/mips/rb532/Makefile
@@ -0,0 +1,7 @@
1#
2# Makefile for the RB532 board specific parts of the kernel
3#
4
5obj-y += irq.o time.o setup.o serial.o prom.o gpio.o devices.o
6
7EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/rb532/devices.c b/arch/mips/rb532/devices.c
new file mode 100644
index 000000000000..44fb0a62877f
--- /dev/null
+++ b/arch/mips/rb532/devices.c
@@ -0,0 +1,331 @@
1/*
2 * RouterBoard 500 Platform devices
3 *
4 * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
5 * Copyright (C) 2007 Florian Fainelli <florian@openwrt.org>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */
17#include <linux/kernel.h>
18#include <linux/init.h>
19#include <linux/ctype.h>
20#include <linux/string.h>
21#include <linux/platform_device.h>
22#include <linux/mtd/nand.h>
23#include <linux/mtd/mtd.h>
24#include <linux/mtd/partitions.h>
25#include <linux/gpio_keys.h>
26#include <linux/input.h>
27
28#include <asm/bootinfo.h>
29
30#include <asm/mach-rc32434/rc32434.h>
31#include <asm/mach-rc32434/dma.h>
32#include <asm/mach-rc32434/dma_v.h>
33#include <asm/mach-rc32434/eth.h>
34#include <asm/mach-rc32434/rb.h>
35#include <asm/mach-rc32434/integ.h>
36#include <asm/mach-rc32434/gpio.h>
37
38#define ETH0_DMA_RX_IRQ (GROUP1_IRQ_BASE + 0)
39#define ETH0_DMA_TX_IRQ (GROUP1_IRQ_BASE + 1)
40#define ETH0_RX_OVR_IRQ (GROUP3_IRQ_BASE + 9)
41#define ETH0_TX_UND_IRQ (GROUP3_IRQ_BASE + 10)
42
43#define ETH0_RX_DMA_ADDR (DMA0_BASE_ADDR + 0 * DMA_CHAN_OFFSET)
44#define ETH0_TX_DMA_ADDR (DMA0_BASE_ADDR + 1 * DMA_CHAN_OFFSET)
45
46/* NAND definitions */
47#define GPIO_RDY (1 << 0x08)
48#define GPIO_WPX (1 << 0x09)
49#define GPIO_ALE (1 << 0x0a)
50#define GPIO_CLE (1 << 0x0b)
51
52extern char *board_type;
53
54static struct resource korina_dev0_res[] = {
55 {
56 .name = "korina_regs",
57 .start = ETH0_BASE_ADDR,
58 .end = ETH0_BASE_ADDR + sizeof(struct eth_regs),
59 .flags = IORESOURCE_MEM,
60 }, {
61 .name = "korina_rx",
62 .start = ETH0_DMA_RX_IRQ,
63 .end = ETH0_DMA_RX_IRQ,
64 .flags = IORESOURCE_IRQ
65 }, {
66 .name = "korina_tx",
67 .start = ETH0_DMA_TX_IRQ,
68 .end = ETH0_DMA_TX_IRQ,
69 .flags = IORESOURCE_IRQ
70 }, {
71 .name = "korina_ovr",
72 .start = ETH0_RX_OVR_IRQ,
73 .end = ETH0_RX_OVR_IRQ,
74 .flags = IORESOURCE_IRQ
75 }, {
76 .name = "korina_und",
77 .start = ETH0_TX_UND_IRQ,
78 .end = ETH0_TX_UND_IRQ,
79 .flags = IORESOURCE_IRQ
80 }, {
81 .name = "korina_dma_rx",
82 .start = ETH0_RX_DMA_ADDR,
83 .end = ETH0_RX_DMA_ADDR + DMA_CHAN_OFFSET - 1,
84 .flags = IORESOURCE_MEM,
85 }, {
86 .name = "korina_dma_tx",
87 .start = ETH0_TX_DMA_ADDR,
88 .end = ETH0_TX_DMA_ADDR + DMA_CHAN_OFFSET - 1,
89 .flags = IORESOURCE_MEM,
90 }
91};
92
93static struct korina_device korina_dev0_data = {
94 .name = "korina0",
95 .mac = {0xde, 0xca, 0xff, 0xc0, 0xff, 0xee}
96};
97
98static struct platform_device korina_dev0 = {
99 .id = 0,
100 .name = "korina",
101 .dev.platform_data = &korina_dev0_data,
102 .resource = korina_dev0_res,
103 .num_resources = ARRAY_SIZE(korina_dev0_res),
104};
105
106#define CF_GPIO_NUM 13
107
108static struct resource cf_slot0_res[] = {
109 {
110 .name = "cf_membase",
111 .flags = IORESOURCE_MEM
112 }, {
113 .name = "cf_irq",
114 .start = (8 + 4 * 32 + CF_GPIO_NUM), /* 149 */
115 .end = (8 + 4 * 32 + CF_GPIO_NUM),
116 .flags = IORESOURCE_IRQ
117 }
118};
119
120static struct cf_device cf_slot0_data = {
121 .gpio_pin = 13
122};
123
124static struct platform_device cf_slot0 = {
125 .id = 0,
126 .name = "pata-rb532-cf",
127 .dev.platform_data = &cf_slot0_data,
128 .resource = cf_slot0_res,
129 .num_resources = ARRAY_SIZE(cf_slot0_res),
130};
131
132/* Resources and device for NAND */
133static int rb532_dev_ready(struct mtd_info *mtd)
134{
135 return readl(IDT434_REG_BASE + GPIOD) & GPIO_RDY;
136}
137
138static void rb532_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
139{
140 struct nand_chip *chip = mtd->priv;
141 unsigned char orbits, nandbits;
142
143 if (ctrl & NAND_CTRL_CHANGE) {
144 orbits = (ctrl & NAND_CLE) << 1;
145 orbits |= (ctrl & NAND_ALE) >> 1;
146
147 nandbits = (~ctrl & NAND_CLE) << 1;
148 nandbits |= (~ctrl & NAND_ALE) >> 1;
149
150 set_latch_u5(orbits, nandbits);
151 }
152 if (cmd != NAND_CMD_NONE)
153 writeb(cmd, chip->IO_ADDR_W);
154}
155
156static struct resource nand_slot0_res[] = {
157 [0] = {
158 .name = "nand_membase",
159 .flags = IORESOURCE_MEM
160 }
161};
162
163static struct platform_nand_data rb532_nand_data = {
164 .ctrl.dev_ready = rb532_dev_ready,
165 .ctrl.cmd_ctrl = rb532_cmd_ctrl,
166};
167
168static struct platform_device nand_slot0 = {
169 .name = "gen_nand",
170 .id = -1,
171 .resource = nand_slot0_res,
172 .num_resources = ARRAY_SIZE(nand_slot0_res),
173 .dev.platform_data = &rb532_nand_data,
174};
175
176static struct mtd_partition rb532_partition_info[] = {
177 {
178 .name = "Routerboard NAND boot",
179 .offset = 0,
180 .size = 4 * 1024 * 1024,
181 }, {
182 .name = "rootfs",
183 .offset = MTDPART_OFS_NXTBLK,
184 .size = MTDPART_SIZ_FULL,
185 }
186};
187
188static struct platform_device rb532_led = {
189 .name = "rb532-led",
190 .id = 0,
191};
192
193static struct gpio_keys_button rb532_gpio_btn[] = {
194 {
195 .gpio = 1,
196 .code = BTN_0,
197 .desc = "S1",
198 .active_low = 1,
199 }
200};
201
202static struct gpio_keys_platform_data rb532_gpio_btn_data = {
203 .buttons = rb532_gpio_btn,
204 .nbuttons = ARRAY_SIZE(rb532_gpio_btn),
205};
206
207static struct platform_device rb532_button = {
208 .name = "gpio-keys",
209 .id = -1,
210 .dev = {
211 .platform_data = &rb532_gpio_btn_data,
212 }
213};
214
215static struct resource rb532_wdt_res[] = {
216 {
217 .name = "rb532_wdt_res",
218 .start = INTEG0_BASE_ADDR,
219 .end = INTEG0_BASE_ADDR + sizeof(struct integ),
220 .flags = IORESOURCE_MEM,
221 }
222};
223
224static struct platform_device rb532_wdt = {
225 .name = "rc32434_wdt",
226 .id = -1,
227 .resource = rb532_wdt_res,
228 .num_resources = ARRAY_SIZE(rb532_wdt_res),
229};
230
231static struct platform_device *rb532_devs[] = {
232 &korina_dev0,
233 &nand_slot0,
234 &cf_slot0,
235 &rb532_led,
236 &rb532_button,
237 &rb532_wdt
238};
239
240static void __init parse_mac_addr(char *macstr)
241{
242 int i, j;
243 unsigned char result, value;
244
245 for (i = 0; i < 6; i++) {
246 result = 0;
247
248 if (i != 5 && *(macstr + 2) != ':')
249 return;
250
251 for (j = 0; j < 2; j++) {
252 if (isxdigit(*macstr)
253 && (value =
254 isdigit(*macstr) ? *macstr -
255 '0' : toupper(*macstr) - 'A' + 10) < 16) {
256 result = result * 16 + value;
257 macstr++;
258 } else
259 return;
260 }
261
262 macstr++;
263 korina_dev0_data.mac[i] = result;
264 }
265}
266
267
268/* DEVICE CONTROLLER 1 */
269#define CFG_DC_DEV1 ((void *)0xb8010010)
270#define CFG_DC_DEV2 ((void *)0xb8010020)
271#define CFG_DC_DEVBASE 0x0
272#define CFG_DC_DEVMASK 0x4
273#define CFG_DC_DEVC 0x8
274#define CFG_DC_DEVTC 0xC
275
276/* NAND definitions */
277#define NAND_CHIP_DELAY 25
278
279static void __init rb532_nand_setup(void)
280{
281 switch (mips_machtype) {
282 case MACH_MIKROTIK_RB532A:
283 set_latch_u5(LO_FOFF | LO_CEX,
284 LO_ULED | LO_ALE | LO_CLE | LO_WPX);
285 break;
286 default:
287 set_latch_u5(LO_WPX | LO_FOFF | LO_CEX,
288 LO_ULED | LO_ALE | LO_CLE);
289 break;
290 }
291
292 /* Setup NAND specific settings */
293 rb532_nand_data.chip.nr_chips = 1;
294 rb532_nand_data.chip.nr_partitions = ARRAY_SIZE(rb532_partition_info);
295 rb532_nand_data.chip.partitions = rb532_partition_info;
296 rb532_nand_data.chip.chip_delay = NAND_CHIP_DELAY;
297 rb532_nand_data.chip.options = NAND_NO_AUTOINCR;
298}
299
300
301static int __init plat_setup_devices(void)
302{
303 /* Look for the CF card reader */
304 if (!readl(CFG_DC_DEV1 + CFG_DC_DEVMASK))
305 rb532_devs[1] = NULL;
306 else {
307 cf_slot0_res[0].start =
308 readl(CFG_DC_DEV1 + CFG_DC_DEVBASE);
309 cf_slot0_res[0].end = cf_slot0_res[0].start + 0x1000;
310 }
311
312 /* Read the NAND resources from the device controller */
313 nand_slot0_res[0].start = readl(CFG_DC_DEV2 + CFG_DC_DEVBASE);
314 nand_slot0_res[0].end = nand_slot0_res[0].start + 0x1000;
315
316 /* Initialise the NAND device */
317 rb532_nand_setup();
318
319 return platform_add_devices(rb532_devs, ARRAY_SIZE(rb532_devs));
320}
321
322static int __init setup_kmac(char *s)
323{
324 printk(KERN_INFO "korina mac = %s\n", s);
325 parse_mac_addr(s);
326 return 0;
327}
328
329__setup("kmac=", setup_kmac);
330
331arch_initcall(plat_setup_devices);
diff --git a/arch/mips/rb532/gpio.c b/arch/mips/rb532/gpio.c
new file mode 100644
index 000000000000..b2fe82dba0a5
--- /dev/null
+++ b/arch/mips/rb532/gpio.c
@@ -0,0 +1,220 @@
1/*
2 * Miscellaneous functions for IDT EB434 board
3 *
4 * Copyright 2004 IDT Inc. (rischelp@idt.com)
5 * Copyright 2006 Phil Sutter <n0-1@freewrt.org>
6 * Copyright 2007 Florian Fainelli <florian@openwrt.org>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
14 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
16 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
19 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 675 Mass Ave, Cambridge, MA 02139, USA.
27 */
28
29#include <linux/kernel.h>
30#include <linux/gpio.h>
31#include <linux/init.h>
32#include <linux/types.h>
33#include <linux/pci.h>
34#include <linux/spinlock.h>
35#include <linux/io.h>
36#include <linux/platform_device.h>
37
38#include <asm/addrspace.h>
39
40#include <asm/mach-rc32434/rb.h>
41
42struct rb532_gpio_reg __iomem *rb532_gpio_reg0;
43EXPORT_SYMBOL(rb532_gpio_reg0);
44
45struct mpmc_device dev3;
46
47static struct resource rb532_gpio_reg0_res[] = {
48 {
49 .name = "gpio_reg0",
50 .start = (u32)(IDT434_REG_BASE + GPIOBASE),
51 .end = (u32)(IDT434_REG_BASE + GPIOBASE + sizeof(struct rb532_gpio_reg)),
52 .flags = IORESOURCE_MEM,
53 }
54};
55
56static struct resource rb532_dev3_ctl_res[] = {
57 {
58 .name = "dev3_ctl",
59 .start = (u32)(IDT434_REG_BASE + DEV3BASE),
60 .end = (u32)(IDT434_REG_BASE + DEV3BASE + sizeof(struct dev_reg)),
61 .flags = IORESOURCE_MEM,
62 }
63};
64
65void set_434_reg(unsigned reg_offs, unsigned bit, unsigned len, unsigned val)
66{
67 unsigned flags, data;
68 unsigned i = 0;
69
70 spin_lock_irqsave(&dev3.lock, flags);
71
72 data = *(volatile unsigned *) (IDT434_REG_BASE + reg_offs);
73 for (i = 0; i != len; ++i) {
74 if (val & (1 << i))
75 data |= (1 << (i + bit));
76 else
77 data &= ~(1 << (i + bit));
78 }
79 writel(data, (IDT434_REG_BASE + reg_offs));
80
81 spin_unlock_irqrestore(&dev3.lock, flags);
82}
83EXPORT_SYMBOL(set_434_reg);
84
85unsigned get_434_reg(unsigned reg_offs)
86{
87 return readl(IDT434_REG_BASE + reg_offs);
88}
89EXPORT_SYMBOL(get_434_reg);
90
91void set_latch_u5(unsigned char or_mask, unsigned char nand_mask)
92{
93 unsigned flags;
94
95 spin_lock_irqsave(&dev3.lock, flags);
96
97 dev3.state = (dev3.state | or_mask) & ~nand_mask;
98 writel(dev3.state, &dev3.base);
99
100 spin_unlock_irqrestore(&dev3.lock, flags);
101}
102EXPORT_SYMBOL(set_latch_u5);
103
104unsigned char get_latch_u5(void)
105{
106 return dev3.state;
107}
108EXPORT_SYMBOL(get_latch_u5);
109
110int rb532_gpio_get_value(unsigned gpio)
111{
112 return readl(&rb532_gpio_reg0->gpiod) & (1 << gpio);
113}
114EXPORT_SYMBOL(rb532_gpio_get_value);
115
116void rb532_gpio_set_value(unsigned gpio, int value)
117{
118 unsigned tmp;
119
120 tmp = readl(&rb532_gpio_reg0->gpiod) & ~(1 << gpio);
121 if (value)
122 tmp |= 1 << gpio;
123
124 writel(tmp, (void *)&rb532_gpio_reg0->gpiod);
125}
126EXPORT_SYMBOL(rb532_gpio_set_value);
127
128int rb532_gpio_direction_input(unsigned gpio)
129{
130 writel(readl(&rb532_gpio_reg0->gpiocfg) & ~(1 << gpio),
131 (void *)&rb532_gpio_reg0->gpiocfg);
132
133 return 0;
134}
135EXPORT_SYMBOL(rb532_gpio_direction_input);
136
137int rb532_gpio_direction_output(unsigned gpio, int value)
138{
139 gpio_set_value(gpio, value);
140 writel(readl(&rb532_gpio_reg0->gpiocfg) | (1 << gpio),
141 (void *)&rb532_gpio_reg0->gpiocfg);
142
143 return 0;
144}
145EXPORT_SYMBOL(rb532_gpio_direction_output);
146
147void rb532_gpio_set_int_level(unsigned gpio, int value)
148{
149 unsigned tmp;
150
151 tmp = readl(&rb532_gpio_reg0->gpioilevel) & ~(1 << gpio);
152 if (value)
153 tmp |= 1 << gpio;
154 writel(tmp, (void *)&rb532_gpio_reg0->gpioilevel);
155}
156EXPORT_SYMBOL(rb532_gpio_set_int_level);
157
158int rb532_gpio_get_int_level(unsigned gpio)
159{
160 return readl(&rb532_gpio_reg0->gpioilevel) & (1 << gpio);
161}
162EXPORT_SYMBOL(rb532_gpio_get_int_level);
163
164void rb532_gpio_set_int_status(unsigned gpio, int value)
165{
166 unsigned tmp;
167
168 tmp = readl(&rb532_gpio_reg0->gpioistat);
169 if (value)
170 tmp |= 1 << gpio;
171 writel(tmp, (void *)&rb532_gpio_reg0->gpioistat);
172}
173EXPORT_SYMBOL(rb532_gpio_set_int_status);
174
175int rb532_gpio_get_int_status(unsigned gpio)
176{
177 return readl(&rb532_gpio_reg0->gpioistat) & (1 << gpio);
178}
179EXPORT_SYMBOL(rb532_gpio_get_int_status);
180
181void rb532_gpio_set_func(unsigned gpio, int value)
182{
183 unsigned tmp;
184
185 tmp = readl(&rb532_gpio_reg0->gpiofunc);
186 if (value)
187 tmp |= 1 << gpio;
188 writel(tmp, (void *)&rb532_gpio_reg0->gpiofunc);
189}
190EXPORT_SYMBOL(rb532_gpio_set_func);
191
192int rb532_gpio_get_func(unsigned gpio)
193{
194 return readl(&rb532_gpio_reg0->gpiofunc) & (1 << gpio);
195}
196EXPORT_SYMBOL(rb532_gpio_get_func);
197
198int __init rb532_gpio_init(void)
199{
200 rb532_gpio_reg0 = ioremap_nocache(rb532_gpio_reg0_res[0].start,
201 rb532_gpio_reg0_res[0].end -
202 rb532_gpio_reg0_res[0].start);
203
204 if (!rb532_gpio_reg0) {
205 printk(KERN_ERR "rb532: cannot remap GPIO register 0\n");
206 return -ENXIO;
207 }
208
209 dev3.base = ioremap_nocache(rb532_dev3_ctl_res[0].start,
210 rb532_dev3_ctl_res[0].end -
211 rb532_dev3_ctl_res[0].start);
212
213 if (!dev3.base) {
214 printk(KERN_ERR "rb532: cannot remap device controller 3\n");
215 return -ENXIO;
216 }
217
218 return 0;
219}
220arch_initcall(rb532_gpio_init);
diff --git a/arch/mips/rb532/irq.c b/arch/mips/rb532/irq.c
new file mode 100644
index 000000000000..c0d0f950caf2
--- /dev/null
+++ b/arch/mips/rb532/irq.c
@@ -0,0 +1,209 @@
1/*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License as published by the
4 * Free Software Foundation; either version 2 of the License, or (at your
5 * option) any later version.
6 *
7 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
8 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
10 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
11 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
12 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
13 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
14 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
15 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
16 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 * Copyright 2002 MontaVista Software Inc.
23 * Author: MontaVista Software, Inc.
24 * stevel@mvista.com or source@mvista.com
25 */
26
27#include <linux/bitops.h>
28#include <linux/errno.h>
29#include <linux/init.h>
30#include <linux/io.h>
31#include <linux/kernel_stat.h>
32#include <linux/module.h>
33#include <linux/signal.h>
34#include <linux/sched.h>
35#include <linux/types.h>
36#include <linux/interrupt.h>
37#include <linux/ioport.h>
38#include <linux/timex.h>
39#include <linux/slab.h>
40#include <linux/random.h>
41#include <linux/delay.h>
42
43#include <asm/bootinfo.h>
44#include <asm/time.h>
45#include <asm/mipsregs.h>
46#include <asm/system.h>
47
48#include <asm/mach-rc32434/rc32434.h>
49
50struct intr_group {
51 u32 mask; /* mask of valid bits in pending/mask registers */
52 volatile u32 *base_addr;
53};
54
55#define RC32434_NR_IRQS (GROUP4_IRQ_BASE + 32)
56
57#if (NR_IRQS < RC32434_NR_IRQS)
58#error Too little irqs defined. Did you override <asm/irq.h> ?
59#endif
60
61static const struct intr_group intr_group[NUM_INTR_GROUPS] = {
62 {
63 .mask = 0x0000efff,
64 .base_addr = (u32 *) KSEG1ADDR(IC_GROUP0_PEND + 0 * IC_GROUP_OFFSET)},
65 {
66 .mask = 0x00001fff,
67 .base_addr = (u32 *) KSEG1ADDR(IC_GROUP0_PEND + 1 * IC_GROUP_OFFSET)},
68 {
69 .mask = 0x00000007,
70 .base_addr = (u32 *) KSEG1ADDR(IC_GROUP0_PEND + 2 * IC_GROUP_OFFSET)},
71 {
72 .mask = 0x0003ffff,
73 .base_addr = (u32 *) KSEG1ADDR(IC_GROUP0_PEND + 3 * IC_GROUP_OFFSET)},
74 {
75 .mask = 0xffffffff,
76 .base_addr = (u32 *) KSEG1ADDR(IC_GROUP0_PEND + 4 * IC_GROUP_OFFSET)}
77};
78
79#define READ_PEND(base) (*(base))
80#define READ_MASK(base) (*(base + 2))
81#define WRITE_MASK(base, val) (*(base + 2) = (val))
82
83static inline int irq_to_group(unsigned int irq_nr)
84{
85 return (irq_nr - GROUP0_IRQ_BASE) >> 5;
86}
87
88static inline int group_to_ip(unsigned int group)
89{
90 return group + 2;
91}
92
93static inline void enable_local_irq(unsigned int ip)
94{
95 int ipnum = 0x100 << ip;
96
97 set_c0_status(ipnum);
98}
99
100static inline void disable_local_irq(unsigned int ip)
101{
102 int ipnum = 0x100 << ip;
103
104 clear_c0_status(ipnum);
105}
106
107static inline void ack_local_irq(unsigned int ip)
108{
109 int ipnum = 0x100 << ip;
110
111 clear_c0_cause(ipnum);
112}
113
114static void rb532_enable_irq(unsigned int irq_nr)
115{
116 int ip = irq_nr - GROUP0_IRQ_BASE;
117 unsigned int group, intr_bit;
118 volatile unsigned int *addr;
119
120 if (ip < 0)
121 enable_local_irq(irq_nr);
122 else {
123 group = ip >> 5;
124
125 ip &= (1 << 5) - 1;
126 intr_bit = 1 << ip;
127
128 enable_local_irq(group_to_ip(group));
129
130 addr = intr_group[group].base_addr;
131 WRITE_MASK(addr, READ_MASK(addr) & ~intr_bit);
132 }
133}
134
135static void rb532_disable_irq(unsigned int irq_nr)
136{
137 int ip = irq_nr - GROUP0_IRQ_BASE;
138 unsigned int group, intr_bit, mask;
139 volatile unsigned int *addr;
140
141 if (ip < 0) {
142 disable_local_irq(irq_nr);
143 } else {
144 group = ip >> 5;
145
146 ip &= (1 << 5) - 1;
147 intr_bit = 1 << ip;
148 addr = intr_group[group].base_addr;
149 mask = READ_MASK(addr);
150 mask |= intr_bit;
151 WRITE_MASK(addr, mask);
152
153 /*
154 * if there are no more interrupts enabled in this
155 * group, disable corresponding IP
156 */
157 if (mask == intr_group[group].mask)
158 disable_local_irq(group_to_ip(group));
159 }
160}
161
162static void rb532_mask_and_ack_irq(unsigned int irq_nr)
163{
164 rb532_disable_irq(irq_nr);
165 ack_local_irq(group_to_ip(irq_to_group(irq_nr)));
166}
167
168static struct irq_chip rc32434_irq_type = {
169 .name = "RB532",
170 .ack = rb532_disable_irq,
171 .mask = rb532_disable_irq,
172 .mask_ack = rb532_mask_and_ack_irq,
173 .unmask = rb532_enable_irq,
174};
175
176void __init arch_init_irq(void)
177{
178 int i;
179
180 pr_info("Initializing IRQ's: %d out of %d\n", RC32434_NR_IRQS, NR_IRQS);
181
182 for (i = 0; i < RC32434_NR_IRQS; i++)
183 set_irq_chip_and_handler(i, &rc32434_irq_type,
184 handle_level_irq);
185}
186
187/* Main Interrupt dispatcher */
188asmlinkage void plat_irq_dispatch(void)
189{
190 unsigned int ip, pend, group;
191 volatile unsigned int *addr;
192 unsigned int cp0_cause = read_c0_cause() & read_c0_status();
193
194 if (cp0_cause & CAUSEF_IP7) {
195 do_IRQ(7);
196 } else {
197 ip = (cp0_cause & 0x7c00);
198 if (ip) {
199 group = 21 + (fls(ip) - 32);
200
201 addr = intr_group[group].base_addr;
202
203 pend = READ_PEND(addr);
204 pend &= ~READ_MASK(addr); /* only unmasked interrupts */
205 pend = 39 + (fls(pend) - 32);
206 do_IRQ((group << 5) + pend);
207 }
208 }
209}
diff --git a/arch/mips/rb532/prom.c b/arch/mips/rb532/prom.c
new file mode 100644
index 000000000000..1bc0af8febf4
--- /dev/null
+++ b/arch/mips/rb532/prom.c
@@ -0,0 +1,158 @@
1/*
2 * RouterBoard 500 specific prom routines
3 *
4 * Copyright (C) 2003, Peter Sadik <peter.sadik@idt.com>
5 * Copyright (C) 2005-2006, P.Christeas <p_christ@hol.gr>
6 * Copyright (C) 2007, Gabor Juhos <juhosg@openwrt.org>
7 * Felix Fietkau <nbd@openwrt.org>
8 * Florian Fainelli <florian@openwrt.org>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301, USA.
24 *
25 */
26
27#include <linux/init.h>
28#include <linux/mm.h>
29#include <linux/module.h>
30#include <linux/string.h>
31#include <linux/console.h>
32#include <linux/bootmem.h>
33#include <linux/ioport.h>
34#include <linux/blkdev.h>
35
36#include <asm/bootinfo.h>
37#include <asm/mach-rc32434/ddr.h>
38#include <asm/mach-rc32434/prom.h>
39
40extern void __init setup_serial_port(void);
41
42unsigned int idt_cpu_freq = 132000000;
43EXPORT_SYMBOL(idt_cpu_freq);
44unsigned int gpio_bootup_state;
45EXPORT_SYMBOL(gpio_bootup_state);
46
47static struct resource ddr_reg[] = {
48 {
49 .name = "ddr-reg",
50 .start = DDR0_PHYS_ADDR,
51 .end = DDR0_PHYS_ADDR + sizeof(struct ddr_ram),
52 .flags = IORESOURCE_MEM,
53 }
54};
55
56void __init prom_free_prom_memory(void)
57{
58 /* No prom memory to free */
59}
60
61static inline int match_tag(char *arg, const char *tag)
62{
63 return strncmp(arg, tag, strlen(tag)) == 0;
64}
65
66static inline unsigned long tag2ul(char *arg, const char *tag)
67{
68 char *num;
69
70 num = arg + strlen(tag);
71 return simple_strtoul(num, 0, 10);
72}
73
74void __init prom_setup_cmdline(void)
75{
76 char cmd_line[CL_SIZE];
77 char *cp, *board;
78 int prom_argc;
79 char **prom_argv, **prom_envp;
80 int i;
81
82 prom_argc = fw_arg0;
83 prom_argv = (char **) fw_arg1;
84 prom_envp = (char **) fw_arg2;
85
86 cp = cmd_line;
87 /* Note: it is common that parameters start
88 * at argv[1] and not argv[0],
89 * however, our elf loader starts at [0] */
90 for (i = 0; i < prom_argc; i++) {
91 if (match_tag(prom_argv[i], FREQ_TAG)) {
92 idt_cpu_freq = tag2ul(prom_argv[i], FREQ_TAG);
93 continue;
94 }
95#ifdef IGNORE_CMDLINE_MEM
96 /* parses out the "mem=xx" arg */
97 if (match_tag(prom_argv[i], MEM_TAG))
98 continue;
99#endif
100 if (i > 0)
101 *(cp++) = ' ';
102 if (match_tag(prom_argv[i], BOARD_TAG)) {
103 board = prom_argv[i] + strlen(BOARD_TAG);
104
105 if (match_tag(board, BOARD_RB532A))
106 mips_machtype = MACH_MIKROTIK_RB532A;
107 else
108 mips_machtype = MACH_MIKROTIK_RB532;
109 }
110
111 if (match_tag(prom_argv[i], GPIO_TAG))
112 gpio_bootup_state = tag2ul(prom_argv[i], GPIO_TAG);
113
114 strcpy(cp, prom_argv[i]);
115 cp += strlen(prom_argv[i]);
116 }
117 *(cp++) = ' ';
118
119 i = strlen(arcs_cmdline);
120 if (i > 0) {
121 *(cp++) = ' ';
122 strcpy(cp, arcs_cmdline);
123 cp += strlen(arcs_cmdline);
124 }
125 if (gpio_bootup_state & 0x02)
126 strcpy(cp, GPIO_INIT_NOBUTTON);
127 else
128 strcpy(cp, GPIO_INIT_BUTTON);
129
130 cmd_line[CL_SIZE-1] = '\0';
131
132 strcpy(arcs_cmdline, cmd_line);
133}
134
135void __init prom_init(void)
136{
137 struct ddr_ram __iomem *ddr;
138 phys_t memsize;
139 phys_t ddrbase;
140
141 ddr = ioremap_nocache(ddr_reg[0].start,
142 ddr_reg[0].end - ddr_reg[0].start);
143
144 if (!ddr) {
145 printk(KERN_ERR "Unable to remap DDR register\n");
146 return;
147 }
148
149 ddrbase = (phys_t)&ddr->ddrbase;
150 memsize = (phys_t)&ddr->ddrmask;
151 memsize = 0 - memsize;
152
153 prom_setup_cmdline();
154
155 /* give all RAM to boot allocator,
156 * except for the first 0x400 and the last 0x200 bytes */
157 add_memory_region(ddrbase + 0x400, memsize - 0x600, BOOT_MEM_RAM);
158}
diff --git a/arch/mips/rb532/serial.c b/arch/mips/rb532/serial.c
new file mode 100644
index 000000000000..1a05b5ddee09
--- /dev/null
+++ b/arch/mips/rb532/serial.c
@@ -0,0 +1,53 @@
1/*
2 * BRIEF MODULE DESCRIPTION
3 * Serial port initialisation.
4 *
5 * Copyright 2004 IDT Inc. (rischelp@idt.com)
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
15 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
18 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
19 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 675 Mass Ave, Cambridge, MA 02139, USA.
26 */
27
28#include <linux/init.h>
29#include <linux/tty.h>
30#include <linux/serial_core.h>
31#include <linux/serial_8250.h>
32
33#include <asm/serial.h>
34#include <asm/mach-rc32434/rc32434.h>
35
36extern unsigned int idt_cpu_freq;
37
38static struct uart_port rb532_uart = {
39 .type = PORT_16550A,
40 .line = 0,
41 .irq = RC32434_UART0_IRQ,
42 .iotype = UPIO_MEM,
43 .membase = (char *)KSEG1ADDR(RC32434_UART0_BASE),
44 .regshift = 2
45};
46
47int __init setup_serial_port(void)
48{
49 rb532_uart.uartclk = idt_cpu_freq;
50
51 return early_serial_setup(&rb532_uart);
52}
53arch_initcall(setup_serial_port);
diff --git a/arch/mips/rb532/setup.c b/arch/mips/rb532/setup.c
new file mode 100644
index 000000000000..7aafa95ac20b
--- /dev/null
+++ b/arch/mips/rb532/setup.c
@@ -0,0 +1,79 @@
1/*
2 * setup.c - boot time setup code
3 */
4
5#include <linux/init.h>
6
7#include <asm/bootinfo.h>
8#include <asm/reboot.h>
9#include <asm/time.h>
10#include <linux/ioport.h>
11
12#include <asm/mach-rc32434/rc32434.h>
13#include <asm/mach-rc32434/pci.h>
14
15struct pci_reg __iomem *pci_reg;
16EXPORT_SYMBOL(pci_reg);
17
18static struct resource pci0_res[] = {
19 {
20 .name = "pci_reg0",
21 .start = PCI0_BASE_ADDR,
22 .end = PCI0_BASE_ADDR + sizeof(struct pci_reg),
23 .flags = IORESOURCE_MEM,
24 }
25};
26
27static void rb_machine_restart(char *command)
28{
29 /* just jump to the reset vector */
30 writel(0x80000001, (void *)KSEG1ADDR(RC32434_REG_BASE + RC32434_RST));
31 ((void (*)(void)) KSEG1ADDR(0x1FC00000u))();
32}
33
34static void rb_machine_halt(void)
35{
36 for (;;)
37 continue;
38}
39
40void __init plat_mem_setup(void)
41{
42 u32 val;
43
44 _machine_restart = rb_machine_restart;
45 _machine_halt = rb_machine_halt;
46 pm_power_off = rb_machine_halt;
47
48 set_io_port_base(KSEG1);
49
50 pci_reg = ioremap_nocache(pci0_res[0].start,
51 pci0_res[0].end - pci0_res[0].start);
52 if (!pci_reg) {
53 printk(KERN_ERR "Could not remap PCI registers\n");
54 return;
55 }
56
57 val = __raw_readl(&pci_reg->pcic);
58 val &= 0xFFFFFF7;
59 __raw_writel(val, (void *)&pci_reg->pcic);
60
61#ifdef CONFIG_PCI
62 /* Enable PCI interrupts in EPLD Mask register */
63 *epld_mask = 0x0;
64 *(epld_mask + 1) = 0x0;
65#endif
66 write_c0_wired(0);
67}
68
69const char *get_system_type(void)
70{
71 switch (mips_machtype) {
72 case MACH_MIKROTIK_RB532A:
73 return "Mikrotik RB532A";
74 break;
75 default:
76 return "Mikrotik RB532";
77 break;
78 }
79}
diff --git a/arch/mips/rb532/time.c b/arch/mips/rb532/time.c
new file mode 100644
index 000000000000..db74edf8cefb
--- /dev/null
+++ b/arch/mips/rb532/time.c
@@ -0,0 +1,67 @@
1/*
2 * Carsten Langgaard, carstenl@mips.com
3 * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
4 *
5 * This program is free software; you can distribute it and/or modify it
6 * under the terms of the GNU General Public License (Version 2) as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
17 *
18 * Setting up the clock on the MIPS boards.
19 */
20
21#include <linux/init.h>
22#include <linux/kernel_stat.h>
23#include <linux/ptrace.h>
24#include <linux/sched.h>
25#include <linux/spinlock.h>
26#include <linux/mc146818rtc.h>
27#include <linux/irq.h>
28#include <linux/timex.h>
29
30#include <asm/mipsregs.h>
31#include <asm/debug.h>
32#include <asm/time.h>
33#include <asm/mach-rc32434/rc32434.h>
34
35extern unsigned int idt_cpu_freq;
36
37/*
38 * Figure out the r4k offset, the amount to increment the compare
39 * register for each time tick. There is no RTC available.
40 *
41 * The RC32434 counts at half the CPU *core* speed.
42 */
43static unsigned long __init cal_r4koff(void)
44{
45 mips_hpt_frequency = idt_cpu_freq * IDT_CLOCK_MULT / 2;
46
47 return mips_hpt_frequency / HZ;
48}
49
50void __init plat_time_init(void)
51{
52 unsigned int est_freq, flags;
53 unsigned long r4k_offset;
54
55 local_irq_save(flags);
56
57 printk(KERN_INFO "calculating r4koff... ");
58 r4k_offset = cal_r4koff();
59 printk("%08lx(%d)\n", r4k_offset, (int) r4k_offset);
60
61 est_freq = 2 * r4k_offset * HZ;
62 est_freq += 5000; /* round */
63 est_freq -= est_freq % 10000;
64 printk(KERN_INFO "CPU frequency %d.%02d MHz\n", est_freq / 1000000,
65 (est_freq % 1000000) * 100 / 1000000);
66 local_irq_restore(flags);
67}
diff --git a/arch/mips/sgi-ip22/ip22-platform.c b/arch/mips/sgi-ip22/ip22-platform.c
index fc6df96305ed..60141235ec40 100644
--- a/arch/mips/sgi-ip22/ip22-platform.c
+++ b/arch/mips/sgi-ip22/ip22-platform.c
@@ -188,8 +188,7 @@ static int __init sgi_button_devinit(void)
188 if (ip22_is_fullhouse()) 188 if (ip22_is_fullhouse())
189 return 0; /* full house has no volume buttons */ 189 return 0; /* full house has no volume buttons */
190 190
191 return IS_ERR(platform_device_register_simple("sgiindybtns", 191 return IS_ERR(platform_device_register_simple("sgibtns", -1, NULL, 0));
192 -1, NULL, 0));
193} 192}
194 193
195device_initcall(sgi_button_devinit); 194device_initcall(sgi_button_devinit);
diff --git a/arch/mips/sgi-ip22/ip28-berr.c b/arch/mips/sgi-ip22/ip28-berr.c
index fee7a2e0e538..30e12e2ec4b5 100644
--- a/arch/mips/sgi-ip22/ip28-berr.c
+++ b/arch/mips/sgi-ip22/ip28-berr.c
@@ -412,7 +412,7 @@ static int ip28_be_interrupt(const struct pt_regs *regs)
412 * Now we have an asynchronous bus error, speculatively or DMA caused. 412 * Now we have an asynchronous bus error, speculatively or DMA caused.
413 * Need to search all DMA descriptors for the error address. 413 * Need to search all DMA descriptors for the error address.
414 */ 414 */
415 for (i = 0; i < ARRAY_SIZE(hpc3); ++i) { 415 for (i = 0; i < sizeof(hpc3)/sizeof(struct hpc3_stat); ++i) {
416 struct hpc3_stat *hp = (struct hpc3_stat *)&hpc3 + i; 416 struct hpc3_stat *hp = (struct hpc3_stat *)&hpc3 + i;
417 if ((cpu_err_stat & CPU_ERRMASK) && 417 if ((cpu_err_stat & CPU_ERRMASK) &&
418 (cpu_err_addr == hp->ndptr || cpu_err_addr == hp->cbp)) 418 (cpu_err_addr == hp->ndptr || cpu_err_addr == hp->cbp))
@@ -421,7 +421,7 @@ static int ip28_be_interrupt(const struct pt_regs *regs)
421 (gio_err_addr == hp->ndptr || gio_err_addr == hp->cbp)) 421 (gio_err_addr == hp->ndptr || gio_err_addr == hp->cbp))
422 break; 422 break;
423 } 423 }
424 if (i < ARRAY_SIZE(hpc3)) { 424 if (i < sizeof(hpc3)/sizeof(struct hpc3_stat)) {
425 struct hpc3_stat *hp = (struct hpc3_stat *)&hpc3 + i; 425 struct hpc3_stat *hp = (struct hpc3_stat *)&hpc3 + i;
426 printk(KERN_ERR "at DMA addresses: HPC3 @ %08lx:" 426 printk(KERN_ERR "at DMA addresses: HPC3 @ %08lx:"
427 " ctl %08x, ndp %08x, cbp %08x\n", 427 " ctl %08x, ndp %08x, cbp %08x\n",
diff --git a/arch/mips/sgi-ip32/ip32-platform.c b/arch/mips/sgi-ip32/ip32-platform.c
index 2ee401ba0b25..3d63721e0e80 100644
--- a/arch/mips/sgi-ip32/ip32-platform.c
+++ b/arch/mips/sgi-ip32/ip32-platform.c
@@ -85,18 +85,7 @@ device_initcall(sgio2audio_devinit);
85 85
86static __init int sgio2btns_devinit(void) 86static __init int sgio2btns_devinit(void)
87{ 87{
88 struct platform_device *pd; 88 return IS_ERR(platform_device_register_simple("sgibtns", -1, NULL, 0));
89 int ret;
90
91 pd = platform_device_alloc("sgio2btns", -1);
92 if (!pd)
93 return -ENOMEM;
94
95 ret = platform_device_add(pd);
96 if (ret)
97 platform_device_put(pd);
98
99 return ret;
100} 89}
101 90
102device_initcall(sgio2btns_devinit); 91device_initcall(sgio2btns_devinit);
diff --git a/arch/mips/txx9/Kconfig b/arch/mips/txx9/Kconfig
index b92a134ef124..6de4c5aa92be 100644
--- a/arch/mips/txx9/Kconfig
+++ b/arch/mips/txx9/Kconfig
@@ -7,6 +7,8 @@ config TOSHIBA_RBTX4927
7 bool "Toshiba RBTX49[23]7 board" 7 bool "Toshiba RBTX49[23]7 board"
8 depends on MACH_TX49XX 8 depends on MACH_TX49XX
9 select SOC_TX4927 9 select SOC_TX4927
10 # TX4937 is subset of TX4938
11 select SOC_TX4938
10 help 12 help
11 This Toshiba board is based on the TX4927 processor. Say Y here to 13 This Toshiba board is based on the TX4927 processor. Say Y here to
12 support this machine type 14 support this machine type
diff --git a/arch/mips/txx9/generic/Makefile b/arch/mips/txx9/generic/Makefile
index 668fdaad6448..9c120771e65f 100644
--- a/arch/mips/txx9/generic/Makefile
+++ b/arch/mips/txx9/generic/Makefile
@@ -4,8 +4,8 @@
4 4
5obj-y += setup.o 5obj-y += setup.o
6obj-$(CONFIG_PCI) += pci.o 6obj-$(CONFIG_PCI) += pci.o
7obj-$(CONFIG_SOC_TX4927) += mem_tx4927.o irq_tx4927.o 7obj-$(CONFIG_SOC_TX4927) += mem_tx4927.o setup_tx4927.o irq_tx4927.o
8obj-$(CONFIG_SOC_TX4938) += mem_tx4938.o irq_tx4938.o 8obj-$(CONFIG_SOC_TX4938) += mem_tx4927.o setup_tx4938.o irq_tx4938.o
9obj-$(CONFIG_TOSHIBA_FPCIB0) += smsc_fdc37m81x.o 9obj-$(CONFIG_TOSHIBA_FPCIB0) += smsc_fdc37m81x.o
10obj-$(CONFIG_KGDB) += dbgio.o 10obj-$(CONFIG_KGDB) += dbgio.o
11 11
diff --git a/arch/mips/txx9/generic/irq_tx4927.c b/arch/mips/txx9/generic/irq_tx4927.c
index 6377bd8a9050..cbea1fdde82b 100644
--- a/arch/mips/txx9/generic/irq_tx4927.c
+++ b/arch/mips/txx9/generic/irq_tx4927.c
@@ -31,7 +31,7 @@
31void __init tx4927_irq_init(void) 31void __init tx4927_irq_init(void)
32{ 32{
33 mips_cpu_irq_init(); 33 mips_cpu_irq_init();
34 txx9_irq_init(TX4927_IRC_REG); 34 txx9_irq_init(TX4927_IRC_REG & 0xfffffffffULL);
35 set_irq_chained_handler(MIPS_CPU_IRQ_BASE + TX4927_IRC_INT, 35 set_irq_chained_handler(MIPS_CPU_IRQ_BASE + TX4927_IRC_INT,
36 handle_simple_irq); 36 handle_simple_irq);
37} 37}
diff --git a/arch/mips/txx9/generic/irq_tx4938.c b/arch/mips/txx9/generic/irq_tx4938.c
index 5fc86c9c9d2f..6eac684bf190 100644
--- a/arch/mips/txx9/generic/irq_tx4938.c
+++ b/arch/mips/txx9/generic/irq_tx4938.c
@@ -19,7 +19,7 @@
19void __init tx4938_irq_init(void) 19void __init tx4938_irq_init(void)
20{ 20{
21 mips_cpu_irq_init(); 21 mips_cpu_irq_init();
22 txx9_irq_init(TX4938_IRC_REG); 22 txx9_irq_init(TX4938_IRC_REG & 0xfffffffffULL);
23 set_irq_chained_handler(MIPS_CPU_IRQ_BASE + TX4938_IRC_INT, 23 set_irq_chained_handler(MIPS_CPU_IRQ_BASE + TX4938_IRC_INT,
24 handle_simple_irq); 24 handle_simple_irq);
25} 25}
diff --git a/arch/mips/txx9/generic/mem_tx4927.c b/arch/mips/txx9/generic/mem_tx4927.c
index 12dfc377bf2f..ef6ea6e97873 100644
--- a/arch/mips/txx9/generic/mem_tx4927.c
+++ b/arch/mips/txx9/generic/mem_tx4927.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/arch/mips/tx4927/common/tx4927_prom.c 2 * linux/arch/mips/txx9/generic/mem_tx4927.c
3 * 3 *
4 * common tx4927 memory interface 4 * common tx4927 memory interface
5 * 5 *
@@ -32,8 +32,9 @@
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/types.h> 33#include <linux/types.h>
34#include <linux/io.h> 34#include <linux/io.h>
35#include <asm/txx9/tx4927.h>
35 36
36static unsigned int __init tx4927_process_sdccr(unsigned long addr) 37static unsigned int __init tx4927_process_sdccr(u64 __iomem *addr)
37{ 38{
38 u64 val; 39 u64 val;
39 unsigned int sdccr_ce; 40 unsigned int sdccr_ce;
@@ -45,97 +46,32 @@ static unsigned int __init tx4927_process_sdccr(unsigned long addr)
45 unsigned int rs = 0; 46 unsigned int rs = 0;
46 unsigned int cs = 0; 47 unsigned int cs = 0;
47 unsigned int mw = 0; 48 unsigned int mw = 0;
48 unsigned int msize = 0;
49 49
50 val = __raw_readq((void __iomem *)addr); 50 val = __raw_readq(addr);
51 51
52 /* MVMCP -- need #defs for these bits masks */ 52 /* MVMCP -- need #defs for these bits masks */
53 sdccr_ce = ((val & (1 << 10)) >> 10); 53 sdccr_ce = ((val & (1 << 10)) >> 10);
54 sdccr_bs = ((val & (1 << 8)) >> 8); 54 sdccr_bs = ((val & (1 << 8)) >> 8);
55 sdccr_rs = ((val & (3 << 5)) >> 5); 55 sdccr_rs = ((val & (3 << 5)) >> 5);
56 sdccr_cs = ((val & (3 << 2)) >> 2); 56 sdccr_cs = ((val & (7 << 2)) >> 2);
57 sdccr_mw = ((val & (1 << 0)) >> 0); 57 sdccr_mw = ((val & (1 << 0)) >> 0);
58 58
59 if (sdccr_ce) { 59 if (sdccr_ce) {
60 switch (sdccr_bs) { 60 bs = 2 << sdccr_bs;
61 case 0:{ 61 rs = 2048 << sdccr_rs;
62 bs = 2; 62 cs = 256 << sdccr_cs;
63 break; 63 mw = 8 >> sdccr_mw;
64 }
65 case 1:{
66 bs = 4;
67 break;
68 }
69 }
70 switch (sdccr_rs) {
71 case 0:{
72 rs = 2048;
73 break;
74 }
75 case 1:{
76 rs = 4096;
77 break;
78 }
79 case 2:{
80 rs = 8192;
81 break;
82 }
83 case 3:{
84 rs = 0;
85 break;
86 }
87 }
88 switch (sdccr_cs) {
89 case 0:{
90 cs = 256;
91 break;
92 }
93 case 1:{
94 cs = 512;
95 break;
96 }
97 case 2:{
98 cs = 1024;
99 break;
100 }
101 case 3:{
102 cs = 2048;
103 break;
104 }
105 }
106 switch (sdccr_mw) {
107 case 0:{
108 mw = 8;
109 break;
110 } /* 8 bytes = 64 bits */
111 case 1:{
112 mw = 4;
113 break;
114 } /* 4 bytes = 32 bits */
115 }
116 } 64 }
117 65
118 /* bytes per chip MB per chip num chips */ 66 return rs * cs * mw * bs;
119 msize = (((rs * cs * mw) / (1024 * 1024)) * bs);
120
121 return (msize);
122} 67}
123 68
124
125unsigned int __init tx4927_get_mem_size(void) 69unsigned int __init tx4927_get_mem_size(void)
126{ 70{
127 unsigned int c0; 71 unsigned int total = 0;
128 unsigned int c1; 72 int i;
129 unsigned int c2;
130 unsigned int c3;
131 unsigned int total;
132
133 /* MVMCP -- need #defs for these registers */
134 c0 = tx4927_process_sdccr(0xff1f8000);
135 c1 = tx4927_process_sdccr(0xff1f8008);
136 c2 = tx4927_process_sdccr(0xff1f8010);
137 c3 = tx4927_process_sdccr(0xff1f8018);
138 total = c0 + c1 + c2 + c3;
139 73
140 return (total); 74 for (i = 0; i < ARRAY_SIZE(tx4927_sdramcptr->cr); i++)
75 total += tx4927_process_sdccr(&tx4927_sdramcptr->cr[i]);
76 return total;
141} 77}
diff --git a/arch/mips/txx9/generic/mem_tx4938.c b/arch/mips/txx9/generic/mem_tx4938.c
deleted file mode 100644
index 20baeaeba4cd..000000000000
--- a/arch/mips/txx9/generic/mem_tx4938.c
+++ /dev/null
@@ -1,124 +0,0 @@
1/*
2 * linux/arch/mips/tx4938/common/prom.c
3 *
4 * common tx4938 memory interface
5 * Copyright (C) 2000-2001 Toshiba Corporation
6 *
7 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
8 * terms of the GNU General Public License version 2. This program is
9 * licensed "as is" without any warranty of any kind, whether express
10 * or implied.
11 *
12 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
13 */
14
15#include <linux/init.h>
16#include <linux/types.h>
17#include <linux/io.h>
18
19static unsigned int __init
20tx4938_process_sdccr(u64 * addr)
21{
22 u64 val;
23 unsigned int sdccr_ce;
24 unsigned int sdccr_rs;
25 unsigned int sdccr_cs;
26 unsigned int sdccr_mw;
27 unsigned int rs = 0;
28 unsigned int cs = 0;
29 unsigned int mw = 0;
30 unsigned int bc = 4;
31 unsigned int msize = 0;
32
33 val = ____raw_readq((void __iomem *)addr);
34
35 /* MVMCP -- need #defs for these bits masks */
36 sdccr_ce = ((val & (1 << 10)) >> 10);
37 sdccr_rs = ((val & (3 << 5)) >> 5);
38 sdccr_cs = ((val & (7 << 2)) >> 2);
39 sdccr_mw = ((val & (1 << 0)) >> 0);
40
41 if (sdccr_ce) {
42 switch (sdccr_rs) {
43 case 0:{
44 rs = 2048;
45 break;
46 }
47 case 1:{
48 rs = 4096;
49 break;
50 }
51 case 2:{
52 rs = 8192;
53 break;
54 }
55 default:{
56 rs = 0;
57 break;
58 }
59 }
60 switch (sdccr_cs) {
61 case 0:{
62 cs = 256;
63 break;
64 }
65 case 1:{
66 cs = 512;
67 break;
68 }
69 case 2:{
70 cs = 1024;
71 break;
72 }
73 case 3:{
74 cs = 2048;
75 break;
76 }
77 case 4:{
78 cs = 4096;
79 break;
80 }
81 default:{
82 cs = 0;
83 break;
84 }
85 }
86 switch (sdccr_mw) {
87 case 0:{
88 mw = 8;
89 break;
90 } /* 8 bytes = 64 bits */
91 case 1:{
92 mw = 4;
93 break;
94 } /* 4 bytes = 32 bits */
95 }
96 }
97
98 /* bytes per chip MB per chip bank count */
99 msize = (((rs * cs * mw) / (1024 * 1024)) * (bc));
100
101 /* MVMCP -- bc hard coded to 4 from table 9.3.1 */
102 /* boad supports bc=2 but no way to detect */
103
104 return (msize);
105}
106
107unsigned int __init
108tx4938_get_mem_size(void)
109{
110 unsigned int c0;
111 unsigned int c1;
112 unsigned int c2;
113 unsigned int c3;
114 unsigned int total;
115
116 /* MVMCP -- need #defs for these registers */
117 c0 = tx4938_process_sdccr((u64 *) 0xff1f8000);
118 c1 = tx4938_process_sdccr((u64 *) 0xff1f8008);
119 c2 = tx4938_process_sdccr((u64 *) 0xff1f8010);
120 c3 = tx4938_process_sdccr((u64 *) 0xff1f8018);
121 total = c0 + c1 + c2 + c3;
122
123 return (total);
124}
diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index 5afc5d5cab03..8c60c78b9a9e 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -19,7 +19,9 @@
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/clk.h> 20#include <linux/clk.h>
21#include <linux/err.h> 21#include <linux/err.h>
22#include <linux/gpio.h>
22#include <asm/bootinfo.h> 23#include <asm/bootinfo.h>
24#include <asm/time.h>
23#include <asm/txx9/generic.h> 25#include <asm/txx9/generic.h>
24#ifdef CONFIG_CPU_TX49XX 26#ifdef CONFIG_CPU_TX49XX
25#include <asm/txx9/tx4938.h> 27#include <asm/txx9/tx4938.h>
@@ -30,6 +32,7 @@ struct resource txx9_ce_res[8];
30static char txx9_ce_res_name[8][4]; /* "CEn" */ 32static char txx9_ce_res_name[8][4]; /* "CEn" */
31 33
32/* pcode, internal register */ 34/* pcode, internal register */
35unsigned int txx9_pcode;
33char txx9_pcode_str[8]; 36char txx9_pcode_str[8];
34static struct resource txx9_reg_res = { 37static struct resource txx9_reg_res = {
35 .name = txx9_pcode_str, 38 .name = txx9_pcode_str,
@@ -59,15 +62,16 @@ unsigned int txx9_master_clock;
59unsigned int txx9_cpu_clock; 62unsigned int txx9_cpu_clock;
60unsigned int txx9_gbus_clock; 63unsigned int txx9_gbus_clock;
61 64
65int txx9_ccfg_toeon __initdata = 1;
62 66
63/* Minimum CLK support */ 67/* Minimum CLK support */
64 68
65struct clk *clk_get(struct device *dev, const char *id) 69struct clk *clk_get(struct device *dev, const char *id)
66{ 70{
67 if (!strcmp(id, "spi-baseclk")) 71 if (!strcmp(id, "spi-baseclk"))
68 return (struct clk *)(txx9_gbus_clock / 2 / 4); 72 return (struct clk *)((unsigned long)txx9_gbus_clock / 2 / 4);
69 if (!strcmp(id, "imbus_clk")) 73 if (!strcmp(id, "imbus_clk"))
70 return (struct clk *)(txx9_gbus_clock / 2); 74 return (struct clk *)((unsigned long)txx9_gbus_clock / 2);
71 return ERR_PTR(-ENOENT); 75 return ERR_PTR(-ENOENT);
72} 76}
73EXPORT_SYMBOL(clk_get); 77EXPORT_SYMBOL(clk_get);
@@ -94,6 +98,22 @@ void clk_put(struct clk *clk)
94} 98}
95EXPORT_SYMBOL(clk_put); 99EXPORT_SYMBOL(clk_put);
96 100
101/* GPIO support */
102
103#ifdef CONFIG_GENERIC_GPIO
104int gpio_to_irq(unsigned gpio)
105{
106 return -EINVAL;
107}
108EXPORT_SYMBOL(gpio_to_irq);
109
110int irq_to_gpio(unsigned irq)
111{
112 return -EINVAL;
113}
114EXPORT_SYMBOL(irq_to_gpio);
115#endif
116
97extern struct txx9_board_vec jmr3927_vec; 117extern struct txx9_board_vec jmr3927_vec;
98extern struct txx9_board_vec rbtx4927_vec; 118extern struct txx9_board_vec rbtx4927_vec;
99extern struct txx9_board_vec rbtx4937_vec; 119extern struct txx9_board_vec rbtx4937_vec;
@@ -107,6 +127,12 @@ void __init prom_init_cmdline(void)
107 int argc = (int)fw_arg0; 127 int argc = (int)fw_arg0;
108 char **argv = (char **)fw_arg1; 128 char **argv = (char **)fw_arg1;
109 int i; /* Always ignore the "-c" at argv[0] */ 129 int i; /* Always ignore the "-c" at argv[0] */
130#ifdef CONFIG_64BIT
131 char *fixed_argv[32];
132 for (i = 0; i < argc; i++)
133 fixed_argv[i] = (char *)(long)(*((__s32 *)argv + i));
134 argv = fixed_argv;
135#endif
110 136
111 /* ignore all built-in args if any f/w args given */ 137 /* ignore all built-in args if any f/w args given */
112 if (argc > 1) 138 if (argc > 1)
@@ -126,15 +152,19 @@ void __init prom_init(void)
126#endif 152#endif
127#ifdef CONFIG_CPU_TX49XX 153#ifdef CONFIG_CPU_TX49XX
128 switch (TX4938_REV_PCODE()) { 154 switch (TX4938_REV_PCODE()) {
155#ifdef CONFIG_TOSHIBA_RBTX4927
129 case 0x4927: 156 case 0x4927:
130 txx9_board_vec = &rbtx4927_vec; 157 txx9_board_vec = &rbtx4927_vec;
131 break; 158 break;
132 case 0x4937: 159 case 0x4937:
133 txx9_board_vec = &rbtx4937_vec; 160 txx9_board_vec = &rbtx4937_vec;
134 break; 161 break;
162#endif
163#ifdef CONFIG_TOSHIBA_RBTX4938
135 case 0x4938: 164 case 0x4938:
136 txx9_board_vec = &rbtx4938_vec; 165 txx9_board_vec = &rbtx4938_vec;
137 break; 166 break;
167#endif
138 } 168 }
139#endif 169#endif
140 170
@@ -160,6 +190,10 @@ char * __init prom_getcmdline(void)
160/* wrappers */ 190/* wrappers */
161void __init plat_mem_setup(void) 191void __init plat_mem_setup(void)
162{ 192{
193 ioport_resource.start = 0;
194 ioport_resource.end = ~0UL; /* no limit */
195 iomem_resource.start = 0;
196 iomem_resource.end = ~0UL; /* no limit */
163 txx9_board_vec->mem_setup(); 197 txx9_board_vec->mem_setup();
164} 198}
165 199
diff --git a/arch/mips/txx9/generic/setup_tx4927.c b/arch/mips/txx9/generic/setup_tx4927.c
new file mode 100644
index 000000000000..89d6e28add93
--- /dev/null
+++ b/arch/mips/txx9/generic/setup_tx4927.c
@@ -0,0 +1,194 @@
1/*
2 * TX4927 setup routines
3 * Based on linux/arch/mips/txx9/rbtx4938/setup.c,
4 * and RBTX49xx patch from CELF patch archive.
5 *
6 * 2003-2005 (c) MontaVista Software, Inc.
7 * (C) Copyright TOSHIBA CORPORATION 2000-2001, 2004-2007
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
12 */
13#include <linux/init.h>
14#include <linux/ioport.h>
15#include <linux/delay.h>
16#include <linux/serial_core.h>
17#include <linux/param.h>
18#include <asm/txx9irq.h>
19#include <asm/txx9tmr.h>
20#include <asm/txx9pio.h>
21#include <asm/txx9/generic.h>
22#include <asm/txx9/tx4927.h>
23
24void __init tx4927_wdr_init(void)
25{
26 /* clear WatchDogReset (W1C) */
27 tx4927_ccfg_set(TX4927_CCFG_WDRST);
28 /* do reset on watchdog */
29 tx4927_ccfg_set(TX4927_CCFG_WR);
30}
31
32static struct resource tx4927_sdram_resource[4];
33
34void __init tx4927_setup(void)
35{
36 int i;
37 __u32 divmode;
38 int cpuclk = 0;
39 u64 ccfg;
40
41 txx9_reg_res_init(TX4927_REV_PCODE(), TX4927_REG_BASE,
42 TX4927_REG_SIZE);
43
44 /* SDRAMC,EBUSC are configured by PROM */
45 for (i = 0; i < 8; i++) {
46 if (!(TX4927_EBUSC_CR(i) & 0x8))
47 continue; /* disabled */
48 txx9_ce_res[i].start = (unsigned long)TX4927_EBUSC_BA(i);
49 txx9_ce_res[i].end =
50 txx9_ce_res[i].start + TX4927_EBUSC_SIZE(i) - 1;
51 request_resource(&iomem_resource, &txx9_ce_res[i]);
52 }
53
54 /* clocks */
55 ccfg = ____raw_readq(&tx4927_ccfgptr->ccfg);
56 if (txx9_master_clock) {
57 /* calculate gbus_clock and cpu_clock from master_clock */
58 divmode = (__u32)ccfg & TX4927_CCFG_DIVMODE_MASK;
59 switch (divmode) {
60 case TX4927_CCFG_DIVMODE_8:
61 case TX4927_CCFG_DIVMODE_10:
62 case TX4927_CCFG_DIVMODE_12:
63 case TX4927_CCFG_DIVMODE_16:
64 txx9_gbus_clock = txx9_master_clock * 4; break;
65 default:
66 txx9_gbus_clock = txx9_master_clock;
67 }
68 switch (divmode) {
69 case TX4927_CCFG_DIVMODE_2:
70 case TX4927_CCFG_DIVMODE_8:
71 cpuclk = txx9_gbus_clock * 2; break;
72 case TX4927_CCFG_DIVMODE_2_5:
73 case TX4927_CCFG_DIVMODE_10:
74 cpuclk = txx9_gbus_clock * 5 / 2; break;
75 case TX4927_CCFG_DIVMODE_3:
76 case TX4927_CCFG_DIVMODE_12:
77 cpuclk = txx9_gbus_clock * 3; break;
78 case TX4927_CCFG_DIVMODE_4:
79 case TX4927_CCFG_DIVMODE_16:
80 cpuclk = txx9_gbus_clock * 4; break;
81 }
82 txx9_cpu_clock = cpuclk;
83 } else {
84 if (txx9_cpu_clock == 0)
85 txx9_cpu_clock = 200000000; /* 200MHz */
86 /* calculate gbus_clock and master_clock from cpu_clock */
87 cpuclk = txx9_cpu_clock;
88 divmode = (__u32)ccfg & TX4927_CCFG_DIVMODE_MASK;
89 switch (divmode) {
90 case TX4927_CCFG_DIVMODE_2:
91 case TX4927_CCFG_DIVMODE_8:
92 txx9_gbus_clock = cpuclk / 2; break;
93 case TX4927_CCFG_DIVMODE_2_5:
94 case TX4927_CCFG_DIVMODE_10:
95 txx9_gbus_clock = cpuclk * 2 / 5; break;
96 case TX4927_CCFG_DIVMODE_3:
97 case TX4927_CCFG_DIVMODE_12:
98 txx9_gbus_clock = cpuclk / 3; break;
99 case TX4927_CCFG_DIVMODE_4:
100 case TX4927_CCFG_DIVMODE_16:
101 txx9_gbus_clock = cpuclk / 4; break;
102 }
103 switch (divmode) {
104 case TX4927_CCFG_DIVMODE_8:
105 case TX4927_CCFG_DIVMODE_10:
106 case TX4927_CCFG_DIVMODE_12:
107 case TX4927_CCFG_DIVMODE_16:
108 txx9_master_clock = txx9_gbus_clock / 4; break;
109 default:
110 txx9_master_clock = txx9_gbus_clock;
111 }
112 }
113 /* change default value to udelay/mdelay take reasonable time */
114 loops_per_jiffy = txx9_cpu_clock / HZ / 2;
115
116 /* CCFG */
117 tx4927_wdr_init();
118 /* clear BusErrorOnWrite flag (W1C) */
119 tx4927_ccfg_set(TX4927_CCFG_BEOW);
120 /* enable Timeout BusError */
121 if (txx9_ccfg_toeon)
122 tx4927_ccfg_set(TX4927_CCFG_TOE);
123
124 /* DMA selection */
125 txx9_clear64(&tx4927_ccfgptr->pcfg, TX4927_PCFG_DMASEL_ALL);
126
127 /* Use external clock for external arbiter */
128 if (!(____raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_PCIARB))
129 txx9_clear64(&tx4927_ccfgptr->pcfg, TX4927_PCFG_PCICLKEN_ALL);
130
131 printk(KERN_INFO "%s -- %dMHz(M%dMHz) CRIR:%08x CCFG:%llx PCFG:%llx\n",
132 txx9_pcode_str,
133 (cpuclk + 500000) / 1000000,
134 (txx9_master_clock + 500000) / 1000000,
135 (__u32)____raw_readq(&tx4927_ccfgptr->crir),
136 (unsigned long long)____raw_readq(&tx4927_ccfgptr->ccfg),
137 (unsigned long long)____raw_readq(&tx4927_ccfgptr->pcfg));
138
139 printk(KERN_INFO "%s SDRAMC --", txx9_pcode_str);
140 for (i = 0; i < 4; i++) {
141 __u64 cr = TX4927_SDRAMC_CR(i);
142 unsigned long base, size;
143 if (!((__u32)cr & 0x00000400))
144 continue; /* disabled */
145 base = (unsigned long)(cr >> 49) << 21;
146 size = (((unsigned long)(cr >> 33) & 0x7fff) + 1) << 21;
147 printk(" CR%d:%016llx", i, (unsigned long long)cr);
148 tx4927_sdram_resource[i].name = "SDRAM";
149 tx4927_sdram_resource[i].start = base;
150 tx4927_sdram_resource[i].end = base + size - 1;
151 tx4927_sdram_resource[i].flags = IORESOURCE_MEM;
152 request_resource(&iomem_resource, &tx4927_sdram_resource[i]);
153 }
154 printk(" TR:%09llx\n",
155 (unsigned long long)____raw_readq(&tx4927_sdramcptr->tr));
156
157 /* TMR */
158 /* disable all timers */
159 for (i = 0; i < TX4927_NR_TMR; i++)
160 txx9_tmr_init(TX4927_TMR_REG(i) & 0xfffffffffULL);
161
162 /* PIO */
163 txx9_gpio_init(TX4927_PIO_REG & 0xfffffffffULL, 0, TX4927_NUM_PIO);
164 __raw_writel(0, &tx4927_pioptr->maskcpu);
165 __raw_writel(0, &tx4927_pioptr->maskext);
166}
167
168void __init tx4927_time_init(unsigned int tmrnr)
169{
170 if (____raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_TINTDIS)
171 txx9_clockevent_init(TX4927_TMR_REG(tmrnr) & 0xfffffffffULL,
172 TXX9_IRQ_BASE + TX4927_IR_TMR(tmrnr),
173 TXX9_IMCLK);
174}
175
176void __init tx4927_setup_serial(void)
177{
178#ifdef CONFIG_SERIAL_TXX9
179 int i;
180 struct uart_port req;
181
182 for (i = 0; i < 2; i++) {
183 memset(&req, 0, sizeof(req));
184 req.line = i;
185 req.iotype = UPIO_MEM;
186 req.membase = (unsigned char __iomem *)TX4927_SIO_REG(i);
187 req.mapbase = TX4927_SIO_REG(i) & 0xfffffffffULL;
188 req.irq = TXX9_IRQ_BASE + TX4927_IR_SIO(i);
189 req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/;
190 req.uartclk = TXX9_IMCLK;
191 early_serial_txx9_setup(&req);
192 }
193#endif /* CONFIG_SERIAL_TXX9 */
194}
diff --git a/arch/mips/txx9/generic/setup_tx4938.c b/arch/mips/txx9/generic/setup_tx4938.c
new file mode 100644
index 000000000000..317378d8579d
--- /dev/null
+++ b/arch/mips/txx9/generic/setup_tx4938.c
@@ -0,0 +1,259 @@
1/*
2 * TX4938/4937 setup routines
3 * Based on linux/arch/mips/txx9/rbtx4938/setup.c,
4 * and RBTX49xx patch from CELF patch archive.
5 *
6 * 2003-2005 (c) MontaVista Software, Inc.
7 * (C) Copyright TOSHIBA CORPORATION 2000-2001, 2004-2007
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
12 */
13#include <linux/init.h>
14#include <linux/ioport.h>
15#include <linux/delay.h>
16#include <linux/serial_core.h>
17#include <linux/param.h>
18#include <asm/txx9irq.h>
19#include <asm/txx9tmr.h>
20#include <asm/txx9pio.h>
21#include <asm/txx9/generic.h>
22#include <asm/txx9/tx4938.h>
23
24void __init tx4938_wdr_init(void)
25{
26 /* clear WatchDogReset (W1C) */
27 tx4938_ccfg_set(TX4938_CCFG_WDRST);
28 /* do reset on watchdog */
29 tx4938_ccfg_set(TX4938_CCFG_WR);
30}
31
32static struct resource tx4938_sdram_resource[4];
33static struct resource tx4938_sram_resource;
34
35#define TX4938_SRAM_SIZE 0x800
36
37void __init tx4938_setup(void)
38{
39 int i;
40 __u32 divmode;
41 int cpuclk = 0;
42 u64 ccfg;
43
44 txx9_reg_res_init(TX4938_REV_PCODE(), TX4938_REG_BASE,
45 TX4938_REG_SIZE);
46
47 /* SDRAMC,EBUSC are configured by PROM */
48 for (i = 0; i < 8; i++) {
49 if (!(TX4938_EBUSC_CR(i) & 0x8))
50 continue; /* disabled */
51 txx9_ce_res[i].start = (unsigned long)TX4938_EBUSC_BA(i);
52 txx9_ce_res[i].end =
53 txx9_ce_res[i].start + TX4938_EBUSC_SIZE(i) - 1;
54 request_resource(&iomem_resource, &txx9_ce_res[i]);
55 }
56
57 /* clocks */
58 ccfg = ____raw_readq(&tx4938_ccfgptr->ccfg);
59 if (txx9_master_clock) {
60 /* calculate gbus_clock and cpu_clock from master_clock */
61 divmode = (__u32)ccfg & TX4938_CCFG_DIVMODE_MASK;
62 switch (divmode) {
63 case TX4938_CCFG_DIVMODE_8:
64 case TX4938_CCFG_DIVMODE_10:
65 case TX4938_CCFG_DIVMODE_12:
66 case TX4938_CCFG_DIVMODE_16:
67 case TX4938_CCFG_DIVMODE_18:
68 txx9_gbus_clock = txx9_master_clock * 4; break;
69 default:
70 txx9_gbus_clock = txx9_master_clock;
71 }
72 switch (divmode) {
73 case TX4938_CCFG_DIVMODE_2:
74 case TX4938_CCFG_DIVMODE_8:
75 cpuclk = txx9_gbus_clock * 2; break;
76 case TX4938_CCFG_DIVMODE_2_5:
77 case TX4938_CCFG_DIVMODE_10:
78 cpuclk = txx9_gbus_clock * 5 / 2; break;
79 case TX4938_CCFG_DIVMODE_3:
80 case TX4938_CCFG_DIVMODE_12:
81 cpuclk = txx9_gbus_clock * 3; break;
82 case TX4938_CCFG_DIVMODE_4:
83 case TX4938_CCFG_DIVMODE_16:
84 cpuclk = txx9_gbus_clock * 4; break;
85 case TX4938_CCFG_DIVMODE_4_5:
86 case TX4938_CCFG_DIVMODE_18:
87 cpuclk = txx9_gbus_clock * 9 / 2; break;
88 }
89 txx9_cpu_clock = cpuclk;
90 } else {
91 if (txx9_cpu_clock == 0)
92 txx9_cpu_clock = 300000000; /* 300MHz */
93 /* calculate gbus_clock and master_clock from cpu_clock */
94 cpuclk = txx9_cpu_clock;
95 divmode = (__u32)ccfg & TX4938_CCFG_DIVMODE_MASK;
96 switch (divmode) {
97 case TX4938_CCFG_DIVMODE_2:
98 case TX4938_CCFG_DIVMODE_8:
99 txx9_gbus_clock = cpuclk / 2; break;
100 case TX4938_CCFG_DIVMODE_2_5:
101 case TX4938_CCFG_DIVMODE_10:
102 txx9_gbus_clock = cpuclk * 2 / 5; break;
103 case TX4938_CCFG_DIVMODE_3:
104 case TX4938_CCFG_DIVMODE_12:
105 txx9_gbus_clock = cpuclk / 3; break;
106 case TX4938_CCFG_DIVMODE_4:
107 case TX4938_CCFG_DIVMODE_16:
108 txx9_gbus_clock = cpuclk / 4; break;
109 case TX4938_CCFG_DIVMODE_4_5:
110 case TX4938_CCFG_DIVMODE_18:
111 txx9_gbus_clock = cpuclk * 2 / 9; break;
112 }
113 switch (divmode) {
114 case TX4938_CCFG_DIVMODE_8:
115 case TX4938_CCFG_DIVMODE_10:
116 case TX4938_CCFG_DIVMODE_12:
117 case TX4938_CCFG_DIVMODE_16:
118 case TX4938_CCFG_DIVMODE_18:
119 txx9_master_clock = txx9_gbus_clock / 4; break;
120 default:
121 txx9_master_clock = txx9_gbus_clock;
122 }
123 }
124 /* change default value to udelay/mdelay take reasonable time */
125 loops_per_jiffy = txx9_cpu_clock / HZ / 2;
126
127 /* CCFG */
128 tx4938_wdr_init();
129 /* clear BusErrorOnWrite flag (W1C) */
130 tx4938_ccfg_set(TX4938_CCFG_BEOW);
131 /* enable Timeout BusError */
132 if (txx9_ccfg_toeon)
133 tx4938_ccfg_set(TX4938_CCFG_TOE);
134
135 /* DMA selection */
136 txx9_clear64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_DMASEL_ALL);
137
138 /* Use external clock for external arbiter */
139 if (!(____raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCIARB))
140 txx9_clear64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_PCICLKEN_ALL);
141
142 printk(KERN_INFO "%s -- %dMHz(M%dMHz) CRIR:%08x CCFG:%llx PCFG:%llx\n",
143 txx9_pcode_str,
144 (cpuclk + 500000) / 1000000,
145 (txx9_master_clock + 500000) / 1000000,
146 (__u32)____raw_readq(&tx4938_ccfgptr->crir),
147 (unsigned long long)____raw_readq(&tx4938_ccfgptr->ccfg),
148 (unsigned long long)____raw_readq(&tx4938_ccfgptr->pcfg));
149
150 printk(KERN_INFO "%s SDRAMC --", txx9_pcode_str);
151 for (i = 0; i < 4; i++) {
152 __u64 cr = TX4938_SDRAMC_CR(i);
153 unsigned long base, size;
154 if (!((__u32)cr & 0x00000400))
155 continue; /* disabled */
156 base = (unsigned long)(cr >> 49) << 21;
157 size = (((unsigned long)(cr >> 33) & 0x7fff) + 1) << 21;
158 printk(" CR%d:%016llx", i, (unsigned long long)cr);
159 tx4938_sdram_resource[i].name = "SDRAM";
160 tx4938_sdram_resource[i].start = base;
161 tx4938_sdram_resource[i].end = base + size - 1;
162 tx4938_sdram_resource[i].flags = IORESOURCE_MEM;
163 request_resource(&iomem_resource, &tx4938_sdram_resource[i]);
164 }
165 printk(" TR:%09llx\n",
166 (unsigned long long)____raw_readq(&tx4938_sdramcptr->tr));
167
168 /* SRAM */
169 if (txx9_pcode == 0x4938 && ____raw_readq(&tx4938_sramcptr->cr) & 1) {
170 unsigned int size = TX4938_SRAM_SIZE;
171 tx4938_sram_resource.name = "SRAM";
172 tx4938_sram_resource.start =
173 (____raw_readq(&tx4938_sramcptr->cr) >> (39-11))
174 & ~(size - 1);
175 tx4938_sram_resource.end =
176 tx4938_sram_resource.start + TX4938_SRAM_SIZE - 1;
177 tx4938_sram_resource.flags = IORESOURCE_MEM;
178 request_resource(&iomem_resource, &tx4938_sram_resource);
179 }
180
181 /* TMR */
182 /* disable all timers */
183 for (i = 0; i < TX4938_NR_TMR; i++)
184 txx9_tmr_init(TX4938_TMR_REG(i) & 0xfffffffffULL);
185
186 /* DMA */
187 for (i = 0; i < 2; i++)
188 ____raw_writeq(TX4938_DMA_MCR_MSTEN,
189 (void __iomem *)(TX4938_DMA_REG(i) + 0x50));
190
191 /* PIO */
192 txx9_gpio_init(TX4938_PIO_REG & 0xfffffffffULL, 0, TX4938_NUM_PIO);
193 __raw_writel(0, &tx4938_pioptr->maskcpu);
194 __raw_writel(0, &tx4938_pioptr->maskext);
195
196 if (txx9_pcode == 0x4938) {
197 __u64 pcfg = ____raw_readq(&tx4938_ccfgptr->pcfg);
198 /* set PCIC1 reset */
199 txx9_set64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIC1RST);
200 if (pcfg & (TX4938_PCFG_ETH0_SEL | TX4938_PCFG_ETH1_SEL)) {
201 mdelay(1); /* at least 128 cpu clock */
202 /* clear PCIC1 reset */
203 txx9_clear64(&tx4938_ccfgptr->clkctr,
204 TX4938_CLKCTR_PCIC1RST);
205 } else {
206 printk(KERN_INFO "%s: stop PCIC1\n", txx9_pcode_str);
207 /* stop PCIC1 */
208 txx9_set64(&tx4938_ccfgptr->clkctr,
209 TX4938_CLKCTR_PCIC1CKD);
210 }
211 if (!(pcfg & TX4938_PCFG_ETH0_SEL)) {
212 printk(KERN_INFO "%s: stop ETH0\n", txx9_pcode_str);
213 txx9_set64(&tx4938_ccfgptr->clkctr,
214 TX4938_CLKCTR_ETH0RST);
215 txx9_set64(&tx4938_ccfgptr->clkctr,
216 TX4938_CLKCTR_ETH0CKD);
217 }
218 if (!(pcfg & TX4938_PCFG_ETH1_SEL)) {
219 printk(KERN_INFO "%s: stop ETH1\n", txx9_pcode_str);
220 txx9_set64(&tx4938_ccfgptr->clkctr,
221 TX4938_CLKCTR_ETH1RST);
222 txx9_set64(&tx4938_ccfgptr->clkctr,
223 TX4938_CLKCTR_ETH1CKD);
224 }
225 }
226}
227
228void __init tx4938_time_init(unsigned int tmrnr)
229{
230 if (____raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_TINTDIS)
231 txx9_clockevent_init(TX4938_TMR_REG(tmrnr) & 0xfffffffffULL,
232 TXX9_IRQ_BASE + TX4938_IR_TMR(tmrnr),
233 TXX9_IMCLK);
234}
235
236void __init tx4938_setup_serial(void)
237{
238#ifdef CONFIG_SERIAL_TXX9
239 int i;
240 struct uart_port req;
241 unsigned int ch_mask = 0;
242
243 if (__raw_readq(&tx4938_ccfgptr->pcfg) & TX4938_PCFG_ETH0_SEL)
244 ch_mask |= 1 << 1; /* disable SIO1 by PCFG setting */
245 for (i = 0; i < 2; i++) {
246 if ((1 << i) & ch_mask)
247 continue;
248 memset(&req, 0, sizeof(req));
249 req.line = i;
250 req.iotype = UPIO_MEM;
251 req.membase = (unsigned char __iomem *)TX4938_SIO_REG(i);
252 req.mapbase = TX4938_SIO_REG(i) & 0xfffffffffULL;
253 req.irq = TXX9_IRQ_BASE + TX4938_IR_SIO(i);
254 req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/;
255 req.uartclk = TXX9_IMCLK;
256 early_serial_txx9_setup(&req);
257 }
258#endif /* CONFIG_SERIAL_TXX9 */
259}
diff --git a/arch/mips/txx9/jmr3927/setup.c b/arch/mips/txx9/jmr3927/setup.c
index 5e35ef73c5a5..03647ebe4130 100644
--- a/arch/mips/txx9/jmr3927/setup.c
+++ b/arch/mips/txx9/jmr3927/setup.c
@@ -105,14 +105,6 @@ static void __init jmr3927_mem_setup(void)
105 _machine_halt = jmr3927_machine_halt; 105 _machine_halt = jmr3927_machine_halt;
106 pm_power_off = jmr3927_machine_power_off; 106 pm_power_off = jmr3927_machine_power_off;
107 107
108 /*
109 * IO/MEM resources.
110 */
111 ioport_resource.start = 0;
112 ioport_resource.end = 0xffffffff;
113 iomem_resource.start = 0;
114 iomem_resource.end = 0xffffffff;
115
116 /* Reboot on panic */ 108 /* Reboot on panic */
117 panic_timeout = 180; 109 panic_timeout = 180;
118 110
diff --git a/arch/mips/txx9/rbtx4927/irq.c b/arch/mips/txx9/rbtx4927/irq.c
index 70f13211bc2a..cd748a930328 100644
--- a/arch/mips/txx9/rbtx4927/irq.c
+++ b/arch/mips/txx9/rbtx4927/irq.c
@@ -126,14 +126,12 @@ static struct irq_chip toshiba_rbtx4927_irq_ioc_type = {
126 .mask_ack = toshiba_rbtx4927_irq_ioc_disable, 126 .mask_ack = toshiba_rbtx4927_irq_ioc_disable,
127 .unmask = toshiba_rbtx4927_irq_ioc_enable, 127 .unmask = toshiba_rbtx4927_irq_ioc_enable,
128}; 128};
129#define TOSHIBA_RBTX4927_IOC_INTR_ENAB (void __iomem *)0xbc002000UL
130#define TOSHIBA_RBTX4927_IOC_INTR_STAT (void __iomem *)0xbc002006UL
131 129
132static int toshiba_rbtx4927_irq_nested(int sw_irq) 130static int toshiba_rbtx4927_irq_nested(int sw_irq)
133{ 131{
134 u8 level3; 132 u8 level3;
135 133
136 level3 = readb(TOSHIBA_RBTX4927_IOC_INTR_STAT) & 0x1f; 134 level3 = readb(rbtx4927_imstat_addr) & 0x1f;
137 if (level3) 135 if (level3)
138 sw_irq = RBTX4927_IRQ_IOC + fls(level3) - 1; 136 sw_irq = RBTX4927_IRQ_IOC + fls(level3) - 1;
139 return (sw_irq); 137 return (sw_irq);
@@ -154,18 +152,18 @@ static void toshiba_rbtx4927_irq_ioc_enable(unsigned int irq)
154{ 152{
155 unsigned char v; 153 unsigned char v;
156 154
157 v = readb(TOSHIBA_RBTX4927_IOC_INTR_ENAB); 155 v = readb(rbtx4927_imask_addr);
158 v |= (1 << (irq - RBTX4927_IRQ_IOC)); 156 v |= (1 << (irq - RBTX4927_IRQ_IOC));
159 writeb(v, TOSHIBA_RBTX4927_IOC_INTR_ENAB); 157 writeb(v, rbtx4927_imask_addr);
160} 158}
161 159
162static void toshiba_rbtx4927_irq_ioc_disable(unsigned int irq) 160static void toshiba_rbtx4927_irq_ioc_disable(unsigned int irq)
163{ 161{
164 unsigned char v; 162 unsigned char v;
165 163
166 v = readb(TOSHIBA_RBTX4927_IOC_INTR_ENAB); 164 v = readb(rbtx4927_imask_addr);
167 v &= ~(1 << (irq - RBTX4927_IRQ_IOC)); 165 v &= ~(1 << (irq - RBTX4927_IRQ_IOC));
168 writeb(v, TOSHIBA_RBTX4927_IOC_INTR_ENAB); 166 writeb(v, rbtx4927_imask_addr);
169 mmiowb(); 167 mmiowb();
170} 168}
171 169
diff --git a/arch/mips/txx9/rbtx4927/prom.c b/arch/mips/txx9/rbtx4927/prom.c
index 942e627d2dc1..5c0de54ebdd2 100644
--- a/arch/mips/txx9/rbtx4927/prom.c
+++ b/arch/mips/txx9/rbtx4927/prom.c
@@ -36,10 +36,6 @@
36 36
37void __init rbtx4927_prom_init(void) 37void __init rbtx4927_prom_init(void)
38{ 38{
39 extern int tx4927_get_mem_size(void);
40 int msize;
41
42 prom_init_cmdline(); 39 prom_init_cmdline();
43 msize = tx4927_get_mem_size(); 40 add_memory_region(0, tx4927_get_mem_size(), BOOT_MEM_RAM);
44 add_memory_region(0, msize << 20, BOOT_MEM_RAM);
45} 41}
diff --git a/arch/mips/txx9/rbtx4927/setup.c b/arch/mips/txx9/rbtx4927/setup.c
index 1657fd935da8..3da20ea3e55c 100644
--- a/arch/mips/txx9/rbtx4927/setup.c
+++ b/arch/mips/txx9/rbtx4927/setup.c
@@ -53,17 +53,10 @@
53#include <asm/io.h> 53#include <asm/io.h>
54#include <asm/processor.h> 54#include <asm/processor.h>
55#include <asm/reboot.h> 55#include <asm/reboot.h>
56#include <asm/time.h>
57#include <asm/txx9tmr.h>
58#include <asm/txx9/generic.h> 56#include <asm/txx9/generic.h>
59#include <asm/txx9/pci.h> 57#include <asm/txx9/pci.h>
60#include <asm/txx9/rbtx4927.h> 58#include <asm/txx9/rbtx4927.h>
61#include <asm/txx9/tx4938.h> /* for TX4937 */ 59#include <asm/txx9/tx4938.h> /* for TX4937 */
62#ifdef CONFIG_SERIAL_TXX9
63#include <linux/serial_core.h>
64#endif
65
66static int tx4927_ccfg_toeon = 1;
67 60
68#ifdef CONFIG_PCI 61#ifdef CONFIG_PCI
69static void __init tx4927_pci_setup(void) 62static void __init tx4927_pci_setup(void)
@@ -184,14 +177,14 @@ static void toshiba_rbtx4927_restart(char *command)
184 printk(KERN_NOTICE "System Rebooting...\n"); 177 printk(KERN_NOTICE "System Rebooting...\n");
185 178
186 /* enable the s/w reset register */ 179 /* enable the s/w reset register */
187 writeb(RBTX4927_SW_RESET_ENABLE_SET, RBTX4927_SW_RESET_ENABLE); 180 writeb(1, rbtx4927_softresetlock_addr);
188 181
189 /* wait for enable to be seen */ 182 /* wait for enable to be seen */
190 while ((readb(RBTX4927_SW_RESET_ENABLE) & 183 while (!(readb(rbtx4927_softresetlock_addr) & 1))
191 RBTX4927_SW_RESET_ENABLE_SET) == 0x00); 184 ;
192 185
193 /* do a s/w reset */ 186 /* do a s/w reset */
194 writeb(RBTX4927_SW_RESET_DO_SET, RBTX4927_SW_RESET_DO); 187 writeb(1, rbtx4927_softreset_addr);
195 188
196 /* do something passive while waiting for reset */ 189 /* do something passive while waiting for reset */
197 local_irq_disable(); 190 local_irq_disable();
@@ -213,9 +206,11 @@ static void toshiba_rbtx4927_power_off(void)
213 /* no return */ 206 /* no return */
214} 207}
215 208
209static void __init rbtx4927_clock_init(void);
210static void __init rbtx4937_clock_init(void);
211
216static void __init rbtx4927_mem_setup(void) 212static void __init rbtx4927_mem_setup(void)
217{ 213{
218 int i;
219 u32 cp0_config; 214 u32 cp0_config;
220 char *argptr; 215 char *argptr;
221 216
@@ -227,16 +222,18 @@ static void __init rbtx4927_mem_setup(void)
227 cp0_config = cp0_config & ~(TX49_CONF_IC | TX49_CONF_DC); 222 cp0_config = cp0_config & ~(TX49_CONF_IC | TX49_CONF_DC);
228 write_c0_config(cp0_config); 223 write_c0_config(cp0_config);
229 224
230 ioport_resource.end = 0xffffffff; 225 if (TX4927_REV_PCODE() == 0x4927) {
231 iomem_resource.end = 0xffffffff; 226 rbtx4927_clock_init();
227 tx4927_setup();
228 } else {
229 rbtx4937_clock_init();
230 tx4938_setup();
231 }
232 232
233 _machine_restart = toshiba_rbtx4927_restart; 233 _machine_restart = toshiba_rbtx4927_restart;
234 _machine_halt = toshiba_rbtx4927_halt; 234 _machine_halt = toshiba_rbtx4927_halt;
235 pm_power_off = toshiba_rbtx4927_power_off; 235 pm_power_off = toshiba_rbtx4927_power_off;
236 236
237 for (i = 0; i < TX4927_NR_TMR; i++)
238 txx9_tmr_init(TX4927_TMR_REG(0) & 0xfffffffffULL);
239
240#ifdef CONFIG_PCI 237#ifdef CONFIG_PCI
241 txx9_alloc_pci_controller(&txx9_primary_pcic, 238 txx9_alloc_pci_controller(&txx9_primary_pcic,
242 RBTX4927_PCIMEM, RBTX4927_PCIMEM_SIZE, 239 RBTX4927_PCIMEM, RBTX4927_PCIMEM_SIZE,
@@ -245,36 +242,13 @@ static void __init rbtx4927_mem_setup(void)
245 set_io_port_base(KSEG1 + RBTX4927_ISA_IO_OFFSET); 242 set_io_port_base(KSEG1 + RBTX4927_ISA_IO_OFFSET);
246#endif 243#endif
247 244
248 /* CCFG */ 245 tx4927_setup_serial();
249 /* do reset on watchdog */
250 tx4927_ccfg_set(TX4927_CCFG_WR);
251 /* enable Timeout BusError */
252 if (tx4927_ccfg_toeon)
253 tx4927_ccfg_set(TX4927_CCFG_TOE);
254
255#ifdef CONFIG_SERIAL_TXX9
256 {
257 extern int early_serial_txx9_setup(struct uart_port *port);
258 struct uart_port req;
259 for(i = 0; i < 2; i++) {
260 memset(&req, 0, sizeof(req));
261 req.line = i;
262 req.iotype = UPIO_MEM;
263 req.membase = (char *)(0xff1ff300 + i * 0x100);
264 req.mapbase = 0xff1ff300 + i * 0x100;
265 req.irq = TXX9_IRQ_BASE + TX4927_IR_SIO(i);
266 req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/;
267 req.uartclk = 50000000;
268 early_serial_txx9_setup(&req);
269 }
270 }
271#ifdef CONFIG_SERIAL_TXX9_CONSOLE 246#ifdef CONFIG_SERIAL_TXX9_CONSOLE
272 argptr = prom_getcmdline(); 247 argptr = prom_getcmdline();
273 if (strstr(argptr, "console=") == NULL) { 248 if (strstr(argptr, "console=") == NULL) {
274 strcat(argptr, " console=ttyS0,38400"); 249 strcat(argptr, " console=ttyS0,38400");
275 } 250 }
276#endif 251#endif
277#endif
278 252
279#ifdef CONFIG_ROOT_NFS 253#ifdef CONFIG_ROOT_NFS
280 argptr = prom_getcmdline(); 254 argptr = prom_getcmdline();
@@ -291,19 +265,7 @@ static void __init rbtx4927_mem_setup(void)
291#endif 265#endif
292} 266}
293 267
294static void __init rbtx49x7_common_time_init(void) 268static void __init rbtx4927_clock_init(void)
295{
296 /* change default value to udelay/mdelay take reasonable time */
297 loops_per_jiffy = txx9_cpu_clock / HZ / 2;
298
299 mips_hpt_frequency = txx9_cpu_clock / 2;
300 if (____raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_TINTDIS)
301 txx9_clockevent_init(TX4927_TMR_REG(0) & 0xfffffffffULL,
302 TXX9_IRQ_BASE + 17,
303 50000000);
304}
305
306static void __init rbtx4927_time_init(void)
307{ 269{
308 /* 270 /*
309 * ASSUMPTION: PCIDIVMODE is configured for PCI 33MHz or 66MHz. 271 * ASSUMPTION: PCIDIVMODE is configured for PCI 33MHz or 66MHz.
@@ -325,11 +287,9 @@ static void __init rbtx4927_time_init(void)
325 default: 287 default:
326 txx9_cpu_clock = 200000000; /* 200MHz */ 288 txx9_cpu_clock = 200000000; /* 200MHz */
327 } 289 }
328
329 rbtx49x7_common_time_init();
330} 290}
331 291
332static void __init rbtx4937_time_init(void) 292static void __init rbtx4937_clock_init(void)
333{ 293{
334 /* 294 /*
335 * ASSUMPTION: PCIDIVMODE is configured for PCI 33MHz or 66MHz. 295 * ASSUMPTION: PCIDIVMODE is configured for PCI 33MHz or 66MHz.
@@ -357,15 +317,18 @@ static void __init rbtx4937_time_init(void)
357 default: 317 default:
358 txx9_cpu_clock = 333333333; /* 333MHz */ 318 txx9_cpu_clock = 333333333; /* 333MHz */
359 } 319 }
320}
360 321
361 rbtx49x7_common_time_init(); 322static void __init rbtx4927_time_init(void)
323{
324 tx4927_time_init(0);
362} 325}
363 326
364static int __init toshiba_rbtx4927_rtc_init(void) 327static int __init toshiba_rbtx4927_rtc_init(void)
365{ 328{
366 static struct resource __initdata res = { 329 struct resource res = {
367 .start = 0x1c010000, 330 .start = RBTX4927_BRAMRTC_BASE - IO_BASE,
368 .end = 0x1c010000 + 0x800 - 1, 331 .end = RBTX4927_BRAMRTC_BASE - IO_BASE + 0x800 - 1,
369 .flags = IORESOURCE_MEM, 332 .flags = IORESOURCE_MEM,
370 }; 333 };
371 struct platform_device *dev = 334 struct platform_device *dev =
@@ -375,7 +338,7 @@ static int __init toshiba_rbtx4927_rtc_init(void)
375 338
376static int __init rbtx4927_ne_init(void) 339static int __init rbtx4927_ne_init(void)
377{ 340{
378 static struct resource __initdata res[] = { 341 struct resource res[] = {
379 { 342 {
380 .start = RBTX4927_RTL_8019_BASE, 343 .start = RBTX4927_RTL_8019_BASE,
381 .end = RBTX4927_RTL_8019_BASE + 0x20 - 1, 344 .end = RBTX4927_RTL_8019_BASE + 0x20 - 1,
@@ -434,7 +397,7 @@ struct txx9_board_vec rbtx4937_vec __initdata = {
434 .prom_init = rbtx4927_prom_init, 397 .prom_init = rbtx4927_prom_init,
435 .mem_setup = rbtx4927_mem_setup, 398 .mem_setup = rbtx4927_mem_setup,
436 .irq_setup = rbtx4927_irq_setup, 399 .irq_setup = rbtx4927_irq_setup,
437 .time_init = rbtx4937_time_init, 400 .time_init = rbtx4927_time_init,
438 .device_init = rbtx4927_device_init, 401 .device_init = rbtx4927_device_init,
439 .arch_init = rbtx4937_arch_init, 402 .arch_init = rbtx4937_arch_init,
440#ifdef CONFIG_PCI 403#ifdef CONFIG_PCI
diff --git a/arch/mips/txx9/rbtx4938/prom.c b/arch/mips/txx9/rbtx4938/prom.c
index fbb37458ddb2..ee189519ce5a 100644
--- a/arch/mips/txx9/rbtx4938/prom.c
+++ b/arch/mips/txx9/rbtx4938/prom.c
@@ -18,12 +18,8 @@
18 18
19void __init rbtx4938_prom_init(void) 19void __init rbtx4938_prom_init(void)
20{ 20{
21 extern int tx4938_get_mem_size(void);
22 int msize;
23#ifndef CONFIG_TX4938_NAND_BOOT 21#ifndef CONFIG_TX4938_NAND_BOOT
24 prom_init_cmdline(); 22 prom_init_cmdline();
25#endif 23#endif
26 24 add_memory_region(0, tx4938_get_mem_size(), BOOT_MEM_RAM);
27 msize = tx4938_get_mem_size();
28 add_memory_region(0, msize << 20, BOOT_MEM_RAM);
29} 25}
diff --git a/arch/mips/txx9/rbtx4938/setup.c b/arch/mips/txx9/rbtx4938/setup.c
index aaa987ae0f83..6c2b99bb8af6 100644
--- a/arch/mips/txx9/rbtx4938/setup.c
+++ b/arch/mips/txx9/rbtx4938/setup.c
@@ -20,21 +20,14 @@
20#include <linux/gpio.h> 20#include <linux/gpio.h>
21 21
22#include <asm/reboot.h> 22#include <asm/reboot.h>
23#include <asm/time.h>
24#include <asm/txx9tmr.h>
25#include <asm/io.h> 23#include <asm/io.h>
26#include <asm/txx9/generic.h> 24#include <asm/txx9/generic.h>
27#include <asm/txx9/pci.h> 25#include <asm/txx9/pci.h>
28#include <asm/txx9/rbtx4938.h> 26#include <asm/txx9/rbtx4938.h>
29#ifdef CONFIG_SERIAL_TXX9
30#include <linux/serial_core.h>
31#endif
32#include <linux/spi/spi.h> 27#include <linux/spi/spi.h>
33#include <asm/txx9/spi.h> 28#include <asm/txx9/spi.h>
34#include <asm/txx9pio.h> 29#include <asm/txx9pio.h>
35 30
36static int tx4938_ccfg_toeon = 1;
37
38static void rbtx4938_machine_halt(void) 31static void rbtx4938_machine_halt(void)
39{ 32{
40 printk(KERN_NOTICE "System Halted\n"); 33 printk(KERN_NOTICE "System Halted\n");
@@ -182,188 +175,10 @@ static void __init rbtx4938_spi_setup(void)
182} 175}
183 176
184static struct resource rbtx4938_fpga_resource; 177static struct resource rbtx4938_fpga_resource;
185static struct resource tx4938_sdram_resource[4];
186static struct resource tx4938_sram_resource;
187
188void __init tx4938_board_setup(void)
189{
190 int i;
191 unsigned long divmode;
192 int cpuclk = 0;
193 unsigned long pcode = TX4938_REV_PCODE();
194
195 ioport_resource.start = 0;
196 ioport_resource.end = 0xffffffff;
197 iomem_resource.start = 0;
198 iomem_resource.end = 0xffffffff; /* expand to 4GB */
199
200 txx9_reg_res_init(pcode, TX4938_REG_BASE,
201 TX4938_REG_SIZE);
202 /* SDRAMC,EBUSC are configured by PROM */
203 for (i = 0; i < 8; i++) {
204 if (!(TX4938_EBUSC_CR(i) & 0x8))
205 continue; /* disabled */
206 txx9_ce_res[i].start = (unsigned long)TX4938_EBUSC_BA(i);
207 txx9_ce_res[i].end =
208 txx9_ce_res[i].start + TX4938_EBUSC_SIZE(i) - 1;
209 request_resource(&iomem_resource, &txx9_ce_res[i]);
210 }
211
212 /* clocks */
213 if (txx9_master_clock) {
214 u64 ccfg = ____raw_readq(&tx4938_ccfgptr->ccfg);
215 /* calculate gbus_clock and cpu_clock_freq from master_clock */
216 divmode = (__u32)ccfg & TX4938_CCFG_DIVMODE_MASK;
217 switch (divmode) {
218 case TX4938_CCFG_DIVMODE_8:
219 case TX4938_CCFG_DIVMODE_10:
220 case TX4938_CCFG_DIVMODE_12:
221 case TX4938_CCFG_DIVMODE_16:
222 case TX4938_CCFG_DIVMODE_18:
223 txx9_gbus_clock = txx9_master_clock * 4; break;
224 default:
225 txx9_gbus_clock = txx9_master_clock;
226 }
227 switch (divmode) {
228 case TX4938_CCFG_DIVMODE_2:
229 case TX4938_CCFG_DIVMODE_8:
230 cpuclk = txx9_gbus_clock * 2; break;
231 case TX4938_CCFG_DIVMODE_2_5:
232 case TX4938_CCFG_DIVMODE_10:
233 cpuclk = txx9_gbus_clock * 5 / 2; break;
234 case TX4938_CCFG_DIVMODE_3:
235 case TX4938_CCFG_DIVMODE_12:
236 cpuclk = txx9_gbus_clock * 3; break;
237 case TX4938_CCFG_DIVMODE_4:
238 case TX4938_CCFG_DIVMODE_16:
239 cpuclk = txx9_gbus_clock * 4; break;
240 case TX4938_CCFG_DIVMODE_4_5:
241 case TX4938_CCFG_DIVMODE_18:
242 cpuclk = txx9_gbus_clock * 9 / 2; break;
243 }
244 txx9_cpu_clock = cpuclk;
245 } else {
246 u64 ccfg = ____raw_readq(&tx4938_ccfgptr->ccfg);
247 if (txx9_cpu_clock == 0) {
248 txx9_cpu_clock = 300000000; /* 300MHz */
249 }
250 /* calculate gbus_clock and master_clock from cpu_clock_freq */
251 cpuclk = txx9_cpu_clock;
252 divmode = (__u32)ccfg & TX4938_CCFG_DIVMODE_MASK;
253 switch (divmode) {
254 case TX4938_CCFG_DIVMODE_2:
255 case TX4938_CCFG_DIVMODE_8:
256 txx9_gbus_clock = cpuclk / 2; break;
257 case TX4938_CCFG_DIVMODE_2_5:
258 case TX4938_CCFG_DIVMODE_10:
259 txx9_gbus_clock = cpuclk * 2 / 5; break;
260 case TX4938_CCFG_DIVMODE_3:
261 case TX4938_CCFG_DIVMODE_12:
262 txx9_gbus_clock = cpuclk / 3; break;
263 case TX4938_CCFG_DIVMODE_4:
264 case TX4938_CCFG_DIVMODE_16:
265 txx9_gbus_clock = cpuclk / 4; break;
266 case TX4938_CCFG_DIVMODE_4_5:
267 case TX4938_CCFG_DIVMODE_18:
268 txx9_gbus_clock = cpuclk * 2 / 9; break;
269 }
270 switch (divmode) {
271 case TX4938_CCFG_DIVMODE_8:
272 case TX4938_CCFG_DIVMODE_10:
273 case TX4938_CCFG_DIVMODE_12:
274 case TX4938_CCFG_DIVMODE_16:
275 case TX4938_CCFG_DIVMODE_18:
276 txx9_master_clock = txx9_gbus_clock / 4; break;
277 default:
278 txx9_master_clock = txx9_gbus_clock;
279 }
280 }
281 /* change default value to udelay/mdelay take reasonable time */
282 loops_per_jiffy = txx9_cpu_clock / HZ / 2;
283
284 /* CCFG */
285 /* clear WatchDogReset,BusErrorOnWrite flag (W1C) */
286 tx4938_ccfg_set(TX4938_CCFG_WDRST | TX4938_CCFG_BEOW);
287 /* do reset on watchdog */
288 tx4938_ccfg_set(TX4938_CCFG_WR);
289 /* clear PCIC1 reset */
290 txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIC1RST);
291
292 /* enable Timeout BusError */
293 if (tx4938_ccfg_toeon)
294 tx4938_ccfg_set(TX4938_CCFG_TOE);
295
296 /* DMA selection */
297 txx9_clear64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_DMASEL_ALL);
298
299 /* Use external clock for external arbiter */
300 if (!(____raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCIARB))
301 txx9_clear64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_PCICLKEN_ALL);
302
303 printk(KERN_INFO "%s -- %dMHz(M%dMHz) CRIR:%08x CCFG:%llx PCFG:%llx\n",
304 txx9_pcode_str,
305 (cpuclk + 500000) / 1000000,
306 (txx9_master_clock + 500000) / 1000000,
307 (__u32)____raw_readq(&tx4938_ccfgptr->crir),
308 (unsigned long long)____raw_readq(&tx4938_ccfgptr->ccfg),
309 (unsigned long long)____raw_readq(&tx4938_ccfgptr->pcfg));
310
311 printk(KERN_INFO "%s SDRAMC --", txx9_pcode_str);
312 for (i = 0; i < 4; i++) {
313 unsigned long long cr = tx4938_sdramcptr->cr[i];
314 unsigned long ram_base, ram_size;
315 if (!((unsigned long)cr & 0x00000400))
316 continue; /* disabled */
317 ram_base = (unsigned long)(cr >> 49) << 21;
318 ram_size = ((unsigned long)(cr >> 33) + 1) << 21;
319 if (ram_base >= 0x20000000)
320 continue; /* high memory (ignore) */
321 printk(" CR%d:%016Lx", i, cr);
322 tx4938_sdram_resource[i].name = "SDRAM";
323 tx4938_sdram_resource[i].start = ram_base;
324 tx4938_sdram_resource[i].end = ram_base + ram_size - 1;
325 tx4938_sdram_resource[i].flags = IORESOURCE_MEM;
326 request_resource(&iomem_resource, &tx4938_sdram_resource[i]);
327 }
328 printk(" TR:%09Lx\n", tx4938_sdramcptr->tr);
329
330 /* SRAM */
331 if (tx4938_sramcptr->cr & 1) {
332 unsigned int size = 0x800;
333 unsigned long base =
334 (tx4938_sramcptr->cr >> (39-11)) & ~(size - 1);
335 tx4938_sram_resource.name = "SRAM";
336 tx4938_sram_resource.start = base;
337 tx4938_sram_resource.end = base + size - 1;
338 tx4938_sram_resource.flags = IORESOURCE_MEM;
339 request_resource(&iomem_resource, &tx4938_sram_resource);
340 }
341
342 /* TMR */
343 for (i = 0; i < TX4938_NR_TMR; i++)
344 txx9_tmr_init(TX4938_TMR_REG(i) & 0xfffffffffULL);
345
346 /* enable DMA */
347 for (i = 0; i < 2; i++)
348 ____raw_writeq(TX4938_DMA_MCR_MSTEN,
349 (void __iomem *)(TX4938_DMA_REG(i) + 0x50));
350
351 /* PIO */
352 __raw_writel(0, &tx4938_pioptr->maskcpu);
353 __raw_writel(0, &tx4938_pioptr->maskext);
354
355#ifdef CONFIG_PCI
356 txx9_alloc_pci_controller(&txx9_primary_pcic, 0, 0, 0, 0);
357#endif
358}
359 178
360static void __init rbtx4938_time_init(void) 179static void __init rbtx4938_time_init(void)
361{ 180{
362 mips_hpt_frequency = txx9_cpu_clock / 2; 181 tx4938_time_init(0);
363 if (____raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_TINTDIS)
364 txx9_clockevent_init(TX4938_TMR_REG(0) & 0xfffffffffULL,
365 TXX9_IRQ_BASE + TX4938_IR_TMR(0),
366 txx9_gbus_clock / 2);
367} 182}
368 183
369static void __init rbtx4938_mem_setup(void) 184static void __init rbtx4938_mem_setup(void)
@@ -371,39 +186,24 @@ static void __init rbtx4938_mem_setup(void)
371 unsigned long long pcfg; 186 unsigned long long pcfg;
372 char *argptr; 187 char *argptr;
373 188
374 iomem_resource.end = 0xffffffff; /* 4GB */
375
376 if (txx9_master_clock == 0) 189 if (txx9_master_clock == 0)
377 txx9_master_clock = 25000000; /* 25MHz */ 190 txx9_master_clock = 25000000; /* 25MHz */
378 tx4938_board_setup(); 191
379#ifndef CONFIG_PCI 192 tx4938_setup();
193
194#ifdef CONFIG_PCI
195 txx9_alloc_pci_controller(&txx9_primary_pcic, 0, 0, 0, 0);
196#else
380 set_io_port_base(RBTX4938_ETHER_BASE); 197 set_io_port_base(RBTX4938_ETHER_BASE);
381#endif 198#endif
382 199
383#ifdef CONFIG_SERIAL_TXX9 200 tx4938_setup_serial();
384 {
385 extern int early_serial_txx9_setup(struct uart_port *port);
386 int i;
387 struct uart_port req;
388 for(i = 0; i < 2; i++) {
389 memset(&req, 0, sizeof(req));
390 req.line = i;
391 req.iotype = UPIO_MEM;
392 req.membase = (char *)(0xff1ff300 + i * 0x100);
393 req.mapbase = 0xff1ff300 + i * 0x100;
394 req.irq = RBTX4938_IRQ_IRC_SIO(i);
395 req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/;
396 req.uartclk = 50000000;
397 early_serial_txx9_setup(&req);
398 }
399 }
400#ifdef CONFIG_SERIAL_TXX9_CONSOLE 201#ifdef CONFIG_SERIAL_TXX9_CONSOLE
401 argptr = prom_getcmdline(); 202 argptr = prom_getcmdline();
402 if (strstr(argptr, "console=") == NULL) { 203 if (strstr(argptr, "console=") == NULL) {
403 strcat(argptr, " console=ttyS0,38400"); 204 strcat(argptr, " console=ttyS0,38400");
404 } 205 }
405#endif 206#endif
406#endif
407 207
408#ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_PIO58_61 208#ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_PIO58_61
409 printk("PIOSEL: disabling both ata and nand selection\n"); 209 printk("PIOSEL: disabling both ata and nand selection\n");
@@ -457,7 +257,7 @@ static void __init rbtx4938_mem_setup(void)
457 rbtx4938_fpga_resource.start = CPHYSADDR(RBTX4938_FPGA_REG_ADDR); 257 rbtx4938_fpga_resource.start = CPHYSADDR(RBTX4938_FPGA_REG_ADDR);
458 rbtx4938_fpga_resource.end = CPHYSADDR(RBTX4938_FPGA_REG_ADDR) + 0xffff; 258 rbtx4938_fpga_resource.end = CPHYSADDR(RBTX4938_FPGA_REG_ADDR) + 0xffff;
459 rbtx4938_fpga_resource.flags = IORESOURCE_MEM | IORESOURCE_BUSY; 259 rbtx4938_fpga_resource.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
460 if (request_resource(&iomem_resource, &rbtx4938_fpga_resource)) 260 if (request_resource(&txx9_ce_res[2], &rbtx4938_fpga_resource))
461 printk("request resource for fpga failed\n"); 261 printk("request resource for fpga failed\n");
462 262
463 _machine_restart = rbtx4938_machine_restart; 263 _machine_restart = rbtx4938_machine_restart;
@@ -488,18 +288,6 @@ static int __init rbtx4938_ne_init(void)
488 return IS_ERR(dev) ? PTR_ERR(dev) : 0; 288 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
489} 289}
490 290
491/* GPIO support */
492
493int gpio_to_irq(unsigned gpio)
494{
495 return -EINVAL;
496}
497
498int irq_to_gpio(unsigned irq)
499{
500 return -EINVAL;
501}
502
503static DEFINE_SPINLOCK(rbtx4938_spi_gpio_lock); 291static DEFINE_SPINLOCK(rbtx4938_spi_gpio_lock);
504 292
505static void rbtx4938_spi_gpio_set(struct gpio_chip *chip, unsigned int offset, 293static void rbtx4938_spi_gpio_set(struct gpio_chip *chip, unsigned int offset,
@@ -579,7 +367,6 @@ static int __init rbtx4938_spi_init(void)
579 367
580static void __init rbtx4938_arch_init(void) 368static void __init rbtx4938_arch_init(void)
581{ 369{
582 txx9_gpio_init(TX4938_PIO_REG & 0xfffffffffULL, 0, 16);
583 gpiochip_add(&rbtx4938_spi_gpio_chip); 370 gpiochip_add(&rbtx4938_spi_gpio_chip);
584 rbtx4938_pci_setup(); 371 rbtx4938_pci_setup();
585 rbtx4938_spi_init(); 372 rbtx4938_spi_init();
diff --git a/arch/mn10300/kernel/mn10300-serial.c b/arch/mn10300/kernel/mn10300-serial.c
index b9c268c6b2fb..8b054e7a8ae8 100644
--- a/arch/mn10300/kernel/mn10300-serial.c
+++ b/arch/mn10300/kernel/mn10300-serial.c
@@ -392,7 +392,7 @@ static int mask_test_and_clear(volatile u8 *ptr, u8 mask)
392static void mn10300_serial_receive_interrupt(struct mn10300_serial_port *port) 392static void mn10300_serial_receive_interrupt(struct mn10300_serial_port *port)
393{ 393{
394 struct uart_icount *icount = &port->uart.icount; 394 struct uart_icount *icount = &port->uart.icount;
395 struct tty_struct *tty = port->uart.info->tty; 395 struct tty_struct *tty = port->uart.info->port.tty;
396 unsigned ix; 396 unsigned ix;
397 int count; 397 int count;
398 u8 st, ch, push, status, overrun; 398 u8 st, ch, push, status, overrun;
diff --git a/arch/powerpc/kvm/Makefile b/arch/powerpc/kvm/Makefile
index d0d358d367ec..04e3449e1f42 100644
--- a/arch/powerpc/kvm/Makefile
+++ b/arch/powerpc/kvm/Makefile
@@ -4,7 +4,7 @@
4 4
5EXTRA_CFLAGS += -Ivirt/kvm -Iarch/powerpc/kvm 5EXTRA_CFLAGS += -Ivirt/kvm -Iarch/powerpc/kvm
6 6
7common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o) 7common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o coalesced_mmio.o)
8 8
9kvm-objs := $(common-objs) powerpc.o emulate.o booke_guest.o 9kvm-objs := $(common-objs) powerpc.o emulate.o booke_guest.o
10obj-$(CONFIG_KVM) += kvm.o 10obj-$(CONFIG_KVM) += kvm.o
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 777e0f34e0ea..53826a5f6c06 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -145,6 +145,9 @@ int kvm_dev_ioctl_check_extension(long ext)
145 case KVM_CAP_USER_MEMORY: 145 case KVM_CAP_USER_MEMORY:
146 r = 1; 146 r = 1;
147 break; 147 break;
148 case KVM_CAP_COALESCED_MMIO:
149 r = KVM_COALESCED_MMIO_PAGE_OFFSET;
150 break;
148 default: 151 default:
149 r = 0; 152 r = 0;
150 break; 153 break;
@@ -167,6 +170,10 @@ int kvm_arch_set_memory_region(struct kvm *kvm,
167 return 0; 170 return 0;
168} 171}
169 172
173void kvm_arch_flush_shadow(struct kvm *kvm)
174{
175}
176
170struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id) 177struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id)
171{ 178{
172 struct kvm_vcpu *vcpu; 179 struct kvm_vcpu *vcpu;
@@ -240,10 +247,6 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
240{ 247{
241} 248}
242 249
243void decache_vcpus_on_cpu(int cpu)
244{
245}
246
247int kvm_arch_vcpu_ioctl_debug_guest(struct kvm_vcpu *vcpu, 250int kvm_arch_vcpu_ioctl_debug_guest(struct kvm_vcpu *vcpu,
248 struct kvm_debug_guest *dbg) 251 struct kvm_debug_guest *dbg)
249{ 252{
diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index 84a7fed4cd4e..11230b0db957 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -31,7 +31,7 @@ static int psw_interrupts_disabled(struct kvm_vcpu *vcpu)
31} 31}
32 32
33static int __interrupt_is_deliverable(struct kvm_vcpu *vcpu, 33static int __interrupt_is_deliverable(struct kvm_vcpu *vcpu,
34 struct interrupt_info *inti) 34 struct kvm_s390_interrupt_info *inti)
35{ 35{
36 switch (inti->type) { 36 switch (inti->type) {
37 case KVM_S390_INT_EMERGENCY: 37 case KVM_S390_INT_EMERGENCY:
@@ -91,7 +91,7 @@ static void __set_cpuflag(struct kvm_vcpu *vcpu, u32 flag)
91} 91}
92 92
93static void __set_intercept_indicator(struct kvm_vcpu *vcpu, 93static void __set_intercept_indicator(struct kvm_vcpu *vcpu,
94 struct interrupt_info *inti) 94 struct kvm_s390_interrupt_info *inti)
95{ 95{
96 switch (inti->type) { 96 switch (inti->type) {
97 case KVM_S390_INT_EMERGENCY: 97 case KVM_S390_INT_EMERGENCY:
@@ -111,7 +111,7 @@ static void __set_intercept_indicator(struct kvm_vcpu *vcpu,
111} 111}
112 112
113static void __do_deliver_interrupt(struct kvm_vcpu *vcpu, 113static void __do_deliver_interrupt(struct kvm_vcpu *vcpu,
114 struct interrupt_info *inti) 114 struct kvm_s390_interrupt_info *inti)
115{ 115{
116 const unsigned short table[] = { 2, 4, 4, 6 }; 116 const unsigned short table[] = { 2, 4, 4, 6 };
117 int rc, exception = 0; 117 int rc, exception = 0;
@@ -290,9 +290,9 @@ static int __try_deliver_ckc_interrupt(struct kvm_vcpu *vcpu)
290 290
291int kvm_cpu_has_interrupt(struct kvm_vcpu *vcpu) 291int kvm_cpu_has_interrupt(struct kvm_vcpu *vcpu)
292{ 292{
293 struct local_interrupt *li = &vcpu->arch.local_int; 293 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
294 struct float_interrupt *fi = vcpu->arch.local_int.float_int; 294 struct kvm_s390_float_interrupt *fi = vcpu->arch.local_int.float_int;
295 struct interrupt_info *inti; 295 struct kvm_s390_interrupt_info *inti;
296 int rc = 0; 296 int rc = 0;
297 297
298 if (atomic_read(&li->active)) { 298 if (atomic_read(&li->active)) {
@@ -408,9 +408,9 @@ void kvm_s390_idle_wakeup(unsigned long data)
408 408
409void kvm_s390_deliver_pending_interrupts(struct kvm_vcpu *vcpu) 409void kvm_s390_deliver_pending_interrupts(struct kvm_vcpu *vcpu)
410{ 410{
411 struct local_interrupt *li = &vcpu->arch.local_int; 411 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
412 struct float_interrupt *fi = vcpu->arch.local_int.float_int; 412 struct kvm_s390_float_interrupt *fi = vcpu->arch.local_int.float_int;
413 struct interrupt_info *n, *inti = NULL; 413 struct kvm_s390_interrupt_info *n, *inti = NULL;
414 int deliver; 414 int deliver;
415 415
416 __reset_intercept_indicators(vcpu); 416 __reset_intercept_indicators(vcpu);
@@ -465,8 +465,8 @@ void kvm_s390_deliver_pending_interrupts(struct kvm_vcpu *vcpu)
465 465
466int kvm_s390_inject_program_int(struct kvm_vcpu *vcpu, u16 code) 466int kvm_s390_inject_program_int(struct kvm_vcpu *vcpu, u16 code)
467{ 467{
468 struct local_interrupt *li = &vcpu->arch.local_int; 468 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
469 struct interrupt_info *inti; 469 struct kvm_s390_interrupt_info *inti;
470 470
471 inti = kzalloc(sizeof(*inti), GFP_KERNEL); 471 inti = kzalloc(sizeof(*inti), GFP_KERNEL);
472 if (!inti) 472 if (!inti)
@@ -487,9 +487,9 @@ int kvm_s390_inject_program_int(struct kvm_vcpu *vcpu, u16 code)
487int kvm_s390_inject_vm(struct kvm *kvm, 487int kvm_s390_inject_vm(struct kvm *kvm,
488 struct kvm_s390_interrupt *s390int) 488 struct kvm_s390_interrupt *s390int)
489{ 489{
490 struct local_interrupt *li; 490 struct kvm_s390_local_interrupt *li;
491 struct float_interrupt *fi; 491 struct kvm_s390_float_interrupt *fi;
492 struct interrupt_info *inti; 492 struct kvm_s390_interrupt_info *inti;
493 int sigcpu; 493 int sigcpu;
494 494
495 inti = kzalloc(sizeof(*inti), GFP_KERNEL); 495 inti = kzalloc(sizeof(*inti), GFP_KERNEL);
@@ -544,8 +544,8 @@ int kvm_s390_inject_vm(struct kvm *kvm,
544int kvm_s390_inject_vcpu(struct kvm_vcpu *vcpu, 544int kvm_s390_inject_vcpu(struct kvm_vcpu *vcpu,
545 struct kvm_s390_interrupt *s390int) 545 struct kvm_s390_interrupt *s390int)
546{ 546{
547 struct local_interrupt *li; 547 struct kvm_s390_local_interrupt *li;
548 struct interrupt_info *inti; 548 struct kvm_s390_interrupt_info *inti;
549 549
550 inti = kzalloc(sizeof(*inti), GFP_KERNEL); 550 inti = kzalloc(sizeof(*inti), GFP_KERNEL);
551 if (!inti) 551 if (!inti)
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 6558b09ff579..1782cbcd2829 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -79,10 +79,6 @@ void kvm_arch_hardware_disable(void *garbage)
79{ 79{
80} 80}
81 81
82void decache_vcpus_on_cpu(int cpu)
83{
84}
85
86int kvm_arch_hardware_setup(void) 82int kvm_arch_hardware_setup(void)
87{ 83{
88 return 0; 84 return 0;
@@ -198,6 +194,7 @@ out_nokvm:
198void kvm_arch_destroy_vm(struct kvm *kvm) 194void kvm_arch_destroy_vm(struct kvm *kvm)
199{ 195{
200 debug_unregister(kvm->arch.dbf); 196 debug_unregister(kvm->arch.dbf);
197 kvm_free_physmem(kvm);
201 free_page((unsigned long)(kvm->arch.sca)); 198 free_page((unsigned long)(kvm->arch.sca));
202 kfree(kvm); 199 kfree(kvm);
203 module_put(THIS_MODULE); 200 module_put(THIS_MODULE);
@@ -250,11 +247,16 @@ static void kvm_s390_vcpu_initial_reset(struct kvm_vcpu *vcpu)
250 vcpu->arch.sie_block->gbea = 1; 247 vcpu->arch.sie_block->gbea = 1;
251} 248}
252 249
250/* The current code can have up to 256 pages for virtio */
251#define VIRTIODESCSPACE (256ul * 4096ul)
252
253int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu) 253int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
254{ 254{
255 atomic_set(&vcpu->arch.sie_block->cpuflags, CPUSTAT_ZARCH); 255 atomic_set(&vcpu->arch.sie_block->cpuflags, CPUSTAT_ZARCH);
256 vcpu->arch.sie_block->gmslm = 0xffffffffffUL; 256 vcpu->arch.sie_block->gmslm = vcpu->kvm->arch.guest_memsize +
257 vcpu->arch.sie_block->gmsor = 0x000000000000; 257 vcpu->kvm->arch.guest_origin +
258 VIRTIODESCSPACE - 1ul;
259 vcpu->arch.sie_block->gmsor = vcpu->kvm->arch.guest_origin;
258 vcpu->arch.sie_block->ecb = 2; 260 vcpu->arch.sie_block->ecb = 2;
259 vcpu->arch.sie_block->eca = 0xC1002001U; 261 vcpu->arch.sie_block->eca = 0xC1002001U;
260 setup_timer(&vcpu->arch.ckc_timer, kvm_s390_idle_wakeup, 262 setup_timer(&vcpu->arch.ckc_timer, kvm_s390_idle_wakeup,
@@ -273,7 +275,8 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
273 if (!vcpu) 275 if (!vcpu)
274 goto out_nomem; 276 goto out_nomem;
275 277
276 vcpu->arch.sie_block = (struct sie_block *) get_zeroed_page(GFP_KERNEL); 278 vcpu->arch.sie_block = (struct kvm_s390_sie_block *)
279 get_zeroed_page(GFP_KERNEL);
277 280
278 if (!vcpu->arch.sie_block) 281 if (!vcpu->arch.sie_block)
279 goto out_free_cpu; 282 goto out_free_cpu;
@@ -672,6 +675,10 @@ int kvm_arch_set_memory_region(struct kvm *kvm,
672 return 0; 675 return 0;
673} 676}
674 677
678void kvm_arch_flush_shadow(struct kvm *kvm)
679{
680}
681
675gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn) 682gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn)
676{ 683{
677 return gfn; 684 return gfn;
diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
index c02286c6a931..2e2d2ffb6a07 100644
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
@@ -199,7 +199,7 @@ out:
199 199
200static void handle_stsi_3_2_2(struct kvm_vcpu *vcpu, struct sysinfo_3_2_2 *mem) 200static void handle_stsi_3_2_2(struct kvm_vcpu *vcpu, struct sysinfo_3_2_2 *mem)
201{ 201{
202 struct float_interrupt *fi = &vcpu->kvm->arch.float_int; 202 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
203 int cpus = 0; 203 int cpus = 0;
204 int n; 204 int n;
205 205
diff --git a/arch/s390/kvm/sigp.c b/arch/s390/kvm/sigp.c
index 0a236acfb5f6..5a556114eaa5 100644
--- a/arch/s390/kvm/sigp.c
+++ b/arch/s390/kvm/sigp.c
@@ -45,7 +45,7 @@
45 45
46static int __sigp_sense(struct kvm_vcpu *vcpu, u16 cpu_addr, u64 *reg) 46static int __sigp_sense(struct kvm_vcpu *vcpu, u16 cpu_addr, u64 *reg)
47{ 47{
48 struct float_interrupt *fi = &vcpu->kvm->arch.float_int; 48 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
49 int rc; 49 int rc;
50 50
51 if (cpu_addr >= KVM_MAX_VCPUS) 51 if (cpu_addr >= KVM_MAX_VCPUS)
@@ -71,9 +71,9 @@ static int __sigp_sense(struct kvm_vcpu *vcpu, u16 cpu_addr, u64 *reg)
71 71
72static int __sigp_emergency(struct kvm_vcpu *vcpu, u16 cpu_addr) 72static int __sigp_emergency(struct kvm_vcpu *vcpu, u16 cpu_addr)
73{ 73{
74 struct float_interrupt *fi = &vcpu->kvm->arch.float_int; 74 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
75 struct local_interrupt *li; 75 struct kvm_s390_local_interrupt *li;
76 struct interrupt_info *inti; 76 struct kvm_s390_interrupt_info *inti;
77 int rc; 77 int rc;
78 78
79 if (cpu_addr >= KVM_MAX_VCPUS) 79 if (cpu_addr >= KVM_MAX_VCPUS)
@@ -108,9 +108,9 @@ unlock:
108 108
109static int __sigp_stop(struct kvm_vcpu *vcpu, u16 cpu_addr, int store) 109static int __sigp_stop(struct kvm_vcpu *vcpu, u16 cpu_addr, int store)
110{ 110{
111 struct float_interrupt *fi = &vcpu->kvm->arch.float_int; 111 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
112 struct local_interrupt *li; 112 struct kvm_s390_local_interrupt *li;
113 struct interrupt_info *inti; 113 struct kvm_s390_interrupt_info *inti;
114 int rc; 114 int rc;
115 115
116 if (cpu_addr >= KVM_MAX_VCPUS) 116 if (cpu_addr >= KVM_MAX_VCPUS)
@@ -169,9 +169,9 @@ static int __sigp_set_arch(struct kvm_vcpu *vcpu, u32 parameter)
169static int __sigp_set_prefix(struct kvm_vcpu *vcpu, u16 cpu_addr, u32 address, 169static int __sigp_set_prefix(struct kvm_vcpu *vcpu, u16 cpu_addr, u32 address,
170 u64 *reg) 170 u64 *reg)
171{ 171{
172 struct float_interrupt *fi = &vcpu->kvm->arch.float_int; 172 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
173 struct local_interrupt *li; 173 struct kvm_s390_local_interrupt *li;
174 struct interrupt_info *inti; 174 struct kvm_s390_interrupt_info *inti;
175 int rc; 175 int rc;
176 u8 tmp; 176 u8 tmp;
177 177
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index 87edf1ceb1df..d02def06ca91 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -113,7 +113,7 @@ static void kvm_setup_secondary_clock(void)
113#endif 113#endif
114 114
115#ifdef CONFIG_SMP 115#ifdef CONFIG_SMP
116void __init kvm_smp_prepare_boot_cpu(void) 116static void __init kvm_smp_prepare_boot_cpu(void)
117{ 117{
118 WARN_ON(kvm_register_clock("primary cpu clock")); 118 WARN_ON(kvm_register_clock("primary cpu clock"));
119 native_smp_prepare_boot_cpu(); 119 native_smp_prepare_boot_cpu();
diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile
index c97d35c218db..d0e940bb6f40 100644
--- a/arch/x86/kvm/Makefile
+++ b/arch/x86/kvm/Makefile
@@ -2,7 +2,8 @@
2# Makefile for Kernel-based Virtual Machine module 2# Makefile for Kernel-based Virtual Machine module
3# 3#
4 4
5common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o) 5common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \
6 coalesced_mmio.o)
6ifeq ($(CONFIG_KVM_TRACE),y) 7ifeq ($(CONFIG_KVM_TRACE),y)
7common-objs += $(addprefix ../../../virt/kvm/, kvm_trace.o) 8common-objs += $(addprefix ../../../virt/kvm/, kvm_trace.o)
8endif 9endif
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
index 3829aa7b663f..c0f7872a9124 100644
--- a/arch/x86/kvm/i8254.c
+++ b/arch/x86/kvm/i8254.c
@@ -91,7 +91,7 @@ static void pit_set_gate(struct kvm *kvm, int channel, u32 val)
91 c->gate = val; 91 c->gate = val;
92} 92}
93 93
94int pit_get_gate(struct kvm *kvm, int channel) 94static int pit_get_gate(struct kvm *kvm, int channel)
95{ 95{
96 WARN_ON(!mutex_is_locked(&kvm->arch.vpit->pit_state.lock)); 96 WARN_ON(!mutex_is_locked(&kvm->arch.vpit->pit_state.lock));
97 97
@@ -193,19 +193,16 @@ static void pit_latch_status(struct kvm *kvm, int channel)
193 } 193 }
194} 194}
195 195
196int __pit_timer_fn(struct kvm_kpit_state *ps) 196static int __pit_timer_fn(struct kvm_kpit_state *ps)
197{ 197{
198 struct kvm_vcpu *vcpu0 = ps->pit->kvm->vcpus[0]; 198 struct kvm_vcpu *vcpu0 = ps->pit->kvm->vcpus[0];
199 struct kvm_kpit_timer *pt = &ps->pit_timer; 199 struct kvm_kpit_timer *pt = &ps->pit_timer;
200 200
201 atomic_inc(&pt->pending); 201 if (!atomic_inc_and_test(&pt->pending))
202 smp_mb__after_atomic_inc();
203 if (vcpu0) {
204 set_bit(KVM_REQ_PENDING_TIMER, &vcpu0->requests); 202 set_bit(KVM_REQ_PENDING_TIMER, &vcpu0->requests);
205 if (waitqueue_active(&vcpu0->wq)) { 203 if (vcpu0 && waitqueue_active(&vcpu0->wq)) {
206 vcpu0->arch.mp_state = KVM_MP_STATE_RUNNABLE; 204 vcpu0->arch.mp_state = KVM_MP_STATE_RUNNABLE;
207 wake_up_interruptible(&vcpu0->wq); 205 wake_up_interruptible(&vcpu0->wq);
208 }
209 } 206 }
210 207
211 pt->timer.expires = ktime_add_ns(pt->timer.expires, pt->period); 208 pt->timer.expires = ktime_add_ns(pt->timer.expires, pt->period);
@@ -308,6 +305,7 @@ static void pit_load_count(struct kvm *kvm, int channel, u32 val)
308 create_pit_timer(&ps->pit_timer, val, 0); 305 create_pit_timer(&ps->pit_timer, val, 0);
309 break; 306 break;
310 case 2: 307 case 2:
308 case 3:
311 create_pit_timer(&ps->pit_timer, val, 1); 309 create_pit_timer(&ps->pit_timer, val, 1);
312 break; 310 break;
313 default: 311 default:
@@ -459,7 +457,8 @@ static void pit_ioport_read(struct kvm_io_device *this,
459 mutex_unlock(&pit_state->lock); 457 mutex_unlock(&pit_state->lock);
460} 458}
461 459
462static int pit_in_range(struct kvm_io_device *this, gpa_t addr) 460static int pit_in_range(struct kvm_io_device *this, gpa_t addr,
461 int len, int is_write)
463{ 462{
464 return ((addr >= KVM_PIT_BASE_ADDRESS) && 463 return ((addr >= KVM_PIT_BASE_ADDRESS) &&
465 (addr < KVM_PIT_BASE_ADDRESS + KVM_PIT_MEM_LENGTH)); 464 (addr < KVM_PIT_BASE_ADDRESS + KVM_PIT_MEM_LENGTH));
@@ -500,7 +499,8 @@ static void speaker_ioport_read(struct kvm_io_device *this,
500 mutex_unlock(&pit_state->lock); 499 mutex_unlock(&pit_state->lock);
501} 500}
502 501
503static int speaker_in_range(struct kvm_io_device *this, gpa_t addr) 502static int speaker_in_range(struct kvm_io_device *this, gpa_t addr,
503 int len, int is_write)
504{ 504{
505 return (addr == KVM_SPEAKER_BASE_ADDRESS); 505 return (addr == KVM_SPEAKER_BASE_ADDRESS);
506} 506}
@@ -575,7 +575,7 @@ void kvm_free_pit(struct kvm *kvm)
575 } 575 }
576} 576}
577 577
578void __inject_pit_timer_intr(struct kvm *kvm) 578static void __inject_pit_timer_intr(struct kvm *kvm)
579{ 579{
580 mutex_lock(&kvm->lock); 580 mutex_lock(&kvm->lock);
581 kvm_ioapic_set_irq(kvm->arch.vioapic, 0, 1); 581 kvm_ioapic_set_irq(kvm->arch.vioapic, 0, 1);
diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
index ab29cf2def47..c31164e8aa46 100644
--- a/arch/x86/kvm/i8259.c
+++ b/arch/x86/kvm/i8259.c
@@ -130,8 +130,10 @@ void kvm_pic_set_irq(void *opaque, int irq, int level)
130{ 130{
131 struct kvm_pic *s = opaque; 131 struct kvm_pic *s = opaque;
132 132
133 pic_set_irq1(&s->pics[irq >> 3], irq & 7, level); 133 if (irq >= 0 && irq < PIC_NUM_PINS) {
134 pic_update_irq(s); 134 pic_set_irq1(&s->pics[irq >> 3], irq & 7, level);
135 pic_update_irq(s);
136 }
135} 137}
136 138
137/* 139/*
@@ -346,7 +348,8 @@ static u32 elcr_ioport_read(void *opaque, u32 addr1)
346 return s->elcr; 348 return s->elcr;
347} 349}
348 350
349static int picdev_in_range(struct kvm_io_device *this, gpa_t addr) 351static int picdev_in_range(struct kvm_io_device *this, gpa_t addr,
352 int len, int is_write)
350{ 353{
351 switch (addr) { 354 switch (addr) {
352 case 0x20: 355 case 0x20:
diff --git a/arch/x86/kvm/irq.h b/arch/x86/kvm/irq.h
index 2a15be2275c0..7ca47cbb48bb 100644
--- a/arch/x86/kvm/irq.h
+++ b/arch/x86/kvm/irq.h
@@ -30,6 +30,8 @@
30#include "ioapic.h" 30#include "ioapic.h"
31#include "lapic.h" 31#include "lapic.h"
32 32
33#define PIC_NUM_PINS 16
34
33struct kvm; 35struct kvm;
34struct kvm_vcpu; 36struct kvm_vcpu;
35 37
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index ebc03f5ae162..73f43de69f67 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -356,8 +356,9 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
356 case APIC_DM_SMI: 356 case APIC_DM_SMI:
357 printk(KERN_DEBUG "Ignoring guest SMI\n"); 357 printk(KERN_DEBUG "Ignoring guest SMI\n");
358 break; 358 break;
359
359 case APIC_DM_NMI: 360 case APIC_DM_NMI:
360 printk(KERN_DEBUG "Ignoring guest NMI\n"); 361 kvm_inject_nmi(vcpu);
361 break; 362 break;
362 363
363 case APIC_DM_INIT: 364 case APIC_DM_INIT:
@@ -572,6 +573,8 @@ static u32 __apic_read(struct kvm_lapic *apic, unsigned int offset)
572{ 573{
573 u32 val = 0; 574 u32 val = 0;
574 575
576 KVMTRACE_1D(APIC_ACCESS, apic->vcpu, (u32)offset, handler);
577
575 if (offset >= LAPIC_MMIO_LENGTH) 578 if (offset >= LAPIC_MMIO_LENGTH)
576 return 0; 579 return 0;
577 580
@@ -695,6 +698,8 @@ static void apic_mmio_write(struct kvm_io_device *this,
695 698
696 offset &= 0xff0; 699 offset &= 0xff0;
697 700
701 KVMTRACE_1D(APIC_ACCESS, apic->vcpu, (u32)offset, handler);
702
698 switch (offset) { 703 switch (offset) {
699 case APIC_ID: /* Local APIC ID */ 704 case APIC_ID: /* Local APIC ID */
700 apic_set_reg(apic, APIC_ID, val); 705 apic_set_reg(apic, APIC_ID, val);
@@ -780,7 +785,8 @@ static void apic_mmio_write(struct kvm_io_device *this,
780 785
781} 786}
782 787
783static int apic_mmio_range(struct kvm_io_device *this, gpa_t addr) 788static int apic_mmio_range(struct kvm_io_device *this, gpa_t addr,
789 int len, int size)
784{ 790{
785 struct kvm_lapic *apic = (struct kvm_lapic *)this->private; 791 struct kvm_lapic *apic = (struct kvm_lapic *)this->private;
786 int ret = 0; 792 int ret = 0;
@@ -939,8 +945,8 @@ static int __apic_timer_fn(struct kvm_lapic *apic)
939 int result = 0; 945 int result = 0;
940 wait_queue_head_t *q = &apic->vcpu->wq; 946 wait_queue_head_t *q = &apic->vcpu->wq;
941 947
942 atomic_inc(&apic->timer.pending); 948 if(!atomic_inc_and_test(&apic->timer.pending))
943 set_bit(KVM_REQ_PENDING_TIMER, &apic->vcpu->requests); 949 set_bit(KVM_REQ_PENDING_TIMER, &apic->vcpu->requests);
944 if (waitqueue_active(q)) { 950 if (waitqueue_active(q)) {
945 apic->vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE; 951 apic->vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
946 wake_up_interruptible(q); 952 wake_up_interruptible(q);
diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h
index 676c396c9cee..81858881287e 100644
--- a/arch/x86/kvm/lapic.h
+++ b/arch/x86/kvm/lapic.h
@@ -31,6 +31,7 @@ void kvm_lapic_reset(struct kvm_vcpu *vcpu);
31u64 kvm_lapic_get_cr8(struct kvm_vcpu *vcpu); 31u64 kvm_lapic_get_cr8(struct kvm_vcpu *vcpu);
32void kvm_lapic_set_tpr(struct kvm_vcpu *vcpu, unsigned long cr8); 32void kvm_lapic_set_tpr(struct kvm_vcpu *vcpu, unsigned long cr8);
33void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value); 33void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value);
34u64 kvm_lapic_get_base(struct kvm_vcpu *vcpu);
34 35
35int kvm_apic_match_physical_addr(struct kvm_lapic *apic, u16 dest); 36int kvm_apic_match_physical_addr(struct kvm_lapic *apic, u16 dest);
36int kvm_apic_match_logical_addr(struct kvm_lapic *apic, u8 mda); 37int kvm_apic_match_logical_addr(struct kvm_lapic *apic, u8 mda);
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 7e7c3969f7a2..b0e4ddca6c18 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -66,7 +66,8 @@ static void kvm_mmu_audit(struct kvm_vcpu *vcpu, const char *msg) {}
66#endif 66#endif
67 67
68#if defined(MMU_DEBUG) || defined(AUDIT) 68#if defined(MMU_DEBUG) || defined(AUDIT)
69static int dbg = 1; 69static int dbg = 0;
70module_param(dbg, bool, 0644);
70#endif 71#endif
71 72
72#ifndef MMU_DEBUG 73#ifndef MMU_DEBUG
@@ -776,6 +777,15 @@ static void mmu_page_remove_parent_pte(struct kvm_mmu_page *sp,
776 BUG(); 777 BUG();
777} 778}
778 779
780static void nonpaging_prefetch_page(struct kvm_vcpu *vcpu,
781 struct kvm_mmu_page *sp)
782{
783 int i;
784
785 for (i = 0; i < PT64_ENT_PER_PAGE; ++i)
786 sp->spt[i] = shadow_trap_nonpresent_pte;
787}
788
779static struct kvm_mmu_page *kvm_mmu_lookup_page(struct kvm *kvm, gfn_t gfn) 789static struct kvm_mmu_page *kvm_mmu_lookup_page(struct kvm *kvm, gfn_t gfn)
780{ 790{
781 unsigned index; 791 unsigned index;
@@ -841,7 +851,10 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu,
841 hlist_add_head(&sp->hash_link, bucket); 851 hlist_add_head(&sp->hash_link, bucket);
842 if (!metaphysical) 852 if (!metaphysical)
843 rmap_write_protect(vcpu->kvm, gfn); 853 rmap_write_protect(vcpu->kvm, gfn);
844 vcpu->arch.mmu.prefetch_page(vcpu, sp); 854 if (shadow_trap_nonpresent_pte != shadow_notrap_nonpresent_pte)
855 vcpu->arch.mmu.prefetch_page(vcpu, sp);
856 else
857 nonpaging_prefetch_page(vcpu, sp);
845 return sp; 858 return sp;
846} 859}
847 860
@@ -917,14 +930,17 @@ static void kvm_mmu_zap_page(struct kvm *kvm, struct kvm_mmu_page *sp)
917 } 930 }
918 kvm_mmu_page_unlink_children(kvm, sp); 931 kvm_mmu_page_unlink_children(kvm, sp);
919 if (!sp->root_count) { 932 if (!sp->root_count) {
920 if (!sp->role.metaphysical) 933 if (!sp->role.metaphysical && !sp->role.invalid)
921 unaccount_shadowed(kvm, sp->gfn); 934 unaccount_shadowed(kvm, sp->gfn);
922 hlist_del(&sp->hash_link); 935 hlist_del(&sp->hash_link);
923 kvm_mmu_free_page(kvm, sp); 936 kvm_mmu_free_page(kvm, sp);
924 } else { 937 } else {
938 int invalid = sp->role.invalid;
925 list_move(&sp->link, &kvm->arch.active_mmu_pages); 939 list_move(&sp->link, &kvm->arch.active_mmu_pages);
926 sp->role.invalid = 1; 940 sp->role.invalid = 1;
927 kvm_reload_remote_mmus(kvm); 941 kvm_reload_remote_mmus(kvm);
942 if (!sp->role.metaphysical && !invalid)
943 unaccount_shadowed(kvm, sp->gfn);
928 } 944 }
929 kvm_mmu_reset_last_pte_updated(kvm); 945 kvm_mmu_reset_last_pte_updated(kvm);
930} 946}
@@ -1103,7 +1119,7 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *shadow_pte,
1103 mark_page_dirty(vcpu->kvm, gfn); 1119 mark_page_dirty(vcpu->kvm, gfn);
1104 1120
1105 pgprintk("%s: setting spte %llx\n", __func__, spte); 1121 pgprintk("%s: setting spte %llx\n", __func__, spte);
1106 pgprintk("instantiating %s PTE (%s) at %d (%llx) addr %llx\n", 1122 pgprintk("instantiating %s PTE (%s) at %ld (%llx) addr %p\n",
1107 (spte&PT_PAGE_SIZE_MASK)? "2MB" : "4kB", 1123 (spte&PT_PAGE_SIZE_MASK)? "2MB" : "4kB",
1108 (spte&PT_WRITABLE_MASK)?"RW":"R", gfn, spte, shadow_pte); 1124 (spte&PT_WRITABLE_MASK)?"RW":"R", gfn, spte, shadow_pte);
1109 set_shadow_pte(shadow_pte, spte); 1125 set_shadow_pte(shadow_pte, spte);
@@ -1122,8 +1138,10 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *shadow_pte,
1122 else 1138 else
1123 kvm_release_pfn_clean(pfn); 1139 kvm_release_pfn_clean(pfn);
1124 } 1140 }
1125 if (!ptwrite || !*ptwrite) 1141 if (speculative) {
1126 vcpu->arch.last_pte_updated = shadow_pte; 1142 vcpu->arch.last_pte_updated = shadow_pte;
1143 vcpu->arch.last_pte_gfn = gfn;
1144 }
1127} 1145}
1128 1146
1129static void nonpaging_new_cr3(struct kvm_vcpu *vcpu) 1147static void nonpaging_new_cr3(struct kvm_vcpu *vcpu)
@@ -1171,9 +1189,10 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write,
1171 return -ENOMEM; 1189 return -ENOMEM;
1172 } 1190 }
1173 1191
1174 table[index] = __pa(new_table->spt) 1192 set_shadow_pte(&table[index],
1175 | PT_PRESENT_MASK | PT_WRITABLE_MASK 1193 __pa(new_table->spt)
1176 | shadow_user_mask | shadow_x_mask; 1194 | PT_PRESENT_MASK | PT_WRITABLE_MASK
1195 | shadow_user_mask | shadow_x_mask);
1177 } 1196 }
1178 table_addr = table[index] & PT64_BASE_ADDR_MASK; 1197 table_addr = table[index] & PT64_BASE_ADDR_MASK;
1179 } 1198 }
@@ -1211,15 +1230,6 @@ static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, int write, gfn_t gfn)
1211} 1230}
1212 1231
1213 1232
1214static void nonpaging_prefetch_page(struct kvm_vcpu *vcpu,
1215 struct kvm_mmu_page *sp)
1216{
1217 int i;
1218
1219 for (i = 0; i < PT64_ENT_PER_PAGE; ++i)
1220 sp->spt[i] = shadow_trap_nonpresent_pte;
1221}
1222
1223static void mmu_free_roots(struct kvm_vcpu *vcpu) 1233static void mmu_free_roots(struct kvm_vcpu *vcpu)
1224{ 1234{
1225 int i; 1235 int i;
@@ -1671,6 +1681,18 @@ static void mmu_guess_page_from_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
1671 vcpu->arch.update_pte.pfn = pfn; 1681 vcpu->arch.update_pte.pfn = pfn;
1672} 1682}
1673 1683
1684static void kvm_mmu_access_page(struct kvm_vcpu *vcpu, gfn_t gfn)
1685{
1686 u64 *spte = vcpu->arch.last_pte_updated;
1687
1688 if (spte
1689 && vcpu->arch.last_pte_gfn == gfn
1690 && shadow_accessed_mask
1691 && !(*spte & shadow_accessed_mask)
1692 && is_shadow_present_pte(*spte))
1693 set_bit(PT_ACCESSED_SHIFT, (unsigned long *)spte);
1694}
1695
1674void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa, 1696void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
1675 const u8 *new, int bytes) 1697 const u8 *new, int bytes)
1676{ 1698{
@@ -1694,6 +1716,7 @@ void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
1694 pgprintk("%s: gpa %llx bytes %d\n", __func__, gpa, bytes); 1716 pgprintk("%s: gpa %llx bytes %d\n", __func__, gpa, bytes);
1695 mmu_guess_page_from_pte_write(vcpu, gpa, new, bytes); 1717 mmu_guess_page_from_pte_write(vcpu, gpa, new, bytes);
1696 spin_lock(&vcpu->kvm->mmu_lock); 1718 spin_lock(&vcpu->kvm->mmu_lock);
1719 kvm_mmu_access_page(vcpu, gfn);
1697 kvm_mmu_free_some_pages(vcpu); 1720 kvm_mmu_free_some_pages(vcpu);
1698 ++vcpu->kvm->stat.mmu_pte_write; 1721 ++vcpu->kvm->stat.mmu_pte_write;
1699 kvm_mmu_audit(vcpu, "pre pte write"); 1722 kvm_mmu_audit(vcpu, "pre pte write");
@@ -1948,7 +1971,7 @@ void kvm_mmu_zap_all(struct kvm *kvm)
1948 kvm_flush_remote_tlbs(kvm); 1971 kvm_flush_remote_tlbs(kvm);
1949} 1972}
1950 1973
1951void kvm_mmu_remove_one_alloc_mmu_page(struct kvm *kvm) 1974static void kvm_mmu_remove_one_alloc_mmu_page(struct kvm *kvm)
1952{ 1975{
1953 struct kvm_mmu_page *page; 1976 struct kvm_mmu_page *page;
1954 1977
@@ -1968,6 +1991,8 @@ static int mmu_shrink(int nr_to_scan, gfp_t gfp_mask)
1968 list_for_each_entry(kvm, &vm_list, vm_list) { 1991 list_for_each_entry(kvm, &vm_list, vm_list) {
1969 int npages; 1992 int npages;
1970 1993
1994 if (!down_read_trylock(&kvm->slots_lock))
1995 continue;
1971 spin_lock(&kvm->mmu_lock); 1996 spin_lock(&kvm->mmu_lock);
1972 npages = kvm->arch.n_alloc_mmu_pages - 1997 npages = kvm->arch.n_alloc_mmu_pages -
1973 kvm->arch.n_free_mmu_pages; 1998 kvm->arch.n_free_mmu_pages;
@@ -1980,6 +2005,7 @@ static int mmu_shrink(int nr_to_scan, gfp_t gfp_mask)
1980 nr_to_scan--; 2005 nr_to_scan--;
1981 2006
1982 spin_unlock(&kvm->mmu_lock); 2007 spin_unlock(&kvm->mmu_lock);
2008 up_read(&kvm->slots_lock);
1983 } 2009 }
1984 if (kvm_freed) 2010 if (kvm_freed)
1985 list_move_tail(&kvm_freed->vm_list, &vm_list); 2011 list_move_tail(&kvm_freed->vm_list, &vm_list);
diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h
index 1730757bbc7a..258e5d56298e 100644
--- a/arch/x86/kvm/mmu.h
+++ b/arch/x86/kvm/mmu.h
@@ -15,7 +15,8 @@
15#define PT_USER_MASK (1ULL << 2) 15#define PT_USER_MASK (1ULL << 2)
16#define PT_PWT_MASK (1ULL << 3) 16#define PT_PWT_MASK (1ULL << 3)
17#define PT_PCD_MASK (1ULL << 4) 17#define PT_PCD_MASK (1ULL << 4)
18#define PT_ACCESSED_MASK (1ULL << 5) 18#define PT_ACCESSED_SHIFT 5
19#define PT_ACCESSED_MASK (1ULL << PT_ACCESSED_SHIFT)
19#define PT_DIRTY_MASK (1ULL << 6) 20#define PT_DIRTY_MASK (1ULL << 6)
20#define PT_PAGE_SIZE_MASK (1ULL << 7) 21#define PT_PAGE_SIZE_MASK (1ULL << 7)
21#define PT_PAT_MASK (1ULL << 7) 22#define PT_PAT_MASK (1ULL << 7)
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index 934c7b619396..4d918220baeb 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -460,8 +460,9 @@ static gpa_t FNAME(gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t vaddr)
460static void FNAME(prefetch_page)(struct kvm_vcpu *vcpu, 460static void FNAME(prefetch_page)(struct kvm_vcpu *vcpu,
461 struct kvm_mmu_page *sp) 461 struct kvm_mmu_page *sp)
462{ 462{
463 int i, offset = 0, r = 0; 463 int i, j, offset, r;
464 pt_element_t pt; 464 pt_element_t pt[256 / sizeof(pt_element_t)];
465 gpa_t pte_gpa;
465 466
466 if (sp->role.metaphysical 467 if (sp->role.metaphysical
467 || (PTTYPE == 32 && sp->role.level > PT_PAGE_TABLE_LEVEL)) { 468 || (PTTYPE == 32 && sp->role.level > PT_PAGE_TABLE_LEVEL)) {
@@ -469,19 +470,20 @@ static void FNAME(prefetch_page)(struct kvm_vcpu *vcpu,
469 return; 470 return;
470 } 471 }
471 472
472 if (PTTYPE == 32) 473 pte_gpa = gfn_to_gpa(sp->gfn);
474 if (PTTYPE == 32) {
473 offset = sp->role.quadrant << PT64_LEVEL_BITS; 475 offset = sp->role.quadrant << PT64_LEVEL_BITS;
476 pte_gpa += offset * sizeof(pt_element_t);
477 }
474 478
475 for (i = 0; i < PT64_ENT_PER_PAGE; ++i) { 479 for (i = 0; i < PT64_ENT_PER_PAGE; i += ARRAY_SIZE(pt)) {
476 gpa_t pte_gpa = gfn_to_gpa(sp->gfn); 480 r = kvm_read_guest_atomic(vcpu->kvm, pte_gpa, pt, sizeof pt);
477 pte_gpa += (i+offset) * sizeof(pt_element_t); 481 pte_gpa += ARRAY_SIZE(pt) * sizeof(pt_element_t);
478 482 for (j = 0; j < ARRAY_SIZE(pt); ++j)
479 r = kvm_read_guest_atomic(vcpu->kvm, pte_gpa, &pt, 483 if (r || is_present_pte(pt[j]))
480 sizeof(pt_element_t)); 484 sp->spt[i+j] = shadow_trap_nonpresent_pte;
481 if (r || is_present_pte(pt)) 485 else
482 sp->spt[i] = shadow_trap_nonpresent_pte; 486 sp->spt[i+j] = shadow_notrap_nonpresent_pte;
483 else
484 sp->spt[i] = shadow_notrap_nonpresent_pte;
485 } 487 }
486} 488}
487 489
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 6b0d5fa5bab3..b756e876dce3 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -27,6 +27,8 @@
27 27
28#include <asm/desc.h> 28#include <asm/desc.h>
29 29
30#define __ex(x) __kvm_handle_fault_on_reboot(x)
31
30MODULE_AUTHOR("Qumranet"); 32MODULE_AUTHOR("Qumranet");
31MODULE_LICENSE("GPL"); 33MODULE_LICENSE("GPL");
32 34
@@ -129,17 +131,17 @@ static inline void push_irq(struct kvm_vcpu *vcpu, u8 irq)
129 131
130static inline void clgi(void) 132static inline void clgi(void)
131{ 133{
132 asm volatile (SVM_CLGI); 134 asm volatile (__ex(SVM_CLGI));
133} 135}
134 136
135static inline void stgi(void) 137static inline void stgi(void)
136{ 138{
137 asm volatile (SVM_STGI); 139 asm volatile (__ex(SVM_STGI));
138} 140}
139 141
140static inline void invlpga(unsigned long addr, u32 asid) 142static inline void invlpga(unsigned long addr, u32 asid)
141{ 143{
142 asm volatile (SVM_INVLPGA :: "a"(addr), "c"(asid)); 144 asm volatile (__ex(SVM_INVLPGA) :: "a"(addr), "c"(asid));
143} 145}
144 146
145static inline unsigned long kvm_read_cr2(void) 147static inline unsigned long kvm_read_cr2(void)
@@ -270,19 +272,11 @@ static int has_svm(void)
270 272
271static void svm_hardware_disable(void *garbage) 273static void svm_hardware_disable(void *garbage)
272{ 274{
273 struct svm_cpu_data *svm_data 275 uint64_t efer;
274 = per_cpu(svm_data, raw_smp_processor_id());
275
276 if (svm_data) {
277 uint64_t efer;
278 276
279 wrmsrl(MSR_VM_HSAVE_PA, 0); 277 wrmsrl(MSR_VM_HSAVE_PA, 0);
280 rdmsrl(MSR_EFER, efer); 278 rdmsrl(MSR_EFER, efer);
281 wrmsrl(MSR_EFER, efer & ~MSR_EFER_SVME_MASK); 279 wrmsrl(MSR_EFER, efer & ~MSR_EFER_SVME_MASK);
282 per_cpu(svm_data, raw_smp_processor_id()) = NULL;
283 __free_page(svm_data->save_area);
284 kfree(svm_data);
285 }
286} 280}
287 281
288static void svm_hardware_enable(void *garbage) 282static void svm_hardware_enable(void *garbage)
@@ -321,6 +315,19 @@ static void svm_hardware_enable(void *garbage)
321 page_to_pfn(svm_data->save_area) << PAGE_SHIFT); 315 page_to_pfn(svm_data->save_area) << PAGE_SHIFT);
322} 316}
323 317
318static void svm_cpu_uninit(int cpu)
319{
320 struct svm_cpu_data *svm_data
321 = per_cpu(svm_data, raw_smp_processor_id());
322
323 if (!svm_data)
324 return;
325
326 per_cpu(svm_data, raw_smp_processor_id()) = NULL;
327 __free_page(svm_data->save_area);
328 kfree(svm_data);
329}
330
324static int svm_cpu_init(int cpu) 331static int svm_cpu_init(int cpu)
325{ 332{
326 struct svm_cpu_data *svm_data; 333 struct svm_cpu_data *svm_data;
@@ -458,6 +465,11 @@ err:
458 465
459static __exit void svm_hardware_unsetup(void) 466static __exit void svm_hardware_unsetup(void)
460{ 467{
468 int cpu;
469
470 for_each_online_cpu(cpu)
471 svm_cpu_uninit(cpu);
472
461 __free_pages(pfn_to_page(iopm_base >> PAGE_SHIFT), IOPM_ALLOC_ORDER); 473 __free_pages(pfn_to_page(iopm_base >> PAGE_SHIFT), IOPM_ALLOC_ORDER);
462 iopm_base = 0; 474 iopm_base = 0;
463} 475}
@@ -707,10 +719,6 @@ static void svm_vcpu_put(struct kvm_vcpu *vcpu)
707 rdtscll(vcpu->arch.host_tsc); 719 rdtscll(vcpu->arch.host_tsc);
708} 720}
709 721
710static void svm_vcpu_decache(struct kvm_vcpu *vcpu)
711{
712}
713
714static void svm_cache_regs(struct kvm_vcpu *vcpu) 722static void svm_cache_regs(struct kvm_vcpu *vcpu)
715{ 723{
716 struct vcpu_svm *svm = to_svm(vcpu); 724 struct vcpu_svm *svm = to_svm(vcpu);
@@ -949,7 +957,9 @@ static void new_asid(struct vcpu_svm *svm, struct svm_cpu_data *svm_data)
949 957
950static unsigned long svm_get_dr(struct kvm_vcpu *vcpu, int dr) 958static unsigned long svm_get_dr(struct kvm_vcpu *vcpu, int dr)
951{ 959{
952 return to_svm(vcpu)->db_regs[dr]; 960 unsigned long val = to_svm(vcpu)->db_regs[dr];
961 KVMTRACE_2D(DR_READ, vcpu, (u32)dr, (u32)val, handler);
962 return val;
953} 963}
954 964
955static void svm_set_dr(struct kvm_vcpu *vcpu, int dr, unsigned long value, 965static void svm_set_dr(struct kvm_vcpu *vcpu, int dr, unsigned long value,
@@ -1004,6 +1014,16 @@ static int pf_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
1004 1014
1005 fault_address = svm->vmcb->control.exit_info_2; 1015 fault_address = svm->vmcb->control.exit_info_2;
1006 error_code = svm->vmcb->control.exit_info_1; 1016 error_code = svm->vmcb->control.exit_info_1;
1017
1018 if (!npt_enabled)
1019 KVMTRACE_3D(PAGE_FAULT, &svm->vcpu, error_code,
1020 (u32)fault_address, (u32)(fault_address >> 32),
1021 handler);
1022 else
1023 KVMTRACE_3D(TDP_FAULT, &svm->vcpu, error_code,
1024 (u32)fault_address, (u32)(fault_address >> 32),
1025 handler);
1026
1007 return kvm_mmu_page_fault(&svm->vcpu, fault_address, error_code); 1027 return kvm_mmu_page_fault(&svm->vcpu, fault_address, error_code);
1008} 1028}
1009 1029
@@ -1081,6 +1101,19 @@ static int io_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
1081 return kvm_emulate_pio(&svm->vcpu, kvm_run, in, size, port); 1101 return kvm_emulate_pio(&svm->vcpu, kvm_run, in, size, port);
1082} 1102}
1083 1103
1104static int nmi_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
1105{
1106 KVMTRACE_0D(NMI, &svm->vcpu, handler);
1107 return 1;
1108}
1109
1110static int intr_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
1111{
1112 ++svm->vcpu.stat.irq_exits;
1113 KVMTRACE_0D(INTR, &svm->vcpu, handler);
1114 return 1;
1115}
1116
1084static int nop_on_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run) 1117static int nop_on_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
1085{ 1118{
1086 return 1; 1119 return 1;
@@ -1219,6 +1252,9 @@ static int rdmsr_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
1219 if (svm_get_msr(&svm->vcpu, ecx, &data)) 1252 if (svm_get_msr(&svm->vcpu, ecx, &data))
1220 kvm_inject_gp(&svm->vcpu, 0); 1253 kvm_inject_gp(&svm->vcpu, 0);
1221 else { 1254 else {
1255 KVMTRACE_3D(MSR_READ, &svm->vcpu, ecx, (u32)data,
1256 (u32)(data >> 32), handler);
1257
1222 svm->vmcb->save.rax = data & 0xffffffff; 1258 svm->vmcb->save.rax = data & 0xffffffff;
1223 svm->vcpu.arch.regs[VCPU_REGS_RDX] = data >> 32; 1259 svm->vcpu.arch.regs[VCPU_REGS_RDX] = data >> 32;
1224 svm->next_rip = svm->vmcb->save.rip + 2; 1260 svm->next_rip = svm->vmcb->save.rip + 2;
@@ -1284,16 +1320,19 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 data)
1284 case MSR_K7_EVNTSEL1: 1320 case MSR_K7_EVNTSEL1:
1285 case MSR_K7_EVNTSEL2: 1321 case MSR_K7_EVNTSEL2:
1286 case MSR_K7_EVNTSEL3: 1322 case MSR_K7_EVNTSEL3:
1323 case MSR_K7_PERFCTR0:
1324 case MSR_K7_PERFCTR1:
1325 case MSR_K7_PERFCTR2:
1326 case MSR_K7_PERFCTR3:
1287 /* 1327 /*
1288 * only support writing 0 to the performance counters for now 1328 * Just discard all writes to the performance counters; this
1289 * to make Windows happy. Should be replaced by a real 1329 * should keep both older linux and windows 64-bit guests
1290 * performance counter emulation later. 1330 * happy
1291 */ 1331 */
1292 if (data != 0) 1332 pr_unimpl(vcpu, "unimplemented perfctr wrmsr: 0x%x data 0x%llx\n", ecx, data);
1293 goto unhandled; 1333
1294 break; 1334 break;
1295 default: 1335 default:
1296 unhandled:
1297 return kvm_set_msr_common(vcpu, ecx, data); 1336 return kvm_set_msr_common(vcpu, ecx, data);
1298 } 1337 }
1299 return 0; 1338 return 0;
@@ -1304,6 +1343,10 @@ static int wrmsr_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
1304 u32 ecx = svm->vcpu.arch.regs[VCPU_REGS_RCX]; 1343 u32 ecx = svm->vcpu.arch.regs[VCPU_REGS_RCX];
1305 u64 data = (svm->vmcb->save.rax & -1u) 1344 u64 data = (svm->vmcb->save.rax & -1u)
1306 | ((u64)(svm->vcpu.arch.regs[VCPU_REGS_RDX] & -1u) << 32); 1345 | ((u64)(svm->vcpu.arch.regs[VCPU_REGS_RDX] & -1u) << 32);
1346
1347 KVMTRACE_3D(MSR_WRITE, &svm->vcpu, ecx, (u32)data, (u32)(data >> 32),
1348 handler);
1349
1307 svm->next_rip = svm->vmcb->save.rip + 2; 1350 svm->next_rip = svm->vmcb->save.rip + 2;
1308 if (svm_set_msr(&svm->vcpu, ecx, data)) 1351 if (svm_set_msr(&svm->vcpu, ecx, data))
1309 kvm_inject_gp(&svm->vcpu, 0); 1352 kvm_inject_gp(&svm->vcpu, 0);
@@ -1323,6 +1366,8 @@ static int msr_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
1323static int interrupt_window_interception(struct vcpu_svm *svm, 1366static int interrupt_window_interception(struct vcpu_svm *svm,
1324 struct kvm_run *kvm_run) 1367 struct kvm_run *kvm_run)
1325{ 1368{
1369 KVMTRACE_0D(PEND_INTR, &svm->vcpu, handler);
1370
1326 svm->vmcb->control.intercept &= ~(1ULL << INTERCEPT_VINTR); 1371 svm->vmcb->control.intercept &= ~(1ULL << INTERCEPT_VINTR);
1327 svm->vmcb->control.int_ctl &= ~V_IRQ_MASK; 1372 svm->vmcb->control.int_ctl &= ~V_IRQ_MASK;
1328 /* 1373 /*
@@ -1364,8 +1409,8 @@ static int (*svm_exit_handlers[])(struct vcpu_svm *svm,
1364 [SVM_EXIT_EXCP_BASE + PF_VECTOR] = pf_interception, 1409 [SVM_EXIT_EXCP_BASE + PF_VECTOR] = pf_interception,
1365 [SVM_EXIT_EXCP_BASE + NM_VECTOR] = nm_interception, 1410 [SVM_EXIT_EXCP_BASE + NM_VECTOR] = nm_interception,
1366 [SVM_EXIT_EXCP_BASE + MC_VECTOR] = mc_interception, 1411 [SVM_EXIT_EXCP_BASE + MC_VECTOR] = mc_interception,
1367 [SVM_EXIT_INTR] = nop_on_interception, 1412 [SVM_EXIT_INTR] = intr_interception,
1368 [SVM_EXIT_NMI] = nop_on_interception, 1413 [SVM_EXIT_NMI] = nmi_interception,
1369 [SVM_EXIT_SMI] = nop_on_interception, 1414 [SVM_EXIT_SMI] = nop_on_interception,
1370 [SVM_EXIT_INIT] = nop_on_interception, 1415 [SVM_EXIT_INIT] = nop_on_interception,
1371 [SVM_EXIT_VINTR] = interrupt_window_interception, 1416 [SVM_EXIT_VINTR] = interrupt_window_interception,
@@ -1397,6 +1442,9 @@ static int handle_exit(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
1397 struct vcpu_svm *svm = to_svm(vcpu); 1442 struct vcpu_svm *svm = to_svm(vcpu);
1398 u32 exit_code = svm->vmcb->control.exit_code; 1443 u32 exit_code = svm->vmcb->control.exit_code;
1399 1444
1445 KVMTRACE_3D(VMEXIT, vcpu, exit_code, (u32)svm->vmcb->save.rip,
1446 (u32)((u64)svm->vmcb->save.rip >> 32), entryexit);
1447
1400 if (npt_enabled) { 1448 if (npt_enabled) {
1401 int mmu_reload = 0; 1449 int mmu_reload = 0;
1402 if ((vcpu->arch.cr0 ^ svm->vmcb->save.cr0) & X86_CR0_PG) { 1450 if ((vcpu->arch.cr0 ^ svm->vmcb->save.cr0) & X86_CR0_PG) {
@@ -1470,6 +1518,8 @@ static inline void svm_inject_irq(struct vcpu_svm *svm, int irq)
1470{ 1518{
1471 struct vmcb_control_area *control; 1519 struct vmcb_control_area *control;
1472 1520
1521 KVMTRACE_1D(INJ_VIRQ, &svm->vcpu, (u32)irq, handler);
1522
1473 control = &svm->vmcb->control; 1523 control = &svm->vmcb->control;
1474 control->int_vector = irq; 1524 control->int_vector = irq;
1475 control->int_ctl &= ~V_INTR_PRIO_MASK; 1525 control->int_ctl &= ~V_INTR_PRIO_MASK;
@@ -1660,9 +1710,9 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
1660 sync_lapic_to_cr8(vcpu); 1710 sync_lapic_to_cr8(vcpu);
1661 1711
1662 save_host_msrs(vcpu); 1712 save_host_msrs(vcpu);
1663 fs_selector = read_fs(); 1713 fs_selector = kvm_read_fs();
1664 gs_selector = read_gs(); 1714 gs_selector = kvm_read_gs();
1665 ldt_selector = read_ldt(); 1715 ldt_selector = kvm_read_ldt();
1666 svm->host_cr2 = kvm_read_cr2(); 1716 svm->host_cr2 = kvm_read_cr2();
1667 svm->host_dr6 = read_dr6(); 1717 svm->host_dr6 = read_dr6();
1668 svm->host_dr7 = read_dr7(); 1718 svm->host_dr7 = read_dr7();
@@ -1716,17 +1766,17 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
1716 /* Enter guest mode */ 1766 /* Enter guest mode */
1717 "push %%rax \n\t" 1767 "push %%rax \n\t"
1718 "mov %c[vmcb](%[svm]), %%rax \n\t" 1768 "mov %c[vmcb](%[svm]), %%rax \n\t"
1719 SVM_VMLOAD "\n\t" 1769 __ex(SVM_VMLOAD) "\n\t"
1720 SVM_VMRUN "\n\t" 1770 __ex(SVM_VMRUN) "\n\t"
1721 SVM_VMSAVE "\n\t" 1771 __ex(SVM_VMSAVE) "\n\t"
1722 "pop %%rax \n\t" 1772 "pop %%rax \n\t"
1723#else 1773#else
1724 /* Enter guest mode */ 1774 /* Enter guest mode */
1725 "push %%eax \n\t" 1775 "push %%eax \n\t"
1726 "mov %c[vmcb](%[svm]), %%eax \n\t" 1776 "mov %c[vmcb](%[svm]), %%eax \n\t"
1727 SVM_VMLOAD "\n\t" 1777 __ex(SVM_VMLOAD) "\n\t"
1728 SVM_VMRUN "\n\t" 1778 __ex(SVM_VMRUN) "\n\t"
1729 SVM_VMSAVE "\n\t" 1779 __ex(SVM_VMSAVE) "\n\t"
1730 "pop %%eax \n\t" 1780 "pop %%eax \n\t"
1731#endif 1781#endif
1732 1782
@@ -1795,9 +1845,9 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
1795 write_dr7(svm->host_dr7); 1845 write_dr7(svm->host_dr7);
1796 kvm_write_cr2(svm->host_cr2); 1846 kvm_write_cr2(svm->host_cr2);
1797 1847
1798 load_fs(fs_selector); 1848 kvm_load_fs(fs_selector);
1799 load_gs(gs_selector); 1849 kvm_load_gs(gs_selector);
1800 load_ldt(ldt_selector); 1850 kvm_load_ldt(ldt_selector);
1801 load_host_msrs(vcpu); 1851 load_host_msrs(vcpu);
1802 1852
1803 reload_tss(vcpu); 1853 reload_tss(vcpu);
@@ -1889,7 +1939,6 @@ static struct kvm_x86_ops svm_x86_ops = {
1889 .prepare_guest_switch = svm_prepare_guest_switch, 1939 .prepare_guest_switch = svm_prepare_guest_switch,
1890 .vcpu_load = svm_vcpu_load, 1940 .vcpu_load = svm_vcpu_load,
1891 .vcpu_put = svm_vcpu_put, 1941 .vcpu_put = svm_vcpu_put,
1892 .vcpu_decache = svm_vcpu_decache,
1893 1942
1894 .set_guest_debug = svm_guest_debug, 1943 .set_guest_debug = svm_guest_debug,
1895 .get_msr = svm_get_msr, 1944 .get_msr = svm_get_msr,
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 10ce6ee4c491..0cac63701719 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -30,6 +30,8 @@
30#include <asm/io.h> 30#include <asm/io.h>
31#include <asm/desc.h> 31#include <asm/desc.h>
32 32
33#define __ex(x) __kvm_handle_fault_on_reboot(x)
34
33MODULE_AUTHOR("Qumranet"); 35MODULE_AUTHOR("Qumranet");
34MODULE_LICENSE("GPL"); 36MODULE_LICENSE("GPL");
35 37
@@ -53,6 +55,7 @@ struct vmcs {
53 55
54struct vcpu_vmx { 56struct vcpu_vmx {
55 struct kvm_vcpu vcpu; 57 struct kvm_vcpu vcpu;
58 struct list_head local_vcpus_link;
56 int launched; 59 int launched;
57 u8 fail; 60 u8 fail;
58 u32 idt_vectoring_info; 61 u32 idt_vectoring_info;
@@ -88,9 +91,11 @@ static inline struct vcpu_vmx *to_vmx(struct kvm_vcpu *vcpu)
88} 91}
89 92
90static int init_rmode(struct kvm *kvm); 93static int init_rmode(struct kvm *kvm);
94static u64 construct_eptp(unsigned long root_hpa);
91 95
92static DEFINE_PER_CPU(struct vmcs *, vmxarea); 96static DEFINE_PER_CPU(struct vmcs *, vmxarea);
93static DEFINE_PER_CPU(struct vmcs *, current_vmcs); 97static DEFINE_PER_CPU(struct vmcs *, current_vmcs);
98static DEFINE_PER_CPU(struct list_head, vcpus_on_cpu);
94 99
95static struct page *vmx_io_bitmap_a; 100static struct page *vmx_io_bitmap_a;
96static struct page *vmx_io_bitmap_b; 101static struct page *vmx_io_bitmap_b;
@@ -260,6 +265,11 @@ static inline int cpu_has_vmx_vpid(void)
260 SECONDARY_EXEC_ENABLE_VPID); 265 SECONDARY_EXEC_ENABLE_VPID);
261} 266}
262 267
268static inline int cpu_has_virtual_nmis(void)
269{
270 return vmcs_config.pin_based_exec_ctrl & PIN_BASED_VIRTUAL_NMIS;
271}
272
263static int __find_msr_index(struct vcpu_vmx *vmx, u32 msr) 273static int __find_msr_index(struct vcpu_vmx *vmx, u32 msr)
264{ 274{
265 int i; 275 int i;
@@ -278,7 +288,7 @@ static inline void __invvpid(int ext, u16 vpid, gva_t gva)
278 u64 gva; 288 u64 gva;
279 } operand = { vpid, 0, gva }; 289 } operand = { vpid, 0, gva };
280 290
281 asm volatile (ASM_VMX_INVVPID 291 asm volatile (__ex(ASM_VMX_INVVPID)
282 /* CF==1 or ZF==1 --> rc = -1 */ 292 /* CF==1 or ZF==1 --> rc = -1 */
283 "; ja 1f ; ud2 ; 1:" 293 "; ja 1f ; ud2 ; 1:"
284 : : "a"(&operand), "c"(ext) : "cc", "memory"); 294 : : "a"(&operand), "c"(ext) : "cc", "memory");
@@ -290,7 +300,7 @@ static inline void __invept(int ext, u64 eptp, gpa_t gpa)
290 u64 eptp, gpa; 300 u64 eptp, gpa;
291 } operand = {eptp, gpa}; 301 } operand = {eptp, gpa};
292 302
293 asm volatile (ASM_VMX_INVEPT 303 asm volatile (__ex(ASM_VMX_INVEPT)
294 /* CF==1 or ZF==1 --> rc = -1 */ 304 /* CF==1 or ZF==1 --> rc = -1 */
295 "; ja 1f ; ud2 ; 1:\n" 305 "; ja 1f ; ud2 ; 1:\n"
296 : : "a" (&operand), "c" (ext) : "cc", "memory"); 306 : : "a" (&operand), "c" (ext) : "cc", "memory");
@@ -311,7 +321,7 @@ static void vmcs_clear(struct vmcs *vmcs)
311 u64 phys_addr = __pa(vmcs); 321 u64 phys_addr = __pa(vmcs);
312 u8 error; 322 u8 error;
313 323
314 asm volatile (ASM_VMX_VMCLEAR_RAX "; setna %0" 324 asm volatile (__ex(ASM_VMX_VMCLEAR_RAX) "; setna %0"
315 : "=g"(error) : "a"(&phys_addr), "m"(phys_addr) 325 : "=g"(error) : "a"(&phys_addr), "m"(phys_addr)
316 : "cc", "memory"); 326 : "cc", "memory");
317 if (error) 327 if (error)
@@ -329,6 +339,9 @@ static void __vcpu_clear(void *arg)
329 if (per_cpu(current_vmcs, cpu) == vmx->vmcs) 339 if (per_cpu(current_vmcs, cpu) == vmx->vmcs)
330 per_cpu(current_vmcs, cpu) = NULL; 340 per_cpu(current_vmcs, cpu) = NULL;
331 rdtscll(vmx->vcpu.arch.host_tsc); 341 rdtscll(vmx->vcpu.arch.host_tsc);
342 list_del(&vmx->local_vcpus_link);
343 vmx->vcpu.cpu = -1;
344 vmx->launched = 0;
332} 345}
333 346
334static void vcpu_clear(struct vcpu_vmx *vmx) 347static void vcpu_clear(struct vcpu_vmx *vmx)
@@ -336,7 +349,6 @@ static void vcpu_clear(struct vcpu_vmx *vmx)
336 if (vmx->vcpu.cpu == -1) 349 if (vmx->vcpu.cpu == -1)
337 return; 350 return;
338 smp_call_function_single(vmx->vcpu.cpu, __vcpu_clear, vmx, 1); 351 smp_call_function_single(vmx->vcpu.cpu, __vcpu_clear, vmx, 1);
339 vmx->launched = 0;
340} 352}
341 353
342static inline void vpid_sync_vcpu_all(struct vcpu_vmx *vmx) 354static inline void vpid_sync_vcpu_all(struct vcpu_vmx *vmx)
@@ -378,7 +390,7 @@ static unsigned long vmcs_readl(unsigned long field)
378{ 390{
379 unsigned long value; 391 unsigned long value;
380 392
381 asm volatile (ASM_VMX_VMREAD_RDX_RAX 393 asm volatile (__ex(ASM_VMX_VMREAD_RDX_RAX)
382 : "=a"(value) : "d"(field) : "cc"); 394 : "=a"(value) : "d"(field) : "cc");
383 return value; 395 return value;
384} 396}
@@ -413,7 +425,7 @@ static void vmcs_writel(unsigned long field, unsigned long value)
413{ 425{
414 u8 error; 426 u8 error;
415 427
416 asm volatile (ASM_VMX_VMWRITE_RAX_RDX "; setna %0" 428 asm volatile (__ex(ASM_VMX_VMWRITE_RAX_RDX) "; setna %0"
417 : "=q"(error) : "a"(value), "d"(field) : "cc"); 429 : "=q"(error) : "a"(value), "d"(field) : "cc");
418 if (unlikely(error)) 430 if (unlikely(error))
419 vmwrite_error(field, value); 431 vmwrite_error(field, value);
@@ -431,10 +443,8 @@ static void vmcs_write32(unsigned long field, u32 value)
431 443
432static void vmcs_write64(unsigned long field, u64 value) 444static void vmcs_write64(unsigned long field, u64 value)
433{ 445{
434#ifdef CONFIG_X86_64
435 vmcs_writel(field, value);
436#else
437 vmcs_writel(field, value); 446 vmcs_writel(field, value);
447#ifndef CONFIG_X86_64
438 asm volatile (""); 448 asm volatile ("");
439 vmcs_writel(field+1, value >> 32); 449 vmcs_writel(field+1, value >> 32);
440#endif 450#endif
@@ -474,7 +484,7 @@ static void reload_tss(void)
474 struct descriptor_table gdt; 484 struct descriptor_table gdt;
475 struct desc_struct *descs; 485 struct desc_struct *descs;
476 486
477 get_gdt(&gdt); 487 kvm_get_gdt(&gdt);
478 descs = (void *)gdt.base; 488 descs = (void *)gdt.base;
479 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */ 489 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
480 load_TR_desc(); 490 load_TR_desc();
@@ -530,9 +540,9 @@ static void vmx_save_host_state(struct kvm_vcpu *vcpu)
530 * Set host fs and gs selectors. Unfortunately, 22.2.3 does not 540 * Set host fs and gs selectors. Unfortunately, 22.2.3 does not
531 * allow segment selectors with cpl > 0 or ti == 1. 541 * allow segment selectors with cpl > 0 or ti == 1.
532 */ 542 */
533 vmx->host_state.ldt_sel = read_ldt(); 543 vmx->host_state.ldt_sel = kvm_read_ldt();
534 vmx->host_state.gs_ldt_reload_needed = vmx->host_state.ldt_sel; 544 vmx->host_state.gs_ldt_reload_needed = vmx->host_state.ldt_sel;
535 vmx->host_state.fs_sel = read_fs(); 545 vmx->host_state.fs_sel = kvm_read_fs();
536 if (!(vmx->host_state.fs_sel & 7)) { 546 if (!(vmx->host_state.fs_sel & 7)) {
537 vmcs_write16(HOST_FS_SELECTOR, vmx->host_state.fs_sel); 547 vmcs_write16(HOST_FS_SELECTOR, vmx->host_state.fs_sel);
538 vmx->host_state.fs_reload_needed = 0; 548 vmx->host_state.fs_reload_needed = 0;
@@ -540,7 +550,7 @@ static void vmx_save_host_state(struct kvm_vcpu *vcpu)
540 vmcs_write16(HOST_FS_SELECTOR, 0); 550 vmcs_write16(HOST_FS_SELECTOR, 0);
541 vmx->host_state.fs_reload_needed = 1; 551 vmx->host_state.fs_reload_needed = 1;
542 } 552 }
543 vmx->host_state.gs_sel = read_gs(); 553 vmx->host_state.gs_sel = kvm_read_gs();
544 if (!(vmx->host_state.gs_sel & 7)) 554 if (!(vmx->host_state.gs_sel & 7))
545 vmcs_write16(HOST_GS_SELECTOR, vmx->host_state.gs_sel); 555 vmcs_write16(HOST_GS_SELECTOR, vmx->host_state.gs_sel);
546 else { 556 else {
@@ -576,15 +586,15 @@ static void __vmx_load_host_state(struct vcpu_vmx *vmx)
576 ++vmx->vcpu.stat.host_state_reload; 586 ++vmx->vcpu.stat.host_state_reload;
577 vmx->host_state.loaded = 0; 587 vmx->host_state.loaded = 0;
578 if (vmx->host_state.fs_reload_needed) 588 if (vmx->host_state.fs_reload_needed)
579 load_fs(vmx->host_state.fs_sel); 589 kvm_load_fs(vmx->host_state.fs_sel);
580 if (vmx->host_state.gs_ldt_reload_needed) { 590 if (vmx->host_state.gs_ldt_reload_needed) {
581 load_ldt(vmx->host_state.ldt_sel); 591 kvm_load_ldt(vmx->host_state.ldt_sel);
582 /* 592 /*
583 * If we have to reload gs, we must take care to 593 * If we have to reload gs, we must take care to
584 * preserve our gs base. 594 * preserve our gs base.
585 */ 595 */
586 local_irq_save(flags); 596 local_irq_save(flags);
587 load_gs(vmx->host_state.gs_sel); 597 kvm_load_gs(vmx->host_state.gs_sel);
588#ifdef CONFIG_X86_64 598#ifdef CONFIG_X86_64
589 wrmsrl(MSR_GS_BASE, vmcs_readl(HOST_GS_BASE)); 599 wrmsrl(MSR_GS_BASE, vmcs_readl(HOST_GS_BASE));
590#endif 600#endif
@@ -617,13 +627,17 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
617 vcpu_clear(vmx); 627 vcpu_clear(vmx);
618 kvm_migrate_timers(vcpu); 628 kvm_migrate_timers(vcpu);
619 vpid_sync_vcpu_all(vmx); 629 vpid_sync_vcpu_all(vmx);
630 local_irq_disable();
631 list_add(&vmx->local_vcpus_link,
632 &per_cpu(vcpus_on_cpu, cpu));
633 local_irq_enable();
620 } 634 }
621 635
622 if (per_cpu(current_vmcs, cpu) != vmx->vmcs) { 636 if (per_cpu(current_vmcs, cpu) != vmx->vmcs) {
623 u8 error; 637 u8 error;
624 638
625 per_cpu(current_vmcs, cpu) = vmx->vmcs; 639 per_cpu(current_vmcs, cpu) = vmx->vmcs;
626 asm volatile (ASM_VMX_VMPTRLD_RAX "; setna %0" 640 asm volatile (__ex(ASM_VMX_VMPTRLD_RAX) "; setna %0"
627 : "=g"(error) : "a"(&phys_addr), "m"(phys_addr) 641 : "=g"(error) : "a"(&phys_addr), "m"(phys_addr)
628 : "cc"); 642 : "cc");
629 if (error) 643 if (error)
@@ -640,8 +654,8 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
640 * Linux uses per-cpu TSS and GDT, so set these when switching 654 * Linux uses per-cpu TSS and GDT, so set these when switching
641 * processors. 655 * processors.
642 */ 656 */
643 vmcs_writel(HOST_TR_BASE, read_tr_base()); /* 22.2.4 */ 657 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
644 get_gdt(&dt); 658 kvm_get_gdt(&dt);
645 vmcs_writel(HOST_GDTR_BASE, dt.base); /* 22.2.4 */ 659 vmcs_writel(HOST_GDTR_BASE, dt.base); /* 22.2.4 */
646 660
647 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp); 661 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
@@ -684,11 +698,6 @@ static void vmx_fpu_deactivate(struct kvm_vcpu *vcpu)
684 update_exception_bitmap(vcpu); 698 update_exception_bitmap(vcpu);
685} 699}
686 700
687static void vmx_vcpu_decache(struct kvm_vcpu *vcpu)
688{
689 vcpu_clear(to_vmx(vcpu));
690}
691
692static unsigned long vmx_get_rflags(struct kvm_vcpu *vcpu) 701static unsigned long vmx_get_rflags(struct kvm_vcpu *vcpu)
693{ 702{
694 return vmcs_readl(GUEST_RFLAGS); 703 return vmcs_readl(GUEST_RFLAGS);
@@ -913,6 +922,18 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data)
913 case MSR_IA32_TIME_STAMP_COUNTER: 922 case MSR_IA32_TIME_STAMP_COUNTER:
914 guest_write_tsc(data); 923 guest_write_tsc(data);
915 break; 924 break;
925 case MSR_P6_PERFCTR0:
926 case MSR_P6_PERFCTR1:
927 case MSR_P6_EVNTSEL0:
928 case MSR_P6_EVNTSEL1:
929 /*
930 * Just discard all writes to the performance counters; this
931 * should keep both older linux and windows 64-bit guests
932 * happy
933 */
934 pr_unimpl(vcpu, "unimplemented perfctr wrmsr: 0x%x data 0x%llx\n", msr_index, data);
935
936 break;
916 default: 937 default:
917 vmx_load_host_state(vmx); 938 vmx_load_host_state(vmx);
918 msr = find_msr_entry(vmx, msr_index); 939 msr = find_msr_entry(vmx, msr_index);
@@ -1022,6 +1043,7 @@ static void hardware_enable(void *garbage)
1022 u64 phys_addr = __pa(per_cpu(vmxarea, cpu)); 1043 u64 phys_addr = __pa(per_cpu(vmxarea, cpu));
1023 u64 old; 1044 u64 old;
1024 1045
1046 INIT_LIST_HEAD(&per_cpu(vcpus_on_cpu, cpu));
1025 rdmsrl(MSR_IA32_FEATURE_CONTROL, old); 1047 rdmsrl(MSR_IA32_FEATURE_CONTROL, old);
1026 if ((old & (MSR_IA32_FEATURE_CONTROL_LOCKED | 1048 if ((old & (MSR_IA32_FEATURE_CONTROL_LOCKED |
1027 MSR_IA32_FEATURE_CONTROL_VMXON_ENABLED)) 1049 MSR_IA32_FEATURE_CONTROL_VMXON_ENABLED))
@@ -1032,13 +1054,25 @@ static void hardware_enable(void *garbage)
1032 MSR_IA32_FEATURE_CONTROL_LOCKED | 1054 MSR_IA32_FEATURE_CONTROL_LOCKED |
1033 MSR_IA32_FEATURE_CONTROL_VMXON_ENABLED); 1055 MSR_IA32_FEATURE_CONTROL_VMXON_ENABLED);
1034 write_cr4(read_cr4() | X86_CR4_VMXE); /* FIXME: not cpu hotplug safe */ 1056 write_cr4(read_cr4() | X86_CR4_VMXE); /* FIXME: not cpu hotplug safe */
1035 asm volatile (ASM_VMX_VMXON_RAX : : "a"(&phys_addr), "m"(phys_addr) 1057 asm volatile (ASM_VMX_VMXON_RAX
1058 : : "a"(&phys_addr), "m"(phys_addr)
1036 : "memory", "cc"); 1059 : "memory", "cc");
1037} 1060}
1038 1061
1062static void vmclear_local_vcpus(void)
1063{
1064 int cpu = raw_smp_processor_id();
1065 struct vcpu_vmx *vmx, *n;
1066
1067 list_for_each_entry_safe(vmx, n, &per_cpu(vcpus_on_cpu, cpu),
1068 local_vcpus_link)
1069 __vcpu_clear(vmx);
1070}
1071
1039static void hardware_disable(void *garbage) 1072static void hardware_disable(void *garbage)
1040{ 1073{
1041 asm volatile (ASM_VMX_VMXOFF : : : "cc"); 1074 vmclear_local_vcpus();
1075 asm volatile (__ex(ASM_VMX_VMXOFF) : : : "cc");
1042 write_cr4(read_cr4() & ~X86_CR4_VMXE); 1076 write_cr4(read_cr4() & ~X86_CR4_VMXE);
1043} 1077}
1044 1078
@@ -1072,7 +1106,7 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf)
1072 u32 _vmentry_control = 0; 1106 u32 _vmentry_control = 0;
1073 1107
1074 min = PIN_BASED_EXT_INTR_MASK | PIN_BASED_NMI_EXITING; 1108 min = PIN_BASED_EXT_INTR_MASK | PIN_BASED_NMI_EXITING;
1075 opt = 0; 1109 opt = PIN_BASED_VIRTUAL_NMIS;
1076 if (adjust_vmx_controls(min, opt, MSR_IA32_VMX_PINBASED_CTLS, 1110 if (adjust_vmx_controls(min, opt, MSR_IA32_VMX_PINBASED_CTLS,
1077 &_pin_based_exec_control) < 0) 1111 &_pin_based_exec_control) < 0)
1078 return -EIO; 1112 return -EIO;
@@ -1389,6 +1423,8 @@ static void exit_lmode(struct kvm_vcpu *vcpu)
1389static void vmx_flush_tlb(struct kvm_vcpu *vcpu) 1423static void vmx_flush_tlb(struct kvm_vcpu *vcpu)
1390{ 1424{
1391 vpid_sync_vcpu_all(to_vmx(vcpu)); 1425 vpid_sync_vcpu_all(to_vmx(vcpu));
1426 if (vm_need_ept())
1427 ept_sync_context(construct_eptp(vcpu->arch.mmu.root_hpa));
1392} 1428}
1393 1429
1394static void vmx_decache_cr4_guest_bits(struct kvm_vcpu *vcpu) 1430static void vmx_decache_cr4_guest_bits(struct kvm_vcpu *vcpu)
@@ -1420,7 +1456,7 @@ static void ept_update_paging_mode_cr0(unsigned long *hw_cr0,
1420 if (!(cr0 & X86_CR0_PG)) { 1456 if (!(cr0 & X86_CR0_PG)) {
1421 /* From paging/starting to nonpaging */ 1457 /* From paging/starting to nonpaging */
1422 vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, 1458 vmcs_write32(CPU_BASED_VM_EXEC_CONTROL,
1423 vmcs_config.cpu_based_exec_ctrl | 1459 vmcs_read32(CPU_BASED_VM_EXEC_CONTROL) |
1424 (CPU_BASED_CR3_LOAD_EXITING | 1460 (CPU_BASED_CR3_LOAD_EXITING |
1425 CPU_BASED_CR3_STORE_EXITING)); 1461 CPU_BASED_CR3_STORE_EXITING));
1426 vcpu->arch.cr0 = cr0; 1462 vcpu->arch.cr0 = cr0;
@@ -1430,7 +1466,7 @@ static void ept_update_paging_mode_cr0(unsigned long *hw_cr0,
1430 } else if (!is_paging(vcpu)) { 1466 } else if (!is_paging(vcpu)) {
1431 /* From nonpaging to paging */ 1467 /* From nonpaging to paging */
1432 vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, 1468 vmcs_write32(CPU_BASED_VM_EXEC_CONTROL,
1433 vmcs_config.cpu_based_exec_ctrl & 1469 vmcs_read32(CPU_BASED_VM_EXEC_CONTROL) &
1434 ~(CPU_BASED_CR3_LOAD_EXITING | 1470 ~(CPU_BASED_CR3_LOAD_EXITING |
1435 CPU_BASED_CR3_STORE_EXITING)); 1471 CPU_BASED_CR3_STORE_EXITING));
1436 vcpu->arch.cr0 = cr0; 1472 vcpu->arch.cr0 = cr0;
@@ -1821,7 +1857,7 @@ static void allocate_vpid(struct vcpu_vmx *vmx)
1821 spin_unlock(&vmx_vpid_lock); 1857 spin_unlock(&vmx_vpid_lock);
1822} 1858}
1823 1859
1824void vmx_disable_intercept_for_msr(struct page *msr_bitmap, u32 msr) 1860static void vmx_disable_intercept_for_msr(struct page *msr_bitmap, u32 msr)
1825{ 1861{
1826 void *va; 1862 void *va;
1827 1863
@@ -1907,8 +1943,8 @@ static int vmx_vcpu_setup(struct vcpu_vmx *vmx)
1907 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */ 1943 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
1908 vmcs_write16(HOST_DS_SELECTOR, __KERNEL_DS); /* 22.2.4 */ 1944 vmcs_write16(HOST_DS_SELECTOR, __KERNEL_DS); /* 22.2.4 */
1909 vmcs_write16(HOST_ES_SELECTOR, __KERNEL_DS); /* 22.2.4 */ 1945 vmcs_write16(HOST_ES_SELECTOR, __KERNEL_DS); /* 22.2.4 */
1910 vmcs_write16(HOST_FS_SELECTOR, read_fs()); /* 22.2.4 */ 1946 vmcs_write16(HOST_FS_SELECTOR, kvm_read_fs()); /* 22.2.4 */
1911 vmcs_write16(HOST_GS_SELECTOR, read_gs()); /* 22.2.4 */ 1947 vmcs_write16(HOST_GS_SELECTOR, kvm_read_gs()); /* 22.2.4 */
1912 vmcs_write16(HOST_SS_SELECTOR, __KERNEL_DS); /* 22.2.4 */ 1948 vmcs_write16(HOST_SS_SELECTOR, __KERNEL_DS); /* 22.2.4 */
1913#ifdef CONFIG_X86_64 1949#ifdef CONFIG_X86_64
1914 rdmsrl(MSR_FS_BASE, a); 1950 rdmsrl(MSR_FS_BASE, a);
@@ -1922,7 +1958,7 @@ static int vmx_vcpu_setup(struct vcpu_vmx *vmx)
1922 1958
1923 vmcs_write16(HOST_TR_SELECTOR, GDT_ENTRY_TSS*8); /* 22.2.4 */ 1959 vmcs_write16(HOST_TR_SELECTOR, GDT_ENTRY_TSS*8); /* 22.2.4 */
1924 1960
1925 get_idt(&dt); 1961 kvm_get_idt(&dt);
1926 vmcs_writel(HOST_IDTR_BASE, dt.base); /* 22.2.4 */ 1962 vmcs_writel(HOST_IDTR_BASE, dt.base); /* 22.2.4 */
1927 1963
1928 asm("mov $.Lkvm_vmx_return, %0" : "=r"(kvm_vmx_return)); 1964 asm("mov $.Lkvm_vmx_return, %0" : "=r"(kvm_vmx_return));
@@ -2114,6 +2150,13 @@ static void vmx_inject_irq(struct kvm_vcpu *vcpu, int irq)
2114 irq | INTR_TYPE_EXT_INTR | INTR_INFO_VALID_MASK); 2150 irq | INTR_TYPE_EXT_INTR | INTR_INFO_VALID_MASK);
2115} 2151}
2116 2152
2153static void vmx_inject_nmi(struct kvm_vcpu *vcpu)
2154{
2155 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD,
2156 INTR_TYPE_NMI_INTR | INTR_INFO_VALID_MASK | NMI_VECTOR);
2157 vcpu->arch.nmi_pending = 0;
2158}
2159
2117static void kvm_do_inject_irq(struct kvm_vcpu *vcpu) 2160static void kvm_do_inject_irq(struct kvm_vcpu *vcpu)
2118{ 2161{
2119 int word_index = __ffs(vcpu->arch.irq_summary); 2162 int word_index = __ffs(vcpu->arch.irq_summary);
@@ -2554,8 +2597,6 @@ static int handle_apic_access(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2554 exit_qualification = vmcs_read64(EXIT_QUALIFICATION); 2597 exit_qualification = vmcs_read64(EXIT_QUALIFICATION);
2555 offset = exit_qualification & 0xffful; 2598 offset = exit_qualification & 0xffful;
2556 2599
2557 KVMTRACE_1D(APIC_ACCESS, vcpu, (u32)offset, handler);
2558
2559 er = emulate_instruction(vcpu, kvm_run, 0, 0, 0); 2600 er = emulate_instruction(vcpu, kvm_run, 0, 0, 0);
2560 2601
2561 if (er != EMULATE_DONE) { 2602 if (er != EMULATE_DONE) {
@@ -2639,6 +2680,19 @@ static int handle_ept_violation(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2639 return 1; 2680 return 1;
2640} 2681}
2641 2682
2683static int handle_nmi_window(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2684{
2685 u32 cpu_based_vm_exec_control;
2686
2687 /* clear pending NMI */
2688 cpu_based_vm_exec_control = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL);
2689 cpu_based_vm_exec_control &= ~CPU_BASED_VIRTUAL_NMI_PENDING;
2690 vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, cpu_based_vm_exec_control);
2691 ++vcpu->stat.nmi_window_exits;
2692
2693 return 1;
2694}
2695
2642/* 2696/*
2643 * The exit handlers return 1 if the exit was handled fully and guest execution 2697 * The exit handlers return 1 if the exit was handled fully and guest execution
2644 * may resume. Otherwise they set the kvm_run parameter to indicate what needs 2698 * may resume. Otherwise they set the kvm_run parameter to indicate what needs
@@ -2649,6 +2703,7 @@ static int (*kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu,
2649 [EXIT_REASON_EXCEPTION_NMI] = handle_exception, 2703 [EXIT_REASON_EXCEPTION_NMI] = handle_exception,
2650 [EXIT_REASON_EXTERNAL_INTERRUPT] = handle_external_interrupt, 2704 [EXIT_REASON_EXTERNAL_INTERRUPT] = handle_external_interrupt,
2651 [EXIT_REASON_TRIPLE_FAULT] = handle_triple_fault, 2705 [EXIT_REASON_TRIPLE_FAULT] = handle_triple_fault,
2706 [EXIT_REASON_NMI_WINDOW] = handle_nmi_window,
2652 [EXIT_REASON_IO_INSTRUCTION] = handle_io, 2707 [EXIT_REASON_IO_INSTRUCTION] = handle_io,
2653 [EXIT_REASON_CR_ACCESS] = handle_cr, 2708 [EXIT_REASON_CR_ACCESS] = handle_cr,
2654 [EXIT_REASON_DR_ACCESS] = handle_dr, 2709 [EXIT_REASON_DR_ACCESS] = handle_dr,
@@ -2736,17 +2791,52 @@ static void enable_irq_window(struct kvm_vcpu *vcpu)
2736 vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, cpu_based_vm_exec_control); 2791 vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, cpu_based_vm_exec_control);
2737} 2792}
2738 2793
2794static void enable_nmi_window(struct kvm_vcpu *vcpu)
2795{
2796 u32 cpu_based_vm_exec_control;
2797
2798 if (!cpu_has_virtual_nmis())
2799 return;
2800
2801 cpu_based_vm_exec_control = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL);
2802 cpu_based_vm_exec_control |= CPU_BASED_VIRTUAL_NMI_PENDING;
2803 vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, cpu_based_vm_exec_control);
2804}
2805
2806static int vmx_nmi_enabled(struct kvm_vcpu *vcpu)
2807{
2808 u32 guest_intr = vmcs_read32(GUEST_INTERRUPTIBILITY_INFO);
2809 return !(guest_intr & (GUEST_INTR_STATE_NMI |
2810 GUEST_INTR_STATE_MOV_SS |
2811 GUEST_INTR_STATE_STI));
2812}
2813
2814static int vmx_irq_enabled(struct kvm_vcpu *vcpu)
2815{
2816 u32 guest_intr = vmcs_read32(GUEST_INTERRUPTIBILITY_INFO);
2817 return (!(guest_intr & (GUEST_INTR_STATE_MOV_SS |
2818 GUEST_INTR_STATE_STI)) &&
2819 (vmcs_readl(GUEST_RFLAGS) & X86_EFLAGS_IF));
2820}
2821
2822static void enable_intr_window(struct kvm_vcpu *vcpu)
2823{
2824 if (vcpu->arch.nmi_pending)
2825 enable_nmi_window(vcpu);
2826 else if (kvm_cpu_has_interrupt(vcpu))
2827 enable_irq_window(vcpu);
2828}
2829
2739static void vmx_intr_assist(struct kvm_vcpu *vcpu) 2830static void vmx_intr_assist(struct kvm_vcpu *vcpu)
2740{ 2831{
2741 struct vcpu_vmx *vmx = to_vmx(vcpu); 2832 struct vcpu_vmx *vmx = to_vmx(vcpu);
2742 u32 idtv_info_field, intr_info_field; 2833 u32 idtv_info_field, intr_info_field, exit_intr_info_field;
2743 int has_ext_irq, interrupt_window_open;
2744 int vector; 2834 int vector;
2745 2835
2746 update_tpr_threshold(vcpu); 2836 update_tpr_threshold(vcpu);
2747 2837
2748 has_ext_irq = kvm_cpu_has_interrupt(vcpu);
2749 intr_info_field = vmcs_read32(VM_ENTRY_INTR_INFO_FIELD); 2838 intr_info_field = vmcs_read32(VM_ENTRY_INTR_INFO_FIELD);
2839 exit_intr_info_field = vmcs_read32(VM_EXIT_INTR_INFO);
2750 idtv_info_field = vmx->idt_vectoring_info; 2840 idtv_info_field = vmx->idt_vectoring_info;
2751 if (intr_info_field & INTR_INFO_VALID_MASK) { 2841 if (intr_info_field & INTR_INFO_VALID_MASK) {
2752 if (idtv_info_field & INTR_INFO_VALID_MASK) { 2842 if (idtv_info_field & INTR_INFO_VALID_MASK) {
@@ -2754,8 +2844,7 @@ static void vmx_intr_assist(struct kvm_vcpu *vcpu)
2754 if (printk_ratelimit()) 2844 if (printk_ratelimit())
2755 printk(KERN_ERR "Fault when IDT_Vectoring\n"); 2845 printk(KERN_ERR "Fault when IDT_Vectoring\n");
2756 } 2846 }
2757 if (has_ext_irq) 2847 enable_intr_window(vcpu);
2758 enable_irq_window(vcpu);
2759 return; 2848 return;
2760 } 2849 }
2761 if (unlikely(idtv_info_field & INTR_INFO_VALID_MASK)) { 2850 if (unlikely(idtv_info_field & INTR_INFO_VALID_MASK)) {
@@ -2765,30 +2854,56 @@ static void vmx_intr_assist(struct kvm_vcpu *vcpu)
2765 u8 vect = idtv_info_field & VECTORING_INFO_VECTOR_MASK; 2854 u8 vect = idtv_info_field & VECTORING_INFO_VECTOR_MASK;
2766 2855
2767 vmx_inject_irq(vcpu, vect); 2856 vmx_inject_irq(vcpu, vect);
2768 if (unlikely(has_ext_irq)) 2857 enable_intr_window(vcpu);
2769 enable_irq_window(vcpu);
2770 return; 2858 return;
2771 } 2859 }
2772 2860
2773 KVMTRACE_1D(REDELIVER_EVT, vcpu, idtv_info_field, handler); 2861 KVMTRACE_1D(REDELIVER_EVT, vcpu, idtv_info_field, handler);
2774 2862
2775 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, idtv_info_field); 2863 /*
2864 * SDM 3: 25.7.1.2
2865 * Clear bit "block by NMI" before VM entry if a NMI delivery
2866 * faulted.
2867 */
2868 if ((idtv_info_field & VECTORING_INFO_TYPE_MASK)
2869 == INTR_TYPE_NMI_INTR && cpu_has_virtual_nmis())
2870 vmcs_write32(GUEST_INTERRUPTIBILITY_INFO,
2871 vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) &
2872 ~GUEST_INTR_STATE_NMI);
2873
2874 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, idtv_info_field
2875 & ~INTR_INFO_RESVD_BITS_MASK);
2776 vmcs_write32(VM_ENTRY_INSTRUCTION_LEN, 2876 vmcs_write32(VM_ENTRY_INSTRUCTION_LEN,
2777 vmcs_read32(VM_EXIT_INSTRUCTION_LEN)); 2877 vmcs_read32(VM_EXIT_INSTRUCTION_LEN));
2778 2878
2779 if (unlikely(idtv_info_field & INTR_INFO_DELIVER_CODE_MASK)) 2879 if (unlikely(idtv_info_field & INTR_INFO_DELIVER_CODE_MASK))
2780 vmcs_write32(VM_ENTRY_EXCEPTION_ERROR_CODE, 2880 vmcs_write32(VM_ENTRY_EXCEPTION_ERROR_CODE,
2781 vmcs_read32(IDT_VECTORING_ERROR_CODE)); 2881 vmcs_read32(IDT_VECTORING_ERROR_CODE));
2782 if (unlikely(has_ext_irq)) 2882 enable_intr_window(vcpu);
2783 enable_irq_window(vcpu);
2784 return; 2883 return;
2785 } 2884 }
2786 if (!has_ext_irq) 2885 if (cpu_has_virtual_nmis()) {
2886 /*
2887 * SDM 3: 25.7.1.2
2888 * Re-set bit "block by NMI" before VM entry if vmexit caused by
2889 * a guest IRET fault.
2890 */
2891 if ((exit_intr_info_field & INTR_INFO_UNBLOCK_NMI) &&
2892 (exit_intr_info_field & INTR_INFO_VECTOR_MASK) != 8)
2893 vmcs_write32(GUEST_INTERRUPTIBILITY_INFO,
2894 vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) |
2895 GUEST_INTR_STATE_NMI);
2896 else if (vcpu->arch.nmi_pending) {
2897 if (vmx_nmi_enabled(vcpu))
2898 vmx_inject_nmi(vcpu);
2899 enable_intr_window(vcpu);
2900 return;
2901 }
2902
2903 }
2904 if (!kvm_cpu_has_interrupt(vcpu))
2787 return; 2905 return;
2788 interrupt_window_open = 2906 if (vmx_irq_enabled(vcpu)) {
2789 ((vmcs_readl(GUEST_RFLAGS) & X86_EFLAGS_IF) &&
2790 (vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) & 3) == 0);
2791 if (interrupt_window_open) {
2792 vector = kvm_cpu_get_interrupt(vcpu); 2907 vector = kvm_cpu_get_interrupt(vcpu);
2793 vmx_inject_irq(vcpu, vector); 2908 vmx_inject_irq(vcpu, vector);
2794 kvm_timer_intr_post(vcpu, vector); 2909 kvm_timer_intr_post(vcpu, vector);
@@ -2838,7 +2953,7 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2838 "push %%edx; push %%ebp;" 2953 "push %%edx; push %%ebp;"
2839 "push %%ecx \n\t" 2954 "push %%ecx \n\t"
2840#endif 2955#endif
2841 ASM_VMX_VMWRITE_RSP_RDX "\n\t" 2956 __ex(ASM_VMX_VMWRITE_RSP_RDX) "\n\t"
2842 /* Check if vmlaunch of vmresume is needed */ 2957 /* Check if vmlaunch of vmresume is needed */
2843 "cmpl $0, %c[launched](%0) \n\t" 2958 "cmpl $0, %c[launched](%0) \n\t"
2844 /* Load guest registers. Don't clobber flags. */ 2959 /* Load guest registers. Don't clobber flags. */
@@ -2873,9 +2988,9 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2873#endif 2988#endif
2874 /* Enter guest mode */ 2989 /* Enter guest mode */
2875 "jne .Llaunched \n\t" 2990 "jne .Llaunched \n\t"
2876 ASM_VMX_VMLAUNCH "\n\t" 2991 __ex(ASM_VMX_VMLAUNCH) "\n\t"
2877 "jmp .Lkvm_vmx_return \n\t" 2992 "jmp .Lkvm_vmx_return \n\t"
2878 ".Llaunched: " ASM_VMX_VMRESUME "\n\t" 2993 ".Llaunched: " __ex(ASM_VMX_VMRESUME) "\n\t"
2879 ".Lkvm_vmx_return: " 2994 ".Lkvm_vmx_return: "
2880 /* Save guest registers, load host registers, keep flags */ 2995 /* Save guest registers, load host registers, keep flags */
2881#ifdef CONFIG_X86_64 2996#ifdef CONFIG_X86_64
@@ -2949,7 +3064,8 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2949 fixup_rmode_irq(vmx); 3064 fixup_rmode_irq(vmx);
2950 3065
2951 vcpu->arch.interrupt_window_open = 3066 vcpu->arch.interrupt_window_open =
2952 (vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) & 3) == 0; 3067 (vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) &
3068 (GUEST_INTR_STATE_STI | GUEST_INTR_STATE_MOV_SS)) == 0;
2953 3069
2954 asm("mov %0, %%ds; mov %0, %%es" : : "r"(__USER_DS)); 3070 asm("mov %0, %%ds; mov %0, %%es" : : "r"(__USER_DS));
2955 vmx->launched = 1; 3071 vmx->launched = 1;
@@ -2957,7 +3073,8 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2957 intr_info = vmcs_read32(VM_EXIT_INTR_INFO); 3073 intr_info = vmcs_read32(VM_EXIT_INTR_INFO);
2958 3074
2959 /* We need to handle NMIs before interrupts are enabled */ 3075 /* We need to handle NMIs before interrupts are enabled */
2960 if ((intr_info & INTR_INFO_INTR_TYPE_MASK) == 0x200) { /* nmi */ 3076 if ((intr_info & INTR_INFO_INTR_TYPE_MASK) == 0x200 &&
3077 (intr_info & INTR_INFO_VALID_MASK)) {
2961 KVMTRACE_0D(NMI, vcpu, handler); 3078 KVMTRACE_0D(NMI, vcpu, handler);
2962 asm("int $2"); 3079 asm("int $2");
2963 } 3080 }
@@ -2968,7 +3085,7 @@ static void vmx_free_vmcs(struct kvm_vcpu *vcpu)
2968 struct vcpu_vmx *vmx = to_vmx(vcpu); 3085 struct vcpu_vmx *vmx = to_vmx(vcpu);
2969 3086
2970 if (vmx->vmcs) { 3087 if (vmx->vmcs) {
2971 on_each_cpu(__vcpu_clear, vmx, 1); 3088 vcpu_clear(vmx);
2972 free_vmcs(vmx->vmcs); 3089 free_vmcs(vmx->vmcs);
2973 vmx->vmcs = NULL; 3090 vmx->vmcs = NULL;
2974 } 3091 }
@@ -3095,7 +3212,6 @@ static struct kvm_x86_ops vmx_x86_ops = {
3095 .prepare_guest_switch = vmx_save_host_state, 3212 .prepare_guest_switch = vmx_save_host_state,
3096 .vcpu_load = vmx_vcpu_load, 3213 .vcpu_load = vmx_vcpu_load,
3097 .vcpu_put = vmx_vcpu_put, 3214 .vcpu_put = vmx_vcpu_put,
3098 .vcpu_decache = vmx_vcpu_decache,
3099 3215
3100 .set_guest_debug = set_guest_debug, 3216 .set_guest_debug = set_guest_debug,
3101 .guest_debug_pre = kvm_guest_debug_pre, 3217 .guest_debug_pre = kvm_guest_debug_pre,
diff --git a/arch/x86/kvm/vmx.h b/arch/x86/kvm/vmx.h
index 79d94c610dfe..425a13436b3f 100644
--- a/arch/x86/kvm/vmx.h
+++ b/arch/x86/kvm/vmx.h
@@ -40,6 +40,7 @@
40#define CPU_BASED_CR8_LOAD_EXITING 0x00080000 40#define CPU_BASED_CR8_LOAD_EXITING 0x00080000
41#define CPU_BASED_CR8_STORE_EXITING 0x00100000 41#define CPU_BASED_CR8_STORE_EXITING 0x00100000
42#define CPU_BASED_TPR_SHADOW 0x00200000 42#define CPU_BASED_TPR_SHADOW 0x00200000
43#define CPU_BASED_VIRTUAL_NMI_PENDING 0x00400000
43#define CPU_BASED_MOV_DR_EXITING 0x00800000 44#define CPU_BASED_MOV_DR_EXITING 0x00800000
44#define CPU_BASED_UNCOND_IO_EXITING 0x01000000 45#define CPU_BASED_UNCOND_IO_EXITING 0x01000000
45#define CPU_BASED_USE_IO_BITMAPS 0x02000000 46#define CPU_BASED_USE_IO_BITMAPS 0x02000000
@@ -216,7 +217,7 @@ enum vmcs_field {
216#define EXIT_REASON_TRIPLE_FAULT 2 217#define EXIT_REASON_TRIPLE_FAULT 2
217 218
218#define EXIT_REASON_PENDING_INTERRUPT 7 219#define EXIT_REASON_PENDING_INTERRUPT 7
219 220#define EXIT_REASON_NMI_WINDOW 8
220#define EXIT_REASON_TASK_SWITCH 9 221#define EXIT_REASON_TASK_SWITCH 9
221#define EXIT_REASON_CPUID 10 222#define EXIT_REASON_CPUID 10
222#define EXIT_REASON_HLT 12 223#define EXIT_REASON_HLT 12
@@ -251,7 +252,9 @@ enum vmcs_field {
251#define INTR_INFO_VECTOR_MASK 0xff /* 7:0 */ 252#define INTR_INFO_VECTOR_MASK 0xff /* 7:0 */
252#define INTR_INFO_INTR_TYPE_MASK 0x700 /* 10:8 */ 253#define INTR_INFO_INTR_TYPE_MASK 0x700 /* 10:8 */
253#define INTR_INFO_DELIVER_CODE_MASK 0x800 /* 11 */ 254#define INTR_INFO_DELIVER_CODE_MASK 0x800 /* 11 */
255#define INTR_INFO_UNBLOCK_NMI 0x1000 /* 12 */
254#define INTR_INFO_VALID_MASK 0x80000000 /* 31 */ 256#define INTR_INFO_VALID_MASK 0x80000000 /* 31 */
257#define INTR_INFO_RESVD_BITS_MASK 0x7ffff000
255 258
256#define VECTORING_INFO_VECTOR_MASK INTR_INFO_VECTOR_MASK 259#define VECTORING_INFO_VECTOR_MASK INTR_INFO_VECTOR_MASK
257#define VECTORING_INFO_TYPE_MASK INTR_INFO_INTR_TYPE_MASK 260#define VECTORING_INFO_TYPE_MASK INTR_INFO_INTR_TYPE_MASK
@@ -259,9 +262,16 @@ enum vmcs_field {
259#define VECTORING_INFO_VALID_MASK INTR_INFO_VALID_MASK 262#define VECTORING_INFO_VALID_MASK INTR_INFO_VALID_MASK
260 263
261#define INTR_TYPE_EXT_INTR (0 << 8) /* external interrupt */ 264#define INTR_TYPE_EXT_INTR (0 << 8) /* external interrupt */
265#define INTR_TYPE_NMI_INTR (2 << 8) /* NMI */
262#define INTR_TYPE_EXCEPTION (3 << 8) /* processor exception */ 266#define INTR_TYPE_EXCEPTION (3 << 8) /* processor exception */
263#define INTR_TYPE_SOFT_INTR (4 << 8) /* software interrupt */ 267#define INTR_TYPE_SOFT_INTR (4 << 8) /* software interrupt */
264 268
269/* GUEST_INTERRUPTIBILITY_INFO flags. */
270#define GUEST_INTR_STATE_STI 0x00000001
271#define GUEST_INTR_STATE_MOV_SS 0x00000002
272#define GUEST_INTR_STATE_SMI 0x00000004
273#define GUEST_INTR_STATE_NMI 0x00000008
274
265/* 275/*
266 * Exit Qualifications for MOV for Control Register Access 276 * Exit Qualifications for MOV for Control Register Access
267 */ 277 */
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 0faa2546b1cd..9f1cdb011cff 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -72,6 +72,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
72 { "mmio_exits", VCPU_STAT(mmio_exits) }, 72 { "mmio_exits", VCPU_STAT(mmio_exits) },
73 { "signal_exits", VCPU_STAT(signal_exits) }, 73 { "signal_exits", VCPU_STAT(signal_exits) },
74 { "irq_window", VCPU_STAT(irq_window_exits) }, 74 { "irq_window", VCPU_STAT(irq_window_exits) },
75 { "nmi_window", VCPU_STAT(nmi_window_exits) },
75 { "halt_exits", VCPU_STAT(halt_exits) }, 76 { "halt_exits", VCPU_STAT(halt_exits) },
76 { "halt_wakeup", VCPU_STAT(halt_wakeup) }, 77 { "halt_wakeup", VCPU_STAT(halt_wakeup) },
77 { "hypercalls", VCPU_STAT(hypercalls) }, 78 { "hypercalls", VCPU_STAT(hypercalls) },
@@ -173,6 +174,12 @@ void kvm_inject_page_fault(struct kvm_vcpu *vcpu, unsigned long addr,
173 kvm_queue_exception_e(vcpu, PF_VECTOR, error_code); 174 kvm_queue_exception_e(vcpu, PF_VECTOR, error_code);
174} 175}
175 176
177void kvm_inject_nmi(struct kvm_vcpu *vcpu)
178{
179 vcpu->arch.nmi_pending = 1;
180}
181EXPORT_SYMBOL_GPL(kvm_inject_nmi);
182
176void kvm_queue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code) 183void kvm_queue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code)
177{ 184{
178 WARN_ON(vcpu->arch.exception.pending); 185 WARN_ON(vcpu->arch.exception.pending);
@@ -604,6 +611,38 @@ static void kvm_write_guest_time(struct kvm_vcpu *v)
604 mark_page_dirty(v->kvm, vcpu->time >> PAGE_SHIFT); 611 mark_page_dirty(v->kvm, vcpu->time >> PAGE_SHIFT);
605} 612}
606 613
614static bool msr_mtrr_valid(unsigned msr)
615{
616 switch (msr) {
617 case 0x200 ... 0x200 + 2 * KVM_NR_VAR_MTRR - 1:
618 case MSR_MTRRfix64K_00000:
619 case MSR_MTRRfix16K_80000:
620 case MSR_MTRRfix16K_A0000:
621 case MSR_MTRRfix4K_C0000:
622 case MSR_MTRRfix4K_C8000:
623 case MSR_MTRRfix4K_D0000:
624 case MSR_MTRRfix4K_D8000:
625 case MSR_MTRRfix4K_E0000:
626 case MSR_MTRRfix4K_E8000:
627 case MSR_MTRRfix4K_F0000:
628 case MSR_MTRRfix4K_F8000:
629 case MSR_MTRRdefType:
630 case MSR_IA32_CR_PAT:
631 return true;
632 case 0x2f8:
633 return true;
634 }
635 return false;
636}
637
638static int set_msr_mtrr(struct kvm_vcpu *vcpu, u32 msr, u64 data)
639{
640 if (!msr_mtrr_valid(msr))
641 return 1;
642
643 vcpu->arch.mtrr[msr - 0x200] = data;
644 return 0;
645}
607 646
608int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data) 647int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
609{ 648{
@@ -625,8 +664,9 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
625 break; 664 break;
626 case MSR_IA32_UCODE_REV: 665 case MSR_IA32_UCODE_REV:
627 case MSR_IA32_UCODE_WRITE: 666 case MSR_IA32_UCODE_WRITE:
628 case 0x200 ... 0x2ff: /* MTRRs */
629 break; 667 break;
668 case 0x200 ... 0x2ff:
669 return set_msr_mtrr(vcpu, msr, data);
630 case MSR_IA32_APICBASE: 670 case MSR_IA32_APICBASE:
631 kvm_set_apic_base(vcpu, data); 671 kvm_set_apic_base(vcpu, data);
632 break; 672 break;
@@ -684,6 +724,15 @@ int kvm_get_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata)
684 return kvm_x86_ops->get_msr(vcpu, msr_index, pdata); 724 return kvm_x86_ops->get_msr(vcpu, msr_index, pdata);
685} 725}
686 726
727static int get_msr_mtrr(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
728{
729 if (!msr_mtrr_valid(msr))
730 return 1;
731
732 *pdata = vcpu->arch.mtrr[msr - 0x200];
733 return 0;
734}
735
687int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata) 736int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
688{ 737{
689 u64 data; 738 u64 data;
@@ -705,11 +754,13 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
705 case MSR_IA32_MC0_MISC+16: 754 case MSR_IA32_MC0_MISC+16:
706 case MSR_IA32_UCODE_REV: 755 case MSR_IA32_UCODE_REV:
707 case MSR_IA32_EBL_CR_POWERON: 756 case MSR_IA32_EBL_CR_POWERON:
708 /* MTRR registers */
709 case 0xfe:
710 case 0x200 ... 0x2ff:
711 data = 0; 757 data = 0;
712 break; 758 break;
759 case MSR_MTRRcap:
760 data = 0x500 | KVM_NR_VAR_MTRR;
761 break;
762 case 0x200 ... 0x2ff:
763 return get_msr_mtrr(vcpu, msr, pdata);
713 case 0xcd: /* fsb frequency */ 764 case 0xcd: /* fsb frequency */
714 data = 3; 765 data = 3;
715 break; 766 break;
@@ -817,41 +868,6 @@ out:
817 return r; 868 return r;
818} 869}
819 870
820/*
821 * Make sure that a cpu that is being hot-unplugged does not have any vcpus
822 * cached on it.
823 */
824void decache_vcpus_on_cpu(int cpu)
825{
826 struct kvm *vm;
827 struct kvm_vcpu *vcpu;
828 int i;
829
830 spin_lock(&kvm_lock);
831 list_for_each_entry(vm, &vm_list, vm_list)
832 for (i = 0; i < KVM_MAX_VCPUS; ++i) {
833 vcpu = vm->vcpus[i];
834 if (!vcpu)
835 continue;
836 /*
837 * If the vcpu is locked, then it is running on some
838 * other cpu and therefore it is not cached on the
839 * cpu in question.
840 *
841 * If it's not locked, check the last cpu it executed
842 * on.
843 */
844 if (mutex_trylock(&vcpu->mutex)) {
845 if (vcpu->cpu == cpu) {
846 kvm_x86_ops->vcpu_decache(vcpu);
847 vcpu->cpu = -1;
848 }
849 mutex_unlock(&vcpu->mutex);
850 }
851 }
852 spin_unlock(&kvm_lock);
853}
854
855int kvm_dev_ioctl_check_extension(long ext) 871int kvm_dev_ioctl_check_extension(long ext)
856{ 872{
857 int r; 873 int r;
@@ -869,6 +885,9 @@ int kvm_dev_ioctl_check_extension(long ext)
869 case KVM_CAP_MP_STATE: 885 case KVM_CAP_MP_STATE:
870 r = 1; 886 r = 1;
871 break; 887 break;
888 case KVM_CAP_COALESCED_MMIO:
889 r = KVM_COALESCED_MMIO_PAGE_OFFSET;
890 break;
872 case KVM_CAP_VAPIC: 891 case KVM_CAP_VAPIC:
873 r = !kvm_x86_ops->cpu_has_accelerated_tpr(); 892 r = !kvm_x86_ops->cpu_has_accelerated_tpr();
874 break; 893 break;
@@ -1781,13 +1800,14 @@ static void kvm_init_msr_list(void)
1781 * Only apic need an MMIO device hook, so shortcut now.. 1800 * Only apic need an MMIO device hook, so shortcut now..
1782 */ 1801 */
1783static struct kvm_io_device *vcpu_find_pervcpu_dev(struct kvm_vcpu *vcpu, 1802static struct kvm_io_device *vcpu_find_pervcpu_dev(struct kvm_vcpu *vcpu,
1784 gpa_t addr) 1803 gpa_t addr, int len,
1804 int is_write)
1785{ 1805{
1786 struct kvm_io_device *dev; 1806 struct kvm_io_device *dev;
1787 1807
1788 if (vcpu->arch.apic) { 1808 if (vcpu->arch.apic) {
1789 dev = &vcpu->arch.apic->dev; 1809 dev = &vcpu->arch.apic->dev;
1790 if (dev->in_range(dev, addr)) 1810 if (dev->in_range(dev, addr, len, is_write))
1791 return dev; 1811 return dev;
1792 } 1812 }
1793 return NULL; 1813 return NULL;
@@ -1795,13 +1815,15 @@ static struct kvm_io_device *vcpu_find_pervcpu_dev(struct kvm_vcpu *vcpu,
1795 1815
1796 1816
1797static struct kvm_io_device *vcpu_find_mmio_dev(struct kvm_vcpu *vcpu, 1817static struct kvm_io_device *vcpu_find_mmio_dev(struct kvm_vcpu *vcpu,
1798 gpa_t addr) 1818 gpa_t addr, int len,
1819 int is_write)
1799{ 1820{
1800 struct kvm_io_device *dev; 1821 struct kvm_io_device *dev;
1801 1822
1802 dev = vcpu_find_pervcpu_dev(vcpu, addr); 1823 dev = vcpu_find_pervcpu_dev(vcpu, addr, len, is_write);
1803 if (dev == NULL) 1824 if (dev == NULL)
1804 dev = kvm_io_bus_find_dev(&vcpu->kvm->mmio_bus, addr); 1825 dev = kvm_io_bus_find_dev(&vcpu->kvm->mmio_bus, addr, len,
1826 is_write);
1805 return dev; 1827 return dev;
1806} 1828}
1807 1829
@@ -1869,7 +1891,7 @@ mmio:
1869 * Is this MMIO handled locally? 1891 * Is this MMIO handled locally?
1870 */ 1892 */
1871 mutex_lock(&vcpu->kvm->lock); 1893 mutex_lock(&vcpu->kvm->lock);
1872 mmio_dev = vcpu_find_mmio_dev(vcpu, gpa); 1894 mmio_dev = vcpu_find_mmio_dev(vcpu, gpa, bytes, 0);
1873 if (mmio_dev) { 1895 if (mmio_dev) {
1874 kvm_iodevice_read(mmio_dev, gpa, bytes, val); 1896 kvm_iodevice_read(mmio_dev, gpa, bytes, val);
1875 mutex_unlock(&vcpu->kvm->lock); 1897 mutex_unlock(&vcpu->kvm->lock);
@@ -1924,7 +1946,7 @@ mmio:
1924 * Is this MMIO handled locally? 1946 * Is this MMIO handled locally?
1925 */ 1947 */
1926 mutex_lock(&vcpu->kvm->lock); 1948 mutex_lock(&vcpu->kvm->lock);
1927 mmio_dev = vcpu_find_mmio_dev(vcpu, gpa); 1949 mmio_dev = vcpu_find_mmio_dev(vcpu, gpa, bytes, 1);
1928 if (mmio_dev) { 1950 if (mmio_dev) {
1929 kvm_iodevice_write(mmio_dev, gpa, bytes, val); 1951 kvm_iodevice_write(mmio_dev, gpa, bytes, val);
1930 mutex_unlock(&vcpu->kvm->lock); 1952 mutex_unlock(&vcpu->kvm->lock);
@@ -2020,6 +2042,7 @@ int emulate_invlpg(struct kvm_vcpu *vcpu, gva_t address)
2020 2042
2021int emulate_clts(struct kvm_vcpu *vcpu) 2043int emulate_clts(struct kvm_vcpu *vcpu)
2022{ 2044{
2045 KVMTRACE_0D(CLTS, vcpu, handler);
2023 kvm_x86_ops->set_cr0(vcpu, vcpu->arch.cr0 & ~X86_CR0_TS); 2046 kvm_x86_ops->set_cr0(vcpu, vcpu->arch.cr0 & ~X86_CR0_TS);
2024 return X86EMUL_CONTINUE; 2047 return X86EMUL_CONTINUE;
2025} 2048}
@@ -2053,21 +2076,19 @@ int emulator_set_dr(struct x86_emulate_ctxt *ctxt, int dr, unsigned long value)
2053 2076
2054void kvm_report_emulation_failure(struct kvm_vcpu *vcpu, const char *context) 2077void kvm_report_emulation_failure(struct kvm_vcpu *vcpu, const char *context)
2055{ 2078{
2056 static int reported;
2057 u8 opcodes[4]; 2079 u8 opcodes[4];
2058 unsigned long rip = vcpu->arch.rip; 2080 unsigned long rip = vcpu->arch.rip;
2059 unsigned long rip_linear; 2081 unsigned long rip_linear;
2060 2082
2061 rip_linear = rip + get_segment_base(vcpu, VCPU_SREG_CS); 2083 if (!printk_ratelimit())
2062
2063 if (reported)
2064 return; 2084 return;
2065 2085
2086 rip_linear = rip + get_segment_base(vcpu, VCPU_SREG_CS);
2087
2066 emulator_read_std(rip_linear, (void *)opcodes, 4, vcpu); 2088 emulator_read_std(rip_linear, (void *)opcodes, 4, vcpu);
2067 2089
2068 printk(KERN_ERR "emulation failed (%s) rip %lx %02x %02x %02x %02x\n", 2090 printk(KERN_ERR "emulation failed (%s) rip %lx %02x %02x %02x %02x\n",
2069 context, rip, opcodes[0], opcodes[1], opcodes[2], opcodes[3]); 2091 context, rip, opcodes[0], opcodes[1], opcodes[2], opcodes[3]);
2070 reported = 1;
2071} 2092}
2072EXPORT_SYMBOL_GPL(kvm_report_emulation_failure); 2093EXPORT_SYMBOL_GPL(kvm_report_emulation_failure);
2073 2094
@@ -2105,27 +2126,6 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
2105 ? X86EMUL_MODE_PROT64 : cs_db 2126 ? X86EMUL_MODE_PROT64 : cs_db
2106 ? X86EMUL_MODE_PROT32 : X86EMUL_MODE_PROT16; 2127 ? X86EMUL_MODE_PROT32 : X86EMUL_MODE_PROT16;
2107 2128
2108 if (vcpu->arch.emulate_ctxt.mode == X86EMUL_MODE_PROT64) {
2109 vcpu->arch.emulate_ctxt.cs_base = 0;
2110 vcpu->arch.emulate_ctxt.ds_base = 0;
2111 vcpu->arch.emulate_ctxt.es_base = 0;
2112 vcpu->arch.emulate_ctxt.ss_base = 0;
2113 } else {
2114 vcpu->arch.emulate_ctxt.cs_base =
2115 get_segment_base(vcpu, VCPU_SREG_CS);
2116 vcpu->arch.emulate_ctxt.ds_base =
2117 get_segment_base(vcpu, VCPU_SREG_DS);
2118 vcpu->arch.emulate_ctxt.es_base =
2119 get_segment_base(vcpu, VCPU_SREG_ES);
2120 vcpu->arch.emulate_ctxt.ss_base =
2121 get_segment_base(vcpu, VCPU_SREG_SS);
2122 }
2123
2124 vcpu->arch.emulate_ctxt.gs_base =
2125 get_segment_base(vcpu, VCPU_SREG_GS);
2126 vcpu->arch.emulate_ctxt.fs_base =
2127 get_segment_base(vcpu, VCPU_SREG_FS);
2128
2129 r = x86_decode_insn(&vcpu->arch.emulate_ctxt, &emulate_ops); 2129 r = x86_decode_insn(&vcpu->arch.emulate_ctxt, &emulate_ops);
2130 2130
2131 /* Reject the instructions other than VMCALL/VMMCALL when 2131 /* Reject the instructions other than VMCALL/VMMCALL when
@@ -2300,9 +2300,10 @@ static void pio_string_write(struct kvm_io_device *pio_dev,
2300} 2300}
2301 2301
2302static struct kvm_io_device *vcpu_find_pio_dev(struct kvm_vcpu *vcpu, 2302static struct kvm_io_device *vcpu_find_pio_dev(struct kvm_vcpu *vcpu,
2303 gpa_t addr) 2303 gpa_t addr, int len,
2304 int is_write)
2304{ 2305{
2305 return kvm_io_bus_find_dev(&vcpu->kvm->pio_bus, addr); 2306 return kvm_io_bus_find_dev(&vcpu->kvm->pio_bus, addr, len, is_write);
2306} 2307}
2307 2308
2308int kvm_emulate_pio(struct kvm_vcpu *vcpu, struct kvm_run *run, int in, 2309int kvm_emulate_pio(struct kvm_vcpu *vcpu, struct kvm_run *run, int in,
@@ -2331,11 +2332,10 @@ int kvm_emulate_pio(struct kvm_vcpu *vcpu, struct kvm_run *run, int in,
2331 2332
2332 kvm_x86_ops->cache_regs(vcpu); 2333 kvm_x86_ops->cache_regs(vcpu);
2333 memcpy(vcpu->arch.pio_data, &vcpu->arch.regs[VCPU_REGS_RAX], 4); 2334 memcpy(vcpu->arch.pio_data, &vcpu->arch.regs[VCPU_REGS_RAX], 4);
2334 kvm_x86_ops->decache_regs(vcpu);
2335 2335
2336 kvm_x86_ops->skip_emulated_instruction(vcpu); 2336 kvm_x86_ops->skip_emulated_instruction(vcpu);
2337 2337
2338 pio_dev = vcpu_find_pio_dev(vcpu, port); 2338 pio_dev = vcpu_find_pio_dev(vcpu, port, size, !in);
2339 if (pio_dev) { 2339 if (pio_dev) {
2340 kernel_pio(pio_dev, vcpu, vcpu->arch.pio_data); 2340 kernel_pio(pio_dev, vcpu, vcpu->arch.pio_data);
2341 complete_pio(vcpu); 2341 complete_pio(vcpu);
@@ -2417,7 +2417,9 @@ int kvm_emulate_pio_string(struct kvm_vcpu *vcpu, struct kvm_run *run, int in,
2417 } 2417 }
2418 } 2418 }
2419 2419
2420 pio_dev = vcpu_find_pio_dev(vcpu, port); 2420 pio_dev = vcpu_find_pio_dev(vcpu, port,
2421 vcpu->arch.pio.cur_count,
2422 !vcpu->arch.pio.in);
2421 if (!vcpu->arch.pio.in) { 2423 if (!vcpu->arch.pio.in) {
2422 /* string PIO write */ 2424 /* string PIO write */
2423 ret = pio_copy_data(vcpu); 2425 ret = pio_copy_data(vcpu);
@@ -2600,27 +2602,41 @@ void realmode_lmsw(struct kvm_vcpu *vcpu, unsigned long msw,
2600 2602
2601unsigned long realmode_get_cr(struct kvm_vcpu *vcpu, int cr) 2603unsigned long realmode_get_cr(struct kvm_vcpu *vcpu, int cr)
2602{ 2604{
2605 unsigned long value;
2606
2603 kvm_x86_ops->decache_cr4_guest_bits(vcpu); 2607 kvm_x86_ops->decache_cr4_guest_bits(vcpu);
2604 switch (cr) { 2608 switch (cr) {
2605 case 0: 2609 case 0:
2606 return vcpu->arch.cr0; 2610 value = vcpu->arch.cr0;
2611 break;
2607 case 2: 2612 case 2:
2608 return vcpu->arch.cr2; 2613 value = vcpu->arch.cr2;
2614 break;
2609 case 3: 2615 case 3:
2610 return vcpu->arch.cr3; 2616 value = vcpu->arch.cr3;
2617 break;
2611 case 4: 2618 case 4:
2612 return vcpu->arch.cr4; 2619 value = vcpu->arch.cr4;
2620 break;
2613 case 8: 2621 case 8:
2614 return kvm_get_cr8(vcpu); 2622 value = kvm_get_cr8(vcpu);
2623 break;
2615 default: 2624 default:
2616 vcpu_printf(vcpu, "%s: unexpected cr %u\n", __func__, cr); 2625 vcpu_printf(vcpu, "%s: unexpected cr %u\n", __func__, cr);
2617 return 0; 2626 return 0;
2618 } 2627 }
2628 KVMTRACE_3D(CR_READ, vcpu, (u32)cr, (u32)value,
2629 (u32)((u64)value >> 32), handler);
2630
2631 return value;
2619} 2632}
2620 2633
2621void realmode_set_cr(struct kvm_vcpu *vcpu, int cr, unsigned long val, 2634void realmode_set_cr(struct kvm_vcpu *vcpu, int cr, unsigned long val,
2622 unsigned long *rflags) 2635 unsigned long *rflags)
2623{ 2636{
2637 KVMTRACE_3D(CR_WRITE, vcpu, (u32)cr, (u32)val,
2638 (u32)((u64)val >> 32), handler);
2639
2624 switch (cr) { 2640 switch (cr) {
2625 case 0: 2641 case 0:
2626 kvm_set_cr0(vcpu, mk_cr_64(vcpu->arch.cr0, val)); 2642 kvm_set_cr0(vcpu, mk_cr_64(vcpu->arch.cr0, val));
@@ -2771,8 +2787,10 @@ static void vapic_exit(struct kvm_vcpu *vcpu)
2771 if (!apic || !apic->vapic_addr) 2787 if (!apic || !apic->vapic_addr)
2772 return; 2788 return;
2773 2789
2790 down_read(&vcpu->kvm->slots_lock);
2774 kvm_release_page_dirty(apic->vapic_page); 2791 kvm_release_page_dirty(apic->vapic_page);
2775 mark_page_dirty(vcpu->kvm, apic->vapic_addr >> PAGE_SHIFT); 2792 mark_page_dirty(vcpu->kvm, apic->vapic_addr >> PAGE_SHIFT);
2793 up_read(&vcpu->kvm->slots_lock);
2776} 2794}
2777 2795
2778static int __vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 2796static int __vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
@@ -2928,9 +2946,7 @@ out:
2928 2946
2929 post_kvm_run_save(vcpu, kvm_run); 2947 post_kvm_run_save(vcpu, kvm_run);
2930 2948
2931 down_read(&vcpu->kvm->slots_lock);
2932 vapic_exit(vcpu); 2949 vapic_exit(vcpu);
2933 up_read(&vcpu->kvm->slots_lock);
2934 2950
2935 return r; 2951 return r;
2936} 2952}
@@ -2942,15 +2958,15 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2942 2958
2943 vcpu_load(vcpu); 2959 vcpu_load(vcpu);
2944 2960
2961 if (vcpu->sigset_active)
2962 sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved);
2963
2945 if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) { 2964 if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) {
2946 kvm_vcpu_block(vcpu); 2965 kvm_vcpu_block(vcpu);
2947 vcpu_put(vcpu); 2966 r = -EAGAIN;
2948 return -EAGAIN; 2967 goto out;
2949 } 2968 }
2950 2969
2951 if (vcpu->sigset_active)
2952 sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved);
2953
2954 /* re-sync apic's tpr */ 2970 /* re-sync apic's tpr */
2955 if (!irqchip_in_kernel(vcpu->kvm)) 2971 if (!irqchip_in_kernel(vcpu->kvm))
2956 kvm_set_cr8(vcpu, kvm_run->cr8); 2972 kvm_set_cr8(vcpu, kvm_run->cr8);
@@ -3070,8 +3086,8 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
3070 return 0; 3086 return 0;
3071} 3087}
3072 3088
3073static void get_segment(struct kvm_vcpu *vcpu, 3089void kvm_get_segment(struct kvm_vcpu *vcpu,
3074 struct kvm_segment *var, int seg) 3090 struct kvm_segment *var, int seg)
3075{ 3091{
3076 kvm_x86_ops->get_segment(vcpu, var, seg); 3092 kvm_x86_ops->get_segment(vcpu, var, seg);
3077} 3093}
@@ -3080,7 +3096,7 @@ void kvm_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l)
3080{ 3096{
3081 struct kvm_segment cs; 3097 struct kvm_segment cs;
3082 3098
3083 get_segment(vcpu, &cs, VCPU_SREG_CS); 3099 kvm_get_segment(vcpu, &cs, VCPU_SREG_CS);
3084 *db = cs.db; 3100 *db = cs.db;
3085 *l = cs.l; 3101 *l = cs.l;
3086} 3102}
@@ -3094,15 +3110,15 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
3094 3110
3095 vcpu_load(vcpu); 3111 vcpu_load(vcpu);
3096 3112
3097 get_segment(vcpu, &sregs->cs, VCPU_SREG_CS); 3113 kvm_get_segment(vcpu, &sregs->cs, VCPU_SREG_CS);
3098 get_segment(vcpu, &sregs->ds, VCPU_SREG_DS); 3114 kvm_get_segment(vcpu, &sregs->ds, VCPU_SREG_DS);
3099 get_segment(vcpu, &sregs->es, VCPU_SREG_ES); 3115 kvm_get_segment(vcpu, &sregs->es, VCPU_SREG_ES);
3100 get_segment(vcpu, &sregs->fs, VCPU_SREG_FS); 3116 kvm_get_segment(vcpu, &sregs->fs, VCPU_SREG_FS);
3101 get_segment(vcpu, &sregs->gs, VCPU_SREG_GS); 3117 kvm_get_segment(vcpu, &sregs->gs, VCPU_SREG_GS);
3102 get_segment(vcpu, &sregs->ss, VCPU_SREG_SS); 3118 kvm_get_segment(vcpu, &sregs->ss, VCPU_SREG_SS);
3103 3119
3104 get_segment(vcpu, &sregs->tr, VCPU_SREG_TR); 3120 kvm_get_segment(vcpu, &sregs->tr, VCPU_SREG_TR);
3105 get_segment(vcpu, &sregs->ldt, VCPU_SREG_LDTR); 3121 kvm_get_segment(vcpu, &sregs->ldt, VCPU_SREG_LDTR);
3106 3122
3107 kvm_x86_ops->get_idt(vcpu, &dt); 3123 kvm_x86_ops->get_idt(vcpu, &dt);
3108 sregs->idt.limit = dt.limit; 3124 sregs->idt.limit = dt.limit;
@@ -3154,7 +3170,7 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
3154 return 0; 3170 return 0;
3155} 3171}
3156 3172
3157static void set_segment(struct kvm_vcpu *vcpu, 3173static void kvm_set_segment(struct kvm_vcpu *vcpu,
3158 struct kvm_segment *var, int seg) 3174 struct kvm_segment *var, int seg)
3159{ 3175{
3160 kvm_x86_ops->set_segment(vcpu, var, seg); 3176 kvm_x86_ops->set_segment(vcpu, var, seg);
@@ -3191,7 +3207,7 @@ static void get_segment_descritptor_dtable(struct kvm_vcpu *vcpu,
3191 if (selector & 1 << 2) { 3207 if (selector & 1 << 2) {
3192 struct kvm_segment kvm_seg; 3208 struct kvm_segment kvm_seg;
3193 3209
3194 get_segment(vcpu, &kvm_seg, VCPU_SREG_LDTR); 3210 kvm_get_segment(vcpu, &kvm_seg, VCPU_SREG_LDTR);
3195 3211
3196 if (kvm_seg.unusable) 3212 if (kvm_seg.unusable)
3197 dtable->limit = 0; 3213 dtable->limit = 0;
@@ -3297,7 +3313,7 @@ static u16 get_segment_selector(struct kvm_vcpu *vcpu, int seg)
3297{ 3313{
3298 struct kvm_segment kvm_seg; 3314 struct kvm_segment kvm_seg;
3299 3315
3300 get_segment(vcpu, &kvm_seg, seg); 3316 kvm_get_segment(vcpu, &kvm_seg, seg);
3301 return kvm_seg.selector; 3317 return kvm_seg.selector;
3302} 3318}
3303 3319
@@ -3313,8 +3329,8 @@ static int load_segment_descriptor_to_kvm_desct(struct kvm_vcpu *vcpu,
3313 return 0; 3329 return 0;
3314} 3330}
3315 3331
3316static int load_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, 3332int kvm_load_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector,
3317 int type_bits, int seg) 3333 int type_bits, int seg)
3318{ 3334{
3319 struct kvm_segment kvm_seg; 3335 struct kvm_segment kvm_seg;
3320 3336
@@ -3327,7 +3343,7 @@ static int load_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector,
3327 if (!kvm_seg.s) 3343 if (!kvm_seg.s)
3328 kvm_seg.unusable = 1; 3344 kvm_seg.unusable = 1;
3329 3345
3330 set_segment(vcpu, &kvm_seg, seg); 3346 kvm_set_segment(vcpu, &kvm_seg, seg);
3331 return 0; 3347 return 0;
3332} 3348}
3333 3349
@@ -3373,25 +3389,25 @@ static int load_state_from_tss32(struct kvm_vcpu *vcpu,
3373 vcpu->arch.regs[VCPU_REGS_RSI] = tss->esi; 3389 vcpu->arch.regs[VCPU_REGS_RSI] = tss->esi;
3374 vcpu->arch.regs[VCPU_REGS_RDI] = tss->edi; 3390 vcpu->arch.regs[VCPU_REGS_RDI] = tss->edi;
3375 3391
3376 if (load_segment_descriptor(vcpu, tss->ldt_selector, 0, VCPU_SREG_LDTR)) 3392 if (kvm_load_segment_descriptor(vcpu, tss->ldt_selector, 0, VCPU_SREG_LDTR))
3377 return 1; 3393 return 1;
3378 3394
3379 if (load_segment_descriptor(vcpu, tss->es, 1, VCPU_SREG_ES)) 3395 if (kvm_load_segment_descriptor(vcpu, tss->es, 1, VCPU_SREG_ES))
3380 return 1; 3396 return 1;
3381 3397
3382 if (load_segment_descriptor(vcpu, tss->cs, 9, VCPU_SREG_CS)) 3398 if (kvm_load_segment_descriptor(vcpu, tss->cs, 9, VCPU_SREG_CS))
3383 return 1; 3399 return 1;
3384 3400
3385 if (load_segment_descriptor(vcpu, tss->ss, 1, VCPU_SREG_SS)) 3401 if (kvm_load_segment_descriptor(vcpu, tss->ss, 1, VCPU_SREG_SS))
3386 return 1; 3402 return 1;
3387 3403
3388 if (load_segment_descriptor(vcpu, tss->ds, 1, VCPU_SREG_DS)) 3404 if (kvm_load_segment_descriptor(vcpu, tss->ds, 1, VCPU_SREG_DS))
3389 return 1; 3405 return 1;
3390 3406
3391 if (load_segment_descriptor(vcpu, tss->fs, 1, VCPU_SREG_FS)) 3407 if (kvm_load_segment_descriptor(vcpu, tss->fs, 1, VCPU_SREG_FS))
3392 return 1; 3408 return 1;
3393 3409
3394 if (load_segment_descriptor(vcpu, tss->gs, 1, VCPU_SREG_GS)) 3410 if (kvm_load_segment_descriptor(vcpu, tss->gs, 1, VCPU_SREG_GS))
3395 return 1; 3411 return 1;
3396 return 0; 3412 return 0;
3397} 3413}
@@ -3432,24 +3448,24 @@ static int load_state_from_tss16(struct kvm_vcpu *vcpu,
3432 vcpu->arch.regs[VCPU_REGS_RSI] = tss->si; 3448 vcpu->arch.regs[VCPU_REGS_RSI] = tss->si;
3433 vcpu->arch.regs[VCPU_REGS_RDI] = tss->di; 3449 vcpu->arch.regs[VCPU_REGS_RDI] = tss->di;
3434 3450
3435 if (load_segment_descriptor(vcpu, tss->ldt, 0, VCPU_SREG_LDTR)) 3451 if (kvm_load_segment_descriptor(vcpu, tss->ldt, 0, VCPU_SREG_LDTR))
3436 return 1; 3452 return 1;
3437 3453
3438 if (load_segment_descriptor(vcpu, tss->es, 1, VCPU_SREG_ES)) 3454 if (kvm_load_segment_descriptor(vcpu, tss->es, 1, VCPU_SREG_ES))
3439 return 1; 3455 return 1;
3440 3456
3441 if (load_segment_descriptor(vcpu, tss->cs, 9, VCPU_SREG_CS)) 3457 if (kvm_load_segment_descriptor(vcpu, tss->cs, 9, VCPU_SREG_CS))
3442 return 1; 3458 return 1;
3443 3459
3444 if (load_segment_descriptor(vcpu, tss->ss, 1, VCPU_SREG_SS)) 3460 if (kvm_load_segment_descriptor(vcpu, tss->ss, 1, VCPU_SREG_SS))
3445 return 1; 3461 return 1;
3446 3462
3447 if (load_segment_descriptor(vcpu, tss->ds, 1, VCPU_SREG_DS)) 3463 if (kvm_load_segment_descriptor(vcpu, tss->ds, 1, VCPU_SREG_DS))
3448 return 1; 3464 return 1;
3449 return 0; 3465 return 0;
3450} 3466}
3451 3467
3452int kvm_task_switch_16(struct kvm_vcpu *vcpu, u16 tss_selector, 3468static int kvm_task_switch_16(struct kvm_vcpu *vcpu, u16 tss_selector,
3453 struct desc_struct *cseg_desc, 3469 struct desc_struct *cseg_desc,
3454 struct desc_struct *nseg_desc) 3470 struct desc_struct *nseg_desc)
3455{ 3471{
@@ -3472,7 +3488,7 @@ out:
3472 return ret; 3488 return ret;
3473} 3489}
3474 3490
3475int kvm_task_switch_32(struct kvm_vcpu *vcpu, u16 tss_selector, 3491static int kvm_task_switch_32(struct kvm_vcpu *vcpu, u16 tss_selector,
3476 struct desc_struct *cseg_desc, 3492 struct desc_struct *cseg_desc,
3477 struct desc_struct *nseg_desc) 3493 struct desc_struct *nseg_desc)
3478{ 3494{
@@ -3502,7 +3518,7 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason)
3502 struct desc_struct nseg_desc; 3518 struct desc_struct nseg_desc;
3503 int ret = 0; 3519 int ret = 0;
3504 3520
3505 get_segment(vcpu, &tr_seg, VCPU_SREG_TR); 3521 kvm_get_segment(vcpu, &tr_seg, VCPU_SREG_TR);
3506 3522
3507 if (load_guest_segment_descriptor(vcpu, tss_selector, &nseg_desc)) 3523 if (load_guest_segment_descriptor(vcpu, tss_selector, &nseg_desc))
3508 goto out; 3524 goto out;
@@ -3561,7 +3577,7 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason)
3561 kvm_x86_ops->set_cr0(vcpu, vcpu->arch.cr0 | X86_CR0_TS); 3577 kvm_x86_ops->set_cr0(vcpu, vcpu->arch.cr0 | X86_CR0_TS);
3562 seg_desct_to_kvm_desct(&nseg_desc, tss_selector, &tr_seg); 3578 seg_desct_to_kvm_desct(&nseg_desc, tss_selector, &tr_seg);
3563 tr_seg.type = 11; 3579 tr_seg.type = 11;
3564 set_segment(vcpu, &tr_seg, VCPU_SREG_TR); 3580 kvm_set_segment(vcpu, &tr_seg, VCPU_SREG_TR);
3565out: 3581out:
3566 kvm_x86_ops->decache_regs(vcpu); 3582 kvm_x86_ops->decache_regs(vcpu);
3567 return ret; 3583 return ret;
@@ -3628,15 +3644,15 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
3628 } 3644 }
3629 } 3645 }
3630 3646
3631 set_segment(vcpu, &sregs->cs, VCPU_SREG_CS); 3647 kvm_set_segment(vcpu, &sregs->cs, VCPU_SREG_CS);
3632 set_segment(vcpu, &sregs->ds, VCPU_SREG_DS); 3648 kvm_set_segment(vcpu, &sregs->ds, VCPU_SREG_DS);
3633 set_segment(vcpu, &sregs->es, VCPU_SREG_ES); 3649 kvm_set_segment(vcpu, &sregs->es, VCPU_SREG_ES);
3634 set_segment(vcpu, &sregs->fs, VCPU_SREG_FS); 3650 kvm_set_segment(vcpu, &sregs->fs, VCPU_SREG_FS);
3635 set_segment(vcpu, &sregs->gs, VCPU_SREG_GS); 3651 kvm_set_segment(vcpu, &sregs->gs, VCPU_SREG_GS);
3636 set_segment(vcpu, &sregs->ss, VCPU_SREG_SS); 3652 kvm_set_segment(vcpu, &sregs->ss, VCPU_SREG_SS);
3637 3653
3638 set_segment(vcpu, &sregs->tr, VCPU_SREG_TR); 3654 kvm_set_segment(vcpu, &sregs->tr, VCPU_SREG_TR);
3639 set_segment(vcpu, &sregs->ldt, VCPU_SREG_LDTR); 3655 kvm_set_segment(vcpu, &sregs->ldt, VCPU_SREG_LDTR);
3640 3656
3641 vcpu_put(vcpu); 3657 vcpu_put(vcpu);
3642 3658
@@ -3751,14 +3767,14 @@ void fx_init(struct kvm_vcpu *vcpu)
3751 * allocate ram with GFP_KERNEL. 3767 * allocate ram with GFP_KERNEL.
3752 */ 3768 */
3753 if (!used_math()) 3769 if (!used_math())
3754 fx_save(&vcpu->arch.host_fx_image); 3770 kvm_fx_save(&vcpu->arch.host_fx_image);
3755 3771
3756 /* Initialize guest FPU by resetting ours and saving into guest's */ 3772 /* Initialize guest FPU by resetting ours and saving into guest's */
3757 preempt_disable(); 3773 preempt_disable();
3758 fx_save(&vcpu->arch.host_fx_image); 3774 kvm_fx_save(&vcpu->arch.host_fx_image);
3759 fx_finit(); 3775 kvm_fx_finit();
3760 fx_save(&vcpu->arch.guest_fx_image); 3776 kvm_fx_save(&vcpu->arch.guest_fx_image);
3761 fx_restore(&vcpu->arch.host_fx_image); 3777 kvm_fx_restore(&vcpu->arch.host_fx_image);
3762 preempt_enable(); 3778 preempt_enable();
3763 3779
3764 vcpu->arch.cr0 |= X86_CR0_ET; 3780 vcpu->arch.cr0 |= X86_CR0_ET;
@@ -3775,8 +3791,8 @@ void kvm_load_guest_fpu(struct kvm_vcpu *vcpu)
3775 return; 3791 return;
3776 3792
3777 vcpu->guest_fpu_loaded = 1; 3793 vcpu->guest_fpu_loaded = 1;
3778 fx_save(&vcpu->arch.host_fx_image); 3794 kvm_fx_save(&vcpu->arch.host_fx_image);
3779 fx_restore(&vcpu->arch.guest_fx_image); 3795 kvm_fx_restore(&vcpu->arch.guest_fx_image);
3780} 3796}
3781EXPORT_SYMBOL_GPL(kvm_load_guest_fpu); 3797EXPORT_SYMBOL_GPL(kvm_load_guest_fpu);
3782 3798
@@ -3786,8 +3802,8 @@ void kvm_put_guest_fpu(struct kvm_vcpu *vcpu)
3786 return; 3802 return;
3787 3803
3788 vcpu->guest_fpu_loaded = 0; 3804 vcpu->guest_fpu_loaded = 0;
3789 fx_save(&vcpu->arch.guest_fx_image); 3805 kvm_fx_save(&vcpu->arch.guest_fx_image);
3790 fx_restore(&vcpu->arch.host_fx_image); 3806 kvm_fx_restore(&vcpu->arch.host_fx_image);
3791 ++vcpu->stat.fpu_reload; 3807 ++vcpu->stat.fpu_reload;
3792} 3808}
3793EXPORT_SYMBOL_GPL(kvm_put_guest_fpu); 3809EXPORT_SYMBOL_GPL(kvm_put_guest_fpu);
@@ -4016,6 +4032,11 @@ int kvm_arch_set_memory_region(struct kvm *kvm,
4016 return 0; 4032 return 0;
4017} 4033}
4018 4034
4035void kvm_arch_flush_shadow(struct kvm *kvm)
4036{
4037 kvm_mmu_zap_all(kvm);
4038}
4039
4019int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu) 4040int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
4020{ 4041{
4021 return vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE 4042 return vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE
diff --git a/arch/x86/kvm/x86_emulate.c b/arch/x86/kvm/x86_emulate.c
index 932f216d890c..f2f90468f8b1 100644
--- a/arch/x86/kvm/x86_emulate.c
+++ b/arch/x86/kvm/x86_emulate.c
@@ -121,7 +121,7 @@ static u16 opcode_table[256] = {
121 0, 0, 0, DstReg | SrcMem32 | ModRM | Mov /* movsxd (x86/64) */ , 121 0, 0, 0, DstReg | SrcMem32 | ModRM | Mov /* movsxd (x86/64) */ ,
122 0, 0, 0, 0, 122 0, 0, 0, 0,
123 /* 0x68 - 0x6F */ 123 /* 0x68 - 0x6F */
124 0, 0, ImplicitOps | Mov | Stack, 0, 124 SrcImm | Mov | Stack, 0, SrcImmByte | Mov | Stack, 0,
125 SrcNone | ByteOp | ImplicitOps, SrcNone | ImplicitOps, /* insb, insw/insd */ 125 SrcNone | ByteOp | ImplicitOps, SrcNone | ImplicitOps, /* insb, insw/insd */
126 SrcNone | ByteOp | ImplicitOps, SrcNone | ImplicitOps, /* outsb, outsw/outsd */ 126 SrcNone | ByteOp | ImplicitOps, SrcNone | ImplicitOps, /* outsb, outsw/outsd */
127 /* 0x70 - 0x77 */ 127 /* 0x70 - 0x77 */
@@ -138,9 +138,11 @@ static u16 opcode_table[256] = {
138 /* 0x88 - 0x8F */ 138 /* 0x88 - 0x8F */
139 ByteOp | DstMem | SrcReg | ModRM | Mov, DstMem | SrcReg | ModRM | Mov, 139 ByteOp | DstMem | SrcReg | ModRM | Mov, DstMem | SrcReg | ModRM | Mov,
140 ByteOp | DstReg | SrcMem | ModRM | Mov, DstReg | SrcMem | ModRM | Mov, 140 ByteOp | DstReg | SrcMem | ModRM | Mov, DstReg | SrcMem | ModRM | Mov,
141 0, ModRM | DstReg, 0, Group | Group1A, 141 DstMem | SrcReg | ModRM | Mov, ModRM | DstReg,
142 /* 0x90 - 0x9F */ 142 DstReg | SrcMem | ModRM | Mov, Group | Group1A,
143 0, 0, 0, 0, 0, 0, 0, 0, 143 /* 0x90 - 0x97 */
144 DstReg, DstReg, DstReg, DstReg, DstReg, DstReg, DstReg, DstReg,
145 /* 0x98 - 0x9F */
144 0, 0, 0, 0, ImplicitOps | Stack, ImplicitOps | Stack, 0, 0, 146 0, 0, 0, 0, ImplicitOps | Stack, ImplicitOps | Stack, 0, 0,
145 /* 0xA0 - 0xA7 */ 147 /* 0xA0 - 0xA7 */
146 ByteOp | DstReg | SrcMem | Mov | MemAbs, DstReg | SrcMem | Mov | MemAbs, 148 ByteOp | DstReg | SrcMem | Mov | MemAbs, DstReg | SrcMem | Mov | MemAbs,
@@ -152,7 +154,8 @@ static u16 opcode_table[256] = {
152 ByteOp | ImplicitOps | Mov | String, ImplicitOps | Mov | String, 154 ByteOp | ImplicitOps | Mov | String, ImplicitOps | Mov | String,
153 ByteOp | ImplicitOps | String, ImplicitOps | String, 155 ByteOp | ImplicitOps | String, ImplicitOps | String,
154 /* 0xB0 - 0xBF */ 156 /* 0xB0 - 0xBF */
155 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 157 0, 0, 0, 0, 0, 0, 0, 0,
158 DstReg | SrcImm | Mov, 0, 0, 0, 0, 0, 0, 0,
156 /* 0xC0 - 0xC7 */ 159 /* 0xC0 - 0xC7 */
157 ByteOp | DstMem | SrcImm | ModRM, DstMem | SrcImmByte | ModRM, 160 ByteOp | DstMem | SrcImm | ModRM, DstMem | SrcImmByte | ModRM,
158 0, ImplicitOps | Stack, 0, 0, 161 0, ImplicitOps | Stack, 0, 0,
@@ -168,7 +171,8 @@ static u16 opcode_table[256] = {
168 /* 0xE0 - 0xE7 */ 171 /* 0xE0 - 0xE7 */
169 0, 0, 0, 0, 0, 0, 0, 0, 172 0, 0, 0, 0, 0, 0, 0, 0,
170 /* 0xE8 - 0xEF */ 173 /* 0xE8 - 0xEF */
171 ImplicitOps | Stack, SrcImm|ImplicitOps, 0, SrcImmByte|ImplicitOps, 174 ImplicitOps | Stack, SrcImm | ImplicitOps,
175 ImplicitOps, SrcImmByte | ImplicitOps,
172 0, 0, 0, 0, 176 0, 0, 0, 0,
173 /* 0xF0 - 0xF7 */ 177 /* 0xF0 - 0xF7 */
174 0, 0, 0, 0, 178 0, 0, 0, 0,
@@ -215,7 +219,7 @@ static u16 twobyte_table[256] = {
215 /* 0xA0 - 0xA7 */ 219 /* 0xA0 - 0xA7 */
216 0, 0, 0, DstMem | SrcReg | ModRM | BitOp, 0, 0, 0, 0, 220 0, 0, 0, DstMem | SrcReg | ModRM | BitOp, 0, 0, 0, 0,
217 /* 0xA8 - 0xAF */ 221 /* 0xA8 - 0xAF */
218 0, 0, 0, DstMem | SrcReg | ModRM | BitOp, 0, 0, 0, 0, 222 0, 0, 0, DstMem | SrcReg | ModRM | BitOp, 0, 0, ModRM, 0,
219 /* 0xB0 - 0xB7 */ 223 /* 0xB0 - 0xB7 */
220 ByteOp | DstMem | SrcReg | ModRM, DstMem | SrcReg | ModRM, 0, 224 ByteOp | DstMem | SrcReg | ModRM, DstMem | SrcReg | ModRM, 0,
221 DstMem | SrcReg | ModRM | BitOp, 225 DstMem | SrcReg | ModRM | BitOp,
@@ -518,6 +522,39 @@ static inline void jmp_rel(struct decode_cache *c, int rel)
518 register_address_increment(c, &c->eip, rel); 522 register_address_increment(c, &c->eip, rel);
519} 523}
520 524
525static void set_seg_override(struct decode_cache *c, int seg)
526{
527 c->has_seg_override = true;
528 c->seg_override = seg;
529}
530
531static unsigned long seg_base(struct x86_emulate_ctxt *ctxt, int seg)
532{
533 if (ctxt->mode == X86EMUL_MODE_PROT64 && seg < VCPU_SREG_FS)
534 return 0;
535
536 return kvm_x86_ops->get_segment_base(ctxt->vcpu, seg);
537}
538
539static unsigned long seg_override_base(struct x86_emulate_ctxt *ctxt,
540 struct decode_cache *c)
541{
542 if (!c->has_seg_override)
543 return 0;
544
545 return seg_base(ctxt, c->seg_override);
546}
547
548static unsigned long es_base(struct x86_emulate_ctxt *ctxt)
549{
550 return seg_base(ctxt, VCPU_SREG_ES);
551}
552
553static unsigned long ss_base(struct x86_emulate_ctxt *ctxt)
554{
555 return seg_base(ctxt, VCPU_SREG_SS);
556}
557
521static int do_fetch_insn_byte(struct x86_emulate_ctxt *ctxt, 558static int do_fetch_insn_byte(struct x86_emulate_ctxt *ctxt,
522 struct x86_emulate_ops *ops, 559 struct x86_emulate_ops *ops,
523 unsigned long linear, u8 *dest) 560 unsigned long linear, u8 *dest)
@@ -660,7 +697,7 @@ static int decode_modrm(struct x86_emulate_ctxt *ctxt,
660{ 697{
661 struct decode_cache *c = &ctxt->decode; 698 struct decode_cache *c = &ctxt->decode;
662 u8 sib; 699 u8 sib;
663 int index_reg = 0, base_reg = 0, scale, rip_relative = 0; 700 int index_reg = 0, base_reg = 0, scale;
664 int rc = 0; 701 int rc = 0;
665 702
666 if (c->rex_prefix) { 703 if (c->rex_prefix) {
@@ -731,47 +768,28 @@ static int decode_modrm(struct x86_emulate_ctxt *ctxt,
731 } 768 }
732 if (c->modrm_rm == 2 || c->modrm_rm == 3 || 769 if (c->modrm_rm == 2 || c->modrm_rm == 3 ||
733 (c->modrm_rm == 6 && c->modrm_mod != 0)) 770 (c->modrm_rm == 6 && c->modrm_mod != 0))
734 if (!c->override_base) 771 if (!c->has_seg_override)
735 c->override_base = &ctxt->ss_base; 772 set_seg_override(c, VCPU_SREG_SS);
736 c->modrm_ea = (u16)c->modrm_ea; 773 c->modrm_ea = (u16)c->modrm_ea;
737 } else { 774 } else {
738 /* 32/64-bit ModR/M decode. */ 775 /* 32/64-bit ModR/M decode. */
739 switch (c->modrm_rm) { 776 if ((c->modrm_rm & 7) == 4) {
740 case 4:
741 case 12:
742 sib = insn_fetch(u8, 1, c->eip); 777 sib = insn_fetch(u8, 1, c->eip);
743 index_reg |= (sib >> 3) & 7; 778 index_reg |= (sib >> 3) & 7;
744 base_reg |= sib & 7; 779 base_reg |= sib & 7;
745 scale = sib >> 6; 780 scale = sib >> 6;
746 781
747 switch (base_reg) { 782 if ((base_reg & 7) == 5 && c->modrm_mod == 0)
748 case 5: 783 c->modrm_ea += insn_fetch(s32, 4, c->eip);
749 if (c->modrm_mod != 0) 784 else
750 c->modrm_ea += c->regs[base_reg];
751 else
752 c->modrm_ea +=
753 insn_fetch(s32, 4, c->eip);
754 break;
755 default:
756 c->modrm_ea += c->regs[base_reg]; 785 c->modrm_ea += c->regs[base_reg];
757 } 786 if (index_reg != 4)
758 switch (index_reg) {
759 case 4:
760 break;
761 default:
762 c->modrm_ea += c->regs[index_reg] << scale; 787 c->modrm_ea += c->regs[index_reg] << scale;
763 } 788 } else if ((c->modrm_rm & 7) == 5 && c->modrm_mod == 0) {
764 break; 789 if (ctxt->mode == X86EMUL_MODE_PROT64)
765 case 5: 790 c->rip_relative = 1;
766 if (c->modrm_mod != 0) 791 } else
767 c->modrm_ea += c->regs[c->modrm_rm];
768 else if (ctxt->mode == X86EMUL_MODE_PROT64)
769 rip_relative = 1;
770 break;
771 default:
772 c->modrm_ea += c->regs[c->modrm_rm]; 792 c->modrm_ea += c->regs[c->modrm_rm];
773 break;
774 }
775 switch (c->modrm_mod) { 793 switch (c->modrm_mod) {
776 case 0: 794 case 0:
777 if (c->modrm_rm == 5) 795 if (c->modrm_rm == 5)
@@ -785,22 +803,6 @@ static int decode_modrm(struct x86_emulate_ctxt *ctxt,
785 break; 803 break;
786 } 804 }
787 } 805 }
788 if (rip_relative) {
789 c->modrm_ea += c->eip;
790 switch (c->d & SrcMask) {
791 case SrcImmByte:
792 c->modrm_ea += 1;
793 break;
794 case SrcImm:
795 if (c->d & ByteOp)
796 c->modrm_ea += 1;
797 else
798 if (c->op_bytes == 8)
799 c->modrm_ea += 4;
800 else
801 c->modrm_ea += c->op_bytes;
802 }
803 }
804done: 806done:
805 return rc; 807 return rc;
806} 808}
@@ -838,6 +840,7 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
838 840
839 memset(c, 0, sizeof(struct decode_cache)); 841 memset(c, 0, sizeof(struct decode_cache));
840 c->eip = ctxt->vcpu->arch.rip; 842 c->eip = ctxt->vcpu->arch.rip;
843 ctxt->cs_base = seg_base(ctxt, VCPU_SREG_CS);
841 memcpy(c->regs, ctxt->vcpu->arch.regs, sizeof c->regs); 844 memcpy(c->regs, ctxt->vcpu->arch.regs, sizeof c->regs);
842 845
843 switch (mode) { 846 switch (mode) {
@@ -876,23 +879,15 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
876 /* switch between 2/4 bytes */ 879 /* switch between 2/4 bytes */
877 c->ad_bytes = def_ad_bytes ^ 6; 880 c->ad_bytes = def_ad_bytes ^ 6;
878 break; 881 break;
882 case 0x26: /* ES override */
879 case 0x2e: /* CS override */ 883 case 0x2e: /* CS override */
880 c->override_base = &ctxt->cs_base; 884 case 0x36: /* SS override */
881 break;
882 case 0x3e: /* DS override */ 885 case 0x3e: /* DS override */
883 c->override_base = &ctxt->ds_base; 886 set_seg_override(c, (c->b >> 3) & 3);
884 break;
885 case 0x26: /* ES override */
886 c->override_base = &ctxt->es_base;
887 break; 887 break;
888 case 0x64: /* FS override */ 888 case 0x64: /* FS override */
889 c->override_base = &ctxt->fs_base;
890 break;
891 case 0x65: /* GS override */ 889 case 0x65: /* GS override */
892 c->override_base = &ctxt->gs_base; 890 set_seg_override(c, c->b & 7);
893 break;
894 case 0x36: /* SS override */
895 c->override_base = &ctxt->ss_base;
896 break; 891 break;
897 case 0x40 ... 0x4f: /* REX */ 892 case 0x40 ... 0x4f: /* REX */
898 if (mode != X86EMUL_MODE_PROT64) 893 if (mode != X86EMUL_MODE_PROT64)
@@ -964,15 +959,11 @@ done_prefixes:
964 if (rc) 959 if (rc)
965 goto done; 960 goto done;
966 961
967 if (!c->override_base) 962 if (!c->has_seg_override)
968 c->override_base = &ctxt->ds_base; 963 set_seg_override(c, VCPU_SREG_DS);
969 if (mode == X86EMUL_MODE_PROT64 &&
970 c->override_base != &ctxt->fs_base &&
971 c->override_base != &ctxt->gs_base)
972 c->override_base = NULL;
973 964
974 if (c->override_base) 965 if (!(!c->twobyte && c->b == 0x8d))
975 c->modrm_ea += *c->override_base; 966 c->modrm_ea += seg_override_base(ctxt, c);
976 967
977 if (c->ad_bytes != 8) 968 if (c->ad_bytes != 8)
978 c->modrm_ea = (u32)c->modrm_ea; 969 c->modrm_ea = (u32)c->modrm_ea;
@@ -1049,6 +1040,7 @@ done_prefixes:
1049 break; 1040 break;
1050 case DstMem: 1041 case DstMem:
1051 if ((c->d & ModRM) && c->modrm_mod == 3) { 1042 if ((c->d & ModRM) && c->modrm_mod == 3) {
1043 c->dst.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
1052 c->dst.type = OP_REG; 1044 c->dst.type = OP_REG;
1053 c->dst.val = c->dst.orig_val = c->modrm_val; 1045 c->dst.val = c->dst.orig_val = c->modrm_val;
1054 c->dst.ptr = c->modrm_ptr; 1046 c->dst.ptr = c->modrm_ptr;
@@ -1058,6 +1050,9 @@ done_prefixes:
1058 break; 1050 break;
1059 } 1051 }
1060 1052
1053 if (c->rip_relative)
1054 c->modrm_ea += c->eip;
1055
1061done: 1056done:
1062 return (rc == X86EMUL_UNHANDLEABLE) ? -1 : 0; 1057 return (rc == X86EMUL_UNHANDLEABLE) ? -1 : 0;
1063} 1058}
@@ -1070,7 +1065,7 @@ static inline void emulate_push(struct x86_emulate_ctxt *ctxt)
1070 c->dst.bytes = c->op_bytes; 1065 c->dst.bytes = c->op_bytes;
1071 c->dst.val = c->src.val; 1066 c->dst.val = c->src.val;
1072 register_address_increment(c, &c->regs[VCPU_REGS_RSP], -c->op_bytes); 1067 register_address_increment(c, &c->regs[VCPU_REGS_RSP], -c->op_bytes);
1073 c->dst.ptr = (void *) register_address(c, ctxt->ss_base, 1068 c->dst.ptr = (void *) register_address(c, ss_base(ctxt),
1074 c->regs[VCPU_REGS_RSP]); 1069 c->regs[VCPU_REGS_RSP]);
1075} 1070}
1076 1071
@@ -1080,7 +1075,7 @@ static inline int emulate_grp1a(struct x86_emulate_ctxt *ctxt,
1080 struct decode_cache *c = &ctxt->decode; 1075 struct decode_cache *c = &ctxt->decode;
1081 int rc; 1076 int rc;
1082 1077
1083 rc = ops->read_std(register_address(c, ctxt->ss_base, 1078 rc = ops->read_std(register_address(c, ss_base(ctxt),
1084 c->regs[VCPU_REGS_RSP]), 1079 c->regs[VCPU_REGS_RSP]),
1085 &c->dst.val, c->dst.bytes, ctxt->vcpu); 1080 &c->dst.val, c->dst.bytes, ctxt->vcpu);
1086 if (rc != 0) 1081 if (rc != 0)
@@ -1402,11 +1397,11 @@ special_insn:
1402 register_address_increment(c, &c->regs[VCPU_REGS_RSP], 1397 register_address_increment(c, &c->regs[VCPU_REGS_RSP],
1403 -c->op_bytes); 1398 -c->op_bytes);
1404 c->dst.ptr = (void *) register_address( 1399 c->dst.ptr = (void *) register_address(
1405 c, ctxt->ss_base, c->regs[VCPU_REGS_RSP]); 1400 c, ss_base(ctxt), c->regs[VCPU_REGS_RSP]);
1406 break; 1401 break;
1407 case 0x58 ... 0x5f: /* pop reg */ 1402 case 0x58 ... 0x5f: /* pop reg */
1408 pop_instruction: 1403 pop_instruction:
1409 if ((rc = ops->read_std(register_address(c, ctxt->ss_base, 1404 if ((rc = ops->read_std(register_address(c, ss_base(ctxt),
1410 c->regs[VCPU_REGS_RSP]), c->dst.ptr, 1405 c->regs[VCPU_REGS_RSP]), c->dst.ptr,
1411 c->op_bytes, ctxt->vcpu)) != 0) 1406 c->op_bytes, ctxt->vcpu)) != 0)
1412 goto done; 1407 goto done;
@@ -1420,9 +1415,8 @@ special_insn:
1420 goto cannot_emulate; 1415 goto cannot_emulate;
1421 c->dst.val = (s32) c->src.val; 1416 c->dst.val = (s32) c->src.val;
1422 break; 1417 break;
1418 case 0x68: /* push imm */
1423 case 0x6a: /* push imm8 */ 1419 case 0x6a: /* push imm8 */
1424 c->src.val = 0L;
1425 c->src.val = insn_fetch(s8, 1, c->eip);
1426 emulate_push(ctxt); 1420 emulate_push(ctxt);
1427 break; 1421 break;
1428 case 0x6c: /* insb */ 1422 case 0x6c: /* insb */
@@ -1433,7 +1427,7 @@ special_insn:
1433 c->rep_prefix ? 1427 c->rep_prefix ?
1434 address_mask(c, c->regs[VCPU_REGS_RCX]) : 1, 1428 address_mask(c, c->regs[VCPU_REGS_RCX]) : 1,
1435 (ctxt->eflags & EFLG_DF), 1429 (ctxt->eflags & EFLG_DF),
1436 register_address(c, ctxt->es_base, 1430 register_address(c, es_base(ctxt),
1437 c->regs[VCPU_REGS_RDI]), 1431 c->regs[VCPU_REGS_RDI]),
1438 c->rep_prefix, 1432 c->rep_prefix,
1439 c->regs[VCPU_REGS_RDX]) == 0) { 1433 c->regs[VCPU_REGS_RDX]) == 0) {
@@ -1449,9 +1443,8 @@ special_insn:
1449 c->rep_prefix ? 1443 c->rep_prefix ?
1450 address_mask(c, c->regs[VCPU_REGS_RCX]) : 1, 1444 address_mask(c, c->regs[VCPU_REGS_RCX]) : 1,
1451 (ctxt->eflags & EFLG_DF), 1445 (ctxt->eflags & EFLG_DF),
1452 register_address(c, c->override_base ? 1446 register_address(c,
1453 *c->override_base : 1447 seg_override_base(ctxt, c),
1454 ctxt->ds_base,
1455 c->regs[VCPU_REGS_RSI]), 1448 c->regs[VCPU_REGS_RSI]),
1456 c->rep_prefix, 1449 c->rep_prefix,
1457 c->regs[VCPU_REGS_RDX]) == 0) { 1450 c->regs[VCPU_REGS_RDX]) == 0) {
@@ -1490,6 +1483,7 @@ special_insn:
1490 emulate_2op_SrcV("test", c->src, c->dst, ctxt->eflags); 1483 emulate_2op_SrcV("test", c->src, c->dst, ctxt->eflags);
1491 break; 1484 break;
1492 case 0x86 ... 0x87: /* xchg */ 1485 case 0x86 ... 0x87: /* xchg */
1486 xchg:
1493 /* Write back the register source. */ 1487 /* Write back the register source. */
1494 switch (c->dst.bytes) { 1488 switch (c->dst.bytes) {
1495 case 1: 1489 case 1:
@@ -1514,14 +1508,60 @@ special_insn:
1514 break; 1508 break;
1515 case 0x88 ... 0x8b: /* mov */ 1509 case 0x88 ... 0x8b: /* mov */
1516 goto mov; 1510 goto mov;
1511 case 0x8c: { /* mov r/m, sreg */
1512 struct kvm_segment segreg;
1513
1514 if (c->modrm_reg <= 5)
1515 kvm_get_segment(ctxt->vcpu, &segreg, c->modrm_reg);
1516 else {
1517 printk(KERN_INFO "0x8c: Invalid segreg in modrm byte 0x%02x\n",
1518 c->modrm);
1519 goto cannot_emulate;
1520 }
1521 c->dst.val = segreg.selector;
1522 break;
1523 }
1517 case 0x8d: /* lea r16/r32, m */ 1524 case 0x8d: /* lea r16/r32, m */
1518 c->dst.val = c->modrm_ea; 1525 c->dst.val = c->modrm_ea;
1519 break; 1526 break;
1527 case 0x8e: { /* mov seg, r/m16 */
1528 uint16_t sel;
1529 int type_bits;
1530 int err;
1531
1532 sel = c->src.val;
1533 if (c->modrm_reg <= 5) {
1534 type_bits = (c->modrm_reg == 1) ? 9 : 1;
1535 err = kvm_load_segment_descriptor(ctxt->vcpu, sel,
1536 type_bits, c->modrm_reg);
1537 } else {
1538 printk(KERN_INFO "Invalid segreg in modrm byte 0x%02x\n",
1539 c->modrm);
1540 goto cannot_emulate;
1541 }
1542
1543 if (err < 0)
1544 goto cannot_emulate;
1545
1546 c->dst.type = OP_NONE; /* Disable writeback. */
1547 break;
1548 }
1520 case 0x8f: /* pop (sole member of Grp1a) */ 1549 case 0x8f: /* pop (sole member of Grp1a) */
1521 rc = emulate_grp1a(ctxt, ops); 1550 rc = emulate_grp1a(ctxt, ops);
1522 if (rc != 0) 1551 if (rc != 0)
1523 goto done; 1552 goto done;
1524 break; 1553 break;
1554 case 0x90: /* nop / xchg r8,rax */
1555 if (!(c->rex_prefix & 1)) { /* nop */
1556 c->dst.type = OP_NONE;
1557 break;
1558 }
1559 case 0x91 ... 0x97: /* xchg reg,rax */
1560 c->src.type = c->dst.type = OP_REG;
1561 c->src.bytes = c->dst.bytes = c->op_bytes;
1562 c->src.ptr = (unsigned long *) &c->regs[VCPU_REGS_RAX];
1563 c->src.val = *(c->src.ptr);
1564 goto xchg;
1525 case 0x9c: /* pushf */ 1565 case 0x9c: /* pushf */
1526 c->src.val = (unsigned long) ctxt->eflags; 1566 c->src.val = (unsigned long) ctxt->eflags;
1527 emulate_push(ctxt); 1567 emulate_push(ctxt);
@@ -1540,11 +1580,10 @@ special_insn:
1540 c->dst.type = OP_MEM; 1580 c->dst.type = OP_MEM;
1541 c->dst.bytes = (c->d & ByteOp) ? 1 : c->op_bytes; 1581 c->dst.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
1542 c->dst.ptr = (unsigned long *)register_address(c, 1582 c->dst.ptr = (unsigned long *)register_address(c,
1543 ctxt->es_base, 1583 es_base(ctxt),
1544 c->regs[VCPU_REGS_RDI]); 1584 c->regs[VCPU_REGS_RDI]);
1545 if ((rc = ops->read_emulated(register_address(c, 1585 if ((rc = ops->read_emulated(register_address(c,
1546 c->override_base ? *c->override_base : 1586 seg_override_base(ctxt, c),
1547 ctxt->ds_base,
1548 c->regs[VCPU_REGS_RSI]), 1587 c->regs[VCPU_REGS_RSI]),
1549 &c->dst.val, 1588 &c->dst.val,
1550 c->dst.bytes, ctxt->vcpu)) != 0) 1589 c->dst.bytes, ctxt->vcpu)) != 0)
@@ -1560,8 +1599,7 @@ special_insn:
1560 c->src.type = OP_NONE; /* Disable writeback. */ 1599 c->src.type = OP_NONE; /* Disable writeback. */
1561 c->src.bytes = (c->d & ByteOp) ? 1 : c->op_bytes; 1600 c->src.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
1562 c->src.ptr = (unsigned long *)register_address(c, 1601 c->src.ptr = (unsigned long *)register_address(c,
1563 c->override_base ? *c->override_base : 1602 seg_override_base(ctxt, c),
1564 ctxt->ds_base,
1565 c->regs[VCPU_REGS_RSI]); 1603 c->regs[VCPU_REGS_RSI]);
1566 if ((rc = ops->read_emulated((unsigned long)c->src.ptr, 1604 if ((rc = ops->read_emulated((unsigned long)c->src.ptr,
1567 &c->src.val, 1605 &c->src.val,
@@ -1572,7 +1610,7 @@ special_insn:
1572 c->dst.type = OP_NONE; /* Disable writeback. */ 1610 c->dst.type = OP_NONE; /* Disable writeback. */
1573 c->dst.bytes = (c->d & ByteOp) ? 1 : c->op_bytes; 1611 c->dst.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
1574 c->dst.ptr = (unsigned long *)register_address(c, 1612 c->dst.ptr = (unsigned long *)register_address(c,
1575 ctxt->es_base, 1613 es_base(ctxt),
1576 c->regs[VCPU_REGS_RDI]); 1614 c->regs[VCPU_REGS_RDI]);
1577 if ((rc = ops->read_emulated((unsigned long)c->dst.ptr, 1615 if ((rc = ops->read_emulated((unsigned long)c->dst.ptr,
1578 &c->dst.val, 1616 &c->dst.val,
@@ -1596,7 +1634,7 @@ special_insn:
1596 c->dst.type = OP_MEM; 1634 c->dst.type = OP_MEM;
1597 c->dst.bytes = (c->d & ByteOp) ? 1 : c->op_bytes; 1635 c->dst.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
1598 c->dst.ptr = (unsigned long *)register_address(c, 1636 c->dst.ptr = (unsigned long *)register_address(c,
1599 ctxt->es_base, 1637 es_base(ctxt),
1600 c->regs[VCPU_REGS_RDI]); 1638 c->regs[VCPU_REGS_RDI]);
1601 c->dst.val = c->regs[VCPU_REGS_RAX]; 1639 c->dst.val = c->regs[VCPU_REGS_RAX];
1602 register_address_increment(c, &c->regs[VCPU_REGS_RDI], 1640 register_address_increment(c, &c->regs[VCPU_REGS_RDI],
@@ -1608,8 +1646,7 @@ special_insn:
1608 c->dst.bytes = (c->d & ByteOp) ? 1 : c->op_bytes; 1646 c->dst.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
1609 c->dst.ptr = (unsigned long *)&c->regs[VCPU_REGS_RAX]; 1647 c->dst.ptr = (unsigned long *)&c->regs[VCPU_REGS_RAX];
1610 if ((rc = ops->read_emulated(register_address(c, 1648 if ((rc = ops->read_emulated(register_address(c,
1611 c->override_base ? *c->override_base : 1649 seg_override_base(ctxt, c),
1612 ctxt->ds_base,
1613 c->regs[VCPU_REGS_RSI]), 1650 c->regs[VCPU_REGS_RSI]),
1614 &c->dst.val, 1651 &c->dst.val,
1615 c->dst.bytes, 1652 c->dst.bytes,
@@ -1622,6 +1659,8 @@ special_insn:
1622 case 0xae ... 0xaf: /* scas */ 1659 case 0xae ... 0xaf: /* scas */
1623 DPRINTF("Urk! I don't handle SCAS.\n"); 1660 DPRINTF("Urk! I don't handle SCAS.\n");
1624 goto cannot_emulate; 1661 goto cannot_emulate;
1662 case 0xb8: /* mov r, imm */
1663 goto mov;
1625 case 0xc0 ... 0xc1: 1664 case 0xc0 ... 0xc1:
1626 emulate_grp2(ctxt); 1665 emulate_grp2(ctxt);
1627 break; 1666 break;
@@ -1660,13 +1699,39 @@ special_insn:
1660 break; 1699 break;
1661 } 1700 }
1662 case 0xe9: /* jmp rel */ 1701 case 0xe9: /* jmp rel */
1663 case 0xeb: /* jmp rel short */ 1702 goto jmp;
1703 case 0xea: /* jmp far */ {
1704 uint32_t eip;
1705 uint16_t sel;
1706
1707 switch (c->op_bytes) {
1708 case 2:
1709 eip = insn_fetch(u16, 2, c->eip);
1710 break;
1711 case 4:
1712 eip = insn_fetch(u32, 4, c->eip);
1713 break;
1714 default:
1715 DPRINTF("jmp far: Invalid op_bytes\n");
1716 goto cannot_emulate;
1717 }
1718 sel = insn_fetch(u16, 2, c->eip);
1719 if (kvm_load_segment_descriptor(ctxt->vcpu, sel, 9, VCPU_SREG_CS) < 0) {
1720 DPRINTF("jmp far: Failed to load CS descriptor\n");
1721 goto cannot_emulate;
1722 }
1723
1724 c->eip = eip;
1725 break;
1726 }
1727 case 0xeb:
1728 jmp: /* jmp rel short */
1664 jmp_rel(c, c->src.val); 1729 jmp_rel(c, c->src.val);
1665 c->dst.type = OP_NONE; /* Disable writeback. */ 1730 c->dst.type = OP_NONE; /* Disable writeback. */
1666 break; 1731 break;
1667 case 0xf4: /* hlt */ 1732 case 0xf4: /* hlt */
1668 ctxt->vcpu->arch.halt_request = 1; 1733 ctxt->vcpu->arch.halt_request = 1;
1669 goto done; 1734 break;
1670 case 0xf5: /* cmc */ 1735 case 0xf5: /* cmc */
1671 /* complement carry flag from eflags reg */ 1736 /* complement carry flag from eflags reg */
1672 ctxt->eflags ^= EFLG_CF; 1737 ctxt->eflags ^= EFLG_CF;
@@ -1882,6 +1947,8 @@ twobyte_insn:
1882 c->src.val &= (c->dst.bytes << 3) - 1; 1947 c->src.val &= (c->dst.bytes << 3) - 1;
1883 emulate_2op_SrcV_nobyte("bts", c->src, c->dst, ctxt->eflags); 1948 emulate_2op_SrcV_nobyte("bts", c->src, c->dst, ctxt->eflags);
1884 break; 1949 break;
1950 case 0xae: /* clflush */
1951 break;
1885 case 0xb0 ... 0xb1: /* cmpxchg */ 1952 case 0xb0 ... 0xb1: /* cmpxchg */
1886 /* 1953 /*
1887 * Save real source value, then compare EAX against 1954 * Save real source value, then compare EAX against