Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update aeabi_divmod.c #2

Closed
wants to merge 5 commits into from
Closed

Update aeabi_divmod.c #2

wants to merge 5 commits into from

Conversation

hsibert
Copy link

@hsibert hsibert commented Jun 13, 2014

Corrected division_qr to work on unsigned ints, and simplified uint_div_qr accordingly
Note - this file is no longer ARM-specific.

Herve Sibert added 5 commits June 13, 2014 14:56
Corrected division_qr to work on unsigned ints, and simplified uint_div_qr accordingly
Note - this file is no longer ARM-specific.
Kernel coding style done
Right condition to stop the increment
Cleaned up the code (removed unnecessary tests and operations)
Forgot two spaces (krnl coding style)
@jenswi-linaro
Copy link
Contributor

Test OK on hardware.

@ghost ghost closed this in #7 Jun 26, 2014
jforissier referenced this pull request in jforissier/optee_os Sep 13, 2016
There is a race condition in the code that creates and deletes trusted
storage. If multiple threads invoke a multi-session TA to create and
delete different files (such as xtest 6016), the following can occur:

    Thread #1 (create file #1) |   Thread #2 (delete file #2)
                               |
                               |   remove("/TA_dir/file");
    mkdir("/TA_dir");          |
                               |   rmdir("/TA_dir");
    create("/TA_dir/file1");   |
      => ENOENT                |

Add a mutex to prevent this race condition.

Note: the bug is currently not triggered by xtest 1016 because the test
is run for RPMB FS only, and because directory operations are no-ops in
the RPMB implementation. The fix will be needed when enabling single-TA
concurrency with the REE and SQL backends.

Signed-off-by: Jerome Forissier <[email protected]>
jforissier referenced this pull request in jforissier/optee_os Sep 13, 2016
There is a race condition in the code that creates and deletes trusted
storage. If multiple threads invoke a multi-session TA to create and
delete different files (such as xtest 6016), the following can occur:

    Thread #1 (create file #1) |   Thread #2 (delete file #2)
                               |
                               |   unlink("/TA_dir/file2");
    mkdir("/TA_dir");          |
                               |   rmdir("/TA_dir");
    create("/TA_dir/file1");   |
      => ENOENT                |

Add a mutex to prevent this race condition.

Note: the bug is currently not triggered by xtest 1016 because the test
is run for RPMB FS only, and because directory operations are no-ops in
the RPMB implementation. The fix will be needed when enabling single-TA
concurrency with the REE and SQL backends.

Signed-off-by: Jerome Forissier <[email protected]>
jforissier referenced this pull request in jforissier/optee_os Aug 7, 2017
Address Etienne's comments (round #2).

Signed-off-by: Jerome Forissier <[email protected]>
jforissier referenced this pull request in jforissier/optee_os Aug 7, 2017
Address Etienne's comments (round #2).

Signed-off-by: Jerome Forissier <[email protected]>
jforissier referenced this pull request in jforissier/optee_os Aug 7, 2017
Address Etienne's comments (round #2).

Signed-off-by: Jerome Forissier <[email protected]>
jforissier referenced this pull request in jforissier/optee_os Aug 7, 2017
Address Etienne's comments (round #2)

Signed-off-by: Jerome Forissier <[email protected]>
jforissier referenced this pull request in jforissier/optee_os Aug 7, 2017
Address Etienne's comments (round #2).

Signed-off-by: Jerome Forissier <[email protected]>
@0xB0D 0xB0D mentioned this pull request Aug 30, 2018
jforissier added a commit that referenced this pull request Nov 8, 2018
This commit introduces an algorithm that may be used to detect improper
usage of locks at runtime. It can detect two kinds errors:

 1. A thread tries to release a lock it does not own,
 2. A thread tries to aquire a lock and the operation could *potentially*
    result in a deadlock.

