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: <20061004194441.GF16218@in.ibm.com>
Date:	Wed, 4 Oct 2006 15:44:41 -0400
From:	Vivek Goyal <vgoyal@...ibm.com>
To:	Franck Bui-Huu <vagabon.xyz@...il.com>
Cc:	linux-kernel@...r.kernel.org,
	Reloc Kernel List <fastboot@...ts.osdl.org>,
	ebiederm@...ssion.com, akpm@...l.org, ak@...e.de,
	horms@...ge.net.au, lace@...kratochvil.net, hpa@...or.com,
	magnus.damm@...il.com, lwang@...hat.com, dzickus@...hat.com,
	maneesh@...ibm.com
Subject: Re: [PATCH 4/12] i386: define __pa_symbol()

On Wed, Oct 04, 2006 at 10:26:44AM +0200, Franck Bui-Huu wrote:
> hi,
> 
> Sorry for the late feedback...
> 
> Vivek Goyal wrote:
> > 
> > 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.
> > 
> 
> [snip]
> 
> > +#define __pa_symbol(x)          \
> > +	({unsigned long v;  \
> > +	  asm("" : "=r" (v) : "0" (x)); \
> > +	  __pa(v); })
> 
> Why not simply reusing RELOC_HIDE  like this ?
> 
> 	#define __pa_symbol(x)	__pa(RELOC_HIDE(x,0))
>

Thanks. Above did not work and compiler gave following warning message upon
using __pa_symbol(_text)

error: cast specified array type

Then I specifically typecasted x to unsigned long and it seems to be
fine. 

Regenerated patch is attached.

 


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.

Added assembly magic similar to RELOC_HIDE as suggested by Andi Kleen.
Just picked it up from x86_64.

Signed-off-by: Eric W. Biederman <ebiederm@...ssion.com>
Signed-off-by: Vivek Goyal <vgoyal@...ibm.com>
---

 include/asm-i386/page.h |    3 +++
 1 file changed, 3 insertions(+)

diff -puN include/asm-i386/page.h~i386-define-__pa_symbol include/asm-i386/page.h
--- linux-2.6.18-git17/include/asm-i386/page.h~i386-define-__pa_symbol	2006-10-02 14:39:18.000000000 -0400
+++ linux-2.6.18-git17-root/include/asm-i386/page.h	2006-10-04 14:48:54.000000000 -0400
@@ -124,6 +124,9 @@ extern int page_is_ram(unsigned long pag
 #define VMALLOC_RESERVE		((unsigned long)__VMALLOC_RESERVE)
 #define MAXMEM			(-__PAGE_OFFSET-__VMALLOC_RESERVE)
 #define __pa(x)			((unsigned long)(x)-PAGE_OFFSET)
+/* __pa_symbol should be used for C visible symbols.
+   This seems to be the official gcc blessed way to do such arithmetic. */
+#define __pa_symbol(x)          __pa(RELOC_HIDE((unsigned long)x,0))
 #define __va(x)			((void *)((unsigned long)(x)+PAGE_OFFSET))
 #define pfn_to_kaddr(pfn)      __va((pfn) << PAGE_SHIFT)
 #ifdef CONFIG_FLATMEM
_
 
-
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