From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH] KVM: mark segments accessed on HW task switch Date: Mon, 25 Jan 2010 16:22:37 +0200 Message-ID: <20100125142237.GF8483@redhat.com> References: <20100125100104.GA4609@redhat.com> <4B5D7B9D.7080401@redhat.com> <20100125111109.GA8483@redhat.com> <4B5D7CA4.5070605@redhat.com> <20100125122419.GB8483@redhat.com> <4B5D9435.2010707@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: mtosatti@redhat.com, kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from mx1.redhat.com ([209.132.183.28]:34418 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752351Ab0AYOWi (ORCPT ); Mon, 25 Jan 2010 09:22:38 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o0PEMcXA024263 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 25 Jan 2010 09:22:38 -0500 Content-Disposition: inline In-Reply-To: <4B5D9435.2010707@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, Jan 25, 2010 at 02:53:09PM +0200, Avi Kivity wrote: > On 01/25/2010 02:24 PM, Gleb Natapov wrote: > >On Mon, Jan 25, 2010 at 01:12:36PM +0200, Avi Kivity wrote: > >>On 01/25/2010 01:11 PM, Gleb Natapov wrote: > >>>On Mon, Jan 25, 2010 at 01:08:13PM +0200, Avi Kivity wrote: > >>>>On 01/25/2010 12:01 PM, Gleb Natapov wrote: > >>>>>On HW task switch newly loaded segments should me marked as accessed. > >>>>> > >>>>>@@ -4775,6 +4766,11 @@ int kvm_load_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, > >>>>> kvm_seg.unusable = 1; > >>>>> > >>>>> kvm_set_segment(vcpu,&kvm_seg, seg); > >>>>>+ if (selector&& !kvm_seg.unusable&& kvm_seg.s) { > >>>>>+ /* mark segment as accessed */ > >>>>>+ seg_desc.type |= 1; > >>>>>+ save_guest_segment_descriptor(vcpu, selector,&seg_desc); > >>>>>+ } > >>>>> return 0; > >>>>> } > >>>>What about an error return from s_g_s_d? > >>>> > >>>What can or should we do about it? > >>> > >>If -EFAULT, propagate to userspace. > >> > >We don't handle it anywhere in task switch emulation. Separate patch? > > > > Things like 'return kvm_write_guest_virt()' do handle it. > That what save_guest_segment_descriptor() calls, but error is not propagated to userspace anywhere in the task switch code. Lets apply this patch and I'll send follow up with fixes for error handling in task switch code. -- Gleb.