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] [day] [month] [year] [list]
Date:	Tue, 29 Mar 2011 14:32:46 -0300
From:	Mauro Carvalho Chehab <mchehab@...hat.com>
To:	Borislav Petkov <bp@...64.org>
CC:	"linux-edac@...r.kernel.org" <linux-edac@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 05/30] amd64_edac: Cleanup chipselect handling

Em 29-03-2011 13:02, Borislav Petkov escreveu:
> On Tue, Mar 29, 2011 at 11:39:09AM -0400, Mauro Carvalho Chehab wrote:
>>>>> + * Create a contiguous bitmask starting at bit position @lo and ending at
>>>>> + * position @hi. For example
>>>>> + *
>>>>> + * GENMASK(21, 39) gives us the 64bit vector 0x000000ffffe00000.
>>>>> + */
>>>>> +#define GENMASK(lo, hi)			(((1ULL << ((hi) - (lo) + 1)) - 1) << (lo))
>>>>> +
>>>>
>>>> This is a nice macro that could be useful outside amd64. It is probably a good
>>>> idea to move it to include/linux/bitops.h.
>>>
>>> I'd suggest rather <drivers/edac/edac_core.h> if you want to use it in
>>> EDAC. But if we have more users, I don't have a problem with putting
>>> it there (or somewhere else generic enough if people have a better
>>> suggestion).
>>
>> Yeah, other edac drivers could benefit of using it, and also could benefit on a
>> variant that would do an AND operation and shift it, something like (untested):
>>
>> /*
>>  * Create a contiguous bitmask starting at bit position @lo and ending at
>>  * position @hi. For example
>>  *
>>  * APPLY_BITMASK(v, 21, 39) will return the result of:
>>  * 	(v & 0x000000ffffe00000) >> 21
>>  */
>> #define APPLY_BITMASK(v, lo, hi)	(((v) & ((1ULL << ((hi) - (lo) + 1)) - 1) << (lo)) >> (lo))
> 
> The macro definition doesn't match the comment. In the comment you do a bitwise
> AND first and shift the result then. The way you've written it, it does
> 
> 	((v & 0x000000000007ffff << 21) >> 21)
> 
> you need to fixup the brackets:

Ah, yes. As I said, it was untested ;) I was in the middle of reviewing lots of edac patches,
but I didn't want to loose the idea, so I was quick on my reply ;)
> 
> #define APPLY_BITMASK(v, lo, hi)	(((v) & (((1ULL << ((hi) - (lo) + 1)) - 1) << (lo))) >> (lo))
> 
> Also, this doesn't only apply it but shifts too, so it should be
> 
> #define APPLY_BITMASK_AND_SHIFT(...)

Yeah, that name sounds better ;)
> 
> But this macro gets too special to put it in shared code.

Ok.

> 
>> Almost all edac drivers do something like the above, for example, to get DIMM rows/cols/banks, etc.
>>
>> Probably, the most complex part is to find a nice name for it ;)
>>
>> Yet, I think non-edac drivers could also benefit of such macro, and, as this is not
>> edac-specific, I think it would be better to add it at bitops.h.
> 
> No, this should go into generic code only if it has users - "it might
> benefit" is not strong-enough an argument for polluting generic code.
> I'd leave it in edac_core.h and push it somewhere more generic only when
> I need it in other subsystems.

Works for me.

Thanks!
Mauro

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