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.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 0F628C4361B for ; Fri, 18 Dec 2020 21:58:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 62F7823B7B for ; Fri, 18 Dec 2020 21:58:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 62F7823B7B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 711C66B005C; Fri, 18 Dec 2020 16:58:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C3566B005D; Fri, 18 Dec 2020 16:58:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B2AB6B0068; Fri, 18 Dec 2020 16:58:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0242.hostedemail.com [216.40.44.242]) by kanga.kvack.org (Postfix) with ESMTP id 42E366B005C for ; Fri, 18 Dec 2020 16:58:23 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 0E3B4443F for ; Fri, 18 Dec 2020 21:58:23 +0000 (UTC) X-FDA: 77607767286.26.pull57_2502e1427440 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id E40FE180BE987 for ; Fri, 18 Dec 2020 21:58:22 +0000 (UTC) X-HE-Tag: pull57_2502e1427440 X-Filterd-Recvd-Size: 6037 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) by imf15.hostedemail.com (Postfix) with ESMTP for ; Fri, 18 Dec 2020 21:58:21 +0000 (UTC) Received: by mail-ej1-f44.google.com with SMTP id q22so5352429eja.2 for ; Fri, 18 Dec 2020 13:58:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=awSkLxPxfKKMYWXrPvJO5HFC6rX6G+L4B8C1Llf9W6k=; b=hLBV/ED7BfeJwzOqpNCmMYChlwoFiY2KhYRYAh9YAvNmhTCp5Rl5vOtjXE5lcygy6P xGW8sekB6mt/nykunGGg68jfMt3kl8nI0XjHiLHAw/Jl44bdjco/2PBUvN8fBn5kDwON gE1GN8Dxfx9SDSEZCsA/rAzWdaPWuRJucgTnKWiNxbhGi9kV9JTK9FfS9yflDIleezEV bNojTL0m3+dL9+Bw8KoCwccFevhvpilw/9ImOHE0xnU4wNOK7nlI50q9eVjVevAIbBH7 jimQcsulIbzCWqGNVfNFRrbVZ+LrmM/3NVINZEg9b1lVwrhdpKkWdJLhFQIZGVrqeCxa DBdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=awSkLxPxfKKMYWXrPvJO5HFC6rX6G+L4B8C1Llf9W6k=; b=UzoIHo4EPaVmBSVGB92g0XrAPh22ijIMEmH3jDl8vX75Vzwc46x+EOvXXz/O0sox1q LmsXM+8qpJq7Af+XPjYMesZkFha4t7PYzzJsjwVW6WgWWOG64Ql8UCqE8a1EjmSSvUgX HUKhcKNyVGDqT2egDo8VTJRmKobAyzDTJrgKzef9+hv7KLgYM5tr7PdieSSG17wXtY6t 81x4A8ZXIEy3YD1rzMeRJPFjTysEaZzptxdDIfIYqa9XRLDH9GN8D6qB6SWGgbF3SWyO CKdQA034Txi+YFFH0bHIKnzIvULHPlTtL+OexI5NI8AzpwW249X55lyJZtix5HpDmjX9 MUEw== X-Gm-Message-State: AOAM533Nw3iWGTGWzMOGJXp7XiEnq9/34un47QJ/hMMKpDiPVVK0Wtor VzqMrFU53ncefkvI8JfSPri2umwz8u/gJlTqvjprow== X-Google-Smtp-Source: ABdhPJw+WBaQpu6K/EP/XCCpxET87+bULI/RU+iA1GSA2CpDe3vqce08alBcHTx2GShwo2pEUBLYdR2k0/3Rq4IDZN0= X-Received: by 2002:a17:906:edb2:: with SMTP id sa18mr5756613ejb.264.1608328700420; Fri, 18 Dec 2020 13:58:20 -0800 (PST) MIME-Version: 1.0 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> <875z4yrfhr.fsf@nanos.tec.linutronix.de> In-Reply-To: <875z4yrfhr.fsf@nanos.tec.linutronix.de> From: Dan Williams Date: Fri, 18 Dec 2020 13:58:09 -0800 Message-ID: Subject: Re: [PATCH V3 04/10] x86/pks: Preserve the PKRS MSR on context switch To: Thomas Gleixner 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 Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Dec 18, 2020 at 1:06 PM Thomas Gleixner wrote: > > 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? Yup, got it. The dax code can be precise wrt to PKS in a way that kmap_local() cannot.