From owner-freebsd-arch@FreeBSD.ORG Wed Jan 21 19:32:26 2015 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 97588BBA; Wed, 21 Jan 2015 19:32:26 +0000 (UTC) Received: from c.mail.sonic.net (c.mail.sonic.net [64.142.111.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 777151F0; Wed, 21 Jan 2015 19:32:26 +0000 (UTC) Received: from aurora.physics.berkeley.edu (aurora.Physics.Berkeley.EDU [128.32.117.67]) (authenticated bits=0) by c.mail.sonic.net (8.14.9/8.14.9) with ESMTP id t0LJWIci009073 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 21 Jan 2015 11:32:18 -0800 Message-ID: <54BFFEC2.5070909@freebsd.org> Date: Wed, 21 Jan 2015 11:32:18 -0800 From: Nathan Whitehorn User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: freebsd-arch@freebsd.org, FreeBSD PowerPC ML Subject: Making the powerpc64 relocatable Content-Type: multipart/mixed; boundary="------------080909080605030806020708" X-Sonic-CAuth: UmFuZG9tSVYz054BBw4mQjeHeqof58Qc36fiVZWhlStR4Ac0oi+AMHAzWjYemaEgsbjAMSr57X5a6KZmuAnlThsyNasbd8pATTMBH6/gCuU= X-Sonic-ID: C;YOgJNqSh5BGi7KnrCx1YGw== M;DLVUNqSh5BGi7KnrCx1YGw== X-Spam-Flag: No X-Sonic-Spam-Details: 0.0/5.0 by cerberusd X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jan 2015 19:32:26 -0000 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 ZWNrIHRvIHNlZSB3aGF0IHNvcnQgb2YgbW9kdWxlIHdlIGFyZS4KICAgICAgKi8KICAgICBr ZnAgPSBmaWxlX2ZpbmRmaWxlKE5VTEwsIF9fZWxmTihrZXJuZWx0eXBlKSk7CisjaWYgZGVm aW5lZChfX3Bvd2VycGNfXykgJiYgX19FTEZfV09SRF9TSVpFID09IDY0CisgICAgaWYgKGVo ZHItPmVfdHlwZSA9PSBFVF9EWU4gJiYgZWhkci0+ZV9lbnRyeSA9PSAwKSB7CisjZWxzZQog ICAgIGlmIChlaGRyLT5lX3R5cGUgPT0gRVRfRFlOKSB7CisjZW5kaWYKIAkvKiBMb29rcyBs aWtlIGEga2xkIG1vZHVsZSAqLwogCWlmIChtdWx0aWJvb3QgIT0gMCkgewogCQlwcmludGYo ImVsZiIgX19YU1RSSU5HKF9fRUxGX1dPUkRfU0laRSkgIl9sb2FkZmlsZTogY2FuJ3QgbG9h ZCBtb2R1bGUgYXMgbXVsdGlib290XG4iKTsKQEAgLTE5NSw3ICsxOTksMTIgQEAKIAkvKiBM b29rcyBPSywgZ290IGFoZWFkICovCiAJZWYua2VybmVsID0gMDsKIAorI2lmIGRlZmluZWQo X19wb3dlcnBjX18pICYmIF9fRUxGX1dPUkRfU0laRSA9PSA2NAorICAgIH0gZWxzZSBpZiAo ZWhkci0+ZV90eXBlID09IEVUX0VYRUMgfHwKKyAgICAgIChlaGRyLT5lX3R5cGUgPT0gRVRf RFlOICYmIGVoZHItPmVfZW50cnkgIT0gMCkpIHsKKyNlbHNlCiAgICAgfSBlbHNlIGlmIChl aGRyLT5lX3R5cGUgPT0gRVRfRVhFQykgeworI2VuZGlmCiAJLyogTG9va3MgbGlrZSBhIGtl cm5lbCAqLwogCWlmIChrZnAgIT0gTlVMTCkgewogCSAgICBwcmludGYoImVsZiIgX19YU1RS SU5HKF9fRUxGX1dPUkRfU0laRSkgIl9sb2FkZmlsZToga2VybmVsIGFscmVhZHkgbG9hZGVk XG4iKTsKSW5kZXg6IGNvbmYvTWFrZWZpbGUucG93ZXJwYwo9PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBj b25mL01ha2VmaWxlLnBvd2VycGMJKHJldmlzaW9uIDI3NzQzOCkKKysrIGNvbmYvTWFrZWZp bGUucG93ZXJwYwkod29ya2luZyBjb3B5KQpAQCAtMzcsNiArMzcsMTEgQEAKIAogQ0ZMQUdT Kz0gLW1zb2Z0LWZsb2F0IC1XYSwtbWFueQogCisuaWYgJHtNQUNISU5FX0FSQ0h9ID09ICJw b3dlcnBjNjQiCitDRkxBR1MrPSAtZlBJQworTERGTEFHUys9IC1waWUKKy5lbmRpZgorCiAu aWYgIWVtcHR5KEREQl9FTkFCTEVEKQogQ0ZMQUdTKz0JLWZuby1vbWl0LWZyYW1lLXBvaW50 ZXIKIC5lbmRpZgpJbmRleDogY29uZi9rbW9kLm1rCj09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIGNvbmYv a21vZC5tawkocmV2aXNpb24gMjc3NDM4KQorKysgY29uZi9rbW9kLm1rCSh3b3JraW5nIGNv cHkpCkBAIC0xNzksNiArMTc5LDkgQEAKIAkke09CSkNPUFl9IC0tb25seS1rZWVwLWRlYnVn ICR7RlVMTFBST0d9ICR7LlRBUkdFVH0KIC5lbmRpZgogCisjIERvbid0IGFkZCBhIGZha2Ug ZW50cnkgcG9pbnQgdG8gbW9kdWxlcworX0xERkxBR1MrPSAtZSAwCisKIC5pZiAke19fS0xE X1NIQVJFRH0gPT0geWVzCiAke0ZVTExQUk9HfTogJHtLTU9EfS5rbGQKIAkke0xEfSAtQnNo YXJlYWJsZSAke19MREZMQUdTfSAtbyAkey5UQVJHRVR9ICR7S01PRH0ua2xkCg== --------------080909080605030806020708--