Patrick Williams | 7784c42 | 2022-11-17 07:29:11 -0600 | [diff] [blame^] | 1 | From 4b59905d2fec01cc17038b1c167b4e57e7835adf Mon Sep 17 00:00:00 2001 |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame] | 2 | From: Davidson K <davidson.kumaresan@arm.com> |
| 3 | Date: Thu, 7 Oct 2021 12:20:08 +0530 |
| 4 | Subject: [PATCH] feat(vhe): set STAGE1_NS while mapping memory from NWd to SWd |
| 5 | |
| 6 | If the memory is shared by a VM executing in non secure world, attribute |
| 7 | MM_MODE_NS had to be set while mapping that in a S-EL0 SP executing in |
| 8 | secure world. It will not be needed for a S-EL1 SP since the NS bit is |
| 9 | available only for the stage 1 translations and the stage 1 translations |
| 10 | for a S-EL1 SP will be handled by a trusted OS running in S-EL1. |
| 11 | |
| 12 | Signed-off-by: Davidson K <davidson.kumaresan@arm.com> |
| 13 | Change-Id: I074e2d5a50a659bd3c097d797c4901f08d210b1b |
| 14 | Upstream-Status: Pending [Not submitted to upstream yet] |
| 15 | --- |
| 16 | src/ffa_memory.c | 12 ++++++++++++ |
| 17 | 1 file changed, 12 insertions(+) |
| 18 | |
| 19 | diff --git a/src/ffa_memory.c b/src/ffa_memory.c |
Patrick Williams | 7784c42 | 2022-11-17 07:29:11 -0600 | [diff] [blame^] | 20 | index 048cca9c..8910cc79 100644 |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame] | 21 | --- a/src/ffa_memory.c |
| 22 | +++ b/src/ffa_memory.c |
| 23 | @@ -2483,6 +2483,18 @@ struct ffa_value ffa_memory_retrieve(struct vm_locked to_locked, |
| 24 | |
| 25 | memory_to_attributes = ffa_memory_permissions_to_mode( |
| 26 | permissions, share_state->sender_orig_mode); |
| 27 | + |
| 28 | + if (to_locked.vm->el0_partition) { |
| 29 | + /* |
| 30 | + * Get extra mapping attributes for the given VM ID. |
| 31 | + * If the memory is shared by a VM executing in non secure |
| 32 | + * world, attribute MM_MODE_NS had to be set while mapping |
| 33 | + * that in a SP executing in secure world. |
| 34 | + */ |
| 35 | + memory_to_attributes |= arch_mm_extra_attributes_from_vm( |
| 36 | + retrieve_request->sender); |
| 37 | + } |
| 38 | + |
| 39 | ret = ffa_retrieve_check_update( |
| 40 | to_locked, memory_region->sender, share_state->fragments, |
| 41 | share_state->fragment_constituent_counts, |