14 Dec, 2020

2 commits

  • Call request/release busfreq HIGH each time a SMC
    is called.
    This ensure that OPTEE is running in HIGH frequency mode
    until no more SMC running

    Signed-off-by: Cedric Neveux
    Acked-by: Peng Fan
    (cherry picked from commit 41604a3382306b78f1038524a1018647f3cf3f52)

    Cedric Neveux
     
  • When allocating pages for share memory with OP-TEE,
    the driver checks the page attribute (pte).
    The current checks only allow writealloc pages.
    i.MX 6SLL sets the page attribute to writeback.
    Relax this check to allow writealloc, writeback and writethrough.

    Signed-off-by: Silvano di Ninno
    Reviewed-by: Franck Lenormand
    Reviewed-by: Horia Geanta
    Acked-by: Leonard Crestez
    (cherry picked from commit a4c5efa2df07a54ce112206c3ffc8fccf3369c52)

    Silvano di Ninno
     

25 Nov, 2020

1 commit

  • Only in smp systems the cache policy is setup as write alloc, in
    single cpu systems the cache policy is set as writeback and it is
    normal memory, so, it should pass the is_normal_memory check in the
    share memory registration.

    Add the right condition to make it work in no smp systems.

    Fixes: cdbcf83d29c1 ("tee: optee: check type of registered shared memory")
    Signed-off-by: Rui Miguel Silva
    Signed-off-by: Jens Wiklander

    Rui Miguel Silva
     

14 Sep, 2020

1 commit


01 Sep, 2020

1 commit

  • When the optee driver is compiled into the kernel while the i2c core
    is configured as a module, the i2c symbols are not available.

    This commit addresses the situation by disabling the i2c support for
    this use case while allowing it in all other scenarios:

    i2c=y, optee=y
    i2c=m, optee=m
    i2c=y, optee=m
    i2c=m, optee=y (not supported)

    Fixes: c05210ab9757 ("drivers: optee: allow op-tee to access devices on the i2c bus")
    Reported-by: kernel test robot
    Signed-off-by: Jorge Ramirez-Ortiz
    Signed-off-by: Jens Wiklander

    Jorge Ramirez-Ortiz
     

22 Aug, 2020

1 commit

  • …der/linux-tee into arm/drivers

    Handle NULL pointer indication from tee client

    Adds support to indicate NULL pointers instead of a valid buffer when
    querying the needed size of a buffer.

    * tag 'tee-memref-null-for-v5.10' of git://git.linaro.org/people/jens.wiklander/linux-tee:
    driver: tee: Handle NULL pointer indication from client

    Link: https://lore.kernel.org/r/20200821102535.GA1872111@jade
    Signed-off-by: Olof Johansson <olof@lixom.net>

    Olof Johansson
     

21 Aug, 2020

2 commits

  • Some secure elements like NXP's SE050 sit on I2C buses. For OP-TEE to
    control this type of cryptographic devices it needs coordinated access
    to the bus, so collisions and RUNTIME_PM dont get in the way.

    This trampoline driver allow OP-TEE to access them.

    Signed-off-by: Jorge Ramirez-Ortiz
    Signed-off-by: Jens Wiklander

    Jorge Ramirez-Ortiz
     
  • TEE Client introduce a new capability "TEE_GEN_CAP_MEMREF_NULL"
    to handle the support of the shared memory buffer with a NULL pointer.

    This capability depends on TEE Capabilities and driver support.
    Driver and TEE exchange capabilities at driver initialization.

    Signed-off-by: Michael Whitfield
    Signed-off-by: Cedric Neveux
    Reviewed-by: Joakim Bech
    Tested-by: Joakim Bech (QEMU)
    Signed-off-by: Jens Wiklander

    Cedric Neveux
     

13 Jul, 2020

1 commit

  • …ux-tee into arm/drivers

    Enable multi-stage OP-TEE bus enumeration

    Probes drivers on the OP-TEE bus in two steps. First for drivers which
    do not depend on tee-supplicant. After tee-supplicant has been started
    probe the devices which do depend on tee-supplicant.

    Also introduces driver which uses an OP-TEE based fTPM Trusted
    Application depends on tee-supplicant NV RAM implementation based on
    RPMB secure storage.

    * tag 'optee-bus-for-v5.9' of git://git.linaro.org/people/jens.wiklander/linux-tee:
    tpm_ftpm_tee: register driver on TEE bus
    optee: enable support for multi-stage bus enumeration
    optee: use uuid for sysfs driver entry

    Link: https://lore.kernel.org/r/20200710085230.GA1312913@jade
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>

    Arnd Bergmann
     

10 Jul, 2020

