From owner-svn-src-all@freebsd.org Mon Jan 25 14:09:37 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8882AA462F4; Mon, 25 Jan 2016 14:09:37 +0000 (UTC) (envelope-from skra@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 mx1.freebsd.org (Postfix) with ESMTPS id 3DF1BB59; Mon, 25 Jan 2016 14:09:37 +0000 (UTC) (envelope-from skra@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u0PE9aCV013307; Mon, 25 Jan 2016 14:09:36 GMT (envelope-from skra@FreeBSD.org) Received: (from skra@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u0PE9abE013306; Mon, 25 Jan 2016 14:09:36 GMT (envelope-from skra@FreeBSD.org) Message-Id: <201601251409.u0PE9abE013306@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: skra set sender to skra@FreeBSD.org using -f From: Svatopluk Kraus Date: Mon, 25 Jan 2016 14:09:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r294727 - head/sys/arm/arm X-SVN-Group: head 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.20 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, 25 Jan 2016 14:09:37 -0000 Author: skra Date: Mon Jan 25 14:09:35 2016 New Revision: 294727 URL: https://svnweb.freebsd.org/changeset/base/294727 Log: Fix an occasional undefined instruction abort during module loading. Even if data cache maintenance was done by IO code, the relocation fixup process creates dirty cache entries that we must write back before doing icache sync. Reported by: Thiagarajan Venkatasubramanian Reviewed by: ian Modified: head/sys/arm/arm/elf_machdep.c Modified: head/sys/arm/arm/elf_machdep.c ============================================================================== --- head/sys/arm/arm/elf_machdep.c Mon Jan 25 13:35:28 2016 (r294726) +++ head/sys/arm/arm/elf_machdep.c Mon Jan 25 14:09:35 2016 (r294727) @@ -256,7 +256,7 @@ elf_reloc_local(linker_file_t lf, Elf_Ad } int -elf_cpu_load_file(linker_file_t lf __unused) +elf_cpu_load_file(linker_file_t lf) { /* @@ -265,13 +265,25 @@ elf_cpu_load_file(linker_file_t lf __unu * that kernel memory allocations always have EXECUTABLE protection even * when the memory isn't going to hold executable code. The only time * kernel memory holding instructions does need a sync is after loading - * a kernel module, and that's when this function gets called. Normal - * data cache maintenance has already been done by the IO code, and TLB - * maintenance has been done by the pmap code, so all we have to do here - * is invalidate the instruction cache (which also invalidates the - * branch predictor cache on platforms that have one). + * a kernel module, and that's when this function gets called. + * + * This syncs data and instruction caches after loading a module. We + * don't worry about the kernel itself (lf->id is 1) as locore.S did + * that on entry. Even if data cache maintenance was done by IO code, + * the relocation fixup process creates dirty cache entries that we must + * write back before doing icache sync. The instruction cache sync also + * invalidates the branch predictor cache on platforms that have one. */ + if (lf->id == 1) + return (0); +#if __ARM_ARCH >= 6 + dcache_wb_pou((vm_offset_t)lf->address, (vm_size_t)lf->size); + icache_inv_all(); +#else + cpu_dcache_wb_range((vm_offset_t)lf->address, (vm_size_t)lf->size); + cpu_l2cache_wb_range((vm_offset_t)lf->address, (vm_size_t)lf->size); cpu_icache_sync_all(); +#endif return (0); }