From owner-svn-src-head@freebsd.org Fri Mar 22 01:43:32 2019 Return-Path: Delivered-To: svn-src-head@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 6AE001555D5A; Fri, 22 Mar 2019 01:43:32 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::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.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0AC4089C2E; Fri, 22 Mar 2019 01:43:32 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DA80A19819; Fri, 22 Mar 2019 01:43:31 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2M1hVhl052954; Fri, 22 Mar 2019 01:43:31 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2M1hVvr052953; Fri, 22 Mar 2019 01:43:31 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201903220143.x2M1hVvr052953@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Fri, 22 Mar 2019 01:43:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345402 - head/sys/powerpc/aim X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: head/sys/powerpc/aim X-SVN-Commit-Revision: 345402 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 0AC4089C2E X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.969,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Mar 2019 01:43:32 -0000 Author: jhibbits Date: Fri Mar 22 01:43:31 2019 New Revision: 345402 URL: https://svnweb.freebsd.org/changeset/base/345402 Log: powerpc64: Handle the modern (2.05+) implementaiton of tlbie By happenstance gcc4 puts 'vpn' into r0 in all uses of TLBIE(), but modern gcc does not. Also, the single-argument form of tlbie zeros all unused arguments, making the modern tlbie instruction use r0 as the RS field (LPID). The vpn argument has the bottom 12 bits cleared (the input having been left-shifted by 12 bits), which just so happens, on the POWER9 and previous incarnations, to be the number of LPID bits supported. With those bits being zero, the instruction: tlbie r0, r0 will invalidate the VPN in r0, in LPAR 0 (ignoring the upper bits of r0 for the RS field). One build with gcc8 yields: tlbie r9, r0 with r0 having arbitrary contents, not equal to r9. This leads to strange crashes, behaviors, and panics, due to the requested TLB entry not actually being invalidated. As the moea64_native must work on both old and new, we explicitly zero out r0 so that it can work with only the single argument, built with base gcc and modern gcc. isa3_hashtb takes a different approach, encoding the two-argument form, soas not to explicitly clobber r0, and instead let the compiler decide. Reported by: Brandon Bergren Tested by: Brandon Bergren MFC after: 1 week Modified: head/sys/powerpc/aim/isa3_hashtb.c head/sys/powerpc/aim/moea64_native.c Modified: head/sys/powerpc/aim/isa3_hashtb.c ============================================================================== --- head/sys/powerpc/aim/isa3_hashtb.c Fri Mar 22 01:42:27 2019 (r345401) +++ head/sys/powerpc/aim/isa3_hashtb.c Fri Mar 22 01:43:31 2019 (r345402) @@ -139,7 +139,8 @@ TLBIE(uint64_t vpn) { vpn <<= ADDR_PIDX_SHFT; - __asm __volatile("tlbie %0" :: "r"(vpn) : "memory"); + __asm __volatile(".long 0x7c000264 | (%0 << 11) | (%1 << 21)" + :: "r"(vpn), "r"(0) : "memory"); __asm __volatile("eieio; tlbsync; ptesync" ::: "memory"); } Modified: head/sys/powerpc/aim/moea64_native.c ============================================================================== --- head/sys/powerpc/aim/moea64_native.c Fri Mar 22 01:42:27 2019 (r345401) +++ head/sys/powerpc/aim/moea64_native.c Fri Mar 22 01:43:31 2019 (r345402) @@ -156,7 +156,7 @@ TLBIE(uint64_t vpn) { vpn &= ~(0xffffULL << 48); #ifdef __powerpc64__ - __asm __volatile("tlbie %0" :: "r"(vpn) : "memory"); + __asm __volatile("li 0, 0; tlbie %0" :: "r"(vpn) : "0","memory"); __asm __volatile("eieio; tlbsync; ptesync" ::: "memory"); #else vpn_hi = (uint32_t)(vpn >> 32);