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:	Tue, 01 Aug 2006 20:19:21 -0600
From:	ebiederm@...ssion.com (Eric W. Biederman)
To:	Andi Kleen <ak@...e.de>
Cc:	<linux-kernel@...r.kernel.org>, Horms <horms@...ge.net.au>,
	Jan Kratochvil <lace@...kratochvil.net>,
	"H. Peter Anvin" <hpa@...or.com>,
	Magnus Damm <magnus.damm@...il.com>,
	Vivek Goyal <vgoyal@...ibm.com>, Linda Wang <lwang@...hat.com>
Subject: Re: [PATCH 2/33] i386: define __pa_symbol

Andi Kleen <ak@...e.de> writes:

> "Eric W. Biederman" <ebiederm@...ssion.com> writes:
>
>> On x86_64 we have to be careful with calculating the physical
>> address of kernel symbols.  Both because of compiler odditities
>> and because the symbols live in a different range of the virtual
>> address space.
>> 
>> Having a defintition of __pa_symbol that works on both x86_64 and
>> i386 simplifies writing code that works for both x86_64 and
>> i386 that has these kinds of dependencies.
>> 
>> So this patch adds the trivial i386 __pa_symbol definition.
>> 
>> Signed-off-by: Eric W. Biederman <ebiederm@...ssion.com>
>> ---
>>  include/asm-i386/page.h |    1 +
>>  1 files changed, 1 insertions(+), 0 deletions(-)
>> 
>> diff --git a/include/asm-i386/page.h b/include/asm-i386/page.h
>> index f5bf544..eceb7f5 100644
>> --- a/include/asm-i386/page.h
>> +++ b/include/asm-i386/page.h
>> @@ -124,6 +124,7 @@ #define PAGE_OFFSET		((unsigned long)__P
>>  #define VMALLOC_RESERVE		((unsigned long)__VMALLOC_RESERVE)
>>  #define MAXMEM			(-__PAGE_OFFSET-__VMALLOC_RESERVE)
>>  #define __pa(x)			((unsigned long)(x)-PAGE_OFFSET)
>> +#define __pa_symbol(x)		__pa(x)
>
> Actually PAGE_OFFSET arithmetic on symbols is outside ISO C and gcc 
> misoptimizes it occassionally. You would need to use HIDE_RELOC
> or similar. That is why x86-64 has the magic.

Yes.  ISO C only defines pointer arithmetic with in arrays.  
I believe gnu C makes it a well defined case.

Currently we do not appear to have any problems on i386.
But I have at least one case of code that is shared between
i386 and x86_64 and it is appropriate to use __pa_symbol on
x86_64.

So I added __pa_symbol for that practical reason.

I would have no problems with generalizing this but I wanted to
at least make it possible to use the concept on i386.

I will be happy to add in the assembly magic, if you don't have
any other problems with this.

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