All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <marc.zyngier@arm.com>
To: Christoffer Dall <christoffer.dall@linaro.org>
Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	kvmarm@lists.cs.columbia.edu
Subject: [PATCH v2 09/18] arm64: KVM: Runtime detection of lower HYP offset
Date: Thu, 30 Jun 2016 18:40:42 +0100	[thread overview]
Message-ID: <1467308451-13365-10-git-send-email-marc.zyngier@arm.com> (raw)
In-Reply-To: <1467308451-13365-1-git-send-email-marc.zyngier@arm.com>

Add the code that enables the switch to the lower HYP VA range.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
 arch/arm64/kernel/cpufeature.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 811773d..ffb3e14d 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -726,6 +726,19 @@ static bool runs_at_el2(const struct arm64_cpu_capabilities *entry, int __unused
 	return is_kernel_in_hyp_mode();
 }
 
+static bool hyp_offset_low(const struct arm64_cpu_capabilities *entry,
+			   int __unused)
+{
+	phys_addr_t idmap_addr = virt_to_phys(__hyp_idmap_text_start);
+
+	/*
+	 * Activate the lower HYP offset only if:
+	 * - the idmap doesn't clash with it,
+	 * - the kernel is not running at EL2.
+	 */
+	return idmap_addr > GENMASK(VA_BITS - 2, 0) && !is_kernel_in_hyp_mode();
+}
+
 static const struct arm64_cpu_capabilities arm64_features[] = {
 	{
 		.desc = "GIC system register CPU interface",
@@ -803,6 +816,12 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
 		.field_pos = ID_AA64PFR0_EL0_SHIFT,
 		.min_field_value = ID_AA64PFR0_EL0_32BIT_64BIT,
 	},
+	{
+		.desc = "Reduced HYP mapping offset",
+		.capability = ARM64_HYP_OFFSET_LOW,
+		.def_scope = SCOPE_SYSTEM,
+		.matches = hyp_offset_low,
+	},
 	{},
 };
 
-- 
2.1.4

WARNING: multiple messages have this Message-ID (diff)
From: marc.zyngier@arm.com (Marc Zyngier)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 09/18] arm64: KVM: Runtime detection of lower HYP offset
Date: Thu, 30 Jun 2016 18:40:42 +0100	[thread overview]
Message-ID: <1467308451-13365-10-git-send-email-marc.zyngier@arm.com> (raw)
In-Reply-To: <1467308451-13365-1-git-send-email-marc.zyngier@arm.com>

Add the code that enables the switch to the lower HYP VA range.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
 arch/arm64/kernel/cpufeature.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 811773d..ffb3e14d 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -726,6 +726,19 @@ static bool runs_at_el2(const struct arm64_cpu_capabilities *entry, int __unused
 	return is_kernel_in_hyp_mode();
 }
 
+static bool hyp_offset_low(const struct arm64_cpu_capabilities *entry,
+			   int __unused)
+{
+	phys_addr_t idmap_addr = virt_to_phys(__hyp_idmap_text_start);
+
+	/*
+	 * Activate the lower HYP offset only if:
+	 * - the idmap doesn't clash with it,
+	 * - the kernel is not running at EL2.
+	 */
+	return idmap_addr > GENMASK(VA_BITS - 2, 0) && !is_kernel_in_hyp_mode();
+}
+
 static const struct arm64_cpu_capabilities arm64_features[] = {
 	{
 		.desc = "GIC system register CPU interface",
@@ -803,6 +816,12 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
 		.field_pos = ID_AA64PFR0_EL0_SHIFT,
 		.min_field_value = ID_AA64PFR0_EL0_32BIT_64BIT,
 	},
+	{
+		.desc = "Reduced HYP mapping offset",
+		.capability = ARM64_HYP_OFFSET_LOW,
+		.def_scope = SCOPE_SYSTEM,
+		.matches = hyp_offset_low,
+	},
 	{},
 };
 
