Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755777AbcJ0JQU (ORCPT ); Thu, 27 Oct 2016 05:16:20 -0400 Received: from merlin.infradead.org ([205.233.59.134]:39922 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753809AbcJ0JQP (ORCPT ); Thu, 27 Oct 2016 05:16:15 -0400 Date: Thu, 27 Oct 2016 11:15:43 +0200 From: Peter Zijlstra To: Pavel Machek Cc: acme@redhat.com, kernel list , mingo@redhat.com, alexander.shishkin@linux.intel.com Subject: Re: Getting interrupt every million cache misses Message-ID: <20161027091543.GJ3102@twins.programming.kicks-ass.net> References: <20161026204748.GA11177@amd> <20161027082801.GE3568@worktop.programming.kicks-ass.net> <20161027084637.GA19469@amd> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161027084637.GA19469@amd> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 823 Lines: 19 On Thu, Oct 27, 2016 at 10:46:38AM +0200, Pavel Machek wrote: > And actually, printk() is not needed, udelay(50msec) is. Reason is, > that DRAM becomes unreliable if about milion cache misses happen in > under 64msec -- so I'd like to slow the system down in such cases to > prevent bug from biting me. > > (Details are here > https://googleprojectzero.blogspot.cz/2015/03/exploiting-dram-rowhammer-bug-to-gain.html > ). Bug is exploitable to get local root; it is also exploitable to > gain local code execution from javascript... so it is rather severe. Cute, a rowhammer defence. So we can do in-kernel perf events too, see for example kernel/watchdog.c:wd_hw_attr and its users. I suppose you want PERF_COUNT_HW_CACHE_MISSES as config, although depending on platform you could use better (u-arch specific) events.