Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2420282pxu; Fri, 18 Dec 2020 12:50:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJwsjcwXNr9BVezfgsIjHHlSFOFnllme0Z2rcXUasAWA+XLQvayYNZfthuTiU1OG4/F9hBYu X-Received: by 2002:a17:906:15ca:: with SMTP id l10mr5615581ejd.402.1608324655718; Fri, 18 Dec 2020 12:50:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608324655; cv=none; d=google.com; s=arc-20160816; b=pn/BRHZ1umgiX2shPkqgu1zTT+XY1auwAg+9hy0o6VRN3/vgMJiRWVYT1PBEZ5gXiq Y79uW3RaKApTUHm3F2L17H8U/z/CjM9SUpYcFCJlMZlVsE+LF2uhyzM04IiYmOglXGTf u3hDUjNSLmx9tyssFXZo46v7LFEYPHkKYYfXh40V8LSjvQROTPXEDypU2VPZPFlQkHB+ /oMEjqclSlU0mNUsAjPsIAWLIAarw+3l0Ow7u76Dcf8FyuWF2lo3ieHM1SAWQhOMFRjw TqHalKPULsDC2+eIYVklO1jBxWg0vDOdtZWmKPuJAN3P8cUz7EmSpBQOC3o5moZ2VbRI 0oaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=2HEr0MPReqXsQ4qjOEHDWj7dDqEmzb7cQ1SBc7J5+dw=; b=TKsxRbnGOFqkMPzNv2p691P7KKEI2Yo3kuyvKmQOyeGHt+4a0qpRymS4Cutsy1JMOT K/zNw9mkw77g0hpBs2CrjAAhx2RnBpy04NGslB+rINzfK+fQciWyY2JBpf65IulDJQEt G4OJ7ynnEkF4fo3tf86ZPuyqFB6iFSx9AxT+DOpcZJ+BL3z+T3D5BGrxWNTXw+VPt1GD N8FhHxq1rsltXI6jpEMlpKhsl5wQ/+Cbql1EGmFmg5qgbvgx+K0eh0ETPOTYwoc7Ey81 Z0WXUvz3UK2uCDBN8yN9Cjg3wsfMFsuE9sOg3j1RERPnXPnAPJfA5l5BGDJkJcpXscN6 8N5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=0gUyIB6k; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bx26si7291959edb.358.2020.12.18.12.50.33; Fri, 18 Dec 2020 12:50:55 -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=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=0gUyIB6k; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728576AbgLRTVi (ORCPT + 99 others); Fri, 18 Dec 2020 14:21:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728150AbgLRTVh (ORCPT ); Fri, 18 Dec 2020 14:21:37 -0500 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41464C06138C for ; Fri, 18 Dec 2020 11:20:57 -0800 (PST) Received: by mail-ej1-x630.google.com with SMTP id n26so4793158eju.6 for ; Fri, 18 Dec 2020 11:20:57 -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=2HEr0MPReqXsQ4qjOEHDWj7dDqEmzb7cQ1SBc7J5+dw=; b=0gUyIB6kwj5RKOw851fk6tIuNDG4efEdNNdTwLooyi3Ofm0EJNVeG9KuAjSj3aMg6f Nwg+eoJoWVdwLtTY3Y8taw8Fef0vS6Q+iXd/8DHKpkBDllC+QxxTWM+tmflFQ56pKF9B r2XxuUfLtlwWmeTgBIAJmw9ETjSzKJTBTFdP2PkwnVqnR01L9FpICe97GYFCb2DWdW5K seQ68bOOeWzb3UjT1JmBfrvoBnu9/DfF7C6IExaFWhrhWglsaMg1lwmZ33uUG9d1/Sb+ XYVWsgUrBCaZCqgbA6uAiGkasFBAenXSTwAqf6Hsd5Vrz7GPCAPk7LmnxkGUwVTkpXZL KpAw== 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=2HEr0MPReqXsQ4qjOEHDWj7dDqEmzb7cQ1SBc7J5+dw=; b=avBngEnepLnUA/2MY4CtMeRwOYHAErnEWjzbfZXyiKNUKFlXy35Tauc27kYAanPq5B gW6g6yY7RFeHgHDbkIuBo25vOr3hN19cAXiI26Yak/f84mkXRFmlucrUrKd3YeRASPI/ uUtdXJKPBEjLDyTXdedTljg4U5pN0PTSwFNLjCywSg2saqqB4KaLtf+o7w1Ym+/tMKhp NE1/inC/edg8rQIV5jP/WTvlRsuAIQeLiOSCviIUNikC6uY3ux8iufuAoq/RogQjFJvN uHfYT4K7bBkVnpfFuz8xWRY/zcPZBxidsaqgf7p73d90ljrQvJ1W6QQIU3zlwpOM+R92 BTXg== X-Gm-Message-State: AOAM533mc/A76MaIRYuz4scTKM1Vme0vJT1nNBWxJRexLO9YZsuDT+Td 7vHg1dvJXb3qgaxMX7qsdrWL4V58CHCMaLNs6NwcUA== X-Received: by 2002:a17:906:4146:: with SMTP id l6mr5459331ejk.341.1608319255787; Fri, 18 Dec 2020 11:20:55 -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> In-Reply-To: <878s9vqkrk.fsf@nanos.tec.linutronix.de> From: Dan Williams Date: Fri, 18 Dec 2020 11:20:45 -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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.