All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Oliver Upton <oliver.upton@linux.dev>
Cc: kvmarm@lists.linux.dev, Joey Gouly <joey.gouly@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>
Subject: Re: [PATCH v2 14/27] KVM: arm64: Describe SCTLR2_ELx RESx masks
Date: Sat, 21 Jun 2025 12:34:14 +0100	[thread overview]
Message-ID: <86bjqhcoqx.wl-maz@kernel.org> (raw)
In-Reply-To: <20250616230308.1192565-15-oliver.upton@linux.dev>

On Tue, 17 Jun 2025 00:02:55 +0100,
Oliver Upton <oliver.upton@linux.dev> wrote:
> 
> External abort injection will soon rely on a sanitised view of
> SCTLR2_ELx to determine exception routing. Compute the RESx masks.
> 
> Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
> ---
>  arch/arm64/kvm/config.c | 28 ++++++++++++++++++++++++++++
>  arch/arm64/kvm/nested.c |  6 ++++++
>  2 files changed, 34 insertions(+)
> 
> diff --git a/arch/arm64/kvm/config.c b/arch/arm64/kvm/config.c
> index 54911a93b001..e8a33e91e665 100644
> --- a/arch/arm64/kvm/config.c
> +++ b/arch/arm64/kvm/config.c
> @@ -131,6 +131,8 @@ struct reg_bits_to_feat_map {
>  #define FEAT_SPMU		ID_AA64DFR1_EL1, SPMU, IMP
>  #define FEAT_SPE_nVM		ID_AA64DFR2_EL1, SPE_nVM, IMP
>  #define FEAT_STEP2		ID_AA64DFR2_EL1, STEP, IMP
> +#define FEAT_SYSREG128		ID_AA64ISAR2_EL1, SYSREG_128, IMP
> +#define FEAT_CPA2		ID_AA64ISAR3_EL1, CPA, CPA2
>  
>  static bool not_feat_aa64el3(struct kvm *kvm)
>  {
> @@ -832,6 +834,23 @@ static const struct reg_bits_to_feat_map hcr_feat_map[] = {
>  	NEEDS_FEAT_FIXED(HCR_EL2_E2H, compute_hcr_e2h),
>  };
>  
> +static const struct reg_bits_to_feat_map sctlr2_feat_map[] = {
> +	NEEDS_FEAT(SCTLR2_EL1_NMEA	|
> +		   SCTLR2_EL1_EASE,
> +		   FEAT_DoubleFault2),
> +	NEEDS_FEAT(SCTLR2_EL1_EnADERR, feat_aderr),
> +	NEEDS_FEAT(SCTLR2_EL1_EnANERR, feat_anerr),
> +	NEEDS_FEAT(SCTLR2_EL1_EnIDCP128, FEAT_SYSREG128),
> +	NEEDS_FEAT(SCTLR2_EL1_EnPACM	|
> +		   SCTLR2_EL1_EnPACM0,
> +		   feat_pauth_lr),
> +	NEEDS_FEAT(SCTLR2_EL1_CPTA	|
> +		   SCTLR2_EL1_CPTA0	|
> +		   SCTLR2_EL1_CPTM	|
> +		   SCTLR2_EL1_CPTM0,
> +		   FEAT_CPA2),
> +};
> +
>  static void __init check_feat_map(const struct reg_bits_to_feat_map *map,
>  				  int map_size, u64 res0, const char *str)
>  {
> @@ -863,6 +882,8 @@ void __init check_feature_map(void)
>  		       __HCRX_EL2_RES0, "HCRX_EL2");
>  	check_feat_map(hcr_feat_map, ARRAY_SIZE(hcr_feat_map),
>  		       HCR_EL2_RES0, "HCR_EL2");
> +	check_feat_map(sctlr2_feat_map, ARRAY_SIZE(sctlr2_feat_map),
> +		       SCTLR2_EL1_RES0, "SCTLR2_EL1");
>  }
>  
>  static bool idreg_feat_match(struct kvm *kvm, const struct reg_bits_to_feat_map *map)
> @@ -1077,6 +1098,13 @@ void get_reg_fixed_bits(struct kvm *kvm, enum vcpu_sysreg reg, u64 *res0, u64 *r
>  		*res0 |= HCR_EL2_RES0 | (mask & ~fixed);
>  		*res1 = HCR_EL2_RES1 | (mask & fixed);
>  		break;
> +	case SCTLR2_EL1:
> +	case SCTLR2_EL2:
> +		*res0 = compute_res0_bits(kvm, sctlr2_feat_map,
> +					  ARRAY_SIZE(sctlr2_feat_map), 0, 0);
> +		*res0 |= SCTLR2_EL1_RES0;
> +		*res1 = SCTLR2_EL1_RES1;
> +		break;

This is potentially mis-describing SCTLR2_EL2.EMEC, which is
conditioned on FEAT_MEC. This isn't a huge deal at this stage, but may
become useful if MEC gets expanded to non-Realm PAS. I think it'd be
worth adding a SCTLR2_EL2-specific table for this.

Thanks,

	M.

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

  reply	other threads:[~2025-06-21 11:34 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-16 23:02 [PATCH v2 00/27] KVM: arm64: SCTLR2, DoubleFault2, and NV external abort fixes Oliver Upton
2025-06-16 23:02 ` [PATCH v2 01/27] arm64: Detect FEAT_SCTLR2 Oliver Upton
2025-06-16 23:02 ` [PATCH v2 02/27] arm64: Detect FEAT_DoubleFault2 Oliver Upton
2025-06-16 23:02 ` [PATCH v2 03/27] KVM: arm64: Add helper to identify a nested context Oliver Upton
2025-06-16 23:02 ` [PATCH v2 04/27] KVM: arm64: Treat vCPU with pending SError as runnable Oliver Upton
2025-06-16 23:02 ` [PATCH v2 05/27] KVM: arm64: nv: Respect exception routing rules for SEAs Oliver Upton
2025-06-21  9:51   ` Marc Zyngier
2025-06-16 23:02 ` [PATCH v2 06/27] KVM: arm64: nv: Honor SError exception routing / masking Oliver Upton
2025-06-21 10:47   ` Marc Zyngier
2025-06-24 11:44     ` Oliver Upton
2025-06-16 23:02 ` [PATCH v2 07/27] KVM: arm64: nv: Add FEAT_RAS vSError sys regs to table Oliver Upton
2025-06-16 23:02 ` [PATCH v2 08/27] KVM: arm64: nv: Use guest hypervisor's vSError state Oliver Upton
2025-06-21 11:09   ` Marc Zyngier
2025-06-16 23:02 ` [PATCH v2 09/27] KVM: arm64: nv: Advertise support for FEAT_RAS Oliver Upton
2025-06-16 23:02 ` [PATCH v2 10/27] KVM: arm64: nv: Describe trap behavior of SCTLR2_EL1 Oliver Upton
2025-06-16 23:02 ` [PATCH v2 11/27] KVM: arm64: Wire up SCTLR2_ELx sysreg descriptors Oliver Upton
2025-06-16 23:02 ` [PATCH v2 12/27] KVM: arm64: Context switch SCTLR2_ELx when advertised to the guest Oliver Upton
2025-06-16 23:02 ` [PATCH v2 13/27] KVM: arm64: Enable SCTLR2 " Oliver Upton
2025-06-16 23:02 ` [PATCH v2 14/27] KVM: arm64: Describe SCTLR2_ELx RESx masks Oliver Upton
2025-06-21 11:34   ` Marc Zyngier [this message]
2025-06-16 23:02 ` [PATCH v2 15/27] KVM: arm64: Factor out helper for selecting exception target EL Oliver Upton
2025-06-16 23:02 ` [PATCH v2 16/27] KVM: arm64: nv: Ensure Address size faults affect correct ESR Oliver Upton
2025-06-16 23:02 ` [PATCH v2 17/27] KVM: arm64: Route SEAs to the SError vector when EASE is set Oliver Upton
2025-06-21 11:54   ` Marc Zyngier
2025-06-24  8:12     ` Oliver Upton
2025-06-16 23:02 ` [PATCH v2 18/27] KVM: arm64: nv: Handle effects of HCRX_EL2.TMEA on SError injection Oliver Upton
2025-06-21 13:03   ` Marc Zyngier
2025-06-16 23:03 ` [PATCH v2 19/27] KVM: arm64: Take "masked" SEAs to EL2 when TMEA is set Oliver Upton
2025-06-22  8:39   ` Marc Zyngier
2025-06-16 23:03 ` [PATCH v2 20/27] KVM: arm64: nv: Enable vSErrors when HCRX_EL2.TMEA " Oliver Upton
2025-06-16 23:03 ` [PATCH v2 21/27] KVM: arm64: Advertise support for FEAT_SCTLR2 Oliver Upton
2025-06-16 23:03 ` [PATCH v2 22/27] KVM: arm64: Advertise support for FEAT_DoubleFault2 Oliver Upton
2025-06-16 23:03 ` [PATCH v2 23/27] KVM: arm64: Don't retire MMIO instruction w/ pending (emulated) SError Oliver Upton
2025-06-16 23:03 ` [PATCH v2 24/27] KVM: arm64: selftests: Add basic SError injection test Oliver Upton
2025-06-16 23:03 ` [PATCH v2 25/27] KVM: arm64: selftests: Test SEAs are taken to SError vector when EASE=1 Oliver Upton
2025-06-16 23:03 ` [PATCH v2 26/27] KVM: arm64: selftests: Add SCTLR2_EL1 to get-reg-list Oliver Upton
2025-06-16 23:03 ` [PATCH v2 27/27] KVM: arm64: selftests: Catch up set_id_regs with the kernel Oliver Upton
2025-06-22  9:25 ` [PATCH v2 00/27] KVM: arm64: SCTLR2, DoubleFault2, and NV external abort fixes 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=86bjqhcoqx.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=joey.gouly@arm.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=oliver.upton@linux.dev \
    --cc=suzuki.poulose@arm.com \
    --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 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.