public inbox for kvmarm@lists.cs.columbia.edu
 help / color / mirror / Atom feed
From: Kalesh Singh <kaleshsingh@google.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Joey Gouly <joey.gouly@arm.com>,
	Kalesh Singh <kaleshsingh@google.com>,
	will@kernel.org, kvmarm@lists.cs.columbia.edu,
	Andrew Walbran <qwandor@google.com>,
	maz@kernel.org, linux-arm-kernel@lists.infradead.org,
	kernel-team@android.com,
	Pasha Tatashin <pasha.tatashin@soleen.com>,
	surenb@google.com, Peter Collingbourne <pcc@google.com>,
	linux-kernel@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>
Subject: [PATCH 1/7] KVM: arm64: Map the stack pages in the 'private' range
Date: Thu, 10 Feb 2022 14:41:42 -0800	[thread overview]
Message-ID: <20220210224220.4076151-2-kaleshsingh@google.com> (raw)
In-Reply-To: <20220210224220.4076151-1-kaleshsingh@google.com>

From: Quentin Perret <qperret@google.com>

In preparation for introducing guard pages for the stacks, map them
in the 'private' range of the EL2 VA space in which the VA to PA
relation is flexible when running in protected mode.

Signed-off-by: Quentin Perret <qperret@google.com>
[Kalesh - Refactor, add comments, resolve conflicts,
          use  __pkvm_create_private_mapping()]
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
---
 arch/arm64/kvm/hyp/nvhe/setup.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/kvm/hyp/nvhe/setup.c b/arch/arm64/kvm/hyp/nvhe/setup.c
index 27af337f9fea..99e178cf4249 100644
--- a/arch/arm64/kvm/hyp/nvhe/setup.c
+++ b/arch/arm64/kvm/hyp/nvhe/setup.c
@@ -105,11 +105,19 @@ static int recreate_hyp_mappings(phys_addr_t phys, unsigned long size,
 		if (ret)
 			return ret;
 
-		end = (void *)per_cpu_ptr(&kvm_init_params, i)->stack_hyp_va;
+		/* Map stack pages in the 'private' VA range */
+		end = (void *)__hyp_pa(per_cpu_ptr(&kvm_init_params, i)->stack_hyp_va);
 		start = end - PAGE_SIZE;
-		ret = pkvm_create_mappings(start, end, PAGE_HYP);
-		if (ret)
-			return ret;
+		start = (void *)__pkvm_create_private_mapping((phys_addr_t)start,
+					PAGE_SIZE, PAGE_HYP);
+		if (IS_ERR_OR_NULL(start))
+			return PTR_ERR(start);
+		end = start + PAGE_SIZE;
+		/*
+		 * Update stack_hyp_va to the end of the stack page's
+		 * allocated 'private' VA range.
+		 */
+		per_cpu_ptr(&kvm_init_params, i)->stack_hyp_va = (unsigned long) end;
 	}
 
 	/*
-- 
2.35.1.265.g69c8d7142f-goog

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

  reply	other threads:[~2022-02-11  9:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-10 22:41 [PATCH 0/7] KVM: arm64: Hypervisor stack enhancements Kalesh Singh
2022-02-10 22:41 ` Kalesh Singh [this message]
2022-02-10 22:41 ` [PATCH 2/7] KVM: arm64: Factor out private range VA allocation Kalesh Singh
2022-02-10 22:41 ` [PATCH 3/7] arm64: asm: Introduce test_sp_overflow macro Kalesh Singh
2022-02-10 22:41 ` [PATCH 4/7] KVM: arm64: Allocate guard pages near hyp stacks Kalesh Singh
2022-02-14 14:06   ` Marc Zyngier
2022-02-14 22:03     ` Kalesh Singh
2022-02-10 22:41 ` [PATCH 5/7] KVM: arm64: Add Hyp overflow stack Kalesh Singh
2022-02-10 22:41 ` [PATCH 6/7] KVM: arm64: Unwind and dump nVHE HYP stacktrace Kalesh Singh
2022-02-10 22:41 ` [PATCH 7/7] KVM: arm64: Symbolize the nVHE HYP backtrace Kalesh Singh
2022-02-14 11:41 ` [PATCH 0/7] KVM: arm64: Hypervisor stack enhancements Marc Zyngier
2022-02-14 21:54   ` Kalesh Singh

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=20220210224220.4076151-2-kaleshsingh@google.com \
    --to=kaleshsingh@google.com \
    --cc=catalin.marinas@arm.com \
    --cc=joey.gouly@arm.com \
    --cc=kernel-team@android.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=pasha.tatashin@soleen.com \
    --cc=pbonzini@redhat.com \
    --cc=pcc@google.com \
    --cc=qwandor@google.com \
    --cc=surenb@google.com \
    --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