From patchwork Tue Jul 14 10:00:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pekka Enberg X-Patchwork-Id: 11662223 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 00DD113B1 for ; Tue, 14 Jul 2020 10:01:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B7FBF21D7A for ; Tue, 14 Jul 2020 10:01:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YZl4Dt4L" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B7FBF21D7A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 96FE86B0006; Tue, 14 Jul 2020 06:01:01 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8CE916B0007; Tue, 14 Jul 2020 06:01:01 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7BFB68D0001; Tue, 14 Jul 2020 06:01:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0065.hostedemail.com [216.40.44.65]) by kanga.kvack.org (Postfix) with ESMTP id 5C3FD6B0006 for ; Tue, 14 Jul 2020 06:01:01 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 1C747180AD815 for ; Tue, 14 Jul 2020 10:01:01 +0000 (UTC) X-FDA: 77036237922.11.cup70_5c119bc26ef0 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 559F9180F8B86 for ; Tue, 14 Jul 2020 10:00:58 +0000 (UTC) X-Spam-Summary: 1,0,0,06f57d36c6fe2d71,d41d8cd98f00b204,penberg@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:968:973:988:989:1260:1311:1314:1345:1437:1515:1535:1543:1711:1730:1747:1777:1792:1978:1981:2194:2199:2393:2559:2562:2897:3138:3139:3140:3141:3142:3354:3865:3866:3868:3871:3874:4117:4321:4419:5007:6261:6653:7576:9413:9592:10004:11026:11658:11914:12043:12291:12296:12297:12438:12517:12519:12555:12679:12683:12895:13161:13229:13894:14096:14181:14394:14687:14721:14819:21080:21444:21451:21627:21666:21990:30003:30054:30064,0,RBL:209.85.167.65:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04yf5isbwyohj8sumsdsjfsryr5f7oc3ephg9r1s7ahkudrebu4r9bh6k9j4r7g.szjjqgskct6epyjx7g93buak85yti8n88ti6fxirnxh83s7g6agm3eq8bjkkbeo.6-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: cup70_5c119bc26ef0 X-Filterd-Recvd-Size: 6321 Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Tue, 14 Jul 2020 10:00:57 +0000 (UTC) Received: by mail-lf1-f65.google.com with SMTP id k17so11004155lfg.3 for ; Tue, 14 Jul 2020 03:00:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9hegCtgYYonDTxzG2P7M3NgTaesYZp6ZeRypjC7FVkc=; b=YZl4Dt4LbuOWK4kupIrnK8GgFFPA/fKYMQGbAMbl3uRcN4Aiwvdf69mwWowgDFzHfo 8MJOr5LlMd1miUn+6bIOEaPwsXNZHVGPe8ezYZVRKR7bEGRcy4b+l4VGaYWEBjW0Vzat xMklvoavVYl21c0XURmftIPI5DvTqjVaTTPT4OEIFtZ0HjhMmJU2SJJuyYhQfNSJZuJQ huscOIYyukq6anKXEsO2GTn2G9/PNNmn3QHRxbQ+BR7HRjjuw2/APu0D1qad5YTeS1Ft cFtPA/qezDnynGh6DSBmrGpw2NkIAQp+s2xaJwNcBlPwvDrl317iW7xAvb0gjGwq+Dli 9GFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9hegCtgYYonDTxzG2P7M3NgTaesYZp6ZeRypjC7FVkc=; b=Ymh5RMZgDZrQ/nAaCnNfgks5D8P97+p/NP52C15eJ68AO1hCoCCF/RBcayzR0Xm8th lCSZlAng6guY4BZSYK4HSVEYfmSTY9UO6ug5WLwC4kJcTNbaEP8gtEMmWpC3sMGO8MXv KcuMJw1VrVi+SerZhNXQSriL8LsGxdT96nKySiFzOTGuHLhDI7IW00BrG613KHAoV0BC O1+ip15Rfo9TNES8tegTKFart7QH3AaZVX/LY16PF97SUryJcIdJIAaF+sWgJKhvItZV PpvRt4WNRsDmU6zQt2I8qRndjbl778IiORi0WpotZf23Hi99JtsqkPPjE/GkAmcJmpzt VcbA== X-Gm-Message-State: AOAM531ko3JihUQg3gA6c9BX/SokcGcEYkuxlxn+DG53AGIeS3csVI9/ VecDYEWPQynyryY8jalWL98= X-Google-Smtp-Source: ABdhPJyLCcHVa1MAXGziSZoP1Bpw2XghpI0TwlWE5Hvjgr4PMH4MfVP4HC8mw5tWu8896icrBPdXNQ== X-Received: by 2002:ac2:52ac:: with SMTP id r12mr1808859lfm.175.1594720856307; Tue, 14 Jul 2020 03:00:56 -0700 (PDT) Received: from nero.bb.dnainternet.fi (dyn9cmyyyyyyyyyyyyyft-3.rev.dnainternet.fi. [2001:14ba:2fa:2500::9]) by smtp.gmail.com with ESMTPSA id y22sm4560279ljn.2.2020.07.14.03.00.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 03:00:55 -0700 (PDT) From: Pekka Enberg To: linux-riscv@lists.infradead.org, linux-mm@kvack.org Cc: Pekka Enberg , Palmer Dabbelt , Mike Rapoport , Tom Lendacky Subject: [PATCH 1/2] mm: pgtable: Make generic pgprot_* macros available for no-MMU Date: Tue, 14 Jul 2020 13:00:50 +0300 Message-Id: <20200714100051.345018-1-penberg@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Rspamd-Queue-Id: 559F9180F8B86 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: From: Pekka Enberg The header defines some generic pgprot_* implementations, but they are only available when CONFIG_MMU is enabled. The RISC-V architecture, for example, therefore defines some of these pgprot_* macros for !NOMMU. Let's make the pgprot_* generic available even for !NOMMU so we can remove the RISC-V specific definitions. Compile-tested with x86 defconfig, and riscv defconfig and !MMU defconfig. Suggested-by: Palmer Dabbelt Cc: Mike Rapoport Cc: Tom Lendacky Signed-off-by: Pekka Enberg Reviewed-by: Mike Rapoport Reported-by: kernel test robot --- include/linux/pgtable.h | 69 +++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 56c1e8eb7bb0..ed9026ad7c31 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -647,40 +647,6 @@ static inline int arch_unmap_one(struct mm_struct *mm, #define flush_tlb_fix_spurious_fault(vma, address) flush_tlb_page(vma, address) #endif -#ifndef pgprot_nx -#define pgprot_nx(prot) (prot) -#endif - -#ifndef pgprot_noncached -#define pgprot_noncached(prot) (prot) -#endif - -#ifndef pgprot_writecombine -#define pgprot_writecombine pgprot_noncached -#endif - -#ifndef pgprot_writethrough -#define pgprot_writethrough pgprot_noncached -#endif - -#ifndef pgprot_device -#define pgprot_device pgprot_noncached -#endif - -#ifndef pgprot_modify -#define pgprot_modify pgprot_modify -static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot) -{ - if (pgprot_val(oldprot) == pgprot_val(pgprot_noncached(oldprot))) - newprot = pgprot_noncached(newprot); - if (pgprot_val(oldprot) == pgprot_val(pgprot_writecombine(oldprot))) - newprot = pgprot_writecombine(newprot); - if (pgprot_val(oldprot) == pgprot_val(pgprot_device(oldprot))) - newprot = pgprot_device(newprot); - return newprot; -} -#endif - /* * When walking page tables, get the address of the next boundary, * or the end address of the range if that comes earlier. Although no @@ -840,6 +806,41 @@ static inline void ptep_modify_prot_commit(struct vm_area_struct *vma, * No-op macros that just return the current protection value. Defined here * because these macros can be used used even if CONFIG_MMU is not defined. */ + +#ifndef pgprot_nx +#define pgprot_nx(prot) (prot) +#endif + +#ifndef pgprot_noncached +#define pgprot_noncached(prot) (prot) +#endif + +#ifndef pgprot_writecombine +#define pgprot_writecombine pgprot_noncached +#endif + +#ifndef pgprot_writethrough +#define pgprot_writethrough pgprot_noncached +#endif + +#ifndef pgprot_device +#define pgprot_device pgprot_noncached +#endif + +#ifndef pgprot_modify +#define pgprot_modify pgprot_modify +static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot) +{ + if (pgprot_val(oldprot) == pgprot_val(pgprot_noncached(oldprot))) + newprot = pgprot_noncached(newprot); + if (pgprot_val(oldprot) == pgprot_val(pgprot_writecombine(oldprot))) + newprot = pgprot_writecombine(newprot); + if (pgprot_val(oldprot) == pgprot_val(pgprot_device(oldprot))) + newprot = pgprot_device(newprot); + return newprot; +} +#endif + #ifndef pgprot_encrypted #define pgprot_encrypted(prot) (prot) #endif