Re: [PATCH 23/42] KVM: Activate Virtualization On Demand
On 16.08.2010, at 15:49, Serge Belyshev wrote: > Alexander Graf writes: > >> Hrm - try to use the following (probably whitespace broken and 100% >> untested) hacky patch: >> >> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c >> index 56c9b6b..bde9ee3 100644 >> --- a/arch/x86/kvm/svm.c >> +++ b/arch/x86/kvm/svm.c >> @@ -429,9 +429,11 @@ static int svm_hardware_enable(void *garbage) >>struct desc_struct *gdt; >>int me = raw_smp_processor_id(); >> >> +#if 0 >>rdmsrl(MSR_EFER, efer); >>if (efer & EFER_SVME) >>return -EBUSY; >> +#endif >> > > I tested a bit different hack keeping rdmsrl but removing the if() and > it works fine for me: > > Index: linux/arch/x86/kvm/svm.c > === > --- linux.orig/arch/x86/kvm/svm.c > +++ linux/arch/x86/kvm/svm.c > @@ -429,8 +429,7 @@ static int svm_hardware_enable(void *gar > int me = raw_smp_processor_id(); > > rdmsrl(MSR_EFER, efer); > - if (efer & EFER_SVME) > - return -EBUSY; > + printk(KERN_DEBUG "svm_hardware_enable: efer %x on %d\n", efer, me); Ouch, yes. Thanks for not taking my patch ;). The efer read is of course still mandatory. > > if (!has_svm()) { > printk(KERN_ERR "svm_hardware_enable: err EOPNOTSUPP on %d\n", > > Here is an example of its output: > > [231441.358111] svm_hardware_enable: efer 1d01 on 0 > [231441.358117] svm_hardware_enable: efer d01 on 3 > [231441.358124] svm_hardware_enable: efer d01 on 2 > [231441.358135] svm_hardware_enable: efer d01 on 1 > [231675.168967] svm_hardware_enable: efer d01 on 0 > [231675.168972] svm_hardware_enable: efer d01 on 1 > [231675.168983] svm_hardware_enable: efer d01 on 2 > [231675.168995] svm_hardware_enable: efer d01 on 3 > > > After reboot, the first kvm run always reports efer = 1d01 on the first cpu. > In all subsequent runs before reboot efer stays d01 on all cpus. Happy broken BIOS fun. Oh well, I guess you can live with the patched version and normal end-users will just update their BIOSes. Alex -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 23/42] KVM: Activate Virtualization On Demand
Alexander Graf writes: > Hrm - try to use the following (probably whitespace broken and 100% untested) > hacky patch: > > diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c > index 56c9b6b..bde9ee3 100644 > --- a/arch/x86/kvm/svm.c > +++ b/arch/x86/kvm/svm.c > @@ -429,9 +429,11 @@ static int svm_hardware_enable(void *garbage) > struct desc_struct *gdt; > int me = raw_smp_processor_id(); > > +#if 0 > rdmsrl(MSR_EFER, efer); > if (efer & EFER_SVME) > return -EBUSY; > +#endif > I tested a bit different hack keeping rdmsrl but removing the if() and it works fine for me: Index: linux/arch/x86/kvm/svm.c === --- linux.orig/arch/x86/kvm/svm.c +++ linux/arch/x86/kvm/svm.c @@ -429,8 +429,7 @@ static int svm_hardware_enable(void *gar int me = raw_smp_processor_id(); rdmsrl(MSR_EFER, efer); - if (efer & EFER_SVME) - return -EBUSY; + printk(KERN_DEBUG "svm_hardware_enable: efer %x on %d\n", efer, me); if (!has_svm()) { printk(KERN_ERR "svm_hardware_enable: err EOPNOTSUPP on %d\n", Here is an example of its output: [231441.358111] svm_hardware_enable: efer 1d01 on 0 [231441.358117] svm_hardware_enable: efer d01 on 3 [231441.358124] svm_hardware_enable: efer d01 on 2 [231441.358135] svm_hardware_enable: efer d01 on 1 [231675.168967] svm_hardware_enable: efer d01 on 0 [231675.168972] svm_hardware_enable: efer d01 on 1 [231675.168983] svm_hardware_enable: efer d01 on 2 [231675.168995] svm_hardware_enable: efer d01 on 3 After reboot, the first kvm run always reports efer = 1d01 on the first cpu. In all subsequent runs before reboot efer stays d01 on all cpus. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 23/42] KVM: Activate Virtualization On Demand
On 08.08.2010, at 14:02, Serge Belyshev wrote: > Hi! Since the above patch went in > http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=10474ae8 > I have exactly the same problem as Dieter. > If that's the case I'd say you have a broken BIOS or bootloader. >>> >>> You are right, it seems to be always cpu0. I'll check my BIOS and flash >>> a newer version if available. >> >> Please do. If that doesn't help ping me again. I'll write up a quirk patch >> then. >> > > My h/w is a bit different (cpu: 9850 B3, mb: GA-MA790FX-DQ6 bios F7b), > but I cannot use latest available BIOS (F7d) as it breaks my SAS controller. > > So I guess I need the quirk patch. Hrm - try to use the following (probably whitespace broken and 100% untested) hacky patch: diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 56c9b6b..bde9ee3 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -429,9 +429,11 @@ static int svm_hardware_enable(void *garbage) struct desc_struct *gdt; int me = raw_smp_processor_id(); +#if 0 rdmsrl(MSR_EFER, efer); if (efer & EFER_SVME) return -EBUSY; +#endif if (!has_svm()) { printk(KERN_ERR "svm_hardware_enable: err EOPNOTSUPP on %d\n", Alex-- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 23/42] KVM: Activate Virtualization On Demand
Hi! Since the above patch went in http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=10474ae8 I have exactly the same problem as Dieter. >>> If that's the case I'd say you have a broken BIOS or bootloader. >> >> You are right, it seems to be always cpu0. I'll check my BIOS and flash >> a newer version if available. > > Please do. If that doesn't help ping me again. I'll write up a quirk patch > then. > My h/w is a bit different (cpu: 9850 B3, mb: GA-MA790FX-DQ6 bios F7b), but I cannot use latest available BIOS (F7d) as it breaks my SAS controller. So I guess I need the quirk patch. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 23/42] KVM: Activate Virtualization On Demand
On Thu, Mar 18, 2010 at 08:17:01AM +0100, Alexander Graf wrote: > On 18.03.2010, at 08:11, Dieter Ries wrote: > > You are right, it seems to be always cpu0. I'll check my BIOS and flash > > a newer version if available. > > Please do. If that doesn't help ping me again. I'll write up a quirk patch > then. It seems you were right, I flashed the BIOS to the latest version and now it is working. So thanks everybody, and sorry for the inconvenience. > Alex cu Dieter -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 23/42] KVM: Activate Virtualization On Demand
On 18.03.2010, at 08:11, Dieter Ries wrote: > On Wed, Mar 17, 2010 at 11:47:14PM +0100, Alexander Graf wrote: >> It looks like one of your CPUs has EFER_SVME enabled on bootup already. I'm >> not aware of code clearing EFER, so if there's garbage in there on boot it >> stays there. >> >> Could you please add the current CPU number to your printk? I bet it's >> always the same one. > > [ 1300.393635] efer on CPU1 is d01 > [ 1300.393638] efer on CPU3 is d01 > [ 1300.393641] efer on CPU2 is d01 > [ 1300.393643] EFER_SVME is 1000 > [ 1300.393645] EFER_SVME is 1000 > [ 1300.393646] EFER_SVME is 1000 > [ 1300.393650] efer on CPU0 is 1d01 > [ 1300.393652] EFER_SVME is 1000 > [ 1300.393653] kvm: enabling virtualization on CPU0 failed > > >> If that's the case I'd say you have a broken BIOS or bootloader. > > You are right, it seems to be always cpu0. I'll check my BIOS and flash > a newer version if available. Please do. If that doesn't help ping me again. I'll write up a quirk patch then. Alex-- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 23/42] KVM: Activate Virtualization On Demand
On Wed, Mar 17, 2010 at 11:47:14PM +0100, Alexander Graf wrote: > It looks like one of your CPUs has EFER_SVME enabled on bootup already. I'm > not aware of code clearing EFER, so if there's garbage in there on boot it > stays there. > > Could you please add the current CPU number to your printk? I bet it's always > the same one. [ 1300.393635] efer on CPU1 is d01 [ 1300.393638] efer on CPU3 is d01 [ 1300.393641] efer on CPU2 is d01 [ 1300.393643] EFER_SVME is 1000 [ 1300.393645] EFER_SVME is 1000 [ 1300.393646] EFER_SVME is 1000 [ 1300.393650] efer on CPU0 is 1d01 [ 1300.393652] EFER_SVME is 1000 [ 1300.393653] kvm: enabling virtualization on CPU0 failed > If that's the case I'd say you have a broken BIOS or bootloader. You are right, it seems to be always cpu0. I'll check my BIOS and flash a newer version if available. > > Alex cu Dieter -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 23/42] KVM: Activate Virtualization On Demand
On Thu, Mar 18, 2010 at 08:41:28AM +0300, Michael Tokarev wrote: > Dieter Ries wrote: > > On Wed, Mar 17, 2010 at 11:02:40PM +0100, Alexander Graf wrote: > [] > >> Are you 100% sure you don't have vmware, virtualbox, parallels, whatever > >> running in parallel on that machine? > > > > Definitely. I have virtualbox installed, but haven't used it in months. > > The others I don't use at all, so they are not installed either. > > Dieter, we've talked with you on IRC yesterday... Yes, I remember. > Can you take a look at what's in the startup script sequence on > your machine, and what modules are loaded which may be related? > What I'm trying to say: I don't know how virtualbox works, but it > may come with a kernel module or a bootup script that touches SVM > settings. I checked it again: I don't even have the virtualbox modules installed for this kernel, I cannot modprobe them. lsmod is here: before modprobe kvm_amd Module Size Used by snd_pcm_oss33062 0 snd_mixer_oss 13798 1 snd_pcm_oss snd_seq_oss23963 0 snd_seq_midi_event 5684 1 snd_seq_oss snd_seq44953 4 snd_seq_oss,snd_seq_midi_event snd_seq_device 5481 2 snd_seq_oss,snd_seq nvidia 9613596 40 snd_hda_codec_realtek 264327 1 snd_hda_intel 20099 4 snd_hda_codec 57443 2 snd_hda_codec_realtek,snd_hda_intel snd_hwdep 5642 1 snd_hda_codec snd_pcm68342 4 snd_pcm_oss,snd_hda_intel,snd_hda_codec snd_timer 17426 3 snd_seq,snd_pcm snd52486 17 snd_pcm_oss,snd_mixer_oss,snd_seq_oss,snd_seq,snd_seq_device,snd_hda_codec_realtek,snd_hda_intel,snd_hda_codec,snd_hwdep,snd_pcm,snd_timer soundcore 6287 1 snd snd_page_alloc 7029 2 snd_hda_intel,snd_pcm i2c_core 18944 1 nvidia after: Module Size Used by kvm_amd32387 0 kvm 249238 1 kvm_amd snd_pcm_oss33062 0 snd_mixer_oss 13798 1 snd_pcm_oss snd_seq_oss23963 0 snd_seq_midi_event 5684 1 snd_seq_oss snd_seq44953 4 snd_seq_oss,snd_seq_midi_event snd_seq_device 5481 2 snd_seq_oss,snd_seq nvidia 9613596 40 snd_hda_codec_realtek 264327 1 snd_hda_intel 20099 4 snd_hda_codec 57443 2 snd_hda_codec_realtek,snd_hda_intel snd_hwdep 5642 1 snd_hda_codec snd_pcm68342 4 snd_pcm_oss,snd_hda_intel,snd_hda_codec snd_timer 17426 3 snd_seq,snd_pcm snd52486 17 snd_pcm_oss,snd_mixer_oss,snd_seq_oss,snd_seq,snd_seq_device,snd_hda_codec_realtek,snd_hda_intel,snd_hda_codec,snd_hwdep,snd_pcm,snd_timer soundcore 6287 1 snd snd_page_alloc 7029 2 snd_hda_intel,snd_pcm i2c_core 18944 1 nvidia This is a gentoo box, and there are no services started which are related to virtualization. No autoloaded modules or anything. Just standard desktop stuff + lvm and raid. Runlevel: boot hwclock [ started ] modules [ started ] lvm [ started ] device-mapper[ started ] fsck [ started ] root [ started ] mtab [ started ] hostname [ started ] localmount [ started ] sysctl [ started ] bootmisc [ started ] sysklogd [ started ] urandom [ started ] termencoding [ started ] consolefont [ started ] net.lo [ started ] staticroute [ started ] mdadm[ started ] swap [ started ] acpid[ started ] procfs
Re: [PATCH 23/42] KVM: Activate Virtualization On Demand
Dieter Ries wrote: > On Wed, Mar 17, 2010 at 11:02:40PM +0100, Alexander Graf wrote: [] >> Are you 100% sure you don't have vmware, virtualbox, parallels, whatever >> running in parallel on that machine? > > Definitely. I have virtualbox installed, but haven't used it in months. > The others I don't use at all, so they are not installed either. Dieter, we've talked with you on IRC yesterday... Can you take a look at what's in the startup script sequence on your machine, and what modules are loaded which may be related? What I'm trying to say: I don't know how virtualbox works, but it may come with a kernel module or a bootup script that touches SVM settings. /mjt -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 23/42] KVM: Activate Virtualization On Demand
On 17.03.2010, at 23:40, Dieter Ries wrote: > On Wed, Mar 17, 2010 at 11:02:40PM +0100, Alexander Graf wrote: >> On 17.03.2010, at 22:57, Dieter Ries wrote: >>> Hi, >>> >>> This is breaking KVM on my Phenom II X4 955. >>> >>> When I start kvm I get this on the terminal: >>> >>> kvm_create_vm: Device or resource busy >>> Could not initialize KVM, will disable KVM support >>> >>> And in dmesg: >>> [ 67.980732] kvm: enabling virtualization on CPU0 failed >>> >>> >>> I commented out the if() and return, and I added 2 printk's there for >>> debugging, and now that's what I see in dmesg when I start kvm: >>> >>> [ 3341.740112] efer is 3329 >>> [ 3341.740113] efer is 3329 >>> [ 3341.740117] efer is 3329 >>> [ 3341.740119] EFER_SVME is 4096 >>> [ 3341.740121] EFER_SVME is 4096 >>> [ 3341.740124] EFER_SVME is 4096 >>> [ 3341.740130] efer is 3329 >>> [ 3341.740132] EFER_SVME is 4096 >>> >>> In hex the values are 0x1000 and 0x0d01 >>> >>> KVM has been working well on this machine before, and it still works >>> well after commenting that part out. >>> >>> I am not sure what the value of this register is supposed to be, but are >>> you sure >>> >>> if (efer & EFER_SVME) >>> >>> is the right condition? >> >> According to the printks you show above the & condition should never apply. >> >> Are you 100% sure you don't have vmware, virtualbox, parallels, whatever >> running in parallel on that machine? > > Definitely. I have virtualbox installed, but haven't used it in months. > The others I don't use at all, so they are not installed either. > > There is nothing running which could cause that. Behaviour is the same > when I don't log into KDE but just try this without X, where nearly > nothing is started. > > I noted something more now: When I comment it out once, and start kvm > like that, and then remove the comments again, then it works. So I guess > the dmesg parts I wrote were not perfect. It's more like: > > I: After reboot, with debugging printk and if condition: > > [ 42.089423] efer is d01 > [ 42.089425] efer is d01 > [ 42.089428] efer is d01 > [ 42.089430] EFER_SVME is 1000 > [ 42.089431] EFER_SVME is 1000 > [ 42.089433] EFER_SVME is 1000 > [ 42.089436] efer is 1d01 > [ 42.089438] EFER_SVME is 1000 > [ 42.089440] kvm: enabling virtualization on CPU0 failed > > II: debugging printk, no if condition: > > [ 317.355519] efer is d01 > [ 317.355522] efer is d01 > [ 317.355524] efer is d01 > [ 317.355527] EFER_SVME is 1000 > [ 317.355528] EFER_SVME is 1000 > [ 317.355531] EFER_SVME is 1000 > [ 317.355534] efer is 1d01 > [ 317.355536] EFER_SVME is 1000 > > III: debugging printk and if condition: > > [ 421.955433] efer is d01 > [ 421.955437] efer is d01 > [ 421.955440] efer is d01 > [ 421.955442] EFER_SVME is 1000 > [ 421.955443] EFER_SVME is 1000 > [ 421.955445] EFER_SVME is 1000 > [ 421.955449] efer is d01 > [ 421.955451] EFER_SVME is 1000 > > > > This is without reboots in between. So now before I use the commented > out version for the first time, it doesnt work, the 2nd time it works. > Maybe some initialization problem... It looks like one of your CPUs has EFER_SVME enabled on bootup already. I'm not aware of code clearing EFER, so if there's garbage in there on boot it stays there. Could you please add the current CPU number to your printk? I bet it's always the same one. If that's the case I'd say you have a broken BIOS or bootloader. Alex-- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 23/42] KVM: Activate Virtualization On Demand
On Wed, Mar 17, 2010 at 11:02:40PM +0100, Alexander Graf wrote: > On 17.03.2010, at 22:57, Dieter Ries wrote: > > Hi, > > > > This is breaking KVM on my Phenom II X4 955. > > > > When I start kvm I get this on the terminal: > > > > kvm_create_vm: Device or resource busy > > Could not initialize KVM, will disable KVM support > > > > And in dmesg: > > [ 67.980732] kvm: enabling virtualization on CPU0 failed > > > > > > I commented out the if() and return, and I added 2 printk's there for > > debugging, and now that's what I see in dmesg when I start kvm: > > > > [ 3341.740112] efer is 3329 > > [ 3341.740113] efer is 3329 > > [ 3341.740117] efer is 3329 > > [ 3341.740119] EFER_SVME is 4096 > > [ 3341.740121] EFER_SVME is 4096 > > [ 3341.740124] EFER_SVME is 4096 > > [ 3341.740130] efer is 3329 > > [ 3341.740132] EFER_SVME is 4096 > > > > In hex the values are 0x1000 and 0x0d01 > > > > KVM has been working well on this machine before, and it still works > > well after commenting that part out. > > > > I am not sure what the value of this register is supposed to be, but are > > you sure > > > > if (efer & EFER_SVME) > > > > is the right condition? > > According to the printks you show above the & condition should never apply. > > Are you 100% sure you don't have vmware, virtualbox, parallels, whatever > running in parallel on that machine? Definitely. I have virtualbox installed, but haven't used it in months. The others I don't use at all, so they are not installed either. There is nothing running which could cause that. Behaviour is the same when I don't log into KDE but just try this without X, where nearly nothing is started. I noted something more now: When I comment it out once, and start kvm like that, and then remove the comments again, then it works. So I guess the dmesg parts I wrote were not perfect. It's more like: I: After reboot, with debugging printk and if condition: [ 42.089423] efer is d01 [ 42.089425] efer is d01 [ 42.089428] efer is d01 [ 42.089430] EFER_SVME is 1000 [ 42.089431] EFER_SVME is 1000 [ 42.089433] EFER_SVME is 1000 [ 42.089436] efer is 1d01 [ 42.089438] EFER_SVME is 1000 [ 42.089440] kvm: enabling virtualization on CPU0 failed II: debugging printk, no if condition: [ 317.355519] efer is d01 [ 317.355522] efer is d01 [ 317.355524] efer is d01 [ 317.355527] EFER_SVME is 1000 [ 317.355528] EFER_SVME is 1000 [ 317.355531] EFER_SVME is 1000 [ 317.355534] efer is 1d01 [ 317.355536] EFER_SVME is 1000 III: debugging printk and if condition: [ 421.955433] efer is d01 [ 421.955437] efer is d01 [ 421.955440] efer is d01 [ 421.955442] EFER_SVME is 1000 [ 421.955443] EFER_SVME is 1000 [ 421.955445] EFER_SVME is 1000 [ 421.955449] efer is d01 [ 421.955451] EFER_SVME is 1000 This is without reboots in between. So now before I use the commented out version for the first time, it doesnt work, the 2nd time it works. Maybe some initialization problem... > Alex cu Dieter -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 23/42] KVM: Activate Virtualization On Demand
Am 16.11.2009 13:19, schrieb Avi Kivity: > From: Alexander Graf > diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c > index f54c4f9..59fe4d5 100644 > --- a/arch/x86/kvm/svm.c > +++ b/arch/x86/kvm/svm.c > @@ -316,7 +316,7 @@ static void svm_hardware_disable(void *garbage) > cpu_svm_disable(); > } > > -static void svm_hardware_enable(void *garbage) > +static int svm_hardware_enable(void *garbage) > { > > struct svm_cpu_data *svm_data; > @@ -325,16 +325,20 @@ static void svm_hardware_enable(void *garbage) > struct desc_struct *gdt; > int me = raw_smp_processor_id(); > > + rdmsrl(MSR_EFER, efer); > + if (efer & EFER_SVME) > + return -EBUSY; > + Hi, This is breaking KVM on my Phenom II X4 955. When I start kvm I get this on the terminal: kvm_create_vm: Device or resource busy Could not initialize KVM, will disable KVM support And in dmesg: [ 67.980732] kvm: enabling virtualization on CPU0 failed I commented out the if() and return, and I added 2 printk's there for debugging, and now that's what I see in dmesg when I start kvm: [ 3341.740112] efer is 3329 [ 3341.740113] efer is 3329 [ 3341.740117] efer is 3329 [ 3341.740119] EFER_SVME is 4096 [ 3341.740121] EFER_SVME is 4096 [ 3341.740124] EFER_SVME is 4096 [ 3341.740130] efer is 3329 [ 3341.740132] EFER_SVME is 4096 In hex the values are 0x1000 and 0x0d01 KVM has been working well on this machine before, and it still works well after commenting that part out. I am not sure what the value of this register is supposed to be, but are you sure if (efer & EFER_SVME) is the right condition? cu Dieter -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 23/42] KVM: Activate Virtualization On Demand
On 17.03.2010, at 22:57, Dieter Ries wrote: > Am 16.11.2009 13:19, schrieb Avi Kivity: >> From: Alexander Graf >> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c >> index f54c4f9..59fe4d5 100644 >> --- a/arch/x86/kvm/svm.c >> +++ b/arch/x86/kvm/svm.c >> @@ -316,7 +316,7 @@ static void svm_hardware_disable(void *garbage) >> cpu_svm_disable(); >> } >> >> -static void svm_hardware_enable(void *garbage) >> +static int svm_hardware_enable(void *garbage) >> { >> >> struct svm_cpu_data *svm_data; >> @@ -325,16 +325,20 @@ static void svm_hardware_enable(void *garbage) >> struct desc_struct *gdt; >> int me = raw_smp_processor_id(); >> >> +rdmsrl(MSR_EFER, efer); >> +if (efer & EFER_SVME) >> +return -EBUSY; >> + > > Hi, > > This is breaking KVM on my Phenom II X4 955. > > When I start kvm I get this on the terminal: > > kvm_create_vm: Device or resource busy > Could not initialize KVM, will disable KVM support > > And in dmesg: > [ 67.980732] kvm: enabling virtualization on CPU0 failed > > > I commented out the if() and return, and I added 2 printk's there for > debugging, and now that's what I see in dmesg when I start kvm: > > [ 3341.740112] efer is 3329 > [ 3341.740113] efer is 3329 > [ 3341.740117] efer is 3329 > [ 3341.740119] EFER_SVME is 4096 > [ 3341.740121] EFER_SVME is 4096 > [ 3341.740124] EFER_SVME is 4096 > [ 3341.740130] efer is 3329 > [ 3341.740132] EFER_SVME is 4096 > > In hex the values are 0x1000 and 0x0d01 > > KVM has been working well on this machine before, and it still works > well after commenting that part out. > > I am not sure what the value of this register is supposed to be, but are > you sure > > if (efer & EFER_SVME) > > is the right condition? According to the printks you show above the & condition should never apply. Are you 100% sure you don't have vmware, virtualbox, parallels, whatever running in parallel on that machine? Alex-- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 23/42] KVM: Activate Virtualization On Demand
From: Alexander Graf X86 CPUs need to have some magic happening to enable the virtualization extensions on them. This magic can result in unpleasant results for users, like blocking other VMMs from working (vmx) or using invalid TLB entries (svm). Currently KVM activates virtualization when the respective kernel module is loaded. This blocks us from autoloading KVM modules without breaking other VMMs. To circumvent this problem at least a bit, this patch introduces on demand activation of virtualization. This means, that instead virtualization is enabled on creation of the first virtual machine and disabled on destruction of the last one. So using this, KVM can be easily autoloaded, while keeping other hypervisors usable. Signed-off-by: Alexander Graf Signed-off-by: Marcelo Tosatti Signed-off-by: Avi Kivity --- arch/ia64/kvm/kvm-ia64.c|8 ++- arch/powerpc/kvm/powerpc.c |3 +- arch/s390/kvm/kvm-s390.c|3 +- arch/x86/include/asm/kvm_host.h |2 +- arch/x86/kvm/svm.c | 13 -- arch/x86/kvm/vmx.c | 11 +++- arch/x86/kvm/x86.c |4 +- include/linux/kvm_host.h|2 +- virt/kvm/kvm_main.c | 90 +- 9 files changed, 108 insertions(+), 28 deletions(-) diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index f6471c8..5fdeec5 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c @@ -124,7 +124,7 @@ long ia64_pal_vp_create(u64 *vpd, u64 *host_iva, u64 *opt_handler) static DEFINE_SPINLOCK(vp_lock); -void kvm_arch_hardware_enable(void *garbage) +int kvm_arch_hardware_enable(void *garbage) { long status; long tmp_base; @@ -137,7 +137,7 @@ void kvm_arch_hardware_enable(void *garbage) slot = ia64_itr_entry(0x3, KVM_VMM_BASE, pte, KVM_VMM_SHIFT); local_irq_restore(saved_psr); if (slot < 0) - return; + return -EINVAL; spin_lock(&vp_lock); status = ia64_pal_vp_init_env(kvm_vsa_base ? @@ -145,7 +145,7 @@ void kvm_arch_hardware_enable(void *garbage) __pa(kvm_vm_buffer), KVM_VM_BUFFER_BASE, &tmp_base); if (status != 0) { printk(KERN_WARNING"kvm: Failed to Enable VT Support\n"); - return ; + return -EINVAL; } if (!kvm_vsa_base) { @@ -154,6 +154,8 @@ void kvm_arch_hardware_enable(void *garbage) } spin_unlock(&vp_lock); ia64_ptr_entry(0x3, slot); + + return 0; } void kvm_arch_hardware_disable(void *garbage) diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index 95af622..5902bbc 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -78,8 +78,9 @@ int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu) return r; } -void kvm_arch_hardware_enable(void *garbage) +int kvm_arch_hardware_enable(void *garbage) { + return 0; } void kvm_arch_hardware_disable(void *garbage) diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 00e2ce8..5445058 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -74,9 +74,10 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { static unsigned long long *facilities; /* Section: not file related */ -void kvm_arch_hardware_enable(void *garbage) +int kvm_arch_hardware_enable(void *garbage) { /* every s390 is virtualization enabled ;-) */ + return 0; } void kvm_arch_hardware_disable(void *garbage) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index a46e2dd..295c7c4 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -459,7 +459,7 @@ struct descriptor_table { struct kvm_x86_ops { int (*cpu_has_kvm_support)(void); /* __init */ int (*disabled_by_bios)(void); /* __init */ - void (*hardware_enable)(void *dummy); /* __init */ + int (*hardware_enable)(void *dummy); void (*hardware_disable)(void *dummy); void (*check_processor_compatibility)(void *rtn); int (*hardware_setup)(void); /* __init */ diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index f54c4f9..59fe4d5 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -316,7 +316,7 @@ static void svm_hardware_disable(void *garbage) cpu_svm_disable(); } -static void svm_hardware_enable(void *garbage) +static int svm_hardware_enable(void *garbage) { struct svm_cpu_data *svm_data; @@ -325,16 +325,20 @@ static void svm_hardware_enable(void *garbage) struct desc_struct *gdt; int me = raw_smp_processor_id(); + rdmsrl(MSR_EFER, efer); + if (efer & EFER_SVME) + return -EBUSY; + if (!has_svm()) { printk(KERN_ERR "svm_cpu_init: err EOPNOTSUPP on %d\n", me); - return; +