3.11.6-stable review
Subsystems (28)
Greg Kroah-Hartman
maintainercover 3.11.6-stable review
This is the start of the stable review cycle for the 3.11.6 release. There are 50 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri Oct 18 17:43:24 UTC 2013. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.11.6-rc1.gz
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 3.11.6-rc1
Linn Crosetto <[email protected]>
x86: avoid remapping data in parse_setup_data()
Manfred Spraul <[email protected]>
ipc/sem.c: update sem_otime for all operations
Manfred Spraul <[email protected]>
ipc/sem.c: synchronize the proc interface
Manfred Spraul <[email protected]>
ipc/sem.c: optimize sem_lock()
Davidlohr Bueso <[email protected]>
ipc: drop ipc_lock_check
Davidlohr Bueso <[email protected]>
ipc, shm: drop shm_lock_check
Davidlohr Bueso <[email protected]>
ipc: drop ipc_lock_by_ptr
Davidlohr Bueso <[email protected]>
ipc, shm: guard against non-existant vma in shmdt(2)
Davidlohr Bueso <[email protected]>
ipc: document general ipc locking scheme
Davidlohr Bueso <[email protected]>
ipc,msg: drop msg_unlock
Davidlohr Bueso <[email protected]>
ipc: rename ids->rw_mutex
Davidlohr Bueso <[email protected]>
ipc,shm: shorten critical region for shmat
Davidlohr Bueso <[email protected]>
ipc,shm: cleanup do_shmat pasta
Davidlohr Bueso <[email protected]>
ipc,shm: shorten critical region for shmctl
Davidlohr Bueso <[email protected]>
ipc,shm: make shmctl_nolock lockless
Davidlohr Bueso <[email protected]>
ipc,shm: introduce shmctl_nolock
Davidlohr Bueso <[email protected]>
ipc: drop ipcctl_pre_down
Davidlohr Bueso <[email protected]>
ipc,shm: shorten critical region in shmctl_down
Davidlohr Bueso <[email protected]>
ipc,shm: introduce lockless functions to obtain the ipc object
wojciech kapuscinski <[email protected]>
drm/radeon: fix hw contexts for SUMO2 asics
Alex Deucher <[email protected]>
drm/radeon: fix typo in CP DMA register headers
Dan Carpenter <[email protected]>
drm/radeon: forever loop on error in radeon_do_test_moves()
Dan Carpenter <[email protected]>
drm/radeon/dpm: off by one in si_set_mc_special_registers()
Imre Deak <[email protected]>
drm/i915: fix rps.vlv_work initialization
Chris Wilson <[email protected]>
drm/i915: Only apply DPMS to the encoder if enabled
Francisco Jerez <[email protected]>
drm/i915/hsw: Disable L3 caching of atomic memory operations.
David Henningsson <[email protected]>
ALSA: hda - Fix mono speakers and headset mic on Dell Vostro 5470
Ingo Molnar <[email protected]>
compiler/gcc4: Add quirk for 'asm goto' miscompilation bug
Dan Carpenter <[email protected]>
drm/radeon/dpm/btc: off by one in btc_set_mc_special_registers()
James Hogan <[email protected]>
MIPS: stack protector: Fix per-task canary switch
Jingoo Han <[email protected]>
watchdog: kempld_wdt: Fix bit mask definition
Dan Carpenter <[email protected]>
watchdog: ts72xx_wdt: locking bug in ioctl
Vineet Gupta <[email protected]>
ARC: Ignore ptrace SETREGSET request for synthetic register "stop_pc"
Christian Ruppert <[email protected]>
ARC: Fix signal frame management for SA_SIGINFO
Vineet Gupta <[email protected]>
ARC: Workaround spinlock livelock in SMP SystemC simulation
Vineet Gupta <[email protected]>
ARC: Fix 32-bit wrap around in access_ok()
Mischa Jonker <[email protected]>
ARC: Handle zero-overhead-loop in unaligned access handler
Mischa Jonker <[email protected]>
ARC: Fix __udelay calculation
Helge Deller <[email protected]>
parisc: fix interruption handler to respect pagefault_disable()
Paul Mackerras <[email protected]>
KVM: PPC: Book3S HV: Fix typo in saving DSCR
Dave Jones <[email protected]>
ext4: fix memory leak in xattr
Josef Bacik <[email protected]>
Btrfs: use right root when checking for hash collision
Henrik Rydberg <[email protected]>
hwmon: (applesmc) Always read until end of data
Taras Kondratiuk <[email protected]>
i2c: omap: Clear ARDY bit twice
Linus Torvalds <[email protected]>
vfs: allow O_PATH file descriptors for fstatfs()
Theodore Ts'o <[email protected]>
random: run random_int_secret_init() run after all late_initcalls
David Henningsson <[email protected]>
ALSA: hda - Fix microphone for Sony VAIO Pro 13 (Haswell model)
Takashi Iwai <[email protected]>
ALSA: hda - Add fixup for ASUS N56VZ
Anssi Hannula <[email protected]>
ALSA: hda - hdmi: Fix channel map switch not taking effect
Daniel Mack <[email protected]>
ALSA: snd-usb-usx2y: remove bogus frame checks
-------------
Diffstat:
Makefile | 4 +- arch/arc/include/asm/delay.h | 5 +- arch/arc/include/asm/spinlock.h | 9 +- arch/arc/include/asm/uaccess.h | 4 +- arch/arc/kernel/ptrace.c | 2 +- arch/arc/kernel/signal.c | 25 ++-- arch/arc/kernel/unaligned.c | 6 + arch/arm/include/asm/jump_label.h | 2 +- arch/mips/include/asm/jump_label.h | 2 +- arch/mips/kernel/octeon_switch.S | 2 +- arch/mips/kernel/r2300_switch.S | 2 +- arch/mips/kernel/r4k_switch.S | 2 +- arch/parisc/kernel/traps.c | 6 +- arch/powerpc/include/asm/jump_label.h | 2 +- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 2 +- arch/s390/include/asm/jump_label.h | 2 +- arch/sparc/include/asm/jump_label.h | 2 +- arch/x86/include/asm/cpufeature.h | 6 +- arch/x86/include/asm/e820.h | 2 +- arch/x86/include/asm/jump_label.h | 2 +- arch/x86/kernel/e820.c | 5 +- arch/x86/kernel/setup.c | 19 +-- drivers/char/random.c | 3 +- drivers/gpu/drm/i915/i915_reg.h | 6 + drivers/gpu/drm/i915/intel_display.c | 8 +- drivers/gpu/drm/i915/intel_pm.c | 9 +- drivers/gpu/drm/radeon/btc_dpm.c | 6 +- drivers/gpu/drm/radeon/evergreen.c | 2 +- drivers/gpu/drm/radeon/evergreend.h | 4 +- drivers/gpu/drm/radeon/r600d.h | 2 +- drivers/gpu/drm/radeon/radeon_test.c | 4 +- drivers/gpu/drm/radeon/si_dpm.c | 6 +- drivers/gpu/drm/radeon/sid.h | 4 +- drivers/hwmon/applesmc.c | 13 ++ drivers/i2c/busses/i2c-omap.c | 3 + drivers/watchdog/kempld_wdt.c | 2 +- drivers/watchdog/ts72xx_wdt.c | 3 +- fs/btrfs/inode.c | 2 +- fs/ext4/xattr.c | 2 + fs/statfs.c | 2 +- include/linux/compiler-gcc4.h | 15 ++ include/linux/ipc_namespace.h | 2 +- include/linux/random.h | 1 + init/main.c | 2 + ipc/msg.c | 25 ++-- ipc/namespace.c | 7 +- ipc/sem.c | 82 ++++++---- ipc/shm.c | 255 ++++++++++++++++++-------------- ipc/util.c | 82 ++++------ ipc/util.h | 14 +- sound/pci/hda/patch_hdmi.c | 18 +-- sound/pci/hda/patch_realtek.c | 37 +++++ sound/usb/usx2y/usbusx2yaudio.c | 22 +-- sound/usb/usx2y/usx2yhwdeppcm.c | 7 +- 54 files changed, 437 insertions(+), 326 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/50 ALSA: snd-usb-usx2y: remove bogus frame checks
3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Mack <[email protected]>
commit a9d14bc0b188a822e42787d01e56c06fe9750162 upstream.
The frame check in i_usX2Y_urb_complete() and i_usX2Y_usbpcm_urb_complete() is bogus and produces false positives as described in this LAU thread:
http://linuxaudio.org/mailarchive/lau/2013/5/20/200177
This patch removes the check code entirely.
--- sound/usb/usx2y/usbusx2yaudio.c | 22 +++------------------- sound/usb/usx2y/usx2yhwdeppcm.c | 7 +------ 2 files changed, 4 insertions(+), 25 deletions(-)
sound/usb/usx2y/usbusx2yaudio.c +3 -19
@@ -299,19 +299,6 @@ static void usX2Y_error_urb_status(strucusX2Y_clients_stop (usX2Y); } -static void usX2Y_error_sequence (struct usX2Ydev *usX2Y, -struct snd_usX2Y_substream *subs,struct urb *urb) -{ -snd_printk (KERN_ERR -"Sequence Error!(hcd_frame=%i ep=%i%s;wait=%i,frame=%i).\n" -"Most probably some urb of usb-frame %i is still missing.\n" -"Cause could be too long delays in usb-hcd interrupt handling.\n" , -usb_get_current_frame_number (usX2Y->dev), - subs->endpoint,usb_pipein (urb->pipe) ?"in" :"out" , - usX2Y->wait_iso_frame, urb->start_frame, usX2Y->wait_iso_frame); -usX2Y_clients_stop (usX2Y); -} -static void i_usX2Y_urb_complete (struct urb *urb) {struct snd_usX2Y_substream *subs = urb->context;
@@ -328,12 +315,9 @@ static void i_usX2Y_urb_complete(structusX2Y_error_urb_status (usX2Y, subs, urb);return ; } -if (likely ((urb->start_frame &0xFFFF ) == (usX2Y->wait_iso_frame &0xFFFF ))) - subs->completed_urb = urb; -else { -usX2Y_error_sequence (usX2Y, subs, urb); -return ; - } + + subs->completed_urb = urb; + {struct snd_usX2Y_substream *capsubs = usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE ], *playbacksubs = usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK ];
sound/usb/usx2y/usx2yhwdeppcm.c +1 -6
@@ -244,13 +244,8 @@ static void i_usX2Y_usbpcm_urb_complete(usX2Y_error_urb_status (usX2Y, subs, urb);return ; } -if (likely ((urb->start_frame &0xFFFF ) == (usX2Y->wait_iso_frame &0xFFFF ))) - subs->completed_urb = urb; -else { -usX2Y_error_sequence (usX2Y, subs, urb); -return ; - } + subs->completed_urb = urb; capsubs = usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE ]; capsubs2 = usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE +2 ]; playbacksubs = usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK ];
Greg Kroah-Hartman
maintainerPATCH 2/50 ALSA: hda - hdmi: Fix channel map switch not taking effect
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anssi Hannula <[email protected]>
commit 39edac70e9aedf451fccaa851b273ace9fcca0bd upstream.
Currently hdmi_setup_audio_infoframe() reprograms the HDA channel mapping only when the infoframe is not up-to-date or the non-PCM flag has changed.
However, when just the channel map has been changed, the infoframe may still be up-to-date and non-PCM flag may not have changed, so the new channel map is not actually programmed into the HDA codec.
Notably, this failing case is also always triggered when the device is already in a prepared state and a new channel map is configured while changing only the channel positions (for example, plain "speaker-test -c2 -m FR,FL").
Fix that by always programming the channel map in hdmi_setup_audio_infoframe(). Tested on Intel HDMI.
--- sound/pci/hda/patch_hdmi.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
sound/pci/hda/patch_hdmi.c +8 -10
@@ -930,6 +930,14 @@ static void hdmi_setup_audio_infoframe(s }/* +* always configure channel mapping, it may have been changed by the +* user in the meantime +*/ +hdmi_setup_channel_mapping (codec, pin_nid, non_pcm, ca, + channels, per_pin->chmap, + per_pin->chmap_set); + +/* * sizeof(ai) is used instead of sizeof(*hdmi_ai) or * sizeof(*dp_ai) to avoid partial match/update problems when * the user switches between HDMI/DP monitors.
@@ -940,20 +948,10 @@ static void hdmi_setup_audio_infoframe(s"pin=%d channels=%d\n" , pin_nid, channels); -hdmi_setup_channel_mapping (codec, pin_nid, non_pcm, ca, - channels, per_pin->chmap, - per_pin->chmap_set);hdmi_stop_infoframe_trans (codec, pin_nid);hdmi_fill_audio_infoframe (codec, pin_nid, ai.bytes,sizeof (ai));hdmi_start_infoframe_trans (codec, pin_nid); - }else { -/* For non-pcm audio switch, setup new channel mapping -* accordingly */ -if (per_pin->non_pcm != non_pcm) -hdmi_setup_channel_mapping (codec, pin_nid, non_pcm, ca, - channels, per_pin->chmap, - per_pin->chmap_set); } per_pin->non_pcm = non_pcm;
Greg Kroah-Hartman
maintainerPATCH 3/50 ALSA: hda - Add fixup for ASUS N56VZ
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit c6cc3d58b4042f5cadae653ff8d3df26af1a0169 upstream.
ASUS N56VZ needs a fixup for the bass speaker pin, which was already provided via model=asus-mode4.
Bugzilla: https://bugzilla.novell.com/show_bug.cgi?id=841645
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -4345,6 +4345,7 @@ static const struct snd_pci_quirk alc662SND_PCI_QUIRK (0x1028 ,0x05d8 ,"Dell" ,ALC668_FIXUP_DELL_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1028 ,0x05db ,"Dell" ,ALC668_FIXUP_DELL_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x103c ,0x1632 ,"HP RP5800" ,ALC662_FIXUP_HP_RP5800 ), +SND_PCI_QUIRK (0x1043 ,0x1477 ,"ASUS N56VZ" ,ALC662_FIXUP_ASUS_MODE4 ),SND_PCI_QUIRK (0x1043 ,0x8469 ,"ASUS mobo" ,ALC662_FIXUP_NO_JACK_DETECT ),SND_PCI_QUIRK (0x105b ,0x0cd6 ,"Foxconn" ,ALC662_FIXUP_ASUS_MODE2 ), SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Greg Kroah-Hartman
maintainerPATCH 4/50 ALSA: hda - Fix microphone for Sony VAIO Pro 13 (Haswell model)
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Henningsson <[email protected]>
commit 88cfcf86aa3ada84d97195bcad74f4dadb4ae23b upstream.
The external mic showed up with a precense detect of "always present", essentially disabling the internal mic. Therefore turn off presence detection for this pin.
Note: The external mic seems not yet working, but an internal mic is certainly better than no mic at all.
--- sound/pci/hda/patch_realtek.c | 9 +++++++++ 1 file changed, 9 insertions(+)
sound/pci/hda/patch_realtek.c +9 -0
@@ -3331,6 +3331,7 @@ enum {ALC269_FIXUP_HP_GPIO_LED ,ALC269_FIXUP_INV_DMIC ,ALC269_FIXUP_LENOVO_DOCK , +ALC286_FIXUP_SONY_MIC_NO_PRESENCE ,ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT ,ALC269_FIXUP_DELL1_MIC_NO_PRESENCE , ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
@@ -3529,6 +3530,13 @@ static const struct hda_fixup alc269_fix .type = HDA_FIXUP_FUNC, .v.func = alc_fixup_headset_mode_no_hp_mic, }, + [ALC286_FIXUP_SONY_MIC_NO_PRESENCE] = { + .type = HDA_FIXUP_PINS, + .v.pins = (const struct hda_pintbl []) { + {0x18 ,0x01a1913c },/* use as headset mic, without its own jack detect */ + { } + }, + }, [ALC269_FIXUP_ASUS_X101_FUNC] = { .type = HDA_FIXUP_FUNC, .v.func = alc269_fixup_x101_headset_mic,
@@ -3651,6 +3659,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x1043 ,0x8398 ,"ASUS P1005" ,ALC269_FIXUP_STEREO_DMIC ),SND_PCI_QUIRK (0x1043 ,0x83ce ,"ASUS P1005" ,ALC269_FIXUP_STEREO_DMIC ),SND_PCI_QUIRK (0x1043 ,0x8516 ,"ASUS X101CH" ,ALC269_FIXUP_ASUS_X101 ), +SND_PCI_QUIRK (0x104d ,0x90b6 ,"Sony VAIO Pro 13" ,ALC286_FIXUP_SONY_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x104d ,0x9073 ,"Sony VAIO" ,ALC275_FIXUP_SONY_VAIO_GPIO2 ),SND_PCI_QUIRK (0x104d ,0x907b ,"Sony VAIO" ,ALC275_FIXUP_SONY_HWEQ ), SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
Greg Kroah-Hartman
maintainerPATCH 5/50 random: run random_int_secret_init() run after all late_initcalls
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
commit 47d06e532e95b71c0db3839ebdef3fe8812fca2c upstream.
The some platforms (e.g., ARM) initializes their clocks as late_initcalls for some unknown reason. So make sure random_int_secret_init() is run after all of the late_initcalls are run.
--- drivers/char/random.c | 3 +-- include/linux/random.h | 1 + init/main.c | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-)
drivers/char/random.c +1 -2
@@ -1462,12 +1462,11 @@ struct ctl_table random_table[] = {static u32 random_int_secret[MD5_MESSAGE_BYTES /4 ]____cacheline_aligned ; -static int __init random_int_secret_init (void ) +int random_int_secret_init (void ) {get_random_bytes (random_int_secret,sizeof (random_int_secret));return 0 ; } -late_initcall (random_int_secret_init);/* * Get a random word for internal kernel use only. Similar to urandom but
include/linux/random.h +1 -0
@@ -17,6 +17,7 @@ extern void add_interrupt_randomness(intextern 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 ]); +extern int random_int_secret_init (void );#ifndef MODULE extern const struct file_operations random_fops, urandom_fops;
init/main.c +2 -0
@@ -75,6 +75,7 @@#include <linux/blkdev.h> #include <linux/elevator.h> #include <linux/sched_clock.h> +#include <linux/random.h> #include <asm/io.h> #include <asm/bugs.h>
@@ -778,6 +779,7 @@ static void __init do_basic_setup(void)do_ctors ();usermodehelper_enable ();do_initcalls (); +random_int_secret_init (); }static void __init do_pre_smp_initcalls (void )
Greg Kroah-Hartman
maintainerPATCH 6/50 vfs: allow O_PATH file descriptors for fstatfs()
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <[email protected]>
commit 9d05746e7b16d8565dddbe3200faa1e669d23bbf upstream.
Olga reported that file descriptors opened with O_PATH do not work with fstatfs(), found during further development of ksh93's thread support.
There is no reason to not allow O_PATH file descriptors here (fstatfs is very much a path operation), so use "fdget_raw()". See commit 55815f70147d ("vfs: make O_PATH file descriptors usable for 'fstat()'") for a very similar issue reported for fstat() by the same team.
--- fs/statfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/statfs.c +1 -1
@@ -94,7 +94,7 @@ retry:int fd_statfs (int fd,struct kstatfs *st) { -struct fd f =fdget (fd); +struct fd f =fdget_raw (fd);int error = -EBADF ;if (f.file) { error =vfs_statfs (&f.file->f_path, st);
Greg Kroah-Hartman
maintainerPATCH 7/50 i2c: omap: Clear ARDY bit twice
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Taras Kondratiuk <[email protected]>
commit 4cdbf7d346e7461c3b93a26707c852e2c9db3753 upstream.
Initially commit cb527ede1bf6ff2008a025606f25344b8ed7b4ac "i2c-omap: Double clear of ARDY status in IRQ handler" added a workaround for undocumented errata ProDB0017052. But then commit 1d7afc95946487945cc7f5019b41255b72224b70 "i2c: omap: ack IRQ in parts" refactored code and missed one of ARDY clearings. So current code violates errata. It causes often i2c bus timeouts on my Pandaboard.
This patch adds a second clearing in place.
--- drivers/i2c/busses/i2c-omap.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/i2c/busses/i2c-omap.c +3 -0
@@ -944,6 +944,9 @@ omap_i2c_isr_thread(int this_irq, void */* * ProDB0017052: Clear ARDY bit twice */ +if (stat &OMAP_I2C_STAT_ARDY ) +omap_i2c_ack_stat (dev,OMAP_I2C_STAT_ARDY ); +if (stat & (OMAP_I2C_STAT_ARDY |OMAP_I2C_STAT_NACK |OMAP_I2C_STAT_AL )) { omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_RRDY |
Greg Kroah-Hartman
maintainerPATCH 8/50 hwmon: (applesmc) Always read until end of data
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henrik Rydberg <[email protected]>
commit 25f2bd7f5add608c1d1405938f39c96927b275ca upstream.
The crash reported and investigated in commit 5f4513 turned out to be caused by a change to the read interface on newer (2012) SMCs.
Tests by Chris show that simply reading the data valid line is enough for the problem to go away. Additional tests show that the newer SMCs no longer wait for the number of requested bytes, but start sending data right away. Apparently the number of bytes to read is no longer specified as before, but instead found out by reading until end of data. Failure to read until end of data confuses the state machine, which eventually causes the crash.
As a remedy, assuming bit0 is the read valid line, make sure there is nothing more to read before leaving the read function.
Tested to resolve the original problem, and runtested on MBA3,1, MBP4,1, MBP8,2, MBP10,1, MBP10,2. The patch seems to have no effect on machines before 2012.
--- drivers/hwmon/applesmc.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/hwmon/applesmc.c +13 -0
@@ -230,6 +230,7 @@ static int send_argument(const char *keystatic int read_smc (u8 cmd,const char *key,u8 *buffer,u8 len) { +u8 status, data =0 ;int i;if (send_command (cmd) ||send_argument (key)) {
@@ -237,6 +238,7 @@ static int read_smc(u8 cmd, const char *return -EIO ; } +/* This has no effect on newer (2012) SMCs */ if (send_byte (len,APPLESMC_DATA_PORT )) {pr_warn ("%.4s: read len fail\n" , key);return -EIO ;
@@ -250,6 +252,17 @@ static int read_smc(u8 cmd, const char * buffer[i] =inb (APPLESMC_DATA_PORT ); } +/* Read the data port until bit0 is cleared */ +for (i =0 ; i <16 ; i++) { +udelay (APPLESMC_MIN_WAIT ); + status =inb (APPLESMC_CMD_PORT ); +if (!(status &0x01 )) +break ; + data =inb (APPLESMC_DATA_PORT ); + } +if (i) +pr_warn ("flushed %d bytes, last value is: %d\n" , i, data); +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 9/50 Btrfs: use right root when checking for hash collision
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit 4871c1588f92c6c13f4713a7009f25f217055807 upstream.
btrfs_rename was using the root of the old dir instead of the root of the new dir when checking for a hash collision, so if you tried to move a file into a subvol it would freak out because it would see the file you are trying to move in its current root. This fixes the bug where this would fail
btrfs subvol create test1
btrfs subvol create test2
mv test1 test2.
Thanks to Chris Murphy for catching this,
--- fs/btrfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/inode.c +1 -1
@@ -8036,7 +8036,7 @@ static int btrfs_rename(struct inode *ol/* check for collisions, even if the name isn't there */ - ret =btrfs_check_dir_item_collision (root, new_dir->i_ino, + ret =btrfs_check_dir_item_collision (dest, new_dir->i_ino, new_dentry->d_name.name, new_dentry->d_name.len);
Greg Kroah-Hartman
maintainerPATCH 10/50 ext4: fix memory leak in xattr
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jones <[email protected]>
commit 6e4ea8e33b2057b85d75175dd89b93f5e26de3bc upstream.
If we take the 2nd retry path in ext4_expand_extra_isize_ea, we potentionally return from the function without having freed these allocations. If we don't do the return, we over-write the previous allocation pointers, so we leak either way.
Spotted with Coverity.
[ Fixed by tytso to set is and bs to NULL after freeing these
pointers, in case in the retry loop we later end up triggering an error causing a jump to cleanup, at which point we could have a double free bug. -- Ted ]
--- fs/ext4/xattr.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ext4/xattr.c +2 -0
@@ -1350,6 +1350,8 @@ retry: s_min_extra_isize) { tried_min_extra_isize++; new_extra_isize = s_min_extra_isize; +kfree (is); is =NULL ; +kfree (bs); bs =NULL ; goto retry; } error =-1 ;
Greg Kroah-Hartman
maintainerPATCH 11/50 KVM: PPC: Book3S HV: Fix typo in saving DSCR
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Mackerras <[email protected]>
commit cfc860253abd73e1681696c08ea268d33285a2c4 upstream.
This fixes a typo in the code that saves the guest DSCR (Data Stream Control Register) into the kvm_vcpu_arch struct on guest exit. The effect of the typo was that the DSCR value was saved in the wrong place, so changes to the DSCR by the guest didn't persist across guest exit and entry, and some host kernel memory got corrupted.
--- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kvm/book3s_hv_rmhandlers.S +1 -1
@@ -1054,7 +1054,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) BEGIN_FTR_SECTION mfspr r8, SPRN_DSCR ld r7, HSTATE_DSCR(r13) - std r8, VCPU_DSCR(r7) + std r8, VCPU_DSCR(r9) mtspr SPRN_DSCR, r7 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
Greg Kroah-Hartman
maintainerPATCH 12/50 parisc: fix interruption handler to respect pagefault_disable()
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit 59b33f148cc08fb33cbe823fca1e34f7f023765e upstream.
Running an "echo t > /proc/sysrq-trigger" crashes the parisc kernel. The problem is, that in print_worker_info() we try to read the workqueue info via the probe_kernel_read() functions which use pagefault_disable() to avoid crashes like this:
probe_kernel_read(&pwq, &worker->current_pwq, sizeof(pwq));
probe_kernel_read(&wq, &pwq->wq, sizeof(wq));
probe_kernel_read(name, wq->name, sizeof(name) - 1);The problem here is, that the first probe_kernel_read(&pwq) might return zero in pwq and as such the following probe_kernel_reads() try to access contents of the page zero which is read protected and generate a kernel segfault.
With this patch we fix the interruption handler to call parisc_terminate() directly only if pagefault_disable() was not called (in which case preempt_count()==0). Otherwise we hand over to the pagefault handler which will try to look up the faulting address in the fixup tables.
--- arch/parisc/kernel/traps.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/parisc/kernel/traps.c +3 -3
@@ -805,14 +805,14 @@ void notrace handle_interruption(int codelse {/* -* The kernel should never fault on its own address space. +* The kernel should never fault on its own address space, +* unless pagefault_disable() was called before. */ -if (fault_space ==0 ) +if (fault_space ==0 && !in_atomic ()) {pdc_chassis_send_status (PDC_CHASSIS_DIRECT_PANIC );parisc_terminate ("Kernel Fault" , regs, code, fault_address); - } }
Greg Kroah-Hartman
maintainerPATCH 13/50 ARC: Fix __udelay calculation
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mischa Jonker <[email protected]>
commit 7efd0da2d17360e1cef91507dbe619db0ee2c691 upstream.
Cast usecs to u64, to ensure that the (usecs * 4295 * HZ) multiplication is 64 bit.
Initially, the (usecs * 4295 * HZ) part was done as a 32 bit multiplication, with the result casted to 64 bit. This led to some bits falling off, causing a "DMA initialization error" in the stmmac Ethernet driver, due to a premature timeout.
--- arch/arc/include/asm/delay.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/arc/include/asm/delay.h +2 -3
@@ -53,11 +53,10 @@ static inline void __udelay(unsigned lon {unsigned long loops; -/* (long long) cast ensures 64 bit MPY - real or emulated +/* (u64) cast ensures 64 bit MPY - real or emulated * HZ * 4295 is pre-evaluated by gcc - hence only 2 mpy ops */ - loops = ((long long )(usecs *4295 *HZ ) * - (long long )(loops_per_jiffy)) >>32 ; + loops = ((u64 ) usecs *4295 *HZ * loops_per_jiffy) >>32 ;__delay (loops); }
Greg Kroah-Hartman
maintainerPATCH 14/50 ARC: Handle zero-overhead-loop in unaligned access handler
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mischa Jonker <[email protected]>
commit c11eb222fd7d4db91196121dbf854178505d2751 upstream.
If a load or store is the last instruction in a zero-overhead-loop, and it's misaligned, the loop would execute only once.
This fixes that problem.
--- arch/arc/kernel/unaligned.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arc/kernel/unaligned.c +6 -0
@@ -233,6 +233,12 @@ int misaligned_fixup(unsigned long addre regs->status32 &= ~STATUS_DE_MASK ; }else { regs->ret += state.instr_len; + +/* handle zero-overhead-loop */ +if ((regs->ret == regs->lp_end) && (regs->lp_count)) { + regs->ret = regs->lp_start; + regs->lp_count--; + } }return 0 ;
Greg Kroah-Hartman
maintainerPATCH 15/50 ARC: Fix 32-bit wrap around in access_ok()
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vineet Gupta <[email protected]>
commit 0752adfda15f0eca9859a76da3db1800e129ad43 upstream.
Anton reported
| LTP tests syscalls/process_vm_readv01 and process_vm_writev01 fail | similarly in one testcase test_iov_invalid -> lvec->iov_base. | Testcase expects errno EFAULT and return code -1, | but it gets return code 1 and ERRNO is 0 what means success.
Essentially test case was passing a pointer of -1 which access_ok() was not catching. It was doing [@addr + @sz <= TASK_SIZE] which would pass for @addr == -1
Fixed that by rewriting as [@addr <= TASK_SIZE - @sz]
--- arch/arc/include/asm/uaccess.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arc/include/asm/uaccess.h +2 -2
@@ -43,7 +43,7 @@* Because it essentially checks if buffer end is within limit and @len is * non-ngeative, which implies that buffer start will be within limit too. * -* The reason for rewriting being, for majorit yof cases, @len is generally +* The reason for rewriting being, for majority of cases, @len is generally * compile time constant, causing first sub-expression to be compile time * subsumed. *
@@ -53,7 +53,7 @@* */ #define __user_ok (addr, sz) (((sz) <= TASK_SIZE) && \ - (((addr)+(sz)) <= get_fs())) + ((addr) <= (get_fs() - (sz))))#define __access_ok (addr, sz) (unlikely(__kernel_ok) || \ likely(__user_ok((addr), (sz))))
Greg Kroah-Hartman
maintainerPATCH 16/50 ARC: Workaround spinlock livelock in SMP SystemC simulation
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vineet Gupta <[email protected]>
commit 6c00350b573c0bd3635436e43e8696951dd6e1b6 upstream.
Some ARC SMP systems lack native atomic R-M-W (LLOCK/SCOND) insns and can only use atomic EX insn (reg with mem) to build higher level R-M-W primitives. This includes a SystemC based SMP simulation model.
So rwlocks need to use a protecting spinlock for atomic cmp-n-exchange operation to update reader(s)/writer count.
The spinlock operation itself looks as follows:
mov reg, 1 ; 1=locked, 0=unlocked
retry:
EX reg, [lock] ; load existing, store 1, atomically
BREQ reg, 1, rety ; if already locked, retry
In single-threaded simulation, SystemC alternates between the 2 cores with "N" insn each based scheduling. Additionally for insn with global side effect, such as EX writing to shared mem, a core switch is enforced too.
Given that, 2 cores doing a repeated EX on same location, Linux often got into a livelock e.g. when both cores were fiddling with tasklist lock (gdbserver / hackbench) for read/write respectively as the sequence diagram below shows:
core1 core2
-------- --------
1. spin lock [EX r=0, w=1] - LOCKED
2. rwlock(Read) - LOCKED
3. spin unlock [ST 0] - UNLOCKED
spin lock [EX r=0,w=1] - LOCKED
-- resched core 1----5. spin lock [EX r=1] - ALREADY-LOCKED
-- resched core 2---- 6. rwlock(Write) - READER-LOCKED 7. spin unlock [ST 0] 8. rwlock failed, retry again
9. spin lock [EX r=0, w=1]
-- resched core 1----
10 spinlock locked in #9, retry #5
11. spin lock [EX gets 1]
-- resched core 2----
...
...
The fix was to unlock using the EX insn too (step 7), to trigger another SystemC scheduling pass which would let core1 proceed, eliding the livelock.
--- arch/arc/include/asm/spinlock.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
arch/arc/include/asm/spinlock.h +8 -1
@@ -45,7 +45,14 @@ static inline int arch_spin_trylock(archstatic inline void arch_spin_unlock (arch_spinlock_t *lock) { - lock->slock = __ARCH_SPIN_LOCK_UNLOCKED__; +unsigned int tmp = __ARCH_SPIN_LOCK_UNLOCKED__; + + __asm__ __volatile__( +" ex %0, [%1] \n" + :"+r" (tmp) + :"r" (&(lock->slock)) + :"memory" ); +smp_mb (); }
Greg Kroah-Hartman
maintainerPATCH 17/50 ARC: Fix signal frame management for SA_SIGINFO
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Ruppert <[email protected]>
commit 10469350e345599dfef3fa78a7c19fb230e674c1 upstream.
Previously, when a signal was registered with SA_SIGINFO, parameters 2 and 3 of the signal handler were written to registers r1 and r2 before the register set was saved. This led to corruption of these two registers after returning from the signal handler (the wrong values were restored).
With this patch, registers are now saved before any parameters are passed, thus maintaining the processor state from before signal entry.
--- arch/arc/kernel/signal.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-)
arch/arc/kernel/signal.c +13 -12
@@ -101,7 +101,6 @@ SYSCALL_DEFINE0(rt_sigreturn) {struct rt_sigframe __user *sf;unsigned int magic; -int err;struct pt_regs *regs =current_pt_regs ();/* Always make any pending restarted system calls return -EINTR */
@@ -119,15 +118,16 @@ SYSCALL_DEFINE0(rt_sigreturn)if (!access_ok (VERIFY_READ , sf,sizeof (*sf))) goto badframe; - err =restore_usr_regs (regs, sf); - err |=__get_user (magic, &sf->sigret_magic); -if (err) +if (__get_user (magic, &sf->sigret_magic)) goto badframe;if (unlikely (is_do_ss_needed (magic)))if (restore_altstack (&sf->uc.uc_stack)) goto badframe; +if (restore_usr_regs (regs, sf)) + goto badframe; +/* Don't restart from sigreturn */ syscall_wont_restart (regs);
@@ -191,6 +191,15 @@ setup_rt_frame(int signo, struct k_sigacreturn 1 ;/* +* w/o SA_SIGINFO, struct ucontext is partially populated (only +* uc_mcontext/uc_sigmask) for kernel's normal user state preservation +* during signal handler execution. This works for SA_SIGINFO as well +* although the semantics are now overloaded (the same reg state can be +* inspected by userland: but are they allowed to fiddle with it ? +*/ + err |=stash_usr_regs (sf, regs, set); + +/* * SA_SIGINFO requires 3 args to signal handler: * #1: sig-no (common to any handler) * #2: struct siginfo
@@ -213,14 +222,6 @@ setup_rt_frame(int signo, struct k_sigac magic =MAGIC_SIGALTSTK ; } -/* -* w/o SA_SIGINFO, struct ucontext is partially populated (only -* uc_mcontext/uc_sigmask) for kernel's normal user state preservation -* during signal handler execution. This works for SA_SIGINFO as well -* although the semantics are now overloaded (the same reg state can be -* inspected by userland: but are they allowed to fiddle with it ? -*/ - err |=stash_usr_regs (sf, regs, set); err |=__put_user (magic, &sf->sigret_magic);if (err)return err;
Greg Kroah-Hartman
maintainerPATCH 18/50 ARC: Ignore ptrace SETREGSET request for synthetic register "stop_pc"
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vineet Gupta <[email protected]>
commit 5b24282846c064ee90d40fcb3a8f63b8e754fd28 upstream.
ARCompact TRAP_S insn used for breakpoints, commits before exception is taken (updating architectural PC). So ptregs->ret contains next-PC and not the breakpoint PC itself. This is different from other restartable exceptions such as TLB Miss where ptregs->ret has exact faulting PC. gdb needs to know exact-PC hence ARC ptrace GETREGSET provides for @stop_pc which returns ptregs->ret vs. EFA depending on the situation.
However, writing stop_pc (SETREGSET request), which updates ptregs->ret doesn't makes sense stop_pc doesn't always correspond to that reg as described above.
This was not an issue so far since user_regs->ret / user_regs->stop_pc had same value and both writing to ptregs->ret was OK, needless, but NOT broken, hence not observed.
With gdb "jump", they diverge, and user_regs->ret updating ptregs is overwritten immediately with stop_pc, which this patch fixes.
--- arch/arc/kernel/ptrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arc/kernel/ptrace.c +1 -1
@@ -102,7 +102,7 @@ static int genregs_set(struct task_strucREG_IGNORE_ONE (pad2);REG_IN_CHUNK (callee, efa, cregs);/* callee_regs[r25..r13] */ REG_IGNORE_ONE (efa);/* efa update invalid */ -REG_IN_ONE (stop_pc, &ptregs->ret);/* stop_pc: PC update */ +REG_IGNORE_ONE (stop_pc);/* PC updated via @ret */ return ret; }
Greg Kroah-Hartman
maintainerPATCH 19/50 watchdog: ts72xx_wdt: locking bug in ioctl
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 8612ed0d97abcf1c016d34755b7cf2060de71963 upstream.
Calling the WDIOC_GETSTATUS & WDIOC_GETBOOTSTATUS and twice will cause a interruptible deadlock.
--- drivers/watchdog/ts72xx_wdt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/watchdog/ts72xx_wdt.c +2 -1
@@ -310,7 +310,8 @@ static long ts72xx_wdt_ioctl(struct filecase WDIOC_GETSTATUS :case WDIOC_GETBOOTSTATUS : -return put_user (0 , p); + error =put_user (0 , p); +break ;case WDIOC_KEEPALIVE :ts72xx_wdt_kick (wdt);
Greg Kroah-Hartman
maintainerPATCH 20/50 watchdog: kempld_wdt: Fix bit mask definition
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jingoo Han <[email protected]>
commit 4c4e45669de475573b15d968a6dca8d00124c9ad upstream.
STAGE_CFG bits are defined as [5:4] bits. However, '(((x) & 0x30) << 4)' handles [9:8] bits. Thus, it should be fixed in order to handle [5:4] bits.
--- drivers/watchdog/kempld_wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/kempld_wdt.c +1 -1
@@ -35,7 +35,7 @@#define KEMPLD_WDT_STAGE_TIMEOUT (x) (0x1b + (x) * 4)#define KEMPLD_WDT_STAGE_CFG (x) (0x18 + (x))#define STAGE_CFG_GET_PRESCALER (x) (((x) & 0x30) >> 4) -#define STAGE_CFG_SET_PRESCALER (x) (((x) & 0x30) << 4) +#define STAGE_CFG_SET_PRESCALER (x) (((x) & 0x3) << 4)#define STAGE_CFG_PRESCALER_MASK 0x30#define STAGE_CFG_ACTION_MASK 0x7#define STAGE_CFG_ASSERT (1 << 3)
Greg Kroah-Hartman
maintainerPATCH 21/50 MIPS: stack protector: Fix per-task canary switch
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Hogan <[email protected]>
commit 8b3c569a3999a8fd5a819f892525ab5520777c92 upstream.
Commit 1400eb6 (MIPS: r4k,octeon,r2300: stack protector: change canary per task) was merged in v3.11 and introduced assembly in the MIPS resume functions to update the value of the current canary in __stack_chk_guard. However it used PTR_L resulting in a load of the canary value, instead of PTR_LA to construct its address. The value is intended to be random but is then treated as an address in the subsequent LONG_S (store).
This was observed to cause a fault and panic:
CPU 0 Unable to handle kernel paging request at virtual address 139fea20, epc == 8000cc0c, ra == 8034f2a4 Oops[#1]:
...
$24 : 139fea20 1e1f7cb6
...
Call Trace: [<8000cc0c>] resume+0xac/0x118 [<8034f2a4>] __schedule+0x5f8/0x78c [<8034f4e0>] schedule_preempt_disabled+0x20/0x2c [<80348eec>] rest_init+0x74/0x84 [<804dc990>] start_kernel+0x43c/0x454 Code: 3c18804b 8f184030 8cb901f8 <af190000> 00c0e021 8cb002f0 8cb102f4 8cb202f8 8cb302fc
This can also be forced by modifying arch/mips/include/asm/stackprotector.h so that the default __stack_chk_guard value is more likely to be a bad (or unaligned) pointer.
Fix it to use PTR_LA instead, to load the address of the canary value, which the LONG_S can then use to write into it.
Patchwork: https://patchwork.linux-mips.org/patch/6026/
--- arch/mips/kernel/octeon_switch.S | 2 +- arch/mips/kernel/r2300_switch.S | 2 +- arch/mips/kernel/r4k_switch.S | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
arch/mips/kernel/octeon_switch.S +1 -1
@@ -73,7 +73,7 @@ 3: #if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP) - PTR_L t8, __stack_chk_guard + PTR_LA t8, __stack_chk_guard LONG_L t9, TASK_STACK_CANARY(a1) LONG_S t9, 0(t8) #endif
arch/mips/kernel/r2300_switch.S +1 -1
@@ -67,7 +67,7 @@ LEAF(resume) 1: #if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP) - PTR_L t8, __stack_chk_guard + PTR_LA t8, __stack_chk_guard LONG_L t9, TASK_STACK_CANARY(a1) LONG_S t9, 0(t8) #endif
arch/mips/kernel/r4k_switch.S +1 -1
@@ -69,7 +69,7 @@ 1: #if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP) - PTR_L t8, __stack_chk_guard + PTR_LA t8, __stack_chk_guard LONG_L t9, TASK_STACK_CANARY(a1) LONG_S t9, 0(t8) #endif
Greg Kroah-Hartman
maintainerPATCH 22/50 drm/radeon/dpm/btc: off by one in btc_set_mc_special_registers()
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 96d8df846f52a720c8ae1fadadfad7c9e733e336 upstream.
It should be ">=" instead of ">" here. The table->mc_reg_address[] array has SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE (16) elements.
--- drivers/gpu/drm/radeon/btc_dpm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/radeon/btc_dpm.c +3 -3
@@ -1913,7 +1913,7 @@ static int btc_set_mc_special_registers( } j++; -if (j >SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE ) +if (j >=SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE )return -EINVAL ; tmp =RREG32 (MC_PMG_CMD_MRS );
@@ -1928,7 +1928,7 @@ static int btc_set_mc_special_registers( } j++; -if (j >SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE ) +if (j >=SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE )return -EINVAL ;break ;case MC_SEQ_RESERVE_M >>2 :
@@ -1942,7 +1942,7 @@ static int btc_set_mc_special_registers( } j++; -if (j >SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE ) +if (j >=SMC_EVERGREEN_MC_REGISTER_ARRAY_SIZE )return -EINVAL ;break ;default :
Greg Kroah-Hartman
maintainerPATCH 23/50 compiler/gcc4: Add quirk for asm goto miscompilation bug
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ingo Molnar <[email protected]>
commit 3f0116c3238a96bc18ad4b4acefe4e7be32fa861 upstream.
Fengguang Wu, Oleg Nesterov and Peter Zijlstra tracked down a kernel crash to a GCC bug: GCC miscompiles certain 'asm goto' constructs, as outlined here:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
Implement a workaround suggested by Jakub Jelinek.
--- arch/arm/include/asm/jump_label.h | 2 +- arch/mips/include/asm/jump_label.h | 2 +- arch/powerpc/include/asm/jump_label.h | 2 +- arch/s390/include/asm/jump_label.h | 2 +- arch/sparc/include/asm/jump_label.h | 2 +- arch/x86/include/asm/cpufeature.h | 6 +++--- arch/x86/include/asm/jump_label.h | 2 +- include/linux/compiler-gcc4.h | 15 +++++++++++++++ 8 files changed, 24 insertions(+), 9 deletions(-)
arch/arm/include/asm/jump_label.h +1 -1
@@ -16,7 +16,7 @@ static __always_inline bool arch_static_branch(struct static_key *key) { - asm goto("1:\n\t" +asm_volatile_goto ("1:\n\t" JUMP_LABEL_NOP "\n\t" ".pushsection __jump_table, \"aw\"\n\t" ".word 1b, %l[l_yes], %c0\n\t"
arch/mips/include/asm/jump_label.h +1 -1
@@ -22,7 +22,7 @@ static __always_inline bool arch_static_branch(struct static_key *key) { - asm goto("1:\tnop\n\t" +asm_volatile_goto ("1:\tnop\n\t" "nop\n\t" ".pushsection __jump_table, \"aw\"\n\t" WORD_INSN " 1b, %l[l_yes], %0\n\t"
arch/powerpc/include/asm/jump_label.h +1 -1
@@ -19,7 +19,7 @@ static __always_inline bool arch_static_branch(struct static_key *key) { - asm goto("1:\n\t" +asm_volatile_goto ("1:\n\t" "nop\n\t" ".pushsection __jump_table, \"aw\"\n\t" JUMP_ENTRY_TYPE "1b, %l[l_yes], %c0\n\t"
arch/s390/include/asm/jump_label.h +1 -1
@@ -15,7 +15,7 @@ static __always_inline bool arch_static_branch(struct static_key *key) { - asm goto("0: brcl 0,0\n" +asm_volatile_goto ("0: brcl 0,0\n" ".pushsection __jump_table, \"aw\"\n" ASM_ALIGN "\n" ASM_PTR " 0b, %l[label], %0\n"
arch/sparc/include/asm/jump_label.h +1 -1
@@ -9,7 +9,7 @@ static __always_inline bool arch_static_branch(struct static_key *key) { - asm goto("1:\n\t" +asm_volatile_goto ("1:\n\t" "nop\n\t" "nop\n\t" ".pushsection __jump_table, \"aw\"\n\t"
arch/x86/include/asm/cpufeature.h +3 -3
@@ -373,7 +373,7 @@ static __always_inline __pure bool __sta* Catch too early usage of this before alternatives * have run. */ - asm goto("1: jmp %l[t_warn]\n" +asm_volatile_goto ("1: jmp %l[t_warn]\n" "2:\n" ".section .altinstructions,\"a\"\n" " .long 1b - .\n"
@@ -386,7 +386,7 @@ static __always_inline __pure bool __sta : : "i" (X86_FEATURE_ALWAYS) : : t_warn);#endif - asm goto("1: jmp %l[t_no]\n" +asm_volatile_goto ("1: jmp %l[t_no]\n" "2:\n" ".section .altinstructions,\"a\"\n" " .long 1b - .\n"
@@ -448,7 +448,7 @@ static __always_inline __pure bool _stat* have. Thus, we force the jump to the widest, 4-byte, signed relative * offset even though the last would often fit in less bytes. */ - asm goto("1: .byte 0xe9\n .long %l[t_dynamic] - 2f\n" +asm_volatile_goto ("1: .byte 0xe9\n .long %l[t_dynamic] - 2f\n" "2:\n" ".section .altinstructions,\"a\"\n" " .long 1b - .\n" /* src offset */
arch/x86/include/asm/jump_label.h +1 -1
@@ -13,7 +13,7 @@ static __always_inline bool arch_static_branch(struct static_key *key) { - asm goto("1:" +asm_volatile_goto ("1:" STATIC_KEY_INITIAL_NOP ".pushsection __jump_table, \"aw\" \n\t" _ASM_ALIGN "\n\t"
include/linux/compiler-gcc4.h +15 -0
@@ -65,6 +65,21 @@#define __visible __attribute__((externally_visible))#endif +/* +* GCC 'asm goto' miscompiles certain code sequences: +* +* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670 +* +* Work it around via a compiler barrier quirk suggested by Jakub Jelinek. +* Fixed in GCC 4.8.2 and later versions. +* +* (asm goto is automatically volatile - the naming reflects this.) +*/ +#if GCC_VERSION <=40801 +# define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0) +#else +# define asm_volatile_goto(x...) do { asm goto(x); } while (0) +#endif #ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP #if GCC_VERSION >=40400
Greg Kroah-Hartman
maintainerPATCH 24/50 ALSA: hda - Fix mono speakers and headset mic on Dell Vostro 5470
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Henningsson <[email protected]>
This is a backport for stable. The original commit SHA is 338cae565c53755de9f87d6a801517940d2d56f7.
On this machine, DAC on node 0x03 seems to give mono output.
Also, it needs additional patches for headset mic support. It supports CTIA style headsets only.
Alsa-info available at the bug link below.
--- sound/pci/hda/patch_realtek.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
sound/pci/hda/patch_realtek.c +27 -0
@@ -3308,6 +3308,15 @@ static void alc269_fixup_limit_int_mic_b } } +static void alc290_fixup_mono_speakers (struct hda_codec *codec, +const struct hda_fixup *fix,int action) +{ +if (action ==HDA_FIXUP_ACT_PRE_PROBE ) +/* Remove DAC node 0x03, as it seems to be +giving mono output */ +snd_hda_override_wcaps (codec,0x03 ,0 ); +} +enum {ALC269_FIXUP_SONY_VAIO ,ALC275_FIXUP_SONY_VAIO_GPIO2 ,
@@ -3335,6 +3344,8 @@ enum {ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT ,ALC269_FIXUP_DELL1_MIC_NO_PRESENCE ,ALC269_FIXUP_DELL2_MIC_NO_PRESENCE , +ALC269_FIXUP_DELL3_MIC_NO_PRESENCE , +ALC290_FIXUP_MONO_SPEAKERS ,ALC269_FIXUP_HEADSET_MODE ,ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC , ALC269_FIXUP_ASUS_X101_FUNC,
@@ -3522,6 +3533,15 @@ static const struct hda_fixup alc269_fix .chained = true, .chain_id =ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC }, + [ALC269_FIXUP_DELL3_MIC_NO_PRESENCE] = { + .type = HDA_FIXUP_PINS, + .v.pins = (const struct hda_pintbl []) { + {0x1a ,0x01a1913c },/* use as headset mic, without its own jack detect */ + { } + }, + .chained = true, + .chain_id =ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC + }, [ALC269_FIXUP_HEADSET_MODE] = { .type = HDA_FIXUP_FUNC, .v.func = alc_fixup_headset_mode,
@@ -3603,6 +3623,12 @@ static const struct hda_fixup alc269_fix { } }, }, + [ALC290_FIXUP_MONO_SPEAKERS ] = { + .type =HDA_FIXUP_FUNC , + .v.func = alc290_fixup_mono_speakers, + .chained = true, + .chain_id =ALC269_FIXUP_DELL3_MIC_NO_PRESENCE , + }, };static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -3639,6 +3665,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x1028 ,0x0608 ,"Dell" ,ALC269_FIXUP_DELL1_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1028 ,0x0609 ,"Dell" ,ALC269_FIXUP_DELL1_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1028 ,0x0613 ,"Dell" ,ALC269_FIXUP_DELL1_MIC_NO_PRESENCE ), +SND_PCI_QUIRK (0x1028 ,0x0616 ,"Dell Vostro 5470" ,ALC290_FIXUP_MONO_SPEAKERS ),SND_PCI_QUIRK (0x1028 ,0x15cc ,"Dell X5 Precision" ,ALC269_FIXUP_DELL2_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1028 ,0x15cd ,"Dell X5 Precision" ,ALC269_FIXUP_DELL2_MIC_NO_PRESENCE ), SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
Greg Kroah-Hartman
maintainerPATCH 25/50 drm/i915/hsw: Disable L3 caching of atomic memory operations.
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Francisco Jerez <[email protected]>
commit f3fc4884ebe6ae649d3723be14b219230d3b7fd2 upstream.
Otherwise using any atomic memory operation will lock up the GPU due to a Haswell hardware bug.
v2: Use the _MASKED_BIT_ENABLE macro. Drop drm parameter definition.
--- drivers/gpu/drm/i915/i915_reg.h | 6 ++++++ drivers/gpu/drm/i915/intel_pm.c | 5 +++++ 2 files changed, 11 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +6 -0
@@ -3791,6 +3791,9 @@#define GEN7_SQ_CHICKEN_MBCUNIT_CONFIG 0x9030#define GEN7_SQ_CHICKEN_MBCUNIT_SQINTMOB (1<<11) +#define HSW_SCRATCH1 0xb038 +#define HSW_SCRATCH1_L3_DATA_ATOMICS_DISABLE (1<<27) +#define HSW_FUSE_STRAP 0x42014#define HSW_CDCLK_LIMIT (1 << 24)
@@ -4624,6 +4627,9 @@#define GEN7_ROW_CHICKEN2_GT2 0xf4f4#define DOP_CLOCK_GATING_DISABLE (1<<0) +#define HSW_ROW_CHICKEN3 0xe49c +#define HSW_ROW_CHICKEN3_L3_GLOBAL_ATOMICS_DISABLE (1 << 6) +#define G4X_AUD_VID_DID (dev_priv->info->display_mmio_offset + 0x62020)#define INTEL_AUDIO_DEVCL 0x808629FB#define INTEL_AUDIO_DEVBLC 0x80862801
drivers/gpu/drm/i915/intel_pm.c +5 -0
@@ -4699,6 +4699,11 @@ static void haswell_init_clock_gating(stI915_WRITE (GEN7_L3_CHICKEN_MODE_REGISTER ,GEN7_WA_L3_CHICKEN_MODE ); +/* L3 caching of data atomics doesn't work -- disable it. */ +I915_WRITE (HSW_SCRATCH1 ,HSW_SCRATCH1_L3_DATA_ATOMICS_DISABLE ); +I915_WRITE (HSW_ROW_CHICKEN3 , +_MASKED_BIT_ENABLE (HSW_ROW_CHICKEN3_L3_GLOBAL_ATOMICS_DISABLE )); +/* This is required by WaCatErrorRejectionIssue:hsw */ I915_WRITE(GEN7_SQ_CHICKEN_MBCUNIT_CONFIG, I915_READ(GEN7_SQ_CHICKEN_MBCUNIT_CONFIG) |
Greg Kroah-Hartman
maintainerPATCH 26/50 drm/i915: Only apply DPMS to the encoder if enabled
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Wilson <[email protected]>
commit c9976dcf55c8aaa7037427b239f15e5acfc01a3a upstream.
The current test for an attached enabled encoder fails if we have multiple connectors aliased to the same encoder - both connectors believe they own the enabled encoder and so we attempt to both enable and disable DPMS on the encoder, leading to hilarity and an OOPs:
[ 354.803064] WARNING: CPU: 0 PID: 482 at /usr/src/linux/dist/3.11.2/drivers/gpu/drm/i915/intel_display.c:3869 intel_modeset_check_state+0x764/0x770 [i915]() [ 354.803064] wrong connector dpms state [ 354.803084] Modules linked in: nfsd auth_rpcgss oid_registry exportfs nfs lockd sunrpc xt_nat iptable_nat nf_nat_ipv4 nf_nat xt_limit xt_LOG xt_tcpudp nf_conntrack_ipv4 nf_defrag_ipv4 ipt_REJECT ipv6 xt_recent xt_conntrack nf_conntrack iptable_filter ip_tables x_tables snd_hda_codec_realtek snd_hda_codec_hdmi x86_pkg_temp_thermal snd_hda_intel coretemp kvm_intel snd_hda_codec i915 kvm snd_hwdep snd_pcm_oss snd_mixer_oss crc32_pclmul snd_pcm crc32c_intel e1000e intel_agp igb ghash_clmulni_intel intel_gtt aesni_intel cfbfillrect aes_x86_64 cfbimgblt lrw cfbcopyarea drm_kms_helper ptp video thermal processor gf128mul snd_page_alloc drm snd_timer glue_helper 8250_pci snd pps_core ablk_helper agpgart cryptd sg soundcore fan i2c_algo_bit sr_mod thermal_sys 8250 i2c_i801 serial_core hwmon cdrom i2c_core evdev button [ 354.803086] CPU: 0 PID: 482 Comm: kworker/0:1 Not tainted 3.11.2 #1 [ 354.803087] Hardware name: Supermicro X10SAE/X10SAE, BIOS 1.00 05/03/2013 [ 354.803091] Workqueue: events console_callback [ 354.803092] 0000000000000009 ffff88023611db48 ffffffff814048ac ffff88023611db90 [ 354.803093] ffff88023611db80 ffffffff8103d4e3 ffff880230d82800 ffff880230f9b800 [ 354.803094] ffff880230f99000 ffff880230f99448 ffff8802351c0e00 ffff88023611dbe0 [ 354.803094] Call Trace: [ 354.803098] [<ffffffff814048ac>] dump_stack+0x54/0x8d [ 354.803101] [<ffffffff8103d4e3>] warn_slowpath_common+0x73/0x90 [ 354.803103] [<ffffffff8103d547>] warn_slowpath_fmt+0x47/0x50 [ 354.803109] [<ffffffffa089f1be>] ? intel_ddi_connector_get_hw_state+0x5e/0x110 [i915] [ 354.803114] [<ffffffffa0896974>] intel_modeset_check_state+0x764/0x770 [i915] [ 354.803117] [<ffffffffa08969bb>] intel_connector_dpms+0x3b/0x60 [i915] [ 354.803120] [<ffffffffa037e1d0>] drm_fb_helper_dpms.isra.11+0x120/0x160 [drm_kms_helper] [ 354.803122] [<ffffffffa037e24e>] drm_fb_helper_blank+0x3e/0x80 [drm_kms_helper] [ 354.803123] [<ffffffff812116c2>] fb_blank+0x52/0xc0 [ 354.803125] [<ffffffff8121e04b>] fbcon_blank+0x21b/0x2d0 [ 354.803127] [<ffffffff81062243>] ? update_rq_clock.part.74+0x13/0x30 [ 354.803129] [<ffffffff81047486>] ? lock_timer_base.isra.30+0x26/0x50 [ 354.803130] [<ffffffff810472b2>] ? internal_add_timer+0x12/0x40 [ 354.803131] [<ffffffff81047f48>] ? mod_timer+0xf8/0x1c0 [ 354.803133] [<ffffffff81266d61>] do_unblank_screen+0xa1/0x1c0 [ 354.803134] [<ffffffff81268087>] poke_blanked_console+0xc7/0xd0 [ 354.803136] [<ffffffff812681cf>] console_callback+0x13f/0x160 [ 354.803137] [<ffffffff81053258>] process_one_work+0x148/0x3d0 [ 354.803138] [<ffffffff81053f19>] worker_thread+0x119/0x3a0 [ 354.803140] [<ffffffff81053e00>] ? manage_workers.isra.30+0x2a0/0x2a0 [ 354.803141] [<ffffffff8105994b>] kthread+0xbb/0xc0 [ 354.803142] [<ffffffff81059890>] ? kthread_create_on_node+0x120/0x120 [ 354.803144] [<ffffffff8140b32c>] ret_from_fork+0x7c/0xb0 [ 354.803145] [<ffffffff81059890>] ? kthread_create_on_node+0x120/0x120
This regression goes back to the big modeset rework and the conversion to the new dpms helpers which started with:
commit 5ab432ef4997ce32c9406721b37ef6e97e57dae1
Author: Daniel Vetter <[email protected]> Date: Sat Jun 30 08:59:56 2012 +0200
drm/i915/hdmi: convert to encoder->disable/enable
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=68030
[danvet: Add regression citation, mention the igt testcase this fixes and slap a cc: stable on the patch.]
--- drivers/gpu/drm/i915/intel_display.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_display.c +2 -6
@@ -3890,8 +3890,6 @@ static void intel_connector_check_state(* consider. */ void intel_connector_dpms (struct drm_connector *connector,int mode) { -struct intel_encoder *encoder =intel_attached_encoder (connector); -/* All the simple cases only support two dpms states. */ if (mode !=DRM_MODE_DPMS_ON ) mode =DRM_MODE_DPMS_OFF ;
@@ -3902,10 +3900,8 @@ void intel_connector_dpms(struct drm_con connector->dpms = mode;/* Only need to change hw state when actually enabled */ -if (encoder->base.crtc) -intel_encoder_dpms (encoder, mode); -else -WARN_ON (encoder->connectors_active != false); +if (connector->encoder) +intel_encoder_dpms (to_intel_encoder (connector->encoder), mode);intel_modeset_check_state (connector->dev); }
Greg Kroah-Hartman
maintainerPATCH 27/50 drm/i915: fix rps.vlv_work initialization
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Deak <[email protected]>
commit 671952a2a290a90017c64e75b7dd0343b0d005b4 upstream.
During driver loading we are initializing rps.vlv_work in valleyview_enable_rps() via the rps.delayed_resume_work delayed work. This is too late since we are using vlv_work already via i915_driver_load()->intel_uncore_sanitize()-> intel_disable_gt_powersave(). This at least leads to the following kernel warning:
INFO: trying to register non-static key.
the code is fine but needs lockdep annotation.
turning off the locking correctness validator.
Fix this by initialzing vlv_work before we call intel_uncore_sanitize().
The regression was introduced in
commit 7dcd2677ea912573d9ed4bcd629b0023b2d11505
Author: Konstantin Khlebnikov <[email protected]> Date: Wed Jul 17 10:22:58 2013 +0400
drm/i915: fix long-standing SNB regression in power consumption after resume
though there was no good reason to initialize the static vlv_work from another delayed work to begin with (especially since this will happen multiple times).
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=69397
--- drivers/gpu/drm/i915/intel_pm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +2 -2
@@ -3603,8 +3603,6 @@ static void valleyview_enable_rps(struct dev_priv->rps.rpe_delay), dev_priv->rps.rpe_delay); -INIT_DELAYED_WORK (&dev_priv->rps.vlv_work, vlv_rps_timer_work); -valleyview_set_rps (dev_priv->dev, dev_priv->rps.rpe_delay);/* requires MSI enabled */
@@ -5567,6 +5565,8 @@ void intel_pm_init(struct drm_device *deINIT_DELAYED_WORK (&dev_priv->rps.delayed_resume_work, intel_gen6_powersave_work); + +INIT_DELAYED_WORK (&dev_priv->rps.vlv_work, vlv_rps_timer_work); }int sandybridge_pcode_read (struct drm_i915_private *dev_priv,u8 mbox,u32 *val)
Greg Kroah-Hartman
maintainerPATCH 28/50 drm/radeon/dpm: off by one in si_set_mc_special_registers()
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 5fd9c581862a4874c0bdaf16231d8873832bbb99 upstream.
These checks should be ">=" instead of ">". j is used as an offset into the table->mc_reg_address[] array and that has SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE (16) elements.
--- drivers/gpu/drm/radeon/si_dpm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/radeon/si_dpm.c +3 -3
@@ -5174,7 +5174,7 @@ static int si_set_mc_special_registers(s table->mc_reg_table_entry[k].mc_data[j] |=0x100 ; } j++; -if (j >SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE ) +if (j >=SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE )return -EINVAL ;if (!pi->mem_gddr5) {
@@ -5184,7 +5184,7 @@ static int si_set_mc_special_registers(s table->mc_reg_table_entry[k].mc_data[j] = (table->mc_reg_table_entry[k].mc_data[i] &0xffff0000 ) >>16 ; j++; -if (j >SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE ) +if (j >=SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE )return -EINVAL ; }break ;
@@ -5197,7 +5197,7 @@ static int si_set_mc_special_registers(s (temp_reg &0xffff0000 ) | (table->mc_reg_table_entry[k].mc_data[i] &0x0000ffff ); j++; -if (j >SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE ) +if (j >=SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE )return -EINVAL ;break ;default :
Greg Kroah-Hartman
maintainerPATCH 29/50 drm/radeon: forever loop on error in radeon_do_test_moves()
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 89cd67b326fa95872cc2b4524cd807128db6071d upstream.
The error path does this:
for (--i; i >= 0; --i) {which is a forever loop because "i" is unsigned.
--- drivers/gpu/drm/radeon/radeon_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_test.c +2 -2
@@ -36,8 +36,8 @@ static void radeon_do_test_moves(structstruct radeon_bo *vram_obj =NULL ;struct radeon_bo **gtt_obj =NULL ;uint64_t gtt_addr, vram_addr; -unsigned i, n, size; -int r, ring; +unsigned n, size; +int i, r, ring;switch (flag) {case RADEON_TEST_COPY_DMA :
Greg Kroah-Hartman
maintainerPATCH 30/50 drm/radeon: fix typo in CP DMA register headers
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit aa3e146d04b6ae37939daeebaec060562b3db559 upstream.
Wrong bit offset for SRC endian swapping.
--- drivers/gpu/drm/radeon/evergreend.h | 4 ++-- drivers/gpu/drm/radeon/r600d.h | 2 +- drivers/gpu/drm/radeon/sid.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/radeon/evergreend.h +2 -2
@@ -1494,7 +1494,7 @@* 6. COMMAND [29:22] | BYTE_COUNT [20:0] */ # define PACKET3_CP_DMA_DST_SEL (x) ((x) << 20) -/* 0 - SRC_ADDR +/* 0 - DST_ADDR * 1 - GDS */ # define PACKET3_CP_DMA_ENGINE (x) ((x) << 27)
@@ -1509,7 +1509,7 @@# define PACKET3_CP_DMA_CP_SYNC (1 << 31)/* COMMAND */ # define PACKET3_CP_DMA_DIS_WC (1 << 21) -# define PACKET3_CP_DMA_CMD_SRC_SWAP (x) ((x) << 23) +# define PACKET3_CP_DMA_CMD_SRC_SWAP (x) ((x) << 22)/* 0 - none * 1 - 8 in 16 * 2 - 8 in 32
drivers/gpu/drm/radeon/r600d.h +1 -1
@@ -1487,7 +1487,7 @@*/ # define PACKET3_CP_DMA_CP_SYNC (1 << 31)/* COMMAND */ -# define PACKET3_CP_DMA_CMD_SRC_SWAP (x) ((x) << 23) +# define PACKET3_CP_DMA_CMD_SRC_SWAP (x) ((x) << 22)/* 0 - none * 1 - 8 in 16 * 2 - 8 in 32
drivers/gpu/drm/radeon/sid.h +2 -2
@@ -1490,7 +1490,7 @@* 6. COMMAND [30:21] | BYTE_COUNT [20:0] */ # define PACKET3_CP_DMA_DST_SEL (x) ((x) << 20) -/* 0 - SRC_ADDR +/* 0 - DST_ADDR * 1 - GDS */ # define PACKET3_CP_DMA_ENGINE (x) ((x) << 27)
@@ -1505,7 +1505,7 @@# define PACKET3_CP_DMA_CP_SYNC (1 << 31)/* COMMAND */ # define PACKET3_CP_DMA_DIS_WC (1 << 21) -# define PACKET3_CP_DMA_CMD_SRC_SWAP (x) ((x) << 23) +# define PACKET3_CP_DMA_CMD_SRC_SWAP (x) ((x) << 22)/* 0 - none * 1 - 8 in 16 * 2 - 8 in 32
Greg Kroah-Hartman
maintainerPATCH 31/50 drm/radeon: fix hw contexts for SUMO2 asics
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: wojciech kapuscinski <[email protected]>
commit 50b8f5aec04ebec7dbdf2adb17220b9148c99e63 upstream.
They have 4 rather than 8.
Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=63599
--- drivers/gpu/drm/radeon/evergreen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/radeon/evergreen.c +1 -1
@@ -3126,7 +3126,7 @@ static void evergreen_gpu_init(struct ra rdev->config.evergreen.sx_max_export_size =256 ; rdev->config.evergreen.sx_max_export_pos_size =64 ; rdev->config.evergreen.sx_max_export_smx_size =192 ; - rdev->config.evergreen.max_hw_contexts =8 ; + rdev->config.evergreen.max_hw_contexts =4 ; rdev->config.evergreen.sq_num_cf_insts =2 ; rdev->config.evergreen.sc_prim_fifo_size =0x40 ;
Greg Kroah-Hartman
maintainerPATCH 32/50 ipc,shm: introduce lockless functions to obtain the ipc object
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davidlohr Bueso <[email protected]>
commit 8b8d52ac382b17a19906b930cd69e2edb0aca8ba upstream.
This is the third and final patchset that deals with reducing the amount of contention we impose on the ipc lock (kern_ipc_perm.lock). These changes mostly deal with shared memory, previous work has already been done for semaphores and message queues:
http://lkml.org/lkml/2013/3/20/546 (sems)
http://lkml.org/lkml/2013/5/15/584 (mqueues)
With these patches applied, a custom shm microbenchmark stressing shmctl doing IPC_STAT with 4 threads a million times, reduces the execution time by 50%. A similar run, this time with IPC_SET, reduces the execution time from 3 mins and 35 secs to 27 seconds.
Patches 1-8: replaces blindly taking the ipc lock for a smarter combination of rcu and ipc_obtain_object, only acquiring the spinlock when updating.
Patch 9: renames the ids rw_mutex to rwsem, which is what it already was.
Patch 10: is a trivial mqueue leftover cleanup
Patch 11: adds a brief lock scheme description, requested by Andrew.
This patch:
Add shm_obtain_object() and shm_obtain_object_check(), which will allow us to get the ipc object without acquiring the lock. Just as with other forms of ipc, these functions are basically wrappers around ipc_obtain_object*().
--- ipc/shm.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
ipc/shm.c +20 -0
@@ -124,6 +124,26 @@ void __init shm_init (void) IPC_SHM_IDS, sysvipc_shm_proc_show); } +static inline struct shmid_kernel *shm_obtain_object (struct ipc_namespace *ns,int id) +{ +struct kern_ipc_perm *ipcp =ipc_obtain_object (&shm_ids (ns), id); + +if (IS_ERR (ipcp)) +return ERR_CAST (ipcp); + + return container_of(ipcp, struct shmid_kernel, shm_perm); +} + +static inline struct shmid_kernel *shm_obtain_object_check (struct ipc_namespace *ns,int id) +{ +struct kern_ipc_perm *ipcp =ipc_obtain_object_check (&shm_ids (ns), id); + +if (IS_ERR (ipcp)) +return ERR_CAST (ipcp); + + return container_of(ipcp, struct shmid_kernel, shm_perm); +} +/* * shm_lock_(check_) routines are called in the paths where the rw_mutex * is not necessarily held.
Greg Kroah-Hartman
maintainerPATCH 33/50 ipc,shm: shorten critical region in shmctl_down
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davidlohr Bueso <[email protected]>
commit 79ccf0f8c8e04e8b9eda6645ba0f63b0915a3075 upstream.
Instead of holding the ipc lock for the entire function, use the ipcctl_pre_down_nolock and only acquire the lock for specific commands:
RMID and SET.
--- ipc/shm.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
ipc/shm.c +6 -4
@@ -787,11 +787,10 @@ static int shmctl_down(struct ipc_namespdown_write (&shm_ids (ns).rw_mutex);rcu_read_lock (); - ipcp =ipcctl_pre_down (ns, &shm_ids (ns), shmid, cmd, - &shmid64.shm_perm,0 ); + ipcp =ipcctl_pre_down_nolock (ns, &shm_ids (ns), shmid, cmd, + &shmid64.shm_perm,0 );if (IS_ERR (ipcp)) { err =PTR_ERR (ipcp); -/* the ipc lock is not held upon failure */ goto out_unlock1; }
@@ -799,14 +798,16 @@ static int shmctl_down(struct ipc_namesp err =security_shm_shmctl (shp, cmd);if (err) - goto out_unlock0; + goto out_unlock1;switch (cmd) {case IPC_RMID : +ipc_lock_object (&shp->shm_perm);/* do_shm_rmid unlocks the ipc object and rcu */ do_shm_rmid (ns, ipcp); goto out_up;case IPC_SET : +ipc_lock_object (&shp->shm_perm); err =ipc_update_perm (&shmid64.shm_perm, ipcp);if (err) goto out_unlock0;
@@ -814,6 +815,7 @@ static int shmctl_down(struct ipc_namespbreak ;default : err = -EINVAL ; + goto out_unlock1; } out_unlock0:
Greg Kroah-Hartman
maintainerPATCH 34/50 ipc: drop ipcctl_pre_down
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davidlohr Bueso <[email protected]>
commit 3b1c4ad37741e53804ffe0a30dd01e08b2ab6241 upstream.
Now that sem, msgque and shm, through *_down(), all use the lockless variant of ipcctl_pre_down(), go ahead and delete it.
--- ipc/util.c | 24 ++++-------------------- ipc/util.h | 3 --- 2 files changed, 4 insertions(+), 23 deletions(-)
ipc/util.c +4 -20
@@ -725,7 +725,7 @@ int ipc_update_perm(struct ipc64_perm *i }/** -* ipcctl_pre_down - retrieve an ipc and check permissions for some IPC_XXX cmd +* ipcctl_pre_down_nolock - retrieve an ipc and check permissions for some IPC_XXX cmd * @ns: the ipc namespace * @ids: the table of ids where to look for the ipc * @id: the id of the ipc to retrieve
@@ -738,29 +738,13 @@ int ipc_update_perm(struct ipc64_perm *i* It must be called without any lock held and * - retrieves the ipc with the given id in the given table. * - performs some audit and permission check, depending on the given cmd -* - returns the ipc with the ipc lock held in case of success -* or an err-code without any lock held otherwise. +* - returns a pointer to the ipc object or otherwise, the corresponding error. * * Call holding the both the rw_mutex and the rcu read lock. */ -struct kern_ipc_perm *ipcctl_pre_down (struct ipc_namespace *ns, -struct ipc_ids *ids,int id,int cmd, -struct ipc64_perm *perm,int extra_perm) -{ -struct kern_ipc_perm *ipcp; - - ipcp =ipcctl_pre_down_nolock (ns, ids, id, cmd, perm, extra_perm); -if (IS_ERR (ipcp)) - goto out; - -spin_lock (&ipcp->lock); -out: -return ipcp; -} -struct kern_ipc_perm *ipcctl_pre_down_nolock (struct ipc_namespace *ns, -struct ipc_ids *ids,int id,int cmd, -struct ipc64_perm *perm,int extra_perm) +struct ipc_ids *ids,int id,int cmd, +struct ipc64_perm *perm,int extra_perm) {kuid_t euid;int err = -EPERM ;
ipc/util.h +0 -3
@@ -139,9 +139,6 @@ int ipc_update_perm(struct ipc64_perm *istruct kern_ipc_perm *ipcctl_pre_down_nolock (struct ipc_namespace *ns,struct ipc_ids *ids,int id,int cmd,struct ipc64_perm *perm,int extra_perm); -struct kern_ipc_perm *ipcctl_pre_down (struct ipc_namespace *ns, -struct ipc_ids *ids,int id,int cmd, -struct ipc64_perm *perm,int extra_perm);#ifndef CONFIG_ARCH_WANT_IPC_PARSE_VERSION /* On IA-64, we always use the "64-bit version" of the IPC structures. */
Greg Kroah-Hartman
maintainerPATCH 35/50 ipc,shm: introduce shmctl_nolock
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davidlohr Bueso <[email protected]>
commit 68eccc1dc345539d589ae78ee43b835c1a06a134 upstream.
Similar to semctl and msgctl, when calling msgctl, the *_INFO and *_STAT commands can be performed without acquiring the ipc object.
Add a shmctl_nolock() function and move the logic of *_INFO and *_STAT out of msgctl(). Since we are just moving functionality, this change still takes the lock and it will be properly lockless in the next patch.
--- ipc/shm.c | 57 +++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 18 deletions(-)
ipc/shm.c +39 -18
@@ -827,29 +827,24 @@ out_up:return err; } -SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, struct shmid_ds __user *, buf) +static int shmctl_nolock (struct ipc_namespace *ns,int shmid, +int cmd,int version,void __user *buf) { +int err;struct shmid_kernel *shp; -int err, version; -struct ipc_namespace *ns; -if (cmd <0 || shmid <0 ) { - err = -EINVAL ; - goto out; +/* preliminary security checks for *_INFO */ +if (cmd ==IPC_INFO || cmd ==SHM_INFO ) { + err =security_shm_shmctl (NULL , cmd); +if (err) +return err; } - version =ipc_parse_version (&cmd); - ns = current->nsproxy->ipc_ns; - -switch (cmd) {/* replace with proc interface ? */ +switch (cmd) {case IPC_INFO : {struct shminfo64 shminfo; - err =security_shm_shmctl (NULL , cmd); -if (err) -return err; -memset (&shminfo,0 ,sizeof (shminfo)); shminfo.shmmni = shminfo.shmseg = ns->shm_ctlmni; shminfo.shmmax = ns->shm_ctlmax;
@@ -871,10 +866,6 @@ SYSCALL_DEFINE3(shmctl, int, shmid, int, {struct shm_info shm_info; - err =security_shm_shmctl (NULL , cmd); -if (err) -return err; -memset (&shm_info,0 ,sizeof (shm_info));down_read (&shm_ids (ns).rw_mutex); shm_info.used_ids =shm_ids (ns).in_use;
@@ -935,6 +926,36 @@ SYSCALL_DEFINE3(shmctl, int, shmid, int, err = result; goto out; } +default : +return -EINVAL ; + } + +out_unlock: +shm_unlock (shp); +out: +return err; +} + +SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, struct shmid_ds __user *, buf) +{ +struct shmid_kernel *shp; +int err, version; +struct ipc_namespace *ns; + +if (cmd <0 || shmid <0 ) { + err = -EINVAL ; + goto out; + } + + version =ipc_parse_version (&cmd); + ns = current->nsproxy->ipc_ns; + +switch (cmd) { +case IPC_INFO : +case SHM_INFO : +case SHM_STAT : +case IPC_STAT : +return shmctl_nolock (ns, shmid, cmd, version, buf);case SHM_LOCK :case SHM_UNLOCK : {
Greg Kroah-Hartman
maintainerPATCH 36/50 ipc,shm: make shmctl_nolock lockless
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davidlohr Bueso <[email protected]>
commit c97cb9ccab8c85428ec21eff690642ad2ce1fa8a upstream.
While the INFO cmd doesn't take the ipc lock, the STAT commands do acquire it unnecessarily. We can do the permissions and security checks only holding the rcu lock.
--- ipc/shm.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
ipc/shm.c +12 -7
@@ -889,27 +889,31 @@ static int shmctl_nolock(struct ipc_namestruct shmid64_ds tbuf;int result; +rcu_read_lock ();if (cmd ==SHM_STAT ) { - shp =shm_lock (ns, shmid); + shp =shm_obtain_object (ns, shmid);if (IS_ERR (shp)) { err =PTR_ERR (shp); - goto out; + goto out_unlock; } result = shp->shm_perm.id; }else { - shp =shm_lock_check (ns, shmid); + shp =shm_obtain_object_check (ns, shmid);if (IS_ERR (shp)) { err =PTR_ERR (shp); - goto out; + goto out_unlock; } result =0 ; } + err = -EACCES ;if (ipcperms (ns, &shp->shm_perm,S_IRUGO )) goto out_unlock; + err =security_shm_shmctl (shp, cmd);if (err) goto out_unlock; +memset (&tbuf,0 ,sizeof (tbuf));kernel_to_ipc64_perm (&shp->shm_perm, &tbuf.shm_perm); tbuf.shm_segsz = shp->shm_segsz;
@@ -919,8 +923,9 @@ static int shmctl_nolock(struct ipc_name tbuf.shm_cpid = shp->shm_cprid; tbuf.shm_lpid = shp->shm_lprid; tbuf.shm_nattch = shp->shm_nattch; -shm_unlock (shp); -if (copy_shmid_to_user (buf, &tbuf, version)) +rcu_read_unlock (); + +if (copy_shmid_to_user (buf, &tbuf, version)) err = -EFAULT ;else err = result;
@@ -931,7 +936,7 @@ static int shmctl_nolock(struct ipc_name } out_unlock: -shm_unlock (shp); +rcu_read_unlock (); out:return err; }
Greg Kroah-Hartman
maintainerPATCH 37/50 ipc,shm: shorten critical region for shmctl
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davidlohr Bueso <[email protected]>
commit 2caacaa82a51b78fc0c800e206473874094287ed upstream.
With the *_INFO, *_STAT, IPC_RMID and IPC_SET commands already optimized, deal with the remaining SHM_LOCK and SHM_UNLOCK commands. Take the shm_perm lock after doing the initial auditing and security checks. The rest of the logic remains unchanged.
--- ipc/shm.c | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-)
ipc/shm.c +25 -24
@@ -947,10 +947,8 @@ SYSCALL_DEFINE3(shmctl, int, shmid, int,int err, version;struct ipc_namespace *ns; -if (cmd <0 || shmid <0 ) { - err = -EINVAL ; - goto out; - } +if (cmd <0 || shmid <0 ) +return -EINVAL ; version =ipc_parse_version (&cmd); ns = current->nsproxy->ipc_ns;
@@ -961,36 +959,40 @@ SYSCALL_DEFINE3(shmctl, int, shmid, int,case SHM_STAT :case IPC_STAT :return shmctl_nolock (ns, shmid, cmd, version, buf); +case IPC_RMID : +case IPC_SET : +return shmctl_down (ns, shmid, cmd, buf, version);case SHM_LOCK :case SHM_UNLOCK : {struct file *shm_file; - shp =shm_lock_check (ns, shmid); +rcu_read_lock (); + shp =shm_obtain_object_check (ns, shmid);if (IS_ERR (shp)) { err =PTR_ERR (shp); - goto out; + goto out_unlock1; }audit_ipc_obj (&(shp->shm_perm)); + err =security_shm_shmctl (shp, cmd); +if (err) + goto out_unlock1; +ipc_lock_object (&shp->shm_perm);if (!ns_capable (ns->user_ns,CAP_IPC_LOCK )) {kuid_t euid =current_euid (); err = -EPERM ;if (!uid_eq (euid, shp->shm_perm.uid) && !uid_eq (euid, shp->shm_perm.cuid)) - goto out_unlock; + goto out_unlock0;if (cmd ==SHM_LOCK && !rlimit (RLIMIT_MEMLOCK )) - goto out_unlock; + goto out_unlock0; } - err =security_shm_shmctl (shp, cmd); -if (err) - goto out_unlock; - shm_file = shp->shm_file;if (is_file_hugepages (shm_file)) - goto out_unlock; + goto out_unlock0;if (cmd ==SHM_LOCK ) {struct user_struct *user =current_user ();
@@ -999,32 +1001,31 @@ SYSCALL_DEFINE3(shmctl, int, shmid, int, shp->shm_perm.mode |=SHM_LOCKED ; shp->mlock_user = user; } - goto out_unlock; + goto out_unlock0; }/* SHM_UNLOCK */ if (!(shp->shm_perm.mode &SHM_LOCKED )) - goto out_unlock; + goto out_unlock0;shmem_lock (shm_file,0 , shp->mlock_user); shp->shm_perm.mode &= ~SHM_LOCKED ; shp->mlock_user =NULL ;get_file (shm_file); -shm_unlock (shp); +ipc_unlock_object (&shp->shm_perm); +rcu_read_unlock ();shmem_unlock_mapping (shm_file->f_mapping); +fput (shm_file); - goto out; - } -case IPC_RMID : -case IPC_SET : - err =shmctl_down (ns, shmid, cmd, buf, version);return err; + }default :return -EINVAL ; } -out_unlock: -shm_unlock (shp); -out: +out_unlock0: +ipc_unlock_object (&shp->shm_perm); +out_unlock1: +rcu_read_unlock ();return err; }
Greg Kroah-Hartman
maintainerPATCH 38/50 ipc,shm: cleanup do_shmat pasta
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davidlohr Bueso <[email protected]>
commit f42569b1388b1408b574a5e93a23a663647d4181 upstream.
Clean up some of the messy do_shmat() spaghetti code, getting rid of out_free and out_put_dentry labels. This makes shortening the critical region of this function in the next patch a little easier to do and read.
--- ipc/shm.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
ipc/shm.c +12 -14
@@ -1115,16 +1115,21 @@ long do_shmat(int shmid, char __user *sh err = -ENOMEM ; sfd =kzalloc (sizeof (*sfd),GFP_KERNEL ); -if (!sfd) - goto out_put_dentry; +if (!sfd) { +path_put (&path); + goto out_nattch; + } file =alloc_file (&path, f_mode,is_file_hugepages (shp->shm_file) ? &shm_file_operations_huge : &shm_file_operations); err =PTR_ERR (file); -if (IS_ERR (file)) - goto out_free; +if (IS_ERR (file)) { +kfree (sfd); +path_put (&path); + goto out_nattch; + } file->private_data = sfd; file->f_mapping = shp->shm_file->f_mapping;
@@ -1150,7 +1155,7 @@ long do_shmat(int shmid, char __user *sh addr > current->mm->start_stack - size - PAGE_SIZE * 5) goto invalid; } - + addr =do_mmap_pgoff (file, addr, size, prot, flags,0 , &populate); *raddr = addr; err =0 ;
@@ -1174,19 +1179,12 @@ out_nattch:else shm_unlock (shp);up_write (&shm_ids (ns).rw_mutex); - -out:return err; out_unlock:shm_unlock (shp); - goto out; - -out_free: -kfree (sfd); -out_put_dentry: -path_put (&path); - goto out_nattch; +out: +return err; } SYSCALL_DEFINE3(shmat, int, shmid, char __user *, shmaddr, int, shmflg)
Greg Kroah-Hartman
maintainerPATCH 39/50 ipc,shm: shorten critical region for shmat
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davidlohr Bueso <[email protected]>
commit c2c737a0461e61a34676bd0bd1bc1a70a1b4e396 upstream.
Similar to other system calls, acquire the kern_ipc_perm lock after doing the initial permission and security checks.
--- ipc/shm.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
ipc/shm.c +10 -4
@@ -19,6 +19,9 @@* namespaces support * OpenVZ, SWsoft Inc. * Pavel Emelianov <[email protected]> +* +* Better ipc lock (kern_ipc_perm.lock) handling +* Davidlohr Bueso <[email protected]>, June 2013. */ #include <linux/slab.h>
@@ -1093,10 +1096,11 @@ long do_shmat(int shmid, char __user *sh* additional creator id... */ ns = current->nsproxy->ipc_ns; - shp =shm_lock_check (ns, shmid); +rcu_read_lock (); + shp =shm_obtain_object_check (ns, shmid);if (IS_ERR (shp)) { err =PTR_ERR (shp); - goto out; + goto out_unlock; } err = -EACCES ;
@@ -1107,11 +1111,13 @@ long do_shmat(int shmid, char __user *shif (err) goto out_unlock; +ipc_lock_object (&shp->shm_perm); path = shp->shm_file->f_path;path_get (&path); shp->shm_nattch++; size =i_size_read (path.dentry->d_inode); -shm_unlock (shp); +ipc_unlock_object (&shp->shm_perm); +rcu_read_unlock (); err = -ENOMEM ; sfd =kzalloc (sizeof (*sfd),GFP_KERNEL );
@@ -1182,7 +1188,7 @@ out_nattch:return err; out_unlock: -shm_unlock (shp); +rcu_read_unlock (); out:return err; }
Greg Kroah-Hartman
maintainerPATCH 40/50 ipc: rename ids->rw_mutex
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davidlohr Bueso <[email protected]>
commit d9a605e40b1376eb02b067d7690580255a0df68f upstream.
Since in some situations the lock can be shared for readers, we shouldn't be calling it a mutex, rename it to rwsem.
--- include/linux/ipc_namespace.h | 2 - ipc/msg.c | 20 +++++++-------- ipc/namespace.c | 4 +-- ipc/sem.c | 24 +++++++++--------- ipc/shm.c | 56 +++++++++++++++++++++--------------------- ipc/util.c | 28 ++++++++++----------- ipc/util.h | 4 +-- 7 files changed, 69 insertions(+), 69 deletions(-)
include/linux/ipc_namespace.h +1 -1
@@ -22,7 +22,7 @@ struct ipc_ids {int in_use;unsigned short seq;unsigned short seq_max; -struct rw_semaphore rw_mutex; +struct rw_semaphore rwsem;struct idr ipcs_idr;int next_id; };
ipc/msg.c +10 -10
@@ -181,7 +181,7 @@ static void msg_rcu_free(struct rcu_head* @ns: namespace * @params: ptr to the structure that contains the key and msgflg * -* Called with msg_ids.rw_mutex held (writer) +* Called with msg_ids.rwsem held (writer) */ static int newque (struct ipc_namespace *ns,struct ipc_params *params) {
@@ -267,8 +267,8 @@ static void expunge_all(struct msg_queue* removes the message queue from message queue ID IDR, and cleans up all the * messages associated with this queue. * -* msg_ids.rw_mutex (writer) and the spinlock for this message queue are held -* before freeque() is called. msg_ids.rw_mutex remains locked on exit. +* msg_ids.rwsem (writer) and the spinlock for this message queue are held +* before freeque() is called. msg_ids.rwsem remains locked on exit. */ static void freeque (struct ipc_namespace *ns,struct kern_ipc_perm *ipcp) {
@@ -289,7 +289,7 @@ static void freeque(struct ipc_namespace }/* -* Called with msg_ids.rw_mutex and ipcp locked. +* Called with msg_ids.rwsem and ipcp locked. */ static inline int msg_security (struct kern_ipc_perm *ipcp,int msgflg) {
@@ -393,9 +393,9 @@ copy_msqid_from_user(struct msqid64_ds * }/* -* This function handles some msgctl commands which require the rw_mutex +* This function handles some msgctl commands which require the rwsem * to be held in write mode. -* NOTE: no locks must be held, the rw_mutex is taken inside this function. +* NOTE: no locks must be held, the rwsem is taken inside this function. */ static int msgctl_down (struct ipc_namespace *ns,int msqid,int cmd,struct msqid_ds __user *buf,int version)
@@ -410,7 +410,7 @@ static int msgctl_down(struct ipc_namespreturn -EFAULT ; } -down_write (&msg_ids (ns).rw_mutex); +down_write (&msg_ids (ns).rwsem);rcu_read_lock (); ipcp = ipcctl_pre_down_nolock(ns, &msg_ids(ns), msqid, cmd,
@@ -466,7 +466,7 @@ out_unlock0: out_unlock1:rcu_read_unlock (); out_up: -up_write (&msg_ids (ns).rw_mutex); +up_write (&msg_ids (ns).rwsem);return err; }
@@ -501,7 +501,7 @@ static int msgctl_nolock(struct ipc_name msginfo.msgmnb = ns->msg_ctlmnb; msginfo.msgssz =MSGSSZ ; msginfo.msgseg =MSGSEG ; -down_read (&msg_ids (ns).rw_mutex); +down_read (&msg_ids (ns).rwsem);if (cmd ==MSG_INFO ) { msginfo.msgpool =msg_ids (ns).in_use; msginfo.msgmap =atomic_read (&ns->msg_hdrs);
@@ -512,7 +512,7 @@ static int msgctl_nolock(struct ipc_name msginfo.msgtql =MSGTQL ; } max_id =ipc_get_maxid (&msg_ids (ns)); -up_read (&msg_ids (ns).rw_mutex); +up_read (&msg_ids (ns).rwsem);if (copy_to_user (buf, &msginfo,sizeof (struct msginfo )))return -EFAULT ;return (max_id <0 ) ?0 : max_id;
ipc/namespace.c +2 -2
@@ -81,7 +81,7 @@ void free_ipcs(struct ipc_namespace *ns,int next_id;int total, in_use; -down_write (&ids->rw_mutex); +down_write (&ids->rwsem); in_use = ids->in_use;
@@ -93,7 +93,7 @@ void free_ipcs(struct ipc_namespace *ns,free (ns, perm); total++; } -up_write (&ids->rw_mutex); +up_write (&ids->rwsem); }static void free_ipc_ns (struct ipc_namespace *ns)
ipc/sem.c +12 -12
@@ -365,7 +365,7 @@ static inline void sem_unlock(struct sem }/* -* sem_lock_(check_) routines are called in the paths where the rw_mutex +* sem_lock_(check_) routines are called in the paths where the rwsem * is not held. * * The caller holds the RCU read lock.
@@ -464,7 +464,7 @@ static inline void sem_rmid(struct ipc_n* @ns: namespace * @params: ptr to the structure that contains key, semflg and nsems * -* Called with sem_ids.rw_mutex held (as a writer) +* Called with sem_ids.rwsem held (as a writer) */ static int newary (struct ipc_namespace *ns,struct ipc_params *params)
@@ -529,7 +529,7 @@ static int newary(struct ipc_namespace */* -* Called with sem_ids.rw_mutex and ipcp locked. +* Called with sem_ids.rwsem and ipcp locked. */ static inline int sem_security (struct kern_ipc_perm *ipcp,int semflg) {
@@ -540,7 +540,7 @@ static inline int sem_security(struct ke }/* -* Called with sem_ids.rw_mutex and ipcp locked. +* Called with sem_ids.rwsem and ipcp locked. */ static inline int sem_more_checks (struct kern_ipc_perm *ipcp,struct ipc_params *params)
@@ -1031,8 +1031,8 @@ static int count_semzcnt (struct sem_arrreturn semzcnt; } -/* Free a semaphore set. freeary() is called with sem_ids.rw_mutex locked -* as a writer and the spinlock for this semaphore set hold. sem_ids.rw_mutex +/* Free a semaphore set. freeary() is called with sem_ids.rwsem locked +* as a writer and the spinlock for this semaphore set hold. sem_ids.rwsem * remains locked on exit. */ static void freeary (struct ipc_namespace *ns,struct kern_ipc_perm *ipcp)
@@ -1152,7 +1152,7 @@ static int semctl_nolock(struct ipc_name seminfo.semmnu =SEMMNU ; seminfo.semmap =SEMMAP ; seminfo.semume =SEMUME ; -down_read (&sem_ids (ns).rw_mutex); +down_read (&sem_ids (ns).rwsem);if (cmd ==SEM_INFO ) { seminfo.semusz =sem_ids (ns).in_use; seminfo.semaem = ns->used_sems;
@@ -1161,7 +1161,7 @@ static int semctl_nolock(struct ipc_name seminfo.semaem =SEMAEM ; } max_id =ipc_get_maxid (&sem_ids (ns)); -up_read (&sem_ids (ns).rw_mutex); +up_read (&sem_ids (ns).rwsem);if (copy_to_user (p, &seminfo,sizeof (struct seminfo )))return -EFAULT ;return (max_id <0 ) ?0 : max_id;
@@ -1467,9 +1467,9 @@ copy_semid_from_user(struct semid64_ds * }/* -* This function handles some semctl commands which require the rw_mutex +* This function handles some semctl commands which require the rwsem * to be held in write mode. -* NOTE: no locks must be held, the rw_mutex is taken inside this function. +* NOTE: no locks must be held, the rwsem is taken inside this function. */ static int semctl_down (struct ipc_namespace *ns,int semid,int cmd,int version,void __user *p)
@@ -1484,7 +1484,7 @@ static int semctl_down(struct ipc_namespreturn -EFAULT ; } -down_write (&sem_ids (ns).rw_mutex); +down_write (&sem_ids (ns).rwsem);rcu_read_lock (); ipcp = ipcctl_pre_down_nolock(ns, &sem_ids(ns), semid, cmd,
@@ -1523,7 +1523,7 @@ out_unlock0: out_unlock1:rcu_read_unlock (); out_up: -up_write (&sem_ids (ns).rw_mutex); +up_write (&sem_ids (ns).rwsem);return err; }
ipc/shm.c +28 -28
196 lines not on this page · raw message
ipc/util.c +14 -14
@@ -119,7 +119,7 @@ __initcall(ipc_init);void ipc_init_ids (struct ipc_ids *ids) { -init_rwsem (&ids->rw_mutex); +init_rwsem (&ids->rwsem); ids->in_use =0 ; ids->seq =0 ;
@@ -174,7 +174,7 @@ void __init ipc_init_proc_interface(cons* @ids: Identifier set * @key: The key to find * -* Requires ipc_ids.rw_mutex locked. +* Requires ipc_ids.rwsem locked. * Returns the LOCKED pointer to the ipc structure if found or NULL * if not. * If key is found ipc points to the owning ipc structure
@@ -208,7 +208,7 @@ static struct kern_ipc_perm *ipc_findkey* ipc_get_maxid - get the last assigned id * @ids: IPC identifier set * -* Called with ipc_ids.rw_mutex held. +* Called with ipc_ids.rwsem held. */ int ipc_get_maxid (struct ipc_ids *ids)
@@ -246,7 +246,7 @@ int ipc_get_maxid(struct ipc_ids *ids)* is returned. The 'new' entry is returned in a locked state on success. * On failure the entry is not locked and a negative err-code is returned. * -* Called with writer ipc_ids.rw_mutex held. +* Called with writer ipc_ids.rwsem held. */ int ipc_addid (struct ipc_ids * ids,struct kern_ipc_perm * new,int size) {
@@ -312,9 +312,9 @@ static int ipcget_new(struct ipc_namespa {int err; -down_write (&ids->rw_mutex); +down_write (&ids->rwsem); err = ops->getnew (ns, params); -up_write (&ids->rw_mutex); +up_write (&ids->rwsem);return err; }
@@ -331,7 +331,7 @@ static int ipcget_new(struct ipc_namespa* * On success, the IPC id is returned. * -* It is called with ipc_ids.rw_mutex and ipcp->lock held. +* It is called with ipc_ids.rwsem and ipcp->lock held. */ static int ipc_check_perms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp,
@@ -376,7 +376,7 @@ static int ipcget_public(struct ipc_name* Take the lock as a writer since we are potentially going to add * a new entry + read locks are not "upgradable" */ -down_write (&ids->rw_mutex); +down_write (&ids->rwsem); ipcp =ipc_findkey (ids, params->key);if (ipcp ==NULL ) {/* key not used */
@@ -402,7 +402,7 @@ static int ipcget_public(struct ipc_name }ipc_unlock (ipcp); } -up_write (&ids->rw_mutex); +up_write (&ids->rwsem);return err; }
@@ -413,7 +413,7 @@ static int ipcget_public(struct ipc_name* @ids: IPC identifier set * @ipcp: ipc perm structure containing the identifier to remove * -* ipc_ids.rw_mutex (as a writer) and the spinlock for this ID are held +* ipc_ids.rwsem (as a writer) and the spinlock for this ID are held * before this function is called, and remain locked on the exit. */
@@ -613,7 +613,7 @@ struct kern_ipc_perm *ipc_obtain_object( }/** -* ipc_lock - Lock an ipc structure without rw_mutex held +* ipc_lock - Lock an ipc structure without rwsem held * @ids: IPC identifier set * @id: ipc id to look for *
@@ -740,7 +740,7 @@ int ipc_update_perm(struct ipc64_perm *i* - performs some audit and permission check, depending on the given cmd * - returns a pointer to the ipc object or otherwise, the corresponding error. * -* Call holding the both the rw_mutex and the rcu read lock. +* Call holding the both the rwsem and the rcu read lock. */ struct kern_ipc_perm *ipcctl_pre_down_nolock(struct ipc_namespace *ns, struct ipc_ids *ids, int id, int cmd,
@@ -860,7 +860,7 @@ static void *sysvipc_proc_start(struct s* Take the lock - this will be released by the corresponding * call to stop(). */ -down_read (&ids->rw_mutex); +down_read (&ids->rwsem);/* pos < 0 is invalid */ if (*pos <0 )
@@ -887,7 +887,7 @@ static void sysvipc_proc_stop(struct seq ids = &iter->ns->ids[iface->ids];/* Release the lock we took in start() */ -up_read (&ids->rw_mutex); +up_read (&ids->rwsem); }static int sysvipc_proc_show (struct seq_file *s,void *it)
ipc/util.h +2 -2
@@ -101,10 +101,10 @@ void __init ipc_init_proc_interface(cons#define ipcid_to_idx (id) ((id) % SEQ_MULTIPLIER)#define ipcid_to_seqx (id) ((id) / SEQ_MULTIPLIER) -/* must be called with ids->rw_mutex acquired for writing */ +/* must be called with ids->rwsem acquired for writing */ int ipc_addid (struct ipc_ids *,struct kern_ipc_perm *,int ); -/* must be called with ids->rw_mutex acquired for reading */ +/* must be called with ids->rwsem acquired for reading */ int ipc_get_maxid (struct ipc_ids *);/* must be called with both locks acquired. */
Greg Kroah-Hartman
maintainerPATCH 41/50 ipc,msg: drop msg_unlock
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davidlohr Bueso <[email protected]>
commit 4718787d1f626f45ddb239912bc07266b9880044 upstream.
There is only one user left, drop this function and just call ipc_unlock_object() and rcu_read_unlock().
--- ipc/msg.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
ipc/msg.c +2 -3
@@ -70,8 +70,6 @@ struct msg_sender {#define msg_ids (ns) ((ns)->ids[IPC_MSG_IDS]) -#define msg_unlock (msq) ipc_unlock(&(msq)->q_perm) -static void freeque (struct ipc_namespace *,struct kern_ipc_perm *);static int newque (struct ipc_namespace *,struct ipc_params *);#ifdef CONFIG_PROC_FS
@@ -278,7 +276,8 @@ static void freeque(struct ipc_namespaceexpunge_all (msq, -EIDRM );ss_wakeup (&msq->q_senders,1 );msg_rmid (ns, msq); -msg_unlock (msq); +ipc_unlock_object (&msq->q_perm); +rcu_read_unlock ();list_for_each_entry_safe (msg, t, &msq->q_messages, m_list) {atomic_dec (&ns->msg_hdrs);
Greg Kroah-Hartman
maintainerPATCH 42/50 ipc: document general ipc locking scheme
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davidlohr Bueso <[email protected]>
commit 05603c44a7627793219b0bd9a7b236099dc9cd9d upstream.
As suggested by Andrew, add a generic initial locking scheme used throughout all sysv ipc mechanisms. Documenting the ids rwsem, how rcu can be enough to do the initial checks and when to actually acquire the kern_ipc_perm.lock spinlock.
I found that adding it to util.c was generic enough.
--- ipc/util.c | 8 ++++++++ 1 file changed, 8 insertions(+)
ipc/util.c +8 -0
@@ -15,6 +15,14 @@* Jun 2006 - namespaces ssupport * OpenVZ, SWsoft Inc. * Pavel Emelianov <[email protected]> +* +* General sysv ipc locking scheme: +* when doing ipc id lookups, take the ids->rwsem +* rcu_read_lock() +* obtain the ipc object (kern_ipc_perm) +* perform security, capabilities, auditing and permission checks, etc. +* acquire the ipc lock (kern_ipc_perm.lock) throught ipc_lock_object() +* perform data updates (ie: SET, RMID, LOCK/UNLOCK commands) */ #include <linux/mm.h>
Greg Kroah-Hartman
maintainerPATCH 43/50 ipc, shm: guard against non-existant vma in shmdt(2)
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davidlohr Bueso <[email protected]>
commit 530fcd16d87cd2417c472a581ba5a1e501556c86 upstream.
When !CONFIG_MMU there's a chance we can derefence a NULL pointer when the VM area isn't found - check the return value of find_vma().
Also, remove the redundant -EINVAL return: retval is set to the proper return code and *only* changed to 0, when we actually unmap the segments.
--- ipc/shm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
ipc/shm.c +1 -2
@@ -1295,8 +1295,7 @@ SYSCALL_DEFINE1(shmdt, char __user *, sh#else /* CONFIG_MMU */ /* under NOMMU conditions, the exact address to be destroyed must be * given */ - retval = -EINVAL ; -if (vma->vm_start == addr && vma->vm_ops == &shm_vm_ops) { +if (vma && vma->vm_start == addr && vma->vm_ops == &shm_vm_ops) {do_munmap (mm, vma->vm_start, vma->vm_end - vma->vm_start); retval =0 ; }
Greg Kroah-Hartman
maintainerPATCH 44/50 ipc: drop ipc_lock_by_ptr
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davidlohr Bueso <[email protected]>
commit 32a2750010981216fb788c5190fb0e646abfab30 upstream.
After previous cleanups and optimizations, this function is no longer heavily used and we don't have a good reason to keep it. Update the few remaining callers and get rid of it.
--- ipc/namespace.c | 3 ++- ipc/util.c | 6 ++++-- ipc/util.h | 6 ------ 3 files changed, 6 insertions(+), 9 deletions(-)
ipc/namespace.c +2 -1
@@ -89,7 +89,8 @@ void free_ipcs(struct ipc_namespace *ns, perm =idr_find (&ids->ipcs_idr, next_id);if (perm ==NULL )continue ; -ipc_lock_by_ptr (perm); +rcu_read_lock (); +ipc_lock_object (perm);free (ns, perm); total++; }
ipc/util.c +4 -2
@@ -205,7 +205,8 @@ static struct kern_ipc_perm *ipc_findkeycontinue ; } -ipc_lock_by_ptr (ipc); +rcu_read_lock (); +ipc_lock_object (ipc);return ipc; }
@@ -830,7 +831,8 @@ static struct kern_ipc_perm *sysvipc_fin ipc =idr_find (&ids->ipcs_idr, pos);if (ipc !=NULL ) { *new_pos = pos +1 ; -ipc_lock_by_ptr (ipc); +rcu_read_lock (); +ipc_lock_object (ipc);return ipc; } }
ipc/util.h +0 -6
@@ -179,12 +179,6 @@ static inline void ipc_assert_locked_objassert_spin_locked (&perm->lock); } -static inline void ipc_lock_by_ptr (struct kern_ipc_perm *perm) -{ -rcu_read_lock (); -ipc_lock_object (perm); -} -static inline void ipc_unlock (struct kern_ipc_perm *perm) {ipc_unlock_object (perm);
Greg Kroah-Hartman
maintainerPATCH 45/50 ipc, shm: drop shm_lock_check
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davidlohr Bueso <[email protected]>
commit 7a25dd9e042b2b94202a67e5551112f4ac87285a upstream.
This function was replaced by a the lockless shm_obtain_object_check(), and no longer has any users.
--- ipc/shm.c | 11 ----------- 1 file changed, 11 deletions(-)
ipc/shm.c +0 -11
@@ -167,17 +167,6 @@ static inline void shm_lock_by_ptr(strucipc_lock_object (&ipcp->shm_perm); } -static inline struct shmid_kernel *shm_lock_check (struct ipc_namespace *ns, -int id) -{ -struct kern_ipc_perm *ipcp =ipc_lock_check (&shm_ids (ns), id); - -if (IS_ERR (ipcp)) -return (struct shmid_kernel *)ipcp; - - return container_of(ipcp, struct shmid_kernel, shm_perm); -} -static void shm_rcu_free (struct rcu_head *head) { struct ipc_rcu *p = container_of(head, struct ipc_rcu, rcu);
Greg Kroah-Hartman
maintainerPATCH 46/50 ipc: drop ipc_lock_check
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davidlohr Bueso <[email protected]>
commit 20b8875abcf2daa1dda5cf70bd6369df5e85d4c1 upstream.
No remaining users, we now use ipc_obtain_object_check().
--- ipc/util.c | 16 ---------------- ipc/util.h | 1 - 2 files changed, 17 deletions(-)
ipc/util.c +0 -16
@@ -678,22 +678,6 @@ out:return out; } -struct kern_ipc_perm *ipc_lock_check (struct ipc_ids *ids,int id) -{ -struct kern_ipc_perm *out; - - out =ipc_lock (ids, id); -if (IS_ERR (out)) -return out; - -if (ipc_checkid (out, id)) { -ipc_unlock (out); -return ERR_PTR (-EIDRM ); - } - -return out; -} -/** * ipcget - Common sys_*get() code * @ns : namsepace
ipc/util.h +0 -1
@@ -185,7 +185,6 @@ static inline void ipc_unlock(struct kerrcu_read_unlock (); } -struct kern_ipc_perm *ipc_lock_check (struct ipc_ids *ids,int id);struct kern_ipc_perm *ipc_obtain_object_check (struct ipc_ids *ids,int id);int ipcget (struct ipc_namespace *ns,struct ipc_ids *ids,struct ipc_ops *ops,struct ipc_params *params);
Greg Kroah-Hartman
maintainerPATCH 47/50 ipc/sem.c: optimize sem_lock()
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manfred Spraul <[email protected]>
commit 6d07b68ce16ae9535955ba2059dedba5309c3ca1 upstream.
Operations that need access to the whole array must guarantee that there are no simple operations ongoing. Right now this is achieved by spin_unlock_wait(sem->lock) on all semaphores.
If complex_count is nonzero, then this spin_unlock_wait() is not necessary, because it was already performed in the past by the thread that increased complex_count and even though sem_perm.lock was dropped inbetween, no simple operation could have started, because simple operations cannot start when complex_count is non-zero.
--- ipc/sem.c | 8 ++++++++ 1 file changed, 8 insertions(+)
ipc/sem.c +8 -0
@@ -248,12 +248,20 @@ static void merge_queues(struct sem_arra* Caller must own sem_perm.lock. * New simple ops cannot start, because simple ops first check * that sem_perm.lock is free. +* that a) sem_perm.lock is free and b) complex_count is 0. */ static void sem_wait_array (struct sem_array *sma) {int i;struct sem *sem; +if (sma->complex_count) { +/* The thread that increased sma->complex_count waited on +* all sem->lock locks. Thus we don't need to wait again. +*/ +return ; + } +for (i =0 ; i < sma->sem_nsems; i++) { sem = sma->sem_base + i;spin_unlock_wait (&sem->lock);
Greg Kroah-Hartman
maintainerPATCH 48/50 ipc/sem.c: synchronize the proc interface
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manfred Spraul <[email protected]>
commit d8c633766ad88527f25d9f81a5c2f083d78a2b39 upstream.
The proc interface is not aware of sem_lock(), it instead calls ipc_lock_object() directly. This means that simple semop() operations can run in parallel with the proc interface. Right now, this is uncritical, because the implementation doesn't do anything that requires a proper synchronization.
But it is dangerous and therefore should be fixed.
--- ipc/sem.c | 8 ++++++++ 1 file changed, 8 insertions(+)
ipc/sem.c +8 -0
@@ -2103,6 +2103,14 @@ static int sysvipc_sem_proc_show(structstruct sem_array *sma = it;time_t sem_otime; +/* +* The proc interface isn't aware of sem_lock(), it calls +* ipc_lock_object() directly (in sysvipc_find_ipc). +* In order to stay compatible with sem_lock(), we must wait until +* all simple semop() calls have left their critical regions. +*/ +sem_wait_array (sma); + sem_otime =get_semotime (sma); return seq_printf(s,
Greg Kroah-Hartman
maintainerPATCH 49/50 ipc/sem.c: update sem_otime for all operations
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manfred Spraul <[email protected]>
commit 0e8c665699e953fa58dc1b0b0d09e5dce7343cc7 upstream.
In commit 0a2b9d4c7967 ("ipc/sem.c: move wake_up_process out of the spinlock section"), the update of semaphore's sem_otime(last semop time) was moved to one central position (do_smart_update).
But since do_smart_update() is only called for operations that modify the array, this means that wait-for-zero semops do not update sem_otime anymore.
The fix is simple:
Non-alter operations must update sem_otime.
--- ipc/sem.c | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-)
ipc/sem.c +29 -13
@@ -918,6 +918,24 @@ again: }/** +* set_semotime(sma, sops) - set sem_otime +* @sma: semaphore array +* @sops: operations that modified the array, may be NULL +* +* sem_otime is replicated to avoid cache line trashing. +* This function sets one instance to the current time. +*/ +static void set_semotime (struct sem_array *sma,struct sembuf *sops) +{ +if (sops ==NULL ) { + sma->sem_base[0 ].sem_otime =get_seconds (); + }else { + sma->sem_base[sops[0 ].sem_num].sem_otime = +get_seconds (); + } +} + +/** * do_smart_update(sma, sops, nsops, otime, pt) - optimized update_queue * @sma: semaphore array * @sops: operations that were performed
@@ -967,17 +985,10 @@ static void do_smart_update(struct sem_a } } } -if (otime) { -if (sops ==NULL ) { - sma->sem_base[0 ].sem_otime =get_seconds (); - }else { - sma->sem_base[sops[0 ].sem_num].sem_otime = -get_seconds (); - } - } +if (otime) +set_semotime (sma, sops); } -/* The following counts are associated to each semaphore: * semncnt number of tasks waiting on semval being nonzero * semzcnt number of tasks waiting on semval being zero
@@ -1839,12 +1850,17 @@ SYSCALL_DEFINE4(semtimedop, int, semid, error =perform_atomic_semop (sma, sops, nsops, un,task_tgid_vnr (current)); -if (error <=0 ) { -if (alter && error ==0 ) +if (error ==0 ) { +/* If the operation was successful, then do +* the required updates. +*/ +if (alter)do_smart_update (sma, sops, nsops,1 , &tasks); - - goto out_unlock_free; +else +set_semotime (sma, sops); } +if (error <=0 ) + goto out_unlock_free;/* We need to sleep on this operation, so we put the current * task into the pending queue and go to sleep.
Greg Kroah-Hartman
maintainerPATCH 50/50 x86: avoid remapping data in parse_setup_data()
In reply to Greg Kroah-Hartman3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linn Crosetto <[email protected]>
commit 30e46b574a1db7d14404e52dca8e1aa5f5155fd2 upstream.
Type SETUP_PCI, added by setup_efi_pci(), may advertise a ROM size larger than early_memremap() is able to handle, which is currently limited to 256kB. If this occurs it leads to a NULL dereference in parse_setup_data().
To avoid this, remap the setup_data header and allow parsing functions for individual types to handle their own data remapping.
--- arch/x86/include/asm/e820.h | 2 +- arch/x86/kernel/e820.c | 5 ++++- arch/x86/kernel/setup.c | 19 ++++++++----------- 3 files changed, 13 insertions(+), 13 deletions(-)
arch/x86/include/asm/e820.h +1 -1
@@ -29,7 +29,7 @@ extern void e820_setup_gap(void);extern int e820_search_gap (unsigned long *gapstart,unsigned long *gapsize,unsigned long start_addr,unsigned long long end_addr);struct setup_data ; -extern void parse_e820_ext (struct setup_data *data); +extern void parse_e820_ext (u64 phys_addr,u32 data_len);#if defined(CONFIG_X86_64 ) || \ (defined(CONFIG_X86_32 ) && defined(CONFIG_HIBERNATION ))
arch/x86/kernel/e820.c +4 -1
@@ -658,15 +658,18 @@ __init void e820_setup_gap(void)* boot_params.e820_map, others are passed via SETUP_E820_EXT node of * linked list of struct setup_data, which is parsed here. */ -void __init parse_e820_ext (struct setup_data *sdata) +void __init parse_e820_ext (u64 phys_addr,u32 data_len) {int entries;struct e820entry *extmap; +struct setup_data *sdata; + sdata =early_memremap (phys_addr, data_len); entries = sdata->len /sizeof (struct e820entry ); extmap = (struct e820entry *)(sdata->data);__append_e820_map (extmap, entries);sanitize_e820_map (e820.map,ARRAY_SIZE (e820.map), &e820.nr_map); +early_iounmap (sdata, data_len);printk (KERN_INFO "e820: extended physical RAM map:\n" );e820_print_map ("extended" ); }
arch/x86/kernel/setup.c +8 -11
@@ -426,25 +426,23 @@ static void __init reserve_initrd(void)static void __init parse_setup_data (void ) {struct setup_data *data; -u64 pa_data; +u64 pa_data, pa_next; pa_data = boot_params.hdr.setup_data;while (pa_data) { -u32 data_len, map_len; +u32 data_len, map_len, data_type; map_len =max (PAGE_SIZE - (pa_data & ~PAGE_MASK ), (u64 )sizeof (struct setup_data )); data =early_memremap (pa_data, map_len); data_len = data->len +sizeof (struct setup_data ); -if (data_len > map_len) { -early_iounmap (data, map_len); - data =early_memremap (pa_data, data_len); - map_len = data_len; - } + data_type = data->type; + pa_next = data->next; +early_iounmap (data, map_len); -switch (data->type) { +switch (data_type) {case SETUP_E820_EXT : -parse_e820_ext (data); +parse_e820_ext (pa_data, data_len);break ;case SETUP_DTB :add_dtb (pa_data);
@@ -452,8 +450,7 @@ static void __init parse_setup_data(voiddefault :break ; } - pa_data = data->next; -early_iounmap (data, map_len); + pa_data = pa_next; } }
Guenter Roeck
maintainerQuoted 5 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 3.11.6 release. There are 50 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Quoted 7 lines
Responses should be made by Fri Oct 18 17:43:24 UTC 2013. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.11.6-rc1.gzand the diffstat can be found below.
Build results:
total: 110 pass: 108 skipped: 2 fail: 0
qemu tests all passed, with the usual warning for the 'sh' target.
Thanks,
Guenter
Greg Kroah-Hartman
maintainerQuoted 14 lines · Guenter Roeck
Quoted 5 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 3.11.6 release. There are 50 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Quoted 7 lines
Responses should be made by Fri Oct 18 17:43:24 UTC 2013. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.11.6-rc1.gzand the diffstat can be found below.
Quoted 4 lines
Build results:
total: 110 pass: 108 skipped: 2 fail: 0qemu tests all passed, with the usual warning for the 'sh' target.
Thanks for testing and letting me know.
greg k-h
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 3.11.6 release. There are 50 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri Oct 18 17:43:24 UTC 2013. Anything received after that time might be too late.
Quoted 8 lines
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.11.6-rc1.gzand the diffstat can be found below.
thanks,
greg k-h
3.11.6
Patch applied cleanly - yes
Compile testing - passed
Boot testing - passed
dmesg regression testing - passed
dmesgs look good. No regressions compared to the previous dmesgs for this release. dmesg emerg, crit, alert, err are clean. No regressions in warn.
Test systems:
Samsung Series 9 900X4C Intel Corei5 (3.4 and later)
HP ProBook 6475b AMD A10-4600M APU with Radeon(tm) HD Graphics HP Compaq dc7700 SFF desktop: x86-64 Intel Core-i2 (cross-compile testing)
alpha defconfig Passed Passed
arm defconfig Passed Passed
arm64 defconfig Passed Passed
blackfin defconfig Passed Passed
c6x defconfig Passed Passed
mips defconfig Passed Passed
mipsel defconfig Passed Passed
powerpc Passed Passed
sh defconfig Passed Passed
sparc defconfig Passed Passed
tile defconfig Passed Passed
-- Shuah
Signature · 4 lines
Shuah Khan Senior Linux Kernel Developer - Open Source Group Samsung Research America(Silicon Valley) [email protected] | (970) 672-0658
Greg Kroah-Hartman
maintainerQuoted 20 lines · Shuah Khan
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 3.11.6 release. There are 50 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri Oct 18 17:43:24 UTC 2013. Anything received after that time might be too late.
Quoted 8 lines
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.11.6-rc1.gzand the diffstat can be found below.
thanks,
greg k-h
3.11.6
Quoted 9 lines
Patch applied cleanly - yes
Compile testing - passed
Boot testing - passed
dmesg regression testing - passeddmesgs look good. No regressions compared to the previous dmesgs for this release. dmesg emerg, crit, alert, err are clean. No regressions in warn.
Thanks for testing this, and 3.10.17 and letting me know it's all working properly.
greg k-h