platform/kernel/linux-amlogic.git
6 years agocrypto: Enable EXT4_ENCRYPTION for file based encryption [2/4]
Matthew Shyu [Mon, 15 Jan 2018 09:07:21 +0000 (17:07 +0800)]
crypto: Enable EXT4_ENCRYPTION for file based encryption [2/4]

PD#158397: crypto: enable FBE

Encrypto CONFIG_EXT4_ENCRYPTION for file based encryption

Change-Id: Iaad3679bc9ac05eea1d44ad7c6d30a0324e82e89
Signed-off-by: Matthew Shyu <matthew.shyu@amlogic.com>
6 years agoppmgr:enable ppmgr module [1/1]
Tellen Yu [Fri, 26 Jan 2018 07:18:22 +0000 (15:18 +0800)]
ppmgr:enable ppmgr module [1/1]

PD#157786: enable ppmgr

enable txlx ppmgr feature

Change-Id: I3939724e5a9c51349875bc340e5fcd47c2774e12
Signed-off-by: Tellen Yu <tellen.yu@amlogic.com>
6 years agoaudio: add audio external loopback feature for axg chip
Peipeng Zhao [Thu, 25 Jan 2018 05:49:44 +0000 (13:49 +0800)]
audio: add audio external loopback feature for axg chip

PD#159617: audio: add audio external loopback feature for axg chip

For S400 & S420 board, please modify dts to enable external loopback
please read following file:
Documentation/devicetree/bindings/amlogic/axg-sound-loopback.txt

Change-Id: Ie96d10eb8e6ae81aaff0b3e6965aa4e22f07f0b8
Signed-off-by: Peipeng Zhao <peipeng.zhao@amlogic.com>
6 years agotouchscreen: goodix gt9xx driver support
Sunny Luo [Sat, 20 Jan 2018 10:02:17 +0000 (18:02 +0800)]
touchscreen: goodix gt9xx driver support

PD#158973: goodix gt9xx driver support

Change-Id: Iffac9172ab1869521ecff731f7d50ddf7ea01b14
Signed-off-by: Sunny Luo <sunny.luo@amlogic.com>
6 years agohdmitx: update gxm dts
Yi Zhou [Fri, 19 Jan 2018 08:48:09 +0000 (16:48 +0800)]
hdmitx: update gxm dts

PD#154260: hdmitx: update gxm dts

Change-Id: Iddf3aa4512e5073f7e7dd1ba4558f38eb7998d58
Signed-off-by: Yi Zhou <yi.zhou@amlogic.com>
6 years agodts: fix 8.1 r311 bt open fail
Kuibao Zhang [Mon, 22 Jan 2018 07:20:35 +0000 (15:20 +0800)]
dts: fix 8.1 r311 bt open fail

PD#159307: BT fix 8.1 r311 bt open fail
1.DTS,change bt en pin
2.FIX bt en pinmux

Change-Id: I59c5978a5b52b49f9aa1aeede93d2761bca62959
Signed-off-by: Kuibao Zhang <kuibao.zhang@amlogic.com>
6 years agohdmitx: update txlx dts
Kaifu Hu [Tue, 23 Jan 2018 02:49:06 +0000 (10:49 +0800)]
hdmitx: update txlx dts

PD#159209: hdmitx: update txlx dts

add hdcp22_skpclk and hdcp22_esmclk.

Change-Id: I2a1cc3fd31cf3bb5002cdc1673573f18349f612d
Signed-off-by: Kaifu Hu <kaifu.hu@amlogic.com>
6 years agovbi: fix vbi crash on switch channel
Nian Jing [Fri, 19 Jan 2018 07:38:51 +0000 (15:38 +0800)]
vbi: fix vbi crash on switch channel

PD#158142: fix vbi crash on switch channel

Change-Id: I0d4a585479b142cc585db0b00efb9d8772cc61ee
Signed-off-by: Nian Jing <nian.jing@amlogic.com>
6 years agolcd: add lcd_extern p070acb driver
Weiming Liu [Thu, 18 Jan 2018 02:21:13 +0000 (10:21 +0800)]
lcd: add lcd_extern p070acb driver

PD#159016: lcd_extern: add p070acb driver

Change-Id: Id2fd949f37815de1ec9bbd90170dce459b661256
Signed-off-by: Weiming Liu <weiming.liu@amlogic.com>
6 years agoMerge branch 'android-4.9' into amlogic-4.9-dev
Victor Wan [Mon, 22 Jan 2018 12:17:25 +0000 (20:17 +0800)]
Merge branch 'android-4.9' into amlogic-4.9-dev

Conflicts:
Makefile
init/main.c

6 years agonand: Rsv zone bug fix
Liang Yang [Wed, 13 Dec 2017 09:15:01 +0000 (17:15 +0800)]
nand: Rsv zone bug fix

PD#156785: enhance rsv ecc&incomplete abnormal handler

NOTE: Relative commit(bug156785), patch together.

Change-Id: I05f9a4c521b75f5fcd071fdf09ca76a3f0aae033
Signed-off-by: Liang Yang <liang.yang@amlogic.com>
6 years agoaudio: dts: fix i2c for tas5707 and i2s pinmux
Xing Wang [Fri, 19 Jan 2018 15:07:58 +0000 (23:07 +0800)]
audio: dts: fix i2c for tas5707 and i2s pinmux

PD#159131: audio: dts : fix i2c for tas5707 and i2s pinmux

Change-Id: Ic4a2de8b5dcba668a793bf0c0c17d660418933b2
Signed-off-by: Xing Wang <xing.wang@amlogic.com>
6 years agolcd: optimize gpio register function for init value
Evoke Zhang [Fri, 19 Jan 2018 07:15:07 +0000 (15:15 +0800)]
lcd: optimize gpio register function for init value

PD#158752: lcd: optimize gpio register function for init value

For gpio register required init value, we can't register gpio when
lcd probe, otherwise it maybe change the gpio value which is working
by bootloader init.
So we register gpio when first calling by lcd power step controlling.

Change-Id: I629143f50924aac7e3ea27aa1a2c4b12a1992b71
Signed-off-by: Evoke Zhang <evoke.zhang@amlogic.com>
6 years agoionvideo: update ionvideo dts for tv
Jian Wang [Fri, 19 Jan 2018 10:08:58 +0000 (18:08 +0800)]
ionvideo: update ionvideo dts for tv

PD#158997: update ionvideo dts for tv

Change-Id: Iefa4ed1b93dc244d23aa0892e04722aed2836eb7
Signed-off-by: Jian Wang <jian.wang@amlogic.com>
6 years agoPD#158974: touchscreen: goodix GT1X driver support
Sunny Luo [Thu, 18 Jan 2018 13:27:27 +0000 (21:27 +0800)]
PD#158974: touchscreen: goodix GT1X driver support

Change-Id: I45b6e97a2fdba801c681e1858a155e2df7f050fd
Signed-off-by: Sunny Luo <sunny.luo@amlogic.com>
6 years agodi: add dummy buffer for first field
kele bai [Tue, 16 Jan 2018 10:46:05 +0000 (18:46 +0800)]
di: add dummy buffer for first field

PD#158592: di: add dummy buffer for first field

1) only middle buffer can be process in di

Change-Id: Ide92f1a17428cf5c27468a6dfc086ad2f4685fe3
Signed-off-by: kele bai <kele.bai@amlogic.com>
6 years agochar_dev: extend dynamic allocation of majors into a higher range
Logan Gunthorpe [Thu, 15 Jun 2017 20:05:20 +0000 (14:05 -0600)]
char_dev: extend dynamic allocation of majors into a higher range

PD#159028: char_dev: extend dynamic allocation of majors into a higher range

We've run into problems with running out of dynamicly assign char
device majors particullarly on automated test systems with
all-yes-configs. Roughly 40 dynamic assignments can be made with such
kernels at this time while space is reserved for only 20.

Currently, the kernel only prints a warning when dynamic allocation
overflows the reserved region. And when this happens drivers that have
fixed assignments can randomly fail depending on the order of
initialization of other drivers. Thus, adding a new char device can cause
unexpected failures in completely unrelated parts of the kernel.

This patch solves the problem by extending dynamic major number
allocations down from 511 once the 234-254 region fills up. Fixed
majors already exist above 255 so the infrastructure to support
high number majors is already in place. The patch reserves an
additional 128 major numbers which should hopefully last us a while.

Kernels that don't require more than 20 dynamic majors assigned (which
is pretty typical) should not be affected by this change.

Change-Id: Ibf1ddaf0b7ce623c9f1a18c42a1ad39a89bb3f41
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Alan Cox <alan@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Link: https://lkml.org/lkml/2017/6/4/107
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Yixun Lan <yixun.lan@amlogic.com>
6 years agopinctrl: correct spelling mistakes for txlx and axg
Xingyu Chen [Thu, 18 Jan 2018 09:41:00 +0000 (17:41 +0800)]
pinctrl: correct spelling mistakes for txlx and axg

PD#158937: pinctrl: correct spelling mistakes for txlx and axg

