Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Joey Gouly <joey.gouly@arm.com>
To: Wei-Lin Chang <weilin.chang@arm.com>
Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
	linux-kernel@vger.kernel.org, Marc Zyngier <maz@kernel.org>,
	Oliver Upton <oupton@kernel.org>,
	Fuad Tabba <fuad.tabba@linux.dev>,
	Steffen Eiden <seiden@linux.ibm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Jonathan Cameron <jic23@kernel.org>,
	Mark Brown <broonie@kernel.org>,
	Sascha Bischoff <Sascha.Bischoff@arm.com>,
	James Clark <james.clark@linaro.org>,
	Lorenzo Pieralisi <lpieralisi@kernel.org>,
	Anshuman Khandual <anshuman.khandual@arm.com>,
	Thomas Huth <thuth@redhat.com>,
	Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
Subject: Re: [PATCH v2 3/4] KVM: arm64: Reset TCR_EL2 according to guest's E2H mode
Date: Thu, 29 Oct 2026 11:36:17 +0000	[thread overview]
Message-ID: <auMvsSOJ7canv8lh@e143914.arm.com> (raw)
In-Reply-To: <20260917214215.74135-4-weilin.chang@arm.com>

On Thu, Sep 17, 2026 at 10:42:13PM +0100, Wei-Lin Chang wrote:
> From: Marc Zyngier <maz@kernel.org>
> 
> Previously vCPU TCR_EL2's reset value didn't consider TCR_EL2's
> different formats based on the value of HCR_EL2.E2H. It always resets to
> the E2H == 0 version.
> 
> This didn't cause any problem because the bits set in the E2H == 0
> version (TCR_EL2_RES1) all reset to UNKNOWN for E2H == 1 per the
> architecture.
> 
> Still, it's better to fix it. Choose the correct reset value by checking
> KVM_ARM_VCPU_HAS_EL2_E2H0.
> 
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> Signed-off-by: Wei-Lin Chang <weilin.chang@arm.com>

Reviewed-by: Joey Gouly <joey.gouly@arm.com>

> ---
>  arch/arm64/kvm/sys_regs.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> index 44aae52c473d..62c059747fbb 100644
> --- a/arch/arm64/kvm/sys_regs.c
> +++ b/arch/arm64/kvm/sys_regs.c
> @@ -3275,6 +3275,14 @@ static u64 reset_mdcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
>  	return vcpu->kvm->arch.nr_pmu_counters;
>  }
>  
> +static u64 reset_tcr_el2(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
> +{
> +	__vcpu_assign_sys_reg(vcpu, r->reg,
> +			      vcpu_has_feature(vcpu, KVM_ARM_VCPU_HAS_EL2_E2H0) ?
> +			      TCR_EL2_RES1 : VHE_TCR_EL2_RES1);
> +	return __vcpu_sys_reg(vcpu, r->reg);
> +}
> +
>  /*
>   * Architected system registers.
>   * Important: Must be sorted ascending by Op0, Op1, CRn, CRm, Op2
> @@ -3853,7 +3861,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {
>  
>  	EL2_REG(TTBR0_EL2, access_rw, reset_val, 0),
>  	EL2_REG(TTBR1_EL2, access_rw, reset_val, 0),
> -	EL2_REG(TCR_EL2, access_rw, reset_val, TCR_EL2_RES1),
> +	EL2_REG(TCR_EL2, access_rw, reset_tcr_el2, 0),
>  	EL2_REG_FILTERED(TCR2_EL2, access_rw, reset_val, TCR2_EL2_RES1,
>  			 tcr2_el2_visibility),
>  	EL2_REG_VNCR(VTTBR_EL2, reset_val, 0),
> -- 
> 2.43.0
> 


  reply	other threads:[~2026-10-29 11:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17 21:42 [PATCH v2 0/4] KVM: arm64: Properly advertise !FEAT_LPA2 for NV Wei-Lin Chang
2026-09-17 21:42 ` [PATCH v2 1/4] KVM: arm64: nv: Don't advertise FEAT_LPA2 for guest stage-1 Wei-Lin Chang
2026-09-17 21:42 ` [PATCH v2 2/4] arm64: sysreg: Add TCR_EL2 to sysreg infrastructure Wei-Lin Chang
2026-09-17 21:42 ` [PATCH v2 3/4] KVM: arm64: Reset TCR_EL2 according to guest's E2H mode Wei-Lin Chang
2026-10-29 11:36   ` Joey Gouly [this message]
2026-09-17 21:42 ` [PATCH v2 4/4] KVM: arm64: Convert TCR_EL2 to config-driven sanitisation Wei-Lin Chang
2026-10-29 12:38   ` Joey Gouly
2026-10-29 15:39     ` Wei-Lin Chang

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=auMvsSOJ7canv8lh@e143914.arm.com \
    --to=joey.gouly@arm.com \
    --cc=Sascha.Bischoff@arm.com \
    --cc=anshuman.khandual@arm.com \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=fuad.tabba@linux.dev \
    --cc=gankulkarni@os.amperecomputing.com \
    --cc=james.clark@linaro.org \
    --cc=jic23@kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=seiden@linux.ibm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=thuth@redhat.com \
    --cc=weilin.chang@arm.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