blob: 1808295d4b46dc0821d9e88f4897a6ac5f8f753f [file] [log] [blame]
Patrick Williams8dd68482022-10-04 07:57:18 -05001From 02c8afc4f7315b4e12098ffeb8bd5e64e4891e78 Mon Sep 17 00:00:00 2001
2From: Davidson K <davidson.kumaresan@arm.com>
3Date: Thu, 7 Oct 2021 12:20:08 +0530
4Subject: [PATCH] feat(vhe): set STAGE1_NS while mapping memory from NWd to SWd
5
6If the memory is shared by a VM executing in non secure world, attribute
7MM_MODE_NS had to be set while mapping that in a S-EL0 SP executing in
8secure world. It will not be needed for a S-EL1 SP since the NS bit is
9available only for the stage 1 translations and the stage 1 translations
10for a S-EL1 SP will be handled by a trusted OS running in S-EL1.
11
12Signed-off-by: Davidson K <davidson.kumaresan@arm.com>
13Change-Id: I074e2d5a50a659bd3c097d797c4901f08d210b1b
14Upstream-Status: Pending [Not submitted to upstream yet]
15---
16 src/ffa_memory.c | 12 ++++++++++++
17 1 file changed, 12 insertions(+)
18
19diff --git a/src/ffa_memory.c b/src/ffa_memory.c
20index 048cca9..8910cc7 100644
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,
42--
432.34.1
44