From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754673AbcGUW1R (ORCPT ); Thu, 21 Jul 2016 18:27:17 -0400 Received: from mga01.intel.com ([192.55.52.88]:18573 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754174AbcGUW1O (ORCPT ); Thu, 21 Jul 2016 18:27:14 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,401,1464678000"; d="scan'208";a="1021590677" Subject: Re: Minor PKRU bug? To: "H. Peter Anvin" , Andy Lutomirski References: <57850D8A.9090801@linux.intel.com> <5791402C.4050300@linux.intel.com> <1CBB681E-737A-4799-ADE6-3CDD904D33D3@zytor.com> Cc: X86 ML , "linux-kernel@vger.kernel.org" From: Dave Hansen Message-ID: <57914C24.3040408@linux.intel.com> Date: Thu, 21 Jul 2016 15:26:44 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: <1CBB681E-737A-4799-ADE6-3CDD904D33D3@zytor.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/21/2016 02:48 PM, H. Peter Anvin wrote: >> >I like it, except that reading just a single byte is a bit silly. >> >OTOH, that's what the current code needs and I see no fundamental >> >reason to change it until there's a real user. >>> > The thing is that we can't actually test this, since there is no > machine on which this code path will ever execute. That concerns me > a bit. I rigged the is_prefetch() check to return true on an instruction that I know causes a sigbus. If I run without protection keys, this setup sits in a never-ending fault loop, which is the behavior that we want from *real* prefetch instructions. But, if I have that instruction be marked execute-only by pkeys, is_prefetch() returns false and the app gets the sigbus, and it *looks* like it came from the (fake) prefetch instruction, which isn't what we want. It's not exactly a real-world test, but it did convince me that the code is doing the right thing.