* [PATCH] X86: don't print a warning when MTRR are blank and running in KVM
@ 2008-02-21 14:50 Joerg Roedel
2008-02-21 19:54 ` Yinghai Lu
2008-02-21 20:37 ` Ingo Molnar
0 siblings, 2 replies; 11+ messages in thread
From: Joerg Roedel @ 2008-02-21 14:50 UTC (permalink / raw)
To: tglx, mingo; +Cc: linux-kernel, Joerg Roedel
Inside a KVM virtual machine the MTRRs are usually blank. This confuses Linux
and causes a warning message at boot. This patch removes that warning message
when running Linux as a KVM guest.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kernel/cpu/mtrr/main.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
index b6e136f..47e624c 100644
--- a/arch/x86/kernel/cpu/mtrr/main.c
+++ b/arch/x86/kernel/cpu/mtrr/main.c
@@ -43,6 +43,7 @@
#include <asm/uaccess.h>
#include <asm/processor.h>
#include <asm/msr.h>
+#include <asm/kvm_para.h>
#include "mtrr.h"
u32 num_var_ranges = 0;
@@ -687,12 +688,14 @@ int __init mtrr_trim_uncached_memory(unsigned long end_pfn)
}
/* kvm/qemu doesn't have mtrr set right, don't trim them all */
- if (!highest_pfn) {
+ if (!highest_pfn && !kvm_para_available()) {
printk(KERN_WARNING "WARNING: strange, CPU MTRRs all blank?\n");
WARN_ON(1);
- return 0;
}
+ if (!highest_pfn)
+ return 0;
+
if (highest_pfn < end_pfn) {
printk(KERN_WARNING "WARNING: BIOS bug: CPU MTRRs don't cover"
" all of memory, losing %luMB of RAM.\n",
--
1.5.3.7
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH] X86: don't print a warning when MTRR are blank and running in KVM
2008-02-21 14:50 [PATCH] X86: don't print a warning when MTRR are blank and running in KVM Joerg Roedel
@ 2008-02-21 19:54 ` Yinghai Lu
2008-02-22 11:18 ` Joerg Roedel
2008-02-21 20:37 ` Ingo Molnar
1 sibling, 1 reply; 11+ messages in thread
From: Yinghai Lu @ 2008-02-21 19:54 UTC (permalink / raw)
To: Joerg Roedel; +Cc: tglx, mingo, linux-kernel
On Thu, Feb 21, 2008 at 6:50 AM, Joerg Roedel <joerg.roedel@amd.com> wrote:
> Inside a KVM virtual machine the MTRRs are usually blank. This confuses Linux
> and causes a warning message at boot. This patch removes that warning message
> when running Linux as a KVM guest.
>
> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
> ---
> arch/x86/kernel/cpu/mtrr/main.c | 7 +++++--
> 1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
> index b6e136f..47e624c 100644
> --- a/arch/x86/kernel/cpu/mtrr/main.c
> +++ b/arch/x86/kernel/cpu/mtrr/main.c
> @@ -43,6 +43,7 @@
> #include <asm/uaccess.h>
> #include <asm/processor.h>
> #include <asm/msr.h>
> +#include <asm/kvm_para.h>
> #include "mtrr.h"
>
> u32 num_var_ranges = 0;
> @@ -687,12 +688,14 @@ int __init mtrr_trim_uncached_memory(unsigned long end_pfn)
> }
>
> /* kvm/qemu doesn't have mtrr set right, don't trim them all */
> - if (!highest_pfn) {
> + if (!highest_pfn && !kvm_para_available()) {
> printk(KERN_WARNING "WARNING: strange, CPU MTRRs all blank?\n");
> WARN_ON(1);
> - return 0;
> }
>
> + if (!highest_pfn)
> + return 0;
> +
> if (highest_pfn < end_pfn) {
> printk(KERN_WARNING "WARNING: BIOS bug: CPU MTRRs don't cover"
> " all of memory, losing %luMB of RAM.\n",
> --
> 1.5.3.7
>
Doest that WARN_ON(1) hurt?
or you may do some patch in qemu too.
so
rdmsr(MTRRdefType_MSR, def, dummy);
def &= 0xff;
if (def != MTRR_TYPE_UNCACHABLE)
return 0;
is happy out.
or set those MTRR entries in qemu...
YH
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH] X86: don't print a warning when MTRR are blank and running in KVM
2008-02-21 19:54 ` Yinghai Lu
@ 2008-02-22 11:18 ` Joerg Roedel
0 siblings, 0 replies; 11+ messages in thread
From: Joerg Roedel @ 2008-02-22 11:18 UTC (permalink / raw)
To: Yinghai Lu; +Cc: tglx, mingo, linux-kernel
On Thu, Feb 21, 2008 at 11:54:00AM -0800, Yinghai Lu wrote:
> On Thu, Feb 21, 2008 at 6:50 AM, Joerg Roedel <joerg.roedel@amd.com> wrote:
> > Inside a KVM virtual machine the MTRRs are usually blank. This confuses Linux
> > and causes a warning message at boot. This patch removes that warning message
> > when running Linux as a KVM guest.
> >
> > Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
> > ---
> > arch/x86/kernel/cpu/mtrr/main.c | 7 +++++--
> > 1 files changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
> > index b6e136f..47e624c 100644
> > --- a/arch/x86/kernel/cpu/mtrr/main.c
> > +++ b/arch/x86/kernel/cpu/mtrr/main.c
> > @@ -43,6 +43,7 @@
> > #include <asm/uaccess.h>
> > #include <asm/processor.h>
> > #include <asm/msr.h>
> > +#include <asm/kvm_para.h>
> > #include "mtrr.h"
> >
> > u32 num_var_ranges = 0;
> > @@ -687,12 +688,14 @@ int __init mtrr_trim_uncached_memory(unsigned long end_pfn)
> > }
> >
> > /* kvm/qemu doesn't have mtrr set right, don't trim them all */
> > - if (!highest_pfn) {
> > + if (!highest_pfn && !kvm_para_available()) {
> > printk(KERN_WARNING "WARNING: strange, CPU MTRRs all blank?\n");
> > WARN_ON(1);
> > - return 0;
> > }
> >
> > + if (!highest_pfn)
> > + return 0;
> > +
> > if (highest_pfn < end_pfn) {
> > printk(KERN_WARNING "WARNING: BIOS bug: CPU MTRRs don't cover"
> > " all of memory, losing %luMB of RAM.\n",
> > --
> > 1.5.3.7
> >
>
> Doest that WARN_ON(1) hurt?
Yes. It inidicates a problem where there isn't one. In a virtual machine
MTRRs make absolutly no sense and so they should all be blank there.
Joerg
--
| AMD Saxony Limited Liability Company & Co. KG
Operating | Wilschdorfer Landstr. 101, 01109 Dresden, Germany
System | Register Court Dresden: HRA 4896
Research | General Partner authorized to represent:
Center | AMD Saxony LLC (Wilmington, Delaware, US)
| General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] X86: don't print a warning when MTRR are blank and running in KVM
2008-02-21 14:50 [PATCH] X86: don't print a warning when MTRR are blank and running in KVM Joerg Roedel
2008-02-21 19:54 ` Yinghai Lu
@ 2008-02-21 20:37 ` Ingo Molnar
2008-02-21 22:31 ` H. Peter Anvin
1 sibling, 1 reply; 11+ messages in thread
From: Ingo Molnar @ 2008-02-21 20:37 UTC (permalink / raw)
To: Joerg Roedel; +Cc: tglx, mingo, linux-kernel
* Joerg Roedel <joerg.roedel@amd.com> wrote:
> - if (!highest_pfn) {
> + if (!highest_pfn && !kvm_para_available()) {
> printk(KERN_WARNING "WARNING: strange, CPU MTRRs all blank?\n");
> WARN_ON(1);
> - return 0;
> }
>
> + if (!highest_pfn)
> + return 0;
hm, why not have a single test for !highest_pfn:
if (!highest_pfn) {
if (!kvm_para_available()) {
printk(KERN_WARNING
"WARNING: strange, CPU MTRRs all blank?\n");
WARN_ON(1);
}
return 0;
}
? But yeah, your patch looks good otherwise.
I'm not sure how we could detect pure Qemu instances - perhaps it should
define some special MSR or something?
Ingo
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH] X86: don't print a warning when MTRR are blank and running in KVM
2008-02-21 20:37 ` Ingo Molnar
@ 2008-02-21 22:31 ` H. Peter Anvin
2008-02-22 9:45 ` Ingo Molnar
0 siblings, 1 reply; 11+ messages in thread
From: H. Peter Anvin @ 2008-02-21 22:31 UTC (permalink / raw)
To: Ingo Molnar; +Cc: Joerg Roedel, tglx, mingo, linux-kernel
Ingo Molnar wrote:
>
> I'm not sure how we could detect pure Qemu instances - perhaps it should
> define some special MSR or something?
>
Perhaps they should fix the Qemu BIOS to actually simulate working MSRs;
if nothing else, they should set up the default MTRR to be cachable.
-hpa
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] X86: don't print a warning when MTRR are blank and running in KVM
2008-02-21 22:31 ` H. Peter Anvin
@ 2008-02-22 9:45 ` Ingo Molnar
2008-02-22 9:58 ` H. Peter Anvin
0 siblings, 1 reply; 11+ messages in thread
From: Ingo Molnar @ 2008-02-22 9:45 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: Joerg Roedel, tglx, mingo, linux-kernel
* H. Peter Anvin <hpa@zytor.com> wrote:
>> I'm not sure how we could detect pure Qemu instances - perhaps it
>> should define some special MSR or something?
>
> Perhaps they should fix the Qemu BIOS to actually simulate working
> MSRs; if nothing else, they should set up the default MTRR to be
> cachable.
btw., should KVM do the same?
Ingo
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] X86: don't print a warning when MTRR are blank and running in KVM
2008-02-22 9:45 ` Ingo Molnar
@ 2008-02-22 9:58 ` H. Peter Anvin
2008-02-22 10:00 ` Ingo Molnar
0 siblings, 1 reply; 11+ messages in thread
From: H. Peter Anvin @ 2008-02-22 9:58 UTC (permalink / raw)
To: Ingo Molnar; +Cc: Joerg Roedel, tglx, mingo, linux-kernel
Ingo Molnar wrote:
> * H. Peter Anvin <hpa@zytor.com> wrote:
>
>>> I'm not sure how we could detect pure Qemu instances - perhaps it
>>> should define some special MSR or something?
>> Perhaps they should fix the Qemu BIOS to actually simulate working
>> MSRs; if nothing else, they should set up the default MTRR to be
>> cachable.
>
> btw., should KVM do the same?
>
Yes. Especially since they share a BIOS.
-hpa
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] X86: don't print a warning when MTRR are blank and running in KVM
2008-02-22 9:58 ` H. Peter Anvin
@ 2008-02-22 10:00 ` Ingo Molnar
2008-02-22 10:04 ` H. Peter Anvin
2008-02-22 11:15 ` Joerg Roedel
0 siblings, 2 replies; 11+ messages in thread
From: Ingo Molnar @ 2008-02-22 10:00 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: Joerg Roedel, tglx, mingo, linux-kernel
* H. Peter Anvin <hpa@zytor.com> wrote:
> Ingo Molnar wrote:
>> * H. Peter Anvin <hpa@zytor.com> wrote:
>>
>>>> I'm not sure how we could detect pure Qemu instances - perhaps it should
>>>> define some special MSR or something?
>>> Perhaps they should fix the Qemu BIOS to actually simulate working MSRs;
>>> if nothing else, they should set up the default MTRR to be cachable.
>>
>> btw., should KVM do the same?
>
> Yes. Especially since they share a BIOS.
ok. Then i guess we should just leave the warning and the backtrace in
place until they get a fix done?
Ingo
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] X86: don't print a warning when MTRR are blank and running in KVM
2008-02-22 10:00 ` Ingo Molnar
@ 2008-02-22 10:04 ` H. Peter Anvin
2008-02-22 11:15 ` Joerg Roedel
1 sibling, 0 replies; 11+ messages in thread
From: H. Peter Anvin @ 2008-02-22 10:04 UTC (permalink / raw)
To: Ingo Molnar; +Cc: Joerg Roedel, tglx, mingo, linux-kernel
Ingo Molnar wrote:
> * H. Peter Anvin <hpa@zytor.com> wrote:
>
>> Ingo Molnar wrote:
>>> * H. Peter Anvin <hpa@zytor.com> wrote:
>>>
>>>>> I'm not sure how we could detect pure Qemu instances - perhaps it should
>>>>> define some special MSR or something?
>>>> Perhaps they should fix the Qemu BIOS to actually simulate working MSRs;
>>>> if nothing else, they should set up the default MTRR to be cachable.
>>> btw., should KVM do the same?
>> Yes. Especially since they share a BIOS.
>
> ok. Then i guess we should just leave the warning and the backtrace in
> place until they get a fix done?
>
That would be my opinion.
Last I checked, they didn't even clear the cache disable bits in %cr0.
-hpa
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] X86: don't print a warning when MTRR are blank and running in KVM
2008-02-22 10:00 ` Ingo Molnar
2008-02-22 10:04 ` H. Peter Anvin
@ 2008-02-22 11:15 ` Joerg Roedel
2008-02-22 12:48 ` Ingo Molnar
1 sibling, 1 reply; 11+ messages in thread
From: Joerg Roedel @ 2008-02-22 11:15 UTC (permalink / raw)
To: Ingo Molnar; +Cc: H. Peter Anvin, tglx, mingo, linux-kernel
On Fri, Feb 22, 2008 at 11:00:44AM +0100, Ingo Molnar wrote:
>
> * H. Peter Anvin <hpa@zytor.com> wrote:
>
> > Ingo Molnar wrote:
> >> * H. Peter Anvin <hpa@zytor.com> wrote:
> >>
> >>>> I'm not sure how we could detect pure Qemu instances - perhaps it should
> >>>> define some special MSR or something?
> >>> Perhaps they should fix the Qemu BIOS to actually simulate working MSRs;
> >>> if nothing else, they should set up the default MTRR to be cachable.
> >>
> >> btw., should KVM do the same?
> >
> > Yes. Especially since they share a BIOS.
>
> ok. Then i guess we should just leave the warning and the backtrace in
> place until they get a fix done?
No. I don't agree. The MTRRs are set up by the BIOS because it knows the
hardware best (I know this is only true in theory). The OS should
basically trust the BIOS MTRR settings. If the OS can't trust the BIOS,
like on real hardware, the check and the warning is necessary. If the OS
can trust the BIOS, like running in a KVM or QEMU virtual machine, it
should just ignore the case where all MTRRs are blank.
Joerg
--
| AMD Saxony Limited Liability Company & Co. KG
Operating | Wilschdorfer Landstr. 101, 01109 Dresden, Germany
System | Register Court Dresden: HRA 4896
Research | General Partner authorized to represent:
Center | AMD Saxony LLC (Wilmington, Delaware, US)
| General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH] X86: don't print a warning when MTRR are blank and running in KVM
2008-02-22 11:15 ` Joerg Roedel
@ 2008-02-22 12:48 ` Ingo Molnar
0 siblings, 0 replies; 11+ messages in thread
From: Ingo Molnar @ 2008-02-22 12:48 UTC (permalink / raw)
To: Joerg Roedel; +Cc: H. Peter Anvin, tglx, mingo, linux-kernel
* Joerg Roedel <joerg.roedel@amd.com> wrote:
> > ok. Then i guess we should just leave the warning and the backtrace
> > in place until they get a fix done?
>
> No. I don't agree. The MTRRs are set up by the BIOS because it knows
> the hardware best (I know this is only true in theory). The OS should
> basically trust the BIOS MTRR settings. If the OS can't trust the
> BIOS, like on real hardware, the check and the warning is necessary.
> If the OS can trust the BIOS, like running in a KVM or QEMU virtual
> machine, it should just ignore the case where all MTRRs are blank.
well, i can agree with the warning being pointless on KVM paravirt, but
it's not pointless in the Qemu context.
we fundamentall _dont_ trust the BIOS's MTRR settings, just check the
very function that you modified: mtrr_trim_uncached_memory() - that
function handles _exactly_ a case where a BIOS messes up MTRR's. This
problem has caused real user-side breakage and just not emitting a
warning because Qemu is lazy to emulate a proper PC is not a strong
enough argument.
so i've applied the KVM bits but the warning stays for Qemu.
Ingo
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2008-02-22 12:48 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-21 14:50 [PATCH] X86: don't print a warning when MTRR are blank and running in KVM Joerg Roedel
2008-02-21 19:54 ` Yinghai Lu
2008-02-22 11:18 ` Joerg Roedel
2008-02-21 20:37 ` Ingo Molnar
2008-02-21 22:31 ` H. Peter Anvin
2008-02-22 9:45 ` Ingo Molnar
2008-02-22 9:58 ` H. Peter Anvin
2008-02-22 10:00 ` Ingo Molnar
2008-02-22 10:04 ` H. Peter Anvin
2008-02-22 11:15 ` Joerg Roedel
2008-02-22 12:48 ` Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox