BACKPORT: mwifiex: fix hung task on command timeout

Sometimes when command timeout occurs due to a firmware or
hardware bug, there may be some synchronous commands in command
queue. These commands are never downloaded to firmware causing
hung task warnings. This patch replaces wait_event_interruptible
call with wait_event_interruptible_timeout to fix the issue.

BUG=chrome-os-partner:34422
TEST=On Daisy ToT kernel, added a hack to trigger command timeout
and confirmed that other pending commands don't wait infinitely.

Change-Id: I7327a9a3a76920c9d4820ee8d413384da84c24a7
Signed-off-by: Avinash Patil <patila@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Reviewed-on: https://chromium-review.googlesource.com/233674
Reviewed-by: Paul Stewart <pstew@chromium.org>
BACKPORT: x86_64, traps: Stop using IST for #SS

On a 32-bit kernel, this has no effect, since there are no IST stacks.

On a 64-bit kernel, #SS can only happen in user code, on a failed iret
to user space, a canonical violation on access via RSP or RBP, or a
genuine stack segment violation in 32-bit kernel code.  The first two
cases don't need IST, and the latter two cases are unlikely fatal bugs,
and promoting them to double faults would be fine.

This fixes a bug in which the espfix64 code mishandles a stack segment
violation.

This saves 4k of memory per CPU and a tiny bit of code.

Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

BUG=chromium:439158
TEST=link build & boot, sigreturn PoC runs without failures

(cherry-picked from commit 6f442be2fb22be02cafa606f1769fa1e6f894441)
Signed-off-by: Kees Cook <keescook@chromium.org>

Change-Id: I9cd3fb516fef5785191fff6762339654c4656348
Reviewed-on: https://chromium-review.googlesource.com/236044
Tested-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Commit-Queue: Kees Cook <keescook@chromium.org>
UPSTREAM: x86/tls: Validate TLS entries to protect espfix

Installing a 16-bit RW data segment into the GDT defeats espfix.
AFAICT this will not affect glibc, Wine, or dosemu at all.

Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Acked-by: H. Peter Anvin <hpa@zytor.com>
Cc: stable@vger.kernel.org
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: security@kernel.org <security@kernel.org>
Cc: Willy Tarreau <w@1wt.eu>
Signed-off-by: Ingo Molnar <mingo@kernel.org>

BUG=chromium:439158
TEST=link build & boot, sigreturn PoC runs without failures

(cherry picked from commit 41bdc78544b8a93a9c6814b8bbbfef966272abbe)
Signed-off-by: Kees Cook <keescook@chromium.org>

Change-Id: I4c10847079e1746c01f5454cb6bc2485ef79521e
Reviewed-on: https://chromium-review.googlesource.com/236045
Tested-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Commit-Queue: Kees Cook <keescook@chromium.org>
UPSTREAM: x86/tls: Disallow unusual TLS segments

Users have no business installing custom code segments into the
GDT, and segments that are not present but are otherwise valid
are a historical source of interesting attacks.

For completeness, block attempts to set the L bit.  (Prior to
this patch, the L bit would have been silently dropped.)

This is an ABI break.  I've checked glibc, musl, and Wine, and
none of them look like they'll have any trouble.

Note to stable maintainers: this is a hardening patch that fixes
no known bugs.  Given the possibility of ABI issues, this
probably shouldn't be backported quickly.

Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Acked-by: H. Peter Anvin <hpa@zytor.com>
Cc: stable@vger.kernel.org # optional
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: security@kernel.org <security@kernel.org>
Cc: Willy Tarreau <w@1wt.eu>
Signed-off-by: Ingo Molnar <mingo@kernel.org>

BUG=chromium:439158
TEST=link build & boot, sigreturn PoC runs without failures

(cherry picked from commit 0e58af4e1d2166e9e33375a0f121e4867010d4f8)
Signed-off-by: Kees Cook <keescook@chromium.org>

