Zachary Amsden | 1 Aug 2010 01:55
Picon
Favicon

Re: 2.6.35-rc1 regression with pvclock and smp guests

On 07/31/2010 06:36 AM, Arjan Koers wrote:
> On 2010-07-31 13:53, Arjan Koers wrote:
>    
>> The kernel boots successfully when CONFIG_PRINTK_TIME is not set.
>>
>>      
> The problem occurs when this message is printed:
>
> [    0.016000] kvm-clock: cpu 1, msr 0:1511c01, secondary cpu clock
>
> When I disable that printk, the kernel boots with
> CONFIG_PRINTK_TIME=y
>
> --- a/arch/x86/kernel/kvmclock.c
> +++ b/arch/x86/kernel/kvmclock.c
>  <at>  <at>  -131,8 +131,8  <at>  <at>  static int kvm_register_clock(char *txt)
>   	int low, high;
>   	low = (int)__pa(&per_cpu(hv_clock, cpu)) | 1;
>   	high = ((u64)__pa(&per_cpu(hv_clock, cpu))>>  32);
> -	printk(KERN_INFO "kvm-clock: cpu %d, msr %x:%x, %s\n",
> -	       cpu, high, low, txt);
> +	/*printk(KERN_INFO "kvm-clock: cpu %d, msr %x:%x, %s\n",
> +	       cpu, high, low, txt);*/
>
>   	return native_write_msr_safe(msr_kvm_system_time, low, high);
>   }
>
> So the problem appears to be that the clock of the second CPU
> is used too soon (or that clock setup should finish earlier).
>    
(Continue reading)

Avi Kivity | 1 Aug 2010 09:51
Picon
Favicon

Re: enabling X86_FEATURE_ARCH_PERFMON in guest

  On 07/30/2010 08:02 PM, David S. Ahern wrote:
> How do I get X86_FEATURE_ARCH_PERFMON enabled for a guest?
>
> I've tried "-cpu host,+perfmon" and "-cpu host,+arch_perfmon", but both
> get rejected with an error: CPU feature perfmon not found
>

qemu doesn't know about the perfmon feature bits.  Even if it did, kvm 
doesn't, so it wouldn't work.

Jes is working on this.

--

-- 
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Gleb Natapov | 1 Aug 2010 10:28
Picon
Favicon

Re: [PATCH 1/2] KVM: x86 emulator: don't update vcpu state if instruction is restarted.

On Sat, Jul 31, 2010 at 08:25:13PM +0300, Avi Kivity wrote:
>  On 07/29/2010 03:11 PM, Gleb Natapov wrote:
> >No need to update vcpu state since instruction is in the middle of the
> >emulation.
> >
> >Signed-off-by: Gleb Natapov<gleb <at> redhat.com>
> >---
> >  arch/x86/kvm/x86.c |   31 +++++++++++++------------------
> >  1 files changed, 13 insertions(+), 18 deletions(-)
> >
> >diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> >index 76fbc32..7e5f075 100644
> >--- a/arch/x86/kvm/x86.c
> >+++ b/arch/x86/kvm/x86.c
> > <at>  <at>  -4057,32 +4057,27  <at>  <at>  restart:
> >  		return handle_emulation_failure(vcpu);
> >  	}
> >
> >-	toggle_interruptibility(vcpu, vcpu->arch.emulate_ctxt.interruptibility);
> >-	kvm_x86_ops->set_rflags(vcpu, vcpu->arch.emulate_ctxt.eflags);
> >-	memcpy(vcpu->arch.regs, c->regs, sizeof c->regs);
> >-	kvm_rip_write(vcpu, vcpu->arch.emulate_ctxt.eip);
> >+	r = EMULATE_DONE;
> >
> >-	if (vcpu->arch.emulate_ctxt.exception>= 0) {
> >+	if (vcpu->arch.emulate_ctxt.exception>= 0)
> >  		inject_emulated_exception(vcpu);
> >-		return EMULATE_DONE;
> >-	}
> >-
(Continue reading)

Avi Kivity | 1 Aug 2010 10:54
Picon
Favicon

Re: [PATCH 1/2] KVM: x86 emulator: don't update vcpu state if instruction is restarted.

  On 08/01/2010 11:28 AM, Gleb Natapov wrote:
