From nobody Tue Feb 10 04:55:26 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1594919556; cv=none; d=zohomail.com; s=zohoarc; b=h+A0HO7887ufSEurtcX0mQ/AuFZm4I68NzCsFBhLkTYI28gCKizhjqlefxvxSspMWzZaa8VNtf4KklDvGA/tzTxYMmXKPYkfEVI/2woaA4WkiNKAUhojKifn6dDxZuaKVfq/zPQYM2FDrYVRSq78SUXzWtTCWIctVGRA6Qq1ihg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594919556; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VkyD/gBxyER7trM+AaTUbTxH2R0Fm54phAWSQoU+rY8=; b=I7co/8Q/+Wf7n5TMnudgYcae6Ln5aK0EKMBe5MPGP66UjprhCy1sJeNHlUwe3r1z449q1gkoaOd2s9V4OkJYUNcfXEBL5+CitBtUU2SFverLtuNdM2hKyv35PVq5nnGlihzZwjHNVq4TEvaN4vRXKBeHivbXQXoWJIKsy7A4ZyQ= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594919556666593.8198187370193; Thu, 16 Jul 2020 10:12:36 -0700 (PDT) Received: from localhost ([::1]:60432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jw7Qx-00059W-Dt for importer@patchew.org; Thu, 16 Jul 2020 13:12:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jw7Q4-0004Dk-CX for qemu-devel@nongnu.org; Thu, 16 Jul 2020 13:11:40 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:41206 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jw7Q1-0007Kp-QS for qemu-devel@nongnu.org; Thu, 16 Jul 2020 13:11:40 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-283-KOiE28a6OEGzVQBlUtN5sQ-1; Thu, 16 Jul 2020 13:11:30 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 60BF1803A1C; Thu, 16 Jul 2020 17:11:23 +0000 (UTC) Received: from bahia.lan (ovpn-113-187.ams2.redhat.com [10.36.113.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B6B07B5E1; Thu, 16 Jul 2020 17:11:22 +0000 (UTC) X-MC-Unique: KOiE28a6OEGzVQBlUtN5sQ-1 Subject: [PATCH v4 for-5.2 2/2] spapr: Forbid nested KVM-HV in pre-power9 compat mode From: Greg Kurz To: David Gibson Date: Thu, 16 Jul 2020 19:11:21 +0200 Message-ID: <159491948127.188975.9621435875869177751.stgit@bahia.lan> In-Reply-To: <159491945918.188975.4358645698778061430.stgit@bahia.lan> References: <159491945918.188975.4358645698778061430.stgit@bahia.lan> User-Agent: StGit/0.21 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kaod.org Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: softfail client-ip=207.211.31.120; envelope-from=groug@kaod.org; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/16 04:25:38 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster , Vladimir Sementsov-Ogievskiy , qemu-ppc@nongnu.org, Laurent Vivier , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Nested KVM HV only works if the kernel is using the radix MMU mode, ie. the CPU is POWER9 and it is not running in some pre-power9 compat mode. Otherwise, the KVM HV module fails to load in the guest with -ENODEV. It might be painful for a user to discover this late that nested cannot work with their setup. Erroring out at machine init instead seems to be the best we can do. Signed-off-by: Greg Kurz Reviewed-by: Laurent Vivier --- hw/ppc/spapr_caps.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c index 275f5bd0342c..10a80a8159f4 100644 --- a/hw/ppc/spapr_caps.c +++ b/hw/ppc/spapr_caps.c @@ -382,6 +382,8 @@ static void cap_nested_kvm_hv_apply(SpaprMachineState *= spapr, uint8_t val, Error **errp) { ERRP_GUARD(); + PowerPCCPU *cpu =3D POWERPC_CPU(first_cpu); + if (!val) { /* capability disabled by default */ return; @@ -391,6 +393,14 @@ static void cap_nested_kvm_hv_apply(SpaprMachineState = *spapr, error_setg(errp, "No Nested KVM-HV support in TCG"); error_append_hint(errp, "Try appending -machine cap-nested-hv=3Dof= f\n"); } else if (kvm_enabled()) { + if (!ppc_check_compat(cpu, CPU_POWERPC_LOGICAL_3_00, 0, + spapr->max_compat_pvr)) { + error_setg(errp, "Nested KVM-HV only supported on POWER9"); + error_append_hint(errp, + "Try appending -machine max-cpu-compat=3Dpow= er9\n"); + return; + } + if (!kvmppc_has_cap_nested_kvm_hv()) { error_setg(errp, "KVM implementation does not support Nested KVM-HV"= );