Change-Id: I465cd138b9b9a5e7089715c8495f47137d21e6ad
Signed-off-by: Xingyu Chen <xingyu.chen@amlogic.com>
6 years agomedia: fixed the issure of crash when get pts rec num.
Nanxin Qin [Tue, 16 Jan 2018 08:02:49 +0000 (16:02 +0800)]
media: fixed the issure of crash when get pts rec num.

PD#158950: fixed the issure of crash when get pts rec num.

Change-Id: Iadba80bd5c0c1c4dc001e0321ed0e1a460c57ced
Signed-off-by: Nanxin Qin <nanxin.qin@amlogic.com>
6 years agoDRM: fix gem object leak in PRIME_EXPORT operation.
sky zhou [Wed, 17 Jan 2018 04:12:59 +0000 (12:12 +0800)]
DRM: fix gem object leak in PRIME_EXPORT operation.

PD#158474: fixed exported fd leaked.

Exported fd didnot bind correct release function,
use core gem-prime function to re-write export function.
The import function is not provded, for now we only import
the buffer created from meson driver.

Change-Id: I15fad65741631ee2b367d088e733f20af8b0cf5a
Signed-off-by: sky zhou <sky.zhou@amlogic.com>
6 years agoPD#158972: touchscreen: focaltech ft3x27 driver support
Sunny Luo [Thu, 18 Jan 2018 06:08:22 +0000 (14:08 +0800)]
PD#158972: touchscreen: focaltech ft3x27 driver support

Change-Id: I5e1de4a6074a75c288d52fd388323978415610bd
Signed-off-by: Sunny Luo <sunny.luo@amlogic.com>
6 years agosd: add txlx r311 sd_uart support
Nan Li [Wed, 17 Jan 2018 02:58:29 +0000 (10:58 +0800)]
sd: add txlx r311 sd_uart support

PD#158480: r321 sd_emmc_b port is sdio wifi,
so modify r321 dts b port pinname.

Change-Id: I6a7e44c7b567f1ba9467c2696b6d5637b12939de
Signed-off-by: Nan Li <nan.li@amlogic.com>
6 years agoemmc: optimize emmc dts config
Nan Li [Tue, 16 Jan 2018 07:05:44 +0000 (15:05 +0800)]
emmc: optimize emmc dts config

PD#158871: optimize emmc dts config,
delete "status" cfg.

Change-Id: I5ae2aa66384db84619ffcad7354facd4aa2bac54
Signed-off-by: Nan Li <nan.li@amlogic.com>
6 years agoRevert "drm: force ARGB8888 format to osd display"
Yalong Liu [Thu, 18 Jan 2018 00:11:35 +0000 (08:11 +0800)]
Revert "drm: force ARGB8888 format to osd display"

PD#152825: Revert "drm: force ARGB8888 format to osd display"
This reverts commit 63a6fdd4fa329e0ac41da0ac672d014b7ad5a5ef.

Change-Id: Icc99d5ec3bcbf6e879bedf9385b4b56be679741b
Signed-off-by: Yalong Liu <yalong.liu@amlogic.com>
6 years agoledring: add suspend/resume for ledring
Renjun Xu [Wed, 17 Jan 2018 02:42:13 +0000 (10:42 +0800)]
ledring: add suspend/resume for ledring

PD#158940: add suspend/resume for ledring

Change-Id: I64827cd230708481768be7aabc3b4f814af8b636
Signed-off-by: Renjun Xu <renjun.xu@amlogic.com>
6 years agomm: fix compile error on other configs
tao zeng [Tue, 16 Jan 2018 06:47:49 +0000 (14:47 +0800)]
mm: fix compile error on other configs

PD#153120: mm:fix compile error on other configs

Change-Id: I8e72afa508c44149f69c6d8c34698d13848e539c
Signed-off-by: tao zeng <tao.zeng@amlogic.com>
6 years agonand: add llseek for fw_env tools
Liang Yang [Fri, 12 Jan 2018 06:18:52 +0000 (14:18 +0800)]
nand: add llseek for fw_env tools

PD#158552: Implememt llseek for fw_printenv/fw_setenv tools

Change-Id: Ie6176903c7155cdb7daf17049a7356ed8f61e463
Signed-off-by: Liang Yang <liang.yang@amlogic.com>
6 years agosd: add txlx r311 sd_uart support
Nan Li [Thu, 11 Jan 2018 08:43:14 +0000 (16:43 +0800)]
sd: add txlx r311 sd_uart support

PD#158480: add sd_uart support on txlx r311.

Change-Id: I62a094e66ca5934e0992cc6a5cc44d14e8ce20c3
Signed-off-by: Nan Li <nan.li@amlogic.com>
6 years agomm: close debug print of cma alloc
tao zeng [Mon, 15 Jan 2018 06:04:52 +0000 (14:04 +0800)]
mm: close debug print of cma alloc

PD#153120: mm: close debug print of cma alloc

These print message may print a lot when video playback
And cause it not smooth.

Change-Id: If1f18d5e8a0234f1daca2c6e803a23ba90354414
Signed-off-by: tao zeng <tao.zeng@amlogic.com>
6 years agomm: check pfn overflow for low memory platform
tao zeng [Tue, 9 Jan 2018 06:03:15 +0000 (14:03 +0800)]
mm: check pfn overflow for low memory platform

PD#158373: mm: check pfn overflow for low memory platform

On ARM64 platform, when vmemmap_populate is called for reserve
memory for struct page, it reserved based 1GB a loop. And 16MB
memory will be reserved at least. This caused memory waste if
total RAM is less than 1GB.

Basically reserve memory size for struct page is calculated by:

    reserve size = sizeof(struct page) * number of pages.

For example, currently struct page is 64 bytes on ARM64. A page
is 4KB. So reserve size table can be:

    Memory  |  page count  |  reserve size(bytes)
-------------------------------------------------
     128MB  |       32768  |         2097152(2MB)
     256MB  |       65536  |         4194304(4MB)
     512MB  |      131072  |         8388608(8MB)

Note, This reserve is aligned at 2MB.

Change-Id: I912ab01252d68fd065eb94fa2c5556cefa59a256
Signed-off-by: tao zeng <tao.zeng@amlogic.com>
6 years agoledring: modify ioctl support 32bit and 64bit
Renjun Xu [Thu, 11 Jan 2018 05:54:10 +0000 (13:54 +0800)]
ledring: modify ioctl support 32bit and 64bit

PD#157849: modify ioctl support 32bit and 64bit

Change-Id: I2f2395110454a2a05ec089601a937a1c884fa800
Signed-off-by: Renjun Xu <renjun.xu@amlogic.com>
6 years agoclkmsr: init clkmsr earlier for lcd driver called
Evoke Zhang [Thu, 11 Jan 2018 08:51:36 +0000 (16:51 +0800)]
clkmsr: init clkmsr earlier for lcd driver called

PD#158608: clkmsr: init clkmsr earlier for lcd driver called.
also add missed pwm config in dts for backlight,
and add pwm pointer protection in backlight driver.

Change-Id: Ib3d435a0f4418e31d94e65b1cee9919f1f6325c8
Signed-off-by: Evoke Zhang <evoke.zhang@amlogic.com>
6 years agoemmc: optimize emmc driver configs.
Nan Li [Tue, 9 Jan 2018 11:44:58 +0000 (19:44 +0800)]
emmc: optimize emmc driver configs.

PD#158348: modify emmc dts config data to match data.

Change-Id: Id1f29a8f5b47342376cfa976c6dba7e88bcc5514
Signed-off-by: Nan Li <nan.li@amlogic.com>
6 years agoMerge 4.9.76 into android-4.9
Greg Kroah-Hartman [Wed, 10 Jan 2018 08:51:38 +0000 (09:51 +0100)]
Merge 4.9.76 into android-4.9

Changes in 4.9.76
kernel/acct.c: fix the acct->needcheck check in check_free_space()
crypto: n2 - cure use after free
crypto: chacha20poly1305 - validate the digest size
crypto: pcrypt - fix freeing pcrypt instances
sunxi-rsb: Include OF based modalias in device uevent
fscache: Fix the default for fscache_maybe_release_page()
nbd: fix use-after-free of rq/bio in the xmit path
kernel: make groups_sort calling a responsibility group_info allocators
kernel/signal.c: protect the traced SIGNAL_UNKILLABLE tasks from SIGKILL
kernel/signal.c: protect the SIGNAL_UNKILLABLE tasks from !sig_kernel_only() signals
kernel/signal.c: remove the no longer needed SIGNAL_UNKILLABLE check in complete_signal()
iommu/arm-smmu-v3: Don't free page table ops twice
iommu/arm-smmu-v3: Cope with duplicated Stream IDs
ARC: uaccess: dont use "l" gcc inline asm constraint modifier
Input: elantech - add new icbody type 15
x86/microcode/AMD: Add support for fam17h microcode loading
parisc: Fix alignment of pa_tlb_lock in assembly on 32-bit SMP kernel
parisc: qemu idle sleep support
x86/tlb: Drop the _GPL from the cpu_tlbstate export
Map the vsyscall page with _PAGE_USER
mtd: nand: pxa3xx: Fix READOOB implementation
Linux 4.9.76

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
6 years agoaudio: tdm: set tdmin max channals by dts
Yueguie He [Wed, 10 Jan 2018 05:22:33 +0000 (13:22 +0800)]
audio: tdm: set tdmin max channals by dts

