From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90192C433E7 for ; Fri, 16 Oct 2020 11:12:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3828C2145D for ; Fri, 16 Oct 2020 11:12:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="MFRxAjkW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406806AbgJPLMp (ORCPT ); Fri, 16 Oct 2020 07:12:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406802AbgJPLMp (ORCPT ); Fri, 16 Oct 2020 07:12:45 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C61E1C061755; Fri, 16 Oct 2020 04:12:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=wAy2lh21ULGhfKu1lWKdjXSaLAVUcJ27z4IflXzPX1A=; b=MFRxAjkWFnE13dfJ8D+zIoix/z nIt9L4wOVDn8LU0pJX766VrtXGM6nVgouteYlsw/9lmgyGsOGIPNxD2iKWoO31fYbwO7lyCa+n63K r0PTSyJ8GHYfCGvXK3CZyEjU0Uu84qddnuxSHPLsXCz66lLVy7N0i+x45gcUsroopk4bC/41M3MOE qhe7v1QkSXOTyg0Uq+j/RyXAVm+8kagUs7e9F9+awmsnqOS8yvhgJHQZcSmDAdwZoz/shUV4XEcYM 1A8F/BCloojyeLlbnnSW8LF5mmuf3NpoZg97gfqYsNry9dyernrphRaVWcuoeF2Ns9dJfry1BC3gL u0ro6j5Q==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kTNeu-00032M-82; Fri, 16 Oct 2020 11:12:28 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id EB4833011E6; Fri, 16 Oct 2020 13:12:26 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id D315A2011673A; Fri, 16 Oct 2020 13:12:26 +0200 (CEST) Date: Fri, 16 Oct 2020 13:12:26 +0200 From: Peter Zijlstra To: Dave Hansen Cc: ira.weiny@intel.com, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Andy Lutomirski , Fenghua Yu , x86@kernel.org, Dave Hansen , Dan Williams , Andrew Morton , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH RFC V3 4/9] x86/pks: Preserve the PKRS MSR on context switch Message-ID: <20201016111226.GN2611@hirez.programming.kicks-ass.net> References: <20201009194258.3207172-1-ira.weiny@intel.com> <20201009194258.3207172-5-ira.weiny@intel.com> <429789d3-ab5b-49c3-65c3-f0fc30a12516@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <429789d3-ab5b-49c3-65c3-f0fc30a12516@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org On Tue, Oct 13, 2020 at 11:31:45AM -0700, Dave Hansen wrote: > > +/** > > + * It should also be noted that the underlying WRMSR(MSR_IA32_PKRS) is not > > + * serializing but still maintains ordering properties similar to WRPKRU. > > + * The current SDM section on PKRS needs updating but should be the same as > > + * that of WRPKRU. So to quote from the WRPKRU text: > > + * > > + * WRPKRU will never execute transiently. Memory accesses > > + * affected by PKRU register will not execute (even transiently) > > + * until all prior executions of WRPKRU have completed execution > > + * and updated the PKRU register. > > + */ > > +void write_pkrs(u32 new_pkrs) > > +{ > > + u32 *pkrs; > > + > > + if (!static_cpu_has(X86_FEATURE_PKS)) > > + return; > > + > > + pkrs = get_cpu_ptr(&pkrs_cache); > > + if (*pkrs != new_pkrs) { > > + *pkrs = new_pkrs; > > + wrmsrl(MSR_IA32_PKRS, new_pkrs); > > + } > > + put_cpu_ptr(pkrs); > > +} > > > > It bugs me a *bit* that this is being called in a preempt-disabled > region, but we still bother with the get/put_cpu jazz. Are there other > future call-sites for this that aren't in preempt-disabled regions? So the previous version had a useful comment that got lost. This stuff needs to fundamentally be preempt disabled, so it either needs to explicitly do so, or have an assertion that preemption is indeed disabled.