Skip to content

Commit 169cd0f

Browse files
Quentin PerretMarc Zyngier
authored andcommitted
KVM: arm64: Don't unnecessarily map host kernel sections at EL2
We no longer need to map the host's '.rodata' and '.bss' sections in the stage-1 page-table of the pKVM hypervisor at EL2, so remove those mappings and avoid creating any future dependencies at EL2 on host-controlled data structures. Tested-by: Vincent Donnefort <[email protected]> Signed-off-by: Quentin Perret <[email protected]> Signed-off-by: Will Deacon <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 27eb26b commit 169cd0f

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

arch/arm64/kernel/image-vars.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,6 @@ KVM_NVHE_ALIAS_HYP(__memcpy, __pi_memcpy);
102102
KVM_NVHE_ALIAS_HYP(__memset, __pi_memset);
103103
#endif
104104

105-
/* Kernel memory sections */
106-
KVM_NVHE_ALIAS(__start_rodata);
107-
KVM_NVHE_ALIAS(__end_rodata);
108-
KVM_NVHE_ALIAS(__bss_start);
109-
KVM_NVHE_ALIAS(__bss_stop);
110-
111105
/* Hyp memory sections */
112106
KVM_NVHE_ALIAS(__hyp_idmap_text_start);
113107
KVM_NVHE_ALIAS(__hyp_idmap_text_end);

arch/arm64/kvm/hyp/nvhe/setup.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,23 +144,15 @@ static int recreate_hyp_mappings(phys_addr_t phys, unsigned long size,
144144
}
145145

146146
/*
147-
* Map the host's .bss and .rodata sections RO in the hypervisor, but
148-
* transfer the ownership from the host to the hypervisor itself to
149-
* make sure it can't be donated or shared with another entity.
147+
* Map the host sections RO in the hypervisor, but transfer the
148+
* ownership from the host to the hypervisor itself to make sure they
149+
* can't be donated or shared with another entity.
150150
*
151151
* The ownership transition requires matching changes in the host
152152
* stage-2. This will be done later (see finalize_host_mappings()) once
153153
* the hyp_vmemmap is addressable.
154154
*/
155155
prot = pkvm_mkstate(PAGE_HYP_RO, PKVM_PAGE_SHARED_OWNED);
156-
ret = pkvm_create_mappings(__start_rodata, __end_rodata, prot);
157-
if (ret)
158-
return ret;
159-
160-
ret = pkvm_create_mappings(__hyp_bss_end, __bss_stop, prot);
161-
if (ret)
162-
return ret;
163-
164156
ret = pkvm_create_mappings(&kvm_vgic_global_state,
165157
&kvm_vgic_global_state + 1, prot);
166158
if (ret)

0 commit comments

Comments
 (0)