From nobody Tue May 7 14:19:57 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.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=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543205935654465.96033346685965; Sun, 25 Nov 2018 20:18:55 -0800 (PST) Received: from localhost ([::1]:34100 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gR8M2-0005CA-S5 for importer@patchew.org; Sun, 25 Nov 2018 23:18:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58419) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gR8L4-0003zc-4W for qemu-devel@nongnu.org; Sun, 25 Nov 2018 23:17:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gR8L0-0000l5-2K for qemu-devel@nongnu.org; Sun, 25 Nov 2018 23:17:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48436) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gR8Kz-0000js-T6 for qemu-devel@nongnu.org; Sun, 25 Nov 2018 23:17:34 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 37005C0495BB; Mon, 26 Nov 2018 04:17:32 +0000 (UTC) Received: from gigantic.usersys.redhat.com (dhcp-17-169.bos.redhat.com [10.18.17.169]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4058387C85; Mon, 26 Nov 2018 04:17:29 +0000 (UTC) From: Bandan Das To: Eduardo Habkost , Paolo Bonzini , References: <7280.1542702495@dschgrazlin2.units.it> <20181121125008.GV4755@habkost.net> Date: Sun, 25 Nov 2018 23:17:28 -0500 In-Reply-To: <20181121125008.GV4755@habkost.net> (Eduardo Habkost's message of "Wed, 21 Nov 2018 10:50:08 -0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 26 Nov 2018 04:17:32 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] kvm: Use KVM_GET_MSR_INDEX_LIST for MSR_IA32_ARCH_CAPABILITIES support 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: balducci@units.it, Cole Robinson , qemu-devel@nongnu.org, Laine Stump , David Alan Gilbert Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When writing to guest's MSR_IA32_ARCH_CAPABILITIES, check whether it's supported in the guest using the KVM_GET_MSR_INDEX_LIST ioctl. Fixes: d86f963694df27f11b3681ffd225c9362de1b634 Suggested-by: Eduardo Habkost Tested-by: balducci@units.it Signed-off-by: Bandan Das --- target/i386/kvm.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index f524e7d929..3d6739a2b2 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -95,6 +95,7 @@ static bool has_msr_xss; static bool has_msr_spec_ctrl; static bool has_msr_virt_ssbd; static bool has_msr_smi_count; +static bool has_msr_arch_capabs; =20 static uint32_t has_architectural_pmu_version; static uint32_t num_architectural_pmu_gp_counters; @@ -1481,6 +1482,9 @@ static int kvm_get_supported_msrs(KVMState *s) case MSR_VIRT_SSBD: has_msr_virt_ssbd =3D true; break; + case MSR_IA32_ARCH_CAPABILITIES: + has_msr_arch_capabs =3D true; + break; } } } @@ -2002,14 +2006,9 @@ static int kvm_put_msrs(X86CPU *cpu, int level) #endif =20 /* If host supports feature MSR, write down. */ - if (kvm_feature_msrs) { - int i; - for (i =3D 0; i < kvm_feature_msrs->nmsrs; i++) - if (kvm_feature_msrs->indices[i] =3D=3D MSR_IA32_ARCH_CAPABILI= TIES) { - kvm_msr_entry_add(cpu, MSR_IA32_ARCH_CAPABILITIES, - env->features[FEAT_ARCH_CAPABILITIES]); - break; - } + if (has_msr_arch_capabs) { + kvm_msr_entry_add(cpu, MSR_IA32_ARCH_CAPABILITIES, + env->features[FEAT_ARCH_CAPABILITIES]); } =20 /* --=20 2.14.5