From: Marc Zyngier <maz@kernel.org>
To: Oliver Upton <oliver.upton@linux.dev>
Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
kvm@vger.kernel.org, James Morse <james.morse@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Ard Biesheuvel <ardb@kernel.org>, Will Deacon <will@kernel.org>,
Quentin Perret <qperret@google.com>,
Sean Christopherson <seanjc@google.com>,
David Matlack <dmatlack@google.com>,
stable@vger.kernel.org
Subject: Re: [PATCH v2 1/2] KVM: arm64: Disable interrupts while walking userspace PTs
Date: Fri, 17 Mar 2023 09:03:50 +0000 [thread overview]
Message-ID: <760caa64691576b728c224bbbfdd18a4@kernel.org> (raw)
In-Reply-To: <ZBOpVLEPEJazjyGD@linux.dev>
On 2023-03-16 23:42, Oliver Upton wrote:
> Marc,
>
> On Thu, Mar 16, 2023 at 05:45:45PM +0000, Marc Zyngier wrote:
>> We walk the userspace PTs to discover what mapping size was
>> used there. However, this can race against the userspace tables
>> being freed, and we end-up in the weeds.
>>
>> Thankfully, the mm code is being generous and will IPI us when
>> doing so. So let's implement our part of the bargain and disable
>> interrupts around the walk. This ensures that nothing terrible
>> happens during that time.
>>
>> We still need to handle the removal of the page tables before
>> the walk. For that, allow get_user_mapping_size() to return an
>> error, and make sure this error can be propagated all the way
>> to the the exit handler.
>>
>> Signed-off-by: Marc Zyngier <maz@kernel.org>
>> Cc: stable@vger.kernel.org
>
> Looks good. I've squashed in this meaningless diff to make use of an
> existing
> helper.
>
>
> diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
> index e95593736ae3..3b9d4d24c361 100644
> --- a/arch/arm64/kvm/mmu.c
> +++ b/arch/arm64/kvm/mmu.c
> @@ -691,7 +691,7 @@ static int get_user_mapping_size(struct kvm *kvm,
> u64 addr)
> return -EFAULT;
>
> /* Oops, the userspace PTs are gone... Replay the fault */
> - if (!(pte & PTE_VALID))
> + if (!kvm_pte_valid(pte))
> return -EAGAIN;
Sure, LGTM.
Thanks,
M.
--
Jazz is not dead. It just smells funny...
WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Oliver Upton <oliver.upton@linux.dev>
Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
kvm@vger.kernel.org, James Morse <james.morse@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Ard Biesheuvel <ardb@kernel.org>, Will Deacon <will@kernel.org>,
Quentin Perret <qperret@google.com>,
Sean Christopherson <seanjc@google.com>,
David Matlack <dmatlack@google.com>,
stable@vger.kernel.org
Subject: Re: [PATCH v2 1/2] KVM: arm64: Disable interrupts while walking userspace PTs
Date: Fri, 17 Mar 2023 09:03:50 +0000 [thread overview]
Message-ID: <760caa64691576b728c224bbbfdd18a4@kernel.org> (raw)
In-Reply-To: <ZBOpVLEPEJazjyGD@linux.dev>
On 2023-03-16 23:42, Oliver Upton wrote:
> Marc,
>
> On Thu, Mar 16, 2023 at 05:45:45PM +0000, Marc Zyngier wrote:
>> We walk the userspace PTs to discover what mapping size was
>> used there. However, this can race against the userspace tables
>> being freed, and we end-up in the weeds.
>>
>> Thankfully, the mm code is being generous and will IPI us when
>> doing so. So let's implement our part of the bargain and disable
>> interrupts around the walk. This ensures that nothing terrible
>> happens during that time.
>>
>> We still need to handle the removal of the page tables before
>> the walk. For that, allow get_user_mapping_size() to return an
>> error, and make sure this error can be propagated all the way
>> to the the exit handler.
>>
>> Signed-off-by: Marc Zyngier <maz@kernel.org>
>> Cc: stable@vger.kernel.org
>
> Looks good. I've squashed in this meaningless diff to make use of an
> existing
> helper.
>
>
> diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
> index e95593736ae3..3b9d4d24c361 100644
> --- a/arch/arm64/kvm/mmu.c
> +++ b/arch/arm64/kvm/mmu.c
> @@ -691,7 +691,7 @@ static int get_user_mapping_size(struct kvm *kvm,
> u64 addr)
> return -EFAULT;
>
> /* Oops, the userspace PTs are gone... Replay the fault */
> - if (!(pte & PTE_VALID))
> + if (!kvm_pte_valid(pte))
> return -EAGAIN;
Sure, LGTM.
Thanks,
M.
--
Jazz is not dead. It just smells funny...
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-03-17 9:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-16 17:45 [PATCH v2 0/2] KVM: arm64: Plug a couple of MM races Marc Zyngier
2023-03-16 17:45 ` Marc Zyngier
2023-03-16 17:45 ` [PATCH v2 1/2] KVM: arm64: Disable interrupts while walking userspace PTs Marc Zyngier
2023-03-16 17:45 ` Marc Zyngier
2023-03-16 23:42 ` Oliver Upton
2023-03-16 23:42 ` Oliver Upton
2023-03-17 9:03 ` Marc Zyngier [this message]
2023-03-17 9:03 ` Marc Zyngier
2023-03-16 17:45 ` [PATCH v2 2/2] KVM: arm64: Check for kvm_vma_mte_allowed in the critical section Marc Zyngier
2023-03-16 17:45 ` Marc Zyngier
2023-03-17 1:20 ` [PATCH v2 0/2] KVM: arm64: Plug a couple of MM races Oliver Upton
2023-03-17 1:20 ` Oliver Upton
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=760caa64691576b728c224bbbfdd18a4@kernel.org \
--to=maz@kernel.org \
--cc=ardb@kernel.org \
--cc=dmatlack@google.com \
--cc=james.morse@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=oliver.upton@linux.dev \
--cc=qperret@google.com \
--cc=seanjc@google.com \
--cc=stable@vger.kernel.org \
--cc=suzuki.poulose@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 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.