2008-01-30 09:36:52

by Huang, Ying

[permalink] [raw]
Subject: ioremap_xxx() with EXEC enabled

Hi,

On i386, EFI may need to map EFI runtime code area as EXEC enabled with
ioremap(). But, I found that the memory are mapped as EXEC disabled when
mapped with ioremap() now. I think we may need a method to map memory
area as EXEC enabled with ioremap_xxx(). Some possible interface schemes
for mapping as EXEC enabled are as follow:

- Interface scheme 1:

ioremap_cache_exec()
ioremap_uncache_exec()

- Interface scheme 2:

enum ioremap_mode {
IOR_MODE_UNCACHED,
IOR_MODE_CACHED,
};

enum ioremap_xmode {
IOR_XMODE_UNEXEC,
IOR_XMODE_EXEC,
};

void __iomem *__ioremap(unsigned long phys_addr, unsigned long size,
enum ioremap_mode mode,
enum ioremap_xmode xmode);


Which one do you think is better? Or we should use some other interface
or method?

Best Regards,
Huang Ying


2008-01-30 10:01:19

by Andi Kleen

[permalink] [raw]
Subject: Re: ioremap_xxx() with EXEC enabled

On Wednesday 30 January 2008 10:32, Huang, Ying wrote:
> Hi,
>
> On i386, EFI may need to map EFI runtime code area as EXEC enabled with
> ioremap(). But, I found that the memory are mapped as EXEC disabled when
> mapped with ioremap() now. I think we may need a method to map memory
> area as EXEC enabled with ioremap_xxx(). Some possible interface schemes
> for mapping as EXEC enabled are as follow:

Does __ioremap(..., PAGE_KERNEL_EXEC) not work?

-Andi

2008-01-30 13:00:18

by huang ying

[permalink] [raw]
Subject: Re: ioremap_xxx() with EXEC enabled

On Jan 30, 2008 5:59 PM, Andi Kleen <[email protected]> wrote:
> On Wednesday 30 January 2008 10:32, Huang, Ying wrote:
> > Hi,
> >
> > On i386, EFI may need to map EFI runtime code area as EXEC enabled with
> > ioremap(). But, I found that the memory are mapped as EXEC disabled when
> > mapped with ioremap() now. I think we may need a method to map memory
> > area as EXEC enabled with ioremap_xxx(). Some possible interface schemes
> > for mapping as EXEC enabled are as follow:
>
> Does __ioremap(..., PAGE_KERNEL_EXEC) not work?

The the last parameter of the current implementation of __ioremap() in
x86 git is enum ioremap_mode (IOR_MODE_UNCACHED and IOR_MODE_CACHED),
not the flags like before. So this does not work.

Best Regards,
Huang Ying

2008-01-30 13:24:15

by Andi Kleen

[permalink] [raw]
Subject: Re: ioremap_xxx() with EXEC enabled


> The the last parameter of the current implementation of __ioremap() in
> x86 git is enum ioremap_mode (IOR_MODE_UNCACHED and IOR_MODE_CACHED),
> not the flags like before. So this does not work.

Ah you're right sorry. Looks like a design flaw in the recent git-x86 changes.

-Andi

2008-01-30 15:47:08

by Arjan van de Ven

[permalink] [raw]
Subject: Re: ioremap_xxx() with EXEC enabled

On Wed, 30 Jan 2008 17:32:10 +0800
"Huang, Ying" <[email protected]> wrote:

> Hi,
>
> On i386, EFI may need to map EFI runtime code area as EXEC enabled
> with ioremap(). But, I found that the memory are mapped as EXEC
> disabled when mapped with ioremap() now. I think we may need a method
> to map memory area as EXEC enabled with ioremap_xxx(). Some possible
> interface schemes for mapping as EXEC enabled are as follow:
>
> - Interface scheme 1:

scheme 3:

set_memory_x(... )

2008-01-30 17:31:00

by Andi Kleen

[permalink] [raw]
Subject: Re: ioremap_xxx() with EXEC enabled

On Wed, Jan 30, 2008 at 07:45:40AM -0800, Arjan van de Ven wrote:
> On Wed, 30 Jan 2008 17:32:10 +0800
> "Huang, Ying" <[email protected]> wrote:
>
> > Hi,
> >
> > On i386, EFI may need to map EFI runtime code area as EXEC enabled
> > with ioremap(). But, I found that the memory are mapped as EXEC
> > disabled when mapped with ioremap() now. I think we may need a method
> > to map memory area as EXEC enabled with ioremap_xxx(). Some possible
> > interface schemes for mapping as EXEC enabled are as follow:
> >
> > - Interface scheme 1:
>
> scheme 3:
>
> set_memory_x(... )

On i386 EFI is unlikely to be in the direct mapping ...

-Andi

2008-01-30 17:45:29

by Arjan van de Ven

[permalink] [raw]
Subject: Re: ioremap_xxx() with EXEC enabled

On Wed, 30 Jan 2008 18:30:48 +0100
Andi Kleen <[email protected]> wrote:

> On Wed, Jan 30, 2008 at 07:45:40AM -0800, Arjan van de Ven wrote:
> > On Wed, 30 Jan 2008 17:32:10 +0800
> > "Huang, Ying" <[email protected]> wrote:
> >
> > > Hi,
> > >
> > > On i386, EFI may need to map EFI runtime code area as EXEC enabled
> > > with ioremap(). But, I found that the memory are mapped as EXEC
> > > disabled when mapped with ioremap() now. I think we may need a
> > > method to map memory area as EXEC enabled with ioremap_xxx().
> > > Some possible interface schemes for mapping as EXEC enabled are
> > > as follow:
> > >
> > > - Interface scheme 1:
> >
> > scheme 3:
> >
> > set_memory_x(... )
>
> On i386 EFI is unlikely to be in the direct mapping ...

1) 32 bit EFI is totally irrelevant.
2) set_memory_ and set_pages_ API is not restricted to direct mapping. That's why they take a virtual address / struct page

>
> -Andi
>


--
If you want to reach me at my work email, use [email protected]
For development, discussion and tips for power savings,
visit http://www.lesswatts.org

2008-01-30 18:35:21

by Andi Kleen

[permalink] [raw]
Subject: Re: ioremap_xxx() with EXEC enabled


> 1) 32 bit EFI is totally irrelevant.

Apparently not to the original poster. And some Apple x86 users might
also disagree.

On x86-64 BTW while they could still rely on end_pfn_mapped and
it being direct mapped Venki's PAT patchkit removes that so ioremap
would be needed there too

> 2) set_memory_ and set_pages_ API is not restricted to direct mapping.
> That's why they take a virtual address / struct page

If there is no direct mapping what page tables should they change?
Surely you're not suggesting they should walk all vmalloc areas and switch
them over. I don't think this is correct.

-Andi