linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Mostafa Saleh <smostafa@google.com>
To: Marc Zyngier <maz@kernel.org>
Cc: oliver.upton@linux.dev, Sudeep Holla <sudeep.holla@arm.com>,
	linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
	linux-kernel@vger.kernel.org, tabba@google.com,
	qperret@google.com, will@kernel.org, catalin.marinas@arm.com,
	yuzenghui@huawei.com, suzuki.poulose@arm.com,
	james.morse@arm.com, bgardon@google.com, gshan@redhat.com
Subject: Re: [PATCH v3] KVM: arm64: Use BTI for nvhe
Date: Thu, 6 Jul 2023 15:23:32 +0000	[thread overview]
Message-ID: <ZKbcdGNurXPdNJgf@google.com> (raw)
In-Reply-To: <873521yv1j.wl-maz@kernel.org>

On Thu, Jul 06, 2023 at 03:27:36PM +0100, Marc Zyngier wrote:
> Hi Mostafa,
> 
> On Thu, 06 Jul 2023 13:49:04 +0100,
> Mostafa Saleh <smostafa@google.com> wrote:
> > 
> > Hi Marc and Oliver,
> > 
> > I was double checking that nothing else was missed.
> > 
> > I found there is another problem for hw that has BTI and is affected
> > by specterv3a.
> > 
> > "br'' instructions are generated at runtime for the vector
> > table(__bp_harden_hyp_vecs).  These branches would land on vectors
> > in __kvm_hyp_vector at offset 8.
> > 
> > As all the macros are defined with valid_vect/invalid_vect, it is
> > sufficient to add "bti j" there at the correct offset.
> >
> > I am not sure if such hardware exists. I tested this with a stubbed
> > "has_spectre_v3a" which confirms the issue and the fix.
> 
> Thanks for the heads up.
> 
> Fortunately, there is no such HW as far as I can tell. Only Cortex-A57
> and A72 are affected by this (and the only two CPUs for which we
> engage the mitigation), and they are way too old to know about BTI.
> 
> > Please let me know if this fix suitable, I can include it with the other fix in
> > "[PATCH] KVM: arm64: Add missing BTI instruction in kvm_host_psci_cpu_entry"
> > 
> > diff --git a/arch/arm64/kvm/hyp/hyp-entry.S b/arch/arm64/kvm/hyp/hyp-entry.S
> > index 8f3f93fa119e..175c030379e3 100644
> > --- a/arch/arm64/kvm/hyp/hyp-entry.S
> > +++ b/arch/arm64/kvm/hyp/hyp-entry.S
> > @@ -154,6 +154,12 @@ SYM_CODE_END(\label)
> >   esb
> >   stp x0, x1, [sp, #-16]!
> >  662:
> > + /*
> > + * Specter vectors __bp_harden_hyp_vecs generate br instructions at runtime
> > + * that jump at offset 8 at __kvm_hyp_vector.
> > + * As hyp .text is guarded section, it needs bti j.
> > + */
> > + bti j
> >   b \target
> > 
> >  check_preamble_length 661b, 662b
> > @@ -165,6 +171,8 @@ check_preamble_length 661b, 662b
> >   nop
> >   stp x0, x1, [sp, #-16]!
> >  662:
> > + /* Check valid_vect */
> > + bti j
> >   b \target
> > 
> >  check_preamble_length 661b, 662b
> 
> This looks correct to me.
> 
> If you can respin you initial patch (with maybe a slightly more
> generic subject) so that Oliver can pick it up as part of the next
> batch of fixes, that'd be great.

Thanks a lot, I just sent v2.
[PATCH v2] KVM: arm64: Add missing BTI instructions

> Thanks,
> 
> 	M.
> 
> -- 
> Without deviation from the norm, progress is not possible.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-07-06 15:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-30 15:08 [PATCH v3] KVM: arm64: Use BTI for nvhe Mostafa Saleh
2023-05-30 18:01 ` Oliver Upton
2023-07-04 13:41 ` Sudeep Holla
2023-07-04 14:18   ` Mostafa Saleh
2023-07-04 14:33     ` Sudeep Holla
2023-07-04 16:27       ` Mostafa Saleh
2023-07-04 19:25         ` Sudeep Holla
2023-07-05 15:56           ` Mostafa Saleh
2023-07-06 12:49             ` Mostafa Saleh
2023-07-06 14:27               ` Marc Zyngier
2023-07-06 15:23                 ` Mostafa Saleh [this message]
2023-07-12 10:34   ` Linux regression tracking (Thorsten Leemhuis)
2023-07-12 10:44     ` Marc Zyngier
2023-07-12 10:52       ` Linux regression tracking (Thorsten Leemhuis)
2023-07-12 11:01         ` Marc Zyngier
2023-07-12 11:16           ` Linux regression tracking (Thorsten Leemhuis)

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=ZKbcdGNurXPdNJgf@google.com \
    --to=smostafa@google.com \
    --cc=bgardon@google.com \
    --cc=catalin.marinas@arm.com \
    --cc=gshan@redhat.com \
    --cc=james.morse@arm.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=qperret@google.com \
    --cc=sudeep.holla@arm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=tabba@google.com \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.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 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).