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,USER_AGENT_GIT autolearn=unavailable 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 899E6C433E4 for ; Tue, 14 Jul 2020 10:01:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 49D7021D7A for ; Tue, 14 Jul 2020 10:01:02 +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 49D7021D7A 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) Received: by kanga.kvack.org (Postfix, from userid 40) id 8CE916B0007; Tue, 14 Jul 2020 06:01:01 -0400 (EDT) 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-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-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 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 Cc: Mike Rapoport Cc: Tom Lendacky Signed-off-by: Pekka Enberg --- 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 *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,41 @@ 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 + +#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 + #ifndef pgprot_encrypted #define pgprot_encrypted(prot) (prot) #endif --=20 2.26.2