The potential deadlock detection assumes that the code adheres to a strict
locking hierarchy, in other word, that there is a partial ordering on the
locks so that there can be no situation where circular waits can occur. To
put things simply, any two locks should be acquired in the same order in
the same thread. This addresses the following case:

  [Thread #1]  [Thread #2]

    lock(A)
                 lock(B)
    lock(B)
                 lock(A) <-- deadlock!
      ...

The algorithm builds the lock hierarchy dynamically and reports as soon as
a violation is detected.

The interface is made of two functions: lockdep_lock_acquire() and
lockdep_lock_release(), which are meant to be introduced in the
implementation of the actual lock objects. The "acquire" hook tells the
algorithm that a particular lock is about to be requested by a particular
thread, while the "release" hook is meant to be called before the lock is
actually released. If an error is detected, debugging information is sent
to the console, and panic() is called. The debugging information includes
the lock cycle that was detected (in the above example, {A, B}), as well
as the call stacks at the points where the locks were acquired.

The good thing with such an instrumentation of the locking code is that
there is no need to wait for an actual deadlock to occur in order to
detect potential problems. For instance, the timing of execution in the
above example could be different but the problem would still be detected:

  [Thread #1]  [Thread #2]

    lock(A)
    lock(B)
    unlock(B)
    unlock(A)
                 lock(B)
                 lock(A) <-- error!

A pseudo-TA is added for testing (pta/core_lockdep_tests.c).

This code is based on two sources:
- A presentation called "Dl-Check: dynamic potential deadlock detection
tool for Java programs" [1], although the somewhat complex MNR algorithm
for topological ordering of a DAG was not used;
- A depth-first search algorithm [2] was used instead.

Link: [1] https://www.slideshare.net/IosifItkin/tmpa2017-dlcheck-dynamic-potential-deadlock-detection-tool-for-java-programs
Link: [2] https://en.wikipedia.org/wiki/Topological_sorting#Depth-first_search
Signed-off-by: Jerome Forissier <[email protected]>
Reviewed-by: Joakim Bech <[email protected]>
Reviewed-by: Etienne Carriere <[email protected]>
Acked-by: Jens Wiklander <[email protected]>
clementfaure added a commit to clementfaure/optee_os that referenced this pull request Aug 2, 2019
Remove empty line in imx8m.h
Remove extra space in sub.mk
Replace "%x" with "%" PRIx32.

Signed-off-by: Clement Faure <[email protected]>
clementfaure added a commit to clementfaure/optee_os that referenced this pull request Aug 13, 2019
Signed-off-by: Clement Faure <[email protected]>
clementfaure added a commit to clementfaure/optee_os that referenced this pull request Nov 15, 2019
Use the newly defined UL macro.

Signed-off-by: Clement Faure <[email protected]>
clementfaure added a commit to clementfaure/optee_os that referenced this pull request Nov 15, 2019
Use the newly defined UL macro.

Signed-off-by: Clement Faure <[email protected]>
clementfaure added a commit to clementfaure/optee_os that referenced this pull request Feb 27, 2020
clementfaure added a commit to clementfaure/optee_os that referenced this pull request Feb 27, 2020
Minor fix rsassa.c

Signed-off-by: Clement Faure <[email protected]>
clementfaure added a commit to clementfaure/optee_os that referenced this pull request Mar 5, 2020
clementfaure added a commit to clementfaure/optee_os that referenced this pull request Mar 5, 2020
vingu-linaro pushed a commit to vingu-linaro/optee_os that referenced this pull request May 20, 2020
A squashed series of changes in stm32mp1 clock driver for
supporting SCMI server as a clock consumer. These changes
have not been upstream yet in OP-TEE OS. Below the details.

Signed-off-by: Etienne Carriere <[email protected]>

### Commit message OP-TEE#1
plat-stm32mp1: clock: remove oscillators and PLLs from shared resources

Oscillators, PLL1 and PLL2 are not resources allocated upon platform
configuration, these are always under secure world control. This change
removes them fro the list of the shared resources.

Since these resource are always secure, there is no need to look up
clock tree when a leaf clock is registered as secure to know which
parent clock(s) is/are secure. This removes functions from
shared_resources.c and stm32mp1_clk.c.

stm32mp_register_clock_parents_secure() can be removed and all its
private dependencies.

Signed-off-by: Etienne Carriere <[email protected]>

### Commit message OP-TEE#2
plat-stm32mp1: clock: fix mcu/axi parent clock

Correct MCU clock parent selector: MCU subsystem clock is derived
from clock  PLL3_P, not PLL3.

Correct AXI clock parent selector: AXI subsystem clock is derived
from clock  PLL2_P, not PLL2.

This change also renames MCU clock and AXI clock resources to
prevent confusion.

Signed-off-by: Etienne Carriere <[email protected]>

### Commit message OP-TEE#3
plat-stm32mp1: clock: allow tree lookup for several system clocks

Oscillators, PLLs and some system clocks can be related straight to
a parent clock. Prior this change were only oscillators and few
clocks supported by this look up. This changes adds PLLs and other
system clocks. This enables for flexible use of clock tree exploration
when computing a clock frequency value.

Signed-off-by: Etienne Carriere <[email protected]>

### Commit message OP-TEE#4
plat-stm32mp1: clock: handle always on clocks

Oscillators and PLLs are not gated on stm32mp_clk_enable/disable()
calls. This change allows function to blindly call clock gating function
on always on clocks. Gating these clock is out of the scope of this
change even if preferred for power consumption optimization.

Signed-off-by: Etienne Carriere <[email protected]>

### Commit message OP-TEE#5
plat-stm32mp1: clock: add rtc as gateable clock

Add clock RTC as a clock one can access through the
stm32_util.h API function stm32_clock_*().

Signed-off-by: Etienne Carriere <[email protected]>

### Commit message OP-TEE#6
plat-stm32mp1: clock: enable some secure clocks at init

With this change some system clock are enabled by core at
boot time and have a reference counter synchronized with
the clock hardware state.

Signed-off-by: Etienne Carriere <[email protected]>

### Commit message OP-TEE#7
plat-stm32mp1: factorize rtc clock gating bit position

For consistency, define macro RCC_BDCR_RTCCKEN_POS in stm32mp1_rcc.h
to factorize definition of the RTC clock gating resources.

Signed-off-by: Etienne Carriere <[email protected]>

### Commit message OP-TEE#8
plat-stm32mp1: add mdma secure clock

Add support for MDMA secure clock.

Signed-off-by: Etienne Carriere <[email protected]>

### Commit message OP-TEE#9
plat-stm32mp1: remove unused usb non-secure clock

Remove unused clocks USBO_CLK and USBPHY_K resources.

Signed-off-by: Etienne Carriere <[email protected]>

### Commit message OP-TEE#10
plat-stm32mp1: clock: secure and non-secure gateable clocks

Array stm32mp1_clk_gate[] defines the clock resources. This change
add a secure attribute to the clock: secure upon RCC[TZEN] (SEC),
secure upon RCC[TZEN] and RCC[MCKPROT] (MKP) or always accessible
from non-secure (N_S).

At init, lookup clock tree to ensure that parents of a secure clock
are registered a secure resources in the shared_resources.c driver.

Non-secure clock that OP-TEE expect to enable are enabled without
increase the clock refcount. For consistency, such clocks are not
disabled by core. Such clocks may be accessed by OP-TEE Core when
the non-secure world is not executing, for example at boot time
or could be when system is suspending/resuming.

Signed-off-by: Etienne Carriere <[email protected]>

### Commit message OP-TEE#11
plat-stm32mp1: clock: fixup parent clock ids

Use _UNKNOWN_ID macro rather than 0xff for clocks parent IDs
that do not relate to a gateable clock.

Fix parent clock ID _HSE_KER_DIV2 that relates to clock
CK_HSE_KER_DIV2, not CK_HSE.

Signed-off-by: Etienne Carriere <[email protected]>

### Commit message OP-TEE#12
plat-stm32mp1: clock: don't embed unused non-secure uart clock

Embed UART parent clock resource upon CFG_WITH_NSEC_UARTS=y.
This configuration switch was already used to embed or not
the non-secure UART clocks but not the resources used to
looks there ascendant clocks.

Signed-off-by: Etienne Carriere <[email protected]>

### Commit message OP-TEE#13
plat-stm32mp1: shared resources: get shared clock controller state

stm32mp_nsec_can_access_clock() reports whether a clock is assigned
to the secure world only, or when it can be manipulated by the
non-secure world.

Signed-off-by: Etienne Carriere <[email protected]>

### Commit message OP-TEE#14
plat-stm32mp1: shared resource: remove unused stm32mp_clock_is_*()

Remove unused functions stm32mp_clock_is_shareable(),
stm32mp_clock_is_shared() and stm32mp_clock_is_non_secure().

Signed-off-by: Etienne Carriere <[email protected]>
jforissier added a commit that referenced this pull request Aug 26, 2020
Tracing the log syscall is of very little value since it will generate
some output to the console anyways. Worse, it pollutes the TA output in
case of a panic or an abort. For example:

 o regression_4005.1 AE case 0 algo 0x40000710 line 2819
 F/TC:?? 0 trace_syscall:132 syscall #27 (syscall_cryp_obj_alloc)
 F/TC:?? 0 trace_syscall:132 syscall #15 (syscall_cryp_state_alloc)
 F/TC:?? 0 trace_syscall:132 syscall #27 (syscall_cryp_obj_alloc)
 F/TC:?? 0 trace_syscall:132 syscall #24 (syscall_cryp_obj_get_info)
 F/TC:?? 0 trace_syscall:132 syscall #30 (syscall_cryp_obj_populate)
 F/TC:?? 0 trace_syscall:132 syscall #24 (syscall_cryp_obj_get_info)
 F/TC:?? 0 trace_syscall:132 syscall #24 (syscall_cryp_obj_get_info)
 F/TC:?? 0 trace_syscall:132 syscall #29 (syscall_cryp_obj_reset)
 F/TC:?? 0 trace_syscall:132 syscall #24 (syscall_cryp_obj_get_info)
 F/TC:?? 0 trace_syscall:132 syscall #24 (syscall_cryp_obj_get_info)
 F/TC:?? 0 trace_syscall:132 syscall #31 (syscall_cryp_obj_copy)
 F/TC:?? 0 trace_syscall:132 syscall #24 (syscall_cryp_obj_get_info)
 F/TC:?? 0 trace_syscall:132 syscall #28 (syscall_cryp_obj_close)
 F/TC:?? 0 trace_syscall:132 syscall #34 (syscall_authenc_init)
 F/TC:?? 0 trace_syscall:132 syscall #2 (syscall_panic)
 E/TC:?? 0
 E/TC:?? 0 TA panicked with code 0xffff0006
 F/TC:?? 0 trace_syscall:132 syscall #1 (syscall_log)
 E/LD:  Status of TA cb3e5ba0-adf1-11e0-998b-0002a5d5c51b
 F/TC:?? 0 trace_syscall:132 syscall #1 (syscall_log)
 E/LD:   arch: aarch64
 F/TC:?? 0 trace_syscall:132 syscall #1 (syscall_log)
 E/LD:  region  0: va 0x40004000 pa 0x100062d000 size 0x002000 flags rw-s (ldelf)
 F/TC:?? 0 trace_syscall:132 syscall #1 (syscall_log)
 E/LD:  region  1: va 0x40006000 pa 0x100062f000 size 0x00d000 flags r-xs (ldelf)
 ...

Therefore, skip the trace if the syscall number it TEE_SCN_LOG.

Signed-off-by: Jerome Forissier <[email protected]>
Reviewed-by: Jens Wiklander <[email protected]>
brenzi pushed a commit to elias-vd/optee_os that referenced this pull request Feb 13, 2021
Tracing the log syscall is of very little value since it will generate
some output to the console anyways. Worse, it pollutes the TA output in
case of a panic or an abort. For example:

 o regression_4005.1 AE case 0 algo 0x40000710 line 2819
 F/TC:?? 0 trace_syscall:132 syscall OP-TEE#27 (syscall_cryp_obj_alloc)
 F/TC:?? 0 trace_syscall:132 syscall OP-TEE#15 (syscall_cryp_state_alloc)
 F/TC:?? 0 trace_syscall:132 syscall OP-TEE#27 (syscall_cryp_obj_alloc)
 F/TC:?? 0 trace_syscall:132 syscall OP-TEE#24 (syscall_cryp_obj_get_info)
 F/TC:?? 0 trace_syscall:132 syscall OP-TEE#30 (syscall_cryp_obj_populate)
 F/TC:?? 0 trace_syscall:132 syscall OP-TEE#24 (syscall_cryp_obj_get_info)
 F/TC:?? 0 trace_syscall:132 syscall OP-TEE#24 (syscall_cryp_obj_get_info)
 F/TC:?? 0 trace_syscall:132 syscall OP-TEE#29 (syscall_cryp_obj_reset)
 F/TC:?? 0 trace_syscall:132 syscall OP-TEE#24 (syscall_cryp_obj_get_info)
 F/TC:?? 0 trace_syscall:132 syscall OP-TEE#24 (syscall_cryp_obj_get_info)
 F/TC:?? 0 trace_syscall:132 syscall OP-TEE#31 (syscall_cryp_obj_copy)
 F/TC:?? 0 trace_syscall:132 syscall OP-TEE#24 (syscall_cryp_obj_get_info)
 F/TC:?? 0 trace_syscall:132 syscall OP-TEE#28 (syscall_cryp_obj_close)
 F/TC:?? 0 trace_syscall:132 syscall OP-TEE#34 (syscall_authenc_init)
 F/TC:?? 0 trace_syscall:132 syscall OP-TEE#2 (syscall_panic)
 E/TC:?? 0
 E/TC:?? 0 TA panicked with code 0xffff0006
 F/TC:?? 0 trace_syscall:132 syscall OP-TEE#1 (syscall_log)
 E/LD:  Status of TA cb3e5ba0-adf1-11e0-998b-0002a5d5c51b
 F/TC:?? 0 trace_syscall:132 syscall OP-TEE#1 (syscall_log)
 E/LD:   arch: aarch64
 F/TC:?? 0 trace_syscall:132 syscall OP-TEE#1 (syscall_log)
 E/LD:  region  0: va 0x40004000 pa 0x100062d000 size 0x002000 flags rw-s (ldelf)
 F/TC:?? 0 trace_syscall:132 syscall OP-TEE#1 (syscall_log)
 E/LD:  region  1: va 0x40006000 pa 0x100062f000 size 0x00d000 flags r-xs (ldelf)
 ...

Therefore, skip the trace if the syscall number it TEE_SCN_LOG.

Signed-off-by: Jerome Forissier <[email protected]>
Reviewed-by: Jens Wiklander <[email protected]>
jenswi-linaro added a commit that referenced this pull request May 27, 2021
Adds checks in e32_relocate() that sym_tab is assigned a symbol table
before using it.

This fixes coverity scan:
CID 1501826 (#1 of 3): Explicit null dereferenced (FORWARD_NULL)
CID 1501826 (#2 of 3): Explicit null dereferenced (FORWARD_NULL)
CID 1501826 (#3 of 3): Explicit null dereferenced (FORWARD_NULL)

Signed-off-by: Jens Wiklander <[email protected]>
a-rybakov added a commit to a-rybakov/optee_os-1 that referenced this pull request Jun 3, 2021
Fixed description in core_memprot.h
Fixed range in tests/invoke.c
Removed line in imx_uart.c

Signed-off-by: Anton Rybakov <[email protected]>
jforissier pushed a commit that referenced this pull request Jun 7, 2021
Adds checks in e32_relocate() that sym_tab is assigned a symbol table
before using it.

This fixes coverity scan:
CID 1501826 (#1 of 3): Explicit null dereferenced (FORWARD_NULL)
CID 1501826 (#2 of 3): Explicit null dereferenced (FORWARD_NULL)
CID 1501826 (#3 of 3): Explicit null dereferenced (FORWARD_NULL)

Acked-by: Jerome Forissier <[email protected]>
Signed-off-by: Jens Wiklander <[email protected]>
MrCry0 added a commit to MrCry0/optee_os that referenced this pull request Oct 2, 2022
Signed-off-by: Oleksandr Suvorov <[email protected]>
MrCry0 added a commit to MrCry0/optee_os that referenced this pull request Oct 2, 2022
Signed-off-by: Oleksandr Suvorov <[email protected]>
ricardosalveti pushed a commit to ricardosalveti/optee_os that referenced this pull request Apr 3, 2023
Initialize return value to 0 to suppress the following Coverity issue:

CID 21684940 (OP-TEE#2 of 2): Uninitialized scalar variable (UNINIT)
15. uninit_use: Using uninitialized value ret.

Signed-off-by: Clement Faure <[email protected]>
(cherry picked from commit b3dadf9)
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants