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

Assign non-sec DDR configuration from DT #1623

Merged
merged 2 commits into from
Jun 22, 2017

Conversation

jenswi-linaro
Copy link
Contributor

This should take care of the problem with unexpected non-sec addresses from normal world in for instance #1232 by updating the non-sec DDR config from DT instead of using hard coded value on QEMU.

@lorc please confirm

Copy link
Contributor

@lorc lorc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a minor comments, but overall it is fine

  • second patch can be split into number of smaller ones. For example, get_dt_val_and_advance() can be introduced in separate patch.
  • empty lines are missing in indicated locates

Anyways:
Reviewed-by: Volodymyr Babchuk <vlad.babchuk@gmail.com>


DMSG("No SHM configured");
return -1;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: empty line is not needed.

offs = fdt_subnode_offset(fdt, 0, "memory");
if (offs < 0)
return NULL;
prop = fdt_getprop(fdt, offs, "reg", &addr_size);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: add empty line before prop =

prop = fdt_getprop(fdt, offs, "reg", &addr_size);
if (!prop)
return NULL;
prop_len = addr_size;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: minor: add empty line before prop_len =

addr_size = fdt_address_cells(fdt, offs);
if (addr_size < 0)
return NULL;
len_size = fdt_size_cells(fdt, offs);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: minor: add empty line before len_size =

@jenswi-linaro
Copy link
Contributor Author

Added/removed newlines as commented.

* non-secure memory is used for NSEC_SHM.
*/
carve_out_phys_mem(&m, &num_elems, map->pa, map->size);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this loop could also check that the discovered SHM does not intersect any of the 'secure' memory areas.


while (!core_mmap_is_end_of_table(map)) {
if (map->type == MEM_AREA_NSEC_SHM ||
map->type == MEM_AREA_SDP_MEM) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SDP memory is listed in the static_memory_mapping array: actually these areas are not default (statically) mapped in the core. You must parse the array __start/end_phys_nsec_ddr_section.


while (true) {
if (n >= *nelems) {
DMSG("Can't carve out %#" PRIxPA " size %#zx",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: this sound like an error trace. Suggest "No need to carve out ..."

return;
}
if (core_is_buffer_inside(pa, size, m[n].addr, m[n].size))
break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add if (core_is_buffer_intersect(...)) panic();

Copy link
Contributor Author

@jenswi-linaro jenswi-linaro Jun 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or perhaps even better, only carve out the part that intersects?
Edit: Hmm, that turned out to be a bit tricky and shouldn't happen anyway so I guess a panic() is OK.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, could be fine. But drawback is that linux world may/will later try to register a SHM in the reject area and will get an late error at runtime whereas optee could warn at init of this non conformance.

@jenswi-linaro
Copy link
Contributor Author

Update

1 similar comment
@jenswi-linaro
Copy link
Contributor Author

Update

@etienne-lms
Copy link
Contributor

Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>

@jenswi-linaro
Copy link
Contributor Author

Squashed, rebased, tags applied.

@jforissier
Copy link
Contributor

The checkpatch warnings can be fixed easily, I think (at least the first one).

@jenswi-linaro
Copy link
Contributor Author

Checkpatch fixes

@jforissier
Copy link
Contributor

checkpatch fixed indeed

Plat-vexpress uses register_nsec_ddr() to define the non-secure DDR
memory.

Reviewed-by: Volodymyr Babchuk <vlad.babchuk@gmail.com>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Assigns non-secure DDR configuration from device tree if CFG_DT=y. Already
present DDR configuration from register_nsec_ddr() is overridden.

Reviewed-by: Volodymyr Babchuk <vlad.babchuk@gmail.com>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Tested-by: Jens Wiklander <jens.wiklander@linaro.org> (QEMU)
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
@jenswi-linaro
Copy link
Contributor Author

Rebased, checkpatch patch applied.

@jforissier
Copy link
Contributor

Thanks

@jforissier jforissier merged commit 490c50d into OP-TEE:master Jun 22, 2017
@jenswi-linaro jenswi-linaro deleted the dt_nsec_ddr branch June 22, 2017 21:09
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.

4 participants