From owner-freebsd-ppc@freebsd.org Fri Jun 7 10:21:58 2019 Return-Path: Delivered-To: freebsd-ppc@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C97D015A85A3 for ; Fri, 7 Jun 2019 10:21:58 +0000 (UTC) (envelope-from marklmi@yahoo.com) Received: from sonic315-15.consmr.mail.bf2.yahoo.com (sonic315-15.consmr.mail.bf2.yahoo.com [74.6.134.125]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ADD6E6DF90 for ; Fri, 7 Jun 2019 10:21:57 +0000 (UTC) (envelope-from marklmi@yahoo.com) X-YMail-OSG: jzMihPoVM1n4ta6LOQZqwQrO6bE6qNrrwdL0rDZGi8MvNGCaGUQgZm_pJqyxCoQ 7047RZ1CQoJuUnbO9XqTO4dk44coMd.JWp4hE8U5_WVALH4XasghkInZyBa9eR84e0nIirPHQtZi nJCwVL95WyiuidypsFkJvQewwaNYhfIwlfcltQtj8D4xJ6Q1Uy7IvAVxCAefpclrFD5XmDkasjGk Wwe86h_Mg294KmDjtpH0tnEeLdM29A32fsRnB5SHyLPz772YJenr1hg4N498gEGo4Q0Y3qZgU9Tr Z.NyOkk0CrpIpo1iz9mfu7Fa6e_ky6Qp.RVYYDyXJHgFXKkR_P6jFakKDpQAmq7ay_2BVURekpqB RDKdgHfrBhL2r1GM48akwq1JaVoEF4_ReVzH.KKexPs6qMiynaO1b8gx842KGPj_KXJ.WaJOoIRm ePhxbOl3Ag_25Arn._7lEDPjrMobNpFiJeIVoe_YCZ0bZYtA52ZHkk0EWcpjZgGIS4u_uSTqpYhg SBZsc2KnldH2zjeFDb6QKDtjmmzSnm.aPYHrdJQiY2XHPlX11G8uPLft5RVUAZSLpsQ5EgsOF_pS Qsz8XXzznrwg7bhgcVboWtDsfxms.RqrOmqQa3kHy.XakOejvnUbSm9SApNaVLGmHwDLerTltea1 tZrFVMGLtvNW5tyHa1fmHdTklQtfkuZMR7Af41i67eJL1bSns9iGAUeA5ZoMcOdjL3gID4RkGuw. bc.4UF_TIyLEZ.faY5Ayy9il4twPN6pMiPv8qdjfTKe72VZuIyCdWZoOi1YIVCyzIkTtQHiVnCvX mG4X6eApX03MvUWZuMaP8iM8gLOc3mmlYq13Fmzb7fuSCQ8DcxP1JarPKMQvbDHSy.a7x6xWBLg4 FUASx7oKgq._ndDbMBKrzQXXT.qFC_B8ceMbhXyieKcqVzTqbvHg6MpAFUqxuBPcImKizqAcaXLj .5gSeM76TQ0wGK2FilhW.SGL4mqckwfyatDpbbU2xwHc3MGKMxj5MGHh4Dk_eMSXTprMaxDrB5ri Vh6GVaM6r1Sb1G0YIsZ2vlRXYxiAfSaRFqtOuo1DbE6qGNT6_NJhuQ4.xQiWZ28LNl5RlqkVUq_4 7VWwkJDSHsaCeNGnnfA2x6xxr3GYZzQXuOdXbfp.eSpYEfI.vDXdwhKSYRQaitw3aUh44V1DyB0s ndkKYxDrPU.JzVhdPCfY5QX2vziPCo4gzLj_C8HCJjxjbT891J9QdqzXn_Jx80w-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic315.consmr.mail.bf2.yahoo.com with HTTP; Fri, 7 Jun 2019 10:21:51 +0000 Received: from c-67-170-167-181.hsd1.or.comcast.net (EHLO [192.168.1.113]) ([67.170.167.181]) by smtp429.mail.bf1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 9d9a361610f42d057fc0bafb86364161; Fri, 07 Jun 2019 10:21:47 +0000 (UTC) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: 32-bit powerpc's elf_reloc_internal has no support for R_PPC_JMP_SLOT but clang with devel/powerpc64-binutils uses such for building kernel modules From: Mark Millard In-Reply-To: Date: Fri, 7 Jun 2019 03:21:44 -0700 Cc: FreeBSD PowerPC ML Content-Transfer-Encoding: quoted-printable Message-Id: <52B6890B-1514-424B-AC4F-B6419F8CBC79@yahoo.com> References: To: Justin Hibbits X-Mailer: Apple Mail (2.3445.104.11) X-Rspamd-Queue-Id: ADD6E6DF90 X-Spamd-Bar: +++ X-Spamd-Result: default: False [3.37 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_SPF_ALLOW(-0.20)[+ptr:yahoo.com]; MV_CASE(0.50)[]; FREEMAIL_FROM(0.00)[yahoo.com]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_ALL(0.00)[]; MX_GOOD(-0.01)[cached: mta6.am0.yahoodns.net]; DKIM_TRACE(0.00)[yahoo.com:+]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[yahoo.com,reject]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[yahoo.com]; ASN(0.00)[asn:26101, ipnet:74.6.128.0/21, country:US]; MID_RHS_MATCH_FROM(0.00)[]; DWL_DNSWL_NONE(0.00)[yahoo.com.dwl.dnswl.org : 127.0.5.0]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[yahoo.com:s=s2048]; FROM_HAS_DN(0.00)[]; NEURAL_SPAM_SHORT(0.69)[0.687,0]; MIME_GOOD(-0.10)[text/plain]; IP_SCORE(1.61)[ip: (5.37), ipnet: 74.6.128.0/21(1.53), asn: 26101(1.22), country: US(-0.06)]; NEURAL_SPAM_MEDIUM(0.83)[0.833,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_SPAM_LONG(0.74)[0.742,0]; RCVD_IN_DNSWL_NONE(0.00)[125.134.6.74.list.dnswl.org : 127.0.5.0] X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Jun 2019 10:21:59 -0000 On 2019-Jun-6, at 19:41, Justin Hibbits = wrote: > On Thu, Jun 6, 2019 at 8:06 PM Mark Millard via freebsd-ppc > wrote: >>=20 >>=20 >> /usr/src/sys/powerpc/powerpc/elf64_machdep.c has: >>=20 >> static int >> elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void = *data, >> int type, int local, elf_lookup_fn lookup) >> { >> . . . >> case R_PPC_JMP_SLOT: /* function descriptor copy */ >> lookup(lf, symidx, 1, &addr); >> #if !defined(_CALL_ELF) || _CALL_ELF =3D=3D 1 >> memcpy(where, (Elf_Addr *)addr, 3*sizeof(Elf_Addr)); >> #else >> *where =3D addr; >> #endif >> __asm __volatile("dcbst 0,%0; sync" :: "r"(where) : = "memory"); >> break; >>=20 >> . . . >>=20 >> But /usr/src/sys/powerpc/powerpc/elf32_machdep.c 's = elf_reloc_internal >> does not have any R_PPC_JMP_SLOT case in its code. >>=20 >> Yet, from using clang as the system compiler for targeting 32-bit = powerpc, >> readelf -asW /boot/kernel/if_gem.ko shows the likes of: >>=20 >> Relocation section with addend (.rela.plt): >> r_offset r_info r_type st_value st_name + r_addend >> 00018328 00000215 R_PPC_JMP_SLOT 00000000 if_maddr_runlock + 0 >> 00018330 00000315 R_PPC_JMP_SLOT 00000000 mii_mediachg + 0 >> 00018338 00000415 R_PPC_JMP_SLOT 00000000 m_freem + 0 >> 00018340 00000515 R_PPC_JMP_SLOT 00000000 device_get_softc + 0 >> 00018348 00000715 R_PPC_JMP_SLOT 00000000 device_set_desc + 0 >> 00018350 00000815 R_PPC_JMP_SLOT 00000000 printf + 0 >> 00018358 00000b15 R_PPC_JMP_SLOT 00000000 ether_crc32_le + 0 >> 00018360 00000e15 R_PPC_JMP_SLOT 00000000 bpf_mtap + 0 >> . . . >>=20 >> # file /boot/kernel/if_gem.ko >> /boot/kernel/if_gem.ko: ELF 32-bit MSB shared object, PowerPC or = cisco 4500, version 1 (FreeBSD), dynamically linked, = BuildID[sha1]=3D013a358835fddcd6bbb82d35a6ce36243eccb743, not stripped >>=20 >> So, naturally, module loading such (manual or automatic) >> is a problem for the 32-bit powerpc context. >>=20 >> The context was head -r347549 . >>=20 >> =3D=3D=3D >> Mark Millard >> marklmi at yahoo.com >> ( dsl-only.net went >> away in early 2018-Mar) >=20 > Can you try this patch? Untested, just compiled. It's essentially a > copy of the ELFv2 part of the elf64_machdep bit you posted above. >=20 > - Justin >=20 > diff --git a/sys/powerpc/powerpc/elf32_machdep.c > b/sys/powerpc/powerpc/elf32_machdep.c > index 11c14671d0b..219a61363cd 100644 > --- a/sys/powerpc/powerpc/elf32_machdep.c > +++ b/sys/powerpc/powerpc/elf32_machdep.c > @@ -295,6 +295,12 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr > relocbase, const void *data, > *where =3D elf_relocaddr(lf, relocbase + addend); > break; >=20 > + case R_PPC_JMP_SLOT: > + lookup(lf, symidx, 1, &addr); > + *where =3D addr; > + __asm __volatile("dcbst 0,%0; sync" :: "r"(where) : = "memory"); > + break; > + > default: > printf("kldload: unexpected relocation type %d\n", > (int) rtype); [I was away from the PowerMac, thus the delay.] Other things that I've not figured out block use of a clang based kernel for my oontext. So this was a test of a gcc-4.2.1-based debug kernel loading a clang built filemon.ko (also from a debug build). This was done via the loader prompt: Ok unload Ok load /boot/kerdbg/kernel Ok boot At the time /boot/kernel/* was from a clang-based build. The above context still uses /boot/kernel/ for finding modules, not /boot/kerdbg/ . Attempting kldload filemon.ko after booting (as an example of something with R_PPC_JMP_SLOT involved) caused a system crash via an illegal instruction: (typed from a picture of the screen) exception =3D 0x700 (program) srr0 =3D 0xdd3a28b0 srr1 =3D 0x89032 current msr=3D 0x9032 ls =3D 0xdd38fcd8 frame=3D 0x24f23a0 pid =3D 1247, comm =3D kldload . . . kdb_backtrace+0x5c vpanic+0x1f8 panic+0x54 trap_fatal+0x238 trap+0xca8 powerpc_interrupt+0x248 kernel PGM trap by _GLOBAL_OFFSET_TABLE+0x13c: srr1=3D0x89032 r1=3D0xe1d3e5d0 cr=3D0x8000f044 xer=3D0x2000000 ctr=3D0xdd38fcfc = frame=3D0xe1d3e518 0xca2af4 module_register_init+0xb4 linker_load_module_+0x8dc kern_kldload+0x138 sys_kldload+0x80 trap+0x54c powerpc_interrupt+0x248 user SC trap by 0x418a44f8: srr1=3D0xf032 r1=3D0xffffd750 cr=3D0x44222800 xer=3D0 ctr=3D0x418a44f0 = frame=3D0xe1d3ea48 A better test would be not from my experimental environment, say matching some artifact build, other than haivng your patch. But if I do that it will not be tonight/this-morning. I do not expect a different result. =3D=3D=3D Mark Millard marklmi at yahoo.com ( dsl-only.net went away in early 2018-Mar)