Message ID | 20240118095653.2588129-1-amachhiw@linux.ibm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-29988-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp234148dyb; Thu, 18 Jan 2024 01:58:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEBl2SDFkdqJGl0OhpMQt0y+s347RMICjEhStQVQv4/D6LAlKg/DOnG3Q2OUg8Kwj8YbDg4 X-Received: by 2002:a05:6808:2e9a:b0:3bd:76b7:f412 with SMTP id gt26-20020a0568082e9a00b003bd76b7f412mr733456oib.39.1705571936421; Thu, 18 Jan 2024 01:58:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705571936; cv=pass; d=google.com; s=arc-20160816; b=KCPLCDBRVcYUyG4xNvGGGlTIKQ9NyGc+7YLIP4rqzAyYXHOSJcqlTlHA/vEFHZSxyD vUs93RKgBDxc3hyiRwYNZ4O3uvEjrLtROxu+QKKM2Gt2tmVUKJLnCMBadcDzqv36MZfu TojzNhF70dkFGI8GwE73Nz8LJBWzk7kctsOK5tOKRiIo8bs/ulcANRVU8j4OG6DwRwpg oZgdPv3aJRhJrA8xC8OGcaMXLZM2QQxwOjhJmT+JzspE7XC6qFhDFVNWj7r6+oKow9Xt vOkIwr5lGwfNAcnUqo9bBeHtkkAQXGpvks6e7z1ymQwXyYACbhqENzDiM7iqNDBc1kNt jxxg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=tDsa17QGnZJdJ7xoNKAU1deQRzOdcbYO8QmA7kYtEIc=; fh=sDkaTom/Ll/ftvYU3leOOynxpMdqlaux7os0gQIqzHI=; b=EfKrBfAznhy+JfwlL/XvljafbZhLJBNygj7Hb3y/s3kYaOqE6wrhKFWAJqvRG5HkAU 9Nx5luRhMNCjv7G3VU7+VHPATSqgA4p0/aGLDxaJuVIKZVIGKT//VHw9PJbOXNxn3gZZ VeWxvSsy2roVRIrlqd+MnTXc7K1NjxH7iogjo/UP3DUeoWrjDi19Nr8f36CRW2+sJbEe nynPBjnCO4Hxms5Zbp16mjAgAioycAphV85o1SERT02azw44UWkZ3UOdGB/3pdwgHEUf rB/jiva2ldP51wfmDUOF6JQy6u64UcbjsHQbAHuSo01IxbIFVExyfVX0WmcWX4yFY2H2 gl+A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=LNluS1n3; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-29988-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29988-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d7-20020a05622a100700b0042a030c6790si5038156qte.681.2024.01.18.01.58.56 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 01:58:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29988-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=LNluS1n3; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-29988-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29988-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 28BE61C24DE7 for <ouuuleilei@gmail.com>; Thu, 18 Jan 2024 09:58:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CA85D20B02; Thu, 18 Jan 2024 09:58:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="LNluS1n3" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B358125D1; Thu, 18 Jan 2024 09:58:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705571914; cv=none; b=m9OcnPFPxsZBOQMcJ5H+C7RITjHLQV+2O9vM15/BIs96hT94hO1L22JuAEDDG35fXNplBi0DfCdbWwW+sTPpI5bwLkIo63SbVN4BWiC0EGQLyUk1gcY00BH6TCTr77Ud1XxFxUbrzroAz2PI9x+KHJQsXIl1xLxZuamODfHfQSQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705571914; c=relaxed/simple; bh=us7rkNzH3kgjjBtdp/OFNF7E2uhJBQ6GmJ8gywPwYDY=; h=Received:DKIM-Signature:Received:Received:Received:Received: Received:Received:Received:Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-TM-AS-GCONF:X-Proofpoint-GUID:X-Proofpoint-ORIG-GUID: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; b=oX1EGv4HuT5hEroEKfndJmCsL602ESP3Rf8t6S7DlC4kiPHiPT5Y+j4H9NFOSzXnhmJlOhoppCU0Hln3TvlORSGopQcix2IgJKlQHnBKsG/sxvkyRnUc4mW0yZmvzrHlyJHct7qFV455xHiVSw6rl1Q3K+vaFpZwdJs3zah4NOg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=LNluS1n3; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40I9Keqp003504; Thu, 18 Jan 2024 09:58:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=tDsa17QGnZJdJ7xoNKAU1deQRzOdcbYO8QmA7kYtEIc=; b=LNluS1n3x8Hb6WLcT5dJt2X7g3hPRIi6MuAhjB9rfPCT8GmIIxFO9R+omJfNCfgLYPqM 7fTSFJmlD8Y0kEuQlFn00dWGe5lROXQ1RNikZdy8vxOIsc4TDVFh9PSYY8pm47jucc1H r2fnEFBnhYjd/fddA9t1zSUNGO60dVDax9XS2gqxeGgNaqta8NoiL3dRt+5HVCGlIQcp Ic5agQL8bDmErzQGYsYS1ir0O2xi9gHgmxUkDPdzOyAQ1Hgx07gpSQ559oqo5DE+iDJq zLiSDjhTEYUAXqSdRMxwMuN6x4YsmP4t+MtG16pIVhP1Zl17ur2wAv7VCAQ3BQif+M6+ hQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vq12x97ks-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 Jan 2024 09:58:10 +0000 Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40I9NZEe016473; Thu, 18 Jan 2024 09:58:10 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vq12x97jp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 Jan 2024 09:58:10 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 40I6t3l8005788; Thu, 18 Jan 2024 09:58:08 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3vm6bkth3a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 Jan 2024 09:58:08 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 40I9w51k41222586 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 18 Jan 2024 09:58:05 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4DD7A2004E; Thu, 18 Jan 2024 09:58:05 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AD7E420040; Thu, 18 Jan 2024 09:58:02 +0000 (GMT) Received: from li-a83676cc-350e-11b2-a85c-e11f86bb8d73.in.ibm.com (unknown [9.204.204.156]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 18 Jan 2024 09:58:02 +0000 (GMT) From: Amit Machhiwal <amachhiw@linux.ibm.com> To: linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org Cc: Vaibhav Jain <vaibhav@linux.ibm.com>, Nicholas Piggin <npiggin@gmail.com>, Michael Ellerman <mpe@ellerman.id.au>, Jordan Niethe <jniethe5@gmail.com>, Vaidyanathan Srinivasan <svaidy@linux.ibm.com>, "Aneesh Kumar K . V" <aneesh.kumar@kernel.org>, "Naveen N . Rao" <naveen.n.rao@linux.ibm.com>, Christophe Leroy <christophe.leroy@csgroup.eu>, Amit Machhiwal <amachhiw@linux.ibm.com>, Amit Machhiwal <amit.machhiwal@ibm.com>, linux-kernel@vger.kernel.org Subject: [PATCH] KVM: PPC: Book3S HV: Fix L2 guest reboot failure due to empty 'arch_compat' Date: Thu, 18 Jan 2024 15:26:53 +0530 Message-ID: <20240118095653.2588129-1-amachhiw@linux.ibm.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: -Ffy459YXDPle-vIK3r04gKDoVnHSbTb X-Proofpoint-ORIG-GUID: Rl1pfpqO9J81VDdV_1Gvp8ltEJWiRkzB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-18_05,2024-01-17_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 spamscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=700 adultscore=0 clxscore=1011 priorityscore=1501 mlxscore=0 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401180071 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788421799081346939 X-GMAIL-MSGID: 1788421799081346939 |
Series |
KVM: PPC: Book3S HV: Fix L2 guest reboot failure due to empty 'arch_compat'
|
|
Commit Message
Amit Machhiwal
Jan. 18, 2024, 9:56 a.m. UTC
Currently, rebooting a pseries nested qemu-kvm guest (L2) results in
below error as L1 qemu sends PVR value 'arch_compat' == 0 via
ppc_set_compat ioctl. This triggers a condition failure in
kvmppc_set_arch_compat() resulting in an EINVAL.
qemu-system-ppc64: Unable to set CPU compatibility mode in KVM: Invalid
This patch updates kvmppc_set_arch_compat() to use the host PVR value if
'compat_pvr' == 0 indicating that qemu doesn't want to enforce any
specific PVR compat mode.
Signed-off-by: Amit Machhiwal <amachhiw@linux.ibm.com>
---
arch/powerpc/kvm/book3s_hv.c | 2 +-
arch/powerpc/kvm/book3s_hv_nestedv2.c | 12 ++++++++++--
2 files changed, 11 insertions(+), 3 deletions(-)
Comments
On Thu, Jan 18, 2024 at 03:26:53PM +0530, Amit Machhiwal wrote: > Currently, rebooting a pseries nested qemu-kvm guest (L2) results in > below error as L1 qemu sends PVR value 'arch_compat' == 0 via > ppc_set_compat ioctl. This triggers a condition failure in > kvmppc_set_arch_compat() resulting in an EINVAL. > > qemu-system-ppc64: Unable to set CPU compatibility mode in KVM: Invalid > > This patch updates kvmppc_set_arch_compat() to use the host PVR value if > 'compat_pvr' == 0 indicating that qemu doesn't want to enforce any > specific PVR compat mode. > > Signed-off-by: Amit Machhiwal <amachhiw@linux.ibm.com> > --- > arch/powerpc/kvm/book3s_hv.c | 2 +- > arch/powerpc/kvm/book3s_hv_nestedv2.c | 12 ++++++++++-- > 2 files changed, 11 insertions(+), 3 deletions(-) > > diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c > index 1ed6ec140701..9573d7f4764a 100644 > --- a/arch/powerpc/kvm/book3s_hv.c > +++ b/arch/powerpc/kvm/book3s_hv.c > @@ -439,7 +439,7 @@ static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat) > if (guest_pcr_bit > host_pcr_bit) > return -EINVAL; > > - if (kvmhv_on_pseries() && kvmhv_is_nestedv2()) { > + if (kvmhv_on_pseries() && kvmhv_is_nestedv2() && arch_compat) { > if (!(cap & nested_capabilities)) > return -EINVAL; > } > diff --git a/arch/powerpc/kvm/book3s_hv_nestedv2.c b/arch/powerpc/kvm/book3s_hv_nestedv2.c > index fd3c4f2d9480..069a1fcfd782 100644 > --- a/arch/powerpc/kvm/book3s_hv_nestedv2.c > +++ b/arch/powerpc/kvm/book3s_hv_nestedv2.c > @@ -138,6 +138,7 @@ static int gs_msg_ops_vcpu_fill_info(struct kvmppc_gs_buff *gsb, > vector128 v; > int rc, i; > u16 iden; > + u32 arch_compat = 0; > > vcpu = gsm->data; > > @@ -347,8 +348,15 @@ static int gs_msg_ops_vcpu_fill_info(struct kvmppc_gs_buff *gsb, > break; > } > case KVMPPC_GSID_LOGICAL_PVR: > - rc = kvmppc_gse_put_u32(gsb, iden, > - vcpu->arch.vcore->arch_compat); > + if (!vcpu->arch.vcore->arch_compat) { > + if (cpu_has_feature(CPU_FTR_ARCH_31)) > + arch_compat = PVR_ARCH_31; > + else if (cpu_has_feature(CPU_FTR_ARCH_300)) > + arch_compat = PVR_ARCH_300; > + } else { > + arch_compat = vcpu->arch.vcore->arch_compat; > + } > + rc = kvmppc_gse_put_u32(gsb, iden, arch_compat); > break; > } > > -- > 2.43.0 > I tested this patch on pseries Power 10 machine with KVM support : Without this patch, with the latest mainline as host,the kvm guest on pseries/powervm fails to reboot and with this patch, reboot works fine. Tested-by: Gautam Menghani <gautam@linux.ibm.com>
Amit Machhiwal <amachhiw@linux.ibm.com> writes: > Currently, rebooting a pseries nested qemu-kvm guest (L2) results in > below error as L1 qemu sends PVR value 'arch_compat' == 0 via > ppc_set_compat ioctl. This triggers a condition failure in > kvmppc_set_arch_compat() resulting in an EINVAL. > > qemu-system-ppc64: Unable to set CPU compatibility mode in KVM: Invalid > > This patch updates kvmppc_set_arch_compat() to use the host PVR value if > 'compat_pvr' == 0 indicating that qemu doesn't want to enforce any > specific PVR compat mode. > > Signed-off-by: Amit Machhiwal <amachhiw@linux.ibm.com> > --- > arch/powerpc/kvm/book3s_hv.c | 2 +- > arch/powerpc/kvm/book3s_hv_nestedv2.c | 12 ++++++++++-- > 2 files changed, 11 insertions(+), 3 deletions(-) > > diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c > index 1ed6ec140701..9573d7f4764a 100644 > --- a/arch/powerpc/kvm/book3s_hv.c > +++ b/arch/powerpc/kvm/book3s_hv.c > @@ -439,7 +439,7 @@ static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat) > if (guest_pcr_bit > host_pcr_bit) > return -EINVAL; > > - if (kvmhv_on_pseries() && kvmhv_is_nestedv2()) { > + if (kvmhv_on_pseries() && kvmhv_is_nestedv2() && arch_compat) { > if (!(cap & nested_capabilities)) > return -EINVAL; > } > Instead of that arch_compat check, would it better to do if (kvmhv_on_pseries() && kvmhv_is_nestedv2()) { if (cap && !(cap & nested_capabilities)) return -EINVAL; } ie, if a capability is requested, then check against nested_capbilites to see if the capability exist. > diff --git a/arch/powerpc/kvm/book3s_hv_nestedv2.c b/arch/powerpc/kvm/book3s_hv_nestedv2.c > index fd3c4f2d9480..069a1fcfd782 100644 > --- a/arch/powerpc/kvm/book3s_hv_nestedv2.c > +++ b/arch/powerpc/kvm/book3s_hv_nestedv2.c > @@ -138,6 +138,7 @@ static int gs_msg_ops_vcpu_fill_info(struct kvmppc_gs_buff *gsb, > vector128 v; > int rc, i; > u16 iden; > + u32 arch_compat = 0; > > vcpu = gsm->data; > > @@ -347,8 +348,15 @@ static int gs_msg_ops_vcpu_fill_info(struct kvmppc_gs_buff *gsb, > break; > } > case KVMPPC_GSID_LOGICAL_PVR: > - rc = kvmppc_gse_put_u32(gsb, iden, > - vcpu->arch.vcore->arch_compat); > + if (!vcpu->arch.vcore->arch_compat) { > + if (cpu_has_feature(CPU_FTR_ARCH_31)) > + arch_compat = PVR_ARCH_31; > + else if (cpu_has_feature(CPU_FTR_ARCH_300)) > + arch_compat = PVR_ARCH_300; > + } else { > + arch_compat = vcpu->arch.vcore->arch_compat; > + } > + rc = kvmppc_gse_put_u32(gsb, iden, arch_compat); > Won't a arch_compat = 0 work here?. ie, where you observing the -EINVAL from the first hunk or does this hunk have an impact? > break; > } > > -- > 2.43.0 -aneesh
Hi Aneesh, Thanks for looking into the patch. My comments are inline below. On 2024/01/24 01:06 PM, Aneesh Kumar K.V wrote: > Amit Machhiwal <amachhiw@linux.ibm.com> writes: > > > Currently, rebooting a pseries nested qemu-kvm guest (L2) results in > > below error as L1 qemu sends PVR value 'arch_compat' == 0 via > > ppc_set_compat ioctl. This triggers a condition failure in > > kvmppc_set_arch_compat() resulting in an EINVAL. > > > > qemu-system-ppc64: Unable to set CPU compatibility mode in KVM: Invalid > > > > This patch updates kvmppc_set_arch_compat() to use the host PVR value if > > 'compat_pvr' == 0 indicating that qemu doesn't want to enforce any > > specific PVR compat mode. > > > > Signed-off-by: Amit Machhiwal <amachhiw@linux.ibm.com> > > --- > > arch/powerpc/kvm/book3s_hv.c | 2 +- > > arch/powerpc/kvm/book3s_hv_nestedv2.c | 12 ++++++++++-- > > 2 files changed, 11 insertions(+), 3 deletions(-) > > > > diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c > > index 1ed6ec140701..9573d7f4764a 100644 > > --- a/arch/powerpc/kvm/book3s_hv.c > > +++ b/arch/powerpc/kvm/book3s_hv.c > > @@ -439,7 +439,7 @@ static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat) > > if (guest_pcr_bit > host_pcr_bit) > > return -EINVAL; > > > > - if (kvmhv_on_pseries() && kvmhv_is_nestedv2()) { > > + if (kvmhv_on_pseries() && kvmhv_is_nestedv2() && arch_compat) { > > if (!(cap & nested_capabilities)) > > return -EINVAL; > > } > > > > Instead of that arch_compat check, would it better to do > > if (kvmhv_on_pseries() && kvmhv_is_nestedv2()) { > if (cap && !(cap & nested_capabilities)) > return -EINVAL; > } > > ie, if a capability is requested, then check against nested_capbilites > to see if the capability exist. The above condition check will cause problems when we would try to boot a machine below Power 9. For example, if we passed the arch_compat == PVR_ARCH_207, cap will remain 0 resulting the above check into a false condition. Consequently, we would never return an -EINVAL in that case resulting the arch compatilbility request succeed when it doesn't support nested papr guest. > > > > diff --git a/arch/powerpc/kvm/book3s_hv_nestedv2.c b/arch/powerpc/kvm/book3s_hv_nestedv2.c > > index fd3c4f2d9480..069a1fcfd782 100644 > > --- a/arch/powerpc/kvm/book3s_hv_nestedv2.c > > +++ b/arch/powerpc/kvm/book3s_hv_nestedv2.c > > @@ -138,6 +138,7 @@ static int gs_msg_ops_vcpu_fill_info(struct kvmppc_gs_buff *gsb, > > vector128 v; > > int rc, i; > > u16 iden; > > + u32 arch_compat = 0; > > > > vcpu = gsm->data; > > > > @@ -347,8 +348,15 @@ static int gs_msg_ops_vcpu_fill_info(struct kvmppc_gs_buff *gsb, > > break; > > } > > case KVMPPC_GSID_LOGICAL_PVR: > > - rc = kvmppc_gse_put_u32(gsb, iden, > > - vcpu->arch.vcore->arch_compat); > > + if (!vcpu->arch.vcore->arch_compat) { > > + if (cpu_has_feature(CPU_FTR_ARCH_31)) > > + arch_compat = PVR_ARCH_31; > > + else if (cpu_has_feature(CPU_FTR_ARCH_300)) > > + arch_compat = PVR_ARCH_300; > > + } else { > > + arch_compat = vcpu->arch.vcore->arch_compat; > > + } > > + rc = kvmppc_gse_put_u32(gsb, iden, arch_compat); > > > > Won't a arch_compat = 0 work here?. ie, where you observing the -EINVAL from > the first hunk or does this hunk have an impact? > No, an arch_compat == 0 won't work in nested API v2. That's because the guest wide PVR cannot be 0, and if arch_compat == 0, then suppported host PVR value should be mentioned. If we were to skip this hunk (keeping the arch_compat == 0), a system reboot of L2 guest would fail and result into a kernel trap as below: [ 22.106360] reboot: Restarting system KVM: unknown exit, hardware reason ffffffffffffffea NIP 0000000000000100 LR 000000000000fe44 CTR 0000000000000000 XER 0000000020040092 CPU#0 MSR 0000000000001000 HID0 0000000000000000 HF 6c000000 iidx 3 didx 3 TB 00000000 00000000 DECR 0 GPR00 0000000000000000 0000000000000000 c000000002a8c300 000000007fe00000 GPR04 0000000000000000 0000000000000000 0000000000001002 8000000002803033 GPR08 000000000a000000 0000000000000000 0000000000000004 000000002fff0000 GPR12 0000000000000000 c000000002e10000 0000000105639200 0000000000000004 GPR16 0000000000000000 000000010563a090 0000000000000000 0000000000000000 GPR20 0000000105639e20 00000001056399c8 00007fffe54abab0 0000000105639288 GPR24 0000000000000000 0000000000000001 0000000000000001 0000000000000000 GPR28 0000000000000000 0000000000000000 c000000002b30840 0000000000000000 CR 00000000 [ - - - - - - - - ] RES 000@ffffffffffffffff SRR0 0000000000000000 SRR1 0000000000000000 PVR 0000000000800200 VRSAVE 0000000000000000 SPRG0 0000000000000000 SPRG1 0000000000000000 SPRG2 0000000000000000 SPRG3 0000000000000000 SPRG4 0000000000000000 SPRG5 0000000000000000 SPRG6 0000000000000000 SPRG7 0000000000000000 HSRR0 0000000000000000 HSRR1 0000000000000000 CFAR 0000000000000000 LPCR 0000000000020400 PTCR 0000000000000000 DAR 0000000000000000 DSISR 0000000000000000 Message from syslogd@ltcd48-lp1 at Jan 24 08:02:16 ... kernel:trap=0xffffffea | pc=0x100 | msr=0x1000 > > > break; > > } > > > > -- > > 2.43.0 > > -aneesh ~Amit
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 1ed6ec140701..9573d7f4764a 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -439,7 +439,7 @@ static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat) if (guest_pcr_bit > host_pcr_bit) return -EINVAL; - if (kvmhv_on_pseries() && kvmhv_is_nestedv2()) { + if (kvmhv_on_pseries() && kvmhv_is_nestedv2() && arch_compat) { if (!(cap & nested_capabilities)) return -EINVAL; } diff --git a/arch/powerpc/kvm/book3s_hv_nestedv2.c b/arch/powerpc/kvm/book3s_hv_nestedv2.c index fd3c4f2d9480..069a1fcfd782 100644 --- a/arch/powerpc/kvm/book3s_hv_nestedv2.c +++ b/arch/powerpc/kvm/book3s_hv_nestedv2.c @@ -138,6 +138,7 @@ static int gs_msg_ops_vcpu_fill_info(struct kvmppc_gs_buff *gsb, vector128 v; int rc, i; u16 iden; + u32 arch_compat = 0; vcpu = gsm->data; @@ -347,8 +348,15 @@ static int gs_msg_ops_vcpu_fill_info(struct kvmppc_gs_buff *gsb, break; } case KVMPPC_GSID_LOGICAL_PVR: - rc = kvmppc_gse_put_u32(gsb, iden, - vcpu->arch.vcore->arch_compat); + if (!vcpu->arch.vcore->arch_compat) { + if (cpu_has_feature(CPU_FTR_ARCH_31)) + arch_compat = PVR_ARCH_31; + else if (cpu_has_feature(CPU_FTR_ARCH_300)) + arch_compat = PVR_ARCH_300; + } else { + arch_compat = vcpu->arch.vcore->arch_compat; + } + rc = kvmppc_gse_put_u32(gsb, iden, arch_compat); break; }