From nobody Tue Nov 4 19:03:27 2025 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530710045208745.8463933760316; Wed, 4 Jul 2018 06:14:05 -0700 (PDT) Received: from localhost ([::1]:47144 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fahbg-0004Og-Ed for importer@patchew.org; Wed, 04 Jul 2018 09:14:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fahak-0003xs-Kg for qemu-devel@nongnu.org; Wed, 04 Jul 2018 09:13:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fahah-0004ox-EW for qemu-devel@nongnu.org; Wed, 04 Jul 2018 09:13:06 -0400 Received: from mga03.intel.com ([134.134.136.65]:39291) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fahah-0004oN-4D for qemu-devel@nongnu.org; Wed, 04 Jul 2018 09:13:03 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jul 2018 06:13:01 -0700 Received: from dst.sh.intel.com ([10.239.48.156]) by orsmga002.jf.intel.com with ESMTP; 04 Jul 2018 06:12:59 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,306,1526367600"; d="scan'208";a="72218962" From: Jingqi Liu To: pbonzini@redhat.com Date: Wed, 4 Jul 2018 21:12:22 +0800 Message-Id: <1530709942-87947-1-git-send-email-jingqi.liu@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: 134.134.136.65 Subject: [Qemu-devel] [PATCH] kvm: x86: Add support for -machine split-lock-ac 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: ehabkost@redhat.com, Jingqi Liu , mtosatti@redhat.com, qemu-devel@nongnu.org, wei.w.wang@intel.com, rth@twiddle.net 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" Add the option split-lock-ac to control whether the #AC exception is generated for split locked accesses, which is introduced for the machine, there is an example to enable it: -machine split-lock-ac=3Don It is disabled on default. When bit 29 of the MSR (33H) is set, the processor causes an #AC exception to be issued instead of suppressing LOCK on bus(during split lock access). Signed-off-by: Jingqi Liu --- accel/kvm/kvm-all.c | 10 ++++++++++ hw/core/machine.c | 19 +++++++++++++++++++ include/hw/boards.h | 1 + linux-headers/linux/kvm.h | 1 + qemu-options.hx | 3 +++ 5 files changed, 34 insertions(+) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index eb7db92..e960a4d 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1699,6 +1699,16 @@ static int kvm_init(MachineState *ms) =20 s->sync_mmu =3D !!kvm_vm_check_extension(kvm_state, KVM_CAP_SYNC_MMU); =20 + if (ms->split_lock_ac && + kvm_check_extension(s, KVM_CAP_X86_SPLIT_LOCK_AC)) { + ret =3D kvm_vm_enable_cap(s, KVM_CAP_X86_SPLIT_LOCK_AC, 0); + if (ret) { + fprintf(stderr, "Could not enable the feature that #AC excepti= on" + "will be generated for split lock accesses!\n"); + goto err; + } + } + return 0; =20 err: diff --git a/hw/core/machine.c b/hw/core/machine.c index 617e5f8..e054119 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -350,6 +350,22 @@ static void machine_set_memory_encryption(Object *obj,= const char *value, ms->memory_encryption =3D g_strdup(value); } =20 +static void machine_set_split_lock_ac(Object *obj, bool value, + Error **errp) +{ + MachineState *ms =3D MACHINE(obj); + + ms->split_lock_ac =3D value; +} + +static bool machine_get_split_lock_ac(Object *obj, Error **errp) +{ + MachineState *ms =3D MACHINE(obj); + + return ms->split_lock_ac; +} + + void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *= type) { strList *item =3D g_new0(strList, 1); @@ -634,6 +650,9 @@ static void machine_class_init(ObjectClass *oc, void *d= ata) &error_abort); object_class_property_set_description(oc, "memory-encryption", "Set memory encyption object to use", &error_abort); + object_class_property_add_bool(oc, "split-lock-ac", + machine_get_split_lock_ac, machine_set_split_lock_ac, + &error_abort); } =20 static void machine_class_base_init(ObjectClass *oc, void *data) diff --git a/include/hw/boards.h b/include/hw/boards.h index 79069dd..9c1e2c0 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -256,6 +256,7 @@ struct MachineState { bool suppress_vmdesc; bool enforce_config_section; bool enable_graphics; + bool split_lock_ac; char *memory_encryption; DeviceMemoryState *device_memory; =20 diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index 98f389a..4bfa879 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -949,6 +949,7 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_GET_MSR_FEATURES 153 #define KVM_CAP_HYPERV_EVENTFD 154 #define KVM_CAP_HYPERV_TLBFLUSH 155 +#define KVM_CAP_X86_SPLIT_LOCK_AC 156 =20 #ifdef KVM_CAP_IRQ_ROUTING =20 diff --git a/qemu-options.hx b/qemu-options.hx index 81b1e99..935cefe 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -44,6 +44,7 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ " nvdimm=3Don|off controls NVDIMM support (default=3Dof= f)\n" " enforce-config-section=3Don|off enforce configuration= section migration (default=3Doff)\n" " s390-squash-mcss=3Don|off (deprecated) controls suppo= rt for squashing into default css (default=3Doff)\n" + " split-lock-ac=3Don|off controls support #AC exception= for split locked accesses (default=3Doff)\n" " memory-encryption=3D@var{} memory encryption object t= o use (default=3Dnone)\n", QEMU_ARCH_ALL) STEXI @@ -113,6 +114,8 @@ NOTE: this parameter is deprecated. Please use @option{= -global} @option{migration.send-configuration}=3D@var{on|off} instead. @item memory-encryption=3D@var{} Memory encryption object to use. The default is none. +@item split-lock-ac=3Don|off +Enables or disables #AC exception for split locked accesses. @end table ETEXI =20 --=20 1.8.3.1