Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2431189pxu; Fri, 18 Dec 2020 13:07:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwLumq+jXiH8Ibnp8NiqwmXL64woq9DANPJbg91rxk/4Dt9BcOBADJbaL6o77sqJuRvKmTw X-Received: by 2002:a17:906:314f:: with SMTP id e15mr5816386eje.496.1608325670746; Fri, 18 Dec 2020 13:07:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608325670; cv=none; d=google.com; s=arc-20160816; b=NZ+EZNssbAA00DHo0TR2eGssTEpCoTqE4jhkH9AhYZc4hAmsKPCZlLyzKIch8iQIQb PJ5KOl/mTjxaogr8dkPXEdPN8l4rjd/XDnFcrbc/6+D5OEMnVGzQdM7uUztDv6pJr7d4 NPU+IC6N800BTfv5DNq2APThRCU1Ahi9IaBXKthyTUH0ln3jA8bBQ7IAVm0oAcSVPuPS fhDFgCDmNhHoGYQc1ZWHRmBPszSU1owrMf7LGXdAzPfrU9Rktw5U6BrQ3QEALP04YzOl qIeXUbXIlZyOXOvi98MyhDcCd4JTxTyonxxCsRwwZFFmfJ5qOXtFy+9H+AA4DTT97Bga ixtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=5KbSIN55suX89YOBcIXDM5LxH+O6LLG2triQiwJQEiw=; b=gAYII3G252S6vpYbaw7DLbrM82743zziGZmGPaNkGX0LDq7QMctU7w4wO+qybdZJd9 UzLSabPFO9jA16EbW4behtoHGirfqR1x8wRV1/uaz0/gLq18yVwx0RlJixwdjKY3TZ/Q Qec6cA+NcSHqgmhEUwMdwN9RqW6+BZtL7oiuJjNFRTRcJyBJKIo6AWz4+PZ4YkpWbnrq MbFTAlkeSBQj0mHU0NBKyBrLt4O2nig5LtjEs05KkDSh264HSfVdsELEAMINOGmriw2C 2v1sxoDBBv9Micu+srLejQTZweydN1x1/xit1hQe1UnOSfYETVMQ/otBgJ+YKpWRCQBN c9iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="lxq0Z0/2"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw14si6479367edb.289.2020.12.18.13.07.27; Fri, 18 Dec 2020 13:07:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="lxq0Z0/2"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725966AbgLRVHJ (ORCPT + 99 others); Fri, 18 Dec 2020 16:07:09 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:54938 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725843AbgLRVHJ (ORCPT ); Fri, 18 Dec 2020 16:07:09 -0500 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1608325586; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=5KbSIN55suX89YOBcIXDM5LxH+O6LLG2triQiwJQEiw=; b=lxq0Z0/2O14CTwirAq+bb6fuW6UqCM6iqC8qzHXHLrZfy+sDRGOF/0How3eiSpYti5hyy1 PPjKqCf3MKtrf7IQYaOFjyuXT4RetV9r+fcaYWFfkisBByb0n0d6/Oz8hpeuclU2liQ+zF b9UZig1XjIDtkpFQUGed0hJ9FSlPU8zI3iu4ngwn8ZXccAFZTXAmD+IAi9lNZOjDIv05V6 0hdumIZXflEtEFfoAyzhRw6zWRPLAlhR2F6ZwRzJTud4+jkuGbq92iptCpTRZzgpYytBBv +1bhFOhdCmZjOEKl9Odfaojy3oH3jv/xMNUCbWSAye7FSC970xo3MgIOPjbxaw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1608325586; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=5KbSIN55suX89YOBcIXDM5LxH+O6LLG2triQiwJQEiw=; b=BngWZDtOpkOjDlsMazPLISfJ/Wv/jD0wklYW3MtSj1b941oW4rqP5E8tjXsT4f09a0QbS1 JhvFAp2tpTn1qMBA== To: Dan Williams Cc: "Weiny\, Ira" , Ingo Molnar , Borislav Petkov , Andy Lutomirski , Peter Zijlstra , Dave Hansen , Fenghua Yu , X86 ML , Linux Kernel Mailing List , Andrew Morton , Linux Doc Mailing List , linux-nvdimm , Linux MM , linux-kselftest@vger.kernel.org, Greg KH Subject: Re: [PATCH V3 04/10] x86/pks: Preserve the PKRS MSR on context switch In-Reply-To: References: <20201106232908.364581-1-ira.weiny@intel.com> <20201106232908.364581-5-ira.weiny@intel.com> <871rfoscz4.fsf@nanos.tec.linutronix.de> <87mtycqcjf.fsf@nanos.tec.linutronix.de> <878s9vqkrk.fsf@nanos.tec.linutronix.de> Date: Fri, 18 Dec 2020 22:06:24 +0100 Message-ID: <875z4yrfhr.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 18 2020 at 11:20, Dan Williams wrote: > On Fri, Dec 18, 2020 at 5:58 AM Thomas Gleixner wrote: > [..] >> 5) The DAX case which you made "work" with dev_access_enable() and >> dev_access_disable(), i.e. with yet another lazy approach of >> avoiding to change a handful of usage sites. >> >> The use cases are strictly context local which means the global >> magic is not used at all. Why does it exist in the first place? >> >> Aside of that this global thing would never work at all because the >> refcounting is per thread and not global. >> >> So that DAX use case is just a matter of: >> >> grant/revoke_access(DEV_PKS_KEY, READ/WRITE) >> >> which is effective for the current execution context and really >> wants to be a distinct READ/WRITE protection and not the magic >> global thing which just has on/off. All usage sites know whether >> they want to read or write. > > I was tracking and nodding until this point. Yes, kill the global / > kmap() support, but if grant/revoke_access is not integrated behind > kmap_{local,atomic}() then it's not a "handful" of sites that need to > be instrumented it's 100s. Are you suggesting that "relaxed" mode > enforcement is a way to distribute the work of teaching driver writers > that they need to incorporate explicit grant/revoke-read/write in > addition to kmap? The entire reason PTE_DEVMAP exists was to allow > get_user_pages() for PMEM and not require every downstream-GUP code > path to specifically consider whether it was talking to PMEM or RAM > pages, and certainly not whether they were reading or writing to it. kmap_local() is fine. That can work automatically because it's strict local to the context which does the mapping. kmap() is dubious because it's a 'global' mapping as dictated per HIGHMEM. So doing the RELAXED mode for kmap() is sensible I think to identify cases where the mapped address is really handed to a different execution context. We want to see those cases and analyse whether this can't be solved in a different way. That's why I suggested to do a warning in that case. Also vs. the DAX use case I really meant the code in fs/dax and drivers/dax/ itself which is handling this via dax_read_[un]lock. Does that make more sense? Thanks, tglx