All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Upton <oliver.upton@linux.dev>
To: Fuad Tabba <tabba@google.com>
Cc: kvmarm@lists.linux.dev, maz@kernel.org, catalin.marinas@arm.com,
	james.morse@arm.com, suzuki.poulose@arm.com,
	yuzenghui@huawei.com, will@kernel.org
Subject: Re: [PATCH v1 2/5] KVM: arm64: Disable SME Traps for (h)VHE at setup
Date: Wed, 19 Jul 2023 17:34:12 +0000	[thread overview]
Message-ID: <ZLgelCk3+W3YOpVx@linux.dev> (raw)
In-Reply-To: <20230719150639.1968034-3-tabba@google.com>

On Wed, Jul 19, 2023 at 04:06:36PM +0100, Fuad Tabba wrote:
> Ensure that SME traps are disabled for (h)VHE when setting up
> EL2, as they are for nVHE.
> 
> Signed-off-by: Fuad Tabba <tabba@google.com>
> ---
>  arch/arm64/include/asm/el2_setup.h | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/el2_setup.h b/arch/arm64/include/asm/el2_setup.h
> index c106b31d776c..7001b6db3ccc 100644
> --- a/arch/arm64/include/asm/el2_setup.h
> +++ b/arch/arm64/include/asm/el2_setup.h
> @@ -292,9 +292,21 @@
>  	check_override id_aa64pfr1, ID_AA64PFR1_EL1_SME_SHIFT, .Linit_sme_\@, .Lskip_sme_\@, x1, x2
>  
>  .Linit_sme_\@:	/* SME register access and priority mapping */
> +	mrs	x1, hcr_el2
> +	and	x1, x1, #HCR_E2H
> +	cbz	x1, .Lcptr_nvhe_sme_\@

Hmm.. Our test for hVHE is repeated enough times, it might make sense
for readability to wrap it up in a macro:

.macro check_hvhe pass, fail, tmp
	mrs	\tmp, hcr_el2
	and	\tmp, \tmp, #HCR_E2H
	cbnz	\tmp, \pass
	b	\fail
.endm

So long as we tolerate the additional word of bloat for the extra branch
:)

> +	// (h)VHE case
> +	mrs	x0, cpacr_el1			// Disable SME traps
> +	orr	x0, x0, #(CPACR_EL1_SMEN_EL0EN | CPACR_EL1_SMEN_EL1EN)
> +	msr	cpacr_el1, x0
> +	b	.Lskip_set_cptr_sme_\@
> +
> +.Lcptr_nvhe_sme_\@: // nVHE case
>  	mrs	x0, cptr_el2			// Disable SME traps
>  	bic	x0, x0, #CPTR_EL2_TSM
>  	msr	cptr_el2, x0
> +.Lskip_set_cptr_sme_\@:
>  	isb
>  
>  	mrs	x1, sctlr_el2
> -- 
> 2.41.0.255.g8b1d071c50-goog
> 

-- 
Thanks,
Oliver

  reply	other threads:[~2023-07-19 17:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-19 15:06 [PATCH v1 0/5] Fix setting SVE and SME traps in (h)VHE Fuad Tabba
2023-07-19 15:06 ` [PATCH v1 1/5] KVM: arm64: Use the appropriate feature trap register for SVE at EL2 setup Fuad Tabba
2023-07-19 15:06 ` [PATCH v1 2/5] KVM: arm64: Disable SME Traps for (h)VHE at setup Fuad Tabba
2023-07-19 17:34   ` Oliver Upton [this message]
2023-07-20  8:03     ` Fuad Tabba
2023-07-20  8:36       ` Fuad Tabba
2023-07-19 15:06 ` [PATCH v1 3/5] KVM: arm64: Use the appropriate feature trap register when activating traps Fuad Tabba
2023-07-19 17:48   ` Oliver Upton
2023-07-19 18:40     ` Fuad Tabba
2023-07-19 15:06 ` [PATCH v1 4/5] KVM: arm64: Fix resetting SVE trap values on reset for hVHE Fuad Tabba
2023-07-19 15:06 ` [PATCH v1 5/5] KVM: arm64: Fix resetting SME trap values on reset for (h)VHE Fuad Tabba
2023-07-19 15:20 ` [PATCH v1 0/5] Fix setting SVE and SME traps in (h)VHE Marc Zyngier
2023-07-20  8:42   ` Fuad Tabba

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=ZLgelCk3+W3YOpVx@linux.dev \
    --to=oliver.upton@linux.dev \
    --cc=catalin.marinas@arm.com \
    --cc=james.morse@arm.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=maz@kernel.org \
    --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 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.