Skip to content

Commit

Permalink
Merge changes Idb78cba3,Iee5cbea5,I46a7ad12 into integration
Browse files Browse the repository at this point in the history
* changes:
  fix(rmm): add 'ipa_bound' check
  fix(rmm): add 'level_bound' failure condition
  fix(rmm): fix static_checks warnings and errors
  • Loading branch information
soby-mathew authored and TrustedFirmware Code Review committed Sep 22, 2023
2 parents fa5dee3 + 868a651 commit 969e576
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 26 deletions.
2 changes: 1 addition & 1 deletion docs/about/change-log.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Build/Testing improvements
attestation initialization flow. Also a sample minimal Realm create, run and
destroy sequence is added to showcase the RMI calls involved.

- Further improvements to the the unit test framework :
- Further improvements to the unit test framework :

* Restore the sysreg state between test runs so each test gets a known
sysreg state.
Expand Down
4 changes: 2 additions & 2 deletions lib/attestation/include/attestation_token.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ attest_realm_token_sign(struct attest_token_encode_ctx *me,
* Combine realm token and platform token to top-level cca token
*
* attest_token_buf Pointer to the buffer where the token will be
* written.
* written.
* attest_token_buf_size Size of the buffer where the token will be
* written.
* written.
* realm_token_buf Pointer to the realm token.
* realm_token_len Length of the realm token.
*
Expand Down
4 changes: 2 additions & 2 deletions lib/attestation/src/attestation_rnd.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ static int get_random_seed(unsigned char *output, size_t len)
* For details see `MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG` in mbedtls/mbedtls_config.h
*/
psa_status_t mbedtls_psa_external_get_random(
mbedtls_psa_external_random_context_t *context,
uint8_t *output, size_t output_size, size_t *output_length)
mbedtls_psa_external_random_context_t *context,
uint8_t *output, size_t output_size, size_t *output_length)
{
int ret;
unsigned int cpu_id = my_cpuid();
Expand Down
1 change: 1 addition & 0 deletions lib/measurement/src/measurement.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ static void measurement_print(unsigned char *measurement,
const enum hash_algo algorithm)
{
unsigned int size = 0U;

assert(measurement != NULL);

VERBOSE("Measurement ");
Expand Down
3 changes: 0 additions & 3 deletions lib/realm/src/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,6 @@ void buffer_unmap(void *buf)
buffer_arch_unmap(buf);
}

bool memcpy_ns_read(void *dest, const void *ns_src, size_t size);
bool memcpy_ns_write(void *ns_dest, const void *src, size_t size);

/*
* Map a Non secure granule @g into the slot @slot and read data from
* this granule to @dest. Unmap the granule once the read is done.
Expand Down
2 changes: 2 additions & 0 deletions lib/realm/src/include/buffer_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@

struct xlat_llt_info *get_cached_llt_info(void);
uintptr_t slot_to_va(enum buffer_slot slot);
bool memcpy_ns_read(void *dest, const void *ns_src, size_t size);
bool memcpy_ns_write(void *ns_dest, const void *src, size_t size);
14 changes: 6 additions & 8 deletions lib/xlat/src/xlat_tables_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,13 @@ static action_t xlat_tables_map_region_action(const struct xlat_mmap_region *mm,
* overwrite.
*/
return ACTION_NONE;
} else {
if (desc_type != INVALID_DESC) {
ERROR("%s (%u): Expected invalid descriptor\n",
__func__, __LINE__);
panic();
}
return ACTION_WRITE_BLOCK_ENTRY;
}

if (desc_type != INVALID_DESC) {
ERROR("%s (%u): Expected invalid descriptor\n",
__func__, __LINE__);
panic();
}
return ACTION_WRITE_BLOCK_ENTRY;
} else {

/*
Expand Down
2 changes: 1 addition & 1 deletion plat/fvp/src/include/fvp_dram.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#ifndef FVP_DRAM_H
#define FVP_DRAM_H

#include <rmm_el3_ifc.h>
#include <stddef.h>
#include <stdint.h>
#include <rmm_el3_ifc.h>

/* Maximum number of DRAM banks supported */
#define MAX_DRAM_NUM_BANKS 2UL
Expand Down
4 changes: 0 additions & 4 deletions plat/host/host_test/src/test_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
#include <utest_exit.h>
#include <xlat_tables.h>

/* Implemented in init.c and needed here */
void rmm_warmboot_main(void);
void rmm_main(void);

/*
* Define and set the Boot Interface arguments.
*/
Expand Down
4 changes: 4 additions & 0 deletions plat/host/host_test/src/test_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@
*/
uintptr_t get_cb(enum cb_ids id);

/* Implemented in init.c and needed in test_helpers.c */
void rmm_warmboot_main(void);
void rmm_main(void);

#endif /* TEST_PRIVATE_H */
1 change: 0 additions & 1 deletion plat/host/host_test/src/utest_exit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ extern "C" {
{
TEST_EXIT;
}

}
16 changes: 14 additions & 2 deletions runtime/rmi/rtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,10 @@ unsigned long smc_rtt_map_unprotected(unsigned long rd_addr,
long level = (long)ulevel;
struct smc_result res;

if ((level < RTT_MIN_BLOCK_LEVEL) || (level > RTT_PAGE_LEVEL)) {
return RMI_ERROR_INPUT;
}

if (!host_ns_s2tte_is_valid(s2tte, level)) {
return RMI_ERROR_INPUT;
}
Expand All @@ -722,7 +726,14 @@ void smc_rtt_unmap_unprotected(unsigned long rd_addr,
unsigned long ulevel,
struct smc_result *res)
{
return map_unmap_ns(rd_addr, map_addr, (long)ulevel, 0UL, UNMAP_NS, res);
long level = (long)ulevel;

if ((level < RTT_MIN_BLOCK_LEVEL) || (level > RTT_PAGE_LEVEL)) {
res->x[0] = RMI_ERROR_INPUT;
return;
}

map_unmap_ns(rd_addr, map_addr, level, 0UL, UNMAP_NS, res);
}

void smc_rtt_read_entry(unsigned long rd_addr,
Expand Down Expand Up @@ -1011,7 +1022,8 @@ void smc_data_destroy(unsigned long rd_addr,
rd = granule_map(g_rd, SLOT_RD);
assert(rd != NULL);

if (!validate_map_addr(map_addr, RTT_PAGE_LEVEL, rd)) {
if (!addr_in_par(rd, map_addr) ||
!validate_map_addr(map_addr, RTT_PAGE_LEVEL, rd)) {
buffer_unmap(rd);
granule_unlock(g_rd);
res->x[0] = RMI_ERROR_INPUT;
Expand Down
2 changes: 0 additions & 2 deletions runtime/rmi/run.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,11 @@ unsigned long smc_rec_enter(unsigned long rec_addr,
case REALM_STATE_NEW:
ret = pack_return_code(RMI_ERROR_REALM, 0U);
goto out_unmap_buffers;
break;
case REALM_STATE_ACTIVE:
break;
case REALM_STATE_SYSTEM_OFF:
ret = pack_return_code(RMI_ERROR_REALM, 1U);
goto out_unmap_buffers;
break;
default:
assert(false);
break;
Expand Down
1 change: 1 addition & 0 deletions runtime/rsi/psci.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ static unsigned long rd_map_read_rec_count(struct granule *g_rd)
{
unsigned long rec_count;
struct rd *rd = granule_map(g_rd, SLOT_RD);

assert(rd != NULL);

rec_count = get_rd_rec_count_unlocked(rd);
Expand Down

0 comments on commit 969e576

Please sign in to comment.