mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fix msr list
@ 2009-10-06 17:24 Glauber Costa
  2009-10-12 17:50 ` Marcelo Tosatti
  0 siblings, 1 reply; 3+ messages in thread
From: Glauber Costa @ 2009-10-06 17:24 UTC (permalink / raw)
  To: kvm; +Cc: linux-kernel, avi

For a while now, we are issuing a rdmsr instruction to find out which msrs in our
save list are really supported by the underlying machine. However, it fails to account
for kvm-specific msrs, such as the pvclock ones.

This patch moves then to the beginning of the list, and skip testing them.

Signed-off-by: Glauber Costa <glommer@redhat.com>
---
 arch/x86/kvm/x86.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 11a6f2f..747e566 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -503,16 +503,19 @@ static inline u32 bit(int bitno)
  * and KVM_SET_MSRS, and KVM_GET_MSR_INDEX_LIST.
  *
  * This list is modified at module load time to reflect the
- * capabilities of the host cpu.
+ * capabilities of the host cpu. This capabilities test skips MSRs that are
+ * kvm-specific. Those are put in the beginning of the list.
  */
+
+#define KVM_SAVE_MSRS_BEGIN	2
 static u32 msrs_to_save[] = {
+	MSR_KVM_SYSTEM_TIME, MSR_KVM_WALL_CLOCK,
 	MSR_IA32_SYSENTER_CS, MSR_IA32_SYSENTER_ESP, MSR_IA32_SYSENTER_EIP,
 	MSR_K6_STAR,
 #ifdef CONFIG_X86_64
 	MSR_CSTAR, MSR_KERNEL_GS_BASE, MSR_SYSCALL_MASK, MSR_LSTAR,
 #endif
-	MSR_IA32_TSC, MSR_KVM_SYSTEM_TIME, MSR_KVM_WALL_CLOCK,
-	MSR_IA32_PERF_STATUS, MSR_IA32_CR_PAT, MSR_VM_HSAVE_PA
+	MSR_IA32_TSC, MSR_IA32_PERF_STATUS, MSR_IA32_CR_PAT, MSR_VM_HSAVE_PA
 };
 
 static unsigned num_msrs_to_save;
@@ -2446,7 +2449,8 @@ static void kvm_init_msr_list(void)
 	u32 dummy[2];
 	unsigned i, j;
 
-	for (i = j = 0; i < ARRAY_SIZE(msrs_to_save); i++) {
+	/* skip the first msrs in the list. KVM-specific */
+	for (i = j = KVM_SAVE_MSRS_BEGIN; i < ARRAY_SIZE(msrs_to_save); i++) {
 		if (rdmsr_safe(msrs_to_save[i], &dummy[0], &dummy[1]) < 0)
 			continue;
 		if (j < i)
-- 
1.6.2.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fix msr list
  2009-10-06 17:24 [PATCH] fix msr list Glauber Costa
@ 2009-10-12 17:50 ` Marcelo Tosatti
  2009-10-13 12:30   ` Glauber Costa
  0 siblings, 1 reply; 3+ messages in thread
From: Marcelo Tosatti @ 2009-10-12 17:50 UTC (permalink / raw)
  To: Glauber Costa; +Cc: kvm, linux-kernel, avi

On Tue, Oct 06, 2009 at 01:24:50PM -0400, Glauber Costa wrote:
> For a while now, we are issuing a rdmsr instruction to find out which msrs in our
> save list are really supported by the underlying machine. However, it fails to account
> for kvm-specific msrs, such as the pvclock ones.
> 
> This patch moves then to the beginning of the list, and skip testing them.
> 
> Signed-off-by: Glauber Costa <glommer@redhat.com>

Applied, thanks.

But this alone won't fix migration to include the two pvclock MSRs
right?


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fix msr list
  2009-10-12 17:50 ` Marcelo Tosatti
@ 2009-10-13 12:30   ` Glauber Costa
  0 siblings, 0 replies; 3+ messages in thread
From: Glauber Costa @ 2009-10-13 12:30 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: kvm, linux-kernel, avi

On Mon, Oct 12, 2009 at 02:50:27PM -0300, Marcelo Tosatti wrote:
> On Tue, Oct 06, 2009 at 01:24:50PM -0400, Glauber Costa wrote:
> > For a while now, we are issuing a rdmsr instruction to find out which msrs in our
> > save list are really supported by the underlying machine. However, it fails to account
> > for kvm-specific msrs, such as the pvclock ones.
> > 
> > This patch moves then to the beginning of the list, and skip testing them.
> > 
> > Signed-off-by: Glauber Costa <glommer@redhat.com>
> 
> Applied, thanks.
> 
> But this alone won't fix migration to include the two pvclock MSRs
> right?
Yes, exactly. It will just make userspace see the correct list, but we'd
still have to take action based on it.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-10-13 12:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-06 17:24 [PATCH] fix msr list Glauber Costa
2009-10-12 17:50 ` Marcelo Tosatti
2009-10-13 12:30   ` Glauber Costa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome