From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave Hansen Subject: Re: RFC: userspace exception fixups Date: Wed, 7 Nov 2018 12:56:58 -0800 Message-ID: <662fa2c8-c9a8-b2a8-ee8b-92a8a89c0630@intel.com> References: <209cf4a5-eda9-2495-539f-fed22252cf02@intel.com> <9B76E95B-5745-412E-8007-7FAA7F83D6FB@amacapital.net> <1541541565.8854.13.camel@intel.com> <7FF4802E-FBC5-4E6D-A8F6-8A65114F18C7@amacapital.net> <20181106233515.GB11101@linux.intel.com> <20181107000235.GC11101@linux.intel.com> <20181107153452.GB22972@linux.intel.com> <20181107190114.GA26603@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: In-Reply-To: <20181107190114.GA26603@linux.intel.com> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org To: Sean Christopherson , Andy Lutomirski Cc: Jann Horn , Linus Torvalds , Rich Felker , Dave Hansen , Jethro Beekman , Jarkko Sakkinen , Florian Weimer , Linux API , X86 ML , linux-arch , LKML , Peter Zijlstra , nhorman@redhat.com, npmccallum@redhat.com, "Ayoun, Serge" , shay.katz-zamir@intel.com, linux-sgx@vger.kernel.org, Andy Shevchenko , Thomas Gleixner , Ingo Molnar , Borislav Petkov List-Id: linux-arch.vger.kernel.org On 11/7/18 11:01 AM, Sean Christopherson wrote: > Going off comments in similar code related to UMIP, we'd need to figure > out how to handle protection keys. There are two options: 1. Don't depend on the userspace mapping. Do get_user_pages() to find the instruction in the kernel direct map, and use that. 2. Do a WRPKRU that allows read access, do the read, then put PKRU back. This is a pain because of preemption and all that jazz. Right now, we just let the prefetch instruction detection fail if you mark it unreadable with pkeys. Tough cookies, basically. But, that's just the kernel being nice, but you need it for functionality, so it's tougher. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com ([192.55.52.136]:10534 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726932AbeKHG3H (ORCPT ); Thu, 8 Nov 2018 01:29:07 -0500 Subject: Re: RFC: userspace exception fixups References: <209cf4a5-eda9-2495-539f-fed22252cf02@intel.com> <9B76E95B-5745-412E-8007-7FAA7F83D6FB@amacapital.net> <1541541565.8854.13.camel@intel.com> <7FF4802E-FBC5-4E6D-A8F6-8A65114F18C7@amacapital.net> <20181106233515.GB11101@linux.intel.com> <20181107000235.GC11101@linux.intel.com> <20181107153452.GB22972@linux.intel.com> <20181107190114.GA26603@linux.intel.com> From: Dave Hansen Message-ID: <662fa2c8-c9a8-b2a8-ee8b-92a8a89c0630@intel.com> Date: Wed, 7 Nov 2018 12:56:58 -0800 MIME-Version: 1.0 In-Reply-To: <20181107190114.GA26603@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-arch-owner@vger.kernel.org List-ID: To: Sean Christopherson , Andy Lutomirski Cc: Jann Horn , Linus Torvalds , Rich Felker , Dave Hansen , Jethro Beekman , Jarkko Sakkinen , Florian Weimer , Linux API , X86 ML , linux-arch , LKML , Peter Zijlstra , nhorman@redhat.com, npmccallum@redhat.com, "Ayoun, Serge" , shay.katz-zamir@intel.com, linux-sgx@vger.kernel.org, Andy Shevchenko , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Carlos O'Donell , adhemerval.zanella@linaro.org Message-ID: <20181107205658.E_T6LVEWcNOWTvqVzA_Xx7LdBmZcfk8NRcWA5oIje1U@z> On 11/7/18 11:01 AM, Sean Christopherson wrote: > Going off comments in similar code related to UMIP, we'd need to figure > out how to handle protection keys. There are two options: 1. Don't depend on the userspace mapping. Do get_user_pages() to find the instruction in the kernel direct map, and use that. 2. Do a WRPKRU that allows read access, do the read, then put PKRU back. This is a pain because of preemption and all that jazz. Right now, we just let the prefetch instruction detection fail if you mark it unreadable with pkeys. Tough cookies, basically. But, that's just the kernel being nice, but you need it for functionality, so it's tougher.