Re: [PATCH] x86_64: Implement personality ADDR_LIMIT_32BIT

Kirill A. Shutemov
2008-10-03T09:24:51Z

[-- Attachment #1: Type: text/plain, Size: 1518 bytes --]

On Fri, Oct 03, 2008 at 10:02:44AM +0200, Ingo Molnar wrote:
>
> * Kirill A. Shutemov <kirill@shutemov.name> wrote:
>
> > - /* for MAP_32BIT mappings we force the legact mmap base */
> > - if (!test_thread_flag(TIF_IA32) && (flags & MAP_32BIT))
> > + /* for MAP_32BIT mappings and ADDR_LIMIT_32BIT personality we force the
> > + * legact mmap base
> > + */
>
> please use the customary multi-line comment style:
>
> /*
> * Comment .....
> * ...... goes here:
> */
>
> and you might use the opportunity to fix the s/legact/legacy typo as
> well.

Ok, I'll fix it.

>
> but more generally, we already have ADDR_LIMIT_3GB support on x86.

Does ADDR_LIMIT_3GB really work?

$ cat 1.c
#include <stdio.h>
#include <sys/personality.h>
#include <sys/ipc.h>
#include <sys/shm.h>

#define ADDR_LIMIT_3GB 0x8000000

int main(void)
{
int id;
void *shm;

personality(ADDR_LIMIT_3GB);

id = shmget(0x123456, 1, IPC_CREAT | 0600);
shm = shmat(id, NULL, 0);
printf("shm: %p\n", shm);
shmdt(shm);

return 0;
}
$ gcc -Wall 1.c
$ sudo ./a.out
shm: 0x7f4fca755000

> Why
> should support for ADDR_LIMIT_32BIT be added?

It's useful for user mode qemu when you try emulate 32-bit target on
x86_64. For example, if shmat(2) return addres above 32-bit, target will
get SIGSEGV on access to it.

--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.com/

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]