aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/lguest/lguest.c70
-rw-r--r--Documentation/lguest/lguest.txt19
-rw-r--r--MAINTAINERS8
-rw-r--r--arch/powerpc/configs/pasemi_defconfig142
-rw-r--r--arch/powerpc/kernel/process.c10
-rw-r--r--arch/x86/lguest/boot.c108
-rw-r--r--arch/x86/lguest/i386_head.S15
-rw-r--r--arch/x86/mm/highmem_32.c6
-rw-r--r--drivers/acpi/fan.c34
-rw-r--r--drivers/acpi/processor_core.c30
-rw-r--r--drivers/acpi/video.c28
-rw-r--r--drivers/base/driver.c5
-rw-r--r--drivers/char/drm/ati_pcigart.c5
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_cm.c2
-rw-r--r--drivers/input/misc/ixp4xx-beeper.c1
-rw-r--r--drivers/lguest/Makefile8
-rw-r--r--drivers/lguest/core.c18
-rw-r--r--drivers/lguest/hypercalls.c11
-rw-r--r--drivers/lguest/interrupts_and_traps.c7
-rw-r--r--drivers/lguest/lguest_device.c11
-rw-r--r--drivers/lguest/lguest_user.c30
-rw-r--r--drivers/lguest/page_tables.c32
-rw-r--r--drivers/lguest/x86/core.c33
-rw-r--r--drivers/lguest/x86/switcher_32.S8
-rw-r--r--drivers/md/dm-crypt.c58
-rw-r--r--drivers/md/dm-io.c2
-rw-r--r--drivers/md/dm-raid1.c4
-rw-r--r--drivers/md/dm-snap.c2
-rw-r--r--drivers/md/kcopyd.c10
-rw-r--r--drivers/md/kcopyd.h4
-rw-r--r--drivers/memstick/host/tifm_ms.c4
-rw-r--r--drivers/mtd/maps/physmap.c15
-rw-r--r--drivers/mtd/nand/rtc_from4.c2
-rw-r--r--drivers/pci/quirks.c11
-rw-r--r--drivers/video/bf54x-lq043fb.c2
-rw-r--r--drivers/video/bfin-t350mcqb-fb.c38
-rw-r--r--drivers/virtio/virtio_pci.c1
-rw-r--r--fs/afs/cell.c15
-rw-r--r--fs/buffer.c13
-rw-r--r--include/asm-x86/lguest_hcall.h2
-rw-r--r--include/linux/Kbuild2
-rw-r--r--include/linux/bitops.h40
-rw-r--r--include/linux/hardirq.h7
-rw-r--r--include/linux/lguest_launcher.h6
-rw-r--r--kernel/audit.c6
-rw-r--r--kernel/fork.c2
-rw-r--r--mm/slub.c3
-rw-r--r--net/9p/trans_fd.c2
-rwxr-xr-xscripts/checkpatch.pl463
49 files changed, 816 insertions, 539 deletions
diff --git a/Documentation/lguest/lguest.c b/Documentation/lguest/lguest.c
index bec5a32e4095..4c1fc65a8b3d 100644
--- a/Documentation/lguest/lguest.c
+++ b/Documentation/lguest/lguest.c
@@ -1,7 +1,7 @@
1/*P:100 This is the Launcher code, a simple program which lays out the 1/*P:100 This is the Launcher code, a simple program which lays out the
2 * "physical" memory for the new Guest by mapping the kernel image and the 2 * "physical" memory for the new Guest by mapping the kernel image and
3 * virtual devices, then reads repeatedly from /dev/lguest to run the Guest. 3 * the virtual devices, then opens /dev/lguest to tell the kernel
4:*/ 4 * about the Guest and control it. :*/
5#define _LARGEFILE64_SOURCE 5#define _LARGEFILE64_SOURCE
6#define _GNU_SOURCE 6#define _GNU_SOURCE
7#include <stdio.h> 7#include <stdio.h>
@@ -43,7 +43,7 @@
43#include "linux/virtio_console.h" 43#include "linux/virtio_console.h"
44#include "linux/virtio_ring.h" 44#include "linux/virtio_ring.h"
45#include "asm-x86/bootparam.h" 45#include "asm-x86/bootparam.h"
46/*L:110 We can ignore the 38 include files we need for this program, but I do 46/*L:110 We can ignore the 39 include files we need for this program, but I do
47 * want to draw attention to the use of kernel-style types. 47 * want to draw attention to the use of kernel-style types.
48 * 48 *
49 * As Linus said, "C is a Spartan language, and so should your naming be." I 49 * As Linus said, "C is a Spartan language, and so should your naming be." I
@@ -320,7 +320,7 @@ static unsigned long map_elf(int elf_fd, const Elf32_Ehdr *ehdr)
320 err(1, "Reading program headers"); 320 err(1, "Reading program headers");
321 321
322 /* Try all the headers: there are usually only three. A read-only one, 322 /* Try all the headers: there are usually only three. A read-only one,
323 * a read-write one, and a "note" section which isn't loadable. */ 323 * a read-write one, and a "note" section which we don't load. */
324 for (i = 0; i < ehdr->e_phnum; i++) { 324 for (i = 0; i < ehdr->e_phnum; i++) {
325 /* If this isn't a loadable segment, we ignore it */ 325 /* If this isn't a loadable segment, we ignore it */
326 if (phdr[i].p_type != PT_LOAD) 326 if (phdr[i].p_type != PT_LOAD)
@@ -387,7 +387,7 @@ static unsigned long load_kernel(int fd)
387 if (memcmp(hdr.e_ident, ELFMAG, SELFMAG) == 0) 387 if (memcmp(hdr.e_ident, ELFMAG, SELFMAG) == 0)
388 return map_elf(fd, &hdr); 388 return map_elf(fd, &hdr);
389 389
390 /* Otherwise we assume it's a bzImage, and try to unpack it */ 390 /* Otherwise we assume it's a bzImage, and try to load it. */
391 return load_bzimage(fd); 391 return load_bzimage(fd);
392} 392}
393 393
@@ -433,12 +433,12 @@ static unsigned long load_initrd(const char *name, unsigned long mem)
433 return len; 433 return len;
434} 434}
435 435
436/* Once we know how much memory we have, we can construct simple linear page 436/* Once we know how much memory we have we can construct simple linear page
437 * tables which set virtual == physical which will get the Guest far enough 437 * tables which set virtual == physical which will get the Guest far enough
438 * into the boot to create its own. 438 * into the boot to create its own.
439 * 439 *
440 * We lay them out of the way, just below the initrd (which is why we need to 440 * We lay them out of the way, just below the initrd (which is why we need to
441 * know its size). */ 441 * know its size here). */
442static unsigned long setup_pagetables(unsigned long mem, 442static unsigned long setup_pagetables(unsigned long mem,
443 unsigned long initrd_size) 443 unsigned long initrd_size)
444{ 444{
@@ -850,7 +850,8 @@ static void handle_console_output(int fd, struct virtqueue *vq)
850 * 850 *
851 * Handling output for network is also simple: we get all the output buffers 851 * Handling output for network is also simple: we get all the output buffers
852 * and write them (ignoring the first element) to this device's file descriptor 852 * and write them (ignoring the first element) to this device's file descriptor
853 * (stdout). */ 853 * (/dev/net/tun).
854 */
854static void handle_net_output(int fd, struct virtqueue *vq) 855static void handle_net_output(int fd, struct virtqueue *vq)
855{ 856{
856 unsigned int head, out, in; 857 unsigned int head, out, in;
@@ -924,7 +925,7 @@ static void enable_fd(int fd, struct virtqueue *vq)
924 write(waker_fd, &vq->dev->fd, sizeof(vq->dev->fd)); 925 write(waker_fd, &vq->dev->fd, sizeof(vq->dev->fd));
925} 926}
926 927
927/* Resetting a device is fairly easy. */ 928/* When the Guest asks us to reset a device, it's is fairly easy. */
928static void reset_device(struct device *dev) 929static void reset_device(struct device *dev)
929{ 930{
930 struct virtqueue *vq; 931 struct virtqueue *vq;
@@ -1003,8 +1004,8 @@ static void handle_input(int fd)
1003 if (select(devices.max_infd+1, &fds, NULL, NULL, &poll) == 0) 1004 if (select(devices.max_infd+1, &fds, NULL, NULL, &poll) == 0)
1004 break; 1005 break;
1005 1006
1006 /* Otherwise, call the device(s) which have readable 1007 /* Otherwise, call the device(s) which have readable file
1007 * file descriptors and a method of handling them. */ 1008 * descriptors and a method of handling them. */
1008 for (i = devices.dev; i; i = i->next) { 1009 for (i = devices.dev; i; i = i->next) {
1009 if (i->handle_input && FD_ISSET(i->fd, &fds)) { 1010 if (i->handle_input && FD_ISSET(i->fd, &fds)) {
1010 int dev_fd; 1011 int dev_fd;
@@ -1015,8 +1016,7 @@ static void handle_input(int fd)
1015 * should no longer service it. Networking and 1016 * should no longer service it. Networking and
1016 * console do this when there's no input 1017 * console do this when there's no input
1017 * buffers to deliver into. Console also uses 1018 * buffers to deliver into. Console also uses
1018 * it when it discovers that stdin is 1019 * it when it discovers that stdin is closed. */
1019 * closed. */
1020 FD_CLR(i->fd, &devices.infds); 1020 FD_CLR(i->fd, &devices.infds);
1021 /* Tell waker to ignore it too, by sending a 1021 /* Tell waker to ignore it too, by sending a
1022 * negative fd number (-1, since 0 is a valid 1022 * negative fd number (-1, since 0 is a valid
@@ -1033,7 +1033,8 @@ static void handle_input(int fd)
1033 * 1033 *
1034 * All devices need a descriptor so the Guest knows it exists, and a "struct 1034 * All devices need a descriptor so the Guest knows it exists, and a "struct
1035 * device" so the Launcher can keep track of it. We have common helper 1035 * device" so the Launcher can keep track of it. We have common helper
1036 * routines to allocate and manage them. */ 1036 * routines to allocate and manage them.
1037 */
1037 1038
1038/* The layout of the device page is a "struct lguest_device_desc" followed by a 1039/* The layout of the device page is a "struct lguest_device_desc" followed by a
1039 * number of virtqueue descriptors, then two sets of feature bits, then an 1040 * number of virtqueue descriptors, then two sets of feature bits, then an
@@ -1078,7 +1079,7 @@ static void add_virtqueue(struct device *dev, unsigned int num_descs,
1078 struct virtqueue **i, *vq = malloc(sizeof(*vq)); 1079 struct virtqueue **i, *vq = malloc(sizeof(*vq));
1079 void *p; 1080 void *p;
1080 1081
1081 /* First we need some pages for this virtqueue. */ 1082 /* First we need some memory for this virtqueue. */
1082 pages = (vring_size(num_descs, getpagesize()) + getpagesize() - 1) 1083 pages = (vring_size(num_descs, getpagesize()) + getpagesize() - 1)
1083 / getpagesize(); 1084 / getpagesize();
1084 p = get_pages(pages); 1085 p = get_pages(pages);
@@ -1122,7 +1123,7 @@ static void add_virtqueue(struct device *dev, unsigned int num_descs,
1122} 1123}
1123 1124
1124/* The first half of the feature bitmask is for us to advertise features. The 1125/* The first half of the feature bitmask is for us to advertise features. The
1125 * second half if for the Guest to accept features. */ 1126 * second half is for the Guest to accept features. */
1126static void add_feature(struct device *dev, unsigned bit) 1127static void add_feature(struct device *dev, unsigned bit)
1127{ 1128{
1128 u8 *features = get_feature_bits(dev); 1129 u8 *features = get_feature_bits(dev);
@@ -1151,7 +1152,9 @@ static void set_config(struct device *dev, unsigned len, const void *conf)
1151} 1152}
1152 1153
1153/* This routine does all the creation and setup of a new device, including 1154/* This routine does all the creation and setup of a new device, including
1154 * calling new_dev_desc() to allocate the descriptor and device memory. */ 1155 * calling new_dev_desc() to allocate the descriptor and device memory.
1156 *
1157 * See what I mean about userspace being boring? */
1155static struct device *new_device(const char *name, u16 type, int fd, 1158static struct device *new_device(const char *name, u16 type, int fd,
1156 bool (*handle_input)(int, struct device *)) 1159 bool (*handle_input)(int, struct device *))
1157{ 1160{
@@ -1383,7 +1386,6 @@ struct vblk_info
1383 * Launcher triggers interrupt to Guest. */ 1386 * Launcher triggers interrupt to Guest. */
1384 int done_fd; 1387 int done_fd;
1385}; 1388};
1386/*:*/
1387 1389
1388/*L:210 1390/*L:210
1389 * The Disk 1391 * The Disk
@@ -1493,7 +1495,10 @@ static int io_thread(void *_dev)
1493 while (read(vblk->workpipe[0], &c, 1) == 1) { 1495 while (read(vblk->workpipe[0], &c, 1) == 1) {
1494 /* We acknowledge each request immediately to reduce latency, 1496 /* We acknowledge each request immediately to reduce latency,
1495 * rather than waiting until we've done them all. I haven't 1497 * rather than waiting until we've done them all. I haven't
1496 * measured to see if it makes any difference. */ 1498 * measured to see if it makes any difference.
1499 *
1500 * That would be an interesting test, wouldn't it? You could
1501 * also try having more than one I/O thread. */
1497 while (service_io(dev)) 1502 while (service_io(dev))
1498 write(vblk->done_fd, &c, 1); 1503 write(vblk->done_fd, &c, 1);
1499 } 1504 }
@@ -1501,7 +1506,7 @@ static int io_thread(void *_dev)
1501} 1506}
1502 1507
1503/* Now we've seen the I/O thread, we return to the Launcher to see what happens 1508/* Now we've seen the I/O thread, we return to the Launcher to see what happens
1504 * when the thread tells us it's completed some I/O. */ 1509 * when that thread tells us it's completed some I/O. */
1505static bool handle_io_finish(int fd, struct device *dev) 1510static bool handle_io_finish(int fd, struct device *dev)
1506{ 1511{
1507 char c; 1512 char c;
@@ -1573,11 +1578,12 @@ static void setup_block_file(const char *filename)
1573 * more work. */ 1578 * more work. */
1574 pipe(vblk->workpipe); 1579 pipe(vblk->workpipe);
1575 1580
1576 /* Create stack for thread and run it */ 1581 /* Create stack for thread and run it. Since stack grows upwards, we
1582 * point the stack pointer to the end of this region. */
1577 stack = malloc(32768); 1583 stack = malloc(32768);
1578 /* SIGCHLD - We dont "wait" for our cloned thread, so prevent it from 1584 /* SIGCHLD - We dont "wait" for our cloned thread, so prevent it from
1579 * becoming a zombie. */ 1585 * becoming a zombie. */
1580 if (clone(io_thread, stack + 32768, CLONE_VM | SIGCHLD, dev) == -1) 1586 if (clone(io_thread, stack + 32768, CLONE_VM | SIGCHLD, dev) == -1)
1581 err(1, "Creating clone"); 1587 err(1, "Creating clone");
1582 1588
1583 /* We don't need to keep the I/O thread's end of the pipes open. */ 1589 /* We don't need to keep the I/O thread's end of the pipes open. */
@@ -1587,14 +1593,14 @@ static void setup_block_file(const char *filename)
1587 verbose("device %u: virtblock %llu sectors\n", 1593 verbose("device %u: virtblock %llu sectors\n",
1588 devices.device_num, le64_to_cpu(conf.capacity)); 1594 devices.device_num, le64_to_cpu(conf.capacity));
1589} 1595}
1590/* That's the end of device setup. :*/ 1596/* That's the end of device setup. */
1591 1597
1592/* Reboot */ 1598/*L:230 Reboot is pretty easy: clean up and exec() the Launcher afresh. */
1593static void __attribute__((noreturn)) restart_guest(void) 1599static void __attribute__((noreturn)) restart_guest(void)
1594{ 1600{
1595 unsigned int i; 1601 unsigned int i;
1596 1602
1597 /* Closing pipes causes the waker thread and io_threads to die, and 1603 /* Closing pipes causes the Waker thread and io_threads to die, and
1598 * closing /dev/lguest cleans up the Guest. Since we don't track all 1604 * closing /dev/lguest cleans up the Guest. Since we don't track all
1599 * open fds, we simply close everything beyond stderr. */ 1605 * open fds, we simply close everything beyond stderr. */
1600 for (i = 3; i < FD_SETSIZE; i++) 1606 for (i = 3; i < FD_SETSIZE; i++)
@@ -1603,7 +1609,7 @@ static void __attribute__((noreturn)) restart_guest(void)
1603 err(1, "Could not exec %s", main_args[0]); 1609 err(1, "Could not exec %s", main_args[0]);
1604} 1610}
1605 1611
1606/*L:220 Finally we reach the core of the Launcher, which runs the Guest, serves 1612/*L:220 Finally we reach the core of the Launcher which runs the Guest, serves
1607 * its input and output, and finally, lays it to rest. */ 1613 * its input and output, and finally, lays it to rest. */
1608static void __attribute__((noreturn)) run_guest(int lguest_fd) 1614static void __attribute__((noreturn)) run_guest(int lguest_fd)
1609{ 1615{
@@ -1644,7 +1650,7 @@ static void __attribute__((noreturn)) run_guest(int lguest_fd)
1644 err(1, "Resetting break"); 1650 err(1, "Resetting break");
1645 } 1651 }
1646} 1652}
1647/* 1653/*L:240
1648 * This is the end of the Launcher. The good news: we are over halfway 1654 * This is the end of the Launcher. The good news: we are over halfway
1649 * through! The bad news: the most fiendish part of the code still lies ahead 1655 * through! The bad news: the most fiendish part of the code still lies ahead
1650 * of us. 1656 * of us.
@@ -1691,8 +1697,8 @@ int main(int argc, char *argv[])
1691 * device receive input from a file descriptor, we keep an fdset 1697 * device receive input from a file descriptor, we keep an fdset
1692 * (infds) and the maximum fd number (max_infd) with the head of the 1698 * (infds) and the maximum fd number (max_infd) with the head of the
1693 * list. We also keep a pointer to the last device. Finally, we keep 1699 * list. We also keep a pointer to the last device. Finally, we keep
1694 * the next interrupt number to hand out (1: remember that 0 is used by 1700 * the next interrupt number to use for devices (1: remember that 0 is
1695 * the timer). */ 1701 * used by the timer). */
1696 FD_ZERO(&devices.infds); 1702 FD_ZERO(&devices.infds);
1697 devices.max_infd = -1; 1703 devices.max_infd = -1;
1698 devices.lastdev = NULL; 1704 devices.lastdev = NULL;
@@ -1793,8 +1799,8 @@ int main(int argc, char *argv[])
1793 lguest_fd = tell_kernel(pgdir, start); 1799 lguest_fd = tell_kernel(pgdir, start);
1794 1800
1795 /* We fork off a child process, which wakes the Launcher whenever one 1801 /* We fork off a child process, which wakes the Launcher whenever one
1796 * of the input file descriptors needs attention. Otherwise we would 1802 * of the input file descriptors needs attention. We call this the
1797 * run the Guest until it tries to output something. */ 1803 * Waker, and we'll cover it in a moment. */
1798 waker_fd = setup_waker(lguest_fd); 1804 waker_fd = setup_waker(lguest_fd);
1799 1805
1800 /* Finally, run the Guest. This doesn't return. */ 1806 /* Finally, run the Guest. This doesn't return. */
diff --git a/Documentation/lguest/lguest.txt b/Documentation/lguest/lguest.txt
index 722d4e7fbebe..29510dc51510 100644
--- a/Documentation/lguest/lguest.txt
+++ b/Documentation/lguest/lguest.txt
@@ -1,6 +1,7 @@
1Rusty's Remarkably Unreliable Guide to Lguest 1 __
2 - or, A Young Coder's Illustrated Hypervisor 2 (___()'`; Rusty's Remarkably Unreliable Guide to Lguest
3http://lguest.ozlabs.org 3 /, /` - or, A Young Coder's Illustrated Hypervisor
4 \\"--\\ http://lguest.ozlabs.org
4 5
5Lguest is designed to be a minimal hypervisor for the Linux kernel, for 6Lguest is designed to be a minimal hypervisor for the Linux kernel, for
6Linux developers and users to experiment with virtualization with the 7Linux developers and users to experiment with virtualization with the
@@ -41,12 +42,16 @@ Running Lguest:
41 CONFIG_PHYSICAL_ALIGN=0x100000) 42 CONFIG_PHYSICAL_ALIGN=0x100000)
42 43
43 "Device Drivers": 44 "Device Drivers":
45 "Block devices"
46 "Virtio block driver (EXPERIMENTAL)" = M/Y
44 "Network device support" 47 "Network device support"
45 "Universal TUN/TAP device driver support" = M/Y 48 "Universal TUN/TAP device driver support" = M/Y
46 (CONFIG_TUN=m) 49 "Virtio network driver (EXPERIMENTAL)" = M/Y
47 "Virtualization" 50 (CONFIG_VIRTIO_BLK=m, CONFIG_VIRTIO_NET=m and CONFIG_TUN=m)
48 "Linux hypervisor example code" = M/Y 51
49 (CONFIG_LGUEST=m) 52 "Virtualization"
53 "Linux hypervisor example code" = M/Y
54 (CONFIG_LGUEST=m)
50 55
51- A tool called "lguest" is available in this directory: type "make" 56- A tool called "lguest" is available in this directory: type "make"
52 to build it. If you didn't build your kernel in-tree, use "make 57 to build it. If you didn't build your kernel in-tree, use "make
diff --git a/MAINTAINERS b/MAINTAINERS
index f1ed75cef6a4..90dcbbcad91c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -163,6 +163,12 @@ M: A2232@gmx.net
163L: linux-m68k@lists.linux-m68k.org 163L: linux-m68k@lists.linux-m68k.org
164S: Maintained 164S: Maintained
165 165
166AFS FILESYSTEM & AF_RXRPC SOCKET DOMAIN
167P: David Howells
168M: dhowells@redhat.com
169L: linux-afs@lists.infradead.org
170S: Supported
171
166AIO 172AIO
167P: Benjamin LaHaise 173P: Benjamin LaHaise
168M: bcrl@kvack.org 174M: bcrl@kvack.org
@@ -2314,8 +2320,6 @@ L: kexec@lists.infradead.org
2314S: Maintained 2320S: Maintained
2315 2321
2316KPROBES 2322KPROBES
2317P: Prasanna S Panchamukhi
2318M: prasanna@in.ibm.com
2319P: Ananth N Mavinakayanahalli 2323P: Ananth N Mavinakayanahalli
2320M: ananth@in.ibm.com 2324M: ananth@in.ibm.com
2321P: Anil S Keshavamurthy 2325P: Anil S Keshavamurthy
diff --git a/arch/powerpc/configs/pasemi_defconfig b/arch/powerpc/configs/pasemi_defconfig
index 797f0dfebde2..09f306248f2e 100644
--- a/arch/powerpc/configs/pasemi_defconfig
+++ b/arch/powerpc/configs/pasemi_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.24-rc6 3# Linux kernel version: 2.6.25-rc6
4# Tue Jan 15 10:26:10 2008 4# Tue Mar 25 10:25:48 2008
5# 5#
6CONFIG_PPC64=y 6CONFIG_PPC64=y
7 7
@@ -27,6 +27,7 @@ CONFIG_GENERIC_TIME=y
27CONFIG_GENERIC_TIME_VSYSCALL=y 27CONFIG_GENERIC_TIME_VSYSCALL=y
28CONFIG_GENERIC_CLOCKEVENTS=y 28CONFIG_GENERIC_CLOCKEVENTS=y
29CONFIG_GENERIC_HARDIRQS=y 29CONFIG_GENERIC_HARDIRQS=y
30CONFIG_HAVE_SETUP_PER_CPU_AREA=y
30CONFIG_IRQ_PER_CPU=y 31CONFIG_IRQ_PER_CPU=y
31CONFIG_RWSEM_XCHGADD_ALGORITHM=y 32CONFIG_RWSEM_XCHGADD_ALGORITHM=y
32CONFIG_ARCH_HAS_ILOG2_U32=y 33CONFIG_ARCH_HAS_ILOG2_U32=y
@@ -67,17 +68,19 @@ CONFIG_SYSVIPC_SYSCTL=y
67# CONFIG_POSIX_MQUEUE is not set 68# CONFIG_POSIX_MQUEUE is not set
68# CONFIG_BSD_PROCESS_ACCT is not set 69# CONFIG_BSD_PROCESS_ACCT is not set
69# CONFIG_TASKSTATS is not set 70# CONFIG_TASKSTATS is not set
70# CONFIG_USER_NS is not set
71# CONFIG_PID_NS is not set
72# CONFIG_AUDIT is not set 71# CONFIG_AUDIT is not set
73# CONFIG_IKCONFIG is not set 72# CONFIG_IKCONFIG is not set
74CONFIG_LOG_BUF_SHIFT=17 73CONFIG_LOG_BUF_SHIFT=17
75# CONFIG_CGROUPS is not set 74# CONFIG_CGROUPS is not set
76CONFIG_FAIR_GROUP_SCHED=y 75# CONFIG_GROUP_SCHED is not set
77CONFIG_FAIR_USER_SCHED=y
78# CONFIG_FAIR_CGROUP_SCHED is not set
79CONFIG_SYSFS_DEPRECATED=y 76CONFIG_SYSFS_DEPRECATED=y
77CONFIG_SYSFS_DEPRECATED_V2=y
80# CONFIG_RELAY is not set 78# CONFIG_RELAY is not set
79CONFIG_NAMESPACES=y
80# CONFIG_UTS_NS is not set
81# CONFIG_IPC_NS is not set
82# CONFIG_USER_NS is not set
83# CONFIG_PID_NS is not set
81CONFIG_BLK_DEV_INITRD=y 84CONFIG_BLK_DEV_INITRD=y
82CONFIG_INITRAMFS_SOURCE="" 85CONFIG_INITRAMFS_SOURCE=""
83# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 86# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
@@ -91,11 +94,13 @@ CONFIG_HOTPLUG=y
91CONFIG_PRINTK=y 94CONFIG_PRINTK=y
92CONFIG_BUG=y 95CONFIG_BUG=y
93CONFIG_ELF_CORE=y 96CONFIG_ELF_CORE=y
97CONFIG_COMPAT_BRK=y
94CONFIG_BASE_FULL=y 98CONFIG_BASE_FULL=y
95CONFIG_FUTEX=y 99CONFIG_FUTEX=y
96CONFIG_ANON_INODES=y 100CONFIG_ANON_INODES=y
97CONFIG_EPOLL=y 101CONFIG_EPOLL=y
98CONFIG_SIGNALFD=y 102CONFIG_SIGNALFD=y
103CONFIG_TIMERFD=y
99CONFIG_EVENTFD=y 104CONFIG_EVENTFD=y
100CONFIG_SHMEM=y 105CONFIG_SHMEM=y
101CONFIG_VM_EVENT_COUNTERS=y 106CONFIG_VM_EVENT_COUNTERS=y
@@ -103,6 +108,15 @@ CONFIG_SLUB_DEBUG=y
103# CONFIG_SLAB is not set 108# CONFIG_SLAB is not set
104CONFIG_SLUB=y 109CONFIG_SLUB=y
105# CONFIG_SLOB is not set 110# CONFIG_SLOB is not set
111CONFIG_PROFILING=y
112# CONFIG_MARKERS is not set
113CONFIG_OPROFILE=y
114CONFIG_HAVE_OPROFILE=y
115# CONFIG_KPROBES is not set
116CONFIG_HAVE_KPROBES=y
117CONFIG_HAVE_KRETPROBES=y
118CONFIG_PROC_PAGE_MONITOR=y
119CONFIG_SLABINFO=y
106CONFIG_RT_MUTEXES=y 120CONFIG_RT_MUTEXES=y
107# CONFIG_TINY_SHMEM is not set 121# CONFIG_TINY_SHMEM is not set
108CONFIG_BASE_SMALL=0 122CONFIG_BASE_SMALL=0
@@ -130,6 +144,7 @@ CONFIG_DEFAULT_AS=y
130# CONFIG_DEFAULT_CFQ is not set 144# CONFIG_DEFAULT_CFQ is not set
131# CONFIG_DEFAULT_NOOP is not set 145# CONFIG_DEFAULT_NOOP is not set
132CONFIG_DEFAULT_IOSCHED="anticipatory" 146CONFIG_DEFAULT_IOSCHED="anticipatory"
147CONFIG_CLASSIC_RCU=y
133 148
134# 149#
135# Platform support 150# Platform support
@@ -140,8 +155,8 @@ CONFIG_PPC_MULTIPLATFORM=y
140# CONFIG_PPC_86xx is not set 155# CONFIG_PPC_86xx is not set
141# CONFIG_PPC_PSERIES is not set 156# CONFIG_PPC_PSERIES is not set
142# CONFIG_PPC_ISERIES is not set 157# CONFIG_PPC_ISERIES is not set
143# CONFIG_PPC_MPC52xx is not set 158# CONFIG_PPC_MPC512x is not set
144# CONFIG_PPC_MPC5200 is not set 159# CONFIG_PPC_MPC5121 is not set
145# CONFIG_PPC_PMAC is not set 160# CONFIG_PPC_PMAC is not set
146# CONFIG_PPC_MAPLE is not set 161# CONFIG_PPC_MAPLE is not set
147CONFIG_PPC_PASEMI=y 162CONFIG_PPC_PASEMI=y
@@ -159,6 +174,7 @@ CONFIG_PPC_PASEMI_MDIO=y
159# CONFIG_PPC_IBM_CELL_BLADE is not set 174# CONFIG_PPC_IBM_CELL_BLADE is not set
160# CONFIG_PQ2ADS is not set 175# CONFIG_PQ2ADS is not set
161CONFIG_PPC_NATIVE=y 176CONFIG_PPC_NATIVE=y
177# CONFIG_IPIC is not set
162CONFIG_MPIC=y 178CONFIG_MPIC=y
163# CONFIG_MPIC_WEIRD is not set 179# CONFIG_MPIC_WEIRD is not set
164# CONFIG_PPC_I8259 is not set 180# CONFIG_PPC_I8259 is not set
@@ -189,7 +205,6 @@ CONFIG_CPU_FREQ_GOV_ONDEMAND=y
189# CPU Frequency drivers 205# CPU Frequency drivers
190# 206#
191CONFIG_PPC_PASEMI_CPUFREQ=y 207CONFIG_PPC_PASEMI_CPUFREQ=y
192# CONFIG_CPM2 is not set
193# CONFIG_FSL_ULI1575 is not set 208# CONFIG_FSL_ULI1575 is not set
194 209
195# 210#
@@ -204,16 +219,20 @@ CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
204# CONFIG_HZ_300 is not set 219# CONFIG_HZ_300 is not set
205CONFIG_HZ_1000=y 220CONFIG_HZ_1000=y
206CONFIG_HZ=1000 221CONFIG_HZ=1000
222# CONFIG_SCHED_HRTICK is not set
207CONFIG_PREEMPT_NONE=y 223CONFIG_PREEMPT_NONE=y
208# CONFIG_PREEMPT_VOLUNTARY is not set 224# CONFIG_PREEMPT_VOLUNTARY is not set
209# CONFIG_PREEMPT is not set 225# CONFIG_PREEMPT is not set
210# CONFIG_PREEMPT_BKL is not set
211CONFIG_BINFMT_ELF=y 226CONFIG_BINFMT_ELF=y
227CONFIG_COMPAT_BINFMT_ELF=y
212# CONFIG_BINFMT_MISC is not set 228# CONFIG_BINFMT_MISC is not set
213CONFIG_FORCE_MAX_ZONEORDER=9 229CONFIG_FORCE_MAX_ZONEORDER=9
214CONFIG_HUGETLB_PAGE_SIZE_VARIABLE=y 230CONFIG_HUGETLB_PAGE_SIZE_VARIABLE=y
215CONFIG_IOMMU_VMERGE=y 231CONFIG_IOMMU_VMERGE=y
232CONFIG_IOMMU_HELPER=y
216CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y 233CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
234CONFIG_ARCH_HAS_WALK_MEMORY=y
235CONFIG_ARCH_ENABLE_MEMORY_HOTREMOVE=y
217# CONFIG_KEXEC is not set 236# CONFIG_KEXEC is not set
218# CONFIG_CRASH_DUMP is not set 237# CONFIG_CRASH_DUMP is not set
219# CONFIG_IRQ_ALL_CPUS is not set 238# CONFIG_IRQ_ALL_CPUS is not set
@@ -236,12 +255,12 @@ CONFIG_ZONE_DMA_FLAG=1
236CONFIG_BOUNCE=y 255CONFIG_BOUNCE=y
237CONFIG_PPC_HAS_HASH_64K=y 256CONFIG_PPC_HAS_HASH_64K=y
238CONFIG_PPC_64K_PAGES=y 257CONFIG_PPC_64K_PAGES=y
258# CONFIG_PPC_SUBPAGE_PROT is not set
239# CONFIG_SCHED_SMT is not set 259# CONFIG_SCHED_SMT is not set
240CONFIG_PROC_DEVICETREE=y 260CONFIG_PROC_DEVICETREE=y
241# CONFIG_CMDLINE_BOOL is not set 261# CONFIG_CMDLINE_BOOL is not set
242# CONFIG_PM is not set 262# CONFIG_PM is not set
243# CONFIG_SECCOMP is not set 263# CONFIG_SECCOMP is not set
244# CONFIG_WANT_DEVICE_TREE is not set
245CONFIG_ISA_DMA_API=y 264CONFIG_ISA_DMA_API=y
246 265
247# 266#
@@ -290,6 +309,7 @@ CONFIG_XFRM=y
290CONFIG_XFRM_USER=y 309CONFIG_XFRM_USER=y
291# CONFIG_XFRM_SUB_POLICY is not set 310# CONFIG_XFRM_SUB_POLICY is not set
292# CONFIG_XFRM_MIGRATE is not set 311# CONFIG_XFRM_MIGRATE is not set
312# CONFIG_XFRM_STATISTICS is not set
293CONFIG_NET_KEY=y 313CONFIG_NET_KEY=y
294# CONFIG_NET_KEY_MIGRATE is not set 314# CONFIG_NET_KEY_MIGRATE is not set
295CONFIG_INET=y 315CONFIG_INET=y
@@ -346,6 +366,7 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
346# 366#
347# CONFIG_NET_PKTGEN is not set 367# CONFIG_NET_PKTGEN is not set
348# CONFIG_HAMRADIO is not set 368# CONFIG_HAMRADIO is not set
369# CONFIG_CAN is not set
349# CONFIG_IRDA is not set 370# CONFIG_IRDA is not set
350# CONFIG_BT is not set 371# CONFIG_BT is not set
351# CONFIG_AF_RXRPC is not set 372# CONFIG_AF_RXRPC is not set
@@ -441,8 +462,10 @@ CONFIG_MTD_NAND=y
441CONFIG_MTD_NAND_IDS=y 462CONFIG_MTD_NAND_IDS=y
442# CONFIG_MTD_NAND_DISKONCHIP is not set 463# CONFIG_MTD_NAND_DISKONCHIP is not set
443# CONFIG_MTD_NAND_CAFE is not set 464# CONFIG_MTD_NAND_CAFE is not set
465CONFIG_MTD_NAND_PASEMI=y
444# CONFIG_MTD_NAND_PLATFORM is not set 466# CONFIG_MTD_NAND_PLATFORM is not set
445# CONFIG_MTD_ALAUDA is not set 467# CONFIG_MTD_ALAUDA is not set
468# CONFIG_MTD_NAND_FSL_ELBC is not set
446# CONFIG_MTD_ONENAND is not set 469# CONFIG_MTD_ONENAND is not set
447 470
448# 471#
@@ -465,7 +488,7 @@ CONFIG_BLK_DEV_LOOP=y
465CONFIG_BLK_DEV_RAM=y 488CONFIG_BLK_DEV_RAM=y
466CONFIG_BLK_DEV_RAM_COUNT=16 489CONFIG_BLK_DEV_RAM_COUNT=16
467CONFIG_BLK_DEV_RAM_SIZE=16384 490CONFIG_BLK_DEV_RAM_SIZE=16384
468CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024 491# CONFIG_BLK_DEV_XIP is not set
469# CONFIG_CDROM_PKTCDVD is not set 492# CONFIG_CDROM_PKTCDVD is not set
470# CONFIG_ATA_OVER_ETH is not set 493# CONFIG_ATA_OVER_ETH is not set
471CONFIG_MISC_DEVICES=y 494CONFIG_MISC_DEVICES=y
@@ -473,11 +496,13 @@ CONFIG_MISC_DEVICES=y
473# CONFIG_EEPROM_93CX6 is not set 496# CONFIG_EEPROM_93CX6 is not set
474# CONFIG_SGI_IOC4 is not set 497# CONFIG_SGI_IOC4 is not set
475# CONFIG_TIFM_CORE is not set 498# CONFIG_TIFM_CORE is not set
499# CONFIG_ENCLOSURE_SERVICES is not set
500CONFIG_HAVE_IDE=y
476CONFIG_IDE=y 501CONFIG_IDE=y
477CONFIG_BLK_DEV_IDE=y 502CONFIG_BLK_DEV_IDE=y
478 503
479# 504#
480# Please see Documentation/ide.txt for help/info on IDE drives 505# Please see Documentation/ide/ide.txt for help/info on IDE drives
481# 506#
482# CONFIG_BLK_DEV_IDE_SATA is not set 507# CONFIG_BLK_DEV_IDE_SATA is not set
483CONFIG_BLK_DEV_IDEDISK=y 508CONFIG_BLK_DEV_IDEDISK=y
@@ -485,6 +510,7 @@ CONFIG_IDEDISK_MULTI_MODE=y
485# CONFIG_BLK_DEV_IDECS is not set 510# CONFIG_BLK_DEV_IDECS is not set
486# CONFIG_BLK_DEV_DELKIN is not set 511# CONFIG_BLK_DEV_DELKIN is not set
487CONFIG_BLK_DEV_IDECD=y 512CONFIG_BLK_DEV_IDECD=y
513CONFIG_BLK_DEV_IDECD_VERBOSE_ERRORS=y
488# CONFIG_BLK_DEV_IDETAPE is not set 514# CONFIG_BLK_DEV_IDETAPE is not set
489# CONFIG_BLK_DEV_IDEFLOPPY is not set 515# CONFIG_BLK_DEV_IDEFLOPPY is not set
490CONFIG_BLK_DEV_IDESCSI=y 516CONFIG_BLK_DEV_IDESCSI=y
@@ -500,7 +526,6 @@ CONFIG_IDE_PROC_FS=y
500# 526#
501# PCI IDE chipsets support 527# PCI IDE chipsets support
502# 528#
503# CONFIG_IDEPCI_PCIBUS_ORDER is not set
504# CONFIG_BLK_DEV_GENERIC is not set 529# CONFIG_BLK_DEV_GENERIC is not set
505# CONFIG_BLK_DEV_OPTI621 is not set 530# CONFIG_BLK_DEV_OPTI621 is not set
506# CONFIG_BLK_DEV_AEC62XX is not set 531# CONFIG_BLK_DEV_AEC62XX is not set
@@ -528,7 +553,6 @@ CONFIG_IDE_PROC_FS=y
528# CONFIG_BLK_DEV_TRM290 is not set 553# CONFIG_BLK_DEV_TRM290 is not set
529# CONFIG_BLK_DEV_VIA82CXXX is not set 554# CONFIG_BLK_DEV_VIA82CXXX is not set
530# CONFIG_BLK_DEV_TC86C001 is not set 555# CONFIG_BLK_DEV_TC86C001 is not set
531# CONFIG_IDE_ARM is not set
532# CONFIG_BLK_DEV_IDEDMA is not set 556# CONFIG_BLK_DEV_IDEDMA is not set
533CONFIG_IDE_ARCH_OBSOLETE_INIT=y 557CONFIG_IDE_ARCH_OBSOLETE_INIT=y
534# CONFIG_BLK_DEV_HD is not set 558# CONFIG_BLK_DEV_HD is not set
@@ -593,6 +617,7 @@ CONFIG_SCSI_LOWLEVEL=y
593# CONFIG_SCSI_IPS is not set 617# CONFIG_SCSI_IPS is not set
594# CONFIG_SCSI_INITIO is not set 618# CONFIG_SCSI_INITIO is not set
595# CONFIG_SCSI_INIA100 is not set 619# CONFIG_SCSI_INIA100 is not set
620# CONFIG_SCSI_MVSAS is not set
596# CONFIG_SCSI_STEX is not set 621# CONFIG_SCSI_STEX is not set
597# CONFIG_SCSI_SYM53C8XX_2 is not set 622# CONFIG_SCSI_SYM53C8XX_2 is not set
598# CONFIG_SCSI_IPR is not set 623# CONFIG_SCSI_IPR is not set
@@ -646,6 +671,7 @@ CONFIG_ATA_GENERIC=y
646# CONFIG_PATA_MPIIX is not set 671# CONFIG_PATA_MPIIX is not set
647# CONFIG_PATA_OLDPIIX is not set 672# CONFIG_PATA_OLDPIIX is not set
648# CONFIG_PATA_NETCELL is not set 673# CONFIG_PATA_NETCELL is not set
674# CONFIG_PATA_NINJA32 is not set
649# CONFIG_PATA_NS87410 is not set 675# CONFIG_PATA_NS87410 is not set
650# CONFIG_PATA_NS87415 is not set 676# CONFIG_PATA_NS87415 is not set
651# CONFIG_PATA_OPTI is not set 677# CONFIG_PATA_OPTI is not set
@@ -699,7 +725,6 @@ CONFIG_DUMMY=y
699# CONFIG_EQUALIZER is not set 725# CONFIG_EQUALIZER is not set
700# CONFIG_TUN is not set 726# CONFIG_TUN is not set
701# CONFIG_VETH is not set 727# CONFIG_VETH is not set
702# CONFIG_IP1000 is not set
703# CONFIG_ARCNET is not set 728# CONFIG_ARCNET is not set
704CONFIG_PHYLIB=y 729CONFIG_PHYLIB=y
705 730
@@ -715,6 +740,7 @@ CONFIG_MARVELL_PHY=y
715# CONFIG_SMSC_PHY is not set 740# CONFIG_SMSC_PHY is not set
716# CONFIG_BROADCOM_PHY is not set 741# CONFIG_BROADCOM_PHY is not set
717# CONFIG_ICPLUS_PHY is not set 742# CONFIG_ICPLUS_PHY is not set
743# CONFIG_REALTEK_PHY is not set
718# CONFIG_FIXED_PHY is not set 744# CONFIG_FIXED_PHY is not set
719# CONFIG_MDIO_BITBANG is not set 745# CONFIG_MDIO_BITBANG is not set
720CONFIG_NET_ETHERNET=y 746CONFIG_NET_ETHERNET=y
@@ -742,6 +768,7 @@ CONFIG_NET_PCI=y
742# CONFIG_NE2K_PCI is not set 768# CONFIG_NE2K_PCI is not set
743# CONFIG_8139CP is not set 769# CONFIG_8139CP is not set
744# CONFIG_8139TOO is not set 770# CONFIG_8139TOO is not set
771# CONFIG_R6040 is not set
745# CONFIG_SIS900 is not set 772# CONFIG_SIS900 is not set
746# CONFIG_EPIC100 is not set 773# CONFIG_EPIC100 is not set
747# CONFIG_SUNDANCE is not set 774# CONFIG_SUNDANCE is not set
@@ -754,6 +781,9 @@ CONFIG_E1000=y
754CONFIG_E1000_NAPI=y 781CONFIG_E1000_NAPI=y
755# CONFIG_E1000_DISABLE_PACKET_SPLIT is not set 782# CONFIG_E1000_DISABLE_PACKET_SPLIT is not set
756# CONFIG_E1000E is not set 783# CONFIG_E1000E is not set
784# CONFIG_E1000E_ENABLED is not set
785# CONFIG_IP1000 is not set
786# CONFIG_IGB is not set
757# CONFIG_NS83820 is not set 787# CONFIG_NS83820 is not set
758# CONFIG_HAMACHI is not set 788# CONFIG_HAMACHI is not set
759# CONFIG_YELLOWFIN is not set 789# CONFIG_YELLOWFIN is not set
@@ -779,6 +809,7 @@ CONFIG_NETDEV_10000=y
779CONFIG_PASEMI_MAC=y 809CONFIG_PASEMI_MAC=y
780# CONFIG_MLX4_CORE is not set 810# CONFIG_MLX4_CORE is not set
781# CONFIG_TEHUTI is not set 811# CONFIG_TEHUTI is not set
812# CONFIG_BNX2X is not set
782# CONFIG_TR is not set 813# CONFIG_TR is not set
783 814
784# 815#
@@ -802,7 +833,6 @@ CONFIG_PASEMI_MAC=y
802# CONFIG_PPP is not set 833# CONFIG_PPP is not set
803# CONFIG_SLIP is not set 834# CONFIG_SLIP is not set
804# CONFIG_NET_FC is not set 835# CONFIG_NET_FC is not set
805# CONFIG_SHAPER is not set
806# CONFIG_NETCONSOLE is not set 836# CONFIG_NETCONSOLE is not set
807# CONFIG_NETPOLL is not set 837# CONFIG_NETPOLL is not set
808# CONFIG_NET_POLL_CONTROLLER is not set 838# CONFIG_NET_POLL_CONTROLLER is not set
@@ -861,6 +891,7 @@ CONFIG_VT_CONSOLE=y
861CONFIG_HW_CONSOLE=y 891CONFIG_HW_CONSOLE=y
862# CONFIG_VT_HW_CONSOLE_BINDING is not set 892# CONFIG_VT_HW_CONSOLE_BINDING is not set
863# CONFIG_SERIAL_NONSTANDARD is not set 893# CONFIG_SERIAL_NONSTANDARD is not set
894# CONFIG_NOZOMI is not set
864 895
865# 896#
866# Serial drivers 897# Serial drivers
@@ -886,8 +917,7 @@ CONFIG_LEGACY_PTY_COUNT=4
886# CONFIG_IPMI_HANDLER is not set 917# CONFIG_IPMI_HANDLER is not set
887CONFIG_HW_RANDOM=y 918CONFIG_HW_RANDOM=y
888CONFIG_HW_RANDOM_PASEMI=y 919CONFIG_HW_RANDOM_PASEMI=y
889CONFIG_GEN_RTC=y 920# CONFIG_GEN_RTC is not set
890CONFIG_GEN_RTC_X=y
891# CONFIG_R3964 is not set 921# CONFIG_R3964 is not set
892# CONFIG_APPLICOM is not set 922# CONFIG_APPLICOM is not set
893 923
@@ -897,6 +927,7 @@ CONFIG_GEN_RTC_X=y
897# CONFIG_SYNCLINK_CS is not set 927# CONFIG_SYNCLINK_CS is not set
898# CONFIG_CARDMAN_4000 is not set 928# CONFIG_CARDMAN_4000 is not set
899# CONFIG_CARDMAN_4040 is not set 929# CONFIG_CARDMAN_4040 is not set
930# CONFIG_IPWIRELESS is not set
900CONFIG_RAW_DRIVER=y 931CONFIG_RAW_DRIVER=y
901CONFIG_MAX_RAW_DEVS=256 932CONFIG_MAX_RAW_DEVS=256
902# CONFIG_HANGCHECK_TIMER is not set 933# CONFIG_HANGCHECK_TIMER is not set
@@ -944,13 +975,12 @@ CONFIG_I2C_PASEMI=y
944# 975#
945# Miscellaneous I2C Chip support 976# Miscellaneous I2C Chip support
946# 977#
947# CONFIG_SENSORS_DS1337 is not set
948# CONFIG_SENSORS_DS1374 is not set
949# CONFIG_DS1682 is not set 978# CONFIG_DS1682 is not set
950CONFIG_SENSORS_EEPROM=y 979CONFIG_SENSORS_EEPROM=y
951# CONFIG_SENSORS_PCF8574 is not set 980# CONFIG_SENSORS_PCF8574 is not set
952# CONFIG_SENSORS_PCA9539 is not set 981# CONFIG_PCF8575 is not set
953# CONFIG_SENSORS_PCF8591 is not set 982# CONFIG_SENSORS_PCF8591 is not set
983# CONFIG_TPS65010 is not set
954# CONFIG_SENSORS_MAX6875 is not set 984# CONFIG_SENSORS_MAX6875 is not set
955# CONFIG_SENSORS_TSL2550 is not set 985# CONFIG_SENSORS_TSL2550 is not set
956# CONFIG_I2C_DEBUG_CORE is not set 986# CONFIG_I2C_DEBUG_CORE is not set
@@ -975,6 +1005,7 @@ CONFIG_HWMON_VID=y
975# CONFIG_SENSORS_ADM1031 is not set 1005# CONFIG_SENSORS_ADM1031 is not set
976# CONFIG_SENSORS_ADM9240 is not set 1006# CONFIG_SENSORS_ADM9240 is not set
977# CONFIG_SENSORS_ADT7470 is not set 1007# CONFIG_SENSORS_ADT7470 is not set
1008# CONFIG_SENSORS_ADT7473 is not set
978# CONFIG_SENSORS_ATXP1 is not set 1009# CONFIG_SENSORS_ATXP1 is not set
979# CONFIG_SENSORS_DS1621 is not set 1010# CONFIG_SENSORS_DS1621 is not set
980# CONFIG_SENSORS_I5K_AMB is not set 1011# CONFIG_SENSORS_I5K_AMB is not set
@@ -1004,6 +1035,7 @@ CONFIG_SENSORS_LM90=y
1004# CONFIG_SENSORS_SMSC47M1 is not set 1035# CONFIG_SENSORS_SMSC47M1 is not set
1005# CONFIG_SENSORS_SMSC47M192 is not set 1036# CONFIG_SENSORS_SMSC47M192 is not set
1006# CONFIG_SENSORS_SMSC47B397 is not set 1037# CONFIG_SENSORS_SMSC47B397 is not set
1038# CONFIG_SENSORS_ADS7828 is not set
1007# CONFIG_SENSORS_THMC50 is not set 1039# CONFIG_SENSORS_THMC50 is not set
1008# CONFIG_SENSORS_VIA686A is not set 1040# CONFIG_SENSORS_VIA686A is not set
1009# CONFIG_SENSORS_VT1211 is not set 1041# CONFIG_SENSORS_VT1211 is not set
@@ -1013,9 +1045,11 @@ CONFIG_SENSORS_LM90=y
1013# CONFIG_SENSORS_W83792D is not set 1045# CONFIG_SENSORS_W83792D is not set
1014# CONFIG_SENSORS_W83793 is not set 1046# CONFIG_SENSORS_W83793 is not set
1015# CONFIG_SENSORS_W83L785TS is not set 1047# CONFIG_SENSORS_W83L785TS is not set
1048# CONFIG_SENSORS_W83L786NG is not set
1016# CONFIG_SENSORS_W83627HF is not set 1049# CONFIG_SENSORS_W83627HF is not set
1017# CONFIG_SENSORS_W83627EHF is not set 1050# CONFIG_SENSORS_W83627EHF is not set
1018# CONFIG_HWMON_DEBUG_CHIP is not set 1051# CONFIG_HWMON_DEBUG_CHIP is not set
1052# CONFIG_THERMAL is not set
1019# CONFIG_WATCHDOG is not set 1053# CONFIG_WATCHDOG is not set
1020 1054
1021# 1055#
@@ -1183,6 +1217,7 @@ CONFIG_SND_VERBOSE_PROCFS=y
1183# CONFIG_SND_BT87X is not set 1217# CONFIG_SND_BT87X is not set
1184# CONFIG_SND_CA0106 is not set 1218# CONFIG_SND_CA0106 is not set
1185# CONFIG_SND_CMIPCI is not set 1219# CONFIG_SND_CMIPCI is not set
1220# CONFIG_SND_OXYGEN is not set
1186# CONFIG_SND_CS4281 is not set 1221# CONFIG_SND_CS4281 is not set
1187# CONFIG_SND_CS46XX is not set 1222# CONFIG_SND_CS46XX is not set
1188# CONFIG_SND_CS5530 is not set 1223# CONFIG_SND_CS5530 is not set
@@ -1208,6 +1243,7 @@ CONFIG_SND_VERBOSE_PROCFS=y
1208# CONFIG_SND_HDA_INTEL is not set 1243# CONFIG_SND_HDA_INTEL is not set
1209# CONFIG_SND_HDSP is not set 1244# CONFIG_SND_HDSP is not set
1210# CONFIG_SND_HDSPM is not set 1245# CONFIG_SND_HDSPM is not set
1246# CONFIG_SND_HIFIER is not set
1211# CONFIG_SND_ICE1712 is not set 1247# CONFIG_SND_ICE1712 is not set
1212# CONFIG_SND_ICE1724 is not set 1248# CONFIG_SND_ICE1724 is not set
1213# CONFIG_SND_INTEL8X0 is not set 1249# CONFIG_SND_INTEL8X0 is not set
@@ -1225,6 +1261,7 @@ CONFIG_SND_VERBOSE_PROCFS=y
1225# CONFIG_SND_TRIDENT is not set 1261# CONFIG_SND_TRIDENT is not set
1226# CONFIG_SND_VIA82XX is not set 1262# CONFIG_SND_VIA82XX is not set
1227# CONFIG_SND_VIA82XX_MODEM is not set 1263# CONFIG_SND_VIA82XX_MODEM is not set
1264# CONFIG_SND_VIRTUOSO is not set
1228# CONFIG_SND_VX222 is not set 1265# CONFIG_SND_VX222 is not set
1229# CONFIG_SND_YMFPCI is not set 1266# CONFIG_SND_YMFPCI is not set
1230 1267
@@ -1259,6 +1296,10 @@ CONFIG_SND_USB_USX2Y=y
1259# 1296#
1260 1297
1261# 1298#
1299# ALSA SoC audio for Freescale SOCs
1300#
1301
1302#
1262# Open Sound System 1303# Open Sound System
1263# 1304#
1264# CONFIG_SOUND_PRIME is not set 1305# CONFIG_SOUND_PRIME is not set
@@ -1280,6 +1321,7 @@ CONFIG_USB_ARCH_HAS_OHCI=y
1280CONFIG_USB_ARCH_HAS_EHCI=y 1321CONFIG_USB_ARCH_HAS_EHCI=y
1281CONFIG_USB=y 1322CONFIG_USB=y
1282# CONFIG_USB_DEBUG is not set 1323# CONFIG_USB_DEBUG is not set
1324# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set
1283 1325
1284# 1326#
1285# Miscellaneous USB options 1327# Miscellaneous USB options
@@ -1293,17 +1335,14 @@ CONFIG_USB_DEVICEFS=y
1293# USB Host Controller Drivers 1335# USB Host Controller Drivers
1294# 1336#
1295CONFIG_USB_EHCI_HCD=y 1337CONFIG_USB_EHCI_HCD=y
1296# CONFIG_USB_EHCI_SPLIT_ISO is not set
1297# CONFIG_USB_EHCI_ROOT_HUB_TT is not set 1338# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
1298# CONFIG_USB_EHCI_TT_NEWSCHED is not set 1339# CONFIG_USB_EHCI_TT_NEWSCHED is not set
1340CONFIG_USB_EHCI_HCD_PPC_OF=y
1299# CONFIG_USB_ISP116X_HCD is not set 1341# CONFIG_USB_ISP116X_HCD is not set
1300CONFIG_USB_OHCI_HCD=y 1342CONFIG_USB_OHCI_HCD=y
1301CONFIG_USB_OHCI_HCD_PPC_OF=y 1343# CONFIG_USB_OHCI_HCD_PPC_OF is not set
1302CONFIG_USB_OHCI_HCD_PPC_OF_BE=y 1344# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
1303# CONFIG_USB_OHCI_HCD_PPC_OF_LE is not set 1345# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
1304CONFIG_USB_OHCI_HCD_PCI=y
1305CONFIG_USB_OHCI_BIG_ENDIAN_DESC=y
1306CONFIG_USB_OHCI_BIG_ENDIAN_MMIO=y
1307CONFIG_USB_OHCI_LITTLE_ENDIAN=y 1346CONFIG_USB_OHCI_LITTLE_ENDIAN=y
1308CONFIG_USB_UHCI_HCD=y 1347CONFIG_USB_UHCI_HCD=y
1309CONFIG_USB_SL811_HCD=y 1348CONFIG_USB_SL811_HCD=y
@@ -1348,10 +1387,6 @@ CONFIG_USB_LIBUSUAL=y
1348# 1387#
1349# USB port drivers 1388# USB port drivers
1350# 1389#
1351
1352#
1353# USB Serial Converter support
1354#
1355# CONFIG_USB_SERIAL is not set 1390# CONFIG_USB_SERIAL is not set
1356 1391
1357# 1392#
@@ -1377,16 +1412,9 @@ CONFIG_USB_LIBUSUAL=y
1377# CONFIG_USB_TRANCEVIBRATOR is not set 1412# CONFIG_USB_TRANCEVIBRATOR is not set
1378# CONFIG_USB_IOWARRIOR is not set 1413# CONFIG_USB_IOWARRIOR is not set
1379# CONFIG_USB_TEST is not set 1414# CONFIG_USB_TEST is not set
1380
1381#
1382# USB DSL modem support
1383#
1384
1385#
1386# USB Gadget Support
1387#
1388# CONFIG_USB_GADGET is not set 1415# CONFIG_USB_GADGET is not set
1389# CONFIG_MMC is not set 1416# CONFIG_MMC is not set
1417# CONFIG_MEMSTICK is not set
1390# CONFIG_NEW_LEDS is not set 1418# CONFIG_NEW_LEDS is not set
1391# CONFIG_INFINIBAND is not set 1419# CONFIG_INFINIBAND is not set
1392CONFIG_EDAC=y 1420CONFIG_EDAC=y
@@ -1425,6 +1453,7 @@ CONFIG_RTC_DRV_DS1307=y
1425# CONFIG_RTC_DRV_PCF8563 is not set 1453# CONFIG_RTC_DRV_PCF8563 is not set
1426# CONFIG_RTC_DRV_PCF8583 is not set 1454# CONFIG_RTC_DRV_PCF8583 is not set
1427# CONFIG_RTC_DRV_M41T80 is not set 1455# CONFIG_RTC_DRV_M41T80 is not set
1456# CONFIG_RTC_DRV_S35390A is not set
1428 1457
1429# 1458#
1430# SPI RTC drivers 1459# SPI RTC drivers
@@ -1434,9 +1463,10 @@ CONFIG_RTC_DRV_DS1307=y
1434# Platform RTC drivers 1463# Platform RTC drivers
1435# 1464#
1436# CONFIG_RTC_DRV_CMOS is not set 1465# CONFIG_RTC_DRV_CMOS is not set
1466# CONFIG_RTC_DRV_DS1511 is not set
1437# CONFIG_RTC_DRV_DS1553 is not set 1467# CONFIG_RTC_DRV_DS1553 is not set
1438# CONFIG_RTC_DRV_STK17TA8 is not set
1439# CONFIG_RTC_DRV_DS1742 is not set 1468# CONFIG_RTC_DRV_DS1742 is not set
1469# CONFIG_RTC_DRV_STK17TA8 is not set
1440# CONFIG_RTC_DRV_M48T86 is not set 1470# CONFIG_RTC_DRV_M48T86 is not set
1441# CONFIG_RTC_DRV_M48T59 is not set 1471# CONFIG_RTC_DRV_M48T59 is not set
1442# CONFIG_RTC_DRV_V3020 is not set 1472# CONFIG_RTC_DRV_V3020 is not set
@@ -1444,6 +1474,7 @@ CONFIG_RTC_DRV_DS1307=y
1444# 1474#
1445# on-CPU RTC drivers 1475# on-CPU RTC drivers
1446# 1476#
1477# CONFIG_DMADEVICES is not set
1447 1478
1448# 1479#
1449# Userspace I/O 1480# Userspace I/O
@@ -1471,12 +1502,10 @@ CONFIG_FS_POSIX_ACL=y
1471# CONFIG_XFS_FS is not set 1502# CONFIG_XFS_FS is not set
1472# CONFIG_GFS2_FS is not set 1503# CONFIG_GFS2_FS is not set
1473# CONFIG_OCFS2_FS is not set 1504# CONFIG_OCFS2_FS is not set
1474# CONFIG_MINIX_FS is not set 1505CONFIG_DNOTIFY=y
1475# CONFIG_ROMFS_FS is not set
1476CONFIG_INOTIFY=y 1506CONFIG_INOTIFY=y
1477CONFIG_INOTIFY_USER=y 1507CONFIG_INOTIFY_USER=y
1478# CONFIG_QUOTA is not set 1508# CONFIG_QUOTA is not set
1479CONFIG_DNOTIFY=y
1480CONFIG_AUTOFS_FS=y 1509CONFIG_AUTOFS_FS=y
1481CONFIG_AUTOFS4_FS=y 1510CONFIG_AUTOFS4_FS=y
1482# CONFIG_FUSE_FS is not set 1511# CONFIG_FUSE_FS is not set
@@ -1536,8 +1565,10 @@ CONFIG_JFFS2_RTIME=y
1536# CONFIG_JFFS2_RUBIN is not set 1565# CONFIG_JFFS2_RUBIN is not set
1537# CONFIG_CRAMFS is not set 1566# CONFIG_CRAMFS is not set
1538# CONFIG_VXFS_FS is not set 1567# CONFIG_VXFS_FS is not set
1568# CONFIG_MINIX_FS is not set
1539# CONFIG_HPFS_FS is not set 1569# CONFIG_HPFS_FS is not set
1540# CONFIG_QNX4FS_FS is not set 1570# CONFIG_QNX4FS_FS is not set
1571# CONFIG_ROMFS_FS is not set
1541# CONFIG_SYSV_FS is not set 1572# CONFIG_SYSV_FS is not set
1542# CONFIG_UFS_FS is not set 1573# CONFIG_UFS_FS is not set
1543CONFIG_NETWORK_FILESYSTEMS=y 1574CONFIG_NETWORK_FILESYSTEMS=y
@@ -1629,7 +1660,6 @@ CONFIG_NLS_ISO8859_1=y
1629# CONFIG_NLS_KOI8_U is not set 1660# CONFIG_NLS_KOI8_U is not set
1630# CONFIG_NLS_UTF8 is not set 1661# CONFIG_NLS_UTF8 is not set
1631# CONFIG_DLM is not set 1662# CONFIG_DLM is not set
1632# CONFIG_UCC_SLOW is not set
1633 1663
1634# 1664#
1635# Library routines 1665# Library routines
@@ -1647,11 +1677,6 @@ CONFIG_PLIST=y
1647CONFIG_HAS_IOMEM=y 1677CONFIG_HAS_IOMEM=y
1648CONFIG_HAS_IOPORT=y 1678CONFIG_HAS_IOPORT=y
1649CONFIG_HAS_DMA=y 1679CONFIG_HAS_DMA=y
1650CONFIG_INSTRUMENTATION=y
1651CONFIG_PROFILING=y
1652CONFIG_OPROFILE=y
1653# CONFIG_KPROBES is not set
1654# CONFIG_MARKERS is not set
1655 1680
1656# 1681#
1657# Kernel hacking 1682# Kernel hacking
@@ -1670,6 +1695,7 @@ CONFIG_DETECT_SOFTLOCKUP=y
1670# CONFIG_SCHEDSTATS is not set 1695# CONFIG_SCHEDSTATS is not set
1671# CONFIG_TIMER_STATS is not set 1696# CONFIG_TIMER_STATS is not set
1672# CONFIG_SLUB_DEBUG_ON is not set 1697# CONFIG_SLUB_DEBUG_ON is not set
1698# CONFIG_SLUB_STATS is not set
1673# CONFIG_DEBUG_RT_MUTEXES is not set 1699# CONFIG_DEBUG_RT_MUTEXES is not set
1674# CONFIG_RT_MUTEX_TESTER is not set 1700# CONFIG_RT_MUTEX_TESTER is not set
1675# CONFIG_DEBUG_SPINLOCK is not set 1701# CONFIG_DEBUG_SPINLOCK is not set
@@ -1682,9 +1708,9 @@ CONFIG_DEBUG_BUGVERBOSE=y
1682# CONFIG_DEBUG_VM is not set 1708# CONFIG_DEBUG_VM is not set
1683# CONFIG_DEBUG_LIST is not set 1709# CONFIG_DEBUG_LIST is not set
1684# CONFIG_DEBUG_SG is not set 1710# CONFIG_DEBUG_SG is not set
1685# CONFIG_FORCED_INLINING is not set
1686# CONFIG_BOOT_PRINTK_DELAY is not set 1711# CONFIG_BOOT_PRINTK_DELAY is not set
1687# CONFIG_RCU_TORTURE_TEST is not set 1712# CONFIG_RCU_TORTURE_TEST is not set
1713# CONFIG_BACKTRACE_SELF_TEST is not set
1688# CONFIG_FAULT_INJECTION is not set 1714# CONFIG_FAULT_INJECTION is not set
1689# CONFIG_SAMPLES is not set 1715# CONFIG_SAMPLES is not set
1690# CONFIG_DEBUG_STACKOVERFLOW is not set 1716# CONFIG_DEBUG_STACKOVERFLOW is not set
@@ -1710,7 +1736,9 @@ CONFIG_ASYNC_MEMCPY=y
1710CONFIG_ASYNC_XOR=y 1736CONFIG_ASYNC_XOR=y
1711CONFIG_CRYPTO=y 1737CONFIG_CRYPTO=y
1712CONFIG_CRYPTO_ALGAPI=y 1738CONFIG_CRYPTO_ALGAPI=y
1739CONFIG_CRYPTO_AEAD=y
1713CONFIG_CRYPTO_BLKCIPHER=y 1740CONFIG_CRYPTO_BLKCIPHER=y
1741# CONFIG_CRYPTO_SEQIV is not set
1714CONFIG_CRYPTO_HASH=y 1742CONFIG_CRYPTO_HASH=y
1715CONFIG_CRYPTO_MANAGER=y 1743CONFIG_CRYPTO_MANAGER=y
1716CONFIG_CRYPTO_HMAC=y 1744CONFIG_CRYPTO_HMAC=y
@@ -1729,6 +1757,9 @@ CONFIG_CRYPTO_CBC=y
1729# CONFIG_CRYPTO_PCBC is not set 1757# CONFIG_CRYPTO_PCBC is not set
1730# CONFIG_CRYPTO_LRW is not set 1758# CONFIG_CRYPTO_LRW is not set
1731# CONFIG_CRYPTO_XTS is not set 1759# CONFIG_CRYPTO_XTS is not set
1760# CONFIG_CRYPTO_CTR is not set
1761# CONFIG_CRYPTO_GCM is not set
1762# CONFIG_CRYPTO_CCM is not set
1732# CONFIG_CRYPTO_CRYPTD is not set 1763# CONFIG_CRYPTO_CRYPTD is not set
1733CONFIG_CRYPTO_DES=y 1764CONFIG_CRYPTO_DES=y
1734# CONFIG_CRYPTO_FCRYPT is not set 1765# CONFIG_CRYPTO_FCRYPT is not set
@@ -1743,11 +1774,14 @@ CONFIG_CRYPTO_AES=y
1743# CONFIG_CRYPTO_KHAZAD is not set 1774# CONFIG_CRYPTO_KHAZAD is not set
1744# CONFIG_CRYPTO_ANUBIS is not set 1775# CONFIG_CRYPTO_ANUBIS is not set
1745# CONFIG_CRYPTO_SEED is not set 1776# CONFIG_CRYPTO_SEED is not set
1777# CONFIG_CRYPTO_SALSA20 is not set
1746# CONFIG_CRYPTO_DEFLATE is not set 1778# CONFIG_CRYPTO_DEFLATE is not set
1747# CONFIG_CRYPTO_MICHAEL_MIC is not set 1779# CONFIG_CRYPTO_MICHAEL_MIC is not set
1748# CONFIG_CRYPTO_CRC32C is not set 1780# CONFIG_CRYPTO_CRC32C is not set
1749# CONFIG_CRYPTO_CAMELLIA is not set 1781# CONFIG_CRYPTO_CAMELLIA is not set
1750# CONFIG_CRYPTO_TEST is not set 1782# CONFIG_CRYPTO_TEST is not set
1751# CONFIG_CRYPTO_AUTHENC is not set 1783CONFIG_CRYPTO_AUTHENC=y
1784# CONFIG_CRYPTO_LZO is not set
1752CONFIG_CRYPTO_HW=y 1785CONFIG_CRYPTO_HW=y
1786# CONFIG_CRYPTO_DEV_HIFN_795X is not set
1753# CONFIG_PPC_CLOCK is not set 1787# CONFIG_PPC_CLOCK is not set
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 59311ec0d422..4ec605521504 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -241,8 +241,12 @@ void discard_lazy_cpu_state(void)
241} 241}
242#endif /* CONFIG_SMP */ 242#endif /* CONFIG_SMP */
243 243
244static DEFINE_PER_CPU(unsigned long, current_dabr);
245
244int set_dabr(unsigned long dabr) 246int set_dabr(unsigned long dabr)
245{ 247{
248 __get_cpu_var(current_dabr) = dabr;
249
246#ifdef CONFIG_PPC_MERGE /* XXX for now */ 250#ifdef CONFIG_PPC_MERGE /* XXX for now */
247 if (ppc_md.set_dabr) 251 if (ppc_md.set_dabr)
248 return ppc_md.set_dabr(dabr); 252 return ppc_md.set_dabr(dabr);
@@ -259,8 +263,6 @@ int set_dabr(unsigned long dabr)
259DEFINE_PER_CPU(struct cpu_usage, cpu_usage_array); 263DEFINE_PER_CPU(struct cpu_usage, cpu_usage_array);
260#endif 264#endif
261 265
262static DEFINE_PER_CPU(unsigned long, current_dabr);
263
264struct task_struct *__switch_to(struct task_struct *prev, 266struct task_struct *__switch_to(struct task_struct *prev,
265 struct task_struct *new) 267 struct task_struct *new)
266{ 268{
@@ -325,10 +327,8 @@ struct task_struct *__switch_to(struct task_struct *prev,
325 327
326#endif /* CONFIG_SMP */ 328#endif /* CONFIG_SMP */
327 329
328 if (unlikely(__get_cpu_var(current_dabr) != new->thread.dabr)) { 330 if (unlikely(__get_cpu_var(current_dabr) != new->thread.dabr))
329 set_dabr(new->thread.dabr); 331 set_dabr(new->thread.dabr);
330 __get_cpu_var(current_dabr) = new->thread.dabr;
331 }
332 332
333 new_thread = &new->thread; 333 new_thread = &new->thread;
334 old_thread = &current->thread; 334 old_thread = &current->thread;
diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index a104c532ff70..3335b4595efd 100644
--- a/arch/x86/lguest/boot.c
+++ b/arch/x86/lguest/boot.c
@@ -10,21 +10,19 @@
10 * (such as the example in Documentation/lguest/lguest.c) is called the 10 * (such as the example in Documentation/lguest/lguest.c) is called the
11 * Launcher. 11 * Launcher.
12 * 12 *
13 * Secondly, we only run specially modified Guests, not normal kernels. When 13 * Secondly, we only run specially modified Guests, not normal kernels: setting
14 * you set CONFIG_LGUEST to 'y' or 'm', this automatically sets 14 * CONFIG_LGUEST_GUEST to "y" compiles this file into the kernel so it knows
15 * CONFIG_LGUEST_GUEST=y, which compiles this file into the kernel so it knows 15 * how to be a Guest at boot time. This means that you can use the same kernel
16 * how to be a Guest. This means that you can use the same kernel you boot 16 * you boot normally (ie. as a Host) as a Guest.
17 * normally (ie. as a Host) as a Guest.
18 * 17 *
19 * These Guests know that they cannot do privileged operations, such as disable 18 * These Guests know that they cannot do privileged operations, such as disable
20 * interrupts, and that they have to ask the Host to do such things explicitly. 19 * interrupts, and that they have to ask the Host to do such things explicitly.
21 * This file consists of all the replacements for such low-level native 20 * This file consists of all the replacements for such low-level native
22 * hardware operations: these special Guest versions call the Host. 21 * hardware operations: these special Guest versions call the Host.
23 * 22 *
24 * So how does the kernel know it's a Guest? The Guest starts at a special 23 * So how does the kernel know it's a Guest? We'll see that later, but let's
25 * entry point marked with a magic string, which sets up a few things then 24 * just say that we end up here where we replace the native functions various
26 * calls here. We replace the native functions various "paravirt" structures 25 * "paravirt" structures with our Guest versions, then boot like normal. :*/
27 * with our Guest versions, then boot like normal. :*/
28 26
29/* 27/*
30 * Copyright (C) 2006, Rusty Russell <rusty@rustcorp.com.au> IBM Corporation. 28 * Copyright (C) 2006, Rusty Russell <rusty@rustcorp.com.au> IBM Corporation.
@@ -134,7 +132,7 @@ static void async_hcall(unsigned long call, unsigned long arg1,
134 * lguest_leave_lazy_mode(). 132 * lguest_leave_lazy_mode().
135 * 133 *
136 * So, when we're in lazy mode, we call async_hcall() to store the call for 134 * So, when we're in lazy mode, we call async_hcall() to store the call for
137 * future processing. */ 135 * future processing: */
138static void lazy_hcall(unsigned long call, 136static void lazy_hcall(unsigned long call,
139 unsigned long arg1, 137 unsigned long arg1,
140 unsigned long arg2, 138 unsigned long arg2,
@@ -147,7 +145,7 @@ static void lazy_hcall(unsigned long call,
147} 145}
148 146
149/* When lazy mode is turned off reset the per-cpu lazy mode variable and then 147/* When lazy mode is turned off reset the per-cpu lazy mode variable and then
150 * issue a hypercall to flush any stored calls. */ 148 * issue the do-nothing hypercall to flush any stored calls. */
151static void lguest_leave_lazy_mode(void) 149static void lguest_leave_lazy_mode(void)
152{ 150{
153 paravirt_leave_lazy(paravirt_get_lazy_mode()); 151 paravirt_leave_lazy(paravirt_get_lazy_mode());
@@ -164,7 +162,7 @@ static void lguest_leave_lazy_mode(void)
164 * 162 *
165 * So instead we keep an "irq_enabled" field inside our "struct lguest_data", 163 * So instead we keep an "irq_enabled" field inside our "struct lguest_data",
166 * which the Guest can update with a single instruction. The Host knows to 164 * which the Guest can update with a single instruction. The Host knows to
167 * check there when it wants to deliver an interrupt. 165 * check there before it tries to deliver an interrupt.
168 */ 166 */
169 167
170/* save_flags() is expected to return the processor state (ie. "flags"). The 168/* save_flags() is expected to return the processor state (ie. "flags"). The
@@ -196,10 +194,15 @@ static void irq_enable(void)
196/*M:003 Note that we don't check for outstanding interrupts when we re-enable 194/*M:003 Note that we don't check for outstanding interrupts when we re-enable
197 * them (or when we unmask an interrupt). This seems to work for the moment, 195 * them (or when we unmask an interrupt). This seems to work for the moment,
198 * since interrupts are rare and we'll just get the interrupt on the next timer 196 * since interrupts are rare and we'll just get the interrupt on the next timer
199 * tick, but when we turn on CONFIG_NO_HZ, we should revisit this. One way 197 * tick, but now we can run with CONFIG_NO_HZ, we should revisit this. One way
200 * would be to put the "irq_enabled" field in a page by itself, and have the 198 * would be to put the "irq_enabled" field in a page by itself, and have the
201 * Host write-protect it when an interrupt comes in when irqs are disabled. 199 * Host write-protect it when an interrupt comes in when irqs are disabled.
202 * There will then be a page fault as soon as interrupts are re-enabled. :*/ 200 * There will then be a page fault as soon as interrupts are re-enabled.
201 *
202 * A better method is to implement soft interrupt disable generally for x86:
203 * instead of disabling interrupts, we set a flag. If an interrupt does come
204 * in, we then disable them for real. This is uncommon, so we could simply use
205 * a hypercall for interrupt control and not worry about efficiency. :*/
203 206
204/*G:034 207/*G:034
205 * The Interrupt Descriptor Table (IDT). 208 * The Interrupt Descriptor Table (IDT).
@@ -212,6 +215,10 @@ static void irq_enable(void)
212static void lguest_write_idt_entry(gate_desc *dt, 215static void lguest_write_idt_entry(gate_desc *dt,
213 int entrynum, const gate_desc *g) 216 int entrynum, const gate_desc *g)
214{ 217{
218 /* The gate_desc structure is 8 bytes long: we hand it to the Host in
219 * two 32-bit chunks. The whole 32-bit kernel used to hand descriptors
220 * around like this; typesafety wasn't a big concern in Linux's early
221 * years. */
215 u32 *desc = (u32 *)g; 222 u32 *desc = (u32 *)g;
216 /* Keep the local copy up to date. */ 223 /* Keep the local copy up to date. */
217 native_write_idt_entry(dt, entrynum, g); 224 native_write_idt_entry(dt, entrynum, g);
@@ -243,7 +250,8 @@ static void lguest_load_idt(const struct desc_ptr *desc)
243 * 250 *
244 * This is the opposite of the IDT code where we have a LOAD_IDT_ENTRY 251 * This is the opposite of the IDT code where we have a LOAD_IDT_ENTRY
245 * hypercall and use that repeatedly to load a new IDT. I don't think it 252 * hypercall and use that repeatedly to load a new IDT. I don't think it
246 * really matters, but wouldn't it be nice if they were the same? 253 * really matters, but wouldn't it be nice if they were the same? Wouldn't
254 * it be even better if you were the one to send the patch to fix it?
247 */ 255 */
248static void lguest_load_gdt(const struct desc_ptr *desc) 256static void lguest_load_gdt(const struct desc_ptr *desc)
249{ 257{
@@ -298,9 +306,9 @@ static void lguest_load_tr_desc(void)
298 306
299/* The "cpuid" instruction is a way of querying both the CPU identity 307/* The "cpuid" instruction is a way of querying both the CPU identity
300 * (manufacturer, model, etc) and its features. It was introduced before the 308 * (manufacturer, model, etc) and its features. It was introduced before the
301 * Pentium in 1993 and keeps getting extended by both Intel and AMD. As you 309 * Pentium in 1993 and keeps getting extended by both Intel, AMD and others.
302 * might imagine, after a decade and a half this treatment, it is now a giant 310 * As you might imagine, after a decade and a half this treatment, it is now a
303 * ball of hair. Its entry in the current Intel manual runs to 28 pages. 311 * giant ball of hair. Its entry in the current Intel manual runs to 28 pages.
304 * 312 *
305 * This instruction even it has its own Wikipedia entry. The Wikipedia entry 313 * This instruction even it has its own Wikipedia entry. The Wikipedia entry
306 * has been translated into 4 languages. I am not making this up! 314 * has been translated into 4 languages. I am not making this up!
@@ -594,17 +602,17 @@ static unsigned long lguest_get_wallclock(void)
594 return lguest_data.time.tv_sec; 602 return lguest_data.time.tv_sec;
595} 603}
596 604
597/* The TSC is a Time Stamp Counter. The Host tells us what speed it runs at, 605/* The TSC is an Intel thing called the Time Stamp Counter. The Host tells us
598 * or 0 if it's unusable as a reliable clock source. This matches what we want 606 * what speed it runs at, or 0 if it's unusable as a reliable clock source.
599 * here: if we return 0 from this function, the x86 TSC clock will not register 607 * This matches what we want here: if we return 0 from this function, the x86
600 * itself. */ 608 * TSC clock will give up and not register itself. */
601static unsigned long lguest_cpu_khz(void) 609static unsigned long lguest_cpu_khz(void)
602{ 610{
603 return lguest_data.tsc_khz; 611 return lguest_data.tsc_khz;
604} 612}
605 613
606/* If we can't use the TSC, the kernel falls back to our "lguest_clock", where 614/* If we can't use the TSC, the kernel falls back to our lower-priority
607 * we read the time value given to us by the Host. */ 615 * "lguest_clock", where we read the time value given to us by the Host. */
608static cycle_t lguest_clock_read(void) 616static cycle_t lguest_clock_read(void)
609{ 617{
610 unsigned long sec, nsec; 618 unsigned long sec, nsec;
@@ -648,12 +656,16 @@ static struct clocksource lguest_clock = {
648static int lguest_clockevent_set_next_event(unsigned long delta, 656static int lguest_clockevent_set_next_event(unsigned long delta,
649 struct clock_event_device *evt) 657 struct clock_event_device *evt)
650{ 658{
659 /* FIXME: I don't think this can ever happen, but James tells me he had
660 * to put this code in. Maybe we should remove it now. Anyone? */
651 if (delta < LG_CLOCK_MIN_DELTA) { 661 if (delta < LG_CLOCK_MIN_DELTA) {
652 if (printk_ratelimit()) 662 if (printk_ratelimit())
653 printk(KERN_DEBUG "%s: small delta %lu ns\n", 663 printk(KERN_DEBUG "%s: small delta %lu ns\n",
654 __FUNCTION__, delta); 664 __FUNCTION__, delta);
655 return -ETIME; 665 return -ETIME;
656 } 666 }
667
668 /* Please wake us this far in the future. */
657 hcall(LHCALL_SET_CLOCKEVENT, delta, 0, 0); 669 hcall(LHCALL_SET_CLOCKEVENT, delta, 0, 0);
658 return 0; 670 return 0;
659} 671}
@@ -738,7 +750,7 @@ static void lguest_time_init(void)
738 * will not tolerate us trying to use that), the stack pointer, and the number 750 * will not tolerate us trying to use that), the stack pointer, and the number
739 * of pages in the stack. */ 751 * of pages in the stack. */
740static void lguest_load_sp0(struct tss_struct *tss, 752static void lguest_load_sp0(struct tss_struct *tss,
741 struct thread_struct *thread) 753 struct thread_struct *thread)
742{ 754{
743 lazy_hcall(LHCALL_SET_STACK, __KERNEL_DS|0x1, thread->sp0, 755 lazy_hcall(LHCALL_SET_STACK, __KERNEL_DS|0x1, thread->sp0,
744 THREAD_SIZE/PAGE_SIZE); 756 THREAD_SIZE/PAGE_SIZE);
@@ -786,9 +798,8 @@ static void lguest_safe_halt(void)
786 hcall(LHCALL_HALT, 0, 0, 0); 798 hcall(LHCALL_HALT, 0, 0, 0);
787} 799}
788 800
789/* Perhaps CRASH isn't the best name for this hypercall, but we use it to get a 801/* The SHUTDOWN hypercall takes a string to describe what's happening, and
790 * message out when we're crashing as well as elegant termination like powering 802 * an argument which says whether this to restart (reboot) the Guest or not.
791 * off.
792 * 803 *
793 * Note that the Host always prefers that the Guest speak in physical addresses 804 * Note that the Host always prefers that the Guest speak in physical addresses
794 * rather than virtual addresses, so we use __pa() here. */ 805 * rather than virtual addresses, so we use __pa() here. */
@@ -816,8 +827,9 @@ static struct notifier_block paniced = {
816/* Setting up memory is fairly easy. */ 827/* Setting up memory is fairly easy. */
817static __init char *lguest_memory_setup(void) 828static __init char *lguest_memory_setup(void)
818{ 829{
819 /* We do this here and not earlier because lockcheck barfs if we do it 830 /* We do this here and not earlier because lockcheck used to barf if we
820 * before start_kernel() */ 831 * did it before start_kernel(). I think we fixed that, so it'd be
832 * nice to move it back to lguest_init. Patch welcome... */
821 atomic_notifier_chain_register(&panic_notifier_list, &paniced); 833 atomic_notifier_chain_register(&panic_notifier_list, &paniced);
822 834
823 /* The Linux bootloader header contains an "e820" memory map: the 835 /* The Linux bootloader header contains an "e820" memory map: the
@@ -850,12 +862,19 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
850 return len; 862 return len;
851} 863}
852 864
865/* Rebooting also tells the Host we're finished, but the RESTART flag tells the
866 * Launcher to reboot us. */
867static void lguest_restart(char *reason)
868{
869 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0);
870}
871
853/*G:050 872/*G:050
854 * Patching (Powerfully Placating Performance Pedants) 873 * Patching (Powerfully Placating Performance Pedants)
855 * 874 *
856 * We have already seen that pv_ops structures let us replace simple 875 * We have already seen that pv_ops structures let us replace simple native
857 * native instructions with calls to the appropriate back end all throughout 876 * instructions with calls to the appropriate back end all throughout the
858 * the kernel. This allows the same kernel to run as a Guest and as a native 877 * kernel. This allows the same kernel to run as a Guest and as a native
859 * kernel, but it's slow because of all the indirect branches. 878 * kernel, but it's slow because of all the indirect branches.
860 * 879 *
861 * Remember that David Wheeler quote about "Any problem in computer science can 880 * Remember that David Wheeler quote about "Any problem in computer science can
@@ -908,14 +927,9 @@ static unsigned lguest_patch(u8 type, u16 clobber, void *ibuf,
908 return insn_len; 927 return insn_len;
909} 928}
910 929
911static void lguest_restart(char *reason) 930/*G:030 Once we get to lguest_init(), we know we're a Guest. The various
912{ 931 * pv_ops structures in the kernel provide points for (almost) every routine we
913 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0); 932 * have to override to avoid privileged instructions. */
914}
915
916/*G:030 Once we get to lguest_init(), we know we're a Guest. The pv_ops
917 * structures in the kernel provide points for (almost) every routine we have
918 * to override to avoid privileged instructions. */
919__init void lguest_init(void) 933__init void lguest_init(void)
920{ 934{
921 /* We're under lguest, paravirt is enabled, and we're running at 935 /* We're under lguest, paravirt is enabled, and we're running at
@@ -1003,9 +1017,9 @@ __init void lguest_init(void)
1003 * the normal data segment to get through booting. */ 1017 * the normal data segment to get through booting. */
1004 asm volatile ("mov %0, %%fs" : : "r" (__KERNEL_DS) : "memory"); 1018 asm volatile ("mov %0, %%fs" : : "r" (__KERNEL_DS) : "memory");
1005 1019
1006 /* The Host uses the top of the Guest's virtual address space for the 1020 /* The Host<->Guest Switcher lives at the top of our address space, and
1007 * Host<->Guest Switcher, and it tells us how big that is in 1021 * the Host told us how big it is when we made LGUEST_INIT hypercall:
1008 * lguest_data.reserve_mem, set up on the LGUEST_INIT hypercall. */ 1022 * it put the answer in lguest_data.reserve_mem */
1009 reserve_top_address(lguest_data.reserve_mem); 1023 reserve_top_address(lguest_data.reserve_mem);
1010 1024
1011 /* If we don't initialize the lock dependency checker now, it crashes 1025 /* If we don't initialize the lock dependency checker now, it crashes
@@ -1027,6 +1041,7 @@ __init void lguest_init(void)
1027 /* Math is always hard! */ 1041 /* Math is always hard! */
1028 new_cpu_data.hard_math = 1; 1042 new_cpu_data.hard_math = 1;
1029 1043
1044 /* We don't have features. We have puppies! Puppies! */
1030#ifdef CONFIG_X86_MCE 1045#ifdef CONFIG_X86_MCE
1031 mce_disabled = 1; 1046 mce_disabled = 1;
1032#endif 1047#endif
@@ -1044,10 +1059,11 @@ __init void lguest_init(void)
1044 virtio_cons_early_init(early_put_chars); 1059 virtio_cons_early_init(early_put_chars);
1045 1060
1046 /* Last of all, we set the power management poweroff hook to point to 1061 /* Last of all, we set the power management poweroff hook to point to
1047 * the Guest routine to power off. */ 1062 * the Guest routine to power off, and the reboot hook to our restart
1063 * routine. */
1048 pm_power_off = lguest_power_off; 1064 pm_power_off = lguest_power_off;
1049
1050 machine_ops.restart = lguest_restart; 1065 machine_ops.restart = lguest_restart;
1066
1051 /* Now we're set up, call start_kernel() in init/main.c and we proceed 1067 /* Now we're set up, call start_kernel() in init/main.c and we proceed
1052 * to boot as normal. It never returns. */ 1068 * to boot as normal. It never returns. */
1053 start_kernel(); 1069 start_kernel();
diff --git a/arch/x86/lguest/i386_head.S b/arch/x86/lguest/i386_head.S
index 95b6fbcded63..5c7cef34c9e7 100644
--- a/arch/x86/lguest/i386_head.S
+++ b/arch/x86/lguest/i386_head.S
@@ -5,13 +5,20 @@
5#include <asm/thread_info.h> 5#include <asm/thread_info.h>
6#include <asm/processor-flags.h> 6#include <asm/processor-flags.h>
7 7
8/*G:020 This is where we begin: head.S notes that the boot header's platform 8/*G:020 Our story starts with the kernel booting into startup_32 in
9 * type field is "1" (lguest), so calls us here. 9 * arch/x86/kernel/head_32.S. It expects a boot header, which is created by
10 * the bootloader (the Launcher in our case).
11 *
12 * The startup_32 function does very little: it clears the uninitialized global
13 * C variables which we expect to be zero (ie. BSS) and then copies the boot
14 * header and kernel command line somewhere safe. Finally it checks the
15 * 'hardware_subarch' field. This was introduced in 2.6.24 for lguest and Xen:
16 * if it's set to '1' (lguest's assigned number), then it calls us here.
10 * 17 *
11 * WARNING: be very careful here! We're running at addresses equal to physical 18 * WARNING: be very careful here! We're running at addresses equal to physical
12 * addesses (around 0), not above PAGE_OFFSET as most code expectes 19 * addesses (around 0), not above PAGE_OFFSET as most code expectes
13 * (eg. 0xC0000000). Jumps are relative, so they're OK, but we can't touch any 20 * (eg. 0xC0000000). Jumps are relative, so they're OK, but we can't touch any
14 * data. 21 * data without remembering to subtract __PAGE_OFFSET!
15 * 22 *
16 * The .section line puts this code in .init.text so it will be discarded after 23 * The .section line puts this code in .init.text so it will be discarded after
17 * boot. */ 24 * boot. */
@@ -24,7 +31,7 @@ ENTRY(lguest_entry)
24 int $LGUEST_TRAP_ENTRY 31 int $LGUEST_TRAP_ENTRY
25 32
26 /* The Host put the toplevel pagetable in lguest_data.pgdir. The movsl 33 /* The Host put the toplevel pagetable in lguest_data.pgdir. The movsl
27 * instruction uses %esi implicitly as the source for the copy we' 34 * instruction uses %esi implicitly as the source for the copy we're
28 * about to do. */ 35 * about to do. */
29 movl lguest_data - __PAGE_OFFSET + LGUEST_DATA_pgdir, %esi 36 movl lguest_data - __PAGE_OFFSET + LGUEST_DATA_pgdir, %esi
30 37
diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
index 3d936f232704..9cf33d3ee5bc 100644
--- a/arch/x86/mm/highmem_32.c
+++ b/arch/x86/mm/highmem_32.c
@@ -73,15 +73,15 @@ void *kmap_atomic_prot(struct page *page, enum km_type type, pgprot_t prot)
73{ 73{
74 enum fixed_addresses idx; 74 enum fixed_addresses idx;
75 unsigned long vaddr; 75 unsigned long vaddr;
76 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
77
78 debug_kmap_atomic_prot(type);
79 76
77 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
80 pagefault_disable(); 78 pagefault_disable();
81 79
82 if (!PageHighMem(page)) 80 if (!PageHighMem(page))
83 return page_address(page); 81 return page_address(page);
84 82
83 debug_kmap_atomic_prot(type);
84
85 idx = type + KM_TYPE_NR*smp_processor_id(); 85 idx = type + KM_TYPE_NR*smp_processor_id();
86 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 86 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
87 BUG_ON(!pte_none(*(kmap_pte-idx))); 87 BUG_ON(!pte_none(*(kmap_pte-idx)));
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 4d535c50d821..c8e3cba423ef 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -260,22 +260,24 @@ static int acpi_fan_add(struct acpi_device *device)
260 result = PTR_ERR(cdev); 260 result = PTR_ERR(cdev);
261 goto end; 261 goto end;
262 } 262 }
263 printk(KERN_INFO PREFIX 263 if (cdev) {
264 "%s is registered as cooling_device%d\n", 264 printk(KERN_INFO PREFIX
265 device->dev.bus_id, cdev->id); 265 "%s is registered as cooling_device%d\n",
266 266 device->dev.bus_id, cdev->id);
267 acpi_driver_data(device) = cdev; 267
268 result = sysfs_create_link(&device->dev.kobj, 268 acpi_driver_data(device) = cdev;
269 &cdev->device.kobj, 269 result = sysfs_create_link(&device->dev.kobj,
270 "thermal_cooling"); 270 &cdev->device.kobj,
271 if (result) 271 "thermal_cooling");
272 return result; 272 if (result)
273 273 return result;
274 result = sysfs_create_link(&cdev->device.kobj, 274
275 &device->dev.kobj, 275 result = sysfs_create_link(&cdev->device.kobj,
276 "device"); 276 &device->dev.kobj,
277 if (result) 277 "device");
278 return result; 278 if (result)
279 return result;
280 }
279 281
280 result = acpi_fan_add_fs(device); 282 result = acpi_fan_add_fs(device);
281 if (result) 283 if (result)
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 3a136f6c66a3..36a68fa114e3 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -674,20 +674,22 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device)
674 result = PTR_ERR(pr->cdev); 674 result = PTR_ERR(pr->cdev);
675 goto end; 675 goto end;
676 } 676 }
677 printk(KERN_INFO PREFIX 677 if (pr->cdev) {
678 "%s is registered as cooling_device%d\n", 678 printk(KERN_INFO PREFIX
679 device->dev.bus_id, pr->cdev->id); 679 "%s is registered as cooling_device%d\n",
680 680 device->dev.bus_id, pr->cdev->id);
681 result = sysfs_create_link(&device->dev.kobj, 681
682 &pr->cdev->device.kobj, 682 result = sysfs_create_link(&device->dev.kobj,
683 "thermal_cooling"); 683 &pr->cdev->device.kobj,
684 if (result) 684 "thermal_cooling");
685 return result; 685 if (result)
686 result = sysfs_create_link(&pr->cdev->device.kobj, 686 return result;
687 &device->dev.kobj, 687 result = sysfs_create_link(&pr->cdev->device.kobj,
688 "device"); 688 &device->dev.kobj,
689 if (result) 689 "device");
690 return result; 690 if (result)
691 return result;
692 }
691 693
692 if (pr->flags.throttling) { 694 if (pr->flags.throttling) {
693 printk(KERN_INFO PREFIX "%s [%s] (supports", 695 printk(KERN_INFO PREFIX "%s [%s] (supports",
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index fe09b57de617..12fb44f16766 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -734,19 +734,21 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
734 if (IS_ERR(device->cdev)) 734 if (IS_ERR(device->cdev))
735 return; 735 return;
736 736
737 printk(KERN_INFO PREFIX 737 if (device->cdev) {
738 "%s is registered as cooling_device%d\n", 738 printk(KERN_INFO PREFIX
739 device->dev->dev.bus_id, device->cdev->id); 739 "%s is registered as cooling_device%d\n",
740 result = sysfs_create_link(&device->dev->dev.kobj, 740 device->dev->dev.bus_id, device->cdev->id);
741 &device->cdev->device.kobj, 741 result = sysfs_create_link(&device->dev->dev.kobj,
742 "thermal_cooling"); 742 &device->cdev->device.kobj,
743 if (result) 743 "thermal_cooling");
744 printk(KERN_ERR PREFIX "Create sysfs link\n"); 744 if (result)
745 result = sysfs_create_link(&device->cdev->device.kobj, 745 printk(KERN_ERR PREFIX "Create sysfs link\n");
746 &device->dev->dev.kobj, 746 result = sysfs_create_link(&device->cdev->device.kobj,
747 "device"); 747 &device->dev->dev.kobj,
748 if (result) 748 "device");
749 printk(KERN_ERR PREFIX "Create sysfs link\n"); 749 if (result)
750 printk(KERN_ERR PREFIX "Create sysfs link\n");
751 }
750 } 752 }
751 if (device->cap._DCS && device->cap._DSS){ 753 if (device->cap._DCS && device->cap._DSS){
752 static int count = 0; 754 static int count = 0;
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index bf31a0170a48..9a6537f14401 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -133,6 +133,7 @@ int driver_add_kobj(struct device_driver *drv, struct kobject *kobj,
133{ 133{
134 va_list args; 134 va_list args;
135 char *name; 135 char *name;
136 int ret;
136 137
137 va_start(args, fmt); 138 va_start(args, fmt);
138 name = kvasprintf(GFP_KERNEL, fmt, args); 139 name = kvasprintf(GFP_KERNEL, fmt, args);
@@ -141,7 +142,9 @@ int driver_add_kobj(struct device_driver *drv, struct kobject *kobj,
141 if (!name) 142 if (!name)
142 return -ENOMEM; 143 return -ENOMEM;
143 144
144 return kobject_add(kobj, &drv->p->kobj, "%s", name); 145 ret = kobject_add(kobj, &drv->p->kobj, "%s", name);
146 kfree(name);
147 return ret;
145} 148}
146EXPORT_SYMBOL_GPL(driver_add_kobj); 149EXPORT_SYMBOL_GPL(driver_add_kobj);
147 150
diff --git a/drivers/char/drm/ati_pcigart.c b/drivers/char/drm/ati_pcigart.c
index e5a0e97cfdda..35d25d821c38 100644
--- a/drivers/char/drm/ati_pcigart.c
+++ b/drivers/char/drm/ati_pcigart.c
@@ -122,8 +122,9 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga
122 } else { 122 } else {
123 address = gart_info->addr; 123 address = gart_info->addr;
124 bus_address = gart_info->bus_addr; 124 bus_address = gart_info->bus_addr;
125 DRM_DEBUG("PCI: Gart Table: VRAM %08X mapped at %08lX\n", 125 DRM_DEBUG("PCI: Gart Table: VRAM %08LX mapped at %08lX\n",
126 bus_address, (unsigned long)address); 126 (unsigned long long)bus_address,
127 (unsigned long)address);
127 } 128 }
128 129
129 pci_gart = (u32 *) address; 130 pci_gart = (u32 *) address;
diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c
index 320f2b6ddee6..99f2f2a46bf7 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_cm.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c
@@ -1745,7 +1745,7 @@ int iwch_accept_cr(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
1745 1745
1746 /* bind QP to EP and move to RTS */ 1746 /* bind QP to EP and move to RTS */
1747 attrs.mpa_attr = ep->mpa_attr; 1747 attrs.mpa_attr = ep->mpa_attr;
1748 attrs.max_ird = ep->ord; 1748 attrs.max_ird = ep->ird;
1749 attrs.max_ord = ep->ord; 1749 attrs.max_ord = ep->ord;
1750 attrs.llp_stream_handle = ep; 1750 attrs.llp_stream_handle = ep;
1751 attrs.next_state = IWCH_QP_STATE_RTS; 1751 attrs.next_state = IWCH_QP_STATE_RTS;
diff --git a/drivers/input/misc/ixp4xx-beeper.c b/drivers/input/misc/ixp4xx-beeper.c
index d2ade7443b7d..798d84c44d03 100644
--- a/drivers/input/misc/ixp4xx-beeper.c
+++ b/drivers/input/misc/ixp4xx-beeper.c
@@ -25,6 +25,7 @@
25MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); 25MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
26MODULE_DESCRIPTION("ixp4xx beeper driver"); 26MODULE_DESCRIPTION("ixp4xx beeper driver");
27MODULE_LICENSE("GPL"); 27MODULE_LICENSE("GPL");
28MODULE_ALIAS("platform:ixp4xx-beeper");
28 29
29static DEFINE_SPINLOCK(beep_lock); 30static DEFINE_SPINLOCK(beep_lock);
30 31
diff --git a/drivers/lguest/Makefile b/drivers/lguest/Makefile
index 5e8272d296d8..7d463c26124f 100644
--- a/drivers/lguest/Makefile
+++ b/drivers/lguest/Makefile
@@ -19,3 +19,11 @@ Beer:
19 @for f in Preparation Guest Drivers Launcher Host Switcher Mastery; do echo "{==- $$f -==}"; make -s $$f; done; echo "{==-==}" 19 @for f in Preparation Guest Drivers Launcher Host Switcher Mastery; do echo "{==- $$f -==}"; make -s $$f; done; echo "{==-==}"
20Preparation Preparation! Guest Drivers Launcher Host Switcher Mastery: 20Preparation Preparation! Guest Drivers Launcher Host Switcher Mastery:
21 @sh ../../Documentation/lguest/extract $(PREFIX) `find ../../* -name '*.[chS]' -wholename '*lguest*'` 21 @sh ../../Documentation/lguest/extract $(PREFIX) `find ../../* -name '*.[chS]' -wholename '*lguest*'`
22Puppy:
23 @clear
24 @printf " __ \n (___()'\`;\n /, /\`\n \\\\\\\"--\\\\\\ \n"
25 @sleep 2; clear; printf "\n\n Sit!\n\n"; sleep 1; clear
26 @printf " __ \n ()'\`; \n /\\|\` \n / | \n(/_)_|_ \n"
27 @sleep 2; clear; printf "\n\n Stand!\n\n"; sleep 1; clear
28 @printf " __ \n ()'\`; \n /\\|\` \n /._.= \n /| / \n(_\_)_ \n"
29 @sleep 2; clear; printf "\n\n Good puppy!\n\n"; sleep 1; clear
diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
index c632c08cbbdc..5eea4356d703 100644
--- a/drivers/lguest/core.c
+++ b/drivers/lguest/core.c
@@ -1,8 +1,6 @@
1/*P:400 This contains run_guest() which actually calls into the Host<->Guest 1/*P:400 This contains run_guest() which actually calls into the Host<->Guest
2 * Switcher and analyzes the return, such as determining if the Guest wants the 2 * Switcher and analyzes the return, such as determining if the Guest wants the
3 * Host to do something. This file also contains useful helper routines, and a 3 * Host to do something. This file also contains useful helper routines. :*/
4 * couple of non-obvious setup and teardown pieces which were implemented after
5 * days of debugging pain. :*/
6#include <linux/module.h> 4#include <linux/module.h>
7#include <linux/stringify.h> 5#include <linux/stringify.h>
8#include <linux/stddef.h> 6#include <linux/stddef.h>
@@ -49,8 +47,8 @@ static __init int map_switcher(void)
49 * easy. 47 * easy.
50 */ 48 */
51 49
52 /* We allocate an array of "struct page"s. map_vm_area() wants the 50 /* We allocate an array of struct page pointers. map_vm_area() wants
53 * pages in this form, rather than just an array of pointers. */ 51 * this, rather than just an array of pages. */
54 switcher_page = kmalloc(sizeof(switcher_page[0])*TOTAL_SWITCHER_PAGES, 52 switcher_page = kmalloc(sizeof(switcher_page[0])*TOTAL_SWITCHER_PAGES,
55 GFP_KERNEL); 53 GFP_KERNEL);
56 if (!switcher_page) { 54 if (!switcher_page) {
@@ -172,7 +170,7 @@ void __lgread(struct lg_cpu *cpu, void *b, unsigned long addr, unsigned bytes)
172 } 170 }
173} 171}
174 172
175/* This is the write (copy into guest) version. */ 173/* This is the write (copy into Guest) version. */
176void __lgwrite(struct lg_cpu *cpu, unsigned long addr, const void *b, 174void __lgwrite(struct lg_cpu *cpu, unsigned long addr, const void *b,
177 unsigned bytes) 175 unsigned bytes)
178{ 176{
@@ -209,9 +207,9 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user)
209 if (cpu->break_out) 207 if (cpu->break_out)
210 return -EAGAIN; 208 return -EAGAIN;
211 209
212 /* Check if there are any interrupts which can be delivered 210 /* Check if there are any interrupts which can be delivered now:
213 * now: if so, this sets up the hander to be executed when we 211 * if so, this sets up the hander to be executed when we next
214 * next run the Guest. */ 212 * run the Guest. */
215 maybe_do_interrupt(cpu); 213 maybe_do_interrupt(cpu);
216 214
217 /* All long-lived kernel loops need to check with this horrible 215 /* All long-lived kernel loops need to check with this horrible
@@ -246,8 +244,10 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user)
246 lguest_arch_handle_trap(cpu); 244 lguest_arch_handle_trap(cpu);
247 } 245 }
248 246
247 /* Special case: Guest is 'dead' but wants a reboot. */
249 if (cpu->lg->dead == ERR_PTR(-ERESTART)) 248 if (cpu->lg->dead == ERR_PTR(-ERESTART))
250 return -ERESTART; 249 return -ERESTART;
250
251 /* The Guest is dead => "No such file or directory" */ 251 /* The Guest is dead => "No such file or directory" */
252 return -ENOENT; 252 return -ENOENT;
253} 253}
diff --git a/drivers/lguest/hypercalls.c b/drivers/lguest/hypercalls.c
index 0f2cb4fd7c69..54d66f05fefa 100644
--- a/drivers/lguest/hypercalls.c
+++ b/drivers/lguest/hypercalls.c
@@ -29,7 +29,7 @@
29#include "lg.h" 29#include "lg.h"
30 30
31/*H:120 This is the core hypercall routine: where the Guest gets what it wants. 31/*H:120 This is the core hypercall routine: where the Guest gets what it wants.
32 * Or gets killed. Or, in the case of LHCALL_CRASH, both. */ 32 * Or gets killed. Or, in the case of LHCALL_SHUTDOWN, both. */
33static void do_hcall(struct lg_cpu *cpu, struct hcall_args *args) 33static void do_hcall(struct lg_cpu *cpu, struct hcall_args *args)
34{ 34{
35 switch (args->arg0) { 35 switch (args->arg0) {
@@ -190,6 +190,13 @@ static void initialize(struct lg_cpu *cpu)
190 * pagetable. */ 190 * pagetable. */
191 guest_pagetable_clear_all(cpu); 191 guest_pagetable_clear_all(cpu);
192} 192}
193/*:*/
194
195/*M:013 If a Guest reads from a page (so creates a mapping) that it has never
196 * written to, and then the Launcher writes to it (ie. the output of a virtual
197 * device), the Guest will still see the old page. In practice, this never
198 * happens: why would the Guest read a page which it has never written to? But
199 * a similar scenario might one day bite us, so it's worth mentioning. :*/
193 200
194/*H:100 201/*H:100
195 * Hypercalls 202 * Hypercalls
@@ -227,7 +234,7 @@ void do_hypercalls(struct lg_cpu *cpu)
227 * However, if we are signalled or the Guest sends I/O to the 234 * However, if we are signalled or the Guest sends I/O to the
228 * Launcher, the run_guest() loop will exit without running the 235 * Launcher, the run_guest() loop will exit without running the
229 * Guest. When it comes back it would try to re-run the 236 * Guest. When it comes back it would try to re-run the
230 * hypercall. */ 237 * hypercall. Finding that bug sucked. */
231 cpu->hcall = NULL; 238 cpu->hcall = NULL;
232 } 239 }
233} 240}
diff --git a/drivers/lguest/interrupts_and_traps.c b/drivers/lguest/interrupts_and_traps.c
index 32e97c1858e5..0414ddf87587 100644
--- a/drivers/lguest/interrupts_and_traps.c
+++ b/drivers/lguest/interrupts_and_traps.c
@@ -144,7 +144,6 @@ void maybe_do_interrupt(struct lg_cpu *cpu)
144 if (copy_from_user(&blk, cpu->lg->lguest_data->blocked_interrupts, 144 if (copy_from_user(&blk, cpu->lg->lguest_data->blocked_interrupts,
145 sizeof(blk))) 145 sizeof(blk)))
146 return; 146 return;
147
148 bitmap_andnot(blk, cpu->irqs_pending, blk, LGUEST_IRQS); 147 bitmap_andnot(blk, cpu->irqs_pending, blk, LGUEST_IRQS);
149 148
150 /* Find the first interrupt. */ 149 /* Find the first interrupt. */
@@ -237,9 +236,9 @@ void free_interrupts(void)
237 clear_bit(syscall_vector, used_vectors); 236 clear_bit(syscall_vector, used_vectors);
238} 237}
239 238
240/*H:220 Now we've got the routines to deliver interrupts, delivering traps 239/*H:220 Now we've got the routines to deliver interrupts, delivering traps like
241 * like page fault is easy. The only trick is that Intel decided that some 240 * page fault is easy. The only trick is that Intel decided that some traps
242 * traps should have error codes: */ 241 * should have error codes: */
243static int has_err(unsigned int trap) 242static int has_err(unsigned int trap)
244{ 243{
245 return (trap == 8 || (trap >= 10 && trap <= 14) || trap == 17); 244 return (trap == 8 || (trap >= 10 && trap <= 14) || trap == 17);
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c
index 1b2ec0bf5eb1..2bc9bf7e88e5 100644
--- a/drivers/lguest/lguest_device.c
+++ b/drivers/lguest/lguest_device.c
@@ -1,10 +1,10 @@
1/*P:050 Lguest guests use a very simple method to describe devices. It's a 1/*P:050 Lguest guests use a very simple method to describe devices. It's a
2 * series of device descriptors contained just above the top of normal 2 * series of device descriptors contained just above the top of normal Guest
3 * memory. 3 * memory.
4 * 4 *
5 * We use the standard "virtio" device infrastructure, which provides us with a 5 * We use the standard "virtio" device infrastructure, which provides us with a
6 * console, a network and a block driver. Each one expects some configuration 6 * console, a network and a block driver. Each one expects some configuration
7 * information and a "virtqueue" mechanism to send and receive data. :*/ 7 * information and a "virtqueue" or two to send and receive data. :*/
8#include <linux/init.h> 8#include <linux/init.h>
9#include <linux/bootmem.h> 9#include <linux/bootmem.h>
10#include <linux/lguest_launcher.h> 10#include <linux/lguest_launcher.h>
@@ -53,7 +53,7 @@ struct lguest_device {
53 * Device configurations 53 * Device configurations
54 * 54 *
55 * The configuration information for a device consists of one or more 55 * The configuration information for a device consists of one or more
56 * virtqueues, a feature bitmaks, and some configuration bytes. The 56 * virtqueues, a feature bitmap, and some configuration bytes. The
57 * configuration bytes don't really matter to us: the Launcher sets them up, and 57 * configuration bytes don't really matter to us: the Launcher sets them up, and
58 * the driver will look at them during setup. 58 * the driver will look at them during setup.
59 * 59 *
@@ -179,7 +179,7 @@ struct lguest_vq_info
179}; 179};
180 180
181/* When the virtio_ring code wants to prod the Host, it calls us here and we 181/* When the virtio_ring code wants to prod the Host, it calls us here and we
182 * make a hypercall. We hand the page number of the virtqueue so the Host 182 * make a hypercall. We hand the physical address of the virtqueue so the Host
183 * knows which virtqueue we're talking about. */ 183 * knows which virtqueue we're talking about. */
184static void lg_notify(struct virtqueue *vq) 184static void lg_notify(struct virtqueue *vq)
185{ 185{
@@ -199,7 +199,8 @@ static void lg_notify(struct virtqueue *vq)
199 * allocate its own pages and tell the Host where they are, but for lguest it's 199 * allocate its own pages and tell the Host where they are, but for lguest it's
200 * simpler for the Host to simply tell us where the pages are. 200 * simpler for the Host to simply tell us where the pages are.
201 * 201 *
202 * So we provide devices with a "find virtqueue and set it up" function. */ 202 * So we provide drivers with a "find the Nth virtqueue and set it up"
203 * function. */
203static struct virtqueue *lg_find_vq(struct virtio_device *vdev, 204static struct virtqueue *lg_find_vq(struct virtio_device *vdev,
204 unsigned index, 205 unsigned index,
205 void (*callback)(struct virtqueue *vq)) 206 void (*callback)(struct virtqueue *vq))
diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c
index 2221485b0773..564e425d71dd 100644
--- a/drivers/lguest/lguest_user.c
+++ b/drivers/lguest/lguest_user.c
@@ -73,7 +73,7 @@ static ssize_t read(struct file *file, char __user *user, size_t size,loff_t*o)
73 if (current != cpu->tsk) 73 if (current != cpu->tsk)
74 return -EPERM; 74 return -EPERM;
75 75
76 /* If the guest is already dead, we indicate why */ 76 /* If the Guest is already dead, we indicate why */
77 if (lg->dead) { 77 if (lg->dead) {
78 size_t len; 78 size_t len;
79 79
@@ -88,7 +88,7 @@ static ssize_t read(struct file *file, char __user *user, size_t size,loff_t*o)
88 return len; 88 return len;
89 } 89 }
90 90
91 /* If we returned from read() last time because the Guest notified, 91 /* If we returned from read() last time because the Guest sent I/O,
92 * clear the flag. */ 92 * clear the flag. */
93 if (cpu->pending_notify) 93 if (cpu->pending_notify)
94 cpu->pending_notify = 0; 94 cpu->pending_notify = 0;
@@ -97,14 +97,20 @@ static ssize_t read(struct file *file, char __user *user, size_t size,loff_t*o)
97 return run_guest(cpu, (unsigned long __user *)user); 97 return run_guest(cpu, (unsigned long __user *)user);
98} 98}
99 99
100/*L:025 This actually initializes a CPU. For the moment, a Guest is only
101 * uniprocessor, so "id" is always 0. */
100static int lg_cpu_start(struct lg_cpu *cpu, unsigned id, unsigned long start_ip) 102static int lg_cpu_start(struct lg_cpu *cpu, unsigned id, unsigned long start_ip)
101{ 103{
104 /* We have a limited number the number of CPUs in the lguest struct. */
102 if (id >= NR_CPUS) 105 if (id >= NR_CPUS)
103 return -EINVAL; 106 return -EINVAL;
104 107
108 /* Set up this CPU's id, and pointer back to the lguest struct. */
105 cpu->id = id; 109 cpu->id = id;
106 cpu->lg = container_of((cpu - id), struct lguest, cpus[0]); 110 cpu->lg = container_of((cpu - id), struct lguest, cpus[0]);
107 cpu->lg->nr_cpus++; 111 cpu->lg->nr_cpus++;
112
113 /* Each CPU has a timer it can set. */
108 init_clockdev(cpu); 114 init_clockdev(cpu);
109 115
110 /* We need a complete page for the Guest registers: they are accessible 116 /* We need a complete page for the Guest registers: they are accessible
@@ -120,11 +126,11 @@ static int lg_cpu_start(struct lg_cpu *cpu, unsigned id, unsigned long start_ip)
120 * address. */ 126 * address. */
121 lguest_arch_setup_regs(cpu, start_ip); 127 lguest_arch_setup_regs(cpu, start_ip);
122 128
123 /* Initialize the queue for the waker to wait on */ 129 /* Initialize the queue for the Waker to wait on */
124 init_waitqueue_head(&cpu->break_wq); 130 init_waitqueue_head(&cpu->break_wq);
125 131
126 /* We keep a pointer to the Launcher task (ie. current task) for when 132 /* We keep a pointer to the Launcher task (ie. current task) for when
127 * other Guests want to wake this one (inter-Guest I/O). */ 133 * other Guests want to wake this one (eg. console input). */
128 cpu->tsk = current; 134 cpu->tsk = current;
129 135
130 /* We need to keep a pointer to the Launcher's memory map, because if 136 /* We need to keep a pointer to the Launcher's memory map, because if
@@ -136,6 +142,7 @@ static int lg_cpu_start(struct lg_cpu *cpu, unsigned id, unsigned long start_ip)
136 * when the same Guest runs on the same CPU twice. */ 142 * when the same Guest runs on the same CPU twice. */
137 cpu->last_pages = NULL; 143 cpu->last_pages = NULL;
138 144
145 /* No error == success. */
139 return 0; 146 return 0;
140} 147}
141 148
@@ -185,14 +192,13 @@ static int initialize(struct file *file, const unsigned long __user *input)
185 lg->mem_base = (void __user *)(long)args[0]; 192 lg->mem_base = (void __user *)(long)args[0];
186 lg->pfn_limit = args[1]; 193 lg->pfn_limit = args[1];
187 194
188 /* This is the first cpu */ 195 /* This is the first cpu (cpu 0) and it will start booting at args[3] */
189 err = lg_cpu_start(&lg->cpus[0], 0, args[3]); 196 err = lg_cpu_start(&lg->cpus[0], 0, args[3]);
190 if (err) 197 if (err)
191 goto release_guest; 198 goto release_guest;
192 199
193 /* Initialize the Guest's shadow page tables, using the toplevel 200 /* Initialize the Guest's shadow page tables, using the toplevel
194 * address the Launcher gave us. This allocates memory, so can 201 * address the Launcher gave us. This allocates memory, so can fail. */
195 * fail. */
196 err = init_guest_pagetable(lg, args[2]); 202 err = init_guest_pagetable(lg, args[2]);
197 if (err) 203 if (err)
198 goto free_regs; 204 goto free_regs;
@@ -218,11 +224,16 @@ unlock:
218/*L:010 The first operation the Launcher does must be a write. All writes 224/*L:010 The first operation the Launcher does must be a write. All writes
219 * start with an unsigned long number: for the first write this must be 225 * start with an unsigned long number: for the first write this must be
220 * LHREQ_INITIALIZE to set up the Guest. After that the Launcher can use 226 * LHREQ_INITIALIZE to set up the Guest. After that the Launcher can use
221 * writes of other values to send interrupts. */ 227 * writes of other values to send interrupts.
228 *
229 * Note that we overload the "offset" in the /dev/lguest file to indicate what
230 * CPU number we're dealing with. Currently this is always 0, since we only
231 * support uniprocessor Guests, but you can see the beginnings of SMP support
232 * here. */
222static ssize_t write(struct file *file, const char __user *in, 233static ssize_t write(struct file *file, const char __user *in,
223 size_t size, loff_t *off) 234 size_t size, loff_t *off)
224{ 235{
225 /* Once the guest is initialized, we hold the "struct lguest" in the 236 /* Once the Guest is initialized, we hold the "struct lguest" in the
226 * file private data. */ 237 * file private data. */
227 struct lguest *lg = file->private_data; 238 struct lguest *lg = file->private_data;
228 const unsigned long __user *input = (const unsigned long __user *)in; 239 const unsigned long __user *input = (const unsigned long __user *)in;
@@ -230,6 +241,7 @@ static ssize_t write(struct file *file, const char __user *in,
230 struct lg_cpu *uninitialized_var(cpu); 241 struct lg_cpu *uninitialized_var(cpu);
231 unsigned int cpu_id = *off; 242 unsigned int cpu_id = *off;
232 243
244 /* The first value tells us what this request is. */
233 if (get_user(req, input) != 0) 245 if (get_user(req, input) != 0)
234 return -EFAULT; 246 return -EFAULT;
235 input++; 247 input++;
diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
index a7f64a9d67e0..d93500f24fbb 100644
--- a/drivers/lguest/page_tables.c
+++ b/drivers/lguest/page_tables.c
@@ -2,8 +2,8 @@
2 * previous encounters. It's functional, and as neat as it can be in the 2 * previous encounters. It's functional, and as neat as it can be in the
3 * circumstances, but be wary, for these things are subtle and break easily. 3 * circumstances, but be wary, for these things are subtle and break easily.
4 * The Guest provides a virtual to physical mapping, but we can neither trust 4 * The Guest provides a virtual to physical mapping, but we can neither trust
5 * it nor use it: we verify and convert it here to point the hardware to the 5 * it nor use it: we verify and convert it here then point the CPU to the
6 * actual Guest pages when running the Guest. :*/ 6 * converted Guest pages when running the Guest. :*/
7 7
8/* Copyright (C) Rusty Russell IBM Corporation 2006. 8/* Copyright (C) Rusty Russell IBM Corporation 2006.
9 * GPL v2 and any later version */ 9 * GPL v2 and any later version */
@@ -106,6 +106,11 @@ static unsigned long gpte_addr(pgd_t gpgd, unsigned long vaddr)
106 BUG_ON(!(pgd_flags(gpgd) & _PAGE_PRESENT)); 106 BUG_ON(!(pgd_flags(gpgd) & _PAGE_PRESENT));
107 return gpage + ((vaddr>>PAGE_SHIFT) % PTRS_PER_PTE) * sizeof(pte_t); 107 return gpage + ((vaddr>>PAGE_SHIFT) % PTRS_PER_PTE) * sizeof(pte_t);
108} 108}
109/*:*/
110
111/*M:014 get_pfn is slow; it takes the mmap sem and calls get_user_pages. We
112 * could probably try to grab batches of pages here as an optimization
113 * (ie. pre-faulting). :*/
109 114
110/*H:350 This routine takes a page number given by the Guest and converts it to 115/*H:350 This routine takes a page number given by the Guest and converts it to
111 * an actual, physical page number. It can fail for several reasons: the 116 * an actual, physical page number. It can fail for several reasons: the
@@ -113,8 +118,8 @@ static unsigned long gpte_addr(pgd_t gpgd, unsigned long vaddr)
113 * and the page is read-only, or the write flag was set and the page was 118 * and the page is read-only, or the write flag was set and the page was
114 * shared so had to be copied, but we ran out of memory. 119 * shared so had to be copied, but we ran out of memory.
115 * 120 *
116 * This holds a reference to the page, so release_pte() is careful to 121 * This holds a reference to the page, so release_pte() is careful to put that
117 * put that back. */ 122 * back. */
118static unsigned long get_pfn(unsigned long virtpfn, int write) 123static unsigned long get_pfn(unsigned long virtpfn, int write)
119{ 124{
120 struct page *page; 125 struct page *page;
@@ -532,13 +537,13 @@ static void do_set_pte(struct lg_cpu *cpu, int idx,
532 * all processes. So when the page table above that address changes, we update 537 * all processes. So when the page table above that address changes, we update
533 * all the page tables, not just the current one. This is rare. 538 * all the page tables, not just the current one. This is rare.
534 * 539 *
535 * The benefit is that when we have to track a new page table, we can copy keep 540 * The benefit is that when we have to track a new page table, we can keep all
536 * all the kernel mappings. This speeds up context switch immensely. */ 541 * the kernel mappings. This speeds up context switch immensely. */
537void guest_set_pte(struct lg_cpu *cpu, 542void guest_set_pte(struct lg_cpu *cpu,
538 unsigned long gpgdir, unsigned long vaddr, pte_t gpte) 543 unsigned long gpgdir, unsigned long vaddr, pte_t gpte)
539{ 544{
540 /* Kernel mappings must be changed on all top levels. Slow, but 545 /* Kernel mappings must be changed on all top levels. Slow, but doesn't
541 * doesn't happen often. */ 546 * happen often. */
542 if (vaddr >= cpu->lg->kernel_address) { 547 if (vaddr >= cpu->lg->kernel_address) {
543 unsigned int i; 548 unsigned int i;
544 for (i = 0; i < ARRAY_SIZE(cpu->lg->pgdirs); i++) 549 for (i = 0; i < ARRAY_SIZE(cpu->lg->pgdirs); i++)
@@ -704,12 +709,11 @@ static __init void populate_switcher_pte_page(unsigned int cpu,
704/* We've made it through the page table code. Perhaps our tired brains are 709/* We've made it through the page table code. Perhaps our tired brains are
705 * still processing the details, or perhaps we're simply glad it's over. 710 * still processing the details, or perhaps we're simply glad it's over.
706 * 711 *
707 * If nothing else, note that all this complexity in juggling shadow page 712 * If nothing else, note that all this complexity in juggling shadow page tables
708 * tables in sync with the Guest's page tables is for one reason: for most 713 * in sync with the Guest's page tables is for one reason: for most Guests this
709 * Guests this page table dance determines how bad performance will be. This 714 * page table dance determines how bad performance will be. This is why Xen
710 * is why Xen uses exotic direct Guest pagetable manipulation, and why both 715 * uses exotic direct Guest pagetable manipulation, and why both Intel and AMD
711 * Intel and AMD have implemented shadow page table support directly into 716 * have implemented shadow page table support directly into hardware.
712 * hardware.
713 * 717 *
714 * There is just one file remaining in the Host. */ 718 * There is just one file remaining in the Host. */
715 719
diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
index 635187812d52..5126d5d9ea0e 100644
--- a/drivers/lguest/x86/core.c
+++ b/drivers/lguest/x86/core.c
@@ -17,6 +17,13 @@
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 19 */
20/*P:450 This file contains the x86-specific lguest code. It used to be all
21 * mixed in with drivers/lguest/core.c but several foolhardy code slashers
22 * wrestled most of the dependencies out to here in preparation for porting
23 * lguest to other architectures (see what I mean by foolhardy?).
24 *
25 * This also contains a couple of non-obvious setup and teardown pieces which
26 * were implemented after days of debugging pain. :*/
20#include <linux/kernel.h> 27#include <linux/kernel.h>
21#include <linux/start_kernel.h> 28#include <linux/start_kernel.h>
22#include <linux/string.h> 29#include <linux/string.h>
@@ -157,6 +164,8 @@ static void run_guest_once(struct lg_cpu *cpu, struct lguest_pages *pages)
157 * also simplify copy_in_guest_info(). Note that we'd still need to restore 164 * also simplify copy_in_guest_info(). Note that we'd still need to restore
158 * things when we exit to Launcher userspace, but that's fairly easy. 165 * things when we exit to Launcher userspace, but that's fairly easy.
159 * 166 *
167 * We could also try using this hooks for PGE, but that might be too expensive.
168 *
160 * The hooks were designed for KVM, but we can also put them to good use. :*/ 169 * The hooks were designed for KVM, but we can also put them to good use. :*/
161 170
162/*H:040 This is the i386-specific code to setup and run the Guest. Interrupts 171/*H:040 This is the i386-specific code to setup and run the Guest. Interrupts
@@ -182,7 +191,7 @@ void lguest_arch_run_guest(struct lg_cpu *cpu)
182 * was doing. */ 191 * was doing. */
183 run_guest_once(cpu, lguest_pages(raw_smp_processor_id())); 192 run_guest_once(cpu, lguest_pages(raw_smp_processor_id()));
184 193
185 /* Note that the "regs" pointer contains two extra entries which are 194 /* Note that the "regs" structure contains two extra entries which are
186 * not really registers: a trap number which says what interrupt or 195 * not really registers: a trap number which says what interrupt or
187 * trap made the switcher code come back, and an error code which some 196 * trap made the switcher code come back, and an error code which some
188 * traps set. */ 197 * traps set. */
@@ -293,11 +302,10 @@ void lguest_arch_handle_trap(struct lg_cpu *cpu)
293 break; 302 break;
294 case 14: /* We've intercepted a Page Fault. */ 303 case 14: /* We've intercepted a Page Fault. */
295 /* The Guest accessed a virtual address that wasn't mapped. 304 /* The Guest accessed a virtual address that wasn't mapped.
296 * This happens a lot: we don't actually set up most of the 305 * This happens a lot: we don't actually set up most of the page
297 * page tables for the Guest at all when we start: as it runs 306 * tables for the Guest at all when we start: as it runs it asks
298 * it asks for more and more, and we set them up as 307 * for more and more, and we set them up as required. In this
299 * required. In this case, we don't even tell the Guest that 308 * case, we don't even tell the Guest that the fault happened.
300 * the fault happened.
301 * 309 *
302 * The errcode tells whether this was a read or a write, and 310 * The errcode tells whether this was a read or a write, and
303 * whether kernel or userspace code. */ 311 * whether kernel or userspace code. */
@@ -342,7 +350,7 @@ void lguest_arch_handle_trap(struct lg_cpu *cpu)
342 if (!deliver_trap(cpu, cpu->regs->trapnum)) 350 if (!deliver_trap(cpu, cpu->regs->trapnum))
343 /* If the Guest doesn't have a handler (either it hasn't 351 /* If the Guest doesn't have a handler (either it hasn't
344 * registered any yet, or it's one of the faults we don't let 352 * registered any yet, or it's one of the faults we don't let
345 * it handle), it dies with a cryptic error message. */ 353 * it handle), it dies with this cryptic error message. */
346 kill_guest(cpu, "unhandled trap %li at %#lx (%#lx)", 354 kill_guest(cpu, "unhandled trap %li at %#lx (%#lx)",
347 cpu->regs->trapnum, cpu->regs->eip, 355 cpu->regs->trapnum, cpu->regs->eip,
348 cpu->regs->trapnum == 14 ? cpu->arch.last_pagefault 356 cpu->regs->trapnum == 14 ? cpu->arch.last_pagefault
@@ -375,8 +383,8 @@ void __init lguest_arch_host_init(void)
375 * The only exception is the interrupt handlers in switcher.S: their 383 * The only exception is the interrupt handlers in switcher.S: their
376 * addresses are placed in a table (default_idt_entries), so we need to 384 * addresses are placed in a table (default_idt_entries), so we need to
377 * update the table with the new addresses. switcher_offset() is a 385 * update the table with the new addresses. switcher_offset() is a
378 * convenience function which returns the distance between the builtin 386 * convenience function which returns the distance between the
379 * switcher code and the high-mapped copy we just made. */ 387 * compiled-in switcher code and the high-mapped copy we just made. */
380 for (i = 0; i < IDT_ENTRIES; i++) 388 for (i = 0; i < IDT_ENTRIES; i++)
381 default_idt_entries[i] += switcher_offset(); 389 default_idt_entries[i] += switcher_offset();
382 390
@@ -416,7 +424,7 @@ void __init lguest_arch_host_init(void)
416 state->guest_gdt_desc.address = (long)&state->guest_gdt; 424 state->guest_gdt_desc.address = (long)&state->guest_gdt;
417 425
418 /* We know where we want the stack to be when the Guest enters 426 /* We know where we want the stack to be when the Guest enters
419 * the switcher: in pages->regs. The stack grows upwards, so 427 * the Switcher: in pages->regs. The stack grows upwards, so
420 * we start it at the end of that structure. */ 428 * we start it at the end of that structure. */
421 state->guest_tss.sp0 = (long)(&pages->regs + 1); 429 state->guest_tss.sp0 = (long)(&pages->regs + 1);
422 /* And this is the GDT entry to use for the stack: we keep a 430 /* And this is the GDT entry to use for the stack: we keep a
@@ -513,8 +521,8 @@ int lguest_arch_init_hypercalls(struct lg_cpu *cpu)
513{ 521{
514 u32 tsc_speed; 522 u32 tsc_speed;
515 523
516 /* The pointer to the Guest's "struct lguest_data" is the only 524 /* The pointer to the Guest's "struct lguest_data" is the only argument.
517 * argument. We check that address now. */ 525 * We check that address now. */
518 if (!lguest_address_ok(cpu->lg, cpu->hcall->arg1, 526 if (!lguest_address_ok(cpu->lg, cpu->hcall->arg1,
519 sizeof(*cpu->lg->lguest_data))) 527 sizeof(*cpu->lg->lguest_data)))
520 return -EFAULT; 528 return -EFAULT;
@@ -546,6 +554,7 @@ int lguest_arch_init_hypercalls(struct lg_cpu *cpu)
546 554
547 return 0; 555 return 0;
548} 556}
557/*:*/
549 558
550/*L:030 lguest_arch_setup_regs() 559/*L:030 lguest_arch_setup_regs()
551 * 560 *
diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
index 0af8baaa0d4a..3fc15318a80f 100644
--- a/drivers/lguest/x86/switcher_32.S
+++ b/drivers/lguest/x86/switcher_32.S
@@ -1,6 +1,6 @@
1/*P:900 This is the Switcher: code which sits at 0xFFC00000 to do the low-level 1/*P:900 This is the Switcher: code which sits at 0xFFC00000 astride both the
2 * Guest<->Host switch. It is as simple as it can be made, but it's naturally 2 * Host and Guest to do the low-level Guest<->Host switch. It is as simple as
3 * very specific to x86. 3 * it can be made, but it's naturally very specific to x86.
4 * 4 *
5 * You have now completed Preparation. If this has whet your appetite; if you 5 * You have now completed Preparation. If this has whet your appetite; if you
6 * are feeling invigorated and refreshed then the next, more challenging stage 6 * are feeling invigorated and refreshed then the next, more challenging stage
@@ -189,7 +189,7 @@ ENTRY(switch_to_guest)
189 // Interrupts are turned back on: we are Guest. 189 // Interrupts are turned back on: we are Guest.
190 iret 190 iret
191 191
192// We treat two paths to switch back to the Host 192// We tread two paths to switch back to the Host
193// Yet both must save Guest state and restore Host 193// Yet both must save Guest state and restore Host
194// So we put the routine in a macro. 194// So we put the routine in a macro.
195#define SWITCH_TO_HOST \ 195#define SWITCH_TO_HOST \
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index b04f98df94ea..835def11419d 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (C) 2003 Christophe Saout <christophe@saout.de> 2 * Copyright (C) 2003 Christophe Saout <christophe@saout.de>
3 * Copyright (C) 2004 Clemens Fruhwirth <clemens@endorphin.org> 3 * Copyright (C) 2004 Clemens Fruhwirth <clemens@endorphin.org>
4 * Copyright (C) 2006-2007 Red Hat, Inc. All rights reserved. 4 * Copyright (C) 2006-2008 Red Hat, Inc. All rights reserved.
5 * 5 *
6 * This file is released under the GPL. 6 * This file is released under the GPL.
7 */ 7 */
@@ -93,6 +93,8 @@ struct crypt_config {
93 93
94 struct workqueue_struct *io_queue; 94 struct workqueue_struct *io_queue;
95 struct workqueue_struct *crypt_queue; 95 struct workqueue_struct *crypt_queue;
96 wait_queue_head_t writeq;
97
96 /* 98 /*
97 * crypto related data 99 * crypto related data
98 */ 100 */
@@ -331,14 +333,7 @@ static void crypt_convert_init(struct crypt_config *cc,
331 ctx->idx_out = bio_out ? bio_out->bi_idx : 0; 333 ctx->idx_out = bio_out ? bio_out->bi_idx : 0;
332 ctx->sector = sector + cc->iv_offset; 334 ctx->sector = sector + cc->iv_offset;
333 init_completion(&ctx->restart); 335 init_completion(&ctx->restart);
334 /* 336 atomic_set(&ctx->pending, 1);
335 * Crypto operation can be asynchronous,
336 * ctx->pending is increased after request submission.
337 * We need to ensure that we don't call the crypt finish
338 * operation before pending got incremented
339 * (dependent on crypt submission return code).
340 */
341 atomic_set(&ctx->pending, 2);
342} 337}
343 338
344static int crypt_convert_block(struct crypt_config *cc, 339static int crypt_convert_block(struct crypt_config *cc,
@@ -411,43 +406,42 @@ static void crypt_alloc_req(struct crypt_config *cc,
411static int crypt_convert(struct crypt_config *cc, 406static int crypt_convert(struct crypt_config *cc,
412 struct convert_context *ctx) 407 struct convert_context *ctx)
413{ 408{
414 int r = 0; 409 int r;
415 410
416 while(ctx->idx_in < ctx->bio_in->bi_vcnt && 411 while(ctx->idx_in < ctx->bio_in->bi_vcnt &&
417 ctx->idx_out < ctx->bio_out->bi_vcnt) { 412 ctx->idx_out < ctx->bio_out->bi_vcnt) {
418 413
419 crypt_alloc_req(cc, ctx); 414 crypt_alloc_req(cc, ctx);
420 415
416 atomic_inc(&ctx->pending);
417
421 r = crypt_convert_block(cc, ctx, cc->req); 418 r = crypt_convert_block(cc, ctx, cc->req);
422 419
423 switch (r) { 420 switch (r) {
421 /* async */
424 case -EBUSY: 422 case -EBUSY:
425 wait_for_completion(&ctx->restart); 423 wait_for_completion(&ctx->restart);
426 INIT_COMPLETION(ctx->restart); 424 INIT_COMPLETION(ctx->restart);
427 /* fall through*/ 425 /* fall through*/
428 case -EINPROGRESS: 426 case -EINPROGRESS:
429 atomic_inc(&ctx->pending);
430 cc->req = NULL; 427 cc->req = NULL;
431 r = 0; 428 ctx->sector++;
432 /* fall through*/ 429 continue;
430
431 /* sync */
433 case 0: 432 case 0:
433 atomic_dec(&ctx->pending);
434 ctx->sector++; 434 ctx->sector++;
435 continue; 435 continue;
436 }
437 436
438 break; 437 /* error */
438 default:
439 atomic_dec(&ctx->pending);
440 return r;
441 }
439 } 442 }
440 443
441 /* 444 return 0;
442 * If there are pending crypto operation run async
443 * code. Otherwise process return code synchronously.
444 * The step of 2 ensures that async finish doesn't
445 * call crypto finish too early.
446 */
447 if (atomic_sub_return(2, &ctx->pending))
448 return -EINPROGRESS;
449
450 return r;
451} 445}
452 446
453static void dm_crypt_bio_destructor(struct bio *bio) 447static void dm_crypt_bio_destructor(struct bio *bio)
@@ -624,8 +618,10 @@ static void kcryptd_io_read(struct dm_crypt_io *io)
624static void kcryptd_io_write(struct dm_crypt_io *io) 618static void kcryptd_io_write(struct dm_crypt_io *io)
625{ 619{
626 struct bio *clone = io->ctx.bio_out; 620 struct bio *clone = io->ctx.bio_out;
621 struct crypt_config *cc = io->target->private;
627 622
628 generic_make_request(clone); 623 generic_make_request(clone);
624 wake_up(&cc->writeq);
629} 625}
630 626
631static void kcryptd_io(struct work_struct *work) 627static void kcryptd_io(struct work_struct *work)
@@ -698,7 +694,8 @@ static void kcryptd_crypt_write_convert_loop(struct dm_crypt_io *io)
698 694
699 r = crypt_convert(cc, &io->ctx); 695 r = crypt_convert(cc, &io->ctx);
700 696
701 if (r != -EINPROGRESS) { 697 if (atomic_dec_and_test(&io->ctx.pending)) {
698 /* processed, no running async crypto */
702 kcryptd_crypt_write_io_submit(io, r, 0); 699 kcryptd_crypt_write_io_submit(io, r, 0);
703 if (unlikely(r < 0)) 700 if (unlikely(r < 0))
704 return; 701 return;
@@ -706,8 +703,12 @@ static void kcryptd_crypt_write_convert_loop(struct dm_crypt_io *io)
706 atomic_inc(&io->pending); 703 atomic_inc(&io->pending);
707 704
708 /* out of memory -> run queues */ 705 /* out of memory -> run queues */
709 if (unlikely(remaining)) 706 if (unlikely(remaining)) {
707 /* wait for async crypto then reinitialize pending */
708 wait_event(cc->writeq, !atomic_read(&io->ctx.pending));
709 atomic_set(&io->ctx.pending, 1);
710 congestion_wait(WRITE, HZ/100); 710 congestion_wait(WRITE, HZ/100);
711 }
711 } 712 }
712} 713}
713 714
@@ -746,7 +747,7 @@ static void kcryptd_crypt_read_convert(struct dm_crypt_io *io)
746 747
747 r = crypt_convert(cc, &io->ctx); 748 r = crypt_convert(cc, &io->ctx);
748 749
749 if (r != -EINPROGRESS) 750 if (atomic_dec_and_test(&io->ctx.pending))
750 kcryptd_crypt_read_done(io, r); 751 kcryptd_crypt_read_done(io, r);
751 752
752 crypt_dec_pending(io); 753 crypt_dec_pending(io);
@@ -1047,6 +1048,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
1047 goto bad_crypt_queue; 1048 goto bad_crypt_queue;
1048 } 1049 }
1049 1050
1051 init_waitqueue_head(&cc->writeq);
1050 ti->private = cc; 1052 ti->private = cc;
1051 return 0; 1053 return 0;
1052 1054
diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c
index b8e342fe7586..8f25f628ef16 100644
--- a/drivers/md/dm-io.c
+++ b/drivers/md/dm-io.c
@@ -114,7 +114,7 @@ static void dec_count(struct io *io, unsigned int region, int error)
114 wake_up_process(io->sleeper); 114 wake_up_process(io->sleeper);
115 115
116 else { 116 else {
117 int r = io->error; 117 unsigned long r = io->error;
118 io_notify_fn fn = io->callback; 118 io_notify_fn fn = io->callback;
119 void *context = io->context; 119 void *context = io->context;
120 120
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index 51605870f898..762cb086bb7f 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -753,7 +753,7 @@ out:
753 * are in the no-sync state. We have to recover these by 753 * are in the no-sync state. We have to recover these by
754 * recopying from the default mirror to all the others. 754 * recopying from the default mirror to all the others.
755 *---------------------------------------------------------------*/ 755 *---------------------------------------------------------------*/
756static void recovery_complete(int read_err, unsigned int write_err, 756static void recovery_complete(int read_err, unsigned long write_err,
757 void *context) 757 void *context)
758{ 758{
759 struct region *reg = (struct region *)context; 759 struct region *reg = (struct region *)context;
@@ -767,7 +767,7 @@ static void recovery_complete(int read_err, unsigned int write_err,
767 } 767 }
768 768
769 if (write_err) { 769 if (write_err) {
770 DMERR_LIMIT("Write error during recovery (error = 0x%x)", 770 DMERR_LIMIT("Write error during recovery (error = 0x%lx)",
771 write_err); 771 write_err);
772 /* 772 /*
773 * Bits correspond to devices (excluding default mirror). 773 * Bits correspond to devices (excluding default mirror).
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index ae24eab8cd81..4dc8a43c034b 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -804,7 +804,7 @@ static void commit_callback(void *context, int success)
804 * Called when the copy I/O has finished. kcopyd actually runs 804 * Called when the copy I/O has finished. kcopyd actually runs
805 * this code so don't block. 805 * this code so don't block.
806 */ 806 */
807static void copy_callback(int read_err, unsigned int write_err, void *context) 807static void copy_callback(int read_err, unsigned long write_err, void *context)
808{ 808{
809 struct dm_snap_pending_exception *pe = context; 809 struct dm_snap_pending_exception *pe = context;
810 struct dm_snapshot *s = pe->snap; 810 struct dm_snapshot *s = pe->snap;
diff --git a/drivers/md/kcopyd.c b/drivers/md/kcopyd.c
index f3831f31223e..e76b52ade690 100644
--- a/drivers/md/kcopyd.c
+++ b/drivers/md/kcopyd.c
@@ -169,7 +169,7 @@ struct kcopyd_job {
169 * Error state of the job. 169 * Error state of the job.
170 */ 170 */
171 int read_err; 171 int read_err;
172 unsigned int write_err; 172 unsigned long write_err;
173 173
174 /* 174 /*
175 * Either READ or WRITE 175 * Either READ or WRITE
@@ -293,7 +293,7 @@ static int run_complete_job(struct kcopyd_job *job)
293{ 293{
294 void *context = job->context; 294 void *context = job->context;
295 int read_err = job->read_err; 295 int read_err = job->read_err;
296 unsigned int write_err = job->write_err; 296 unsigned long write_err = job->write_err;
297 kcopyd_notify_fn fn = job->fn; 297 kcopyd_notify_fn fn = job->fn;
298 struct kcopyd_client *kc = job->kc; 298 struct kcopyd_client *kc = job->kc;
299 299
@@ -396,7 +396,7 @@ static int process_jobs(struct list_head *jobs, int (*fn) (struct kcopyd_job *))
396 if (r < 0) { 396 if (r < 0) {
397 /* error this rogue job */ 397 /* error this rogue job */
398 if (job->rw == WRITE) 398 if (job->rw == WRITE)
399 job->write_err = (unsigned int) -1; 399 job->write_err = (unsigned long) -1L;
400 else 400 else
401 job->read_err = 1; 401 job->read_err = 1;
402 push(&_complete_jobs, job); 402 push(&_complete_jobs, job);
@@ -448,8 +448,8 @@ static void dispatch_job(struct kcopyd_job *job)
448} 448}
449 449
450#define SUB_JOB_SIZE 128 450#define SUB_JOB_SIZE 128
451static void segment_complete(int read_err, 451static void segment_complete(int read_err, unsigned long write_err,
452 unsigned int write_err, void *context) 452 void *context)
453{ 453{
454 /* FIXME: tidy this function */ 454 /* FIXME: tidy this function */
455 sector_t progress = 0; 455 sector_t progress = 0;
diff --git a/drivers/md/kcopyd.h b/drivers/md/kcopyd.h
index 4621ea055c0e..4845f2a0c676 100644
--- a/drivers/md/kcopyd.h
+++ b/drivers/md/kcopyd.h
@@ -32,8 +32,8 @@ void kcopyd_client_destroy(struct kcopyd_client *kc);
32 * read_err is a boolean, 32 * read_err is a boolean,
33 * write_err is a bitset, with 1 bit for each destination region 33 * write_err is a bitset, with 1 bit for each destination region
34 */ 34 */
35typedef void (*kcopyd_notify_fn)(int read_err, 35typedef void (*kcopyd_notify_fn)(int read_err, unsigned long write_err,
36 unsigned int write_err, void *context); 36 void *context);
37 37
38int kcopyd_copy(struct kcopyd_client *kc, struct io_region *from, 38int kcopyd_copy(struct kcopyd_client *kc, struct io_region *from,
39 unsigned int num_dests, struct io_region *dests, 39 unsigned int num_dests, struct io_region *dests,
diff --git a/drivers/memstick/host/tifm_ms.c b/drivers/memstick/host/tifm_ms.c
index eb150dfb637f..8577de4ebb0e 100644
--- a/drivers/memstick/host/tifm_ms.c
+++ b/drivers/memstick/host/tifm_ms.c
@@ -182,7 +182,7 @@ static unsigned int tifm_ms_transfer_data(struct tifm_ms *host)
182 struct tifm_dev *sock = host->dev; 182 struct tifm_dev *sock = host->dev;
183 unsigned int length; 183 unsigned int length;
184 unsigned int off; 184 unsigned int off;
185 unsigned int t_size, p_off, p_cnt; 185 unsigned int t_size, p_cnt;
186 unsigned char *buf; 186 unsigned char *buf;
187 struct page *pg; 187 struct page *pg;
188 unsigned long flags = 0; 188 unsigned long flags = 0;
@@ -198,6 +198,8 @@ static unsigned int tifm_ms_transfer_data(struct tifm_ms *host)
198 host->block_pos); 198 host->block_pos);
199 199
200 while (length) { 200 while (length) {
201 unsigned int uninitialized_var(p_off);
202
201 if (host->req->long_data) { 203 if (host->req->long_data) {
202 pg = nth_page(sg_page(&host->req->sg), 204 pg = nth_page(sg_page(&host->req->sg),
203 off >> PAGE_SHIFT); 205 off >> PAGE_SHIFT);
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index f00e04efbe28..bc4649a17b9d 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -202,9 +202,8 @@ static int physmap_flash_suspend(struct platform_device *dev, pm_message_t state
202 int ret = 0; 202 int ret = 0;
203 int i; 203 int i;
204 204
205 if (info) 205 for (i = 0; i < MAX_RESOURCES && info->mtd[i]; i++)
206 for (i = 0; i < MAX_RESOURCES; i++) 206 ret |= info->mtd[i]->suspend(info->mtd[i]);
207 ret |= info->mtd[i]->suspend(info->mtd[i]);
208 207
209 return ret; 208 return ret;
210} 209}
@@ -214,9 +213,9 @@ static int physmap_flash_resume(struct platform_device *dev)
214 struct physmap_flash_info *info = platform_get_drvdata(dev); 213 struct physmap_flash_info *info = platform_get_drvdata(dev);
215 int i; 214 int i;
216 215
217 if (info) 216 for (i = 0; i < MAX_RESOURCES && info->mtd[i]; i++)
218 for (i = 0; i < MAX_RESOURCES; i++) 217 info->mtd[i]->resume(info->mtd[i]);
219 info->mtd[i]->resume(info->mtd[i]); 218
220 return 0; 219 return 0;
221} 220}
222 221
@@ -225,8 +224,8 @@ static void physmap_flash_shutdown(struct platform_device *dev)
225 struct physmap_flash_info *info = platform_get_drvdata(dev); 224 struct physmap_flash_info *info = platform_get_drvdata(dev);
226 int i; 225 int i;
227 226
228 for (i = 0; i < MAX_RESOURCES; i++) 227 for (i = 0; i < MAX_RESOURCES && info->mtd[i]; i++)
229 if (info && info->mtd[i]->suspend(info->mtd[i]) == 0) 228 if (info->mtd[i]->suspend(info->mtd[i]) == 0)
230 info->mtd[i]->resume(info->mtd[i]); 229 info->mtd[i]->resume(info->mtd[i]);
231} 230}
232#else 231#else
diff --git a/drivers/mtd/nand/rtc_from4.c b/drivers/mtd/nand/rtc_from4.c
index 9189ec8f243e..0f6ac250f434 100644
--- a/drivers/mtd/nand/rtc_from4.c
+++ b/drivers/mtd/nand/rtc_from4.c
@@ -460,7 +460,7 @@ static int rtc_from4_errstat(struct mtd_info *mtd, struct nand_chip *this,
460 er_stat |= 1 << 1; 460 er_stat |= 1 << 1;
461 kfree(buf); 461 kfree(buf);
462 } 462 }
463 463out:
464 rtn = status; 464 rtn = status;
465 if (er_stat == 0) { /* if ECC is available */ 465 if (er_stat == 0) { /* if ECC is available */
466 rtn = (status & ~NAND_STATUS_FAIL); /* clear the error bit */ 466 rtn = (status & ~NAND_STATUS_FAIL); /* clear the error bit */
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index e9a333d98552..e887aa45c9cd 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -951,6 +951,12 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82375, quirk_e
951 * accesses to the SMBus registers, with potentially bad effects. Thus you 951 * accesses to the SMBus registers, with potentially bad effects. Thus you
952 * should be very careful when adding new entries: if SMM is accessing the 952 * should be very careful when adding new entries: if SMM is accessing the
953 * Intel SMBus, this is a very good reason to leave it hidden. 953 * Intel SMBus, this is a very good reason to leave it hidden.
954 *
955 * Likewise, many recent laptops use ACPI for thermal management. If the
956 * ACPI DSDT code accesses the SMBus, then Linux should not access it
957 * natively, and keeping the SMBus hidden is the right thing to do. If you
958 * are about to add an entry in the table below, please first disassemble
959 * the DSDT and double-check that there is no code accessing the SMBus.
954 */ 960 */
955static int asus_hides_smbus; 961static int asus_hides_smbus;
956 962
@@ -1028,11 +1034,6 @@ static void __init asus_hides_smbus_hostbridge(struct pci_dev *dev)
1028 case 0x12bf: /* HP xw4100 */ 1034 case 0x12bf: /* HP xw4100 */
1029 asus_hides_smbus = 1; 1035 asus_hides_smbus = 1;
1030 } 1036 }
1031 else if (dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB)
1032 switch (dev->subsystem_device) {
1033 case 0x099c: /* HP Compaq nx6110 */
1034 asus_hides_smbus = 1;
1035 }
1036 } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG)) { 1037 } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG)) {
1037 if (dev->device == PCI_DEVICE_ID_INTEL_82855PM_HB) 1038 if (dev->device == PCI_DEVICE_ID_INTEL_82855PM_HB)
1038 switch(dev->subsystem_device) { 1039 switch(dev->subsystem_device) {
diff --git a/drivers/video/bf54x-lq043fb.c b/drivers/video/bf54x-lq043fb.c
index 986a550c0439..eefba3d0e4b9 100644
--- a/drivers/video/bf54x-lq043fb.c
+++ b/drivers/video/bf54x-lq043fb.c
@@ -384,7 +384,7 @@ static int bfin_bf54x_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
384 * Other flags can be set, and are documented in 384 * Other flags can be set, and are documented in
385 * include/linux/mm.h 385 * include/linux/mm.h
386 */ 386 */
387 vma->vm_flags |= VM_MAYSHARE; 387 vma->vm_flags |= VM_MAYSHARE | VM_SHARED;
388 388
389 return 0; 389 return 0;
390} 390}
diff --git a/drivers/video/bfin-t350mcqb-fb.c b/drivers/video/bfin-t350mcqb-fb.c
index a2bb2de9e020..135d6dd7e672 100644
--- a/drivers/video/bfin-t350mcqb-fb.c
+++ b/drivers/video/bfin-t350mcqb-fb.c
@@ -91,6 +91,7 @@ struct bfin_t350mcqbfb_info {
91 int lq043_open_cnt; 91 int lq043_open_cnt;
92 int irq; 92 int irq;
93 spinlock_t lock; /* lock */ 93 spinlock_t lock; /* lock */
94 u32 pseudo_pal[16];
94}; 95};
95 96
96static int nocursor; 97static int nocursor;
@@ -182,13 +183,13 @@ static void bfin_t350mcqb_config_dma(struct bfin_t350mcqbfb_info *fbi)
182 183
183} 184}
184 185
185static int bfin_t350mcqb_request_ports(int action) 186static u16 ppi0_req_8[] = {P_PPI0_CLK, P_PPI0_FS1, P_PPI0_FS2,
186{
187 u16 ppi0_req_8[] = {P_PPI0_CLK, P_PPI0_FS1, P_PPI0_FS2,
188 P_PPI0_D0, P_PPI0_D1, P_PPI0_D2, 187 P_PPI0_D0, P_PPI0_D1, P_PPI0_D2,
189 P_PPI0_D3, P_PPI0_D4, P_PPI0_D5, 188 P_PPI0_D3, P_PPI0_D4, P_PPI0_D5,
190 P_PPI0_D6, P_PPI0_D7, 0}; 189 P_PPI0_D6, P_PPI0_D7, 0};
191 190
191static int bfin_t350mcqb_request_ports(int action)
192{
192 if (action) { 193 if (action) {
193 if (peripheral_request_list(ppi0_req_8, DRIVER_NAME)) { 194 if (peripheral_request_list(ppi0_req_8, DRIVER_NAME)) {
194 printk(KERN_ERR "Requesting Peripherals faild\n"); 195 printk(KERN_ERR "Requesting Peripherals faild\n");
@@ -301,7 +302,7 @@ static int bfin_t350mcqb_fb_mmap(struct fb_info *info, struct vm_area_struct *vm
301 * Other flags can be set, and are documented in 302 * Other flags can be set, and are documented in
302 * include/linux/mm.h 303 * include/linux/mm.h
303 */ 304 */
304 vma->vm_flags |= VM_MAYSHARE; 305 vma->vm_flags |= VM_MAYSHARE | VM_SHARED;
305 306
306 return 0; 307 return 0;
307} 308}
@@ -520,16 +521,7 @@ static int __init bfin_t350mcqb_probe(struct platform_device *pdev)
520 521
521 fbinfo->fbops = &bfin_t350mcqb_fb_ops; 522 fbinfo->fbops = &bfin_t350mcqb_fb_ops;
522 523
523 fbinfo->pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL); 524 fbinfo->pseudo_palette = &info->pseudo_pal;
524 if (!fbinfo->pseudo_palette) {
525 printk(KERN_ERR DRIVER_NAME
526 "Fail to allocate pseudo_palette\n");
527
528 ret = -ENOMEM;
529 goto out4;
530 }
531
532 memset(fbinfo->pseudo_palette, 0, sizeof(u32) * 16);
533 525
534 if (fb_alloc_cmap(&fbinfo->cmap, BFIN_LCD_NBR_PALETTE_ENTRIES, 0) 526 if (fb_alloc_cmap(&fbinfo->cmap, BFIN_LCD_NBR_PALETTE_ENTRIES, 0)
535 < 0) { 527 < 0) {
@@ -537,7 +529,7 @@ static int __init bfin_t350mcqb_probe(struct platform_device *pdev)
537 "Fail to allocate colormap (%d entries)\n", 529 "Fail to allocate colormap (%d entries)\n",
538 BFIN_LCD_NBR_PALETTE_ENTRIES); 530 BFIN_LCD_NBR_PALETTE_ENTRIES);
539 ret = -EFAULT; 531 ret = -EFAULT;
540 goto out5; 532 goto out4;
541 } 533 }
542 534
543 if (bfin_t350mcqb_request_ports(1)) { 535 if (bfin_t350mcqb_request_ports(1)) {
@@ -552,11 +544,11 @@ static int __init bfin_t350mcqb_probe(struct platform_device *pdev)
552 goto out7; 544 goto out7;
553 } 545 }
554 546
555 if (request_irq(info->irq, (void *)bfin_t350mcqb_irq_error, IRQF_DISABLED, 547 ret = request_irq(info->irq, bfin_t350mcqb_irq_error, IRQF_DISABLED,
556 "PPI ERROR", info) < 0) { 548 "PPI ERROR", info);
549 if (ret < 0) {
557 printk(KERN_ERR DRIVER_NAME 550 printk(KERN_ERR DRIVER_NAME
558 ": unable to request PPI ERROR IRQ\n"); 551 ": unable to request PPI ERROR IRQ\n");
559 ret = -EFAULT;
560 goto out7; 552 goto out7;
561 } 553 }
562 554
@@ -584,8 +576,6 @@ out7:
584 bfin_t350mcqb_request_ports(0); 576 bfin_t350mcqb_request_ports(0);
585out6: 577out6:
586 fb_dealloc_cmap(&fbinfo->cmap); 578 fb_dealloc_cmap(&fbinfo->cmap);
587out5:
588 kfree(fbinfo->pseudo_palette);
589out4: 579out4:
590 dma_free_coherent(NULL, fbinfo->fix.smem_len, info->fb_buffer, 580 dma_free_coherent(NULL, fbinfo->fix.smem_len, info->fb_buffer,
591 info->dma_handle); 581 info->dma_handle);
@@ -605,6 +595,8 @@ static int bfin_t350mcqb_remove(struct platform_device *pdev)
605 struct fb_info *fbinfo = platform_get_drvdata(pdev); 595 struct fb_info *fbinfo = platform_get_drvdata(pdev);
606 struct bfin_t350mcqbfb_info *info = fbinfo->par; 596 struct bfin_t350mcqbfb_info *info = fbinfo->par;
607 597
598 unregister_framebuffer(fbinfo);
599
608 free_dma(CH_PPI); 600 free_dma(CH_PPI);
609 free_irq(info->irq, info); 601 free_irq(info->irq, info);
610 602
@@ -612,7 +604,6 @@ static int bfin_t350mcqb_remove(struct platform_device *pdev)
612 dma_free_coherent(NULL, fbinfo->fix.smem_len, info->fb_buffer, 604 dma_free_coherent(NULL, fbinfo->fix.smem_len, info->fb_buffer,
613 info->dma_handle); 605 info->dma_handle);
614 606
615 kfree(fbinfo->pseudo_palette);
616 fb_dealloc_cmap(&fbinfo->cmap); 607 fb_dealloc_cmap(&fbinfo->cmap);
617 608
618#ifndef NO_BL_SUPPORT 609#ifndef NO_BL_SUPPORT
@@ -620,10 +611,11 @@ static int bfin_t350mcqb_remove(struct platform_device *pdev)
620 backlight_device_unregister(bl_dev); 611 backlight_device_unregister(bl_dev);
621#endif 612#endif
622 613
623 unregister_framebuffer(fbinfo);
624
625 bfin_t350mcqb_request_ports(0); 614 bfin_t350mcqb_request_ports(0);
626 615
616 platform_set_drvdata(pdev, NULL);
617 framebuffer_release(fbinfo);
618
627 printk(KERN_INFO DRIVER_NAME ": Unregister LCD driver.\n"); 619 printk(KERN_INFO DRIVER_NAME ": Unregister LCD driver.\n");
628 620
629 return 0; 621 return 0;
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index 59a8f73dec73..6c8ecde6aad1 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -388,6 +388,7 @@ static void __devexit virtio_pci_remove(struct pci_dev *pci_dev)
388{ 388{
389 struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev); 389 struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
390 390
391 unregister_virtio_device(&vp_dev->vdev);
391 free_irq(pci_dev->irq, vp_dev); 392 free_irq(pci_dev->irq, vp_dev);
392 pci_set_drvdata(pci_dev, NULL); 393 pci_set_drvdata(pci_dev, NULL);
393 pci_iounmap(pci_dev, vp_dev->ioaddr); 394 pci_iounmap(pci_dev, vp_dev->ioaddr);
diff --git a/fs/afs/cell.c b/fs/afs/cell.c
index 970d38f30565..788865df1bc9 100644
--- a/fs/afs/cell.c
+++ b/fs/afs/cell.c
@@ -127,14 +127,20 @@ struct afs_cell *afs_cell_create(const char *name, char *vllist)
127 127
128 _enter("%s,%s", name, vllist); 128 _enter("%s,%s", name, vllist);
129 129
130 down_write(&afs_cells_sem);
131 read_lock(&afs_cells_lock);
132 list_for_each_entry(cell, &afs_cells, link) {
133 if (strcasecmp(cell->name, name) == 0)
134 goto duplicate_name;
135 }
136 read_unlock(&afs_cells_lock);
137
130 cell = afs_cell_alloc(name, vllist); 138 cell = afs_cell_alloc(name, vllist);
131 if (IS_ERR(cell)) { 139 if (IS_ERR(cell)) {
132 _leave(" = %ld", PTR_ERR(cell)); 140 _leave(" = %ld", PTR_ERR(cell));
133 return cell; 141 return cell;
134 } 142 }
135 143
136 down_write(&afs_cells_sem);
137
138 /* add a proc directory for this cell */ 144 /* add a proc directory for this cell */
139 ret = afs_proc_cell_setup(cell); 145 ret = afs_proc_cell_setup(cell);
140 if (ret < 0) 146 if (ret < 0)
@@ -167,6 +173,11 @@ error:
167 kfree(cell); 173 kfree(cell);
168 _leave(" = %d", ret); 174 _leave(" = %d", ret);
169 return ERR_PTR(ret); 175 return ERR_PTR(ret);
176
177duplicate_name:
178 read_unlock(&afs_cells_lock);
179 up_write(&afs_cells_sem);
180 return ERR_PTR(-EEXIST);
170} 181}
171 182
172/* 183/*
diff --git a/fs/buffer.c b/fs/buffer.c
index 7ba58386beee..98196327ddf0 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -2564,14 +2564,13 @@ int nobh_write_end(struct file *file, struct address_space *mapping,
2564 struct inode *inode = page->mapping->host; 2564 struct inode *inode = page->mapping->host;
2565 struct buffer_head *head = fsdata; 2565 struct buffer_head *head = fsdata;
2566 struct buffer_head *bh; 2566 struct buffer_head *bh;
2567 BUG_ON(fsdata != NULL && page_has_buffers(page));
2567 2568
2568 if (!PageMappedToDisk(page)) { 2569 if (unlikely(copied < len) && !page_has_buffers(page))
2569 if (unlikely(copied < len) && !page_has_buffers(page)) 2570 attach_nobh_buffers(page, head);
2570 attach_nobh_buffers(page, head); 2571 if (page_has_buffers(page))
2571 if (page_has_buffers(page)) 2572 return generic_write_end(file, mapping, pos, len,
2572 return generic_write_end(file, mapping, pos, len, 2573 copied, page, fsdata);
2573 copied, page, fsdata);
2574 }
2575 2574
2576 SetPageUptodate(page); 2575 SetPageUptodate(page);
2577 set_page_dirty(page); 2576 set_page_dirty(page);
diff --git a/include/asm-x86/lguest_hcall.h b/include/asm-x86/lguest_hcall.h
index 758b9a5d4539..f239e7069cab 100644
--- a/include/asm-x86/lguest_hcall.h
+++ b/include/asm-x86/lguest_hcall.h
@@ -27,7 +27,7 @@
27#ifndef __ASSEMBLY__ 27#ifndef __ASSEMBLY__
28#include <asm/hw_irq.h> 28#include <asm/hw_irq.h>
29 29
30/*G:031 First, how does our Guest contact the Host to ask for privileged 30/*G:031 But first, how does our Guest contact the Host to ask for privileged
31 * operations? There are two ways: the direct way is to make a "hypercall", 31 * operations? There are two ways: the direct way is to make a "hypercall",
32 * to make requests of the Host Itself. 32 * to make requests of the Host Itself.
33 * 33 *
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index 4108b38ebb16..4a446a19295e 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -195,7 +195,6 @@ unifdef-y += ethtool.h
195unifdef-y += eventpoll.h 195unifdef-y += eventpoll.h
196unifdef-y += signalfd.h 196unifdef-y += signalfd.h
197unifdef-y += ext2_fs.h 197unifdef-y += ext2_fs.h
198unifdef-y += ext3_fs.h
199unifdef-y += fb.h 198unifdef-y += fb.h
200unifdef-y += fcntl.h 199unifdef-y += fcntl.h
201unifdef-y += filter.h 200unifdef-y += filter.h
@@ -248,7 +247,6 @@ unifdef-y += isdn.h
248unifdef-y += isdnif.h 247unifdef-y += isdnif.h
249unifdef-y += isdn_divertif.h 248unifdef-y += isdn_divertif.h
250unifdef-y += isdn_ppp.h 249unifdef-y += isdn_ppp.h
251unifdef-y += jbd.h
252unifdef-y += joystick.h 250unifdef-y += joystick.h
253unifdef-y += kdev_t.h 251unifdef-y += kdev_t.h
254unifdef-y += kd.h 252unifdef-y += kd.h
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 69c1edb9fe54..40d54731de7e 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -65,6 +65,46 @@ static inline __u32 ror32(__u32 word, unsigned int shift)
65 return (word >> shift) | (word << (32 - shift)); 65 return (word >> shift) | (word << (32 - shift));
66} 66}
67 67
68/**
69 * rol16 - rotate a 16-bit value left
70 * @word: value to rotate
71 * @shift: bits to roll
72 */
73static inline __u16 rol16(__u16 word, unsigned int shift)
74{
75 return (word << shift) | (word >> (16 - shift));
76}
77
78/**
79 * ror16 - rotate a 16-bit value right
80 * @word: value to rotate
81 * @shift: bits to roll
82 */
83static inline __u16 ror16(__u16 word, unsigned int shift)
84{
85 return (word >> shift) | (word << (16 - shift));
86}
87
88/**
89 * rol8 - rotate an 8-bit value left
90 * @word: value to rotate
91 * @shift: bits to roll
92 */
93static inline __u8 rol8(__u8 word, unsigned int shift)
94{
95 return (word << shift) | (word >> (8 - shift));
96}
97
98/**
99 * ror8 - rotate an 8-bit value right
100 * @word: value to rotate
101 * @shift: bits to roll
102 */
103static inline __u8 ror8(__u8 word, unsigned int shift)
104{
105 return (word >> shift) | (word << (8 - shift));
106}
107
68static inline unsigned fls_long(unsigned long l) 108static inline unsigned fls_long(unsigned long l)
69{ 109{
70 if (sizeof(l) == 4) 110 if (sizeof(l) == 4)
diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
index 49829988bfa0..897f723bd222 100644
--- a/include/linux/hardirq.h
+++ b/include/linux/hardirq.h
@@ -72,6 +72,13 @@
72#define in_softirq() (softirq_count()) 72#define in_softirq() (softirq_count())
73#define in_interrupt() (irq_count()) 73#define in_interrupt() (irq_count())
74 74
75/*
76 * Are we running in atomic context? WARNING: this macro cannot
77 * always detect atomic context; in particular, it cannot know about
78 * held spinlocks in non-preemptible kernels. Thus it should not be
79 * used in the general case to determine whether sleeping is possible.
80 * Do not use in_atomic() in driver code.
81 */
75#define in_atomic() ((preempt_count() & ~PREEMPT_ACTIVE) != 0) 82#define in_atomic() ((preempt_count() & ~PREEMPT_ACTIVE) != 0)
76 83
77#ifdef CONFIG_PREEMPT 84#ifdef CONFIG_PREEMPT
diff --git a/include/linux/lguest_launcher.h b/include/linux/lguest_launcher.h
index 589be3e1f3ac..e7217dc58f39 100644
--- a/include/linux/lguest_launcher.h
+++ b/include/linux/lguest_launcher.h
@@ -16,6 +16,10 @@
16 * a new device, we simply need to write a new virtio driver and create support 16 * a new device, we simply need to write a new virtio driver and create support
17 * for it in the Launcher: this code won't need to change. 17 * for it in the Launcher: this code won't need to change.
18 * 18 *
19 * Virtio devices are also used by kvm, so we can simply reuse their optimized
20 * device drivers. And one day when everyone uses virtio, my plan will be
21 * complete. Bwahahahah!
22 *
19 * Devices are described by a simplified ID, a status byte, and some "config" 23 * Devices are described by a simplified ID, a status byte, and some "config"
20 * bytes which describe this device's configuration. This is placed by the 24 * bytes which describe this device's configuration. This is placed by the
21 * Launcher just above the top of physical memory: 25 * Launcher just above the top of physical memory:
@@ -26,7 +30,7 @@ struct lguest_device_desc {
26 /* The number of virtqueues (first in config array) */ 30 /* The number of virtqueues (first in config array) */
27 __u8 num_vq; 31 __u8 num_vq;
28 /* The number of bytes of feature bits. Multiply by 2: one for host 32 /* The number of bytes of feature bits. Multiply by 2: one for host
29 * features and one for guest acknowledgements. */ 33 * features and one for Guest acknowledgements. */
30 __u8 feature_len; 34 __u8 feature_len;
31 /* The number of bytes of the config array after virtqueues. */ 35 /* The number of bytes of the config array after virtqueues. */
32 __u8 config_len; 36 __u8 config_len;
diff --git a/kernel/audit.c b/kernel/audit.c
index be55cb503633..b782b046543d 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1269,8 +1269,8 @@ static void audit_log_n_string(struct audit_buffer *ab, size_t slen,
1269 1269
1270/** 1270/**
1271 * audit_string_contains_control - does a string need to be logged in hex 1271 * audit_string_contains_control - does a string need to be logged in hex
1272 * @string - string to be checked 1272 * @string: string to be checked
1273 * @len - max length of the string to check 1273 * @len: max length of the string to check
1274 */ 1274 */
1275int audit_string_contains_control(const char *string, size_t len) 1275int audit_string_contains_control(const char *string, size_t len)
1276{ 1276{
@@ -1285,7 +1285,7 @@ int audit_string_contains_control(const char *string, size_t len)
1285/** 1285/**
1286 * audit_log_n_untrustedstring - log a string that may contain random characters 1286 * audit_log_n_untrustedstring - log a string that may contain random characters
1287 * @ab: audit_buffer 1287 * @ab: audit_buffer
1288 * @len: lenth of string (not including trailing null) 1288 * @len: length of string (not including trailing null)
1289 * @string: string to be logged 1289 * @string: string to be logged
1290 * 1290 *
1291 * This code will escape a string that is passed to it if the string 1291 * This code will escape a string that is passed to it if the string
diff --git a/kernel/fork.c b/kernel/fork.c
index dd249c37b3a3..9c042f901570 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -394,7 +394,6 @@ void __mmdrop(struct mm_struct *mm)
394{ 394{
395 BUG_ON(mm == &init_mm); 395 BUG_ON(mm == &init_mm);
396 mm_free_pgd(mm); 396 mm_free_pgd(mm);
397 mm_free_cgroup(mm);
398 destroy_context(mm); 397 destroy_context(mm);
399 free_mm(mm); 398 free_mm(mm);
400} 399}
@@ -416,6 +415,7 @@ void mmput(struct mm_struct *mm)
416 spin_unlock(&mmlist_lock); 415 spin_unlock(&mmlist_lock);
417 } 416 }
418 put_swap_token(mm); 417 put_swap_token(mm);
418 mm_free_cgroup(mm);
419 mmdrop(mm); 419 mmdrop(mm);
420 } 420 }
421} 421}
diff --git a/mm/slub.c b/mm/slub.c
index b72bc98e2dc1..84ed734b96b3 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1470,6 +1470,9 @@ static void *__slab_alloc(struct kmem_cache *s,
1470 void **object; 1470 void **object;
1471 struct page *new; 1471 struct page *new;
1472 1472
1473 /* We handle __GFP_ZERO in the caller */
1474 gfpflags &= ~__GFP_ZERO;
1475
1473 if (!c->page) 1476 if (!c->page)
1474 goto new_slab; 1477 goto new_slab;
1475 1478
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index 4e8d4e724b96..f624dff76852 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -1520,7 +1520,7 @@ static int __init p9_trans_fd_init(void)
1520 v9fs_register_trans(&p9_unix_trans); 1520 v9fs_register_trans(&p9_unix_trans);
1521 v9fs_register_trans(&p9_fd_trans); 1521 v9fs_register_trans(&p9_fd_trans);
1522 1522
1523 return 1; 1523 return 0;
1524} 1524}
1525 1525
1526module_init(p9_trans_fd_init); 1526module_init(p9_trans_fd_init);
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2a7cef9726e4..58a94947d655 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -9,7 +9,7 @@ use strict;
9my $P = $0; 9my $P = $0;
10$P =~ s@.*/@@g; 10$P =~ s@.*/@@g;
11 11
12my $V = '0.15'; 12my $V = '0.16';
13 13
14use Getopt::Long qw(:config no_auto_abbrev); 14use Getopt::Long qw(:config no_auto_abbrev);
15 15
@@ -18,6 +18,7 @@ my $tree = 1;
18my $chk_signoff = 1; 18my $chk_signoff = 1;
19my $chk_patch = 1; 19my $chk_patch = 1;
20my $tst_type = 0; 20my $tst_type = 0;
21my $tst_only;
21my $emacs = 0; 22my $emacs = 0;
22my $terse = 0; 23my $terse = 0;
23my $file = 0; 24my $file = 0;
@@ -44,6 +45,7 @@ GetOptions(
44 45
45 'debug=s' => \%debug, 46 'debug=s' => \%debug,
46 'test-type!' => \$tst_type, 47 'test-type!' => \$tst_type,
48 'test-only=s' => \$tst_only,
47) or exit; 49) or exit;
48 50
49my $exit = 0; 51my $exit = 0;
@@ -263,17 +265,7 @@ sub expand_tabs {
263 return $res; 265 return $res;
264} 266}
265sub copy_spacing { 267sub copy_spacing {
266 my ($str) = @_; 268 (my $res = shift) =~ tr/\t/ /c;
267
268 my $res = '';
269 for my $c (split(//, $str)) {
270 if ($c eq "\t") {
271 $res .= $c;
272 } else {
273 $res .= ' ';
274 }
275 }
276
277 return $res; 269 return $res;
278} 270}
279 271
@@ -290,53 +282,76 @@ sub line_stats {
290 return (length($line), length($white)); 282 return (length($line), length($white));
291} 283}
292 284
285my $sanitise_quote = '';
286
287sub sanitise_line_reset {
288 my ($in_comment) = @_;
289
290 if ($in_comment) {
291 $sanitise_quote = '*/';
292 } else {
293 $sanitise_quote = '';
294 }
295}
293sub sanitise_line { 296sub sanitise_line {
294 my ($line) = @_; 297 my ($line) = @_;
295 298
296 my $res = ''; 299 my $res = '';
297 my $l = ''; 300 my $l = '';
298 301
299 my $quote = '';
300 my $qlen = 0; 302 my $qlen = 0;
303 my $off = 0;
304 my $c;
301 305
302 foreach my $c (split(//, $line)) { 306 # Always copy over the diff marker.
303 # The second backslash of a pair is not a "quote". 307 $res = substr($line, 0, 1);
304 if ($l eq "\\" && $c eq "\\") { 308
305 $c = 'X'; 309 for ($off = 1; $off < length($line); $off++) {
306 } 310 $c = substr($line, $off, 1);
307 if ($l ne "\\" && ($c eq "'" || $c eq '"')) { 311
308 if ($quote eq '') { 312 # Comments we are wacking completly including the begin
309 $quote = $c; 313 # and end, all to $;.
310 $res .= $c; 314 if ($sanitise_quote eq '' && substr($line, $off, 2) eq '/*') {
311 $l = $c; 315 $sanitise_quote = '*/';
312 $qlen = 0; 316
313 next; 317 substr($res, $off, 2, "$;$;");
314 } elsif ($quote eq $c) { 318 $off++;
315 $quote = ''; 319 next;
316 }
317 } 320 }
318 if ($quote eq "'" && $qlen > 1) { 321 if (substr($line, $off, 2) eq $sanitise_quote) {
319 $quote = ''; 322 $sanitise_quote = '';
323 substr($res, $off, 2, "$;$;");
324 $off++;
325 next;
320 } 326 }
321 if ($quote && $c ne "\t") { 327
322 $res .= "X"; 328 # A \ in a string means ignore the next character.
323 $qlen++; 329 if (($sanitise_quote eq "'" || $sanitise_quote eq '"') &&
324 } else { 330 $c eq "\\") {
325 $res .= $c; 331 substr($res, $off, 2, 'XX');
332 $off++;
333 next;
326 } 334 }
335 # Regular quotes.
336 if ($c eq "'" || $c eq '"') {
337 if ($sanitise_quote eq '') {
338 $sanitise_quote = $c;
327 339
328 $l = $c; 340 substr($res, $off, 1, $c);
329 } 341 next;
342 } elsif ($sanitise_quote eq $c) {
343 $sanitise_quote = '';
344 }
345 }
330 346
331 # Clear out the comments. 347 #print "SQ:$sanitise_quote\n";
332 while ($res =~ m@(/\*.*?\*/)@g) { 348 if ($off != 0 && $sanitise_quote eq '*/' && $c ne "\t") {
333 substr($res, $-[1], $+[1] - $-[1]) = $; x ($+[1] - $-[1]); 349 substr($res, $off, 1, $;);
334 } 350 } elsif ($off != 0 && $sanitise_quote && $c ne "\t") {
335 if ($res =~ m@(/\*.*)@) { 351 substr($res, $off, 1, 'X');
336 substr($res, $-[1], $+[1] - $-[1]) = $; x ($+[1] - $-[1]); 352 } else {
337 } 353 substr($res, $off, 1, $c);
338 if ($res =~ m@^.(.*\*/)@) { 354 }
339 substr($res, $-[1], $+[1] - $-[1]) = $; x ($+[1] - $-[1]);
340 } 355 }
341 356
342 # The pathname on a #include may be surrounded by '<' and '>'. 357 # The pathname on a #include may be surrounded by '<' and '>'.
@@ -359,6 +374,7 @@ sub ctx_statement_block {
359 my $blk = ''; 374 my $blk = '';
360 my $soff = $off; 375 my $soff = $off;
361 my $coff = $off - 1; 376 my $coff = $off - 1;
377 my $coff_set = 0;
362 378
363 my $loff = 0; 379 my $loff = 0;
364 380
@@ -370,7 +386,7 @@ sub ctx_statement_block {
370 386
371 my $remainder; 387 my $remainder;
372 while (1) { 388 while (1) {
373 #warn "CSB: blk<$blk>\n"; 389 #warn "CSB: blk<$blk> remain<$remain>\n";
374 # If we are about to drop off the end, pull in more 390 # If we are about to drop off the end, pull in more
375 # context. 391 # context.
376 if ($off >= $len) { 392 if ($off >= $len) {
@@ -393,7 +409,7 @@ sub ctx_statement_block {
393 $c = substr($blk, $off, 1); 409 $c = substr($blk, $off, 1);
394 $remainder = substr($blk, $off); 410 $remainder = substr($blk, $off);
395 411
396 #warn "CSB: c<$c> type<$type> level<$level>\n"; 412 #warn "CSB: c<$c> type<$type> level<$level> remainder<$remainder> coff_set<$coff_set>\n";
397 # Statement ends at the ';' or a close '}' at the 413 # Statement ends at the ';' or a close '}' at the
398 # outermost level. 414 # outermost level.
399 if ($level == 0 && $c eq ';') { 415 if ($level == 0 && $c eq ';') {
@@ -401,10 +417,14 @@ sub ctx_statement_block {
401 } 417 }
402 418
403 # An else is really a conditional as long as its not else if 419 # An else is really a conditional as long as its not else if
404 if ($level == 0 && (!defined($p) || $p =~ /(?:\s|\})/) && 420 if ($level == 0 && $coff_set == 0 &&
405 $remainder =~ /(else)(?:\s|{)/ && 421 (!defined($p) || $p =~ /(?:\s|\}|\+)/) &&
406 $remainder !~ /else\s+if\b/) { 422 $remainder =~ /^(else)(?:\s|{)/ &&
407 $coff = $off + length($1); 423 $remainder !~ /^else\s+if\b/) {
424 $coff = $off + length($1) - 1;
425 $coff_set = 1;
426 #warn "CSB: mark coff<$coff> soff<$soff> 1<$1>\n";
427 #warn "[" . substr($blk, $soff, $coff - $soff + 1) . "]\n";
408 } 428 }
409 429
410 if (($type eq '' || $type eq '(') && $c eq '(') { 430 if (($type eq '' || $type eq '(') && $c eq '(') {
@@ -417,6 +437,8 @@ sub ctx_statement_block {
417 437
418 if ($level == 0 && $coff < $soff) { 438 if ($level == 0 && $coff < $soff) {
419 $coff = $off; 439 $coff = $off;
440 $coff_set = 1;
441 #warn "CSB: mark coff<$coff>\n";
420 } 442 }
421 } 443 }
422 if (($type eq '' || $type eq '{') && $c eq '{') { 444 if (($type eq '' || $type eq '{') && $c eq '{') {
@@ -444,7 +466,7 @@ sub ctx_statement_block {
444 #warn "STATEMENT<$statement>\n"; 466 #warn "STATEMENT<$statement>\n";
445 #warn "CONDITION<$condition>\n"; 467 #warn "CONDITION<$condition>\n";
446 468
447 #print "off<$off> loff<$loff>\n"; 469 #print "coff<$coff> soff<$off> loff<$loff>\n";
448 470
449 return ($statement, $condition, 471 return ($statement, $condition,
450 $line, $remain + 1, $off - $loff + 1, $level); 472 $line, $remain + 1, $off - $loff + 1, $level);
@@ -502,7 +524,7 @@ sub ctx_statement_full {
502 # Grab the first conditional/block pair. 524 # Grab the first conditional/block pair.
503 ($statement, $condition, $linenr, $remain, $off, $level) = 525 ($statement, $condition, $linenr, $remain, $off, $level) =
504 ctx_statement_block($linenr, $remain, $off); 526 ctx_statement_block($linenr, $remain, $off);
505 #print "F: c<$condition> s<$statement>\n"; 527 #print "F: c<$condition> s<$statement> remain<$remain>\n";
506 push(@chunks, [ $condition, $statement ]); 528 push(@chunks, [ $condition, $statement ]);
507 if (!($remain > 0 && $condition =~ /^\s*(?:\n[+-])?\s*(?:if|else|do)\b/s)) { 529 if (!($remain > 0 && $condition =~ /^\s*(?:\n[+-])?\s*(?:if|else|do)\b/s)) {
508 return ($level, $linenr, @chunks); 530 return ($level, $linenr, @chunks);
@@ -514,7 +536,7 @@ sub ctx_statement_full {
514 ($statement, $condition, $linenr, $remain, $off, $level) = 536 ($statement, $condition, $linenr, $remain, $off, $level) =
515 ctx_statement_block($linenr, $remain, $off); 537 ctx_statement_block($linenr, $remain, $off);
516 #print "C: c<$condition> s<$statement> remain<$remain>\n"; 538 #print "C: c<$condition> s<$statement> remain<$remain>\n";
517 last if (!($remain > 0 && $condition =~ /^\s*(?:\n[+-])?\s*(?:else|do)\b/s)); 539 last if (!($remain > 0 && $condition =~ /^(?:\s*\n[+-])*\s*(?:else|do)\b/s));
518 #print "C: push\n"; 540 #print "C: push\n";
519 push(@chunks, [ $condition, $statement ]); 541 push(@chunks, [ $condition, $statement ]);
520 } 542 }
@@ -668,6 +690,7 @@ sub annotate_values {
668 print "$stream\n" if ($dbg_values > 1); 690 print "$stream\n" if ($dbg_values > 1);
669 691
670 while (length($cur)) { 692 while (length($cur)) {
693 @av_paren_type = ('E') if ($#av_paren_type < 0);
671 print " <" . join('', @av_paren_type) . 694 print " <" . join('', @av_paren_type) .
672 "> <$type> " if ($dbg_values > 1); 695 "> <$type> " if ($dbg_values > 1);
673 if ($cur =~ /^(\s+)/o) { 696 if ($cur =~ /^(\s+)/o) {
@@ -804,28 +827,34 @@ sub possible {
804my $prefix = ''; 827my $prefix = '';
805 828
806sub report { 829sub report {
830 if (defined $tst_only && $_[0] !~ /\Q$tst_only\E/) {
831 return 0;
832 }
807 my $line = $prefix . $_[0]; 833 my $line = $prefix . $_[0];
808 834
809 $line = (split('\n', $line))[0] . "\n" if ($terse); 835 $line = (split('\n', $line))[0] . "\n" if ($terse);
810 836
811 push(our @report, $line); 837 push(our @report, $line);
838
839 return 1;
812} 840}
813sub report_dump { 841sub report_dump {
814 our @report; 842 our @report;
815} 843}
816sub ERROR { 844sub ERROR {
817 report("ERROR: $_[0]\n"); 845 if (report("ERROR: $_[0]\n")) {
818 our $clean = 0; 846 our $clean = 0;
819 our $cnt_error++; 847 our $cnt_error++;
848 }
820} 849}
821sub WARN { 850sub WARN {
822 report("WARNING: $_[0]\n"); 851 if (report("WARNING: $_[0]\n")) {
823 our $clean = 0; 852 our $clean = 0;
824 our $cnt_warn++; 853 our $cnt_warn++;
854 }
825} 855}
826sub CHK { 856sub CHK {
827 if ($check) { 857 if ($check && report("CHECK: $_[0]\n")) {
828 report("CHECK: $_[0]\n");
829 our $clean = 0; 858 our $clean = 0;
830 our $cnt_chk++; 859 our $cnt_chk++;
831 } 860 }
@@ -867,30 +896,76 @@ sub process {
867 my $prev_values = 'E'; 896 my $prev_values = 'E';
868 897
869 # suppression flags 898 # suppression flags
870 my $suppress_ifbraces = 0; 899 my %suppress_ifbraces;
871 900
872 # Pre-scan the patch sanitizing the lines. 901 # Pre-scan the patch sanitizing the lines.
873 # Pre-scan the patch looking for any __setup documentation. 902 # Pre-scan the patch looking for any __setup documentation.
874 # 903 #
875 my @setup_docs = (); 904 my @setup_docs = ();
876 my $setup_docs = 0; 905 my $setup_docs = 0;
906
907 sanitise_line_reset();
877 my $line; 908 my $line;
878 foreach my $rawline (@rawlines) { 909 foreach my $rawline (@rawlines) {
879 # Standardise the strings and chars within the input to 910 $linenr++;
880 # simplify matching. 911 $line = $rawline;
881 $line = sanitise_line($rawline);
882 push(@lines, $line);
883
884 ##print "==>$rawline\n";
885 ##print "-->$line\n";
886 912
887 if ($line=~/^\+\+\+\s+(\S+)/) { 913 if ($rawline=~/^\+\+\+\s+(\S+)/) {
888 $setup_docs = 0; 914 $setup_docs = 0;
889 if ($1 =~ m@Documentation/kernel-parameters.txt$@) { 915 if ($1 =~ m@Documentation/kernel-parameters.txt$@) {
890 $setup_docs = 1; 916 $setup_docs = 1;
891 } 917 }
892 next; 918 #next;
919 }
920 if ($rawline=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) {
921 $realline=$1-1;
922 if (defined $2) {
923 $realcnt=$3+1;
924 } else {
925 $realcnt=1+1;
926 }
927
928 # Guestimate if this is a continuing comment. Run
929 # the context looking for a comment "edge". If this
930 # edge is a close comment then we must be in a comment
931 # at context start.
932 my $edge;
933 for (my $ln = $linenr; $ln < ($linenr + $realcnt); $ln++) {
934 next if ($line =~ /^-/);
935 ($edge) = ($rawlines[$ln - 1] =~ m@(/\*|\*/)@);
936 last if (defined $edge);
937 }
938 if (defined $edge && $edge eq '*/') {
939 $in_comment = 1;
940 }
941
942 # Guestimate if this is a continuing comment. If this
943 # is the start of a diff block and this line starts
944 # ' *' then it is very likely a comment.
945 if (!defined $edge &&
946 $rawlines[$linenr] =~ m@^.\s* \*(?:\s|$)@)
947 {
948 $in_comment = 1;
949 }
950
951 ##print "COMMENT:$in_comment edge<$edge> $rawline\n";
952 sanitise_line_reset($in_comment);
953
954 } elsif ($realcnt) {
955 # Standardise the strings and chars within the input to
956 # simplify matching.
957 $line = sanitise_line($rawline);
893 } 958 }
959 push(@lines, $line);
960
961 if ($realcnt > 1) {
962 $realcnt-- if ($line =~ /^(?:\+| |$)/);
963 } else {
964 $realcnt = 0;
965 }
966
967 #print "==>$rawline\n";
968 #print "-->$line\n";
894 969
895 if ($setup_docs && $line =~ /^\+/) { 970 if ($setup_docs && $line =~ /^\+/) {
896 push(@setup_docs, $line); 971 push(@setup_docs, $line);
@@ -899,23 +974,17 @@ sub process {
899 974
900 $prefix = ''; 975 $prefix = '';
901 976
977 $realcnt = 0;
978 $linenr = 0;
902 foreach my $line (@lines) { 979 foreach my $line (@lines) {
903 $linenr++; 980 $linenr++;
904 981
905 my $rawline = $rawlines[$linenr - 1]; 982 my $rawline = $rawlines[$linenr - 1];
906 983
907#extract the filename as it passes
908 if ($line=~/^\+\+\+\s+(\S+)/) {
909 $realfile=$1;
910 $realfile =~ s@^[^/]*/@@;
911 $in_comment = 0;
912 next;
913 }
914#extract the line range in the file after the patch is applied 984#extract the line range in the file after the patch is applied
915 if ($line=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) { 985 if ($line=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) {
916 $is_patch = 1; 986 $is_patch = 1;
917 $first_line = $linenr + 1; 987 $first_line = $linenr + 1;
918 $in_comment = 0;
919 $realline=$1-1; 988 $realline=$1-1;
920 if (defined $2) { 989 if (defined $2) {
921 $realcnt=$3+1; 990 $realcnt=$3+1;
@@ -925,50 +994,16 @@ sub process {
925 annotate_reset(); 994 annotate_reset();
926 $prev_values = 'E'; 995 $prev_values = 'E';
927 996
928 $suppress_ifbraces = $linenr - 1; 997 %suppress_ifbraces = ();
929 next; 998 next;
930 }
931 999
932# track the line number as we move through the hunk, note that 1000# track the line number as we move through the hunk, note that
933# new versions of GNU diff omit the leading space on completely 1001# new versions of GNU diff omit the leading space on completely
934# blank context lines so we need to count that too. 1002# blank context lines so we need to count that too.
935 if ($line =~ /^( |\+|$)/) { 1003 } elsif ($line =~ /^( |\+|$)/) {
936 $realline++; 1004 $realline++;
937 $realcnt-- if ($realcnt != 0); 1005 $realcnt-- if ($realcnt != 0);
938 1006
939 # Guestimate if this is a continuing comment. Run
940 # the context looking for a comment "edge". If this
941 # edge is a close comment then we must be in a comment
942 # at context start.
943 if ($linenr == $first_line) {
944 my $edge;
945 for (my $ln = $first_line; $ln < ($linenr + $realcnt); $ln++) {
946 ($edge) = ($rawlines[$ln - 1] =~ m@(/\*|\*/)@);
947 last if (defined $edge);
948 }
949 if (defined $edge && $edge eq '*/') {
950 $in_comment = 1;
951 }
952 }
953
954 # Guestimate if this is a continuing comment. If this
955 # is the start of a diff block and this line starts
956 # ' *' then it is very likely a comment.
957 if ($linenr == $first_line and $rawline =~ m@^.\s* \*(?:\s|$)@) {
958 $in_comment = 1;
959 }
960
961 # Find the last comment edge on _this_ line.
962 $comment_edge = 0;
963 while (($rawline =~ m@(/\*|\*/)@g)) {
964 if ($1 eq '/*') {
965 $in_comment = 1;
966 } else {
967 $in_comment = 0;
968 }
969 $comment_edge = 1;
970 }
971
972 # Measure the line length and indent. 1007 # Measure the line length and indent.
973 ($length, $indent) = line_stats($rawline); 1008 ($length, $indent) = line_stats($rawline);
974 1009
@@ -977,23 +1012,36 @@ sub process {
977 ($previndent, $stashindent) = ($stashindent, $indent); 1012 ($previndent, $stashindent) = ($stashindent, $indent);
978 ($prevrawline, $stashrawline) = ($stashrawline, $rawline); 1013 ($prevrawline, $stashrawline) = ($stashrawline, $rawline);
979 1014
980 #warn "ic<$in_comment> ce<$comment_edge> line<$line>\n"; 1015 #warn "line<$line>\n";
981 1016
982 } elsif ($realcnt == 1) { 1017 } elsif ($realcnt == 1) {
983 $realcnt--; 1018 $realcnt--;
984 } 1019 }
985 1020
986#make up the handle for any error we report on this line 1021#make up the handle for any error we report on this line
1022 $prefix = "$filename:$realline: " if ($emacs && $file);
1023 $prefix = "$filename:$linenr: " if ($emacs && !$file);
1024
987 $here = "#$linenr: " if (!$file); 1025 $here = "#$linenr: " if (!$file);
988 $here = "#$realline: " if ($file); 1026 $here = "#$realline: " if ($file);
1027
1028 # extract the filename as it passes
1029 if ($line=~/^\+\+\+\s+(\S+)/) {
1030 $realfile = $1;
1031 $realfile =~ s@^[^/]*/@@;
1032
1033 if ($realfile =~ m@include/asm/@) {
1034 ERROR("do not modify files in include/asm, change architecture specific files in include/asm-<architecture>\n" . "$here$rawline\n");
1035 }
1036 next;
1037 }
1038
989 $here .= "FILE: $realfile:$realline:" if ($realcnt != 0); 1039 $here .= "FILE: $realfile:$realline:" if ($realcnt != 0);
990 1040
991 my $hereline = "$here\n$rawline\n"; 1041 my $hereline = "$here\n$rawline\n";
992 my $herecurr = "$here\n$rawline\n"; 1042 my $herecurr = "$here\n$rawline\n";
993 my $hereprev = "$here\n$prevrawline\n$rawline\n"; 1043 my $hereprev = "$here\n$prevrawline\n$rawline\n";
994 1044
995 $prefix = "$filename:$realline: " if ($emacs && $file);
996 $prefix = "$filename:$linenr: " if ($emacs && !$file);
997 $cnt_lines++ if ($realcnt != 0); 1045 $cnt_lines++ if ($realcnt != 0);
998 1046
999#check the patch for a signoff: 1047#check the patch for a signoff:
@@ -1005,7 +1053,7 @@ sub process {
1005 $herecurr); 1053 $herecurr);
1006 } 1054 }
1007 if ($line =~ /^\s*signed-off-by:\S/i) { 1055 if ($line =~ /^\s*signed-off-by:\S/i) {
1008 WARN("need space after Signed-off-by:\n" . 1056 WARN("space required after Signed-off-by:\n" .
1009 $herecurr); 1057 $herecurr);
1010 } 1058 }
1011 } 1059 }
@@ -1072,11 +1120,6 @@ sub process {
1072 WARN("CVS style keyword markers, these will _not_ be updated\n". $herecurr); 1120 WARN("CVS style keyword markers, these will _not_ be updated\n". $herecurr);
1073 } 1121 }
1074 1122
1075# The rest of our checks refer specifically to C style
1076# only apply those _outside_ comments. Only skip
1077# lines in the middle of comments.
1078 next if (!$comment_edge && $in_comment);
1079
1080# Check for potential 'bare' types 1123# Check for potential 'bare' types
1081 if ($realcnt) { 1124 if ($realcnt) {
1082 my ($s, $c) = ctx_statement_block($linenr, $realcnt, 0); 1125 my ($s, $c) = ctx_statement_block($linenr, $realcnt, 0);
@@ -1110,7 +1153,7 @@ sub process {
1110 my ($name_len) = length($1); 1153 my ($name_len) = length($1);
1111 1154
1112 my $ctx = $s; 1155 my $ctx = $s;
1113 substr($ctx, 0, $name_len + 1) = ''; 1156 substr($ctx, 0, $name_len + 1, '');
1114 $ctx =~ s/\)[^\)]*$//; 1157 $ctx =~ s/\)[^\)]*$//;
1115 1158
1116 for my $arg (split(/\s*,\s*/, $ctx)) { 1159 for my $arg (split(/\s*,\s*/, $ctx)) {
@@ -1151,27 +1194,33 @@ sub process {
1151 1194
1152# if/while/etc brace do not go on next line, unless defining a do while loop, 1195# if/while/etc brace do not go on next line, unless defining a do while loop,
1153# or if that brace on the next line is for something else 1196# or if that brace on the next line is for something else
1154 if ($line =~ /\b(?:(if|while|for|switch)\s*\(|do\b|else\b)/ && $line !~ /^.#/) { 1197 if ($line =~ /(.*)\b((?:if|while|for|switch)\s*\(|do\b|else\b)/ && $line !~ /^.#/) {
1198 my $pre_ctx = "$1$2";
1199
1155 my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0); 1200 my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0);
1156 my $ctx_ln = $linenr + $#ctx + 1; 1201 my $ctx_ln = $linenr + $#ctx + 1;
1157 my $ctx_cnt = $realcnt - $#ctx - 1; 1202 my $ctx_cnt = $realcnt - $#ctx - 1;
1158 my $ctx = join("\n", @ctx); 1203 my $ctx = join("\n", @ctx);
1159 1204
1205 ##warn "realcnt<$realcnt> ctx_cnt<$ctx_cnt>\n";
1206
1160 # Skip over any removed lines in the context following statement. 1207 # Skip over any removed lines in the context following statement.
1161 while ($ctx_cnt > 0 && $lines[$ctx_ln - 1] =~ /^-/) { 1208 while (defined($lines[$ctx_ln - 1]) && $lines[$ctx_ln - 1] =~ /^-/) {
1162 $ctx_ln++; 1209 $ctx_ln++;
1163 $ctx_cnt--;
1164 } 1210 }
1165 ##warn "line<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>"; 1211 ##warn "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n";
1166 1212
1167 if ($ctx !~ /{\s*/ && $ctx_cnt > 0 && $lines[$ctx_ln - 1] =~ /^\+\s*{/) { 1213 if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln -1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) {
1168 ERROR("That open brace { should be on the previous line\n" . 1214 ERROR("that open brace { should be on the previous line\n" .
1169 "$here\n$ctx\n$lines[$ctx_ln - 1]"); 1215 "$here\n$ctx\n$lines[$ctx_ln - 1]");
1170 } 1216 }
1171 if ($level == 0 && $ctx =~ /\)\s*\;\s*$/ && defined $lines[$ctx_ln - 1]) { 1217 if ($level == 0 && $pre_ctx !~ /}\s*while\s*\($/ &&
1218 $ctx =~ /\)\s*\;\s*$/ &&
1219 defined $lines[$ctx_ln - 1])
1220 {
1172 my ($nlength, $nindent) = line_stats($lines[$ctx_ln - 1]); 1221 my ($nlength, $nindent) = line_stats($lines[$ctx_ln - 1]);
1173 if ($nindent > $indent) { 1222 if ($nindent > $indent) {
1174 WARN("Trailing semicolon indicates no statements, indent implies otherwise\n" . 1223 WARN("trailing semicolon indicates no statements, indent implies otherwise\n" .
1175 "$here\n$ctx\n$lines[$ctx_ln - 1]"); 1224 "$here\n$ctx\n$lines[$ctx_ln - 1]");
1176 } 1225 }
1177 } 1226 }
@@ -1200,7 +1249,7 @@ sub process {
1200# check for initialisation to aggregates open brace on the next line 1249# check for initialisation to aggregates open brace on the next line
1201 if ($prevline =~ /$Declare\s*$Ident\s*=\s*$/ && 1250 if ($prevline =~ /$Declare\s*$Ident\s*=\s*$/ &&
1202 $line =~ /^.\s*{/) { 1251 $line =~ /^.\s*{/) {
1203 ERROR("That open brace { should be on the previous line\n" . $hereprev); 1252 ERROR("that open brace { should be on the previous line\n" . $hereprev);
1204 } 1253 }
1205 1254
1206# 1255#
@@ -1325,22 +1374,31 @@ sub process {
1325# check for spaces between functions and their parentheses. 1374# check for spaces between functions and their parentheses.
1326 while ($line =~ /($Ident)\s+\(/g) { 1375 while ($line =~ /($Ident)\s+\(/g) {
1327 my $name = $1; 1376 my $name = $1;
1328 my $ctx = substr($line, 0, $-[1]); 1377 my $ctx_before = substr($line, 0, $-[1]);
1378 my $ctx = "$ctx_before$name";
1329 1379
1330 # Ignore those directives where spaces _are_ permitted. 1380 # Ignore those directives where spaces _are_ permitted.
1331 if ($name =~ /^(?:if|for|while|switch|return|volatile|__volatile__|__attribute__|format|__extension__|Copyright|case|__asm__)$/) { 1381 if ($name =~ /^(?:
1382 if|for|while|switch|return|case|
1383 volatile|__volatile__|
1384 __attribute__|format|__extension__|
1385 asm|__asm__)$/x)
1386 {
1332 1387
1333 # cpp #define statements have non-optional spaces, ie 1388 # cpp #define statements have non-optional spaces, ie
1334 # if there is a space between the name and the open 1389 # if there is a space between the name and the open
1335 # parenthesis it is simply not a parameter group. 1390 # parenthesis it is simply not a parameter group.
1336 } elsif ($ctx =~ /^.\#\s*define\s*$/) { 1391 } elsif ($ctx_before =~ /^.\#\s*define\s*$/) {
1392
1393 # cpp #elif statement condition may start with a (
1394 } elsif ($ctx =~ /^.\#\s*elif\s*$/) {
1337 1395
1338 # If this whole things ends with a type its most 1396 # If this whole things ends with a type its most
1339 # likely a typedef for a function. 1397 # likely a typedef for a function.
1340 } elsif ("$ctx$name" =~ /$Type$/) { 1398 } elsif ($ctx =~ /$Type$/) {
1341 1399
1342 } else { 1400 } else {
1343 WARN("no space between function name and open parenthesis '('\n" . $herecurr); 1401 WARN("space prohibited between function name and open parenthesis '('\n" . $herecurr);
1344 } 1402 }
1345 } 1403 }
1346# Check operator spacing. 1404# Check operator spacing.
@@ -1359,13 +1417,21 @@ sub process {
1359 for (my $n = 0; $n < $#elements; $n += 2) { 1417 for (my $n = 0; $n < $#elements; $n += 2) {
1360 $off += length($elements[$n]); 1418 $off += length($elements[$n]);
1361 1419
1420 # Pick up the preceeding and succeeding characters.
1421 my $ca = substr($opline, 0, $off);
1422 my $cc = '';
1423 if (length($opline) >= ($off + length($elements[$n + 1]))) {
1424 $cc = substr($opline, $off + length($elements[$n + 1]));
1425 }
1426 my $cb = "$ca$;$cc";
1427
1362 my $a = ''; 1428 my $a = '';
1363 $a = 'V' if ($elements[$n] ne ''); 1429 $a = 'V' if ($elements[$n] ne '');
1364 $a = 'W' if ($elements[$n] =~ /\s$/); 1430 $a = 'W' if ($elements[$n] =~ /\s$/);
1365 $a = 'C' if ($elements[$n] =~ /$;$/); 1431 $a = 'C' if ($elements[$n] =~ /$;$/);
1366 $a = 'B' if ($elements[$n] =~ /(\[|\()$/); 1432 $a = 'B' if ($elements[$n] =~ /(\[|\()$/);
1367 $a = 'O' if ($elements[$n] eq ''); 1433 $a = 'O' if ($elements[$n] eq '');
1368 $a = 'E' if ($elements[$n] eq '' && $n == 0); 1434 $a = 'E' if ($ca =~ /^\s*$/);
1369 1435
1370 my $op = $elements[$n + 1]; 1436 my $op = $elements[$n + 1];
1371 1437
@@ -1381,14 +1447,6 @@ sub process {
1381 $c = 'E'; 1447 $c = 'E';
1382 } 1448 }
1383 1449
1384 # Pick up the preceeding and succeeding characters.
1385 my $ca = substr($opline, 0, $off);
1386 my $cc = '';
1387 if (length($opline) >= ($off + length($elements[$n + 1]))) {
1388 $cc = substr($opline, $off + length($elements[$n + 1]));
1389 }
1390 my $cb = "$ca$;$cc";
1391
1392 my $ctx = "${a}x${c}"; 1450 my $ctx = "${a}x${c}";
1393 1451
1394 my $at = "(ctx:$ctx)"; 1452 my $at = "(ctx:$ctx)";
@@ -1424,7 +1482,7 @@ sub process {
1424 } elsif ($op eq ';') { 1482 } elsif ($op eq ';') {
1425 if ($ctx !~ /.x[WEBC]/ && 1483 if ($ctx !~ /.x[WEBC]/ &&
1426 $cc !~ /^\\/ && $cc !~ /^;/) { 1484 $cc !~ /^\\/ && $cc !~ /^;/) {
1427 ERROR("need space after that '$op' $at\n" . $hereptr); 1485 ERROR("space required after that '$op' $at\n" . $hereptr);
1428 } 1486 }
1429 1487
1430 # // is a comment 1488 # // is a comment
@@ -1433,13 +1491,13 @@ sub process {
1433 # -> should have no spaces 1491 # -> should have no spaces
1434 } elsif ($op eq '->') { 1492 } elsif ($op eq '->') {
1435 if ($ctx =~ /Wx.|.xW/) { 1493 if ($ctx =~ /Wx.|.xW/) {
1436 ERROR("no spaces around that '$op' $at\n" . $hereptr); 1494 ERROR("spaces prohibited around that '$op' $at\n" . $hereptr);
1437 } 1495 }
1438 1496
1439 # , must have a space on the right. 1497 # , must have a space on the right.
1440 } elsif ($op eq ',') { 1498 } elsif ($op eq ',') {
1441 if ($ctx !~ /.x[WEC]/ && $cc !~ /^}/) { 1499 if ($ctx !~ /.x[WEC]/ && $cc !~ /^}/) {
1442 ERROR("need space after that '$op' $at\n" . $hereptr); 1500 ERROR("space required after that '$op' $at\n" . $hereptr);
1443 } 1501 }
1444 1502
1445 # '*' as part of a type definition -- reported already. 1503 # '*' as part of a type definition -- reported already.
@@ -1452,21 +1510,26 @@ sub process {
1452 } elsif ($op eq '!' || $op eq '~' || 1510 } elsif ($op eq '!' || $op eq '~' ||
1453 ($is_unary && ($op eq '*' || $op eq '-' || $op eq '&'))) { 1511 ($is_unary && ($op eq '*' || $op eq '-' || $op eq '&'))) {
1454 if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) { 1512 if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) {
1455 ERROR("need space before that '$op' $at\n" . $hereptr); 1513 ERROR("space required before that '$op' $at\n" . $hereptr);
1456 } 1514 }
1457 if ($ctx =~ /.xW/) { 1515 if ($ctx =~ /.xW/) {
1458 ERROR("no space after that '$op' $at\n" . $hereptr); 1516 ERROR("space prohibited after that '$op' $at\n" . $hereptr);
1459 } 1517 }
1460 1518
1461 # unary ++ and unary -- are allowed no space on one side. 1519 # unary ++ and unary -- are allowed no space on one side.
1462 } elsif ($op eq '++' or $op eq '--') { 1520 } elsif ($op eq '++' or $op eq '--') {
1463 if ($ctx !~ /[WOBC]x[^W]/ && $ctx !~ /[^W]x[WOBEC]/) { 1521 if ($ctx !~ /[WEOBC]x[^W]/ && $ctx !~ /[^W]x[WOBEC]/) {
1464 ERROR("need space one side of that '$op' $at\n" . $hereptr); 1522 ERROR("space required one side of that '$op' $at\n" . $hereptr);
1523 }
1524 if ($ctx =~ /Wx[BE]/ ||
1525 ($ctx =~ /Wx./ && $cc =~ /^;/)) {
1526 ERROR("space prohibited before that '$op' $at\n" . $hereptr);
1465 } 1527 }
1466 if ($ctx =~ /WxB/ || ($ctx =~ /Wx./ && $cc =~ /^;/)) { 1528 if ($ctx =~ /ExW/) {
1467 ERROR("no space before that '$op' $at\n" . $hereptr); 1529 ERROR("space prohibited after that '$op' $at\n" . $hereptr);
1468 } 1530 }
1469 1531
1532
1470 # << and >> may either have or not have spaces both sides 1533 # << and >> may either have or not have spaces both sides
1471 } elsif ($op eq '<<' or $op eq '>>' or 1534 } elsif ($op eq '<<' or $op eq '>>' or
1472 $op eq '&' or $op eq '^' or $op eq '|' or 1535 $op eq '&' or $op eq '^' or $op eq '|' or
@@ -1474,7 +1537,7 @@ sub process {
1474 $op eq '*' or $op eq '/' or 1537 $op eq '*' or $op eq '/' or
1475 $op eq '%') 1538 $op eq '%')
1476 { 1539 {
1477 if ($ctx !~ /VxV|WxW|VxE|WxE|VxO|Cx.|.xC/) { 1540 if ($ctx =~ /Wx[^WCE]|[^WCE]xW/) {
1478 ERROR("need consistent spacing around '$op' $at\n" . 1541 ERROR("need consistent spacing around '$op' $at\n" .
1479 $hereptr); 1542 $hereptr);
1480 } 1543 }
@@ -1484,7 +1547,7 @@ sub process {
1484 # Ignore email addresses <foo@bar> 1547 # Ignore email addresses <foo@bar>
1485 if (!($op eq '<' && $cb =~ /$;\S+\@\S+>/) && 1548 if (!($op eq '<' && $cb =~ /$;\S+\@\S+>/) &&
1486 !($op eq '>' && $cb =~ /<\S+\@\S+$;/)) { 1549 !($op eq '>' && $cb =~ /<\S+\@\S+$;/)) {
1487 ERROR("need spaces around that '$op' $at\n" . $hereptr); 1550 ERROR("spaces required around that '$op' $at\n" . $hereptr);
1488 } 1551 }
1489 } 1552 }
1490 $off += length($elements[$n + 1]); 1553 $off += length($elements[$n + 1]);
@@ -1514,31 +1577,31 @@ sub process {
1514#need space before brace following if, while, etc 1577#need space before brace following if, while, etc
1515 if (($line =~ /\(.*\){/ && $line !~ /\($Type\){/) || 1578 if (($line =~ /\(.*\){/ && $line !~ /\($Type\){/) ||
1516 $line =~ /do{/) { 1579 $line =~ /do{/) {
1517 ERROR("need a space before the open brace '{'\n" . $herecurr); 1580 ERROR("space required before the open brace '{'\n" . $herecurr);
1518 } 1581 }
1519 1582
1520# closing brace should have a space following it when it has anything 1583# closing brace should have a space following it when it has anything
1521# on the line 1584# on the line
1522 if ($line =~ /}(?!(?:,|;|\)))\S/) { 1585 if ($line =~ /}(?!(?:,|;|\)))\S/) {
1523 ERROR("need a space after that close brace '}'\n" . $herecurr); 1586 ERROR("space required after that close brace '}'\n" . $herecurr);
1524 } 1587 }
1525 1588
1526# check spacing on square brackets 1589# check spacing on square brackets
1527 if ($line =~ /\[\s/ && $line !~ /\[\s*$/) { 1590 if ($line =~ /\[\s/ && $line !~ /\[\s*$/) {
1528 ERROR("no space after that open square bracket '['\n" . $herecurr); 1591 ERROR("space prohibited after that open square bracket '['\n" . $herecurr);
1529 } 1592 }
1530 if ($line =~ /\s\]/) { 1593 if ($line =~ /\s\]/) {
1531 ERROR("no space before that close square bracket ']'\n" . $herecurr); 1594 ERROR("space prohibited before that close square bracket ']'\n" . $herecurr);
1532 } 1595 }
1533 1596
1534# check spacing on paretheses 1597# check spacing on paretheses
1535 if ($line =~ /\(\s/ && $line !~ /\(\s*(?:\\)?$/ && 1598 if ($line =~ /\(\s/ && $line !~ /\(\s*(?:\\)?$/ &&
1536 $line !~ /for\s*\(\s+;/) { 1599 $line !~ /for\s*\(\s+;/) {
1537 ERROR("no space after that open parenthesis '('\n" . $herecurr); 1600 ERROR("space prohibited after that open parenthesis '('\n" . $herecurr);
1538 } 1601 }
1539 if ($line =~ /(\s+)\)/ && $line !~ /^.\s*\)/ && 1602 if ($line =~ /(\s+)\)/ && $line !~ /^.\s*\)/ &&
1540 $line !~ /for\s*\(.*;\s+\)/) { 1603 $line !~ /for\s*\(.*;\s+\)/) {
1541 ERROR("no space before that close parenthesis ')'\n" . $herecurr); 1604 ERROR("space prohibited before that close parenthesis ')'\n" . $herecurr);
1542 } 1605 }
1543 1606
1544#goto labels aren't indented, allow a single space however 1607#goto labels aren't indented, allow a single space however
@@ -1549,7 +1612,7 @@ sub process {
1549 1612
1550# Need a space before open parenthesis after if, while etc 1613# Need a space before open parenthesis after if, while etc
1551 if ($line=~/\b(if|while|for|switch)\(/) { 1614 if ($line=~/\b(if|while|for|switch)\(/) {
1552 ERROR("need a space before the open parenthesis '('\n" . $herecurr); 1615 ERROR("space required before the open parenthesis '('\n" . $herecurr);
1553 } 1616 }
1554 1617
1555# Check for illegal assignment in if conditional. 1618# Check for illegal assignment in if conditional.
@@ -1562,10 +1625,12 @@ sub process {
1562 1625
1563 # Find out what is on the end of the line after the 1626 # Find out what is on the end of the line after the
1564 # conditional. 1627 # conditional.
1565 substr($s, 0, length($c)) = ''; 1628 substr($s, 0, length($c), '');
1566 $s =~ s/\n.*//g; 1629 $s =~ s/\n.*//g;
1567 $s =~ s/$;//g; # Remove any comments 1630 $s =~ s/$;//g; # Remove any comments
1568 if (length($c) && $s !~ /^\s*({|;|)\s*\\*\s*$/) { 1631 if (length($c) && $s !~ /^\s*({|;|)\s*\\*\s*$/ &&
1632 $c !~ /^.\#\s*if/)
1633 {
1569 ERROR("trailing statements should be on next line\n" . $herecurr); 1634 ERROR("trailing statements should be on next line\n" . $herecurr);
1570 } 1635 }
1571 } 1636 }
@@ -1607,7 +1672,7 @@ sub process {
1607 1672
1608 # Find out what is on the end of the line after the 1673 # Find out what is on the end of the line after the
1609 # conditional. 1674 # conditional.
1610 substr($s, 0, length($c)) = ''; 1675 substr($s, 0, length($c), '');
1611 $s =~ s/\n.*//g; 1676 $s =~ s/\n.*//g;
1612 1677
1613 if ($s =~ /^\s*;/) { 1678 if ($s =~ /^\s*;/) {
@@ -1631,7 +1696,7 @@ sub process {
1631 if ($tree && $rawline =~ m{^.\#\s*include\s*\<asm\/(.*)\.h\>}) { 1696 if ($tree && $rawline =~ m{^.\#\s*include\s*\<asm\/(.*)\.h\>}) {
1632 my $checkfile = "$root/include/linux/$1.h"; 1697 my $checkfile = "$root/include/linux/$1.h";
1633 if (-f $checkfile && $1 ne 'irq.h') { 1698 if (-f $checkfile && $1 ne 'irq.h') {
1634 CHK("Use #include <linux/$1.h> instead of <asm/$1.h>\n" . 1699 WARN("Use #include <linux/$1.h> instead of <asm/$1.h>\n" .
1635 $herecurr); 1700 $herecurr);
1636 } 1701 }
1637 } 1702 }
@@ -1692,15 +1757,24 @@ sub process {
1692 if ($#chunks > 0 && $level == 0) { 1757 if ($#chunks > 0 && $level == 0) {
1693 my $allowed = 0; 1758 my $allowed = 0;
1694 my $seen = 0; 1759 my $seen = 0;
1695 my $herectx = $here . "\n";; 1760 my $herectx = $here . "\n";
1696 my $ln = $linenr - 1; 1761 my $ln = $linenr - 1;
1697 for my $chunk (@chunks) { 1762 for my $chunk (@chunks) {
1698 my ($cond, $block) = @{$chunk}; 1763 my ($cond, $block) = @{$chunk};
1699 1764
1700 $herectx .= "$rawlines[$ln]\n[...]\n"; 1765 # If the condition carries leading newlines, then count those as offsets.
1766 my ($whitespace) = ($cond =~ /^((?:\s*\n[+-])*\s*)/s);
1767 my $offset = statement_rawlines($whitespace) - 1;
1768
1769 #print "COND<$cond> whitespace<$whitespace> offset<$offset>\n";
1770
1771 # We have looked at and allowed this specific line.
1772 $suppress_ifbraces{$ln + $offset} = 1;
1773
1774 $herectx .= "$rawlines[$ln + $offset]\n[...]\n";
1701 $ln += statement_rawlines($block) - 1; 1775 $ln += statement_rawlines($block) - 1;
1702 1776
1703 substr($block, 0, length($cond)) = ''; 1777 substr($block, 0, length($cond), '');
1704 1778
1705 $seen++ if ($block =~ /^\s*{/); 1779 $seen++ if ($block =~ /^\s*{/);
1706 1780
@@ -1721,16 +1795,10 @@ sub process {
1721 if ($seen && !$allowed) { 1795 if ($seen && !$allowed) {
1722 WARN("braces {} are not necessary for any arm of this statement\n" . $herectx); 1796 WARN("braces {} are not necessary for any arm of this statement\n" . $herectx);
1723 } 1797 }
1724 # Either way we have looked over this whole
1725 # statement and said what needs to be said.
1726 $suppress_ifbraces = $endln;
1727 } 1798 }
1728 } 1799 }
1729 if ($linenr > $suppress_ifbraces && 1800 if (!defined $suppress_ifbraces{$linenr - 1} &&
1730 $line =~ /\b(if|while|for|else)\b/) { 1801 $line =~ /\b(if|while|for|else)\b/) {
1731 my ($level, $endln, @chunks) =
1732 ctx_statement_full($linenr, $realcnt, $-[0]);
1733
1734 my $allowed = 0; 1802 my $allowed = 0;
1735 1803
1736 # Check the pre-context. 1804 # Check the pre-context.
@@ -1738,10 +1806,15 @@ sub process {
1738 #print "APW: ALLOWED: pre<$1>\n"; 1806 #print "APW: ALLOWED: pre<$1>\n";
1739 $allowed = 1; 1807 $allowed = 1;
1740 } 1808 }
1809
1810 my ($level, $endln, @chunks) =
1811 ctx_statement_full($linenr, $realcnt, $-[0]);
1812
1741 # Check the condition. 1813 # Check the condition.
1742 my ($cond, $block) = @{$chunks[0]}; 1814 my ($cond, $block) = @{$chunks[0]};
1815 #print "CHECKING<$linenr> cond<$cond> block<$block>\n";
1743 if (defined $cond) { 1816 if (defined $cond) {
1744 substr($block, 0, length($cond)) = ''; 1817 substr($block, 0, length($cond), '');
1745 } 1818 }
1746 if (statement_lines($cond) > 1) { 1819 if (statement_lines($cond) > 1) {
1747 #print "APW: ALLOWED: cond<$cond>\n"; 1820 #print "APW: ALLOWED: cond<$cond>\n";
@@ -1759,7 +1832,7 @@ sub process {
1759 if (defined $chunks[1]) { 1832 if (defined $chunks[1]) {
1760 my ($cond, $block) = @{$chunks[1]}; 1833 my ($cond, $block) = @{$chunks[1]};
1761 if (defined $cond) { 1834 if (defined $cond) {
1762 substr($block, 0, length($cond)) = ''; 1835 substr($block, 0, length($cond), '');
1763 } 1836 }
1764 if ($block =~ /^\s*\{/) { 1837 if ($block =~ /^\s*\{/) {
1765 #print "APW: ALLOWED: chunk-1 block<$block>\n"; 1838 #print "APW: ALLOWED: chunk-1 block<$block>\n";
@@ -1882,6 +1955,28 @@ sub process {
1882 if ($line =~ /__FUNCTION__/) { 1955 if ($line =~ /__FUNCTION__/) {
1883 WARN("__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr); 1956 WARN("__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr);
1884 } 1957 }
1958
1959# check for semaphores used as mutexes
1960 if ($line =~ /\b(DECLARE_MUTEX|init_MUTEX)\s*\(/) {
1961 WARN("mutexes are preferred for single holder semaphores\n" . $herecurr);
1962 }
1963# check for semaphores used as mutexes
1964 if ($line =~ /\binit_MUTEX_LOCKED\s*\(/) {
1965 WARN("consider using a completion\n" . $herecurr);
1966 }
1967# recommend strict_strto* over simple_strto*
1968 if ($line =~ /\bsimple_(strto.*?)\s*\(/) {
1969 WARN("consider using strict_$1 in preference to simple_$1\n" . $herecurr);
1970 }
1971
1972# use of NR_CPUS is usually wrong
1973# ignore definitions of NR_CPUS and usage to define arrays as likely right
1974 if ($line =~ /\bNR_CPUS\b/ &&
1975 $line !~ /^.#\s*define\s+NR_CPUS\s+/ &&
1976 $line !~ /^.\s*$Declare\s.*\[[^\]]*NR_CPUS[^\]]*\]/)
1977 {
1978 WARN("usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr);
1979 }
1885 } 1980 }
1886 1981
1887 # If we have no input at all, then there is nothing to report on 1982 # If we have no input at all, then there is nothing to report on