Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp7037345ybf; Fri, 6 Mar 2020 09:09:32 -0800 (PST) X-Google-Smtp-Source: ADFU+vuh4Xhf3dvOA6Jy2ChGTm9urzvlyyh2EPQ7r7wF8pCgPfKbUBKZeSLpUfPsgeuYkWLomebb X-Received: by 2002:aca:47c8:: with SMTP id u191mr3363408oia.17.1583514572781; Fri, 06 Mar 2020 09:09:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583514572; cv=none; d=google.com; s=arc-20160816; b=gXWZRoKYA52VgzGe4b2P7Y6c1hDdC858OtZWj/px/erlC9AAe2VyBEYLyLOmhLZlwb 6/l5IVOhWpW5V2FbsrP4QqSyGS2NZIUWUlSNai6ml1R3XvqEXIfDU7IST1afAWeJWlYr zBd1+86bl+7pN/LhRNze92T0Scy2B/JUKXYc7LAqZv1BTX0pNNQS02fKQljLxVSD8fS4 05ubWCn7tgvzShA42QhsnCCTqrD5aidRZJpteQKt3EbqXUeiJUVDZfOfG33FX00N7LVt gwlvtGbrrNGo71osskXyTw97ptFe/zXYKHqGnJ2Zr9ErQzUvFm/0OPTlYLA0eKLxsvaz WrEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:cc:to:from; bh=Q9dvVwl4bRNciCrME6c5IV18um/0kMT74xOPG5YTSbI=; b=oWdDthCx3CPZg8G3rQHXno11V/1x+axd+tPG3wBdd8JMVjXBPJdWrygEwoC7/7I8zu apDtC8crMQiBjW3lzwcs0wP4id0D3GVWT+GnhQUQN1uwul0Pz4w19etWYIMQhgTxS7Cs yHrd14M0pReXbj7KYSWCK9c+zi7QFK9x//+eCLSARpTEcNCLf3dl9x2tGVmO0Fb5TaSg 4jHVQH4x56MpCDjV6Oxa2cgr6tCWiEQIf/XKz/Y7raDDBZb/LikqfV+rOAnI9DHKAqGh zYRhSqcQDEIZw/pFvGjTsdXMgQiYDn7GdGlpQCtz3rMFX0TxUBtGGv7lfNPqBf74VvkJ y4qg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d22si1638247oti.316.2020.03.06.09.09.20; Fri, 06 Mar 2020 09:09:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727077AbgCFRJE (ORCPT + 99 others); Fri, 6 Mar 2020 12:09:04 -0500 Received: from ale.deltatee.com ([207.54.116.67]:38410 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725873AbgCFRJD (ORCPT ); Fri, 6 Mar 2020 12:09:03 -0500 Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jAGSz-0004aT-QF; Fri, 06 Mar 2020 10:08:55 -0700 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.92) (envelope-from ) id 1jAGSv-0002RZ-Mn; Fri, 06 Mar 2020 10:08:49 -0700 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-mm@kvack.org, Dan Williams , Michal Hocko , David Hildenbrand , Andrew Morton Cc: Christoph Hellwig , Catalin Marinas , Will Deacon , Benjamin Herrenschmidt , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Eric Badger , Logan Gunthorpe , "H. Peter Anvin" , x86@kernel.org Date: Fri, 6 Mar 2020 10:08:43 -0700 Message-Id: <20200306170846.9333-5-logang@deltatee.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200306170846.9333-1-logang@deltatee.com> References: <20200306170846.9333-1-logang@deltatee.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-mm@kvack.org, dan.j.williams@intel.com, akpm@linux-foundation.org, hch@lst.de, catalin.marinas@arm.com, benh@kernel.crashing.org, tglx@linutronix.de, david@redhat.com, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, peterz@infradead.org, ebadger@gigaio.com, logang@deltatee.com, hpa@zytor.com, mhocko@kernel.org, will@kernel.org, luto@kernel.org, x86@kernel.org X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE,MYRULES_NO_TEXT,SURBL_BLOCKED,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Subject: [PATCH v4 4/7] x86/mm: Introduce __set_memory_prot() X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For use in the 32bit arch_add_memory() to set the pgprot type of the memory to add. Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: x86@kernel.org Cc: Dave Hansen Cc: Andy Lutomirski Cc: Peter Zijlstra Signed-off-by: Logan Gunthorpe Reviewed-by: Dan Williams --- arch/x86/include/asm/set_memory.h | 1 + arch/x86/mm/pat/set_memory.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/arch/x86/include/asm/set_memory.h b/arch/x86/include/asm/set_memory.h index 64c3dce374e5..034358da4837 100644 --- a/arch/x86/include/asm/set_memory.h +++ b/arch/x86/include/asm/set_memory.h @@ -34,6 +34,7 @@ * The caller is required to take care of these. */ +int __set_memory_prot(unsigned long addr, int numpages, pgprot_t prot); int _set_memory_uc(unsigned long addr, int numpages); int _set_memory_wc(unsigned long addr, int numpages); int _set_memory_wt(unsigned long addr, int numpages); diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c index c4aedd00c1ba..a7b14dffeb0b 100644 --- a/arch/x86/mm/pat/set_memory.c +++ b/arch/x86/mm/pat/set_memory.c @@ -1792,6 +1792,19 @@ static inline int cpa_clear_pages_array(struct page **pages, int numpages, CPA_PAGES_ARRAY, pages); } +/* + * _set_memory_prot is an internal helper for callers that have been passed + * a pgprot_t value from upper layers and a reservation has already been taken. + * If you want to set the pgprot to a specific page protocol, use the + * set_memory_xx() functions. + */ +int __set_memory_prot(unsigned long addr, int numpages, pgprot_t prot) +{ + return change_page_attr_set_clr(&addr, numpages, prot, + __pgprot(~pgprot_val(prot)), 0, 0, + NULL); +} + int _set_memory_uc(unsigned long addr, int numpages) { /* -- 2.20.1