From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH 15/24] KVM: x86 emulator: Provide more callbacks for x86 emulator. Date: Tue, 9 Mar 2010 19:57:14 +0200 Message-ID: <20100309175714.GD9066@redhat.com> References: <1268143762-4000-1-git-send-email-gleb@redhat.com> <1268143762-4000-16-git-send-email-gleb@redhat.com> <4B965EAF.10505@redhat.com> <20100309162515.GC9066@redhat.com> <4B9683EB.8010806@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from mx1.redhat.com ([209.132.183.28]:54454 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754271Ab0CIR5Q (ORCPT ); Tue, 9 Mar 2010 12:57:16 -0500 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o29HvF8M025022 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 9 Mar 2010 12:57:15 -0500 Content-Disposition: inline In-Reply-To: <4B9683EB.8010806@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Mar 09, 2010 at 07:22:51PM +0200, Avi Kivity wrote: > On 03/09/2010 06:25 PM, Gleb Natapov wrote: > >On Tue, Mar 09, 2010 at 04:43:59PM +0200, Avi Kivity wrote: > >>On 03/09/2010 04:09 PM, Gleb Natapov wrote: > >>>Provide get_cached_descriptor(), set_cached_descriptor(), > >>>get_segment_selector(), set_segment_selector(), get_gdt(), > >>>write_std() callbacks. > >>> > >>>Signed-off-by: Gleb Natapov > >>>--- > >>> arch/x86/include/asm/kvm_emulate.h | 16 +++++ > >>> arch/x86/kvm/x86.c | 130 +++++++++++++++++++++++++++++++---- > >>> 2 files changed, 131 insertions(+), 15 deletions(-) > >>> > >>>diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h > >>>index 032d02f..e881618 100644 > >>>--- a/arch/x86/include/asm/kvm_emulate.h > >>>+++ b/arch/x86/include/asm/kvm_emulate.h > >>>@@ -63,6 +63,15 @@ struct x86_emulate_ops { > >>> unsigned int bytes, struct kvm_vcpu *vcpu, u32 *error); > >>> > >>> /* > >>>+ * write_std: Write bytes of standard (non-emulated/special) memory. > >>>+ * Used for descriptor writing. > >>>+ * @addr: [IN ] Linear address to which to write. > >>>+ * @val: [OUT] Value write to memory, zero-extended to 'u_long'. > >>>+ * @bytes: [IN ] Number of bytes to write to memory. > >>>+ */ > >>>+ int (*write_std)(unsigned long addr, void *val, > >>>+ unsigned int bytes, struct kvm_vcpu *vcpu, u32 *error); > >>Descriptor writes need an atomic kvm_set_guest_bit(), no? > >> > >It is? atomic against what? Current code just write whole descriptor > >using write_std(). > > These are accessed bit changes, and are done atomically in the same > way as a page table walk sets the accessed and dirty bit. > Presumably the atomic operation is to allow the kernel to scan > segments and swap them out if they are not used. > We can use cmpxchg callback for that, no? -- Gleb.