From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 64E55CFD636 for ; Wed, 7 Jan 2026 13:45:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=f50r9o/apZYEhSlUpxuAT6n0HCDC8jD1nc1uCfC4uoo=; b=fTiLTD8BLQbj1qC/1LWcPdPYAb IXGBh+Am5mWTu7PQEWMB++k9V46BOXVuG0DLIrKZlH70JBoz30GmWk2cHWi67tR9YeffjEeraiCjJ 1RPTuwFoodSkTkqiqezUKfhFmackEtIEZn+b1fHxQvq+3mgGVDrlpQ86aEnlJY0H2qwJ3reno0D9r Mgj6uz/QqqLhCKj/fsNCiCaN3fSieQyRfc5rVM5+hMWds5g2YP/czwkRYhW2PSRHCM0WJqIZci3K6 OJiTTmaZSZIxH/ft+1/EbOygDiCAcaawmnccS270QSqHGVfS5tBojyvZKjoLnbXwV+Nja3w4Ma+nv Cp7OnG1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vdTqe-0000000F1r0-0YCO; Wed, 07 Jan 2026 13:45:16 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vdTqd-0000000F1qs-18vJ for linux-arm-kernel@lists.infradead.org; Wed, 07 Jan 2026 13:45:15 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 432986000A; Wed, 7 Jan 2026 13:45:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6149C4CEF7; Wed, 7 Jan 2026 13:45:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767793514; bh=FUnu2/d32Z+rAwqi5Nbaz8wsPSyg/MoQclwAm3YXqJk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=itAl+snnQm40572JvVmDdz8fg0UKD82AkqmTnYzf0FqWfkzJSUt0WvzaReVRrJJ6h tcVIJ36cfg7wOZJxuEo4QQi4XI9UziTM88AFs/dLEspvRUANEw1qFwfaHDfyTpQyrY htNZP/BPlGFclpvjzFxaEF5Jewz7fMmxrsyvz1YoQJyKb5RztrkKM8lk7ZI0W11Orw gasKTLhSTJcXU97+VdtxTxi4j7q8FS2YgLDEL9foemX5/udIE5TQBbEUX44jq0ZQEa IANNpcfJuWELF5OFxMIO8orhEG4cpTIGTUpCe0d3HwoPr/SJY5njTSzlGgBAS3VXFB 7HB12GuhC2CvA== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vdTqZ-000000005dY-2U3q; Wed, 07 Jan 2026 13:45:11 +0000 Date: Wed, 07 Jan 2026 13:45:11 +0000 Message-ID: <86cy3lmt94.wl-maz@kernel.org> From: Marc Zyngier To: Vincent Donnefort Cc: rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, linux-trace-kernel@vger.kernel.org, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, jstultz@google.com, qperret@google.com, will@kernel.org, aneesh.kumar@kernel.org, kernel-team@android.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v9 21/30] KVM: arm64: Initialise hyp_nr_cpus for nVHE hyp In-Reply-To: <20251202093623.2337860-22-vdonnefort@google.com> References: <20251202093623.2337860-1-vdonnefort@google.com> <20251202093623.2337860-22-vdonnefort@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: vdonnefort@google.com, rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, linux-trace-kernel@vger.kernel.org, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, jstultz@google.com, qperret@google.com, will@kernel.org, aneesh.kumar@kernel.org, kernel-team@android.com, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 02 Dec 2025 09:36:14 +0000, Vincent Donnefort wrote: > > Knowing the number of CPUs is necessary for determining the boundaries > of per-cpu variables, which will be used for upcoming hypervisor > tracing. hyp_nr_cpus which stores this value, is only initialised for > the pKVM hypervisor. Make it accessible for the nVHE hypervisor as well. > > With the kernel now responsible for initialising hyp_nr_cpus, the > nr_cpus parameter is no longer needed in __pkvm_init. > > Signed-off-by: Vincent Donnefort > > diff --git a/arch/arm64/include/asm/kvm_hyp.h b/arch/arm64/include/asm/kvm_hyp.h > index e6be1f5d0967..b169d85458f9 100644 > --- a/arch/arm64/include/asm/kvm_hyp.h > +++ b/arch/arm64/include/asm/kvm_hyp.h > @@ -128,8 +128,7 @@ void __noreturn __hyp_do_panic(struct kvm_cpu_context *host_ctxt, u64 spsr, > #ifdef __KVM_NVHE_HYPERVISOR__ > void __pkvm_init_switch_pgd(phys_addr_t pgd, unsigned long sp, > void (*fn)(void)); > -int __pkvm_init(phys_addr_t phys, unsigned long size, unsigned long nr_cpus, > - unsigned long *per_cpu_base, u32 hyp_va_bits); > +int __pkvm_init(phys_addr_t phys, unsigned long size, unsigned long *per_cpu_base, u32 hyp_va_bits); > void __noreturn __host_enter(struct kvm_cpu_context *host_ctxt); > #endif > > @@ -146,5 +145,6 @@ extern u64 kvm_nvhe_sym(id_aa64smfr0_el1_sys_val); > extern unsigned long kvm_nvhe_sym(__icache_flags); > extern unsigned int kvm_nvhe_sym(kvm_arm_vmid_bits); > extern unsigned int kvm_nvhe_sym(kvm_host_sve_max_vl); > +extern unsigned long kvm_nvhe_sym(hyp_nr_cpus); > > #endif /* __ARM64_KVM_HYP_H__ */ > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > index 052bf0d4d0b0..7ba427f9608c 100644 > --- a/arch/arm64/kvm/arm.c > +++ b/arch/arm64/kvm/arm.c > @@ -35,6 +35,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -2396,7 +2397,7 @@ static int __init do_pkvm_init(u32 hyp_va_bits) > preempt_disable(); > cpu_hyp_init_context(); > ret = kvm_call_hyp_nvhe(__pkvm_init, hyp_mem_base, hyp_mem_size, > - num_possible_cpus(), kern_hyp_va(per_cpu_base), > + kern_hyp_va(per_cpu_base), > hyp_va_bits); > cpu_hyp_init_features(); > > @@ -2605,6 +2606,8 @@ static int __init init_hyp_mode(void) > kvm_nvhe_sym(kvm_arm_hyp_percpu_base)[cpu] = (unsigned long)page_addr; > } > > + kvm_nvhe_sym(hyp_nr_cpus) = num_possible_cpus(); Is num_possible_cpus() always the correct thing to do? Given that pKVM doesn't support late onlining, this really should be the number of online CPUs. Probably not a big deal, but worth thinking about it. Thanks, M. -- Without deviation from the norm, progress is not possible.