From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xiao Guangrong Subject: Re: [PATCH v2 05/22] KVM: x86: abstract the operation for read/write emulation Date: Wed, 29 Jun 2011 18:59:00 +0800 Message-ID: <4E0B0574.4010008@cn.fujitsu.com> References: <4E01FBC9.3020009@cn.fujitsu.com> <4E01FC78.6060000@cn.fujitsu.com> <4E0AE457.7010507@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , LKML , KVM To: Avi Kivity Return-path: In-Reply-To: <4E0AE457.7010507@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 06/29/2011 04:37 PM, Avi Kivity wrote: >> +struct read_write_emulator_ops { >> + int (*read_write_prepare)(struct kvm_vcpu *vcpu, void *val, >> + int bytes); >> + int (*read_write_emulate)(struct kvm_vcpu *vcpu, gpa_t gpa, >> + void *val, int bytes); >> + int (*read_write_mmio)(struct kvm_vcpu *vcpu, gpa_t gpa, >> + int bytes, void *val); >> + int (*read_write_exit_mmio)(struct kvm_vcpu *vcpu, gpa_t gpa, >> + void *val, int bytes); >> + bool write; >> +}; > > > Interesting! > > This structure combines two unrelated operations, though. One is the internals of the iteration on a virtual address that is split to various physical addresses. The other is the interaction with userspace on mmio exits. They should be split, but I think it's fine to do it in a later patch. This series is long enough already. > > I was also annoyed by the duplication. They way I thought of fixing it is having gva_to_gpa() return two gpas, and having the access function accept gpa vectors. The reason was so that we can implemented locked cross-page operations (which we now emulate as unlocked writes). > > But I think we can do without it, and instead emulated locked cross-page ops by stalling all other vcpus while we write, or by unmapping the pages involved. It isn't pretty but it doesn't need to be fast since it's a very rare operation. So I think we can go with your approach. > OK, i'll post it in the separate patchset, thanks, Avi.