All of lore.kernel.org
 help / color / mirror / Atom feed
From: Will Deacon <will@kernel.org>
To: Mark Rutland <mark.rutland@arm.com>
Cc: linux-arm-kernel@lists.infradead.org, alexandru.elisei@arm.com,
	catalin.marinas@arm.com, james.morse@arm.com, maz@kernel.org,
	stable@vger.kernel.org, suzuki.poulose@arm.com
Subject: Re: [PATCH] arm64/kvm: extract ESR_ELx.EC only
Date: Mon, 8 Nov 2021 10:07:46 +0000	[thread overview]
Message-ID: <20211108100745.GA2328@willie-the-truck> (raw)
In-Reply-To: <20211103110545.4613-1-mark.rutland@arm.com>

On Wed, Nov 03, 2021 at 11:05:45AM +0000, Mark Rutland wrote:
> Since ARMv8.0 the upper 32 bits of ESR_ELx have been RES0, and recently
> some of the upper bits gained a meaning and can be non-zero. For
> example, when FEAT_LS64 is implemented, ESR_ELx[36:32] contain ISS2,
> which for an ST64BV or ST64BV0 can be non-zero. This can be seen in ARM
> DDI 0487G.b, page D13-3145, section D13.2.37.
> 
> Generally, we must not rely on RES0 bit remaining zero in future, and
> when extracting ESR_ELx.EC we must mask out all other bits.
> 
> All C code uses the ESR_ELx_EC() macro, which masks out the irrelevant
> bits, and therefore no alterations are required to C code to avoid
> consuming irrelevant bits.
> 
> In a couple of places the KVM assembly extracts ESR_ELx.EC using LSR on
> an X register, and so could in theory consume previously RES0 bits. In
> both cases this is for comparison with EC values ESR_ELx_EC_HVC32 and
> ESR_ELx_EC_HVC64, for which the upper bits of ESR_ELx must currently be
> zero, but this could change in future.
> 
> This patch adjusts the KVM vectors to use UBFX rather than LSR to
> extract ESR_ELx.EC, ensuring these are robust to future additions to
> ESR_ELx.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Alexandru Elisei <alexandru.elisei@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: James Morse <james.morse@arm.com>
> Cc: Marc Zyngier <maz@kernel.org>
> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
> Cc: Will Deacon <will@kernel.org>
> ---
>  arch/arm64/include/asm/esr.h   | 1 +
>  arch/arm64/kvm/hyp/hyp-entry.S | 2 +-
>  arch/arm64/kvm/hyp/nvhe/host.S | 2 +-
>  3 files changed, 3 insertions(+), 2 deletions(-)

Acked-by: Will Deacon <will@kernel.org>

Will

WARNING: multiple messages have this Message-ID (diff)
From: Will Deacon <will@kernel.org>
To: Mark Rutland <mark.rutland@arm.com>
Cc: linux-arm-kernel@lists.infradead.org, alexandru.elisei@arm.com,
	catalin.marinas@arm.com, james.morse@arm.com, maz@kernel.org,
	stable@vger.kernel.org, suzuki.poulose@arm.com
Subject: Re: [PATCH] arm64/kvm: extract ESR_ELx.EC only
Date: Mon, 8 Nov 2021 10:07:46 +0000	[thread overview]
Message-ID: <20211108100745.GA2328@willie-the-truck> (raw)
In-Reply-To: <20211103110545.4613-1-mark.rutland@arm.com>

On Wed, Nov 03, 2021 at 11:05:45AM +0000, Mark Rutland wrote:
> Since ARMv8.0 the upper 32 bits of ESR_ELx have been RES0, and recently
> some of the upper bits gained a meaning and can be non-zero. For
> example, when FEAT_LS64 is implemented, ESR_ELx[36:32] contain ISS2,
> which for an ST64BV or ST64BV0 can be non-zero. This can be seen in ARM
> DDI 0487G.b, page D13-3145, section D13.2.37.
> 
> Generally, we must not rely on RES0 bit remaining zero in future, and
> when extracting ESR_ELx.EC we must mask out all other bits.
> 
> All C code uses the ESR_ELx_EC() macro, which masks out the irrelevant
> bits, and therefore no alterations are required to C code to avoid
> consuming irrelevant bits.
> 
> In a couple of places the KVM assembly extracts ESR_ELx.EC using LSR on
> an X register, and so could in theory consume previously RES0 bits. In
> both cases this is for comparison with EC values ESR_ELx_EC_HVC32 and
> ESR_ELx_EC_HVC64, for which the upper bits of ESR_ELx must currently be
> zero, but this could change in future.
> 
> This patch adjusts the KVM vectors to use UBFX rather than LSR to
> extract ESR_ELx.EC, ensuring these are robust to future additions to
> ESR_ELx.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Alexandru Elisei <alexandru.elisei@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: James Morse <james.morse@arm.com>
> Cc: Marc Zyngier <maz@kernel.org>
> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
> Cc: Will Deacon <will@kernel.org>
> ---
>  arch/arm64/include/asm/esr.h   | 1 +
>  arch/arm64/kvm/hyp/hyp-entry.S | 2 +-
>  arch/arm64/kvm/hyp/nvhe/host.S | 2 +-
>  3 files changed, 3 insertions(+), 2 deletions(-)

Acked-by: Will Deacon <will@kernel.org>

Will

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

  reply	other threads:[~2021-11-08 10:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-03 11:05 [PATCH] arm64/kvm: extract ESR_ELx.EC only Mark Rutland
2021-11-03 11:05 ` Mark Rutland
2021-11-08 10:07 ` Will Deacon [this message]
2021-11-08 10:07   ` Will Deacon
2021-11-08 10:42 ` Marc Zyngier
2021-11-08 10:42   ` Marc Zyngier

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=20211108100745.GA2328@willie-the-truck \
    --to=will@kernel.org \
    --cc=alexandru.elisei@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=james.morse@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=suzuki.poulose@arm.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.