Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp7078866ioo; Thu, 2 Jun 2022 22:11:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQEJw++3iHF2YxbYxGXdvctpeMG4nH35uUPTNx7fmLJsCZbw6qoC5m8ewWwZtRdMIOpzJZ X-Received: by 2002:a17:902:f552:b0:163:f64a:6154 with SMTP id h18-20020a170902f55200b00163f64a6154mr8569592plf.147.1654233096011; Thu, 02 Jun 2022 22:11:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654233096; cv=none; d=google.com; s=arc-20160816; b=VHtxqp1X2vHRU6mf6FwKP5TJB4VdPHsnmaDwhE6MjpPJ66Rus7Ecfzl0NDtlPu4wFG ucFNMHSKe5il1WrDJqQDjxn3GE4ytDzFPbBSGTSoOTD8TCdqlgCEmtN6k6FsgihmAssd MQIGb39Pi57ZhYqlNGSrxVCHS3E5UixmePIBeOHlVmSn9s2O6azlmevMPtp7G6jjm+9H 62gVG+9YY8KGs6mgJ9wwSeSjgoIuU9T1tDdixeN6Y7NkRZrH35wUT5krp9clpw72wSs2 SY0RcED0QvWP7YHyWTFPnG33hgoJXvJBeDlp50b57o/KSqLgoY2nnCVWYD1hsj1+oUlK 6qUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=TAJUwPBPgyhmgdPF+DL8j/4CG1cjyDArH/IuaAEzA/Q=; b=BR9QrDMqeTMmpBQDiUT71NERV0NrgPYoA8VQVr+qJhKmQxIJEsKhedCJ6lwzrn6bq6 7Hlv4UV8Xu4wbxYgvEB8iA08S8bPOQvp6X9mnoCCfgk7xtemAXmJBv7oMEQyJJ0+9Xrn iyMVYjAnE+I8le+GB5ItJ8dGaXkRMmV+YX5pU0gGxJPMC07jGcThp+a2cvQ/887Nsrac Aeh2OTCXzri02jRSIKpC1xAmDdEpPtZc+Nm0e2n9OFQb6PwlBTA55WUAODn3/5eZGh4K QUmUdfbqJ/e9w6sgYSn4KAI+f8jX6XZZhswVKrkRP1w5uzRrD/u6VmppBWSg+HRzRP7J DCYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UhoF05iN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q13-20020a632a0d000000b003fcaa41c494si8113026pgq.175.2022.06.02.22.11.23; Thu, 02 Jun 2022 22:11:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UhoF05iN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237261AbiFBQrm (ORCPT + 99 others); Thu, 2 Jun 2022 12:47:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237251AbiFBQrj (ORCPT ); Thu, 2 Jun 2022 12:47:39 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E0B9E02E for ; Thu, 2 Jun 2022 09:47:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654188458; x=1685724458; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=A8LiKaAE36i4kEOLQiMiWUcBtJI+3DyK4ToZlO6mza8=; b=UhoF05iNsO9QkOdOqI7iWzwUIjI8KysOpMjpY3DcS0Nu00k+K5RY0oCA LQ244ZtYfn2aSSg0t06rupIVbrvvdDgTR1jWpCeUMLvbsdzcVJt7Qyki3 qitv2BMM7fWDNNenTfW2PVF8MScmggksohod4cU6aI3VLJAtB2c6IPPbr yvD0r18nv5Gg3iqCJ3a/vhUNLysxpKzvXuw+JYX+WeJzLZoitnNwBk7jj udLAgZcHUo3XtQnVBGrPSlZMm91yaJjyWZa/GFDoZqjUGmIFDS5IzKd6P xoLgtZcXQlhWhwUWIqcoBF4nQD0s+shdZLlj/FevqwmI/qGHM29/JYvOv w==; X-IronPort-AV: E=McAfee;i="6400,9594,10366"; a="275737502" X-IronPort-AV: E=Sophos;i="5.91,271,1647327600"; d="scan'208";a="275737502" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2022 09:47:36 -0700 X-IronPort-AV: E=Sophos;i="5.91,271,1647327600"; d="scan'208";a="577592309" Received: from bkakkar-mobl1.amr.corp.intel.com (HELO [10.212.249.147]) ([10.212.249.147]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2022 09:47:35 -0700 Message-ID: <1f0fd9f4-295f-6b44-47ff-b6b56892e680@intel.com> Date: Thu, 2 Jun 2022 09:47:33 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: Is _PAGE_PROTNONE set only for user mappings? Content-Language: en-US To: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: Mel Gorman , Tom Lendacky , Rick Edgecombe , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , "Kirill A. Shutemov" , Tianyu Lan , "Aneesh Kumar K.V" , linux-kernel@vger.kernel.org, linux-mm@kvack.org, vbabka@suse.cz, akpm@linux-foundation.org, willy@infradead.org References: <20220506051940.156952-1-42.hyeyoo@gmail.com> <56f89895-601e-44c9-bda4-5fae6782e27e@amd.com> <5fe161cb-6c55-6c4d-c208-16c77e115d3f@amd.com> <8c2735ac-0335-6e2a-8341-8266d5d13c30@intel.com> <20220512103748.GH3441@techsingularity.net> <3f2f7c09-ddf3-6052-9860-8554a4ff2798@intel.com> From: Dave Hansen In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/29/22 03:32, Hyeonggon Yoo wrote: > On Mon, May 16, 2022 at 07:04:32AM -0700, Dave Hansen wrote: > Writing code I'm a bit confused: > commit d1440b23c922d8 ("x86/mm: Factor out pageattr > _PAGE_GLOBAL setting") says: > > "This unconditional setting of _PAGE_GLOBAL is a problem when we have > PTI and non-PTI and we want some areas to have _PAGE_GLOBAL and some > not." > > Is this this sentence not valid anymore in PTI, > and just unconditionally setting _PAGE_GLOBAL would be okay in kernel > side regardless of PTI? I believe it's still valid. IIRC, there are three cases: 1. No KPTI. All kernel mappings are _PAGE_GLOBAL. Basically, for present mappings, if _PAGE_USER is clear, _PAGE_GLOBAL is set. 2. KPTI with PCID hardware support (or in a few other cases): The kernel image is mostly non-global. Anything mapped into userspace *is* marked global, like entry text. 3. KPTI without PCIDs: Basically case #2, but with more of the kernel image left global. So, not only are there different KPTI modes, there a different pars of the kernel that require different _PAGE_GLOBAL behavior. pti_kernel_image_global_ok() in arch/x86/mm/pti.c explains it pretty well.