PD#158473: set tdmin max channals by dts

Change-Id: Ia6ff262fec6b3c156ac35f89b72cd690621f12fc
Signed-off-by: Yueguie He <yuegui.he@amlogic.com>
6 years agodi: add protection for no mirror function
kele bai [Wed, 20 Dec 2017 02:12:46 +0000 (10:12 +0800)]
di: add protection for no mirror function

PD#157314: di: add protection for no mirror function

1) disable mirror function, set keep frame to 0 avoid post process
   buffer
2) modify for keep function, avoid crash caused by calling de post
   in blankout mode
3) move mutex operation out of tasklet
4) remove framereset in hw disable function

Change-Id: I6166a855a7fe6ad38a21c570e9ad0a6f9a204424
Signed-off-by: kele bai <kele.bai@amlogic.com>
6 years agoLinux 4.9.76 v4.9.76
Greg Kroah-Hartman [Wed, 10 Jan 2018 08:29:55 +0000 (09:29 +0100)]
Linux 4.9.76

6 years agomtd: nand: pxa3xx: Fix READOOB implementation
Boris Brezillon [Mon, 18 Dec 2017 10:32:45 +0000 (11:32 +0100)]
mtd: nand: pxa3xx: Fix READOOB implementation

commit fee4380f368e84ed216b62ccd2fbc4126f2bf40b upstream.

In the current driver, OOB bytes are accessed in raw mode, and when a
page access is done with NDCR_SPARE_EN set and NDCR_ECC_EN cleared, the
driver must read the whole spare area (64 bytes in case of a 2k page,
16 bytes for a 512 page). The driver was only reading the free OOB
bytes, which was leaving some unread data in the FIFO and was somehow
leading to a timeout.

We could patch the driver to read ->spare_size + ->ecc_size instead of
just ->spare_size when READOOB is requested, but we'd better make
in-band and OOB accesses consistent.
Since the driver is always accessing in-band data in non-raw mode (with
the ECC engine enabled), we should also access OOB data in this mode.
That's particularly useful when using the BCH engine because in this
mode the free OOB bytes are also ECC protected.

Fixes: 43bcfd2bb24a ("mtd: nand: pxa3xx: Add driver-specific ECC BCH support")
Reported-by: Sean Nyekjær <sean.nyekjaer@prevas.dk>
Tested-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Tested-by: Sean Nyekjaer <sean.nyekjaer@prevas.dk>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agoMap the vsyscall page with _PAGE_USER
Borislav Petkov [Thu, 4 Jan 2018 16:42:45 +0000 (17:42 +0100)]
Map the vsyscall page with _PAGE_USER

This needs to happen early in kaiser_pagetable_walk(), before the
hierarchy is established so that _PAGE_USER permission can be really
set.

A proper fix would be to teach kaiser_pagetable_walk() to update those
permissions but the vsyscall page is the only exception here so ...

Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agox86/tlb: Drop the _GPL from the cpu_tlbstate export
Thomas Gleixner [Thu, 4 Jan 2018 21:19:04 +0000 (22:19 +0100)]
x86/tlb: Drop the _GPL from the cpu_tlbstate export

commit 1e5476815fd7f98b888e01a0f9522b63085f96c9 upstream.

The recent changes for PTI touch cpu_tlbstate from various tlb_flush
inlines. cpu_tlbstate is exported as GPL symbol, so this causes a
regression when building out of tree drivers for certain graphics cards.

Aside of that the export was wrong since it was introduced as it should
have been EXPORT_PER_CPU_SYMBOL_GPL().

Use the correct PER_CPU export and drop the _GPL to restore the previous
state which allows users to utilize the cards they payed for.

As always I'm really thrilled to make this kind of change to support the
#friends (or however the hot hashtag of today is spelled) from that closet
sauce graphics corp.

Fixes: 1e02ce4cccdc ("x86: Store a per-cpu shadow copy of CR4")
Fixes: 6fd166aae78c ("x86/mm: Use/Fix PCID to optimize user/kernel switches")
Reported-by: Kees Cook <keescook@google.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Thomas Backlund <tmb@mageia.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agoparisc: qemu idle sleep support
Helge Deller [Fri, 5 Jan 2018 20:55:38 +0000 (21:55 +0100)]
parisc: qemu idle sleep support

commit 310d82784fb4d60c80569f5ca9f53a7f3bf1d477 upstream.

Add qemu idle sleep support when running under qemu with SeaBIOS PDC
firmware.

Like the power architecture we use the "or" assembler instructions,
which translate to nops on real hardware, to indicate that qemu shall
idle sleep.

Signed-off-by: Helge Deller <deller@gmx.de>
Cc: Richard Henderson <rth@twiddle.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agoparisc: Fix alignment of pa_tlb_lock in assembly on 32-bit SMP kernel
Helge Deller [Tue, 2 Jan 2018 19:36:44 +0000 (20:36 +0100)]
parisc: Fix alignment of pa_tlb_lock in assembly on 32-bit SMP kernel

commit 88776c0e70be0290f8357019d844aae15edaa967 upstream.

Qemu for PARISC reported on a 32bit SMP parisc kernel strange failures
about "Not-handled unaligned insn 0x0e8011d6 and 0x0c2011c9."

Those opcodes evaluate to the ldcw() assembly instruction which requires
(on 32bit) an alignment of 16 bytes to ensure atomicity.

As it turns out, qemu is correct and in our assembly code in entry.S and
pacache.S we don't pay attention to the required alignment.

This patch fixes the problem by aligning the lock offset in assembly
code in the same manner as we do in our C-code.

Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agox86/microcode/AMD: Add support for fam17h microcode loading
Tom Lendacky [Thu, 30 Nov 2017 22:46:40 +0000 (16:46 -0600)]
x86/microcode/AMD: Add support for fam17h microcode loading

commit f4e9b7af0cd58dd039a0fb2cd67d57cea4889abf upstream.

The size for the Microcode Patch Block (MPB) for an AMD family 17h
processor is 3200 bytes.  Add a #define for fam17h so that it does
not default to 2048 bytes and fail a microcode load/update.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Borislav Petkov <bp@alien8.de>
Link: https://lkml.kernel.org/r/20171130224640.15391.40247.stgit@tlendack-t1.amdoffice.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Alice Ferrazzi <alicef@gentoo.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agoInput: elantech - add new icbody type 15
Aaron Ma [Sun, 26 Nov 2017 00:48:41 +0000 (16:48 -0800)]
Input: elantech - add new icbody type 15

commit 10d900303f1c3a821eb0bef4e7b7ece16768fba4 upstream.

The touchpad of Lenovo Thinkpad L480 reports it's version as 15.

Signed-off-by: Aaron Ma <aaron.ma@canonical.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agoARC: uaccess: dont use "l" gcc inline asm constraint modifier
Vineet Gupta [Fri, 8 Dec 2017 16:26:58 +0000 (08:26 -0800)]
ARC: uaccess: dont use "l" gcc inline asm constraint modifier

commit 79435ac78d160e4c245544d457850a56f805ac0d upstream.

This used to setup the LP_COUNT register automatically, but now has been
removed.

There was an earlier fix 3c7c7a2fc8811 which fixed instance in delay.h but
somehow missed this one as gcc change had not made its way into
production toolchains and was not pedantic as it is now !

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agoiommu/arm-smmu-v3: Cope with duplicated Stream IDs
Robin Murphy [Tue, 2 Jan 2018 12:33:14 +0000 (12:33 +0000)]
iommu/arm-smmu-v3: Cope with duplicated Stream IDs

commit 563b5cbe334e9503ab2b234e279d500fc4f76018 upstream.

For PCI devices behind an aliasing PCIe-to-PCI/X bridge, the bridge
alias to DevFn 0.0 on the subordinate bus may match the original RID of
the device, resulting in the same SID being present in the device's
fwspec twice. This causes trouble later in arm_smmu_write_strtab_ent()
when we wind up visiting the STE a second time and find it already live.

Avoid the issue by giving arm_smmu_install_ste_for_dev() the cleverness
to skip over duplicates. It seems mildly counterintuitive compared to
preventing the duplicates from existing in the first place, but since
the DT and ACPI probe paths build their fwspecs differently, this is
actually the cleanest and most self-contained way to deal with it.

Fixes: 8f78515425da ("iommu/arm-smmu: Implement of_xlate() for SMMUv3")
Reported-by: Tomasz Nowicki <tomasz.nowicki@caviumnetworks.com>
Tested-by: Tomasz Nowicki <Tomasz.Nowicki@cavium.com>
Tested-by: Jayachandran C. <jnair@caviumnetworks.com>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agoiommu/arm-smmu-v3: Don't free page table ops twice
Jean-Philippe Brucker [Thu, 14 Dec 2017 11:03:01 +0000 (11:03 +0000)]
iommu/arm-smmu-v3: Don't free page table ops twice

