summaryrefslogtreecommitdiff
path: root/arch/arm64/kvm/hyp (follow)
Commit message (Collapse)AuthorAge
* Merge branch 'v4.4/topic/hibernate' into linux-linaro-lsk-v4.4Alex Shi2016-11-17
|\ | | | | | | | | | | | | | | Conflicts: arch/arm64/include/asm/kvm_asm.h arch/arm64/include/asm/memory.h arch/arm64/kernel/head.S arch/arm64/kvm/hyp.S
| * arm64: hyp/kvm: Make hyp-stub extensibleGeoff Levand2016-11-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The existing arm64 hcall implementations are limited in that they only allow for two distinct hcalls; with the x0 register either zero or not zero. Also, the API of the hyp-stub exception vector routines and the KVM exception vector routines differ; hyp-stub uses a non-zero value in x0 to implement __hyp_set_vectors, whereas KVM uses it to implement kvm_call_hyp. To allow for additional hcalls to be defined and to make the arm64 hcall API more consistent across exception vector routines, change the hcall implementations to reserve all x0 values below 0xfff for hcalls such as {s,g}et_vectors(). Define two new preprocessor macros HVC_GET_VECTORS, and HVC_SET_VECTORS to be used as hcall type specifiers and convert the existing __hyp_get_vectors() and __hyp_set_vectors() routines to use these new macros when executing an HVC call. Also, change the corresponding hyp-stub and KVM el1_sync exception vector routines to use these new macros. Signed-off-by: Geoff Levand <geoff@infradead.org> [Merged two hcall patches, moved immediate value from esr to x0, use lr as a scratch register, changed limit to 0xfff] Signed-off-by: James Morse <james.morse@arm.com> Acked-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com> (cherry picked from commit ad72e59ff2bad55f6b9e7ac1fe5d824831ea2550) Signed-off-by: Alex Shi <alex.shi@linaro.org>
| * arm64: kvm: Move lr save/restore from do_el2_call into EL1James Morse2016-11-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Today the 'hvc' calling KVM or the hyp-stub is expected to preserve all registers. KVM saves/restores the registers it needs on the EL2 stack using do_el2_call(). The hyp-stub has no stack, later patches need to be able to be able to clobber the link register. Move the link register save/restore to the the call sites. Signed-off-by: James Morse <james.morse@arm.com> Acked-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com> (cherry picked from commit 00a44cdaba0900c63a003e0c431f506f49376a90) Signed-off-by: Alex Shi <alex.shi@linaro.org>
* | arm64/kvm: fix build issue on kvm debugAlex Shi2016-11-14
|/ | | | | | | | | | | | | | Add the header file asm/debug-monitors.h into debug-sr.c to fix the following bug arch/arm64/kvm/hyp/debug-sr.c: In function ‘__debug_cond_save_host_state’: arch/arm64/kvm/hyp/debug-sr.c:118:45: error: ‘DBG_MDSCR_KDE’ undeclared (first use in this function) if ((vcpu->arch.ctxt.sys_regs[MDSCR_EL1] & DBG_MDSCR_KDE) || ^~~~~~~~~~~~~ arch/arm64/kvm/hyp/debug-sr.c:118:45: note: each undeclared identifier is reported only once for each function it appears in arch/arm64/kvm/hyp/debug-sr.c:119:45: error: ‘DBG_MDSCR_MDE’ undeclared (first use in this function) (vcpu->arch.ctxt.sys_regs[MDSCR_EL1] & DBG_MDSCR_MDE)) ^~~~~~~~~~~~~ Signed-off-by: Alex Shi <alex.shi@linaro.org>
* arm64: KVM: Remove weak attributesMarc Zyngier2016-11-09
| | | | | | | | | | | As we've now switched to the new world switch implementation, remove the weak attributes, as nobody is supposed to override it anymore. Acked-by: Christoffer Dall <christoffer.dall@linaro.org> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> (cherry picked from commit 3ffa75cd18134a03f86f9d9b8b6e9128e0eda254) Signed-off-by: Alex Shi <alex.shi@linaro.org>
* arm64: KVM: Turn system register numbers to an enumMarc Zyngier2016-11-09
| | | | | | | | | | | | | | Having the system register numbers as #defines has been a pain since day one, as the ordering is pretty fragile, and moving things around leads to renumbering and epic conflict resolutions. Now that we're mostly acessing the sysreg file in C, an enum is a much better type to use, and we can clean things up a bit. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Acked-by: Christoffer Dall <christoffer.dall@linaro.org> (cherry picked from commit 9d8415d6c148a16b6d906a96f0596851d7e4d607) Signed-off-by: Alex Shi <alex.shi@linaro.org>
* arm64: KVM: VHE: Patch out use of HVCMarc Zyngier2016-11-09
| | | | | | | | | | | | With VHE, the host never issues an HVC instruction to get into the KVM code, as we can simply branch there. Use runtime code patching to simplify things a bit. Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> (cherry picked from commit b81125c791a2958cc60ae968fc1cdea82b7cd3b0) Signed-off-by: Alex Shi <alex.shi@linaro.org>
* arm64: KVM: Add compatibility aliasesMarc Zyngier2016-11-09
| | | | | | | | | | | | | | | | | | | | So far, we've implemented the new world switch with a completely different namespace, so that we could have both implementation compiled in. Let's take things one step further by adding weak aliases that have the same names as the original implementation. The weak attributes allows the new implementation to be overriden by the old one, and everything still work. At a later point, we'll be able to simply drop the old code, and everything will hopefully keep working, thanks to the aliases we have just added. This also saves us repainting all the callers. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Acked-by: Christoffer Dall <christoffer.dall@linaro.org> (cherry picked from commit 044ac37d1281fc7b59d5dce4fe979a99369e95f2) Signed-off-by: Alex Shi <alex.shi@linaro.org>
* arm64: KVM: Implement vgic-v3 save/restoreMarc Zyngier2016-11-09
| | | | | | | | | | | | | Implement the vgic-v3 save restore as a direct translation of the assembly code version. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> (cherry picked from commit f68d2b1b73cc3d8f6eb189c11ce79a472ed27c42) Signed-off-by: Alex Shi <alex.shi@linaro.org> Conflicts: arch/arm64/kvm/hyp/Makefile arch/arm64/kvm/hyp/hyp.h
* arm64: KVM: Add panic handlingMarc Zyngier2016-11-09
| | | | | | | | | | Add the panic handler, together with the small bits of assembly code to call the kernel's panic implementation. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org> (cherry picked from commit 53fd5b6487e4438049a5da5e36dfb8edcf1fd789) Signed-off-by: Alex Shi <alex.shi@linaro.org>
* arm64: KVM: HYP mode entry pointsMarc Zyngier2016-11-09
| | | | | | | | | | Add the entry points for HYP mode (both for hypercalls and exception handling). Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org> (cherry picked from commit 2b28162cf65a6fe1c93d172675e4f2792792f17e) Signed-off-by: Alex Shi <alex.shi@linaro.org>
* arm64: KVM: Implement TLB handlingMarc Zyngier2016-11-09
| | | | | | | | | | Implement the TLB handling as a direct translation of the assembly code version. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org> (cherry picked from commit 5eec0a91e32a2862e86265532ae773820e0afd77) Signed-off-by: Alex Shi <alex.shi@linaro.org>
* arm64: KVM: Implement fpsimd save/restoreMarc Zyngier2016-11-09
| | | | | | | | | | Implement the fpsimd save restore, keeping the lazy part in assembler (as returning to C would be overkill). Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org> (cherry picked from commit c13d1683df16db16c91372177ca10c31677b5ed5) Signed-off-by: Alex Shi <alex.shi@linaro.org>
* arm64: KVM: Implement the core world switchMarc Zyngier2016-11-09
| | | | | | | | | | | | Implement the core of the world switch in C. Not everything is there yet, and there is nothing to re-enter the world switch either. But this already outlines the code structure well enough. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org> (cherry picked from commit be901e9b15cd2c8e48dc089b4655ea4a076e66fd) Signed-off-by: Alex Shi <alex.shi@linaro.org>
* arm64: KVM: Add patchable function selectorMarc Zyngier2016-11-09
| | | | | | | | | | | | | | | KVM so far relies on code patching, and is likely to use it more in the future. The main issue is that our alternative system works at the instruction level, while we'd like to have alternatives at the function level. In order to cope with this, add the "hyp_alternate_select" macro that outputs a brief sequence of code that in turn can be patched, allowing an alternative function to be selected. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> (cherry picked from commit c1bf6e18e97e7ead77371d4251f8ef1567455584) Signed-off-by: Alex Shi <alex.shi@linaro.org>
* arm64: KVM: Implement guest entryMarc Zyngier2016-11-09
| | | | | | | | | | | Contrary to the previous patch, the guest entry is fairly different from its assembly counterpart, mostly because it is only concerned with saving/restoring the GP registers, and nothing else. Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> (cherry picked from commit b97b66c14b96ab562e4fd516d804c5cd05c0529e) Signed-off-by: Alex Shi <alex.shi@linaro.org>
* arm64: KVM: Implement debug save/restoreMarc Zyngier2016-11-09
| | | | | | | | | | | | Implement the debug save restore as a direct translation of the assembly code version. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Tested-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org> (cherry picked from commit 8eb992674c9e69d57af199f36b6455dbc00ac9f9) Signed-off-by: Alex Shi <alex.shi@linaro.org>
* arm64: KVM: Implement 32bit system register save/restoreMarc Zyngier2016-11-09
| | | | | | | | | | Implement the 32bit system register save/restore as a direct translation of the assembly code version. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org> (cherry picked from commit c209ec85a2a7d2fd38bca0a44b7e70abd079c178) Signed-off-by: Alex Shi <alex.shi@linaro.org>
* arm64: KVM: Implement system register save/restoreMarc Zyngier2016-11-09
| | | | | | | | | | Implement the system register save/restore as a direct translation of the assembly code version. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org> (cherry picked from commit 6d6ec20fcf2830ca10c1b7c8efd7e2592c40e3d6) Signed-off-by: Alex Shi <alex.shi@linaro.org>
* arm64: KVM: Implement timer save/restoreMarc Zyngier2016-11-09
| | | | | | | | | | | | | Implement the timer save restore as a direct translation of the assembly code version. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> (cherry picked from commit 1431af367e52b08038e78d346822966d968f1694) Signed-off-by: Alex Shi <alex.shi@linaro.org> Conflicts: arch/arm64/kvm/hyp/Makefile arch/arm64/kvm/hyp/hyp.h
* arm64: KVM: Implement vgic-v2 save/restoreMarc Zyngier2016-11-09
| | | | | | | | | Implement the vgic-v2 save restore (mostly) as a direct translation of the assembly code version. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> (cherry picked from commit 06282fd2c2bf61619649a2b13e4a08556598a64c) Signed-off-by: Alex Shi <alex.shi@linaro.org>
* arm64: KVM: Add a HYP-specific header fileMarc Zyngier2016-11-09
In order to expose the various EL2 services that are private to the hypervisor, add a new hyp.h file. So far, it only contains mundane things such as section annotation and VA manipulation. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> (cherry picked from commit c76a0a6695c61088c8d2e731e25305502666bf7d) Signed-off-by: Alex Shi <alex.shi@linaro.org>