From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12670C433E3 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 C1D7A2068F for ; Wed, 15 Jul 2020 05:33:53 +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 C1D7A2068F 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) Received: by kanga.kvack.org (Postfix, from userid 40) id 406716B0006; Wed, 15 Jul 2020 01:33:53 -0400 (EDT) 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-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-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 Content-Transfer-Encoding: quoted-printable 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 --- 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 *m= m, #define flush_tlb_fix_spurious_fault(vma, address) flush_tlb_page(vma, a= ddress) #endif =20 -#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) =3D=3D pgprot_val(pgprot_noncached(oldprot))) - newprot =3D pgprot_noncached(newprot); - if (pgprot_val(oldprot) =3D=3D pgprot_val(pgprot_writecombine(oldprot))= ) - newprot =3D pgprot_writecombine(newprot); - if (pgprot_val(oldprot) =3D=3D pgprot_val(pgprot_device(oldprot))) - newprot =3D 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 h= ere * because these macros can be used used even if CONFIG_MMU is not defin= ed. */ + +#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) =3D=3D pgprot_val(pgprot_noncached(oldprot))) + newprot =3D pgprot_noncached(newprot); + if (pgprot_val(oldprot) =3D=3D pgprot_val(pgprot_writecombine(oldprot))= ) + newprot =3D pgprot_writecombine(newprot); + if (pgprot_val(oldprot) =3D=3D pgprot_val(pgprot_device(oldprot))) + newprot =3D pgprot_device(newprot); + return newprot; +} +#endif +#endif /* CONFIG_MMU */ + #ifndef pgprot_encrypted #define pgprot_encrypted(prot) (prot) #endif --=20 2.26.2