All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Emulate MSR_EBC_FREQUENCY_ID
@ 2010-09-09 10:06 Jes.Sorensen
  2010-09-09 10:06 ` [PATCH 1/2] Define MSR_EBC_FREQUENCY_ID Jes.Sorensen
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jes.Sorensen @ 2010-09-09 10:06 UTC (permalink / raw)
  To: kvm; +Cc: avi

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Hi,

Discussed this with Juan and he spotted this place in
arch/x86/kernel/cpu/cpufreq/speedstep-lib.c which relies on the 'Core
Clock Frequency to System Bus Frequency Ratio', so leaving it set to 0
is not going to work. Reading the spec it also says that bits 31:24
are reserved on models 0-1, so it should be safe to set it for this
case.

Here is v2, which should hopefully do the right thing.

Cheers,
Jes


static unsigned int pentium4_get_frequency(void)
{
...
	rdmsr(0x2c, msr_lo, msr_hi);
...
	/* Multiplier. */
	mult = msr_lo >> 24;

	dprintk("P4 - FSB %u kHz; Multiplier %u; Speed %u kHz\n",
			fsb, mult, (fsb * mult));

	ret = (fsb * mult);
	return ret;

Jes Sorensen (2):
  Define MSR_EBC_FREQUENCY_ID
  Emulate MSR_EBC_FREQUENCY_ID

 arch/x86/include/asm/msr-index.h |    1 +
 arch/x86/kvm/x86.c               |   14 ++++++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)


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

* [PATCH 1/2] Define MSR_EBC_FREQUENCY_ID
  2010-09-09 10:06 [PATCH v2 0/2] Emulate MSR_EBC_FREQUENCY_ID Jes.Sorensen
@ 2010-09-09 10:06 ` Jes.Sorensen
  2010-09-09 10:06 ` [PATCH 2/2] Emulate MSR_EBC_FREQUENCY_ID Jes.Sorensen
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Jes.Sorensen @ 2010-09-09 10:06 UTC (permalink / raw)
  To: kvm; +Cc: avi

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 arch/x86/include/asm/msr-index.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index 986f779..83c4bb1 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -198,6 +198,7 @@
 #define MSR_IA32_TSC			0x00000010
 #define MSR_IA32_PLATFORM_ID		0x00000017
 #define MSR_IA32_EBL_CR_POWERON		0x0000002a
+#define MSR_EBC_FREQUENCY_ID		0x0000002c
 #define MSR_IA32_FEATURE_CONTROL        0x0000003a
 
 #define FEATURE_CONTROL_LOCKED				(1<<0)
-- 
1.7.1


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

* [PATCH 2/2] Emulate MSR_EBC_FREQUENCY_ID
  2010-09-09 10:06 [PATCH v2 0/2] Emulate MSR_EBC_FREQUENCY_ID Jes.Sorensen
  2010-09-09 10:06 ` [PATCH 1/2] Define MSR_EBC_FREQUENCY_ID Jes.Sorensen