2 commits

  • Some drivers (like ftpm) can operate only after tee-supplicant
    runs because of tee-supplicant provides things like storage
    services (rpmb, shm).  This patch splits probe of non tee-supplicant
    dependable drivers to the early stage, and after tee-supplicant run
    probe other drivers.

    Signed-off-by: Maxim Uvarov
    Suggested-by: Sumit Garg
    Suggested-by: Arnd Bergmann
    Reviewed-by: Sumit Garg
    Acked-by: Jarkko Sakkinen
    Tested-by: Sumit Garg
    Signed-off-by: Jens Wiklander

    Maxim Uvarov
     
  • With the evolving use-cases for TEE bus, now it's required to support
    multi-stage enumeration process. But using a simple index doesn't
    suffice this requirement and instead leads to duplicate sysfs entries.
    So instead switch to use more informative device UUID for sysfs entry
    like:
    /sys/bus/tee/devices/optee-ta-

    Signed-off-by: Maxim Uvarov
    Reviewed-by: Sumit Garg
    Reviewed-by: Jarkko Sakkinen
    Tested-by: Sumit Garg
    Signed-off-by: Jens Wiklander

    Maxim Uvarov
     

10 Jun, 2020

1 commit

  • This change converts the existing mmap_sem rwsem calls to use the new mmap
    locking API instead.

    The change is generated using coccinelle with the following rule:

    // spatch --sp-file mmap_lock_api.cocci --in-place --include-headers --dir .

    @@
    expression mm;
    @@
    (
    -init_rwsem
    +mmap_init_lock
    |
    -down_write
    +mmap_write_lock
    |
    -down_write_killable
    +mmap_write_lock_killable
    |
    -down_write_trylock
    +mmap_write_trylock
    |
    -up_write
    +mmap_write_unlock
    |
    -downgrade_write
    +mmap_write_downgrade
    |
    -down_read
    +mmap_read_lock
    |
    -down_read_killable
    +mmap_read_lock_killable
    |
    -down_read_trylock
    +mmap_read_trylock
    |
    -up_read
    +mmap_read_unlock
    )
    -(&mm->mmap_sem)
    +(mm)

    Signed-off-by: Michel Lespinasse
    Signed-off-by: Andrew Morton
    Reviewed-by: Daniel Jordan
    Reviewed-by: Laurent Dufour
    Reviewed-by: Vlastimil Babka
    Cc: Davidlohr Bueso
    Cc: David Rientjes
    Cc: Hugh Dickins
    Cc: Jason Gunthorpe
    Cc: Jerome Glisse
    Cc: John Hubbard
    Cc: Liam Howlett
    Cc: Matthew Wilcox
    Cc: Peter Zijlstra
    Cc: Ying Han
    Link: http://lkml.kernel.org/r/20200520052908.204642-5-walken@google.com
    Signed-off-by: Linus Torvalds

    Michel Lespinasse
     

11 May, 2020

1 commit


09 Feb, 2020

1 commit

  • Pull ARM SoC-related driver updates from Olof Johansson:
    "Various driver updates for platforms:

    - Nvidia: Fuse support for Tegra194, continued memory controller
    pieces for Tegra30

    - NXP/FSL: Refactorings of QuickEngine drivers to support
    ARM/ARM64/PPC

    - NXP/FSL: i.MX8MP SoC driver pieces

    - TI Keystone: ring accelerator driver

    - Qualcomm: SCM driver cleanup/refactoring + support for new SoCs.

    - Xilinx ZynqMP: feature checking interface for firmware. Mailbox
    communication for power management

    - Overall support patch set for cpuidle on more complex hierarchies
    (PSCI-based)

    and misc cleanups, refactorings of Marvell, TI, other platforms"

    * tag 'armsoc-drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (166 commits)
    drivers: soc: xilinx: Use mailbox IPI callback
    dt-bindings: power: reset: xilinx: Add bindings for ipi mailbox
    drivers: soc: ti: knav_qmss_queue: Pass lockdep expression to RCU lists
    MAINTAINERS: Add brcmstb PCIe controller entry
    soc/tegra: fuse: Unmap registers once they are not needed anymore
    soc/tegra: fuse: Correct straps' address for older Tegra124 device trees
    soc/tegra: fuse: Warn if straps are not ready
    soc/tegra: fuse: Cache values of straps and Chip ID registers
    memory: tegra30-emc: Correct error message for timed out auto calibration
    memory: tegra30-emc: Firm up hardware programming sequence
    memory: tegra30-emc: Firm up suspend/resume sequence
    soc/tegra: regulators: Do nothing if voltage is unchanged
    memory: tegra: Correct reset value of xusb_hostr
    soc/tegra: fuse: Add APB DMA dependency for Tegra20
    bus: tegra-aconnect: Remove PM_CLK dependency
    dt-bindings: mediatek: add MT6765 power dt-bindings
    soc: mediatek: cmdq: delete not used define
    memory: tegra: Add support for the Tegra194 memory controller
    memory: tegra: Only include support for enabled SoCs
    memory: tegra: Support DVFS on Tegra186 and later
    ...

    Linus Torvalds
     

25 Jan, 2020

1 commit


23 Jan, 2020

