From: "H. Peter Anvin" <hpa@linux.intel.com>
To: Neil Horman <nhorman@tuxdriver.com>, dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH v4] eal_common_cpuflags: Fix %rbx corruption, and simplify the code
Date: Tue, 25 Mar 2014 10:37:18 -0700 [thread overview]
Message-ID: <5331BECE.3070601@linux.intel.com> (raw)
In-Reply-To: <1395767000-28709-1-git-send-email-nhorman@tuxdriver.com>
On 03/25/2014 10:03 AM, Neil Horman wrote:
> int
> rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature)
> {
> - int value;
> + const struct feature_entry *feat;
> + cpuid_registers_t regs;
> + static uint32_t max_leaf = 0;
> +
> + if (!max_leaf) {
> + /* Get the max input leaf for this processor */
> + rte_cpu_get_features(0, 0, regs);
> + max_leaf = regs[REG_EAX];
> + }
>
> if (feature >= RTE_CPUFLAG_NUMFLAGS)
> /* Flag does not match anything in the feature tables */
> return -ENOENT;
>
> - /* get value of the register containing the desired feature */
> - value = rte_cpu_get_features(cpu_feature_table[feature].params);
> + feat = &cpu_feature_table[feature];
> +
> + if (!feat->leaf)
> + /* This entry in the table wasn't filled out! */
> + return -EFAULT;
> + if (feat->leaf > max_leaf)
> + return -EINVAL;
This doesn't quite work. The max_leaf is per CPUID "group", i.e. the
8000xxxx CPUID leaves have a different limit than 0000xxxx leaves. So I
would just do this as:
rte_cpu_get_features(feat->leaf & 0xffff0000, 0, regs);
if (((regs[REG_EAX] ^ feat->leaf) & 0xffff0000) ||
regs[REG_EAX] < feat->leaf)
return 0;
Returning 0 is the right thing, because this is a legitimate instance of
"this feature is not supported."
The first part is a sanity check that the CPUID leaf group is supported
at all; the second part is the actual limit check.
-hpa
next prev parent reply other threads:[~2014-03-25 17:46 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1395330830-1310-1-git-send-email-hpa@linux.intel.com>
2014-03-20 16:39 ` [dpdk-dev] [RFC UNTESTED PATCH] " Neil Horman
2014-03-20 17:02 ` Thomas Monjalon
2014-03-20 18:04 ` Neil Horman
2014-03-21 14:49 ` [dpdk-dev] [PATCH v2] " Neil Horman
2014-03-21 15:03 ` H. Peter Anvin
2014-03-21 17:48 ` Neil Horman
2014-03-24 11:18 ` Thomas Monjalon
2014-03-24 17:44 ` [dpdk-dev] [PATCH v3] " Neil Horman
2014-03-24 18:09 ` H. Peter Anvin
2014-03-24 19:52 ` Neil Horman
2014-03-24 20:47 ` H. Peter Anvin
2014-03-25 10:41 ` Neil Horman
2014-03-25 17:03 ` [dpdk-dev] [PATCH v4] " Neil Horman
2014-03-25 17:06 ` Chris Wright
2014-03-25 17:37 ` H. Peter Anvin [this message]
2014-03-25 19:52 ` [dpdk-dev] [PATCH v5] " Neil Horman
2014-03-25 20:51 ` H. Peter Anvin
2014-04-02 11:16 ` Neil Horman
2014-04-02 11:53 ` Thomas Monjalon
2014-04-02 12:42 ` Thomas Monjalon
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=5331BECE.3070601@linux.intel.com \
--to=hpa@linux.intel.com \
--cc=dev@dpdk.org \
--cc=nhorman@tuxdriver.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;
as well as URLs for NNTP newsgroup(s).