1
0
Fork 0
Commit Graph

644094 Commits (eirik/updates-from-linux-fsl)

Author SHA1 Message Date
Eirik Schultz 6651000c1e
scripts/dtc: Remove redundant YYLOC global declaration
gcc 10 will default to -fno-common, which causes this error at link
time:

  (.text+0x0): multiple definition of `yylloc'; dtc-lexer.lex.o (symbol from plugin):(.text+0x0): first defined here

This is because both dtc-lexer as well as dtc-parser define the same
global symbol yyloc. Before with -fcommon those were merged into one
defintion. The proper solution would be to to mark this as "extern",
however that leads to:

  dtc-lexer.l:26:16: error: redundant redeclaration of 'yylloc' [-Werror=redundant-decls]
   26 | extern YYLTYPE yylloc;
      |                ^~~~~~
In file included from dtc-lexer.l:24:
dtc-parser.tab.h:127:16: note: previous declaration of 'yylloc' was here
  127 | extern YYLTYPE yylloc;
      |                ^~~~~~
cc1: all warnings being treated as errors

which means the declaration is completely redundant and can just be
dropped.
2020-11-18 17:05:42 +01:00
Lars Ivar Miljeteig 04581f986c
video: mxc epdc: Add QOS handling in driver
Enables QOS support in EPDC hardware
2020-11-18 16:50:35 +01:00
Eirik Schultz 077ab708cb
devicetree: remove prototype from model -> reMarkable 1.0 2020-11-18 16:50:34 +01:00
Eirik Schultz b5d1878d51
Revert "devicetree: Don't specify vbus gpio in factory dts"
This reverts commit 5c76066147.
2020-11-18 16:50:33 +01:00
Steinar Bakkemo a3e7695450
Update defconfig in order to build brcmfmac/cfg80211 as modules using backported driver in Yocto 2020-11-18 16:50:32 +01:00
Lars Ivar Miljeteig 3e2d77d6da
devicetree: Don't specify vbus gpio in factory dts
The test application controls the OTG pin itself,
not via the usb OTG driver. A change between kern
4.1 and 4.9 causes the regulator to take the
gpio pin even if there are no references to it.

This commit removes the vbus gpio from the
driver, so that the test application works again.
2020-11-18 16:50:31 +01:00
Lars Ivar Miljeteig 4e1bc6a9d6
config: Enable CPU FREQ Governor
Set ondemand as default
2020-11-18 16:50:30 +01:00
Lars Ivar Miljeteig 4cd9226616
devicetree: Make cpufreq great again
CPUFreq failed due to misconfigured soc, arm and pu
regulators. The way to set this up changed from kernel
4.1 to 4.9. It works now.
2020-11-18 16:50:29 +01:00
Lars Ivar Miljeteig b399fe15ad
Device tree: Add factory device tree
There are two flavours of the device tree today, one
for the main application and one for the testing
application used in the factory. This patch gathers
them both in the same branch, to be able to use the
same kernel for both factory and end user.
2020-11-18 16:50:28 +01:00
Steinar Bakkemo 9226ba9f01
Add zero-gravitas-dev_defconfig containing memtest and other test configuration settings as required
The linux-rmxxx recipes in yocto contains machine_feature selecting the appropriate kernel config to build with
2020-11-18 16:50:27 +01:00
Steinar Bakkemo 35c0409ee8
Turn off memory tests 2020-11-18 16:50:26 +01:00
Lars Ivar Miljeteig 63fcaca9ec
brcmfmac: Add support for 43455 2020-11-18 16:50:25 +01:00
Lars Ivar Miljeteig a163195378
config: Add memtest and imx6sll 2020-11-18 16:50:24 +01:00
Lars Ivar Miljeteig ea9a8a19b5
bq27441: New kernel, stricter rules for memory 2020-11-18 16:50:23 +01:00
Lars Ivar Miljeteig c540d1d16a
bq27441: Driver in kernel
Used to be an out-of-tree module
2020-11-18 16:50:22 +01:00
Lars Ivar Miljeteig 71016330f2
brcmfmac: Update firmware 2020-11-18 16:50:21 +01:00
Lars Ivar Miljeteig a9564a6874
brcmfmac: nvram config 2020-11-18 16:50:20 +01:00
Lars Ivar Miljeteig 570320758b
brcmfmac: Device tree entry support 2020-11-18 16:50:20 +01:00
Lars Ivar Miljeteig 8999f669d5
dts: VCOM values 2020-11-18 16:50:19 +01:00
Martin T. H. Sandsmark d20e514f80
caamrng: bump up quality so it is used by default 2020-11-18 16:50:18 +01:00
Martin T. H. Sandsmark 887170c499
pfuze100: sysfs file to disable SWBST regulator
add ugly hack because the factory needs to be able to disable the SWBST regulator to reset the charging circuit during tests
2020-11-18 16:50:17 +01:00
Martin T. H. Sandsmark 9754594671
borrow the IBM rndis vid and pid until we get the code signing certificate and our own driver 2020-11-18 16:50:16 +01:00
Martin T. H. Sandsmark d7b1759475
fsl_otp: read CPU serial from OTP during init 2020-11-18 16:50:15 +01:00
Martin T. H. Sandsmark 47165eee1f
pm-imx6: fix suspend of imx6sl with ddr3 2020-11-18 16:50:14 +01:00
Martin T. H. Sandsmark 0bbf7cc7cd
Touch firmware
touch: add updated firmware for touch controller
touch firmware: update firmware for touch controller to latest calibrated version
touch firmware: upgrade to vendor version 4
2020-11-18 16:50:13 +01:00
Martin T. H. Sandsmark d184045866
touch: Fix getting of GPIO in cyttsp5 from device tree 2020-11-18 16:50:12 +01:00
Martin T. H. Sandsmark d7e06391be
touch: Import cyttsp5 driver from Parade 2020-11-18 16:50:11 +01:00
Martin T. H. Sandsmark 62a0191745
epdc: epdc configuration for zero-gravitas
epdc: Turn on regulators unconditionally
  Add hack to EPDC driver to unconditionally turn on the regulators
  during initialization for Kaifa testing

epdc: Set pir display configuration
  First attempt at setting our display configuration, based on info sheet from E-Ink

epdc: Add waveform for our display
epdc: Move waveform to correct folder
epdc: Update EPDC driver to use correct pixels per SDCLK and data bus width
epdc: Update panel timing information based on NXP EPD calculator values
epdc: Update waveform after attempting to fix NXP's waveform converter
epdc: Bring up our panel by default
epdc: Update panel timing values based on independent calculations
epdc: Add 4bit waveform for ES103CS1
epdc: Add support for ES103CS1 display with 4bit waveforms
epdc: Add patch from NXP to use the correct mutex when panning display
epdc: Remove all traces of the 5bit waveforms
epdc: Remove EPDC powerup hack
epdc: update parameters for 85hz
epdc: undo some custom unnecessary changes
epdc: don't do a normal grayscale update just for init
epdc: fix some printing of errors
epdc: use synchronous firmware loading so users know that the EPDC is inited and can do stuff
mxc_epdc_fb: restore powerdown delay after suspend
mxc_epdc_fb: fix inverted conditional leading to endless collisions
mxc_epdc_fb: epdc driver wants pixclock in hz, not ps
mxc_epdc_fb: add support for automatically getting updated temperature from pmic
2020-11-18 16:50:10 +01:00
Lars Ivar Miljeteig f4c23584d3
Busfreq: Disable busfreq 2020-11-18 16:50:09 +01:00
Martin T. H. Sandsmark 8bc3b46c3f
max17135: Tweaks
max17135: Add some extra output for Kaifa
max17135: Make the MAX17135 driver check the PWRGOOD pin
max17135: Set the default pass number for MAX17135 to 2
max17135: specify chip version in devicetree
max17135: print ret when failing to write to device
max17135: use sysfs for programming vcom
max17135: add thermistor regulator to read temperature
max17135: get_voltage parameter
2020-11-18 16:50:08 +01:00
Martin T. H. Sandsmark 261c6aaa87
max17135: Ensure that the MAX17135 MFD selects MFD_CORE 2020-11-18 16:50:07 +01:00
Lars Ivar Miljeteig a2f2eea6b4
Devicetree: Quick fixes 2020-11-18 16:50:06 +01:00
Lars Ivar Miljeteig 3b6bf66d98
mmc: Try to bring up SD card
mmc

ENGR00285671 mmc: setup emmc boot partition configure methods

- Configure boot partition
Expose the interfaces that used to enable the configurations
of the boot mode of the eMMC cards.
usage how-to and examples:
Enable the boot partition 1 boot enabled.
"echo 8 > /sys/devices/soc0/soc.1/2100000.aips-bus/
219c000.usdhc/mmc_host/mmc2/mmc2\:0001/boot_config"

In order to make sure that the re-read the ext-csd of card
can be completed successfully, add the method to wait for
the finish of the busy state.

- setup boot_info message output
Output bit means of important esd_csd register

Read esd_csd info each time when cat boot_info
becasue user may change config affect esd_csd
value.

- Boot partition access howto:
About the details, please refer to the guidance of
Documentation/mmc/mmc-dev-parts.txt

To enable write access to /dev/mmcblkXbootY, disable the forced
read-only access with:
echo 0 > /sys/block/mmcblkXbootY/force_ro

To re-enable read-only access:
echo 1 > /sys/block/mmcblkXbootY/force_ro

NOTE:
- The definitions of the EXT_CSD_PART_CONFIG and EXT_CSD_BOOT_BUS_WIDTH
+------------------------------------------------------------+
| Bit7 | Bit6     | Bit5 Bit4 Bit3        | Bit2 Bit1 Bit0   |
|------|----------|-----------------------|------------------|
| X    | BOOT_ACK | BOOT_PARTITION_ENABLE | PARTITION_ACCESS |
+------------------------------------------------------------+
Bit7: Reserved
Bit6: always set to vaule '1' when boot_part is enabled
Bit[5:3]:
0x0 : Device not boot enabled (default)
0x1 : Boot partition 1 enabled for boot
0x2 : Boot partition 2 enabled for boot
0x7 : User area enabled for boot
Bit[2:0]:
0x0 : No access to boot partition (default)
0x1 : R/W boot partition 1
0x2 : R/W boot partition 2

+--------------------------------------------------------------------+
| Bit7 Bit6 Bit5 | Bit4 Bit3 | Bit2                 | Bit1 Bit0      |
|----------------|----------------------------------|----------------|
| X              | BOOT_MODE | RESET_BOOT_BUS_WIDTH | BOOT_BUS_WIDTH |
+--------------------------------------------------------------------+
Bit [4:3] : BOOT_MODE (non-volatile)
0x0 : Use single data rate + backward compatible timings in boot
operation (default)
0x1 : Use single data rate + high speed timings in boot operation mode
0x2 : Use dual data rate in boot operation
0x3 : Reserved
Bit [2]: RESET_BOOT_BUS_WIDTH (non-volatile)
0x0 : Reset bus width to x1, single data rate and backward compatible
timings after boot operation (default)
0x1 : Retain boot bus width and boot mode after boot operation
Bit[1:0] : BOOT_BUS_WIDTH (non-volatile)
0x0 : x1 (sdr) or x4 (ddr) bus width in boot operation mode (default)
0x1 : x4 (sdr/ddr) bus width in boot operation mode
0x2 : x8 (sdr/ddr) bus width in boot operation mode
0x3 : Reserved

- example of the boot_info:
boot_info:0x07;
  ALT_BOOT_MODE:1 - Supports alternate boot method
  DDR_BOOT_MODE:1 - Supports alternate dual data rate during boot
  HS_BOOTMODE:1 - Supports high speed timing during boot
boot_size:2048KB
  boot_partition:0x48;
  BOOT_ACK:1 - Boot acknowledge sent during boot operation
  BOOT_PARTITION-ENABLE: 1 - Boot partition 1 enabled
  PARTITION_ACCESS:0 - No access to boot partition
boot_bus:0x00
  BOOT_MODE:0 - Use single data rate + backward compatible timings
  in boot operation
  RESET_BOOT_BUS_WIDTH:0 - Reset bus width to x1, single data rate
  and backwardcompatible timings after boot operation
  BOOT_BUS_WIDTH:0 - x1 (sdr) or x4 (ddr) bus width in boot
  operation mode

Signed-off-by: Richard Zhu <r65037@freescale.com>

ENGR00323682 MMC: Fixed boot_config overwritten by switch partition

In MMC driver, two variables: boot_config and part_config  are used to
keep eCSD(179) PARTITION_CONFIG. The part_config is not updated when
set new boot_config, which causes the eCSD(179) is overwritten by
any following partition switching, so the new boot_config is lost.

Signed-off-by: Ye.Li <B37916@freescale.com>
(cherry picked from commit e66d21ade29855299ce048c97830a4bb79373761)

Port NXP boot_options patch to new mmc API

Set stricter permissions for boot_config
2020-11-18 16:50:05 +01:00
Martin T. H. Sandsmark e9474770a8
wacom_i2c: the new wacom firmware reports tilt with 2 bytes 2020-11-18 16:50:04 +01:00
Martin T. H. Sandsmark 656e4970a6
wacom_i2c: Remove some useless debug output from wacom_i2c driver 2020-11-18 16:50:03 +01:00
Martin T. H. Sandsmark cd216acf48
wacom_i2c: Add tilt and distance reporting to Wacom I2C 2020-11-18 16:50:02 +01:00
Martin T. H. Sandsmark d898c85bcb
wacom_12c: Port wacom_i2c to device tree 2020-11-18 16:50:01 +01:00
Martin T. H. Sandsmark 8c0154cbcf
defconfig
Add a default config based on imx6 default config
Update our default config
Update defconfig
Clean out unused stuff from defconfig
Re-add IMX serial to defconfig
Re-enable large files support
Enable PXPv2 in defconfig
Disable auto update mode in EPDC driver
Use correct poweroff driver
defconfig: switch to interactive cpu scheduler, enable cpu idle
defconfig: disable cyttsp debug output
defconfig: enable usb gadget support
defconfig: enable fsl_otp, remove some debug output
defconfig: Enable brcmfmac
defconfig: add reset controller for wifi for powering it up
defconfig: power management, support more USB devices, gpio charger support, CAAM support for RNG
defconfig: enable nbd for vfatbuse, enable reset by syscon, fuck around with spi
defconfig enable f2fs support
defconfig: Disable busfreq
defconfig: re-enable cpu frequency scaling
defconfig: use ethernet gadget by default
2020-11-18 16:50:00 +01:00
Martin T. H. Sandsmark 96eff6b564
Add our DTS to the Makefile 2020-11-18 16:49:59 +01:00
Martin T. H. Sandsmark 468fa84160
Initial device tree 2020-11-18 16:49:58 +01:00
Otavio Salvador 5b5a04065f
Merge pull request #25 from MaxKrummenacher/4.9-1.0.x-imx-stable-merge
4.9 1.0.x imx stable merge
2018-06-08 10:09:28 -03:00
Max Krummenacher 8d99753ad9 This is the 4.9.87 stable release
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAlqlSYcACgkQONu9yGCS
 aT4QOBAAlV3X1U64uPZAafv52q/4GVvjh3fymj2aThOImY6cCG2wuQfEHq4lqRKJ
 ua+AY1etuGqJbQlroy8j85bIRtE1pmtW+hAA+vaITcrPJhWzhHmssMCK2aM1Jtim
 +zDXuh4GjXZ+5Gv3p4bbf3otFOgegr2Ftn4dVEmDClkSqRmNEpAtPzSo5TZQCopN
 +QksrFTXMs9QEBxCnfXWHxz0c1EIpaJVtyteX6wVZKC2hjOoF5RBBvErUABW9Po0
 db9+6v488AVouaEqxoLmtcwwUFhetMh/5M4oapD8NeRuwkG+4jFNDZcXIRaCzzyu
 /8DzeyaP1luA/6q0dSI9JD5Whg7FnuZ4A888D+pLHjEQgSgnxhIX38lpsRcrEbl9
 8myFYPoxj6eryM31Z3jW566TI7vT0uqxrc5RzKaFW1xwxLU1Dur5N09VROYIsLvm
 YXUjELN+RwrQa5OkenKbTFy0OPjDHzuo1V/b98T6LujozkyboKAsCUyqE+HukUSe
 Vicg8h5APSPnMSbPLVW5xDDzShBaKhFps92ELsUEZzr5GGS5SX7TBHlbX0bRKs59
 1+hsVts6Twi30/PUJBGkYCAfJ/Jqe0L9l/kj4wnBKWyBLFP5YRerkww2pZ1b/diY
 kwmxH26tSI9g3Nh4oeUB3j5MKu23XhDucB0r2H3pLqfTqFcoT3M=
 =Y/Vz
 -----END PGP SIGNATURE-----

Merge tag 'v4.9.87' into fslc_4.9-1.0.x-imx

This is the 4.9.87 stable release

 Conflicts:
	drivers/dma/fsl-edma.c
2018-03-12 16:59:40 +01:00
Greg Kroah-Hartman b67416226a Linux 4.9.87 2018-03-11 16:21:35 +01:00
Ernesto A. Fernández 931dde83a2 btrfs: preserve i_mode if __btrfs_set_acl() fails
commit d7d8249665 upstream.

When changing a file's acl mask, btrfs_set_acl() will first set the
group bits of i_mode to the value of the mask, and only then set the
actual extended attribute representing the new acl.

If the second part fails (due to lack of space, for example) and the
file had no acl attribute to begin with, the system will from now on
assume that the mask permission bits are actual group permission bits,
potentially granting access to the wrong users.

Prevent this by restoring the original mode bits if __btrfs_set_acl
fails.

Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-11 16:21:35 +01:00
Daniel Borkmann 2b70de4ea9 bpf, ppc64: fix out of bounds access in tail call
[ upstream commit d269176e76 ]

While working on 16338a9b3a ("bpf, arm64: fix out of bounds access in
tail call") I noticed that ppc64 JIT is partially affected as well. While
the bound checking is correctly performed as unsigned comparison, the
register with the index value however, is never truncated into 32 bit
space, so e.g. a index value of 0x100000000ULL with a map of 1 element
would pass with PPC_CMPLW() whereas we later on continue with the full
64 bit register value. Therefore, as we do in interpreter and other JITs
truncate the value to 32 bit initially in order to fix access.

Fixes: ce0761419f ("powerpc/bpf: Implement support for tail calls")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Tested-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-11 16:21:35 +01:00
Eric Dumazet 2a8bc5316a bpf: add schedule points in percpu arrays management
[ upstream commit 32fff239de ]

syszbot managed to trigger RCU detected stalls in
bpf_array_free_percpu()

It takes time to allocate a huge percpu map, but even more time to free
it.

Since we run in process context, use cond_resched() to yield cpu if
needed.

Fixes: a10423b87a ("bpf: introduce BPF_MAP_TYPE_PERCPU_ARRAY map")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-11 16:21:35 +01:00
Daniel Borkmann 54c6d01b1a bpf, arm64: fix out of bounds access in tail call
[ upstream commit 16338a9b3a ]

I recently noticed a crash on arm64 when feeding a bogus index
into BPF tail call helper. The crash would not occur when the
interpreter is used, but only in case of JIT. Output looks as
follows:

  [  347.007486] Unable to handle kernel paging request at virtual address fffb850e96492510
  [...]
  [  347.043065] [fffb850e96492510] address between user and kernel address ranges
  [  347.050205] Internal error: Oops: 96000004 [#1] SMP
  [...]
  [  347.190829] x13: 0000000000000000 x12: 0000000000000000
  [  347.196128] x11: fffc047ebe782800 x10: ffff808fd7d0fd10
  [  347.201427] x9 : 0000000000000000 x8 : 0000000000000000
  [  347.206726] x7 : 0000000000000000 x6 : 001c991738000000
  [  347.212025] x5 : 0000000000000018 x4 : 000000000000ba5a
  [  347.217325] x3 : 00000000000329c4 x2 : ffff808fd7cf0500
  [  347.222625] x1 : ffff808fd7d0fc00 x0 : ffff808fd7cf0500
  [  347.227926] Process test_verifier (pid: 4548, stack limit = 0x000000007467fa61)
  [  347.235221] Call trace:
  [  347.237656]  0xffff000002f3a4fc
  [  347.240784]  bpf_test_run+0x78/0xf8
  [  347.244260]  bpf_prog_test_run_skb+0x148/0x230
  [  347.248694]  SyS_bpf+0x77c/0x1110
  [  347.251999]  el0_svc_naked+0x30/0x34
  [  347.255564] Code: 9100075a d280220a 8b0a002a d37df04b (f86b694b)
  [...]

In this case the index used in BPF r3 is the same as in r1
at the time of the call, meaning we fed a pointer as index;
here, it had the value 0xffff808fd7cf0500 which sits in x2.

While I found tail calls to be working in general (also for
hitting the error cases), I noticed the following in the code
emission:

  # bpftool p d j i 988
  [...]
  38:   ldr     w10, [x1,x10]
  3c:   cmp     w2, w10
  40:   b.ge    0x000000000000007c              <-- signed cmp
  44:   mov     x10, #0x20                      // #32
  48:   cmp     x26, x10
  4c:   b.gt    0x000000000000007c
  50:   add     x26, x26, #0x1
  54:   mov     x10, #0x110                     // #272
  58:   add     x10, x1, x10
  5c:   lsl     x11, x2, #3
  60:   ldr     x11, [x10,x11]                  <-- faulting insn (f86b694b)
  64:   cbz     x11, 0x000000000000007c
  [...]

Meaning, the tests passed because commit ddb55992b0 ("arm64:
bpf: implement bpf_tail_call() helper") was using signed compares
instead of unsigned which as a result had the test wrongly passing.

Change this but also the tail call count test both into unsigned
and cap the index as u32. Latter we did as well in 90caccdd8c
("bpf: fix bpf_tail_call() x64 JIT") and is needed in addition here,
too. Tested on HiSilicon Hi1616.

Result after patch:

  # bpftool p d j i 268
  [...]
  38:	ldr	w10, [x1,x10]
  3c:	add	w2, w2, #0x0
  40:	cmp	w2, w10
  44:	b.cs	0x0000000000000080
  48:	mov	x10, #0x20                  	// #32
  4c:	cmp	x26, x10
  50:	b.hi	0x0000000000000080
  54:	add	x26, x26, #0x1
  58:	mov	x10, #0x110                 	// #272
  5c:	add	x10, x1, x10
  60:	lsl	x11, x2, #3
  64:	ldr	x11, [x10,x11]
  68:	cbz	x11, 0x0000000000000080
  [...]

Fixes: ddb55992b0 ("arm64: bpf: implement bpf_tail_call() helper")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-11 16:21:34 +01:00
Daniel Borkmann 017219b598 bpf, x64: implement retpoline for tail call
[ upstream commit a493a87f38 ]

Implement a retpoline [0] for the BPF tail call JIT'ing that converts
the indirect jump via jmp %rax that is used to make the long jump into
another JITed BPF image. Since this is subject to speculative execution,
we need to control the transient instruction sequence here as well
when CONFIG_RETPOLINE is set, and direct it into a pause + lfence loop.
The latter aligns also with what gcc / clang emits (e.g. [1]).

JIT dump after patch:

  # bpftool p d x i 1
   0: (18) r2 = map[id:1]
   2: (b7) r3 = 0
   3: (85) call bpf_tail_call#12
   4: (b7) r0 = 2
   5: (95) exit

With CONFIG_RETPOLINE:

  # bpftool p d j i 1
  [...]
  33:	cmp    %edx,0x24(%rsi)
  36:	jbe    0x0000000000000072  |*
  38:	mov    0x24(%rbp),%eax
  3e:	cmp    $0x20,%eax
  41:	ja     0x0000000000000072  |
  43:	add    $0x1,%eax
  46:	mov    %eax,0x24(%rbp)
  4c:	mov    0x90(%rsi,%rdx,8),%rax
  54:	test   %rax,%rax
  57:	je     0x0000000000000072  |
  59:	mov    0x28(%rax),%rax
  5d:	add    $0x25,%rax
  61:	callq  0x000000000000006d  |+
  66:	pause                      |
  68:	lfence                     |
  6b:	jmp    0x0000000000000066  |
  6d:	mov    %rax,(%rsp)         |
  71:	retq                       |
  72:	mov    $0x2,%eax
  [...]

  * relative fall-through jumps in error case
  + retpoline for indirect jump

Without CONFIG_RETPOLINE:

  # bpftool p d j i 1
  [...]
  33:	cmp    %edx,0x24(%rsi)
  36:	jbe    0x0000000000000063  |*
  38:	mov    0x24(%rbp),%eax
  3e:	cmp    $0x20,%eax
  41:	ja     0x0000000000000063  |
  43:	add    $0x1,%eax
  46:	mov    %eax,0x24(%rbp)
  4c:	mov    0x90(%rsi,%rdx,8),%rax
  54:	test   %rax,%rax
  57:	je     0x0000000000000063  |
  59:	mov    0x28(%rax),%rax
  5d:	add    $0x25,%rax
  61:	jmpq   *%rax               |-
  63:	mov    $0x2,%eax
  [...]

  * relative fall-through jumps in error case
  - plain indirect jump as before

  [0] https://support.google.com/faqs/answer/7625886
  [1] a31e654fa1

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-11 16:21:34 +01:00
Daniel Borkmann 422baf61d4 bpf: fix mlock precharge on arraymaps
[ upstream commit 9c2d63b843 ]

syzkaller recently triggered OOM during percpu map allocation;
while there is work in progress by Dennis Zhou to add __GFP_NORETRY
semantics for percpu allocator under pressure, there seems also a
missing bpf_map_precharge_memlock() check in array map allocation.

Given today the actual bpf_map_charge_memlock() happens after the
find_and_alloc_map() in syscall path, the bpf_map_precharge_memlock()
is there to bail out early before we go and do the map setup work
when we find that we hit the limits anyway. Therefore add this for
array map as well.

Fixes: 6c90598174 ("bpf: pre-allocate hash map elements")
Fixes: a10423b87a ("bpf: introduce BPF_MAP_TYPE_PERCPU_ARRAY map")
Reported-by: syzbot+adb03f3f0bb57ce3acda@syzkaller.appspotmail.com
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Dennis Zhou <dennisszhou@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-11 16:21:34 +01:00
Daniel Borkmann 816cfeb77c bpf: fix wrong exposure of map_flags into fdinfo for lpm
[ upstream commit a316338cb7 ]

trie_alloc() always needs to have BPF_F_NO_PREALLOC passed in via
attr->map_flags, since it does not support preallocation yet. We
check the flag, but we never copy the flag into trie->map.map_flags,
which is later on exposed into fdinfo and used by loaders such as
iproute2. Latter uses this in bpf_map_selfcheck_pinned() to test
whether a pinned map has the same spec as the one from the BPF obj
file and if not, bails out, which is currently the case for lpm
since it exposes always 0 as flags.

Also copy over flags in array_map_alloc() and stack_map_alloc().
They always have to be 0 right now, but we should make sure to not
miss to copy them over at a later point in time when we add actual
flags for them to use.

Fixes: b95a5c4db0 ("bpf: add a longest prefix match trie map implementation")
Reported-by: Jarno Rajahalme <jarno@covalent.io>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-11 16:21:34 +01:00