From nobody Fri May 3 19:35:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14963170107555.086757513267912; Thu, 1 Jun 2017 04:36:50 -0700 (PDT) Received: from localhost ([::1]:43470 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGOPJ-0004iQ-EO for importer@patchew.org; Thu, 01 Jun 2017 07:36:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGOOA-00049G-MH for qemu-devel@nongnu.org; Thu, 01 Jun 2017 07:35:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGOO6-0000Eh-0C for qemu-devel@nongnu.org; Thu, 01 Jun 2017 07:35:38 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:3889) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1dGOO5-0000Dt-EA for qemu-devel@nongnu.org; Thu, 01 Jun 2017 07:35:33 -0400 Received: from 172.30.72.54 (EHLO dggeml406-hub.china.huawei.com) ([172.30.72.54]) by dggrg03-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id AOQ65388; Thu, 01 Jun 2017 19:35:30 +0800 (CST) Received: from localhost (10.177.18.62) by dggeml406-hub.china.huawei.com (10.3.17.50) with Microsoft SMTP Server id 14.3.301.0; Thu, 1 Jun 2017 19:35:23 +0800 From: Gonglei To: Date: Thu, 1 Jun 2017 19:35:15 +0800 Message-ID: <1496316915-121196-1-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 2.8.2.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.177.18.62] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.592FFC03.0017, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: e0c796adbf0991f8e7628dc21ee271d3 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 45.249.212.189 Subject: [Qemu-devel] [PATCH v2] kvm: don't register smram_listener when smm is off 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: pbonzini@redhat.com, Gonglei , yechuan@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If the user set disable smm by '-machine smm=3Doff', we should not register smram_listener so that we can avoid waster memory in kvm since the added sencond address space. Meanwhile we should assign value of the global kvm_state before invoking the kvm_arch_init(), because pc_machine_is_smm_enabled() may use it by kvm_has_mm(). Signed-off-by: Gonglei --- v2:=20 Do a a object_dynamic_cast before invoking PC_MACHINE(ms) [Paolo] kvm-all.c | 4 ++-- target/i386/kvm.c | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index 90b8573..92bdf2c 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1746,6 +1746,8 @@ static int kvm_init(MachineState *ms) kvm_ioeventfd_any_length_allowed =3D (kvm_check_extension(s, KVM_CAP_IOEVENTFD_ANY_LENGTH) > 0); =20 + kvm_state =3D s; + ret =3D kvm_arch_init(ms, s); if (ret < 0) { goto err; @@ -1755,8 +1757,6 @@ static int kvm_init(MachineState *ms) kvm_irqchip_create(ms, s); } =20 - kvm_state =3D s; - if (kvm_eventfds_allowed) { s->memory_listener.listener.eventfd_add =3D kvm_mem_ioeventfd_add; s->memory_listener.listener.eventfd_del =3D kvm_mem_ioeventfd_del; diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 011d4a5..5106f5f 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1254,7 +1254,9 @@ int kvm_arch_init(MachineState *ms, KVMState *s) } } =20 - if (kvm_check_extension(s, KVM_CAP_X86_SMM)) { + if (kvm_check_extension(s, KVM_CAP_X86_SMM) && + object_dynamic_cast(OBJECT(ms), TYPE_PC_MACHINE) && + pc_machine_is_smm_enabled(PC_MACHINE(ms))) { smram_machine_done.notify =3D register_smram_listener; qemu_add_machine_init_done_notifier(&smram_machine_done); } --=20 1.8.3.1