From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796243196; b=ZArLRoGcyzI1TA9NQjpN51xrdtimCi7O2DfJpfg/a7hFIWcI/5IYJoG9sxhBgKV04XuY dQM44Aj94PSNd13bE4oEVzqXjdU3kdOrcJa2scwH08iAyz5XOW7rGVJ+ofwDS0jNSR8fP VfphI9ed34f9VX9agynZug3r5BTg4dG/Vwv52ZVsIgaAfFMfIRE4oW7ugwTyiCALvjkyH 1g+l/g3xMb7+oWpWGuZsT2YuNCQXK7nNeAQSbD/KYiOAsbB8uYlocK93JbIMq81GvaWFc D3KDeikfsYT3W0jLXoWVLXnzlPTWEJenVUVMDjTDyseuZO8/fc/6Uq7FdIMhD2bKdYQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796243196; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=A/28dTi8XFhp1lF0jJwUmA+ra+sNVFCaSWz6rq915nw=; b=CbxaGsYjX+Z2g+BhPbyg6ON8t4F+UjMfplORlVA9a+MJLd6sbTYHHzVdOIfGG/lLP5Yx D4sHFkUC4SXllH7IPbkFK+OFxsDNa74G+Z6c3pHBjgfiklsGnOLmlCMx+TdVcN8rzgzkp n/33FYJJZZKp/rPdzopNfSt6J9fVNU+nwPGfO9aeYQQ3fWTh9aeGTT0mkq1yEf8unnh73 MKzTMaKPiOPhvI6U4fghPZyaYydKODXaoHWPJMxBC+nL34tCGuT+ii/Wfp6DI6I/uupC3 /22sPfKizEU7m521pvBo6ee9sSiwP6xk53KokVTAyUSplS9H6iZ09pP2O9M3tlp79Hg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=SvBo+oXg; arc=none smtp.remote-ip=209.85.221.43 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2935606A332 for ; Wed, 2 Dec 2026 20:26:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B2935606A332 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=SvBo+oXg Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-4ac109a8a12so8080207f8f.3 for ; Wed, 02 Dec 2026 12:26:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796243194; x=1796847994; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=A/28dTi8XFhp1lF0jJwUmA+ra+sNVFCaSWz6rq915nw=; b=SvBo+oXgOJaKnHTKPvSG5CFQ8xcW7fTzsuEiagzHKbh62CPrxeC3VBWspFVtPFWFLC ZWzY0y7i4BzBmhYaTfFpSZ+7jA1Lajpx4gkdYdDDxx5DZRtNhEZrKDR+tTwojjlzAcWu r2lMRuv+nHNcRy8tRCbj8L8R4pShzungQouH0YLZj+S1kaL6hUUJvPUmANHHjI8mszPy XENp7N2zzaYX96mUCp+XHFKL3Esh0JefgKQKuwzF6qDkfaVv6/JLlKJ/xhJyHM3QFwhd VNC9y0V7qIlhLSxDl5w8BO0r7dHqwWvJSuTB6iH82R2u5iGD9nLsPhc+ufYlD4in4M6u 5/wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796243194; x=1796847994; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=A/28dTi8XFhp1lF0jJwUmA+ra+sNVFCaSWz6rq915nw=; b=Z8/AUVW/al3z1f7AscbpYy8GeGrfgzGRdBNHqOGpxf+8hW5aXZ5fJytujEUoS7XQAe MT/6xUxLzqBMAmc8W8sfUUg1g5Lowii0n0nVcnzDcH79TNrwH5MTzE8TRkOfF66nli5+ T5lxVrQMg4+XBSX65nPxzS03KsOsT29G//hDmk8t1L0U+D3Ae7kmEeOewbByLJnwVola GDamYAJe96jHADGwKeoYieVDBP2Q8Kf5zPG75i4hoFCxswxePeJYLAWwFLXLxTI9DgBt FW70jiMChrd2R/RkBN88FJVj1siKtIFIZsdPvcO+7/BOpUJfHO+XhUuFzLrSvOlXdKd4 d9mw== X-Forwarded-Encrypted: i=1; AL+hErESE1PDLrxq05etrB7QVC1/Z1yYAvzkQA/+fm5YGBpC14fgyu+0c+TXQ+ATnH6h8Ktff8s=@vger.kernel.org X-Gm-Message-State: APuU4Z9zm4+0Eq7U1WWKM+OCHhpsIeXKWz5Xk7quRNp/4FSrlN5+f5YN Aa3baoHMfx30uFEDTReEx5JB5eKNW0IuvcWxMcux1GEGnnEqxhrPJF+Wdg0DCeA7XA== X-Gm-Gg: AZFdTZdwk4VrbOO64W9WocjxrhY1nRT476HTMCCU5fAYCFwnACJpiQ6yXRcqPHXCk0R tjkKTjRn0IMlhEF6SPocUzK3tHNldkkxnua1tnny70qnSE4TGkNwjHVhlOrjrVGdxPS32FVblFS K8BOgWYP1EZtEF24KVO2HyAClZwmUXKaLTMyIbDCL0PA1322QNhFBYlZ9xxkOBUoAEsWXiynqQu wV11LxEYUTSarjZdqSkdWOnN0mvz8Ugb4ILItJdesCAuxxBzO4njbeAxSE6RMizp4AtA1yT7cbK c0bLPH69wzOCVPdt7CoxPttN7NoXPLKI/C5/3pTvscEO+TfWsCeSqQDrfxpQoAU3EhKc/mvKuX+ 6yIlIQHoB4HzV9GddQegdnmkxl0sUF/JRn4MvSL6Y71GMTVr+XA4FL5eviSovi50VDggtjSLwc3 RJTufHkw41ahdb87jA+MuyL5DJgTi4kmnQYd7xajSLrz8m5lO131+NzO2rMa8PeGd+AkGvs8LKq SLSfzLY+RRe7M4LfvtwimdjFOV3r+WkKadAXSHORI6Y+rO0fKXYXhzv5ujEojUgnXqEpnD7usW+ gg+cvucIGbKVJMGdK6TqA7y1SpDb84VFK8KrNiVLsTKE9R3xKRDdjXXhA9VmLkiggSUWlUpliLd jrP6ICB1xo4WjSjlaDP9R X-Received: by 2002:a5d:5e8f:0:b0:48f:bf71:2ad9 with SMTP id ffacd0b85a97d-4abb400bcb1mr84155054f8f.41.1796243193533; Wed, 02 Dec 2026 12:26:33 -0800 (PST) Received: from google.com (0.182.34.34.bc.googleusercontent.com. [34.34.182.0]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4cd29a369c1sm5256439f8f.57.2026.12.02.12.26.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 12:26:32 -0800 (PST) Date: Wed, 2 Dec 2026 20:26:29 +0000 From: Vincent Donnefort To: Fuad Tabba Cc: Marc Zyngier , Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Mark Rutland , Quentin Perret , Martijn Bogaard , Steffen Eiden , Fuad Tabba , kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/3] KVM: arm64: Align the pKVM selftest VM's stage-2 PGD Message-ID: References: <20261105075606.367005-1-fuad.tabba@linux.dev> <20261105075606.367005-3-fuad.tabba@linux.dev> X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261105075606.367005-3-fuad.tabba@linux.dev> On Thu, Nov 05, 2026 at 07:56:05AM +0000, Fuad Tabba wrote: > With CONFIG_NVHE_EL2_DEBUG, pKVM init sets up a selftest VM whose PGD is > the start of its 32-page block. That block is the first allocation out > of the hyp reserve, which falls back to page alignment when its > PMD-aligned allocation fails (512M on a 64K host). > > A PGD of concatenated tables must be naturally aligned, or the VM's pool > never coalesces it into a block hyp_alloc_pages() can return. So when > the reserve isn't aligned to the PGD's size, the allocation in > guest_s2_zalloc_pages_exact() fails and pKVM init panics. A 64K host > with a 44-bit PA has a four-page PGD, and on a 1G QEMU VM the reserve > landed at 0x7fae0000. > > Take the aligned pages inside the block instead. The pages either side > of it go to the memcache and the pool. The PGD is at most 16 pages, so > it always fits. > > Fixes: 48d5645072930 ("KVM: arm64: Extend pKVM selftest for np-guests") > Signed-off-by: Fuad Tabba > --- > arch/arm64/kvm/hyp/nvhe/pkvm.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/kvm/hyp/nvhe/pkvm.c b/arch/arm64/kvm/hyp/nvhe/pkvm.c > index 03e530e15b4a2..820baf9ff74a2 100644 > --- a/arch/arm64/kvm/hyp/nvhe/pkvm.c > +++ b/arch/arm64/kvm/hyp/nvhe/pkvm.c > @@ -847,10 +847,14 @@ struct pkvm_hyp_vcpu *init_selftest_vm(void *virt) > { > struct hyp_page *p = hyp_virt_to_page(virt); > unsigned long min_pages, seeded = 0; > + void *pgd; > int i; > > selftest_vm.kvm.arch.mmu.vtcr = host_mmu.arch.mmu.vtcr; > - WARN_ON(kvm_guest_prepare_stage2(&selftest_vm, virt)); > + > + /* A concatenated PGD must be naturally aligned for the pool to coalesce it. */ > + pgd = PTR_ALIGN(virt, kvm_pgtable_stage2_pgd_size(selftest_vm.kvm.arch.mmu.vtcr)); > + WARN_ON(kvm_guest_prepare_stage2(&selftest_vm, pgd)); > > /* > * Mirror pkvm_refill_memcache() for the share/donate pre-checks; > -- > 2.47.3 > I believe the patch from the THPs series where I make this selftest an HVC and allocate that memory with __get_free_pages() [1] fixes this issue. If this one doesn't get backported, perhaps this isn't necessary? [1] https://lore.kernel.org/all/20261130155710.2371874-6-vdonnefort@google.com/ -- Vincent