> On Sat, Jul 31, 2010 at 08:25:13PM +0300, Avi Kivity wrote:
>>   On 07/29/2010 03:11 PM, Gleb Natapov wrote:
>>> No need to update vcpu state since instruction is in the middle of the
>>> emulation.
>>>
>>> Signed-off-by: Gleb Natapov<gleb <at> redhat.com>
>>> ---
>>>   arch/x86/kvm/x86.c |   31 +++++++++++++------------------
>>>   1 files changed, 13 insertions(+), 18 deletions(-)
>>>
>>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>>> index 76fbc32..7e5f075 100644
>>> --- a/arch/x86/kvm/x86.c
>>> +++ b/arch/x86/kvm/x86.c
>>>  <at>  <at>  -4057,32 +4057,27  <at>  <at>  restart:
>>>   		return handle_emulation_failure(vcpu);
>>>   	}
>>>
>>> -	toggle_interruptibility(vcpu, vcpu->arch.emulate_ctxt.interruptibility);
>>> -	kvm_x86_ops->set_rflags(vcpu, vcpu->arch.emulate_ctxt.eflags);
>>> -	memcpy(vcpu->arch.regs, c->regs, sizeof c->regs);
>>> -	kvm_rip_write(vcpu, vcpu->arch.emulate_ctxt.eip);
>>> +	r = EMULATE_DONE;
>>>
>>> -	if (vcpu->arch.emulate_ctxt.exception>= 0) {
>>> +	if (vcpu->arch.emulate_ctxt.exception>= 0)
>>>   		inject_emulated_exception(vcpu);
>>> -		return EMULATE_DONE;
>>> -	}
(Continue reading)

Gleb Natapov | 1 Aug 2010 11:01
Picon
Favicon

Re: [PATCH 1/2] KVM: x86 emulator: don't update vcpu state if instruction is restarted.

On Sun, Aug 01, 2010 at 11:54:38AM +0300, Avi Kivity wrote:
>  On 08/01/2010 11:28 AM, Gleb Natapov wrote:
> >On Sat, Jul 31, 2010 at 08:25:13PM +0300, Avi Kivity wrote:
> >>  On 07/29/2010 03:11 PM, Gleb Natapov wrote:
> >>>No need to update vcpu state since instruction is in the middle of the
> >>>emulation.
> >>>
> >>>Signed-off-by: Gleb Natapov<gleb <at> redhat.com>
> >>>---
> >>>  arch/x86/kvm/x86.c |   31 +++++++++++++------------------
> >>>  1 files changed, 13 insertions(+), 18 deletions(-)
> >>>
> >>>diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> >>>index 76fbc32..7e5f075 100644
> >>>--- a/arch/x86/kvm/x86.c
> >>>+++ b/arch/x86/kvm/x86.c
> >>> <at>  <at>  -4057,32 +4057,27  <at>  <at>  restart:
> >>>  		return handle_emulation_failure(vcpu);
> >>>  	}
> >>>
> >>>-	toggle_interruptibility(vcpu, vcpu->arch.emulate_ctxt.interruptibility);
> >>>-	kvm_x86_ops->set_rflags(vcpu, vcpu->arch.emulate_ctxt.eflags);
> >>>-	memcpy(vcpu->arch.regs, c->regs, sizeof c->regs);
> >>>-	kvm_rip_write(vcpu, vcpu->arch.emulate_ctxt.eip);
> >>>+	r = EMULATE_DONE;
> >>>
> >>>-	if (vcpu->arch.emulate_ctxt.exception>= 0) {
> >>>+	if (vcpu->arch.emulate_ctxt.exception>= 0)
> >>>  		inject_emulated_exception(vcpu);
> >>>-		return EMULATE_DONE;
(Continue reading)

Avi Kivity | 1 Aug 2010 11:14
Picon
Favicon

Re: [PATCH 1/2] KVM: x86 emulator: don't update vcpu state if instruction is restarted.

  On 08/01/2010 12:01 PM, Gleb Natapov wrote:
>>>
>>> It uses rip _during_ pio. And pio emulation changes rip
>>> only at the end of emulation.
>> But non-emulated pio does a skip_emulated_instruction() immediately
>> (or so the code in kvm-tpr-opt.c assumes:
>>
> Indeed, this is bug in non-emulated pio.

But userspace depends on this bug.

> But the patch does not change
> rip behaviour for emulated pio. vcpu->arch.emulate_ctxt.eip is updated
> only at the end of emulation.

That will lead to failures if the emulator is used for the kvm-tpr-opt 
pio (which may happen with big real mode).

--

-- 
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Gleb Natapov | 1 Aug 2010 11:24
Picon
Favicon

Re: [PATCH 1/2] KVM: x86 emulator: don't update vcpu state if instruction is restarted.

On Sun, Aug 01, 2010 at 12:14:40PM +0300, Avi Kivity wrote:
>  On 08/01/2010 12:01 PM, Gleb Natapov wrote:
> >>>
> >>>It uses rip _during_ pio. And pio emulation changes rip
> >>>only at the end of emulation.
> >>But non-emulated pio does a skip_emulated_instruction() immediately
> >>(or so the code in kvm-tpr-opt.c assumes:
> >>
> >Indeed, this is bug in non-emulated pio.
> 
> But userspace depends on this bug.
We can fix that, or make it smarter. Look for io instruction at
rip/rip-2 and use rip accordingly for instance.

> 
> >But the patch does not change
> >rip behaviour for emulated pio. vcpu->arch.emulate_ctxt.eip is updated
> >only at the end of emulation.
> 
> That will lead to failures if the emulator is used for the
> kvm-tpr-opt pio (which may happen with big real mode).
> 
IIRC it was always this way in emulator. I'd rather fix userspace than
break emulator.

--
			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo <at> vger.kernel.org
(Continue reading)

Avi Kivity | 1 Aug 2010 12:00
Picon
Favicon

Re: [PATCH 1/2] KVM: x86 emulator: don't update vcpu state if instruction is restarted.

  On 08/01/2010 12:24 PM, Gleb Natapov wrote:
> On Sun, Aug 01, 2010 at 12:14:40PM +0300, Avi Kivity wrote:
>>   On 08/01/2010 12:01 PM, Gleb Natapov wrote:
>>>>> It uses rip _during_ pio. And pio emulation changes rip
>>>>> only at the end of emulation.
>>>> But non-emulated pio does a skip_emulated_instruction() immediately
>>>> (or so the code in kvm-tpr-opt.c assumes:
>>>>
>>> Indeed, this is bug in non-emulated pio.
>> But userspace depends on this bug.
> We can fix that, or make it smarter. Look for io instruction at
> rip/rip-2 and use rip accordingly for instance.

That requires everyone to update, or suffer major breakage.

>>> But the patch does not change
>>> rip behaviour for emulated pio. vcpu->arch.emulate_ctxt.eip is updated
>>> only at the end of emulation.
>> That will lead to failures if the emulator is used for the
>> kvm-tpr-opt pio (which may happen with big real mode).
>>
> IIRC it was always this way in emulator. I'd rather fix userspace than
> break emulator.

It wasn't a problem because the emulator wasn't (and still isn't) used 
for this.  But it has the potential to break badly once we make 
emulate_invalid_guest_state=1 the default.

--

-- 
error compiling committee.c: too many arguments to function
(Continue reading)

Gleb Natapov | 1 Aug 2010 12:53
Picon
Favicon

Re: [PATCH 1/2] KVM: x86 emulator: don't update vcpu state if instruction is restarted.

On Sun, Aug 01, 2010 at 01:00:11PM +0300, Avi Kivity wrote:
>  On 08/01/2010 12:24 PM, Gleb Natapov wrote:
> >On Sun, Aug 01, 2010 at 12:14:40PM +0300, Avi Kivity wrote:
> >>  On 08/01/2010 12:01 PM, Gleb Natapov wrote:
> >>>>>It uses rip _during_ pio. And pio emulation changes rip
> >>>>>only at the end of emulation.
> >>>>But non-emulated pio does a skip_emulated_instruction() immediately
> >>>>(or so the code in kvm-tpr-opt.c assumes:
> >>>>
> >>>Indeed, this is bug in non-emulated pio.
> >>But userspace depends on this bug.
> >We can fix that, or make it smarter. Look for io instruction at
> >rip/rip-2 and use rip accordingly for instance.
> 
> That requires everyone to update, or suffer major breakage.
> 
They will suffer major breakage when they update to a kvm that calls to
kvm-tpr-opt.c from emulator anyway.

> >>>But the patch does not change
> >>>rip behaviour for emulated pio. vcpu->arch.emulate_ctxt.eip is updated
> >>>only at the end of emulation.
> >>That will lead to failures if the emulator is used for the
> >>kvm-tpr-opt pio (which may happen with big real mode).
> >>
> >IIRC it was always this way in emulator. I'd rather fix userspace than
> >break emulator.
> 
> It wasn't a problem because the emulator wasn't (and still isn't)
> used for this.  But it has the potential to break badly once we make
(Continue reading)

Avi Kivity | 1 Aug 2010 14:17
Picon
Favicon

Re: [PATCH 1/2] KVM: x86 emulator: don't update vcpu state if instruction is restarted.

  On 08/01/2010 01:53 PM, Gleb Natapov wrote:
>
>> That requires everyone to update, or suffer major breakage.
>>
> They will suffer major breakage when they update to a kvm that calls to
> kvm-tpr-opt.c from emulator anyway.

Why?

>>> IIRC it was always this way in emulator. I'd rather fix userspace than
>>> break emulator.
>> It wasn't a problem because the emulator wasn't (and still isn't)
>> used for this.  But it has the potential to break badly once we make
>> emulate_invalid_guest_state=1 the default.
>>
> So what can we do about it?
>

Keep the existing behaviour.

--

-- 
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Gmane