* Re: [PATCH] x86: fix rdmsr MSR_PLATFORM_INFO unsafe warning in kvm guest
2016-06-22 1:28 [PATCH] x86: fix rdmsr MSR_PLATFORM_INFO unsafe warning in kvm guest Wanpeng Li
@ 2016-06-22 17:43 ` Paolo Bonzini
2016-06-23 7:09 ` Thomas Gleixner
` (2 subsequent siblings)
3 siblings, 0 replies; 11+ messages in thread
From: Paolo Bonzini @ 2016-06-22 17:43 UTC (permalink / raw)
To: Wanpeng Li, linux-kernel, kvm, Linux PM list, linux-acpi, lkp,
x86
Cc: Wanpeng Li, Len Brown, Rafael J. Wysocki, Zhang Rui, Chen Yu,
Radim Krčmář, jacob.jun.pan, Thomas Gleixner,
Ingo Molnar, H. Peter Anvin
On 22/06/2016 03:28, Wanpeng Li wrote:
>
> get_ratio:
> - rdmsr(MSR_PLATFORM_INFO, lo, hi);
> - ratio = (lo >> 8) & 0xff;
> + if (!rdmsr_safe(MSR_PLATFORM_INFO, &lo, &hi))
> + ratio = (lo >> 8) & 0xff;
This looks good, thanks.
Paolo
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] x86: fix rdmsr MSR_PLATFORM_INFO unsafe warning in kvm guest
2016-06-22 1:28 [PATCH] x86: fix rdmsr MSR_PLATFORM_INFO unsafe warning in kvm guest Wanpeng Li
2016-06-22 17:43 ` Paolo Bonzini
@ 2016-06-23 7:09 ` Thomas Gleixner
2016-06-23 7:28 ` Wanpeng Li
2016-06-23 7:37 ` [LKP] " Yu Chen
2016-07-11 2:38 ` Wanpeng Li
2016-07-11 7:40 ` [tip:x86/timers] x86/tsc_msr: Fix rdmsr(MSR_PLATFORM_INFO) unsafe warning in KVM guest tip-bot for Wanpeng Li
3 siblings, 2 replies; 11+ messages in thread
From: Thomas Gleixner @ 2016-06-23 7:09 UTC (permalink / raw)
To: Wanpeng Li
Cc: linux-kernel, kvm, Linux PM list, linux-acpi, lkp, x86,
Wanpeng Li, Len Brown, Rafael J. Wysocki, Zhang Rui, Chen Yu,
Paolo Bonzini, Radim Krčmář, jacob.jun.pan,
Ingo Molnar, H. Peter Anvin
On Wed, 22 Jun 2016, Wanpeng Li wrote:
> After commit (fc141535ad8 : "x86 tsc_msr: Extend to include Intel Core
Where did you find that commit? It's neither in Linus tree nor in tip.
Thanks,
tglx
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] x86: fix rdmsr MSR_PLATFORM_INFO unsafe warning in kvm guest
2016-06-23 7:09 ` Thomas Gleixner
@ 2016-06-23 7:28 ` Wanpeng Li
2016-06-23 7:34 ` Wanpeng Li
2016-06-23 7:37 ` [LKP] " Yu Chen
1 sibling, 1 reply; 11+ messages in thread
From: Wanpeng Li @ 2016-06-23 7:28 UTC (permalink / raw)
To: Thomas Gleixner
Cc: linux-kernel@vger.kernel.org, kvm, Linux PM list, linux-acpi, lkp,
x86, Wanpeng Li, Len Brown, Rafael J. Wysocki, Zhang Rui, Chen Yu,
Paolo Bonzini, Radim Krčmář, jacob.jun.pan,
Ingo Molnar, H. Peter Anvin
2016-06-23 15:09 GMT+08:00 Thomas Gleixner <tglx@linutronix.de>:
> On Wed, 22 Jun 2016, Wanpeng Li wrote:
>> After commit (fc141535ad8 : "x86 tsc_msr: Extend to include Intel Core
>
> Where did you find that commit? It's neither in Linus tree nor in tip.
It is reported by lkp. https://lkml.org/lkml/2016/6/20/110 The patch
is against x86 branch on Len Brown's tree. And try to fix this commit:
https://git.kernel.org/cgit/linux/kernel/git/lenb/linux.git/commit/?h=x86&id=fc141535ad8a67fd58623289c04e35465e2a07f2
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] x86: fix rdmsr MSR_PLATFORM_INFO unsafe warning in kvm guest
2016-06-23 7:28 ` Wanpeng Li
@ 2016-06-23 7:34 ` Wanpeng Li
0 siblings, 0 replies; 11+ messages in thread
From: Wanpeng Li @ 2016-06-23 7:34 UTC (permalink / raw)
To: Thomas Gleixner
Cc: linux-kernel@vger.kernel.org, kvm, Linux PM list, linux-acpi, lkp,
x86, Wanpeng Li, Len Brown, Rafael J. Wysocki, Zhang Rui, Chen Yu,
Paolo Bonzini, Radim Krčmář, jacob.jun.pan,
Ingo Molnar, H. Peter Anvin
Hi Jacob,
2016-06-23 15:28 GMT+08:00 Wanpeng Li <kernellwp@gmail.com>:
> 2016-06-23 15:09 GMT+08:00 Thomas Gleixner <tglx@linutronix.de>:
>> On Wed, 22 Jun 2016, Wanpeng Li wrote:
>>> After commit (fc141535ad8 : "x86 tsc_msr: Extend to include Intel Core
>>
>> Where did you find that commit? It's neither in Linus tree nor in tip.
>
> It is reported by lkp. https://lkml.org/lkml/2016/6/20/110 The patch
> is against x86 branch on Len Brown's tree. And try to fix this commit:
> https://git.kernel.org/cgit/linux/kernel/git/lenb/linux.git/commit/?h=x86&id=fc141535ad8a67fd58623289c04e35465e2a07f2
I prefer this patch can be applied separately instead of fold into the
bad commit since it shows the issue when access MSR_PLATFORM_INFO in
kvm guest and other guys who want to access MSR_PLATFORM_INFO later
can find the changelog and make better decisions.
Regards,
Wanpeng Li
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LKP] [PATCH] x86: fix rdmsr MSR_PLATFORM_INFO unsafe warning in kvm guest
2016-06-23 7:09 ` Thomas Gleixner
2016-06-23 7:28 ` Wanpeng Li
@ 2016-06-23 7:37 ` Yu Chen
2016-06-23 7:41 ` Wanpeng Li
1 sibling, 1 reply; 11+ messages in thread
From: Yu Chen @ 2016-06-23 7:37 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Wanpeng Li, Radim Krčmář, kvm, Linux PM list,
the arch/x86 maintainers, Rafael J. Wysocki,
Linux Kernel Mailing List, linux-acpi, Ingo Molnar, Jacob Pan,
H. Peter Anvin, Paolo Bonzini, Zhang Rui, lkp, Wanpeng Li,
Chen Yu
On Thu, Jun 23, 2016 at 3:09 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
> On Wed, 22 Jun 2016, Wanpeng Li wrote:
>> After commit (fc141535ad8 : "x86 tsc_msr: Extend to include Intel Core
>
> Where did you find that commit? It's neither in Linus tree nor in tip.
>
It is in Len's tree, we are planing to resend the patchset with Wanpeng's fix
merged with a credit to him in commit msg, thanks for Wanpeng's effort.
thanks all.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LKP] [PATCH] x86: fix rdmsr MSR_PLATFORM_INFO unsafe warning in kvm guest
2016-06-23 7:37 ` [LKP] " Yu Chen
@ 2016-06-23 7:41 ` Wanpeng Li
2016-06-23 8:00 ` Wanpeng Li
0 siblings, 1 reply; 11+ messages in thread
From: Wanpeng Li @ 2016-06-23 7:41 UTC (permalink / raw)
To: Yu Chen
Cc: Thomas Gleixner, Radim Krčmář, kvm, Linux PM list,
the arch/x86 maintainers, Rafael J. Wysocki,
Linux Kernel Mailing List, linux-acpi, Ingo Molnar, Jacob Pan,
H. Peter Anvin, Paolo Bonzini, Zhang Rui, lkp, Wanpeng Li
Hi Yu,
2016-06-23 15:37 GMT+08:00 Yu Chen <yu.chen.surf@gmail.com>:
> On Thu, Jun 23, 2016 at 3:09 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
>> On Wed, 22 Jun 2016, Wanpeng Li wrote:
>>> After commit (fc141535ad8 : "x86 tsc_msr: Extend to include Intel Core
>>
>> Where did you find that commit? It's neither in Linus tree nor in tip.
>>
> It is in Len's tree, we are planing to resend the patchset with Wanpeng's fix
> merged with a credit to him in commit msg, thanks for Wanpeng's effort.
> thanks all.
I prefer this patch can be applied separately instead of fold into the
bad commit since it shows the issue when access MSR_PLATFORM_INFO in
kvm guest and other guys who want to access MSR_PLATFORM_INFO later
can find the changelog and make better decisions.
Regards,
Wanpeng Li
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LKP] [PATCH] x86: fix rdmsr MSR_PLATFORM_INFO unsafe warning in kvm guest
2016-06-23 7:41 ` Wanpeng Li
@ 2016-06-23 8:00 ` Wanpeng Li
0 siblings, 0 replies; 11+ messages in thread
From: Wanpeng Li @ 2016-06-23 8:00 UTC (permalink / raw)
To: Yu Chen
Cc: Thomas Gleixner, Radim Krčmář, kvm, Linux PM list,
the arch/x86 maintainers, Rafael J. Wysocki,
Linux Kernel Mailing List, linux-acpi, Ingo Molnar, Jacob Pan,
H. Peter Anvin, Paolo Bonzini, Zhang Rui, lkp, Wanpeng Li
2016-06-23 15:41 GMT+08:00 Wanpeng Li <kernellwp@gmail.com>:
> Hi Yu,
> 2016-06-23 15:37 GMT+08:00 Yu Chen <yu.chen.surf@gmail.com>:
>> On Thu, Jun 23, 2016 at 3:09 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
>>> On Wed, 22 Jun 2016, Wanpeng Li wrote:
>>>> After commit (fc141535ad8 : "x86 tsc_msr: Extend to include Intel Core
>>>
>>> Where did you find that commit? It's neither in Linus tree nor in tip.
>>>
>> It is in Len's tree, we are planing to resend the patchset with Wanpeng's fix
>> merged with a credit to him in commit msg, thanks for Wanpeng's effort.
>> thanks all.
>
> I prefer this patch can be applied separately instead of fold into the
> bad commit since it shows the issue when access MSR_PLATFORM_INFO in
> kvm guest and other guys who want to access MSR_PLATFORM_INFO later
> can find the changelog and make better decisions.
Thomas, does it make sense to keep separate?
Regards,
Wanpeng Li
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] x86: fix rdmsr MSR_PLATFORM_INFO unsafe warning in kvm guest
2016-06-22 1:28 [PATCH] x86: fix rdmsr MSR_PLATFORM_INFO unsafe warning in kvm guest Wanpeng Li
2016-06-22 17:43 ` Paolo Bonzini
2016-06-23 7:09 ` Thomas Gleixner
@ 2016-07-11 2:38 ` Wanpeng Li
2016-07-11 7:38 ` Ingo Molnar
2016-07-11 7:40 ` [tip:x86/timers] x86/tsc_msr: Fix rdmsr(MSR_PLATFORM_INFO) unsafe warning in KVM guest tip-bot for Wanpeng Li
3 siblings, 1 reply; 11+ messages in thread
From: Wanpeng Li @ 2016-07-11 2:38 UTC (permalink / raw)
To: linux-kernel@vger.kernel.org, kvm, Linux PM list, linux-acpi, lkp,
the arch/x86 maintainers
Cc: Wanpeng Li, Len Brown, Rafael J. Wysocki, Zhang Rui, Chen Yu,
Paolo Bonzini, Radim Krčmář, Jacob Pan,
Thomas Gleixner, Ingo Molnar, H. Peter Anvin
Hi Ingo, Thomas,
2016-06-22 9:28 GMT+08:00 Wanpeng Li <kernellwp@gmail.com>:
> From: Wanpeng Li <wanpeng.li@hotmail.com>
>
> ------------[ cut here ]------------
> WARNING: CPU: 0 PID: 0 at arch/x86/mm/extable.c:50 ex_handler_rdmsr_unsafe+0x6a/0x70
> unchecked MSR access error: RDMSR from 0xce
> Modules linked in:
> CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.7.0-rc3+ #1
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
> 0000000000000000 ffffffff81c03ce0 ffffffff813b3eae ffffffff81c03d30
> 0000000000000000 ffffffff81c03d20 ffffffff81067181 0000003200000001
> ffffffff81c03df8 ffffffff8179676c 0000000000000000 ffffffff81fcd2c0
> Call Trace:
> dump_stack+0x67/0x99
> __warn+0xd1/0xf0
> warn_slowpath_fmt+0x4f/0x60
> ex_handler_rdmsr_unsafe+0x6a/0x70
> fixup_exception+0x39/0x50
> do_general_protection+0x93/0x1b0
> general_protection+0x22/0x30
> ? cpu_khz_from_msr+0xd8/0x1c0
> native_calibrate_cpu+0x30/0x5b0
> tsc_init+0x2b/0x297
> x86_late_time_init+0xf/0x11
> start_kernel+0x398/0x451
> ? set_init_arg+0x55/0x55
> x86_64_start_reservations+0x2f/0x31
> x86_64_start_kernel+0xea/0xed
>
> After commit (fc141535ad8 : "x86 tsc_msr: Extend to include Intel Core
> Architecture"), rdmsr MSR_PLATFORM_INFO is used to get maximum non-turbo
I just saw commit (fc273eeef314c : "x86 tsc_msr: Extend to include
Intel Core Architecture") was merged in tip tree, then this patch is
needed to fix that commit. The bug is reported by LKP several weeks
ago, and kvm maintainer Paolo has already replied "This looks good" to
this patch.
Regards,
Wanpeng Li
> ratio for recent Intel Core Architecture which results in kvm guest rdmsr
> unsafe warning.
>
> As Radim pointed out before:
>
> | MSR_PLATFORM_INFO: Intel changes it from family to family and there is
> | no obvious overlap or default. If we picked 0 (any other fixed value),
> | then the guest would have to know that 0 doesn't mean that
> | MSR_PLATFORM_INFO returned 0, but that KVM doesn't emulate this MSR and
> | the value cannot be used. This is very similar to handling a #GP in the
> | guest, but also has a disadvantage, because KVM cannot say that
> | MSR_PLATFORM_INFO is 0. Simple emulation is not possible.
>
> This patch fix it by using rdmsr_safe to read MSR_PLATFORM_INFO in kvm
> guest in order that #GP can be fixed up, then tsc will be calibrated by
> PIT, HPET etc.
>
> Reported-by: kernel test robot <xiaolong.ye@intel.com>
> Cc: Len Brown <len.brown@intel.com>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Zhang Rui <rui.zhang@intel.com>
> Cc: Chen Yu <yu.c.chen@intel.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Cc: jacob.jun.pan@intel.com
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
> ---
> arch/x86/kernel/tsc_msr.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kernel/tsc_msr.c b/arch/x86/kernel/tsc_msr.c
> index e0c2b30..e6e465e 100644
> --- a/arch/x86/kernel/tsc_msr.c
> +++ b/arch/x86/kernel/tsc_msr.c
> @@ -70,7 +70,7 @@ static int match_cpu(u8 family, u8 model)
> */
> unsigned long cpu_khz_from_msr(void)
> {
> - u32 lo, hi, ratio, freq_id, freq;
> + u32 lo, hi, freq_id, freq, ratio = 0;
> unsigned long res;
> int cpu_index;
>
> @@ -123,8 +123,8 @@ unsigned long cpu_khz_from_msr(void)
> }
>
> get_ratio:
> - rdmsr(MSR_PLATFORM_INFO, lo, hi);
> - ratio = (lo >> 8) & 0xff;
> + if (!rdmsr_safe(MSR_PLATFORM_INFO, &lo, &hi))
> + ratio = (lo >> 8) & 0xff;
>
> done:
> /* TSC frequency = maximum resolved freq * maximum resolved bus ratio */
> --
> 1.9.1
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] x86: fix rdmsr MSR_PLATFORM_INFO unsafe warning in kvm guest
2016-07-11 2:38 ` Wanpeng Li
@ 2016-07-11 7:38 ` Ingo Molnar
0 siblings, 0 replies; 11+ messages in thread
From: Ingo Molnar @ 2016-07-11 7:38 UTC (permalink / raw)
To: Wanpeng Li
Cc: linux-kernel@vger.kernel.org, kvm, Linux PM list, linux-acpi, lkp,
the arch/x86 maintainers, Wanpeng Li, Len Brown,
Rafael J. Wysocki, Zhang Rui, Chen Yu, Paolo Bonzini,
Radim Krčmář, Jacob Pan, Thomas Gleixner,
Ingo Molnar, H. Peter Anvin
* Wanpeng Li <kernellwp@gmail.com> wrote:
> Hi Ingo, Thomas,
> 2016-06-22 9:28 GMT+08:00 Wanpeng Li <kernellwp@gmail.com>:
> > From: Wanpeng Li <wanpeng.li@hotmail.com>
> >
> > ------------[ cut here ]------------
> > WARNING: CPU: 0 PID: 0 at arch/x86/mm/extable.c:50 ex_handler_rdmsr_unsafe+0x6a/0x70
> > unchecked MSR access error: RDMSR from 0xce
> > Modules linked in:
> > CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.7.0-rc3+ #1
> > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
> > 0000000000000000 ffffffff81c03ce0 ffffffff813b3eae ffffffff81c03d30
> > 0000000000000000 ffffffff81c03d20 ffffffff81067181 0000003200000001
> > ffffffff81c03df8 ffffffff8179676c 0000000000000000 ffffffff81fcd2c0
> > Call Trace:
> > dump_stack+0x67/0x99
> > __warn+0xd1/0xf0
> > warn_slowpath_fmt+0x4f/0x60
> > ex_handler_rdmsr_unsafe+0x6a/0x70
> > fixup_exception+0x39/0x50
> > do_general_protection+0x93/0x1b0
> > general_protection+0x22/0x30
> > ? cpu_khz_from_msr+0xd8/0x1c0
> > native_calibrate_cpu+0x30/0x5b0
> > tsc_init+0x2b/0x297
> > x86_late_time_init+0xf/0x11
> > start_kernel+0x398/0x451
> > ? set_init_arg+0x55/0x55
> > x86_64_start_reservations+0x2f/0x31
> > x86_64_start_kernel+0xea/0xed
> >
> > After commit (fc141535ad8 : "x86 tsc_msr: Extend to include Intel Core
> > Architecture"), rdmsr MSR_PLATFORM_INFO is used to get maximum non-turbo
>
> I just saw commit (fc273eeef314c : "x86 tsc_msr: Extend to include
> Intel Core Architecture") was merged in tip tree, then this patch is
> needed to fix that commit. The bug is reported by LKP several weeks
> ago, and kvm maintainer Paolo has already replied "This looks good" to
> this patch.
Applied, thanks!
Ingo
^ permalink raw reply [flat|nested] 11+ messages in thread
* [tip:x86/timers] x86/tsc_msr: Fix rdmsr(MSR_PLATFORM_INFO) unsafe warning in KVM guest
2016-06-22 1:28 [PATCH] x86: fix rdmsr MSR_PLATFORM_INFO unsafe warning in kvm guest Wanpeng Li
` (2 preceding siblings ...)
2016-07-11 2:38 ` Wanpeng Li
@ 2016-07-11 7:40 ` tip-bot for Wanpeng Li
3 siblings, 0 replies; 11+ messages in thread
From: tip-bot for Wanpeng Li @ 2016-07-11 7:40 UTC (permalink / raw)
To: linux-tip-commits
Cc: len.brown, linux-pm, y.c.chen, tglx, rui.zhang, hpa, mingo,
xiaolong.ye, rkrcmar, pbonzini, rjw, peterz, wanpeng.li, torvalds,
linux-kernel
Commit-ID: 37c528ee1af7f24eb31f4195b8b7d4f23e6c716d
Gitweb: http://git.kernel.org/tip/37c528ee1af7f24eb31f4195b8b7d4f23e6c716d
Author: Wanpeng Li <wanpeng.li@hotmail.com>
AuthorDate: Wed, 22 Jun 2016 09:28:28 +0800
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 11 Jul 2016 09:20:36 +0200
x86/tsc_msr: Fix rdmsr(MSR_PLATFORM_INFO) unsafe warning in KVM guest
After this commit:
fc273eeef314 ("x86/tsc_msr: Extend to include Intel Core Architecture")
The following unsafe MSR reading warning triggers:
WARNING: CPU: 0 PID: 0 at arch/x86/mm/extable.c:50 ex_handler_rdmsr_unsafe+0x6a/0x70
unchecked MSR access error: RDMSR from 0xce
Call Trace:
dump_stack+0x67/0x99
__warn+0xd1/0xf0
warn_slowpath_fmt+0x4f/0x60
ex_handler_rdmsr_unsafe+0x6a/0x70
fixup_exception+0x39/0x50
do_general_protection+0x93/0x1b0
general_protection+0x22/0x30
? cpu_khz_from_msr+0xd8/0x1c0
native_calibrate_cpu+0x30/0x5b0
tsc_init+0x2b/0x297
x86_late_time_init+0xf/0x11
start_kernel+0x398/0x451
? set_init_arg+0x55/0x55
x86_64_start_reservations+0x2f/0x31
x86_64_start_kernel+0xea/0xed
As Radim pointed out before:
| MSR_PLATFORM_INFO: Intel changes it from family to family and there is
| no obvious overlap or default. If we picked 0 (any other fixed value),
| then the guest would have to know that 0 doesn't mean that
| MSR_PLATFORM_INFO returned 0, but that KVM doesn't emulate this MSR and
| the value cannot be used. This is very similar to handling a #GP in the
| guest, but also has a disadvantage, because KVM cannot say that
| MSR_PLATFORM_INFO is 0. Simple emulation is not possible.
Fix it by using rdmsr_safe(MSR_PLATFORM_INFO) in KVM guest to
not trigger a #GP, then tsc will be calibrated by a fallback
method: PIT, HPET etc.
Reported-by: kernel test robot <xiaolong.ye@intel.com>
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: Chen Yu <y.c.chen@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Linux PM list <linux-pm@vger.kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: jacob.jun.pan@intel.com
Cc: kvm@vger.kernel.org
Cc: linux-acpi@vger.kernel.org
Cc: lkp@01.org
Link: http://lkml.kernel.org/r/1466558908-3524-1-git-send-email-wanpeng.li@hotmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/kernel/tsc_msr.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/tsc_msr.c b/arch/x86/kernel/tsc_msr.c
index e0c2b30..e6e465e 100644
--- a/arch/x86/kernel/tsc_msr.c
+++ b/arch/x86/kernel/tsc_msr.c
@@ -70,7 +70,7 @@ static int match_cpu(u8 family, u8 model)
*/
unsigned long cpu_khz_from_msr(void)
{
- u32 lo, hi, ratio, freq_id, freq;
+ u32 lo, hi, freq_id, freq, ratio = 0;
unsigned long res;
int cpu_index;
@@ -123,8 +123,8 @@ unsigned long cpu_khz_from_msr(void)
}
get_ratio:
- rdmsr(MSR_PLATFORM_INFO, lo, hi);
- ratio = (lo >> 8) & 0xff;
+ if (!rdmsr_safe(MSR_PLATFORM_INFO, &lo, &hi))
+ ratio = (lo >> 8) & 0xff;
done:
/* TSC frequency = maximum resolved freq * maximum resolved bus ratio */
^ permalink raw reply related [flat|nested] 11+ messages in thread