lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9745d473-e4bc-7ae2-fc67-a898c3606088@hpe.com>
Date:   Thu, 5 Sep 2019 15:42:41 -0700
From:   Mike Travis <mike.travis@....com>
To:     Sasha Levin <sashal@...nel.org>,
        Greg KH <gregkh@...uxfoundation.org>
Cc:     Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>,
        "H. Peter Anvin" <hpa@...or.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Borislav Petkov <bp@...en8.de>,
        Christoph Hellwig <hch@...radead.org>,
        Dimitri Sivanich <dimitri.sivanich@....com>,
        Russ Anderson <russ.anderson@....com>,
        Hedi Berriche <hedi.berriche@....com>,
        Steve Wahl <steve.wahl@....com>, x86@...nel.org,
        linux-kernel@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH 6/8] x86/platform/uv: Decode UVsystab Info



On 9/5/2019 2:40 PM, Sasha Levin wrote:
> On Thu, Sep 05, 2019 at 04:16:34PM +0200, Greg KH wrote:
>> On Thu, Sep 05, 2019 at 08:02:58AM -0500, Mike Travis wrote:
>>> --- linux.orig/arch/x86/kernel/apic/x2apic_uv_x.c
>>> +++ linux/arch/x86/kernel/apic/x2apic_uv_x.c
>>> @@ -1303,7 +1303,8 @@ static int __init decode_uv_systab(void)
>>>      struct uv_systab *st;
>>>      int i;
>>>
>>> -    if (uv_hub_info->hub_revision < UV4_HUB_REVISION_BASE)
>>> +    /* Select only UV4 (hubbed or hubless) and higher */
>>> +    if (is_uv_hubbed(-2) < uv(4) && is_uv_hubless(-2) < uv(4))
> 
> For someone not too familiar with the code, this is completely
> unreadable. There must be a nicer way to do this.
> 
> -- 
> Thanks,
> Sasha

Hi Sasha,

I can put in further explanation but first the uv() function returns 1 
left shifted by the UV #:

static inline int uv(int uvtype)
{
         /* uv(0) is "any" */
         if (uvtype >= 0 && uvtype <= 30)
                 return 1 << uvtype;
         return 1;
}

The "is_uv_hubbed(x)" and "is_uv_hubless(x)" AND's the incoming arg with 
the actual uv type:

int is_uv_hubbed(int uvtype)
{
         return (uv_hubbed_system & uvtype);
}

The uv_hub{bed,less}_system is set to 1 left shifted by the UV # plus in 
bit 0 is a '1' to indicate "any" UV (as in "is_uv_hubbed(1)" is any UV 
hubbed system).  Hubbed indicates a hubbed system, and hubless indicates 
a hubless system, it cannot be both but can be neither.

>                 /* UV4 Hubless, (0x11:UV4+Any) */
>                 if (strncmp(oem_id, "NSGI4", 5) == 0)
>                         uv_hubless_system = 0x11;
> 
>                 /* UV3 Hubless, UV300/MC990X w/o hub (0x9:UV3+Any) */
>                 else
>                         uv_hubless_system = 0x9;
> 

(There are only hubbed versions of UV1 and UV2.)

Lastly (-2) translates to 0xffff...fffe (note bit 0 is clear to avoid 
the "any" bit.   So it is looking for a a hubbed or hubless UV system 
that is less than UV4 meaning only UV4,5,6...qualify, hence this comment:

 >>> +    /* Select only UV4 (hubbed or hubless) and higher */
	if (UV is less than UV4 either hubbed or hubless)
		return;  /* does not have an extended UVsystab */

Have you a suggestion on what would make it more clear?  Perhaps instead 
of -2 I should use a hex mask?

Thanks,
Mike


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