commit 57d72e159b60456c8bb281736c02ddd3164037aa upstream.

Kasan reports a double free when finalise_stage_fn fails: the io_pgtable
ops are freed by arm_smmu_domain_finalise and then again by
arm_smmu_domain_free. Prevent this by leaving pgtbl_ops empty on failure.

Fixes: 48ec83bcbcf5 ("iommu/arm-smmu: Add initial driver support for ARM SMMUv3 devices")
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agokernel/signal.c: remove the no longer needed SIGNAL_UNKILLABLE check in complete_signal()
Oleg Nesterov [Fri, 17 Nov 2017 23:30:08 +0000 (15:30 -0800)]
kernel/signal.c: remove the no longer needed SIGNAL_UNKILLABLE check in complete_signal()

commit 426915796ccaf9c2bd9bb06dc5702225957bc2e5 upstream.

complete_signal() checks SIGNAL_UNKILLABLE before it starts to destroy
the thread group, today this is wrong in many ways.

If nothing else, fatal_signal_pending() should always imply that the
whole thread group (except ->group_exit_task if it is not NULL) is
killed, this check breaks the rule.

After the previous changes we can rely on sig_task_ignored();
sig_fatal(sig) && SIGNAL_UNKILLABLE can only be true if we actually want
to kill this task and sig == SIGKILL OR it is traced and debugger can
intercept the signal.

This should hopefully fix the problem reported by Dmitry.  This
test-case

static int init(void *arg)
{
for (;;)
pause();
}

int main(void)
{
char stack[16 * 1024];

for (;;) {
int pid = clone(init, stack + sizeof(stack)/2,
CLONE_NEWPID | SIGCHLD, NULL);
assert(pid > 0);

assert(ptrace(PTRACE_ATTACH, pid, 0, 0) == 0);
assert(waitpid(-1, NULL, WSTOPPED) == pid);

assert(ptrace(PTRACE_DETACH, pid, 0, SIGSTOP) == 0);
assert(syscall(__NR_tkill, pid, SIGKILL) == 0);
assert(pid == wait(NULL));
}
}

triggers the WARN_ON_ONCE(!(task->jobctl & JOBCTL_STOP_PENDING)) in
task_participate_group_stop().  do_signal_stop()->signal_group_exit()
checks SIGNAL_GROUP_EXIT and return false, but task_set_jobctl_pending()
checks fatal_signal_pending() and does not set JOBCTL_STOP_PENDING.

And his should fix the minor security problem reported by Kyle,
SECCOMP_RET_TRACE can miss fatal_signal_pending() the same way if the
task is the root of a pid namespace.

Link: http://lkml.kernel.org/r/20171103184246.GD21036@redhat.com
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Reported-by: Kyle Huey <me@kylehuey.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Tested-by: Kyle Huey <me@kylehuey.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agokernel/signal.c: protect the SIGNAL_UNKILLABLE tasks from !sig_kernel_only() signals
Oleg Nesterov [Fri, 17 Nov 2017 23:30:04 +0000 (15:30 -0800)]
kernel/signal.c: protect the SIGNAL_UNKILLABLE tasks from !sig_kernel_only() signals

commit ac25385089f673560867eb5179228a44ade0cfc1 upstream.

Change sig_task_ignored() to drop the SIG_DFL && !sig_kernel_only()
signals even if force == T.  This simplifies the next change and this
matches the same check in get_signal() which will drop these signals
anyway.

Link: http://lkml.kernel.org/r/20171103184227.GC21036@redhat.com
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Tested-by: Kyle Huey <me@kylehuey.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agokernel/signal.c: protect the traced SIGNAL_UNKILLABLE tasks from SIGKILL
Oleg Nesterov [Fri, 17 Nov 2017 23:30:01 +0000 (15:30 -0800)]
kernel/signal.c: protect the traced SIGNAL_UNKILLABLE tasks from SIGKILL

commit 628c1bcba204052d19b686b5bac149a644cdb72e upstream.

The comment in sig_ignored() says "Tracers may want to know about even
ignored signals" but SIGKILL can not be reported to debugger and it is
just wrong to return 0 in this case: SIGKILL should only kill the
SIGNAL_UNKILLABLE task if it comes from the parent ns.

Change sig_ignored() to ignore ->ptrace if sig == SIGKILL and rely on
sig_task_ignored().

SISGTOP coming from within the namespace is not really right too but at
least debugger can intercept it, and we can't drop it here because this
will break "gdb -p 1": ptrace_attach() won't work.  Perhaps we will add
another ->ptrace check later, we will see.

Link: http://lkml.kernel.org/r/20171103184206.GB21036@redhat.com
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Tested-by: Kyle Huey <me@kylehuey.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agokernel: make groups_sort calling a responsibility group_info allocators
Thiago Rafael Becker [Thu, 14 Dec 2017 23:33:12 +0000 (15:33 -0800)]
kernel: make groups_sort calling a responsibility group_info allocators

commit bdcf0a423ea1c40bbb40e7ee483b50fc8aa3d758 upstream.

In testing, we found that nfsd threads may call set_groups in parallel
for the same entry cached in auth.unix.gid, racing in the call of
groups_sort, corrupting the groups for that entry and leading to
permission denials for the client.

This patch:
 - Make groups_sort globally visible.
 - Move the call to groups_sort to the modifiers of group_info
 - Remove the call to groups_sort from set_groups

Link: http://lkml.kernel.org/r/20171211151420.18655-1-thiago.becker@gmail.com
Signed-off-by: Thiago Rafael Becker <thiago.becker@gmail.com>
Reviewed-by: Matthew Wilcox <mawilcox@microsoft.com>
Reviewed-by: NeilBrown <neilb@suse.com>
Acked-by: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agonbd: fix use-after-free of rq/bio in the xmit path
Jens Axboe [Thu, 17 Nov 2016 19:30:37 +0000 (12:30 -0700)]
nbd: fix use-after-free of rq/bio in the xmit path

commit 429a787be6793554ee02aacc7e1f11ebcecc4453 upstream.

For writes, we can get a completion in while we're still iterating
the request and bio chain. If that happens, we're reading freed
memory and we can crash.

Break out after the last segment and avoid having the iterator
read freed memory.

Reviewed-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agofscache: Fix the default for fscache_maybe_release_page()
David Howells [Tue, 2 Jan 2018 10:02:19 +0000 (10:02 +0000)]
fscache: Fix the default for fscache_maybe_release_page()

commit 98801506552593c9b8ac11021b0cdad12cab4f6b upstream.

Fix the default for fscache_maybe_release_page() for when the cookie isn't
valid or the page isn't cached.  It mustn't return false as that indicates
the page cannot yet be freed.

The problem with the default is that if, say, there's no cache, but a
network filesystem's pages are using up almost all the available memory, a
system can OOM because the filesystem ->releasepage() op will not allow
them to be released as fscache_maybe_release_page() incorrectly prevents
it.

This can be tested by writing a sequence of 512MiB files to an AFS mount.
It does not affect NFS or CIFS because both of those wrap the call in a
check of PG_fscache and it shouldn't bother Ceph as that only has
PG_private set whilst writeback is in progress.  This might be an issue for
9P, however.

Note that the pages aren't entirely stuck.  Removing a file or unmounting
will clear things because that uses ->invalidatepage() instead.

Fixes: 201a15428bd5 ("FS-Cache: Handle pages pending storage that get evicted under OOM conditions")
Reported-by: Marc Dionne <marc.dionne@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Tested-by: Marc Dionne <marc.dionne@auristor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agosunxi-rsb: Include OF based modalias in device uevent
Stefan Brüns [Mon, 27 Nov 2017 19:05:34 +0000 (20:05 +0100)]
sunxi-rsb: Include OF based modalias in device uevent

commit e2bf801ecd4e62222a46d1ba9e57e710171d29c1 upstream.

Include the OF-based modalias in the uevent sent when registering devices
on the sunxi RSB bus, so that user space has a chance to autoload the
kernel module for the device.

