From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB88BC433DB for ; Tue, 30 Mar 2021 14:39:37 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 407B5619C8 for ; Tue, 30 Mar 2021 14:39:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 407B5619C8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dme.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRFWq-0004Xu-5f for qemu-devel@archiver.kernel.org; Tue, 30 Mar 2021 10:39:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRFSj-0008T3-Nr for qemu-devel@nongnu.org; Tue, 30 Mar 2021 10:35:26 -0400 Received: from forward3-smtp.messagingengine.com ([66.111.4.237]:53051) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRFSg-0003GT-D1 for qemu-devel@nongnu.org; Tue, 30 Mar 2021 10:35:21 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailforward.nyi.internal (Postfix) with ESMTP id E547C194135B; Tue, 30 Mar 2021 10:35:16 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Tue, 30 Mar 2021 10:35:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=an9CjP Eia3NFZo9+jaQ9oH7WEovvSvPWesUXDrZMjmM=; b=nWgf5EWn2oHIDO/xVHuo3R peRvmVA3MCPzt3B6P1lUJcAAtiUn03/yxpt5QT1vrf1mS2dOVG/CxIxbClNmYcND aLL6mAKjnOk0DuGl+LUO64km9ConaRDNZ5eJD+TUXz7dJYzUIR7HkQ0N5nd7aF2K cFP7xy/rapVstdJ6VCrVgEmqQ5lLRbEf6vYd/WFBUlQ9X8eLwBR++CB2USxY432f s+98MqQlIHBmjaEBjDD0ZC5DllNgpGWqkSSHYH2MOxHikj1oqaRzkcpPxReTtmXB v00baCywqOKGO1sjMgrRu31585D/wpMip0ezbHX94XJJTQQYEr1s0CgQX1Jvxo4A == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudeitddgjeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepvffujghfhfffkfggtgesthdtredttddttdenucfhrhhomhepffgrvhhiugcu gfgumhhonhgushhonhcuoegumhgvsegumhgvrdhorhhgqeenucggtffrrghtthgvrhhnpe fhkeeguedtvdegffffteehjedvjeeitefgfefgffdugeffffegudehgeetgeelkeenucfk phepkedurddukeejrddviedrvdefkeenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpegumhgvsegumhgvrdhorhhg X-ME-Proxy: Received: from disaster-area.hh.sledj.net (disaster-area.hh.sledj.net [81.187.26.238]) by mail.messagingengine.com (Postfix) with ESMTPA id 138CF1080063; Tue, 30 Mar 2021 10:35:15 -0400 (EDT) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id c97b5c0f; Tue, 30 Mar 2021 14:35:13 +0000 (UTC) To: Vitaly Kuznetsov , qemu-devel@nongnu.org, Paolo Bonzini , "Dr . David Alan Gilbert" Subject: Re: [PATCH] i386: Make 'hv-reenlightenment' require explicit 'tsc-frequency' setting In-Reply-To: <20210330123603.284354-1-vkuznets@redhat.com> References: <20210330123603.284354-1-vkuznets@redhat.com> X-HGTTG: zarquon From: David Edmondson Date: Tue, 30 Mar 2021 15:35:13 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Received-SPF: neutral client-ip=66.111.4.237; envelope-from=dme@dme.org; helo=forward3-smtp.messagingengine.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_NEUTRAL=0.779, UNPARSEABLE_RELAY=0.001 autolearn=ham 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: Richard Henderson , Eduardo Habkost , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Tuesday, 2021-03-30 at 14:36:03 +02, Vitaly Kuznetsov wrote: > Commit 561dbb41b1d7 "i386: Make migration fail when Hyper-V reenlightenment > was enabled but 'user_tsc_khz' is unset" forbade migrations with when guest > has opted for reenlightenment notifications but 'tsc-frequency' wasn't set > explicitly on the command line. This works but the migration fail late and s/fail/fails/ > this may come as an unpleasant surprise. To make things more explicit, > require 'tsc-frequency=' on the command line when 'hv-reenlightenment' was > enabled. Make the change affect 6.0+ machine types only to preserve > previously-valid configurations valid. s/ valid// > > Signed-off-by: Vitaly Kuznetsov > --- > docs/hyperv.txt | 1 + > hw/i386/pc.c | 1 + > target/i386/cpu.c | 23 +++++++++++++++++++++-- > target/i386/cpu.h | 1 + > 4 files changed, 24 insertions(+), 2 deletions(-) > > diff --git a/docs/hyperv.txt b/docs/hyperv.txt > index e53c581f4586..5b02d341ab25 100644 > --- a/docs/hyperv.txt > +++ b/docs/hyperv.txt > @@ -165,6 +165,7 @@ emulate TSC accesses after migration so 'tsc-frequency=' CPU option also has to > be specified to make migration succeed. The destination host has to either have > the same TSC frequency or support TSC scaling CPU feature. > > +Requires: tsc-frequency > Recommended: hv-frequencies > > 3.16. hv-evmcs > diff --git a/hw/i386/pc.c b/hw/i386/pc.c > index 8a84b25a031e..47b79e949ad7 100644 > --- a/hw/i386/pc.c > +++ b/hw/i386/pc.c > @@ -98,6 +98,7 @@ > > GlobalProperty pc_compat_5_2[] = { > { "ICH9-LPC", "x-smi-cpu-hotunplug", "off" }, > + { TYPE_X86_CPU, "x-hv-reenlightenment-requires-tscfreq", "off"}, > }; > const size_t pc_compat_5_2_len = G_N_ELEMENTS(pc_compat_5_2); > > diff --git a/target/i386/cpu.c b/target/i386/cpu.c > index 6b3e9467f177..751636bafac5 100644 > --- a/target/i386/cpu.c > +++ b/target/i386/cpu.c > @@ -6647,10 +6647,23 @@ static void x86_cpu_filter_features(X86CPU *cpu, bool verbose) > } > } > > -static void x86_cpu_hyperv_realize(X86CPU *cpu) > +static void x86_cpu_hyperv_realize(X86CPU *cpu, Error **errp) > { > + CPUX86State *env = &cpu->env; > size_t len; > > + /* > + * Reenlightenment requires explicit 'tsc-frequency' setting for successful > + * migration (see hyperv_reenlightenment_post_load(). As 'hv-passthrough' s/post_load()/post_load())/ > + * mode is not migratable, we can loosen the restriction. > + */ > + if (hyperv_feat_enabled(cpu, HYPERV_FEAT_REENLIGHTENMENT) && > + !cpu->hyperv_passthrough && !env->user_tsc_khz && > + cpu->hyperv_reenlightenment_requires_tscfreq) { > + error_setg(errp, "'hv-reenlightenment' requires 'tsc-frequency=' to be set"); s/=// > + return; > + } > + > /* Hyper-V vendor id */ > if (!cpu->hyperv_vendor) { > memcpy(cpu->hyperv_vendor_id, "Microsoft Hv", 12); > @@ -6846,7 +6859,11 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) > } > > /* Process Hyper-V enlightenments */ > - x86_cpu_hyperv_realize(cpu); > + x86_cpu_hyperv_realize(cpu, &local_err); > + if (local_err != NULL) { > + error_propagate(errp, local_err); > + return; > + } > > cpu_exec_realizefn(cs, &local_err); > if (local_err != NULL) { > @@ -7374,6 +7391,8 @@ static Property x86_cpu_properties[] = { > DEFINE_PROP_INT32("x-hv-max-vps", X86CPU, hv_max_vps, -1), > DEFINE_PROP_BOOL("x-hv-synic-kvm-only", X86CPU, hyperv_synic_kvm_only, > false), > + DEFINE_PROP_BOOL("x-hv-reenlightenment-requires-tscfreq", X86CPU, > + hyperv_reenlightenment_requires_tscfreq, true), > DEFINE_PROP_BOOL("x-intel-pt-auto-level", X86CPU, intel_pt_auto_level, > true), > DEFINE_PROP_END_OF_LIST() > diff --git a/target/i386/cpu.h b/target/i386/cpu.h > index 570f916878f9..0196a300f018 100644 > --- a/target/i386/cpu.h > +++ b/target/i386/cpu.h > @@ -1677,6 +1677,7 @@ struct X86CPU { > uint32_t hyperv_spinlock_attempts; > char *hyperv_vendor; > bool hyperv_synic_kvm_only; > + bool hyperv_reenlightenment_requires_tscfreq; > uint64_t hyperv_features; > bool hyperv_passthrough; > OnOffAuto hyperv_no_nonarch_cs; > -- > 2.30.2 dme. -- No proper time of day.