From: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: peterz@infradead.org, avi@redhat.com, raghukt@linux.vnet.ibm.com,
alex.shi@intel.com, mingo@elte.hu, kvm@vger.kernel.org,
hpa@zytor.com
Subject: Re: [PATCH v3 4/8] KVM-HV: Add VCPU running/pre-empted state for guest
Date: Sun, 05 Aug 2012 00:03:57 +0530 [thread overview]
Message-ID: <8739428q22.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <20120803173122.GA5905@amt.cnet>
On Fri, 3 Aug 2012 14:31:22 -0300, Marcelo Tosatti <mtosatti@redhat.com> wrote:
> On Fri, Aug 03, 2012 at 11:25:44AM +0530, Nikunj A Dadhania wrote:
> > On Thu, 2 Aug 2012 16:56:28 -0300, Marcelo Tosatti <mtosatti@redhat.com> wrote:
> > > >
> > > > + case MSR_KVM_VCPU_STATE:
> > > > + vcpu->arch.v_state.vs_page = gfn_to_page(vcpu->kvm, data >> PAGE_SHIFT);
> > > > + vcpu->arch.v_state.vs_offset = data & ~(PAGE_MASK | KVM_MSR_ENABLED);
> > >
> > > Assign vs_offset after success.
> > >
> > > > +
> > > > + if (is_error_page(vcpu->arch.v_state.vs_page)) {
> > > > + kvm_release_page_clean(vcpu->arch.time_page);
> > > > + vcpu->arch.v_state.vs_page = NULL;
> > > > + pr_info("KVM: VCPU_STATE - Unable to pin the page\n");
> > >
> > > Missing break or return;
> > >
> > > > + }
> > > > + vcpu->arch.v_state.msr_val = data;
> > > > + break;
> > > > +
> > > > case MSR_IA32_MCG_CTL:
> > >
> > > Please verify this code carefully again.
> > >
> > > Also leaking the page reference.
> > >
> > > > vcpu->arch.apf.msr_val = 0;
> > > > vcpu->arch.st.msr_val = 0;
> > > > + vcpu->arch.v_state.msr_val = 0;
> > >
> > > Add a newline and comment (or even better a new helper).
> > > >
> > > > kvmclock_reset(vcpu);
> > >
> >
> > How about something like the below. I have tried to look at time_page
> > for reference:
> >
> >
> > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> > index 580abcf..c82cc12 100644
> > --- a/arch/x86/kvm/x86.c
> > +++ b/arch/x86/kvm/x86.c
> > @@ -1604,6 +1604,16 @@ static void kvm_clear_vcpu_state(struct kvm_vcpu *vcpu)
> > kunmap_atomic(kaddr);
> > }
> >
> > +static void kvm_vcpu_state_reset(struct kvm_vcpu *vcpu)
> > +{
> > + vcpu->arch.v_state.msr_val = 0;
> > + vcpu->arch.v_state.vs_offset = 0;
> > + if (vcpu->arch.v_state.vs_page) {
> > + kvm_release_page_dirty(vcpu->arch.v_state.vs_page);
> > + vcpu->arch.v_state.vs_page = NULL;
> > + }
> > +}
> > +
> > int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
> > {
> > bool pr = false;
> > @@ -1724,14 +1734,17 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
> > break;
> >
> > case MSR_KVM_VCPU_STATE:
> > + kvm_vcpu_state_reset(vcpu);
> > +
> > vcpu->arch.v_state.vs_page = gfn_to_page(vcpu->kvm, data >> PAGE_SHIFT);
> > - vcpu->arch.v_state.vs_offset = data & ~(PAGE_MASK | KVM_MSR_ENABLED);
>
> Should also fail if its not enabled (KVM_MSR_ENABLED bit).
>
> What is the point of having non-NULL vs_page pointer if KVM_MSR_ENABLED
> bit is not set?
>
Yes, will do that.
> The rest is fine, thanks.
>
Thanks
Nikunj
next prev parent reply other threads:[~2012-08-04 18:34 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-31 10:47 [PATCH v3 0/8] KVM paravirt remote flush tlb Nikunj A. Dadhania
2012-07-31 10:47 ` [PATCH v3 1/8] mm, x86: Add HAVE_RCU_TABLE_FREE support Nikunj A. Dadhania
2012-07-31 10:48 ` [PATCH v3 2/8] mm: Add missing TLB invalidate to RCU page-table freeing Nikunj A. Dadhania
2012-07-31 10:48 ` [PATCH v3 3/8] KVM Guest: Add VCPU running/pre-empted state for guest Nikunj A. Dadhania
2012-07-31 10:48 ` [PATCH v3 4/8] KVM-HV: " Nikunj A. Dadhania
2012-08-02 19:56 ` Marcelo Tosatti
2012-08-03 5:17 ` Nikunj A Dadhania
2012-08-03 5:55 ` Nikunj A Dadhania
2012-08-03 17:31 ` Marcelo Tosatti
2012-08-04 18:33 ` Nikunj A Dadhania [this message]
2012-07-31 10:48 ` [PATCH v3 5/8] KVM Guest: Add paravirt kvm_flush_tlb_others Nikunj A. Dadhania
2012-07-31 10:49 ` [PATCH v3 6/8] KVM-HV: Add flush_on_enter before guest enter Nikunj A. Dadhania
2012-08-02 20:14 ` Marcelo Tosatti
2012-08-02 20:16 ` Marcelo Tosatti
2012-08-03 5:37 ` Nikunj A Dadhania
2012-08-03 17:31 ` Marcelo Tosatti
2012-07-31 10:49 ` [PATCH v3 7/8] Enable HAVE_RCU_TABLE_FREE for kvm when PARAVIRT_TLB_FLUSH is enabled Nikunj A. Dadhania
2012-07-31 10:49 ` [PATCH v3 8/8] KVM-doc: Add paravirt tlb flush document Nikunj A. Dadhania
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=8739428q22.fsf@linux.vnet.ibm.com \
--to=nikunj@linux.vnet.ibm.com \
--cc=alex.shi@intel.com \
--cc=avi@redhat.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mtosatti@redhat.com \
--cc=peterz@infradead.org \
--cc=raghukt@linux.vnet.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).