Linux KVM/arm64 development list
 help / color / mirror / Atom feed
From: Alexandru Elisei <alexandru.elisei@arm.com>
To: Marc Zyngier <maz@kernel.org>
Cc: kvmarm@lists.cs.columbia.edu, shan.gavin@gmail.com
Subject: Re: [PATCH] arm64/kvm: Fix zapping stage2 page table wrongly
Date: Wed, 2 Sep 2020 12:56:47 +0100	[thread overview]
Message-ID: <af71b748-d28b-138c-9acf-fdba3408e0e8@arm.com> (raw)
In-Reply-To: <772ab66f-1e17-275f-f65d-08d8f67a90f9@arm.com>

Hi,

On 9/2/20 12:53 PM, Alexandru Elisei wrote:
> [..]
> And we end up jumping back to retry forever. IMO, in user_mem_abort(), if PUD_SIZE
> == PMD_SIZE, we should try to map PMD_SIZE instead of PUD_SIZE. Maybe something
> like this?
>
> diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
> index ba00bcc0c884..178267dec511 100644
> --- a/arch/arm64/kvm/mmu.c
> +++ b/arch/arm64/kvm/mmu.c
> @@ -1886,8 +1886,10 @@ static int user_mem_abort(struct kvm_vcpu *vcpu,
> phys_addr_t fault_ipa,
>          * As for PUD huge maps, we must make sure that we have at least
>          * 3 levels, i.e, PMD is not folded.
>          */
> -       if (vma_pagesize == PMD_SIZE ||
> -           (vma_pagesize == PUD_SIZE && kvm_stage2_has_pmd(kvm)))
> +       if (vma_pagesize == PUD_SIZE && !kvm_stage2_has_pmd(kvm))
> +               vma_pagesize = PMD_SIZE;
> +
> +       if (vma_pagesize == PUD_SIZE || vma_pagesize == PUD_SIZE)
>                 gfn = (fault_ipa & huge_page_mask(hstate_vma(vma))) >> PAGE_SHIFT;
>         mmap_read_unlock(current->mm);

Erm... goes without saying, completely untested and the check should have been:

+       if (vma_pagesize == PUD_SIZE || vma_pagesize == PMD_SIZE)

Thanks,

Alex

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

  reply	other threads:[~2020-09-02 11:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-22  2:44 [PATCH] arm64/kvm: Fix zapping stage2 page table wrongly Gavin Shan
2020-08-22 10:01 ` Marc Zyngier
2020-08-22 23:59   ` Gavin Shan
2020-09-01 16:50     ` Marc Zyngier
2020-09-02 10:59 ` Alexandru Elisei
2020-09-02 11:10   ` Marc Zyngier
2020-09-02 11:53     ` Alexandru Elisei
2020-09-02 11:56       ` Alexandru Elisei [this message]
2020-09-02 12:04       ` Marc Zyngier
2020-09-02 13:58         ` Alexandru Elisei
2020-09-02 17:38     ` Auger Eric
2020-09-02 23:55     ` Gavin Shan

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=af71b748-d28b-138c-9acf-fdba3408e0e8@arm.com \
    --to=alexandru.elisei@arm.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=maz@kernel.org \
    --cc=shan.gavin@gmail.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