Re: [tip:ras/core] x86/RAS: Simplify SMCA HWID descriptor struct

2016-11-10 Thread Yazen Ghannam
> > 
> > Argh, the macro should be adding the additional parentheses:
> > 
> > #define HWID_MCATYPE(hwid, mcatype) (((hwid) << 16) | (mcatype))
> > 
> > That should fix the issue too.
>

Yep, sure does.
 
> Patch please.

Will do.

Thanks,
Yazen


Re: [tip:ras/core] x86/RAS: Simplify SMCA HWID descriptor struct

2016-11-10 Thread Yazen Ghannam
> > 
> > Argh, the macro should be adding the additional parentheses:
> > 
> > #define HWID_MCATYPE(hwid, mcatype) (((hwid) << 16) | (mcatype))
> > 
> > That should fix the issue too.
>

Yep, sure does.
 
> Patch please.

Will do.

Thanks,
Yazen


Re: [tip:ras/core] x86/RAS: Simplify SMCA HWID descriptor struct

2016-11-10 Thread Thomas Gleixner
On Thu, 10 Nov 2016, Borislav Petkov wrote:
> On Thu, Nov 10, 2016 at 12:50:04PM -0500, Yazen Ghannam wrote:
> > Adding extra parentheses in HWID_MCATYPE() gives the same assembly as the
> > original code and fixes the behavior.
> > 
> > > + hwid_mcatype = HWID_MCATYPE((high & MCI_IPID_HWID)),
> > > + ((high & MCI_IPID_MCATYPE) >> 16));
> 
> Argh, the macro should be adding the additional parentheses:
> 
> #define HWID_MCATYPE(hwid, mcatype) (((hwid) << 16) | (mcatype))
> 
> That should fix the issue too.

Patch please.


Re: [tip:ras/core] x86/RAS: Simplify SMCA HWID descriptor struct

2016-11-10 Thread Thomas Gleixner
On Thu, 10 Nov 2016, Borislav Petkov wrote:
> On Thu, Nov 10, 2016 at 12:50:04PM -0500, Yazen Ghannam wrote:
> > Adding extra parentheses in HWID_MCATYPE() gives the same assembly as the
> > original code and fixes the behavior.
> > 
> > > + hwid_mcatype = HWID_MCATYPE((high & MCI_IPID_HWID)),
> > > + ((high & MCI_IPID_MCATYPE) >> 16));
> 
> Argh, the macro should be adding the additional parentheses:
> 
> #define HWID_MCATYPE(hwid, mcatype) (((hwid) << 16) | (mcatype))
> 
> That should fix the issue too.

Patch please.


Re: [tip:ras/core] x86/RAS: Simplify SMCA HWID descriptor struct

2016-11-10 Thread Yazen Ghannam
>  static void get_smca_bank_info(unsigned int bank)
>  {
>   unsigned int i, hwid_mcatype, cpu = smp_processor_id();
> - struct smca_hwid_mcatype *type;
> + struct smca_hwid *s_hwid;
>   u32 high, instance_id;
> - u16 hwid, mcatype;
>  
>   /* Collect bank_info using CPU 0 for now. */
>   if (cpu)
> @@ -162,14 +157,13 @@ static void get_smca_bank_info(unsigned int bank)
>   return;
>   }
>  
> - hwid = high & MCI_IPID_HWID;
> - mcatype = (high & MCI_IPID_MCATYPE) >> 16;
> - hwid_mcatype = HWID_MCATYPE(hwid, mcatype);
> + hwid_mcatype = HWID_MCATYPE(high & MCI_IPID_HWID,
> + (high & MCI_IPID_MCATYPE) >> 16);
>

Sorry for catching this late, but it seems this change doesn't compile
correctly. This causes the value of hwid_mcatype to be incorrect, so we
will never match a bank to its type.

I see this with GCC 4.8.5 and 5.4.0. 

There are no warnings or issues when building or booting just
that the behavior is incorrect. 

Disassembly of above change:
  db:   8b 45 e0mov-0x20(%rbp),%eax
  de:   41 89 c4mov%eax,%r12d
  e1:   25 00 00 ff 0f  and$0xfff,%eax
  e6:   41 c1 ec 10 shr$0x10,%r12d
  ea:   41 09 c4or %eax,%r12d

