Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751874AbbEGPdL (ORCPT ); Thu, 7 May 2015 11:33:11 -0400 Received: from mail-wi0-f175.google.com ([209.85.212.175]:33132 "EHLO mail-wi0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751818AbbEGPdH (ORCPT ); Thu, 7 May 2015 11:33:07 -0400 Date: Thu, 7 May 2015 17:33:02 +0200 From: Ingo Molnar To: Dave Hansen Cc: Ingo Molnar , linux-kernel@vger.kernel.org, Andy Lutomirski , Borislav Petkov , Fenghua Yu , "H. Peter Anvin" , Linus Torvalds , Oleg Nesterov , Thomas Gleixner Subject: Re: [PATCH 084/208] x86/fpu: Rename xsave.header::xstate_bv to 'xfeatures' Message-ID: <20150507153302.GA20993@gmail.com> References: <1430848300-27877-1-git-send-email-mingo@kernel.org> <1430848300-27877-6-git-send-email-mingo@kernel.org> <554904A6.8040503@linux.intel.com> <20150505181613.GA28562@gmail.com> <55490B1F.3080409@linux.intel.com> <20150506061603.GA13720@gmail.com> <554A5D23.2030405@linux.intel.com> <20150507122209.GB15656@gmail.com> <554B7DAA.3040606@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <554B7DAA.3040606@linux.intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2814 Lines: 73 * Dave Hansen wrote: > > Btw., regarding XCR0.PKRU: that enables 'Protection Keys' in the > > PTE format. What's the main purpose of these keys? They seem to > > duplicate the read/write bits in the PTE, with the exception that > > they don't impact instruction fetches. So is this used to allow > > user-space to execute but otherwise not read instructions? > > > > Or some other purpose I missed? > > You can change the permissions of a given key with writes to the > register without changing the PTE. No TLB shootdown, plus the > permission changes are local to the CPU thread. interesting ... where are we doing that? kmap_atomic() is the only place I can think of in the kernel, but there we are already skipping the TLB shootdown by doing an INVLPG. > I have patches today if you're interested. I'm always interested in new CPU features ;-) > ... > >> We'd need to determine which fields are in the init state before we > >> do an xsaves. > > > > Why? I don't think that's necessary. > > "If RFBM[i] = 0, XSTATE_BV[i] is written as 0." Yes, that's natural: RFBM is the combination of XCR0 (constant) and the 'instruction mask' (constant as well) - i.e. it's a wide bitmask including all our xfeatures - essentially 'xfeatures_mask' (in tmp.fpu). > We need to pull XSTATE_BV in to the instruction mask when doing an > XSAVE* if our RFBM has bits unset that *are* set in XSTATE_BV. > Otherwise, we'll destroy the bits at XSAVE* time. But why would our RFBM be narrower than any possible XSTATE_BV we handle? Our XCR0 is at the max. Also, the XSTATE_BV value of the save area is immaterial when we do an XSAVES: all the state is in CPU registers, we want to save it to the save area. XSAVES will write it for us. > It's not a problem today because the instruction mask is always -1, > so it always has every bit set that *MIGHT* be set in XSTATE_BV. Yes. And why would we ever want to narrow it? > As for the whole bit 63 thing... It's possible and valid to have a > XCOMP_BV[62:0]=0 because the instruction mask only contained bits > that were unset in XCR0|IA32_XSS. You need bit 63 to tell you which > format you are using. So basically if you request an XSAVES to ... write nothing (XCR0 AND instruction mask is 0), then it will represent this as 0|1<<63 in XCOMP_BV? In that case it does not matter whether the area is compacted or standard: nothing was saved and nothing will have to be restored, only the xsave header area will be accessed. Am I missing something? Thanks, Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/