From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xiao Guangrong Subject: Re: [PATCH 2/9] KVM: x86: simplify read_emulated Date: Fri, 20 Jul 2012 10:17:36 +0800 Message-ID: <5008BFC0.4070703@linux.vnet.ibm.com> References: <50056DB8.7080702@linux.vnet.ibm.com> <50056DE6.6020801@linux.vnet.ibm.com> <20120719235828.GA7121@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Avi Kivity , LKML , KVM To: Marcelo Tosatti Return-path: Received: from e28smtp05.in.ibm.com ([122.248.162.5]:49885 "EHLO e28smtp05.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752589Ab2GTCRo (ORCPT ); Thu, 19 Jul 2012 22:17:44 -0400 Received: from /spool/local by e28smtp05.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 20 Jul 2012 07:47:40 +0530 In-Reply-To: <20120719235828.GA7121@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: On 07/20/2012 07:58 AM, Marcelo Tosatti wrote: >> - } >> + rc = ctxt->ops->read_emulated(ctxt, addr, mc->data + mc->end, size, >> + &ctxt->exception); >> + if (rc != X86EMUL_CONTINUE) >> + return rc; >> + >> + mc->end += size; >> + >> +read_cached: >> + memcpy(dest, mc->data + mc->pos, size); > > What prevents read_emulated(size > 8) call, with > mc->pos == (mc->end - 8) now? Marcelo, The splitting has been done in emulator_read_write_onepage: while (bytes) { unsigned now = min(bytes, 8U); frag = &vcpu->mmio_fragments[vcpu->mmio_nr_fragments++]; frag->gpa = gpa; frag->data = val; frag->len = now; frag->write_readonly_mem = (ret == -EPERM); gpa += now; val += now; bytes -= now; } So i think it is safe to remove the splitting in read_emulated.