Disassembly of original code:
 286:   8b 45 d0mov-0x30(%rbp),%eax
 289:   41 89 c5mov%eax,%r13d
 28c:   c1 e8 10shr$0x10,%eax
 28f:   41 81 e5 ff 0f 00 00and$0xfff,%r13d
 296:   41 c1 e5 10 shl$0x10,%r13d
 29a:   41 09 c5or %eax,%r13d

Adding extra parentheses in HWID_MCATYPE() gives the same assembly as the
original code and fixes the behavior.

> + hwid_mcatype = HWID_MCATYPE((high & MCI_IPID_HWID)),
> + ((high & MCI_IPID_MCATYPE) >> 16));

Thanks,
Yazen



Re: [tip:ras/core] x86/RAS: Simplify SMCA HWID descriptor struct

2016-11-10 Thread Yazen Ghannam
>  static void get_smca_bank_info(unsigned int bank)
>  {
>   unsigned int i, hwid_mcatype, cpu = smp_processor_id();
> - struct smca_hwid_mcatype *type;
> + struct smca_hwid *s_hwid;
>   u32 high, instance_id;
> - u16 hwid, mcatype;
>  
>   /* Collect bank_info using CPU 0 for now. */
>   if (cpu)
> @@ -162,14 +157,13 @@ static void get_smca_bank_info(unsigned int bank)
>   return;
>   }
>  
> - hwid = high & MCI_IPID_HWID;
> - mcatype = (high & MCI_IPID_MCATYPE) >> 16;
> - hwid_mcatype = HWID_MCATYPE(hwid, mcatype);
> + hwid_mcatype = HWID_MCATYPE(high & MCI_IPID_HWID,
> + (high & MCI_IPID_MCATYPE) >> 16);
>

Sorry for catching this late, but it seems this change doesn't compile
correctly. This causes the value of hwid_mcatype to be incorrect, so we
will never match a bank to its type.

I see this with GCC 4.8.5 and 5.4.0. 

There are no warnings or issues when building or booting just
that the behavior is incorrect. 

Disassembly of above change:
  db:   8b 45 e0mov-0x20(%rbp),%eax
  de:   41 89 c4mov%eax,%r12d
  e1:   25 00 00 ff 0f  and$0xfff,%eax
  e6:   41 c1 ec 10 shr$0x10,%r12d
  ea:   41 09 c4or %eax,%r12d

Disassembly of original code:
 286:   8b 45 d0mov-0x30(%rbp),%eax
 289:   41 89 c5mov%eax,%r13d
 28c:   c1 e8 10shr$0x10,%eax
 28f:   41 81 e5 ff 0f 00 00and$0xfff,%r13d
 296:   41 c1 e5 10 shl$0x10,%r13d
 29a:   41 09 c5or %eax,%r13d

Adding extra parentheses in HWID_MCATYPE() gives the same assembly as the
original code and fixes the behavior.

> + hwid_mcatype = HWID_MCATYPE((high & MCI_IPID_HWID)),
> + ((high & MCI_IPID_MCATYPE) >> 16));

Thanks,
Yazen



Re: [tip:ras/core] x86/RAS: Simplify SMCA HWID descriptor struct

2016-11-10 Thread Borislav Petkov
On Thu, Nov 10, 2016 at 12:50:04PM -0500, Yazen Ghannam wrote:
> Adding extra parentheses in HWID_MCATYPE() gives the same assembly as the
> original code and fixes the behavior.
> 
> > +   hwid_mcatype = HWID_MCATYPE((high & MCI_IPID_HWID)),
> > +   ((high & MCI_IPID_MCATYPE) >> 16));

Argh, the macro should be adding the additional parentheses:

#define HWID_MCATYPE(hwid, mcatype) (((hwid) << 16) | (mcatype))

That should fix the issue too.

-- 
Regards/Gruss,
Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 
(AG Nürnberg)
-- 


Re: [tip:ras/core] x86/RAS: Simplify SMCA HWID descriptor struct

2016-11-10 Thread Borislav Petkov
On Thu, Nov 10, 2016 at 12:50:04PM -0500, Yazen Ghannam wrote:
> Adding extra parentheses in HWID_MCATYPE() gives the same assembly as the
> original code and fixes the behavior.
> 
> > +   hwid_mcatype = HWID_MCATYPE((high & MCI_IPID_HWID)),
> > +   ((high & MCI_IPID_MCATYPE) >> 16));

Argh, the macro should be adding the additional parentheses:

#define HWID_MCATYPE(hwid, mcatype) (((hwid) << 16) | (mcatype))

That should fix the issue too.

-- 
Regards/Gruss,
Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 
(AG Nürnberg)
--