From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rusty Russell Subject: Re: [PATCH v7 08/12] ARM: KVM: World-switch implementation Date: Fri, 23 Mar 2012 10:53:40 +1030 Message-ID: <87wr6c88s3.fsf@rustcorp.com.au> References: <20120312065134.8074.36949.stgit@ubuntu> <20120312065241.8074.44277.stgit@ubuntu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: tech@virtualopensystems.com To: Christoffer Dall , android-virt@lists.cs.columbia.edu, kvm@vger.kernel.org, "Peter Maydell" Return-path: Received: from ozlabs.org ([203.10.76.45]:51749 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752022Ab2CWAfJ (ORCPT ); Thu, 22 Mar 2012 20:35:09 -0400 In-Reply-To: <20120312065241.8074.44277.stgit@ubuntu> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, 12 Mar 2012 02:52:41 -0400, Christoffer Dall wrote: > @@ -236,6 +237,24 @@ int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu) > > int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) > { > + unsigned long cpsr; > + unsigned long sctlr; > + > + > + /* Init execution CPSR */ > + asm volatile ("mrs %[cpsr], cpsr" : > + [cpsr] "=r" (cpsr)); > + vcpu->arch.regs.cpsr = SVC_MODE | PSR_I_BIT | PSR_F_BIT | PSR_A_BIT | > + (cpsr & PSR_E_BIT); > + > + /* Init SCTLR with MMU disabled */ > + asm volatile ("mrc p15, 0, %[sctlr], c1, c0, 0" : > + [sctlr] "=r" (sctlr)); > + vcpu->arch.cp15[c1_SCTLR] = sctlr & ~1U; > + > + /* Compute guest MPIDR */ > + vcpu->arch.cp15[c0_MPIDR] = (read_cpuid_mpidr() & ~0xff) > + | vcpu->vcpu_id; > return 0; > } Hi Christoffer! I started cleaning this up, on the theory that we should use the defined reset values rather than basing them on host values. Then I discovered that this is ignored by qemu anyway, which overrides the values (except for MPIDR: I set that to 0x80000000 | vcpu->vcpu_id, which seems correct to me). Should this code be dropped altogether? Peter points out that once we add new regs, they *must* be initialized to correct reset values in case older QEMU knows nothing about them, but for the rest it just seems confusing... Thanks, Rusty. -- How could I marry someone with more hair than me? http://baldalex.org