From patchwork Wed Jul 15 05:33:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pekka Enberg X-Patchwork-Id: 11664219 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 719161392 for ; Wed, 15 Jul 2020 05:33:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3D3C42068F for ; Wed, 15 Jul 2020 05:33:54 +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="evNZ8y0A" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3D3C42068F 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 47D2D6B0005; Wed, 15 Jul 2020 01:33:53 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 406716B0006; Wed, 15 Jul 2020 01:33:53 -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 2CECC6B0007; Wed, 15 Jul 2020 01:33:53 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0163.hostedemail.com [216.40.44.163]) by kanga.kvack.org (Postfix) with ESMTP id 16AC86B0005 for ; Wed, 15 Jul 2020 01:33:53 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 95FF31EE6 for ; Wed, 15 Jul 2020 05:33:52 +0000 (UTC) X-FDA: 77039193504.06.jam01_43156f526ef7 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id 6688D10040F3E for ; Wed, 15 Jul 2020 05:33:52 +0000 (UTC) X-Spam-Summary: 1,0,0,9c23743442f80c73,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:3867:3868:3871:3874:4117:4250:4321:4419:4605:5007:6261:6653:7576:7875:7903:9121: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.208.195:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04yf31zw6a5ynuj16eqkspjz8z8ajyp6rst5rm6reb8dq3357qsfbtyxpo7hfpe.pnap6tzm9tkg1ud57g93buak899rrkunopapoo5gc66sta6rp91gc47rwhnmeu9.g-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: jam01_43156f526ef7 X-Filterd-Recvd-Size: 6551 Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Wed, 15 Jul 2020 05:33:51 +0000 (UTC) Received: by mail-lj1-f195.google.com with SMTP id e4so1171252ljn.4 for ; Tue, 14 Jul 2020 22:33:51 -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=sAvmQZqWID7UVdhehRS2dX6KN23mXR/R3FvuzsykU1c=; b=evNZ8y0AD6ZnSFXihIqOJmoKao2t12ADCFj9fiWCMvBzpJ/V9QJOYzt4yRN9uJF4Uc UtNCYqIGMxqzMT6GPG5RHUhdpOh9uxj5kIcwpcOWfrGE7fLq2irACW1Z9q0gjMIP+gDA HNTvLI2aEcdM2veYQFjCyQXZ8+icYbdKrab2WFQ07W6nOTXah8oJQbEBwpQ7tr9QSYse qroZBJS6LOStfRrT+wg8VGZxsLFq/f29KrDmhNLJGasjS7Md1xAupyqFgdVxPTiuBddo NQRaC4dCvQeFRy+qhOy+WYG1ReYcdcCPkgaTWw8caNUERFL82Yo7ydeLjtIJuul/7O/B kUWw== 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=sAvmQZqWID7UVdhehRS2dX6KN23mXR/R3FvuzsykU1c=; b=BFTN6GWAKKMUKCc22H1cu8cf5N+TUzxsclN/94bklaEJPIvGnyMxPjn2U6iElwS1jz 6xgHk40mgiyLRkgcZE7Oaqs+ZHvTqRr06D6zs8GbBN7MfI+vo3i+Mg8NOoTBtrByZY6r LNBVvLQwsy/BOO8l9ai5J1hIFgZAEhD5sBKIHWP0hgb01+t4+OyjPLwRTkJzEDksjqwd kCbjYIjLlztaRdIiZJjvctXQtyAoboRiCtifpTj+4CwKIl9abC9H46rr/6oOOYK9zFsb Gb52OQZB/nb8Bgx7bxUTfa/NWdM1HCe7Fj8AeO/fvLg3wMeh6nA/UTTKsjx1PUbIfzc6 qr8Q== X-Gm-Message-State: AOAM530L5rCi1ZkFb/lSdILxaN8g+xMsYkcZeXPUckV42XFA8svm4661 MGVoKPnOQ1s7g5Cipw+RooU= X-Google-Smtp-Source: ABdhPJzdV9s5/3zfxjQZJb9nSURTEpoixudxUzM4aWQJxU50kgnQTY9vKfs1It6Ve59W+JZV3UKFzQ== X-Received: by 2002:a2e:b5c8:: with SMTP id g8mr3765583ljn.38.1594791230225; Tue, 14 Jul 2020 22:33:50 -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 h14sm233916ljb.53.2020.07.14.22.33.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 22:33:49 -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 v2 1/2] mm: pgtable: Make generic pgprot_* macros available for no-MMU Date: Wed, 15 Jul 2020 08:33:39 +0300 Message-Id: <20200715053340.576300-1-penberg@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Rspamd-Queue-Id: 6688D10040F3E X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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 Reviewed-by: Mike Rapoport Cc: Tom Lendacky Signed-off-by: Pekka Enberg Acked-by: David Rientjes --- v1 -> v2: Wrap pgprot_modify() -- which is specific to mmap -- with CONFIG_MMU to fix a build issue on ARM reported by kernel test robot . include/linux/pgtable.h | 71 +++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 56c1e8eb7bb0..53e97da1e8e2 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,43 @@ 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 + +#ifdef CONFIG_MMU +#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 +#endif /* CONFIG_MMU */ + #ifndef pgprot_encrypted #define pgprot_encrypted(prot) (prot) #endif