From patchwork Sat Apr 10 09:56:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 12195559 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,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 23DE1C43461 for ; Sat, 10 Apr 2021 10:00:55 +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 B3ED861001 for ; Sat, 10 Apr 2021 10:00:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B3ED861001 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=cZsDL54/Lcewphqf7PXftSM7Nza8qvdCoPxgohMIOJ8=; b=Yxt8OUJEZi8TNr+wULUbRXfbq /k+ac1ZEaTqmvOgubx9SICWUVrZ1Ntej5HxndZO3vXh2yJsRq6VQdrkPrrJWZ7no/4EKJgBxSL/DI fXzwtyvLx8fs5XgZOoFnKK5733fD28hC1B9jtkUi8Vbezu0ssav9cSAJ5omRBehguLhSz3KADrWAY lWl6EkI0S0cDvCyOsNuYeN1sD6cpR8gmJAG9Km/d3PboinoTstW4y5ZDlym04Pb1r6JJtTkyXN3u/ m8gnDRNnFejl4rSgNvsCBJ0FKSGtqwyeV3HIYrXoIeZa8ucQbQPSE/S4hIU39eAmUjZeTJ/yF90AY ABMesqdsA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lVAOK-002bjs-Rl; Sat, 10 Apr 2021 09:59: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 1lVANC-002bTC-6L for linux-arm-kernel@desiato.infradead.org; Sat, 10 Apr 2021 09:57:50 +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=zrd7bBLovHvnijnmMdqZkS7Wy6EC6D6qV3B22r4kYsY=; b=mF/C9tLSbMWvTc0P54tGkYJtvK u4G5wfx3XPMqk6x4YyS8eAX/teqAivbyt6f4KHgK/R8Ix+jGj5xQNK/xW8bDe5wrLRIywuZNzQTrq 7XPxquAxLQBZG/zIJzG6vD6p6euxVKCBLYk7rThVRirpx3n43naMB/em72Ul0RCjxO3ByWJ+PsumA DLc3eBa9UY5HT2L7iwn5ucqo0JVKx3BhQvhBSQNLrNUjNOw0TMBRKv+6sg4imZtWMhXtI9dAtXnKI OQHIMZ3WPo2iAsJ42tdvpODpYWh+wAu5TfgCaN8I4czhT17HOSvz34+3uquk854zoQWtDB4cNkk3v sBCIbVQg==; Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVAN9-0051aR-NO for linux-arm-kernel@lists.infradead.org; Sat, 10 Apr 2021 09:57:49 +0000 Received: by mail-pf1-x436.google.com with SMTP id w8so2389474pfn.9 for ; Sat, 10 Apr 2021 02:57:47 -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=zrd7bBLovHvnijnmMdqZkS7Wy6EC6D6qV3B22r4kYsY=; b=kmDTbLootSstV4Gv4MndxXmNuae44mMGjYz3am4sjq0zcKh2hELFopGiJXbINQ1dQP 5r5zUKyk603h5s2OBJWJhRTcP1ynH1XvpJ3qJQW9QhjjnNOH5QeEz8vIk+J58Ka4zpSY Js+j580RZY6j1NVQr4fVQzzgrh2RMHKS/W+hVKIwdMciILw9UiqVx4DtZgDJNIDOUkBz WDBP0kQT9rBw4T9Xtu7IDcQgGwjAIzxxba40+C+uI3WHdcqnAXvNyFJbNXFB+GWk6tJe CS10w5bfsVztH1pnf9x9/3S9i1QIYnC6jgtKrI3f7m3qB7rvXn3rDh+Ez7T6pCd17L6h F9wQ== 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=zrd7bBLovHvnijnmMdqZkS7Wy6EC6D6qV3B22r4kYsY=; b=Ei3bK8ewIBHUuTbKUBdBLPuqCk0jEYImFYssRUn09MgEnB2nYrjODKOGqhRMaqGzzL /4eBapQligv9RJwR//iWoyy0YZytbFHXP/pZPcr9yCbbPzD/SqM9e5omjQwk6b4Su2Pm cfgOxCgyNhNoiYDlTegCwsfSK8SJMHiVMoJGzOisCoI2uN1HNAv19RXqQSlGXBJcr6Z5 4SR9wwRznXK6Pjcixoc2lmtJ7iQO5kSHQLjEnon+N4HIQQAtyF5t/mBo4SIs1ndA1V7r kYGE6Xk3novzczX4MiJhC2NxsD66q6lExs3RtN7zlkROkI4GJourVS542Fh6rY1VdtBN XLOA== X-Gm-Message-State: AOAM531qbsKep2yBhmAHlSDEuphV5eExBg1d7E8JyhtoZD2SN1mROxFC 85gtUgWxi4DxHgQatPBCv1C3XnTFnfNk X-Google-Smtp-Source: ABdhPJyvVmbXrQ1e7NSFfhexzrkc97/ZpolsbiKNztm6qpeZH7HwhRM4NMF8MivNkU3vQxp3YhiTsQ== X-Received: by 2002:a63:fd0a:: with SMTP id d10mr9886701pgh.94.1618048666772; Sat, 10 Apr 2021 02:57:46 -0700 (PDT) Received: from x1pad.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id m14sm3836322pfh.89.2021.04.10.02.57.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Apr 2021 02:57:46 -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: [RFC 7/8] arm64/pgtable-prot.h: reorganize to cope with asm Date: Sat, 10 Apr 2021 17:56:53 +0800 Message-Id: <20210410095654.24102-8-kernelfans@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210410095654.24102-1-kernelfans@gmail.com> References: <20210410095654.24102-1-kernelfans@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210410_025747_781665_236C5C17 X-CRM114-Status: GOOD ( 12.81 ) 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 In order to refer PAGE_KERNEL_EXEC in head.S, reorganize this file. 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 */