Fixes a regression caused by commit 3f241bfa60bd ("arm64: allwinner: a64:
pine64: Use dcdc1 regulator for mmc0"). When the axp20x-rsb module for
the AXP803 PMIC is built as a module, it is not loaded and the system
ends up with an disfunctional MMC controller.

Fixes: d787dcdb9c8f ("bus: sunxi-rsb: Add driver for Allwinner Reduced Serial Bus")
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agocrypto: pcrypt - fix freeing pcrypt instances
Eric Biggers [Wed, 20 Dec 2017 22:28:25 +0000 (14:28 -0800)]
crypto: pcrypt - fix freeing pcrypt instances

commit d76c68109f37cb85b243a1cf0f40313afd2bae68 upstream.

pcrypt is using the old way of freeing instances, where the ->free()
method specified in the 'struct crypto_template' is passed a pointer to
the 'struct crypto_instance'.  But the crypto_instance is being
kfree()'d directly, which is incorrect because the memory was actually
allocated as an aead_instance, which contains the crypto_instance at a
nonzero offset.  Thus, the wrong pointer was being kfree()'d.

Fix it by switching to the new way to free aead_instance's where the
->free() method is specified in the aead_instance itself.

Reported-by: syzbot <syzkaller@googlegroups.com>
Fixes: 0496f56065e0 ("crypto: pcrypt - Add support for new AEAD interface")
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agocrypto: chacha20poly1305 - validate the digest size
Eric Biggers [Mon, 11 Dec 2017 20:15:17 +0000 (12:15 -0800)]
crypto: chacha20poly1305 - validate the digest size

commit e57121d08c38dabec15cf3e1e2ad46721af30cae upstream.

If the rfc7539 template was instantiated with a hash algorithm with
digest size larger than 16 bytes (POLY1305_DIGEST_SIZE), then the digest
overran the 'tag' buffer in 'struct chachapoly_req_ctx', corrupting the
subsequent memory, including 'cryptlen'.  This caused a crash during
crypto_skcipher_decrypt().

Fix it by, when instantiating the template, requiring that the
underlying hash algorithm has the digest size expected for Poly1305.

Reproducer:

    #include <linux/if_alg.h>
    #include <sys/socket.h>
    #include <unistd.h>

    int main()
    {
            int algfd, reqfd;
            struct sockaddr_alg addr = {
                    .salg_type = "aead",
                    .salg_name = "rfc7539(chacha20,sha256)",
            };
            unsigned char buf[32] = { 0 };

            algfd = socket(AF_ALG, SOCK_SEQPACKET, 0);
            bind(algfd, (void *)&addr, sizeof(addr));
            setsockopt(algfd, SOL_ALG, ALG_SET_KEY, buf, sizeof(buf));
            reqfd = accept(algfd, 0, 0);
            write(reqfd, buf, 16);
            read(reqfd, buf, 16);
    }

Reported-by: syzbot <syzkaller@googlegroups.com>
Fixes: 71ebc4d1b27d ("crypto: chacha20poly1305 - Add a ChaCha20-Poly1305 AEAD construction, RFC7539")
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agocrypto: n2 - cure use after free
Jan Engelhardt [Tue, 19 Dec 2017 18:09:07 +0000 (19:09 +0100)]
crypto: n2 - cure use after free

commit 203f45003a3d03eea8fa28d74cfc74c354416fdb upstream.

queue_cache_init is first called for the Control Word Queue
(n2_crypto_probe). At that time, queue_cache[0] is NULL and a new
kmem_cache will be allocated. If the subsequent n2_register_algs call
fails, the kmem_cache will be released in queue_cache_destroy, but
queue_cache_init[0] is not set back to NULL.

So when the Module Arithmetic Unit gets probed next (n2_mau_probe),
queue_cache_init will not allocate a kmem_cache again, but leave it
as its bogus value, causing a BUG() to trigger when queue_cache[0] is
eventually passed to kmem_cache_zalloc:

n2_crypto: Found N2CP at /virtual-devices@100/n2cp@7
n2_crypto: Registered NCS HVAPI version 2.0
called queue_cache_init
n2_crypto: md5 alg registration failed
n2cp f028687c: /virtual-devices@100/n2cp@7: Unable to register algorithms.
called queue_cache_destroy
n2cp: probe of f028687c failed with error -22
n2_crypto: Found NCP at /virtual-devices@100/ncp@6
n2_crypto: Registered NCS HVAPI version 2.0
called queue_cache_init
kernel BUG at mm/slab.c:2993!
Call Trace:
 [0000000000604488] kmem_cache_alloc+0x1a8/0x1e0
                  (inlined) kmem_cache_zalloc
                  (inlined) new_queue
                  (inlined) spu_queue_setup
                  (inlined) handle_exec_unit
 [0000000010c61eb4] spu_mdesc_scan+0x1f4/0x460 [n2_crypto]
 [0000000010c62b80] n2_mau_probe+0x100/0x220 [n2_crypto]
 [000000000084b174] platform_drv_probe+0x34/0xc0

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agokernel/acct.c: fix the acct->needcheck check in check_free_space()
Oleg Nesterov [Fri, 5 Jan 2018 00:17:49 +0000 (16:17 -0800)]
kernel/acct.c: fix the acct->needcheck check in check_free_space()

commit 4d9570158b6260f449e317a5f9ed030c2504a615 upstream.

As Tsukada explains, the time_is_before_jiffies(acct->needcheck) check
is very wrong, we need time_is_after_jiffies() to make sys_acct() work.

Ignoring the overflows, the code should "goto out" if needcheck >
jiffies, while currently it checks "needcheck < jiffies" and thus in the
likely case check_free_space() does nothing until jiffies overflow.

In particular this means that sys_acct() is simply broken, acct_on()
sets acct->needcheck = jiffies and expects that check_free_space()
should set acct->active = 1 after the free-space check, but this won't
happen if jiffies increments in between.

This was broken by commit 32dc73086015 ("get rid of timer in
kern/acct.c") in 2011, then another (correct) commit 795a2f22a8ea
("acct() should honour the limits from the very beginning") made the
problem more visible.

Link: http://lkml.kernel.org/r/20171213133940.GA6554@redhat.com
Fixes: 32dc73086015 ("get rid of timer in kern/acct.c")
Reported-by: TSUKADA Koutaro <tsukada@ascade.co.jp>
Suggested-by: TSUKADA Koutaro <tsukada@ascade.co.jp>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agoled: modify ledring for mic board
Renjun Xu [Tue, 9 Jan 2018 07:53:15 +0000 (15:53 +0800)]
led: modify ledring for mic board

PD#157849: modify ledring for mic board

Change-Id: I81c8400ee559dcf6f2bc3620d75e449c360df4f3
Signed-off-by: Renjun Xu <renjun.xu@amlogic.com>
6 years agowifi: add wifi build in support[2/2]
Rongjun Chen [Tue, 5 Dec 2017 06:12:35 +0000 (14:12 +0800)]
wifi: add wifi build in support[2/2]

PD#158061: wifi: add wifi build in supportD

Change-Id: I42987b8579035cc0ca83d286f7a46fc0b83047e9
Signed-off-by: Rongjun Chen <rongjun.chen@amlogic.com>
6 years agoalarm: fixed the tiemerE counter's reading order
hong.guo [Tue, 9 Jan 2018 08:36:07 +0000 (16:36 +0800)]
alarm: fixed the tiemerE counter's reading order

PD#157845: fixed the tiemerE counter's reading order

Change-Id: Ieccfc2fded45da398fa45e957497eff670790fa6
Signed-off-by: hong.guo <hong.guo@amlogic.com>
6 years agoclocksource: arch_timer: make virtual counter access configurable
Greg Hackmann [Tue, 19 Sep 2017 17:55:17 +0000 (10:55 -0700)]
clocksource: arch_timer: make virtual counter access configurable

Change-Id: Ibdb1fd768b748002b90bfc165612c12c8311f8a2
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
6 years agoarm64: issue isb when trapping CNTVCT_EL0 access
Greg Hackmann [Wed, 4 Oct 2017 16:31:34 +0000 (09:31 -0700)]
arm64: issue isb when trapping CNTVCT_EL0 access

Change-Id: I6005a6e944494257bfc2243fde2f7a09c3fd76c6
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
6 years agoBACKPORT: arm64: Add CNTFRQ_EL0 trap handler
Marc Zyngier [Mon, 24 Apr 2017 08:04:03 +0000 (09:04 +0100)]
BACKPORT: arm64: Add CNTFRQ_EL0 trap handler

We now trap accesses to CNTVCT_EL0 when the counter is broken
enough to require the kernel to mediate the access. But it
turns out that some existing userspace (such as OpenMPI) do
probe for the counter frequency, leading to an UNDEF exception
as CNTVCT_EL0 and CNTFRQ_EL0 share the same control bit.

The fix is to handle the exception the same way we do for CNTVCT_EL0.

Fixes: a86bd139f2ae ("arm64: arch_timer: Enable CNTVCT_EL0 trap if workaround is enabled")
Reported-by: Hanjun Guo <guohanjun@huawei.com>
Tested-by: Hanjun Guo <guohanjun@huawei.com>
Reviewed-by: Hanjun Guo <guohanjun@huawei.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
(cherry picked from commit 9842119a238bfb92cbab63258dabb54f0e7b111b)

Change-Id: I40401111d1e2ba52a9512536ff20c68dcef26c54
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
6 years agoBACKPORT: arm64: Add CNTVCT_EL0 trap handler
Marc Zyngier [Wed, 1 Feb 2017 11:48:58 +0000 (11:48 +0000)]
BACKPORT: arm64: Add CNTVCT_EL0 trap handler

Since people seem to make a point in breaking the userspace visible
counter, we have no choice but to trap the access. Add the required
handler.

Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
(cherry picked from commit 6126ce0588eb5a0752d5c8b5796a7fca324fd887)

Change-Id: I05700a533ea59e864e7a072605e3000e29526db3
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
6 years agoaudio: add headphone and microphone detect feature
Peipeng Zhao [Mon, 8 Jan 2018 11:51:22 +0000 (19:51 +0800)]
audio: add headphone and microphone detect feature

PD#158258: audio: add headphone and microphone detect feature

Change-Id: Iaf6170904470753b5c826fdbcbd4fac3c7884c8c
Signed-off-by: Peipeng Zhao <peipeng.zhao@amlogic.com>
6 years agomedia: codec_mm: del a printk info
Zhi Zhou [Tue, 9 Jan 2018 06:28:24 +0000 (14:28 +0800)]
media: codec_mm: del a printk info

PD#157881: disabled a debug msg info.
this msg is not a bug.

Change-Id: I043c57955646bcff92ee2dd9dbe41b8485e7c136
Signed-off-by: Zhi Zhou <zhi.zhou@amlogic.com>
6 years agohdmirx: enable the hdmirx module and code optimize
Yicheng Shen [Thu, 4 Jan 2018 02:56:31 +0000 (10:56 +0800)]
hdmirx: enable the hdmirx module and code optimize

PD#158047: hdmirx: enable the hdmirx module and code optimize

1.Enable hdmirx in meson64_defconfig;
2.Remove useless code;
3.Add EXTCON interface(communicate with systemcontrol);
4.Modify dump esm log methode;
5.Modify esm/skp clk handle(use clk tree);
6.Fix coding style errors;

Change-Id: I62982ab8f5a6a3b1f482759cd8c2c79236951783
Signed-off-by: Yicheng Shen <yicheng.shen@amlogic.com>
6 years agoANDROID: sdcardfs: Fix missing break on default_normal
Daniel Rosenberg [Mon, 8 Jan 2018 21:57:36 +0000 (13:57 -0800)]
ANDROID: sdcardfs: Fix missing break on default_normal

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 64672411
Change-Id: I98796df95dc9846adb77a11f49a1a254fb1618b1

6 years agoANDROID: arm64: kaslr: fixup Falkor workaround for 4.9
Todd Poynor [Mon, 8 Jan 2018 20:22:41 +0000 (12:22 -0800)]
ANDROID: arm64: kaslr: fixup Falkor workaround for 4.9

android-4.9 port of upstream commit
6c27c4082f4f70b9f41df4d0adf51128b40351df
"arm64: kaslr: Put kernel vectors address in separate data page"
failed to fixup code that does not omcpile when CONFIG_RANDOMIZE_BASE=y.

Port fixup for earlier kernels from ghackmann@google.com to
android-4.9:
  - replace ARM64_WORKAROUND_QCOM_FALKOR_E1003 alternative with
     compile-time CONFIG_ARCH_MSM8996 check]

Change-Id: Idc4bb255db830029093ea0d948a9e5066e2c13f8
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
6 years agoANDROID: usb: f_fs: Prevent gadget unbind if it is already unbound
Hemant Kumar [Mon, 8 Aug 2016 23:20:15 +0000 (16:20 -0700)]
ANDROID: usb: f_fs: Prevent gadget unbind if it is already unbound

Upon usb composition switch there is possibility of ep0 file
release happening after gadget driver bind. In case of composition
switch from adb to a non-adb composition gadget will never gets
bound again resulting into failure of usb device enumeration. Fix
this issue by checking FFS_FL_BOUND flag and avoid extra
gadget driver unbind if it is already done as part of composition
switch.

Change-Id: I1638001ff4a94f08224b188aa42425f3d732fa2b
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
6 years agoaudio: dts: disabled dmic
Xing Wang [Mon, 8 Jan 2018 08:17:38 +0000 (16:17 +0800)]
audio: dts: disabled dmic

PD#157997: audio: dts: disabled dmic

Change-Id: I7d43dccdfea30eb3de6e6243bbc64c279a4edb6b
Signed-off-by: Xing Wang <xing.wang@amlogic.com>
6 years agoMerge branch 'android-4.9' into amlogic-4.9-dev
Victor Wan [Mon, 8 Jan 2018 10:44:19 +0000 (18:44 +0800)]
Merge branch 'android-4.9' into amlogic-4.9-dev

Conflicts:
arch/arm/configs/omap2plus_defconfig
drivers/Makefile
drivers/android/binder.c

6 years agodi: move enable pre mif before frame reset avoid timeout
Bencheng Jing [Thu, 28 Dec 2017 09:30:07 +0000 (17:30 +0800)]
di: move enable pre mif before frame reset avoid timeout

PD#154836: di:  move enable pre mif before frame reset avoid timeout

1) enable pre mif before&after frame reset for
   mc mif will be clear by pre frame reset

