From owner-freebsd-hackers@FreeBSD.ORG Mon Jan 26 01:41:23 2015 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id F0C51E0B for ; Mon, 26 Jan 2015 01:41:23 +0000 (UTC) Received: from shell1.rawbw.com (shell1.rawbw.com [198.144.192.42]) by mx1.freebsd.org (Postfix) with ESMTP id DCD70334 for ; Mon, 26 Jan 2015 01:41:23 +0000 (UTC) Received: from yuri.doctorlan.com (c-50-184-63-128.hsd1.ca.comcast.net [50.184.63.128]) (authenticated bits=0) by shell1.rawbw.com (8.14.9/8.14.9) with ESMTP id t0Q1DEht028337 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Sun, 25 Jan 2015 17:13:14 -0800 (PST) (envelope-from yuri@rawbw.com) X-Authentication-Warning: shell1.rawbw.com: Host c-50-184-63-128.hsd1.ca.comcast.net [50.184.63.128] claimed to be yuri.doctorlan.com Message-ID: <54C594A9.2030802@rawbw.com> Date: Sun, 25 Jan 2015 17:13:13 -0800 From: Yuri User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: freebsd-hackers@FreeBSD.org Subject: 'cacheflush' in FreeBSD ? Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Jan 2015 01:41:24 -0000 LLVM has the function llvm::sys::Memory::InvalidateInstructionCache, that invalidates instruction cache after they allocate memory for the binary code, and before they run it. On Linux this function calls cachflush(2). And on FreeBSD this function is a noop (besides some related valgrind cache call). FreeBSD doesn't have 'cacheflush' system call. So how is instruction cache flushed on FreeBSD? I suspect this is a bug in LLVM that this function is a noop. libexec/rtld-elf also loads binary code in similar way, and it isn't clear from its source code how instruction cache flushing is handled there. Can somebody clarify what is the equivalent of linux cachflush(2), and is this a bug that llvm::sys::Memory::InvalidateInstructionCache is a noop? Yuri