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: <48505A0C.7060506@gmail.com>
Date:	Thu, 12 Jun 2008 01:04:44 +0200
From:	Andrea Righi <righi.andrea@...il.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
CC:	balbir@...ux.vnet.ibm.com, linux-mm@...ck.org,
	skumar@...ux.vnet.ibm.com, yamamoto@...inux.co.jp,
	menage@...gle.com, lizf@...fujitsu.com,
	linux-kernel@...r.kernel.org, xemul@...nvz.org,
	kamezawa.hiroyu@...fujitsu.com
Subject: Re: [-mm][PATCH 2/4] Setup the memrlimit controller (v5)

Andrew Morton wrote:
> On Thu, 12 Jun 2008 00:47:27 +0200
> Andrea Righi <righi.andrea@...il.com> wrote:
> 
>> Andrew Morton wrote:
>>>> At least we could add something like:
>>>>
>>>> #ifdef CONFIG_32BIT
>>>> #define PAGE_ALIGN64(addr) (((((addr)+PAGE_SIZE-1))>>PAGE_SHIFT)<<PAGE_SHIFT)
>>>> #else
>>>> #define PAGE_ALIGN64(addr) PAGE_ALIGN(addr)
>>>> #endif
>>>>
>>>> But IMHO the single PAGE_ALIGN64() implementation is more clear.
>>> No, we should just fix PAGE_ALIGN.  It should work correctly when
>>> passed a long-long.  Otherwse it's just a timebomb.
>>>
>>> This:
>>>
>>> #define PAGE_ALIGN(addr) ({				\
>>> 	typeof(addr) __size = PAGE_SIZE;		\
>>> 	typeof(addr) __mask = PAGE_MASK;		\
>>> 	(addr + __size - 1) & __mask;			\
>>> })
>>>
>>> (with a suitable comment) does what we want.  I didn't check to see
>>> whether this causes the compiler to generate larger code, but it
>>> shouldn't.
>>>
>> No, it doesn't work. The problem seems to be in the PAGE_MASK definition
>> (from include/asm-x86/page.h for example):
>>
>> /* PAGE_SHIFT determines the page size */
>> #define PAGE_SHIFT      12
>> #define PAGE_SIZE       (_AC(1,UL) << PAGE_SHIFT)
>> #define PAGE_MASK       (~(PAGE_SIZE-1))
>>
>> The "~" is performed on a 32-bit value, so everything in "and" with
>> PAGE_MASK greater than 4GB will be truncated to the 32-bit boundary.
> 
> OK, I oversimplified my testcase.
> 
>> What do you think about the following?
>>
>> #define PAGE_SIZE64 (1ULL << PAGE_SHIFT)
>> #define PAGE_MASK64 (~(PAGE_SIZE64 - 1))
>>
>> #define PAGE_ALIGN(addr) ({					\
>> 	typeof(addr) __size = PAGE_SIZE;			\
>> 	typeof(addr) __ret = (addr) + __size - 1;		\
>> 	__ret > -1UL ? __ret & PAGE_MASK64 : __ret & PAGE_MASK;	\
>> })
> 
> Complex.  And I'd worry about added code overhead.
> 
> What about
> 
> #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
> 
> ?
> 
> afaict ALIGN() tries to do the right thing, and if it doesn't, we
> should fix ALIGN().

Good! Much simpler.

-Andrea
--
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