From patchwork Thu Sep 14 10:48:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 813778 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xtFdJ5JHfz9sRW for ; Thu, 14 Sep 2017 20:48:52 +1000 (AEST) Received: from localhost ([::1]:46895 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsRhS-0005EA-SK for incoming@patchwork.ozlabs.org; Thu, 14 Sep 2017 06:48:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56820) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsRgt-0005Dz-5X for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:48:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsRgp-0008NZ-1n for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:48:15 -0400 Received: from 5.mo2.mail-out.ovh.net ([87.98.181.248]:47414) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dsRgo-0008MA-Rb for qemu-devel@nongnu.org; Thu, 14 Sep 2017 06:48:10 -0400 Received: from player770.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo2.mail-out.ovh.net (Postfix) with ESMTP id 45C83A2DA7 for ; Thu, 14 Sep 2017 12:48:09 +0200 (CEST) Received: from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player770.ha.ovh.net (Postfix) with ESMTPA id A4D5C3C0082; Thu, 14 Sep 2017 12:48:04 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Thu, 14 Sep 2017 12:48:04 +0200 Message-ID: <150538608438.12346.9391407971434352383.stgit@bahia.lan> User-Agent: StGit/0.17.1-46-g6855-dirty MIME-Version: 1.0 X-Ovh-Tracer-Id: 6802968713683704114 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelledrgeeigdeffecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 87.98.181.248 Subject: [Qemu-devel] [PATCH] ppc/kvm: use kvm_vm_check_extension() in kvmppc_is_pr() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" If the host has both KVM PR and KVM HV loaded and we pass: -machine pseries,accel=kvm,kvm-type=PR the kvmppc_is_pr() returns false instead of true. Since the helper is mostly used as fallback, it doesn't have any real impact with recent kernels. A notable exception is the workaround to allow migration between compatible hosts with different PVRs (eg, POWER8 and POWER8E), since KVM still doesn't provide a way to check if a specific PVR is supported (see commit c363a37a450f for details). According to the official KVM API documentation [1], KVM_PPC_GET_PVINFO is "vm ioctl", but we check it as a global ioctl. The following function in KVM is hence called with kvm == NULL and considers we're in HV mode. int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) { int r; /* Assume we're using HV mode when the HV module is loaded */ int hv_enabled = kvmppc_hv_ops ? 1 : 0; if (kvm) { /* * Hooray - we know which VM type we're running on. Depend on * that rather than the guess above. */ hv_enabled = is_kvmppc_hv_enabled(kvm); } Let's use kvm_vm_check_extension() to fix the issue. [1] https://www.kernel.org/doc/Documentation/virtual/kvm/api.txt Signed-off-by: Greg Kurz Reviewed-by: Thomas Huth --- target/ppc/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 6442dfcb95b3..1deaf106d2b9 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -120,7 +120,7 @@ static void kvm_kick_cpu(void *opaque) static bool kvmppc_is_pr(KVMState *ks) { /* Assume KVM-PR if the GET_PVINFO capability is available */ - return kvm_check_extension(ks, KVM_CAP_PPC_GET_PVINFO) != 0; + return kvm_vm_check_extension(ks, KVM_CAP_PPC_GET_PVINFO) != 0; } static int kvm_ppc_register_host_cpu_type(void);