1 commit

  • The optee driver uses specific page table types to verify if a memory
    region is normal. These types are not defined in nommu systems. Trying
    to compile the driver in these systems results in a build error:

    linux/drivers/tee/optee/call.c: In function ‘is_normal_memory’:
    linux/drivers/tee/optee/call.c:533:26: error: ‘L_PTE_MT_MASK’ undeclared
    (first use in this function); did you mean ‘PREEMPT_MASK’?
    return (pgprot_val(p) & L_PTE_MT_MASK) == L_PTE_MT_WRITEALLOC;
    ^~~~~~~~~~~~~
    PREEMPT_MASK
    linux/drivers/tee/optee/call.c:533:26: note: each undeclared identifier is
    reported only once for each function it appears in
    linux/drivers/tee/optee/call.c:533:44: error: ‘L_PTE_MT_WRITEALLOC’ undeclared
    (first use in this function)
    return (pgprot_val(p) & L_PTE_MT_MASK) == L_PTE_MT_WRITEALLOC;
    ^~~~~~~~~~~~~~~~~~~

    Make the optee driver depend on MMU to fix the compilation issue.

    Signed-off-by: Vincenzo Frascino
    [jw: update commit title]
    Signed-off-by: Jens Wiklander

    Vincenzo Frascino
     

03 Jan, 2020

2 commits

  • optee_shm_register() expected pages to be passed as an array of page
    pointers rather than as an array of contiguous pages. So fix that via
    correctly passing pages as per expectation.

    Fixes: a249dd200d03 ("tee: optee: Fix dynamic shm pool allocations")
    Reported-by: Vincent Cao
    Signed-off-by: Sumit Garg
    Tested-by: Vincent Cao
    Signed-off-by: Jens Wiklander

    Sumit Garg
     
  • To simplify adding ACPI support to the OP-TEE driver, model it as
    a platform driver. This will permit us to use the generic device
    property layer for parsing additional properties, regardless of
    whether DT or ACPI is being used.

    Note that this change will result in the OP-TEE driver to be loaded
    automatically on systems that advertise the presence of OP-TEE via
    the device tree.

    Acked-by: Sumit Garg
    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Jens Wiklander

    Ard Biesheuvel
     

15 Nov, 2019

2 commits

  • Prior to this patch in optee_probe() when optee_enumerate_devices() was
    called the struct optee was fully initialized. If
    optee_enumerate_devices() returns an error optee_probe() is supposed to
    clean up and free the struct optee completely, but will at this late
    stage need to call optee_remove() instead. This isn't done and thus
    freeing the struct optee prematurely.

    With this patch the call to optee_enumerate_devices() is done after
    optee_probe() has returned successfully and in case
    optee_enumerate_devices() fails everything is cleaned up with a call to
    optee_remove().

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

    Jens Wiklander
     
  • In case of dynamic shared memory pool, kernel memory allocated using
    dmabuf_mgr pool needs to be registered with OP-TEE prior to its usage
    during optee_open_session() or optee_invoke_func().

    So fix dmabuf_mgr pool allocations via an additional call to
    optee_shm_register().

    Also, allow kernel pages to be registered as shared memory with OP-TEE.

    Fixes: 9733b072a12a ("optee: allow to work without static shared memory")
    Signed-off-by: Sumit Garg
    Signed-off-by: Jens Wiklander

    Sumit Garg
     

09 Jul, 2019

1 commit

  • If the kernel is compiled with CONFIG_PREEMPT_VOLUNTARY and OP-TEE is
    executing a long running workload, the following errors are raised:

    [ 1705.971228] rcu: INFO: rcu_sched detected stalls on CPUs/tasks:
    [ 1705.977195] rcu: (detected by 0, t=2102 jiffies, g=51977, q=3)
    [ 1705.983152] rcu: All QSes seen, last rcu_sched kthread activity 2102 (140596-138494), jiffies_till_next_fqs=1, root ->qsmask 0x0
    [ 1705.994729] optee-xtest R running task 0 169 157 0x00000002

    While OP-TEE is returning regularly to the kernel due to timer
    interrupts, the OPTEE_SMC_FUNC_FOREIGN_INTR case does not contain an
    explicit rescheduling point. Add a might_sleep() to the RPC request case
    to ensure that the kernel can reschedule another task if OP-TEE requests
    RPC handling.

    Signed-off-by: Rouven Czerwinski
    Signed-off-by: Jens Wiklander

    Rouven Czerwinski
     

05 Jun, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this software is licensed under the terms of the gnu general public
    license version 2 as published by the free software foundation and
    may be copied distributed and modified under those terms this
    program is distributed in the hope that it will be useful but
    without any warranty without even the implied warranty of
    merchantability or fitness for a particular purpose see the gnu
    general public license for more details

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 285 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Alexios Zavras
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190529141900.642774971@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

21 May, 2019

1 commit


29 Apr, 2019

1 commit


17 Apr, 2019

1 commit


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

2 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 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

1 commit

  • 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
     

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

2 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
     
  • 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

1 commit


20 Jun, 2018

1 commit


19 Jun, 2018

1 commit