All of lore.kernel.org
 help / color / mirror / Atom feed
* Unreachable code about cpu features
@ 2013-03-28 14:40 Choonho Son
  2013-03-28 15:08 ` Andrew Cooper
  2013-03-28 15:09 ` Jan Beulich
  0 siblings, 2 replies; 5+ messages in thread
From: Choonho Son @ 2013-03-28 14:40 UTC (permalink / raw)
  To: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 2033 bytes --]

Hi all,

I still have some questions about cpu flags.
- Reference:
http://lists.xen.org/archives/html/xen-devel/2013-03/msg00891.html

I printed the values about following code:
 if (!~(opt_cpuid_mask_ecx & opt_cpuid_mask_edx &
               opt_cpuid_mask_ext_ecx & opt_cpuid_mask_ext_edx &
               opt_cpuid_mask_xsave_eax))
                return;

Above code is always true, so the next "switch" code is not reachable.
Is it correct code?

##############################
# Source: xen/arch/x86/cpu/intel.c
##############################

#################
# debugging result
#################
(XEN) opt_cpuid_mask_ecx:-1 opt_cpuid_mask_edx:-1 opt_cpuid_mask_ext_ecx:-1
opt_cpuid_mask_ext_edx:-1 opt_cpuid_mask_xsave_eax:-1

/*
 * opt_cpuid_mask_ecx/edx: cpuid.1[ecx, edx] feature mask.
 * For example, E8400[Intel Core 2 Duo Processor series] ecx = 0x0008E3FD,
 * edx = 0xBFEBFBFF when executing CPUID.EAX = 1 normally. If you want to
 * 'rev down' to E8400, you can set these values in these Xen boot
parameters.
 */
