public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Avi Kivity <avi@qumranet.com>
Cc: kvm-devel <kvm@vger.kernel.org>
Subject: Re: RFC: cache_regs in kvm_emulate_pio
Date: Thu, 26 Jun 2008 11:52:43 -0300	[thread overview]
Message-ID: <20080626145243.GB14336@dmt.cnet> (raw)
In-Reply-To: <48635ECF.7030601@qumranet.com>

On Thu, Jun 26, 2008 at 12:18:07PM +0300, Avi Kivity wrote:
>
>>   static int set_guest_debug(struct kvm_vcpu *vcpu, struct 
>> kvm_debug_guest *dbg)
>> @@ -2370,22 +2379,18 @@ static int handle_cr(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
>>  			    (u32)((u64)vcpu->arch.regs[reg] >> 32), handler);
>>  		switch (cr) {
>>  		case 0:
>> -			vcpu_load_rsp_rip(vcpu);
>>  			kvm_set_cr0(vcpu, vcpu->arch.regs[reg]);
>>   
>
> What if reg points at rsp? You need to replace arch.regs[*] with the  
> accessor.

Catch!

>> @@ -2865,6 +2904,8 @@ again:
>>  	local_irq_enable();
>>   	++vcpu->stat.exits;
>> +	vcpu->arch.regs_available = KVM_CACHED_REGS;
>> +	vcpu->arch.regs_dirty = 0;
>>   
>
> How can you have a constant for this? Each subarch has different cached  
> regs. This ought to be set in $subarch_vcpu_run.

This is the intersection of registers cached by both architectures. But
I agree that moving it down to subarch code is saner.

>> diff --git a/include/asm-x86/kvm_host.h b/include/asm-x86/kvm_host.h
>> index 851184d..cc5c94b 100644
>> --- a/include/asm-x86/kvm_host.h
>> +++ b/include/asm-x86/kvm_host.h
>> @@ -87,7 +87,7 @@ extern struct list_head vm_list;
>>  struct kvm_vcpu;
>>  struct kvm;
>>  -enum {
>> +enum kvm_reg {
>>  	VCPU_REGS_RAX = 0,
>>  	VCPU_REGS_RCX = 1,
>>  	VCPU_REGS_RDX = 2,
>> @@ -106,9 +106,21 @@ enum {
>>  	VCPU_REGS_R14 = 14,
>>  	VCPU_REGS_R15 = 15,
>>  #endif
>> +	VCPU_REGS_RIP = 16,
>>  	NR_VCPU_REGS
>>  };
>>   
>
> No, rip is not a GPR.

We need the RIP index to be part of the kvm_reg space (to index in the
dirty/available bitmaps). Otherwise you have to special case it.

Sure it is not a GPR, but what is the problem storing RIP in regs array
instead of a separate variable ?

> Perhaps we ought to have a guest_rip_read() since rip is not truly a GPR.

#define kvm_guest_read_rip(vcpu) kvm_guest_register_read(vcpu, VCPU_REGS_RIP)

?

Will fix the remaining comments.

  reply	other threads:[~2008-06-26 14:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-21 19:46 RFC: cache_regs in kvm_emulate_pio Marcelo Tosatti
2008-06-22  5:16 ` Avi Kivity
2008-06-22 18:05   ` Marcelo Tosatti
2008-06-24 19:33   ` Marcelo Tosatti
2008-06-26  9:18     ` Avi Kivity
2008-06-26 14:52       ` Marcelo Tosatti [this message]
2008-06-26 22:15       ` Marcelo Tosatti
2008-06-27  2:28         ` Marcelo Tosatti
  -- strict thread matches above, loose matches on Subject: below --
2008-06-19 23:31 Marcelo Tosatti
2008-06-20 20:30 ` Avi Kivity
2008-06-20 21:24   ` Marcelo Tosatti
2008-06-21  7:04     ` Avi Kivity

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=20080626145243.GB14336@dmt.cnet \
    --to=mtosatti@redhat.com \
    --cc=avi@qumranet.com \
    --cc=kvm@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox