All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mingwei Zhang <mizhang@google.com>
To: Sean Christopherson <seanjc@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
	kvm <kvm@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>,
	Ben Gardon <bgardon@google.com>,
	David Matlack <dmatlack@google.com>
Subject: Re: [PATCH] KVM: x86/mmu: add lockdep check before lookup_address_in_mm()
Date: Tue, 26 Apr 2022 18:24:14 -0700	[thread overview]
Message-ID: <CAL715W+nMyF_f762Qif8ZsiOT8vgxXJ3Rm8EjgG8A=b7iM-cbg@mail.gmail.com> (raw)
In-Reply-To: <YmiZcZf9YXxMVcfx@google.com>

On Tue, Apr 26, 2022 at 6:16 PM Sean Christopherson <seanjc@google.com> wrote:
>
> On Tue, Apr 26, 2022, Mingwei Zhang wrote:
> > > I completely agree that lookup_address() and friends are unnecessarily fragile,
> > > but I think that attempting to harden them to fix this KVM bug will open a can
> > > of worms and end up delaying getting KVM fixed.
> >
> > So basically, we need to:
> >  - choose perf_get_page_size() instead of using any of the
> > lookup_address*() in mm.
> >  - add a wrapper layer to adapt: 1) irq disabling/enabling and 2) size
> > -> level translation.
> >
> > Agree?
>
> Drat, I didn't see that it returns the page size, not the level.  That's a bit
> unfortunate.  It definitely makes me less averse to fixing lookup_address_in_pgd()
>
> Hrm.  I guess since we know there's at least one broken user, and in theory
> fixing lookup_address_in_pgd() should do no harm to users that don't need protection,
> it makes sense to just fix lookup_address_in_pgd() and see if the x86 maintainers
> push back.

Yeah, fixing lookup_address_in_pgd() should be cleaner(), since the
page fault usage case does not need irq save/restore. But the other
one needs it. So, we can easily fix the function with READ_ONCE and
lockless staff. But wrapping the function with irq save/restore from
the KVM side.

ok, I think I can proceed and upload one version for that.

Thanks.
-Mingwei

  reply	other threads:[~2022-04-27  1:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-27 20:58 [PATCH] KVM: x86/mmu: add lockdep check before lookup_address_in_mm() Mingwei Zhang
2022-03-28 15:16 ` Sean Christopherson
2022-03-28 17:41   ` Mingwei Zhang
2022-03-28 18:15     ` Sean Christopherson
2022-04-26 17:19       ` Mingwei Zhang
2022-04-26 17:49       ` Paolo Bonzini
2022-04-26 18:10         ` Sean Christopherson
2022-04-26 18:48           ` Mingwei Zhang
2022-04-27  1:16             ` Sean Christopherson
2022-04-27  1:24               ` Mingwei Zhang [this message]
2022-04-27  1:30                 ` Sean Christopherson
2022-04-27  2:56                   ` Mingwei Zhang
2022-04-27 14:08                     ` Sean Christopherson
  -- strict thread matches above, loose matches on Subject: below --
2022-03-27 20:35 Mingwei Zhang
2022-03-27 20:43 ` Mingwei Zhang

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='CAL715W+nMyF_f762Qif8ZsiOT8vgxXJ3Rm8EjgG8A=b7iM-cbg@mail.gmail.com' \
    --to=mizhang@google.com \
    --cc=bgardon@google.com \
    --cc=dmatlack@google.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.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.