static void __devinit set_cpuidmask(const struct cpuinfo_x86 *c)
{
        u32 eax, edx;
        const char *extra = "";


        printk(XENLOG_INFO  "opt_cpuid_mask_ecx:%d opt_cpuid_mask_edx:%d
opt_cpuid_mask_ext_ecx:%d opt_cpuid_mask_ext_edx:%d
opt_cpuid_mask_xsave_eax:%d\n", opt_cpuid_mask_ecx, opt_cpuid_mask_edx,
opt_cpuid_mask_ext_ecx, opt_cpuid_mask_ext_edx,opt_cpuid_mask_xsave_eax);
        if (!~(opt_cpuid_mask_ecx & opt_cpuid_mask_edx &
               opt_cpuid_mask_ext_ecx & opt_cpuid_mask_ext_edx &
               opt_cpuid_mask_xsave_eax))
                return;

        /**************************
         * Unreachable code (?)
         **************************/

        /* Only family 6 supports this feature  */
        switch ((c->x86 == 6) * c->x86_model) {
        case 0x17:
                if ((c->x86_mask & 0x0f) < 4)
                        break;
                /* fall through */
        case 0x1d:
                wrmsr(MSR_INTEL_CPUID_FEATURE_MASK,
         ...

[-- Attachment #1.2: Type: text/html, Size: 2835 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Unreachable code about cpu features
  2013-03-28 14:40 Unreachable code about cpu features Choonho Son
@ 2013-03-28 15:08 ` Andrew Cooper
  2013-03-28 15:30   ` Choonho Son
  2013-03-28 15:09 ` Jan Beulich
  1 sibling, 1 reply; 5+ messages in thread
From: Andrew Cooper @ 2013-03-28 15:08 UTC (permalink / raw)
  To: Choonho Son; +Cc: xen-devel@lists.xen.org

On 28/03/2013 14:40, Choonho Son wrote:
> Hi all,
>
> I still have some questions about cpu flags.
> -
> Reference: http://lists.xen.org/archives/html/xen-devel/2013-03/msg00891.html
>
> I printed the values about following code:
>  if (!~(opt_cpuid_mask_ecx & opt_cpuid_mask_edx &
>                opt_cpuid_mask_ext_ecx & opt_cpuid_mask_ext_edx &
>                opt_cpuid_mask_xsave_eax))
>                 return;
>
> Above code is always true, so the next "switch" code is not reachable.
> Is it correct code?

No - these variables can be specified on the command line, as is the
convention with variable beginning "opt_".

The result is that if the user specifies any of them, we enter the
switch statement and apply the appropriate feature masking.

~Andrew

>
> ##############################
> # Source: xen/arch/x86/cpu/intel.c
> ##############################
>
> #################
> # debugging result
> #################
> (XEN) opt_cpuid_mask_ecx:-1 opt_cpuid_mask_edx:-1
> opt_cpuid_mask_ext_ecx:-1 opt_cpuid_mask_ext_edx:-1
> opt_cpuid_mask_xsave_eax:-1
>
> /*
>  * opt_cpuid_mask_ecx/edx: cpuid.1[ecx, edx] feature mask.
>  * For example, E8400[Intel Core 2 Duo Processor series] ecx = 0x0008E3FD,
>  * edx = 0xBFEBFBFF when executing CPUID.EAX = 1 normally. If you want to
>  * 'rev down' to E8400, you can set these values in these Xen boot
> parameters.
>  */
> static void __devinit set_cpuidmask(const struct cpuinfo_x86 *c)
> {
>         u32 eax, edx;
>         const char *extra = "";
>
>
>         printk(XENLOG_INFO  "opt_cpuid_mask_ecx:%d
> opt_cpuid_mask_edx:%d opt_cpuid_mask_ext_ecx:%d
> opt_cpuid_mask_ext_edx:%d opt_cpuid_mask_xsave_eax:%d\n",
> opt_cpuid_mask_ecx, opt_cpuid_mask_edx, opt_cpuid_mask_ext_ecx,
> opt_cpuid_mask_ext_edx,opt_cpuid_mask_xsave_eax);
>         if (!~(opt_cpuid_mask_ecx & opt_cpuid_mask_edx &
>                opt_cpuid_mask_ext_ecx & opt_cpuid_mask_ext_edx &
>                opt_cpuid_mask_xsave_eax))
>                 return;
>
>         /**************************
>          * Unreachable code (?)
>          **************************/
>
>         /* Only family 6 supports this feature  */
>         switch ((c->x86 == 6) * c->x86_model) {
>         case 0x17:
>                 if ((c->x86_mask & 0x0f) < 4)
>                         break;
>                 /* fall through */
>         case 0x1d:
>                 wrmsr(MSR_INTEL_CPUID_FEATURE_MASK,
>          ...

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Unreachable code about cpu features
  2013-03-28 14:40 Unreachable code about cpu features Choonho Son
  2013-03-28 15:08 ` Andrew Cooper
@ 2013-03-28 15:09 ` Jan Beulich
  1 sibling, 0 replies; 5+ messages in thread
From: Jan Beulich @ 2013-03-28 15:09 UTC (permalink / raw)
  To: Choonho Son; +Cc: xen-devel

>>> On 28.03.13 at 15:40, Choonho Son <choonho.son@gmail.com> wrote:
> I still have some questions about cpu flags.
> - Reference:
> http://lists.xen.org/archives/html/xen-devel/2013-03/msg00891.html 
> 
> I printed the values about following code:
>  if (!~(opt_cpuid_mask_ecx & opt_cpuid_mask_edx &
>                opt_cpuid_mask_ext_ecx & opt_cpuid_mask_ext_edx &
>                opt_cpuid_mask_xsave_eax))
>                 return;
> 
> Above code is always true, so the next "switch" code is not reachable.
> Is it correct code?

Of course it is - you just need to make use of the respective
command line options to get those variable have other than their
default (initial) values. It is intentional for the code to do nothing
without command line option saying so.

Jan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Unreachable code about cpu features
  2013-03-28 15:08 ` Andrew Cooper
@ 2013-03-28 15:30   ` Choonho Son
  2013-03-28 15:40     ` Andrew Cooper
  0 siblings, 1 reply; 5+ messages in thread
From: Choonho Son @ 2013-03-28 15:30 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: xen-devel@lists.xen.org


[-- Attachment #1.1: Type: text/plain, Size: 2784 bytes --]

Thanks for quick response.

How can I overwrite values using command line?
I want to hide AVX flag even though my CPU is sandybridge.

Thanks,


2013/3/29 Andrew Cooper <andrew.cooper3@citrix.com>

> On 28/03/2013 14:40, Choonho Son wrote:
> > Hi all,
> >
> > I still have some questions about cpu flags.
> > -
> > Reference:
> http://lists.xen.org/archives/html/xen-devel/2013-03/msg00891.html
> >
> > I printed the values about following code:
> >  if (!~(opt_cpuid_mask_ecx & opt_cpuid_mask_edx &
> >                opt_cpuid_mask_ext_ecx & opt_cpuid_mask_ext_edx &
> >                opt_cpuid_mask_xsave_eax))
> >                 return;
> >
> > Above code is always true, so the next "switch" code is not reachable.
> > Is it correct code?
>
> No - these variables can be specified on the command line, as is the
> convention with variable beginning "opt_".
>
> The result is that if the user specifies any of them, we enter the
> switch statement and apply the appropriate feature masking.
>
> ~Andrew
>
> >
> > ##############################
> > # Source: xen/arch/x86/cpu/intel.c
> > ##############################
> >
> > #################
> > # debugging result
> > #################
> > (XEN) opt_cpuid_mask_ecx:-1 opt_cpuid_mask_edx:-1
> > opt_cpuid_mask_ext_ecx:-1 opt_cpuid_mask_ext_edx:-1
> > opt_cpuid_mask_xsave_eax:-1
> >
> > /*
> >  * opt_cpuid_mask_ecx/edx: cpuid.1[ecx, edx] feature mask.
> >  * For example, E8400[Intel Core 2 Duo Processor series] ecx =
> 0x0008E3FD,
> >  * edx = 0xBFEBFBFF when executing CPUID.EAX = 1 normally. If you want to
> >  * 'rev down' to E8400, you can set these values in these Xen boot
> > parameters.
> >  */
> > static void __devinit set_cpuidmask(const struct cpuinfo_x86 *c)
> > {
> >         u32 eax, edx;
> >         const char *extra = "";
> >
> >
> >         printk(XENLOG_INFO  "opt_cpuid_mask_ecx:%d
> > opt_cpuid_mask_edx:%d opt_cpuid_mask_ext_ecx:%d
> > opt_cpuid_mask_ext_edx:%d opt_cpuid_mask_xsave_eax:%d\n",
> > opt_cpuid_mask_ecx, opt_cpuid_mask_edx, opt_cpuid_mask_ext_ecx,
> > opt_cpuid_mask_ext_edx,opt_cpuid_mask_xsave_eax);
> >         if (!~(opt_cpuid_mask_ecx & opt_cpuid_mask_edx &
> >                opt_cpuid_mask_ext_ecx & opt_cpuid_mask_ext_edx &
> >                opt_cpuid_mask_xsave_eax))
> >                 return;
> >
> >         /**************************
> >          * Unreachable code (?)
> >          **************************/
> >
> >         /* Only family 6 supports this feature  */
> >         switch ((c->x86 == 6) * c->x86_model) {
> >         case 0x17:
> >                 if ((c->x86_mask & 0x0f) < 4)
> >                         break;
> >                 /* fall through */
> >         case 0x1d:
> >                 wrmsr(MSR_INTEL_CPUID_FEATURE_MASK,
> >          ...
>
>

[-- Attachment #1.2: Type: text/html, Size: 3832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Unreachable code about cpu features
  2013-03-28 15:30   ` Choonho Son
@ 2013-03-28 15:40     ` Andrew Cooper
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Cooper @ 2013-03-28 15:40 UTC (permalink / raw)
  To: Choonho Son


[-- Attachment #1.1: Type: text/plain, Size: 3365 bytes --]

On 28/03/2013 15:30, Choonho Son wrote:
> Thanks for quick response.
>
> How can I overwrite values using command line?
> I want to hide AVX flag even though my CPU is sandybridge.
>
> Thanks,

Dropping xen-devel to bcc as this is a xen-users question

http://xenbits.xen.org/docs/unstable/misc/xen-command-line.html

>From memory, you probably want

cpuid_mask_ext_ecx=fffeffff

~Andrew

>
>
> 2013/3/29 Andrew Cooper <andrew.cooper3@citrix.com
> <mailto:andrew.cooper3@citrix.com>>
>
>     On 28/03/2013 14:40, Choonho Son wrote:
>     > Hi all,
>     >
>     > I still have some questions about cpu flags.
>     > -
>     > Reference:
>     http://lists.xen.org/archives/html/xen-devel/2013-03/msg00891.html
>     >
>     > I printed the values about following code:
>     >  if (!~(opt_cpuid_mask_ecx & opt_cpuid_mask_edx &
>     >                opt_cpuid_mask_ext_ecx & opt_cpuid_mask_ext_edx &
>     >                opt_cpuid_mask_xsave_eax))
>     >                 return;
>     >
>     > Above code is always true, so the next "switch" code is not
>     reachable.
>     > Is it correct code?
>
>     No - these variables can be specified on the command line, as is the
>     convention with variable beginning "opt_".
>
>     The result is that if the user specifies any of them, we enter the
>     switch statement and apply the appropriate feature masking.
>
>     ~Andrew
>
>     >
>     > ##############################
>     > # Source: xen/arch/x86/cpu/intel.c
>     > ##############################
>     >
>     > #################
>     > # debugging result
>     > #################
>     > (XEN) opt_cpuid_mask_ecx:-1 opt_cpuid_mask_edx:-1
>     > opt_cpuid_mask_ext_ecx:-1 opt_cpuid_mask_ext_edx:-1
>     > opt_cpuid_mask_xsave_eax:-1
>     >
>     > /*
>     >  * opt_cpuid_mask_ecx/edx: cpuid.1[ecx, edx] feature mask.
>     >  * For example, E8400[Intel Core 2 Duo Processor series] ecx =
>     0x0008E3FD,
>     >  * edx = 0xBFEBFBFF when executing CPUID.EAX = 1 normally. If
>     you want to
>     >  * 'rev down' to E8400, you can set these values in these Xen boot
>     > parameters.
>     >  */
>     > static void __devinit set_cpuidmask(const struct cpuinfo_x86 *c)
>     > {
>     >         u32 eax, edx;
>     >         const char *extra = "";
>     >
>     >
>     >         printk(XENLOG_INFO  "opt_cpuid_mask_ecx:%d
>     > opt_cpuid_mask_edx:%d opt_cpuid_mask_ext_ecx:%d
>     > opt_cpuid_mask_ext_edx:%d opt_cpuid_mask_xsave_eax:%d\n",
>     > opt_cpuid_mask_ecx, opt_cpuid_mask_edx, opt_cpuid_mask_ext_ecx,
>     > opt_cpuid_mask_ext_edx,opt_cpuid_mask_xsave_eax);
>     >         if (!~(opt_cpuid_mask_ecx & opt_cpuid_mask_edx &
>     >                opt_cpuid_mask_ext_ecx & opt_cpuid_mask_ext_edx &
>     >                opt_cpuid_mask_xsave_eax))
>     >                 return;
>     >
>     >         /**************************
>     >          * Unreachable code (?)
>     >          **************************/
>     >
>     >         /* Only family 6 supports this feature  */
>     >         switch ((c->x86 == 6) * c->x86_model) {
>     >         case 0x17:
>     >                 if ((c->x86_mask & 0x0f) < 4)
>     >                         break;
>     >                 /* fall through */
>     >         case 0x1d:
>     >                 wrmsr(MSR_INTEL_CPUID_FEATURE_MASK,
>     >          ...
>
>


[-- Attachment #1.2: Type: text/html, Size: 6993 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-03-28 15:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-28 14:40 Unreachable code about cpu features Choonho Son
2013-03-28 15:08 ` Andrew Cooper
2013-03-28 15:30   ` Choonho Son
2013-03-28 15:40     ` Andrew Cooper
2013-03-28 15:09 ` Jan Beulich

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.