From patchwork Sun Apr 25 14:13:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 12223335 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=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,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 73A71C43462 for ; Sun, 25 Apr 2021 14:16:45 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F083B61370 for ; Sun, 25 Apr 2021 14:16:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F083B61370 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=BYIBxQvSwKAOI3UsDbct72k+UoNiyvuT5RktXrK+iCk=; b=BBCcpi6jn9B4PjESYUgiwZ3je 3j0zYTdCsawLUHulaZ2ia4yyjEWV3tXRKk66gWrvUC5GaXT6yWwIx5mvBAjIgPTcNi8BzgvRyX//m iL/3vP4T26JjX51t/c+sFhBLRdO7brdmhgqG8PNyQrNk7LnAkIfyH+ogeQ7cxCr2suO0dpY17kOEp wc3JX1didasq1UBUhkqLQ90i+plDHZccsqd/QwAYMrQB4R/MdqPCvsE1zjPOlHwktFTsIdkp0EoDV qJAURHhYHZmJ9Q2UdapQeVW3ojnqO0RbrFh7nmnfbXTji+TN5MNs/eJjojbfp5eXUlcxZ/PDQ3rwX 708UjcdqA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lafXJ-005iWZ-Nk; Sun, 25 Apr 2021 14:15:01 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lafWU-005iIg-5l for linux-arm-kernel@desiato.infradead.org; Sun, 25 Apr 2021 14:14:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=vMtiBmNRwxDsN9zQ6Ko5/YP7kk0/VhFH+hMl0hhVbXs=; b=FEF4clG6y/wiogciBie5HAivoz xWVRosQV4EIJluMdjzHruS64Dq5URX8pCh0sGb7DodUbPcbD7gr0ueRh50MhDYKuxCRbnFsQr+3Dp vmRL3svATD4SiY/c4StZVvs5kEJYOnMu4dsUSQZBLDTbXZXrxPhSUmvW5/gEpbUoGNIOjyaOUrUeW vwefo+RxwGXomZ63KZ7TJ00qbGgz1X3fBfIuDF8knxWhm2iRV944Jo+7A+eyldcD3heSfr5i4eM1e u+u2LhF51dGPXc0blJKYC624RvE589iUmq31eNiqXwOOhqck8Q2dC+9PKbPyMnv0IimWIAqe/Ense y2d2ROWg==; Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lafWR-00FT6F-HE for linux-arm-kernel@lists.infradead.org; Sun, 25 Apr 2021 14:14:08 +0000 Received: by mail-pj1-x1029.google.com with SMTP id e8-20020a17090a7288b029014e51f5a6baso3681544pjg.2 for ; Sun, 25 Apr 2021 07:14:07 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=vMtiBmNRwxDsN9zQ6Ko5/YP7kk0/VhFH+hMl0hhVbXs=; b=R6aSTesBGB/c+sh6ed4WJev1QNjxLBFSoitglbNZaGTNpqJJO/IEqgAAZlTpwXWrV8 47DESjNl5BVSRzAVRheh0ZcUcgY7HgyRphck85BptDpwF2LtffWv1IBleBGBuzi9k7ZX l/aVU7drnuwF5M0Kc36HrNPgBvRyzNAwTZc6kKMK40fOScfWPckHwDdJ0ywnejbr6g/M jRJmFtg0nOHjdKkcL19GWRg7icKtJ35qfceZMroYrmYvUVV4aGGC0eV7AWFEkfq0cZht dLCMMX5a9dpNc82HysGYDfJ69zFZC+RFxNSTs2dF+jxQUmr1vHk2V0YzFjuKgKTM67mu CFOg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=vMtiBmNRwxDsN9zQ6Ko5/YP7kk0/VhFH+hMl0hhVbXs=; b=KOAl5n+NxCaFziBRqe1ylcAmPn9HjaYbEvZM2l6CT7j0zsIF7q4LyzqNp0x9D7R6vF Wl6h5n/ybis+cksA4oUpjXzRIiYeHpiUIuBTdDvr+HFMjj8bIuFJz7QBkxROzK/llViz tk4WMXGy+syZVKJjhWgTID//hG36e6tQEQsdc/LP6GezAedrpsEbhkd6Q0giKM3HjPbc spfoNL5wDaj+UbPmVJWsb1I46P8ZqBgrGtGYAObbdaSLxLVxRPj4y3cTnJJTTIXWIDPF XNHEED96ci64uKDF7NDjTz+AjGF8nkK1vngEe5kTxr9puDtpusvhEUPnoxTTkUgjSQui oXdA== X-Gm-Message-State: AOAM5326SnMCTeu+6WYqksfgytzKdEkGzhwS5E03zZ1nOUwskeGHE8/w l3lPW20z0wXGE/l691vYPk7T3bfgUQ== X-Google-Smtp-Source: ABdhPJwts5aPseEn7Q7O/fv7A0LnRWzZjfzP1agw4neo37y6HApFtb7tKr+qDhfLrMneFpRcyscZFA== X-Received: by 2002:a17:902:d913:b029:ec:c4bb:57cf with SMTP id c19-20020a170902d913b02900ecc4bb57cfmr13808491plz.12.1619360046622; Sun, 25 Apr 2021 07:14:06 -0700 (PDT) Received: from x1pad.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id r32sm1007139pgm.49.2021.04.25.07.14.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Apr 2021 07:14:06 -0700 (PDT) From: Pingfan Liu To: linux-arm-kernel@lists.infradead.org Cc: Pingfan Liu , Catalin Marinas , Will Deacon , Marc Zyngier , Kristina Martsenko , James Morse , Steven Price , Jonathan Cameron , Pavel Tatashin , Anshuman Khandual , Atish Patra , Mike Rapoport , Logan Gunthorpe , Mark Brown Subject: [PATCHv2 07/10] arm64/pgtable-prot.h: reorganize to cope with asm Date: Sun, 25 Apr 2021 22:13:01 +0800 Message-Id: <20210425141304.32721-8-kernelfans@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210425141304.32721-1-kernelfans@gmail.com> References: <20210425141304.32721-1-kernelfans@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210425_071407_591346_9272003E X-CRM114-Status: GOOD ( 13.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch is one of the preparation for calling __create_pgd_mapping() from head.S. In order to refer PAGE_KERNEL_EXEC in head.S, reorganize this file and move the needed part under #ifdef __ASSEMBLY__ Signed-off-by: Pingfan Liu Cc: Catalin Marinas Cc: Will Deacon Cc: Marc Zyngier Cc: Kristina Martsenko Cc: James Morse Cc: Steven Price Cc: Jonathan Cameron Cc: Pavel Tatashin Cc: Anshuman Khandual Cc: Atish Patra Cc: Mike Rapoport Cc: Logan Gunthorpe Cc: Mark Brown To: linux-arm-kernel@lists.infradead.org --- arch/arm64/include/asm/pgtable-prot.h | 34 +++++++++++++++++---------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/arch/arm64/include/asm/pgtable-prot.h b/arch/arm64/include/asm/pgtable-prot.h index 9a65fb528110..424fc5e6fd69 100644 --- a/arch/arm64/include/asm/pgtable-prot.h +++ b/arch/arm64/include/asm/pgtable-prot.h @@ -33,9 +33,6 @@ extern bool arm64_use_ng_mappings; -#define _PROT_DEFAULT (PTE_TYPE_PAGE | PTE_AF | PTE_SHARED) -#define _PROT_SECT_DEFAULT (PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S) - #define PTE_MAYBE_NG (arm64_use_ng_mappings ? PTE_NG : 0) #define PMD_MAYBE_NG (arm64_use_ng_mappings ? PMD_SECT_NG : 0) @@ -49,6 +46,26 @@ extern bool arm64_use_ng_mappings; #define PTE_MAYBE_GP 0 #endif +#define PAGE_S2_MEMATTR(attr) \ + ({ \ + u64 __val; \ + if (cpus_have_const_cap(ARM64_HAS_STAGE2_FWB)) \ + __val = PTE_S2_MEMATTR(MT_S2_FWB_ ## attr); \ + else \ + __val = PTE_S2_MEMATTR(MT_S2_ ## attr); \ + __val; \ + }) + +#endif /* __ASSEMBLY__ */ + +#ifdef __ASSEMBLY__ +#define PTE_MAYBE_NG 0 +#define __pgprot(x) (x) +#endif + +#define _PROT_DEFAULT (PTE_TYPE_PAGE | PTE_AF | PTE_SHARED) +#define _PROT_SECT_DEFAULT (PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S) + #define PROT_DEFAULT (_PROT_DEFAULT | PTE_MAYBE_NG) #define PROT_SECT_DEFAULT (_PROT_SECT_DEFAULT | PMD_MAYBE_NG) @@ -71,15 +88,7 @@ extern bool arm64_use_ng_mappings; #define PAGE_KERNEL_EXEC __pgprot(PROT_NORMAL & ~PTE_PXN) #define PAGE_KERNEL_EXEC_CONT __pgprot((PROT_NORMAL & ~PTE_PXN) | PTE_CONT) -#define PAGE_S2_MEMATTR(attr) \ - ({ \ - u64 __val; \ - if (cpus_have_const_cap(ARM64_HAS_STAGE2_FWB)) \ - __val = PTE_S2_MEMATTR(MT_S2_FWB_ ## attr); \ - else \ - __val = PTE_S2_MEMATTR(MT_S2_ ## attr); \ - __val; \ - }) + #define PAGE_NONE __pgprot(((_PAGE_DEFAULT) & ~PTE_VALID) | PTE_PROT_NONE | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_UXN) /* shared+writable pages are clean by default, hence PTE_RDONLY|PTE_WRITE */ @@ -106,6 +115,5 @@ extern bool arm64_use_ng_mappings; #define __S110 PAGE_SHARED_EXEC #define __S111 PAGE_SHARED_EXEC -#endif /* __ASSEMBLY__ */ #endif /* __ASM_PGTABLE_PROT_H */