From: James Morse <james.morse@arm.com>
To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu
Cc: Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Marc Zyngier <maz@kernel.org>
Subject: [RFC PATCH 5/7] arm64: mm: Add pgprot_pbha() to allow drivers to request PBHA values
Date: Fri, 15 Oct 2021 16:14:14 +0000 [thread overview]
Message-ID: <20211015161416.2196-6-james.morse@arm.com> (raw)
In-Reply-To: <20211015161416.2196-1-james.morse@arm.com>
Add a pgprot_pbha() helper that modifies a pgprot_t to include a pbha
value. The value is checked against those that were listed as only
affecting performance.
Signed-off-by: James Morse <james.morse@arm.com>
---
arch/arm64/include/asm/pgtable-hwdef.h | 1 +
arch/arm64/include/asm/pgtable.h | 12 ++++++++++++
arch/arm64/kernel/cpufeature.c | 1 +
3 files changed, 14 insertions(+)
diff --git a/arch/arm64/include/asm/pgtable-hwdef.h b/arch/arm64/include/asm/pgtable-hwdef.h
index 3d41242c52b0..bef11fb9a255 100644
--- a/arch/arm64/include/asm/pgtable-hwdef.h
+++ b/arch/arm64/include/asm/pgtable-hwdef.h
@@ -154,6 +154,7 @@
#define PTE_CONT (_AT(pteval_t, 1) << 52) /* Contiguous range */
#define PTE_PXN (_AT(pteval_t, 1) << 53) /* Privileged XN */
#define PTE_UXN (_AT(pteval_t, 1) << 54) /* User XN */
+#define PTE_PBHA_MASK (_AT(pteval_t, 0xf) << 59) /* Page Base Hardware Attributes */
#define PTE_ADDR_LOW (((_AT(pteval_t, 1) << (48 - PAGE_SHIFT)) - 1) << PAGE_SHIFT)
#ifdef CONFIG_ARM64_PA_BITS_52
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index dfa76afa0ccf..3bc242db2c3c 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -518,6 +518,18 @@ static inline pmd_t pmd_mkdevmap(pmd_t pmd)
__pgprot_modify(prot, PTE_ATTRINDX_MASK, \
PTE_ATTRINDX(MT_NORMAL_NC) | PTE_PXN | PTE_UXN)
+
+extern unsigned long arm64_pbha_perf_only_values;
+static inline unsigned long __pbha_check_perf_only(unsigned long pbha_val)
+{
+ if (test_bit(pbha_val, &arm64_pbha_perf_only_values))
+ return FIELD_PREP(PTE_PBHA_MASK, pbha_val);
+ return 0;
+}
+
+#define pgprot_pbha(prot, pbha_val) \
+ __pgprot_modify(prot, PTE_PBHA_MASK, __pbha_check_perf_only(pbha_val))
+
#define __HAVE_PHYS_MEM_ACCESS_PROT
struct file;
extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 548c6f96a878..88f0f805b938 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -112,6 +112,7 @@ bool arm64_use_ng_mappings = false;
EXPORT_SYMBOL(arm64_use_ng_mappings);
unsigned long __ro_after_init arm64_pbha_perf_only_values;
+EXPORT_SYMBOL(arm64_pbha_perf_only_values);
/*
* Permit PER_LINUX32 and execve() of 32-bit binaries even if not all CPUs
--
2.30.2
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
next prev parent reply other threads:[~2021-10-15 16:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-15 16:14 [RFC PATCH 0/7] arm64: mm: Prototype to allow drivers to request PBHA values James Morse
2021-10-15 16:14 ` [RFC PATCH 1/7] KVM: arm64: Detect and enable PBHA for stage2 James Morse
2021-10-16 13:27 ` Marc Zyngier
2021-10-18 17:26 ` James Morse
2021-10-15 16:14 ` [RFC PATCH 2/7] dt-bindings: Rename the description of cpu nodes cpu.yaml James Morse
2021-10-15 16:14 ` [RFC PATCH 3/7] dt-bindings: arm: Add binding for Page Based Hardware Attributes James Morse
2021-10-15 16:14 ` [RFC PATCH 4/7] arm64: cpufeature: Enable PBHA bits for stage1 James Morse
2021-10-16 13:50 ` Marc Zyngier
2021-10-18 17:26 ` James Morse
2021-10-15 16:14 ` James Morse [this message]
2021-10-15 16:14 ` [RFC PATCH 6/7] KVM: arm64: Configure PBHA bits for stage2 James Morse
2021-10-16 13:46 ` Marc Zyngier
2021-10-15 16:14 ` [RFC PATCH 7/7] Documentation: arm64: Describe the support and expectations for PBHA James Morse
2021-10-16 13:54 ` [RFC PATCH 0/7] arm64: mm: Prototype to allow drivers to request PBHA values Marc Zyngier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211015161416.2196-6-james.morse@arm.com \
--to=james.morse@arm.com \
--cc=catalin.marinas@arm.com \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=maz@kernel.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox