07 Mar, 2019

1 commit

  • Pull ARM SoC driver updates from Arnd Bergmann:
    "As usual, the drivers/tee and drivers/reset subsystems get merged
    here, with the expected set of smaller updates and some new hardware
    support. The tee subsystem now supports device drivers to be attached
    to a tee, the first example here is a random number driver with its
    implementation in the secure world.

    Three new power domain drivers get added for specific chip families:
    - Broadcom BCM283x chips (used in Raspberry Pi)
    - Qualcomm Snapdragon phone chips
    - Xilinx ZynqMP FPGA SoCs

    One new driver is added to talk to the BPMP firmware on NVIDIA
    Tegra210

    Existing drivers are extended for new SoC variants from NXP, NVIDIA,
    Amlogic and Qualcomm"

    * tag 'armsoc-drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (113 commits)
    tee: optee: update optee_msg.h and optee_smc.h to dual license
    tee: add cancellation support to client interface
    dpaa2-eth: configure the cache stashing amount on a queue
    soc: fsl: dpio: configure cache stashing destination
    soc: fsl: dpio: enable frame data cache stashing per software portal
    soc: fsl: guts: make fsl_guts_get_svr() static
    hwrng: make symbol 'optee_rng_id_table' static
    tee: optee: Fix unsigned comparison with less than zero
    hwrng: Fix unsigned comparison with less than zero
    tee: fix possible error pointer ctx dereferencing
    hwrng: optee: Initialize some structs using memset instead of braces
    tee: optee: Initialize some structs using memset instead of braces
    soc: fsl: dpio: fix memory leak of a struct qbman on error exit path
    clk: tegra: dfll: Make symbol 'tegra210_cpu_cvb_tables' static
    soc: qcom: llcc-slice: Fix typos
    qcom: soc: llcc-slice: Consolidate some code
    qcom: soc: llcc-slice: Clear the global drv_data pointer on error
    drivers: soc: xilinx: Add ZynqMP power domain driver
    firmware: xilinx: Add APIs to control node status/power
    dt-bindings: power: Add ZynqMP power domain bindings
    ...

    Linus Torvalds
     

01 Mar, 2019

1 commit


28 Feb, 2019

3 commits

  • The files optee_msg.h and optee_smc.h (under drivers/tee/optee) contain
    information originating from the OP-TEE OS project [1] [2], where the
    licensing terms are BSD 2-Clause. Therefore, apply a dual license to
    those files.

    Link: [1] https://github.com/OP-TEE/optee_os/blob/master/core/include/optee_msg.h
    Link: [2] https://github.com/OP-TEE/optee_os/blob/master/core/arch/arm/include/sm/optee_smc.h
    Signed-off-by: Jerome Forissier
    Signed-off-by: Jens Wiklander

    Jerome Forissier
     
  • Add support of cancellation request to the TEE kernel internal
    client interface. Can be used by software TPM drivers, that leverage
    TEE under the hood (for instance TPM2.0 mobile profile), for requesting
    cancellation of time-consuming operations (RSA key-pair generation etc.).

    Signed-off-by: Igor Opaniuk
    Signed-off-by: Jens Wiklander

    Igor Opaniuk
     
  • Add an of_node_put when a tested device node is not available.

    The semantic patch that fixes this problem is as follows
    (http://coccinelle.lip6.fr):

    //
    @@
    identifier f;
    local idexpression e;
    expression x;
    @@

    e = f(...);
    ... when != of_node_put(e)
    when != x = e
    when != e = x
    when any
    if () {
    ... when != of_node_put(e)
    (
    return e;
    |
    + of_node_put(e);
    return ...;
    )
    }
    //

    Fixes: db878f76b9ff ("tee: optee: take DT status property into account")
    Signed-off-by: Julia Lawall
    Signed-off-by: Jens Wiklander

    Julia Lawall
     

21 Feb, 2019

2 commits

  • The return from the call to tee_client_invoke_func can be a
    negative error code however this is being assigned to an
    unsigned variable 'ret' hence the check is always false.
    Fix this by making 'ret' an int.

    Detected by Coccinelle ("Unsigned expression compared with zero:
    ret < 0")

    Fixes: c3fa24af9244 ("tee: optee: add TEE bus device enumeration support")
    Signed-off-by: YueHaibing
    Reviewed-by: Sumit Garg
    Signed-off-by: Arnd Bergmann

    YueHaibing
     
  • Add check for valid ctx pointer and then only dereference ctx to
    configure supp_nowait flag.

    Fixes: 42bf4152d8a7 ("tee: add supp_nowait flag in tee_context struct")
    Reported-by: Dan Carpenter
    Signed-off-by: Sumit Garg
    Signed-off-by: Arnd Bergmann

    Sumit Garg
     

20 Feb, 2019

1 commit

  • Clang warns:

    drivers/tee/optee/device.c:39:31: warning: suggest braces around
    initialization of subobject [-Wmissing-braces]
    struct tee_param param[4] = {0};
    ^
    {}
    drivers/tee/optee/device.c:92:48: warning: suggest braces around
    initialization of subobject [-Wmissing-braces]
    struct tee_ioctl_open_session_arg sess_arg = {0};
    ^
    {}
    2 warnings generated.

    One way to fix these warnings is to add additional braces like Clang
    suggests; however, there has been a bit of push back from some
    maintainers, who just prefer memset as it is unambiguous, doesn't
    depend on a particular compiler version, and properly initializes all
    subobjects [1][2]. Do that here so there are no more warnings.

    [1]: https://lore.kernel.org/lkml/022e41c0-8465-dc7a-a45c-64187ecd9684@amd.com/
    [2]: https://lore.kernel.org/lkml/20181128.215241.702406654469517539.davem@davemloft.net/

    Fixes: c3fa24af9244 ("tee: optee: add TEE bus device enumeration support")
    Link: https://github.com/ClangBuiltLinux/linux/issues/370
    Signed-off-by: Nathan Chancellor
    Reviewed-by: Sumit Garg
    Signed-off-by: Arnd Bergmann

    Nathan Chancellor
     

01 Feb, 2019

3 commits

  • OP-TEE provides a pseudo TA to enumerate TAs which can act as devices/
    services for TEE bus. So implement device enumeration using invoke
    function: PTA_CMD_GET_DEVICES provided by pseudo TA to fetch array of
    device UUIDs. Also register these enumerated devices with TEE bus as
    "optee-clntX" device.

    Signed-off-by: Sumit Garg
    Reviewed-by: Daniel Thompson
    [jw: fix optee_enumerate_devices() with no devices found]
    Signed-off-by: Jens Wiklander

    Sumit Garg
     
  • Introduce a generic TEE bus driver concept for TEE based kernel drivers
    which would like to communicate with TEE based devices/services. Also
    add support in module device table for these new TEE based devices.

    In this TEE bus concept, devices/services are identified via Universally
    Unique Identifier (UUID) and drivers register a table of device UUIDs
    which they can support.

    So this TEE bus framework registers following apis:
    - match(): Iterates over the driver UUID table to find a corresponding
    match for device UUID. If a match is found, then this particular device
    is probed via corresponding probe api registered by the driver. This
    process happens whenever a device or a driver is registered with TEE
    bus.
    - uevent(): Notifies user-space (udev) whenever a new device is registered
    on this bus for auto-loading of modularized drivers.

    Also this framework allows for device enumeration to be specific to
    corresponding TEE implementation like OP-TEE etc.

    Signed-off-by: Sumit Garg
    Reviewed-by: Daniel Thompson
    Reviewed-by: Bhupesh Sharma
    Signed-off-by: Jens Wiklander

    Sumit Garg
     
  • This flag indicates that requests in this context should not wait for
    tee-supplicant daemon to be started if not present and just return
    with an error code. It is needed for requests which should be
    non-blocking in nature like ones arising from TEE based kernel drivers
    or any in kernel api that uses TEE internal client interface.

    Signed-off-by: Sumit Garg
    Reviewed-by: Daniel Thompson
    Signed-off-by: Jens Wiklander

    Sumit Garg
     

01 Jan, 2019

1 commit


11 Dec, 2018

2 commits

  • When dynamic shared memory support is enabled in the OP-TEE Trusted
    OS, it doesn't mean that the driver supports it, which can confuse
    users during debugging. Log a message when dynamic shared memory is
    enabled in the driver, to let users know for sure.

    Suggested-by: Jerome Forissier
    Signed-off-by: Victor Chong
    Reviewed-by: Jerome Forissier
    Signed-off-by: Jens Wiklander

    Victor Chong
     
  • This bug occurs when:

    - a new request arrives, one thread(let's call it A) is pending in
    optee_supp_req() with req->busy is initial value false.

    - tee-supplicant is killed, then optee_supp_release() is called, this
    function calls list_del(&req->link), and set supp->ctx to NULL. And
    it also wake up process A.

    - process A continues, it firstly checks supp->ctx which is NULL,
    then checks req->busy which is false, at last run list_del(&req->link).
    This triggers double list_del() and results kernel panic.

    For solve this problem, we rename req->busy to req->in_queue, and
    associate it with state of whether req is linked to supp->reqs. So we
    can just only check req->in_queue to make decision calling list_del()
    or not.

    Signed-off-by: Zhizhou Zhang
    Signed-off-by: Jens Wiklander

    Zhizhou Zhang
     

27 Aug, 2018

1 commit

  • …-tee into next/drivers

    Misc enhancement for tee driver subsystem

    * Adds a kernel internal tee client interface allowing other drivers
    etc to access a TEE
    * OP-TEE driver takes DT status property into account

    * tag 'tee-drv-for-4.20' of git://git.linaro.org/people/jens.wiklander/linux-tee:
    tee: add kernel internal client interface
    tee: optee: take DT status property into account

    Signed-off-by: Olof Johansson <olof@lixom.net>

    Olof Johansson
     

24 Aug, 2018

3 commits

  • Adds a kernel internal TEE client interface to be used by other drivers.

    Reviewed-by: Sumit Garg
    Tested-by: Sumit Garg
    Tested-by: Zeng Tao
    Signed-off-by: Jens Wiklander

    Jens Wiklander
     
  • DT nodes may have a 'status' property which, if set to anything other
    than 'ok' or 'okay', indicates to the OS that the DT node should be
    treated as if it was not present. So add that missing logic to the
    OP-TEE driver.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Jens Wiklander

    Ard Biesheuvel
     
  • Pull ARM SoC driver updates from Olof Johansson:
    "Some of the larger changes this merge window:

    - Removal of drivers for Exynos5440, a Samsung SoC that never saw
    widespread use.

    - Uniphier support for USB3 and SPI reset handling

    - Syste control and SRAM drivers and bindings for Allwinner platforms

    - Qualcomm AOSS (Always-on subsystem) reset controller drivers

    - Raspberry Pi hwmon driver for voltage

    - Mediatek pwrap (pmic) support for MT6797 SoC"

    * tag 'armsoc-drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (52 commits)
    drivers/firmware: psci_checker: stash and use topology_core_cpumask for hotplug tests
    soc: fsl: cleanup Kconfig menu
    soc: fsl: dpio: Convert DPIO documentation to .rst
    staging: fsl-mc: Remove remaining files
    staging: fsl-mc: Move DPIO from staging to drivers/soc/fsl
    staging: fsl-dpaa2: eth: move generic FD defines to DPIO
    soc: fsl: qe: gpio: Add qe_gpio_set_multiple
    usb: host: exynos: Remove support for Exynos5440
    clk: samsung: Remove support for Exynos5440
    soc: sunxi: Add the A13, A23 and H3 system control compatibles
    reset: uniphier: add reset control support for SPI
    cpufreq: exynos: Remove support for Exynos5440
    ata: ahci-platform: Remove support for Exynos5440
    soc: imx6qp: Use GENPD_FLAG_ALWAYS_ON for PU errata
    soc: mediatek: pwrap: add mt6351 driver for mt6797 SoCs
    soc: mediatek: pwrap: add pwrap driver for mt6797 SoCs
    soc: mediatek: pwrap: fix cipher init setting error
    dt-bindings: pwrap: mediatek: add pwrap support for MT6797
    reset: uniphier: add USB3 core reset control
    dt-bindings: reset: uniphier: add USB3 core reset support
    ...

    Linus Torvalds
     

22 Jun, 2018

1 commit

  • drm-misc-next for 4.19:

    UAPI Changes:
    - Add writeback connector (Brian Starkey/Liviu Dudau)
    - Add "content type" property to HDMI connectors (Stanislav Lisovskiy)

    Cross-subsystem Changes:
    - some devicetree Docs update
    - fix compile breakage on ION due to the dma-buf cleanups (Christian König)

    Core Changes:
    - Reject over-sized allocation requests early (Chris Wilson)
    - gem-fb-helper: Always do implicit sync (Daniel Vetter)
    - dma-buf cleanups (Christian König)

    Driver Changes:
    - Fixes for the otm8009a panel driver (Philippe Cornu)
    - Add Innolux TV123WAM panel driver support (Sandeep Panda)
    - Move GEM BO to drm_framebuffer in few drivers (Daniel Stone)
    - i915 pinning improvements (Chris Wilson)
    - Stop consulting plane->fb/crtc in a few drivers (Ville Syrjälä)

    Signed-off-by: Dave Airlie

    Link: https://patchwork.freedesktop.org/patch/msgid/20180621105428.GA20795@juma

    Dave Airlie
     

20 Jun, 2018

2 commits


19 Jun, 2018

1 commit


07 May, 2018

2 commits

  • This change prevents userland from referencing TEE shared memory
    outside the area initially allocated by its owner. Prior this change an
    application could not reference or access memory it did not own but
    it could reference memory not explicitly allocated by owner but still
    allocated to the owner due to the memory allocation granule.

    Reported-by: Alexandre Jutras
    Signed-off-by: Etienne Carriere
    Signed-off-by: Jens Wiklander

    Etienne Carriere
     
  • Bump the file's refcount before moving the reference into the fd table,
    not afterwards. The old code could drop the file's refcount to zero for a
    short moment before calling get_file() via get_dma_buf().

    This code can only be triggered on ARM systems that use Linaro's OP-TEE.

    Fixes: 967c9cca2cc5 ("tee: generic TEE subsystem")
    Signed-off-by: Jann Horn
    Signed-off-by: Jens Wiklander

    Jann Horn
     

06 Mar, 2018

3 commits

  • When the driver initializes, report the following information
    about the OP-TEE OS:
    - major and minor version,
    - build identifier (if available).

    Signed-off-by: Jerome Forissier
    Reviewed-by: Matthias Brugger
    Signed-off-by: Jens Wiklander

    Jérôme Forissier
     
  • In the OPTEE_SMC_CALL_GET_OS_REVISION request, the previously reserved
    parameter a2 is now documented as being an optional build identifier
    (such as an SCM revision or commit ID, for instance).

    A new structure optee_smc_call_get_os_revision_result is introduced to
    be used when querying the secure OS version, instead of re-using the
    struct defined for OPTEE_SMC_CALLS_REVISION.

    Signed-off-by: Jerome Forissier
    Reviewed-by: Matthias Brugger
    Signed-off-by: Jens Wiklander

    Jérôme Forissier
     
  • The privileged dev id range is [TEE_NUM_DEVICES / 2, TEE_NUM_DEVICES).
    The non-privileged dev id range is [0, TEE_NUM_DEVICES / 2).

    So when finding a slot for them, need to use different max value.

    Signed-off-by: Peng Fan
    Signed-off-by: Jens Wiklander

    Peng Fan
     

12 Jan, 2018

1 commit

  • …/jens.wiklander/linux-tee into next/drivers

    This pull request updates the previous tee-drv-dynamic-shm-for-v4.16 pull
    request with five new patches fixing review comments and errors.

    Apart from three small fixes there's two larger patches that in the end
    checks that memory to be registered really is normal cached memory.

    * tag 'tee-drv-dynamic-shm+fixes-for-v4.16' of https://git.linaro.org/people/jens.wiklander/linux-tee:
    tee: shm: Potential NULL dereference calling tee_shm_register()
    tee: shm: don't put_page on null shm->pages
    tee: shm: make function __tee_shm_alloc static
    tee: optee: check type of registered shared memory
    tee: add start argument to shm_register callback

    Signed-off-by: Olof Johansson <olof@lixom.net>

    Olof Johansson
     

09 Jan, 2018

1 commit

  • get_user_pages_fast() can return zero in certain error paths. We should
    handle that or else it means we accidentally return ERR_PTR(0) which is
    NULL instead of an error pointer. The callers are not expecting that
    and will crash with a NULL dereference.

    Fixes: 033ddf12bcf5 ("tee: add register user memory")
    Signed-off-by: Dan Carpenter
    Signed-off-by: Jens Wiklander

    Dan Carpenter
     

29 Dec, 2017

2 commits

  • In the case that shm->pages fails to allocate, the current exit
    error path will try to put_page on a null shm->pages and cause
    a null pointer dereference when accessing shm->pages[n]. Fix this
    by only performing the put_page and kfree on shm->pages if it
    is not null.

    Detected by CoverityScan, CID#1463283 ("Dereference after null check")

    Fixes: 033ddf12bcf5 ("tee: add register user memory")
    Signed-off-by: Colin Ian King
    Signed-off-by: Jens Wiklander

    Colin Ian King
     
  • The function __tee_shm_alloc is local to the source and does
    not need to be in global scope, so make it static.

    Cleans up sparse warning:
    symbol '__tee_shm_alloc' was not declared. Should it be static?

    Signed-off-by: Colin Ian King
    Signed-off-by: Jens Wiklander

    Colin Ian King
     

28 Dec, 2017

2 commits


22 Dec, 2017

2 commits

  • The optee driver includes the header files in an unusual order,
    with asm/pgtable.h before the linux/*.h headers. For some reason
    this seems to trigger a build failure:

    drivers/tee/optee/call.c: In function 'optee_fill_pages_list':
    include/asm-generic/memory_model.h:64:14: error: implicit declaration of function 'page_to_section'; did you mean '__nr_to_section'? [-Werror=implicit-function-declaration]
    int __sec = page_to_section(__pg); \
    drivers/tee/optee/call.c:494:15: note: in expansion of macro 'page_to_phys'
    optee_page = page_to_phys(*pages) +

    Let's just include linux/mm.h, which will then get the other
    header implicitly.

    Fixes: 3bb48ba5cd60 ("tee: optee: add page list manipulation functions")
    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     
  • …wiklander/linux-tee into next/drivers

    Pull "tee dynamic shm for v4.16" from Jens Wiklander:

    This pull request enables dynamic shared memory support in the TEE
    subsystem as a whole and in OP-TEE in particular.

    Global Platform TEE specification [1] allows client applications
    to register part of own memory as a shared buffer between
    application and TEE. This allows fast zero-copy communication between
    TEE and REE. But current implementation of TEE in Linux does not support
    this feature.

    Also, current implementation of OP-TEE transport uses fixed size
    pre-shared buffer for all communications with OP-TEE OS. This is okay
    in the most use cases. But this prevents use of OP-TEE in virtualized
    environments, because:
    a) We can't share the same buffer between different virtual machines
    b) Physically contiguous memory as seen by VM can be non-contiguous
    in reality (and as seen by OP-TEE OS) due to second stage of
    MMU translation.
    c) Size of this pre-shared buffer is limited.

    So, first part of this pull request adds generic register/unregister
    interface to tee subsystem. The second part adds necessary features into
    OP-TEE driver, so it can use not only static pre-shared buffer, but
    whole RAM to communicate with OP-TEE OS.

    This change is backwards compatible allowing older secure world or
    user space to work with newer kernels and vice versa.

    [1] https://www.globalplatform.org/specificationsdevice.asp

    * tag 'tee-drv-dynamic-shm-for-v4.16' of https://git.linaro.org/people/jens.wiklander/linux-tee:
    tee: shm: inline tee_shm_get_id()
    tee: use reference counting for tee_context
    tee: optee: enable dynamic SHM support
    tee: optee: add optee-specific shared pool implementation
    tee: optee: store OP-TEE capabilities in private data
    tee: optee: add registered buffers handling into RPC calls
    tee: optee: add registered shared parameters handling
    tee: optee: add shared buffer registration functions
    tee: optee: add page list manipulation functions
    tee: optee: Update protocol definitions
    tee: shm: add page accessor functions
    tee: shm: add accessors for buffer size and page offset
    tee: add register user memory
    tee: flexible shared memory pool creation

    Arnd Bergmann
     

21 Dec, 2017

1 commit

  • …jens.wiklander/linux-tee into next/drivers

    Pull "Enable async communication with tee supplicant" from Jens Wiklander:

    This pull request enables asynchronous communication with TEE supplicant
    by introducing meta parameters in the user space API. The meta
    parameters can be used to tag requests with an id that can be matched
    against an asynchronous response as is done here in the OP-TEE driver.

    Asynchronous supplicant communication is needed by OP-TEE to implement
    GlobalPlatforms TEE Sockets API Specification v1.0.1. The specification
    is available at https://www.globalplatform.org/specificationsdevice.asp.

    This change is backwards compatible allowing older supplicants to work
    with newer kernels and vice versa.

    * tag 'tee-drv-async-supplicant-for-v4.16' of https://git.linaro.org/people/jens.wiklander/linux-tee:
    optee: support asynchronous supplicant requests
    tee: add TEE_IOCTL_PARAM_ATTR_META
    tee: add tee_param_is_memref() for driver use

    Arnd Bergmann
     

15 Dec, 2017

4 commits

  • Now, when struct tee_shm is defined in public header,
    we can inline small getter functions like this one.

    Signed-off-by: Volodymyr Babchuk
    Signed-off-by: Jens Wiklander

    Volodymyr Babchuk
     
  • We need to ensure that tee_context is present until last
    shared buffer will be freed.

    Signed-off-by: Volodymyr Babchuk
    Signed-off-by: Jens Wiklander

    Volodymyr Babchuk
     
  • Previous patches added various features that are needed for dynamic SHM.
    Dynamic SHM allows Normal World to share any buffers with OP-TEE.
    While original design suggested to use pre-allocated region (usually of
    1M to 2M of size), this new approach allows to use all non-secure RAM for
    command buffers, RPC allocations and TA parameters.

    This patch checks capability OPTEE_SMC_SEC_CAP_DYNAMIC_SHM. If it was set
    by OP-TEE, then kernel part of OP-TEE will use kernel page allocator
    to allocate command buffers. Also it will set TEE_GEN_CAP_REG_MEM
    capability to tell userspace that it supports shared memory registration.

    Signed-off-by: Volodymyr Babchuk
    Signed-off-by: Jens Wiklander

    Volodymyr Babchuk
     
  • This is simple pool that uses kernel page allocator. This pool can be
    used in case OP-TEE supports dynamic shared memory.

    Signed-off-by: Volodymyr Babchuk
    Signed-off-by: Jens Wiklander

    Volodymyr Babchuk