From: Sean Christopherson <seanjc@google.com>
To: David Woodhouse <dwmw2@infradead.org>
Cc: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
Ankur Arora <ankur.a.arora@oracle.com>,
Joao Martins <joao.m.martins@oracle.com>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
graf@amazon.com, iaslan@amazon.de, pdurrant@amazon.com,
aagch@amazon.com, fandree@amazon.com, hch@infradead.org
Subject: Re: [PATCH 1/2] KVM: x86/xen: Fix return code when clearing vcpu_info and vcpu_time_info
Date: Mon, 1 Mar 2021 09:34:30 -0800 [thread overview]
Message-ID: <YD0lpr+YspdCsUqE@google.com> (raw)
In-Reply-To: <20210301125309.874953-1-dwmw2@infradead.org>
On Mon, Mar 01, 2021, David Woodhouse wrote:
> From: David Woodhouse <dwmw@amazon.co.uk>
>
> When clearing the per-vCPU shared regions, set the return value to zero
> to indicate success. This was causing spurious errors to be returned to
> userspace on soft reset.
>
> Also add a paranoid BUILD_BUG_ON() for compat structure compatibility.
>
> Fixes: 0c165b3c01fe ("KVM: x86/xen: Allow reset of Xen attributes")
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
> ---
> arch/x86/kvm/xen.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c
> index af8f6562fce4..77b20ff09078 100644
> --- a/arch/x86/kvm/xen.c
> +++ b/arch/x86/kvm/xen.c
> @@ -187,9 +187,12 @@ int kvm_xen_vcpu_set_attr(struct kvm_vcpu *vcpu, struct kvm_xen_vcpu_attr *data)
To avoid similar issues in the future, might be worth throwing "r = -ENOENT" in
the default case and have "r" be initialized to '0', or uninitialized to trigger
compiler warnings. For any which way:
Reviewed-by: Sean Christopherson <seanjc@google.com>
> /* No compat necessary here. */
> BUILD_BUG_ON(sizeof(struct vcpu_info) !=
> sizeof(struct compat_vcpu_info));
> + BUILD_BUG_ON(offsetof(struct vcpu_info, time) !=
> + offsetof(struct compat_vcpu_info, time));
>
> if (data->u.gpa == GPA_INVALID) {
> vcpu->arch.xen.vcpu_info_set = false;
> + r = 0;
> break;
> }
>
> @@ -206,6 +209,7 @@ int kvm_xen_vcpu_set_attr(struct kvm_vcpu *vcpu, struct kvm_xen_vcpu_attr *data)
> case KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO:
> if (data->u.gpa == GPA_INVALID) {
> vcpu->arch.xen.vcpu_time_info_set = false;
> + r = 0;
> break;
> }
>
> --
> 2.29.2
>
prev parent reply other threads:[~2021-03-01 17:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-01 12:53 [PATCH 1/2] KVM: x86/xen: Fix return code when clearing vcpu_info and vcpu_time_info David Woodhouse
2021-03-01 12:53 ` [PATCH 2/2] KVM: x86/xen: Add support for vCPU runstate information David Woodhouse
2021-03-01 17:34 ` 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=YD0lpr+YspdCsUqE@google.com \
--to=seanjc@google.com \
--cc=aagch@amazon.com \
--cc=ankur.a.arora@oracle.com \
--cc=boris.ostrovsky@oracle.com \
--cc=dwmw2@infradead.org \
--cc=fandree@amazon.com \
--cc=graf@amazon.com \
--cc=hch@infradead.org \
--cc=iaslan@amazon.de \
--cc=joao.m.martins@oracle.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=pdurrant@amazon.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