Change-Id: Icebdb636b381b22dc4f5bcacbca9b2e566c15a7b
Reviewed-on: https://chromium-review.googlesource.com/236046
Tested-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Commit-Queue: Kees Cook <keescook@chromium.org>
Revert "CHROMIUM: ALSA: ASoC: max98090: Shutdown codec when changing to/from dmic."

This reverts commit 37e8e28b4b6b4c0e602a8eb618d9ec4d96b2f1b4.

The next patch will add event callback to DMICL_ENA and DMIR_ENA such
that turning on/off of DMIC of these two cases can be unified.
1. Switch recording to/from dmic while capturing.
2. Start/stop capturing using dmic.

BUG=chromium:415156
TEST=with patch series, check dmic works fine.
TEST=with patch series, switch to/from dmic and check captured result
is fine.
Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org>

Conflicts:
	sound/soc/codecs/max98090.c

Change-Id: Ia8eabe08af0c030e416bf4791f5cb9a220740ace
Reviewed-on: https://chromium-review.googlesource.com/236278
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Cheng-Yi Chiang <cychiang@chromium.org>
Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
Commit-Queue: Cheng-Yi Chiang <cychiang@chromium.org>
max98090: Shutdown codec before updating some registers

According to user manual, there are some registers whose change requires
shutdown bit = 0. This patch adds shutdown call before updating those
registers. The codec state will be restored after the update.

In max98090_dai_hw_params, codec might get new lrclk and pcm format.
If pcm format is changed, or needs to be set for the first time,
it needs a shutdown.
If lrclk is changed, or needs to be set for the first time, it needs a
shutdown.
If sysclk is changed, it needs a shutdown.

Apart from the registers listed on user manual, DMIC should be toggled
when codec is off. However, in reality, it is fine to enable DMIC when
codec is on, as long as there is an extra shutdown/restore after DMIC is
enabled.
This patch adds an event callback to DAPM supply widget DMICL_ENA and
DMICR_ENA so DAPM will shutdown codec before DMIC is enabled.
After DMIC is enabled, it does another shutdown/restore since shutdown
register is not protected in the time frame between PRE_PMU and POST_PMU
events.
Note that this is only required for max98090, not max98091.

In methods other than dmic_event, the code to shutdown codec, update
registers, and turn on codec are protected by a mutex in private data to
make sure codec is in shutdown state when register is being updated.

With this patch, there will be no audio drop in playback stream when
capture stream starts to use external mic. There will be audio drop in
playback stream when capture stream starts to use digital mic.

To avoid the playback stream audio drop, dmic can be enabled in all
playback cases, which will be handled in machine driver by adding DAPM
routes.

BUG=chromium:415156
TEST=On peach_pit (using max98090), record using external mic while
playing audio. There will be NO audio drop. Check recorded audio is fine.
TEST=On peach_pit (using max98090), record using internal mic while
playing audio. There will be audio drop. Check recorded audio is fine.
TEST=On peach_pi (using max98091), record using external mic while
playing audio. There will be NO audio drop. Check recorded audio is fine.
TEST=On peach_pi (using max98091), record using internal mic while
playing audio. There will be NO audio drop. Check recorded audio is fine.

Change-Id: I7a8986e70890e6dd39949866958bc9aa90427b32
Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/232355
daisy_max98095: Enable DMIC in all playback cases

On max98090, DMIC enable register can not be safely toggled when
shutdown bit is 1. This causes a short audio drop in playback whenever a
capture stream starts. To overcome this problem, turn on DMIC enable
bits during all audio playback cases.
Captured audio is not sent outside of codec because SDOEN is not enabled.

BUG=chromium:415156
TEST=On daisy 2.0, peach_pit (using max98090). Play youtube in the
background. Check there is no audio drop when capture stream starts.
TEST=On peach_pi (using max98091). Do the same test as above. Also,
check dmic is not enabled (0x13 register is 0x20) when there is only
playback stream.

Change-Id: I9b17eacb071a6ee950b995761ad0091e46c917d3
Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/232356
Merge branch 'chromeos-3.8' of https://chromium.googlesource.com/chromiumos/third_party/kernel into chromeos-3.8