-- 
2.1.4

  parent reply	other threads:[~2016-06-30 17:40 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-30 17:40 [PATCH v2 00/18] arm/arm64: KVM: Merge boot and runtime page tables Marc Zyngier
2016-06-30 17:40 ` Marc Zyngier
2016-06-30 17:40 ` [PATCH v2 01/18] arm64: KVM: Merged page tables documentation Marc Zyngier
2016-06-30 17:40   ` Marc Zyngier
2016-06-30 17:40 ` [PATCH v2 02/18] arm64: KVM: Always reference __hyp_panic_string via its kernel VA Marc Zyngier
2016-06-30 17:40   ` Marc Zyngier
2016-06-30 17:40 ` [PATCH v2 03/18] arm/arm64: KVM: Remove hyp_kern_va helper Marc Zyngier
2016-06-30 17:40   ` Marc Zyngier
2016-06-30 17:40 ` [PATCH v2 04/18] arm64: KVM: Kill HYP_PAGE_OFFSET Marc Zyngier
2016-06-30 17:40   ` Marc Zyngier
2016-06-30 17:40 ` [PATCH v2 05/18] arm64: Add ARM64_HYP_OFFSET_LOW capability Marc Zyngier
2016-06-30 17:40   ` Marc Zyngier
2016-06-30 17:40 ` [PATCH v2 06/18] arm64: KVM: Define HYP offset masks Marc Zyngier
2016-06-30 17:40   ` Marc Zyngier
2016-06-30 17:40 ` [PATCH v2 07/18] arm64: KVM: Refactor kern_hyp_va to deal with multiple offsets Marc Zyngier
2016-06-30 17:40   ` Marc Zyngier
2016-06-30 17:40 ` [PATCH v2 08/18] arm/arm64: KVM: Export __hyp_text_start/end symbols Marc Zyngier
2016-06-30 17:40   ` Marc Zyngier
2016-06-30 17:40 ` Marc Zyngier [this message]
2016-06-30 17:40   ` [PATCH v2 09/18] arm64: KVM: Runtime detection of lower HYP offset Marc Zyngier
2016-06-30 17:40 ` [PATCH v2 10/18] arm/arm64: KVM: Always have merged page tables Marc Zyngier
2016-06-30 17:40   ` Marc Zyngier
2016-06-30 17:40 ` [PATCH v2 11/18] arm64: KVM: Simplify HYP init/teardown Marc Zyngier
2016-06-30 17:40   ` Marc Zyngier
2016-06-30 17:40 ` [PATCH v2 12/18] arm/arm64: KVM: Drop boot_pgd Marc Zyngier
2016-06-30 17:40   ` Marc Zyngier
2016-06-30 17:40 ` [PATCH v2 13/18] arm/arm64: KVM: Kill free_boot_hyp_pgd Marc Zyngier
2016-06-30 17:40   ` Marc Zyngier
2016-06-30 17:40 ` [PATCH v2 14/18] arm: KVM: Simplify HYP init Marc Zyngier
2016-06-30 17:40   ` Marc Zyngier
2016-06-30 17:40 ` [PATCH v2 15/18] arm: KVM: Allow hyp teardown Marc Zyngier
2016-06-30 17:40   ` Marc Zyngier
2016-06-30 17:40 ` [PATCH v2 16/18] arm/arm64: KVM: Prune unused #defines Marc Zyngier
2016-06-30 17:40   ` Marc Zyngier
2016-06-30 17:40 ` [PATCH v2 17/18] arm/arm64: KVM: Check that IDMAP doesn't intersect with VA range Marc Zyngier
2016-06-30 17:40   ` Marc Zyngier
2016-06-30 17:40 ` [PATCH v2 18/18] arm/arm64: Get rid of KERN_TO_HYP Marc Zyngier
2016-06-30 17:40   ` Marc Zyngier
2016-07-03 21:44 ` [PATCH v2 00/18] arm/arm64: KVM: Merge boot and runtime page tables Christoffer Dall
2016-07-03 21:44   ` Christoffer Dall

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=1467308451-13365-10-git-send-email-marc.zyngier@arm.com \
    --to=marc.zyngier@arm.com \
    --cc=christoffer.dall@linaro.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.