loading kernel at any physical address

Igor Shmukler shmukler at mail.ru
Wed Dec 15 11:27:39 PST 2004


I think this might be somewhat off topic, but to support superpages you probably want kernel to be aligned on 4MB boundary.

Also, Mach had macros for alignment. I browsed code and it seems there are macros in i386/include/asmacros.h
Perhaps I am missing something, but I don't see why would you want to align with NOPS.


-----Original Message-----
From: <Vijay.Singh at nokia.com>
To: <hackers at freebsd.org>
Date: Wed, 15 Dec 2004 10:43:45 -0800
Subject: loading kernel at any physical address

> Hello all, for a project I am trying to figure out how to boot a FreeBSD kernel loaded at any physical address. Right now the locore.s magic works because the load addres (KERNLOAD) and (KERNBASE) are set such that
> 
> #define R(foo) ((foo)-KERNBASE)
> 
> macro is able to get the addresses before paging is enabled.
> 
> If the loadaddress information is not embedded in defines, then is the following solution expected to work:
> 
> 	.globl	_loadaddress		/* should be at 16M aligned ??? */
> 	.set	_loadaddress,KERNBASE
> 
> and then:
> 
> NON_GPROF_ENTRY(btext)
> 
>         nop                             /* nops for 8 byte alignment */
>         nop
>         nop
>         call 0f
> 0:
>         mov     4(%ebp), %eax
>         add     $-8, %eax               /* This is actual physical load addr */
>         add     $-0x100000, %eax
>         subl     %eax, _loadaddress     /* new kernbase w.r.t load addr */
>                                         /* instead of standard 1MB reloc */
> 
> and then 
> 
> #define R(foo) ((foo)- _loadaddress)
> 
> One issue might be loadaddress over 16M, but for this problem we can assume that the processor has been in protected mode, so it has access to that space.
> 
> Any input on this is highly appreciated.
> 
> br
> vijay



More information about the freebsd-hackers mailing list