From: Takahiro Itazuri <itazur@amazon.com>
To: <seanjc@google.com>
Cc: <kvm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<pbonzini@redhat.com>, <zulinx86@gmail.com>
Subject: Re: [PATCH] kvm: x86: Update KVM_GET_CPUID2 to return valid entry count
Date: Mon, 10 Apr 2023 19:38:45 +0100 [thread overview]
Message-ID: <20230410183845.98304-1-itazur@amazon.com> (raw)
In-Reply-To: <ZDQveaSDYx+4z5t4@google.com>
Date: Mon, 10 Apr 2023 08:47:05 -0700
From: Sean Christopherson <seanjc@google.com>
> Capitalize KVM please, i.e. "KVM: x86:".
Will fix. Thanks!
> I think we should break from the (IMO) somewhat funky KVM ioctl() pattern of
>
> r = <errno>
> if (try something and it fails)
> goto out;
>
> and instead set "r" in the error paths. That avoids the need for a scratch "nent",
> and IMO makes this much more straightforward.
>
> int r = 0;
>
> if (cpuid->nent < vcpu->arch.cpuid_nent)
> r = -E2BIG;
> else if (copy_to_user(entries, vcpu->arch.cpuid_entries,
> vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
> r = -EFAULT;
>
> /*
> * Update "nent" even on failure, e.g. so that userspace can fix an
> * -E2BIG issue by allocating a larger array.
> */
> cpuid->nent = vcpu->arch.cpuid_nent;
> return r;
Looks better to me! Will fix this too!.
Best regards,
Takahiro Itazuri
prev parent reply other threads:[~2023-04-10 18:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-10 14:18 [PATCH] kvm: x86: Update KVM_GET_CPUID2 to return valid entry count Takahiro Itazuri
2023-04-10 15:47 ` Sean Christopherson
2023-04-10 18:38 ` Takahiro Itazuri [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=20230410183845.98304-1-itazur@amazon.com \
--to=itazur@amazon.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=zulinx86@gmail.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