public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Oliver Upton <oliver.upton@linux.dev>
To: Will Deacon <will@kernel.org>
Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	maz@kernel.org, keirf@google.com,
	Quentin Perret <qperret@google.com>
Subject: Re: [PATCH] KVM: arm64: Add missing memory barriers when switching to pKVM's hyp pgd
Date: Thu, 4 Jan 2024 18:22:19 +0000	[thread overview]
Message-ID: <ZZb3W1N80q6pAib7@linux.dev> (raw)
In-Reply-To: <20240104164220.7968-1-will@kernel.org>

On Thu, Jan 04, 2024 at 04:42:20PM +0000, Will Deacon wrote:
> In commit f320bc742bc23 ("KVM: arm64: Prepare the creation of s1
> mappings at EL2"), pKVM switches from a temporary host-provided
> page-table to its own page-table at EL2. Since there is only a single
> TTBR for the nVHE hypervisor, this involves disabling and re-enabling
> the MMU in __pkvm_init_switch_pgd().
> 
> Unfortunately, the memory barriers here are not quite correct.
> Specifically:
> 
>   - A DSB is required to complete the TLB invalidation executed while
>     the MMU is disabled.
> 
>   - An ISB is required to make the new TTBR value visible to the
>     page-table walker before the MMU is enabled in the SCTLR.
> 
> An earlier version of the patch actually got this correct:
> 
>   https://lore.kernel.org/lkml/20210304184717.GB21795@willie-the-truck/
> 
> but thanks to some badly worded review comments from yours truly, these
> were dropped for the version that was eventually merged.
> 
> Bring back the barriers and fix the potential issue (but note that this
> was found by code inspection).
> 
> Cc: Quentin Perret <qperret@google.com>
> Fixes: f320bc742bc23 ("KVM: arm64: Prepare the creation of s1 mappings at EL2")
> Signed-off-by: Will Deacon <will@kernel.org>

+1 to Marc's suggestion about folding the appropriate barriers into the
macro, but fine with this as is:

Reviewed-by: Oliver Upton <oliver.upton@linux.dev>

-- 
Thanks,
Oliver

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

  parent reply	other threads:[~2024-01-04 18:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-04 16:42 [PATCH] KVM: arm64: Add missing memory barriers when switching to pKVM's hyp pgd Will Deacon
2024-01-04 18:20 ` Marc Zyngier
2024-01-04 18:22 ` Oliver Upton [this message]
2024-01-04 19:34 ` 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=ZZb3W1N80q6pAib7@linux.dev \
    --to=oliver.upton@linux.dev \
    --cc=keirf@google.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=maz@kernel.org \
    --cc=qperret@google.com \
    --cc=will@kernel.org \
    /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