1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00

KVM: arm64: Set up .hyp.rodata ELF section

We will need to recognize pointers in .rodata specific to hyp, so
establish a .hyp.rodata ELF section. Merge it with the existing
.hyp.data..ro_after_init as they are treated the same at runtime.

Signed-off-by: David Brazdil <dbrazdil@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20210105180541.65031-3-dbrazdil@google.com
This commit is contained in:
David Brazdil 2021-01-05 18:05:35 +00:00 committed by Marc Zyngier
parent eceaf38f52
commit 16174eea2e
4 changed files with 11 additions and 9 deletions

View file

@ -11,7 +11,7 @@ extern char __alt_instructions[], __alt_instructions_end[];
extern char __hibernate_exit_text_start[], __hibernate_exit_text_end[]; extern char __hibernate_exit_text_start[], __hibernate_exit_text_end[];
extern char __hyp_idmap_text_start[], __hyp_idmap_text_end[]; extern char __hyp_idmap_text_start[], __hyp_idmap_text_end[];
extern char __hyp_text_start[], __hyp_text_end[]; extern char __hyp_text_start[], __hyp_text_end[];
extern char __hyp_data_ro_after_init_start[], __hyp_data_ro_after_init_end[]; extern char __hyp_rodata_start[], __hyp_rodata_end[];
extern char __idmap_text_start[], __idmap_text_end[]; extern char __idmap_text_start[], __idmap_text_end[];
extern char __initdata_begin[], __initdata_end[]; extern char __initdata_begin[], __initdata_end[];
extern char __inittext_begin[], __inittext_end[]; extern char __inittext_begin[], __inittext_end[];

View file

@ -31,10 +31,11 @@ jiffies = jiffies_64;
__stop___kvm_ex_table = .; __stop___kvm_ex_table = .;
#define HYPERVISOR_DATA_SECTIONS \ #define HYPERVISOR_DATA_SECTIONS \
HYP_SECTION_NAME(.data..ro_after_init) : { \ HYP_SECTION_NAME(.rodata) : { \
__hyp_data_ro_after_init_start = .; \ __hyp_rodata_start = .; \
*(HYP_SECTION_NAME(.data..ro_after_init)) \ *(HYP_SECTION_NAME(.data..ro_after_init)) \
__hyp_data_ro_after_init_end = .; \ *(HYP_SECTION_NAME(.rodata)) \
__hyp_rodata_end = .; \
} }
#define HYPERVISOR_PERCPU_SECTION \ #define HYPERVISOR_PERCPU_SECTION \

View file

@ -1749,11 +1749,10 @@ static int init_hyp_mode(void)
goto out_err; goto out_err;
} }
err = create_hyp_mappings(kvm_ksym_ref(__hyp_data_ro_after_init_start), err = create_hyp_mappings(kvm_ksym_ref(__hyp_rodata_start),
kvm_ksym_ref(__hyp_data_ro_after_init_end), kvm_ksym_ref(__hyp_rodata_end), PAGE_HYP_RO);
PAGE_HYP_RO);
if (err) { if (err) {
kvm_err("Cannot map .hyp.data..ro_after_init section\n"); kvm_err("Cannot map .hyp.rodata section\n");
goto out_err; goto out_err;
} }

View file

@ -14,6 +14,9 @@
SECTIONS { SECTIONS {
HYP_SECTION(.idmap.text) HYP_SECTION(.idmap.text)
HYP_SECTION(.text) HYP_SECTION(.text)
HYP_SECTION(.data..ro_after_init)
HYP_SECTION(.rodata)
/* /*
* .hyp..data..percpu needs to be page aligned to maintain the same * .hyp..data..percpu needs to be page aligned to maintain the same
* alignment for when linking into vmlinux. * alignment for when linking into vmlinux.
@ -22,5 +25,4 @@ SECTIONS {
HYP_SECTION_NAME(.data..percpu) : { HYP_SECTION_NAME(.data..percpu) : {
PERCPU_INPUT(L1_CACHE_BYTES) PERCPU_INPUT(L1_CACHE_BYTES)
} }
HYP_SECTION(.data..ro_after_init)
} }