From: christoffer.dall@linaro.org (Christoffer Dall)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 12/15] arm: KVM: Simplify HYP init
Date: Tue, 28 Jun 2016 23:50:37 +0200 [thread overview]
Message-ID: <20160628215037.GS26498@cbox> (raw)
In-Reply-To: <1465297115-13091-13-git-send-email-marc.zyngier@arm.com>
On Tue, Jun 07, 2016 at 11:58:32AM +0100, Marc Zyngier wrote:
> Just like for arm64, we can now make the HYP setup a lot simpler,
> and we can now initialise it in one go (instead of the two
> phases we currently have).
>
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
> ---
> arch/arm/include/asm/kvm_host.h | 15 +++++--------
> arch/arm/kvm/init.S | 49 ++++++++---------------------------------
> 2 files changed, 14 insertions(+), 50 deletions(-)
>
> diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h
> index 020f4eb..eafbfd5 100644
> --- a/arch/arm/include/asm/kvm_host.h
> +++ b/arch/arm/include/asm/kvm_host.h
> @@ -250,18 +250,13 @@ static inline void __cpu_init_hyp_mode(phys_addr_t pgd_ptr,
> * code. The init code doesn't need to preserve these
> * registers as r0-r3 are already callee saved according to
> * the AAPCS.
> - * Note that we slightly misuse the prototype by casing the
> + * Note that we slightly misuse the prototype by casting the
> * stack pointer to a void *.
> - *
> - * We don't have enough registers to perform the full init in
> - * one go. Install the boot PGD first, and then install the
> - * runtime PGD, stack pointer and vectors. The PGDs are always
> - * passed as the third argument, in order to be passed into
> - * r2-r3 to the init code (yes, this is compliant with the
> - * PCS!).
> - */
>
> - kvm_call_hyp(NULL, 0, boot_pgd_ptr);
> + * The PGDs are always passed as the third argument, in order
> + * to be passed into r2-r3 to the init code (yes, this is
> + * compliant with the PCS!).
> + */
>
> kvm_call_hyp((void*)hyp_stack_ptr, vector_ptr, pgd_ptr);
> }
> diff --git a/arch/arm/kvm/init.S b/arch/arm/kvm/init.S
> index 1f9ae17..b82a99d 100644
> --- a/arch/arm/kvm/init.S
> +++ b/arch/arm/kvm/init.S
> @@ -32,23 +32,13 @@
> * r2,r3 = Hypervisor pgd pointer
> *
> * The init scenario is:
> - * - We jump in HYP with four parameters: boot HYP pgd, runtime HYP pgd,
> - * runtime stack, runtime vectors
> - * - Enable the MMU with the boot pgd
> - * - Jump to a target into the trampoline page (remember, this is the same
> - * physical page!)
> - * - Now switch to the runtime pgd (same VA, and still the same physical
> - * page!)
> + * - We jump in HYP with 3 parameters: runtime HYP pgd, runtime stack,
> + * runtime vectors
probably just call this HYP pgd, HYP stack, and HYP vectors now
> * - Invalidate TLBs
> * - Set stack and vectors
> + * - Setup the page tables
> + * - Enable the MMU
> * - Profit! (or eret, if you only care about the code).
> - *
> - * As we only have four registers available to pass parameters (and we
> - * need six), we split the init in two phases:
> - * - Phase 1: r0 = 0, r1 = 0, r2,r3 contain the boot PGD.
> - * Provides the basic HYP init, and enable the MMU.
> - * - Phase 2: r0 = ToS, r1 = vectors, r2,r3 contain the runtime PGD.
> - * Switches to the runtime PGD, set stack and vectors.
> */
>
> .text
> @@ -68,8 +58,11 @@ __kvm_hyp_init:
> W(b) .
>
> __do_hyp_init:
> - cmp r0, #0 @ We have a SP?
> - bne phase2 @ Yes, second stage init
> + @ Set stack pointer
> + mov sp, r0
> +
> + @ Set HVBAR to point to the HYP vectors
> + mcr p15, 4, r1, c12, c0, 0 @ HVBAR
>
> @ Set the HTTBR to point to the hypervisor PGD pointer passed
> mcrr p15, 4, rr_lo_hi(r2, r3), c2
> @@ -114,33 +107,9 @@ __do_hyp_init:
> THUMB( ldr r2, =(HSCTLR_M | HSCTLR_A | HSCTLR_TE) )
> orr r1, r1, r2
> orr r0, r0, r1
> - isb
> mcr p15, 4, r0, c1, c0, 0 @ HSCR
> -
> - @ End of init phase-1
> - eret
> -
> -phase2:
> - @ Set stack pointer
> - mov sp, r0
> -
> - @ Set HVBAR to point to the HYP vectors
> - mcr p15, 4, r1, c12, c0, 0 @ HVBAR
> -
> - @ Jump to the trampoline page
> - ldr r0, =TRAMPOLINE_VA
> - adr r1, target
> - bfi r0, r1, #0, #PAGE_SHIFT
> - ret r0
> -
> -target: @ We're now in the trampoline code, switch page tables
> - mcrr p15, 4, rr_lo_hi(r2, r3), c2
> isb
>
> - @ Invalidate the old TLBs
> - mcr p15, 4, r0, c8, c7, 0 @ TLBIALLH
> - dsb ish
how are we sure there are no stale entries in the TLB beyond the idmap
region? Did we take care of this during kernel boot? What about
hotplug/suspend stuff?
Thanks,
-Christoffer
next prev parent reply other threads:[~2016-06-28 21:50 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-07 10:58 [PATCH 00/15] arm/arm64: KVM: Merge boot and runtime page tables Marc Zyngier
2016-06-07 10:58 ` [PATCH 01/15] arm64: KVM: Merged page tables documentation Marc Zyngier
2016-06-27 13:28 ` Christoffer Dall
2016-06-27 14:06 ` Marc Zyngier
2016-06-28 11:46 ` Christoffer Dall
2016-06-29 9:05 ` Marc Zyngier
2016-06-07 10:58 ` [PATCH 02/15] arm64: KVM: Kill HYP_PAGE_OFFSET Marc Zyngier
2016-06-27 13:47 ` Christoffer Dall
2016-06-27 14:20 ` Marc Zyngier
2016-06-28 12:03 ` Christoffer Dall
2016-06-07 10:58 ` [PATCH 03/15] arm64: Add ARM64_HYP_OFFSET_LOW capability Marc Zyngier
2016-06-07 10:58 ` [PATCH 04/15] arm64: KVM: Define HYP offset masks Marc Zyngier
2016-06-07 10:58 ` [PATCH 05/15] arm64: KVM: Refactor kern_hyp_va/hyp_kern_va to deal with multiple offsets Marc Zyngier
2016-06-28 12:42 ` Christoffer Dall
2016-06-30 9:22 ` Marc Zyngier
2016-06-30 10:16 ` Marc Zyngier
2016-06-30 10:26 ` Christoffer Dall
2016-06-30 10:42 ` Ard Biesheuvel
2016-06-30 11:02 ` Marc Zyngier
2016-06-30 11:10 ` Ard Biesheuvel
2016-06-30 11:57 ` Marc Zyngier
2016-06-07 10:58 ` [PATCH 06/15] arm/arm64: KVM: Export __hyp_text_start/end symbols Marc Zyngier
2016-06-07 10:58 ` [PATCH 07/15] arm64: KVM: Runtime detection of lower HYP offset Marc Zyngier
2016-06-07 10:58 ` [PATCH 08/15] arm/arm64: KVM: Always have merged page tables Marc Zyngier
2016-06-28 21:43 ` Christoffer Dall
2016-06-30 12:27 ` Marc Zyngier
2016-06-30 13:28 ` Christoffer Dall
2016-06-07 10:58 ` [PATCH 09/15] arm64: KVM: Simplify HYP init/teardown Marc Zyngier
2016-06-28 21:31 ` Christoffer Dall
2016-06-30 12:10 ` Marc Zyngier
2016-06-30 13:31 ` Christoffer Dall
2016-06-07 10:58 ` [PATCH 10/15] arm/arm64: KVM: Drop boot_pgd Marc Zyngier
2016-06-07 10:58 ` [PATCH 11/15] arm/arm64: KVM: Kill free_boot_hyp_pgd Marc Zyngier
2016-06-07 10:58 ` [PATCH 12/15] arm: KVM: Simplify HYP init Marc Zyngier
2016-06-28 21:50 ` Christoffer Dall [this message]
2016-06-30 12:31 ` Marc Zyngier
2016-06-30 13:32 ` Christoffer Dall
2016-06-07 10:58 ` [PATCH 13/15] arm: KVM: Allow hyp teardown Marc Zyngier
2016-06-07 10:58 ` [PATCH 14/15] arm/arm64: KVM: Prune unused #defines Marc Zyngier
2016-06-07 10:58 ` [PATCH 15/15] arm/arm64: KVM: Check that IDMAP doesn't intersect with VA range Marc Zyngier
2016-06-28 22:01 ` Christoffer Dall
2016-06-30 12:51 ` Marc Zyngier
2016-06-30 13:27 ` Christoffer Dall
2016-06-27 13:29 ` [PATCH 00/15] arm/arm64: KVM: Merge boot and runtime page tables Christoffer Dall
2016-06-27 14:12 ` Marc Zyngier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160628215037.GS26498@cbox \
--to=christoffer.dall@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).