Skip to content

Commit f3b825d

Browse files
lifeixlijinxia
authored andcommitted
hv: trusty: use ept_mr_add to add memory region
Use ept_mr_add to add memory region EPT mapping for trusty. Signed-off-by: Li, Fei1 <fei1.li@intel.com>
1 parent 4bb8456 commit f3b825d

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

hypervisor/arch/x86/trusty.c

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,13 @@ static void create_secure_world_ept(struct vm *vm, uint64_t gpa_orig,
6262
{
6363
uint64_t nworld_pml4e = 0UL;
6464
uint64_t sworld_pml4e = 0UL;
65-
struct mem_map_params map_params;
6665
uint64_t gpa = 0UL;
6766
uint64_t hpa = gpa2hpa(vm, gpa_orig);
68-
uint64_t table_present = (IA32E_EPT_R_BIT |
69-
IA32E_EPT_W_BIT |
70-
IA32E_EPT_X_BIT);
67+
uint64_t table_present = EPT_RWX;
7168
uint64_t pdpte = 0, *dest_pdpte_p = NULL, *src_pdpte_p = NULL;
7269
void *sub_table_addr = NULL, *pml4_base = NULL;
7370
struct vm *vm0 = get_vm_from_vmid(0U);
7471
uint16_t i;
75-
struct vcpu *vcpu;
7672

7773
if (vm0 == NULL) {
7874
pr_err("Parse vm0 context failed.");
@@ -112,7 +108,6 @@ static void create_secure_world_ept(struct vm *vm, uint64_t gpa_orig,
112108
sworld_pml4e = HVA2HPA(sub_table_addr) | table_present;
113109
mem_write64(pml4_base, sworld_pml4e);
114110

115-
116111
nworld_pml4e = mem_read64(vm->arch_vm.nworld_eptp);
117112

118113
/*
@@ -131,18 +126,11 @@ static void create_secure_world_ept(struct vm *vm, uint64_t gpa_orig,
131126
dest_pdpte_p++;
132127
}
133128

134-
/* Map gpa_rebased~gpa_rebased+size to secure ept mapping
129+
/* Map [gpa_rebased, gpa_rebased + size) to secure ept mapping
135130
* TODO: not create inverted page tables for trusty memory
136131
*/
137-
map_params.page_table_type = PTT_EPT;
138-
map_params.pml4_inverted = vm->arch_vm.m2p;
139-
map_params.pml4_base = pml4_base;
140-
map_mem(&map_params, (void *)hpa,
141-
(void *)gpa_rebased, size,
142-
(IA32E_EPT_R_BIT |
143-
IA32E_EPT_W_BIT |
144-
IA32E_EPT_X_BIT |
145-
IA32E_EPT_WB));
132+
ept_mr_add(vm, (uint64_t *)vm->arch_vm.sworld_eptp,
133+
hpa, gpa_rebased, size, EPT_RWX | EPT_WB);
146134

147135
/* Get the gpa address in SOS */
148136
gpa = hpa2gpa(vm0, hpa);
@@ -156,10 +144,6 @@ static void create_secure_world_ept(struct vm *vm, uint64_t gpa_orig,
156144
vm->sworld_control.sworld_memory.base_gpa_in_uos = gpa_orig;
157145
vm->sworld_control.sworld_memory.base_hpa = hpa;
158146
vm->sworld_control.sworld_memory.length = size;
159-
160-
foreach_vcpu(i, vm, vcpu) {
161-
vcpu_make_request(vcpu, ACRN_REQUEST_EPT_FLUSH);
162-
}
163147
}
164148

165149
void destroy_secure_world(struct vm *vm, bool need_clr_mem)

0 commit comments

Comments
 (0)