From nobody Fri May 3 09:26:47 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 1491504754427436.2782935741187; Thu, 6 Apr 2017 11:52:34 -0700 (PDT) Received: from localhost ([::1]:47315 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwCWF-0000U9-D8 for importer@patchew.org; Thu, 06 Apr 2017 14:52:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44191) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwCVS-00005w-S0 for qemu-devel@nongnu.org; Thu, 06 Apr 2017 14:51:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cwCVO-0000Fi-0Y for qemu-devel@nongnu.org; Thu, 06 Apr 2017 14:51:42 -0400 Received: from mga11.intel.com ([192.55.52.93]:52974) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cwCVN-0000FV-NW for qemu-devel@nongnu.org; Thu, 06 Apr 2017 14:51:37 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Apr 2017 11:51:36 -0700 Received: from anthony.sc.intel.com ([10.3.52.155]) by fmsmga005.fm.intel.com with ESMTP; 06 Apr 2017 11:51:36 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1491504697; x=1523040697; h=from:to:cc:subject:date:message-id; bh=RK8kJbYuU6mDAa83rpHk6DOjBD7TuPb7GVauS1wBuR0=; b=VnDpy+rJT2ZLMNkqfhHAt0FnUMMBKd0X4y/LsUGu0D6rZCkTIsAowKn2 V9vtBn821jRv+NcxllXi2gJCWjXIbQ==; X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,160,1488873600"; d="scan'208";a="85498343" From: Anthony Xu To: qemu-devel@nongnu.org Date: Thu, 6 Apr 2017 11:57:35 -0700 Message-Id: <1491505055-31845-1-git-send-email-anthony.xu@intel.com> X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.93 Subject: [Qemu-devel] [PATCH v2] kvmvapic: Enable kvmvapic when necessary 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, sferdjao@redhat.com, Anthony Xu , stefanha@gmail.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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If KVM provides VAPIC, don't set up kvmvapic. Signed-off-by: Anthony Xu --- hw/intc/apic_common.c | 5 ++++- include/sysemu/kvm.h | 1 + kvm-all.c | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index c3829e3..bf72107 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -317,8 +317,11 @@ static void apic_common_realize(DeviceState *dev, Erro= r **errp) info =3D APIC_COMMON_GET_CLASS(s); info->realize(dev, errp); =20 - /* Note: We need at least 1M to map the VAPIC option ROM */ + /* Note: We need at least 1M to map the VAPIC option ROM, + if it is KVM, enable kvmvapic only when KVM doesn't have + VAPIC capability */ if (!vapic && s->vapic_control & VAPIC_ENABLE_MASK && + (!kvm_enabled() || (kvm_enabled() && !kvm_has_vapic())) && !hax_enabled() && ram_size >=3D 1024 * 1024) { vapic =3D sysbus_create_simple("kvmvapic", -1, NULL); } diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 24281fc..43e0e4c 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -215,6 +215,7 @@ extern KVMState *kvm_state; =20 bool kvm_has_free_slot(MachineState *ms); int kvm_has_sync_mmu(void); +int kvm_has_vapic(void); int kvm_has_vcpu_events(void); int kvm_has_robust_singlestep(void); int kvm_has_debugregs(void); diff --git a/kvm-all.c b/kvm-all.c index 90b8573..c331c8c 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -2232,6 +2232,11 @@ int kvm_has_sync_mmu(void) return kvm_check_extension(kvm_state, KVM_CAP_SYNC_MMU); } =20 +int kvm_has_vapic(void) +{ + return !kvm_check_extension(kvm_state, KVM_CAP_VAPIC); +} + int kvm_has_vcpu_events(void) { return kvm_state->vcpu_events; --=20 1.8.3.1