Change-Id: Ied15c337c4b28a62a873bd36361357b8fecdaf32
Signed-off-by: Bencheng Jing <bencheng.jing@amlogic.com>
6 years agosd: add the polling method of sd card_detect
Nan Li [Thu, 4 Jan 2018 08:09:31 +0000 (16:09 +0800)]
sd: add the polling method of sd card_detect

PD#156898: add the polling method of sd card_detect,
because gpio irq remove raising & falling trigger method.

Change-Id: If270d27619d2686e74fe5e6d02748242faec4ce8
Signed-off-by: Nan Li <nan.li@amlogic.com>
6 years agopinctrl: define the pinmux with the same format [4/4]
Xingyu Chen [Thu, 14 Dec 2017 13:04:29 +0000 (21:04 +0800)]
pinctrl: define the pinmux with the same format [4/4]

PD#157965: pinctrl: define the pinmux with the same format.

there are two different pin controllers in Meson Soc Series, one of
them uses continuous 4-bit register to select function for each pin
(Eg: AXG and next), the other use indefinite bits that maybe from
different registers (Eg: Before AXG and GXLX)

previously, the driver use two different format to define the pinmux,
as follows:
[1] Before AXG and GXLX:
mux {
groups = "uart_ao_tx_a", "uart_ao_rx_a";
function = "uart_ao_a";
}

[2] AXG and next
mux {
pins = "GPIOAO_0", "GPIOAO_1";
function = "uart_ao_a";
}

which is a little confusing,and in this patch define the pinmux with
one format[1].

Change-Id: I04fb256294e1b664224c50a1baa622eb3a50b1c1
Signed-off-by: Xingyu Chen <xingyu.chen@amlogic.com>
6 years agopinctrl: separate soc drivers [3/4]
Xingyu Chen [Thu, 14 Dec 2017 07:59:11 +0000 (15:59 +0800)]
pinctrl: separate soc drivers [3/4]

PD#157965: pinctrl: separate soc drivers

When meson pinctrl is enabled, all meson platforms pinctrl drivers are
built in the kernel, with a significant amount of data.

This leads to situation where pinctrl drivers targeting an architecture
are also compiled and shipped on another one (ex: meson8 - ARM - compiled
and shipped on ARM64 builds). This is a waste of memory we can easily
avoid.

This change makes 3 pinctrl drivers (1 per SoC) out the original single
driver, allowing to compile and ship only the ones required.

porting from the upstream v4.15-rc2, commits as follows:

commit 277d14eb815fdfb95a72ea126bc09f75a2bd58fd

Change-Id: I68832eaf4a86233f89b8c32c44aaaab3593711d7
Signed-off-by: Xingyu Chen <xingyu.chen@amlogic.com>
6 years agopinctrl: get rid of unneeded domain structures [2/4]
Xingyu Chen [Thu, 14 Dec 2017 05:03:27 +0000 (13:03 +0800)]
pinctrl: get rid of unneeded domain structures [2/4]

PD#157965: pinctrl: get rid of unneeded domain structures

porting from the upstream v4.15-rc2, commits as follows:

commit db80f0e158e62164308a857bce442dfeddb5c29e

Change-Id: I7c65b6844159378b7ef766569cb373fb78997d51
Signed-off-by: Xingyu Chen <xingyu.chen@amlogic.com>
6 years agopinctrl: remove offset and pin_base from pinctrl [1/4]
Xingyu Chen [Wed, 13 Dec 2017 12:05:49 +0000 (20:05 +0800)]
pinctrl: remove offset and pin_base from pinctrl [1/4]

PD#157965: pinctrl: remove offset and pin_base from pinctrl

porting from the upstream v4.15-rc2, commits as follows:

commit 634e40b0c2bde81051e309cdfe4c26bbca3164ec
commit 70e5ecb1b994f2704c234cb12366d45474b98f32
commit 40833a84faed72f333b1626f00f59e6bebea4d98
commit 6affd6981ca5d2b1d3d9d5191b18bd4a692587fe

Change-Id: Ia856617fc202589199a9fc47664886a25779e8a0
Signed-off-by: Xingyu Chen <xingyu.chen@amlogic.com>
6 years agoirqchip: replace the gpio IRQ driver with upstream
Xingyu Chen [Sat, 30 Sep 2017 06:53:15 +0000 (14:53 +0800)]
irqchip: replace the gpio IRQ driver with upstream

PD#151900: irqchip: replace the gpio IRQ driver with upstream v4.15-rc2

