KVM: arm64: Stub exports in nvhe code
Subsystems (3)
cover KVM: arm64: Stub exports in nvhe code
Hi all,
In the context of the currently ongoing work to remove the host kernel from the TCB under KVM/arm64, I have been trying to wrap the host kernel with a stage 2 page-table -- see [1].
Using this infrastructure, I attempted to unmap the .hyp. sections from the host stage 2 as it really shouldn't need to access them. But by doing so, I realized quickly the module loader was getting very confused by the usage of EXPORT_SYMBOL() macros in library functions that have been pulled into the EL2 object, and that we end up linking modules against the EL2 copy of e.g. memset. And so, this series essentially tries to fix this.
- Patch 01 changes asm-generic/export.h to ensure we respect __DISABLE_EXPORTS even for asm exports;
- and patch 02 makes use of it for all of the nVHE EL2 code.
This was tested on aml-s905x-cc, which now successfully loads kernel modules with .hyp.text unmapped from the host.
Thanks,
Quentin
[1] https://lore.kernel.org/kvmarm/[email protected]/
Quentin Perret (2):
asm-generic: export: Stub EXPORT_SYMBOL with __DISABLE_EXPORTS
KVM: arm64: Stub EXPORT_SYMBOL for nVHE EL2 code
arch/arm64/kvm/hyp/nvhe/Makefile | 4 ++-- include/asm-generic/export.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
Signature · 6 lines
2.30.0.365.g02bc693789-goog _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PATCH 1/2 asm-generic: export: Stub EXPORT_SYMBOL with __DISABLE_EXPORTS
It is currently possible to stub EXPORT_SYMBOL() macros in C code using __DISABLE_EXPORTS, which is necessary to run in constrained environments such as the EFI stub or the decompressor. But this currently doesn't apply to exports from assembly, which can lead to somewhat confusing situations.
Consolidate the __DISABLE_EXPORTS infrastructure by checking it from asm-generic/export.h as well.
--- include/asm-generic/export.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/asm-generic/export.h +1 -1
@@ -33,7 +33,7 @@*/ .macro ___EXPORT_SYMBOL name,val,sec -#ifdef CONFIG_MODULES +#if defined(CONFIG_MODULES ) && !defined(__DISABLE_EXPORTS) .section ___ksymtab\sec+\name,"a" .balign KSYM_ALIGN __ksymtab_\name:
Signature · 6 lines
2.30.0.365.g02bc693789-goog _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH 1/2] asm-generic: export: Stub EXPORT_SYMBOL with __DISABLE_EXPORTS
Quoted 6 lines · Quentin Perret
It is currently possible to stub
EXPORT_SYMBOL()macros in C code using__DISABLE_EXPORTS, which is necessary to run in constrained environments such as the EFI stub or the decompressor. But this currently doesn't apply to exports from assembly, which can lead to somewhat confusing situations.
Quoted 7 lines
Consolidate the
__DISABLE_EXPORTSinfrastructure by checking it fromasm-generic/export.has well.Signed-off-by Quentin Perret <[email protected]>--- include/asm-generic/export.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Will
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PATCH 2/2 KVM: arm64: Stub EXPORT_SYMBOL for nVHE EL2 code
In reply to Quentin PerretIn order to ensure the module loader does not get confused if a symbol is exported in EL2 nVHE code (as will be the case when we will compile e.g. lib/memset.S into the EL2 object), make sure to stub all exports using __DISABLE_EXPORTS in the nvhe folder.
--- arch/arm64/kvm/hyp/nvhe/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kvm/hyp/nvhe/Makefile +2 -2
@@ -3,8 +3,8 @@ # Makefile for Kernel-based Virtual Machine module, HYP/nVHE part # -asflags-y := -D__KVM_NVHE_HYPERVISOR__ -ccflags-y := -D__KVM_NVHE_HYPERVISOR__ +asflags-y := -D__KVM_NVHE_HYPERVISOR__ -D__DISABLE_EXPORTS +ccflags-y := -D__KVM_NVHE_HYPERVISOR__ -D__DISABLE_EXPORTS obj-y := timer-sr.o sysreg-sr.o debug-sr.o switch.o tlb.o hyp-init.o host.o \ hyp-main.o hyp-smp.o psci-relay.o
Signature · 6 lines
2.30.0.365.g02bc693789-goog _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Quoted 12 lines · Quentin Perret
In the context of the currently ongoing work to remove the host kernel from the TCB under KVM/arm64, I have been trying to wrap the host kernel with a stage 2 page-table -- see [1].
Using this infrastructure, I attempted to unmap the .hyp. sections from the host stage 2 as it really shouldn't need to access them. But by doing so, I realized quickly the module loader was getting very confused by the usage of
EXPORT_SYMBOL()macros in library functions that have been pulled into the EL2 object, and that we end up linking modules against the EL2 copy of e.g. memset. And so, this series essentially tries to fix this.
Quoted 1 line
[...]
Applied to kvm-arm64/misc-5.12, thanks!
[1/2] asm-generic: export: Stub EXPORT_SYMBOL with __DISABLE_EXPORTS
commit: 54effa653246c35997f5e990e0134be5be09f9d1
[2/2] KVM: arm64: Stub EXPORT_SYMBOL for nVHE EL2 code
commit: bbc075e01ceac50e0a8353b520544f3089e94e44Cheers,
M.
Signature · 7 lines
Without deviation from the norm, progress is not possible. _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm