Split off nVHE hyp code
v4 cover Split off nVHE hyp code
Refactor files in arch/arm64/kvm/hyp to compile all code which runs in EL2 under nVHE into separate object files from the rest of KVM. This is done in preparation for being able to unmap hyp code from EL1 and kernel code/data from EL2 but has other benefits too, notably:
* safe use of KASAN/UBSAN/GCOV instrumentation on VHE code,
* no need for __hyp_text annotations.
nVHE-specific code is moved to hyp/nvhe and compiled with custom build rules similar to those used by EFI stub. Shared source files are compiled under both VHE and nVHE build rules. Where a source file contained both VHE and nVHE code, it is split into a shared header file and two C source files. This is done one file per commit to make review easier.
All nVHE symbols are prefixed with "__kvm_nvhe_" to avoid collisions with VHE variants (also inspired by EFI stub). Since this prefixes unresolved symbols too, image-vars.h contains a list of kernel symbol aliases where nVHE code still refers to kernel proper. The list grows fairly large as the patch series progresses and code is moved around, but at the end contains 20 symbols. These remaining dependencies on kernel proper will be further reduced in the future.
No functional changes are intended but code was simplified whenever the refactoring made it possible.
Tested by running kvm-unit-tests on QEMU 5.0 with VHE/nVHE and GIC v2/v3.
Dual compilation of code shared by VHE/nVHE increase the size of the kernel. Bloat-o-meter vmlinux diff shows an increase of 21 KB on the ELF symbol level. Size of Image.gz is up by 10 KB; size of Image is unchanged, presumably due to ELF section alignment.
This is based off v5.8-rc2. Available in branch 'topic/el2-obj-v4' of git repo:
https://android-kvm.googlesource.com/linux
Changes v3 -> v4:
* rebase onto v5.8-rc2 (trivial)
* add SYM_DATA_START/END around __smccc_workaround_1_smc
* move VHE-specific source files into hyp/vhe
* move headers shared by VHE/nVHE into hyp/include
* define __KVM_VHE_HYPERVISOR__ for VHE-specific code
* has_vhe() compile-time determinable when used in hyp/
* KVM_NVHE_ALIAS macro in image-vars.h, comments throughout series
* #define hyp symbols in kernel to magically select between VHE/nVHE variant
* duplicate hyp/tlb.c instead of splitting it
* pass idmap_t0sz to hyp-init as parameter to avoid symbol alias
Changes v2 -> v3:
* rebase onto v5.8-rc1
* remove patch changing hypcall interface to function IDs
* move hyp-init.S to nVHE
* fix symbol aliasing under CONFIG_ARM64_PSEUDO_NMI and CONFIG_ARM64_SVE
* remove VHE's unused __kvm_enable_ssbs()
* make nVHE use VHE's hyp_panic_string for consistent use of absolute relocs when returning pointers back to kernel
* replace __noscs annotation (added to __hyp_text macro) with build rule
Changes v1 -> v2:
* change nVHE symbol prefix from __hyp_text_ to __kvm_nvhe_
* rename __HYPERVISOR__ macro to __KVM_NVHE_HYPERVISOR__
* use hcall jump table instead of array of function pointers
* drop patch to unify HVC callers
* move __smccc_workaround_1_smc to own file
* header guards for hyp/*.h
* improve helpers for handling VHE/nVHE hyp syms in kernel proper
* improve commit messages, cover letter
-David
Andrew Scull (2):
arm64: kvm: Handle calls to prefixed hyp functions
arm64: kvm: Move hyp-init.S to nVHE
David Brazdil (13):
arm64: kvm: Fix symbol dependency in __hyp_call_panic_nvhe
arm64: kvm: Move __smccc_workaround_1_smc to .rodata
arm64: kvm: Add build rules for separate VHE/nVHE object files
arm64: kvm: Use build-time defines in has_vhe()
arm64: kvm: Build hyp-entry.S separately for VHE/nVHE
arm64: kvm: Duplicate hyp/tlb.c for VHE/nVHE
arm64: kvm: Split hyp/switch.c to VHE/nVHE
arm64: kvm: Split hyp/debug-sr.c to VHE/nVHE
arm64: kvm: Split hyp/sysreg-sr.c to VHE/nVHE
arm64: kvm: Duplicate hyp/timer-sr.c for VHE/nVHE
arm64: kvm: Compile remaining hyp/ files for both VHE/nVHE
arm64: kvm: Remove __hyp_text macro, use build rules instead
arm64: kvm: Lift instrumentation restrictions on VHE
arch/arm64/include/asm/kvm_asm.h | 48 +-
arch/arm64/include/asm/kvm_emulate.h | 2 +-
arch/arm64/include/asm/kvm_host.h | 23 +-
arch/arm64/include/asm/kvm_hyp.h | 15 +-
arch/arm64/include/asm/mmu.h | 7 -
arch/arm64/include/asm/virt.h | 13 +-
arch/arm64/kernel/image-vars.h | 51 +
arch/arm64/kvm/Makefile | 2 +-
arch/arm64/kvm/arm.c | 18 +-
arch/arm64/kvm/hyp/Makefile | 24 +-
arch/arm64/kvm/hyp/aarch32.c | 6 +-
arch/arm64/kvm/hyp/entry.S | 1 -
arch/arm64/kvm/hyp/fpsimd.S | 1 -
arch/arm64/kvm/hyp/hyp-entry.S | 21 +-
.../{debug-sr.c => include/hyp/debug-sr.h} | 78 +-
arch/arm64/kvm/hyp/include/hyp/switch.h | 509 ++++++++++
.../{sysreg-sr.c => include/hyp/sysreg-sr.h} | 162 +--
arch/arm64/kvm/hyp/nvhe/Makefile | 42 +
arch/arm64/kvm/hyp/nvhe/debug-sr.c | 77 ++
arch/arm64/kvm/{ => hyp/nvhe}/hyp-init.S | 24 +-
arch/arm64/kvm/hyp/nvhe/switch.c | 272 +++++
arch/arm64/kvm/hyp/nvhe/sysreg-sr.c | 46 +
arch/arm64/kvm/hyp/{ => nvhe}/timer-sr.c | 6 +-
arch/arm64/kvm/hyp/{ => nvhe}/tlb.c | 100 +-
arch/arm64/kvm/hyp/smccc_wa.S | 32 +
arch/arm64/kvm/hyp/switch.c | 936 ------------------
arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c | 4 +-
arch/arm64/kvm/hyp/vgic-v3-sr.c | 130 ++-
arch/arm64/kvm/hyp/vhe/Makefile | 11 +
arch/arm64/kvm/hyp/vhe/debug-sr.c | 26 +
arch/arm64/kvm/hyp/vhe/switch.c | 219 ++++
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 114 +++
arch/arm64/kvm/hyp/vhe/timer-sr.c | 12 +
arch/arm64/kvm/hyp/vhe/tlb.c | 162 +++
scripts/kallsyms.c | 1 +
35 files changed, 1786 insertions(+), 1409 deletions(-)
rename arch/arm64/kvm/hyp/{debug-sr.c => include/hyp/debug-sr.h} (71%)
create mode 100644 arch/arm64/kvm/hyp/include/hyp/switch.h
rename arch/arm64/kvm/hyp/{sysreg-sr.c => include/hyp/sysreg-sr.h} (56%)
create mode 100644 arch/arm64/kvm/hyp/nvhe/Makefile
create mode 100644 arch/arm64/kvm/hyp/nvhe/debug-sr.c
rename arch/arm64/kvm/{ => hyp/nvhe}/hyp-init.S (91%)
create mode 100644 arch/arm64/kvm/hyp/nvhe/switch.c
create mode 100644 arch/arm64/kvm/hyp/nvhe/sysreg-sr.c
rename arch/arm64/kvm/hyp/{ => nvhe}/timer-sr.c (84%)
rename arch/arm64/kvm/hyp/{ => nvhe}/tlb.c (55%)
create mode 100644 arch/arm64/kvm/hyp/smccc_wa.S
delete mode 100644 arch/arm64/kvm/hyp/switch.c
create mode 100644 arch/arm64/kvm/hyp/vhe/Makefile
create mode 100644 arch/arm64/kvm/hyp/vhe/debug-sr.c
create mode 100644 arch/arm64/kvm/hyp/vhe/switch.c
create mode 100644 arch/arm64/kvm/hyp/vhe/sysreg-sr.c
create mode 100644 arch/arm64/kvm/hyp/vhe/timer-sr.c
create mode 100644 arch/arm64/kvm/hyp/vhe/tlb.cSignature · 1 line
2.27.0
PATCH v4 1/15 arm64: kvm: Fix symbol dependency in __hyp_call_panic_nvhe
__hyp_call_panic_nvhe contains inline assembly which did not declare its dependency on the __hyp_panic_string symbol.
The static-declared string has previously been kept alive because of a use in __hyp_call_panic_vhe. Fix this in preparation for separating the source files between VHE and nVHE when the two users land in two different compilation units. The static variable otherwise gets dropped when compiling the nVHE source file, causing an undefined symbol linker error later.
--- arch/arm64/kvm/hyp/switch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/hyp/switch.c +1 -1
@@ -897,7 +897,7 @@ static void __hyp_text __hyp_call_panic_nvhe(u64 spsr, u64 elr, u64 par,* making sure it is a kernel address and not a PC-relative * reference. */ - asmvolatile ("ldr %0, =__hyp_panic_string" :"=r" (str_va)); + asmvolatile ("ldr %0, =%1" :"=r" (str_va) :"S" (__hyp_panic_string)); __hyp_do_panic(str_va, spsr, elr,
Signature · 6 lines
2.27.0 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PATCH v4 2/15 arm64: kvm: Move __smccc_workaround_1_smc to .rodata
In reply to David BrazdilThis snippet of assembly is used by cpu_errata.c to overwrite parts of KVM hyp vector. Move it to its own source file and change its ELF section to .rodata.
--- arch/arm64/kvm/hyp/Makefile | 1 + arch/arm64/kvm/hyp/hyp-entry.S | 16 ---------------- arch/arm64/kvm/hyp/smccc_wa.S | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 16 deletions(-) create mode 100644 arch/arm64/kvm/hyp/smccc_wa.S
arch/arm64/kvm/hyp/Makefile +1 -0
@@ -7,6 +7,7 @@ ccflags-y += -fno-stack-protector -DDISABLE_BRANCH_PROFILING \ $(DISABLE_STACKLEAK_PLUGIN) obj-$(CONFIG_KVM) += hyp.o +obj-$(CONFIG_KVM_INDIRECT_VECTORS) += smccc_wa.o hyp-y := vgic-v3-sr.o timer-sr.o aarch32.o vgic-v2-cpuif-proxy.o sysreg-sr.o \ debug-sr.o entry.o switch.o fpsimd.o tlb.o hyp-entry.o
arch/arm64/kvm/hyp/hyp-entry.S +0 -16
@@ -318,20 +318,4 @@ SYM_CODE_START(__bp_harden_hyp_vecs) 1: .org __bp_harden_hyp_vecs + __BP_HARDEN_HYP_VECS_SZ .org 1b SYM_CODE_END(__bp_harden_hyp_vecs) - - .popsection - -SYM_CODE_START(__smccc_workaround_1_smc) - esb - sub sp, sp, #(8 * 4) - stp x2, x3, [sp, #(8 * 0)] - stp x0, x1, [sp, #(8 * 2)] - mov w0, #ARM_SMCCC_ARCH_WORKAROUND_1 - smc #0 - ldp x2, x3, [sp, #(8 * 0)] - ldp x0, x1, [sp, #(8 * 2)] - add sp, sp, #(8 * 4) -1: .org __smccc_workaround_1_smc + __SMCCC_WORKAROUND_1_SMC_SZ - .org 1b -SYM_CODE_END(__smccc_workaround_1_smc) #endif
arch/arm64/kvm/hyp/smccc_wa.S new file +32 -0
@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2015-2018 - ARM Ltd + * Author: Marc Zyngier <[email protected]> + */ + +#include <linux/arm-smccc.h> +#include <linux/linkage.h> + +#include <asm/kvm_asm.h> +#include <asm/kvm_mmu.h> + + /* + * This is not executed directly and is instead copied into the vectors + * by install_bp_hardening_cb(). + */ + .data + .pushsection .rodata + .global __smccc_workaround_1_smc +SYM_DATA_START(__smccc_workaround_1_smc) + esb + sub sp, sp, #(8 * 4) + stp x2, x3, [sp, #(8 * 0)] + stp x0, x1, [sp, #(8 * 2)] + mov w0, #ARM_SMCCC_ARCH_WORKAROUND_1 + smc #0 + ldp x2, x3, [sp, #(8 * 0)] + ldp x0, x1, [sp, #(8 * 2)] + add sp, sp, #(8 * 4) +1: .org __smccc_workaround_1_smc + __SMCCC_WORKAROUND_1_SMC_SZ + .org 1b +SYM_DATA_END(__smccc_workaround_1_smc)
Signature · 6 lines
2.27.0 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PATCH v4 3/15 arm64: kvm: Add build rules for separate VHE/nVHE object files
In reply to David BrazdilAdd new folders arch/arm64/kvm/hyp/{vhe,nvhe} and Makefiles for building code that runs in EL2 under VHE/nVHE KVM, repsectivelly. Add an include folder for hyp-specific header files which will include code common to VHE/nVHE.
Build nVHE code with -D__KVM_NVHE_HYPERVISOR__, VHE code with -D__KVM_VHE_HYPERVISOR__.
Under nVHE compile each source file into a .hyp.tmp.o object first, then prefix all its symbols with "__kvm_nvhe_" using objcopy and produce a .hyp.o. Suffixes were chosen so that it would be possible for VHE and nVHE to share some source files, but compiled with different CFLAGS.
The nVHE ELF symbol prefix is added to kallsyms.c as ignored. EL2-only symbols will never appear in EL1 stack traces.
Due to symbol prefixing, add a section in image-vars.h for aliases of symbols that are defined in nVHE EL2 and accessed by kernel in EL1 or vice versa.
--- arch/arm64/kernel/image-vars.h | 14 +++++++++++++ arch/arm64/kvm/hyp/Makefile | 10 +++++++--- arch/arm64/kvm/hyp/nvhe/Makefile | 34 ++++++++++++++++++++++++++++++++ arch/arm64/kvm/hyp/vhe/Makefile | 17 ++++++++++++++++ scripts/kallsyms.c | 1 + 5 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 arch/arm64/kvm/hyp/nvhe/Makefile create mode 100644 arch/arm64/kvm/hyp/vhe/Makefile
arch/arm64/kernel/image-vars.h +14 -0
@@ -51,4 +51,18 @@ __efistub__ctype = _ctype;#endif +#ifdef CONFIG_KVM + +/* +* KVM nVHE code has its own symbol namespace prefixed with __kvm_nvhe_, to +* separate it from the kernel proper. The following symbols are legally +* accessed by it, therefore provide aliases to make them linkable. +* Do not include symbols which may not be safely accessed under hypervisor +* memory mappings. +*/ + +#define KVM_NVHE_ALIAS (sym) __kvm_nvhe_##sym = sym; + +#endif /* CONFIG_KVM */ +#endif /* __ARM64_KERNEL_IMAGE_VARS_H */
arch/arm64/kvm/hyp/Makefile +7 -3
@@ -3,10 +3,14 @@ # Makefile for Kernel-based Virtual Machine module, HYP part # -ccflags-y += -fno-stack-protector -DDISABLE_BRANCH_PROFILING \ - $(DISABLE_STACKLEAK_PLUGIN) +incdir := $(srctree)/$(src)/include +subdir-asflags-y := -I$(incdir) +subdir-ccflags-y := -I$(incdir) \ + -fno-stack-protector \ + -DDISABLE_BRANCH_PROFILING \ + $(DISABLE_STACKLEAK_PLUGIN) -obj-$(CONFIG_KVM) += hyp.o +obj-$(CONFIG_KVM) += hyp.o nvhe/ obj-$(CONFIG_KVM_INDIRECT_VECTORS) += smccc_wa.o hyp-y := vgic-v3-sr.o timer-sr.o aarch32.o vgic-v2-cpuif-proxy.o sysreg-sr.o \
arch/arm64/kvm/hyp/nvhe/Makefile new file +34 -0
@@ -0,0 +1,34 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for Kernel-based Virtual Machine module, HYP/nVHE part +# + +asflags-y := -D__KVM_NVHE_HYPERVISOR__ +ccflags-y := -D__KVM_NVHE_HYPERVISOR__ + +obj-y := + +obj-y := $(patsubst %.o,%.hyp.o,$(obj-y)) +extra-y := $(patsubst %.hyp.o,%.hyp.tmp.o,$(obj-y)) + +$(obj)/%.hyp.tmp.o: $(src)/%.c FORCE + $(call if_changed_rule,cc_o_c) +$(obj)/%.hyp.tmp.o: $(src)/%.S FORCE + $(call if_changed_rule,as_o_S) +$(obj)/%.hyp.o: $(obj)/%.hyp.tmp.o FORCE + $(call if_changed,hypcopy) + +quiet_cmd_hypcopy = HYPCOPY $@ + cmd_hypcopy = $(OBJCOPY) --prefix-symbols=__kvm_nvhe_ $< $@ + +# KVM nVHE code is run at a different exception code with a different map, so +# compiler instrumentation that inserts callbacks or checks into the code may +# cause crashes. Just disable it. +GCOV_PROFILE := n +KASAN_SANITIZE := n +UBSAN_SANITIZE := n +KCOV_INSTRUMENT := n + +# Skip objtool checking for this directory because nVHE code is compiled with +# non-standard build rules. +OBJECT_FILES_NON_STANDARD := y
arch/arm64/kvm/hyp/vhe/Makefile new file +17 -0
@@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for Kernel-based Virtual Machine module, HYP/nVHE part +# + +asflags-y := -D__KVM_VHE_HYPERVISOR__ +ccflags-y := -D__KVM_VHE_HYPERVISOR__ + +obj-y := + +# KVM code is run at a different exception code with a different map, so +# compiler instrumentation that inserts callbacks or checks into the code may +# cause crashes. Just disable it. +GCOV_PROFILE := n +KASAN_SANITIZE := n +UBSAN_SANITIZE := n +KCOV_INSTRUMENT := n
scripts/kallsyms.c +1 -0
@@ -109,6 +109,7 @@ static bool is_ignored_symbol(const char *name, char type)".LASANPC" ,/* s390 kasan local symbols */ "__crc_" ,/* modversions */ "__efistub_" ,/* arm64 EFI stub namespace */ +"__kvm_nvhe_" ,/* arm64 non-VHE KVM namespace */ NULL };
Signature · 6 lines
2.27.0 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PATCH v4 4/15 arm64: kvm: Use build-time defines in has_vhe()
In reply to David BrazdilBuild system compiles hyp code with macros specifying if the code belongs to VHE or nVHE. Use these macros to evaluate has_vhe() at compile time.
--- arch/arm64/include/asm/virt.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
arch/arm64/include/asm/virt.h +10 -3
@@ -85,10 +85,17 @@ static inline bool is_kernel_in_hyp_mode(void) static __always_inline bool has_vhe(void) { -if (cpus_have_final_cap (ARM64_HAS_VIRT_HOST_EXTN )) +/* +* The following macros are defined for code specic to VHE/nVHE. +* If has_vhe() is inlined into those compilation units, it can +* be determined statically. Otherwise fall back to caps. +*/ +if (__is_defined (__KVM_VHE_HYPERVISOR__))return true; - -return false; +else if (__is_defined (__KVM_NVHE_HYPERVISOR__)) +return false; +else +return cpus_have_final_cap (ARM64_HAS_VIRT_HOST_EXTN ); }#endif /* __ASSEMBLY__ */
Signature · 6 lines
2.27.0 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PATCH v4 5/15 arm64: kvm: Handle calls to prefixed hyp functions
In reply to David BrazdilFrom: Andrew Scull <[email protected]>
Once hyp functions are moved to a hyp object, they will have prefixed symbols. This change declares and gets the address of the prefixed version for calls to the hyp functions.
To aid migration, the hyp functions that have not yet moved have their prefixed versions aliased to their non-prefixed version. This begins with all the hyp functions being listed and will reduce to none of them once the migration is complete.
[David: Extracted kvm_call_hyp nVHE branches into own helper macros, added
comments around symbol aliases.]
--- arch/arm64/include/asm/kvm_asm.h | 19 +++++++++++++++++++ arch/arm64/include/asm/kvm_host.h | 17 ++++++++++++++--- arch/arm64/kernel/image-vars.h | 26 ++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 3 deletions(-)
arch/arm64/include/asm/kvm_asm.h +19 -0
@@ -42,6 +42,24 @@#include <linux/mm.h> +/* +* Translate name of a symbol defined in nVHE hyp to the name seen +* by kernel proper. All nVHE symbols are prefixed by the build system +* to avoid clashes with the VHE variants. +*/ +#define kvm_nvhe_sym (sym) __kvm_nvhe_##sym + +#define DECLARE_KVM_VHE_SYM (sym) extern char sym[] +#define DECLARE_KVM_NVHE_SYM (sym) extern char kvm_nvhe_sym(sym)[] + +/* +* Define a pair of symbols sharing the same name but one defined in +* VHE and the other in nVHE hyp implementations. +*/ +#define DECLARE_KVM_HYP_SYM (sym) \ + DECLARE_KVM_VHE_SYM(sym); \ + DECLARE_KVM_NVHE_SYM(sym) +/* Translate a kernel address of @sym into its equivalent linear mapping */ #define kvm_ksym_ref (sym) \ ({ \
@@ -50,6 +68,7 @@ val =lm_alias (&sym); \ val; \ }) +#define kvm_ksym_ref_nvhe (sym) kvm_ksym_ref(kvm_nvhe_sym(sym))struct kvm ;struct kvm_vcpu ;
arch/arm64/include/asm/kvm_host.h +14 -3
@@ -448,6 +448,18 @@ void kvm_arm_resume_guest(struct kvm *kvm);u64 __kvm_call_hyp (void *hypfn, ...); +#define kvm_call_hyp_nvhe (f, ...) \ + do { \ + DECLARE_KVM_NVHE_SYM(f); \ + __kvm_call_hyp(kvm_ksym_ref_nvhe(f), ##__VA_ARGS__); \ + } while(0) + +#define kvm_call_hyp_nvhe_ret (f, ...) \ + ({ \ + DECLARE_KVM_NVHE_SYM(f); \ + __kvm_call_hyp(kvm_ksym_ref_nvhe(f), ##__VA_ARGS__); \ + }) +/* * The couple of isb() below are there to guarantee the same behaviour * on VHE as on !VHE, where the eret to EL1 acts as a context
@@ -459,7 +471,7 @@ u64 __kvm_call_hyp(void *hypfn, ...);f (__VA_ARGS__); \isb (); \ }else { \ - __kvm_call_hyp(kvm_ksym_ref(f), ##__VA_ARGS__); \ + kvm_call_hyp_nvhe(f, ##__VA_ARGS__); \ } \ }while (0 )
@@ -471,8 +483,7 @@ u64 __kvm_call_hyp(void *hypfn, ...); ret =f (__VA_ARGS__); \isb (); \ }else { \ - ret =__kvm_call_hyp (kvm_ksym_ref (f), \ - ##__VA_ARGS__); \ + ret = kvm_call_hyp_nvhe_ret(f, ##__VA_ARGS__); \ } \ \ ret; \
arch/arm64/kernel/image-vars.h +26 -0
@@ -63,6 +63,32 @@ __efistub__ctype = _ctype;#define KVM_NVHE_ALIAS (sym) __kvm_nvhe_##sym = sym; +/* Symbols defined in debug-sr.c (not yet compiled with nVHE build rules). */ +KVM_NVHE_ALIAS (__kvm_get_mdcr_el2); + +/* Symbols defined in switch.c (not yet compiled with nVHE build rules). */ +KVM_NVHE_ALIAS (__kvm_vcpu_run_nvhe); + +/* Symbols defined in sysreg-sr.c (not yet compiled with nVHE build rules). */ +KVM_NVHE_ALIAS (__kvm_enable_ssbs); + +/* Symbols defined in timer-sr.c (not yet compiled with nVHE build rules). */ +KVM_NVHE_ALIAS (__kvm_timer_set_cntvoff); + +/* Symbols defined in tlb.c (not yet compiled with nVHE build rules). */ +KVM_NVHE_ALIAS (__kvm_flush_vm_context); +KVM_NVHE_ALIAS (__kvm_tlb_flush_local_vmid); +KVM_NVHE_ALIAS (__kvm_tlb_flush_vmid); +KVM_NVHE_ALIAS (__kvm_tlb_flush_vmid_ipa); + +/* Symbols defined in vgic-v3-sr.c (not yet compiled with nVHE build rules). */ +KVM_NVHE_ALIAS (__vgic_v3_get_ich_vtr_el2); +KVM_NVHE_ALIAS (__vgic_v3_init_lrs); +KVM_NVHE_ALIAS (__vgic_v3_read_vmcr); +KVM_NVHE_ALIAS (__vgic_v3_restore_aprs); +KVM_NVHE_ALIAS (__vgic_v3_save_aprs); +KVM_NVHE_ALIAS (__vgic_v3_write_vmcr); +#endif /* CONFIG_KVM */ #endif /* __ARM64_KERNEL_IMAGE_VARS_H */
Signature · 6 lines
2.27.0 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PATCH v4 6/15 arm64: kvm: Build hyp-entry.S separately for VHE/nVHE
In reply to David Brazdilhyp-entry.S contains implementation of KVM hyp vectors. This code is mostly shared between VHE/nVHE, therefore compile it under both VHE and nVHE build rules. nVHE-specific host HVC handler is hidden behind __KVM_NVHE_HYPERVISOR__.
Adjust code which selects which KVM hyp vecs to install to choose the correct VHE/nVHE symbol.
--- arch/arm64/include/asm/kvm_asm.h | 22 +++++++++++++++++----- arch/arm64/include/asm/mmu.h | 7 ------- arch/arm64/kernel/image-vars.h | 24 ++++++++++++++++++++++++ arch/arm64/kvm/arm.c | 2 +- arch/arm64/kvm/hyp/Makefile | 4 ++-- arch/arm64/kvm/hyp/hyp-entry.S | 2 ++ arch/arm64/kvm/hyp/nvhe/Makefile | 2 +- arch/arm64/kvm/hyp/vhe/Makefile | 2 +- 8 files changed, 48 insertions(+), 17 deletions(-)
arch/arm64/include/asm/kvm_asm.h +17 -5
@@ -60,12 +60,17 @@DECLARE_KVM_VHE_SYM (sym); \ DECLARE_KVM_NVHE_SYM(sym) -/* Translate a kernel address of @sym into its equivalent linear mapping */ -#define kvm_ksym_ref (sym) \ +#define CHOOSE_VHE_SYM (sym) sym +#define CHOOSE_NVHE_SYM (sym) kvm_nvhe_sym(sym) +#define CHOOSE_HYP_SYM (sym) (has_vhe() ? CHOOSE_VHE_SYM(sym) \ + : CHOOSE_NVHE_SYM(sym)) + +/* Translate a kernel address @ptr into its equivalent linear mapping */ +#define kvm_ksym_ref (ptr) \ ({ \ - void *val = &sym; \ + void *val = (ptr); \ if (!is_kernel_in_hyp_mode()) \ - val = lm_alias(&sym); \ + val = lm_alias((ptr)); \ val; \ })#define kvm_ksym_ref_nvhe (sym) kvm_ksym_ref(kvm_nvhe_sym(sym))
@@ -76,7 +81,14 @@ struct kvm_vcpu;extern char __kvm_hyp_init[];extern char __kvm_hyp_init_end[]; -extern char __kvm_hyp_vector[]; +DECLARE_KVM_HYP_SYM (__kvm_hyp_vector); +#define __kvm_hyp_vector CHOOSE_HYP_SYM(__kvm_hyp_vector) + +#ifdef CONFIG_KVM_INDIRECT_VECTORS +extern atomic_t arm64_el2_vector_last_slot; +DECLARE_KVM_HYP_SYM (__bp_harden_hyp_vecs); +#define __bp_harden_hyp_vecs CHOOSE_HYP_SYM(__bp_harden_hyp_vecs) +#endif extern void __kvm_flush_vm_context (void );extern void __kvm_tlb_flush_vmid_ipa (struct kvm *kvm,phys_addr_t ipa);
arch/arm64/include/asm/mmu.h +0 -7
@@ -42,13 +42,6 @@ struct bp_hardening_data {bp_hardening_cb_t fn; }; -#if (defined(CONFIG_HARDEN_BRANCH_PREDICTOR ) || \ - defined(CONFIG_HARDEN_EL2_VECTORS )) - -extern char __bp_harden_hyp_vecs[]; -extern atomic_t arm64_el2_vector_last_slot; -#endif /* CONFIG_HARDEN_BRANCH_PREDICTOR || CONFIG_HARDEN_EL2_VECTORS */ -#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR DECLARE_PER_CPU_READ_MOSTLY(struct bp_hardening_data, bp_hardening_data);
arch/arm64/kernel/image-vars.h +24 -0
@@ -66,8 +66,17 @@ __efistub__ctype = _ctype;/* Symbols defined in debug-sr.c (not yet compiled with nVHE build rules). */ KVM_NVHE_ALIAS (__kvm_get_mdcr_el2); +/* Symbols defined in entry.S (not yet compiled with nVHE build rules). */ +KVM_NVHE_ALIAS (__guest_exit); +KVM_NVHE_ALIAS (abort_guest_exit_end); +KVM_NVHE_ALIAS (abort_guest_exit_start); + +/* Symbols defined in hyp-init.S (not yet compiled with nVHE build rules). */ +KVM_NVHE_ALIAS (__kvm_handle_stub_hvc); +/* Symbols defined in switch.c (not yet compiled with nVHE build rules). */ KVM_NVHE_ALIAS (__kvm_vcpu_run_nvhe); +KVM_NVHE_ALIAS (hyp_panic);/* Symbols defined in sysreg-sr.c (not yet compiled with nVHE build rules). */ KVM_NVHE_ALIAS (__kvm_enable_ssbs);
@@ -89,6 +98,21 @@ KVM_NVHE_ALIAS(__vgic_v3_restore_aprs);KVM_NVHE_ALIAS (__vgic_v3_save_aprs);KVM_NVHE_ALIAS (__vgic_v3_write_vmcr); +/* Alternative callbacks for init-time patching of nVHE hyp code. */ +KVM_NVHE_ALIAS (arm64_enable_wa2_handling); +KVM_NVHE_ALIAS (kvm_patch_vector_branch); +KVM_NVHE_ALIAS (kvm_update_va_mask); + +/* Global kernel state accessed by nVHE hyp code. */ +KVM_NVHE_ALIAS (arm64_ssbd_callback_required); +KVM_NVHE_ALIAS (kvm_host_data); + +/* Kernel constant needed to compute idmap addresses. */ +KVM_NVHE_ALIAS (kimage_voffset); + +/* Kernel symbols used to call panic() from nVHE hyp code (via ERET). */ +KVM_NVHE_ALIAS (panic); +#endif /* CONFIG_KVM */ #endif /* __ARM64_KERNEL_IMAGE_VARS_H */
arch/arm64/kvm/arm.c +1 -1
@@ -1285,7 +1285,7 @@ static void cpu_init_hyp_mode(void)* so that we can use adr_l to access per-cpu variables in EL2. */ tpidr_el2 = ((unsigned long )this_cpu_ptr (&kvm_host_data) - - (unsigned long )kvm_ksym_ref (kvm_host_data)); + (unsigned long )kvm_ksym_ref (&kvm_host_data)); pgd_ptr =kvm_mmu_get_httbr (); hyp_stack_ptr =__this_cpu_read (kvm_arm_hyp_stack_page) +PAGE_SIZE ;
arch/arm64/kvm/hyp/Makefile +2 -2
@@ -10,11 +10,11 @@ subdir-ccflags-y := -I$(incdir) \ -DDISABLE_BRANCH_PROFILING \ $(DISABLE_STACKLEAK_PLUGIN) -obj-$(CONFIG_KVM) += hyp.o nvhe/ +obj-$(CONFIG_KVM) += hyp.o vhe/ nvhe/ obj-$(CONFIG_KVM_INDIRECT_VECTORS) += smccc_wa.o hyp-y := vgic-v3-sr.o timer-sr.o aarch32.o vgic-v2-cpuif-proxy.o sysreg-sr.o \ - debug-sr.o entry.o switch.o fpsimd.o tlb.o hyp-entry.o + debug-sr.o entry.o switch.o fpsimd.o tlb.o # KVM code is run at a different exception code with a different map, so # compiler instrumentation that inserts callbacks or checks into the code may
arch/arm64/kvm/hyp/hyp-entry.S +2 -0
@@ -40,6 +40,7 @@ el1_sync: // Guest trapped into EL2 ccmp x0, #ESR_ELx_EC_HVC32, #4, ne b.ne el1_trap +#ifdef __KVM_NVHE_HYPERVISOR__ mrs x1, vttbr_el2 // If vttbr is valid, the guest cbnz x1, el1_hvc_guest // called HVC
@@ -74,6 +75,7 @@ el1_sync: // Guest trapped into EL2 eret sb +#endif /* __KVM_NVHE_HYPERVISOR__ */ el1_hvc_guest: /*
arch/arm64/kvm/hyp/nvhe/Makefile +1 -1
@@ -6,7 +6,7 @@ asflags-y := -D__KVM_NVHE_HYPERVISOR__ ccflags-y := -D__KVM_NVHE_HYPERVISOR__ -obj-y := +obj-y := ../hyp-entry.o obj-y := $(patsubst %.o,%.hyp.o,$(obj-y)) extra-y := $(patsubst %.hyp.o,%.hyp.tmp.o,$(obj-y))
arch/arm64/kvm/hyp/vhe/Makefile +1 -1
@@ -6,7 +6,7 @@ asflags-y := -D__KVM_VHE_HYPERVISOR__ ccflags-y := -D__KVM_VHE_HYPERVISOR__ -obj-y := +obj-y := ../hyp-entry.o # KVM code is run at a different exception code with a different map, so # compiler instrumentation that inserts callbacks or checks into the code may
Signature · 6 lines
2.27.0 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PATCH v4 7/15 arm64: kvm: Move hyp-init.S to nVHE
In reply to David BrazdilFrom: Andrew Scull <[email protected]>
hyp-init.S contains the identity mapped initialisation code for the non-VHE code that runs at EL2. It is only used for non-VHE.
Adjust code that calls into this to use the prefixed symbol name.
---
arch/arm64/include/asm/kvm_asm.h | 5 ++---
arch/arm64/kernel/image-vars.h | 6 +++---
arch/arm64/kvm/Makefile | 2 +-
arch/arm64/kvm/arm.c | 2 +-
arch/arm64/kvm/hyp/nvhe/Makefile | 2 +-
arch/arm64/kvm/{ => hyp/nvhe}/hyp-init.S | 24 ++++++++++++------------
6 files changed, 20 insertions(+), 21 deletions(-)
rename arch/arm64/kvm/{ => hyp/nvhe}/hyp-init.S (91%)arch/arm64/include/asm/kvm_asm.h +2 -3
@@ -78,10 +78,9 @@struct kvm ;struct kvm_vcpu ; -extern char __kvm_hyp_init[]; -extern char __kvm_hyp_init_end[]; - +DECLARE_KVM_NVHE_SYM (__kvm_hyp_init);DECLARE_KVM_HYP_SYM (__kvm_hyp_vector); +#define __kvm_hyp_init CHOOSE_NVHE_SYM(__kvm_hyp_init)#define __kvm_hyp_vector CHOOSE_HYP_SYM(__kvm_hyp_vector)#ifdef CONFIG_KVM_INDIRECT_VECTORS
arch/arm64/kernel/image-vars.h +3 -3
@@ -71,9 +71,6 @@ KVM_NVHE_ALIAS(__guest_exit);KVM_NVHE_ALIAS (abort_guest_exit_end);KVM_NVHE_ALIAS (abort_guest_exit_start); -/* Symbols defined in hyp-init.S (not yet compiled with nVHE build rules). */ -KVM_NVHE_ALIAS (__kvm_handle_stub_hvc); -/* Symbols defined in switch.c (not yet compiled with nVHE build rules). */ KVM_NVHE_ALIAS (__kvm_vcpu_run_nvhe);KVM_NVHE_ALIAS (hyp_panic);
@@ -113,6 +110,9 @@ KVM_NVHE_ALIAS(kimage_voffset);/* Kernel symbols used to call panic() from nVHE hyp code (via ERET). */ KVM_NVHE_ALIAS (panic); +/* Vectors installed by hyp-init on reset HVC. */ +KVM_NVHE_ALIAS (__hyp_stub_vectors); +#endif /* CONFIG_KVM */ #endif /* __ARM64_KERNEL_IMAGE_VARS_H */
arch/arm64/kvm/Makefile +1 -1
@@ -13,7 +13,7 @@ obj-$(CONFIG_KVM) += hyp/ kvm-y := $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o $(KVM)/eventfd.o \ $(KVM)/vfio.o $(KVM)/irqchip.o \ arm.o mmu.o mmio.o psci.o perf.o hypercalls.o pvtime.o \ - inject_fault.o regmap.o va_layout.o hyp.o hyp-init.o handle_exit.o \ + inject_fault.o regmap.o va_layout.o hyp.o handle_exit.o \ guest.o debug.o reset.o sys_regs.o sys_regs_generic_v8.o \ vgic-sys-reg-v3.o fpsimd.o pmu.o \ aarch32.o arch_timer.o \
arch/arm64/kvm/arm.c +1 -1
@@ -1298,7 +1298,7 @@ static void cpu_init_hyp_mode(void)* cpus_have_const_cap() wrapper. */ BUG_ON (!system_capabilities_finalized ()); -__kvm_call_hyp ((void *)pgd_ptr, hyp_stack_ptr, vector_ptr, tpidr_el2); +__kvm_call_hyp ((void *)pgd_ptr, hyp_stack_ptr, vector_ptr, tpidr_el2, idmap_t0sz);/* * Disabling SSBD on a non-VHE system requires us to enable SSBS
arch/arm64/kvm/hyp/nvhe/Makefile +1 -1
@@ -6,7 +6,7 @@ asflags-y := -D__KVM_NVHE_HYPERVISOR__ ccflags-y := -D__KVM_NVHE_HYPERVISOR__ -obj-y := ../hyp-entry.o +obj-y := hyp-init.o ../hyp-entry.o obj-y := $(patsubst %.o,%.hyp.o,$(obj-y)) extra-y := $(patsubst %.hyp.o,%.hyp.tmp.o,$(obj-y))
arch/arm64/kvm/hyp/nvhe/hyp-init.S renamed from arch/arm64/kvm/hyp-init.S +12 -12
@@ -47,23 +47,24 @@ __invalid: * x1: HYP stack * x2: HYP vectors * x3: per-CPU offset + * x4: idmap_t0sz */ __do_hyp_init: /* Check for a stub HVC call */ cmp x0, #HVC_STUB_HCALL_NR b.lo __kvm_handle_stub_hvc - phys_to_ttbr x4, x0 + phys_to_ttbr x5, x0 alternative_if ARM64_HAS_CNP - orr x4, x4, #TTBR_CNP_BIT + orr x5, x5, #TTBR_CNP_BIT alternative_else_nop_endif - msr ttbr0_el2, x4 + msr ttbr0_el2, x5 - mrs x4, tcr_el1 - mov_q x5, TCR_EL2_MASK - and x4, x4, x5 - mov x5, #TCR_EL2_RES1 - orr x4, x4, x5 + mrs x5, tcr_el1 + mov_q x6, TCR_EL2_MASK + and x5, x5, x6 + mov x6, #TCR_EL2_RES1 + orr x5, x5, x6 /* * The ID map may be configured to use an extended virtual address
@@ -79,15 +80,14 @@ alternative_else_nop_endif * * So use the same T0SZ value we use for the ID map. */ - ldr_l x5, idmap_t0sz - bfi x4, x5, TCR_T0SZ_OFFSET, TCR_TxSZ_WIDTH + bfi x5, x4, TCR_T0SZ_OFFSET, TCR_TxSZ_WIDTH /* * Set the PS bits in TCR_EL2. */ - tcr_compute_pa_size x4, #TCR_EL2_PS_SHIFT, x5, x6 + tcr_compute_pa_size x5, #TCR_EL2_PS_SHIFT, x4, x6 - msr tcr_el2, x4 + msr tcr_el2, x5 mrs x4, mair_el1 msr mair_el2, x4
Signature · 6 lines
2.27.0 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Marc Zyngier
maintainerRe: [PATCH v4 07/15] arm64: kvm: Move hyp-init.S to nVHE
Hi David,
Quoted 11 lines · David Brazdil
From: Andrew Scull <[email protected]>
hyp-init.Scontains the identity mapped initialisation code for the non-VHE code that runs at EL2. It is only used for non-VHE.Adjust code that calls into this to use the prefixed symbol name.
Signed-off-by Andrew Scull <[email protected]>[David: pass
idmap_t0szas an argument]
It is unclear to me why moving the way idmap_t0sz is passed is required at this stage. I understand that you want to minimise the amount of shared data between EL1 and EL2, but it hardly seems relevant here.
Or is it, as I expect, to avoid yet another symbol renaming issue? If so, it would be preferable to have the symbol alias, keep the setup hypercall as is, and have a later, separate patch that deals with the the idmap. And I am pretty sure that, as we move to a more autonomous EL2, we won't have to deal with it at all and we'll simply delete this code.
I'm planning to squash the following diff into this patch, effectively reverting the idmap_t0sz related changes. Let me know if you're OK with it.
arch/arm64/kernel/image-vars.h +3 -0
@@ -83,6 +83,9 @@ KVM_NVHE_ALIAS(panic);/* Vectors installed by hyp-init on reset HVC. */ KVM_NVHE_ALIAS (__hyp_stub_vectors); +/* IDMAP TCR_EL1.T0SZ as computed by the EL1 init code */ +KVM_NVHE_ALIAS (idmap_t0sz); +/* Kernel symbol used by icache_is_vpipt(). */ KVM_NVHE_ALIAS (__icache_flags);
arch/arm64/kvm/arm.c +1 -1
@@ -1296,7 +1296,7 @@ static void cpu_init_hyp_mode(void)* cpus_have_const_cap() wrapper. */ BUG_ON (!system_capabilities_finalized ()); -__kvm_call_hyp ((void *)pgd_ptr, hyp_stack_ptr, vector_ptr, tpidr_el2, idmap_t0sz); +__kvm_call_hyp ((void *)pgd_ptr, hyp_stack_ptr, vector_ptr, tpidr_el2);/* * Disabling SSBD on a non-VHE system requires us to enable SSBS
arch/arm64/kvm/hyp/nvhe/hyp-init.S +12 -12
@@ -47,24 +47,23 @@ __invalid: * x1: HYP stack * x2: HYP vectors * x3: per-CPU offset - * x4: idmap_t0sz */ __do_hyp_init: /* Check for a stub HVC call */ cmp x0, #HVC_STUB_HCALL_NR b.lo __kvm_handle_stub_hvc - phys_to_ttbr x5, x0 + phys_to_ttbr x4, x0 alternative_if ARM64_HAS_CNP - orr x5, x5, #TTBR_CNP_BIT + orr x4, x4, #TTBR_CNP_BIT alternative_else_nop_endif - msr ttbr0_el2, x5 + msr ttbr0_el2, x4 - mrs x5, tcr_el1 - mov_q x6, TCR_EL2_MASK - and x5, x5, x6 - mov x6, #TCR_EL2_RES1 - orr x5, x5, x6 + mrs x4, tcr_el1 + mov_q x5, TCR_EL2_MASK + and x4, x4, x5 + mov x5, #TCR_EL2_RES1 + orr x4, x4, x5 /* * The ID map may be configured to use an extended virtual address
@@ -80,14 +79,15 @@ alternative_else_nop_endif * * So use the same T0SZ value we use for the ID map. */ - bfi x5, x4, TCR_T0SZ_OFFSET, TCR_TxSZ_WIDTH + ldr_l x5, idmap_t0sz + bfi x4, x5, TCR_T0SZ_OFFSET, TCR_TxSZ_WIDTH /* * Set the PS bits in TCR_EL2. */ - tcr_compute_pa_size x5, #TCR_EL2_PS_SHIFT, x4, x6 + tcr_compute_pa_size x4, #TCR_EL2_PS_SHIFT, x5, x6 - msr tcr_el2, x5 + msr tcr_el2, x4 mrs x4, mair_el1 msr mair_el2, x4
Thanks,
M.
Signature · 5 lines
Without deviation from the norm, progress is not possible. _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PATCH v4 8/15 arm64: kvm: Duplicate hyp/tlb.c for VHE/nVHE
In reply to David Brazdiltlb.c contains code for flushing the TLB, with code shared between VHE/nVHE. Because common code is small, duplicate tlb.c and specialize each copy for VHE/nVHE.
---
arch/arm64/kernel/image-vars.h | 14 +--
arch/arm64/kvm/hyp/Makefile | 2 +-
arch/arm64/kvm/hyp/nvhe/Makefile | 2 +-
arch/arm64/kvm/hyp/{ => nvhe}/tlb.c | 94 +---------------
arch/arm64/kvm/hyp/vhe/Makefile | 2 +-
arch/arm64/kvm/hyp/vhe/tlb.c | 162 ++++++++++++++++++++++++++++
6 files changed, 178 insertions(+), 98 deletions(-)
rename arch/arm64/kvm/hyp/{ => nvhe}/tlb.c (62%)
create mode 100644 arch/arm64/kvm/hyp/vhe/tlb.carch/arm64/kernel/image-vars.h +8 -6
@@ -81,12 +81,6 @@ KVM_NVHE_ALIAS(__kvm_enable_ssbs);/* Symbols defined in timer-sr.c (not yet compiled with nVHE build rules). */ KVM_NVHE_ALIAS (__kvm_timer_set_cntvoff); -/* Symbols defined in tlb.c (not yet compiled with nVHE build rules). */ -KVM_NVHE_ALIAS (__kvm_flush_vm_context); -KVM_NVHE_ALIAS (__kvm_tlb_flush_local_vmid); -KVM_NVHE_ALIAS (__kvm_tlb_flush_vmid); -KVM_NVHE_ALIAS (__kvm_tlb_flush_vmid_ipa); -/* Symbols defined in vgic-v3-sr.c (not yet compiled with nVHE build rules). */ KVM_NVHE_ALIAS (__vgic_v3_get_ich_vtr_el2);KVM_NVHE_ALIAS (__vgic_v3_init_lrs);
@@ -113,6 +107,14 @@ KVM_NVHE_ALIAS(panic);/* Vectors installed by hyp-init on reset HVC. */ KVM_NVHE_ALIAS (__hyp_stub_vectors); +/* Kernel symbol used by icache_is_vpipt(). */ +KVM_NVHE_ALIAS (__icache_flags); + +/* Kernel symbols needed for cpus_have_final/const_caps checks. */ +KVM_NVHE_ALIAS (arm64_const_caps_ready); +KVM_NVHE_ALIAS (cpu_hwcap_keys); +KVM_NVHE_ALIAS (cpu_hwcaps); +#endif /* CONFIG_KVM */ #endif /* __ARM64_KERNEL_IMAGE_VARS_H */
arch/arm64/kvm/hyp/Makefile +1 -1
@@ -14,7 +14,7 @@ obj-$(CONFIG_KVM) += hyp.o vhe/ nvhe/ obj-$(CONFIG_KVM_INDIRECT_VECTORS) += smccc_wa.o hyp-y := vgic-v3-sr.o timer-sr.o aarch32.o vgic-v2-cpuif-proxy.o sysreg-sr.o \ - debug-sr.o entry.o switch.o fpsimd.o tlb.o + debug-sr.o entry.o switch.o fpsimd.o # KVM code is run at a different exception code with a different map, so # compiler instrumentation that inserts callbacks or checks into the code may
arch/arm64/kvm/hyp/nvhe/Makefile +1 -1
@@ -6,7 +6,7 @@ asflags-y := -D__KVM_NVHE_HYPERVISOR__ ccflags-y := -D__KVM_NVHE_HYPERVISOR__ -obj-y := hyp-init.o ../hyp-entry.o +obj-y := tlb.o hyp-init.o ../hyp-entry.o obj-y := $(patsubst %.o,%.hyp.o,$(obj-y)) extra-y := $(patsubst %.hyp.o,%.hyp.tmp.o,$(obj-y))
arch/arm64/kvm/hyp/nvhe/tlb.c renamed from arch/arm64/kvm/hyp/tlb.c +5 -89
124 lines not on this page · raw message
arch/arm64/kvm/hyp/vhe/Makefile +1 -1
@@ -6,7 +6,7 @@ asflags-y := -D__KVM_VHE_HYPERVISOR__ ccflags-y := -D__KVM_VHE_HYPERVISOR__ -obj-y := ../hyp-entry.o +obj-y := tlb.o ../hyp-entry.o # KVM code is run at a different exception code with a different map, so # compiler instrumentation that inserts callbacks or checks into the code may
arch/arm64/kvm/hyp/vhe/tlb.c new file +162 -0
162 lines not on this page · raw message
Signature · 6 lines
2.27.0 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Marc Zyngier
maintainerRe: [PATCH v4 08/15] arm64: kvm: Duplicate hyp/tlb.c for VHE/nVHE
Quoted 16 lines · David Brazdil
tlb.ccontains code for flushing the TLB, with code shared between VHE/nVHE. Because common code is small, duplicatetlb.cand specialize each copy for VHE/nVHE.Signed-off-by David Brazdil <[email protected]>--- arch/arm64/kernel/image-vars.h | 14 +-- arch/arm64/kvm/hyp/Makefile | 2 +- arch/arm64/kvm/hyp/nvhe/Makefile | 2 +- arch/arm64/kvm/hyp/{ => nvhe}/tlb.c | 94 +--------------- arch/arm64/kvm/hyp/vhe/Makefile | 2 +- arch/arm64/kvm/hyp/vhe/tlb.c | 162 ++++++++++++++++++++++++++++ 6 files changed, 178 insertions(+), 98 deletions(-) rename arch/arm64/kvm/hyp/{ => nvhe}/tlb.c (62%) create mode 100644 arch/arm64/kvm/hyp/vhe/tlb.c
[...]
Quoted 17 lines
arch/arm64/kvm/hyp/nvhe/tlb.c renamed from arch/arm64/kvm/hyp/tlb.c +0
-2@@ -4,8 +4,6 @@* Author: Marc Zyngier <[email protected]> */ -#include <linux/irqflags.h> -#include <asm/kvm_hyp.h> #include <asm/kvm_mmu.h> #include <asm/tlbflush.h>
arch/arm64/kvm/hyp/nvhe/tlb.c struct tlb_inv_context { · line 15
Quoted 2 lines
arch/arm64/kvm/hyp/nvhe/tlb.c renamed from arch/arm64/kvm/hyp/tlb.c +0
-0@@ -16,52 +14,8 @@ struct tlb_inv_context {u64 sctlr; };
nit: You seem to have overlooked that some of the tlb_inv_context fields are now unused. I plan to squash the following patch in:
arch/arm64/kvm/hyp/nvhe/tlb.c +0 -2
@@ -9,9 +9,7 @@#include <asm/tlbflush.h> struct tlb_inv_context { -unsigned long flags;u64 tcr; -u64 sctlr; };static void __tlb_switch_to_guest (struct kvm *kvm,struct tlb_inv_context *cxt)
Otherwise, this looks good to me.
Thanks,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
Marc Zyngier
maintainerRe: [PATCH v4 08/15] arm64: kvm: Duplicate hyp/tlb.c for VHE/nVHE
In reply to David BrazdilQuoted 17 lines · David Brazdil
tlb.ccontains code for flushing the TLB, with code shared between VHE/nVHE. Because common code is small, duplicatetlb.cand specialize each copy for VHE/nVHE.Signed-off-by David Brazdil <[email protected]>--- arch/arm64/kernel/image-vars.h | 14 +-- arch/arm64/kvm/hyp/Makefile | 2 +- arch/arm64/kvm/hyp/nvhe/Makefile | 2 +- arch/arm64/kvm/hyp/{ => nvhe}/tlb.c | 94 +--------------- arch/arm64/kvm/hyp/vhe/Makefile | 2 +- arch/arm64/kvm/hyp/vhe/tlb.c | 162 ++++++++++++++++++++++++++++ 6 files changed, 178 insertions(+), 98 deletions(-) rename arch/arm64/kvm/hyp/{ => nvhe}/tlb.c (62%) create mode 100644 arch/arm64/kvm/hyp/vhe/tlb.c
[...]
Quoted 5 lines
arch/arm64/kvm/hyp/vhe/tlb.c new file +0
-0
[...]
arch/arm64/kvm/hyp/vhe/tlb.c line 88
Quoted 8 lines
arch/arm64/kvm/hyp/vhe/tlb.c new file +8
-0+void __kvm_tlb_flush_vmid_ipa (struct kvm *kvm,phys_addr_t ipa) +{ +struct tlb_inv_context cxt; + +dsb (ishst); + +/* Switch to requested VMID */ + kvm =kern_hyp_va (kvm);
nit: this is now superfluous. I'll drop it locally.
Thanks,
M.
Signature · 5 lines
Without deviation from the norm, progress is not possible. _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PATCH v4 9/15 arm64: kvm: Split hyp/switch.c to VHE/nVHE
In reply to David Brazdilswitch.c implements context-switching for KVM, with large parts shared between VHE/nVHE. These common routines are moved to a header file, VHE-specific code is moved to vhe/switch.c and nVHE-specific code is moved to nvhe/switch.c.
Previously __kvm_vcpu_run needed a different symbol name for VHE/nVHE. This is cleaned up and the caller in arm.c simplified.
--- arch/arm64/include/asm/kvm_asm.h | 4 +- arch/arm64/include/asm/kvm_hyp.h | 6 + arch/arm64/kernel/image-vars.h | 37 +- arch/arm64/kvm/arm.c | 6 +- arch/arm64/kvm/hyp/Makefile | 2 +- arch/arm64/kvm/hyp/hyp-entry.S | 2 + arch/arm64/kvm/hyp/include/hyp/switch.h | 509 +++++++++++++ arch/arm64/kvm/hyp/nvhe/Makefile | 2 +- arch/arm64/kvm/hyp/nvhe/switch.c | 271 +++++++ arch/arm64/kvm/hyp/switch.c | 936 ------------------------ arch/arm64/kvm/hyp/sysreg-sr.c | 4 +- arch/arm64/kvm/hyp/vhe/Makefile | 2 +- arch/arm64/kvm/hyp/vhe/switch.c | 219 ++++++ 13 files changed, 1048 insertions(+), 952 deletions(-) create mode 100644 arch/arm64/kvm/hyp/include/hyp/switch.h create mode 100644 arch/arm64/kvm/hyp/nvhe/switch.c delete mode 100644 arch/arm64/kvm/hyp/switch.c create mode 100644 arch/arm64/kvm/hyp/vhe/switch.c
arch/arm64/include/asm/kvm_asm.h +1 -3
@@ -96,9 +96,7 @@ extern void __kvm_tlb_flush_local_vmid(struct kvm_vcpu *vcpu);extern void __kvm_timer_set_cntvoff (u64 cntvoff); -extern int kvm_vcpu_run_vhe (struct kvm_vcpu *vcpu); - -extern int __kvm_vcpu_run_nvhe (struct kvm_vcpu *vcpu); +extern int __kvm_vcpu_run (struct kvm_vcpu *vcpu);extern void __kvm_enable_ssbs (void );
arch/arm64/include/asm/kvm_hyp.h +6 -0
@@ -81,11 +81,17 @@ void __debug_switch_to_host(struct kvm_vcpu *vcpu);void __fpsimd_save_state (struct user_fpsimd_state *fp_regs);void __fpsimd_restore_state (struct user_fpsimd_state *fp_regs); +#ifndef __KVM_NVHE_HYPERVISOR__void activate_traps_vhe_load (struct kvm_vcpu *vcpu);void deactivate_traps_vhe_put (void ); +#endif u64 __guest_enter (struct kvm_vcpu *vcpu,struct kvm_cpu_context *host_ctxt); + +void __noreturn hyp_panic (struct kvm_cpu_context *host_ctxt); +#ifdef __KVM_NVHE_HYPERVISOR__void __noreturn __hyp_do_panic (unsigned long , ...); +#endif #endif /* __ARM64_KVM_HYP_H__ */
arch/arm64/kernel/image-vars.h +34 -3
@@ -63,30 +63,50 @@ __efistub__ctype = _ctype;#define KVM_NVHE_ALIAS (sym) __kvm_nvhe_##sym = sym; +/* Symbols defined in aarch32.c (not yet compiled with nVHE build rules). */ +KVM_NVHE_ALIAS (kvm_skip_instr32); +/* Symbols defined in debug-sr.c (not yet compiled with nVHE build rules). */ +KVM_NVHE_ALIAS (__debug_switch_to_guest); +KVM_NVHE_ALIAS (__debug_switch_to_host);KVM_NVHE_ALIAS (__kvm_get_mdcr_el2);/* Symbols defined in entry.S (not yet compiled with nVHE build rules). */ +KVM_NVHE_ALIAS (__guest_enter);KVM_NVHE_ALIAS (__guest_exit);KVM_NVHE_ALIAS (abort_guest_exit_end);KVM_NVHE_ALIAS (abort_guest_exit_start); -/* Symbols defined in switch.c (not yet compiled with nVHE build rules). */ -KVM_NVHE_ALIAS (__kvm_vcpu_run_nvhe); -KVM_NVHE_ALIAS (hyp_panic); +/* Symbols defined in fpsimd.S (not yet compiled with nVHE build rules). */ +KVM_NVHE_ALIAS (__fpsimd_restore_state); +KVM_NVHE_ALIAS (__fpsimd_save_state);/* Symbols defined in sysreg-sr.c (not yet compiled with nVHE build rules). */ KVM_NVHE_ALIAS (__kvm_enable_ssbs); +KVM_NVHE_ALIAS (__sysreg32_restore_state); +KVM_NVHE_ALIAS (__sysreg32_save_state); +KVM_NVHE_ALIAS (__sysreg_restore_state_nvhe); +KVM_NVHE_ALIAS (__sysreg_save_state_nvhe);/* Symbols defined in timer-sr.c (not yet compiled with nVHE build rules). */ KVM_NVHE_ALIAS (__kvm_timer_set_cntvoff); +KVM_NVHE_ALIAS (__timer_disable_traps); +KVM_NVHE_ALIAS (__timer_enable_traps); + +/* Symbols defined in vgic-v2-cpuif-proxy.c (not yet compiled with nVHE build rules). */ +KVM_NVHE_ALIAS (__vgic_v2_perform_cpuif_access);/* Symbols defined in vgic-v3-sr.c (not yet compiled with nVHE build rules). */ +KVM_NVHE_ALIAS (__vgic_v3_activate_traps); +KVM_NVHE_ALIAS (__vgic_v3_deactivate_traps);KVM_NVHE_ALIAS (__vgic_v3_get_ich_vtr_el2);KVM_NVHE_ALIAS (__vgic_v3_init_lrs); +KVM_NVHE_ALIAS (__vgic_v3_perform_cpuif_access);KVM_NVHE_ALIAS (__vgic_v3_read_vmcr);KVM_NVHE_ALIAS (__vgic_v3_restore_aprs); +KVM_NVHE_ALIAS (__vgic_v3_restore_state);KVM_NVHE_ALIAS (__vgic_v3_save_aprs); +KVM_NVHE_ALIAS (__vgic_v3_save_state);KVM_NVHE_ALIAS (__vgic_v3_write_vmcr);/* Alternative callbacks for init-time patching of nVHE hyp code. */
@@ -97,11 +117,13 @@ KVM_NVHE_ALIAS(kvm_update_va_mask);/* Global kernel state accessed by nVHE hyp code. */ KVM_NVHE_ALIAS (arm64_ssbd_callback_required);KVM_NVHE_ALIAS (kvm_host_data); +KVM_NVHE_ALIAS (kvm_vgic_global_state);/* Kernel constant needed to compute idmap addresses. */ KVM_NVHE_ALIAS (kimage_voffset);/* Kernel symbols used to call panic() from nVHE hyp code (via ERET). */ +KVM_NVHE_ALIAS (__hyp_panic_string);KVM_NVHE_ALIAS (panic);/* Vectors installed by hyp-init on reset HVC. */
@@ -115,6 +137,15 @@ KVM_NVHE_ALIAS(arm64_const_caps_ready);KVM_NVHE_ALIAS (cpu_hwcap_keys);KVM_NVHE_ALIAS (cpu_hwcaps); +/* Static keys which are set if a vGIC trap should be handled in hyp. */ +KVM_NVHE_ALIAS (vgic_v2_cpuif_trap); +KVM_NVHE_ALIAS (vgic_v3_cpuif_trap); + +/* Static key checked in pmr_sync(). */ +#ifdef CONFIG_ARM64_PSEUDO_NMI +KVM_NVHE_ALIAS (gic_pmr_sync); +#endif +#endif /* CONFIG_KVM */ #endif /* __ARM64_KERNEL_IMAGE_VARS_H */
arch/arm64/kvm/arm.c +1 -5
@@ -748,11 +748,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)trace_kvm_entry (*vcpu_pc (vcpu));guest_enter_irqoff (); -if (has_vhe ()) { - ret =kvm_vcpu_run_vhe (vcpu); - }else { - ret =kvm_call_hyp_ret (__kvm_vcpu_run_nvhe, vcpu); - } + ret =kvm_call_hyp_ret (__kvm_vcpu_run, vcpu); vcpu->mode =OUTSIDE_GUEST_MODE ; vcpu->stat.exits++;
arch/arm64/kvm/hyp/Makefile +1 -1
@@ -14,7 +14,7 @@ obj-$(CONFIG_KVM) += hyp.o vhe/ nvhe/ obj-$(CONFIG_KVM_INDIRECT_VECTORS) += smccc_wa.o hyp-y := vgic-v3-sr.o timer-sr.o aarch32.o vgic-v2-cpuif-proxy.o sysreg-sr.o \ - debug-sr.o entry.o switch.o fpsimd.o + debug-sr.o entry.o fpsimd.o # KVM code is run at a different exception code with a different map, so # compiler instrumentation that inserts callbacks or checks into the code may
arch/arm64/kvm/hyp/hyp-entry.S +2 -0
@@ -182,6 +182,7 @@ el2_error: eret sb +#ifdef __KVM_NVHE_HYPERVISOR__ SYM_FUNC_START(__hyp_do_panic) mov lr, #(PSR_F_BIT | PSR_I_BIT | PSR_A_BIT | PSR_D_BIT |\ PSR_MODE_EL1h)
@@ -191,6 +192,7 @@ SYM_FUNC_START(__hyp_do_panic) eret sb SYM_FUNC_END(__hyp_do_panic) +#endif SYM_CODE_START(__hyp_panic) get_host_ctxt x0, x1
arch/arm64/kvm/hyp/include/hyp/switch.h new file +509 -0
509 lines not on this page · raw message
arch/arm64/kvm/hyp/nvhe/Makefile +1 -1
@@ -6,7 +6,7 @@ asflags-y := -D__KVM_NVHE_HYPERVISOR__ ccflags-y := -D__KVM_NVHE_HYPERVISOR__ -obj-y := tlb.o hyp-init.o ../hyp-entry.o +obj-y := switch.o tlb.o hyp-init.o ../hyp-entry.o obj-y := $(patsubst %.o,%.hyp.o,$(obj-y)) extra-y := $(patsubst %.hyp.o,%.hyp.tmp.o,$(obj-y))
arch/arm64/kvm/hyp/nvhe/switch.c new file +271 -0
271 lines not on this page · raw message
arch/arm64/kvm/hyp/switch.c deleted +0 -936
936 lines not on this page · raw message
arch/arm64/kvm/hyp/sysreg-sr.c +2 -2
@@ -114,7 +114,7 @@ static void __hyp_text __sysreg_restore_el1_state(struct kvm_cpu_context *ctxt)/* * Must only be done for guest registers, hence the context * test. We're coming from the host, so SCTLR.M is already -* set. Pairs with __activate_traps_nvhe(). +* set. Pairs with nVHE's __activate_traps(). */ write_sysreg_el1((ctxt->sys_regs[TCR_EL1] | TCR_EPD1_MASK | TCR_EPD0_MASK),
@@ -142,7 +142,7 @@ static void __hyp_text __sysreg_restore_el1_state(struct kvm_cpu_context *ctxt) ctxt->__hyp_running_vcpu) {/* * Must only be done for host registers, hence the context -* test. Pairs with __deactivate_traps_nvhe(). +* test. Pairs with nVHE's __deactivate_traps(). */ isb ();/*
arch/arm64/kvm/hyp/vhe/Makefile +1 -1
@@ -6,7 +6,7 @@ asflags-y := -D__KVM_VHE_HYPERVISOR__ ccflags-y := -D__KVM_VHE_HYPERVISOR__ -obj-y := tlb.o ../hyp-entry.o +obj-y := switch.o tlb.o ../hyp-entry.o # KVM code is run at a different exception code with a different map, so # compiler instrumentation that inserts callbacks or checks into the code may
arch/arm64/kvm/hyp/vhe/switch.c new file +219 -0
219 lines not on this page · raw message
Signature · 6 lines
2.27.0 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PATCH v4 10/15 arm64: kvm: Split hyp/debug-sr.c to VHE/nVHE
In reply to David Brazdildebug-sr.c contains KVM's code for context-switching debug registers, with some code shared between VHE/nVHE. These common routines are moved to a header file, VHE-specific code is moved to vhe/debug-sr.c and nVHE-specific code to nvhe/debug-sr.c.
Functions are slightly refactored to move code hidden behind has_vhe() checks to the corresponding .c files.
---
arch/arm64/kernel/image-vars.h | 5 --
arch/arm64/kvm/hyp/Makefile | 2 +-
.../{debug-sr.c => include/hyp/debug-sr.h} | 78 +++----------------
arch/arm64/kvm/hyp/nvhe/Makefile | 2 +-
arch/arm64/kvm/hyp/nvhe/debug-sr.c | 77 ++++++++++++++++++
arch/arm64/kvm/hyp/vhe/Makefile | 2 +-
arch/arm64/kvm/hyp/vhe/debug-sr.c | 26 +++++++
7 files changed, 118 insertions(+), 74 deletions(-)
rename arch/arm64/kvm/hyp/{debug-sr.c => include/hyp/debug-sr.h} (71%)
create mode 100644 arch/arm64/kvm/hyp/nvhe/debug-sr.c
create mode 100644 arch/arm64/kvm/hyp/vhe/debug-sr.carch/arm64/kernel/image-vars.h +0 -5
@@ -66,11 +66,6 @@ __efistub__ctype = _ctype;/* Symbols defined in aarch32.c (not yet compiled with nVHE build rules). */ KVM_NVHE_ALIAS (kvm_skip_instr32); -/* Symbols defined in debug-sr.c (not yet compiled with nVHE build rules). */ -KVM_NVHE_ALIAS (__debug_switch_to_guest); -KVM_NVHE_ALIAS (__debug_switch_to_host); -KVM_NVHE_ALIAS (__kvm_get_mdcr_el2); -/* Symbols defined in entry.S (not yet compiled with nVHE build rules). */ KVM_NVHE_ALIAS (__guest_enter);KVM_NVHE_ALIAS (__guest_exit);
arch/arm64/kvm/hyp/Makefile +1 -1
@@ -14,7 +14,7 @@ obj-$(CONFIG_KVM) += hyp.o vhe/ nvhe/ obj-$(CONFIG_KVM_INDIRECT_VECTORS) += smccc_wa.o hyp-y := vgic-v3-sr.o timer-sr.o aarch32.o vgic-v2-cpuif-proxy.o sysreg-sr.o \ - debug-sr.o entry.o fpsimd.o + entry.o fpsimd.o # KVM code is run at a different exception code with a different map, so # compiler instrumentation that inserts callbacks or checks into the code may
arch/arm64/kvm/hyp/include/hyp/debug-sr.h renamed from arch/arm64/kvm/hyp/debug-sr.c +12 -66
123 lines not on this page · raw message
arch/arm64/kvm/hyp/nvhe/Makefile +1 -1
@@ -6,7 +6,7 @@ asflags-y := -D__KVM_NVHE_HYPERVISOR__ ccflags-y := -D__KVM_NVHE_HYPERVISOR__ -obj-y := switch.o tlb.o hyp-init.o ../hyp-entry.o +obj-y := debug-sr.o switch.o tlb.o hyp-init.o ../hyp-entry.o obj-y := $(patsubst %.o,%.hyp.o,$(obj-y)) extra-y := $(patsubst %.hyp.o,%.hyp.tmp.o,$(obj-y))
arch/arm64/kvm/hyp/nvhe/debug-sr.c new file +77 -0
77 lines not on this page · raw message
arch/arm64/kvm/hyp/vhe/Makefile +1 -1
@@ -6,7 +6,7 @@ asflags-y := -D__KVM_VHE_HYPERVISOR__ ccflags-y := -D__KVM_VHE_HYPERVISOR__ -obj-y := switch.o tlb.o ../hyp-entry.o +obj-y := debug-sr.o switch.o tlb.o ../hyp-entry.o # KVM code is run at a different exception code with a different map, so # compiler instrumentation that inserts callbacks or checks into the code may
arch/arm64/kvm/hyp/vhe/debug-sr.c new file +26 -0
@@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2015 - ARM Ltd +* Author: Marc Zyngier <[email protected]> +*/ + +#include <hyp/debug-sr.h> + +#include <linux/kvm_host.h> + +#include <asm/kvm_hyp.h> + +void __debug_switch_to_guest (struct kvm_vcpu *vcpu) +{ +__debug_switch_to_guest_common (vcpu); +} + +void __debug_switch_to_host (struct kvm_vcpu *vcpu) +{ +__debug_switch_to_host_common (vcpu); +} + +u32 __kvm_get_mdcr_el2 (void ) +{ +return read_sysreg (mdcr_el2); +}
Signature · 6 lines
2.27.0 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PATCH v4 11/15 arm64: kvm: Split hyp/sysreg-sr.c to VHE/nVHE
In reply to David Brazdilsysreg-sr.c contains KVM's code for saving/restoring system registers, with some code shared between VHE/nVHE. These common routines are moved to a header file, VHE-specific code is moved to vhe/sysreg-sr.c and nVHE-specific code to nvhe/sysreg-sr.c.
---
arch/arm64/include/asm/kvm_host.h | 6 +-
arch/arm64/include/asm/kvm_hyp.h | 5 +-
arch/arm64/kernel/image-vars.h | 7 -
arch/arm64/kvm/arm.c | 8 +-
arch/arm64/kvm/hyp/Makefile | 4 +-
.../{sysreg-sr.c => include/hyp/sysreg-sr.h} | 158 ++----------------
arch/arm64/kvm/hyp/nvhe/Makefile | 2 +-
arch/arm64/kvm/hyp/nvhe/switch.c | 1 +
arch/arm64/kvm/hyp/nvhe/sysreg-sr.c | 46 +++++
arch/arm64/kvm/hyp/vhe/Makefile | 2 +-
arch/arm64/kvm/hyp/vhe/switch.c | 2 +-
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 114 +++++++++++++
12 files changed, 191 insertions(+), 164 deletions(-)
rename arch/arm64/kvm/hyp/{sysreg-sr.c => include/hyp/sysreg-sr.h} (56%)
create mode 100644 arch/arm64/kvm/hyp/nvhe/sysreg-sr.c
create mode 100644 arch/arm64/kvm/hyp/vhe/sysreg-sr.carch/arm64/include/asm/kvm_host.h +3 -3
@@ -338,7 +338,7 @@ struct kvm_vcpu_arch {struct vcpu_reset_state reset_state;/* True when deferrable sysregs are loaded on the physical CPU, -* see kvm_vcpu_load_sysregs and kvm_vcpu_put_sysregs. */ +* see kvm_vcpu_load_sysregs_vhe and kvm_vcpu_put_sysregs_vhe. */ bool sysregs_loaded_on_cpu;/* Guest PV state */
@@ -639,8 +639,8 @@ static inline int kvm_arm_have_ssbd(void) } } -void kvm_vcpu_load_sysregs (struct kvm_vcpu *vcpu); -void kvm_vcpu_put_sysregs (struct kvm_vcpu *vcpu); +void kvm_vcpu_load_sysregs_vhe (struct kvm_vcpu *vcpu); +void kvm_vcpu_put_sysregs_vhe (struct kvm_vcpu *vcpu);int kvm_set_ipa_limit (void );
arch/arm64/include/asm/kvm_hyp.h +3 -2
@@ -66,14 +66,15 @@ int __vgic_v3_perform_cpuif_access(struct kvm_vcpu *vcpu);void __timer_enable_traps (struct kvm_vcpu *vcpu);void __timer_disable_traps (struct kvm_vcpu *vcpu); +#ifdef __KVM_NVHE_HYPERVISOR__void __sysreg_save_state_nvhe (struct kvm_cpu_context *ctxt);void __sysreg_restore_state_nvhe (struct kvm_cpu_context *ctxt); +#else void sysreg_save_host_state_vhe (struct kvm_cpu_context *ctxt);void sysreg_restore_host_state_vhe (struct kvm_cpu_context *ctxt);void sysreg_save_guest_state_vhe (struct kvm_cpu_context *ctxt);void sysreg_restore_guest_state_vhe (struct kvm_cpu_context *ctxt); -void __sysreg32_save_state (struct kvm_vcpu *vcpu); -void __sysreg32_restore_state (struct kvm_vcpu *vcpu); +#endif void __debug_switch_to_guest (struct kvm_vcpu *vcpu);void __debug_switch_to_host (struct kvm_vcpu *vcpu);
arch/arm64/kernel/image-vars.h +0 -7
@@ -76,13 +76,6 @@ KVM_NVHE_ALIAS(abort_guest_exit_start);KVM_NVHE_ALIAS (__fpsimd_restore_state);KVM_NVHE_ALIAS (__fpsimd_save_state); -/* Symbols defined in sysreg-sr.c (not yet compiled with nVHE build rules). */ -KVM_NVHE_ALIAS (__kvm_enable_ssbs); -KVM_NVHE_ALIAS (__sysreg32_restore_state); -KVM_NVHE_ALIAS (__sysreg32_save_state); -KVM_NVHE_ALIAS (__sysreg_restore_state_nvhe); -KVM_NVHE_ALIAS (__sysreg_save_state_nvhe); -/* Symbols defined in timer-sr.c (not yet compiled with nVHE build rules). */ KVM_NVHE_ALIAS (__kvm_timer_set_cntvoff);KVM_NVHE_ALIAS (__timer_disable_traps);
arch/arm64/kvm/arm.c +5 -3
@@ -351,7 +351,8 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)kvm_vgic_load (vcpu);kvm_timer_vcpu_load (vcpu); -kvm_vcpu_load_sysregs (vcpu); +if (has_vhe ()) +kvm_vcpu_load_sysregs_vhe (vcpu);kvm_arch_vcpu_load_fp (vcpu);kvm_vcpu_pmu_restore_guest (vcpu);if (kvm_arm_is_pvtime_enabled (&vcpu->arch))
@@ -369,7 +370,8 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)void kvm_arch_vcpu_put (struct kvm_vcpu *vcpu) {kvm_arch_vcpu_put_fp (vcpu); -kvm_vcpu_put_sysregs (vcpu); +if (has_vhe ()) +kvm_vcpu_put_sysregs_vhe (vcpu);kvm_timer_vcpu_put (vcpu);kvm_vgic_put (vcpu);kvm_vcpu_pmu_restore_host (vcpu);
@@ -1302,7 +1304,7 @@ static void cpu_init_hyp_mode(void)*/ if (this_cpu_has_cap (ARM64_SSBS ) &&arm64_get_ssbd_state () ==ARM64_SSBD_FORCE_DISABLE ) { -kvm_call_hyp (__kvm_enable_ssbs); +kvm_call_hyp_nvhe (__kvm_enable_ssbs); } }
arch/arm64/kvm/hyp/Makefile +2 -2
@@ -13,8 +13,8 @@ subdir-ccflags-y := -I$(incdir) \ obj-$(CONFIG_KVM) += hyp.o vhe/ nvhe/ obj-$(CONFIG_KVM_INDIRECT_VECTORS) += smccc_wa.o -hyp-y := vgic-v3-sr.o timer-sr.o aarch32.o vgic-v2-cpuif-proxy.o sysreg-sr.o \ - entry.o fpsimd.o +hyp-y := vgic-v3-sr.o timer-sr.o aarch32.o vgic-v2-cpuif-proxy.o entry.o \ + fpsimd.o # KVM code is run at a different exception code with a different map, so # compiler instrumentation that inserts callbacks or checks into the code may
arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h renamed from arch/arm64/kvm/hyp/sysreg-sr.c +14 -144
221 lines not on this page · raw message
arch/arm64/kvm/hyp/nvhe/Makefile +1 -1
@@ -6,7 +6,7 @@ asflags-y := -D__KVM_NVHE_HYPERVISOR__ ccflags-y := -D__KVM_NVHE_HYPERVISOR__ -obj-y := debug-sr.o switch.o tlb.o hyp-init.o ../hyp-entry.o +obj-y := sysreg-sr.o debug-sr.o switch.o tlb.o hyp-init.o ../hyp-entry.o obj-y := $(patsubst %.o,%.hyp.o,$(obj-y)) extra-y := $(patsubst %.hyp.o,%.hyp.tmp.o,$(obj-y))
arch/arm64/kvm/hyp/nvhe/switch.c +1 -0
@@ -5,6 +5,7 @@*/ #include <hyp/switch.h> +#include <hyp/sysreg-sr.h> #include <linux/arm-smccc.h> #include <linux/kvm_host.h>
arch/arm64/kvm/hyp/nvhe/sysreg-sr.c new file +46 -0
46 lines not on this page · raw message
arch/arm64/kvm/hyp/vhe/Makefile +1 -1
@@ -6,7 +6,7 @@ asflags-y := -D__KVM_VHE_HYPERVISOR__ ccflags-y := -D__KVM_VHE_HYPERVISOR__ -obj-y := debug-sr.o switch.o tlb.o ../hyp-entry.o +obj-y := sysreg-sr.o debug-sr.o switch.o tlb.o ../hyp-entry.o # KVM code is run at a different exception code with a different map, so # compiler instrumentation that inserts callbacks or checks into the code may
arch/arm64/kvm/hyp/vhe/switch.c +1 -1
@@ -120,7 +120,7 @@ static int __kvm_vcpu_run_vhe(struct kvm_vcpu *vcpu)* HCR_EL2.TGE. * * We have already configured the guest's stage 1 translation in -* kvm_vcpu_load_sysregs above. We must now call __activate_vm +* kvm_vcpu_load_sysregs_vhe above. We must now call __activate_vm * before __activate_traps, because __activate_vm configures * stage 2 translation, and __activate_traps clear HCR_EL2.TGE * (among other things).
arch/arm64/kvm/hyp/vhe/sysreg-sr.c new file +114 -0
114 lines not on this page · raw message
Signature · 6 lines
2.27.0 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PATCH v4 12/15 arm64: kvm: Duplicate hyp/timer-sr.c for VHE/nVHE
In reply to David Brazdiltimer-sr.c contains a HVC handler for setting CNTVOFF_EL2 and two helper functions for controlling access to physical counter. The former is used by both VHE/nVHE and is duplicated, the latter are used only by nVHE and moved to nvhe/timer-sr.c.
---
arch/arm64/include/asm/kvm_hyp.h | 2 ++
arch/arm64/kernel/image-vars.h | 5 -----
arch/arm64/kvm/hyp/Makefile | 2 +-
arch/arm64/kvm/hyp/nvhe/Makefile | 3 ++-
arch/arm64/kvm/hyp/{ => nvhe}/timer-sr.c | 2 +-
arch/arm64/kvm/hyp/vhe/Makefile | 2 +-
arch/arm64/kvm/hyp/vhe/timer-sr.c | 12 ++++++++++++
7 files changed, 19 insertions(+), 9 deletions(-)
rename arch/arm64/kvm/hyp/{ => nvhe}/timer-sr.c (95%)
create mode 100644 arch/arm64/kvm/hyp/vhe/timer-sr.carch/arm64/include/asm/kvm_hyp.h +2 -0
@@ -63,8 +63,10 @@ void __vgic_v3_save_aprs(struct vgic_v3_cpu_if *cpu_if);void __vgic_v3_restore_aprs (struct vgic_v3_cpu_if *cpu_if);int __vgic_v3_perform_cpuif_access (struct kvm_vcpu *vcpu); +#ifdef __KVM_NVHE_HYPERVISOR__void __timer_enable_traps (struct kvm_vcpu *vcpu);void __timer_disable_traps (struct kvm_vcpu *vcpu); +#endif #ifdef __KVM_NVHE_HYPERVISOR__void __sysreg_save_state_nvhe (struct kvm_cpu_context *ctxt);
arch/arm64/kernel/image-vars.h +0 -5
@@ -76,11 +76,6 @@ KVM_NVHE_ALIAS(abort_guest_exit_start);KVM_NVHE_ALIAS (__fpsimd_restore_state);KVM_NVHE_ALIAS (__fpsimd_save_state); -/* Symbols defined in timer-sr.c (not yet compiled with nVHE build rules). */ -KVM_NVHE_ALIAS (__kvm_timer_set_cntvoff); -KVM_NVHE_ALIAS (__timer_disable_traps); -KVM_NVHE_ALIAS (__timer_enable_traps); -/* Symbols defined in vgic-v2-cpuif-proxy.c (not yet compiled with nVHE build rules). */ KVM_NVHE_ALIAS (__vgic_v2_perform_cpuif_access);
arch/arm64/kvm/hyp/Makefile +1 -1
@@ -13,7 +13,7 @@ subdir-ccflags-y := -I$(incdir) \ obj-$(CONFIG_KVM) += hyp.o vhe/ nvhe/ obj-$(CONFIG_KVM_INDIRECT_VECTORS) += smccc_wa.o -hyp-y := vgic-v3-sr.o timer-sr.o aarch32.o vgic-v2-cpuif-proxy.o entry.o \ +hyp-y := vgic-v3-sr.o aarch32.o vgic-v2-cpuif-proxy.o entry.o \ fpsimd.o # KVM code is run at a different exception code with a different map, so
arch/arm64/kvm/hyp/nvhe/Makefile +2 -1
@@ -6,7 +6,8 @@ asflags-y := -D__KVM_NVHE_HYPERVISOR__ ccflags-y := -D__KVM_NVHE_HYPERVISOR__ -obj-y := sysreg-sr.o debug-sr.o switch.o tlb.o hyp-init.o ../hyp-entry.o +obj-y := timer-sr.o sysreg-sr.o debug-sr.o switch.o tlb.o hyp-init.o \ + ../hyp-entry.o obj-y := $(patsubst %.o,%.hyp.o,$(obj-y)) extra-y := $(patsubst %.hyp.o,%.hyp.tmp.o,$(obj-y))
arch/arm64/kvm/hyp/nvhe/timer-sr.c renamed from arch/arm64/kvm/hyp/timer-sr.c +1 -1
@@ -10,7 +10,7 @@#include <asm/kvm_hyp.h> -void __hyp_text __kvm_timer_set_cntvoff(u64 cntvoff) +void __kvm_timer_set_cntvoff (u64 cntvoff) {write_sysreg (cntvoff, cntvoff_el2); }
arch/arm64/kvm/hyp/vhe/Makefile +1 -1
@@ -6,7 +6,7 @@ asflags-y := -D__KVM_VHE_HYPERVISOR__ ccflags-y := -D__KVM_VHE_HYPERVISOR__ -obj-y := sysreg-sr.o debug-sr.o switch.o tlb.o ../hyp-entry.o +obj-y := timer-sr.o sysreg-sr.o debug-sr.o switch.o tlb.o ../hyp-entry.o # KVM code is run at a different exception code with a different map, so # compiler instrumentation that inserts callbacks or checks into the code may
arch/arm64/kvm/hyp/vhe/timer-sr.c new file +12 -0
@@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2012-2015 - ARM Ltd +* Author: Marc Zyngier <[email protected]> +*/ + +#include <asm/kvm_hyp.h> + +void __kvm_timer_set_cntvoff (u64 cntvoff) +{ +write_sysreg (cntvoff, cntvoff_el2); +}
Signature · 6 lines
2.27.0 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PATCH v4 13/15 arm64: kvm: Compile remaining hyp/ files for both VHE/nVHE
In reply to David BrazdilThe following files in hyp/ contain only code shared by VHE/nVHE:
vgic-v3-sr.c, aarch32.c, vgic-v2-cpuif-proxy.c, entry.S, fpsimd.S
Compile them under both configurations. Deletions in image-vars.h reflect eliminated dependencies of nVHE code on the rest of the kernel.
--- arch/arm64/kernel/image-vars.h | 29 ----------------------------- arch/arm64/kvm/hyp/Makefile | 13 +------------ arch/arm64/kvm/hyp/nvhe/Makefile | 5 +++-- arch/arm64/kvm/hyp/vhe/Makefile | 4 +++- 4 files changed, 7 insertions(+), 44 deletions(-)
arch/arm64/kernel/image-vars.h +0 -29
@@ -63,35 +63,6 @@ __efistub__ctype = _ctype;#define KVM_NVHE_ALIAS (sym) __kvm_nvhe_##sym = sym; -/* Symbols defined in aarch32.c (not yet compiled with nVHE build rules). */ -KVM_NVHE_ALIAS (kvm_skip_instr32); - -/* Symbols defined in entry.S (not yet compiled with nVHE build rules). */ -KVM_NVHE_ALIAS (__guest_enter); -KVM_NVHE_ALIAS (__guest_exit); -KVM_NVHE_ALIAS (abort_guest_exit_end); -KVM_NVHE_ALIAS (abort_guest_exit_start); - -/* Symbols defined in fpsimd.S (not yet compiled with nVHE build rules). */ -KVM_NVHE_ALIAS (__fpsimd_restore_state); -KVM_NVHE_ALIAS (__fpsimd_save_state); - -/* Symbols defined in vgic-v2-cpuif-proxy.c (not yet compiled with nVHE build rules). */ -KVM_NVHE_ALIAS (__vgic_v2_perform_cpuif_access); - -/* Symbols defined in vgic-v3-sr.c (not yet compiled with nVHE build rules). */ -KVM_NVHE_ALIAS (__vgic_v3_activate_traps); -KVM_NVHE_ALIAS (__vgic_v3_deactivate_traps); -KVM_NVHE_ALIAS (__vgic_v3_get_ich_vtr_el2); -KVM_NVHE_ALIAS (__vgic_v3_init_lrs); -KVM_NVHE_ALIAS (__vgic_v3_perform_cpuif_access); -KVM_NVHE_ALIAS (__vgic_v3_read_vmcr); -KVM_NVHE_ALIAS (__vgic_v3_restore_aprs); -KVM_NVHE_ALIAS (__vgic_v3_restore_state); -KVM_NVHE_ALIAS (__vgic_v3_save_aprs); -KVM_NVHE_ALIAS (__vgic_v3_save_state); -KVM_NVHE_ALIAS (__vgic_v3_write_vmcr); -/* Alternative callbacks for init-time patching of nVHE hyp code. */ KVM_NVHE_ALIAS (arm64_enable_wa2_handling);KVM_NVHE_ALIAS (kvm_patch_vector_branch);
arch/arm64/kvm/hyp/Makefile +1 -12
@@ -10,16 +10,5 @@ subdir-ccflags-y := -I$(incdir) \ -DDISABLE_BRANCH_PROFILING \ $(DISABLE_STACKLEAK_PLUGIN) -obj-$(CONFIG_KVM) += hyp.o vhe/ nvhe/ +obj-$(CONFIG_KVM) += vhe/ nvhe/ obj-$(CONFIG_KVM_INDIRECT_VECTORS) += smccc_wa.o - -hyp-y := vgic-v3-sr.o aarch32.o vgic-v2-cpuif-proxy.o entry.o \ - fpsimd.o - -# KVM code is run at a different exception code with a different map, so -# compiler instrumentation that inserts callbacks or checks into the code may -# cause crashes. Just disable it. -GCOV_PROFILE := n -KASAN_SANITIZE := n -UBSAN_SANITIZE := n -KCOV_INSTRUMENT := n
arch/arm64/kvm/hyp/nvhe/Makefile +3 -2
@@ -6,8 +6,9 @@ asflags-y := -D__KVM_NVHE_HYPERVISOR__ ccflags-y := -D__KVM_NVHE_HYPERVISOR__ -obj-y := timer-sr.o sysreg-sr.o debug-sr.o switch.o tlb.o hyp-init.o \ - ../hyp-entry.o +obj-y := timer-sr.o sysreg-sr.o debug-sr.o switch.o tlb.o hyp-init.o +obj-y += ../vgic-v3-sr.o ../aarch32.o ../vgic-v2-cpuif-proxy.o ../entry.o \ + ../fpsimd.o ../hyp-entry.o obj-y := $(patsubst %.o,%.hyp.o,$(obj-y)) extra-y := $(patsubst %.hyp.o,%.hyp.tmp.o,$(obj-y))
arch/arm64/kvm/hyp/vhe/Makefile +3 -1
@@ -6,7 +6,9 @@ asflags-y := -D__KVM_VHE_HYPERVISOR__ ccflags-y := -D__KVM_VHE_HYPERVISOR__ -obj-y := timer-sr.o sysreg-sr.o debug-sr.o switch.o tlb.o ../hyp-entry.o +obj-y := timer-sr.o sysreg-sr.o debug-sr.o switch.o tlb.o +obj-y += ../vgic-v3-sr.o ../aarch32.o ../vgic-v2-cpuif-proxy.o ../entry.o \ + ../fpsimd.o ../hyp-entry.o # KVM code is run at a different exception code with a different map, so # compiler instrumentation that inserts callbacks or checks into the code may
Signature · 6 lines
2.27.0 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PATCH v4 14/15 arm64: kvm: Remove __hyp_text macro, use build rules instead
In reply to David BrazdilWith nVHE code now fully separated from the rest of the kernel, the effects of the __hyp_text macro (which had to be applied on all nVHE code) can be achieved with build rules instead. The macro used to:
(a) move code to .hyp.text ELF section, now done by renaming .text using objcopy, and
(b) notrace and __noscs would negate effects of CC_FLAGS_FTRACE and CC_FLAGS_SCS, respectivelly, now those flags are erased from KBUILD_CFLAGS (same way as in EFI stub).
Note that by removing __hyp_text from code shared with VHE, all VHE code is now compiled into .text and without notrace and __noscs.
Use of '.pushsection .hyp.text' removed from assembly files as this is now also covered by the build rules.
For MAINTAINERS: if needed to re-run, uses of macro were removed with the following command. Formatting was fixed up manually.
find arch/arm64/kvm/hyp -type f -name '*.c' -o -name '*.h' \
-exec sed -i 's/ __hyp_text//g' {} +--- arch/arm64/include/asm/kvm_emulate.h | 2 +- arch/arm64/include/asm/kvm_hyp.h | 2 - arch/arm64/kvm/hyp/aarch32.c | 6 +- arch/arm64/kvm/hyp/entry.S | 1 - arch/arm64/kvm/hyp/fpsimd.S | 1 - arch/arm64/kvm/hyp/hyp-entry.S | 1 - arch/arm64/kvm/hyp/include/hyp/debug-sr.h | 16 +-- arch/arm64/kvm/hyp/include/hyp/switch.h | 36 +++--- arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h | 20 ++-- arch/arm64/kvm/hyp/nvhe/Makefile | 8 +- arch/arm64/kvm/hyp/nvhe/debug-sr.c | 10 +- arch/arm64/kvm/hyp/nvhe/switch.c | 18 +-- arch/arm64/kvm/hyp/nvhe/sysreg-sr.c | 6 +- arch/arm64/kvm/hyp/nvhe/timer-sr.c | 4 +- arch/arm64/kvm/hyp/nvhe/tlb.c | 14 +-- arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c | 4 +- arch/arm64/kvm/hyp/vgic-v3-sr.c | 130 +++++++++------------ 17 files changed, 132 insertions(+), 147 deletions(-)
arch/arm64/include/asm/kvm_emulate.h +1 -1
@@ -516,7 +516,7 @@ static __always_inline void kvm_skip_instr(struct kvm_vcpu *vcpu, bool is_wide_i* Skip an instruction which has been emulated at hyp while most guest sysregs * are live. */ -static __always_inline void __hyp_text __kvm_skip_instr(struct kvm_vcpu *vcpu) +static __always_inline void __kvm_skip_instr(struct kvm_vcpu *vcpu) { *vcpu_pc (vcpu) =read_sysreg_el2 (SYS_ELR ); vcpu->arch.ctxt.gp_regs.regs.pstate =read_sysreg_el2 (SYS_SPSR );
arch/arm64/include/asm/kvm_hyp.h +0 -2
@@ -12,8 +12,6 @@#include <asm/alternative.h> #include <asm/sysreg.h> -#define __hyp_text __section(.hyp.text) notrace __noscs -#define read_sysreg_elx (r,nvh,vh) \ ({ \ u64 reg; \
arch/arm64/kvm/hyp/aarch32.c +3 -3
@@ -44,7 +44,7 @@ static const unsigned short cc_map[16] = {/* * Check if a trapped instruction should have been executed or not. */ -bool __hyp_text kvm_condition_valid32(const struct kvm_vcpu *vcpu) +bool kvm_condition_valid32 (const struct kvm_vcpu *vcpu) {unsigned long cpsr;u32 cpsr_cond;
@@ -93,7 +93,7 @@ bool __hyp_text kvm_condition_valid32(const struct kvm_vcpu *vcpu)* * IT[7:0] -> CPSR[26:25],CPSR[15:10] */ -static void __hyp_text kvm_adjust_itstate(struct kvm_vcpu *vcpu) +static void kvm_adjust_itstate (struct kvm_vcpu *vcpu) {unsigned long itbits, cond;unsigned long cpsr = *vcpu_cpsr (vcpu);
@@ -123,7 +123,7 @@ static void __hyp_text kvm_adjust_itstate(struct kvm_vcpu *vcpu)* kvm_skip_instr - skip a trapped instruction and proceed to the next * @vcpu: The vcpu pointer */ -void __hyp_text kvm_skip_instr32(struct kvm_vcpu *vcpu, bool is_wide_instr) +void kvm_skip_instr32 (struct kvm_vcpu *vcpu,bool is_wide_instr) {u32 pc = *vcpu_pc (vcpu);bool is_thumb;
arch/arm64/kvm/hyp/entry.S +0 -1
@@ -21,7 +21,6 @@ #define CPU_SP_EL0_OFFSET (CPU_XREG_OFFSET(30) + 8) .text - .pushsection .hyp.text, "ax" /* * We treat x18 as callee-saved as the host may use it as a platform
arch/arm64/kvm/hyp/fpsimd.S +0 -1
@@ -9,7 +9,6 @@ #include <asm/fpsimdmacros.h> .text - .pushsection .hyp.text, "ax" SYM_FUNC_START(__fpsimd_save_state) fpsimd_save x0, 1
arch/arm64/kvm/hyp/hyp-entry.S +0 -1
@@ -16,7 +16,6 @@ #include <asm/mmu.h> .text - .pushsection .hyp.text, "ax" .macro do_el2_call /*
arch/arm64/kvm/hyp/include/hyp/debug-sr.h +8 -8
@@ -88,9 +88,9 @@default :write_debug (ptr[0 ], reg,0 ); \ } -static inline void __hyp_text __debug_save_state(struct kvm_vcpu *vcpu, -struct kvm_guest_debug_arch *dbg, -struct kvm_cpu_context *ctxt) +static inline void __debug_save_state (struct kvm_vcpu *vcpu, +struct kvm_guest_debug_arch *dbg, +struct kvm_cpu_context *ctxt) {u64 aa64dfr0;int brps, wrps;
@@ -107,9 +107,9 @@ static inline void __hyp_text __debug_save_state(struct kvm_vcpu *vcpu, ctxt->sys_regs[MDCCINT_EL1 ] =read_sysreg (mdccint_el1); } -static inline void __hyp_text __debug_restore_state(struct kvm_vcpu *vcpu, -struct kvm_guest_debug_arch *dbg, -struct kvm_cpu_context *ctxt) +static inline void __debug_restore_state (struct kvm_vcpu *vcpu, +struct kvm_guest_debug_arch *dbg, +struct kvm_cpu_context *ctxt) {u64 aa64dfr0;int brps, wrps;
@@ -127,7 +127,7 @@ static inline void __hyp_text __debug_restore_state(struct kvm_vcpu *vcpu,write_sysreg (ctxt->sys_regs[MDCCINT_EL1 ], mdccint_el1); } -static inline void __hyp_text __debug_switch_to_guest_common(struct kvm_vcpu *vcpu) +static inline void __debug_switch_to_guest_common (struct kvm_vcpu *vcpu) {struct kvm_cpu_context *host_ctxt;struct kvm_cpu_context *guest_ctxt;
@@ -146,7 +146,7 @@ static inline void __hyp_text __debug_switch_to_guest_common(struct kvm_vcpu *vc__debug_restore_state (vcpu, guest_dbg, guest_ctxt); } -static inline void __hyp_text __debug_switch_to_host_common(struct kvm_vcpu *vcpu) +static inline void __debug_switch_to_host_common (struct kvm_vcpu *vcpu) {struct kvm_cpu_context *host_ctxt;struct kvm_cpu_context *guest_ctxt;
arch/arm64/kvm/hyp/include/hyp/switch.h +18 -18
@@ -30,7 +30,7 @@extern const char __hyp_panic_string[];/* Check whether the FP regs were dirtied while in the host-side run loop: */ -static inline bool __hyp_text update_fp_enabled(struct kvm_vcpu *vcpu) +static inline bool update_fp_enabled (struct kvm_vcpu *vcpu) {/* * When the system doesn't support FP/SIMD, we cannot rely on
@@ -48,7 +48,7 @@ static inline bool __hyp_text update_fp_enabled(struct kvm_vcpu *vcpu) }/* Save the 32-bit only FPSIMD system register state */ -static inline void __hyp_text __fpsimd_save_fpexc32(struct kvm_vcpu *vcpu) +static inline void __fpsimd_save_fpexc32 (struct kvm_vcpu *vcpu) {if (!vcpu_el1_is_32bit (vcpu))return ;
@@ -56,7 +56,7 @@ static inline void __hyp_text __fpsimd_save_fpexc32(struct kvm_vcpu *vcpu) vcpu->arch.ctxt.sys_regs[FPEXC32_EL2 ] =read_sysreg (fpexc32_el2); } -static inline void __hyp_text __activate_traps_fpsimd32(struct kvm_vcpu *vcpu) +static inline void __activate_traps_fpsimd32 (struct kvm_vcpu *vcpu) {/* * We are about to set CPTR_EL2.TFP to trap all floating point
@@ -73,7 +73,7 @@ static inline void __hyp_text __activate_traps_fpsimd32(struct kvm_vcpu *vcpu) } } -static inline void __hyp_text __activate_traps_common(struct kvm_vcpu *vcpu) +static inline void __activate_traps_common (struct kvm_vcpu *vcpu) {/* Trap on AArch32 cp15 c15 (impdef sysregs) accesses (EL1 or EL0) */ write_sysreg (1 <<15 , hstr_el2);
@@ -89,13 +89,13 @@ static inline void __hyp_text __activate_traps_common(struct kvm_vcpu *vcpu)write_sysreg (vcpu->arch.mdcr_el2, mdcr_el2); } -static inline void __hyp_text __deactivate_traps_common(void) +static inline void __deactivate_traps_common (void ) {write_sysreg (0 , hstr_el2);write_sysreg (0 , pmuserenr_el0); } -static inline void __hyp_text ___activate_traps(struct kvm_vcpu *vcpu) +static inline void ___activate_traps (struct kvm_vcpu *vcpu) {u64 hcr = vcpu->arch.hcr_el2;
@@ -108,7 +108,7 @@ static inline void __hyp_text ___activate_traps(struct kvm_vcpu *vcpu)write_sysreg_s (vcpu->arch.vsesr_el2,SYS_VSESR_EL2 ); } -static inline void __hyp_text ___deactivate_traps(struct kvm_vcpu *vcpu) +static inline void ___deactivate_traps (struct kvm_vcpu *vcpu) {/* * If we pended a virtual abort, preserve it until it gets
@@ -122,12 +122,12 @@ static inline void __hyp_text ___deactivate_traps(struct kvm_vcpu *vcpu) } } -static inline void __hyp_text __activate_vm(struct kvm *kvm) +static inline void __activate_vm (struct kvm *kvm) {__load_guest_stage2 (kvm); } -static inline bool __hyp_text __translate_far_to_hpfar(u64 far, u64 *hpfar) +static inline bool __translate_far_to_hpfar (u64 far,u64 *hpfar) {u64 par, tmp;
@@ -156,7 +156,7 @@ static inline bool __hyp_text __translate_far_to_hpfar(u64 far, u64 *hpfar)return true; } -static inline bool __hyp_text __populate_fault_info(struct kvm_vcpu *vcpu) +static inline bool __populate_fault_info (struct kvm_vcpu *vcpu) {u8 ec;u64 esr;
@@ -196,7 +196,7 @@ static inline bool __hyp_text __populate_fault_info(struct kvm_vcpu *vcpu) }/* Check for an FPSIMD/SVE trap and handle as appropriate */ -static inline bool __hyp_text __hyp_handle_fpsimd(struct kvm_vcpu *vcpu) +static inline bool __hyp_handle_fpsimd (struct kvm_vcpu *vcpu) {bool vhe, sve_guest, sve_host;u8 hsr_ec;
@@ -283,7 +283,7 @@ static inline bool __hyp_text __hyp_handle_fpsimd(struct kvm_vcpu *vcpu)return true; } -static inline bool __hyp_text handle_tx2_tvm(struct kvm_vcpu *vcpu) +static inline bool handle_tx2_tvm (struct kvm_vcpu *vcpu) {u32 sysreg =esr_sys64_to_sysreg (kvm_vcpu_get_hsr (vcpu));int rt =kvm_vcpu_sys_get_rt (vcpu);
@@ -338,7 +338,7 @@ static inline bool __hyp_text handle_tx2_tvm(struct kvm_vcpu *vcpu)return true; } -static inline bool __hyp_text esr_is_ptrauth_trap(u32 esr) +static inline bool esr_is_ptrauth_trap (u32 esr) {u32 ec =ESR_ELx_EC (esr);
@@ -371,7 +371,7 @@ static inline bool __hyp_text esr_is_ptrauth_trap(u32 esr) regs[key ## KEYHI_EL1] = read_sysreg_s(SYS_ ## key ## KEYHI_EL1); \ }) -static inline bool __hyp_text __hyp_handle_ptrauth(struct kvm_vcpu *vcpu) +static inline bool __hyp_handle_ptrauth (struct kvm_vcpu *vcpu) {struct kvm_cpu_context *ctxt;u64 val;
@@ -401,7 +401,7 @@ static inline bool __hyp_text __hyp_handle_ptrauth(struct kvm_vcpu *vcpu)* the guest, false when we should restore the host state and return to the * main run loop. */ -static inline bool __hyp_text fixup_guest_exit(struct kvm_vcpu *vcpu, u64 *exit_code) +static inline bool fixup_guest_exit (struct kvm_vcpu *vcpu,u64 *exit_code) {if (ARM_EXCEPTION_CODE (*exit_code) !=ARM_EXCEPTION_IRQ ) vcpu->arch.fault.esr_el2 =read_sysreg_el2 (SYS_ESR );
@@ -473,7 +473,7 @@ static inline bool __hyp_text fixup_guest_exit(struct kvm_vcpu *vcpu, u64 *exit_return false; } -static inline bool __hyp_text __needs_ssbd_off(struct kvm_vcpu *vcpu) +static inline bool __needs_ssbd_off (struct kvm_vcpu *vcpu) {if (!cpus_have_final_cap (ARM64_SSBD ))return false;
@@ -481,7 +481,7 @@ static inline bool __hyp_text __needs_ssbd_off(struct kvm_vcpu *vcpu)return !(vcpu->arch.workaround_flags &VCPU_WORKAROUND_2_FLAG ); } -static inline void __hyp_text __set_guest_arch_workaround_state(struct kvm_vcpu *vcpu) +static inline void __set_guest_arch_workaround_state (struct kvm_vcpu *vcpu) {#ifdef CONFIG_ARM64_SSBD /*
@@ -494,7 +494,7 @@ static inline void __hyp_text __set_guest_arch_workaround_state(struct kvm_vcpu#endif } -static inline void __hyp_text __set_host_arch_workaround_state(struct kvm_vcpu *vcpu) +static inline void __set_host_arch_workaround_state (struct kvm_vcpu *vcpu) {#ifdef CONFIG_ARM64_SSBD /*
arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h +10 -10
@@ -15,18 +15,18 @@#include <asm/kvm_emulate.h> #include <asm/kvm_hyp.h> -static inline void __hyp_text __sysreg_save_common_state(struct kvm_cpu_context *ctxt) +static inline void __sysreg_save_common_state (struct kvm_cpu_context *ctxt) { ctxt->sys_regs[MDSCR_EL1 ] =read_sysreg (mdscr_el1); } -static inline void __hyp_text __sysreg_save_user_state(struct kvm_cpu_context *ctxt) +static inline void __sysreg_save_user_state (struct kvm_cpu_context *ctxt) { ctxt->sys_regs[TPIDR_EL0 ] =read_sysreg (tpidr_el0); ctxt->sys_regs[TPIDRRO_EL0 ] =read_sysreg (tpidrro_el0); } -static inline void __hyp_text __sysreg_save_el1_state(struct kvm_cpu_context *ctxt) +static inline void __sysreg_save_el1_state (struct kvm_cpu_context *ctxt) { ctxt->sys_regs[CSSELR_EL1 ] =read_sysreg (csselr_el1); ctxt->sys_regs[SCTLR_EL1 ] =read_sysreg_el1 (SYS_SCTLR );
@@ -51,7 +51,7 @@ static inline void __hyp_text __sysreg_save_el1_state(struct kvm_cpu_context *ct ctxt->gp_regs.spsr[KVM_SPSR_EL1 ]=read_sysreg_el1 (SYS_SPSR ); } -static inline void __hyp_text __sysreg_save_el2_return_state(struct kvm_cpu_context *ctxt) +static inline void __sysreg_save_el2_return_state (struct kvm_cpu_context *ctxt) { ctxt->gp_regs.regs.pc =read_sysreg_el2 (SYS_ELR ); ctxt->gp_regs.regs.pstate =read_sysreg_el2 (SYS_SPSR );
@@ -60,18 +60,18 @@ static inline void __hyp_text __sysreg_save_el2_return_state(struct kvm_cpu_cont ctxt->sys_regs[DISR_EL1 ] =read_sysreg_s (SYS_VDISR_EL2 ); } -static inline void __hyp_text __sysreg_restore_common_state(struct kvm_cpu_context *ctxt) +static inline void __sysreg_restore_common_state (struct kvm_cpu_context *ctxt) {write_sysreg (ctxt->sys_regs[MDSCR_EL1 ], mdscr_el1); } -static inline void __hyp_text __sysreg_restore_user_state(struct kvm_cpu_context *ctxt) +static inline void __sysreg_restore_user_state (struct kvm_cpu_context *ctxt) {write_sysreg (ctxt->sys_regs[TPIDR_EL0 ], tpidr_el0);write_sysreg (ctxt->sys_regs[TPIDRRO_EL0 ], tpidrro_el0); } -static inline void __hyp_text __sysreg_restore_el1_state(struct kvm_cpu_context *ctxt) +static inline void __sysreg_restore_el1_state (struct kvm_cpu_context *ctxt) {write_sysreg (ctxt->sys_regs[MPIDR_EL1 ], vmpidr_el2);write_sysreg (ctxt->sys_regs[CSSELR_EL1 ], csselr_el1);
@@ -130,7 +130,7 @@ static inline void __hyp_text __sysreg_restore_el1_state(struct kvm_cpu_contextwrite_sysreg_el1 (ctxt->gp_regs.spsr[KVM_SPSR_EL1 ],SYS_SPSR ); } -static inline void __hyp_text __sysreg_restore_el2_return_state(struct kvm_cpu_context *ctxt) +static inline void __sysreg_restore_el2_return_state (struct kvm_cpu_context *ctxt) {u64 pstate = ctxt->gp_regs.regs.pstate;u64 mode = pstate &PSR_AA32_MODE_MASK ;
@@ -156,7 +156,7 @@ static inline void __hyp_text __sysreg_restore_el2_return_state(struct kvm_cpu_cwrite_sysreg_s (ctxt->sys_regs[DISR_EL1 ],SYS_VDISR_EL2 ); } -static inline void __hyp_text __sysreg32_save_state(struct kvm_vcpu *vcpu) +static inline void __sysreg32_save_state (struct kvm_vcpu *vcpu) {u64 *spsr, *sysreg;
@@ -178,7 +178,7 @@ static inline void __hyp_text __sysreg32_save_state(struct kvm_vcpu *vcpu) sysreg[DBGVCR32_EL2 ] =read_sysreg (dbgvcr32_el2); } -static inline void __hyp_text __sysreg32_restore_state(struct kvm_vcpu *vcpu) +static inline void __sysreg32_restore_state (struct kvm_vcpu *vcpu) {u64 *spsr, *sysreg;
arch/arm64/kvm/hyp/nvhe/Makefile +7 -1
@@ -21,7 +21,13 @@ $(obj)/%.hyp.o: $(obj)/%.hyp.tmp.o FORCE $(call if_changed,hypcopy) quiet_cmd_hypcopy = HYPCOPY $@ - cmd_hypcopy = $(OBJCOPY) --prefix-symbols=__kvm_nvhe_ $< $@ + cmd_hypcopy = $(OBJCOPY) --prefix-symbols=__kvm_nvhe_ \ + --rename-section=.text=.hyp.text \ + $< $@ + +# Remove ftrace and Shadow Call Stack CFLAGS. +# This is equivalent to the 'notrace' and '__noscs' annotations. +KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS), $(KBUILD_CFLAGS)) # KVM nVHE code is run at a different exception code with a different map, so # compiler instrumentation that inserts callbacks or checks into the code may
arch/arm64/kvm/hyp/nvhe/debug-sr.c +5 -5
@@ -14,7 +14,7 @@#include <asm/kvm_hyp.h> #include <asm/kvm_mmu.h> -static void __hyp_text __debug_save_spe(u64 *pmscr_el1) +static void __debug_save_spe (u64 *pmscr_el1) {u64 reg;
@@ -46,7 +46,7 @@ static void __hyp_text __debug_save_spe(u64 *pmscr_el1)dsb (nsh); } -static void __hyp_text __debug_restore_spe(u64 pmscr_el1) +static void __debug_restore_spe (u64 pmscr_el1) {if (!pmscr_el1)return ;
@@ -58,20 +58,20 @@ static void __hyp_text __debug_restore_spe(u64 pmscr_el1)write_sysreg_s (pmscr_el1,SYS_PMSCR_EL1 ); } -void __hyp_text __debug_switch_to_guest(struct kvm_vcpu *vcpu) +void __debug_switch_to_guest (struct kvm_vcpu *vcpu) {/* Disable and flush SPE data generation */ __debug_save_spe (&vcpu->arch.host_debug_state.pmscr_el1);__debug_switch_to_guest_common (vcpu); } -void __hyp_text __debug_switch_to_host(struct kvm_vcpu *vcpu) +void __debug_switch_to_host (struct kvm_vcpu *vcpu) {__debug_restore_spe (vcpu->arch.host_debug_state.pmscr_el1);__debug_switch_to_host_common (vcpu); } -u32 __hyp_text __kvm_get_mdcr_el2(void) +u32 __kvm_get_mdcr_el2 (void ) {return read_sysreg (mdcr_el2); }
arch/arm64/kvm/hyp/nvhe/switch.c +9 -9
@@ -27,7 +27,7 @@#include <asm/processor.h> #include <asm/thread_info.h> -static void __hyp_text __activate_traps(struct kvm_vcpu *vcpu) +static void __activate_traps (struct kvm_vcpu *vcpu) {u64 val;
@@ -58,7 +58,7 @@ static void __hyp_text __activate_traps(struct kvm_vcpu *vcpu) } } -static void __hyp_text __deactivate_traps(struct kvm_vcpu *vcpu) +static void __deactivate_traps (struct kvm_vcpu *vcpu) {u64 mdcr_el2;
@@ -93,13 +93,13 @@ static void __hyp_text __deactivate_traps(struct kvm_vcpu *vcpu)write_sysreg (CPTR_EL2_DEFAULT , cptr_el2); } -static void __hyp_text __deactivate_vm(struct kvm_vcpu *vcpu) +static void __deactivate_vm (struct kvm_vcpu *vcpu) {write_sysreg (0 , vttbr_el2); }/* Save VGICv3 state on non-VHE systems */ -static void __hyp_text __hyp_vgic_save_state(struct kvm_vcpu *vcpu) +static void __hyp_vgic_save_state (struct kvm_vcpu *vcpu) {if (static_branch_unlikely (&kvm_vgic_global_state.gicv3_cpuif)) {__vgic_v3_save_state (&vcpu->arch.vgic_cpu.vgic_v3);
@@ -108,7 +108,7 @@ static void __hyp_text __hyp_vgic_save_state(struct kvm_vcpu *vcpu) }/* Restore VGICv3 state on non_VEH systems */ -static void __hyp_text __hyp_vgic_restore_state(struct kvm_vcpu *vcpu) +static void __hyp_vgic_restore_state (struct kvm_vcpu *vcpu) {if (static_branch_unlikely (&kvm_vgic_global_state.gicv3_cpuif)) {__vgic_v3_activate_traps (&vcpu->arch.vgic_cpu.vgic_v3);
@@ -119,7 +119,7 @@ static void __hyp_text __hyp_vgic_restore_state(struct kvm_vcpu *vcpu)/** * Disable host events, enable guest events */ -static bool __hyp_text __pmu_switch_to_guest(struct kvm_cpu_context *host_ctxt) +static bool __pmu_switch_to_guest (struct kvm_cpu_context *host_ctxt) {struct kvm_host_data *host;struct kvm_pmu_events *pmu;
@@ -139,7 +139,7 @@ static bool __hyp_text __pmu_switch_to_guest(struct kvm_cpu_context *host_ctxt)/** * Disable guest events, enable host events */ -static void __hyp_text __pmu_switch_to_host(struct kvm_cpu_context *host_ctxt) +static void __pmu_switch_to_host (struct kvm_cpu_context *host_ctxt) {struct kvm_host_data *host;struct kvm_pmu_events *pmu;
@@ -155,7 +155,7 @@ static void __hyp_text __pmu_switch_to_host(struct kvm_cpu_context *host_ctxt) }/* Switch to the guest for legacy non-VHE systems */ -int __hyp_text __kvm_vcpu_run(struct kvm_vcpu *vcpu) +int __kvm_vcpu_run (struct kvm_vcpu *vcpu) {struct kvm_cpu_context *host_ctxt;struct kvm_cpu_context *guest_ctxt;
@@ -242,7 +242,7 @@ int __hyp_text __kvm_vcpu_run(struct kvm_vcpu *vcpu)return exit_code; } -void __hyp_text __noreturn hyp_panic(struct kvm_cpu_context *host_ctxt) +void __noreturn hyp_panic (struct kvm_cpu_context *host_ctxt) {u64 spsr =read_sysreg_el2 (SYS_SPSR );u64 elr =read_sysreg_el2 (SYS_ELR );
arch/arm64/kvm/hyp/nvhe/sysreg-sr.c +3 -3
@@ -18,7 +18,7 @@* Non-VHE: Both host and guest must save everything. */ -void __hyp_text __sysreg_save_state_nvhe(struct kvm_cpu_context *ctxt) +void __sysreg_save_state_nvhe (struct kvm_cpu_context *ctxt) {__sysreg_save_el1_state (ctxt);__sysreg_save_common_state (ctxt);
@@ -26,7 +26,7 @@ void __hyp_text __sysreg_save_state_nvhe(struct kvm_cpu_context *ctxt)__sysreg_save_el2_return_state (ctxt); } -void __hyp_text __sysreg_restore_state_nvhe(struct kvm_cpu_context *ctxt) +void __sysreg_restore_state_nvhe (struct kvm_cpu_context *ctxt) {__sysreg_restore_el1_state (ctxt);__sysreg_restore_common_state (ctxt);
@@ -34,7 +34,7 @@ void __hyp_text __sysreg_restore_state_nvhe(struct kvm_cpu_context *ctxt)__sysreg_restore_el2_return_state (ctxt); } -void __hyp_text __kvm_enable_ssbs(void) +void __kvm_enable_ssbs (void ) {u64 tmp;
arch/arm64/kvm/hyp/nvhe/timer-sr.c +2 -2
@@ -19,7 +19,7 @@ void __kvm_timer_set_cntvoff(u64 cntvoff)* Should only be called on non-VHE systems. * VHE systems use EL2 timers and configure EL1 timers in kvm_timer_init_vhe(). */ -void __hyp_text __timer_disable_traps(struct kvm_vcpu *vcpu) +void __timer_disable_traps (struct kvm_vcpu *vcpu) {u64 val;
@@ -33,7 +33,7 @@ void __hyp_text __timer_disable_traps(struct kvm_vcpu *vcpu)* Should only be called on non-VHE systems. * VHE systems use EL2 timers and configure EL1 timers in kvm_timer_init_vhe(). */ -void __hyp_text __timer_enable_traps(struct kvm_vcpu *vcpu) +void __timer_enable_traps (struct kvm_vcpu *vcpu) {u64 val;
arch/arm64/kvm/hyp/nvhe/tlb.c +6 -8
@@ -14,8 +14,7 @@ struct tlb_inv_context {u64 sctlr; }; -static void __hyp_text __tlb_switch_to_guest(struct kvm *kvm, -struct tlb_inv_context *cxt) +static void __tlb_switch_to_guest (struct kvm *kvm,struct tlb_inv_context *cxt) {if (cpus_have_final_cap (ARM64_WORKAROUND_SPECULATIVE_AT )) {u64 val;
@@ -38,8 +37,7 @@ static void __hyp_text __tlb_switch_to_guest(struct kvm *kvm, asm(ALTERNATIVE("isb", "nop", ARM64_WORKAROUND_SPECULATIVE_AT)); } -static void __hyp_text __tlb_switch_to_host(struct kvm *kvm, -struct tlb_inv_context *cxt) +static void __tlb_switch_to_host (struct kvm *kvm,struct tlb_inv_context *cxt) {write_sysreg (0 , vttbr_el2);
@@ -51,7 +49,7 @@ static void __hyp_text __tlb_switch_to_host(struct kvm *kvm, } } -void __hyp_text __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa) +void __kvm_tlb_flush_vmid_ipa (struct kvm *kvm,phys_addr_t ipa) {struct tlb_inv_context cxt;
@@ -105,7 +103,7 @@ void __hyp_text __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa)__tlb_switch_to_host (kvm, &cxt); } -void __hyp_text __kvm_tlb_flush_vmid(struct kvm *kvm) +void __kvm_tlb_flush_vmid (struct kvm *kvm) {struct tlb_inv_context cxt;
@@ -122,7 +120,7 @@ void __hyp_text __kvm_tlb_flush_vmid(struct kvm *kvm)__tlb_switch_to_host (kvm, &cxt); } -void __hyp_text __kvm_tlb_flush_local_vmid(struct kvm_vcpu *vcpu) +void __kvm_tlb_flush_local_vmid (struct kvm_vcpu *vcpu) {struct kvm *kvm =kern_hyp_va (kern_hyp_va (vcpu)->kvm);struct tlb_inv_context cxt;
@@ -137,7 +135,7 @@ void __hyp_text __kvm_tlb_flush_local_vmid(struct kvm_vcpu *vcpu)__tlb_switch_to_host (kvm, &cxt); } -void __hyp_text __kvm_flush_vm_context(void) +void __kvm_flush_vm_context (void ) {dsb (ishst);__tlbi (alle1is);
arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c +2 -2
@@ -13,7 +13,7 @@#include <asm/kvm_hyp.h> #include <asm/kvm_mmu.h> -static bool __hyp_text __is_be(struct kvm_vcpu *vcpu) +static bool __is_be (struct kvm_vcpu *vcpu) {if (vcpu_mode_is_32bit (vcpu))return !!(read_sysreg_el2 (SYS_SPSR ) &PSR_AA32_E_BIT );
@@ -32,7 +32,7 @@ static bool __hyp_text __is_be(struct kvm_vcpu *vcpu)* 0: Not a GICV access * -1: Illegal GICV access successfully performed */ -int __hyp_text __vgic_v2_perform_cpuif_access(struct kvm_vcpu *vcpu) +int __vgic_v2_perform_cpuif_access (struct kvm_vcpu *vcpu) {struct kvm *kvm =kern_hyp_va (vcpu->kvm);struct vgic_dist *vgic = &kvm->arch.vgic;
arch/arm64/kvm/hyp/vgic-v3-sr.c +58 -72
434 lines not on this page · raw message
Signature · 6 lines
2.27.0 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PATCH v4 15/15 arm64: kvm: Lift instrumentation restrictions on VHE
In reply to David BrazdilWith VHE and nVHE executable code completely separated, remove build config that disabled GCOV/KASAN/UBSAN/KCOV instrumentation for VHE as these now execute under the same memory mappings as the rest of the kernel.
No violations are currently being reported by either KASAN or UBSAN.
--- arch/arm64/kvm/hyp/vhe/Makefile | 8 -------- 1 file changed, 8 deletions(-)
arch/arm64/kvm/hyp/vhe/Makefile +0 -8
@@ -9,11 +9,3 @@ ccflags-y := -D__KVM_VHE_HYPERVISOR__ obj-y := timer-sr.o sysreg-sr.o debug-sr.o switch.o tlb.o obj-y += ../vgic-v3-sr.o ../aarch32.o ../vgic-v2-cpuif-proxy.o ../entry.o \ ../fpsimd.o ../hyp-entry.o - -# KVM code is run at a different exception code with a different map, so -# compiler instrumentation that inserts callbacks or checks into the code may -# cause crashes. Just disable it. -GCOV_PROFILE := n -KASAN_SANITIZE := n -UBSAN_SANITIZE := n -KCOV_INSTRUMENT := n
Signature · 6 lines
2.27.0 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Quoted 8 lines · David Brazdil
Refactor files in
arch/arm64/kvm/hypto compile all code which runs in EL2 under nVHE into separate object files from the rest of KVM. This is done in preparation for being able to unmap hyp code from EL1 and kernel code/data from EL2 but has other benefits too, notably:
* safe use of KASAN/UBSAN/GCOV instrumentation on VHE code,
* no need for__hyp_textannotations.[...]
Applied to kvm-arm64/next-5.9, thanks!
[01/15] KVM: arm64: Fix symbol dependency in __hyp_call_panic_nvhe
commit: b38b298aa4397e2dc74a89b4dd3eac9e59b64c96
[02/15] KVM: arm64: Move __smccc_workaround_1_smc to .rodata
commit: 7b2399ea5640b2e5f576af08b91091a26f240ea4
[03/15] KVM: arm64: Add build rules for separate VHE/nVHE object files
commit: 7621712918ad4f5e6356193d9058debf657a6254
[04/15] KVM: arm64: Use build-time defines in has_vhe()
commit: 53b671128bd7f9ea41ae1a06106d88eb4cf66623
[05/15] KVM: arm64: Handle calls to prefixed hyp functions
commit: f50b6f6ae131b6ee7d5dd738961eda0c00b7f027
[06/15] KVM: arm64: Build hyp-entry.S separately for VHE/nVHE
commit: b877e9849d41e7d2100d2933e0a3971d0ddec011
[07/15] KVM: arm64: Move hyp-init.S to nVHE
commit: 208243c752a7eeef4236f7b7d67e806ee356e3f8
[08/15] KVM: arm64: Duplicate hyp/tlb.c for VHE/nVHE
commit: e03fa29164ec1db1a81dc0168d0017a9e0366c7c
[09/15] KVM: arm64: Split hyp/switch.c to VHE/nVHE
commit: 09cf57eba304246141367b95c89801fd2047ac96
[10/15] KVM: arm64: Split hyp/debug-sr.c to VHE/nVHE
commit: d400c5b2025c9aeca76213d6bd4138ec39da5cef
[11/15] KVM: arm64: Split hyp/sysreg-sr.c to VHE/nVHE
commit: 13aeb9b400c5d7c5e979fdbbf994c787487f7889
[12/15] KVM: arm64: Duplicate hyp/timer-sr.c for VHE/nVHE
commit: 9aebdea494b5d2d5fe0ba54d71e9d6c5acfe76b4
[13/15] KVM: arm64: Compile remaining hyp/ files for both VHE/nVHE
commit: c04dd455eb311d2d289c9d81d080eaf11a06cebf
[14/15] KVM: arm64: Remove __hyp_text macro, use build rules instead
commit: c50cb04303cb88c517715b078e3e010c024af1a5
[15/15] KVM: arm64: Lift instrumentation restrictions on VHE
commit: f9a026e3d38ba81cd274725f1caaf64322a86aa5Cheers,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.