From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 F37F83C5832 for ; Thu, 28 May 2026 10:50:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779965409; cv=none; b=qgYPjeshAi87rgnA5vl4bh36z+fpNrdxvZy7PhItopqs8OBwTxMlZf9LKna3xqqADJgnaVtSyqIM8H9y87VXzJM0HxyfJ+cj8a0QpFfuTjfefUork/Ly8lTF9e1UXW3FvysUrz0gM73/8CD/lrVyoRdtD2XNF6Y9UgDj+BDFXyg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779965409; c=relaxed/simple; bh=eCJWbK5m+tNvzAyjDy46Navw29cBVreFmRG2Woa1MAw=; h=From:To:Cc:Subject:In-Reply-To:Date:Message-ID:References; b=nmdlXuVLV4KiErh7dEFFudMI7GrVkDIep07vstUbMsKP/MqJffmFzzrnIIu5TjPLU/q7XOvuWQgamxooLdkDSFkAXSWfozIQtw3+ulWhIjFbJfV8ulHIsrfmEOAwbpCZ6PGN1DkIhgs0ByX+f25nA5GdxZFfPTUDQjqcsw8QWZY= 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=HuqAh1/r; arc=none smtp.client-ip=209.85.214.170 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="HuqAh1/r" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2bea7176c72so57134285ad.0 for ; Thu, 28 May 2026 03:50:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779965407; x=1780570207; 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=46bMWh+gCQYzpY1dEMifCzkdbqK+/RCfas0dsX6v9EQ=; b=HuqAh1/roKoG0hIctEWFdBb2sH5x3sG2/KhuwkiE/htE7DObP/e0nm/OoTr1AuHstG ZE1djmIQWj0O8yMOmrZskKqt72gfx4cqqad7Wru2eTIN9iP6XtUnF3nx/I2Afqdyv5Nr aiZWZMU5dlll+8A6ztSaMyxo31dMWxI89v1r1w7QJsa//Ib1dFhdz7+sZOHepzbzITAT 3eK/KcG9au19qgI0xrojwTeDJArN1MMu/mTEX3ZcRLBoPkznIOpYyaWi9ZPN5xFluz5t ITu9hC4Bv5EasiDfhr8zuuuV1odUJ4kSiPhy2iJE6NAUbfLYNtA1x5DBm2umglUA0Y3M Kr7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779965407; x=1780570207; 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=46bMWh+gCQYzpY1dEMifCzkdbqK+/RCfas0dsX6v9EQ=; b=DBNaMPSYpxMdBuEmlDFY4KINkRukT8vy3NZhiEVKDyEJa5pF2qq6Nv2IDbNbYB8xpu wbQbR/4qGQANw4z2CWWNWS41RxElt7MDtfxpZAYeGicAZ+63uLdxiRbbQjMcni4kLo6Q ZHv8iw0HPssaGaRl1+z52WWw0f/eA0VuE0KODBhY9CRNAwD8uQxFaX12hHFYmZCWJQck HTbOVdzemVdU8jdPsWP3UXgV6tAKivTls1EBGGUP3kTSsZrzbBb5iyN50Vn9sgNGNC1f Yr4n89mwmf321UVabfo8OuQ6rRR6hFXiUCbCxFHVDOIq9tfl+1DfDA+i1uTDiTs6B13c 1VxQ== X-Forwarded-Encrypted: i=1; AFNElJ+HvyGqC+g/fPDYw99NOIrW+Z+BR6JpMQpDpSMoJFGKkefsSDbtBMyjbI0bD4qo9949OI5R720P4kNa0gA=@vger.kernel.org X-Gm-Message-State: AOJu0YwTRGCArI0PhAQ3Q+3Ynj56oMlObRofcvuFkjudorSJzOYrsxih XtJaymWmQz/d2aUNWCIt560S98pPcRxP9VtenJ4mTtSnmYEMB9wZO+Z1 X-Gm-Gg: Acq92OGmn9Nq3JsVHHtlJ+n6f+sO2iovX2nrSZRryE7BfRqwzH5SC7Q8gQMJzzQWfS8 IGfeEgQe1FdgHUnxFAps9s9lfdTM9+sug4F0yb7wu8pCIiCwnQFcsHmwn5S87c/CzLIMYMwItYo VQRCPnsloI4rLFeCYZyD7oqZpazFv9Sna+OTJzTRVmNGEvJgxrjP8KEw6rdDIyLn5VVew0kR7h4 bImVz99iv8/1gxlbsUxz479Qxs8nE+mmsouiPbWCv8NMTiMBdq5KQfR1/YiBFMJotjIQ9YCXHxX ydZjEOJw+b8EV3u7uGlKlkz4I22xsu2C6Ojn2GvAjEgCvVVNwDh739AkU1aIqDleR08ZnrJGEtO lVtqDsEwhqwKTqM8Z2ckX+3260SiR9y4XvZJKKCaal84ZWeuc3p6/Qfp04Ef2AxRrA/QtEneeXX bO4NL9B5bQ7oCAhTmap4jFLSKW9SwRaRf1 X-Received: by 2002:a17:902:e845:b0:2ba:4f37:d3a7 with SMTP id d9443c01a7336-2beb06a63c6mr311583635ad.27.1779965407101; Thu, 28 May 2026 03:50:07 -0700 (PDT) Received: from pve-server ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2beb56bc151sm180571765ad.24.2026.05.28.03.50.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 May 2026 03:50:06 -0700 (PDT) From: Ritesh Harjani (IBM) To: Amit Machhiwal , linuxppc-dev@lists.ozlabs.org, Madhavan Srinivasan Cc: Vaibhav Jain , Amit Machhiwal , Anushree Mathur , Paolo Bonzini , Nicholas Piggin , Michael Ellerman , "Christophe Leroy (CS GROUP)" , Jonathan Corbet , Shuah Khan , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, lkp@intel.com Subject: Re: [PATCH v3 1/5] KVM: PPC: Book3S HV: Validate arch_compat against host compatibility mode In-Reply-To: <20260522152744.55251-2-amachhiw@linux.ibm.com> Date: Thu, 28 May 2026 08:43:04 +0530 Message-ID: References: <20260522152744.55251-1-amachhiw@linux.ibm.com> <20260522152744.55251-2-amachhiw@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Amit Machhiwal writes: > On IBM POWER systems, newer processor generations can operate in > compatibility modes corresponding to earlier generations. This becomes > relevant for nested virtualization, where nested KVM guests may need to > run with a specific processor compatibility level. > > Currently, when running a nested KVM guest (L2) inside a Power11 pSeries > logical partition (L1) booted in Power10 compatibility mode, the guest > fails to boot while setting 'arch_compat'. This happens because the CPU > class is derived from the hardware PVR (via mfspr()), which reflects the > physical processor generation (Power11), rather than the effective > compatibility mode (Power10). > > As a result, userspace may request a Power11 arch_compat for the L2 > guest. However, the L1 partition, running in Power10 compatibility, has > only negotiated support up to Power10 with the Power Hypervisor (L0). > When H_SET_STATE is invoked with a Power11 Logical PVR, the hypervisor s/H_SET_STATE/H_GUEST_SET_STATE > rejects the request, leading to a late guest boot failure: > > KVM-NESTEDv2: couldn't set guest wide elements > [..KVM reg dump..] > I think irrespective of the other UAPI changes, we should still get this fixed - so that we don't see a late KVM guest boot failure msgs. So, in this review, I would like to mainly look at fixing this issue first and would request if we can defer the UAPI changes as a separate patch series please. > This situation should be detected earlier. Rejecting unsupported > 'arch_compat' values in 'kvmppc_set_arch_compat()' avoids issuing an > invalid H_SET_STATE hcall and provides a clearer failure mode. s/H_SET_STATE/H_GUEST_SET_STATE > > Add a check to reject Power11 'arch_compat' requests when the host is > running in Power10 compatibility mode, returning -EINVAL early instead > of deferring the failure to the hypervisor. > > Suggested-by: Vaibhav Jain > Tested-by: Anushree Mathur > Signed-off-by: Amit Machhiwal > --- > arch/powerpc/kvm/book3s_hv.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c > index 61dbeea317f3..249d1f2e4e2c 100644 > --- a/arch/powerpc/kvm/book3s_hv.c > +++ b/arch/powerpc/kvm/book3s_hv.c > @@ -446,7 +446,19 @@ static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat) > guest_pcr_bit = PCR_ARCH_300; > break; > case PVR_ARCH_31: > + guest_pcr_bit = PCR_ARCH_31; > + break; > case PVR_ARCH_31_P11: > + /* > + * Need to check this for ISA 3.1, as Power10 and > + * Power11 share the same PCR. For any subsequent ISA > + * versions, this will be taken care of by the guest vs > + * host PCR comparison below. > + */ > + if ((PVR_ARCH_31 & cur_cpu_spec->pvr_mask) == > + cur_cpu_spec->pvr_value) { > + return -EINVAL; > + } Instead of the complicated check can we simply do this? if (!cpu_has_feature(CPU_FTR_P11_PVR)) return -EINVAL; which means that if the Qemu is trying to set the arch_compat with P11 PVR (arch_compat) and if the host cpu FTR doesn't support P11 PVR, then simply return -EINVAL -ritesh