Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Jan 2015 11:32:18 -0800
From:      Nathan Whitehorn <nwhitehorn@freebsd.org>
To:        freebsd-arch@freebsd.org, FreeBSD PowerPC ML <freebsd-ppc@freebsd.org>
Subject:   Making the powerpc64 relocatable
Message-ID:  <54BFFEC2.5070909@freebsd.org>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------080909080605030806020708
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit

In order to run natively on POWER8 hardware, the 64-bit PPC kernel needs 
to be relocatable. Some architectures do this by executing the kernel at 
a fixed virtual address with varying physical addresses. For PPC64, the 
kernel has a 1:1 direct map and the ABI is always PIC, so it's easier 
just to keep the 1:1 mapping and make both the kernel physical and 
virtual address range float (patch attached and at 
http://people.freebsd.org/~nwhitehorn/ppc64-pie-kernel.diff in case it 
gets stripped).

This is the first architecture to have a PIE kernel, however, so I'd 
like some feedback on the approach. The major immediate difficulty is 
that PIE kernels are ET_DYN ELF executables. loader, however, thinks the 
kernel must be ET_EXEC and that anything that is ET_DYN is a loadable 
module. I have a somewhat hacky workaround in the patches to loader and 
kmod.mk, which uses the ELF entrypoint to decide whether something is a 
kernel or not (setting it to zero for modules). It's the simplest 
approach but I'm not sure the best one.
-Nathan

--------------080909080605030806020708
Content-Type: text/plain; charset=us-ascii;
 name="ppc64-pie-kernel.diff"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="ppc64-pie-kernel.diff"

SW5kZXg6IGJvb3QvY29tbW9uL2xvYWRfZWxmLmMKPT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gYm9vdC9j
b21tb24vbG9hZF9lbGYuYwkocmV2aXNpb24gMjc3NDM4KQorKysgYm9vdC9jb21tb24vbG9h
ZF9lbGYuYwkod29ya2luZyBjb3B5KQpAQCAtMTc1LDcgKzE3NSwxMSBAQAogICAgICAqIENo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XG4iKTsKSW5kZXg6IGNvbmYvTWFrZWZpbGUucG93ZXJwYwo9PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBj
b25mL01ha2VmaWxlLnBvd2VycGMJKHJldmlzaW9uIDI3NzQzOCkKKysrIGNvbmYvTWFrZWZp
bGUucG93ZXJwYwkod29ya2luZyBjb3B5KQpAQCAtMzcsNiArMzcsMTEgQEAKIAogQ0ZMQUdT
Kz0gLW1zb2Z0LWZsb2F0IC1XYSwtbWFueQogCisuaWYgJHtNQUNISU5FX0FSQ0h9ID09ICJw
b3dlcnBjNjQiCitDRkxBR1MrPSAtZlBJQworTERGTEFHUys9IC1waWUKKy5lbmRpZgorCiAu
aWYgIWVtcHR5KEREQl9FTkFCTEVEKQogQ0ZMQUdTKz0JLWZuby1vbWl0LWZyYW1lLXBvaW50
ZXIKIC5lbmRpZgpJbmRleDogY29uZi9rbW9kLm1rCj09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIGNvbmYv
a21vZC5tawkocmV2aXNpb24gMjc3NDM4KQorKysgY29uZi9rbW9kLm1rCSh3b3JraW5nIGNv
cHkpCkBAIC0xNzksNiArMTc5LDkgQEAKIAkke09CSkNPUFl9IC0tb25seS1rZWVwLWRlYnVn
ICR7RlVMTFBST0d9ICR7LlRBUkdFVH0KIC5lbmRpZgogCisjIERvbid0IGFkZCBhIGZha2Ug
ZW50cnkgcG9pbnQgdG8gbW9kdWxlcworX0xERkxBR1MrPSAtZSAwCisKIC5pZiAke19fS0xE
X1NIQVJFRH0gPT0geWVzCiAke0ZVTExQUk9HfTogJHtLTU9EfS5rbGQKIAkke0xEfSAtQnNo
YXJlYWJsZSAke19MREZMQUdTfSAtbyAkey5UQVJHRVR9ICR7S01PRH0ua2xkCg==
--------------080909080605030806020708--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?54BFFEC2.5070909>