From: cdall@cs.columbia.edu (Christoffer Dall)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 6/7] ARM: KVM: switch to a dual-step HYP init code
Date: Wed, 3 Apr 2013 16:15:59 -0700 [thread overview]
Message-ID: <20130403231559.GG29227@gmail.com> (raw)
In-Reply-To: <515C06A6.5030807@arm.com>
On Wed, Apr 03, 2013 at 11:38:30AM +0100, Marc Zyngier wrote:
> On 03/04/13 11:07, Will Deacon wrote:
> > On Tue, Apr 02, 2013 at 02:25:14PM +0100, Marc Zyngier wrote:
> >> Our HYP init code suffers from two major design issues:
> >> - it cannot support CPU hotplug, as we tear down the idmap very early
> >> - it cannot perform a TLB invalidation when switching from init to
> >> runtime mappings, as pages are manipulated from PL1 exclusively
> >
> > [...]
> >
> >> diff --git a/arch/arm/kvm/init.S b/arch/arm/kvm/init.S
> >> index 35a463f..b2c6967 100644
> >> --- a/arch/arm/kvm/init.S
> >> +++ b/arch/arm/kvm/init.S
> >> @@ -21,6 +21,7 @@
> >> #include <asm/asm-offsets.h>
> >> #include <asm/kvm_asm.h>
> >> #include <asm/kvm_arm.h>
> >> +#include <asm/kvm_mmu.h>
> >>
> >> /********************************************************************
> >> * Hypervisor initialization
> >> @@ -47,6 +48,9 @@ __kvm_hyp_init:
> >> W(b) .
> >>
> >> __do_hyp_init:
> >> + cmp r2, #0 @ We have a SP?
> >> + bne phase2 @ Yes, second stage init
> >> +
> >> @ Set the HTTBR to point to the hypervisor PGD pointer passed
> >> mcrr p15, 4, r0, r1, c2
> >>
> >> @@ -96,14 +100,35 @@ __do_hyp_init:
> >> orr r0, r0, r1
> >> isb
> >> mcr p15, 4, r0, c1, c0, 0 @ HSCR
> >> - isb
> >>
> >> - @ Set stack pointer and return to the kernel
> >> + eret
> >> +
> >> +phase2:
> >> + @ Set stack pointer
> >> mov sp, r2
> >>
> >> @ Set HVBAR to point to the HYP vectors
> >> mcr p15, 4, r3, c12, c0, 0 @ HVBAR
> >>
> >> + @ Jump to the trampoline page
> >> + ldr r2, =#PAGE_MASK
> >
> > Shifting right by PAGE_SHIFT can avoid the load.
>
> Not really. We're masking out the top bits of "target" and adding them
> to the trampoline base address, so shifting doesn't help.
>
> But, as you suggested offline, BFI can come to the rescue and make that
> code totally fun and unreadable. How about (untested):
>
> ldr r2, =#TRAMPOLINE_VA
> adr r3, target
> bfi r2, r3, #0, #PAGE_SHIFT
> mov pc, r2
>
> I really like it! :)
>
What kind of drugs are you on?
Ok, I actually like it too.
> >
> >> + adr r3, target
> >> + bic r3, r3, r2
> >> + ldr r2, =#TRAMPOLINE_VA
> >> + add r3, r3, r2
> >> + mov pc, r3
> >> +
> >> + nop
> >
> > <insert dead chicken and voodoo chant here>
>
> ... "You know I'll never sleep no more" ...
>
Seriously, what kind of drugs are you guys on?
next prev parent reply other threads:[~2013-04-03 23:15 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-02 13:25 [PATCH 0/7] ARM: KVM: Revamping the HYP init code for fun and profit Marc Zyngier
2013-04-02 13:25 ` [PATCH 1/7] ARM: KVM: simplify HYP mapping population Marc Zyngier
2013-04-03 23:13 ` Christoffer Dall
2013-04-04 12:35 ` Marc Zyngier
2013-04-02 13:25 ` [PATCH 2/7] ARM: KVM: fix HYP mapping limitations around zero Marc Zyngier
2013-04-03 23:14 ` Christoffer Dall
2013-04-04 12:40 ` Marc Zyngier
2013-04-02 13:25 ` [PATCH 3/7] ARM: KVM: move to a KVM provided HYP idmap Marc Zyngier
2013-04-03 9:43 ` Will Deacon
2013-04-03 9:46 ` Marc Zyngier
2013-04-03 23:14 ` Christoffer Dall
2013-04-02 13:25 ` [PATCH 4/7] ARM: KVM: enforce page alignment for identity mapped code Marc Zyngier
2013-04-03 9:50 ` Will Deacon
2013-04-03 10:00 ` Marc Zyngier
2013-04-03 23:15 ` Christoffer Dall
2013-04-04 10:47 ` Marc Zyngier
2013-04-04 15:32 ` Christoffer Dall
2013-04-02 13:25 ` [PATCH 5/7] ARM: KVM: parametrize HYP page table freeing Marc Zyngier
2013-04-03 23:15 ` Christoffer Dall
2013-04-02 13:25 ` [PATCH 6/7] ARM: KVM: switch to a dual-step HYP init code Marc Zyngier
2013-04-03 10:07 ` Will Deacon
2013-04-03 10:38 ` Marc Zyngier
2013-04-03 23:15 ` Christoffer Dall [this message]
2013-04-04 11:05 ` Marc Zyngier
2013-04-03 23:15 ` Christoffer Dall
2013-04-04 12:52 ` Marc Zyngier
2013-04-04 22:10 ` Geoff Levand
2013-04-05 9:08 ` Marc Zyngier
2013-04-05 16:46 ` Geoff Levand
2013-04-05 16:54 ` Marc Zyngier
2013-04-18 15:54 ` Russell King - ARM Linux
2013-04-18 16:01 ` Marc Zyngier
2013-04-02 13:25 ` [PATCH 7/7] ARM: KVM: perform HYP initilization for hotplugged CPUs Marc Zyngier
2013-04-03 23:16 ` Christoffer Dall
2013-04-03 23:18 ` [PATCH 0/7] ARM: KVM: Revamping the HYP init code for fun and profit Christoffer Dall
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=20130403231559.GG29227@gmail.com \
--to=cdall@cs.columbia.edu \
--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).