linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Alexander Graf <graf@amazon.com>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
	KarimAllah Raslan <karahmed@amazon.de>,
	Aaron Lewis <aaronlewis@google.com>,
	kvm@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/3] KVM: x86: Introduce allow list for MSR emulation
Date: Mon, 3 Aug 2020 14:23:08 -0700	[thread overview]
Message-ID: <20200803212307.GI3151@linux.intel.com> (raw)
In-Reply-To: <2585c6d6-81b0-8375-78ed-862da226ad6c@amazon.com>

On Mon, Aug 03, 2020 at 10:50:53PM +0200, Alexander Graf wrote:
> 
> On 03.08.20 13:37, Vitaly Kuznetsov wrote:
> >>+static int kvm_vm_ioctl_clear_msr_allowlist(struct kvm *kvm)
> >>+{
> >>+     mutex_lock(&kvm->lock);
> >>+     kvm->arch.msr_allowlist_ranges_count = 0;
> >>+     mutex_unlock(&kvm->lock);
> >
> >Are we also supposed to kfree() bitmaps here?
> 
> Phew. Yes, because without the kfree() we're leaking memory. Unfortunately
> if I just put in a kfree() here, we may allow a concurrently executing vCPU
> to access already free'd memory.
> 
> So I'll also add locking around the range check. Let's hope it won't regress
> performance too much.

What about using KVM's SRCU to protect the list?  The only thing I'm not 100%
on is whether holding kvm->lock across synchronize_srcu() is safe from a lock
inversion perspective.  I'm pretty sure KVM doesn't try to acquire kvm->lock
after grabbing SRCU, but that's hard to audit and there aren't any existing
flows that invoke synchronize_srcu() while holding kvm->lock.

  reply	other threads:[~2020-08-03 21:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-31 21:49 [PATCH v3 0/3] Allow user space to restrict and augment MSR emulation Alexander Graf
2020-07-31 21:49 ` [PATCH v3 1/3] KVM: x86: Deflect unknown MSR accesses to user space Alexander Graf
2020-07-31 23:36   ` Jim Mattson
2020-08-03 10:08     ` Alexander Graf
2020-08-03 11:27   ` Vitaly Kuznetsov
2020-08-03 11:34     ` Alexander Graf
2020-07-31 21:49 ` [PATCH v3 2/3] KVM: x86: Introduce allow list for MSR emulation Alexander Graf
2020-08-03 11:37   ` Vitaly Kuznetsov
2020-08-03 20:50     ` Alexander Graf
2020-08-03 21:23       ` Sean Christopherson [this message]
2020-07-31 21:49 ` [PATCH v3 3/3] KVM: selftests: Add test for user space MSR handling Alexander Graf

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=20200803212307.GI3151@linux.intel.com \
    --to=sean.j.christopherson@intel.com \
    --cc=aaronlewis@google.com \
    --cc=corbet@lwn.net \
    --cc=graf@amazon.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=karahmed@amazon.de \
    --cc=kvm@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).