From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>,
Keir Fraser <keir@xen.org>,
Aravind Gopalakrishnan <aravind.gopalakrishnan@amd.com>,
suravee.suthikulpanit@amd.com
Subject: Re: [PATCH v2 3/3] x86/AMD: clean up pre-canned family/revision handling for CPUID masking
Date: Mon, 7 Apr 2014 11:48:58 +0100 [thread overview]
Message-ID: <5342829A.8050900@citrix.com> (raw)
In-Reply-To: <53428F7402000078000060BF@nat28.tlf.novell.com>
[-- Attachment #1.1: Type: text/plain, Size: 4752 bytes --]
On 07/04/14 10:43, Jan Beulich wrote:
> Make it so this is easier to extend, and move the parsing code/data
> into .init.* sections.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> Reviewed-by: Aravind Gopalakrishnan<aravind.gopalakrishnan@amd.com>
>
> --- a/xen/arch/x86/cpu/amd.c
> +++ b/xen/arch/x86/cpu/amd.c
> @@ -91,6 +91,51 @@ static inline int wrmsr_amd_safe(unsigne
> return err;
> }
>
> +static const struct cpuidmask {
> + uint16_t fam;
> + char rev[2];
> + unsigned int ecx, edx, ext_ecx, ext_edx;
> +} pre_canned[] __initconst = {
possibly name the structure amd_precanned_featuremasks or similar, to
make it a little more descriptive than just "pre_canned" ?
> +#define CAN(fam, id, rev) { \
> + fam, #rev, \
> + AMD_FEATURES_##id##_REV_##rev##_ECX, \
> + AMD_FEATURES_##id##_REV_##rev##_EDX, \
> + AMD_EXTFEATURES_##id##_REV_##rev##_ECX, \
> + AMD_EXTFEATURES_##id##_REV_##rev##_EDX \
> + }
> +#define CAN_FAM(fam, rev) CAN(0x##fam, FAM##fam##h, rev)
> +#define CAN_K8(rev) CAN(0x0f, K8, rev)
> + CAN_FAM(11, B),
> + CAN_FAM(10, C),
> + CAN_FAM(10, B),
> + CAN_K8(G),
> + CAN_K8(F),
> + CAN_K8(E),
> + CAN_K8(D),
> + CAN_K8(C)
> +#undef CAN
> +};
> +
> +static const struct cpuidmask *__init noinline get_cpuidmask(const char *opt)
> +{
> + unsigned long fam;
> + char rev;
> + unsigned int i;
> +
> + if (strncmp(opt, "fam_", 4))
> + return NULL;
> + fam = simple_strtoul(opt + 4, &opt, 16);
> + if (strncmp(opt, "_rev_", 5))
> + return NULL;
> + rev = toupper(opt[5]);
if ( opt[6] != '\0' )
return NULL;
Otherwise this code will start accepting malformed values it would
previously discard.
~Andrew
> +
> + for (i = 0; i < ARRAY_SIZE(pre_canned); ++i)
> + if (fam == pre_canned[i].fam && rev == *pre_canned[i].rev)
> + return &pre_canned[i];
> +
> + return NULL;
> +}
> +
> /*
> * Mask the features and extended features returned by CPUID. Parameters are
> * set from the boot line via two methods:
> @@ -136,50 +181,18 @@ static void __devinit set_cpuidmask(cons
> thermal_ecx = opt_cpuid_mask_thermal_ecx;
> } else if (*opt_famrev == '\0') {
> return;
> - } else if (!strcmp(opt_famrev, "fam_0f_rev_c")) {
> - feat_ecx = AMD_FEATURES_K8_REV_C_ECX;
> - feat_edx = AMD_FEATURES_K8_REV_C_EDX;
> - extfeat_ecx = AMD_EXTFEATURES_K8_REV_C_ECX;
> - extfeat_edx = AMD_EXTFEATURES_K8_REV_C_EDX;
> - } else if (!strcmp(opt_famrev, "fam_0f_rev_d")) {
> - feat_ecx = AMD_FEATURES_K8_REV_D_ECX;
> - feat_edx = AMD_FEATURES_K8_REV_D_EDX;
> - extfeat_ecx = AMD_EXTFEATURES_K8_REV_D_ECX;
> - extfeat_edx = AMD_EXTFEATURES_K8_REV_D_EDX;
> - } else if (!strcmp(opt_famrev, "fam_0f_rev_e")) {
> - feat_ecx = AMD_FEATURES_K8_REV_E_ECX;
> - feat_edx = AMD_FEATURES_K8_REV_E_EDX;
> - extfeat_ecx = AMD_EXTFEATURES_K8_REV_E_ECX;
> - extfeat_edx = AMD_EXTFEATURES_K8_REV_E_EDX;
> - } else if (!strcmp(opt_famrev, "fam_0f_rev_f")) {
> - feat_ecx = AMD_FEATURES_K8_REV_F_ECX;
> - feat_edx = AMD_FEATURES_K8_REV_F_EDX;
> - extfeat_ecx = AMD_EXTFEATURES_K8_REV_F_ECX;
> - extfeat_edx = AMD_EXTFEATURES_K8_REV_F_EDX;
> - } else if (!strcmp(opt_famrev, "fam_0f_rev_g")) {
> - feat_ecx = AMD_FEATURES_K8_REV_G_ECX;
> - feat_edx = AMD_FEATURES_K8_REV_G_EDX;
> - extfeat_ecx = AMD_EXTFEATURES_K8_REV_G_ECX;
> - extfeat_edx = AMD_EXTFEATURES_K8_REV_G_EDX;
> - } else if (!strcmp(opt_famrev, "fam_10_rev_b")) {
> - feat_ecx = AMD_FEATURES_FAM10h_REV_B_ECX;
> - feat_edx = AMD_FEATURES_FAM10h_REV_B_EDX;
> - extfeat_ecx = AMD_EXTFEATURES_FAM10h_REV_B_ECX;
> - extfeat_edx = AMD_EXTFEATURES_FAM10h_REV_B_EDX;
> - } else if (!strcmp(opt_famrev, "fam_10_rev_c")) {
> - feat_ecx = AMD_FEATURES_FAM10h_REV_C_ECX;
> - feat_edx = AMD_FEATURES_FAM10h_REV_C_EDX;
> - extfeat_ecx = AMD_EXTFEATURES_FAM10h_REV_C_ECX;
> - extfeat_edx = AMD_EXTFEATURES_FAM10h_REV_C_EDX;
> - } else if (!strcmp(opt_famrev, "fam_11_rev_b")) {
> - feat_ecx = AMD_FEATURES_FAM11h_REV_B_ECX;
> - feat_edx = AMD_FEATURES_FAM11h_REV_B_EDX;
> - extfeat_ecx = AMD_EXTFEATURES_FAM11h_REV_B_ECX;
> - extfeat_edx = AMD_EXTFEATURES_FAM11h_REV_B_EDX;
> } else {
> - printk("Invalid processor string: %s\n", opt_famrev);
> - printk("CPUID will not be masked\n");
> - return;
> + const struct cpuidmask *m = get_cpuidmask(opt_famrev);
> +
> + if (!m) {
> + printk("Invalid processor string: %s\n", opt_famrev);
> + printk("CPUID will not be masked\n");
> + return;
> + }
> + feat_ecx = m->ecx;
> + feat_edx = m->edx;
> + extfeat_ecx = m->ext_ecx;
> + extfeat_edx = m->ext_edx;
> }
>
> /* Setting bits in the CPUID mask MSR that are not set in the
>
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
[-- Attachment #1.2: Type: text/html, Size: 5687 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2014-04-07 10:49 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-07 9:36 [PATCH v2 0/3] x86/AMD: feature masking adjustments Jan Beulich
2014-04-07 9:41 ` [PATCH v2 1/3] x86/AMD: feature masking is unavailable on Fam11 Jan Beulich
2014-04-07 10:14 ` Andrew Cooper
2014-04-07 9:43 ` [PATCH v2 2/3] x86/AMD: support further feature masking MSRs Jan Beulich
2014-04-07 10:23 ` Andrew Cooper
2014-04-07 11:53 ` Jan Beulich
2014-04-07 12:09 ` Andrew Cooper
2014-04-07 15:21 ` Boris Ostrovsky
2014-04-08 7:15 ` Jan Beulich
2014-04-08 13:50 ` Boris Ostrovsky
2014-04-08 14:02 ` Jan Beulich
2014-04-08 14:14 ` Boris Ostrovsky
2014-04-08 14:33 ` Jan Beulich
2014-04-08 15:14 ` Boris Ostrovsky
2014-04-09 15:39 ` Aravind Gopalakrishnan
2014-04-09 15:50 ` Jan Beulich
2014-04-07 9:43 ` [PATCH v2 3/3] x86/AMD: clean up pre-canned family/revision handling for CPUID masking Jan Beulich
2014-04-07 10:48 ` Andrew Cooper [this message]
2014-04-07 11:55 ` Jan Beulich
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=5342829A.8050900@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=aravind.gopalakrishnan@amd.com \
--cc=keir@xen.org \
--cc=suravee.suthikulpanit@amd.com \
--cc=xen-devel@lists.xenproject.org \
/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).