@ 2010-09-09 10:06 ` Jes.Sorensen
  2010-09-09 10:45 ` [PATCH v2 0/2] " Juan Quintela
  2010-09-09 19:53 ` Marcelo Tosatti
  3 siblings, 0 replies; 5+ messages in thread
From: Jes.Sorensen @ 2010-09-09 10:06 UTC (permalink / raw)
  To: kvm; +Cc: avi

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Some operating systems store data about the host processor at the
time of installation, and when booted on a more uptodate cpu tries
to read MSR_EBC_FREQUENCY_ID. This has been found with XP.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 arch/x86/kvm/x86.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index f47db25..9d43477 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1651,6 +1651,20 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
 	case 0xcd: /* fsb frequency */
 		data = 3;
 		break;
+		/*
+		 * MSR_EBC_FREQUENCY_ID
+		 * Conservative value valid for even the basic CPU models.
+		 * Models 0,1: 000 in bits 23:21 indicating a bus speed of
+		 * 100MHz, model 2 000 in bits 18:16 indicating 100MHz,
+		 * and 266MHz for model 3, or 4. Set Core Clock
+		 * Frequency to System Bus Frequency Ratio to 1 (bits
+		 * 31:24) even though these are only valid for CPU
+		 * models > 2, however guests may end up dividing or
+		 * multiplying by zero otherwise.
+		 */
+	case MSR_EBC_FREQUENCY_ID:
+		data = 1 << 24;
+		break;
 	case MSR_IA32_APICBASE:
 		data = kvm_get_apic_base(vcpu);
 		break;
-- 
1.7.1


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

* Re: [PATCH v2 0/2] Emulate MSR_EBC_FREQUENCY_ID
  2010-09-09 10:06 [PATCH v2 0/2] Emulate MSR_EBC_FREQUENCY_ID Jes.Sorensen
  2010-09-09 10:06 ` [PATCH 1/2] Define MSR_EBC_FREQUENCY_ID Jes.Sorensen
  2010-09-09 10:06 ` [PATCH 2/2] Emulate MSR_EBC_FREQUENCY_ID Jes.Sorensen
@ 2010-09-09 10:45 ` Juan Quintela
  2010-09-09 19:53 ` Marcelo Tosatti
  3 siblings, 0 replies; 5+ messages in thread
From: Juan Quintela @ 2010-09-09 10:45 UTC (permalink / raw)
  To: Jes.Sorensen; +Cc: kvm, avi

Jes.Sorensen@redhat.com wrote:
> From: Jes Sorensen <Jes.Sorensen@redhat.com>
>
> Hi,
>
> Discussed this with Juan and he spotted this place in
> arch/x86/kernel/cpu/cpufreq/speedstep-lib.c which relies on the 'Core
> Clock Frequency to System Bus Frequency Ratio', so leaving it set to 0
> is not going to work. Reading the spec it also says that bits 31:24
> are reserved on models 0-1, so it should be safe to set it for this
> case.
>
> Here is v2, which should hopefully do the right thing.
>
> Cheers,
> Jes

Reviewed-by: Juan Quintela <quintela@redhat.com>

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

* Re: [PATCH v2 0/2] Emulate MSR_EBC_FREQUENCY_ID
  2010-09-09 10:06 [PATCH v2 0/2] Emulate MSR_EBC_FREQUENCY_ID Jes.Sorensen
                   ` (2 preceding siblings ...)
  2010-09-09 10:45 ` [PATCH v2 0/2] " Juan Quintela
@ 2010-09-09 19:53 ` Marcelo Tosatti
  3 siblings, 0 replies; 5+ messages in thread
From: Marcelo Tosatti @ 2010-09-09 19:53 UTC (permalink / raw)
  To: Jes.Sorensen; +Cc: kvm, avi

On Thu, Sep 09, 2010 at 12:06:44PM +0200, Jes.Sorensen@redhat.com wrote:
> From: Jes Sorensen <Jes.Sorensen@redhat.com>
> 
> Hi,
> 
> Discussed this with Juan and he spotted this place in
> arch/x86/kernel/cpu/cpufreq/speedstep-lib.c which relies on the 'Core
> Clock Frequency to System Bus Frequency Ratio', so leaving it set to 0
> is not going to work. Reading the spec it also says that bits 31:24
> are reserved on models 0-1, so it should be safe to set it for this
> case.
> 
> Here is v2, which should hopefully do the right thing.
> 
> Cheers,
> Jes

Applied, thanks.


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

end of thread, other threads:[~2010-09-09 19:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-09 10:06 [PATCH v2 0/2] Emulate MSR_EBC_FREQUENCY_ID Jes.Sorensen
2010-09-09 10:06 ` [PATCH 1/2] Define MSR_EBC_FREQUENCY_ID Jes.Sorensen
2010-09-09 10:06 ` [PATCH 2/2] Emulate MSR_EBC_FREQUENCY_ID Jes.Sorensen
2010-09-09 10:45 ` [PATCH v2 0/2] " Juan Quintela
2010-09-09 19:53 ` Marcelo Tosatti

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.