1) separate the driver from the pinctrl driver
2) add support for GPIOAO* of M8B as interrupt source
3) irq lines of GPIOAO* maximum up to eight
4) remove the GPIO IRQ Controller in AO domain

note that the driver does not support for detecting the double-edge signal
through the pin,if you have related needs, please consider using polling.

test pass on axg_skt, p212

Change-Id: Iaa8da8a0cbfa0fe90d26fc8c2b775e045c8768f2
Signed-off-by: Xingyu Chen <xingyu.chen@amlogic.com>
6 years agomm: fix first 256MB lost problem
tao zeng [Wed, 3 Jan 2018 04:32:54 +0000 (12:32 +0800)]
mm: fix first 256MB lost problem

PD#157955: fix first 256MB lost problem

1. add Makefile.boot for define of ZRELADDR/
   PARAMS_PHYS/INITRD_PHYS
2. remove config of ARM_PATCH_PHYS_VIRT/AUTO_ZRELADDR
   to avoid boot panic when first 256MB memory enabled

Change-Id: I0495803f22bcfaa550437169a345adc988b40ef7
Signed-off-by: tao zeng <tao.zeng@amlogic.com>
6 years agoarm64: Kconfig: Reword UNMAP_KERNEL_AT_EL0 kconfig entry
Will Deacon [Tue, 14 Nov 2017 16:19:39 +0000 (16:19 +0000)]
arm64: Kconfig: Reword UNMAP_KERNEL_AT_EL0 kconfig entry

Although CONFIG_UNMAP_KERNEL_AT_EL0 does make KASLR more robust, it's
actually more useful as a mitigation against speculation attacks that
can leak arbitrary kernel data to userspace through speculation.

Reword the Kconfig help message to reflect this, and make the option
depend on EXPERT so that it is on by default for the majority of users.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
6 years agoarm64: use RET instruction for exiting the trampoline
Will Deacon [Tue, 14 Nov 2017 16:15:59 +0000 (16:15 +0000)]
arm64: use RET instruction for exiting the trampoline

Speculation attacks against the entry trampoline can potentially resteer
the speculative instruction stream through the indirect branch and into
arbitrary gadgets within the kernel.

This patch defends against these attacks by forcing a misprediction
through the return stack: a dummy BL instruction loads an entry into
the stack, so that the predicted program flow of the subsequent RET
instruction is to a branch-to-self instruction which is finally resolved
as a branch to the kernel vectors with speculation suppressed.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
6 years agoUPSTREAM: arm64: kaslr: Put kernel vectors address in separate data page
Will Deacon [Wed, 6 Dec 2017 11:24:02 +0000 (11:24 +0000)]
UPSTREAM: arm64: kaslr: Put kernel vectors address in separate data page

The literal pool entry for identifying the vectors base is the only piece
of information in the trampoline page that identifies the true location
of the kernel.

This patch moves it into a page-aligned region of the .rodata section
and maps this adjacent to the trampoline text via an additional fixmap
entry, which protects against any accidental leakage of the trampoline
contents.

Suggested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: Laura Abbott <labbott@redhat.com>
Tested-by: Shanker Donthineni <shankerd@codeaurora.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
(cherry picked from commit 6c27c4082f4f70b9f41df4d0adf51128b40351df)

Change-Id: Id125331e7fa5645c801a26843fecca53f8773705
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
6 years agoUPSTREAM: arm64: mm: Introduce TTBR_ASID_MASK for getting at the ASID in the TTBR
Will Deacon [Fri, 1 Dec 2017 17:33:48 +0000 (17:33 +0000)]
UPSTREAM: arm64: mm: Introduce TTBR_ASID_MASK for getting at the ASID in the TTBR

There are now a handful of open-coded masks to extract the ASID from a
TTBR value, so introduce a TTBR_ASID_MASK and use that instead.

Suggested-by: Mark Rutland <mark.rutland@arm.com>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Laura Abbott <labbott@redhat.com>
Tested-by: Shanker Donthineni <shankerd@codeaurora.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
(cherry picked from commit b519538dfefc2f8478a1bcb458459c861d431784)

[toddpoynor@google.com: fixup context, asm-uaccess.h changes to
uaccess.h]
Change-Id: Ia456c58c83f9bbd02177cefb8e3106dfffe357cc
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
6 years agoUPSTREAM: arm64: Kconfig: Add CONFIG_UNMAP_KERNEL_AT_EL0
Will Deacon [Tue, 14 Nov 2017 14:41:01 +0000 (14:41 +0000)]
UPSTREAM: arm64: Kconfig: Add CONFIG_UNMAP_KERNEL_AT_EL0

Add a Kconfig entry to control use of the entry trampoline, which allows
us to unmap the kernel whilst running in userspace and improve the
robustness of KASLR.

Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Laura Abbott <labbott@redhat.com>
Tested-by: Shanker Donthineni <shankerd@codeaurora.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
(cherry picked from commit 084eb77cd3a81134d02500977dc0ecc9277dc97d)

Change-Id: I70a996e448fa17007a3b8564c794e53e3992d7bf
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
6 years agoUPSTREAM: arm64: entry: Add fake CPU feature for unmapping the kernel at EL0
Will Deacon [Tue, 14 Nov 2017 14:38:19 +0000 (14:38 +0000)]
UPSTREAM: arm64: entry: Add fake CPU feature for unmapping the kernel at EL0

Allow explicit disabling of the entry trampoline on the kernel command
line (kpti=off) by adding a fake CPU feature (ARM64_UNMAP_KERNEL_AT_EL0)
that can be used to toggle the alternative sequences in our entry code and
avoid use of the trampoline altogether if desired. This also allows us to
make use of a static key in arm64_kernel_unmapped_at_el0().

Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Laura Abbott <labbott@redhat.com>
Tested-by: Shanker Donthineni <shankerd@codeaurora.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
(cherry picked from commit ea1e3de85e94d711f63437c04624aa0e8de5c8b3)

[toddpoynor@google.com: fixup context, cpus_have_const_cap ->
cpus_have_cap]
Change-Id: I72936d608b0d4c0dd9725eced7674b95e4abcf2d
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
6 years agoUPSTREAM: arm64: tls: Avoid unconditional zeroing of tpidrro_el0 for native tasks
Will Deacon [Tue, 14 Nov 2017 14:33:28 +0000 (14:33 +0000)]
UPSTREAM: arm64: tls: Avoid unconditional zeroing of tpidrro_el0 for native tasks

When unmapping the kernel at EL0, we use tpidrro_el0 as a scratch register
during exception entry from native tasks and subsequently zero it in
the kernel_ventry macro. We can therefore avoid zeroing tpidrro_el0
in the context-switch path for native tasks using the entry trampoline.

Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Laura Abbott <labbott@redhat.com>
Tested-by: Shanker Donthineni <shankerd@codeaurora.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
(cherry picked from commit 18011eac28c7cb31c87b86b7d0e5b01894405c7f)

[toddpoynor@google.com: fixup context]
Change-Id: I4a0ded2e339b0c75521bc3b5a7fbbb3e60aa8774
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
6 years agoUPSTREAM: arm64: erratum: Work around Falkor erratum #E1003 in trampoline code
Will Deacon [Tue, 14 Nov 2017 14:29:19 +0000 (14:29 +0000)]
UPSTREAM: arm64: erratum: Work around Falkor erratum #E1003 in trampoline code

We rely on an atomic swizzling of TTBR1 when transitioning from the entry
trampoline to the kernel proper on an exception. We can't rely on this
atomicity in the face of Falkor erratum #E1003, so on affected cores we
can issue a TLB invalidation to invalidate the walk cache prior to
jumping into the kernel. There is still the possibility of a TLB conflict
here due to conflicting walk cache entries prior to the invalidation, but
this doesn't appear to be the case on these CPUs in practice.

Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Laura Abbott <labbott@redhat.com>
Tested-by: Shanker Donthineni <shankerd@codeaurora.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
(cherry picked from git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git
 commit d1777e686ad10ba7c594304429c6045fb79255a1)

[ghackmann@google.com: replace runtime alternative_if with a
 compile-time check for Code Aurora's out-of-tree CONFIG_ARCH_MSM8996.
 Kryo needs this workaround too, and 4.4 doesn't have any of the
 upstream Falkor errata infrastructure needed to detect this at boot time.]
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Change-Id: Iaf244a364b22d386b54368f88b73e39d295de49f
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
6 years agoUPSTREAM: arm64: entry: Hook up entry trampoline to exception vectors
Will Deacon [Tue, 14 Nov 2017 14:24:29 +0000 (14:24 +0000)]
UPSTREAM: arm64: entry: Hook up entry trampoline to exception vectors

Hook up the entry trampoline to our exception vectors so that all
exceptions from and returns to EL0 go via the trampoline, which swizzles
the vector base register accordingly. Transitioning to and from the
kernel clobbers x30, so we use tpidrro_el0 and far_el1 as scratch
registers for native tasks.

Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Laura Abbott <labbott@redhat.com>
Tested-by: Shanker Donthineni <shankerd@codeaurora.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
(cherry picked from commit 4bf3286d29f3a88425d8d8cd53428cbb8f865f04)

