From: Avi Kivity <avi@redhat.com>
To: Alexander Graf <agraf@suse.de>
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
kvm@vger.kernel.org, Alexander Graf <agrag@suse.de>
Subject: Re: [PATCH 2/2] KVM: Fix bogus value returned for MSR_IA32_PERF_STATUS
Date: Wed, 01 Sep 2010 11:55:14 +0300 [thread overview]
Message-ID: <4C7E14F2.7040908@redhat.com> (raw)
In-Reply-To: <0DFA763B-EBFF-4913-8BD0-675C4247994B@suse.de>
On 09/01/2010 11:49 AM, Alexander Graf wrote:
> On 01.09.2010, at 09:34, Avi Kivity wrote:
>
>> The returned value is completely bogus, and sets reserved bits.
>> Return zero instead.
>>
>> Signed-off-by: Avi Kivity<avi@redhat.com>
>> ---
>> arch/x86/kvm/x86.c | 5 +----
>> 1 files changed, 1 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>> index 1cbf168..a2c03f1 100644
>> --- a/arch/x86/kvm/x86.c
>> +++ b/arch/x86/kvm/x86.c
>> @@ -1641,10 +1641,7 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
>> data = vcpu->arch.ia32_misc_enable_msr;
>> break;
>> case MSR_IA32_PERF_STATUS:
>> - /* TSC increment by tick */
>> - data = 1000ULL;
>> - /* CPU multiplier */
>> - data |= (((uint64_t)4ULL)<< 40);
>> + data = 0;
>> break;
>> case MSR_EFER:
>> data = vcpu->arch.efer;
>
> This is the respective code snippet from xnu:
>
> /*
> * Get the TSC increment. The TSC is incremented by this
> * on every bus tick. Calculate the TSC conversion factors
> * to and from nano-seconds.
> */
> if (cpuid_info()->cpuid_family == CPU_FAMILY_PENTIUM_M) {
> uint64_t prfsts;
>
> prfsts = rdmsr64(IA32_PERF_STS);
> tscGranularity = (uint32_t)bitfield(prfsts, 44, 40);
> N_by_2_bus_ratio = prfsts& bit(46);
>
> } else {
> panic("rtclock_init: unknown CPU family: 0x%X\n",
> cpuid_info()->cpuid_family);
> }
>
> if (N_by_2_bus_ratio)
> tscFCvtt2n = busFCvtt2n * 2 / (uint64_t)tscGranularity;
> else
> tscFCvtt2n = busFCvtt2n / (uint64_t)tscGranularity;
>
> tscFreq = ((1 * Giga)<< 32) / tscFCvtt2n;
> tscFCvtn2t = 0xFFFFFFFFFFFFFFFFULL / tscFCvtt2n;
>
>
> So by passing in 0 here, you effectively make that code divide something by 0 which results in a panic.
>
>
Right. Searching again I find that this is actually documented, (under
MSR_PERF_STATU
s instead of IA32_PERF_STATUS). I'll just drop this patch.
--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
next prev parent reply other threads:[~2010-09-01 8:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-01 7:34 [PATCH 0/2] Fix MSR_IA32_PERF_STATUS Avi Kivity
2010-09-01 7:34 ` [PATCH 1/2] KVM: Don't save/restore MSR_IA32_PERF_STATUS Avi Kivity
2010-09-01 7:34 ` [PATCH 2/2] KVM: Fix bogus value returned for MSR_IA32_PERF_STATUS Avi Kivity
2010-09-01 8:49 ` Alexander Graf
2010-09-01 8:55 ` Avi Kivity [this message]
2010-09-01 8:56 ` Alexander Graf
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=4C7E14F2.7040908@redhat.com \
--to=avi@redhat.com \
--cc=agraf@suse.de \
--cc=agrag@suse.de \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
/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.