All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bandan Das <bsd@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Cc: balducci@units.it, qemu-devel@nongnu.org,
	Laine Stump <laine@redhat.com>,
	David Alan Gilbert <dgilbert@redhat.com>,
	Cole Robinson <crobinso@redhat.com>
Subject: [Qemu-devel] [PATCH] kvm: Use KVM_GET_MSR_INDEX_LIST for MSR_IA32_ARCH_CAPABILITIES support
Date: Sun, 25 Nov 2018 23:17:28 -0500	[thread overview]
Message-ID: <jpg4lc4iiav.fsf_-_@linux.bootlegged.copy> (raw)
In-Reply-To: <20181121125008.GV4755@habkost.net> (Eduardo Habkost's message of "Wed, 21 Nov 2018 10:50:08 -0200")


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 <ehabkost@redhat.com>
Tested-by: balducci@units.it
Signed-off-by: Bandan Das <bsd@redhat.com>
---
 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;
 
 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 = true;
                     break;
+                case MSR_IA32_ARCH_CAPABILITIES:
+                    has_msr_arch_capabs = true;
+                    break;
                 }
             }
         }
@@ -2002,14 +2006,9 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
 #endif
 
     /* If host supports feature MSR, write down. */
-    if (kvm_feature_msrs) {
-        int i;
-        for (i = 0; i < kvm_feature_msrs->nmsrs; i++)
-            if (kvm_feature_msrs->indices[i] == MSR_IA32_ARCH_CAPABILITIES) {
-                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]);
     }
 
     /*
-- 
2.14.5

  reply	other threads:[~2018-11-26  4:17 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-18 16:40 [Qemu-devel] 3.1.0-rc{0,1} doesn't start balducci
2018-11-19 10:43 ` Dr. David Alan Gilbert
2018-11-19 12:54   ` balducci
2018-11-19 14:16     ` Dr. David Alan Gilbert
2018-11-19 18:35     ` Dr. David Alan Gilbert
2018-11-19 18:54       ` balducci
2018-11-19 18:56         ` Dr. David Alan Gilbert
2018-11-19 20:43       ` Cole Robinson
2018-11-19 21:55 ` Bandan Das
2018-11-19 23:00   ` Eduardo Habkost
2018-11-20 18:40     ` Paolo Bonzini
2018-11-20 18:48       ` Eduardo Habkost
2018-11-20 19:34         ` Paolo Bonzini
2018-11-21  4:05           ` Bandan Das
2018-11-21 13:59             ` Paolo Bonzini
2018-11-20  8:27   ` balducci
2018-11-21  4:28     ` Bandan Das
2018-11-21  7:48       ` balducci
2018-11-21 12:50       ` Eduardo Habkost
2018-11-26  4:17         ` Bandan Das [this message]
2018-11-26 16:34           ` [Qemu-devel] [PATCH] kvm: Use KVM_GET_MSR_INDEX_LIST for MSR_IA32_ARCH_CAPABILITIES support Eduardo Habkost
2018-12-11 10:54           ` Hu, Robert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jpg4lc4iiav.fsf_-_@linux.bootlegged.copy \
    --to=bsd@redhat.com \
    --cc=balducci@units.it \
    --cc=crobinso@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=laine@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.