From: Robert Hoo <robert.hu@linux.intel.com>
To: Eric Blake <eblake@redhat.com>,
pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com
Cc: robert.hu@intel.com, robert.hu@linux.intel.com,
thomas.lendacky@amd.com, qemu-devel@nongnu.org,
jingqi.liu@intel.com
Subject: Re: [Qemu-devel] [PATCH v3 3/3] Change other funcitons referring to feature_word_info[]
Date: Tue, 14 Aug 2018 18:06:01 +0800 [thread overview]
Message-ID: <1534241161.81055.36.camel@linux.intel.com> (raw)
In-Reply-To: <893de8e8-da77-f6d5-5c0c-534e9999b7f0@redhat.com>
On Fri, 2018-08-10 at 10:17 -0500, Eric Blake wrote:
> On 08/10/2018 09:06 AM, Robert Hoo wrote:
>
> In the subject: s/funcitons/functions/
>
> Also, it may be worth using a topic prefix (most of our commit messages
> resemble:
>
> topic: Description of patch
>
> to make it easier to spot patches by topic).
>
> > Add an util function feature_word_description(), which help construct the string
>
> s/an util/a util/
> s/help/helps/
>
Thanks Eric, will fix these typos in v2.
> > describing the feature word (both CPUID and MSR types).
> >
> > report_unavailable_features(): add MSR_FEATURE_WORD type support.
> > x86_cpu_get_feature_words(): limit to CPUID_FEATURE_WORD only.
> > x86_cpu_get_supported_feature_word(): add MSR_FEATURE_WORD type support.
> > x86_cpu_adjust_feat_level(): assert the requested feature must be
> > CPUID_FEATURE_WORD type.
> >
> > Signed-off-by: Robert Hoo <robert.hu@linux.intel.com>
> > ---
> > target/i386/cpu.c | 77 +++++++++++++++++++++++++++++++++++++++++--------------
> > 1 file changed, 58 insertions(+), 19 deletions(-)
> >
> > diff --git a/target/i386/cpu.c b/target/i386/cpu.c
> > index f7c70d9..21ed599 100644
> > --- a/target/i386/cpu.c
> > +++ b/target/i386/cpu.c
> > @@ -3024,21 +3024,51 @@ static const TypeInfo host_x86_cpu_type_info = {
> >
> > #endif
> >
> > +/*
> > +*caller should have input str no less than 64 byte length.
> > +*/
> > +#define FEATURE_WORD_DESCPTION_LEN 64
>
> s/DESCPTION/DESCRIPTION/
>
> > +static int feature_word_description(char str[], FeatureWordInfo *f,
> > + uint32_t bit)
> > +{
>
> Prone to buffer overflow if the caller doesn't pass in the length.
> Would it be better to just g_strdup_printf() into a malloc'd result
> instead of trying to snprintf()'ing into a buffer that you hope the
> caller sized large enough?
>
Oh, wasn't aware of such good util functions. Sure I'd like to use them.
Is there some web page introducing them?
Eduardo/Paolo, do you have more comments?
> > + int ret;
> > +
> > + assert(f->type == CPUID_FEATURE_WORD ||
> > + f->type == MSR_FEATURE_WORD);
> > + switch (f->type) {
> > + case CPUID_FEATURE_WORD:
> > + {
> > + const char *reg = get_register_name_32(f->cpuid.reg);
> > + assert(reg);
> > + ret = snprintf(str, FEATURE_WORD_DESCPTION_LEN,
> > + "CPUID.%02XH:%s%s%s [bit %d]",
> > + f->cpuid.eax, reg,
> > + f->feat_names[bit] ? "." : "",
> > + f->feat_names[bit] ? f->feat_names[bit] : "", bit);
> > + break;
> > + }
> > + case MSR_FEATURE_WORD:
> > + ret = snprintf(str, FEATURE_WORD_DESCPTION_LEN,
> > + "MSR(%xH).%s [bit %d]",
> > + f->msr.index,
> > + f->feat_names[bit] ? f->feat_names[bit] : "", bit);
> > + break;
> > + }
>
next prev parent reply other threads:[~2018-08-14 10:06 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-10 14:06 [Qemu-devel] [PATCH v3 0/3] x86: QEMU side support on MSR based features Robert Hoo
2018-08-10 14:06 ` [Qemu-devel] [PATCH v3 1/3] x86: Data structure changes to support " Robert Hoo
2018-08-17 3:10 ` Eduardo Habkost
2018-08-18 3:10 ` Robert Hoo
2018-08-18 5:48 ` Robert Hoo
2018-08-18 7:50 ` Paolo Bonzini
2018-08-17 15:50 ` Paolo Bonzini
2018-08-17 15:55 ` Eduardo Habkost
2018-08-17 17:34 ` Paolo Bonzini
2018-08-17 17:48 ` [Qemu-devel] X86CPU "feature-words" property on QEMU (was Re: [PATCH v3 1/3] x86: Data structure changes to support MSR based) features Eduardo Habkost
2018-08-17 17:59 ` Paolo Bonzini
2018-08-17 18:10 ` Eduardo Habkost
2018-08-10 14:06 ` [Qemu-devel] [PATCH v3 2/3] kvm: Add support to KVM_GET_MSR_FEATURE_INDEX_LIST and KVM_GET_MSRS system ioctl Robert Hoo
2018-08-17 13:18 ` Eduardo Habkost
2018-08-18 7:27 ` Robert Hoo
2018-08-18 15:05 ` Eduardo Habkost
2018-08-23 6:28 ` Robert Hoo
2018-08-23 17:11 ` Eduardo Habkost
2018-08-23 17:28 ` Paolo Bonzini
2018-08-23 17:36 ` Eduardo Habkost
2018-08-23 20:23 ` Paolo Bonzini
2018-08-25 17:27 ` Eduardo Habkost
2018-08-30 4:22 ` Robert Hoo
2018-08-30 18:28 ` Eduardo Habkost
2018-08-10 14:06 ` [Qemu-devel] [PATCH v3 3/3] Change other funcitons referring to feature_word_info[] Robert Hoo
2018-08-10 15:17 ` Eric Blake
2018-08-14 10:06 ` Robert Hoo [this message]
2018-08-17 13:28 ` Eduardo Habkost
2018-08-18 9:01 ` Robert Hoo
2018-08-18 15:10 ` Eduardo Habkost
2018-08-17 15:52 ` Paolo Bonzini
2018-08-18 12:53 ` Robert Hoo
2018-09-05 5:47 ` Robert Hoo
2018-09-05 14:10 ` Eduardo Habkost
2018-09-05 15:32 ` Eric Blake
2018-09-05 16:44 ` Eduardo Habkost
2018-09-05 17:41 ` Eric Blake
2018-09-06 6:00 ` Hu, Robert
2018-09-10 17:38 ` Eduardo Habkost
2018-09-11 1:44 ` Robert Hoo
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=1534241161.81055.36.camel@linux.intel.com \
--to=robert.hu@linux.intel.com \
--cc=eblake@redhat.com \
--cc=ehabkost@redhat.com \
--cc=jingqi.liu@intel.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=robert.hu@intel.com \
--cc=rth@twiddle.net \
--cc=thomas.lendacky@amd.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.