Change-Id: I92fe4484fdfcf09e772f5d7ddfa29bfa4eb065f7
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
6 years agoUPSTREAM: arm64: entry: Explicitly pass exception level to kernel_ventry macro
Will Deacon [Tue, 14 Nov 2017 14:20:21 +0000 (14:20 +0000)]
UPSTREAM: arm64: entry: Explicitly pass exception level to kernel_ventry macro

We will need to treat exceptions from EL0 differently in kernel_ventry,
so rework the macro to take the exception level as an argument and
construct the branch target using that.

Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Laura Abbott <labbott@redhat.com>
Tested-by: Shanker Donthineni <shankerd@codeaurora.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
(cherry picked from commit 5b1f7fe41909cde40decad9f0e8ee585777a0538)

[toddpoynor@google.com: fixup context, error -> error_invalid]
Change-Id: I5dfbce460f7617e33298a1ece09159572d55fb3a
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
6 years agoUPSTREAM: arm64: mm: Map entry trampoline into trampoline and kernel page tables
Will Deacon [Tue, 14 Nov 2017 14:14:17 +0000 (14:14 +0000)]
UPSTREAM: arm64: mm: Map entry trampoline into trampoline and kernel page tables

The exception entry trampoline needs to be mapped at the same virtual
address in both the trampoline page table (which maps nothing else)
and also the kernel page table, so that we can swizzle TTBR1_EL1 on
exceptions from and return to EL0.

This patch maps the trampoline at a fixed virtual address in the fixmap
area of the kernel virtual address space, which allows the kernel proper
to be randomized with respect to the trampoline when KASLR is enabled.

Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Laura Abbott <labbott@redhat.com>
Tested-by: Shanker Donthineni <shankerd@codeaurora.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
(cherry picked from commit 51a0048beb449682d632d0af52a515adb9f9882e)

[toddpoynor@google.com: fixup context, remove rodata_enabled check]
Change-Id: I920ad6850e4e9b03edea4a84d8603302c28eef37
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
6 years agoUPSTREAM: arm64: entry: Add exception trampoline page for exceptions from EL0
Will Deacon [Tue, 14 Nov 2017 14:07:40 +0000 (14:07 +0000)]
UPSTREAM: arm64: entry: Add exception trampoline page for exceptions from EL0

To allow unmapping of the kernel whilst running at EL0, we need to
point the exception vectors at an entry trampoline that can map/unmap
the kernel on entry/exit respectively.

This patch adds the trampoline page, although it is not yet plugged
into the vector table and is therefore unused.

Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Laura Abbott <labbott@redhat.com>
Tested-by: Shanker Donthineni <shankerd@codeaurora.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
(cherry picked from commit c7b9adaf85f818d747eeff5145eb4095ccd587fb)

[toddpoynor@google.com: fixup context]
Change-Id: I6c6b5eb93a69f26b97628726eccf91df739d03af
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
6 years agoUPSTREAM: arm64: mm: Invalidate both kernel and user ASIDs when performing TLBI
Will Deacon [Thu, 10 Aug 2017 13:13:33 +0000 (14:13 +0100)]
UPSTREAM: arm64: mm: Invalidate both kernel and user ASIDs when performing TLBI

Since an mm has both a kernel and a user ASID, we need to ensure that
broadcast TLB maintenance targets both address spaces so that things
like CoW continue to work with the uaccess primitives in the kernel.

Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Laura Abbott <labbott@redhat.com>
Tested-by: Shanker Donthineni <shankerd@codeaurora.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
(cherry picked from commit 9b0de864b5bc298ea53005ad812f3386f81aee9c)

Change-Id: I8b50e223fc7de6f11388b8dfac705fa618b7335a
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
6 years agoUPSTREAM: arm64: mm: Add arm64_kernel_unmapped_at_el0 helper
Will Deacon [Tue, 14 Nov 2017 13:58:08 +0000 (13:58 +0000)]
UPSTREAM: arm64: mm: Add arm64_kernel_unmapped_at_el0 helper

In order for code such as TLB invalidation to operate efficiently when
the decision to map the kernel at EL0 is determined at runtime, this
patch introduces a helper function, arm64_kernel_unmapped_at_el0, to
determine whether or not the kernel is mapped whilst running in userspace.

Currently, this just reports the value of CONFIG_UNMAP_KERNEL_AT_EL0,
but will later be hooked up to a fake CPU capability using a static key.

Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Laura Abbott <labbott@redhat.com>
Tested-by: Shanker Donthineni <shankerd@codeaurora.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
(cherry picked from commit fc0e1299da548b32440051f58f08e0c1eb7edd0b)

Change-Id: I2d34c2d7b88f82d848d7063efdae7c3cc4fe8fd6
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
6 years agoUPSTREAM: arm64: mm: Allocate ASIDs in pairs
Will Deacon [Thu, 10 Aug 2017 13:10:28 +0000 (14:10 +0100)]
UPSTREAM: arm64: mm: Allocate ASIDs in pairs

In preparation for separate kernel/user ASIDs, allocate them in pairs
for each mm_struct. The bottom bit distinguishes the two: if it is set,
then the ASID will map only userspace.

Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Laura Abbott <labbott@redhat.com>
Tested-by: Shanker Donthineni <shankerd@codeaurora.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
(cherry picked from commit 0c8ea531b7740754cf374ca8b7510655f569c5e3)

[toddpoynor@google.com: fixup context]
Change-Id: I9879f45cd51cdf13814e3cff18653a76c893f386
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
6 years agoUPSTREAM: arm64: mm: Fix and re-enable ARM64_SW_TTBR0_PAN
Will Deacon [Thu, 10 Aug 2017 12:58:16 +0000 (13:58 +0100)]
UPSTREAM: arm64: mm: Fix and re-enable ARM64_SW_TTBR0_PAN

With the ASID now installed in TTBR1, we can re-enable ARM64_SW_TTBR0_PAN
by ensuring that we switch to a reserved ASID of zero when disabling
user access and restore the active user ASID on the uaccess enable path.

Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Laura Abbott <labbott@redhat.com>
Tested-by: Shanker Donthineni <shankerd@codeaurora.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
(cherry picked from commit 27a921e75711d924617269e0ba4adb8bae9fd0d1)

[toddpoynor@google.com: fixup context, move asm-uaccess.h changes to
uaccess.h]
Change-Id: Ie8e1706152b8d7c068c6b1f20241a10669a69ca1
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
6 years agoUPSTREAM: arm64: mm: Rename post_ttbr0_update_workaround
Will Deacon [Thu, 10 Aug 2017 12:34:30 +0000 (13:34 +0100)]
UPSTREAM: arm64: mm: Rename post_ttbr0_update_workaround

The post_ttbr0_update_workaround hook applies to any change to TTBRx_EL1.
Since we're using TTBR1 for the ASID, rename the hook to make it clearer
as to what it's doing.

Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Laura Abbott <labbott@redhat.com>
Tested-by: Shanker Donthineni <shankerd@codeaurora.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
(cherry picked from commit 158d495899ce55db453f682a8ac8390d5a426578)

[toddpoynor@google.com: fixup context conflict in comments]
Change-Id: Ia0f82eee78ad442d1773245b99c7534f0ea066e4
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
6 years agoUPSTREAM: arm64: mm: Move ASID from TTBR0 to TTBR1
Will Deacon [Thu, 10 Aug 2017 12:19:09 +0000 (13:19 +0100)]
UPSTREAM: arm64: mm: Move ASID from TTBR0 to TTBR1

In preparation for mapping kernelspace and userspace with different
ASIDs, move the ASID to TTBR1 and update switch_mm to context-switch
TTBR0 via an invalid mapping (the zero page).

Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Laura Abbott <labbott@redhat.com>
Tested-by: Shanker Donthineni <shankerd@codeaurora.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
(cherry picked from commit 7655abb953860485940d4de74fb45a8192149bb6)

[toddpoynor@google.com: add missing mrs inst from context]
Change-Id: I9575ae2f0b3b5383c44f7ace0ac50588be739e45
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
6 years agoUPSTREAM: arm64: mm: Temporarily disable ARM64_SW_TTBR0_PAN
Will Deacon [Thu, 10 Aug 2017 12:04:48 +0000 (13:04 +0100)]
UPSTREAM: arm64: mm: Temporarily disable ARM64_SW_TTBR0_PAN

We're about to rework the way ASIDs are allocated, switch_mm is
implemented and low-level kernel entry/exit is handled, so keep the
ARM64_SW_TTBR0_PAN code out of the way whilst we do the heavy lifting.

It will be re-enabled in a subsequent patch.

Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Laura Abbott <labbott@redhat.com>
Tested-by: Shanker Donthineni <shankerd@codeaurora.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
(cherry picked from commit 376133b7edc20f237a42e4c72415cc9e8c0a9704)
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Change-Id: Iac0d096cd8eda5bc2d3cd17d7d2492d1838ad8ed
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>