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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 2 Oct 2009 10:37:55 +0900
From:	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
To:	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
Cc:	Hugh Dickins <hugh.dickins@...cali.co.uk>,
	Wu Fengguang <fengguang.wu@...el.com>,
	Nigel Cunningham <ncunningham@...a.org.au>,
	LKML <linux-kernel@...r.kernel.org>,
	"linux-mm@...ck.org" <linux-mm@...ck.org>
Subject: Re: No more bits in vm_area_struct's vm_flags.

On Fri, 2 Oct 2009 09:42:38 +0900
KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com> wrote:

> > > 
> > > (2) All vm macros should be defined with ULL suffix. for supporing ~ 
> > > ==
> > > vm_flags           30 arch/x86/mm/hugetlbpage.c 	unsigned long vm_flags = vma->vm_flags & ~VM_LOCKED;
> > > 
> > > (3) vma_merge()'s vm_flags should be ULL.
> > 
> > At first I thought you'd saved me a lot of embarrassment by mentioning
> > those ULL suffixes, I hadn't put them in.  But after a quick test of
> > what I thought was going to show a problem without them, no problem.
> > Please would you send me a test program which demonstrates the need
> > for all those ULLs?
> > 
> Ah, I'm sorry if I misunderstand C's rule. 
> 
> There are some places which use ~.
> like
> 	vm_flags = vma->vm_flags & ~(VM_LOCKED);
> 
> ~VM_LOCKED is 
> 	0xffffdfff or 0xffffffffffffdffff ?
> 
> Is my concern.
> 
> I tried following function on my old x86 box
> ==
> #define FLAG    (0x20)
> 
> int foo(unsigned long long x)
> {
>         return x & ~FLAG;
> }
> ==
> (returning "int" as "bool")
> 
> compile this with gcc -S -O2 (gcc's version is 4.0)
> ==
> foo:
>         pushl   %ebp
>         movl    %esp, %ebp
>         movl    8(%ebp), %eax
>         andl    $-33, %eax
>         leave
>         ret
> ==
> Them, it seems higher bits are ignored for returning bool.
> 
Sigh, I seems I don't undestand C language yet..

This one
==
#define FLAG    (0x20ULL)

int foo(unsigned long long x)
{
        return (x & ~FLAG);
}
==
is compiled as
==
foo:
        pushl   %ebp
        movl    %esp, %ebp
        movl    8(%ebp), %eax
        andl    $-33, %eax
        leave
        ret
==
ULL suffix makes no difference ;)

This one
==
#define FLAG    (0x20)

int foo(unsigned long long x)
{
        if (x & ~FLAG)
                return 1;
        return 0;
}

==
foo:
        pushl   %ebp
        movl    %esp, %ebp
        movl    8(%ebp), %eax
        movl    12(%ebp), %edx
        andl    $-33, %eax
        orl     %edx, %eax
        setne   %al
        movzbl  %al, %eax
        leave
        ret

seems good.


Hmm. sorry for noise. Maybe I don't understand C's cast rules.

-Kame









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