3.2.27-stable review
Subsystems (50)
cover 3.2.27-stable review
This is the start of the stable review cycle for the 3.2.27 release. There are 70 patches in this series, which will be posted as responses to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu Aug 9 10:00:00 UTC 2012. Anything received after that time might be too late.
A combined patch relative to 3.2.26 will be posted as an additional response to this, and the diffstat can be found below.
Ben.
-------------
Documentation/sound/alsa/HD-Audio-Models.txt | 3 +- Documentation/stable_kernel_rules.txt | 19 +- Makefile | 4 +- arch/arm/include/asm/mutex.h | 119 +---------- arch/arm/kernel/entry-armv.S | 111 +++++++---- arch/arm/kernel/process.c | 2 + arch/arm/kernel/traps.c | 8 - arch/arm/mm/tlb-v7.S | 12 ++ arch/arm/vfp/entry.S | 16 +- arch/arm/vfp/vfphw.S | 19 +- arch/arm/vfp/vfpmodule.c | 8 +- arch/ia64/include/asm/atomic.h | 4 +- arch/m68k/include/asm/entry.h | 4 +- arch/m68k/kernel/sys_m68k.c | 8 +- arch/s390/include/asm/mmu_context.h | 14 +- arch/s390/include/asm/processor.h | 2 + arch/s390/mm/fault.c | 13 +- arch/s390/mm/mmap.c | 12 +- arch/s390/mm/pgtable.c | 5 - arch/x86/kernel/alternative.c | 2 +- arch/x86/xen/p2m.c | 36 ++++ drivers/block/floppy.c | 8 +- drivers/block/virtio_blk.c | 9 +- drivers/char/mspec.c | 2 +- drivers/char/random.c | 273 +++++++++++++++++++------- drivers/firmware/pcdp.c | 4 +- drivers/gpu/drm/i915/intel_dp.c | 4 +- drivers/input/mouse/synaptics.c | 23 +++ drivers/md/dm-thin.c | 7 +- drivers/md/raid1.c | 5 +- drivers/media/rc/ene_ir.c | 3 +- drivers/mfd/ab3100-core.c | 2 - drivers/mfd/wm831x-otp.c | 8 + drivers/net/wireless/rt2x00/rt2800usb.c | 1 + drivers/platform/x86/asus-wmi.c | 7 +- drivers/rtc/rtc-wm831x.c | 24 ++- drivers/staging/media/lirc/lirc_sir.c | 60 +++++- drivers/tty/serial/pch_uart.c | 21 +- drivers/usb/core/hub.c | 9 + drivers/usb/early/ehci-dbgp.c | 2 +- drivers/video/smscufx.c | 2 +- fs/exofs/ore.c | 14 +- fs/nfs/file.c | 7 +- fs/nfsd/nfs4xdr.c | 2 +- fs/nilfs2/ioctl.c | 4 +- fs/nilfs2/super.c | 3 + fs/nilfs2/the_nilfs.c | 1 + fs/nilfs2/the_nilfs.h | 2 + include/linux/hugetlb.h | 10 + include/linux/init_task.h | 12 +- include/linux/random.h | 4 +- include/linux/sched.h | 5 +- kernel/futex.c | 17 +- kernel/irq/handle.c | 7 +- kernel/sched.c | 32 +-- lib/vsprintf.c | 3 +- mm/hugetlb.c | 28 ++- mm/internal.h | 2 + mm/memory.c | 7 +- mm/mmu_notifier.c | 45 ++--- mm/page_alloc.c | 33 ++-- mm/sparse.c | 3 + net/core/dev.c | 3 + net/core/drop_monitor.c | 113 ++++++----- net/core/rtnetlink.c | 1 + net/sunrpc/rpcb_clnt.c | 4 +- net/sunrpc/sched.c | 2 + net/sunrpc/xprtrdma/transport.c | 3 +- net/sunrpc/xprtsock.c | 10 + net/wireless/util.c | 3 + sound/drivers/mpu401/mpu401_uart.c | 1 + sound/pci/hda/patch_realtek.c | 28 +++ sound/pci/hda/patch_via.c | 7 +- sound/soc/codecs/wm8962.c | 3 + sound/soc/codecs/wm8994.c | 2 +- sound/usb/clock.c | 3 +- 76 files changed, 863 insertions(+), 456 deletions(-)
Signature · 3 lines
Ben Hutchings
Theory and practice are closer in theory than in practice.
- John Levine, moderator of comp.compilersPATCH 4/70 lirc_sir: make device registration work
3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jarod Wilson <[email protected]>
commit 4b71ca6bce8fab3d08c61bf330e781f957934ae1 upstream.
For one, the driver device pointer needs to be filled in, or the lirc core will refuse to load the driver. And we really need to wire up all the platform_device bits. This has been tested via the lirc sourceforge tree and verified to work, been sitting there for months, finally getting around to sending it. :\
--- drivers/staging/media/lirc/lirc_sir.c | 60 +++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-)
drivers/staging/media/lirc/lirc_sir.c +58 -2
@@ -52,6 +52,7 @@#include <linux/io.h> #include <asm/irq.h> #include <linux/fcntl.h> +#include <linux/platform_device.h> #ifdef LIRC_ON_SA1100 #include <asm/hardware.h> #ifdef CONFIG_SA1100_COLLIE
@@ -487,9 +488,11 @@ static struct lirc_driver driver = { .owner = THIS_MODULE, }; +static struct platform_device *lirc_sir_dev;static int init_chrdev (void ) { + driver.dev = &lirc_sir_dev->dev; driver.minor =lirc_register_driver (&driver);if (driver.minor <0 ) { printk(KERN_ERR LIRC_DRIVER_NAME ": init_chrdev() failed.\n");
@@ -1215,20 +1218,71 @@ static int init_lirc_sir(void)return 0 ; } +static int __devinit lirc_sir_probe (struct platform_device *dev) +{ +return 0 ; +} + +static int __devexit lirc_sir_remove(struct platform_device *dev) +{ +return 0 ; +} + +static struct platform_driver lirc_sir_driver = { + .probe = lirc_sir_probe, + .remove =__devexit_p (lirc_sir_remove), + .driver = { + .name ="lirc_sir" , + .owner =THIS_MODULE , + }, +};static int __init lirc_sir_init (void ) {int retval; + retval =platform_driver_register (&lirc_sir_driver); +if (retval) { + printk(KERN_ERR LIRC_DRIVER_NAME ": Platform driver register " + "failed!\n"); +return -ENODEV ; + } + + lirc_sir_dev =platform_device_alloc ("lirc_dev" ,0 ); +if (!lirc_sir_dev) { + printk(KERN_ERR LIRC_DRIVER_NAME ": Platform device alloc " + "failed!\n"); + retval = -ENOMEM ; + goto pdev_alloc_fail; + } + + retval =platform_device_add (lirc_sir_dev); +if (retval) { + printk(KERN_ERR LIRC_DRIVER_NAME ": Platform device add " + "failed!\n"); + retval = -ENODEV ; + goto pdev_add_fail; + } + retval =init_chrdev ();if (retval <0 ) -return retval; + goto fail; + retval =init_lirc_sir ();if (retval) {drop_chrdev (); -return retval; + goto fail; } +return 0 ; + +fail: +platform_device_del (lirc_sir_dev); +pdev_add_fail: +platform_device_put (lirc_sir_dev); +pdev_alloc_fail: +platform_driver_unregister (&lirc_sir_driver); +return retval; } static void __exit lirc_sir_exit(void)
@@ -1236,6 +1290,8 @@ static void __exit lirc_sir_exit(void)drop_hardware ();drop_chrdev ();drop_port (); +platform_device_unregister (lirc_sir_dev); +platform_driver_unregister (&lirc_sir_driver); printk(KERN_INFO LIRC_DRIVER_NAME ": Uninstalled.\n"); }
PATCH 10/70 nfsd4: our filesystems are normally case sensitive
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: "J. Bruce Fields" <[email protected]>
commit 2930d381d22b9c56f40dd4c63a8fa59719ca2c3c upstream.
Actually, xfs and jfs can optionally be case insensitive; we'll handle that case in later patches.
--- fs/nfsd/nfs4xdr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/nfs4xdr.c +1 -1
@@ -2259,7 +2259,7 @@ out_acl:if (bmval0 &FATTR4_WORD0_CASE_INSENSITIVE ) {if ((buflen -=4 ) <0 ) goto out_resource; -WRITE32 (1 ); +WRITE32 (0 ); }if (bmval0 &FATTR4_WORD0_CASE_PRESERVING ) {if ((buflen -=4 ) <0 )
PATCH 14/70 random: make add_interrupt_randomness() do something sane
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
commit 775f4b297b780601e61787b766f306ed3e1d23eb upstream.
We've been moving away from add_interrupt_randomness() for various
reasons: it's too expensive to do on every interrupt, and flooding the CPU with interrupts could theoretically cause bogus floods of entropy from a somewhat externally controllable source.
This solves both problems by limiting the actual randomness addition to just once a second or after 64 interrupts, whicever comes first. During that time, the interrupt cycle data is buffered up in a per-cpu pool. Also, we make sure the the nonblocking pool used by urandom is initialized before we start feeding the normal input pool. This assures that /dev/urandom is returning unpredictable data as soon as possible.
(Based on an original patch by Linus, but significantly modified by tytso.)
--- drivers/char/random.c | 103 +++++++++++++++++++++++++++++++++++++-------- drivers/mfd/ab3100-core.c | 2 - include/linux/random.h | 2 +- kernel/irq/handle.c | 7 ++- 4 files changed, 90 insertions(+), 24 deletions(-)
drivers/char/random.c +86 -17
@@ -127,19 +127,15 @@* * void add_input_randomness(unsigned int type, unsigned int code, * unsigned int value); -* void add_interrupt_randomness(int irq); +* void add_interrupt_randomness(int irq, int irq_flags); * void add_disk_randomness(struct gendisk *disk); * * add_input_randomness() uses the input layer interrupt timing, as well as * the event type information from the hardware. * -* add_interrupt_randomness() uses the inter-interrupt timing as random -* inputs to the entropy pool. Note that not all interrupts are good -* sources of randomness! For example, the timer interrupts is not a -* good choice, because the periodicity of the interrupts is too -* regular, and hence predictable to an attacker. Network Interface -* Controller interrupts are a better measure, since the timing of the -* NIC interrupts are more unpredictable. +* add_interrupt_randomness() uses the interrupt timing as random +* inputs to the entropy pool. Using the cycle counters and the irq source +* as inputs, it feeds the randomness roughly once a second. * * add_disk_randomness() uses what amounts to the seek time of block * layer request events, on a per-disk_devt basis, as input to the
@@ -248,6 +244,7 @@#include <linux/percpu.h> #include <linux/cryptohash.h> #include <linux/fips.h> +#include <linux/ptrace.h> #ifdef CONFIG_GENERIC_HARDIRQS # include <linux/irq.h>
@@ -256,6 +253,7 @@#include <asm/processor.h> #include <asm/uaccess.h> #include <asm/irq.h> +#include <asm/irq_regs.h> #include <asm/io.h> /*
@@ -421,7 +419,9 @@ struct entropy_store {spinlock_t lock;unsigned add_ptr;int entropy_count; +int entropy_total;int input_rotate; + unsigned int initialized:1;__u8 last_data[EXTRACT_SIZE ]; };
@@ -454,6 +454,10 @@ static struct entropy_store nonblocking_pool = { .pool = nonblocking_pool_data }; +static __u32 const twist_table[8 ] = { +0x00000000 ,0x3b6e20c8 ,0x76dc4190 ,0x4db26158 , +0xedb88320 ,0xd6d6a3e8 ,0x9b64c2b0 ,0xa00ae278 }; +/* * This function adds bytes into the entropy "pool". It does not * update the entropy estimate. The caller should call
@@ -467,9 +471,6 @@ static struct entropy_store nonblocking_pool = {static void mix_pool_bytes_extract (struct entropy_store *r,const void *in,int nbytes,__u8 out[64 ]) { -static __u32 const twist_table[8 ] = { -0x00000000 ,0x3b6e20c8 ,0x76dc4190 ,0x4db26158 , -0xedb88320 ,0xd6d6a3e8 ,0x9b64c2b0 ,0xa00ae278 };unsigned long i, j, tap1, tap2, tap3, tap4, tap5;int input_rotate;int wordmask = r->poolinfo->poolwords -1 ;
@@ -528,6 +529,36 @@ static void mix_pool_bytes(struct entropy_store *r, const void *in, int bytes)mix_pool_bytes_extract (r, in, bytes,NULL ); } +struct fast_pool { +__u32 pool[4 ]; +unsigned long last; +unsigned short count; +unsigned char rotate; +unsigned char last_timer_intr; +}; + +/* +* This is a fast mixing routine used by the interrupt randomness +* collector. It's hardcoded for an 128 bit pool and assumes that any +* locks that might be needed are taken by the caller. +*/ +static void fast_mix (struct fast_pool *f,const void *in,int nbytes) +{ +const char *bytes = in; +__u32 w; +unsigned i = f->count; +unsigned input_rotate = f->rotate; + +while (nbytes--) { + w =rol32 (*bytes++, input_rotate &31 ) ^ f->pool[i &3 ] ^ + f->pool[(i +1 ) &3 ]; + f->pool[i &3 ] = (w >>3 ) ^ twist_table[w &7 ]; + input_rotate += (i++ &3 ) ?7 :14 ; + } + f->count = i; + f->rotate = input_rotate; +} +/* * Credit (or debit) the entropy store with n bits of entropy */
@@ -551,6 +582,12 @@ static void credit_entropy_bits(struct entropy_store *r, int nbits) entropy_count = r->poolinfo->POOLBITS; r->entropy_count = entropy_count; +if (!r->initialized && nbits >0 ) { + r->entropy_total += nbits; +if (r->entropy_total >128 ) + r->initialized =1 ; + } +/* should we wake readers? */ if (r == &input_pool && entropy_count >= random_read_wakeup_thresh) {wake_up_interruptible (&random_read_wait);
@@ -700,17 +737,48 @@ void add_input_randomness(unsigned int type, unsigned int code, }EXPORT_SYMBOL_GPL (add_input_randomness); -void add_interrupt_randomness (int irq) +static DEFINE_PER_CPU(struct fast_pool, irq_randomness); + +void add_interrupt_randomness (int irq,int irq_flags) { -struct timer_rand_state *state; +struct entropy_store *r; +struct fast_pool *fast_pool = &__get_cpu_var (irq_randomness); +struct pt_regs *regs =get_irq_regs (); +unsigned long now = jiffies; +__u32 input[4 ], cycles =get_cycles (); + + input[0 ] = cycles ^ jiffies; + input[1 ] = irq; +if (regs) { +__u64 ip =instruction_pointer (regs); + input[2 ] = ip; + input[3 ] = ip >>32 ; + } - state =get_timer_rand_state (irq); +fast_mix (fast_pool, input,sizeof (input)); -if (state ==NULL ) +if ((fast_pool->count &1023 ) && + !time_after (now, fast_pool->last +HZ ))return ; -DEBUG_ENT ("irq event %d\n" , irq); -add_timer_randomness (state,0x100 + irq); + fast_pool->last = now; + + r = nonblocking_pool.initialized ? &input_pool : &nonblocking_pool; +mix_pool_bytes (r, &fast_pool->pool,sizeof (fast_pool->pool)); +/* +* If we don't have a valid cycle counter, and we see +* back-to-back timer interrupts, then skip giving credit for +* any entropy. +*/ +if (cycles ==0 ) { +if (irq_flags & __IRQF_TIMER) { +if (fast_pool->last_timer_intr) +return ; + fast_pool->last_timer_intr =1 ; + }else + fast_pool->last_timer_intr =0 ; + } +credit_entropy_bits (r,1 ); }#ifdef CONFIG_BLOCK
@@ -971,6 +1039,7 @@ static void init_std_data(struct entropy_store *r)spin_lock_irqsave (&r->lock, flags); r->entropy_count =0 ; + r->entropy_total =0 ;spin_unlock_irqrestore (&r->lock, flags); now =ktime_get_real ();
drivers/mfd/ab3100-core.c +0 -2
@@ -409,8 +409,6 @@ static irqreturn_t ab3100_irq_handler(int irq, void *data)u32 fatevent;int err; -add_interrupt_randomness (irq); - err =ab3100_get_register_page_interruptible (ab3100,AB3100_EVENTA1 , event_regs,3 );if (err)
include/linux/random.h +1 -1
@@ -52,7 +52,7 @@ extern void rand_initialize_irq(int irq);extern void add_input_randomness (unsigned int type,unsigned int code,unsigned int value); -extern void add_interrupt_randomness (int irq); +extern void add_interrupt_randomness (int irq,int irq_flags);extern void get_random_bytes (void *buf,int nbytes);void generate_random_uuid (unsigned char uuid_out[16 ]);
kernel/irq/handle.c +3 -4
@@ -133,7 +133,7 @@ irqreturn_t handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action) { irqreturn_t retval = IRQ_NONE; -unsigned int random =0 , irq = desc->irq_data.irq; +unsigned int flags =0 , irq = desc->irq_data.irq; do { irqreturn_t res;
@@ -161,7 +161,7 @@ handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action)/* Fall through to add to randomness */ case IRQ_HANDLED : - random |= action->flags; + flags |= action->flags;break ;default :
@@ -172,8 +172,7 @@ handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action) action = action->next; }while (action); -if (random &IRQF_SAMPLE_RANDOM ) -add_interrupt_randomness (irq); +add_interrupt_randomness (irq, flags);if (!noirqdebug)note_interrupt (irq, desc, retval);
PATCH 69/70 pch_uart: Fix rx error interrupt setting issue
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomoya MORINAGA <[email protected]>
commit 9539dfb7ac1c84522fe1f79bb7dac2990f3de44a upstream.
Rx Error interrupt(E.G. parity error) is not enabled. So, when parity error occurs, error interrupt is not occurred. As a result, the received data is not dropped.
This patch adds enable/disable rx error interrupt code.
--- drivers/tty/serial/pch_uart.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/tty/serial/pch_uart.c +12 -6
@@ -757,7 +757,8 @@ static void pch_dma_rx_complete(void *arg)tty_flip_buffer_push (tty);tty_kref_put (tty);async_tx_ack (priv->desc_rx); -pch_uart_hal_enable_interrupt (priv,PCH_UART_HAL_RX_INT ); +pch_uart_hal_enable_interrupt (priv,PCH_UART_HAL_RX_INT | +PCH_UART_HAL_RX_ERR_INT ); }static void pch_dma_tx_complete (void *arg)
@@ -812,7 +813,8 @@ static int handle_rx_to(struct eg20t_port *priv)int rx_size;int ret;if (!priv->start_rx) { -pch_uart_hal_disable_interrupt (priv,PCH_UART_HAL_RX_INT ); +pch_uart_hal_disable_interrupt (priv,PCH_UART_HAL_RX_INT | +PCH_UART_HAL_RX_ERR_INT );return 0 ; } buf = &priv->rxbuf;
@@ -1081,11 +1083,13 @@ static irqreturn_t pch_uart_interrupt(int irq, void *dev_id)case PCH_UART_IID_RDR :/* Received Data Ready */ if (priv->use_dma) {pch_uart_hal_disable_interrupt (priv, -PCH_UART_HAL_RX_INT ); +PCH_UART_HAL_RX_INT | +PCH_UART_HAL_RX_ERR_INT ); ret =dma_handle_rx (priv);if (!ret)pch_uart_hal_enable_interrupt (priv, -PCH_UART_HAL_RX_INT ); +PCH_UART_HAL_RX_INT | +PCH_UART_HAL_RX_ERR_INT ); }else { ret =handle_rx (priv); }
@@ -1211,7 +1215,8 @@ static void pch_uart_stop_rx(struct uart_port *port)struct eg20t_port *priv; priv = container_of(port, struct eg20t_port, port); priv->start_rx =0 ; -pch_uart_hal_disable_interrupt (priv,PCH_UART_HAL_RX_INT ); +pch_uart_hal_disable_interrupt (priv,PCH_UART_HAL_RX_INT | +PCH_UART_HAL_RX_ERR_INT ); priv->int_dis_flag =1 ; }
@@ -1304,7 +1309,8 @@ static int pch_uart_startup(struct uart_port *port)pch_request_dma (port); priv->start_rx =1 ; -pch_uart_hal_enable_interrupt (priv,PCH_UART_HAL_RX_INT ); +pch_uart_hal_enable_interrupt (priv,PCH_UART_HAL_RX_INT | +PCH_UART_HAL_RX_ERR_INT );uart_update_timeout (port,CS8 , default_baud);return 0 ;
PATCH 61/70 m68k: Make sys_atomic_cmpxchg_32 work on classic m68k
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Schwab <[email protected]>
commit 9e2760d18b3cf179534bbc27692c84879c61b97c upstream.
User space access must always go through uaccess accessors, since on classic m68k user space and kernel space are completely separate.
--- arch/m68k/kernel/sys_m68k.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/m68k/kernel/sys_m68k.c +6 -2
@@ -479,9 +479,13 @@ sys_atomic_cmpxchg_32(unsigned long newval, int oldval, int d3, int d4, int d5, goto bad_access; } - mem_value = *mem; +/* +* No need to check for EFAULT; we know that the page is +* present and writable. +*/ +__get_user (mem_value, mem);if (mem_value == oldval) - *mem = newval; +__put_user (newval, mem);pte_unmap_unlock (pte, ptl);up_read (&mm->mmap_sem);
PATCH 59/70 ALSA: hda - Support dock on Lenovo Thinkpad T530 with ALC269VC
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 707fba3fa76a4c8855552f5d4c1a12430c09bce8 upstream.
Lenovo Thinkpad T530 with ALC269VC codec has a dock port but BIOS doesn't set up the pins properly. Enable the pins as well as on Thinkpad X230 Tablet.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -6206,6 +6206,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x17aa ,0x21b8 ,"Thinkpad Edge 14" ,ALC269_FIXUP_SKU_IGNORE ),SND_PCI_QUIRK (0x17aa ,0x21ca ,"Thinkpad L412" ,ALC269_FIXUP_SKU_IGNORE ),SND_PCI_QUIRK (0x17aa ,0x21e9 ,"Thinkpad Edge 15" ,ALC269_FIXUP_SKU_IGNORE ), +SND_PCI_QUIRK (0x17aa ,0x21f6 ,"Thinkpad T530" ,ALC269_FIXUP_LENOVO_DOCK ),SND_PCI_QUIRK (0x17aa ,0x2203 ,"Thinkpad X230 Tablet" ,ALC269_FIXUP_LENOVO_DOCK ),SND_PCI_QUIRK (0x17aa ,0x3bf8 ,"Quanta FL1" ,ALC269_FIXUP_QUANTA_MUTE ), SND_PCI_QUIRK(0x17aa, 0x3bf8, "Lenovo Ideapd", ALC269_FIXUP_PCM_44K),
PATCH 53/70 ASoC: wm8962: Allow VMID time to fully ramp
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
commit 9d40e5582c9c4cfb6977ba2a0ca9c2ed82c56f21 upstream.
Required for reliable power up from cold.
--- sound/soc/codecs/wm8962.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/codecs/wm8962.c +3 -0
@@ -2501,6 +2501,9 @@ static int wm8962_set_bias_level(struct snd_soc_codec *codec,/* VMID 2*250k */ snd_soc_update_bits (codec,WM8962_PWR_MGMT_1 ,WM8962_VMID_SEL_MASK ,0x100 ); + +if (codec->dapm.bias_level ==SND_SOC_BIAS_OFF ) +msleep (100 );break ;case SND_SOC_BIAS_OFF :
PATCH 68/70 pch_uart: Fix missing break for 16 byte fifo
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Cox <[email protected]>
commit 9bc03743fff0770dc5a5324ba92e67cc377f16ca upstream.
Otherwise we fall back to the wrong value.
Resolves-bug: https://bugzilla.kernel.org/show_bug.cgi?id=44091
--- drivers/tty/serial/pch_uart.c | 1 + 1 file changed, 1 insertion(+)
drivers/tty/serial/pch_uart.c +1 -0
@@ -1266,6 +1266,7 @@ static int pch_uart_startup(struct uart_port *port)break ;case 16 : fifo_size =PCH_UART_HAL_FIFO16 ; +break ;case 1 :default : fifo_size =PCH_UART_HAL_FIFO_DIS ;
PATCH 63/70 rt2x00: Add support for BUFFALO WLI-UC-GNM2 to rt2800usb.
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeongdo Son <[email protected]>
commit a769f9577232afe2c754606a83aad85127e7052a upstream.
This is a RT3070 based device.
--- drivers/net/wireless/rt2x00/rt2800usb.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/rt2x00/rt2800usb.c +1 -0
@@ -971,6 +971,7 @@ static struct usb_device_id rt2800usb_device_table[] = { { USB_DEVICE(0x0411, 0x015d) }, { USB_DEVICE(0x0411, 0x016f) }, { USB_DEVICE(0x0411, 0x01a2) }, + { USB_DEVICE(0x0411, 0x01ee) },/* Corega */ { USB_DEVICE(0x07aa, 0x002f) }, { USB_DEVICE(0x07aa, 0x003c) },
PATCH 49/70 ARM: 7477/1: vfp: Always save VFP state in vfp_pm_suspend on UP
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Colin Cross <[email protected]>
commit 24b35521b8ddf088531258f06f681bb7b227bf47 upstream.
vfp_pm_suspend should save the VFP state in suspend after any lazy context switch. If it only saves when the VFP is enabled, the state can get lost when, on a UP system:
Thread 1 uses the VFP
Context switch occurs to thread 2, VFP is disabled but the
VFP context is not saved
Thread 2 initiates suspend
vfp_pm_suspend is called with the VFP disabled, and the unsaved
VFP context of Thread 1 in the registers
Modify vfp_pm_suspend to save the VFP context whenever vfp_current_hw_state is not NULL.
Includes a fix from Ido Yariv <[email protected]>, who pointed out that on SMP systems, the state pointer can be pointing to a freed task struct if a task exited on another cpu, fixed by using #ifndef CONFIG_SMP in the new if clause.
--- arch/arm/vfp/vfpmodule.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm/vfp/vfpmodule.c +6 -0
@@ -457,6 +457,12 @@ static int vfp_pm_suspend(void)/* disable, just in case */ fmxr (FPEXC ,fmrx (FPEXC ) & ~FPEXC_EN ); + }else if (vfp_current_hw_state[ti->cpu]) { +#ifndef CONFIG_SMP +fmxr (FPEXC , fpexc |FPEXC_EN ); +vfp_save_state (vfp_current_hw_state[ti->cpu], fpexc); +fmxr (FPEXC , fpexc); +#endif }/* clear any information we had about last context state */
PATCH 42/70 pcdp: use early_ioremap/early_iounmap to access pcdp table
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Pearson <[email protected]>
commit 6c4088ac3a4d82779903433bcd5f048c58fb1aca upstream.
efi_setup_pcdp_console() is called during boot to parse the HCDP/PCDP EFI system table and setup an early console for printk output. The routine uses ioremap/iounmap to setup access to the HCDP/PCDP table information.
The call to ioremap is happening early in the boot process which leads to a panic on x86_64 systems:
panic+0x01ca
do_exit+0x043c
oops_end+0x00a7
no_context+0x0119
__bad_area_nosemaphore+0x0138
bad_area_nosemaphore+0x000e
do_page_fault+0x0321
page_fault+0x0020
reserve_memtype+0x02a1
__ioremap_caller+0x0123
ioremap_nocache+0x0012
efi_setup_pcdp_console+0x002b
setup_arch+0x03a9
start_kernel+0x00d4
x86_64_start_reservations+0x012c
x86_64_start_kernel+0x00feThis replaces the calls to ioremap/iounmap in efi_setup_pcdp_console() with calls to early_ioremap/early_iounmap which can be called during early boot.
This patch was tested on an x86_64 prototype system which uses the HCDP/PCDP table for early console setup.
--- drivers/firmware/pcdp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/firmware/pcdp.c +2 -2
@@ -95,7 +95,7 @@ efi_setup_pcdp_console(char *cmdline)if (efi.hcdp ==EFI_INVALID_TABLE_ADDR )return -ENODEV ; - pcdp =ioremap (efi.hcdp,4096 ); + pcdp =early_ioremap (efi.hcdp,4096 );printk (KERN_INFO "PCDP: v%d at 0x%lx\n" , pcdp->rev, efi.hcdp);if (strstr (cmdline,"console=hcdp" )) {
@@ -131,6 +131,6 @@ efi_setup_pcdp_console(char *cmdline) } out: -iounmap (pcdp); +early_iounmap (pcdp,4096 );return rc; }
PATCH 34/70 dm thin: reduce endio_hook pool size
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alasdair G Kergon <[email protected]>
commit 7768ed33ccdc02801c4483fc5682dc66ace14aea upstream.
Reduce the slab size used for the dm_thin_endio_hook mempool.
Allocation has been seen to fail on machines with smaller amounts of memory due to fragmentation.
lvm: page allocation failure. order:5, mode:0xd0
device-mapper: table: 253:38: thin-pool: Error creating pool's endio_hook mempool
--- drivers/md/dm-thin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-thin.c +1 -1
@@ -19,7 +19,7 @@/* * Tunable constants */ -#define ENDIO_HOOK_POOL_SIZE 10240 +#define ENDIO_HOOK_POOL_SIZE 1024#define DEFERRED_SET_SIZE 64#define MAPPING_POOL_SIZE 1024#define PRISON_CELLS 1024
PATCH 41/70 md/raid1: dont abort a resync on the first badblock.
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: NeilBrown <[email protected]>
commit b7219ccb33aa0df9949a60c68b5e9f712615e56f upstream.
If a resync of a RAID1 array with 2 devices finds a known bad block one device it will neither read from, or write to, that device for this block offset.
So there will be one read_target (The other device) and zero write targets.
This condition causes md/raid1 to abort the resync assuming that it has finished - without known bad blocks this would be true.
When there are no write targets because of the presence of bad blocks we should only skip over the area covered by the bad block. RAID10 already gets this right, raid1 doesn't. Or didn't.
As this can cause a 'sync' to abort early and appear to have succeeded it could lead to some data corruption, so it suitable for -stable.
--- drivers/md/raid1.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/md/raid1.c +4 -1
@@ -2502,7 +2502,10 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr, int *skipp/* There is nowhere to write, so all non-sync * drives must be failed - so we are finished */ -sector_t rv = max_sector - sector_nr; +sector_t rv; +if (min_bad >0 ) + max_sector = sector_nr + min_bad; + rv = max_sector - sector_nr; *skipped =1 ;put_buf (r1_bio);return rv;
PATCH 20/70 random: add new get_random_bytes_arch() function
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
commit c2557a303ab6712bb6e09447df828c557c710ac9 upstream.
Create a new function, get_random_bytes_arch() which will use the architecture-specific hardware random number generator if it is present. Change get_random_bytes() to not use the HW RNG, even if it is avaiable.
The reason for this is that the hw random number generator is fast (if it is present), but it requires that we trust the hardware manufacturer to have not put in a back door. (For example, an increasing counter encrypted by an AES key known to the NSA.)
It's unlikely that Intel (for example) was paid off by the US Government to do this, but it's impossible for them to prove otherwise --- especially since Bull Mountain is documented to use AES as a whitener. Hence, the output of an evil, trojan-horse version of RDRAND is statistically indistinguishable from an RDRAND implemented to the specifications claimed by Intel. Short of using a tunnelling electronic microscope to reverse engineer an Ivy Bridge chip and disassembling and analyzing the CPU microcode, there's no way for us to tell for sure.
Since users of get_random_bytes() in the Linux kernel need to be able to support hardware systems where the HW RNG is not present, most time-sensitive users of this interface have already created their own cryptographic RNG interface which uses get_random_bytes() as a seed. So it's much better to use the HW RNG to improve the existing random number generator, by mixing in any entropy returned by the HW RNG into /dev/random's entropy pool, but to always _use_ /dev/random's entropy pool.
This way we get almost of the benefits of the HW RNG without any potential liabilities. The only benefits we forgo is the speed/performance enhancements --- and generic kernel code can't depend on depend on get_random_bytes() having the speed of a HW RNG anyway.
For those places that really want access to the arch-specific HW RNG, if it is available, we provide get_random_bytes_arch().
--- drivers/char/random.c | 29 ++++++++++++++++++++++++----- include/linux/random.h | 1 + 2 files changed, 25 insertions(+), 5 deletions(-)
drivers/char/random.c +24 -5
@@ -1038,17 +1038,34 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,/* * This function is the exported kernel interface. It returns some -* number of good random numbers, suitable for seeding TCP sequence -* numbers, etc. +* number of good random numbers, suitable for key generation, seeding +* TCP sequence numbers, etc. It does not use the hw random number +* generator, if available; use get_random_bytes_arch() for that. */ void get_random_bytes (void *buf,int nbytes) { +extract_entropy (&nonblocking_pool, buf, nbytes,0 ,0 ); +} +EXPORT_SYMBOL (get_random_bytes); + +/* +* This function will use the architecture-specific hardware random +* number generator if it is available. The arch-specific hw RNG will +* almost certainly be faster than what we can do in software, but it +* is impossible to verify that it is implemented securely (as +* opposed, to, say, the AES encryption of a sequence number using a +* key known by the NSA). So it's useful if we need the speed, but +* only if we're willing to trust the hardware manufacturer not to +* have put in a back door. +*/ +void get_random_bytes_arch (void *buf,int nbytes) +{char *p = buf;while (nbytes) {unsigned long v;int chunk =min (nbytes, (int )sizeof (unsigned long )); - +if (!arch_get_random_long (&v))break ;
@@ -1057,9 +1074,11 @@ void get_random_bytes(void *buf, int nbytes) nbytes -= chunk; } -extract_entropy (&nonblocking_pool, p, nbytes,0 ,0 ); +if (nbytes) +extract_entropy (&nonblocking_pool, p, nbytes,0 ,0 ); } -EXPORT_SYMBOL (get_random_bytes); +EXPORT_SYMBOL (get_random_bytes_arch); +/* * init_std_data - initialize pool with system data
include/linux/random.h +1 -0
@@ -56,6 +56,7 @@ extern void add_input_randomness(unsigned int type, unsigned int code,extern void add_interrupt_randomness (int irq,int irq_flags);extern void get_random_bytes (void *buf,int nbytes); +extern void get_random_bytes_arch (void *buf,int nbytes);void generate_random_uuid (unsigned char uuid_out[16 ]);#ifndef MODULE
PATCH 25/70 futex: Fix bug in WARN_ON for NULL q.pi_state
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darren Hart <[email protected]>
commit f27071cb7fe3e1d37a9dbe6c0dfc5395cd40fa43 upstream.
The WARN_ON in futex_wait_requeue_pi() for a NULL q.pi_state was testing the address (&q.pi_state) of the pointer instead of the value (q.pi_state) of the pointer. Correct it accordingly.
--- kernel/futex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/futex.c +1 -1
@@ -2343,7 +2343,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags,* signal. futex_unlock_pi() will not destroy the lock_ptr nor * the pi_state. */ -WARN_ON (!&q.pi_state); +WARN_ON (!q.pi_state); pi_mutex = &q.pi_state->pi_mutex; ret =rt_mutex_finish_proxy_lock (pi_mutex, to, &rt_waiter,1 );debug_rt_mutex_free_waiter (&rt_waiter);
PATCH 24/70 futex: Test for pi_mutex on fault in futex_wait_requeue_pi()
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darren Hart <[email protected]>
commit b6070a8d9853eda010a549fa9a09eb8d7269b929 upstream.
If fixup_pi_state_owner() faults, pi_mutex may be NULL. Test for pi_mutex != NULL before testing the owner against current and possibly unlocking it.
--- kernel/futex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/futex.c +1 -1
@@ -2370,7 +2370,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags,* fault, unlock the rt_mutex and return the fault to userspace. */ if (ret == -EFAULT ) { -if (rt_mutex_owner (pi_mutex) == current) +if (pi_mutex &&rt_mutex_owner (pi_mutex) == current)rt_mutex_unlock (pi_mutex); }else if (ret == -EINTR ) {/*
PATCH 21/70 rtc: wm831x: Feed the write counter into device_add_randomness()
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
commit 9dccf55f4cb011a7552a8a2749a580662f5ed8ed upstream.
The tamper evident features of the RTC include the "write counter" which is a pseudo-random number regenerated whenever we set the RTC. Since this value is unpredictable it should provide some useful seeding to the random number generator.
Only do this on boot since the goal is to seed the pool rather than add useful entropy.
--- drivers/rtc/rtc-wm831x.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
drivers/rtc/rtc-wm831x.c +23 -1
@@ -24,7 +24,7 @@#include <linux/mfd/wm831x/core.h> #include <linux/delay.h> #include <linux/platform_device.h> - +#include <linux/random.h> /* * R16416 (0x4020) - RTC Write Counter
@@ -96,6 +96,26 @@ struct wm831x_rtc { unsigned int alarm_enabled:1; }; +static void wm831x_rtc_add_randomness (struct wm831x *wm831x) +{ +int ret; +u16 reg; + +/* +* The write counter contains a pseudo-random number which is +* regenerated every time we set the RTC so it should be a +* useful per-system source of entropy. +*/ + ret =wm831x_reg_read (wm831x,WM831X_RTC_WRITE_COUNTER ); +if (ret >=0 ) { + reg = ret; +add_device_randomness (®,sizeof (reg)); + }else { +dev_warn (wm831x->dev,"Failed to read RTC write counter: %d\n" , + ret); + } +} +/* * Read current time and date in RTC */
@@ -431,6 +451,8 @@ static int wm831x_rtc_probe(struct platform_device *pdev) alm_irq, ret); } +wm831x_rtc_add_randomness (wm831x); +return 0 ; err:
PATCH 22/70 mfd: wm831x: Feed the device UUID into device_add_randomness()
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
commit 27130f0cc3ab97560384da437e4621fc4e94f21c upstream.
wm831x devices contain a unique ID value. Feed this into the newly added device_add_randomness() to add some per device seed data to the pool.
--- drivers/mfd/wm831x-otp.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/mfd/wm831x-otp.c +8 -0
@@ -18,6 +18,7 @@#include <linux/bcd.h> #include <linux/delay.h> #include <linux/mfd/core.h> +#include <linux/random.h> #include <linux/mfd/wm831x/core.h> #include <linux/mfd/wm831x/otp.h>
@@ -66,6 +67,7 @@ static DEVICE_ATTR(unique_id, 0444, wm831x_unique_id_show, NULL);int wm831x_otp_init (struct wm831x *wm831x) { +char uuid[WM831X_UNIQUE_ID_LEN ];int ret; ret =device_create_file (wm831x->dev, &dev_attr_unique_id);
@@ -73,6 +75,12 @@ int wm831x_otp_init(struct wm831x *wm831x)dev_err (wm831x->dev,"Unique ID attribute not created: %d\n" , ret); + ret =wm831x_unique_id_read (wm831x, uuid); +if (ret ==0 ) +add_device_randomness (uuid,sizeof (uuid)); +else +dev_err (wm831x->dev,"Failed to read UUID: %d\n" , ret); +return ret; }
PATCH 26/70 futex: Forbid uaddr == uaddr2 in futex_wait_requeue_pi()
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darren Hart <[email protected]>
commit 6f7b0a2a5c0fb03be7c25bd1745baa50582348ef upstream.
If uaddr == uaddr2, then we have broken the rule of only requeueing from a non-pi futex to a pi futex with this call. If we attempt this, as the trinity test suite manages to do, we miss early wakeups as q.key is equal to key2 (because they are the same uaddr). We will then attempt to dereference the pi_mutex (which would exist had the futex_q been properly requeued to a pi futex) and trigger a NULL pointer dereference.
--- kernel/futex.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
kernel/futex.c +8 -5
@@ -2231,11 +2231,11 @@ int handle_early_requeue_pi_wakeup(struct futex_hash_bucket *hb,* @uaddr2: the pi futex we will take prior to returning to user-space * * The caller will wait on uaddr and will be requeued by futex_requeue() to -* uaddr2 which must be PI aware. Normal wakeup will wake on uaddr2 and -* complete the acquisition of the rt_mutex prior to returning to userspace. -* This ensures the rt_mutex maintains an owner when it has waiters; without -* one, the pi logic wouldn't know which task to boost/deboost, if there was a -* need to. +* uaddr2 which must be PI aware and unique from uaddr. Normal wakeup will wake +* on uaddr2 and complete the acquisition of the rt_mutex prior to returning to +* userspace. This ensures the rt_mutex maintains an owner when it has waiters; +* without one, the pi logic would not know which task to boost/deboost, if +* there was a need to. * * We call schedule in futex_wait_queue_me() when we enqueue and return there * via the following:
@@ -2272,6 +2272,9 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags,struct futex_q q = futex_q_init;int res, ret; +if (uaddr == uaddr2) +return -EINVAL ; +if (!bitset)return -EINVAL ;
PATCH 23/70 ASoC: wm8994: Ensure there are enough BCLKs for four channels
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
commit b8edf3e5522735c8ce78b81845f7a1a2d4a08626 upstream.
Otherwise if someone tries to use all four channels on AIF1 with the device in master mode we won't be able to clock out all the data.
--- sound/soc/codecs/wm8994.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8994.c +1 -1
@@ -2649,7 +2649,7 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream,return -EINVAL ; } - bclk_rate =params_rate (params) *2 ; + bclk_rate =params_rate (params) *4 ;switch (params_format (params)) {case SNDRV_PCM_FORMAT_S16_LE : bclk_rate *=16 ;
PATCH 31/70 x86, nops: Missing break resulting in incorrect selection on Intel
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Cox <[email protected]>
commit d6250a3f12edb3a86db9598ffeca3de8b4a219e9 upstream.
The Intel case falls through into the generic case which then changes the values. For cases like the P6 it doesn't do the right thing so this seems to be a screwup.
--- arch/x86/kernel/alternative.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/alternative.c +1 -1
@@ -219,7 +219,7 @@ void __init arch_init_ideal_nops(void) ideal_nops = intel_nops;#endif } - +break ;default :#ifdef CONFIG_X86_64 ideal_nops = k8_nops;
PATCH 27/70 video/smscufx: fix line counting in fb_write
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Holler <[email protected]>
commit 2fe2d9f47cfe1a3e66e7d087368b3d7155b04c15 upstream.
Line 0 and 1 were both written to line 0 (on the display) and all subsequent lines had an offset of -1. The result was that the last line on the display was never overwritten by writes to /dev/fbN.
The origin of this bug seems to have been udlfb.
--- drivers/video/smscufx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/smscufx.c +1 -1
@@ -904,7 +904,7 @@ static ssize_t ufx_ops_write(struct fb_info *info, const char __user *buf, result =fb_sys_write (info, buf, count, ppos);if (result >0 ) { -int start =max ((int )(offset / info->fix.line_length) -1 ,0 ); +int start =max ((int )(offset / info->fix.line_length),0 );int lines =min ((u32)((result / info->fix.line_length) +1 ), (u32 )info->var.yres);
PATCH 28/70 Input: synaptics - handle out of bounds values from the hardware
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Seth Forshee <[email protected]>
commit c0394506e69b37c47d391c2a7bbea3ea236d8ec8 upstream.
The touchpad on the Acer Aspire One D250 will report out of range values in the extreme lower portion of the touchpad. These appear as abrupt changes in the values reported by the hardware from very low values to very high values, which can cause unexpected vertical jumps in the position of the mouse pointer.
What seems to be happening is that the value is wrapping to a two's compliment negative value of higher resolution than the 13-bit value reported by the hardware, with the high-order bits being truncated. This patch adds handling for these values by converting them to the appropriate negative values.
The only tricky part about this is deciding when to treat a number as negative. It stands to reason that if out of range values can be reported on the low end then it could also happen on the high end, so not all out of range values should be treated as negative. The approach taken here is to split the difference between the maximum legitimate value for the axis and the maximum possible value that the hardware can report, treating values greater than this number as negative and all other values as positive. This can be tweaked later if hardware is found that operates outside of these parameters.
---
drivers/input/mouse/synaptics.c +23 -0
@@ -40,11 +40,28 @@* Note that newer firmware allows querying device for maximum useable * coordinates. */ +#define XMIN 0 +#define XMAX 6143 +#define YMIN 0 +#define YMAX 6143#define XMIN_NOMINAL 1472#define XMAX_NOMINAL 5472#define YMIN_NOMINAL 1408#define YMAX_NOMINAL 4448 +/* Size in bits of absolute position values reported by the hardware */ +#define ABS_POS_BITS 13 + +/* +* Any position values from the hardware above the following limits are +* treated as "wrapped around negative" values that have been truncated to +* the 13-bit reporting range of the hardware. These are just reasonable +* guesses and can be adjusted if hardware is found that operates outside +* of these parameters. +*/ +#define X_MAX_POSITIVE (((1 << ABS_POS_BITS) + XMAX) / 2) +#define Y_MAX_POSITIVE (((1 << ABS_POS_BITS) + YMAX) / 2) +/* * Synaptics touchpads report the y coordinate from bottom to top, which is * opposite from what userspace expects.
@@ -544,6 +561,12 @@ static int synaptics_parse_hw_state(cons hw->right = (buf[0 ] &0x02 ) ?1 :0 ; } +/* Convert wrap-around values to negative */ +if (hw->x >X_MAX_POSITIVE ) + hw->x -=1 <<ABS_POS_BITS ; +if (hw->y >Y_MAX_POSITIVE ) + hw->y -=1 <<ABS_POS_BITS ; +return 0 ; }
PATCH 29/70 ALSA: hda - Fix invalid D3 of headphone DAC on VT202x codecs
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 6162552b0de6ba80937c3dd53e084967851cd199 upstream.
We've got a bug report about the silent output from the headphone on a mobo with VT2021, and spotted out that this was because of the wrong D3 state on the DAC for the headphone output. The bug is triggered by the incomplete check for this DAC in set_widgets_power_state_vt1718S(). It checks only the connectivity of the primary output (0x27) but doesn't consider the path from the headphone pin (0x28).
Now this patch fixes the problem by checking both pins for DAC 0x0b.
[bwh: Backported to 3.2: keep using snd_hda_codec_write() as
update_power_state() is missing]
---
sound/pci/hda/patch_via.c +5 -2
@@ -3227,7 +3227,7 @@ static void set_widgets_power_state_vt17 {struct via_spec *spec = codec->spec;int imux_is_smixer; -unsigned int parm; +unsigned int parm, parm2;/* MUX6 (1eh) = stereo mixer */ imux_is_smixer =snd_hda_codec_read (codec,0x1e ,0 ,AC_VERB_GET_CONNECT_SEL ,0x00 ) ==5 ;
@@ -3250,7 +3250,7 @@ static void set_widgets_power_state_vt17 parm =AC_PWRST_D3 ;set_pin_power_state (codec,0x27 , &parm);snd_hda_codec_write (codec,0x1a ,0 ,AC_VERB_SET_POWER_STATE , parm); -snd_hda_codec_write (codec,0xb ,0 ,AC_VERB_SET_POWER_STATE , parm); + parm2 = parm;/* for pin 0x0b */ /* PW2 (26h), AOW2 (ah) */ parm =AC_PWRST_D3 ;
@@ -3265,6 +3265,9 @@ static void set_widgets_power_state_vt17if (!spec->hp_independent_mode)/* check for redirected HP */ set_pin_power_state (codec,0x28 , &parm);snd_hda_codec_write (codec,0x8 ,0 ,AC_VERB_SET_POWER_STATE , parm); +if (!spec->hp_independent_mode && parm2 !=AC_PWRST_D3 ) + parm = parm2; +snd_hda_codec_write (codec,0xb ,0 ,AC_VERB_SET_POWER_STATE , parm);/* MW9 (21h), Mw2 (1ah), AOW0 (8h) */ snd_hda_codec_write (codec,0x21 ,0 ,AC_VERB_SET_POWER_STATE , imux_is_smixer ?AC_PWRST_D0 : parm);
PATCH 36/70 random: mix in architectural randomness in extract_buf()
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: "H. Peter Anvin" <[email protected]>
commit d2e7c96af1e54b507ae2a6a7dd2baf588417a7e5 upstream.
Mix in any architectural randomness in extract_buf() instead of xfer_secondary_buf(). This allows us to mix in more architectural randomness, and it also makes xfer_secondary_buf() faster, moving a tiny bit of additional CPU overhead to process which is extracting the randomness.
[ Commit description modified by tytso to remove an extended
advertisement for the RDRAND instruction. ]
--- drivers/char/random.c | 56 ++++++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 24 deletions(-)
drivers/char/random.c +32 -24
@@ -277,6 +277,8 @@#define SEC_XFER_SIZE 512#define EXTRACT_SIZE 10 +#define LONGS (x) (((x) + sizeof(unsigned long) - 1)/sizeof(unsigned long)) +/* * The minimum number of bits of entropy before we wake up a read on * /dev/random. Should be enough to do a significant reseed.
@@ -813,11 +815,7 @@ static ssize_t extract_entropy(struct entropy_store *r, void *buf,*/ static void xfer_secondary_pool (struct entropy_store *r,size_t nbytes) { -union { -__u32 tmp[OUTPUT_POOL_WORDS ]; -long hwrand[4 ]; - } u; -int i; +__u32 tmp[OUTPUT_POOL_WORDS ];if (r->pull && r->entropy_count < nbytes *8 && r->entropy_count < r->poolinfo->POOLBITS) {
@@ -828,23 +826,17 @@ static void xfer_secondary_pool(struct entropy_store *r, size_t nbytes)/* pull at least as many as BYTES as wakeup BITS */ bytes =max_t (int, bytes, random_read_wakeup_thresh /8 );/* but never more than the buffer size */ - bytes =min_t (int, bytes,sizeof (u.tmp)); + bytes =min_t (int, bytes,sizeof (tmp));DEBUG_ENT ("going to reseed %s with %d bits " "(%d of %d requested)\n" , r->name, bytes *8 , nbytes *8 , r->entropy_count); - bytes =extract_entropy (r->pull, u.tmp, bytes, + bytes =extract_entropy (r->pull, tmp, bytes, random_read_wakeup_thresh /8 , rsvd); -mix_pool_bytes (r, u.tmp, bytes,NULL ); +mix_pool_bytes (r, tmp, bytes,NULL );credit_entropy_bits (r, bytes*8 ); } -kmemcheck_mark_initialized (&u.hwrand,sizeof (u.hwrand)); -for (i =0 ; i <4 ; i++) -if (arch_get_random_long (&u.hwrand[i])) -break ; -if (i) -mix_pool_bytes (r, &u.hwrand,sizeof (u.hwrand),0 ); }/*
@@ -901,15 +893,19 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,static void extract_buf (struct entropy_store *r,__u8 *out) {int i; -__u32 hash[5 ], workspace[SHA_WORKSPACE_WORDS ]; +union { +__u32 w[5 ]; +unsigned long l[LONGS (EXTRACT_SIZE )]; + } hash; +__u32 workspace[SHA_WORKSPACE_WORDS ];__u8 extract[64 ];unsigned long flags;/* Generate a hash across the pool, 16 words (512 bits) at a time */ -sha_init (hash); +sha_init (hash.w);spin_lock_irqsave (&r->lock, flags);for (i =0 ; i < r->poolinfo->poolwords; i +=16 ) -sha_transform (hash, (__u8 *)(r->pool + i), workspace); +sha_transform (hash.w, (__u8 *)(r->pool + i), workspace);/* * We mix the hash back into the pool to prevent backtracking
@@ -920,14 +916,14 @@ static void extract_buf(struct entropy_store *r, __u8 *out)* brute-forcing the feedback as hard as brute-forcing the * hash. */ -__mix_pool_bytes (r, hash,sizeof (hash), extract); +__mix_pool_bytes (r, hash.w,sizeof (hash.w), extract);spin_unlock_irqrestore (&r->lock, flags);/* * To avoid duplicates, we atomically extract a portion of the * pool while mixing, and hash one final time. */ -sha_transform (hash, extract, workspace); +sha_transform (hash.w, extract, workspace);memset (extract,0 ,sizeof (extract));memset (workspace,0 ,sizeof (workspace));
@@ -936,11 +932,23 @@ static void extract_buf(struct entropy_store *r, __u8 *out)* pattern, we fold it in half. Thus, we always feed back * twice as much data as we output. */ - hash[0 ] ^= hash[3 ]; - hash[1 ] ^= hash[4 ]; - hash[2 ] ^=rol32 (hash[2 ],16 ); -memcpy (out, hash,EXTRACT_SIZE ); -memset (hash,0 ,sizeof (hash)); + hash.w[0 ] ^= hash.w[3 ]; + hash.w[1 ] ^= hash.w[4 ]; + hash.w[2 ] ^=rol32 (hash.w[2 ],16 ); + +/* +* If we have a architectural hardware random number +* generator, mix that in, too. +*/ +for (i =0 ; i <LONGS (EXTRACT_SIZE ); i++) { +unsigned long v; +if (!arch_get_random_long (&v)) +break ; + hash.l[i] ^= v; + } + +memcpy (out, &hash,EXTRACT_SIZE ); +memset (&hash,0 ,sizeof (hash)); } static ssize_t extract_entropy(struct entropy_store *r, void *buf,
PATCH 32/70 s390/mm: downgrade page table after fork of a 31 bit process
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Schwidefsky <[email protected]>
commit 0f6f281b731d20bfe75c13f85d33f3f05b440222 upstream.
The downgrade of the 4 level page table created by init_new_context is currently done only in start_thread31. If a 31 bit process forks the new mm uses a 4 level page table, including the task size of 2<<42 that goes along with it. This is incorrect as now a 31 bit process can map memory beyond 2GB. Define arch_dup_mmap to do the downgrade after fork.
--- arch/s390/include/asm/mmu_context.h | 14 +++++++++++++- arch/s390/include/asm/processor.h | 2 ++ arch/s390/mm/mmap.c | 12 ++++++++++-- arch/s390/mm/pgtable.c | 5 ----- 4 files changed, 25 insertions(+), 8 deletions(-)
arch/s390/include/asm/mmu_context.h +13 -1
@@ -12,7 +12,6 @@#include <asm/pgalloc.h> #include <asm/uaccess.h> #include <asm/tlbflush.h> -#include <asm-generic/mm_hooks.h> static inline int init_new_context (struct task_struct *tsk,struct mm_struct *mm)
@@ -92,4 +91,17 @@ static inline void activate_mm(struct mm switch_mm(prev, next, current); } +static inline void arch_dup_mmap (struct mm_struct *oldmm, +struct mm_struct *mm) +{ +#ifdef CONFIG_64BIT +if (oldmm->context.asce_limit < mm->context.asce_limit) +crst_table_downgrade (mm, oldmm->context.asce_limit); +#endif +} + +static inline void arch_exit_mmap (struct mm_struct *mm) +{ +} +#endif /* __S390_MMU_CONTEXT_H */
arch/s390/include/asm/processor.h +2 -0
@@ -130,7 +130,9 @@ struct stack_frame { regs->psw.mask = psw_user_bits |PSW_MASK_BA ; \ regs->psw.addr = new_psw |PSW_ADDR_AMODE ; \ regs->gprs[15 ] = new_stackp; \ +__tlb_flush_mm (current->mm); \crst_table_downgrade (current->mm,1UL <<31 ); \ +update_mm (current->mm, current); \ }while (0 )/* Forward declaration, a strange C thing */
arch/s390/mm/mmap.c +10 -2
@@ -106,9 +106,15 @@ EXPORT_SYMBOL_GPL(arch_pick_mmap_layout)int s390_mmap_check (unsigned long addr,unsigned long len) { +int rc; +if (!is_compat_task () && - len >=TASK_SIZE &&TASK_SIZE < (1UL <<53 )) -return crst_table_upgrade (current->mm,1UL <<53 ); + len >=TASK_SIZE &&TASK_SIZE < (1UL <<53 )) { + rc =crst_table_upgrade (current->mm,1UL <<53 ); +if (rc) +return rc; +update_mm (current->mm, current); + }return 0 ; }
@@ -128,6 +134,7 @@ s390_get_unmapped_area(struct file *filp rc =crst_table_upgrade (mm,1UL <<53 );if (rc)return (unsigned long ) rc; +update_mm (mm, current); area =arch_get_unmapped_area (filp, addr, len, pgoff, flags); }return area;
@@ -150,6 +157,7 @@ s390_get_unmapped_area_topdown(struct fi rc =crst_table_upgrade (mm,1UL <<53 );if (rc)return (unsigned long ) rc; +update_mm (mm, current); area =arch_get_unmapped_area_topdown (filp, addr, len, pgoff, flags); }
arch/s390/mm/pgtable.c +0 -5
@@ -97,7 +97,6 @@ repeat:crst_table_free (mm, table);if (mm->context.asce_limit < limit) goto repeat; -update_mm (mm, current);return 0 ; }
@@ -105,9 +104,6 @@ void crst_table_downgrade(struct mm_stru {pgd_t *pgd; -if (mm->context.asce_limit <= limit) -return ; -__tlb_flush_mm (mm);while (mm->context.asce_limit > limit) { pgd = mm->pgd;switch (pgd_val (*pgd) & _REGION_ENTRY_TYPE_MASK) {
@@ -130,7 +126,6 @@ void crst_table_downgrade(struct mm_stru mm->task_size = mm->context.asce_limit; crst_table_free(mm, (unsigned long *) pgd); } -update_mm (mm, current); }#endif
PATCH 30/70 ALSA: mpu401: Fix missing initialization of irq field
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit bc733d495267a23ef8660220d696c6e549ce30b3 upstream.
The irq field of struct snd_mpu401 is supposed to be initialized to -1. Since it's set to zero as of now, a probing error before the irq installation results in a kernel warning "Trying to free already-free IRQ 0".
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=44821
--- sound/drivers/mpu401/mpu401_uart.c | 1 + 1 file changed, 1 insertion(+)
sound/drivers/mpu401/mpu401_uart.c +1 -0
@@ -554,6 +554,7 @@ int snd_mpu401_uart_new(struct snd_card *card, int device,spin_lock_init (&mpu->output_lock);spin_lock_init (&mpu->timer_lock); mpu->hardware = hardware; + mpu->irq =-1 ;if (! (info_flags &MPU401_INFO_INTEGRATED )) {int res_size = hardware ==MPU401_HW_PC98II ?4 :2 ; mpu->res =request_region (port, res_size,"MPU401 UART" );
PATCH 44/70 nilfs2: fix deadlock issue between chcp and thaw ioctls
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
commit 572d8b3945a31bee7c40d21556803e4807fd9141 upstream.
An fs-thaw ioctl causes deadlock with a chcp or mkcp -s command:
chcp D ffff88013870f3d0 0 1325 1324 0x00000004
...
Call Trace: nilfs_transaction_begin+0x11c/0x1a0 [nilfs2] wake_up_bit+0x20/0x20 copy_from_user+0x18/0x30 [nilfs2] nilfs_ioctl_change_cpmode+0x7d/0xcf [nilfs2] nilfs_ioctl+0x252/0x61a [nilfs2] do_page_fault+0x311/0x34c get_unmapped_area+0x132/0x14e do_vfs_ioctl+0x44b/0x490 __set_task_blocked+0x5a/0x61 vm_mmap_pgoff+0x76/0x87 __set_current_blocked+0x30/0x4a sys_ioctl+0x4b/0x6f system_call_fastpath+0x16/0x1b thaw D ffff88013870d890 0 1352 1351 0x00000004 ... Call Trace: rwsem_down_failed_common+0xdb/0x10f call_rwsem_down_write_failed+0x13/0x20 down_write+0x25/0x27 thaw_super+0x13/0x9e do_vfs_ioctl+0x1f5/0x490 vm_mmap_pgoff+0x76/0x87 sys_ioctl+0x4b/0x6f filp_close+0x64/0x6c system_call_fastpath+0x16/0x1b
where the thaw ioctl deadlocked at thaw_super() when called while chcp was waiting at nilfs_transaction_begin() called from nilfs_ioctl_change_cpmode(). This deadlock is 100% reproducible.
This is because nilfs_ioctl_change_cpmode() first locks sb->s_umount in read mode and then waits for unfreezing in nilfs_transaction_begin(), whereas thaw_super() locks sb->s_umount in write mode. The locking of sb->s_umount here was intended to make snapshot mounts and the downgrade of snapshots to checkpoints exclusive.
This fixes the deadlock issue by replacing the sb->s_umount usage in nilfs_ioctl_change_cpmode() with a dedicated mutex which protects snapshot mounts.
--- fs/nilfs2/ioctl.c | 4 ++-- fs/nilfs2/super.c | 3 +++ fs/nilfs2/the_nilfs.c | 1 + fs/nilfs2/the_nilfs.h | 2 ++ 4 files changed, 8 insertions(+), 2 deletions(-)
fs/nilfs2/ioctl.c +2 -2
@@ -182,7 +182,7 @@ static int nilfs_ioctl_change_cpmode(strif (copy_from_user (&cpmode, argp,sizeof (cpmode))) goto out; -down_read (&inode->i_sb->s_umount); +mutex_lock (&nilfs->ns_snapshot_mount_mutex);nilfs_transaction_begin (inode->i_sb, &ti,0 ); ret = nilfs_cpfile_change_cpmode(
@@ -192,7 +192,7 @@ static int nilfs_ioctl_change_cpmode(strelse nilfs_transaction_commit (inode->i_sb);/* never fails */ -up_read (&inode->i_sb->s_umount); +mutex_unlock (&nilfs->ns_snapshot_mount_mutex); out:mnt_drop_write (filp->f_path.mnt);return ret;
fs/nilfs2/super.c +3 -0
@@ -951,6 +951,8 @@ static int nilfs_attach_snapshot(structstruct nilfs_root *root;int ret; +mutex_lock (&nilfs->ns_snapshot_mount_mutex); +down_read (&nilfs->ns_segctor_sem); ret =nilfs_cpfile_is_snapshot (nilfs->ns_cpfile, cno);up_read (&nilfs->ns_segctor_sem);
@@ -975,6 +977,7 @@ static int nilfs_attach_snapshot(struct ret =nilfs_get_root_dentry (s, root, root_dentry);nilfs_put_root (root); out: +mutex_unlock (&nilfs->ns_snapshot_mount_mutex);return ret; }
fs/nilfs2/the_nilfs.c +1 -0
@@ -76,6 +76,7 @@ struct the_nilfs *alloc_nilfs(struct blo nilfs->ns_bdev = bdev;atomic_set (&nilfs->ns_ndirtyblks,0 );init_rwsem (&nilfs->ns_sem); +mutex_init (&nilfs->ns_snapshot_mount_mutex);INIT_LIST_HEAD (&nilfs->ns_dirty_files);INIT_LIST_HEAD (&nilfs->ns_gc_inodes);spin_lock_init (&nilfs->ns_inode_lock);
fs/nilfs2/the_nilfs.h +2 -0
@@ -47,6 +47,7 @@ enum {* @ns_flags: flags * @ns_bdev: block device * @ns_sem: semaphore for shared states +* @ns_snapshot_mount_mutex: mutex to protect snapshot mounts * @ns_sbh: buffer heads of on-disk super blocks * @ns_sbp: pointers to super block data * @ns_sbwtime: previous write time of super block
@@ -99,6 +100,7 @@ struct the_nilfs {struct block_device *ns_bdev;struct rw_semaphore ns_sem; +struct mutex ns_snapshot_mount_mutex;/* * used for
PATCH 40/70 nfs: skip commit in releasepage if were freeing memory for fs-related reasons
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Layton <[email protected]>
commit 5cf02d09b50b1ee1c2d536c9cf64af5a7d433f56 upstream.
We've had some reports of a deadlock where rpciod ends up with a stack trace like this:
PID: 2507 TASK: ffff88103691ab40 CPU: 14 COMMAND: "rpciod/14"
#0 [ffff8810343bf2f0] schedule at ffffffff814dabd9
#1 [ffff8810343bf3b8] nfs_wait_bit_killable at ffffffffa038fc04 [nfs]
#2 [ffff8810343bf3c8] __wait_on_bit at ffffffff814dbc2f
#3 [ffff8810343bf418] out_of_line_wait_on_bit at ffffffff814dbcd8
#4 [ffff8810343bf488] nfs_commit_inode at ffffffffa039e0c1 [nfs]
#5 [ffff8810343bf4f8] nfs_release_page at ffffffffa038bef6 [nfs]
#6 [ffff8810343bf528] try_to_release_page at ffffffff8110c670
#7 [ffff8810343bf538] shrink_page_list.clone.0 at ffffffff81126271
#8 [ffff8810343bf668] shrink_inactive_list at ffffffff81126638
#9 [ffff8810343bf818] shrink_zone at ffffffff8112788f
#10 [ffff8810343bf8c8] do_try_to_free_pages at ffffffff81127b1e
#11 [ffff8810343bf958] try_to_free_pages at ffffffff8112812f
#12 [ffff8810343bfa08] __alloc_pages_nodemask at ffffffff8111fdad
#13 [ffff8810343bfb28] kmem_getpages at ffffffff81159942
#14 [ffff8810343bfb58] fallback_alloc at ffffffff8115a55a
#15 [ffff8810343bfbd8] ____cache_alloc_node at ffffffff8115a2d9
#16 [ffff8810343bfc38] kmem_cache_alloc at ffffffff8115b09b
#17 [ffff8810343bfc78] sk_prot_alloc at ffffffff81411808
#18 [ffff8810343bfcb8] sk_alloc at ffffffff8141197c
#19 [ffff8810343bfce8] inet_create at ffffffff81483ba6
#20 [ffff8810343bfd38] __sock_create at ffffffff8140b4a7
#21 [ffff8810343bfd98] xs_create_sock at ffffffffa01f649b [sunrpc]
#22 [ffff8810343bfdd8] xs_tcp_setup_socket at ffffffffa01f6965 [sunrpc]
#23 [ffff8810343bfe38] worker_thread at ffffffff810887d0
#24 [ffff8810343bfee8] kthread at ffffffff8108dd96
#25 [ffff8810343bff48] kernel_thread at ffffffff8100c1carpciod is trying to allocate memory for a new socket to talk to the server. The VM ends up calling ->releasepage to get more memory, and it tries to do a blocking commit. That commit can't succeed however without a connected socket, so we deadlock.
Fix this by setting PF_FSTRANS on the workqueue task prior to doing the socket allocation, and having nfs_release_page check for that flag when deciding whether to do a commit call. Also, set PF_FSTRANS unconditionally in rpc_async_schedule since that function can also do allocations sometimes.
--- fs/nfs/file.c | 7 +++++-- net/sunrpc/sched.c | 2 ++ net/sunrpc/xprtrdma/transport.c | 3 ++- net/sunrpc/xprtsock.c | 10 ++++++++++ 4 files changed, 19 insertions(+), 3 deletions(-)
fs/nfs/file.c +5 -2
@@ -447,8 +447,11 @@ static int nfs_release_page(struct page *page, gfp_t gfp)dfprintk (PAGECACHE ,"NFS: release_page(%p)\n" , page); -/* Only do I/O if gfp is a superset of GFP_KERNEL */ -if (mapping && (gfp &GFP_KERNEL ) ==GFP_KERNEL ) { +/* Only do I/O if gfp is a superset of GFP_KERNEL, and we're not +* doing this memory reclaim for a fs-related allocation. +*/ +if (mapping && (gfp &GFP_KERNEL ) ==GFP_KERNEL && + !(current->flags &PF_FSTRANS )) {int how =FLUSH_SYNC ;/* Don't let kswapd deadlock waiting for OOM RPC calls */
net/sunrpc/sched.c +2 -0
@@ -791,7 +791,9 @@ void rpc_execute(struct rpc_task *task)static void rpc_async_schedule (struct work_struct *work) { + current->flags |=PF_FSTRANS ; __rpc_execute(container_of(work, struct rpc_task, u.tk_work)); + current->flags &= ~PF_FSTRANS ; }/**
net/sunrpc/xprtrdma/transport.c +2 -1
@@ -200,6 +200,7 @@ xprt_rdma_connect_worker(struct work_struct *work)int rc =0 ;if (!xprt->shutdown) { + current->flags |=PF_FSTRANS ;xprt_clear_connected (xprt); dprintk("RPC: %s: %sconnect\n", __func__,
@@ -212,10 +213,10 @@ xprt_rdma_connect_worker(struct work_struct *work) out:xprt_wake_pending_tasks (xprt, rc); - out_clear:dprintk ("RPC: %s: exit\n" , __func__);xprt_clear_connecting (xprt); + current->flags &= ~PF_FSTRANS ; }/*
net/sunrpc/xprtsock.c +10 -0
@@ -1895,6 +1895,8 @@ static void xs_local_setup_socket(struct work_struct *work)if (xprt->shutdown) goto out; + current->flags |=PF_FSTRANS ; +clear_bit (XPRT_CONNECTION_ABORT , &xprt->state); status =__sock_create (xprt->xprt_net,AF_LOCAL ,SOCK_STREAM ,0 , &sock,1 );
@@ -1928,6 +1930,7 @@ static void xs_local_setup_socket(struct work_struct *work) out:xprt_clear_connecting (xprt);xprt_wake_pending_tasks (xprt, status); + current->flags &= ~PF_FSTRANS ; }static void xs_udp_finish_connecting (struct rpc_xprt *xprt,struct socket *sock)
@@ -1970,6 +1973,8 @@ static void xs_udp_setup_socket(struct work_struct *work)if (xprt->shutdown) goto out; + current->flags |=PF_FSTRANS ; +/* Start by resetting any existing state */ xs_reset_transport (transport); sock = xs_create_sock(xprt, transport,
@@ -1988,6 +1993,7 @@ static void xs_udp_setup_socket(struct work_struct *work) out:xprt_clear_connecting (xprt);xprt_wake_pending_tasks (xprt, status); + current->flags &= ~PF_FSTRANS ; }/*
@@ -2113,6 +2119,8 @@ static void xs_tcp_setup_socket(struct work_struct *work)if (xprt->shutdown) goto out; + current->flags |=PF_FSTRANS ; +if (!sock) {clear_bit (XPRT_CONNECTION_ABORT , &xprt->state); sock = xs_create_sock(xprt, transport,
@@ -2162,6 +2170,7 @@ static void xs_tcp_setup_socket(struct work_struct *work)case -EINPROGRESS :case -EALREADY :xprt_clear_connecting (xprt); + current->flags &= ~PF_FSTRANS ;return ;case -EINVAL :/* Happens, for instance, if the user specified a link
@@ -2174,6 +2183,7 @@ out_eagain: out:xprt_clear_connecting (xprt);xprt_wake_pending_tasks (xprt, status); + current->flags &= ~PF_FSTRANS ; }/**
PATCH 39/70 s390/mm: fix fault handling for page table walk case
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
commit 008c2e8f247f0a8db1e8e26139da12f3a3abcda0 upstream.
Make sure the kernel does not incorrectly create a SIGBUS signal during user space accesses:
For user space accesses in the switched addressing mode case the kernel may walk page tables and access user address space via the kernel mapping. If a page table entry is invalid the function __handle_fault() gets called in order to emulate a page fault and trigger all the usual actions like paging in a missing page etc. by calling handle_mm_fault().
If handle_mm_fault() returns with an error fixup handling is necessary. For the switched addressing mode case all errors need to be mapped to -EFAULT, so that the calling uaccess function can return -EFAULT to user space.
Unfortunately the __handle_fault() incorrectly calls do_sigbus() if VM_FAULT_SIGBUS is set. This however should only happen if a page fault was triggered by a user space instruction. For kernel mode uaccesses the correct action is to only return -EFAULT.
So user space may incorrectly see SIGBUS signals because of this bug.
For current machines this would only be possible for the switched addressing mode case in conjunction with futex operations.
--- arch/s390/mm/fault.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
arch/s390/mm/fault.c +7 -6
@@ -453,6 +453,7 @@ int __handle_fault(unsigned long uaddr,struct pt_regs regs;int access, fault; +/* Emulate a uaccess fault from kernel mode. */ regs.psw.mask = psw_kernel_bits |PSW_MASK_DAT |PSW_MASK_MCHECK ;if (!irqs_disabled ()) regs.psw.mask |=PSW_MASK_IO |PSW_MASK_EXT ;
@@ -461,12 +462,12 @@ int __handle_fault(unsigned long uaddr, uaddr &=PAGE_MASK ; access = write ?VM_WRITE :VM_READ ; fault =do_exception (®s, access, uaddr |2 ); -if (unlikely (fault)) { -if (fault &VM_FAULT_OOM ) -return -EFAULT ; -else if (fault &VM_FAULT_SIGBUS ) -do_sigbus (®s, pgm_int_code, uaddr); - } +/* +* Since the fault happened in kernel mode while performing a uaccess +* all we need to do now is emulating a fixup in case "fault" is not +* zero. +* For the calling uaccess functions this results always in -EFAULT. +*/ return fault ? -EFAULT :0 ; }
PATCH 38/70 virtio-blk: Use block layer provided spinlock
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Asias He <[email protected]>
commit 2c95a3290919541b846bee3e0fbaa75860929f53 upstream.
Block layer will allocate a spinlock for the queue if the driver does not provide one in blk_init_queue().
The reason to use the internal spinlock is that blk_cleanup_queue() will switch to use the internal spinlock in the cleanup code path.
if (q->queue_lock != &q->__queue_lock)
q->queue_lock = &q->__queue_lock;However, processes which are in D state might have taken the driver provided spinlock, when the processes wake up, they would release the block provided spinlock.
=====================================
[ BUG: bad unlock balance detected! ]
3.4.0-rc7+ #238 Not tainted
-------------------------------------
fio/3587 is trying to release lock (&(&q->__queue_lock)->rlock) at:
[<ffffffff813274d2>] blk_queue_bio+0x2a2/0x380
but there are no more locks to release!
other info that might help us debug this:
1 lock held by fio/3587:
#0: (&(&vblk->lock)->rlock){......}, at:
[<ffffffff8132661a>] get_request_wait+0x19a/0x250
Other drivers use block layer provided spinlock as well, e.g. SCSI.
Switching to the block layer provided spinlock saves a bit of memory and does not increase lock contention. Performance test shows no real difference is observed before and after this patch.
Changes in v2: Improve commit log as Michael suggested.
--- drivers/block/virtio_blk.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/block/virtio_blk.c +3 -6
@@ -20,8 +20,6 @@ struct workqueue_struct *virtblk_wq;struct virtio_blk { -spinlock_t lock; -struct virtio_device *vdev;struct virtqueue *vq;
@@ -62,7 +60,7 @@ static void blk_done(struct virtqueue *vunsigned int len;unsigned long flags; -spin_lock_irqsave (&vblk->lock, flags); +spin_lock_irqsave (vblk->disk->queue->queue_lock, flags);while ((vbr =virtqueue_get_buf (vblk->vq, &len)) !=NULL ) {int error;
@@ -97,7 +95,7 @@ static void blk_done(struct virtqueue *v }/* In case queue is stopped waiting for more buffers. */ blk_start_queue (vblk->disk->queue); -spin_unlock_irqrestore (&vblk->lock, flags); +spin_unlock_irqrestore (vblk->disk->queue->queue_lock, flags); } static bool do_req(struct request_queue *q, struct virtio_blk *vblk,
@@ -384,7 +382,6 @@ static int __devinit virtblk_probe(struc }INIT_LIST_HEAD (&vblk->reqs); -spin_lock_init (&vblk->lock); vblk->vdev = vdev; vblk->sg_elems = sg_elems;sg_init_table (vblk->sg, vblk->sg_elems);
@@ -410,7 +407,7 @@ static int __devinit virtblk_probe(struc goto out_mempool; } - q = vblk->disk->queue =blk_init_queue (do_virtblk_request, &vblk->lock); + q = vblk->disk->queue =blk_init_queue (do_virtblk_request,NULL );if (!q) { err = -ENOMEM ; goto out_put_disk;
PATCH 66/70 drop_monitor: prevent init path from scheduling on the wrong cpu
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Neil Horman <[email protected]>
commit 4fdcfa12843bca38d0c9deff70c8720e4e8f515f upstream.
I just noticed after some recent updates, that the init path for the drop monitor protocol has a minor error. drop monitor maintains a per cpu structure, that gets initalized from a single cpu. Normally this is fine, as the protocol isn't in use yet, but I recently made a change that causes a failed skb allocation to reschedule itself . Given the current code, the implication is that this workqueue reschedule will take place on the wrong cpu. If drop monitor is used early during the boot process, its possible that two cpus will access a single per-cpu structure in parallel, possibly leading to data corruption.
This patch fixes the situation, by storing the cpu number that a given instance of this per-cpu data should be accessed from. In the case of a need for a reschedule, the cpu stored in the struct is assigned the rescheule, rather than the currently executing cpu
Tested successfully by myself.
--- net/core/drop_monitor.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
net/core/drop_monitor.c +7 -5
@@ -49,6 +49,7 @@ struct per_cpu_dm_data {struct sk_buff __rcu *skb;atomic_t dm_hit_count;struct timer_list send_timer; +int cpu; };struct dm_hw_stat_delta {
@@ -73,7 +74,6 @@ static int dm_hit_limit = 64;static int dm_delay =1 ;static unsigned long dm_hw_check_delta =2 *HZ ;static LIST_HEAD (hw_stats_list); -static int initialized =0 ;static void reset_per_cpu_data (struct per_cpu_dm_data *data) {
@@ -96,8 +96,8 @@ static void reset_per_cpu_data(struct per_cpu_dm_data *data) sizeof(struct net_dm_alert_msg)); msg =nla_data (nla);memset (msg,0 , al); - }else if (initialized) -schedule_work_on (smp_processor_id (), &data->dm_alert_work); + }else +schedule_work_on (data->cpu, &data->dm_alert_work);/* * Don't need to lock this, since we are guaranteed to only
@@ -121,6 +121,8 @@ static void send_dm_alert(struct work_struct *unused)struct sk_buff *skb;struct per_cpu_dm_data *data = &get_cpu_var (dm_cpu_data); +WARN_ON_ONCE (data->cpu !=smp_processor_id ()); +/* * Grab the skb we're about to send */
@@ -404,14 +406,14 @@ static int __init init_net_drop_monitor(void)for_each_present_cpu (cpu) { data = &per_cpu (dm_cpu_data, cpu); -reset_per_cpu_data (data); + data->cpu = cpu;INIT_WORK (&data->dm_alert_work, send_dm_alert);init_timer (&data->send_timer); data->send_timer.data = cpu; data->send_timer.function = sched_send_work; +reset_per_cpu_data (data); } - initialized =1 ; goto out;
PATCH 57/70 mm: hugetlbfs: close race during teardown of hugetlbfs shared page tables
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mel Gorman <[email protected]>
commit d833352a4338dc31295ed832a30c9ccff5c7a183 upstream.
If a process creates a large hugetlbfs mapping that is eligible for page table sharing and forks heavily with children some of whom fault and others which destroy the mapping then it is possible for page tables to get corrupted. Some teardowns of the mapping encounter a "bad pmd" and output a message to the kernel log. The final teardown will trigger a BUG_ON in mm/filemap.c.
This was reproduced in 3.4 but is known to have existed for a long time and goes back at least as far as 2.6.37. It was probably was introduced in 2.6.20 by [39dde65c: shared page table for hugetlb page]. The messages look like this;
[ ..........] Lots of bad pmd messages followed by this [ 127.164256] mm/memory.c:391: bad pmd ffff880412e04fe8(80000003de4000e7). [ 127.164257] mm/memory.c:391: bad pmd ffff880412e04ff0(80000003de6000e7). [ 127.164258] mm/memory.c:391: bad pmd ffff880412e04ff8(80000003de0000e7). [ 127.186778] ------------[ cut here ]------------ [ 127.186781] kernel BUG at mm/filemap.c:134! [ 127.186782] invalid opcode: 0000 [#1] SMP [ 127.186783] CPU 7 [ 127.186784] Modules linked in: af_packet cpufreq_conservative cpufreq_userspace cpufreq_powersave acpi_cpufreq mperf ext3 jbd dm_mod coretemp crc32c_intel usb_storage ghash_clmulni_intel aesni_intel i2c_i801 r8169 mii uas sr_mod cdrom sg iTCO_wdt iTCO_vendor_support shpchp serio_raw cryptd aes_x86_64 e1000e pci_hotplug dcdbas aes_generic container microcode ext4 mbcache jbd2 crc16 sd_mod crc_t10dif i915 drm_kms_helper drm i2c_algo_bit ehci_hcd ahci libahci usbcore rtc_cmos usb_common button i2c_core intel_agp video intel_gtt fan processor thermal thermal_sys hwmon ata_generic pata_atiixp libata scsi_mod [ 127.186801] [ 127.186802] Pid: 9017, comm: hugetlbfs-test Not tainted 3.4.0-autobuild #53 Dell Inc. OptiPlex 990/06D7TR [ 127.186804] RIP: 0010:[<ffffffff810ed6ce>] [<ffffffff810ed6ce>] __delete_from_page_cache+0x15e/0x160 [ 127.186809] RSP: 0000:ffff8804144b5c08 EFLAGS: 00010002 [ 127.186810] RAX: 0000000000000001 RBX: ffffea000a5c9000 RCX: 00000000ffffffc0 [ 127.186811] RDX: 0000000000000000 RSI: 0000000000000009 RDI: ffff88042dfdad00 [ 127.186812] RBP: ffff8804144b5c18 R08: 0000000000000009 R09: 0000000000000003 [ 127.186813] R10: 0000000000000000 R11: 000000000000002d R12: ffff880412ff83d8 [ 127.186814] R13: ffff880412ff83d8 R14: 0000000000000000 R15: ffff880412ff83d8 [ 127.186815] FS: 00007fe18ed2c700(0000) GS:ffff88042dce0000(0000) knlGS:0000000000000000 [ 127.186816] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b [ 127.186817] CR2: 00007fe340000503 CR3: 0000000417a14000 CR4: 00000000000407e0 [ 127.186818] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 127.186819] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [ 127.186820] Process hugetlbfs-test (pid: 9017, threadinfo ffff8804144b4000, task ffff880417f803c0) [ 127.186821] Stack: [ 127.186822] ffffea000a5c9000 0000000000000000 ffff8804144b5c48 ffffffff810ed83b [ 127.186824] ffff8804144b5c48 000000000000138a 0000000000001387 ffff8804144b5c98 [ 127.186825] ffff8804144b5d48 ffffffff811bc925 ffff8804144b5cb8 0000000000000000 [ 127.186827] Call Trace: [ 127.186829] [<ffffffff810ed83b>] delete_from_page_cache+0x3b/0x80 [ 127.186832] [<ffffffff811bc925>] truncate_hugepages+0x115/0x220 [ 127.186834] [<ffffffff811bca43>] hugetlbfs_evict_inode+0x13/0x30 [ 127.186837] [<ffffffff811655c7>] evict+0xa7/0x1b0 [ 127.186839] [<ffffffff811657a3>] iput_final+0xd3/0x1f0 [ 127.186840] [<ffffffff811658f9>] iput+0x39/0x50 [ 127.186842] [<ffffffff81162708>] d_kill+0xf8/0x130 [ 127.186843] [<ffffffff81162812>] dput+0xd2/0x1a0 [ 127.186845] [<ffffffff8114e2d0>] __fput+0x170/0x230 [ 127.186848] [<ffffffff81236e0e>] ? rb_erase+0xce/0x150 [ 127.186849] [<ffffffff8114e3ad>] fput+0x1d/0x30 [ 127.186851] [<ffffffff81117db7>] remove_vma+0x37/0x80 [ 127.186853] [<ffffffff81119182>] do_munmap+0x2d2/0x360 [ 127.186855] [<ffffffff811cc639>] sys_shmdt+0xc9/0x170 [ 127.186857] [<ffffffff81410a39>] system_call_fastpath+0x16/0x1b [ 127.186858] Code: 0f 1f 44 00 00 48 8b 43 08 48 8b 00 48 8b 40 28 8b b0 40 03 00 00 85 f6 0f 88 df fe ff ff 48 89 df e8 e7 cb 05 00 e9 d2 fe ff ff <0f> 0b 55 83 e2 fd 48 89 e5 48 83 ec 30 48 89 5d d8 4c 89 65 e0 [ 127.186868] RIP [<ffffffff810ed6ce>] __delete_from_page_cache+0x15e/0x160 [ 127.186870] RSP <ffff8804144b5c08> [ 127.186871] ---[ end trace 7cbac5d1db69f426 ]---
The bug is a race and not always easy to reproduce. To reproduce it I was doing the following on a single socket I7-based machine with 16G of RAM.
$ hugeadm --pool-pages-max DEFAULT:13G $ echo $((18*1048576*1024)) > /proc/sys/kernel/shmmax $ echo $((18*1048576*1024)) > /proc/sys/kernel/shmall $ for i in `seq 1 9000`; do ./hugetlbfs-test; done
On my particular machine, it usually triggers within 10 minutes but enabling debug options can change the timing such that it never hits. Once the bug is triggered, the machine is in trouble and needs to be rebooted. The machine will respond but processes accessing proc like "ps aux" will hang due to the BUG_ON. shutdown will also hang and needs a hard reset or a sysrq-b.
The basic problem is a race between page table sharing and teardown. For the most part page table sharing depends on i_mmap_mutex. In some cases, it is also taking the mm->page_table_lock for the PTE updates but with shared page tables, it is the i_mmap_mutex that is more important.
Unfortunately it appears to be also insufficient. Consider the following situation
Process A Process B
--------- ---------hugetlb_fault shmdt
LockWrite(mmap_sem)
do_munmap
unmap_region
unmap_vmas
unmap_single_vma
unmap_hugepage_range
Lock(i_mmap_mutex)
Lock(mm->page_table_lock)
huge_pmd_unshare/unmap tables <--- (1)
Unlock(mm->page_table_lock)
Unlock(i_mmap_mutex)
huge_pte_alloc ...
Lock(i_mmap_mutex) ...
vma_prio_walk, find svma, spte ...
Lock(mm->page_table_lock) ...
share spte ...
Unlock(mm->page_table_lock) ...
Unlock(i_mmap_mutex) ... hugetlb_no_page <--- (2)
free_pgtables
unlink_file_vma hugetlb_free_pgd_range
remove_vma_list
In this scenario, it is possible for Process A to share page tables with Process B that is trying to tear them down. The i_mmap_mutex on its own does not prevent Process A walking Process B's page tables. At (1) above, the page tables are not shared yet so it unmaps the PMDs. Process A sets up page table sharing and at (2) faults a new entry. Process B then trips up on it in free_pgtables.
This patch fixes the problem by adding a new function __unmap_hugepage_range_final that is only called when the VMA is about to be destroyed. This function clears VM_MAYSHARE during unmap_hugepage_range() under the i_mmap_mutex. This makes the VMA ineligible for sharing and avoids the race. Superficially this looks like it would then be vunerable to truncate and madvise issues but hugetlbfs has its own truncate handlers so does not use unmap_mapping_range() and does not support madvise(DONTNEED).
This should be treated as a -stable candidate if it is merged.
Test program is as follows. The test case was mostly written by Michal Hocko with a few minor changes to reproduce this bug.
==== CUT HERE ====
static size_t huge_page_size = (2UL << 20);
static size_t nr_huge_page_A = 512;
static size_t nr_huge_page_B = 5632;
unsigned int get_random(unsigned int max)
{
struct timeval tv;
gettimeofday(&tv, NULL);
srandom(tv.tv_usec);
return random() % max;
}static void play(void *addr, size_t size)
{
unsigned char *start = addr,
*end = start + size,
*a;
start += get_random(size/2);
/* we could itterate on huge pages but let's give it more time. */
for (a = start; a < end; a += 4096)
*a = 0;
}int main(int argc, char **argv)
{
key_t key = IPC_PRIVATE;
size_t sizeA = nr_huge_page_A * huge_page_size;
size_t sizeB = nr_huge_page_B * huge_page_size;
int shmidA, shmidB;
void *addrA = NULL, *addrB = NULL;
int nr_children = 300, n = 0;
if ((shmidA = shmget(key, sizeA, IPC_CREAT|SHM_HUGETLB|0660)) == -1) {
perror("shmget:");
return 1;
}
if ((addrA = shmat(shmidA, addrA, SHM_R|SHM_W)) == (void *)-1UL) {
perror("shmat");
return 1;
}
if ((shmidB = shmget(key, sizeB, IPC_CREAT|SHM_HUGETLB|0660)) == -1) {
perror("shmget:");
return 1;
}
if ((addrB = shmat(shmidB, addrB, SHM_R|SHM_W)) == (void *)-1UL) {
perror("shmat");
return 1;
}fork_child:
switch(fork()) {
case 0:
switch (n%3) {
case 0:
play(addrA, sizeA);
break;
case 1:
play(addrB, sizeB);
break;
case 2:
break;
}
break;
case -1:
perror("fork:");
break;
default:
if (++n < nr_children)
goto fork_child;
play(addrA, sizeA);
break;
}
shmdt(addrA);
shmdt(addrB);
do {
wait(NULL);
} while (--n > 0);
shmctl(shmidA, IPC_RMID, NULL);
shmctl(shmidB, IPC_RMID, NULL);
return 0;
}[bwh: Backported to 3.2:
- Adjust context
- Drop the mmu_gather * parameters]
---
include/linux/hugetlb.h +10 -0
@@ -41,6 +41,9 @@ int follow_hugetlb_page(struct mm_struct unsigned long *, int *, int, unsigned int flags);void unmap_hugepage_range (struct vm_area_struct *,unsigned long ,unsigned long ,struct page *); +void __unmap_hugepage_range_final (struct vm_area_struct *vma, +unsigned long start,unsigned long end, +struct page *ref_page);void __unmap_hugepage_range (struct vm_area_struct *,unsigned long ,unsigned long ,struct page *);int hugetlb_prefault (struct address_space *,struct vm_area_struct *);
@@ -99,6 +102,13 @@ static inline unsigned long hugetlb_tota#define copy_hugetlb_page_range (src, dst, vma) ({ BUG(); 0; })#define hugetlb_prefault (mapping, vma) ({ BUG(); 0; })#define unmap_hugepage_range (vma, start, end, page) BUG() +static inline void __unmap_hugepage_range_final (struct vm_area_struct *vma, +unsigned long start,unsigned long end, +struct page *ref_page) +{ +BUG (); +} +static inline void hugetlb_report_meminfo (struct seq_file *m) { }
mm/hugetlb.c +26 -2
@@ -2382,6 +2382,25 @@ void __unmap_hugepage_range(struct vm_ar } } +void __unmap_hugepage_range_final (struct vm_area_struct *vma, +unsigned long start,unsigned long end, +struct page *ref_page) +{ +__unmap_hugepage_range (vma, start, end, ref_page); + +/* +* Clear this flag so that x86's huge_pmd_share page_table_shareable +* test will fail on a vma being torn down, and not grab a page table +* on its way out. We're lucky that the flag has such an appropriate +* name, and can in fact be safely cleared here. We could clear it +* before the __unmap_hugepage_range above, but all that's necessary +* is to clear it before releasing the i_mmap_mutex. This works +* because in the context this is called, the VMA is about to be +* destroyed and the i_mmap_mutex is held. +*/ + vma->vm_flags &= ~VM_MAYSHARE ; +} +void unmap_hugepage_range (struct vm_area_struct *vma,unsigned long start,unsigned long end,struct page *ref_page) {
@@ -2939,9 +2958,14 @@ void hugetlb_change_protection(struct vm } }spin_unlock (&mm->page_table_lock); -mutex_unlock (&vma->vm_file->f_mapping->i_mmap_mutex); - +/* +* Must flush TLB before releasing i_mmap_mutex: x86's huge_pmd_unshare +* may have cleared our pud entry and done put_page on the page table: +* once we release i_mmap_mutex, another task can do the final put_page +* and that page table be reused and filled with junk. +*/ flush_tlb_range (vma, start, end); +mutex_unlock (&vma->vm_file->f_mapping->i_mmap_mutex); } int hugetlb_reserve_pages(struct inode *inode,
mm/memory.c +5 -2
@@ -1358,8 +1358,11 @@ unsigned long unmap_vmas(struct mmu_gath* Since no pte has actually been setup, it is * safe to do nothing in this case. */ -if (vma->vm_file) -unmap_hugepage_range (vma, start, end,NULL ); +if (vma->vm_file) { +mutex_lock (&vma->vm_file->f_mapping->i_mmap_mutex); +__unmap_hugepage_range_final (vma, start, end,NULL ); +mutex_unlock (&vma->vm_file->f_mapping->i_mmap_mutex); + } start = end; }else
PATCH 45/70 SUNRPC: return negative value in case rpcbind client creation error
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanislav Kinsbursky <[email protected]>
commit caea33da898e4e14f0ba58173e3b7689981d2c0b upstream.
Without this patch kernel will panic on LockD start, because lockd_up() checks lockd_up_net() result for negative value.
Quoted 1 line
From my pow it's better to return negative value from rpcbind routines instead
of replacing all such checks like in lockd_up().
--- net/sunrpc/rpcb_clnt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/sunrpc/rpcb_clnt.c +2 -2
@@ -251,7 +251,7 @@ static int rpcb_create_local_unix(struct net *net)if (IS_ERR (clnt)) {dprintk ("RPC: failed to create AF_LOCAL rpcbind " "client (errno %ld).\n" ,PTR_ERR (clnt)); - result = -PTR_ERR (clnt); + result =PTR_ERR (clnt); goto out; }
@@ -298,7 +298,7 @@ static int rpcb_create_local_net(struct net *net)if (IS_ERR (clnt)) {dprintk ("RPC: failed to create local rpcbind " "client (errno %ld).\n" ,PTR_ERR (clnt)); - result = -PTR_ERR (clnt); + result =PTR_ERR (clnt); goto out; }
PATCH 47/70 ARM: 7467/1: mutex: use generic xchg-based implementation for ARMv6+
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
commit a76d7bd96d65fa5119adba97e1b58d95f2e78829 upstream.
The open-coded mutex implementation for ARMv6+ cores suffers from a severe lack of barriers, so in the uncontended case we don't actually protect any accesses performed during the critical section.
Furthermore, the code is largely a duplication of the ARMv6+ atomic_dec code but optimised to remove a branch instruction, as the mutex fastpath was previously inlined. Now that this is executed out-of-line, we can reuse the atomic access code for the locking (in fact, we use the xchg code as this produces shorter critical sections).
This patch uses the generic xchg based implementation for mutexes on ARMv6+, which introduces barriers to the lock/unlock operations and also has the benefit of removing a fair amount of inline assembly code.
--- arch/arm/include/asm/mutex.h | 119 ++---------------------------------------- 1 file changed, 4 insertions(+), 115 deletions(-)
arch/arm/include/asm/mutex.h +4 -115
@@ -7,121 +7,10 @@*/ #ifndef _ASM_MUTEX_H#define _ASM_MUTEX_H - -#if __LINUX_ARM_ARCH__ <6 -/* On pre-ARMv6 hardware the swp based implementation is the most efficient. */ -# include <asm-generic/mutex-xchg.h> -#else -/* -* Attempting to lock a mutex on ARMv6+ can be done with a bastardized -* atomic decrement (it is not a reliable atomic decrement but it satisfies -* the defined semantics for our purpose, while being smaller and faster -* than a real atomic decrement or atomic swap. The idea is to attempt -* decrementing the lock value only once. If once decremented it isn't zero, -* or if its store-back fails due to a dispute on the exclusive store, we -* simply bail out immediately through the slow path where the lock will be -* reattempted until it succeeds. +* On pre-ARMv6 hardware this results in a swp-based implementation, +* which is the most efficient. For ARMv6+, we emit a pair of exclusive +* accesses instead. */ -static inline void -__mutex_fastpath_lock (atomic_t *count,void (*fail_fn)(atomic_t *)) -{ -int __ex_flag, __res; - - __asm__ ( - -"ldrex %0, [%2] \n\t" -"sub %0, %0, #1 \n\t" -"strex %1, %0, [%2] " - - :"=&r" (__res),"=&r" (__ex_flag) - :"r" (&(count)->counter) - :"cc" ,"memory" ); - - __res |= __ex_flag; -if (unlikely (__res !=0 )) -fail_fn (count); -} - -static inline int -__mutex_fastpath_lock_retval (atomic_t *count,int (*fail_fn)(atomic_t *)) -{ -int __ex_flag, __res; - - __asm__ ( - -"ldrex %0, [%2] \n\t" -"sub %0, %0, #1 \n\t" -"strex %1, %0, [%2] " - - :"=&r" (__res),"=&r" (__ex_flag) - :"r" (&(count)->counter) - :"cc" ,"memory" ); - - __res |= __ex_flag; -if (unlikely (__res !=0 )) - __res =fail_fn (count); -return __res; -} - -/* -* Same trick is used for the unlock fast path. However the original value, -* rather than the result, is used to test for success in order to have -* better generated assembly. -*/ -static inline void -__mutex_fastpath_unlock (atomic_t *count,void (*fail_fn)(atomic_t *)) -{ -int __ex_flag, __res, __orig; - - __asm__ ( - -"ldrex %0, [%3] \n\t" -"add %1, %0, #1 \n\t" -"strex %2, %1, [%3] " - - :"=&r" (__orig),"=&r" (__res),"=&r" (__ex_flag) - :"r" (&(count)->counter) - :"cc" ,"memory" ); - - __orig |= __ex_flag; -if (unlikely (__orig !=0 )) -fail_fn (count); -} - -/* -* If the unlock was done on a contended lock, or if the unlock simply fails -* then the mutex remains locked. -*/ -#define __mutex_slowpath_needs_to_unlock () 1 - -/* -* For __mutex_fastpath_trylock we use another construct which could be -* described as a "single value cmpxchg". -* -* This provides the needed trylock semantics like cmpxchg would, but it is -* lighter and less generic than a true cmpxchg implementation. -*/ -static inline int -__mutex_fastpath_trylock (atomic_t *count,int (*fail_fn)(atomic_t *)) -{ -int __ex_flag, __res, __orig; - - __asm__ ( - -"1: ldrex %0, [%3] \n\t" -"subs %1, %0, #1 \n\t" -"strexeq %2, %1, [%3] \n\t" -"movlt %0, #0 \n\t" -"cmpeq %2, #0 \n\t" -"bgt 1b " - - :"=&r" (__orig),"=&r" (__res),"=&r" (__ex_flag) - :"r" (&count->counter) - :"cc" ,"memory" ); - -return __orig; -} - -#endif +#include <asm-generic/mutex-xchg.h> #endif
PATCH 46/70 ARM: 7466/1: disable interrupt before spinning endlessly
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shawn Guo <[email protected]>
commit 98bd8b96b26db3399a48202318dca4aaa2515355 upstream.
The CPU will endlessly spin at the end of machine_halt and machine_restart calls. However, this will lead to a soft lockup warning after about 20 seconds, if CONFIG_LOCKUP_DETECTOR is enabled, as system timer is still alive.
Disable interrupt before going to spin endlessly, so that the lockup warning will never be seen.
--- arch/arm/kernel/process.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/kernel/process.c +2 -0
@@ -125,6 +125,7 @@ void arm_machine_restart(char mode, cons*/ mdelay (1000 );printk ("Reboot failed -- System halted\n" ); +local_irq_disable ();while (1 ); }
@@ -240,6 +241,7 @@ void machine_shutdown(void)void machine_halt (void ) {machine_shutdown (); +local_irq_disable ();while (1 ); }
PATCH 35/70 dm thin: fix memory leak in process_prepared_mapping error paths
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Thornber <[email protected]>
commit 905386f82d08f66726912f303f3e6605248c60a3 upstream.
Fix memory leak in process_prepared_mapping by always freeing the dm_thin_new_mapping structs from the mapping_pool mempool on the error paths.
--- drivers/md/dm-thin.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/md/dm-thin.c +3 -2
@@ -870,7 +870,7 @@ static void process_prepared_mapping(struct dm_thin_new_mapping *m)if (m->err) {cell_error (m->cell); -return ; + goto out; }/*
@@ -882,7 +882,7 @@ static void process_prepared_mapping(struct dm_thin_new_mapping *m)if (r) {DMERR ("dm_thin_insert_block() failed" );cell_error (m->cell); -return ; + goto out; }/*
@@ -897,6 +897,7 @@ static void process_prepared_mapping(struct dm_thin_new_mapping *m) }else cell_defer (tc, m->cell, m->data_block); +out:list_del (&m->list);mempool_free (m, tc->pool->mapping_pool); }
PATCH 33/70 Redefine ATOMIC_INIT and ATOMIC64_INIT to drop the casts
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Luck <[email protected]>
commit a119365586b0130dfea06457f584953e0ff6481d upstream.
The following build error occured during a ia64 build with swap-over-NFS patches applied.
net/core/sock.c:274:36: error: initializer element is not constant net/core/sock.c:274:36: error: (near initialization for 'memalloc_socks') net/core/sock.c:274:36: error: initializer element is not constant
This is identical to a parisc build error. Fengguang Wu, Mel Gorman and James Bottomley did all the legwork to track the root cause of the problem. This fix and entire commit log is shamelessly copied from them with one extra detail to change a dubious runtime use of ATOMIC_INIT() to atomic_set() in drivers/char/mspec.c
Dave Anglin says:
Quoted 4 lines
Here is the line in sock.i:
struct
static_keymemalloc_socks= ((structstatic_key) { .enabled = ((atomic_t) { (0) }) });
The above line contains two compound literals. It also uses a designated initializer to initialize the field enabled. A compound literal is not a constant expression.
The location of the above statement isn't fully clear, but if a compound literal occurs outside the body of a function, the initializer list must consist of constant expressions.
--- arch/ia64/include/asm/atomic.h | 4 ++-- drivers/char/mspec.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/ia64/include/asm/atomic.h +2 -2
@@ -18,8 +18,8 @@#include <asm/system.h> -#define ATOMIC_INIT (i) ((atomic_t) { (i) }) -#define ATOMIC64_INIT (i) ((atomic64_t) { (i) }) +#define ATOMIC_INIT (i) { (i) } +#define ATOMIC64_INIT (i) { (i) }#define atomic_read (v) (*(volatile int *)&(v)->counter)#define atomic64_read (v) (*(volatile long *)&(v)->counter)
drivers/char/mspec.c +1 -1
@@ -284,7 +284,7 @@ mspec_mmap(struct file *file, struct vm_ vdata->flags = flags; vdata->type = type;spin_lock_init (&vdata->lock); - vdata->refcnt =ATOMIC_INIT (1 ); +atomic_set (&vdata->refcnt,1 ); vma->vm_private_data = vdata; vma->vm_flags |= (VM_IO |VM_RESERVED |VM_PFNMAP |VM_DONTEXPAND );
PATCH 37/70 asus-wmi: use ASUS_WMI_METHODID_DSTS2 as default DSTS ID.
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Hung <[email protected]>
commit 63a78bb1051b240417daad3a3fa9c1bb10646dca upstream.
According to responses from the BIOS team, ASUS_WMI_METHODID_DSTS2 (0x53545344) will be used as future DSTS ID. In addition, calling asus_wmi_evaluate_method(ASUS_WMI_METHODID_DSTS2, 0, 0, NULL) returns ASUS_WMI_UNSUPPORTED_METHOD in new ASUS laptop PCs. This patch fixes no DSTS ID will be assigned in this case.
--- drivers/platform/x86/asus-wmi.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/platform/x86/asus-wmi.c +1 -6
@@ -1431,14 +1431,9 @@ static int asus_wmi_platform_init(struct*/ if (!asus_wmi_evaluate_method (ASUS_WMI_METHODID_DSTS ,0 ,0 ,NULL )) asus->dsts_id =ASUS_WMI_METHODID_DSTS ; -else if (!asus_wmi_evaluate_method (ASUS_WMI_METHODID_DSTS2 ,0 ,0 ,NULL )) +else asus->dsts_id =ASUS_WMI_METHODID_DSTS2 ; -if (!asus->dsts_id) { -pr_err ("Can't find DSTS" ); -return -ENODEV ; - } -/* CWAP allow to define the behavior of the Fn+F2 key, * this method doesn't seems to be present on Eee PCs */ if (asus->driver->wapf >=0 )
PATCH 43/70 lib/vsprintf.c: kptr_restrict: fix pK-error in SysRq show-all-timers(Q)
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Rosenberg <[email protected]>
commit 3715c5309f6d175c3053672b73fd4f73be16fd07 upstream.
When using ALT+SysRq+Q all the pointers are replaced with "pK-error" like this:
[23153.208033] .base: pK-error
with echo h > /proc/sysrq-trigger it works:
[23107.776363] .base: ffff88023e60d540
The intent behind this behavior was to return "pK-error" in cases where the %pK format specifier was used in interrupt context, because the CAP_SYSLOG check wouldn't be meaningful. Clearly this should only apply when kptr_restrict is actually enabled though.
--- lib/vsprintf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/vsprintf.c +2 -1
@@ -886,7 +886,8 @@ char *pointer(const char *fmt, char *buf* %pK cannot be used in IRQ context because its test * for CAP_SYSLOG would be meaningless. */ -if (in_irq () ||in_serving_softirq () ||in_nmi ()) { +if (kptr_restrict && (in_irq () ||in_serving_softirq () || +in_nmi ())) {if (spec.field_width ==-1 ) spec.field_width =2 *sizeof (void *);return string (buf, end,"pK-error" , spec);
PATCH 55/70 mm: setup pageblock_order before its used by sparsemem
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xishi Qiu <[email protected]>
commit ca57df79d4f64e1a4886606af4289d40636189c5 upstream.
On architectures with CONFIG_HUGETLB_PAGE_SIZE_VARIABLE set, such as Itanium, pageblock_order is a variable with default value of 0. It's set to the right value by set_pageblock_order() in function free_area_init_core().
But pageblock_order may be used by sparse_init() before free_area_init_core() is called along path:sparse_init()
->sparse_early_usemaps_alloc_node() ->usemap_size() ->SECTION_BLOCKFLAGS_BITS ->((1UL << (PFN_SECTION_SHIFT - pageblock_order)) *
NR_PAGEBLOCK_BITS)
The uninitialized pageblock_size will cause memory wasting because usemap_size() returns a much bigger value then it's really needed.
For example, on an Itanium platform,sparse_init() pageblock_order=0 usemap_size=24576 free_area_init_core() before pageblock_order=0, usemap_size=24576 free_area_init_core() after pageblock_order=12, usemap_size=8
That means 24K memory has been wasted for each section, so fix it by calling set_pageblock_order() from sparse_init().
--- mm/internal.h | 2 ++ mm/page_alloc.c | 4 ++-- mm/sparse.c | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-)
mm/internal.h +2 -0
@@ -309,3 +309,5 @@ extern u64 hwpoison_filter_flags_mask;extern u64 hwpoison_filter_flags_value;extern u64 hwpoison_filter_memcg;extern u32 hwpoison_filter_enable; + +extern void set_pageblock_order (void );
mm/page_alloc.c +2 -2
@@ -4282,7 +4282,7 @@ static inline void setup_usemap(struct p#ifdef CONFIG_HUGETLB_PAGE_SIZE_VARIABLE /* Initialise the number of pages represented by NR_PAGEBLOCK_BITS */ -static inline void __init set_pageblock_order (void ) +void __init set_pageblock_order (void ) {unsigned int order;
@@ -4310,7 +4310,7 @@ static inline void __init set_pageblock_* include/linux/pageblock-flags.h for the values of pageblock_order based on * the kernel config */ -static inline void set_pageblock_order (void ) +void __init set_pageblock_order (void ) { }
mm/sparse.c +3 -0
@@ -486,6 +486,9 @@ void __init sparse_init(void)struct page **map_map;#endif +/* Setup pageblock_order for HUGETLB_PAGE_SIZE_VARIABLE */ +set_pageblock_order (); +/* * map is using big page (aka 2M in x86 64 bit) * usemap is less one page (aka 24 bytes)
PATCH 56/70 mm: mmu_notifier: fix freed page still mapped in secondary MMU
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiao Guangrong <[email protected]>
commit 3ad3d901bbcfb15a5e4690e55350db0899095a68 upstream.
mmu_notifier_release() is called when the process is exiting. It will delete all the mmu notifiers. But at this time the page belonging to the process is still present in page tables and is present on the LRU list, so this race will happen:
CPU 0 CPU 1mmu_notifier_release: try_to_unmap:
hlist_del_init_rcu(&mn->hlist);
ptep_clear_flush_notify:
mmu nofifler not found
free page !!!!!!
/*
* At the point, the page has been
* freed, but it is still mapped in
* the secondary MMU.
*/
mn->ops->release(mn, mm);
Then the box is not stable and sometimes we can get this bug:
[ 738.075923] BUG: Bad page state in process migrate-perf pfn:03bec [ 738.075931] page:ffffea00000efb00 count:0 mapcount:0 mapping: (null) index:0x8076 [ 738.075936] page flags: 0x20000000000014(referenced|dirty)
The same issue is present in mmu_notifier_unregister().
We can call ->release before deleting the notifier to ensure the page has been unmapped from the secondary MMU before it is freed.
--- mm/mmu_notifier.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-)
mm/mmu_notifier.c +23 -22
@@ -33,6 +33,24 @@void __mmu_notifier_release (struct mm_struct *mm) {struct mmu_notifier *mn; +struct hlist_node *n; + +/* +* RCU here will block mmu_notifier_unregister until +* ->release returns. +*/ +rcu_read_lock (); +hlist_for_each_entry_rcu (mn, n, &mm->mmu_notifier_mm->list, hlist) +/* +* if ->release runs before mmu_notifier_unregister it +* must be handled as it's the only way for the driver +* to flush all existing sptes and stop the driver +* from establishing any more sptes before all the +* pages in the mm are freed. +*/ +if (mn->ops->release) + mn->ops->release (mn, mm); +rcu_read_unlock ();spin_lock (&mm->mmu_notifier_mm->lock);while (unlikely (!hlist_empty (&mm->mmu_notifier_mm->list))) {
@@ -46,23 +64,6 @@ void __mmu_notifier_release(struct mm_struct *mm)* mmu_notifier_unregister to return. */ hlist_del_init_rcu (&mn->hlist); -/* -* RCU here will block mmu_notifier_unregister until -* ->release returns. -*/ -rcu_read_lock (); -spin_unlock (&mm->mmu_notifier_mm->lock); -/* -* if ->release runs before mmu_notifier_unregister it -* must be handled as it's the only way for the driver -* to flush all existing sptes and stop the driver -* from establishing any more sptes before all the -* pages in the mm are freed. -*/ -if (mn->ops->release) - mn->ops->release (mn, mm); -rcu_read_unlock (); -spin_lock (&mm->mmu_notifier_mm->lock); }spin_unlock (&mm->mmu_notifier_mm->lock);
@@ -284,16 +285,13 @@ void mmu_notifier_unregister(struct mmu_notifier *mn, struct mm_struct *mm) {BUG_ON (atomic_read (&mm->mm_count) <=0 ); -spin_lock (&mm->mmu_notifier_mm->lock);if (!hlist_unhashed (&mn->hlist)) { -hlist_del_rcu (&mn->hlist); -/* * RCU here will force exit_mmap to wait ->release to finish * before freeing the pages. */ rcu_read_lock (); -spin_unlock (&mm->mmu_notifier_mm->lock); +/* * exit_mmap will block in mmu_notifier_release to * guarantee ->release is called before freeing the
@@ -302,8 +300,11 @@ void mmu_notifier_unregister(struct mmu_notifier *mn, struct mm_struct *mm)if (mn->ops->release) mn->ops->release (mn, mm);rcu_read_unlock (); - }else + +spin_lock (&mm->mmu_notifier_mm->lock); +hlist_del_rcu (&mn->hlist);spin_unlock (&mm->mmu_notifier_mm->lock); + }/* * Wait any running method to finish, of course including
PATCH 54/70 mm/page_alloc.c: remove pageblock_default_order()
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Morton <[email protected]>
commit 955c1cd7401565671b064e499115344ec8067dfd upstream.
This has always been broken: one version takes an unsigned int and the other version takes no arguments. This bug was hidden because one version of set_pageblock_order() was a macro which doesn't evaluate its argument.
Simplify it all and remove pageblock_default_order() altogether.
--- mm/page_alloc.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-)
mm/page_alloc.c +15 -18
@@ -4300,25 +4300,24 @@ static inline void setup_usemap(struct pglist_data *pgdat,#ifdef CONFIG_HUGETLB_PAGE_SIZE_VARIABLE -/* Return a sensible default order for the pageblock size. */ -static inline int pageblock_default_order (void ) -{ -if (HPAGE_SHIFT >PAGE_SHIFT ) -return HUGETLB_PAGE_ORDER ; - -return MAX_ORDER -1 ; -} -/* Initialise the number of pages represented by NR_PAGEBLOCK_BITS */ -static inline void __init set_pageblock_order (unsigned int order) +static inline void __init set_pageblock_order (void ) { +unsigned int order; +/* Check that pageblock_nr_pages has not already been setup */ if (pageblock_order)return ; +if (HPAGE_SHIFT >PAGE_SHIFT ) + order =HUGETLB_PAGE_ORDER ; +else + order =MAX_ORDER -1 ; +/* * Assume the largest contiguous order of interest is a huge page. -* This value may be variable depending on boot parameters on IA64 +* This value may be variable depending on boot parameters on IA64 and +* powerpc. */ pageblock_order = order; }
@@ -4326,15 +4325,13 @@ static inline void __init set_pageblock_order(unsigned int order)/* * When CONFIG_HUGETLB_PAGE_SIZE_VARIABLE is not set, set_pageblock_order() -* and pageblock_default_order() are unused as pageblock_order is set -* at compile-time. See include/linux/pageblock-flags.h for the values of -* pageblock_order based on the kernel config +* is unused as pageblock_order is set at compile-time. See +* include/linux/pageblock-flags.h for the values of pageblock_order based on +* the kernel config */ -static inline int pageblock_default_order (unsigned int order) +static inline void set_pageblock_order (void ) { -return MAX_ORDER -1 ; } -#define set_pageblock_order (x) do {} while (0)#endif /* CONFIG_HUGETLB_PAGE_SIZE_VARIABLE */
@@ -4422,7 +4419,7 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat,if (!size)continue ; -set_pageblock_order (pageblock_default_order ()); +set_pageblock_order ();setup_usemap (pgdat, zone, size); ret =init_currently_empty_zone (zone, zone_start_pfn, size,MEMMAP_EARLY );
PATCH 48/70 ARM: 7476/1: vfp: only clear vfp state for current cpu in vfp_pm_suspend
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Colin Cross <[email protected]>
commit a84b895a2348f0dbff31b71ddf954f70a6cde368 upstream.
vfp_pm_suspend runs on each cpu, only clear the hardware state pointer for the current cpu. Prevents a possible crash if one cpu clears the hw state pointer when another cpu has already checked if it is valid.
--- arch/arm/vfp/vfpmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/vfp/vfpmodule.c +1 -1
@@ -460,7 +460,7 @@ static int vfp_pm_suspend(void) }/* clear any information we had about last context state */ -memset (vfp_current_hw_state,0 ,sizeof (vfp_current_hw_state)); + vfp_current_hw_state[ti->cpu] =NULL ;return 0 ; }
PATCH 67/70 drop_monitor: dont sleep in atomic context
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit bec4596b4e6770c7037f21f6bd27567b152dc0d6 upstream.
drop_monitor calls several sleeping functions while in atomic context.
BUG: sleeping function called from invalid context at mm/slub.c:943 in_atomic(): 1, irqs_disabled(): 0, pid: 2103, name: kworker/0:2 Pid: 2103, comm: kworker/0:2 Not tainted 3.5.0-rc1+ #55 Call Trace: [<ffffffff810697ca>] __might_sleep+0xca/0xf0 [<ffffffff811345a3>] kmem_cache_alloc_node+0x1b3/0x1c0 [<ffffffff8105578c>] ? queue_delayed_work_on+0x11c/0x130 [<ffffffff815343fb>] __alloc_skb+0x4b/0x230 [<ffffffffa00b0360>] ? reset_per_cpu_data+0x160/0x160 [drop_monitor] [<ffffffffa00b022f>] reset_per_cpu_data+0x2f/0x160 [drop_monitor] [<ffffffffa00b03ab>] send_dm_alert+0x4b/0xb0 [drop_monitor] [<ffffffff810568e0>] process_one_work+0x130/0x4c0 [<ffffffff81058249>] worker_thread+0x159/0x360 [<ffffffff810580f0>] ? manage_workers.isra.27+0x240/0x240 [<ffffffff8105d403>] kthread+0x93/0xa0 [<ffffffff816be6d4>] kernel_thread_helper+0x4/0x10 [<ffffffff8105d370>] ? kthread_freezable_should_stop+0x80/0x80 [<ffffffff816be6d0>] ? gs_change+0xb/0xb
Rework the logic to call the sleeping functions in right context.
Use standard timer/workqueue api to let system chose any cpu to perform the allocation and netlink send.
Also avoid a loop if reset_per_cpu_data() cannot allocate memory :
use mod_timer() to wait 1/10 second before next try.
--- net/core/drop_monitor.c | 102 +++++++++++++++-------------------------------- 1 file changed, 33 insertions(+), 69 deletions(-)
net/core/drop_monitor.c +33 -68
@@ -33,9 +33,6 @@#define TRACE_ON 1#define TRACE_OFF 0 -static void send_dm_alert (struct work_struct *unused); - -/* * Globals, our netlink socket pointer * and the work handle that will send up
@@ -45,11 +42,10 @@ static int trace_state = TRACE_OFF;static DEFINE_MUTEX (trace_state_mutex);struct per_cpu_dm_data { -struct work_struct dm_alert_work; -struct sk_buff __rcu *skb; -atomic_t dm_hit_count; -struct timer_list send_timer; -int cpu; +spinlock_t lock; +struct sk_buff *skb; +struct work_struct dm_alert_work; +struct timer_list send_timer; };struct dm_hw_stat_delta {
@@ -75,13 +71,13 @@ static int dm_delay = 1;static unsigned long dm_hw_check_delta =2 *HZ ;static LIST_HEAD (hw_stats_list); -static void reset_per_cpu_data (struct per_cpu_dm_data *data) +static struct sk_buff *reset_per_cpu_data (struct per_cpu_dm_data *data) {size_t al;struct net_dm_alert_msg *msg;struct nlattr *nla;struct sk_buff *skb; -struct sk_buff *oskb =rcu_dereference_protected (data->skb,1 ); +unsigned long flags; al =sizeof (struct net_dm_alert_msg ); al += dm_hit_limit *sizeof (struct net_dm_drop_point );
@@ -96,65 +92,40 @@ static void reset_per_cpu_data(struct pe sizeof(struct net_dm_alert_msg)); msg =nla_data (nla);memset (msg,0 , al); - }else -schedule_work_on (data->cpu, &data->dm_alert_work); - -/* -* Don't need to lock this, since we are guaranteed to only -* run this on a single cpu at a time. -* Note also that we only update data->skb if the old and new skb -* pointers don't match. This ensures that we don't continually call -* synchornize_rcu if we repeatedly fail to alloc a new netlink message. -*/ -if (skb != oskb) { -rcu_assign_pointer (data->skb, skb); - -synchronize_rcu (); - -atomic_set (&data->dm_hit_count, dm_hit_limit); + }else { +mod_timer (&data->send_timer, jiffies +HZ /10 ); } +spin_lock_irqsave (&data->lock, flags); +swap (data->skb, skb); +spin_unlock_irqrestore (&data->lock, flags); + +return skb; } -static void send_dm_alert (struct work_struct *unused) +static void send_dm_alert (struct work_struct *work) {struct sk_buff *skb; -struct per_cpu_dm_data *data = &get_cpu_var (dm_cpu_data); +struct per_cpu_dm_data *data; -WARN_ON_ONCE (data->cpu !=smp_processor_id ()); + data = container_of(work, struct per_cpu_dm_data, dm_alert_work); -/* -* Grab the skb we're about to send -*/ - skb =rcu_dereference_protected (data->skb,1 ); + skb =reset_per_cpu_data (data); -/* -* Replace it with a new one -*/ -reset_per_cpu_data (data); - -/* -* Ship it! -*/ if (skb)genlmsg_multicast (skb,0 ,NET_DM_GRP_ALERT ,GFP_KERNEL ); - -put_cpu_var (dm_cpu_data); }/* * This is the timer function to delay the sending of an alert * in the event that more drops will arrive during the -* hysteresis period. Note that it operates under the timer interrupt -* so we don't need to disable preemption here +* hysteresis period. */ -static void sched_send_work (unsigned long unused) +static void sched_send_work (unsigned long _data) { -struct per_cpu_dm_data *data = &get_cpu_var (dm_cpu_data); +struct per_cpu_dm_data *data = (struct per_cpu_dm_data *)_data; -schedule_work_on (smp_processor_id (), &data->dm_alert_work); - -put_cpu_var (dm_cpu_data); +schedule_work (&data->dm_alert_work); }static void trace_drop_common (struct sk_buff *skb,void *location)
@@ -164,22 +135,17 @@ static void trace_drop_common(struct sk_struct nlattr *nla;int i;struct sk_buff *dskb; -struct per_cpu_dm_data *data = &get_cpu_var (dm_cpu_data); - +struct per_cpu_dm_data *data; +unsigned long flags; -rcu_read_lock (); - dskb =rcu_dereference (data->skb); +local_irq_save (flags); + data = &__get_cpu_var (dm_cpu_data); +spin_lock (&data->lock); + dskb = data->skb;if (!dskb) goto out; -if (!atomic_add_unless (&data->dm_hit_count,-1 ,0 )) { -/* -* we're already at zero, discard this hit -*/ - goto out; - } - nlh = (struct nlmsghdr *)dskb->data; nla =genlmsg_data (nlmsg_data (nlh)); msg =nla_data (nla);
@@ -189,7 +155,8 @@ static void trace_drop_common(struct sk_ goto out; } } - +if (msg->entries == dm_hit_limit) + goto out;/* * We need to create a new entry */
@@ -201,13 +168,11 @@ static void trace_drop_common(struct sk_if (!timer_pending (&data->send_timer)) { data->send_timer.expires = jiffies + dm_delay *HZ ; -add_timer_on (&data->send_timer,smp_processor_id ()); +add_timer (&data->send_timer); } out: -rcu_read_unlock (); -put_cpu_var (dm_cpu_data); -return ; +spin_unlock_irqrestore (&data->lock, flags); }static void trace_kfree_skb_hit (void *ignore,struct sk_buff *skb,void *location)
@@ -405,11 +370,11 @@ static int __init init_net_drop_monitor(for_each_present_cpu (cpu) { data = &per_cpu (dm_cpu_data, cpu); - data->cpu = cpu;INIT_WORK (&data->dm_alert_work, send_dm_alert);init_timer (&data->send_timer); - data->send_timer.data = cpu; + data->send_timer.data = (unsigned long )data; data->send_timer.function = sched_send_work; +spin_lock_init (&data->lock);reset_per_cpu_data (data); }
PATCH 51/70 ARM: Fix undefined instruction exception handling
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Russell King <[email protected]>
commit 15ac49b65024f55c4371a53214879a9c77c4fbf9 upstream.
While trying to get a v3.5 kernel booted on the cubox, I noticed that VFP does not work correctly with VFP bounce handling. This is because of the confusion over 16-bit vs 32-bit instructions, and where PC is supposed to point to.
The rule is that FP handlers are entered with regs->ARM_pc pointing at the _next_ instruction to be executed. However, if the exception is not handled, regs->ARM_pc points at the faulting instruction.
This is easy for ARM mode, because we know that the next instruction and previous instructions are separated by four bytes. This is not true of Thumb2 though.
Since all FP instructions are 32-bit in Thumb2, it makes things easy. We just need to select the appropriate adjustment. Do this by moving the adjustment out of do_undefinstr() into the assembly code, as only the assembly code knows whether it's dealing with a 32-bit or 16-bit instruction.
--- arch/arm/kernel/entry-armv.S | 111 +++++++++++++++++++++++++++--------------- arch/arm/kernel/traps.c | 8 --- arch/arm/vfp/entry.S | 16 +++--- arch/arm/vfp/vfphw.S | 19 +++++--- 4 files changed, 92 insertions(+), 62 deletions(-)
arch/arm/kernel/entry-armv.S +72 -39
@@ -242,6 +242,19 @@ svc_preempt: b 1b #endif +__und_fault: + @ Correct the PC such that it is pointing at the instruction + @ which caused the fault. If the faulting instruction was ARM + @ the PC will be pointing at the next instruction, and have to + @ subtract 4. Otherwise, it is Thumb, and the PC will be + @ pointing at the second half of the Thumb instruction. We + @ have to subtract 2. + ldr r2, [r0, #S_PC] + sub r2, r2, r1 + str r2, [r0, #S_PC] + b do_undefinstr +ENDPROC(__und_fault) + .align 5 __und_svc: #ifdef CONFIG_KPROBES
@@ -259,25 +272,32 @@ __und_svc: @ @ r0 - instruction @ -#ifndef CONFIG_THUMB2_KERNEL +#ifndef CONFIG_THUMB2_KERNEL ldr r0, [r4, #-4] #else + mov r1, #2 ldrh r0, [r4, #-2] @ Thumb instruction at LR - 2 cmp r0, #0xe800 @ 32-bit instruction if xx >= 0 - ldrhhs r9, [r4] @ bottom 16 bits - orrhs r0, r9, r0, lsl #16 + blo __und_svc_fault + ldrh r9, [r4] @ bottom 16 bits + add r4, r4, #2 + str r4, [sp, #S_PC] + orr r0, r9, r0, lsl #16 #endif - adr r9, BSYM(1f) + adr r9, BSYM(__und_svc_finish) mov r2, r4 bl call_fpe + mov r1, #4 @ PC correction to apply +__und_svc_fault: mov r0, sp @ struct pt_regs *regs - bl do_undefinstr + bl __und_fault @ @ IRQs off again before pulling preserved data off the stack @ -1: disable_irq_notrace +__und_svc_finish: + disable_irq_notrace @ @ restore SPSR and restart the instruction
@@ -421,25 +441,33 @@ __und_usr: mov r2, r4 mov r3, r5 + @ r2 = regs->ARM_pc, which is either 2 or 4 bytes ahead of the + @ faulting instruction depending on Thumb mode. + @ r3 = regs->ARM_cpsr @ - @ fall through to the emulation code, which returns using r9 if - @ it has emulated the instruction, or the more conventional lr - @ if we are to treat this as a real undefined instruction - @ - @ r0 - instruction + @ The emulation code returns using r9 if it has emulated the + @ instruction, or the more conventional lr if we are to treat + @ this as a real undefined instruction @ adr r9, BSYM(ret_from_exception) - adr lr, BSYM(__und_usr_unknown) + tst r3, #PSR_T_BIT @ Thumb mode? - itet eq @ explicit IT needed for the 1f label - subeq r4, r2, #4 @ ARM instr at LR - 4 - subne r4, r2, #2 @ Thumb instr at LR - 2 -1: ldreqt r0, [r4] + bne __und_usr_thumb + sub r4, r2, #4 @ ARM instr at LR - 4 +1: ldrt r0, [r4] #ifdef CONFIG_CPU_ENDIAN_BE8 - reveq r0, r0 @ little endian instruction + rev r0, r0 @ little endian instruction #endif - beq call_fpe + @ r0 = 32-bit ARM instruction which caused the exception + @ r2 = PC value for the following instruction (:= regs->ARM_pc) + @ r4 = PC value for the faulting instruction + @ lr = 32-bit undefined instruction function + adr lr, BSYM(__und_usr_fault_32) + b call_fpe + +__und_usr_thumb: @ Thumb instruction + sub r4, r2, #2 @ First half of thumb instr at LR - 2 #if CONFIG_ARM_THUMB && __LINUX_ARM_ARCH__ >= 6 && CONFIG_CPU_V7 /* * Thumb-2 instruction handling. Note that because pre-v6 and >= v6 platforms
@@ -453,7 +481,7 @@ __und_usr: ldr r5, .LCcpu_architecture ldr r5, [r5] cmp r5, #CPU_ARCH_ARMv7 - blo __und_usr_unknown + blo __und_usr_fault_16 @ 16bit undefined instruction /* * The following code won't get run unless the running CPU really is v7, so * coding round the lack of ldrht on older arches is pointless. Temporarily
@@ -461,15 +489,18 @@ __und_usr: */ .arch armv6t2 #endif -2: - ARM( ldrht r5, [r4], #2 ) - THUMB( ldrht r5, [r4] ) - THUMB( add r4, r4, #2 ) +2: ldrht r5, [r4] cmp r5, #0xe800 @ 32bit instruction if xx != 0 - blo __und_usr_unknown -3: ldrht r0, [r4] + blo __und_usr_fault_16 @ 16bit undefined instruction +3: ldrht r0, [r2] add r2, r2, #2 @ r2 is PC + 2, make it PC + 4 + str r2, [sp, #S_PC] @ it's a 2x16bit instr, update orr r0, r0, r5, lsl #16 + adr lr, BSYM(__und_usr_fault_32) + @ r0 = the two 16-bit Thumb instructions which caused the exception + @ r2 = PC value for the following Thumb instruction (:= regs->ARM_pc) + @ r4 = PC value for the first 16-bit Thumb instruction + @ lr = 32bit undefined instruction function #if __LINUX_ARM_ARCH__ < 7 /* If the target arch was overridden, change it back: */
@@ -480,17 +511,13 @@ __und_usr: #endif #endif /* __LINUX_ARM_ARCH__ < 7 */ #else /* !(CONFIG_ARM_THUMB && __LINUX_ARM_ARCH__ >= 6 && CONFIG_CPU_V7) */ - b __und_usr_unknown + b __und_usr_fault_16 #endif - UNWIND(.fnend ) + UNWIND(.fnend) ENDPROC(__und_usr) - @ - @ fallthrough to call_fpe - @ - /* - * The out of line fixup for the ldrt above. + * The out of line fixup for the ldrt instructions above. */ .pushsection .fixup, "ax" 4: mov pc, r9
@@ -521,11 +548,12 @@ ENDPROC(__und_usr) * NEON handler code. * * Emulators may wish to make use of the following registers: - * r0 = instruction opcode. - * r2 = PC+4 + * r0 = instruction opcode (32-bit ARM or two 16-bit Thumb) + * r2 = PC value to resume execution after successful emulation * r9 = normal "successful" return address - * r10 = this threads thread_info structure. + * r10 = this threads thread_info structure * lr = unrecognised instruction return address + * IRQs disabled, FIQs enabled. */ @ @ Fall-through from Thumb-2 __und_usr
@@ -660,12 +688,17 @@ ENTRY(no_fp) mov pc, lr ENDPROC(no_fp) -__und_usr_unknown: - enable_irq +__und_usr_fault_32: + mov r1, #4 + b 1f +__und_usr_fault_16: + mov r1, #2 +1: enable_irq mov r0, sp adr lr, BSYM(ret_from_exception) - b do_undefinstr -ENDPROC(__und_usr_unknown) + b __und_fault +ENDPROC(__und_usr_fault_32) +ENDPROC(__und_usr_fault_16) .align 5 __pabt_usr:
arch/arm/kernel/traps.c +0 -8
@@ -362,18 +362,10 @@ static int call_undef_hook(struct pt_reg asmlinkage void __exception do_undefinstr(struct pt_regs *regs) { -unsigned int correction =thumb_mode (regs) ?2 :4 ;unsigned int instr;siginfo_t info;void __user *pc; -/* -* According to the ARM ARM, PC is 2 or 4 bytes ahead, -* depending whether we're in Thumb mode or not. -* Correct this offset. -*/ - regs->ARM_pc -= correction; - pc = (void __user *)instruction_pointer (regs);if (processor_mode (regs) ==SVC_MODE ) {
arch/arm/vfp/entry.S +9 -7
@@ -7,18 +7,20 @@ * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. - * - * Basic entry code, called from the kernel's undefined instruction trap. - * r0 = faulted instruction - * r5 = faulted PC+4 - * r9 = successful return - * r10 = thread_info structure - * lr = failure return */ #include <asm/thread_info.h> #include <asm/vfpmacros.h> #include "../kernel/entry-header.S" +@ VFP entry point. +@ +@ r0 = instruction opcode (32-bit ARM or two 16-bit Thumb) +@ r2 = PC value to resume execution after successful emulation +@ r9 = normal "successful" return address +@ r10 = this threads thread_info structure +@ lr = unrecognised instruction return address +@ IRQs disabled. +@ ENTRY(do_vfp) #ifdef CONFIG_PREEMPT ldr r4, [r10, #TI_PREEMPT] @ get preempt count
arch/arm/vfp/vfphw.S +11 -8
@@ -61,13 +61,13 @@ @ VFP hardware support entry point. @ -@ r0 = faulted instruction -@ r2 = faulted PC+4 -@ r9 = successful return +@ r0 = instruction opcode (32-bit ARM or two 16-bit Thumb) +@ r2 = PC value to resume execution after successful emulation +@ r9 = normal "successful" return address @ r10 = vfp_state union @ r11 = CPU number -@ lr = failure return - +@ lr = unrecognised instruction return address +@ IRQs enabled. ENTRY(vfp_support_entry) DBGSTR3 "instr %08x pc %08x state %p", r0, r2, r10
@@ -161,9 +161,12 @@ vfp_hw_state_valid: @ exception before retrying branch @ out before setting an FPEXC that @ stops us reading stuff - VFPFMXR FPEXC, r1 @ restore FPEXC last - sub r2, r2, #4 - str r2, [sp, #S_PC] @ retry the instruction + VFPFMXR FPEXC, r1 @ Restore FPEXC last + sub r2, r2, #4 @ Retry current instruction - if Thumb + str r2, [sp, #S_PC] @ mode it's two 16-bit instructions, + @ else it's one 32-bit instruction, so + @ always subtract 4 from the following + @ instruction address. #ifdef CONFIG_PREEMPT get_thread_info r10 ldr r4, [r10, #TI_PREEMPT] @ get preempt count
PATCH 65/70 drop_monitor: Make updating data->skb smp safe
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Neil Horman <[email protected]>
commit 3885ca785a3618593226687ced84f3f336dc3860 upstream.
Eric Dumazet pointed out to me that the drop_monitor protocol has some holes in its smp protections. Specifically, its possible to replace data->skb while its being written. This patch corrects that by making data->skb an rcu protected variable. That will prevent it from being overwritten while a tracepoint is modifying it.
--- net/core/drop_monitor.c | 70 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 16 deletions(-)
net/core/drop_monitor.c +54 -16
@@ -46,7 +46,7 @@ static DEFINE_MUTEX(trace_state_mutex);struct per_cpu_dm_data {struct work_struct dm_alert_work; -struct sk_buff *skb; +struct sk_buff __rcu *skb;atomic_t dm_hit_count;struct timer_list send_timer; };
@@ -73,35 +73,58 @@ static int dm_hit_limit = 64;static int dm_delay =1 ;static unsigned long dm_hw_check_delta =2 *HZ ;static LIST_HEAD (hw_stats_list); +static int initialized =0 ;static void reset_per_cpu_data (struct per_cpu_dm_data *data) {size_t al;struct net_dm_alert_msg *msg;struct nlattr *nla; +struct sk_buff *skb; +struct sk_buff *oskb =rcu_dereference_protected (data->skb,1 ); al =sizeof (struct net_dm_alert_msg ); al += dm_hit_limit *sizeof (struct net_dm_drop_point ); al +=sizeof (struct nlattr ); - data->skb =genlmsg_new (al,GFP_KERNEL ); -genlmsg_put (data->skb,0 ,0 , &net_drop_monitor_family, -0 ,NET_DM_CMD_ALERT ); - nla =nla_reserve (data->skb,NLA_UNSPEC ,sizeof (struct net_dm_alert_msg )); - msg =nla_data (nla); -memset (msg,0 , al); -atomic_set (&data->dm_hit_count, dm_hit_limit); + skb =genlmsg_new (al,GFP_KERNEL ); + +if (skb) { +genlmsg_put (skb,0 ,0 , &net_drop_monitor_family, +0 ,NET_DM_CMD_ALERT ); + nla =nla_reserve (skb,NLA_UNSPEC , +sizeof (struct net_dm_alert_msg )); + msg =nla_data (nla); +memset (msg,0 , al); + }else if (initialized) +schedule_work_on (smp_processor_id (), &data->dm_alert_work); + +/* +* Don't need to lock this, since we are guaranteed to only +* run this on a single cpu at a time. +* Note also that we only update data->skb if the old and new skb +* pointers don't match. This ensures that we don't continually call +* synchornize_rcu if we repeatedly fail to alloc a new netlink message. +*/ +if (skb != oskb) { +rcu_assign_pointer (data->skb, skb); + +synchronize_rcu (); + +atomic_set (&data->dm_hit_count, dm_hit_limit); + } + }static void send_dm_alert (struct work_struct *unused) {struct sk_buff *skb; -struct per_cpu_dm_data *data = &__get_cpu_var (dm_cpu_data); +struct per_cpu_dm_data *data = &get_cpu_var (dm_cpu_data);/* * Grab the skb we're about to send */ - skb = data->skb; + skb =rcu_dereference_protected (data->skb,1 );/* * Replace it with a new one
@@ -111,8 +134,10 @@ static void send_dm_alert(struct work_struct *unused)/* * Ship it! */ -genlmsg_multicast (skb,0 ,NET_DM_GRP_ALERT ,GFP_KERNEL ); +if (skb) +genlmsg_multicast (skb,0 ,NET_DM_GRP_ALERT ,GFP_KERNEL ); +put_cpu_var (dm_cpu_data); }/*
@@ -123,9 +148,11 @@ static void send_dm_alert(struct work_struct *unused)*/ static void sched_send_work (unsigned long unused) { -struct per_cpu_dm_data *data = &__get_cpu_var (dm_cpu_data); +struct per_cpu_dm_data *data = &get_cpu_var (dm_cpu_data); + +schedule_work_on (smp_processor_id (), &data->dm_alert_work); -schedule_work (&data->dm_alert_work); +put_cpu_var (dm_cpu_data); }static void trace_drop_common (struct sk_buff *skb,void *location)
@@ -134,9 +161,16 @@ static void trace_drop_common(struct sk_buff *skb, void *location)struct nlmsghdr *nlh;struct nlattr *nla;int i; -struct per_cpu_dm_data *data = &__get_cpu_var (dm_cpu_data); +struct sk_buff *dskb; +struct per_cpu_dm_data *data = &get_cpu_var (dm_cpu_data); +rcu_read_lock (); + dskb =rcu_dereference (data->skb); + +if (!dskb) + goto out; +if (!atomic_add_unless (&data->dm_hit_count,-1 ,0 )) {/* * we're already at zero, discard this hit
@@ -144,7 +178,7 @@ static void trace_drop_common(struct sk_buff *skb, void *location) goto out; } - nlh = (struct nlmsghdr *)data->skb->data; + nlh = (struct nlmsghdr *)dskb->data; nla =genlmsg_data (nlmsg_data (nlh)); msg =nla_data (nla);for (i =0 ; i < msg->entries; i++) {
@@ -158,7 +192,7 @@ static void trace_drop_common(struct sk_buff *skb, void *location)/* * We need to create a new entry */ -__nla_reserve_nohdr (data->skb,sizeof (struct net_dm_drop_point )); +__nla_reserve_nohdr (dskb,sizeof (struct net_dm_drop_point )); nla->nla_len +=NLA_ALIGN (sizeof (struct net_dm_drop_point ));memcpy (msg->points[msg->entries].pc, &location,sizeof (void *)); msg->points[msg->entries].count =1 ;
@@ -170,6 +204,8 @@ static void trace_drop_common(struct sk_buff *skb, void *location) } out: +rcu_read_unlock (); +put_cpu_var (dm_cpu_data);return ; }
@@ -375,6 +411,8 @@ static int __init init_net_drop_monitor(void) data->send_timer.function = sched_send_work; } + initialized =1 ; + goto out; out_unreg:
PATCH 58/70 ALSA: snd-usb: fix clock source validity index
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Mack <[email protected]>
commit aff252a848ce21b431ba822de3dab9c4c94571cb upstream.
uac_clock_source_is_valid() uses the control selector value to access the bmControls bitmap of the clock source unit. This is wrong, as control selector values start from 1, while the bitmap uses all available bits.
In other words, "Clock Validity Control" is stored in D3..2, not D5..4 of the clock selector unit's bmControls.
--- sound/usb/clock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/usb/clock.c +2 -1
@@ -111,7 +111,8 @@ static bool uac_clock_source_is_valid(struct snd_usb_audio *chip, int source_id)return 0 ;/* If a clock source can't tell us whether it's valid, we assume it is */ -if (!uac2_control_is_readable (cs_desc->bmControls,UAC2_CS_CONTROL_CLOCK_VALID )) +if (!uac2_control_is_readable (cs_desc->bmControls, +UAC2_CS_CONTROL_CLOCK_VALID -1 ))return 1 ; err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR,
PATCH 50/70 ARM: 7478/1: errata: extend workaround for erratum #720789
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
commit 5a783cbc48367cfc7b65afc75430953dfe60098f upstream.
Commit cdf357f1 ("ARM: 6299/1: errata: TLBIASIDIS and TLBIMVAIS operations can broadcast a faulty ASID") replaced by-ASID TLB flushing operations with all-ASID variants to workaround A9 erratum #720789.
This patch extends the workaround to include the tlb_range operations, which were overlooked by the original patch.
--- arch/arm/mm/tlb-v7.S | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/arm/mm/tlb-v7.S +12 -0
@@ -38,11 +38,19 @@ ENTRY(v7wbi_flush_user_tlb_range) dsb mov r0, r0, lsr #PAGE_SHIFT @ align address mov r1, r1, lsr #PAGE_SHIFT +#ifdef CONFIG_ARM_ERRATA_720789 + mov r3, #0 +#else asid r3, r3 @ mask ASID +#endif orr r0, r3, r0, lsl #PAGE_SHIFT @ Create initial MVA mov r1, r1, lsl #PAGE_SHIFT 1: +#ifdef CONFIG_ARM_ERRATA_720789 + ALT_SMP(mcr p15, 0, r0, c8, c3, 3) @ TLB invalidate U MVA all ASID (shareable) +#else ALT_SMP(mcr p15, 0, r0, c8, c3, 1) @ TLB invalidate U MVA (shareable) +#endif ALT_UP(mcr p15, 0, r0, c8, c7, 1) @ TLB invalidate U MVA add r0, r0, #PAGE_SZ
@@ -67,7 +75,11 @@ ENTRY(v7wbi_flush_kern_tlb_range) mov r0, r0, lsl #PAGE_SHIFT mov r1, r1, lsl #PAGE_SHIFT 1: +#ifdef CONFIG_ARM_ERRATA_720789 + ALT_SMP(mcr p15, 0, r0, c8, c3, 3) @ TLB invalidate U MVA all ASID (shareable) +#else ALT_SMP(mcr p15, 0, r0, c8, c3, 1) @ TLB invalidate U MVA (shareable) +#endif ALT_UP(mcr p15, 0, r0, c8, c7, 1) @ TLB invalidate U MVA add r0, r0, #PAGE_SZ cmp r0, r1
Documentation/sound/alsa/HD-Audio-Models.txt +2 -1
@@ -60,10 +60,11 @@ ALC267/268 ========== N/A -ALC269 +ALC269/270/275/276/280/282 ====== laptop-amic Laptops with analog-mic input laptop-dmic Laptops with digital-mic input + lenovo-dock Enables docking station I/O for some Lenovos ALC662/663/272 ==============
Documentation/stable_kernel_rules.txt +14 -5
@@ -1,4 +1,4 @@ -Everything you ever wanted to know about Linux 2.6 -stable releases. +Everything you ever wanted to know about Linux -stable releases. Rules on what kind of patches are accepted, and which ones are not, into the "-stable" tree:
@@ -41,10 +41,10 @@ Procedure for submitting patches to the -stable tree: cherry-picked than this can be specified in the following format in the sign-off area: - Cc: <[email protected]> # .32.x: a1f84a3: sched: Check for idle - Cc: <[email protected]> # .32.x: 1b9508f: sched: Rate-limit newidle - Cc: <[email protected]> # .32.x: fd21073: sched: Fix affinity logic - Cc: <[email protected]> # .32.x + Cc: <[email protected]> # 3.3.x: a1f84a3: sched: Check for idle + Cc: <[email protected]> # 3.3.x: 1b9508f: sched: Rate-limit newidle + Cc: <[email protected]> # 3.3.x: fd21073: sched: Fix affinity logic + Cc: <[email protected]> # 3.3.x Signed-off-by: Ingo Molnar <[email protected]> The tag sequence has the meaning of:
@@ -78,6 +78,15 @@ Review cycle: security kernel team, and not go through the normal review cycle. Contact the kernel security team for more details on this procedure. +Trees: + + - The queues of patches, for both completed versions and in progress + versions can be found at: + http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git + - The finalized and tagged releases of all stable kernels can be found + in separate branches per version at: + http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git + Review committee:
Makefile +2 -2
@@ -1,7 +1,7 @@ VERSION = 3 PATCHLEVEL = 2 -SUBLEVEL = 26 -EXTRAVERSION = +SUBLEVEL = 27 +EXTRAVERSION = -rc1 NAME = Saber-toothed Squirrel # *DOCUMENTATION*
arch/arm/include/asm/mutex.h +4 -115
125 lines not on this page · raw message
arch/arm/kernel/entry-armv.S +72 -39
190 lines not on this page · raw message
arch/arm/kernel/process.c +2 -0
@@ -125,6 +125,7 @@ void arm_machine_restart(char mode, const char *cmd)*/ mdelay (1000 );printk ("Reboot failed -- System halted\n" ); +local_irq_disable ();while (1 ); }
@@ -240,6 +241,7 @@ void machine_shutdown(void)void machine_halt (void ) {machine_shutdown (); +local_irq_disable ();while (1 ); }
arch/arm/kernel/traps.c +0 -8
@@ -362,18 +362,10 @@ static int call_undef_hook(struct pt_regs *regs, unsigned int instr) asmlinkage void __exception do_undefinstr(struct pt_regs *regs) { -unsigned int correction =thumb_mode (regs) ?2 :4 ;unsigned int instr;siginfo_t info;void __user *pc; -/* -* According to the ARM ARM, PC is 2 or 4 bytes ahead, -* depending whether we're in Thumb mode or not. -* Correct this offset. -*/ - regs->ARM_pc -= correction; - pc = (void __user *)instruction_pointer (regs);if (processor_mode (regs) ==SVC_MODE ) {
arch/arm/mm/tlb-v7.S +12 -0
@@ -38,11 +38,19 @@ ENTRY(v7wbi_flush_user_tlb_range) dsb mov r0, r0, lsr #PAGE_SHIFT @ align address mov r1, r1, lsr #PAGE_SHIFT +#ifdef CONFIG_ARM_ERRATA_720789 + mov r3, #0 +#else asid r3, r3 @ mask ASID +#endif orr r0, r3, r0, lsl #PAGE_SHIFT @ Create initial MVA mov r1, r1, lsl #PAGE_SHIFT 1: +#ifdef CONFIG_ARM_ERRATA_720789 + ALT_SMP(mcr p15, 0, r0, c8, c3, 3) @ TLB invalidate U MVA all ASID (shareable) +#else ALT_SMP(mcr p15, 0, r0, c8, c3, 1) @ TLB invalidate U MVA (shareable) +#endif ALT_UP(mcr p15, 0, r0, c8, c7, 1) @ TLB invalidate U MVA add r0, r0, #PAGE_SZ
@@ -67,7 +75,11 @@ ENTRY(v7wbi_flush_kern_tlb_range) mov r0, r0, lsl #PAGE_SHIFT mov r1, r1, lsl #PAGE_SHIFT 1: +#ifdef CONFIG_ARM_ERRATA_720789 + ALT_SMP(mcr p15, 0, r0, c8, c3, 3) @ TLB invalidate U MVA all ASID (shareable) +#else ALT_SMP(mcr p15, 0, r0, c8, c3, 1) @ TLB invalidate U MVA (shareable) +#endif ALT_UP(mcr p15, 0, r0, c8, c7, 1) @ TLB invalidate U MVA add r0, r0, #PAGE_SZ cmp r0, r1
arch/arm/vfp/entry.S +9 -7
@@ -7,18 +7,20 @@ * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. - * - * Basic entry code, called from the kernel's undefined instruction trap. - * r0 = faulted instruction - * r5 = faulted PC+4 - * r9 = successful return - * r10 = thread_info structure - * lr = failure return */ #include <asm/thread_info.h> #include <asm/vfpmacros.h> #include "../kernel/entry-header.S" +@ VFP entry point. +@ +@ r0 = instruction opcode (32-bit ARM or two 16-bit Thumb) +@ r2 = PC value to resume execution after successful emulation +@ r9 = normal "successful" return address +@ r10 = this threads thread_info structure +@ lr = unrecognised instruction return address +@ IRQs disabled. +@ ENTRY(do_vfp) #ifdef CONFIG_PREEMPT ldr r4, [r10, #TI_PREEMPT] @ get preempt count
arch/arm/vfp/vfphw.S +11 -8
@@ -61,13 +61,13 @@ @ VFP hardware support entry point. @ -@ r0 = faulted instruction -@ r2 = faulted PC+4 -@ r9 = successful return +@ r0 = instruction opcode (32-bit ARM or two 16-bit Thumb) +@ r2 = PC value to resume execution after successful emulation +@ r9 = normal "successful" return address @ r10 = vfp_state union @ r11 = CPU number -@ lr = failure return - +@ lr = unrecognised instruction return address +@ IRQs enabled. ENTRY(vfp_support_entry) DBGSTR3 "instr %08x pc %08x state %p", r0, r2, r10
@@ -161,9 +161,12 @@ vfp_hw_state_valid: @ exception before retrying branch @ out before setting an FPEXC that @ stops us reading stuff - VFPFMXR FPEXC, r1 @ restore FPEXC last - sub r2, r2, #4 - str r2, [sp, #S_PC] @ retry the instruction + VFPFMXR FPEXC, r1 @ Restore FPEXC last + sub r2, r2, #4 @ Retry current instruction - if Thumb + str r2, [sp, #S_PC] @ mode it's two 16-bit instructions, + @ else it's one 32-bit instruction, so + @ always subtract 4 from the following + @ instruction address. #ifdef CONFIG_PREEMPT get_thread_info r10 ldr r4, [r10, #TI_PREEMPT] @ get preempt count
arch/arm/vfp/vfpmodule.c +7 -1
@@ -453,10 +453,16 @@ static int vfp_pm_suspend(void)/* disable, just in case */ fmxr (FPEXC ,fmrx (FPEXC ) & ~FPEXC_EN ); + }else if (vfp_current_hw_state[ti->cpu]) { +#ifndef CONFIG_SMP +fmxr (FPEXC , fpexc |FPEXC_EN ); +vfp_save_state (vfp_current_hw_state[ti->cpu], fpexc); +fmxr (FPEXC , fpexc); +#endif }/* clear any information we had about last context state */ -memset (vfp_current_hw_state,0 ,sizeof (vfp_current_hw_state)); + vfp_current_hw_state[ti->cpu] =NULL ;return 0 ; }
arch/ia64/include/asm/atomic.h +2 -2
@@ -18,8 +18,8 @@#include <asm/system.h> -#define ATOMIC_INIT (i) ((atomic_t) { (i) }) -#define ATOMIC64_INIT (i) ((atomic64_t) { (i) }) +#define ATOMIC_INIT (i) { (i) } +#define ATOMIC64_INIT (i) { (i) }#define atomic_read (v) (*(volatile int *)&(v)->counter)#define atomic64_read (v) (*(volatile long *)&(v)->counter)
arch/m68k/include/asm/entry.h +2 -2
@@ -33,8 +33,8 @@/* the following macro is used when enabling interrupts */ #if defined(MACH_ATARI_ONLY ) -/* block out HSYNC on the atari */ -#define ALLOWINT (~0x400) +/* block out HSYNC = ipl 2 on the atari */ +#define ALLOWINT (~0x500)#define MAX_NOINT_IPL 3#else /* portable version */
arch/m68k/kernel/sys_m68k.c +6 -2
@@ -479,9 +479,13 @@ sys_atomic_cmpxchg_32(unsigned long newval, int oldval, int d3, int d4, int d5, goto bad_access; } - mem_value = *mem; +/* +* No need to check for EFAULT; we know that the page is +* present and writable. +*/ +__get_user (mem_value, mem);if (mem_value == oldval) - *mem = newval; +__put_user (newval, mem);pte_unmap_unlock (pte, ptl);up_read (&mm->mmap_sem);
arch/s390/include/asm/mmu_context.h +13 -1
@@ -12,7 +12,6 @@#include <asm/pgalloc.h> #include <asm/uaccess.h> #include <asm/tlbflush.h> -#include <asm-generic/mm_hooks.h> static inline int init_new_context (struct task_struct *tsk,struct mm_struct *mm)
@@ -92,4 +91,17 @@ static inline void activate_mm(struct mm_struct *prev, switch_mm(prev, next, current); } +static inline void arch_dup_mmap (struct mm_struct *oldmm, +struct mm_struct *mm) +{ +#ifdef CONFIG_64BIT +if (oldmm->context.asce_limit < mm->context.asce_limit) +crst_table_downgrade (mm, oldmm->context.asce_limit); +#endif +} + +static inline void arch_exit_mmap (struct mm_struct *mm) +{ +} +#endif /* __S390_MMU_CONTEXT_H */
arch/s390/include/asm/processor.h +2 -0
@@ -130,7 +130,9 @@ struct stack_frame { regs->psw.mask = psw_user_bits |PSW_MASK_BA ; \ regs->psw.addr = new_psw |PSW_ADDR_AMODE ; \ regs->gprs[15 ] = new_stackp; \ +__tlb_flush_mm (current->mm); \crst_table_downgrade (current->mm,1UL <<31 ); \ +update_mm (current->mm, current); \ }while (0 )/* Forward declaration, a strange C thing */
arch/s390/mm/fault.c +7 -6
@@ -453,6 +453,7 @@ int __handle_fault(unsigned long uaddr, unsigned long pgm_int_code, int write)struct pt_regs regs;int access, fault; +/* Emulate a uaccess fault from kernel mode. */ regs.psw.mask = psw_kernel_bits |PSW_MASK_DAT |PSW_MASK_MCHECK ;if (!irqs_disabled ()) regs.psw.mask |=PSW_MASK_IO |PSW_MASK_EXT ;
@@ -461,12 +462,12 @@ int __handle_fault(unsigned long uaddr, unsigned long pgm_int_code, int write) uaddr &=PAGE_MASK ; access = write ?VM_WRITE :VM_READ ; fault =do_exception (®s, access, uaddr |2 ); -if (unlikely (fault)) { -if (fault &VM_FAULT_OOM ) -return -EFAULT ; -else if (fault &VM_FAULT_SIGBUS ) -do_sigbus (®s, pgm_int_code, uaddr); - } +/* +* Since the fault happened in kernel mode while performing a uaccess +* all we need to do now is emulating a fixup in case "fault" is not +* zero. +* For the calling uaccess functions this results always in -EFAULT. +*/ return fault ? -EFAULT :0 ; }
arch/s390/mm/mmap.c +10 -2
@@ -106,9 +106,15 @@ EXPORT_SYMBOL_GPL(arch_pick_mmap_layout);int s390_mmap_check (unsigned long addr,unsigned long len) { +int rc; +if (!is_compat_task () && - len >=TASK_SIZE &&TASK_SIZE < (1UL <<53 )) -return crst_table_upgrade (current->mm,1UL <<53 ); + len >=TASK_SIZE &&TASK_SIZE < (1UL <<53 )) { + rc =crst_table_upgrade (current->mm,1UL <<53 ); +if (rc) +return rc; +update_mm (current->mm, current); + }return 0 ; }
@@ -128,6 +134,7 @@ s390_get_unmapped_area(struct file *filp, unsigned long addr, rc =crst_table_upgrade (mm,1UL <<53 );if (rc)return (unsigned long ) rc; +update_mm (mm, current); area =arch_get_unmapped_area (filp, addr, len, pgoff, flags); }return area;
@@ -150,6 +157,7 @@ s390_get_unmapped_area_topdown(struct file *filp, const unsigned long addr, rc =crst_table_upgrade (mm,1UL <<53 );if (rc)return (unsigned long ) rc; +update_mm (mm, current); area =arch_get_unmapped_area_topdown (filp, addr, len, pgoff, flags); }
arch/s390/mm/pgtable.c +0 -5
@@ -97,7 +97,6 @@ repeat:crst_table_free (mm, table);if (mm->context.asce_limit < limit) goto repeat; -update_mm (mm, current);return 0 ; }
@@ -105,9 +104,6 @@ void crst_table_downgrade(struct mm_struct *mm, unsigned long limit) {pgd_t *pgd; -if (mm->context.asce_limit <= limit) -return ; -__tlb_flush_mm (mm);while (mm->context.asce_limit > limit) { pgd = mm->pgd;switch (pgd_val (*pgd) & _REGION_ENTRY_TYPE_MASK) {
@@ -130,7 +126,6 @@ void crst_table_downgrade(struct mm_struct *mm, unsigned long limit) mm->task_size = mm->context.asce_limit; crst_table_free(mm, (unsigned long *) pgd); } -update_mm (mm, current); }#endif
arch/x86/kernel/alternative.c +1 -1
@@ -219,7 +219,7 @@ void __init arch_init_ideal_nops(void) ideal_nops = intel_nops;#endif } - +break ;default :#ifdef CONFIG_X86_64 ideal_nops = k8_nops;
arch/x86/xen/p2m.c +36 -0
@@ -686,6 +686,7 @@ int m2p_add_override(unsigned long mfn, struct page *page,unsigned long uninitialized_var (address );unsigned level;pte_t *ptep =NULL ; +int ret =0 ; pfn =page_to_pfn (page);if (!PageHighMem (page)) {
@@ -721,6 +722,24 @@ int m2p_add_override(unsigned long mfn, struct page *page,list_add (&page->lru, &m2p_overrides[mfn_hash (mfn)]);spin_unlock_irqrestore (&m2p_override_lock, flags); +/* p2m(m2p(mfn)) == mfn: the mfn is already present somewhere in +* this domain. Set the FOREIGN_FRAME_BIT in the p2m for the other +* pfn so that the following mfn_to_pfn(mfn) calls will return the +* pfn from the m2p_override (the backend pfn) instead. +* We need to do this because the pages shared by the frontend +* (xen-blkfront) can be already locked (lock_page, called by +* do_read_cache_page); when the userspace backend tries to use them +* with direct_IO, mfn_to_pfn returns the pfn of the frontend, so +* do_blockdev_direct_IO is going to try to lock the same pages +* again resulting in a deadlock. +* As a side effect get_user_pages_fast might not be safe on the +* frontend pages while they are being shared with the backend, +* because mfn_to_pfn (that ends up being called by GUPF) will +* return the backend pfn rather than the frontend pfn. */ + ret =__get_user (pfn, &machine_to_phys_mapping[mfn]); +if (ret ==0 &&get_phys_to_machine (pfn) == mfn) +set_phys_to_machine (pfn,FOREIGN_FRAME (mfn)); +return 0 ; }EXPORT_SYMBOL_GPL (m2p_add_override);
@@ -732,6 +751,7 @@ int m2p_remove_override(struct page *page, bool clear_pte)unsigned long uninitialized_var (address );unsigned level;pte_t *ptep =NULL ; +int ret =0 ; pfn =page_to_pfn (page); mfn =get_phys_to_machine (pfn);
@@ -801,6 +821,22 @@ int m2p_remove_override(struct page *page, bool clear_pte) }else set_phys_to_machine (pfn, page->index); +/* p2m(m2p(mfn)) == FOREIGN_FRAME(mfn): the mfn is already present +* somewhere in this domain, even before being added to the +* m2p_override (see comment above in m2p_add_override). +* If there are no other entries in the m2p_override corresponding +* to this mfn, then remove the FOREIGN_FRAME_BIT from the p2m for +* the original pfn (the one shared by the frontend): the backend +* cannot do any IO on this page anymore because it has been +* unshared. Removing the FOREIGN_FRAME_BIT from the p2m entry of +* the original pfn causes mfn_to_pfn(mfn) to return the frontend +* pfn again. */ + mfn &= ~FOREIGN_FRAME_BIT ; + ret =__get_user (pfn, &machine_to_phys_mapping[mfn]); +if (ret ==0 &&get_phys_to_machine (pfn) ==FOREIGN_FRAME (mfn) && +m2p_find_override (mfn) ==NULL ) +set_phys_to_machine (pfn, mfn); +return 0 ; }EXPORT_SYMBOL_GPL (m2p_remove_override);
drivers/block/floppy.c +7 -1
@@ -4369,8 +4369,14 @@ out_unreg_blkdev: out_put_disk:while (dr--) {del_timer_sync (&motor_off_timer[dr]); -if (disks[dr]->queue) +if (disks[dr]->queue) {blk_cleanup_queue (disks[dr]->queue); +/* +* put_disk() is not paired with add_disk() and +* will put queue reference one extra time. fix it. +*/ + disks[dr]->queue =NULL ; + }put_disk (disks[dr]); }return err;
drivers/block/virtio_blk.c +3 -6
@@ -20,8 +20,6 @@ struct workqueue_struct *virtblk_wq;struct virtio_blk { -spinlock_t lock; -struct virtio_device *vdev;struct virtqueue *vq;
@@ -62,7 +60,7 @@ static void blk_done(struct virtqueue *vq)unsigned int len;unsigned long flags; -spin_lock_irqsave (&vblk->lock, flags); +spin_lock_irqsave (vblk->disk->queue->queue_lock, flags);while ((vbr =virtqueue_get_buf (vblk->vq, &len)) !=NULL ) {int error;
@@ -97,7 +95,7 @@ static void blk_done(struct virtqueue *vq) }/* In case queue is stopped waiting for more buffers. */ blk_start_queue (vblk->disk->queue); -spin_unlock_irqrestore (&vblk->lock, flags); +spin_unlock_irqrestore (vblk->disk->queue->queue_lock, flags); } static bool do_req(struct request_queue *q, struct virtio_blk *vblk,
@@ -384,7 +382,6 @@ static int __devinit virtblk_probe(struct virtio_device *vdev) }INIT_LIST_HEAD (&vblk->reqs); -spin_lock_init (&vblk->lock); vblk->vdev = vdev; vblk->sg_elems = sg_elems;sg_init_table (vblk->sg, vblk->sg_elems);
@@ -410,7 +407,7 @@ static int __devinit virtblk_probe(struct virtio_device *vdev) goto out_mempool; } - q = vblk->disk->queue =blk_init_queue (do_virtblk_request, &vblk->lock); + q = vblk->disk->queue =blk_init_queue (do_virtblk_request,NULL );if (!q) { err = -ENOMEM ; goto out_put_disk;
drivers/char/mspec.c +1 -1
@@ -284,7 +284,7 @@ mspec_mmap(struct file *file, struct vm_area_struct *vma, vdata->flags = flags; vdata->type = type;spin_lock_init (&vdata->lock); - vdata->refcnt =ATOMIC_INIT (1 ); +atomic_set (&vdata->refcnt,1 ); vma->vm_private_data = vdata; vma->vm_flags |= (VM_IO |VM_RESERVED |VM_PFNMAP |VM_DONTEXPAND );
drivers/char/random.c +207 -66
490 lines not on this page · raw message
drivers/firmware/pcdp.c +2 -2
@@ -95,7 +95,7 @@ efi_setup_pcdp_console(char *cmdline)if (efi.hcdp ==EFI_INVALID_TABLE_ADDR )return -ENODEV ; - pcdp =ioremap (efi.hcdp,4096 ); + pcdp =early_ioremap (efi.hcdp,4096 );printk (KERN_INFO "PCDP: v%d at 0x%lx\n" , pcdp->rev, efi.hcdp);if (strstr (cmdline,"console=hcdp" )) {
@@ -131,6 +131,6 @@ efi_setup_pcdp_console(char *cmdline) } out: -iounmap (pcdp); +early_iounmap (pcdp,4096 );return rc; }
drivers/gpu/drm/i915/intel_dp.c +2 -2
@@ -708,8 +708,8 @@ intel_dp_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode, bpp = adjusted_mode->private_flags &INTEL_MODE_DP_FORCE_6BPC ?18 :24 ; -for (lane_count =1 ; lane_count <= max_lane_count; lane_count <<=1 ) { -for (clock =0 ; clock <= max_clock; clock++) { +for (clock =0 ; clock <= max_clock; clock++) { +for (lane_count =1 ; lane_count <= max_lane_count; lane_count <<=1 ) {int link_avail =intel_dp_max_data_rate (intel_dp_link_clock (bws[clock]), lane_count); if (intel_dp_link_required(mode->clock, bpp)
drivers/input/mouse/synaptics.c +23 -0
@@ -40,11 +40,28 @@* Note that newer firmware allows querying device for maximum useable * coordinates. */ +#define XMIN 0 +#define XMAX 6143 +#define YMIN 0 +#define YMAX 6143#define XMIN_NOMINAL 1472#define XMAX_NOMINAL 5472#define YMIN_NOMINAL 1408#define YMAX_NOMINAL 4448 +/* Size in bits of absolute position values reported by the hardware */ +#define ABS_POS_BITS 13 + +/* +* Any position values from the hardware above the following limits are +* treated as "wrapped around negative" values that have been truncated to +* the 13-bit reporting range of the hardware. These are just reasonable +* guesses and can be adjusted if hardware is found that operates outside +* of these parameters. +*/ +#define X_MAX_POSITIVE (((1 << ABS_POS_BITS) + XMAX) / 2) +#define Y_MAX_POSITIVE (((1 << ABS_POS_BITS) + YMAX) / 2) +/* * Synaptics touchpads report the y coordinate from bottom to top, which is * opposite from what userspace expects.
@@ -544,6 +561,12 @@ static int synaptics_parse_hw_state(const unsigned char buf[], hw->right = (buf[0 ] &0x02 ) ?1 :0 ; } +/* Convert wrap-around values to negative */ +if (hw->x >X_MAX_POSITIVE ) + hw->x -=1 <<ABS_POS_BITS ; +if (hw->y >Y_MAX_POSITIVE ) + hw->y -=1 <<ABS_POS_BITS ; +return 0 ; }
drivers/md/dm-thin.c +4 -3
@@ -19,7 +19,7 @@/* * Tunable constants */ -#define ENDIO_HOOK_POOL_SIZE 10240 +#define ENDIO_HOOK_POOL_SIZE 1024#define DEFERRED_SET_SIZE 64#define MAPPING_POOL_SIZE 1024#define PRISON_CELLS 1024
@@ -857,7 +857,7 @@ static void process_prepared_mapping(struct new_mapping *m)if (m->err) {cell_error (m->cell); -return ; + goto out; }/*
@@ -869,7 +869,7 @@ static void process_prepared_mapping(struct new_mapping *m)if (r) {DMERR ("dm_thin_insert_block() failed" );cell_error (m->cell); -return ; + goto out; }/*
@@ -884,6 +884,7 @@ static void process_prepared_mapping(struct new_mapping *m) }else cell_defer (tc, m->cell, m->data_block); +out:list_del (&m->list);mempool_free (m, tc->pool->mapping_pool); }
drivers/md/raid1.c +4 -1
@@ -2321,7 +2321,10 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr, int *skipp/* There is nowhere to write, so all non-sync * drives must be failed - so we are finished */ -sector_t rv = max_sector - sector_nr; +sector_t rv; +if (min_bad >0 ) + max_sector = sector_nr + min_bad; + rv = max_sector - sector_nr; *skipped =1 ;put_buf (r1_bio);return rv;
drivers/media/rc/ene_ir.c +2 -1
@@ -1018,6 +1018,8 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)spin_lock_init (&dev->hw_lock); + dev->hw_io =pnp_port_start (pnp_dev,0 ); +pnp_set_drvdata (pnp_dev, dev); dev->pnp_dev = pnp_dev;
@@ -1072,7 +1074,6 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)/* claim the resources */ error = -EBUSY ; - dev->hw_io =pnp_port_start (pnp_dev,0 );if (!request_region (dev->hw_io,ENE_IO_SIZE ,ENE_DRIVER_NAME )) { dev->hw_io =-1 ; dev->irq =-1 ;
drivers/mfd/ab3100-core.c +0 -2
@@ -409,8 +409,6 @@ static irqreturn_t ab3100_irq_handler(int irq, void *data)u32 fatevent;int err; -add_interrupt_randomness (irq); - err =ab3100_get_register_page_interruptible (ab3100,AB3100_EVENTA1 , event_regs,3 );if (err)
drivers/mfd/wm831x-otp.c +8 -0
@@ -18,6 +18,7 @@#include <linux/bcd.h> #include <linux/delay.h> #include <linux/mfd/core.h> +#include <linux/random.h> #include <linux/mfd/wm831x/core.h> #include <linux/mfd/wm831x/otp.h>
@@ -66,6 +67,7 @@ static DEVICE_ATTR(unique_id, 0444, wm831x_unique_id_show, NULL);int wm831x_otp_init (struct wm831x *wm831x) { +char uuid[WM831X_UNIQUE_ID_LEN ];int ret; ret =device_create_file (wm831x->dev, &dev_attr_unique_id);
@@ -73,6 +75,12 @@ int wm831x_otp_init(struct wm831x *wm831x)dev_err (wm831x->dev,"Unique ID attribute not created: %d\n" , ret); + ret =wm831x_unique_id_read (wm831x, uuid); +if (ret ==0 ) +add_device_randomness (uuid,sizeof (uuid)); +else +dev_err (wm831x->dev,"Failed to read UUID: %d\n" , ret); +return ret; }
drivers/net/wireless/rt2x00/rt2800usb.c +1 -0
@@ -925,6 +925,7 @@ static struct usb_device_id rt2800usb_device_table[] = { { USB_DEVICE(0x0411, 0x015d) }, { USB_DEVICE(0x0411, 0x016f) }, { USB_DEVICE(0x0411, 0x01a2) }, + { USB_DEVICE(0x0411, 0x01ee) },/* Corega */ { USB_DEVICE(0x07aa, 0x002f) }, { USB_DEVICE(0x07aa, 0x003c) },
drivers/platform/x86/asus-wmi.c +1 -6
@@ -1431,14 +1431,9 @@ static int asus_wmi_platform_init(struct asus_wmi *asus)*/ if (!asus_wmi_evaluate_method (ASUS_WMI_METHODID_DSTS ,0 ,0 ,NULL )) asus->dsts_id =ASUS_WMI_METHODID_DSTS ; -else if (!asus_wmi_evaluate_method (ASUS_WMI_METHODID_DSTS2 ,0 ,0 ,NULL )) +else asus->dsts_id =ASUS_WMI_METHODID_DSTS2 ; -if (!asus->dsts_id) { -pr_err ("Can't find DSTS" ); -return -ENODEV ; - } -/* CWAP allow to define the behavior of the Fn+F2 key, * this method doesn't seems to be present on Eee PCs */ if (asus->driver->wapf >=0 )
drivers/rtc/rtc-wm831x.c +23 -1
@@ -24,7 +24,7 @@#include <linux/mfd/wm831x/core.h> #include <linux/delay.h> #include <linux/platform_device.h> - +#include <linux/random.h> /* * R16416 (0x4020) - RTC Write Counter
@@ -96,6 +96,26 @@ struct wm831x_rtc { unsigned int alarm_enabled:1; }; +static void wm831x_rtc_add_randomness (struct wm831x *wm831x) +{ +int ret; +u16 reg; + +/* +* The write counter contains a pseudo-random number which is +* regenerated every time we set the RTC so it should be a +* useful per-system source of entropy. +*/ + ret =wm831x_reg_read (wm831x,WM831X_RTC_WRITE_COUNTER ); +if (ret >=0 ) { + reg = ret; +add_device_randomness (®,sizeof (reg)); + }else { +dev_warn (wm831x->dev,"Failed to read RTC write counter: %d\n" , + ret); + } +} +/* * Read current time and date in RTC */
@@ -449,6 +469,8 @@ static int wm831x_rtc_probe(struct platform_device *pdev) alm_irq, ret); } +wm831x_rtc_add_randomness (wm831x); +return 0 ; err:
drivers/staging/media/lirc/lirc_sir.c +58 -2
99 lines not on this page · raw message
drivers/tty/serial/pch_uart.c +14 -7
@@ -660,7 +660,8 @@ static void pch_dma_rx_complete(void *arg)tty_flip_buffer_push (tty);tty_kref_put (tty);async_tx_ack (priv->desc_rx); -pch_uart_hal_enable_interrupt (priv,PCH_UART_HAL_RX_INT ); +pch_uart_hal_enable_interrupt (priv,PCH_UART_HAL_RX_INT | +PCH_UART_HAL_RX_ERR_INT ); }static void pch_dma_tx_complete (void *arg)
@@ -715,7 +716,8 @@ static int handle_rx_to(struct eg20t_port *priv)int rx_size;int ret;if (!priv->start_rx) { -pch_uart_hal_disable_interrupt (priv,PCH_UART_HAL_RX_INT ); +pch_uart_hal_disable_interrupt (priv,PCH_UART_HAL_RX_INT | +PCH_UART_HAL_RX_ERR_INT );return 0 ; } buf = &priv->rxbuf;
@@ -977,11 +979,13 @@ static irqreturn_t pch_uart_interrupt(int irq, void *dev_id)case PCH_UART_IID_RDR :/* Received Data Ready */ if (priv->use_dma) {pch_uart_hal_disable_interrupt (priv, -PCH_UART_HAL_RX_INT ); +PCH_UART_HAL_RX_INT | +PCH_UART_HAL_RX_ERR_INT ); ret =dma_handle_rx (priv);if (!ret)pch_uart_hal_enable_interrupt (priv, -PCH_UART_HAL_RX_INT ); +PCH_UART_HAL_RX_INT | +PCH_UART_HAL_RX_ERR_INT ); }else { ret =handle_rx (priv); }
@@ -1107,7 +1111,8 @@ static void pch_uart_stop_rx(struct uart_port *port)struct eg20t_port *priv; priv = container_of(port, struct eg20t_port, port); priv->start_rx =0 ; -pch_uart_hal_disable_interrupt (priv,PCH_UART_HAL_RX_INT ); +pch_uart_hal_disable_interrupt (priv,PCH_UART_HAL_RX_INT | +PCH_UART_HAL_RX_ERR_INT ); priv->int_dis_flag =1 ; }
@@ -1163,6 +1168,7 @@ static int pch_uart_startup(struct uart_port *port)break ;case 16 : fifo_size =PCH_UART_HAL_FIFO16 ; +break ;case 1 :default : fifo_size =PCH_UART_HAL_FIFO_DIS ;
@@ -1200,7 +1206,8 @@ static int pch_uart_startup(struct uart_port *port)pch_request_dma (port); priv->start_rx =1 ; -pch_uart_hal_enable_interrupt (priv,PCH_UART_HAL_RX_INT ); +pch_uart_hal_enable_interrupt (priv,PCH_UART_HAL_RX_INT | +PCH_UART_HAL_RX_ERR_INT );uart_update_timeout (port,CS8 , default_baud);return 0 ;
@@ -1258,7 +1265,7 @@ static void pch_uart_set_termios(struct uart_port *port, stb =PCH_UART_HAL_STB1 ;if (termios->c_cflag &PARENB ) { -if (!(termios->c_cflag &PARODD )) +if (termios->c_cflag &PARODD ) parity =PCH_UART_HAL_PARITY_ODD ;else parity =PCH_UART_HAL_PARITY_EVEN ;
drivers/usb/core/hub.c +9 -0
@@ -24,6 +24,7 @@#include <linux/kthread.h> #include <linux/mutex.h> #include <linux/freezer.h> +#include <linux/random.h> #include <asm/uaccess.h> #include <asm/byteorder.h>
@@ -1897,6 +1898,14 @@ int usb_new_device(struct usb_device *udev)/* Tell the world! */ announce_device (udev); +if (udev->serial) +add_device_randomness (udev->serial,strlen (udev->serial)); +if (udev->product) +add_device_randomness (udev->product,strlen (udev->product)); +if (udev->manufacturer) +add_device_randomness (udev->manufacturer, +strlen (udev->manufacturer)); +device_enable_async_suspend (&udev->dev);/* Register the device. The device driver is responsible * for configuring the device and invoking the add-device
drivers/usb/early/ehci-dbgp.c +1 -1
@@ -450,7 +450,7 @@ static int dbgp_ehci_startup(void)writel (FLAG_CF , &ehci_regs->configured_flag);/* Wait until the controller is no longer halted */ - loop =10 ; + loop =1000 ; do { status = readl(&ehci_regs->status); if (!(status & STS_HALT))
drivers/video/smscufx.c +1 -1
@@ -904,7 +904,7 @@ static ssize_t ufx_ops_write(struct fb_info *info, const char __user *buf, result =fb_sys_write (info, buf, count, ppos);if (result >0 ) { -int start =max ((int )(offset / info->fix.line_length) -1 ,0 ); +int start =max ((int )(offset / info->fix.line_length),0 );int lines =min ((u32)((result / info->fix.line_length) +1 ), (u32 )info->var.yres);
fs/exofs/ore.c +7 -7
@@ -837,11 +837,11 @@ static int _write_mirror(struct ore_io_state *ios, int cur_comp) bio->bi_rw |=REQ_WRITE ; } -osd_req_write (or,_ios_obj (ios, dev), per_dev->offset, - bio, per_dev->length); +osd_req_write (or,_ios_obj (ios, cur_comp), + per_dev->offset, bio, per_dev->length);ORE_DBGMSG ("write(0x%llx) offset=0x%llx " "length=0x%llx dev=%d\n" , -_LLU (_ios_obj (ios, dev)->id), +_LLU (_ios_obj (ios, cur_comp)->id),_LLU (per_dev->offset),_LLU (per_dev->length), dev); }else if (ios->kern_buff) {
@@ -853,20 +853,20 @@ static int _write_mirror(struct ore_io_state *ios, int cur_comp) (ios->si.unit_off + ios->length > ios->layout->stripe_unit)); - ret =osd_req_write_kern (or,_ios_obj (ios, per_dev->dev), + ret =osd_req_write_kern (or,_ios_obj (ios, cur_comp), per_dev->offset, ios->kern_buff, ios->length);if (unlikely (ret)) goto out;ORE_DBGMSG2 ("write_kern(0x%llx) offset=0x%llx " "length=0x%llx dev=%d\n" , -_LLU (_ios_obj (ios, dev)->id), +_LLU (_ios_obj (ios, cur_comp)->id),_LLU (per_dev->offset),_LLU (ios->length), per_dev->dev); }else { -osd_req_set_attributes (or,_ios_obj (ios, dev)); +osd_req_set_attributes (or,_ios_obj (ios, cur_comp));ORE_DBGMSG2 ("obj(0x%llx) set_attributes=%d dev=%d\n" , -_LLU (_ios_obj (ios, dev)->id), +_LLU (_ios_obj (ios, cur_comp)->id), ios->out_attr_len, dev); }
fs/nfs/file.c +5 -2
@@ -452,8 +452,11 @@ static int nfs_release_page(struct page *page, gfp_t gfp)dfprintk (PAGECACHE ,"NFS: release_page(%p)\n" , page); -/* Only do I/O if gfp is a superset of GFP_KERNEL */ -if (mapping && (gfp &GFP_KERNEL ) ==GFP_KERNEL ) { +/* Only do I/O if gfp is a superset of GFP_KERNEL, and we're not +* doing this memory reclaim for a fs-related allocation. +*/ +if (mapping && (gfp &GFP_KERNEL ) ==GFP_KERNEL && + !(current->flags &PF_FSTRANS )) {int how =FLUSH_SYNC ;/* Don't let kswapd deadlock waiting for OOM RPC calls */
fs/nfsd/nfs4xdr.c +1 -1
@@ -2236,7 +2236,7 @@ out_acl:if (bmval0 &FATTR4_WORD0_CASE_INSENSITIVE ) {if ((buflen -=4 ) <0 ) goto out_resource; -WRITE32 (1 ); +WRITE32 (0 ); }if (bmval0 &FATTR4_WORD0_CASE_PRESERVING ) {if ((buflen -=4 ) <0 )
fs/nilfs2/ioctl.c +2 -2
@@ -182,7 +182,7 @@ static int nilfs_ioctl_change_cpmode(struct inode *inode, struct file *filp,if (copy_from_user (&cpmode, argp,sizeof (cpmode))) goto out; -down_read (&inode->i_sb->s_umount); +mutex_lock (&nilfs->ns_snapshot_mount_mutex);nilfs_transaction_begin (inode->i_sb, &ti,0 ); ret = nilfs_cpfile_change_cpmode(
@@ -192,7 +192,7 @@ static int nilfs_ioctl_change_cpmode(struct inode *inode, struct file *filp,else nilfs_transaction_commit (inode->i_sb);/* never fails */ -up_read (&inode->i_sb->s_umount); +mutex_unlock (&nilfs->ns_snapshot_mount_mutex); out:mnt_drop_write (filp->f_path.mnt);return ret;
fs/nilfs2/super.c +3 -0
@@ -951,6 +951,8 @@ static int nilfs_attach_snapshot(struct super_block *s, __u64 cno,struct nilfs_root *root;int ret; +mutex_lock (&nilfs->ns_snapshot_mount_mutex); +down_read (&nilfs->ns_segctor_sem); ret =nilfs_cpfile_is_snapshot (nilfs->ns_cpfile, cno);up_read (&nilfs->ns_segctor_sem);
@@ -975,6 +977,7 @@ static int nilfs_attach_snapshot(struct super_block *s, __u64 cno, ret =nilfs_get_root_dentry (s, root, root_dentry);nilfs_put_root (root); out: +mutex_unlock (&nilfs->ns_snapshot_mount_mutex);return ret; }
fs/nilfs2/the_nilfs.c +1 -0
@@ -76,6 +76,7 @@ struct the_nilfs *alloc_nilfs(struct block_device *bdev) nilfs->ns_bdev = bdev;atomic_set (&nilfs->ns_ndirtyblks,0 );init_rwsem (&nilfs->ns_sem); +mutex_init (&nilfs->ns_snapshot_mount_mutex);INIT_LIST_HEAD (&nilfs->ns_dirty_files);INIT_LIST_HEAD (&nilfs->ns_gc_inodes);spin_lock_init (&nilfs->ns_inode_lock);
fs/nilfs2/the_nilfs.h +2 -0
@@ -47,6 +47,7 @@ enum {* @ns_flags: flags * @ns_bdev: block device * @ns_sem: semaphore for shared states +* @ns_snapshot_mount_mutex: mutex to protect snapshot mounts * @ns_sbh: buffer heads of on-disk super blocks * @ns_sbp: pointers to super block data * @ns_sbwtime: previous write time of super block
@@ -99,6 +100,7 @@ struct the_nilfs {struct block_device *ns_bdev;struct rw_semaphore ns_sem; +struct mutex ns_snapshot_mount_mutex;/* * used for
include/linux/hugetlb.h +10 -0
@@ -41,6 +41,9 @@ int follow_hugetlb_page(struct mm_struct *, struct vm_area_struct *, unsigned long *, int *, int, unsigned int flags);void unmap_hugepage_range (struct vm_area_struct *,unsigned long ,unsigned long ,struct page *); +void __unmap_hugepage_range_final (struct vm_area_struct *vma, +unsigned long start,unsigned long end, +struct page *ref_page);void __unmap_hugepage_range (struct vm_area_struct *,unsigned long ,unsigned long ,struct page *);int hugetlb_prefault (struct address_space *,struct vm_area_struct *);
@@ -99,6 +102,13 @@ static inline unsigned long hugetlb_total_pages(void)#define copy_hugetlb_page_range (src, dst, vma) ({ BUG(); 0; })#define hugetlb_prefault (mapping, vma) ({ BUG(); 0; })#define unmap_hugepage_range (vma, start, end, page) BUG() +static inline void __unmap_hugepage_range_final (struct vm_area_struct *vma, +unsigned long start,unsigned long end, +struct page *ref_page) +{ +BUG (); +} +static inline void hugetlb_report_meminfo (struct seq_file *m) { }
include/linux/init_task.h +11 -1
@@ -124,8 +124,17 @@ extern struct group_info init_groups;extern struct cred init_cred; +extern struct task_group root_task_group; + +#ifdef CONFIG_CGROUP_SCHED +# define INIT_CGROUP_SCHED (tsk) \ + .sched_task_group = &root_task_group, +#else +# define INIT_CGROUP_SCHED (tsk) +#endif +#ifdef CONFIG_PERF_EVENTS -# define INIT_PERF_EVENTS (tsk) \ +# define INIT_PERF_EVENTS (tsk) \ .perf_event_mutex = \ __MUTEX_INITIALIZER(tsk.perf_event_mutex), \ .perf_event_list = LIST_HEAD_INIT(tsk.perf_event_list),
@@ -162,6 +171,7 @@ extern struct cred init_cred; }, \ .tasks = LIST_HEAD_INIT(tsk.tasks), \ INIT_PUSHABLE_TASKS(tsk) \ +INIT_CGROUP_SCHED (tsk) \ .ptraced = LIST_HEAD_INIT(tsk.ptraced), \ .ptrace_entry = LIST_HEAD_INIT(tsk.ptrace_entry), \ .real_parent = &tsk, \
include/linux/random.h +3 -1
@@ -50,11 +50,13 @@ struct rnd_state {extern void rand_initialize_irq (int irq); +extern void add_device_randomness (const void *,unsigned int );extern void add_input_randomness (unsigned int type,unsigned int code,unsigned int value); -extern void add_interrupt_randomness (int irq); +extern void add_interrupt_randomness (int irq,int irq_flags);extern void get_random_bytes (void *buf,int nbytes); +extern void get_random_bytes_arch (void *buf,int nbytes);void generate_random_uuid (unsigned char uuid_out[16 ]);#ifndef MODULE
include/linux/sched.h +4 -1
@@ -1236,6 +1236,9 @@ struct task_struct {const struct sched_class *sched_class;struct sched_entity se;struct sched_rt_entity rt; +#ifdef CONFIG_CGROUP_SCHED +struct task_group *sched_task_group; +#endif #ifdef CONFIG_PREEMPT_NOTIFIERS /* list of struct preempt_notifier: */
@@ -2646,7 +2649,7 @@ extern int sched_group_set_rt_period(struct task_group *tg,extern long sched_group_rt_period (struct task_group *tg);extern int sched_rt_can_attach (struct task_group *tg,struct task_struct *tsk);#endif -#endif +#endif /* CONFIG_CGROUP_SCHED */ extern int task_can_switch_user (struct user_struct *up,struct task_struct *tsk);
kernel/futex.c +10 -7
@@ -2231,11 +2231,11 @@ int handle_early_requeue_pi_wakeup(struct futex_hash_bucket *hb,* @uaddr2: the pi futex we will take prior to returning to user-space * * The caller will wait on uaddr and will be requeued by futex_requeue() to -* uaddr2 which must be PI aware. Normal wakeup will wake on uaddr2 and -* complete the acquisition of the rt_mutex prior to returning to userspace. -* This ensures the rt_mutex maintains an owner when it has waiters; without -* one, the pi logic wouldn't know which task to boost/deboost, if there was a -* need to. +* uaddr2 which must be PI aware and unique from uaddr. Normal wakeup will wake +* on uaddr2 and complete the acquisition of the rt_mutex prior to returning to +* userspace. This ensures the rt_mutex maintains an owner when it has waiters; +* without one, the pi logic would not know which task to boost/deboost, if +* there was a need to. * * We call schedule in futex_wait_queue_me() when we enqueue and return there * via the following:
@@ -2272,6 +2272,9 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags,struct futex_q q = futex_q_init;int res, ret; +if (uaddr == uaddr2) +return -EINVAL ; +if (!bitset)return -EINVAL ;
@@ -2343,7 +2346,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags,* signal. futex_unlock_pi() will not destroy the lock_ptr nor * the pi_state. */ -WARN_ON (!&q.pi_state); +WARN_ON (!q.pi_state); pi_mutex = &q.pi_state->pi_mutex; ret =rt_mutex_finish_proxy_lock (pi_mutex, to, &rt_waiter,1 );debug_rt_mutex_free_waiter (&rt_waiter);
@@ -2370,7 +2373,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags,* fault, unlock the rt_mutex and return the fault to userspace. */ if (ret == -EFAULT ) { -if (rt_mutex_owner (pi_mutex) == current) +if (pi_mutex &&rt_mutex_owner (pi_mutex) == current)rt_mutex_unlock (pi_mutex); }else if (ret == -EINTR ) {/*
kernel/irq/handle.c +3 -4
@@ -117,7 +117,7 @@ irqreturn_t handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action) { irqreturn_t retval = IRQ_NONE; -unsigned int random =0 , irq = desc->irq_data.irq; +unsigned int flags =0 , irq = desc->irq_data.irq; do { irqreturn_t res;
@@ -145,7 +145,7 @@ handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action)/* Fall through to add to randomness */ case IRQ_HANDLED : - random |= action->flags; + flags |= action->flags;break ;default :
@@ -156,8 +156,7 @@ handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action) action = action->next; }while (action); -if (random &IRQF_SAMPLE_RANDOM ) -add_interrupt_randomness (irq); +add_interrupt_randomness (irq, flags);if (!noirqdebug)note_interrupt (irq, desc, retval);
kernel/sched.c +18 -14
@@ -746,22 +746,19 @@ static inline int cpu_of(struct rq *rq)/* * Return the group to which this tasks belongs. * -* We use task_subsys_state_check() and extend the RCU verification with -* pi->lock and rq->lock because cpu_cgroup_attach() holds those locks for each -* task it moves into the cgroup. Therefore by holding either of those locks, -* we pin the task to the current cgroup. +* We cannot use task_subsys_state() and friends because the cgroup +* subsystem changes that value before the cgroup_subsys::attach() method +* is called, therefore we cannot pin it and might observe the wrong value. +* +* The same is true for autogroup's p->signal->autogroup->tg, the autogroup +* core changes this before calling sched_move_task(). +* +* Instead we use a 'copy' which is updated from sched_move_task() while +* holding both task_struct::pi_lock and rq::lock. */ static inline struct task_group *task_group (struct task_struct *p) { -struct task_group *tg; -struct cgroup_subsys_state *css; - - css =task_subsys_state_check (p, cpu_cgroup_subsys_id, -lockdep_is_held (&p->pi_lock) || -lockdep_is_held (&task_rq (p)->lock)); - tg = container_of(css, struct task_group, css); - -return autogroup_task_group (p, tg); +return p->sched_task_group; }/* Change a task's cfs_rq and parent entity if it moves across CPUs/groups */
@@ -2372,7 +2369,7 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu)* a task's CPU. ->pi_lock for waking tasks, rq->lock for runnable tasks. * * sched_move_task() holds both and thus holding either pins the cgroup, -* see set_task_rq(). +* see task_group(). * * Furthermore, all task_rq users should acquire both locks, see * task_rq_lock().
@@ -8952,6 +8949,7 @@ void sched_destroy_group(struct task_group *tg)*/ void sched_move_task (struct task_struct *tsk) { +struct task_group *tg;int on_rq, running;unsigned long flags;struct rq *rq;
@@ -8966,6 +8964,12 @@ void sched_move_task(struct task_struct *tsk)if (unlikely (running)) tsk->sched_class->put_prev_task (rq, tsk); + tg =container_of (task_subsys_state_check (tsk, cpu_cgroup_subsys_id, +lockdep_is_held (&tsk->sighand->siglock)), + struct task_group, css); + tg =autogroup_task_group (tsk, tg); + tsk->sched_task_group = tg; +#ifdef CONFIG_FAIR_GROUP_SCHED if (tsk->sched_class->task_move_group) tsk->sched_class->task_move_group (tsk, on_rq);
lib/vsprintf.c +2 -1
@@ -886,7 +886,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,* %pK cannot be used in IRQ context because its test * for CAP_SYSLOG would be meaningless. */ -if (in_irq () ||in_serving_softirq () ||in_nmi ()) { +if (kptr_restrict && (in_irq () ||in_serving_softirq () || +in_nmi ())) {if (spec.field_width ==-1 ) spec.field_width =2 *sizeof (void *);return string (buf, end,"pK-error" , spec);
mm/hugetlb.c +26 -2
@@ -2382,6 +2382,25 @@ void __unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start, } } +void __unmap_hugepage_range_final (struct vm_area_struct *vma, +unsigned long start,unsigned long end, +struct page *ref_page) +{ +__unmap_hugepage_range (vma, start, end, ref_page); + +/* +* Clear this flag so that x86's huge_pmd_share page_table_shareable +* test will fail on a vma being torn down, and not grab a page table +* on its way out. We're lucky that the flag has such an appropriate +* name, and can in fact be safely cleared here. We could clear it +* before the __unmap_hugepage_range above, but all that's necessary +* is to clear it before releasing the i_mmap_mutex. This works +* because in the context this is called, the VMA is about to be +* destroyed and the i_mmap_mutex is held. +*/ + vma->vm_flags &= ~VM_MAYSHARE ; +} +void unmap_hugepage_range (struct vm_area_struct *vma,unsigned long start,unsigned long end,struct page *ref_page) {
@@ -2939,9 +2958,14 @@ void hugetlb_change_protection(struct vm_area_struct *vma, } }spin_unlock (&mm->page_table_lock); -mutex_unlock (&vma->vm_file->f_mapping->i_mmap_mutex); - +/* +* Must flush TLB before releasing i_mmap_mutex: x86's huge_pmd_unshare +* may have cleared our pud entry and done put_page on the page table: +* once we release i_mmap_mutex, another task can do the final put_page +* and that page table be reused and filled with junk. +*/ flush_tlb_range (vma, start, end); +mutex_unlock (&vma->vm_file->f_mapping->i_mmap_mutex); } int hugetlb_reserve_pages(struct inode *inode,
mm/internal.h +2 -0
@@ -309,3 +309,5 @@ extern u64 hwpoison_filter_flags_mask;extern u64 hwpoison_filter_flags_value;extern u64 hwpoison_filter_memcg;extern u32 hwpoison_filter_enable; + +extern void set_pageblock_order (void );
mm/memory.c +5 -2
@@ -1358,8 +1358,11 @@ unsigned long unmap_vmas(struct mmu_gather *tlb,* Since no pte has actually been setup, it is * safe to do nothing in this case. */ -if (vma->vm_file) -unmap_hugepage_range (vma, start, end,NULL ); +if (vma->vm_file) { +mutex_lock (&vma->vm_file->f_mapping->i_mmap_mutex); +__unmap_hugepage_range_final (vma, start, end,NULL ); +mutex_unlock (&vma->vm_file->f_mapping->i_mmap_mutex); + } start = end; }else
mm/mmu_notifier.c +23 -22
76 lines not on this page · raw message
mm/page_alloc.c +15 -18
@@ -4281,25 +4281,24 @@ static inline void setup_usemap(struct pglist_data *pgdat,#ifdef CONFIG_HUGETLB_PAGE_SIZE_VARIABLE -/* Return a sensible default order for the pageblock size. */ -static inline int pageblock_default_order (void ) -{ -if (HPAGE_SHIFT >PAGE_SHIFT ) -return HUGETLB_PAGE_ORDER ; - -return MAX_ORDER -1 ; -} -/* Initialise the number of pages represented by NR_PAGEBLOCK_BITS */ -static inline void __init set_pageblock_order (unsigned int order) +void __init set_pageblock_order (void ) { +unsigned int order; +/* Check that pageblock_nr_pages has not already been setup */ if (pageblock_order)return ; +if (HPAGE_SHIFT >PAGE_SHIFT ) + order =HUGETLB_PAGE_ORDER ; +else + order =MAX_ORDER -1 ; +/* * Assume the largest contiguous order of interest is a huge page. -* This value may be variable depending on boot parameters on IA64 +* This value may be variable depending on boot parameters on IA64 and +* powerpc. */ pageblock_order = order; }
@@ -4307,15 +4306,13 @@ static inline void __init set_pageblock_order(unsigned int order)/* * When CONFIG_HUGETLB_PAGE_SIZE_VARIABLE is not set, set_pageblock_order() -* and pageblock_default_order() are unused as pageblock_order is set -* at compile-time. See include/linux/pageblock-flags.h for the values of -* pageblock_order based on the kernel config +* is unused as pageblock_order is set at compile-time. See +* include/linux/pageblock-flags.h for the values of pageblock_order based on +* the kernel config */ -static inline int pageblock_default_order (unsigned int order) +void __init set_pageblock_order (void ) { -return MAX_ORDER -1 ; } -#define set_pageblock_order (x) do {} while (0)#endif /* CONFIG_HUGETLB_PAGE_SIZE_VARIABLE */
@@ -4403,7 +4400,7 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat,if (!size)continue ; -set_pageblock_order (pageblock_default_order ()); +set_pageblock_order ();setup_usemap (pgdat, zone, size); ret =init_currently_empty_zone (zone, zone_start_pfn, size,MEMMAP_EARLY );
mm/sparse.c +3 -0
@@ -486,6 +486,9 @@ void __init sparse_init(void)struct page **map_map;#endif +/* Setup pageblock_order for HUGETLB_PAGE_SIZE_VARIABLE */ +set_pageblock_order (); +/* * map is using big page (aka 2M in x86 64 bit) * usemap is less one page (aka 24 bytes)
net/core/dev.c +3 -0
@@ -1177,6 +1177,7 @@ static int __dev_open(struct net_device *dev)net_dmaengine_get ();dev_set_rx_mode (dev);dev_activate (dev); +add_device_randomness (dev->dev_addr, dev->addr_len); }return ret;
@@ -4841,6 +4842,7 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa) err = ops->ndo_set_mac_address (dev, sa);if (!err)call_netdevice_notifiers (NETDEV_CHANGEADDR , dev); +add_device_randomness (dev->dev_addr, dev->addr_len);return err; }EXPORT_SYMBOL (dev_set_mac_address);
@@ -5621,6 +5623,7 @@ int register_netdevice(struct net_device *dev)dev_init_scheduler (dev);dev_hold (dev);list_netdevice (dev); +add_device_randomness (dev->dev_addr, dev->addr_len);/* Notify protocols, that a new device appeared. */ ret =call_netdevice_notifiers (NETDEV_REGISTER , dev);
net/core/drop_monitor.c +59 -54
222 lines not on this page · raw message
net/core/rtnetlink.c +1 -0
@@ -1354,6 +1354,7 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm, goto errout; send_addr_notify =1 ; modified =1 ; +add_device_randomness (dev->dev_addr, dev->addr_len); }if (tb[IFLA_MTU ]) {
net/sunrpc/rpcb_clnt.c +2 -2
@@ -246,7 +246,7 @@ static int rpcb_create_local_unix(void)if (IS_ERR (clnt)) {dprintk ("RPC: failed to create AF_LOCAL rpcbind " "client (errno %ld).\n" ,PTR_ERR (clnt)); - result = -PTR_ERR (clnt); + result =PTR_ERR (clnt); goto out; }
@@ -293,7 +293,7 @@ static int rpcb_create_local_net(void)if (IS_ERR (clnt)) {dprintk ("RPC: failed to create local rpcbind " "client (errno %ld).\n" ,PTR_ERR (clnt)); - result = -PTR_ERR (clnt); + result =PTR_ERR (clnt); goto out; }
net/sunrpc/sched.c +2 -0
@@ -755,7 +755,9 @@ void rpc_execute(struct rpc_task *task)static void rpc_async_schedule (struct work_struct *work) { + current->flags |=PF_FSTRANS ; __rpc_execute(container_of(work, struct rpc_task, u.tk_work)); + current->flags &= ~PF_FSTRANS ; }/**
net/sunrpc/xprtrdma/transport.c +2 -1
@@ -200,6 +200,7 @@ xprt_rdma_connect_worker(struct work_struct *work)int rc =0 ;if (!xprt->shutdown) { + current->flags |=PF_FSTRANS ;xprt_clear_connected (xprt); dprintk("RPC: %s: %sconnect\n", __func__,
@@ -212,10 +213,10 @@ xprt_rdma_connect_worker(struct work_struct *work) out:xprt_wake_pending_tasks (xprt, rc); - out_clear:dprintk ("RPC: %s: exit\n" , __func__);xprt_clear_connecting (xprt); + current->flags &= ~PF_FSTRANS ; }/*
net/sunrpc/xprtsock.c +10 -0
@@ -1895,6 +1895,8 @@ static void xs_local_setup_socket(struct work_struct *work)if (xprt->shutdown) goto out; + current->flags |=PF_FSTRANS ; +clear_bit (XPRT_CONNECTION_ABORT , &xprt->state); status =__sock_create (xprt->xprt_net,AF_LOCAL ,SOCK_STREAM ,0 , &sock,1 );
@@ -1928,6 +1930,7 @@ static void xs_local_setup_socket(struct work_struct *work) out:xprt_clear_connecting (xprt);xprt_wake_pending_tasks (xprt, status); + current->flags &= ~PF_FSTRANS ; }static void xs_udp_finish_connecting (struct rpc_xprt *xprt,struct socket *sock)
@@ -1970,6 +1973,8 @@ static void xs_udp_setup_socket(struct work_struct *work)if (xprt->shutdown) goto out; + current->flags |=PF_FSTRANS ; +/* Start by resetting any existing state */ xs_reset_transport (transport); sock = xs_create_sock(xprt, transport,
@@ -1988,6 +1993,7 @@ static void xs_udp_setup_socket(struct work_struct *work) out:xprt_clear_connecting (xprt);xprt_wake_pending_tasks (xprt, status); + current->flags &= ~PF_FSTRANS ; }/*
@@ -2113,6 +2119,8 @@ static void xs_tcp_setup_socket(struct work_struct *work)if (xprt->shutdown) goto out; + current->flags |=PF_FSTRANS ; +if (!sock) {clear_bit (XPRT_CONNECTION_ABORT , &xprt->state); sock = xs_create_sock(xprt, transport,
@@ -2162,6 +2170,7 @@ static void xs_tcp_setup_socket(struct work_struct *work)case -EINPROGRESS :case -EALREADY :xprt_clear_connecting (xprt); + current->flags &= ~PF_FSTRANS ;return ;case -EINVAL :/* Happens, for instance, if the user specified a link
@@ -2174,6 +2183,7 @@ out_eagain: out:xprt_clear_connecting (xprt);xprt_wake_pending_tasks (xprt, status); + current->flags &= ~PF_FSTRANS ; }/**
net/wireless/util.c +3 -0
@@ -981,6 +981,9 @@ int cfg80211_can_change_interface(struct cfg80211_registered_device *rdev, }mutex_unlock (&rdev->devlist_mtx); +if (total ==1 ) +return 0 ; +for (i =0 ; i < rdev->wiphy.n_iface_combinations; i++) {const struct ieee80211_iface_combination *c;struct ieee80211_iface_limit *limits;
sound/drivers/mpu401/mpu401_uart.c +1 -0
@@ -554,6 +554,7 @@ int snd_mpu401_uart_new(struct snd_card *card, int device,spin_lock_init (&mpu->output_lock);spin_lock_init (&mpu->timer_lock); mpu->hardware = hardware; + mpu->irq =-1 ;if (! (info_flags &MPU401_INFO_INTEGRATED )) {int res_size = hardware ==MPU401_HW_PC98II ?4 :2 ; mpu->res =request_region (port, res_size,"MPU401 UART" );
sound/pci/hda/patch_realtek.c +28 -0
@@ -4809,6 +4809,15 @@ static int alc269_resume(struct hda_codec *codec) }#endif /* CONFIG_PM */ +static void alc269_fixup_pincfg_no_hp_to_lineout (struct hda_codec *codec, +const struct alc_fixup *fix,int action) +{ +struct alc_spec *spec = codec->spec; + +if (action ==ALC_FIXUP_ACT_PRE_PROBE ) + spec->parse_flags =HDA_PINCFG_NO_HP_FIXUP ; +} +static void alc269_fixup_hweq (struct hda_codec *codec,const struct alc_fixup *fix,int action) {
@@ -4909,6 +4918,8 @@ enum {ALC269_FIXUP_DMIC ,ALC269VB_FIXUP_AMIC ,ALC269VB_FIXUP_DMIC , +ALC269_FIXUP_LENOVO_DOCK , + ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT, }; static const struct alc_fixup alc269_fixups[] = {
@@ -5029,6 +5040,20 @@ static const struct alc_fixup alc269_fixups[] = { { } }, }, + [ALC269_FIXUP_LENOVO_DOCK ] = { + .type =ALC_FIXUP_PINS , + .v.pins = (const struct alc_pincfg []) { + {0x19 ,0x23a11040 },/* dock mic */ + {0x1b ,0x2121103f },/* dock headphone */ + { } + }, + .chained = true, + .chain_id =ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT + }, + [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT ] = { + .type =ALC_FIXUP_FUNC , + .v.func = alc269_fixup_pincfg_no_hp_to_lineout, + }, };static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -5051,6 +5076,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x17aa ,0x21b8 ,"Thinkpad Edge 14" ,ALC269_FIXUP_SKU_IGNORE ),SND_PCI_QUIRK (0x17aa ,0x21ca ,"Thinkpad L412" ,ALC269_FIXUP_SKU_IGNORE ),SND_PCI_QUIRK (0x17aa ,0x21e9 ,"Thinkpad Edge 15" ,ALC269_FIXUP_SKU_IGNORE ), +SND_PCI_QUIRK (0x17aa ,0x21f6 ,"Thinkpad T530" ,ALC269_FIXUP_LENOVO_DOCK ), +SND_PCI_QUIRK (0x17aa ,0x2203 ,"Thinkpad X230 Tablet" ,ALC269_FIXUP_LENOVO_DOCK ),SND_PCI_QUIRK (0x17aa ,0x3bf8 ,"Quanta FL1" ,ALC269_FIXUP_QUANTA_MUTE ),SND_PCI_QUIRK (0x17aa ,0x3bf8 ,"Lenovo Ideapd" ,ALC269_FIXUP_PCM_44K ), SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
@@ -5109,6 +5136,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {static const struct alc_model_fixup alc269_fixup_models[] = { {.id =ALC269_FIXUP_AMIC , .name ="laptop-amic" }, {.id =ALC269_FIXUP_DMIC , .name ="laptop-dmic" }, + {.id =ALC269_FIXUP_LENOVO_DOCK , .name ="lenovo-dock" }, {} };
sound/pci/hda/patch_via.c +5 -2
@@ -3227,7 +3227,7 @@ static void set_widgets_power_state_vt1718S(struct hda_codec *codec) {struct via_spec *spec = codec->spec;int imux_is_smixer; -unsigned int parm; +unsigned int parm, parm2;/* MUX6 (1eh) = stereo mixer */ imux_is_smixer =snd_hda_codec_read (codec,0x1e ,0 ,AC_VERB_GET_CONNECT_SEL ,0x00 ) ==5 ;
@@ -3250,7 +3250,7 @@ static void set_widgets_power_state_vt1718S(struct hda_codec *codec) parm =AC_PWRST_D3 ;set_pin_power_state (codec,0x27 , &parm);snd_hda_codec_write (codec,0x1a ,0 ,AC_VERB_SET_POWER_STATE , parm); -snd_hda_codec_write (codec,0xb ,0 ,AC_VERB_SET_POWER_STATE , parm); + parm2 = parm;/* for pin 0x0b */ /* PW2 (26h), AOW2 (ah) */ parm =AC_PWRST_D3 ;
@@ -3265,6 +3265,9 @@ static void set_widgets_power_state_vt1718S(struct hda_codec *codec)if (!spec->hp_independent_mode)/* check for redirected HP */ set_pin_power_state (codec,0x28 , &parm);snd_hda_codec_write (codec,0x8 ,0 ,AC_VERB_SET_POWER_STATE , parm); +if (!spec->hp_independent_mode && parm2 !=AC_PWRST_D3 ) + parm = parm2; +snd_hda_codec_write (codec,0xb ,0 ,AC_VERB_SET_POWER_STATE , parm);/* MW9 (21h), Mw2 (1ah), AOW0 (8h) */ snd_hda_codec_write (codec,0x21 ,0 ,AC_VERB_SET_POWER_STATE , imux_is_smixer ?AC_PWRST_D0 : parm);
sound/soc/codecs/wm8962.c +3 -0
@@ -3105,6 +3105,9 @@ static int wm8962_set_bias_level(struct snd_soc_codec *codec,/* VMID 2*250k */ snd_soc_update_bits (codec,WM8962_PWR_MGMT_1 ,WM8962_VMID_SEL_MASK ,0x100 ); + +if (codec->dapm.bias_level ==SND_SOC_BIAS_OFF ) +msleep (100 );break ;case SND_SOC_BIAS_OFF :
sound/soc/codecs/wm8994.c +1 -1
@@ -2508,7 +2508,7 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream,return -EINVAL ; } - bclk_rate =params_rate (params) *2 ; + bclk_rate =params_rate (params) *4 ;switch (params_format (params)) {case SNDRV_PCM_FORMAT_S16_LE : bclk_rate *=16 ;
sound/usb/clock.c +2 -1
@@ -111,7 +111,8 @@ static bool uac_clock_source_is_valid(struct snd_usb_audio *chip, int source_id)return 0 ;/* If a clock source can't tell us whether it's valid, we assume it is */ -if (!uac2_control_is_readable (cs_desc->bmControls,UAC2_CS_CONTROL_CLOCK_VALID )) +if (!uac2_control_is_readable (cs_desc->bmControls, +UAC2_CS_CONTROL_CLOCK_VALID -1 ))return 1 ; err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR,
PATCH 64/70 drop_monitor: fix sleeping in invalid context warning
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Neil Horman <[email protected]>
commit cde2e9a651b76d8db36ae94cd0febc82b637e5dd upstream.
Eric Dumazet pointed out this warning in the drop_monitor protocol to me:
[ 38.352571] BUG: sleeping function called from invalid context at kernel/mutex.c:85 [ 38.352576] in_atomic(): 1, irqs_disabled(): 0, pid: 4415, name: dropwatch [ 38.352580] Pid: 4415, comm: dropwatch Not tainted 3.4.0-rc2+ #71 [ 38.352582] Call Trace: [ 38.352592] [<ffffffff8153aaf0>] ? trace_napi_poll_hit+0xd0/0xd0 [ 38.352599] [<ffffffff81063f2a>] __might_sleep+0xca/0xf0 [ 38.352606] [<ffffffff81655b16>] mutex_lock+0x26/0x50 [ 38.352610] [<ffffffff8153aaf0>] ? trace_napi_poll_hit+0xd0/0xd0 [ 38.352616] [<ffffffff810b72d9>] tracepoint_probe_register+0x29/0x90 [ 38.352621] [<ffffffff8153a585>] set_all_monitor_traces+0x105/0x170 [ 38.352625] [<ffffffff8153a8ca>] net_dm_cmd_trace+0x2a/0x40 [ 38.352630] [<ffffffff8154a81a>] genl_rcv_msg+0x21a/0x2b0 [ 38.352636] [<ffffffff810f8029>] ? zone_statistics+0x99/0xc0 [ 38.352640] [<ffffffff8154a600>] ? genl_rcv+0x30/0x30 [ 38.352645] [<ffffffff8154a059>] netlink_rcv_skb+0xa9/0xd0 [ 38.352649] [<ffffffff8154a5f0>] genl_rcv+0x20/0x30 [ 38.352653] [<ffffffff81549a7e>] netlink_unicast+0x1ae/0x1f0 [ 38.352658] [<ffffffff81549d76>] netlink_sendmsg+0x2b6/0x310 [ 38.352663] [<ffffffff8150824f>] sock_sendmsg+0x10f/0x130 [ 38.352668] [<ffffffff8150abe0>] ? move_addr_to_kernel+0x60/0xb0 [ 38.352673] [<ffffffff81515f04>] ? verify_iovec+0x64/0xe0 [ 38.352677] [<ffffffff81509c46>] __sys_sendmsg+0x386/0x390 [ 38.352682] [<ffffffff810ffaf9>] ? handle_mm_fault+0x139/0x210 [ 38.352687] [<ffffffff8165b5bc>] ? do_page_fault+0x1ec/0x4f0 [ 38.352693] [<ffffffff8106ba4d>] ? set_next_entity+0x9d/0xb0 [ 38.352699] [<ffffffff81310b49>] ? tty_ldisc_deref+0x9/0x10 [ 38.352703] [<ffffffff8106d363>] ? pick_next_task_fair+0x63/0x140 [ 38.352708] [<ffffffff8150b8d4>] sys_sendmsg+0x44/0x80 [ 38.352713] [<ffffffff8165f8e2>] system_call_fastpath+0x16/0x1b
It stems from holding a spinlock (trace_state_lock) while attempting to register or unregister tracepoint hooks, making in_atomic() true in this context, leading to the warning when the tracepoint calls might_sleep() while its taking a mutex. Since we only use the trace_state_lock to prevent trace protocol state races, as well as hardware stat list updates on an rcu write side, we can just convert the spinlock to a mutex to avoid this problem.
--- net/core/drop_monitor.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
net/core/drop_monitor.c +7 -7
@@ -42,7 +42,7 @@ static void send_dm_alert(struct work_struct *unused);* netlink alerts */ static int trace_state =TRACE_OFF ; -static DEFINE_SPINLOCK (trace_state_lock); +static DEFINE_MUTEX (trace_state_mutex);struct per_cpu_dm_data {struct work_struct dm_alert_work;
@@ -214,7 +214,7 @@ static int set_all_monitor_traces(int state)struct dm_hw_stat_delta *new_stat =NULL ;struct dm_hw_stat_delta *temp; -spin_lock (&trace_state_lock); +mutex_lock (&trace_state_mutex);if (state == trace_state) { rc = -EAGAIN ;
@@ -253,7 +253,7 @@ static int set_all_monitor_traces(int state) rc = -EINPROGRESS ; out_unlock: -spin_unlock (&trace_state_lock); +mutex_unlock (&trace_state_mutex);return rc; }
@@ -296,12 +296,12 @@ static int dropmon_net_event(struct notifier_block *ev_block, new_stat->dev = dev; new_stat->last_rx = jiffies; -spin_lock (&trace_state_lock); +mutex_lock (&trace_state_mutex);list_add_rcu (&new_stat->list, &hw_stats_list); -spin_unlock (&trace_state_lock); +mutex_unlock (&trace_state_mutex);break ;case NETDEV_UNREGISTER : -spin_lock (&trace_state_lock); +mutex_lock (&trace_state_mutex);list_for_each_entry_safe (new_stat, tmp, &hw_stats_list, list) {if (new_stat->dev == dev) { new_stat->dev =NULL ;
@@ -312,7 +312,7 @@ static int dropmon_net_event(struct notifier_block *ev_block, } } } -spin_unlock (&trace_state_lock); +mutex_unlock (&trace_state_mutex);break ; } out:
PATCH 60/70 ore: Fix out-of-bounds access in _ios_obj()
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boaz Harrosh <[email protected]>
commit 9e62bb4458ad2cf28bd701aa5fab380b846db326 upstream.
_ios_obj() is accessed by group_index not device_table index.
The oc->comps array is only a group_full of devices at a time it is not like ore_comp_dev() which is indexed by a global device_table index.
This did not BUG until now because exofs only uses a single COMP for all devices. But with other FSs like PanFS this is not true.
This bug was only in the write_path, all other users were using it correctly
[This is a bug since 3.2 Kernel]
--- fs/exofs/ore.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
fs/exofs/ore.c +7 -7
@@ -837,11 +837,11 @@ static int _write_mirror(struct ore_io_state *ios, int cur_comp) bio->bi_rw |=REQ_WRITE ; } -osd_req_write (or,_ios_obj (ios, dev), per_dev->offset, - bio, per_dev->length); +osd_req_write (or,_ios_obj (ios, cur_comp), + per_dev->offset, bio, per_dev->length);ORE_DBGMSG ("write(0x%llx) offset=0x%llx " "length=0x%llx dev=%d\n" , -_LLU (_ios_obj (ios, dev)->id), +_LLU (_ios_obj (ios, cur_comp)->id),_LLU (per_dev->offset),_LLU (per_dev->length), dev); }else if (ios->kern_buff) {
@@ -853,20 +853,20 @@ static int _write_mirror(struct ore_io_state *ios, int cur_comp) (ios->si.unit_off + ios->length > ios->layout->stripe_unit)); - ret =osd_req_write_kern (or,_ios_obj (ios, per_dev->dev), + ret =osd_req_write_kern (or,_ios_obj (ios, cur_comp), per_dev->offset, ios->kern_buff, ios->length);if (unlikely (ret)) goto out;ORE_DBGMSG2 ("write_kern(0x%llx) offset=0x%llx " "length=0x%llx dev=%d\n" , -_LLU (_ios_obj (ios, dev)->id), +_LLU (_ios_obj (ios, cur_comp)->id),_LLU (per_dev->offset),_LLU (ios->length), per_dev->dev); }else { -osd_req_set_attributes (or,_ios_obj (ios, dev)); +osd_req_set_attributes (or,_ios_obj (ios, cur_comp));ORE_DBGMSG2 ("obj(0x%llx) set_attributes=%d dev=%d\n" , -_LLU (_ios_obj (ios, dev)->id), +_LLU (_ios_obj (ios, cur_comp)->id), ios->out_attr_len, dev); }
PATCH 11/70 random: Use arch_get_random_int instead of cycle counter if avail
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <[email protected]>
commit cf833d0b9937874b50ef2867c4e8badfd64948ce upstream.
We still don't use rdrand in /dev/random, which just seems stupid. We accept the *cycle*counter* as a random input, but we don't accept rdrand? That's just broken.
Sure, people can do things in user space (write to /dev/random, use rdrand in addition to /dev/random themselves etc etc), but that *still* seems to be a particularly stupid reason for saying "we shouldn't bother to try to do better in /dev/random".
And even if somebody really doesn't trust rdrand as a source of random bytes, it seems singularly stupid to trust the cycle counter *more*.
So I'd suggest the attached patch. I'm not going to even bother arguing that we should add more bits to the entropy estimate, because that's not the point - I don't care if /dev/random fills up slowly or not, I think it's just stupid to not use the bits we can get from rdrand and mix them into the strong randomness pool.
--- drivers/char/random.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/char/random.c +6 -2
@@ -624,8 +624,8 @@ static struct timer_rand_state input_timer_state;static void add_timer_randomness (struct timer_rand_state *state,unsigned num) {struct { -cycles_t cycles;long jiffies; +unsigned cycles;unsigned num; } sample;long delta, delta2, delta3;
@@ -637,7 +637,11 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num) goto out; sample.jiffies = jiffies; - sample.cycles =get_cycles (); + +/* Use arch random value, fall back to cycles */ +if (!arch_get_random_int (&sample.cycles)) + sample.cycles =get_cycles (); + sample.num = num;mix_pool_bytes (&input_pool, &sample,sizeof (sample));
PATCH 52/70 USB: echi-dbgp: increase the controller wait time to come out of halt.
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Colin Ian King <[email protected]>
commit f96a4216e85050c0a9d41a41ecb0ae9d8e39b509 upstream.
The default 10 microsecond delay for the controller to come out of halt in dbgp_ehci_startup is too short, so increase it to 1 millisecond.
This is based on emperical testing on various USB debug ports on modern machines such as a Lenovo X220i and an Ivybridge development platform that needed to wait ~450-950 microseconds.
--- drivers/usb/early/ehci-dbgp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/early/ehci-dbgp.c +1 -1
@@ -450,7 +450,7 @@ static int dbgp_ehci_startup(void)writel (FLAG_CF , &ehci_regs->configured_flag);/* Wait until the controller is no longer halted */ - loop =10 ; + loop =1000 ; do { status = readl(&ehci_regs->status); if (!(status & STS_HALT))
PATCH 62/70 drm/i915: prefer wide & slow to fast & narrow in DP configs
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jesse Barnes <[email protected]>
commit 2514bc510d0c3aadcc5204056bb440fa36845147 upstream.
High frequency link configurations have the potential to cause trouble with long and/or cheap cables, so prefer slow and wide configurations instead. This patch has the potential to cause trouble for eDP configurations that lie about available lanes, so if we run into that we can make it conditional on eDP.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=45801
--- drivers/gpu/drm/i915/intel_dp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +2 -2
@@ -708,8 +708,8 @@ intel_dp_mode_fixup(struct drm_encoder * bpp = adjusted_mode->private_flags &INTEL_MODE_DP_FORCE_6BPC ?18 :24 ; -for (lane_count =1 ; lane_count <= max_lane_count; lane_count <<=1 ) { -for (clock =0 ; clock <= max_clock; clock++) { +for (clock =0 ; clock <= max_clock; clock++) { +for (lane_count =1 ; lane_count <= max_lane_count; lane_count <<=1 ) {int link_avail =intel_dp_max_data_rate (intel_dp_link_clock (bws[clock]), lane_count); if (intel_dp_link_required(mode->clock, bpp)
PATCH 70/70 pch_uart: Fix parity setting issue
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomoya MORINAGA <[email protected]>
commit 38bd2a1ac736901d1cf4971c78ef952ba92ef78b upstream.
Parity Setting value is reverse.
E.G. In case of setting ODD parity, EVEN value is set. This patch inverts "if" condition.
--- drivers/tty/serial/pch_uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/pch_uart.c +1 -1
@@ -1368,7 +1368,7 @@ static void pch_uart_set_termios(struct uart_port *port, stb =PCH_UART_HAL_STB1 ;if (termios->c_cflag &PARENB ) { -if (!(termios->c_cflag &PARODD )) +if (termios->c_cflag &PARODD ) parity =PCH_UART_HAL_PARITY_ODD ;else parity =PCH_UART_HAL_PARITY_EVEN ;
PATCH 3/70 xen: mark local pages as FOREIGN in the m2p_override
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefano Stabellini <[email protected]>
commit b9e0d95c041ca2d7ad297ee37c2e9cfab67a188f upstream.
When the frontend and the backend reside on the same domain, even if we add pages to the m2p_override, these pages will never be returned by mfn_to_pfn because the check "get_phys_to_machine(pfn) != mfn" will always fail, so the pfn of the frontend will be returned instead (resulting in a deadlock because the frontend pages are already locked).
INFO: task qemu-system-i38:1085 blocked for more than 120 seconds.
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
qemu-system-i38 D ffff8800cfc137c0 0 1085 1 0x00000000
ffff8800c47ed898 0000000000000282 ffff8800be4596b0 00000000000137c0 ffff8800c47edfd8 ffff8800c47ec010 00000000000137c0 00000000000137c0 ffff8800c47edfd8 00000000000137c0 ffffffff82213020 ffff8800be4596b0
Call Trace: [<ffffffff81101ee0>] ? __lock_page+0x70/0x70 [<ffffffff81a0fdd9>] schedule+0x29/0x70 [<ffffffff81a0fe80>] io_schedule+0x60/0x80 [<ffffffff81101eee>] sleep_on_page+0xe/0x20 [<ffffffff81a0e1ca>] __wait_on_bit_lock+0x5a/0xc0 [<ffffffff81101ed7>] __lock_page+0x67/0x70 [<ffffffff8106f750>] ? autoremove_wake_function+0x40/0x40 [<ffffffff811867e6>] ? bio_add_page+0x36/0x40 [<ffffffff8110b692>] set_page_dirty_lock+0x52/0x60 [<ffffffff81186021>] bio_set_pages_dirty+0x51/0x70 [<ffffffff8118c6b4>] do_blockdev_direct_IO+0xb24/0xeb0 [<ffffffff811e71a0>] ? ext3_get_blocks_handle+0xe00/0xe00 [<ffffffff8118ca95>] __blockdev_direct_IO+0x55/0x60 [<ffffffff811e71a0>] ? ext3_get_blocks_handle+0xe00/0xe00 [<ffffffff811e91c8>] ext3_direct_IO+0xf8/0x390 [<ffffffff811e71a0>] ? ext3_get_blocks_handle+0xe00/0xe00 [<ffffffff81004b60>] ? xen_mc_flush+0xb0/0x1b0 [<ffffffff81104027>] generic_file_aio_read+0x737/0x780 [<ffffffff813bedeb>] ? gnttab_map_refs+0x15b/0x1e0 [<ffffffff811038f0>] ? find_get_pages+0x150/0x150 [<ffffffff8119736c>] aio_rw_vect_retry+0x7c/0x1d0 [<ffffffff811972f0>] ? lookup_ioctx+0x90/0x90 [<ffffffff81198856>] aio_run_iocb+0x66/0x1a0 [<ffffffff811998b8>] do_io_submit+0x708/0xb90 [<ffffffff81199d50>] sys_io_submit+0x10/0x20 [<ffffffff81a18d69>] system_call_fastpath+0x16/0x1b
The explanation is in the comment within the code:
We need to do this because the pages shared by the frontend (xen-blkfront) can be already locked (lock_page, called by do_read_cache_page); when the userspace backend tries to use them with direct_IO, mfn_to_pfn returns the pfn of the frontend, so do_blockdev_direct_IO is going to try to lock the same pages again resulting in a deadlock.
A simplified call graph looks like this:
pygrub QEMU
-----------------------------------------------do_read_cache_page io_submit
| |
lock_page ext3_direct_IO
|
bio_add_page
|
lock_pageInternally the xen-blkback uses m2p_add_override to swizzle (temporarily) a 'struct page' to have a different MFN (so that it can point to another guest). It also can easily find out whether another pfn corresponding to the mfn exists in the m2p, and can set the FOREIGN bit
in the p2m, making sure that mfn_to_pfn returns the pfn of the backend.
This allows the backend to perform direct_IO on these pages, but as a side effect prevents the frontend from using get_user_pages_fast on them while they are being shared with the backend.
--- arch/x86/xen/p2m.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
arch/x86/xen/p2m.c +36 -0
@@ -706,6 +706,7 @@ int m2p_add_override(unsigned long mfn, struct page *page,unsigned long uninitialized_var (address );unsigned level;pte_t *ptep =NULL ; +int ret =0 ; pfn =page_to_pfn (page);if (!PageHighMem (page)) {
@@ -741,6 +742,24 @@ int m2p_add_override(unsigned long mfn, struct page *page,list_add (&page->lru, &m2p_overrides[mfn_hash (mfn)]);spin_unlock_irqrestore (&m2p_override_lock, flags); +/* p2m(m2p(mfn)) == mfn: the mfn is already present somewhere in +* this domain. Set the FOREIGN_FRAME_BIT in the p2m for the other +* pfn so that the following mfn_to_pfn(mfn) calls will return the +* pfn from the m2p_override (the backend pfn) instead. +* We need to do this because the pages shared by the frontend +* (xen-blkfront) can be already locked (lock_page, called by +* do_read_cache_page); when the userspace backend tries to use them +* with direct_IO, mfn_to_pfn returns the pfn of the frontend, so +* do_blockdev_direct_IO is going to try to lock the same pages +* again resulting in a deadlock. +* As a side effect get_user_pages_fast might not be safe on the +* frontend pages while they are being shared with the backend, +* because mfn_to_pfn (that ends up being called by GUPF) will +* return the backend pfn rather than the frontend pfn. */ + ret =__get_user (pfn, &machine_to_phys_mapping[mfn]); +if (ret ==0 &&get_phys_to_machine (pfn) == mfn) +set_phys_to_machine (pfn,FOREIGN_FRAME (mfn)); +return 0 ; }EXPORT_SYMBOL_GPL (m2p_add_override);
@@ -752,6 +771,7 @@ int m2p_remove_override(struct page *page, bool clear_pte)unsigned long uninitialized_var (address );unsigned level;pte_t *ptep =NULL ; +int ret =0 ; pfn =page_to_pfn (page); mfn =get_phys_to_machine (pfn);
@@ -821,6 +841,22 @@ int m2p_remove_override(struct page *page, bool clear_pte) }else set_phys_to_machine (pfn, page->index); +/* p2m(m2p(mfn)) == FOREIGN_FRAME(mfn): the mfn is already present +* somewhere in this domain, even before being added to the +* m2p_override (see comment above in m2p_add_override). +* If there are no other entries in the m2p_override corresponding +* to this mfn, then remove the FOREIGN_FRAME_BIT from the p2m for +* the original pfn (the one shared by the frontend): the backend +* cannot do any IO on this page anymore because it has been +* unshared. Removing the FOREIGN_FRAME_BIT from the p2m entry of +* the original pfn causes mfn_to_pfn(mfn) to return the frontend +* pfn again. */ + mfn &= ~FOREIGN_FRAME_BIT ; + ret =__get_user (pfn, &machine_to_phys_mapping[mfn]); +if (ret ==0 &&get_phys_to_machine (pfn) ==FOREIGN_FRAME (mfn) && +m2p_find_override (mfn) ==NULL ) +set_phys_to_machine (pfn, mfn); +return 0 ; }EXPORT_SYMBOL_GPL (m2p_remove_override);
PATCH 8/70 m68k: Correct the Atari ALLOWINT definition
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikael Pettersson <[email protected]>
commit c663600584a596b5e66258cc10716fb781a5c2c9 upstream.
Booting a 3.2, 3.3, or 3.4-rc4 kernel on an Atari using the `nfeth' ethernet device triggers a WARN_ONCE() in generic irq handling code on the first irq for that device:
WARNING: at kernel/irq/handle.c:146 handle_irq_event_percpu+0x134/0x142() irq 3 handler nfeth_interrupt+0x0/0x194 enabled interrupts Modules linked in: Call Trace: [<000299b2>] warn_slowpath_common+0x48/0x6a [<000299c0>] warn_slowpath_common+0x56/0x6a [<00029a4c>] warn_slowpath_fmt+0x2a/0x32 [<0005b34c>] handle_irq_event_percpu+0x134/0x142 [<0005b34c>] handle_irq_event_percpu+0x134/0x142 [<0000a584>] nfeth_interrupt+0x0/0x194 [<001ba0a8>] schedule_preempt_disabled+0x0/0xc [<0005b37a>] handle_irq_event+0x20/0x2c [<0005add4>] generic_handle_irq+0x2c/0x3a [<00002ab6>] do_IRQ+0x20/0x32 [<0000289e>] auto_irqhandler_fixup+0x4/0x6 [<00003144>] cpu_idle+0x22/0x2e [<001b8a78>] printk+0x0/0x18 [<0024d112>] start_kernel+0x37a/0x386 [<0003021d>] __do_proc_dointvec+0xb1/0x366 [<0003021d>] __do_proc_dointvec+0xb1/0x366 [<0024c31e>] _sinittext+0x31e/0x9c0
After invoking the irq's handler the kernel sees !irqs_disabled() and concludes that the handler erroneously enabled interrupts.
However, debugging shows that !irqs_disabled() is true even before the handler is invoked, which indicates a problem in the platform code rather than the specific driver.
The warning does not occur in 3.1 or older kernels.
It turns out that the ALLOWINT definition for Atari is incorrect.
The Atari definition of ALLOWINT is ~0x400, the stated purpose of that is to avoid taking HSYNC interrupts. irqs_disabled() returns true if the 3-bit ipl & 4 is non-zero. The nfeth interrupt runs at ipl 3 (it's autovector 3), but 3 & 4 is zero so irqs_disabled() is false, and the warning above is generated.
When interrupts are explicitly disabled, ipl is set to 7. When they are enabled, ipl is masked with ALLOWINT. On Atari this will result in ipl = 3, which blocks interrupts at ipl 3 and below. So how come nfeth interrupts at ipl 3 are received at all? That's because ipl is reset to 2 by Atari-specific code in default_idle(), again with the stated purpose of blocking HSYNC interrupts. This discrepancy means that ipl 3 can remain blocked for longer than intended.
Both default_idle() and falcon_hblhandler() identify HSYNC with ipl 2, and the "Atari ST/.../F030 Hardware Register Listing" agrees, but ALLOWINT is defined as if HSYNC was ipl 3.
[As an experiment I modified default_idle() to reset ipl to 3, and as expected that resulted in all nfeth interrupts being blocked.]
The fix is simple: define ALLOWINT as ~0x500 instead. This makes arch_local_irq_enable() consistent with default_idle(), and prevents the !irqs_disabled() problems for ipl 3 interrupts.
Tested on Atari running in an Aranym VM.
--- arch/m68k/include/asm/entry.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/m68k/include/asm/entry.h +2 -2
@@ -33,8 +33,8 @@/* the following macro is used when enabling interrupts */ #if defined(MACH_ATARI_ONLY ) -/* block out HSYNC on the atari */ -#define ALLOWINT (~0x400) +/* block out HSYNC = ipl 2 on the atari */ +#define ALLOWINT (~0x500)#define MAX_NOINT_IPL 3#else /* portable version */
PATCH 5/70 stable: update references to older 2.6 versions for 3.x
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Gortmaker <[email protected]>
commit 2584f5212d97b664be250ad5700a2d0fee31a10d upstream.
Also add information on where the respective trees are.
--- Documentation/stable_kernel_rules.txt | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
Documentation/stable_kernel_rules.txt +14 -5
@@ -1,4 +1,4 @@ -Everything you ever wanted to know about Linux 2.6 -stable releases. +Everything you ever wanted to know about Linux -stable releases. Rules on what kind of patches are accepted, and which ones are not, into the "-stable" tree:
@@ -36,10 +36,10 @@ Procedure for submitting patches to the -stable tree: cherry-picked than this can be specified in the following format in the sign-off area: - Cc: <[email protected]> # .32.x: a1f84a3: sched: Check for idle - Cc: <[email protected]> # .32.x: 1b9508f: sched: Rate-limit newidle - Cc: <[email protected]> # .32.x: fd21073: sched: Fix affinity logic - Cc: <[email protected]> # .32.x + Cc: <[email protected]> # 3.3.x: a1f84a3: sched: Check for idle + Cc: <[email protected]> # 3.3.x: 1b9508f: sched: Rate-limit newidle + Cc: <[email protected]> # 3.3.x: fd21073: sched: Fix affinity logic + Cc: <[email protected]> # 3.3.x Signed-off-by: Ingo Molnar <[email protected]> The tag sequence has the meaning of:
@@ -73,6 +73,15 @@ Review cycle: security kernel team, and not go through the normal review cycle. Contact the kernel security team for more details on this procedure. +Trees: + + - The queues of patches, for both completed versions and in progress + versions can be found at: + http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git + - The finalized and tagged releases of all stable kernels can be found + in separate branches per version at: + http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git + Review committee:
PATCH 16/70 random: create add_device_randomness() interface
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <[email protected]>
commit a2080a67abe9e314f9e9c2cc3a4a176e8a8f8793 upstream.
Add a new interface, add_device_randomness() for adding data to the random pool that is likely to differ between two devices (or possibly even per boot). This would be things like MAC addresses or serial numbers, or the read-out of the RTC. This does *not* add any actual entropy to the pool, but it initializes the pool to different values for devices that might otherwise be identical and have very little entropy available to them (particularly common in the embedded world).
[ Modified by tytso to mix in a timestamp, since there may be some
variability caused by the time needed to detect/configure the hardware in question. ]
--- drivers/char/random.c | 28 ++++++++++++++++++++++++++++ include/linux/random.h | 1 + 2 files changed, 29 insertions(+)
drivers/char/random.c +28 -0
@@ -125,11 +125,20 @@* The current exported interfaces for gathering environmental noise * from the devices are: * +* void add_device_randomness(const void *buf, unsigned int size); * void add_input_randomness(unsigned int type, unsigned int code, * unsigned int value); * void add_interrupt_randomness(int irq, int irq_flags); * void add_disk_randomness(struct gendisk *disk); * +* add_device_randomness() is for adding data to the random pool that +* is likely to differ between two devices (or possibly even per boot). +* This would be things like MAC addresses or serial numbers, or the +* read-out of the RTC. This does *not* add any actual entropy to the +* pool, but it initializes the pool to different values for devices +* that might otherwise be identical and have very little entropy +* available to them (particularly common in the embedded world). +* * add_input_randomness() uses the input layer interrupt timing, as well as * the event type information from the hardware. *
@@ -646,6 +655,25 @@ static void set_timer_rand_state(unsigned int irq, }#endif +/* +* Add device- or boot-specific data to the input and nonblocking +* pools to help initialize them to unique values. +* +* None of this adds any entropy, it is meant to avoid the +* problem of the nonblocking pool having similar initial state +* across largely identical devices. +*/ +void add_device_randomness (const void *buf,unsigned int size) +{ +unsigned long time =get_cycles () ^ jiffies; + +mix_pool_bytes (&input_pool, buf, size,NULL ); +mix_pool_bytes (&input_pool, &time,sizeof (time),NULL ); +mix_pool_bytes (&nonblocking_pool, buf, size,NULL ); +mix_pool_bytes (&nonblocking_pool, &time,sizeof (time),NULL ); +} +EXPORT_SYMBOL (add_device_randomness); +static struct timer_rand_state input_timer_state;/*
include/linux/random.h +1 -0
@@ -50,6 +50,7 @@ struct rnd_state {extern void rand_initialize_irq (int irq); +extern void add_device_randomness (const void *,unsigned int );extern void add_input_randomness (unsigned int type,unsigned int code,unsigned int value);extern void add_interrupt_randomness (int irq,int irq_flags);
PATCH 13/70 random: Adjust the number of loops when initializing
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: "H. Peter Anvin" <[email protected]>
commit 2dac8e54f988ab58525505d7ef982493374433c3 upstream.
When we are initializing using arch_get_random_long() we only need to loop enough times to touch all the bytes in the buffer; using poolwords for that does twice the number of operations necessary on a 64-bit machine, since in the random number generator code "word" means 32 bits.
--- drivers/char/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/random.c +1 -1
@@ -975,7 +975,7 @@ static void init_std_data(struct entropy_store *r) now =ktime_get_real ();mix_pool_bytes (r, &now,sizeof (now)); -for (i = r->poolinfo->poolwords; i; i--) { +for (i = r->poolinfo->POOLBYTES; i >0 ; i -=sizeof flags) {if (!arch_get_random_long (&flags))break ;mix_pool_bytes (r, &flags,sizeof (flags));
PATCH 17/70 usb: feed USB device information to the /dev/random driver
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
commit b04b3156a20d395a7faa8eed98698d1e17a36000 upstream.
Send the USB device's serial, product, and manufacturer strings to the /dev/random driver to help seed its pools.
--- drivers/usb/core/hub.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/usb/core/hub.c +9 -0
@@ -24,6 +24,7 @@#include <linux/kthread.h> #include <linux/mutex.h> #include <linux/freezer.h> +#include <linux/random.h> #include <asm/uaccess.h> #include <asm/byteorder.h>
@@ -1897,6 +1898,14 @@ int usb_new_device(struct usb_device *ud/* Tell the world! */ announce_device (udev); +if (udev->serial) +add_device_randomness (udev->serial,strlen (udev->serial)); +if (udev->product) +add_device_randomness (udev->product,strlen (udev->product)); +if (udev->manufacturer) +add_device_randomness (udev->manufacturer, +strlen (udev->manufacturer)); +device_enable_async_suspend (&udev->dev);/* Register the device. The device driver is responsible * for configuring the device and invoking the add-device
PATCH 2/70 floppy: Cleanup disk->queue before caling put_disk() if add_disk() was never called
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vivek Goyal <[email protected]>
commit 3f9a5aabd0a9fe0e0cd308506f48963d79169aa7 upstream.
add_disk() takes gendisk reference on request queue. If driver failed during initialization and never called add_disk() then that extra reference is not taken. That reference is put in put_disk(). floppy driver allocates the disk, allocates queue, sets disk->queue and then relizes that floppy controller is not present. It tries to tear down everything and tries to put a reference down in put_disk() which was never taken.
In such error cases cleanup disk->queue before calling put_disk() so that we never try to put down a reference which was never taken in first place.
--- drivers/block/floppy.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/block/floppy.c +7 -1
@@ -4368,8 +4368,14 @@ out_unreg_blkdev: out_put_disk:while (dr--) {del_timer_sync (&motor_off_timer[dr]); -if (disks[dr]->queue) +if (disks[dr]->queue) {blk_cleanup_queue (disks[dr]->queue); +/* +* put_disk() is not paired with add_disk() and +* will put queue reference one extra time. fix it. +*/ + disks[dr]->queue =NULL ; + }put_disk (disks[dr]); }return err;
PATCH 7/70 cfg80211: fix interface combinations check for ADHOC(IBSS)
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liang Li <[email protected]>
partial of commit 8e8b41f9d8c8e63fc92f899ace8da91a490ac573 upstream.
As part of commit 463454b5dbd8 ("cfg80211: fix interface combinations check"), this extra check was introduced:
if ((all_iftypes & used_iftypes) != used_iftypes)
goto cont;However, most wireless NIC drivers did not advertise ADHOC in wiphy.iface_combinations[i].limits[] and hence we'll get -EBUSY when we bring up a ADHOC wlan with commands similar to:
# iwconfig wlan0 mode ad-hoc && ifconfig wlan0 up
In commit 8e8b41f9d8c8e ("cfg80211: enforce lack of interface combinations"), the change below fixes the issue:
if (total == 1)
return 0;But it also introduces other dependencies for stable. For example, a full cherry pick of 8e8b41f9d8c8e would introduce additional regressions unless we also start cherry picking driver specific fixes like the following:
9b4760e ath5k: add possible wiphy interface combinations 1ae2fc2 mac80211_hwsim: advertise interface combinations 20c8e8d ath9k: add possible wiphy interface combinations
And the purpose of the 'if (total == 1)' is to cover the specific use case (IBSS, adhoc) that was mentioned above. So we just pick the specific part out from 8e8b41f9d8c8e here.
Doing so gives stable kernels a way to fix the change introduced by 463454b5dbd8, without having to make cherry picks specific to various NIC drivers.
--- net/wireless/util.c | 3 +++ 1 file changed, 3 insertions(+)
net/wireless/util.c +3 -0
@@ -974,6 +974,9 @@ int cfg80211_can_change_interface(struct cfg80211_registered_device *rdev, }mutex_unlock (&rdev->devlist_mtx); +if (total ==1 ) +return 0 ; +for (i =0 ; i < rdev->wiphy.n_iface_combinations; i++) {const struct ieee80211_iface_combination *c;struct ieee80211_iface_limit *limits;
PATCH 18/70 net: feed /dev/random with the MAC address when registering a device
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
commit 7bf2357524408b97fec58344caf7397f8140c3fd upstream.
--- net/core/dev.c | 3 +++ net/core/rtnetlink.c | 1 + 2 files changed, 4 insertions(+)
net/core/dev.c +3 -0
@@ -1172,6 +1172,7 @@ static int __dev_open(struct net_device *dev)net_dmaengine_get ();dev_set_rx_mode (dev);dev_activate (dev); +add_device_randomness (dev->dev_addr, dev->addr_len); }return ret;
@@ -4763,6 +4764,7 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa) err = ops->ndo_set_mac_address (dev, sa);if (!err)call_netdevice_notifiers (NETDEV_CHANGEADDR , dev); +add_device_randomness (dev->dev_addr, dev->addr_len);return err; }EXPORT_SYMBOL (dev_set_mac_address);
@@ -5541,6 +5543,7 @@ int register_netdevice(struct net_device *dev)dev_init_scheduler (dev);dev_hold (dev);list_netdevice (dev); +add_device_randomness (dev->dev_addr, dev->addr_len);/* Notify protocols, that a new device appeared. */ ret =call_netdevice_notifiers (NETDEV_REGISTER , dev);
net/core/rtnetlink.c +1 -0
@@ -1378,6 +1378,7 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm, goto errout; send_addr_notify =1 ; modified =1 ; +add_device_randomness (dev->dev_addr, dev->addr_len); }if (tb[IFLA_MTU ]) {
PATCH 19/70 random: use the arch-specific rng in xfer_secondary_pool
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
commit e6d4947b12e8ad947add1032dd754803c6004824 upstream.
If the CPU supports a hardware random number generator, use it in xfer_secondary_pool(), where it will significantly improve things and where we can afford it.
Also, remove the use of the arch-specific rng in add_timer_randomness(), since the call is significantly slower than get_cycles(), and we're much better off using it in xfer_secondary_pool() anyway.
--- drivers/char/random.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)
drivers/char/random.c +16 -9
@@ -254,6 +254,7 @@#include <linux/cryptohash.h> #include <linux/fips.h> #include <linux/ptrace.h> +#include <linux/kmemcheck.h> #ifdef CONFIG_GENERIC_HARDIRQS # include <linux/irq.h>
@@ -702,11 +703,7 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num) goto out; sample.jiffies = jiffies; - -/* Use arch random value, fall back to cycles */ -if (!arch_get_random_int (&sample.cycles)) - sample.cycles =get_cycles (); - + sample.cycles =get_cycles (); sample.num = num;mix_pool_bytes (&input_pool, &sample,sizeof (sample),NULL );
@@ -838,7 +835,11 @@ static ssize_t extract_entropy(struct entropy_store *r, void *buf,*/ static void xfer_secondary_pool (struct entropy_store *r,size_t nbytes) { -__u32 tmp[OUTPUT_POOL_WORDS ]; +union { +__u32 tmp[OUTPUT_POOL_WORDS ]; +long hwrand[4 ]; + } u; +int i;if (r->pull && r->entropy_count < nbytes *8 && r->entropy_count < r->poolinfo->POOLBITS) {
@@ -849,17 +850,23 @@ static void xfer_secondary_pool(struct entropy_store *r, size_t nbytes)/* pull at least as many as BYTES as wakeup BITS */ bytes =max_t (int, bytes, random_read_wakeup_thresh /8 );/* but never more than the buffer size */ - bytes =min_t (int, bytes,sizeof (tmp)); + bytes =min_t (int, bytes,sizeof (u.tmp));DEBUG_ENT ("going to reseed %s with %d bits " "(%d of %d requested)\n" , r->name, bytes *8 , nbytes *8 , r->entropy_count); - bytes =extract_entropy (r->pull, tmp, bytes, + bytes =extract_entropy (r->pull, u.tmp, bytes, random_read_wakeup_thresh /8 , rsvd); -mix_pool_bytes (r, tmp, bytes,NULL ); +mix_pool_bytes (r, u.tmp, bytes,NULL );credit_entropy_bits (r, bytes*8 ); } +kmemcheck_mark_initialized (&u.hwrand,sizeof (u.hwrand)); +for (i =0 ; i <4 ; i++) +if (arch_get_random_long (&u.hwrand[i])) +break ; +if (i) +mix_pool_bytes (r, &u.hwrand,sizeof (u.hwrand),0 ); }/*
PATCH 12/70 random: Use arch-specific RNG to initialize the entropy store
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
commit 3e88bdff1c65145f7ba297ccec69c774afe4c785 upstream.
If there is an architecture-specific random number generator (such as RDRAND for Intel architectures), use it to initialize /dev/random's entropy stores. Even in the worst case, if RDRAND is something like AES(NSA_KEY, counter++), it won't hurt, and it will definitely help against any other adversaries.
--- drivers/char/random.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/char/random.c +6 -0
@@ -965,6 +965,7 @@ EXPORT_SYMBOL(get_random_bytes);*/ static void init_std_data (struct entropy_store *r) { +int i;ktime_t now;unsigned long flags;
@@ -974,6 +975,11 @@ static void init_std_data(struct entropy_store *r) now =ktime_get_real ();mix_pool_bytes (r, &now,sizeof (now)); +for (i = r->poolinfo->poolwords; i; i--) { +if (!arch_get_random_long (&flags)) +break ; +mix_pool_bytes (r, &flags,sizeof (flags)); + }mix_pool_bytes (r,utsname (),sizeof (*(utsname ()))); }
PATCH 15/70 random: use lockless techniques in the interrupt path
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
commit 902c098a3663de3fa18639efbb71b6080f0bcd3c upstream.
The real-time Linux folks don't like add_interrupt_randomness() taking a spinlock since it is called in the low-level interrupt routine. This also allows us to reduce the overhead in the fast path, for the random driver, which is the interrupt collection path.
--- drivers/char/random.c | 78 ++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 39 deletions(-)
drivers/char/random.c +39 -39
@@ -418,9 +418,9 @@ struct entropy_store {/* read-write data: */ spinlock_t lock;unsigned add_ptr; +unsigned input_rotate;int entropy_count;int entropy_total; -int input_rotate; unsigned int initialized:1;__u8 last_data[EXTRACT_SIZE ]; };
@@ -468,26 +468,24 @@ static __u32 const twist_table[8] = {* it's cheap to do so and helps slightly in the expected case where * the entropy is concentrated in the low-order bits. */ -static void mix_pool_bytes_extract (struct entropy_store *r,const void *in, -int nbytes,__u8 out[64 ]) +static void __mix_pool_bytes (struct entropy_store *r,const void *in, +int nbytes,__u8 out[64 ]) {unsigned long i, j, tap1, tap2, tap3, tap4, tap5;int input_rotate;int wordmask = r->poolinfo->poolwords -1 ;const char *bytes = in;__u32 w; -unsigned long flags; -/* Taps are constant, so we can load them without holding r->lock. */ tap1 = r->poolinfo->tap1; tap2 = r->poolinfo->tap2; tap3 = r->poolinfo->tap3; tap4 = r->poolinfo->tap4; tap5 = r->poolinfo->tap5; -spin_lock_irqsave (&r->lock, flags); - input_rotate = r->input_rotate; - i = r->add_ptr; +smp_rmb (); + input_rotate =ACCESS_ONCE (r->input_rotate); + i =ACCESS_ONCE (r->add_ptr);/* mix one byte at a time to simplify size handling and churn faster */ while (nbytes--) {
@@ -514,19 +512,23 @@ static void mix_pool_bytes_extract(struct entropy_store *r, const void *in, input_rotate += i ?7 :14 ; } - r->input_rotate = input_rotate; - r->add_ptr = i; +ACCESS_ONCE (r->input_rotate) = input_rotate; +ACCESS_ONCE (r->add_ptr) = i; +smp_wmb ();if (out)for (j =0 ; j <16 ; j++) ((__u32 *)out)[j] = r->pool[(i - j) & wordmask]; - -spin_unlock_irqrestore (&r->lock, flags); } -static void mix_pool_bytes (struct entropy_store *r,const void *in,int bytes) +static void mix_pool_bytes (struct entropy_store *r,const void *in, +int nbytes,__u8 out[64 ]) { -mix_pool_bytes_extract (r, in, bytes,NULL ); +unsigned long flags; + +spin_lock_irqsave (&r->lock, flags); +__mix_pool_bytes (r, in, nbytes, out); +spin_unlock_irqrestore (&r->lock, flags); }struct fast_pool {
@@ -564,23 +566,22 @@ static void fast_mix(struct fast_pool *f, const void *in, int nbytes)*/ static void credit_entropy_bits (struct entropy_store *r,int nbits) { -unsigned long flags; -int entropy_count; +int entropy_count, orig;if (!nbits)return ; -spin_lock_irqsave (&r->lock, flags); -DEBUG_ENT ("added %d entropy credits to %s\n" , nbits, r->name); - entropy_count = r->entropy_count; +retry: + entropy_count = orig =ACCESS_ONCE (r->entropy_count); entropy_count += nbits;if (entropy_count <0 ) {DEBUG_ENT ("negative entropy/overflow\n" ); entropy_count =0 ; }else if (entropy_count > r->poolinfo->POOLBITS) entropy_count = r->poolinfo->POOLBITS; - r->entropy_count = entropy_count; +if (cmpxchg (&r->entropy_count, orig, entropy_count) != orig) + goto retry;if (!r->initialized && nbits >0 ) { r->entropy_total += nbits;
@@ -593,7 +594,6 @@ static void credit_entropy_bits(struct entropy_store *r, int nbits)wake_up_interruptible (&random_read_wait);kill_fasync (&fasync,SIGIO ,POLL_IN ); } -spin_unlock_irqrestore (&r->lock, flags); }/*********************************************************************
@@ -680,7 +680,7 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num) sample.cycles =get_cycles (); sample.num = num; -mix_pool_bytes (&input_pool, &sample,sizeof (sample)); +mix_pool_bytes (&input_pool, &sample,sizeof (sample),NULL );/* * Calculate number of bits of randomness we probably added.
@@ -764,7 +764,7 @@ void add_interrupt_randomness(int irq, int irq_flags) fast_pool->last = now; r = nonblocking_pool.initialized ? &input_pool : &nonblocking_pool; -mix_pool_bytes (r, &fast_pool->pool,sizeof (fast_pool->pool)); +__mix_pool_bytes (r, &fast_pool->pool,sizeof (fast_pool->pool),NULL );/* * If we don't have a valid cycle counter, and we see * back-to-back timer interrupts, then skip giving credit for
@@ -829,7 +829,7 @@ static void xfer_secondary_pool(struct entropy_store *r, size_t nbytes) bytes =extract_entropy (r->pull, tmp, bytes, random_read_wakeup_thresh /8 , rsvd); -mix_pool_bytes (r, tmp, bytes); +mix_pool_bytes (r, tmp, bytes,NULL );credit_entropy_bits (r, bytes*8 ); } }
@@ -890,9 +890,11 @@ static void extract_buf(struct entropy_store *r, __u8 *out)int i;__u32 hash[5 ], workspace[SHA_WORKSPACE_WORDS ];__u8 extract[64 ]; +unsigned long flags;/* Generate a hash across the pool, 16 words (512 bits) at a time */ sha_init (hash); +spin_lock_irqsave (&r->lock, flags);for (i =0 ; i < r->poolinfo->poolwords; i +=16 )sha_transform (hash, (__u8 *)(r->pool + i), workspace);
@@ -905,7 +907,8 @@ static void extract_buf(struct entropy_store *r, __u8 *out)* brute-forcing the feedback as hard as brute-forcing the * hash. */ -mix_pool_bytes_extract (r, hash,sizeof (hash), extract); +__mix_pool_bytes (r, hash,sizeof (hash), extract); +spin_unlock_irqrestore (&r->lock, flags);/* * To avoid duplicates, we atomically extract a portion of the
@@ -928,11 +931,10 @@ static void extract_buf(struct entropy_store *r, __u8 *out) }static ssize_t extract_entropy (struct entropy_store *r,void *buf, -size_t nbytes,int min,int reserved) +size_t nbytes,int min,int reserved) {ssize_t ret =0 , i;__u8 tmp[EXTRACT_SIZE ]; -unsigned long flags;xfer_secondary_pool (r, nbytes); nbytes =account (r, nbytes, min, reserved);
@@ -941,6 +943,8 @@ static ssize_t extract_entropy(struct entropy_store *r, void *buf,extract_buf (r, tmp);if (fips_enabled) { +unsigned long flags; +spin_lock_irqsave (&r->lock, flags);if (!memcmp (tmp, r->last_data,EXTRACT_SIZE ))panic ("Hardware RNG duplicated output!\n" );
@@ -1034,22 +1038,18 @@ EXPORT_SYMBOL(get_random_bytes);static void init_std_data (struct entropy_store *r) {int i; -ktime_t now; -unsigned long flags; +ktime_t now =ktime_get_real (); +unsigned long rv; -spin_lock_irqsave (&r->lock, flags); r->entropy_count =0 ; r->entropy_total =0 ; -spin_unlock_irqrestore (&r->lock, flags); - - now =ktime_get_real (); -mix_pool_bytes (r, &now,sizeof (now)); -for (i = r->poolinfo->POOLBYTES; i >0 ; i -=sizeof flags) { -if (!arch_get_random_long (&flags)) +mix_pool_bytes (r, &now,sizeof (now),NULL ); +for (i = r->poolinfo->POOLBYTES; i >0 ; i -=sizeof (rv)) { +if (!arch_get_random_long (&rv))break ; -mix_pool_bytes (r, &flags,sizeof (flags)); +mix_pool_bytes (r, &rv,sizeof (rv),NULL ); } -mix_pool_bytes (r,utsname (),sizeof (*(utsname ()))); +mix_pool_bytes (r,utsname (),sizeof (*(utsname ())),NULL ); }static int rand_initialize (void )
@@ -1186,7 +1186,7 @@ write_pool(struct entropy_store *r, const char __user *buffer, size_t count) count -= bytes; p += bytes; -mix_pool_bytes (r, buf, bytes); +mix_pool_bytes (r, buf, bytes,NULL );cond_resched (); }
PATCH 1/70 sched: Fix race in task_group()
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <[email protected]>
commit 8323f26ce3425460769605a6aece7a174edaa7d1 upstream
Stefan reported a crash on a kernel before a3e5d1091c1 ("sched:
Don't call task_group() too many times in set_task_rq()"), he found the reason to be that the multiple task_group() invocations in set_task_rq() returned different values.
Looking at all that I found a lack of serialization and plain wrong comments.
The below tries to fix it using an extra pointer which is updated under the appropriate scheduler locks. Its not pretty, but I can't really see another way given how all the cgroup stuff works.
(backported to previous file names and layout)
--- include/linux/init_task.h | 12 +++++++++++- include/linux/sched.h | 5 ++++- kernel/sched.c | 32 ++++++++++++++++++-------------- 3 files changed, 33 insertions(+), 16 deletions(-)
include/linux/init_task.h +11 -1
@@ -117,8 +117,17 @@ extern struct group_info init_groups;extern struct cred init_cred; +extern struct task_group root_task_group; + +#ifdef CONFIG_CGROUP_SCHED +# define INIT_CGROUP_SCHED (tsk) \ + .sched_task_group = &root_task_group, +#else +# define INIT_CGROUP_SCHED (tsk) +#endif +#ifdef CONFIG_PERF_EVENTS -# define INIT_PERF_EVENTS (tsk) \ +# define INIT_PERF_EVENTS (tsk) \ .perf_event_mutex = \ __MUTEX_INITIALIZER(tsk.perf_event_mutex), \ .perf_event_list = LIST_HEAD_INIT(tsk.perf_event_list),
@@ -155,6 +164,7 @@ extern struct cred init_cred; }, \ .tasks = LIST_HEAD_INIT(tsk.tasks), \ INIT_PUSHABLE_TASKS(tsk) \ +INIT_CGROUP_SCHED (tsk) \ .ptraced = LIST_HEAD_INIT(tsk.ptraced), \ .ptrace_entry = LIST_HEAD_INIT(tsk.ptrace_entry), \ .real_parent = &tsk, \
include/linux/sched.h +4 -1
@@ -1235,6 +1235,9 @@ struct task_struct {const struct sched_class *sched_class;struct sched_entity se;struct sched_rt_entity rt; +#ifdef CONFIG_CGROUP_SCHED +struct task_group *sched_task_group; +#endif #ifdef CONFIG_PREEMPT_NOTIFIERS /* list of struct preempt_notifier: */
@@ -2645,7 +2648,7 @@ extern int sched_group_set_rt_period(struct task_group *tg,extern long sched_group_rt_period (struct task_group *tg);extern int sched_rt_can_attach (struct task_group *tg,struct task_struct *tsk);#endif -#endif +#endif /* CONFIG_CGROUP_SCHED */ extern int task_can_switch_user (struct user_struct *up,struct task_struct *tsk);
kernel/sched.c +18 -14
@@ -746,22 +746,19 @@ static inline int cpu_of(struct rq *rq)/* * Return the group to which this tasks belongs. * -* We use task_subsys_state_check() and extend the RCU verification with -* pi->lock and rq->lock because cpu_cgroup_attach() holds those locks for each -* task it moves into the cgroup. Therefore by holding either of those locks, -* we pin the task to the current cgroup. +* We cannot use task_subsys_state() and friends because the cgroup +* subsystem changes that value before the cgroup_subsys::attach() method +* is called, therefore we cannot pin it and might observe the wrong value. +* +* The same is true for autogroup's p->signal->autogroup->tg, the autogroup +* core changes this before calling sched_move_task(). +* +* Instead we use a 'copy' which is updated from sched_move_task() while +* holding both task_struct::pi_lock and rq::lock. */ static inline struct task_group *task_group (struct task_struct *p) { -struct task_group *tg; -struct cgroup_subsys_state *css; - - css =task_subsys_state_check (p, cpu_cgroup_subsys_id, -lockdep_is_held (&p->pi_lock) || -lockdep_is_held (&task_rq (p)->lock)); - tg = container_of(css, struct task_group, css); - -return autogroup_task_group (p, tg); +return p->sched_task_group; }/* Change a task's cfs_rq and parent entity if it moves across CPUs/groups */
@@ -2372,7 +2369,7 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu)* a task's CPU. ->pi_lock for waking tasks, rq->lock for runnable tasks. * * sched_move_task() holds both and thus holding either pins the cgroup, -* see set_task_rq(). +* see task_group(). * * Furthermore, all task_rq users should acquire both locks, see * task_rq_lock().
@@ -8892,6 +8889,7 @@ void sched_destroy_group(struct task_group *tg)*/ void sched_move_task (struct task_struct *tsk) { +struct task_group *tg;int on_rq, running;unsigned long flags;struct rq *rq;
@@ -8906,6 +8904,12 @@ void sched_move_task(struct task_struct *tsk)if (unlikely (running)) tsk->sched_class->put_prev_task (rq, tsk); + tg =container_of (task_subsys_state_check (tsk, cpu_cgroup_subsys_id, +lockdep_is_held (&tsk->sighand->siglock)), + struct task_group, css); + tg =autogroup_task_group (tsk, tg); + tsk->sched_task_group = tg; +#ifdef CONFIG_FAIR_GROUP_SCHED if (tsk->sched_class->task_move_group) tsk->sched_class->task_move_group (tsk, on_rq);
PATCH 6/70 ALSA: hda - add dock support for Thinkpad X230 Tablet
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Henningsson <[email protected]>
commit 108cc108a3bb42fe4705df1317ff98e1e29428a6 upstream.
Also add a model/fixup string "lenovo-dock", so that other Thinkpad users will be able to test this fixup easily, to see if it enables dock I/O for them as well.
--- Documentation/sound/alsa/HD-Audio-Models.txt | 3 ++- sound/pci/hda/patch_realtek.c | 27 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-)
Documentation/sound/alsa/HD-Audio-Models.txt +2 -1
@@ -60,10 +60,11 @@ ALC267/268 ========== N/A -ALC269 +ALC269/270/275/276/280/282 ====== laptop-amic Laptops with analog-mic input laptop-dmic Laptops with digital-mic input + lenovo-dock Enables docking station I/O for some Lenovos ALC662/663/272 ==============
sound/pci/hda/patch_realtek.c +27 -0
@@ -4809,6 +4809,15 @@ static int alc269_resume(struct hda_codec *codec) }#endif /* CONFIG_PM */ +static void alc269_fixup_pincfg_no_hp_to_lineout (struct hda_codec *codec, +const struct alc_fixup *fix,int action) +{ +struct alc_spec *spec = codec->spec; + +if (action ==ALC_FIXUP_ACT_PRE_PROBE ) + spec->parse_flags =HDA_PINCFG_NO_HP_FIXUP ; +} +static void alc269_fixup_hweq (struct hda_codec *codec,const struct alc_fixup *fix,int action) {
@@ -4909,6 +4918,8 @@ enum {ALC269_FIXUP_DMIC ,ALC269VB_FIXUP_AMIC ,ALC269VB_FIXUP_DMIC , +ALC269_FIXUP_LENOVO_DOCK , + ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT, }; static const struct alc_fixup alc269_fixups[] = {
@@ -5029,6 +5040,20 @@ static const struct alc_fixup alc269_fixups[] = { { } }, }, + [ALC269_FIXUP_LENOVO_DOCK ] = { + .type =ALC_FIXUP_PINS , + .v.pins = (const struct alc_pincfg []) { + {0x19 ,0x23a11040 },/* dock mic */ + {0x1b ,0x2121103f },/* dock headphone */ + { } + }, + .chained = true, + .chain_id =ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT + }, + [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT ] = { + .type =ALC_FIXUP_FUNC , + .v.func = alc269_fixup_pincfg_no_hp_to_lineout, + }, };static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -5051,6 +5076,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x17aa ,0x21b8 ,"Thinkpad Edge 14" ,ALC269_FIXUP_SKU_IGNORE ),SND_PCI_QUIRK (0x17aa ,0x21ca ,"Thinkpad L412" ,ALC269_FIXUP_SKU_IGNORE ),SND_PCI_QUIRK (0x17aa ,0x21e9 ,"Thinkpad Edge 15" ,ALC269_FIXUP_SKU_IGNORE ), +SND_PCI_QUIRK (0x17aa ,0x2203 ,"Thinkpad X230 Tablet" ,ALC269_FIXUP_LENOVO_DOCK ),SND_PCI_QUIRK (0x17aa ,0x3bf8 ,"Quanta FL1" ,ALC269_FIXUP_QUANTA_MUTE ),SND_PCI_QUIRK (0x17aa ,0x3bf8 ,"Lenovo Ideapd" ,ALC269_FIXUP_PCM_44K ), SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
@@ -5109,6 +5135,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {static const struct alc_model_fixup alc269_fixup_models[] = { {.id =ALC269_FIXUP_AMIC , .name ="laptop-amic" }, {.id =ALC269_FIXUP_DMIC , .name ="laptop-dmic" }, + {.id =ALC269_FIXUP_LENOVO_DOCK , .name ="lenovo-dock" }, {} };
PATCH 9/70 ene_ir: Fix driver initialisation
In reply to Ben Hutchings3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luis Henriques <[email protected]>
commit b31b021988fed9e3741a46918f14ba9b063811db upstream.
commit 9ef449c6b31bb6a8e6dedc24de475a3b8c79be20 ("[media] rc: Postpone ISR registration") fixed an early ISR registration on several drivers. It did however also introduced a bug by moving the invocation of pnp_port_start() to the end of the probe function.
This patch fixes this issue by moving the invocation of pnp_port_start() to an earlier stage in the probe function.
--- drivers/media/rc/ene_ir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/rc/ene_ir.c +2 -1
@@ -1018,6 +1018,8 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)spin_lock_init (&dev->hw_lock); + dev->hw_io =pnp_port_start (pnp_dev,0 ); +pnp_set_drvdata (pnp_dev, dev); dev->pnp_dev = pnp_dev;
@@ -1072,7 +1074,6 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)/* claim the resources */ error = -EBUSY ; - dev->hw_io =pnp_port_start (pnp_dev,0 );if (!request_region (dev->hw_io,ENE_IO_SIZE ,ENE_DRIVER_NAME )) { dev->hw_io =-1 ; dev->irq =-1 ;
Re: [ 02/70] floppy: Cleanup disk->queue before caling put_disk() if add_disk() was never called
In reply to Ben HutchingsQuoted 38 lines · Ben Hutchings
3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vivek Goyal <[email protected]>
commit
3f9a5aabd0a9fe0e0cd308506f48963d79169aa7upstream.
add_disk()takes gendisk reference on request queue. If driver failed during initialization and never calledadd_disk()then that extra reference is not taken. That reference is put input_disk(). floppy driver allocates the disk, allocates queue, setsdisk->queueand then relizes that floppy controller is not present. It tries to tear down everything and tries to put a reference down input_disk()which was never taken.In such error cases cleanup
disk->queuebefore callingput_disk()so that we never try to put down a reference which was never taken in first place.Reported-and-tested-by Suresh Jayaraman <[email protected]>Tested-by Dirk Gouders <[email protected]>Signed-off-by Vivek Goyal <[email protected]>Acked-by Tejun Heo <[email protected]>Signed-off-by Jens Axboe <[email protected]>Signed-off-by Ben Hutchings <[email protected]>--- drivers/block/floppy.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/block/floppy.c +1
-1@@ -4368,8 +4368,14 @@ out_unreg_blkdev: out_put_disk:while (dr--) {del_timer_sync (&motor_off_timer[dr]); -if (disks[dr]->queue) +if (disks[dr]->queue) {
drivers/block/floppy.c out_unreg_blkdev: · line 4381
Quoted 10 lines
drivers/block/floppy.c +6
-0blk_cleanup_queue (disks[dr]->queue); +/* +* put_disk() is not paired with add_disk() and +* will put queue reference one extra time. fix it. +*/ + disks[dr]->queue =NULL ; + }put_disk (disks[dr]); }return err;
I was taking a look at this, and noticed some issues with the error handling:
* missing cleanup (put_disk) if blk_init_queue fails, dr is decremented first in the error handling loop
* if something fails in the add_disk loop, there is no cleanup of previous iterations in the error handling.
* if (disks[dr]->queue) check is bogus, when reaching there for each dr should exist an queue allocated, and it doesn't take into account iterations where add_disk wasn't done, if failure happens in add_disk loop.
* floppy_module_exit doesn't reset queue pointer if add_disk wasn't done.
I think the more complete diff below (not build tested) is needed, comments?
drivers/block/floppy.c +26 -8
@@ -4178,6 +4178,7 @@ static int __init floppy_init(void) {int i, unit, drive;int err, dr; +int drive_cnt =-1 ;set_debugt (); interruptjiffies = resultjiffies = jiffies;
@@ -4198,6 +4199,7 @@ static int __init floppy_init(void) disks[dr]->queue =blk_init_queue (do_fd_request, &floppy_lock);if (!disks[dr]->queue) { +put_disk (disks[dr]); err = -ENOMEM ; goto out_put_disk; }
@@ -4357,7 +4359,16 @@ static int __init floppy_init(void) out_unreg_platform_dev:platform_device_unregister (&floppy_device[drive]); + drive_cnt = drive -1 ; out_flush_work: +while (drive--) { +if ((allowed_drive_mask & (1 << drive)) && + fdc_state[FDC (drive)].version !=FDC_NONE ) { +del_gendisk (disks[drive]); +device_remove_file (&floppy_device[drive].dev, &dev_attr_cmos); +platform_device_unregister (&floppy_device[drive]); + } + }flush_work_sync (&floppy_work);if (atomic_read (&usage_count))floppy_release_irq_and_dma ();
@@ -4369,14 +4380,14 @@ out_unreg_blkdev: out_put_disk:while (dr--) {del_timer_sync (&motor_off_timer[dr]); -if (disks[dr]->queue) { -blk_cleanup_queue (disks[dr]->queue); -/* -* put_disk() is not paired with add_disk() and -* will put queue reference one extra time. fix it. -*/ +blk_cleanup_queue (disks[dr]->queue); +/* +* put_disk() may not be paired with add_disk() and +* will put queue reference one extra time. fix it. +*/ +if (dr > drive_cnt || !(allowed_drive_mask & (1 << dr)) || + fdc_state[FDC (dr)].version ==FDC_NONE ) disks[dr]->queue =NULL ; - }put_disk (disks[dr]); }return err;
@@ -4584,8 +4595,15 @@ static void __exit floppy_module_exit(void)del_gendisk (disks[drive]);device_remove_file (&floppy_device[drive].dev, &dev_attr_cmos);platform_device_unregister (&floppy_device[drive]); +blk_cleanup_queue (disks[drive]->queue); + }else { +blk_cleanup_queue (disks[drive]->queue); +/* +* put_disk() is not paired with add_disk() and +* will put queue reference one extra time. fix it. +*/ + disks[drive]->queue =NULL ; } -blk_cleanup_queue (disks[drive]->queue);put_disk (disks[drive]); }
Quoted 7 lines
--
To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
[]'s Herton
Re: [ 02/70] floppy: Cleanup disk->queue before caling put_disk() if add_disk() was never called
Quoted 54 lines · Herton Ronaldo Krzesinski
Quoted 38 lines · Ben Hutchings
3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vivek Goyal <[email protected]>
commit
3f9a5aabd0a9fe0e0cd308506f48963d79169aa7upstream.
add_disk()takes gendisk reference on request queue. If driver failed during initialization and never calledadd_disk()then that extra reference is not taken. That reference is put input_disk(). floppy driver allocates the disk, allocates queue, setsdisk->queueand then relizes that floppy controller is not present. It tries to tear down everything and tries to put a reference down input_disk()which was never taken.In such error cases cleanup
disk->queuebefore callingput_disk()so that we never try to put down a reference which was never taken in first place.Reported-and-tested-by Suresh Jayaraman <[email protected]>Tested-by Dirk Gouders <[email protected]>Signed-off-by Vivek Goyal <[email protected]>Acked-by Tejun Heo <[email protected]>Signed-off-by Jens Axboe <[email protected]>Signed-off-by Ben Hutchings <[email protected]>--- drivers/block/floppy.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/block/floppy.c +1
-1@@ -4368,8 +4368,14 @@ out_unreg_blkdev: out_put_disk:while (dr--) {del_timer_sync (&motor_off_timer[dr]); -if (disks[dr]->queue) +if (disks[dr]->queue) {drivers/block/floppy.c out_unreg_blkdev: · line 4381
Quoted 10 lines
drivers/block/floppy.c +6
-0blk_cleanup_queue (disks[dr]->queue); +/* +* put_disk() is not paired with add_disk() and +* will put queue reference one extra time. fix it. +*/ + disks[dr]->queue =NULL ; + }put_disk (disks[dr]); }return err;I was taking a look at this, and noticed some issues with the error handling:
* missing cleanup (put_disk) ifblk_init_queuefails, dr is decremented first in the error handling loop
Quoted 8 lines
* if something fails in the
add_diskloop, there is no cleanup of previous iterations in the error handling.
* if (disks[dr]->queue) check is bogus, when reaching there for each dr should exist an queue allocated, and it doesn't take into account iterations whereadd_diskwasn't done, if failure happens inadd_diskloop.
*floppy_module_exitdoesn't reset queue pointer ifadd_diskwasn't done.
I agree with this analysis.
Quoted 1 line
I think the more complete diff below (not build tested) is needed, comments?
[...]
There are several off-by-one errors, and 'drive_cnt' is not a particularly clear variable name (alongside 'dr' and 'drive'), but I think this is on the right track.
Anyway, do you agree that the patch under review does fix *a* bug and doesn't introduce a regression?
Ben.
Signature · 3 lines
Ben Hutchings
Theory and practice are closer in theory than in practice.
- John Levine, moderator of comp.compilersRe: [ 02/70] floppy: Cleanup disk->queue before caling put_disk() if add_disk() was never called
Quoted 64 lines · Ben Hutchings
Quoted 54 lines · Herton Ronaldo Krzesinski
Quoted 38 lines · Ben Hutchings
3.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vivek Goyal <[email protected]>
commit
3f9a5aabd0a9fe0e0cd308506f48963d79169aa7upstream.
add_disk()takes gendisk reference on request queue. If driver failed during initialization and never calledadd_disk()then that extra reference is not taken. That reference is put input_disk(). floppy driver allocates the disk, allocates queue, setsdisk->queueand then relizes that floppy controller is not present. It tries to tear down everything and tries to put a reference down input_disk()which was never taken.In such error cases cleanup
disk->queuebefore callingput_disk()so that we never try to put down a reference which was never taken in first place.Reported-and-tested-by Suresh Jayaraman <[email protected]>Tested-by Dirk Gouders <[email protected]>Signed-off-by Vivek Goyal <[email protected]>Acked-by Tejun Heo <[email protected]>Signed-off-by Jens Axboe <[email protected]>Signed-off-by Ben Hutchings <[email protected]>--- drivers/block/floppy.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/block/floppy.c +1
-1@@ -4368,8 +4368,14 @@ out_unreg_blkdev: out_put_disk:while (dr--) {del_timer_sync (&motor_off_timer[dr]); -if (disks[dr]->queue) +if (disks[dr]->queue) {drivers/block/floppy.c out_unreg_blkdev: · line 4381
Quoted 10 lines
drivers/block/floppy.c +6
-0blk_cleanup_queue (disks[dr]->queue); +/* +* put_disk() is not paired with add_disk() and +* will put queue reference one extra time. fix it. +*/ + disks[dr]->queue =NULL ; + }put_disk (disks[dr]); }return err;I was taking a look at this, and noticed some issues with the error handling:
* missing cleanup (put_disk) ifblk_init_queuefails, dr is decremented first in the error handling loopQuoted 8 lines
* if something fails in the
add_diskloop, there is no cleanup of previous iterations in the error handling.
* if (disks[dr]->queue) check is bogus, when reaching there for each dr should exist an queue allocated, and it doesn't take into account iterations whereadd_diskwasn't done, if failure happens inadd_diskloop.
*floppy_module_exitdoesn't reset queue pointer ifadd_diskwasn't done.
Quoted 8 lines
I agree with this analysis.
Quoted 1 line
I think the more complete diff below (not build tested) is needed, comments?
[...]
There are several off-by-one errors, and '
drive_cnt' is not a particularly clear variable name (alongside 'dr' and 'drive'), but I think this is on the right track.
Yes, not best naming on variables, but I didn't had much ideas either on a better name, I'll see if I can come with something better. I think I fixed all possible off-by-one errors, if you spot something else let me know.
Quoted 3 lines
Anyway, do you agree that the patch under review does fix *a* bug and doesn't introduce a regression?
Yes, it's incomplete, but does fix one case and is no regression, I don't see an issue keeping it. I'll wrap up and send the patch fixing the other issues, Cc'ing to stable as well.
Quoted 7 lines
Ben.
Signature · 3 lines
Ben Hutchings Theory and practice are closer in theory than in practice. - John Levine, moderator of comp.compilers
Signature · 2 lines
[]'s Herton