From patchwork Thu Jun 8 07:03:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suraj Jitindar Singh X-Patchwork-Id: 9773995 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E476760393 for ; Thu, 8 Jun 2017 07:08:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3E7125D9E for ; Thu, 8 Jun 2017 07:08:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8A20284B2; Thu, 8 Jun 2017 07:08:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 31B9925D9E for ; Thu, 8 Jun 2017 07:08:20 +0000 (UTC) Received: from localhost ([::1]:47805 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIrYJ-0002aD-W8 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 08 Jun 2017 03:08:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57356) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIrUa-0000Yh-QA for qemu-devel@nongnu.org; Thu, 08 Jun 2017 03:04:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIrUZ-0007gj-LZ for qemu-devel@nongnu.org; Thu, 08 Jun 2017 03:04:28 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:36431) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dIrUW-0007eP-RN; Thu, 08 Jun 2017 03:04:25 -0400 Received: by mail-pg0-x243.google.com with SMTP id v18so3671096pgb.3; Thu, 08 Jun 2017 00:04:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ng9rQjTA2n7Uttl1llhcz4Khh7Lda44PExRahOPwS7E=; b=iDz1n6ycCnJBnZY3GDR0Bc/CZT25dVb3GI4fCSQ4IuQmwrog39MoL5eNeek2MCMldg 3wjCWWm8et6XnrHD1tn188fipupN//+aAEiD4ztg3gdoyoCKwIwsvZHQ3jVGZ7C7rKEh 4eo5CMDfFsaYRpvCWC4DXoI6SktdF82mbXn0iX7BjuJqDMtY6bh/F8wQVrqItkpNiKhl KXiI7lFqaNKAKVF5wIuZC7AQ4ktLkMAOQ4U/TCbjKObZ9Hy1oYqWBamDzi7Gl/NPPEre fOlpReP8fe+Jmcnch7fHT4aTZ/maL6zuza/JCMb0XEoqj4PoglXOr8/rVI9xzyjImhdb qIVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ng9rQjTA2n7Uttl1llhcz4Khh7Lda44PExRahOPwS7E=; b=Ob57yKJVlAIvbERQixr2BlGhlu5wnehhZgR8TZ0fR18ak2rDadKd1Sg+f91hTPO3QQ /N3hSbGW9ywhvKV+3Q0wWIVKxEjaSCDX6unKaDXH4o+NfKUO3jV98bFEbL/rSUJjG2Ui 3ToFSPHUqpg8M6CnKSbrfLtYEtUbdfZV5VvYrDybJneJ/EwyHVdQPc2kXVEQadtI76XH y7aw7bK1o5ZMh0YIW8OGk0TRGgPwXRxgRmzSieA7yYfLNyzeXQ8E2bTsf+b5ovehapCI XhlBbWEi0BHsQF6J494KNJ2MoVdSFtA8k7/sj9FNt17kFu2yE0aLklNPqC8V0YhH7Tdf szyw== X-Gm-Message-State: AODbwcDtFHNOlDmubmistL3pnHCBXFd7pBPLncjqfWHrjkctxyXUFHZq O1TvhtbmpUi7MDIX X-Received: by 10.98.50.129 with SMTP id y123mr35516744pfy.53.1496905463684; Thu, 08 Jun 2017 00:04:23 -0700 (PDT) Received: from surajjs1.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id p76sm8568188pfl.24.2017.06.08.00.04.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jun 2017 00:04:23 -0700 (PDT) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Thu, 8 Jun 2017 17:03:51 +1000 Message-Id: <20170608070351.1434-6-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170608070351.1434-1-sjitindarsingh@gmail.com> References: <20170608070351.1434-1-sjitindarsingh@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PATCH 5/5] target/ppc: Add cmd line option to disable the large decrementer 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: agraf@suse.de, qemu-devel@nongnu.org, Suraj Jitindar Singh , david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Given there is no way to tell the guest if the size of the large decrementer changes, it is not possible to migrate a guest between machines where the decrementer size differs. Add a command line option to disable the large decrementer for a guest on boot. This means we will not advertise the availability of the large decrementer to the guest and thus it won't try to use it. This allows for a way for a guest to be started which will be compatible with live migration to a system with a differing decrementer size (assuming that system still implements the basic 32-bit decrementer mode). A required option is supplied to force large decrementer, qemu will fail to start if the host doesn't support it. There is also a default option where the large decrementer will be enabled/disabled based on the capabilities of the hypervisor. Signed-off-by: Suraj Jitindar Singh --- hw/ppc/spapr.c | 59 +++++++++++++++++++++++++++++++++++++++++++++----- hw/ppc/spapr_hcall.c | 4 +++- include/hw/ppc/spapr.h | 1 + 3 files changed, 57 insertions(+), 7 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 6f38939..4290dd8 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -558,12 +558,12 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset, /* * We set this property to let the guest know that it can use the large * decrementer and its width in bits. This means we must be on a processor - * with a large decrementer and the hypervisor must support it. In TCG the - * large decrementer is always supported, in KVM we check the hypervisor - * capability. + * with a large decrementer, it must not have been disabled and the + * hypervisor must support it. In TCG the large decrementer is always + * supported, in KVM we check the hypervisor capability. */ - if (pcc->large_decr_bits && ((!kvm_enabled()) || - kvmppc_has_cap_large_decr())) { + if (pcc->large_decr_bits && (spapr->large_decr_support != -1) && + ((!kvm_enabled()) || kvmppc_has_cap_large_decr())) { _FDT((fdt_setprop_u32(fdt, offset, "ibm,dec-bits", pcc->large_decr_bits))); } @@ -1344,6 +1344,11 @@ static void ppc_spapr_reset(void) /* We have to do this after vcpus are created since it calls ioctls */ if (kvm_enabled()) { kvmppc_check_cap_large_decr(); + + if ((spapr->large_decr_support == 1) && !kvmppc_has_cap_large_decr()) { + error_report("Large decrementer unsupported by hypervisor"); + exit(1); + } } qemu_devices_reset(); @@ -1451,7 +1456,9 @@ static int spapr_import_large_decr_bits(sPAPRMachineState *spapr) CPUState *cs = CPU(cpu); PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs); - if (kvm_enabled()) { + if (spapr->large_decr_support == -1) { + /* Large decrementer disabled on the command line */ + } else if (kvm_enabled()) { if (!kvmppc_has_cap_large_decr()) { error_report("Host doesn't support large decrementer and guest requires it"); return -EINVAL; @@ -2554,6 +2561,37 @@ static void spapr_set_modern_hotplug_events(Object *obj, bool value, spapr->use_hotplug_event_source = value; } +static char *spapr_get_large_decr_support(Object *obj, Error **errp) +{ + sPAPRMachineState *spapr = SPAPR_MACHINE(obj); + + switch (spapr->large_decr_support) { + case -1: + return g_strdup("disabled"); + case 1: + return g_strdup("required"); + default: + return g_strdup("default"); + } +} + +static void spapr_set_large_decr_support(Object *obj, const char *value, + Error **errp) +{ + sPAPRMachineState *spapr = SPAPR_MACHINE(obj); + + if (!strncmp(value, "disabled", strlen("disabled"))) { + spapr->large_decr_support = -1; + } else if (!strncmp(value, "required", strlen("required"))) { + spapr->large_decr_support = 1; + } else if (!strncmp(value, "default", strlen("default"))) { + spapr->large_decr_support = 0; + } else { + error_report("Unknown large-decr-support specified '%s'", value); + exit(1); + } +} + static void spapr_machine_initfn(Object *obj) { sPAPRMachineState *spapr = SPAPR_MACHINE(obj); @@ -2574,6 +2612,15 @@ static void spapr_machine_initfn(Object *obj) " place of standard EPOW events when possible" " (required for memory hot-unplug support)", NULL); + object_property_add_str(obj, "large-decr-support", + spapr_get_large_decr_support, + spapr_set_large_decr_support, NULL); + object_property_set_description(obj, "large-decr-support", + "Specifies the level of large decrementer support" + " {required - don't start if not available " + "| disabled - disable the large decrementer" + " | default - depend on hypervisor support}" + , NULL); } static void spapr_machine_finalizefn(Object *obj) diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index c06421b..b4b22cb 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1096,7 +1096,9 @@ static void cas_enable_large_decr(PowerPCCPU *cpu, sPAPRMachineState *spapr) PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); bool guest_large_decr = false; - if (cpu->compat_pvr) { + if (spapr->large_decr_support == -1) { + /* Large decrementer disabled on the command line */ + } else if (cpu->compat_pvr) { guest_large_decr = cpu->compat_pvr >= CPU_POWERPC_LOGICAL_3_00; } else { guest_large_decr = (cpu->env.spr[SPR_PVR] & CPU_POWERPC_POWER_SERVER_MASK) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 4ba9b89..65c5659 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -114,6 +114,7 @@ struct sPAPRMachineState { /*< public >*/ char *kvm_type; MemoryHotplugState hotplug_memory; + int large_decr_support; /* 1 -> required | 0 -> default | -1 -> disable */ const char *icp_type; };