From owner-freebsd-ppc@freebsd.org Sat Mar 30 07:06:02 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 6284215681CE for ; Sat, 30 Mar 2019 07:06:02 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 06F0E72868 for ; Sat, 30 Mar 2019 07:06:02 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by freefall.freebsd.org (Postfix) id EC1341F2EF; Sat, 30 Mar 2019 07:06:01 +0000 (UTC) Delivered-To: powerpc@localmail.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mx1.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by freefall.freebsd.org (Postfix) with ESMTPS id CF9991F2EE for ; Sat, 30 Mar 2019 07:06:01 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.ysv.freebsd.org (mxrelay.ysv.freebsd.org [IPv6:2001:1900:2254:206a::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.ysv.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7172072866 for ; Sat, 30 Mar 2019 07:06:01 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.ysv.freebsd.org (Postfix) with ESMTPS id A722C1924D for ; Sat, 30 Mar 2019 07:06:00 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id x2U760Rs055910 for ; Sat, 30 Mar 2019 07:06:00 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id x2U7601b055907 for powerpc@FreeBSD.org; Sat, 30 Mar 2019 07:06:00 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: powerpc@FreeBSD.org Subject: [Bug 232387] head -r345558 (updated): system crash during kldload if_epair on powerpc64 (for more modern buildworld buildkernel toolchain experiments) Date: Sat, 30 Mar 2019 07:05:59 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: vimage X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: marklmi26-fbsd@yahoo.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: powerpc@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-Rspamd-Queue-Id: 06F0E72868 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.99 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.99)[-0.988,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,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: Sat, 30 Mar 2019 07:06:02 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D232387 --- Comment #16 from Mark Millard --- (In reply to Mark Millard from comment #15) I added printing &DPCPU_NAME(epair_dpcpu) to: static void epair_dpcpu_init(void) This and ddb use gives the following information for the use of: #define _DPCPU_PTR(b, n) \ (__typeof(DPCPU_NAME(n))*)((b) + (uintptr_t)&DPCPU_NAME(n)) . . . #define DPCPU_ID_PTR(i, n) _DPCPU_PTR(dpcpu_off[(i)], n) (Typed from a picture:) &DPCPU_NAME(epair_dpcpu)=3D0xe00000008fcee810 show dpcpu_off in ddb shows: dpcpu_off[0]=3D0x1ffffffffecf6980 dpcpu_off[1]=3D0x2000000002adc980 dpcpu_off[2]=3D0x2000000002ada980 dpcpu_off[3]=3D0x2000000002ad8980 The failing virtual address was reported as: virtual address =3D 0x8e9e5198 . . . cpuid =3D 0 Then, checking: 0x1ffffffffecf6980+0xe00000008fcee810=3D=3D0x8e9e5190 so 0x8 short. But: addi r3,r22,24 bl <0000001b.plt_call._mtx_init> and: <_mtx_init+0x20> mr r30,r3 . . . <_mtx_init+0x60> addi r3,r30,-24 <_mtx_init+0x64> clrldi r7,r6,32 <_mtx_init+0x68> mr r6,r8 <_mtx_init+0x6c> bl and: stw r4,8(r3) So 0x8e9e5190+24-24+8=3D=3D0x8e9e5198 (the failure address). It appears to me that the dpcpu_off[i] figures are expected to convert 0xc???_????_????_???? type (direct-map) addresses to 0xe???_????_????_???? addresses but &DPCPU_NAME(epair_dpcpu) already was a 0xe???_????_????_???? type of address. The result overflowed/wrapped/truncated and was invalid. This looks likely to be a problem for any kldload'd .ko that uses a DPCPU_DEFINE and DPCPU_ID_PTR similarly to (showing my printf addition as well): struct epair_dpcpu { struct mtx if_epair_mtx; /* Per-CPU locking. */ int epair_drv_flags; /* Per-CPU ``hw'' drv flags= . */ struct eid_list epair_ifp_drain_list; /* Per-CPU list of ifps with * data in the ifq. */ }; DPCPU_DEFINE(struct epair_dpcpu, epair_dpcpu); static void epair_dpcpu_init(void) { struct epair_dpcpu *epair_dpcpu; struct eid_list *s; u_int cpuid; printf("epair_dpcpu_init: &DPCPU_NAME(epair_dpcpu)=3D%p\n", &DPCPU_NAME(epair_dpcpu)); CPU_FOREACH(cpuid) { epair_dpcpu =3D DPCPU_ID_PTR(cpuid, epair_dpcpu); /* Initialize per-cpu lock. */ EPAIR_LOCK_INIT(epair_dpcpu); . . . --=20 You are receiving this mail because: You are the assignee for the bug.=