From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A29862F12AB for ; Fri, 12 Jun 2026 15:17:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781277453; cv=none; b=mG71TbTPuFu68yw+q693qc1TNVpx7pbTzuhdxFomrcslxF8BnAmN5bDS8nqZ0XT9UcYiVyfERLqrs+09OshIdVscY9z+uIEHX8EZH/bqj6XX8ZmH5j3Vm/gQ8TPPJGIv5ZvRJR/hpKGTFXPZb/i5fq9EBG8SG42MABYIxUlDfrE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781277453; c=relaxed/simple; bh=YGzz9U5ptAN+fJtxvPnrBajIVB0+7ihNMtCDsAQmleU=; h=From:To:Cc:Subject:In-Reply-To:Date:Message-ID:References; b=GtwiSG43uHMiiqwFYwqMSHIpzf0LxvZfT8iectJ+cfH+97cwhI7pb9knen9IJBUh8/0yLmojFzcjAetlOeWS69GOmEhbQux7OqegxTwiK+ypgnFCXd5YymWsrudeokfY8EWOSveb5tjX2E/z+InEzVae5o8yh7IA8u9HkkEdoAE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=V3TC/XdO; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V3TC/XdO" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2bf237e1433so12778295ad.1 for ; Fri, 12 Jun 2026 08:17:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781277452; x=1781882252; darn=vger.kernel.org; h=references:message-id:date:in-reply-to:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=hKi6voXMiSHRHdUtGCaL73/GFSuif8U6u8yo1gqGgaw=; b=V3TC/XdONPkSMS+lgesKaCdZkj6lBs/eBCXYEBXiWEpGOKVv4jFS/MB+xgO6zijWAS HpTtOy8Pu4Qf+/Msrh9P0XKA6kfAb0T0vqylWrUqdwyIqw+XbOJWhER9i8NJs6p1m3hH umARVSukOTRhFM1vQUQXgPAIrCDif4d8ETnZoCzozCd6LQPFL3tIUDCyaIEDQhAVXyDj 4mQDQVDCXHYc4vI4iafdv9H2SW4jY53/4YIv4yJb4HQmBtmwsMfrEEVEAoAQ0y8Nidf0 uKHEty5QWE6R6MADwGz+gqhF2beOWvpFCzhk7YHg8BvgOmyj+IBOymB3+imN6W2+XYkJ fGgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781277452; x=1781882252; h=references:message-id:date:in-reply-to:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hKi6voXMiSHRHdUtGCaL73/GFSuif8U6u8yo1gqGgaw=; b=JJN9qy9p7iRs72Futxk8OtIP4Xl/5106ex6+iOOAcHvBZHt64zdR/k56rYFdLxjGv0 GRQbTJUHeP0R2Ozpn4AegSdGsKaw/yLmSDP6P4xbEF8wCSFtGkKYdDZRMojHf3HYVl6k FpkebpJ389scyfVb+lW6tZJQXZJsOdOj1n4pWxuiVX4b3ri/d/PWWF72+GRVakQ5MVeG rfIS91TDY5ZRrr0vBILz94He3Pm2YPBAFzC2f0mDlw7xntgoK2FrGvsBrVPHpos4RQsB Nxw1Si/b9XrsIkskFLmzeE4gF3HEceSBQTb+/pFxhBp/6QKHUAaJti6SzIrOYimHRo1u IvCg== X-Forwarded-Encrypted: i=1; AFNElJ/E/WhqvbQizhsJ/23q638iBnMGRfX8HiYve/0IZ9j6+rKDBBiTPrnd2GZk9dezJpLq+MmX1fecknVvfSk=@vger.kernel.org X-Gm-Message-State: AOJu0YwpxM9kTEmZaT3D7IwQ95DNxG4yz98rIc8KoI5k2s+dWMna1/jE qg6K9E8N1MCnojxhZYoKMQZS48uI+sF2/33wh6qiDUH4dd/hfDXiMaS4 X-Gm-Gg: Acq92OETEJq6cvbMNdpYj9IxTiIUCP+tO7MO3/ja5ADoYdUazH+OgmXZD3/w4Yb3R1c Hwd8kzf4xZ5gLW31TO3GEUR094572Ajdn6s7CnWI2/e1bbsMXT4Bfyshj+AMGmK9LVLV+UR57xl DNWuR8mgeU9ZaY8TwPEvI0VkdNBdUQLR77Ia38vHcMfkJOkKYH8BHY/yFasUQjRJrYGBi8qp5ou goT++t5xtMhaLPL22imnO17Ka7jqSqyfQLG3Jdx1s1Vic5l+jJUs//bcAW1g8FvRDSCfmkYcC5o 8dqwSggQu16lt4Zc8olFAq25f366d9uoXgDIdK7uPsH2Xfw4GhHUZU16jansKlG4VJGL18pY70V NkSVgofWxJ4eA5ygx4NsgZJjyZVLxnD1g2BmDfbs4VqZyAS743zw2rm+4G68cOS4gjk2hjVkLTH ES2GHNwW/hT9k+/ZITeNgcb+HcmA== X-Received: by 2002:a17:903:2285:b0:2c0:db23:4a4 with SMTP id d9443c01a7336-2c412d25493mr38857585ad.36.1781277452015; Fri, 12 Jun 2026 08:17:32 -0700 (PDT) Received: from pve-server ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c4327ac72asm26390065ad.38.2026.06.12.08.17.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jun 2026 08:17:31 -0700 (PDT) From: Ritesh Harjani (IBM) To: Sean Christopherson Cc: kvm@vger.kernel.org, Paolo Bonzini , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Michael Ellerman , Christophe Leroy , Anushree Mathur , Venkat Rao Bagalkote , Harsh Prateek Bora , Ackerley Tng , Christian Borntraeger , Claudio Imbrenda , Nicholas Piggin Subject: Re: [PATCH v3 RESEND 04/10] KVM: PPC: selftests: powerpc enable kvm_create_max_vcpus test In-Reply-To: Date: Fri, 12 Jun 2026 20:44:17 +0530 Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Sean Christopherson writes: > On Fri, Jun 12, 2026, Ritesh Harjani wrote: >> Sean Christopherson writes: >> >> > On Wed, Jun 10, 2026, Ritesh Harjani (IBM) wrote: >> >> From: Nicholas Piggin >> >> >> >> powerpc's maximum permitted vCPU ID depends on the VM's SMT mode, and >> >> the maximum reported by KVM_CAP_MAX_VCPU_ID exceeds a simple non-SMT >> >> VM's limit. >> >> >> >> The powerpc KVM selftest port uses non-SMT VMs, so add a workaround >> >> to the kvm_create_max_vcpus test case to limit vCPU IDs to >> >> KVM_CAP_MAX_VCPUS on powerpc. >> > >> > How is this not a KVM bug? Literally the reason this test exists is to validate >> > KVM's advertised KVM_CAP_MAX_VCPU_ID and KVM_CAP_MAX_VCPUS. >> >> It's not a KVM bug, it's expected on PowerPC. On PowerPC, vCPU ID encodes SMT topology, e.g. on P9, >> vcpu id = core * stride + thread, >> .. where the stride is same as kvm->arch.emul_smt_mode (VM's emulated SMT mode) >> >> So the vcpu ID space can be sparse, however KVM_CAP_MAX_VCPU_ID is the >> absolute ceil value (MAX_SMT_THREADS * KVM_MAX_VCORES) i.e. the value >> with the maximum stride / SMT value. >> >> Since default selftest VM uses stride 1, so it rejects IDS >= max_vcpus. >> >> e.g. >> static int kvmppc_core_vcpu_create_hv(struct kvm_vcpu *vcpu) >> ... >> if (id >= (KVM_MAX_VCPUS * kvm->arch.emul_smt_mode)) { >> pr_devel("KVM: VCPU ID too high\n"); >> core = KVM_MAX_VCORES; /* rejected case */ >> } else { >> >> So, it's expected on PowerPC. vcpus with higher IDs can be created but >> for that we need to set KVM_CAP_PPC_SMT and use strided (sparse) IDs. >> But since the test as of now is not doing that - that's the reason why >> the patch only allows to test max vcpu IDs upto max vcpus. >> >> But I guess you must be hating the #ifdef __powerpc__ there. I agree I >> don't like it either.. maybe we can do it this way? > > I don't love the #ifdef, but it's more that I didn't want to effectively skip a > test because KVM was reporting bad information. But after peeking at KVM_CAP_PPC_SMT, > I 100% agree we don't want to deal with that here. > >> -#ifdef __powerpc64__ >> /* >> - * powerpc has a particular format for the vcpu ID that depends on >> - * the guest SMT mode, and the max ID cap is too large for non-SMT >> - * modes, where the maximum ID is the same as the maximum vCPUs. >> + * Some architectures (e.g. powerpc) encode topology into the vCPU ID, >> + * so a default VM can't necessarily use the full advertised ID range. >> + * Let the arch limit the highest ID this test will create. >> */ >> - kvm_max_vcpu_id = kvm_max_vcpus; >> -#endif >> + kvm_max_vcpu_id = kvm_arch_vcpu_id_limit(kvm_max_vcpus, kvm_max_vcpu_id); >> >> >> And then in kvm_util.c - >> + >> +__weak int kvm_arch_vcpu_id_limit(int nr_vcpus, int vcpu_id_max) >> +{ >> + return vcpu_id_max; >> +} > > What if we do this? We're going to be bleeding PPC details into the test no > matter what, adding an arch hooks just seems like extra cruft and an unnecessary > layer of indirection. > > /* > * Skip the vCPU ID test when running on PowerPC with SMT support, in > * which case system topology is encoded into the vCPU ID, and so a VM > * can't use the full advertised vCPU ID range without crafting a valid > * platform specific topology. > */ > if (kvm_max_vcpu_id > kvm_max_vcpus && !kvm_check_cap(KVM_CAP_PPC_SMT)) > test_vcpu_creation( > kvm_max_vcpu_id - kvm_max_vcpus, kvm_max_vcpus); Thanks! That should do and I think that's the most cleaner version. I will change patch-4 with your suggested changes then. -ritesh