From owner-svn-src-all@freebsd.org Mon Apr 6 22:31:31 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7612627E53B; Mon, 6 Apr 2020 22:31:31 +0000 (UTC) (envelope-from jrtc27@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 48x4yW2LDCz3Cr8; Mon, 6 Apr 2020 22:31:31 +0000 (UTC) (envelope-from jrtc27@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 4B94C2F457; Mon, 6 Apr 2020 22:31:31 +0000 (UTC) (envelope-from jrtc27@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 036MVVhX079572; Mon, 6 Apr 2020 22:31:31 GMT (envelope-from jrtc27@FreeBSD.org) Received: (from jrtc27@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 036MVVvO079571; Mon, 6 Apr 2020 22:31:31 GMT (envelope-from jrtc27@FreeBSD.org) Message-Id: <202004062231.036MVVvO079571@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jrtc27 set sender to jrtc27@FreeBSD.org using -f From: Jessica Clarke Date: Mon, 6 Apr 2020 22:31:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r359672 - head/sys/riscv/riscv X-SVN-Group: head X-SVN-Commit-Author: jrtc27 X-SVN-Commit-Paths: head/sys/riscv/riscv X-SVN-Commit-Revision: 359672 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Apr 2020 22:31:31 -0000 Author: jrtc27 Date: Mon Apr 6 22:31:30 2020 New Revision: 359672 URL: https://svnweb.freebsd.org/changeset/base/359672 Log: riscv: Make sure local hart's icache is synced in pmap_sync_icache The only way to flush the local hart's icache is with a FENCE.I (or an equivalent SBI call); a normal FENCE is insufficient and, for the single-hart case, unnecessary. Reviewed by: jhb (mentor), markj Approved by: jhb (mentor), markj Differential Revision: https://reviews.freebsd.org/D24317 Modified: head/sys/riscv/riscv/pmap.c Modified: head/sys/riscv/riscv/pmap.c ============================================================================== --- head/sys/riscv/riscv/pmap.c Mon Apr 6 22:29:15 2020 (r359671) +++ head/sys/riscv/riscv/pmap.c Mon Apr 6 22:31:30 2020 (r359672) @@ -4335,13 +4335,20 @@ pmap_sync_icache(pmap_t pmap, vm_offset_t va, vm_size_ * RISC-V harts, the writing hart has to execute a data FENCE * before requesting that all remote RISC-V harts execute a * FENCE.I." + * + * However, this is slightly misleading; we still need to + * perform a FENCE.I for the local hart, as FENCE does nothing + * for its icache. FENCE.I alone is also sufficient for the + * local hart. */ sched_pin(); mask = all_harts; CPU_CLR(PCPU_GET(hart), &mask); - fence(); - if (!CPU_EMPTY(&mask) && smp_started) + fence_i() + if (!CPU_EMPTY(&mask) && smp_started) { + fence(); sbi_remote_fence_i(mask.__bits); + } sched_unpin(); }