From nobody Mon Feb 9 09:00:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648192593700324.75269633253924; Fri, 25 Mar 2022 00:16:33 -0700 (PDT) Received: from localhost ([::1]:48004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nXeBU-0008K0-IE for importer@patchew.org; Fri, 25 Mar 2022 03:16:32 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50094) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nXe2T-0007zc-4J for qemu-devel@nongnu.org; Fri, 25 Mar 2022 03:07:14 -0400 Received: from [2a00:1450:4864:20::52b] (port=46729 helo=mail-ed1-x52b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nXe2Q-0000XQ-8t for qemu-devel@nongnu.org; Fri, 25 Mar 2022 03:07:12 -0400 Received: by mail-ed1-x52b.google.com with SMTP id z92so8132075ede.13 for ; Fri, 25 Mar 2022 00:07:09 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:1c09:f536:3de6:228c]) by smtp.gmail.com with ESMTPSA id ka6-20020a170907990600b006ce54c95e3csm2011497ejc.161.2022.03.25.00.07.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 00:07:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2MTfTM5YhwEohgITY6SYuE6xcO+g6Qsatyh2PCd2K4s=; b=WjPc7X+tvMG6aDnvS0Rwr6lgh+cSW+N/pF7/ZNS27Zu61U65tZX3LS16hpJk7zQ/ib g7kH3RX5iAQzyAG4LnLhVIhiB6in2XjokWuj6f0fpAAeuBrp31ZtwzK426aup7WPIWXg 5K1f0OHK4Hp+qn5Y8zBrr7vUPpajJuLwTPdgk8ho9Wml3wW+5lmmaDlvNenI5ZA3RYQL XbAf7e+kUay0YtV4NZFNVXQgDspZVrYa8KIs5CtUpRSNhu3pyYM/9ELFqa4LMsdzy52B YSRH0KKRAtbfz4xQzpv3SI+U9D8ZUdLEx4tbokuWWLHp1pdOdx8GSZMdsVfyCy3ncv8i Sm6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=2MTfTM5YhwEohgITY6SYuE6xcO+g6Qsatyh2PCd2K4s=; b=twBFk3YdwuhVKhBmHMqo3oIqGj8srpVFxXwH5n1OcWk3nPcFwqxkYJRdHxMXPOG+n2 9jFkJlNFt92XVRKClRUTWMUx8+WxZUTj9M2Kaz33kzqtmWBueiynL3gmpVan4SIrwmQg ZT+8VGIBfgoxrPPIEbQ0RYGhNOaRbexSRtbG3JMewn8s0HFvJRfHdhzuIou3L9k2kQeN qsS4H55mB2wzxUK+8WPhRzhXDJei8VSJr8CskZxie3lIoKyCD+DydoAqhX7YX9VHqzRQ fw/xy1N1MOkbskyu1UPvwe6s1BgzBqAim0qL4+TRf09/MCH3Mt5Pra1vfNhQqvL0OhJU um9w== X-Gm-Message-State: AOAM5302IX8ZzxX0vtOao3LTc2eRQubvcf3YfWXGjiCrs85Nm5r5s1f8 YNh2ugondpIUwJ9FU9bjeHnVkk13v6s= X-Google-Smtp-Source: ABdhPJwazMQQ0SKXFHaTDksvYrhYe/Z0+YtZFxg82jSgT/q3byW/9cLGTkmbeP9dZ8oGbJ56HfTmUQ== X-Received: by 2002:aa7:c755:0:b0:419:2f66:e22c with SMTP id c21-20020aa7c755000000b004192f66e22cmr10906888eds.381.1648192028850; Fri, 25 Mar 2022 00:07:08 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 1/7] target/i386/kvm: Free xsave_buf when destroying vCPU Date: Fri, 25 Mar 2022 08:07:00 +0100 Message-Id: <20220325070706.271291-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220325070706.271291-1-pbonzini@redhat.com> References: <20220325070706.271291-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::52b (failed) 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: pass client-ip=2a00:1450:4864:20::52b; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52b.google.com X-Spam_score_int: 0 X-Spam_score: -0.1 X-Spam_bar: / X-Spam_report: (-0.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648192595697100001 From: Philippe Mathieu-Daud=C3=A9 Fix vCPU hot-unplug related leak reported by Valgrind: =3D=3D132362=3D=3D 4,096 bytes in 1 blocks are definitely lost in loss re= cord 8,440 of 8,549 =3D=3D132362=3D=3D at 0x4C3B15F: memalign (vg_replace_malloc.c:1265) =3D=3D132362=3D=3D by 0x4C3B288: posix_memalign (vg_replace_malloc.c:1= 429) =3D=3D132362=3D=3D by 0xB41195: qemu_try_memalign (memalign.c:53) =3D=3D132362=3D=3D by 0xB41204: qemu_memalign (memalign.c:73) =3D=3D132362=3D=3D by 0x7131CB: kvm_init_xsave (kvm.c:1601) =3D=3D132362=3D=3D by 0x7148ED: kvm_arch_init_vcpu (kvm.c:2031) =3D=3D132362=3D=3D by 0x91D224: kvm_init_vcpu (kvm-all.c:516) =3D=3D132362=3D=3D by 0x9242C9: kvm_vcpu_thread_fn (kvm-accel-ops.c:40) =3D=3D132362=3D=3D by 0xB2EB26: qemu_thread_start (qemu-thread-posix.c= :556) =3D=3D132362=3D=3D by 0x7EB2159: start_thread (in /usr/lib64/libpthrea= d-2.28.so) =3D=3D132362=3D=3D by 0x9D45DD2: clone (in /usr/lib64/libc-2.28.so) Reported-by: Mark Kanda Signed-off-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Mark Kanda Message-Id: <20220322120522.26200-1-philippe.mathieu.daude@gmail.com> Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 06901c2a43..7396b430d7 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -2081,6 +2081,8 @@ int kvm_arch_destroy_vcpu(CPUState *cs) X86CPU *cpu =3D X86_CPU(cs); CPUX86State *env =3D &cpu->env; =20 + g_free(env->xsave_buf); + if (cpu->kvm_msr_buf) { g_free(cpu->kvm_msr_buf); cpu->kvm_msr_buf =3D NULL; --=20 2.35.1 From nobody Mon Feb 9 09:00:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648192302452846.1093563509975; Fri, 25 Mar 2022 00:11:42 -0700 (PDT) Received: from localhost ([::1]:39462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nXe6n-0002OZ-EV for importer@patchew.org; Fri, 25 Mar 2022 03:11:41 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nXe2T-0007ze-EQ for qemu-devel@nongnu.org; Fri, 25 Mar 2022 03:07:14 -0400 Received: from [2a00:1450:4864:20::529] (port=36479 helo=mail-ed1-x529.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nXe2Q-0000XU-TB for qemu-devel@nongnu.org; Fri, 25 Mar 2022 03:07:13 -0400 Received: by mail-ed1-x529.google.com with SMTP id h4so395365edr.3 for ; Fri, 25 Mar 2022 00:07:10 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:1c09:f536:3de6:228c]) by smtp.gmail.com with ESMTPSA id ka6-20020a170907990600b006ce54c95e3csm2011497ejc.161.2022.03.25.00.07.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 00:07:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dXYrp3td8hLF+Y2fCpcA9uLAXTP3QpyuvMkFSnX6eDU=; b=TAyV2mRJdINJRclR3WyGrKaZtvNmbz7zrqyRp0Fpltyumbgn4HCgHNb+zweA5dhBCf RWqcmMuSAnUgQUHwwYx23JjEOd1GzOyXWEAXtIxKbw6qOidYgSXrmK6Uk3ouGmyNWkDF JdCeX3R10QZghAV3faOJGaNxZhDOUlRXykqhG9CI+bHlOh9vizPyu/t7a0Pv6ph6VfUb KYGgWJ1vxJ9/1IAwM799Wg1lAyw6E573im6W0rIRJJN5rTqLTSSSoWF1yqf34E9p7q4T sdnjqbmT6gJrttzUxWsKtTS5jbQm6JCFZSuFsHj8SflFk/zOmBbJk6ko3tNuZiF4Vkz6 pgJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=dXYrp3td8hLF+Y2fCpcA9uLAXTP3QpyuvMkFSnX6eDU=; b=K59HeeGFenficoCQ7ioO2U6izieHOGa0EpACS0FzsYIpNvHL1TsNf26AunlkFARLVM 5BHSK+wKb7St5APvZYJqnhs/WoA/YAai4RNb1EgwKdUThLQLuRm+GACSAqpEwzjl86nz lsXnsdfb7sZHAWr7Ryudih876eVTd9eRoyLnrhx+igYw+/JjPfwvxGSttuH/uXWepVlX JmRjzYx7rYLjK7pMOpEXvzp4JUwL/PhzSAdftXcDt8S4eYc52et9NdgGsGe0v1N4aBTJ WYnAvWvIa6iqxJ4auBw+gf3Yjp/qtX8+BR35vztEN4vKeeExwSRti2wmWAtaOg9FSCIa LHBg== X-Gm-Message-State: AOAM531aF8OKOjd2LiYXkHfCACgRaG7CFRUcORs7b/nbAacyUjgukIuc caFN7m72KHSeX0BGarLFIbWOty9xKK4= X-Google-Smtp-Source: ABdhPJxh5N6DAZeZbvdyxCb0YCRwqNpf24vPLz7UaTxAuphwytbUJyb3gL9nb1qqFzPLQwCIXuSGZg== X-Received: by 2002:a05:6402:528e:b0:407:80ff:6eed with SMTP id en14-20020a056402528e00b0040780ff6eedmr11370517edb.165.1648192029626; Fri, 25 Mar 2022 00:07:09 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 2/7] i386: Set MCG_STATUS_RIPV bit for mce SRAR error Date: Fri, 25 Mar 2022 08:07:01 +0100 Message-Id: <20220325070706.271291-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220325070706.271291-1-pbonzini@redhat.com> References: <20220325070706.271291-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::529 (failed) 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: pass client-ip=2a00:1450:4864:20::529; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x529.google.com X-Spam_score_int: 0 X-Spam_score: -0.1 X-Spam_bar: / X-Spam_report: (-0.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: luofei Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648192304976100007 Content-Type: text/plain; charset="utf-8" From: luofei In the physical machine environment, when a SRAR error occurs, the IA32_MCG_STATUS RIPV bit is set, but qemu does not set this bit. When qemu injects an SRAR error into virtual machine, the virtual machine kernel just call do_machine_check() to kill the current task, but not call memory_failure() to isolate the faulty page, which will cause the faulty page to be allocated and used repeatedly. If used by the virtual machine kernel, it will cause the virtual machine to crash Signed-off-by: luofei Message-Id: <20220120084634.131450-1-luofei@unicloud.com> Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 7396b430d7..9cf8e03669 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -569,7 +569,7 @@ static void kvm_mce_inject(X86CPU *cpu, hwaddr paddr, i= nt code) =20 if (code =3D=3D BUS_MCEERR_AR) { status |=3D MCI_STATUS_AR | 0x134; - mcg_status |=3D MCG_STATUS_EIPV; + mcg_status |=3D MCG_STATUS_RIPV | MCG_STATUS_EIPV; } else { status |=3D 0xc0; mcg_status |=3D MCG_STATUS_RIPV; --=20 2.35.1 From nobody Mon Feb 9 09:00:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648192300750666.0656744790014; Fri, 25 Mar 2022 00:11:40 -0700 (PDT) Received: from localhost ([::1]:39398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nXe6l-0002MP-D3 for importer@patchew.org; Fri, 25 Mar 2022 03:11:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nXe2U-000805-1s for qemu-devel@nongnu.org; Fri, 25 Mar 2022 03:07:14 -0400 Received: from [2a00:1450:4864:20::529] (port=41911 helo=mail-ed1-x529.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nXe2S-0000Xc-2n for qemu-devel@nongnu.org; Fri, 25 Mar 2022 03:07:13 -0400 Received: by mail-ed1-x529.google.com with SMTP id x34so8151507ede.8 for ; Fri, 25 Mar 2022 00:07:11 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:1c09:f536:3de6:228c]) by smtp.gmail.com with ESMTPSA id ka6-20020a170907990600b006ce54c95e3csm2011497ejc.161.2022.03.25.00.07.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 00:07:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PRxGaWhCzQyFXNi/mB/7cW8H0Wd6692mLro8T5+Gheg=; b=Sfg11RpesBbVdIdvjQz33hR5914JfYcRQamndkAj5y/v3l89DCyoZEd1/ncJIEsQ6c EakdUWchbvVPDFDFOHv3eGYMN0S8/Qxyi3ATNqYij5tgyXCDbZdKglsmpD4e5CqbriYo U896qesgCaaibnPwystMTNgaevyGHoiDJbZlzHPqGC+xRqF2C/EMZ1tpF75mR2ihAJNe OwYZeILOr9072TXwsObz92+WUvfid3mAbX2GnXF1T9FSkiXqtqMtxdPwi/IlhKamkHw5 zbehGAcOdZc2vbYAjzvVCXZvd/YY/bVm5vgyvR5yoEu7pD/bDOUMcW0Ml9E97SzGDV5s 2fog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=PRxGaWhCzQyFXNi/mB/7cW8H0Wd6692mLro8T5+Gheg=; b=lZpWKTue4qV0XrbNFlrNszKvd8GzWpvlMEQp775SG5JM53Qpy4uBtqMGht1iBTTxol 2PLTmK1/3tJJCRkvAz8FZ92I1cnKuudtibMMtIyuSrdpufrnJqKGudgPdFyAJ8R00ns8 RK0CKopezuLDVxijkn4+/u5BrZEYEhjQsSWUVX85rYjQlk/cWB1HdD5BixUrF0bMyHLL +8FgAwgKCjMfkPe9pHGSJQS/poLj3ojuj0fTbS3h6203FrpeiTcOfgxRIfWwySLNCRnK NMr0DdAlBHSMY1ronhwT3Yx2QH7lxfGbZuj8NQbdxbQE8f1uRLWczzVBQO4434sR8TJi iCow== X-Gm-Message-State: AOAM5319L2fqdq4hHI6O7Ca9NDLUjCmQj45TVABJl2xBWMgDDlUFftRI 2WZDDToQt+vLieiyydXxrLSftDvrpu0= X-Google-Smtp-Source: ABdhPJwRxGa6AQdsT2uyy2qpuxSIpZh/ln9ftLMDwr/cdi/1L8dLDgHu9uy07NfcR8HGfxIVH49wdA== X-Received: by 2002:a05:6402:4402:b0:418:ff4c:f102 with SMTP id y2-20020a056402440200b00418ff4cf102mr11299451eda.365.1648192030485; Fri, 25 Mar 2022 00:07:10 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 3/7] KVM: x86: workaround invalid CPUID[0xD, 9] info on some AMD processors Date: Fri, 25 Mar 2022 08:07:02 +0100 Message-Id: <20220325070706.271291-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220325070706.271291-1-pbonzini@redhat.com> References: <20220325070706.271291-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::529 (failed) 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: pass client-ip=2a00:1450:4864:20::529; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x529.google.com X-Spam_score_int: 0 X-Spam_score: -0.1 X-Spam_bar: / X-Spam_report: (-0.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Zhong , Peter Krempa , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648192302895100002 Some AMD processors expose the PKRU extended save state even if they do not= have the related PKU feature in CPUID. Worse, when they do they report a size of 64, whereas the expected size of the PKRU extended save state is 8, therefo= re the esa->size =3D=3D eax assertion does not hold. The state is already ignored by KVM_GET_SUPPORTED_CPUID because it was not enabled in the host XCR0. However, QEMU kvm_cpu_xsave_init() runs before QEMU invokes arch_prctl() to enable dynamically-enabled save states such as XTILEDATA, and KVM_GET_SUPPORTED_CPUID hides save states that have yet to be enabled. Therefore, kvm_cpu_xsave_init() needs to consult the host CPUID instead of KVM_GET_SUPPORTED_CPUID, and dies with an assertion failure. When setting up the ExtSaveArea array to match the host, ignore features th= at KVM does not report as supported. This will cause QEMU to skip the incorre= ct CPUID leaf instead of tripping the assertion. Closes: https://gitlab.com/qemu-project/qemu/-/issues/916 Reported-by: Daniel P. Berrang=C3=A9 Analyzed-by: Yang Zhong Reported-by: Peter Krempa Tested-by: Daniel P. Berrang=C3=A9 Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 4 ++-- target/i386/cpu.h | 2 ++ target/i386/kvm/kvm-cpu.c | 19 ++++++++++++------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index a88d6554c8..ec3b50bf6e 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4981,8 +4981,8 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Erro= r **errp) return cpu_list; } =20 -static uint64_t x86_cpu_get_supported_feature_word(FeatureWord w, - bool migratable_only) +uint64_t x86_cpu_get_supported_feature_word(FeatureWord w, + bool migratable_only) { FeatureWordInfo *wi =3D &feature_word_info[w]; uint64_t r =3D 0; diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 5e406088a9..e31e6bd8b8 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -606,6 +606,8 @@ typedef enum FeatureWord { } FeatureWord; =20 typedef uint64_t FeatureWordArray[FEATURE_WORDS]; +uint64_t x86_cpu_get_supported_feature_word(FeatureWord w, + bool migratable_only); =20 /* cpuid_features bits */ #define CPUID_FP87 (1U << 0) diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c index a35a1bf9fe..5eb955ce9a 100644 --- a/target/i386/kvm/kvm-cpu.c +++ b/target/i386/kvm/kvm-cpu.c @@ -99,13 +99,18 @@ static void kvm_cpu_xsave_init(void) for (i =3D XSTATE_SSE_BIT + 1; i < XSAVE_STATE_AREA_COUNT; i++) { ExtSaveArea *esa =3D &x86_ext_save_areas[i]; =20 - if (esa->size) { - host_cpuid(0xd, i, &eax, &ebx, &ecx, &edx); - if (eax !=3D 0) { - assert(esa->size =3D=3D eax); - esa->offset =3D ebx; - esa->ecx =3D ecx; - } + if (!esa->size) { + continue; + } + if ((x86_cpu_get_supported_feature_word(esa->feature, false) & esa= ->bits) + !=3D esa->bits) { + continue; + } + host_cpuid(0xd, i, &eax, &ebx, &ecx, &edx); + if (eax !=3D 0) { + assert(esa->size =3D=3D eax); + esa->offset =3D ebx; + esa->ecx =3D ecx; } } } --=20 2.35.1 From nobody Mon Feb 9 09:00:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648192596317276.9633728230665; Fri, 25 Mar 2022 00:16:36 -0700 (PDT) Received: from localhost ([::1]:48118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nXeBW-0008OQ-W8 for importer@patchew.org; Fri, 25 Mar 2022 03:16:35 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nXe2U-000806-2q for qemu-devel@nongnu.org; Fri, 25 Mar 2022 03:07:14 -0400 Received: from [2a00:1450:4864:20::52c] (port=35775 helo=mail-ed1-x52c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nXe2S-0000Xl-KP for qemu-devel@nongnu.org; Fri, 25 Mar 2022 03:07:13 -0400 Received: by mail-ed1-x52c.google.com with SMTP id k10so8185484edj.2 for ; Fri, 25 Mar 2022 00:07:12 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:1c09:f536:3de6:228c]) by smtp.gmail.com with ESMTPSA id ka6-20020a170907990600b006ce54c95e3csm2011497ejc.161.2022.03.25.00.07.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 00:07:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bERp2p0Xrlr6QnzpMTfcSdabbsR9hkmx0eBPG3U9Xy8=; b=T0JeGXOWT95PzgjZvKCKflgt8qiwRKwydhtTnhTtWFnCETaImlYyTzg5xFGEgb3ERi KiRM7+0Bclv0DFg7bGSFoxu0oG1nD6YQesCCfzEkbLzmSnQcgQcbAheuYWgcYS+wepV5 ZjKsJr8cVHcB67pb3K+gKryz2y8parNXZfd9GQ47hhDUIiow3Ad5z+5+hl8wXGQaupot oQmlM7FocbRqT/06dc5AWQyyKoLFOpVKX5AoIpJOK/zpkgMKZD2RlFXfrjjZWgOk3c9E U/ekCS9xStTG9BuNPu3BhlE5M3M9GJl/9CxG6Nr8B5tOJ5Q8KiIuje0wbHbNfYOjQPKl gO+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=bERp2p0Xrlr6QnzpMTfcSdabbsR9hkmx0eBPG3U9Xy8=; b=tWLkylR+a6/ZlFf5TQllvjEGB/DxFWLBJHNtmMdfcTTNuHhhjD23EutHSSHNakczCe lUyHifoe1IKpskie/9MZXoaMiL5L+WqOVMwTrB5zi/YNRgKDX/6nXIDmNYDXT8k/e2qk F6oWgQ0TK9VJ4J/WSf1v0lS7peoPz0/E83hRb8cXOr2PYr0aGKPxzi7/Wbq338/vgU++ sEmfmGrR9RKuhzAszrq0YgxD3URB2xXur7Tt7o1EDwpk7Y4EqEn82q4MddKyB8OpGtzP rt3nq/OwFl6pL69rQFKXX3SV/8/1OpoE/NWkk5CI7Izi5GeQfhYxQsRz4ioSl0G5tbef BK6g== X-Gm-Message-State: AOAM531L/Iuw3MWn/wncrlOpl+rG5VFj6lukWUTUAp9u+OSMoH8lIi9m 8XX28/Js2zUdIpyyfGbp+umFNo1txMs= X-Google-Smtp-Source: ABdhPJzja8QOG13eXPXxVfm7BCejkqqGz82rh7zjSoANr/oOYhUOSWk1/3MxEGEqZJ6QmBzvXjeIyg== X-Received: by 2002:a05:6402:254e:b0:418:e716:f987 with SMTP id l14-20020a056402254e00b00418e716f987mr11208743edb.74.1648192031256; Fri, 25 Mar 2022 00:07:11 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 4/7] configure: remove dead int128 test Date: Fri, 25 Mar 2022 08:07:03 +0100 Message-Id: <20220325070706.271291-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220325070706.271291-1-pbonzini@redhat.com> References: <20220325070706.271291-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::52c (failed) 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: pass client-ip=2a00:1450:4864:20::52c; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52c.google.com X-Spam_score_int: 0 X-Spam_score: -0.1 X-Spam_bar: / X-Spam_report: (-0.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648192597445100005 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- configure | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/configure b/configure index 6d9cb23ac5..7c08c18358 100755 --- a/configure +++ b/configure @@ -2463,24 +2463,6 @@ else # "$safe_stack" =3D "" fi fi =20 -######################################## -# check if __[u]int128_t is usable. - -int128=3Dno -cat > $TMPC << EOF -__int128_t a; -__uint128_t b; -int main (void) { - a =3D a + b; - b =3D a * b; - a =3D a * a; - return 0; -} -EOF -if compile_prog "" "" ; then - int128=3Dyes -fi - ######################################## # check if ccache is interfering with # semantic analysis of macros --=20 2.35.1 From nobody Mon Feb 9 09:00:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648192871867703.2468532733619; Fri, 25 Mar 2022 00:21:11 -0700 (PDT) Received: from localhost ([::1]:55212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nXeFw-0004qG-Me for importer@patchew.org; Fri, 25 Mar 2022 03:21:10 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50136) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nXe2V-00080H-56 for qemu-devel@nongnu.org; Fri, 25 Mar 2022 03:07:15 -0400 Received: from [2a00:1450:4864:20::532] (port=45993 helo=mail-ed1-x532.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nXe2T-0000Y1-Df for qemu-devel@nongnu.org; Fri, 25 Mar 2022 03:07:14 -0400 Received: by mail-ed1-x532.google.com with SMTP id u26so8137061eda.12 for ; Fri, 25 Mar 2022 00:07:13 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:1c09:f536:3de6:228c]) by smtp.gmail.com with ESMTPSA id ka6-20020a170907990600b006ce54c95e3csm2011497ejc.161.2022.03.25.00.07.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 00:07:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gGwR00G2oPsV6CI+SY2f6JpoisnJnzXQj8p1weGDL4c=; b=fgx7QCk7r0zCGQi5IsfqDxWxbnrBtz+zqrVShNJEl/7p1FDMIDCn8+XClKcU/oYzSa OWZCEMowZWNGq30BmAb08YIsQCW64382S1Cb2kl01iQJe6y04dGsIHxeHtip9k/VLLH2 ULRG2eB81L7Ce7TcnOo9scGVTDwsd0dYl9wh73dkxKOLZH1lM2I0EdeK0MWTs6Km9LX8 x3qFNnivqOlZXGiFruDl0g4gzaRNd3Zy+3bCh1izXFahPTDL3cl6AR9O54hWpWDY0hOg do452TtdUzGky6Pe2WwccthdjGR9AQ0nQMcWrAHY+Oj0NJXAdvFoFc5ZarZl6zzsrJ6w b/9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=gGwR00G2oPsV6CI+SY2f6JpoisnJnzXQj8p1weGDL4c=; b=6UDQXEd1C5xyC6UypCQyA4a30TP1N2zm9Kqwv4FBYIf3GcaSgDlJgD6MPg2LpureZ/ 7PxjNlZ9PtY09jwuWqlMUlPGbRhawF7UbOyy61lFwegFjyJXpOx90n/gvqOLjDmVE1JZ vFj2MQ2HANVQIBOMzFXkLPZ3xbhgHXgpVlMwJK9htkMPcWPKBg03rSzzEmgboB+i0m4v k1luWUNdk9giDEL/PFmgnmTOipWeUTmkxDcapno9PwRdPFXim8xplpdkXnA2tfgfe+W3 6dNwtnvZhZQRF6nRCM4vmLMoBSmCauU25+1L4xtiMGFb3RrvwbG3w51RlJrDaMyTyuZT LuUw== X-Gm-Message-State: AOAM531YmotuLBquaZTXAYuqPa1uyj3P7ur9PtEEMUrhSwGDWs3cTJaf lDezsM++L72ZvwF2KJdSE2TaWq2e3Pc= X-Google-Smtp-Source: ABdhPJwpuilyUJ1fXJE7W/TK8knOm1DhxEjjHUd3I/o78iNRIE+A0iqVbizVLCEGnOJXGj2Zdjm49g== X-Received: by 2002:a05:6402:6c2:b0:419:1a14:8fb2 with SMTP id n2-20020a05640206c200b004191a148fb2mr11474997edy.415.1648192032086; Fri, 25 Mar 2022 00:07:12 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 5/7] target/i386: tcg: high bits SSE cmp operation must be ignored Date: Fri, 25 Mar 2022 08:07:04 +0100 Message-Id: <20220325070706.271291-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220325070706.271291-1-pbonzini@redhat.com> References: <20220325070706.271291-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::532 (failed) 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: pass client-ip=2a00:1450:4864:20::532; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x532.google.com X-Spam_score_int: 0 X-Spam_score: -0.1 X-Spam_bar: / X-Spam_report: (-0.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sonicadvance1@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648192873866100001 Content-Type: text/plain; charset="utf-8" High bits in the immediate operand of SSE comparisons are ignored, they do not result in an undefined opcode exception. This is mentioned explicitly in the Intel documentation. Reported-by: sonicadvance1@gmail.com Closes: https://gitlab.com/qemu-project/qemu/-/issues/184 Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 2a94d33742..c393913fe0 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -4509,10 +4509,8 @@ static void gen_sse(CPUX86State *env, DisasContext *= s, int b, sse_fn_ppi(s->ptr0, s->ptr1, tcg_const_i32(val)); break; case 0xc2: - /* compare insns */ - val =3D x86_ldub_code(env, s); - if (val >=3D 8) - goto unknown_op; + /* compare insns, bits 7:3 (7:5 for AVX) are ignored */ + val =3D x86_ldub_code(env, s) & 7; sse_fn_epp =3D sse_op_table4[val][b1]; =20 tcg_gen_addi_ptr(s->ptr0, cpu_env, op1_offset); --=20 2.35.1 From nobody Mon Feb 9 09:00:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648192593796987.5386017028803; Fri, 25 Mar 2022 00:16:33 -0700 (PDT) Received: from localhost ([::1]:48006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nXeBU-0008KC-FM for importer@patchew.org; Fri, 25 Mar 2022 03:16:32 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50146) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nXe2V-00081A-Qw for qemu-devel@nongnu.org; Fri, 25 Mar 2022 03:07:16 -0400 Received: from [2a00:1450:4864:20::636] (port=37559 helo=mail-ej1-x636.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nXe2U-0000YK-AF for qemu-devel@nongnu.org; Fri, 25 Mar 2022 03:07:15 -0400 Received: by mail-ej1-x636.google.com with SMTP id bg10so13556126ejb.4 for ; Fri, 25 Mar 2022 00:07:13 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:1c09:f536:3de6:228c]) by smtp.gmail.com with ESMTPSA id ka6-20020a170907990600b006ce54c95e3csm2011497ejc.161.2022.03.25.00.07.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 00:07:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CUbR9AcG19kIN8ZsGbwDkz1U6dA2t1qr2XCcLZ2Dh6E=; b=PQtyxmdjGXN2Eofrbso5AhtOszMwBXDUiM3SHyN9ZEL71AGZtGDq70uYF3QKuIHzUA xZ3INqWQVfx7RGURN4S3ihLdfxqRmUk2Zu+bmtf+565t9tlkQF5wQBeVUWbr4jY1NY7K 8k7U5QpOpuY934dgk53idUInyyr8hb6S2vWnHNsGpXUKe2iw/inZNUKHeHr2Ir2U0IXo kg5lYUSb/kfdBRa9G7fJ8hkwiuAabkJFwdqFkjh9XaXkGlyZ1RtPGz3MnHSVH3Z5Wekp ZfD9F2320LymtgeiH0snJSX/I6drSsyLsdRMPHYJq+ZpFHfIn8lLdjB4NiiNh4im67oo rZfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=CUbR9AcG19kIN8ZsGbwDkz1U6dA2t1qr2XCcLZ2Dh6E=; b=ZQL3xHlWBv6zezm+7xdbWUh6G8VUAQ7/zgkUZUHSYyH3BvH3V7HO445vHRHHKPjDBo 1hxWy//Xy1EWAmY8se3/WoEb/M7bHzxRQPzk0PK4Hd5ozVG1hBj629nwn+10xE1EPub7 xps7mdbRno4HQpkPWw09cY6dOK2qlUWipxof3RIFLrVeU9182SNv/CMfqnKu7ioOnrYD XvykOtX2QR28cuNfpnMbCg5HuyYG/dNVaFDyrnwIGI6l6VjK5s56xats4fZk07RAv0ZJ YTLAry7zjoxD+khvRPNjP2JK2ZYPuSPXTB0wuO/IO5PlnxMwh2mMHz7zKlXqb0gFf9tD 4dtQ== X-Gm-Message-State: AOAM533dWpdDQZ1TnYtq1aYfQJVN9FJtMUC+zmd+ntrm1B8/jS2sInB2 4hHm95d67DSfwTa/mr7zLSy7F9Mz7uY= X-Google-Smtp-Source: ABdhPJxPW3dIf2NGU22+FWJJk4wOqxq8I77gKN+zIE5OsbwHZpcxrJch02Fim0cUWqWY1QJQmBdEQg== X-Received: by 2002:a17:906:5d08:b0:6db:7291:df22 with SMTP id g8-20020a1709065d0800b006db7291df22mr9390212ejt.178.1648192032978; Fri, 25 Mar 2022 00:07:12 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 6/7] target/i386: properly reset TSC on reset Date: Fri, 25 Mar 2022 08:07:05 +0100 Message-Id: <20220325070706.271291-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220325070706.271291-1-pbonzini@redhat.com> References: <20220325070706.271291-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::636 (failed) 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: pass client-ip=2a00:1450:4864:20::636; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x636.google.com X-Spam_score_int: 0 X-Spam_score: -0.1 X-Spam_bar: / X-Spam_report: (-0.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vadim Rozenfeld Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648192595856100003 Content-Type: text/plain; charset="utf-8" Some versions of Windows hang on reboot if their TSC value is greater than 2^54. The calibration of the Hyper-V reference time overflows and fails; as a result the processors' clock sources are out of sync. The issue is that the TSC _should_ be reset to 0 on CPU reset and QEMU tries to do that. However, KVM special cases writing 0 to the TSC and thinks that QEMU is trying to hot-plug a CPU, which is correct the first time through but not later. Thwart this valiant effort and reset the TSC to 1 instead, but only if the CPU has been run once. For this to work, env->tsc has to be moved to the part of CPUArchState that is not zeroed at the beginning of x86_cpu_reset. Reported-by: Vadim Rozenfeld Supersedes: <20220324082346.72180-1-pbonzini@redhat.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 13 +++++++++++++ target/i386/cpu.h | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index ec3b50bf6e..cb6b5467d0 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5931,6 +5931,19 @@ static void x86_cpu_reset(DeviceState *dev) env->xstate_bv =3D 0; =20 env->pat =3D 0x0007040600070406ULL; + + if (kvm_enabled()) { + /* + * KVM handles TSC =3D 0 specially and thinks we are hot-plugging + * a new CPU, use 1 instead to force a reset. + */ + if (env->tsc !=3D 0) { + env->tsc =3D 1; + } + } else { + env->tsc =3D 0; + } + env->msr_ia32_misc_enable =3D MSR_IA32_MISC_ENABLE_DEFAULT; if (env->features[FEAT_1_ECX] & CPUID_EXT_MONITOR) { env->msr_ia32_misc_enable |=3D MSR_IA32_MISC_ENABLE_MWAIT; diff --git a/target/i386/cpu.h b/target/i386/cpu.h index e31e6bd8b8..982c532353 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1554,7 +1554,6 @@ typedef struct CPUArchState { target_ulong kernelgsbase; #endif =20 - uint64_t tsc; uint64_t tsc_adjust; uint64_t tsc_deadline; uint64_t tsc_aux; @@ -1708,6 +1707,7 @@ typedef struct CPUArchState { int64_t tsc_khz; int64_t user_tsc_khz; /* for sanity check only */ uint64_t apic_bus_freq; + uint64_t tsc; #if defined(CONFIG_KVM) || defined(CONFIG_HVF) void *xsave_buf; uint32_t xsave_buf_len; --=20 2.35.1 From nobody Mon Feb 9 09:00:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648192883067802.9539092857726; Fri, 25 Mar 2022 00:21:23 -0700 (PDT) Received: from localhost ([::1]:55180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nXeG9-0004p3-JT for importer@patchew.org; Fri, 25 Mar 2022 03:21:21 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nXe2W-00081T-Qi for qemu-devel@nongnu.org; Fri, 25 Mar 2022 03:07:18 -0400 Received: from [2a00:1450:4864:20::62f] (port=35798 helo=mail-ej1-x62f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nXe2V-0000YZ-8w for qemu-devel@nongnu.org; Fri, 25 Mar 2022 03:07:16 -0400 Received: by mail-ej1-x62f.google.com with SMTP id yy13so13566111ejb.2 for ; Fri, 25 Mar 2022 00:07:14 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:1c09:f536:3de6:228c]) by smtp.gmail.com with ESMTPSA id ka6-20020a170907990600b006ce54c95e3csm2011497ejc.161.2022.03.25.00.07.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 00:07:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KOXukSeGvKPa/jn/RHjHjBTNJmqDlyXvTERfCqrhePE=; b=IKZjaEZD6yk2Tfm6RtJoMOnOxP/xk9yrOi4hAQYY3UNLMaYBxivVsZ62Wrj0h2hxyl wSY3Zh9Uf6WnUIzqf/EruI8sCCqruJSvyb4K5L5QyOvoj45tF3XWNYAtHTvzaIzB4Ip2 k9zb15zJTyWj6ab7pbX8cCHasdA8OBawulZXyxfxcN/lfX+e7ZkM5lb1iJMeOoP4Z3F4 hugev2ub2VTWReqvg+xStgZND04Gp0FvhSeZLOoWVaoYLtM4j2l+DAD0Zb1V4Iil3Yab xD7biuKNsczjj2Xxi76Yoib6RBqVsrJBlMkYLFFv2Vs0i8uuvGUtU8Nu7DdTkZEbI6Ri dGSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=KOXukSeGvKPa/jn/RHjHjBTNJmqDlyXvTERfCqrhePE=; b=LCmAc0GA3jeCCXK6+HfQd/jQ6adpcyqO66ZEFLXfnVWnC/ST0us1bZz2Rd9HZ2RuLI 26N1uX7DWMeNpdPXI15sIvuFGsFZ0QSxLd6KSWXLwo2qng8gvTbKcS4fdbNtva2shgVM ++3YWCkNuJYbDLa+IKa5d3ur8D2d7uHahroH0OW5wL8/Slc8VX7B2VQawkWYIkW74x9G AjhihU3ZNnww1VCdkoQp4fjrqjoxPOAVV+2hLv2LeDi4oB7Ede5IdNItucsRKix7dGGX ZYrwBhKMkz1eUCQ4D2y9fQ4QFN/Mb8Fmq6WWpR9DImGP4T4fVd8/wuzTRP/sIz3ljxKQ Hi8Q== X-Gm-Message-State: AOAM532xLzapRkMa+x8svNvP5gwb2TQm3oGNUrXfsYoWurhbgHqlI2Qe GYkLiSlvQEqvmM43P31oOH/LFpLMpQo= X-Google-Smtp-Source: ABdhPJx18cqf+GTCRxuKcCGFJitzFmHvUT9z1wPc1YNbBbwhOSTOT9MX1SFydTbMPXG1Y+vMMX7itg== X-Received: by 2002:a17:907:1c29:b0:6df:f779:f122 with SMTP id nc41-20020a1709071c2900b006dff779f122mr9904802ejc.637.1648192033896; Fri, 25 Mar 2022 00:07:13 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 7/7] build: disable fcf-protection on -march=486 -m16 Date: Fri, 25 Mar 2022 08:07:06 +0100 Message-Id: <20220325070706.271291-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220325070706.271291-1-pbonzini@redhat.com> References: <20220325070706.271291-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::62f (failed) 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: pass client-ip=2a00:1450:4864:20::62f; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x62f.google.com X-Spam_score_int: 0 X-Spam_score: -0.1 X-Spam_bar: / X-Spam_report: (-0.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Christian Ehrhardt Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648192884059100001 From: Christian Ehrhardt Some of the roms build with -march=3Di486 -m16 which is incompatible with -fcf-protection. That in turn is can be set by default, for example in Ubuntu [1]. That causes: cc1: error: =E2=80=98-fcf-protection=E2=80=99 is not compatible with this = target This won't work on -march=3Di486 -m16 and no matter if set or not we can override it to "none" if the option is known to the compiler to be able to build reliably. Fixes: https://gitlab.com/qemu-project/qemu/-/issues/889 [1]: https://wiki.ubuntu.com/ToolChain/CompilerFlags#A-fcf-protection Signed-off-by: Christian Ehrhardt Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Thomas Huth Message-Id: <20220323090713.1002588-1-christian.ehrhardt@canonical.com> Signed-off-by: Paolo Bonzini --- pc-bios/optionrom/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pc-bios/optionrom/Makefile b/pc-bios/optionrom/Makefile index 5d55d25acc..f1ef898073 100644 --- a/pc-bios/optionrom/Makefile +++ b/pc-bios/optionrom/Makefile @@ -14,6 +14,10 @@ cc-option =3D $(if $(shell $(CC) $1 -c -o /dev/null -xc = /dev/null >/dev/null 2>&1 =20 override CFLAGS +=3D -march=3Di486 -Wall =20 +# If -fcf-protection is enabled in flags or compiler defaults that will +# conflict with -march=3Di486 +override CFLAGS +=3D $(call cc-option, -fcf-protection=3Dnone) + # Flags for dependency generation override CPPFLAGS +=3D -MMD -MP -MT $@ -MF $(@D)/$(*F).d =20 --=20 2.35.1