linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Vincent Donnefort <vdonnefort@google.com>,
	oliver.upton@linux.dev, kvmarm@lists.linux.dev,
	qperret@google.com, smostafa@google.com, kaleshsingh@google.com,
	linux-arm-kernel@lists.infradead.org, kernel-team@android.com,
	will@kernel.org
Subject: Re: [PATCH v2] KVM: arm64: Remove size-order align in the nVHE hyp private VA range
Date: Mon, 28 Aug 2023 14:19:30 +0100	[thread overview]
Message-ID: <861qfnfgnx.wl-maz@kernel.org> (raw)
In-Reply-To: <79b0ad6e-0c2a-f777-d504-e40e8123d81d@samsung.com>

On Mon, 28 Aug 2023 13:16:51 +0100,
Marek Szyprowski <m.szyprowski@samsung.com> wrote:
> 
> On 11.08.2023 13:20, Vincent Donnefort wrote:
> > commit f922c13e778d ("KVM: arm64: Introduce
> > pkvm_alloc_private_va_range()") and commit 92abe0f81e13 ("KVM: arm64:
> > Introduce hyp_alloc_private_va_range()") added an alignment for the
> > start address of any allocation into the nVHE hypervisor private VA
> > range.
> >
> > This alignment (order of the size of the allocation) intends to enable
> > efficient stack verification (if the PAGE_SHIFT bit is zero, the stack
> > pointer is on the guard page and a stack overflow occurred).
> >
> > But this is only necessary for stack allocation and can waste a lot of
> > VA space. So instead make stack-specific functions, handling the guard
> > page requirements, while other users (e.g.  fixmap) will only get page
> > alignment.
> >
> > Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
> 
> This change, merged to linux-next as f156a7d13fc3 ("KVM: arm64: Remove 
> size-order align in the nVHE hyp private VA range"), introduced the 
> following regression on Raspberry Pi4b board. Here is a log observed on 
> linux next-20230828 release:
> 
> --->8---
> 
> kvm [1]: IPA Size Limit: 44 bits
> ------------[ cut here ]------------
> WARNING: CPU: 0 PID: 1 at arch/arm64/kvm/hyp/pgtable.c:453 
> hyp_map_walker+0xb0/0x120
> Modules linked in:
> CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.5.0-next-20230828 #13889
> Hardware name: Raspberry Pi 4 Model B (DT)
> pstate: 00000005 (nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
> pc : hyp_map_walker+0xb0/0x120
> lr : hyp_map_walker+0x30/0x120
> ...
> Call trace:
>   hyp_map_walker+0xb0/0x120
>   kvm_pgtable_visitor_cb.isra.0+0x38/0x5c
>   __kvm_pgtable_walk+0x1dc/0x32c
>   __kvm_pgtable_walk+0xd0/0x32c
>   __kvm_pgtable_walk+0xd0/0x32c
>   __kvm_pgtable_walk+0xd0/0x32c
>   kvm_pgtable_walk+0xd0/0x224
>   kvm_pgtable_hyp_map+0x8c/0xf0
>   __create_hyp_mappings+0x98/0xc0
>   __create_hyp_private_mapping+0xf0/0x14c
>   create_hyp_io_mappings+0x8c/0x118
>   vgic_v2_probe+0xbc/0x1ec
>   kvm_vgic_hyp_init+0xcc/0x210
>   kvm_arm_init+0x6a4/0x1040

Ah, wonderful. Can you give the snippet below a go?

diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
index 11c1d786c506..50be51cc40cc 100644
--- a/arch/arm64/kvm/mmu.c
+++ b/arch/arm64/kvm/mmu.c
@@ -652,6 +652,9 @@ int hyp_alloc_private_va_range(size_t size, unsigned long *haddr)
 
 	mutex_unlock(&kvm_hyp_pgd_mutex);
 
+	if (!ret)
+		*haddr = base;
+
 	return ret;
 }
 

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-08-28 13:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230828121652eucas1p11cc5921bd55c7e90f83d1938a358237f@eucas1p1.samsung.com>
2023-08-11 11:20 ` [PATCH v2] KVM: arm64: Remove size-order align in the nVHE hyp private VA range Vincent Donnefort
2023-08-11 21:55   ` Kalesh Singh
2023-08-14  7:40     ` Vincent Donnefort
2023-08-26 11:00     ` Marc Zyngier
2023-08-26 13:02   ` Marc Zyngier
2023-08-28 12:16   ` Marek Szyprowski
2023-08-28 13:19     ` Marc Zyngier [this message]
2023-08-28 13:43       ` Marek Szyprowski

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=861qfnfgnx.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=kaleshsingh@google.com \
    --cc=kernel-team@android.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=m.szyprowski@samsung.com \
    --cc=oliver.upton@linux.dev \
    --cc=qperret@google.com \
    --cc=smostafa@google.com \
    --cc=vdonnefort@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;
as well as URLs for NNTP newsgroup(s).