Commit graph

19400 commits

Author SHA1 Message Date
Wayne Ren 5a0ba2faa5 cmake: disable privilege stack generation for arc
Currently, ARC will not use privilege stack generation.

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-02-16 12:20:16 +01:00
Wayne Ren a970b5fd32 arch: arc: scrub regs of kernel context before returning to userspace
scrub all the regs of kernel context before returnning to userspace.
For sys call, ro is not cleared as it's a return value of sys call.

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-02-16 12:20:16 +01:00
Wayne Ren 7ef2506611 arch: arc: enable US bit to check user mode
Enable us bit to check user mode more efficienly.

US is read as zero in user mode. This will allow use mode sleep
instructions, and it enables a form of denial-of-service attack
by putting the processor in sleep mode, but since interrupt
level/mask can't be set from user space that's not worse than
executing a loop without yielding.

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-02-16 12:20:16 +01:00
Wayne Ren 0c3aebef49 tests: add the test case for user space support of arc
add arc specific codes in tests/kernel/mem_protect/userspace

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-02-16 12:20:16 +01:00
Wayne Ren 8feca6c2ef arch: arc: modify the kconfig for mpu case
* user space support requires THREAD_INFO
* for MPU version 2, the stack align is at least 2048 bytes
  * the smallest mpu region is 2048 bytes
  * the region size must bt power of 2
  * the start address of region must be aligned to the region size

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-02-16 12:20:16 +01:00
Wayne Ren e91733c78b arch: arc: bug fixes and add user space support in secure mode
* bug fixes
* add user space support in secure mode

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-02-16 12:20:16 +01:00
Wayne Ren f81dee0b2b arch: arc: add user space support for arc
* add the implementation of syscall
  * based on 'trap_s' intruction, id = 3
* add the privilege stack
  * the privilege stack is allocted with thread stack
  * for the kernel thread, the privilege stack is also a
    part of thread stack, the start of stack can be configured
    as stack guard
  * for the user thread, no stack guard, when the user stack is
    overflow, it will fall into kernel memory area which requires
    kernel privilege, privilege violation will be raised
* modify the linker template and add MPU_ADDR_ALIGN
* add user space corresponding codes in mpu
* the user sp aux reg will be part of thread context
* When user thread is interruptted for the 1st time, the context is
  saved in user stack (U bit of IRQ_CTLR is set to 1). When nest
  interrupt comes, the context is saved in thread's privilege stack
* the arc_mpu_regions.c is moved to board folder, as it's board
  specific
* the above codes have been tested through tests/kernel/mem_protect/
  userspace for MPU version 2

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2018-02-16 12:20:16 +01:00
Vinayak Kariappa Chettimada 3637d50c25 drivers: flash: nRF5x: Fix co-operation with Bluetooth controller
Fixed incorrect comparison of FLASH_SLOT in microseconds
with ticks elapsed.

This caused Bluetooth controller to try scheduling events
beyond the acceptable soft real-time design limits, due to
the CPU halted for flash erase operation.

Fixes #6229.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-02-16 12:03:05 +01:00
Vinayak Kariappa Chettimada 7fa2c4dfac Bluetooth: controller: Add missing HCI supp. cmd bits for PHY Update
Added missing HCI Supported Commands bit fields for PHY
Update feature. Also, refactored with missing conditional
compilation for other bit fields.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-02-16 11:46:21 +01:00
Ruslan Mstoi d35cc75d2d net: icmpv6: Drop ICMPv6 packet if NS header is NULL
This commit fixes the crash of echo_server from malformed
ICMPv6 NS packet.

Fixes #6217

