As part of the effort to isolate hyp from the host on nVHE, this series provides hyp with its very own context and views the host as a vcpu from the point of view of context switching. The journey begins by preparing for hyp-init to instantiate a run loop in hyp that `__guest_enter`s back into the host. The interfaces then migrate to SMCCC rather than the raw function pointer intrface of today. Next, the host state is fully migrated into its vcpu leaving a distinct context for hyp and host. Finally, the save and restore paths of guests and the host are unified such that __kvm_vcpu_run can switch to and run any vcpu it is given. It's a long series, but that seems to be the way Marc likes things around here, hehe. I've tried to keep the patches simple where possible but let me know if there's ever too much in one go and I'll try and help you out. This has been lightly tested on qemu with both VHE and nVHE booting VMs. More rigorous testing will be needed. The first patch is already in arm64/for-next/misc 7af928851508 The second patch can also be seen in <20200713210505.2959828-2-ascull@xxxxxxxxxx> Andrew Scull (37): smccc: Make constants available to assembly KVM: arm64: Move clearing of vcpu debug dirty bit KVM: arm64: Track running vCPU outside of the CPU context KVM: arm64: nVHE: Pass pointers consistently to hyp-init KVM: arm64: nVHE: Break out of the hyp-init idmap KVM: arm64: Only check pending interrupts if it would trap KVM: arm64: Separate SError detection from VAXorcism KVM: arm64: nVHE: Introduce a hyp run loop for the host smccc: Cast arguments to unsigned long KVM: arm64: nVHE: Migrate hyp interface to SMCCC KVM: arm64: nVHE: Migrate hyp-init to SMCCC KVM: arm64: nVHE: Fix pointers during SMCCC convertion KVM: arm64: Rename workaround 2 helpers KVM: arm64: nVHE: Use __kvm_vcpu_run for the host vcpu KVM: arm64: Share some context save and restore macros KVM: arm64: nVHE: Handle stub HVCs in the host loop KVM: arm64: nVHE: Store host sysregs in host vcpu KVM: arm64: nVHE: Access pmu_events directly in kvm_host_data KVM: arm64: nVHE: Drop host_ctxt argument for context switching KVM: arm64: nVHE: Use host vcpu context for host debug state KVM: arm64: Move host debug state from vcpu to percpu KVM: arm64: nVHE: Store host's mdcr_el2 and hcr_el2 in its vcpu KVM: arm64: Skip __hyp_panic and go direct to hyp_panic KVM: arm64: Break apart kvm_host_data KVM: arm64: nVHE: Unify sysreg state saving paths KVM: arm64: nVHE: Unify 32-bit sysreg saving paths KVM: arm64: nVHE: Unify vgic save and restore KVM: arm64: nVHE: Unify fpexc32 saving paths KVM: arm64: nVHE: Separate the save and restore of debug state KVM: arm64: nVHE: Remove MMU assumption in speculative AT workaround KVM: arm64: Move speculative AT ISBs into context KVM: arm64: nVHE: Unify sysreg state restoration paths KVM: arm64: Remove __activate_vm wrapper KVM: arm64: nVHE: Unify timer restore paths KVM: arm64: nVHE: Unify PMU event restoration paths KVM: arm64: nVHE: Unify GIC PMR restoration paths KVM: arm64: Separate save and restore of vcpu trap state arch/arm64/include/asm/kvm_asm.h | 73 +++++- arch/arm64/include/asm/kvm_host.h | 57 ++--- arch/arm64/include/asm/kvm_hyp.h | 33 ++- arch/arm64/include/asm/kvm_mmu.h | 7 - arch/arm64/kernel/asm-offsets.c | 2 - arch/arm64/kernel/image-vars.h | 6 +- arch/arm64/kvm/Makefile | 2 +- arch/arm64/kvm/arm.c | 75 +++++- arch/arm64/kvm/debug.c | 2 + arch/arm64/kvm/hyp.S | 34 --- arch/arm64/kvm/hyp/entry.S | 92 +++---- arch/arm64/kvm/hyp/hyp-entry.S | 81 +----- arch/arm64/kvm/hyp/include/hyp/debug-sr.h | 49 +--- arch/arm64/kvm/hyp/include/hyp/switch.h | 30 ++- arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h | 46 ++-- arch/arm64/kvm/hyp/nvhe/Makefile | 3 +- arch/arm64/kvm/hyp/nvhe/debug-sr.c | 28 +- arch/arm64/kvm/hyp/nvhe/hyp-init.S | 86 ++++--- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 218 ++++++++++++++++ arch/arm64/kvm/hyp/nvhe/hyp-start.S | 49 ++++ arch/arm64/kvm/hyp/nvhe/switch.c | 282 +++++++++++---------- arch/arm64/kvm/hyp/nvhe/timer-sr.c | 35 +-- arch/arm64/kvm/hyp/nvhe/tlb.c | 19 +- arch/arm64/kvm/hyp/vhe/debug-sr.c | 34 ++- arch/arm64/kvm/hyp/vhe/switch.c | 30 +-- arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 4 +- arch/arm64/kvm/hyp/vhe/tlb.c | 4 +- arch/arm64/kvm/pmu.c | 28 +- arch/arm64/kvm/vgic/vgic-v3.c | 4 +- include/linux/arm-smccc.h | 64 ++--- 30 files changed, 873 insertions(+), 604 deletions(-) delete mode 100644 arch/arm64/kvm/hyp.S create mode 100644 arch/arm64/kvm/hyp/nvhe/hyp-main.c create mode 100644 arch/arm64/kvm/hyp/nvhe/hyp-start.S -- 2.27.0.389.gc38d7665816-goog _______________________________________________ kvmarm mailing list kvmarm@xxxxxxxxxxxxxxxxxxxxx https://lists.cs.columbia.edu/mailman/listinfo/kvmarm