From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796243196; b=H0htbs1SUCvGK413PDG3rYbZlPafKXpCr/SKa9mN3Gg/3bo+fWpqw2Ryzw6x60cp/mwv foWBh7KAyDaLGS2JwyO/EuXJF2w0oagJDE54YVBpEwkMBUY1w3Hko0sfqOnCbWcmEcvcy mEcxGsZomvXroz71kaSiL6zZw0UagH1Hc3xtGudqQgKHCY3VLUeU5KPsxPoH3XKjGB5EW gyPehCEtS5ebUTBtACiSlHLFk9hnLtUV5FPRAfu32R4p2RwhmGKcFG2Lpl6E+m0vtGKqE 4+wYMgklLwu9XM3dMLCS+TmRuP0/tD56Z5+k95gZAFdEH2byFVk6qlKvtps6aFUseqw== 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=f92DS80ayMWzrvSssIRyPhex380xI/9TW5bvqG6nRi6kDs0vvXxnqrZPwJ21blvvZa4V Dehg+Odtf7BXoIXVNQwBdXVl+h9u9sTmwY3g2YMDT7PqkBxk31QnP+9tBHVkkGJqa0SGv VGQ6Itv8yNRSH5FC3rprcgx9/T88Oc3w/RBbx/19dY5dSbpUiy1vITiwNS5K3hADiw8V3 l1DzTDZpn6jE6DEVufltXjjiflML6bljf20EOOxGuazkkZP0bRk6f5VSoznnYhOoYryDc ypA02hab+1ORHI/R7+6jqywxTN9/7/Oyr45N4td4TzLp78W4sZAcGHWVjDpXgU/jAsA== 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.48 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 A3976606A338 for ; Wed, 2 Dec 2026 20:26:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A3976606A338 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, unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=SvBo+oXg Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-490c3ae81d3so8645551f8f.2 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=ss3H0lgfknT8Sqy+CANCmfznqc/oSndougS3xZbf3+C8rn7oRoIv2nCGUk2uW9fdVG tM21U/u9a9pkqtKnjcKcw6KcaJZCSAzXCQQp5gZcyRYcqHK8pEWHKM3fn6ksum/Re+dK wDlPDPC+ULsOxg9DKLmEg/DNDjubOVxY0t5LxfzU7I5dokd58wHbS/MkNr6SEPfpvsd7 1ZWwIJv13Co5gCC5mkazmDcI2ZlzzOOYKZws6q2+K0blNwBk8dat9ZIapTuVo4frUI0i ac/C+7B6AqsZlKH4hKt51gaJGeJqWp9loaMR/9ij8VOzO9bL6A5LPsIRL3NwCJVz4NcF hyFQ== X-Forwarded-Encrypted: i=1; AL+hErHIuPNCLz0+hOAQaZUgp8EZM7KyhJZJ7f9sKryXsn50GNCE+2neMW2GR67DkFlbqkyYEQWNWBTwK3uqNbY=@vger.kernel.org X-Gm-Message-State: APuU4Z/8qWoWeZlFX+HTSVhdZJKjVn6+ZyI4rpwsq24G8IAaTsZsVC8q Bk2U5iZO+uNnbYLDLn04Pmx4S5ZvZHBOSgcCCG+PZRI0KftVwpZREE6BDeOB7sdi5g== X-Gm-Gg: AZFdTZeauzvZMszHLgxZNQNbNOlKwUStx9tUtSdyewDClrQpeulGDJW6YCEVvYR7UVm pGTZZIfdw1XdxkMQKxWBeqAU6dQpAUS/LUlc389cQPUpFILMDKdZGd3+whL7LrKD3FWqnkTXYrG 2FRnG8HyBTBHr67ff8kkjGIx5LmAYJVUa6dicx+qYX+5GFt2iLm9uFAVYjS8sUWbQAtqp3nCFaU zNBz9UQIEbLJP70eQdIOb1KNp9Ka1WPtoAwe+1Rq69/F6/ivHL8/OtnqRMw25MboaAe8mQuCm1g l+j7+Uwkzh3Z5vUZssBgw4hvlIR1ACSeBPWdafiDSsZosAWrkM47cdDkgWjnZiZWjYh37LNwX2z 4Kr7AEOSicvK5kzyfM8IiHW63fRQuAv2+Qk7rW1u4kYMnTYzePQUi2YbYYYp2euXv3LsCoFaboy +F/EtRSFm+RVnS3XjowrYvvzjDxEsV6F5/4/7X6b8bUmNOm9KFbAgX4m+xqgwhlBkcO5av3D1pa wKgA8fjSAmUcmscXkYtFgPWq+qQQSLywNcEMhW0UwbKF2JgwEbCxibri7ZtLiAZq/8zRyWrYvGA JQQH3osIryoDxPuCBjC6HGdlWE9emVsVTBZXyVK/pzaWY7IPq4SETXyQQwf5Nbp7dG62k22XJ/x cDapNx1ql9QH0rGZ8DQKH 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: linux-kernel@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