Signed-off-by: Ruslan Mstoi <ruslan.mstoi@intel.com>
2018-02-16 09:22:38 +02:00
Vinayak Kariappa Chettimada ae03e35d6c Bluetooth: controller: Fix incorrect master role scheduling
Revert incorrect calculation introduced in
commit ec5a787da2 ("Bluetooth: controller: Fix multiple
master role event scheduling") and revert a related
incorrect fix in commit a02606cbf9 ("Bluetooth:
controller: Fix missing ticks to us conversion").

Fixes the controller assert in ctrl.c line number 1477. A
64-bit arithmetic took ~35 us in Radio ISR for nRF51 causing
the ISR to take too much time before packet buffer could be
set.

Also, fixed master scheduling by correctly accounting for
the jitter between each master event.

Relates to: #5486

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-02-16 07:29:12 +02:00
Vinayak Kariappa Chettimada 067ac68f0b Bluetooth: controller: Fix XTAL_ADVANCED threshold detection
Fix incorrect calculation of unreserved timespace which
should take into account the ticks_slot of current event,
and compensation for any reduced prepare in the current
event as well as in the next event.

This regression relates to the commit ad7c9d3d76
("Bluetooth: controller: Improved continuous scanning")

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-02-16 07:29:12 +02:00
Vinayak Kariappa Chettimada 1433475b29 Bluetooth: controller: Define HAL_TIMER_SIGN_BIT
Define a macro HAL_TIMER_SIGN_BIT to correspond to the most
significant bit support by counter hardware used by ticker.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-02-16 07:29:12 +02:00
Vinayak Kariappa Chettimada 8f5e96a1b7 Bluetooth: controller: Use XON_BITMASK instead of BIT(31)
Use XON_BITMASK define instead of raw BIT(31) or bit shift
operations in code to represent use of reduced prepared by
an event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-02-16 07:29:12 +02:00
Anas Nashif 8949233390 kconfig: fix more help spacing issues
Fix Kconfig help sections and add spacing to be consistent across all
Kconfig file. In a previous run we missed a few.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-15 23:20:55 -05:00
Leandro Pereira b55eb03e40 kernel: device: Only compare strings if pointer comparison fails
Split the search into two loops: in the common scenario, where device
names are stored in ROM (and are referenced by the user with CONFIG_*
macros), only cheap pointer comparisons will be performed.

Reserve string comparisons for a fallback second pass.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-02-15 17:31:59 -08:00
Vinayak Kariappa Chettimada 1bda83af1c Bluetooth: controller: Fix to use random CRC init value
Fixed controller implementation to use random CRC init value.

Fixes #6204.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-02-15 21:15:21 +01:00
Vinayak Kariappa Chettimada 499baff333 Bluetooth: controller: Reuse safer bt_rand in thread call path
Reuse the thread safe bt_rand() interface in the controller.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-02-15 21:15:21 +01:00
Johan Hedberg 294c68d087 Bluetooth: SMP: Send Pairing failed if there's no key space
If there's no more room to store new pairings, send a proper error
instead of letting the SMP timeout expire.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-02-15 20:54:50 +02:00
Paul Sokolovsky ccec2dcb3a sensors: sensor_value: Elaborate docs
Explicitly show representation peculiarities of the negative values.
Additionally mention that fractional part is in one-millionth parts.

Fixes: #5692

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-02-15 12:55:50 -05:00
Andy Gross 08de82c2f5 arm: mpu: nxp: Set bus master 3 to full access
This patch adjusts the default permissions on the bus master 3 (NET).
Recent changes restricted this to supervisor only, and this caused
issues with the network controllers access to memory.

Restrictions on access should really be enforced on the ARM core bus
master.

Signed-off-by: Andy Gross <andy.gross@linaro.org>
2018-02-15 12:53:16 -05:00
Paul Sokolovsky 42680b07af mbedtls: Switch default MBEDTLS_CFG_FILE to config-mini-tls1_2.h
The previous default, "config-threadnet.h", is more or less arbitrary
choice made in a commit 312def2c78 1.5 years ago. In particular,
it's not related to Thread support in Zephyr per se (there was no
such support at that time).

It doesn't make sense to have a default intended for a particular,
not widely used (yet) protocol. Instead, the default should work
out of the box with a contemporary widely deployed arrays of TLS
servers, which are HTTPS server. config-mini-tls1_2.h works with
https://google.com, and by extension, with many other servers on
the Internet.

So, have that as the default, and let applications with special
needs to override that to what they need.

Addresses: #6132

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-02-15 12:35:31 -05:00
Paul Sokolovsky 9f3d335b0c mbedtls: config-mini-tls1_2.h: Update stale comments
This config enables TLS 1.2 (only), as its name suggests, and
contrary to the (copy-pasted) comments in the file header, so
update these comments.

Fixes: #6131

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-02-15 12:08:36 -05:00
Andy Gross e1fc5c21fc cmake: Add CONFIG_APPLICATION_MEMORY constraint
This patch adds an additional constraint to make sure that we only
do the application memory sizing if it is really necessary.

Signed-off-by: Andy Gross <andy.gross@linaro.org>
2018-02-15 08:37:20 -06:00
Anas Nashif 0be346eed4 tests: do not use comma separated strings
platform_whitelist does not deal with comma separated strings. Also
remove build_only option, this should also run on those devices.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-15 08:53:25 -05:00
Anas Nashif 7fe35cf886 sanitycheck: check for deprecated variant env variable
For those still using old variable ZEPHYR_GCC_VARIANT.
raise an error if the variable is not defined.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-15 08:53:25 -05:00
Anas Nashif 91b681a724 tests: add test for device class/API
Test APIs of device model and verify execution with power management
enabled.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-15 07:54:45 -05:00
Johan Hedberg c9097a9346 Bluetooth: Mesh: Declare seg_rx_buf_data as __noinit
This is a fairly large buffer, and there's no need to initialize it to
zeroes at boottime.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-02-15 10:58:24 +02:00
Johan Hedberg 05884c7f18 Bluetooth: Mesh: Split proxy client buffer payload into separate array
This makes things slightly cleaner, and we don't need to rely on the
deprecated net_buf_simple_init() API (which was a bit hackish for
these custom-constructed net_buf_simple objects anyway).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-02-15 10:58:24 +02:00
Alberto Escolar Piedras d790ed59e2 native: __ASSERT() to immediately terminate
When an __ASSERT() fails compiled for ARCH_POSIX,
instead of spinning forever (probably until sanitycheck times out)
it now terminates immediately and returns 1 to the shell

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-02-14 22:23:52 -05:00
Anas Nashif e172fa3b52 build: support out-of-tree custom boards
This is one way we can support out of tree board definitions. Basically
all this needs is a board definition in the application source directory
that follows the same structure we have in the main Zephyr tree (also
allowing multiple custom boards). An application tree would look like
this for example:

boards/
CMakeLists.txt
prj.conf
README.rst
src/

with boards following the same structure as in Zephyr:

.
├── boards
│   └── x86
│       └── arduino_101
│           ├── doc
│           │   └── img
│           └── support
└── src

To use this, you need to specify the BOARD_ROOT variable on the command
line when building:

cmake -DBOARD=<board name> -DBOARD_ROOT=<path to boards> ..

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-14 19:20:29 -05:00
Marti Bolivar 1f8485ba92 CODEOWNERS: add entries for led_strip drivers
I am the original author of the API  and initial drivers, and would
like to maintain this area.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-02-14 19:06:44 -05:00
Stephen Smalley 7032027f1f tests: userspace: fix read/write privileged stack tests
The read/write_kernel_stack tests are confusingly named and incorrectly
implemented for ARM; they are intended to test that user mode threads
cannot read or write their privileged stacks.  The privileged stacks
on ARM are not relative to the user stack, and thus their location
cannot be computed from the user stack.  To find the privileged stack on
ARM, we have to use _k_priv_stack_find(), which we do during setup
in test_main() rather than from the usermode thread itself.  Accessing
thread_stack directly from the test function requires making it
non-static in ztest, so we also give it a ztest_ prefix to avoid
collisions with other test programs.  Rename the test functions and
global pointer variable to more accurately reflect their purpose.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2018-02-14 13:06:21 -08:00
Christopher Collins 821dc37f3f subsys: storage: flash_map: Fix warning
Prior to this commit, `flash_area_layout()` was being passed a pointer
to the incorrect type (`uint32_t *` where `int *` was expected).  This
caused the following warning to be reported:

```
[...]/subsys/storage/flash_map/flash_map.c: In
function 'flash_area_get_sectors':
[...]/subsys/storage/flash_map/flash_map.c:191:32:
warning: passing argument 2 of 'flash_area_layout' from incompatible
pointer type [-Wincompatible-pointer-types]
  return flash_area_layout(idx, cnt, ret, get_sectors_cb, &data);
                                ^~~
[...]/subsys/storage/flash_map/flash_map.c:136:12:
note: expected 'int *' but argument is of type 'uint32_t * {aka long
unsigned int *}'
 static int flash_area_layout(int idx, int *cnt, void *ret,
            ^~~~~~~~~~~~~~~~~
```

This commit changes the argument type to `u32_t` for both functions.

Signed-off-by: Christopher Collins <ccollins@apache.org>
2018-02-14 14:36:52 -05:00
Carles Cufi 1a5133ccd0 doc: contributing: Document CI
Add basic CI documentation to help users navigate through the CI system
and deal with failures.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-02-14 12:54:21 -05:00
Carles Cufi f982a89c4f doc: contributing: Make instructions cross-platform
The contributing instructions were currently centered exclusively around
Linux. Make them generic and cross-plaform while highlighting the tools
that do not currently work on Windows, namely:

 * sanitycheck
 * checkpatch

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-02-14 12:54:21 -05:00
Mariusz Skamra daa8040e2f Bluetooth: Mesh: Ignore segments of cancelled message
This fixes the issue when after incomplete timer expiration
host sent ACK.
The host failed in two cases:
1. Sending ACK right after the incomplete timer expiration;
2. Sending ACK from new RX context. Now, seq_auth of cancelled
message is not cleaned on RX reset, so segments of cancelled message
will be discarded when resend.

According to the Mesh Profile v1.0
"When the incomplete timer expires, the lower transport layer
shall consider that the message being received has failed and
cancel the acknowledgment timer. Any segment of a canceled
message shall be ignored."

Fixes #6023

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-02-14 17:53:37 +02:00
Ruslan Mstoi c78a1227ff net: icmpv6: Drop ICMPv6 packet if ICMP header is NULL
This commit fixes the crash of echo_server from malformed
ICMPv6 packet.

Fixes #6197

Signed-off-by: Ruslan Mstoi <ruslan.mstoi@intel.com>
2018-02-14 17:44:29 +02:00
Ramakrishna Pallala 85fb583ed2 kernel: device: Remove the redundant device name check
Remove the redundant device name match check in device_get_binding().

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-02-14 10:07:24 -05:00
Leandro Pereira e7b6c8f322 kernel: mem_domain: Break down assertions
Instead of composing expressions with a logical AND, break down it into
multiple assertions.  Smaller assertions are easier to read.  While at
it, compare pointers against the NULL value, and numbers against 0
instead of relying on implicit conversion to boolean-ish values.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-02-14 10:07:10 -05:00
Leandro Pereira 53a7cf9a74 kernel: mem_domain: Fix assertion in k_mem_domain_add_partition()
Without the parenthesis, the code was asserting this expression:

    start + (size > start)

Where it should be this instead:

    (start + size) > start

For a quick sanity check when adding these two unsigned values together.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-02-14 10:07:10 -05:00
Henrik Brix Andersen dd0d07c825 sam0: Enable pinmux in arduino_zero_defconfig.
Commit 247782a7b3 moved the sam0 UART
and SPI configuration into pinmux. Using these drivers without pinmux
causes the kernel to skip the pin configuration.

Tested on arduino_zero.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2018-02-14 09:05:12 -06:00
Yannis Damigos c4dfa9baec drivers/pinmux/stm32: Fix 80 characters line warnings
Fix warnings about lines longer than 80 characters.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2018-02-14 08:51:41 -06:00
Johan Hedberg 67e14d3916 net: buf: Use __noinit where possible
Static variables that don't strictly need to be initialized at
boottime should be declared with __noinit. This makes a considerable
difference especially for large buffers.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-02-14 15:44:04 +02:00
Daniel Wagenknecht 0aef9030e4 tests: spi_loopback: add testcase.yaml
Add a testcase.yaml configuration to spi_loopback test to include
it into sanitycheck.

Fixes #4576

Signed-off-by: Daniel Wagenknecht <wagenknecht.daniel@gmail.com>
2018-02-14 08:06:26 -05:00
Daniel Wagenknecht c7c442ad9f tests: spi_loopback: add board specific configuration
This restores the board specific configurations that were present
before moving the test to using KConfig.

<board>.conf files from boards subdirectory get merged with
prj_base.conf file.

Signed-off-by: Daniel Wagenknecht <wagenknecht.daniel@gmail.com>
2018-02-14 08:06:26 -05:00
Daniel Wagenknecht 64060020ea tests: spi_loopback: Move to using KConfig
Convert this test to using KConfig instead of conditional compilation.
Standard configuration is provided by prj_base.conf and KConfig
default values.

Remove prj_<board>.conf files.

Signed-off-by: Daniel Wagenknecht <wagenknecht.daniel@gmail.com>
2018-02-14 08:06:26 -05:00
Carles Cufi f24f50b12e arm: cortex_m: Use new ARMV6_M_ARMV8_M_BASELINE in vector relay
The old ARMV6_M Kconfig option has been removed, and so to correctly set
the dependencies for SW_VECTOR_RELAY we need to use the new
ARMV6_M_ARMV8_M_BASELINE.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-02-14 12:49:09 +01:00
Johan Hedberg 6b3d2935f4 Bluetooth: Mesh: Fix sending Provisioning Failed for PB-GATT
In the case of an unexpected PDU we need to send the right response.
This was already taken care of for PB-ADV, but not for PB-GATT.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-02-14 11:43:34 +02:00
Johan Hedberg 4f47bc3611 Bluetooth: Mesh: Resend Link Acknowledgment when necessary
The Provisioner might have missed our earlier Link Acknowledgement, so
if we receive another one with matching Link ID and link.expect state,
simply send another acknowledgement.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-02-14 11:43:34 +02:00