From: David Woodhouse <dwmw2@infradead.org>
To: Paolo Bonzini <pbonzini@redhat.com>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: paul@xen.org, seanjc@google.com, Michal Luczaj <mhal@rbox.co>
Subject: Re: [PATCH] KVM: x86/xen: Fix SRCU/RCU usage in readers of evtchn_ports
Date: Mon, 26 Dec 2022 11:21:57 +0000 [thread overview]
Message-ID: <b36fa02bc338d6892e63e37768bf47f035339e30.camel@infradead.org> (raw)
In-Reply-To: <20221224085304.1629042-1-pbonzini@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1655 bytes --]
On Sat, 2022-12-24 at 03:53 -0500, Paolo Bonzini wrote:
> @@ -2005,19 +2009,23 @@ static bool kvm_xen_hcall_evtchn_send(struct kvm_vcpu *vcpu, u64 param, u64 *r)
> gpa_t gpa;
> int idx;
>
> + /*
> + * evtchnfd is protected by kvm->srcu; the idr lookup instead
> + * is protected by RCU.
> + */
> idx = srcu_read_lock(&vcpu->kvm->srcu);
> gpa = kvm_mmu_gva_to_gpa_system(vcpu, param, NULL);
> - srcu_read_unlock(&vcpu->kvm->srcu, idx);
>
> if (!gpa || kvm_vcpu_read_guest(vcpu, gpa, &send, sizeof(send))) {
> *r = -EFAULT;
> - return true;
> + goto out_handled;
> }
>
> - /* The evtchn_ports idr is protected by vcpu->kvm->srcu */
> + rcu_read_lock();
> evtchnfd = idr_find(&vcpu->kvm->arch.xen.evtchn_ports, send.port);
> + rcu_read_unlock();
> if (!evtchnfd)
> - return false;
> + goto out_not_handled;
>
> if (evtchnfd->deliver.port.port) {
> int ret = kvm_xen_set_evtchn(&evtchnfd->deliver.port, vcpu->kvm);
You left a 'return false' in the failure path of this
kvm_xen_set_evtchn() call instead of changing it to 'goto
out_not_handled'.
So rather than adding my kvm_read_guest_virt() patch on top and
removing all the gotos, I'm going to put my patch first and put a
simpler version of your patch on top.
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5965 bytes --]
prev parent reply other threads:[~2022-12-26 11:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-24 8:53 Paolo Bonzini
2022-12-24 10:54 ` David Woodhouse
2022-12-26 11:21 ` David Woodhouse [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=b36fa02bc338d6892e63e37768bf47f035339e30.camel@infradead.org \
--to=dwmw2@infradead.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhal@rbox.co \
--cc=paul@xen.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.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
all inboxes | Powered by JetHome®