From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marc Zyngier Subject: Re: [kvmarm] [PATCH v10 06/14] KVM: ARM: Hypervisor inititalization Date: Fri, 24 Aug 2012 15:38:54 +0200 Message-ID: References: <20120816152637.21484.65421.stgit@ubuntu> <20120816152906.21484.9478.stgit@ubuntu> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Christoffer Dall , , To: Lei Wen Return-path: Received: from inca-roads.misterjones.org ([213.251.177.50]:38722 "EHLO inca-roads.misterjones.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753829Ab2HXOII (ORCPT ); Fri, 24 Aug 2012 10:08:08 -0400 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On Fri, 24 Aug 2012 16:04:02 +0800, Lei Wen wrote: > On Thu, Aug 23, 2012 at 11:27 PM, Christoffer Dall > wrote: >> On Thu, Aug 23, 2012 at 11:08 AM, Lei Wen wrote: >>> Hi Christoffer, >>> >>> [snip] >>> >>>> diff --git a/arch/arm/kvm/init.S b/arch/arm/kvm/init.S >>>> index 1dc8926..4db26cb 100644 >>>> --- a/arch/arm/kvm/init.S >>>> +++ b/arch/arm/kvm/init.S >>>> @@ -15,5 +15,135 @@ >>>> * along with this program; if not, write to the Free Software >>>> * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA >>>> 02110-1301, USA. >>>> */ >>>> + >>>> +#include >>>> +#include >>>> #include >>>> #include >>>> +#include >>>> + >>>> +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ >>>> +@ Hypervisor initialization >>>> +@ - should be called with: >>>> +@ r0 = Hypervisor pgd pointer >>>> +@ r1 = top of Hyp stack (kernel VA) >>>> +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ >>>> + .text >>>> + .arm >>>> + .pushsection .hyp.idmap.text,"ax" >>>> + .align 12 >>>> +__kvm_hyp_init: >>>> + .globl __kvm_hyp_init >>>> + >>>> + @ Hyp-mode exception vector >>>> + nop >>>> + nop >>>> + nop >>>> + nop >>>> + nop >>>> + b __do_hyp_init >>>> + nop >>>> + nop >>>> + >>>> +__do_hyp_init: >>>> + @ Set the sp to end of this page and push data for later use >>>> + mov sp, pc >>>> + bic sp, sp, #0x0ff >>>> + bic sp, sp, #0xf00 >>>> + add sp, sp, #0x1000 >>>> + push {r0, r1, r2, r12} >>> >>> Is safe to use the stack here? Since our HYP memory mapping is >>> gotten valid after the following HTTBR being set as I think. >>> >> >> yes, as you can see in the end of this block we have a .align 12 >> before __kvm_hyp_init_end giving us the stack space we need in this >> page (as long as this init code doesn't grow beyond ~3K > > I know this area is already being mapped in hyp_init_static_idmap, > however, due to the HTTBR is not being set up yet in the below code. > So how the memory get mapped in the hyp mode? I mean what I could > understand the hyp virtual address only could be seen after HTTBR > being set up. Hint: look at HSCTLR, and when the M bit gets set. Until then, the words "virtual address" have no meaning. M. -- Fast, cheap, reliable. Pick two.