All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <marc.zyngier@arm.com>
To: Andrew Jones <drjones@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Auger Eric <eric.auger@redhat.com>,
	Daniel Thompson <daniel.thompson@linaro.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	Robert Richter <robert.richter@caviumnetworks.com>,
	"kvmarm@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>
Subject: Re: v4.9-rc1 fails booting as a guest on ARM64 Cavium ThunderX
Date: Fri, 21 Oct 2016 14:47:43 +0100	[thread overview]
Message-ID: <20161021144743.32b44b3f@arm.com> (raw)
In-Reply-To: <20161021130639.6kxvi73kmagf2gwu@kamzik.brq.redhat.com>

On Fri, 21 Oct 2016 15:06:39 +0200
Andrew Jones <drjones@redhat.com> wrote:

> On Fri, Oct 21, 2016 at 01:52:43PM +0100, Marc Zyngier wrote:
> > On 21/10/16 13:07, Andrew Jones wrote:  
> > > On Fri, Oct 21, 2016 at 12:57:37PM +0100, Peter Maydell wrote:  
> > >> On 21 October 2016 at 12:49, Andrew Jones <drjones@redhat.com> wrote:  
> > >>> I also read the register before writing it and saw it was 3. I tried
> > >>> writing 3 instead of 0 to see what would happen, but the failure
> > >>> persisted. I did read back the register after writing it to confirm the
> > >>> change took affect.  
> > >>
> > >> So what does it read back as after you write 0? The GICv3 spec
> > >> says it can't read back as zero...
> > >>  
> > > 
> > > I read back zero
> > > 
> > > pre-read  bpr1=3
> > > post-read bpr1=0
> > > FAIL: gicv3: ipi: self: Timed-out (5s). ACKS: missing=1 extra=0 unexpected=0  
> > 
> > Gah... I guess we'll have to either roll a dice, or get someone from
> > Cavium to tell us what's happening here. In the meantime, can you give
> > the following patch a go? It doesn't fire on my FSL box, but everything
> > hunky dory on it so far...
> > 
> > Thanks,
> > 
> > 	M.
> > 
> > diff --git a/arch/arm/include/asm/arch_gicv3.h b/arch/arm/include/asm/arch_gicv3.h
> > index a808829..5c03171 100644
> > --- a/arch/arm/include/asm/arch_gicv3.h
> > +++ b/arch/arm/include/asm/arch_gicv3.h
> > @@ -222,6 +222,11 @@ static inline void gic_write_bpr1(u32 val)
> >  	write_sysreg(val, ICC_BPR1);
> >  }
> >  
> > +static inline u32 gic_write_bpr1(void)
> > +{
> > +	return read_sysreg(ICC_BPR1);
> > +}
> > +
> >  /*
> >   * Even in 32bit systems that use LPAE, there is no guarantee that the I/O
> >   * interface provides true 64bit atomic accesses, so using strd/ldrd doesn't
> > diff --git a/arch/arm64/include/asm/arch_gicv3.h b/arch/arm64/include/asm/arch_gicv3.h
> > index f8ae6d6..74fe2c9 100644
> > --- a/arch/arm64/include/asm/arch_gicv3.h
> > +++ b/arch/arm64/include/asm/arch_gicv3.h
> > @@ -184,6 +184,13 @@ static inline void gic_write_bpr1(u32 val)
> >  	asm volatile("msr_s " __stringify(ICC_BPR1_EL1) ", %0" : : "r" (val));
> >  }
> >  
> > +static inline u32 gic_read_bpr1(void)
> > +{
> > +	u64 val;
> > +	asm volatile("mrs_s %0, " __stringify(ICC_BPR1_EL1) : "=r" (val));
> > +	return val;
> > +}
> > +
> >  #define gic_read_typer(c)		readq_relaxed(c)
> >  #define gic_write_irouter(v, c)		writeq_relaxed(v, c)
> >  
> > diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
> > index 9b81bd8..db90286 100644
> > --- a/drivers/irqchip/irq-gic-v3.c
> > +++ b/drivers/irqchip/irq-gic-v3.c
> > @@ -482,6 +482,8 @@ static int gic_populate_rdist(void)
> >  
> >  static void gic_cpu_sys_reg_init(void)
> >  {
> > +	u32 bpr1_old, bpr1_new;
> > +
> >  	/*
> >  	 * Need to check that the SRE bit has actually been set. If
> >  	 * not, it means that SRE is disabled at EL2. We're going to
> > @@ -499,9 +501,19 @@ static void gic_cpu_sys_reg_init(void)
> >  	 * Some firmwares hand over to the kernel with the BPR changed from
> >  	 * its reset value (and with a value large enough to prevent
> >  	 * any pre-emptive interrupts from working at all). Writing a zero
> > -	 * to BPR restores is reset value.
> > +	 * to BPR restores is reset value (though there seems to be some
> > +	 * less than compliant implementations around, hence the warning...).
> >  	 */
> > +	bpr1_old = gic_read_bpr1();
> >  	gic_write_bpr1(0);
> > +	isb();
> > +	bpr1_new = gic_read_bpr1();
> > +
> > +	if (bpr1_new == 0) {
> > +		pr_warn("Failed to reset BPR1 (%d), restoring previous (%d)\n",
> > +			bpr1_new, bpr1_old);
> > +		gic_write_bpr1(bpr1_old);
> > +	}
> >  
> >  	if (static_key_true(&supports_deactivate)) {
> >  		/* EOI drops priority only (mode 1) */
> >  
> 
> FWIW, the equivalent implementation didn't help kvm-unit-tests. Still
> timing-out. Even after attempting to set it back to old, which was 3,
> when I read it again I still get zero,
> 
> pre-read  bpr1=3
> post-read bpr1=0
> new = 0, old = 3
> resetting to old and doing post-post-read...
> post-post-read bpr1=0
> FAIL: gicv3: ipi: self: Timed-out (5s). ACKS: missing=1 extra=0 unexpected=0

fsck... Let's try something else. Obviously, Hardcoded values are bad.
Untested.

	M.

diff --git a/virt/kvm/arm/hyp/vgic-v3-sr.c b/virt/kvm/arm/hyp/vgic-v3-sr.c
index 3947095cc0a1..0d5596f5876c 100644
--- a/virt/kvm/arm/hyp/vgic-v3-sr.c
+++ b/virt/kvm/arm/hyp/vgic-v3-sr.c
@@ -160,6 +160,8 @@ void __hyp_text __vgic_v3_save_state(struct kvm_vcpu *vcpu)
 		dsb(st);
 
 	cpu_if->vgic_vmcr  = read_gicreg(ICH_VMCR_EL2);
+	if (unlikely(!((cpu_if->vgic_vmcr >> 18) & 7)))
+		cpu_if->vgic_vmcr |= 3 << 18;
 
 	if (vcpu->arch.vgic_cpu.live_lrs) {
 		int i;

-- 
Jazz is not dead. It just smells funny.

  reply	other threads:[~2016-10-21 13:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-21  7:01 v4.9-rc1 fails booting as a guest on ARM64 Cavium ThunderX Auger Eric
2016-10-21  8:45 ` Marc Zyngier
2016-10-21  9:05   ` Auger Eric
2016-10-21  9:40     ` Marc Zyngier
2016-10-21  9:46       ` Auger Eric
2016-10-21 11:49         ` Andrew Jones
2016-10-21 11:57           ` Peter Maydell
2016-10-21 12:07             ` Andrew Jones
2016-10-21 12:52               ` Marc Zyngier
2016-10-21 12:58                 ` Peter Maydell
2016-10-21 13:20                   ` Marc Zyngier
2016-10-21 13:06                 ` Andrew Jones
2016-10-21 13:47                   ` Marc Zyngier [this message]
2016-10-21 16:34                 ` Robert Richter
2016-10-26  7:18                 ` Robert Richter
2016-10-26  7:39                   ` Marc Zyngier
2016-11-03 18:01     ` Robert Richter
2016-11-04 13:30       ` Auger Eric
2016-10-21 10:40   ` Daniel Thompson

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=20161021144743.32b44b3f@arm.com \
    --to=marc.zyngier@arm.com \
    --cc=daniel.thompson@linaro.org \
    --cc=drjones@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=peter.maydell@linaro.org \
    --cc=robert.richter@caviumnetworks.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.