From: Sean Christopherson <seanjc@google.com>
To: "Carlos López" <clopez@suse.de>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com, stable@vger.kernel.org,
Thomas Gleixner <tglx@kernel.org>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<x86@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
Avi Kivity <avi@qumranet.com>, Qing He <qing.he@intel.com>,
"Yaozu (Eddie) Dong" <eddie.dong@intel.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
"open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] KVM: x86: Take PIC lock on KVM_GET_IRQCHIP path
Date: Fri, 29 May 2026 06:59:24 -0700 [thread overview]
Message-ID: <ahmbvDGHvORqofrj@google.com> (raw)
In-Reply-To: <99613b74-44db-4233-9480-26cc04bc0c7b@suse.de>
On Fri, May 29, 2026, Carlos López wrote:
> On 5/29/26 3:24 PM, Sean Christopherson wrote:
> > On Fri, May 29, 2026, Carlos López wrote:
> >> When userspace issues the KVM_SET_IRQCHIP ioctl to set the state of
> >> the PIC, kvm_vm_ioctl_set_irqchip() grabs @kvm->arch.vpic->lock before
> >> updating the state. However, the KVM_GET_IRQCHIP ioctl to retrieve the
> >> same PIC state does not grab such lock, potentially causing torn reads
> >> for userspace.
> >
> > Meh, if userspace hasn't fully paused the VM, save/restore is going to fail
> > anyways. Heck, torn reads is probably _better_ than the alternative, because
> > at least that might cause visible failure during the restore. If there are
> > concurrent modifications in-flight, then KVM_GET_IRQCHIP is going to return
> > stale data (assuming userspace doesn't redo KVM_GET_IRQCHIP), i.e. save/restore
> > will effectively corrupt the guest.
>
> Right, do you want a v2 to at least prevent userspace from reading a
> torn state? It seems wrong to have this asymmetry with KVM_SET_IRQCHIP
> and other save/restore ioctls (e.g. KVM_{G,S}ET_PIT).
Yeah, please send a v2. I 100% agree there should be symmetry, which is why
it's tempting to drop the locks for SET :-)
prev parent reply other threads:[~2026-05-29 13:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-29 9:17 [PATCH] KVM: x86: Take PIC lock on KVM_GET_IRQCHIP path Carlos López
2026-05-29 13:24 ` Sean Christopherson
2026-05-29 13:57 ` Carlos López
2026-05-29 13:59 ` Sean Christopherson [this message]
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=ahmbvDGHvORqofrj@google.com \
--to=seanjc@google.com \
--cc=avi@qumranet.com \
--cc=bp@alien8.de \
--cc=clopez@suse.de \
--cc=dave.hansen@linux.intel.com \
--cc=eddie.dong@intel.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qing.he@intel.com \
--cc=stable@vger.kernel.org \
--cc=tglx@kernel.org \
--cc=x86@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