From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xiao Guangrong Subject: Re: [PATCH v4 28/33] nvdimm acpi: support DSM_FUN_IMPLEMENTED function Date: Wed, 21 Oct 2015 21:32:38 +0800 Message-ID: <562793F6.5090904@linux.intel.com> References: <1445216059-88521-1-git-send-email-guangrong.xiao@linux.intel.com> <1445216059-88521-29-git-send-email-guangrong.xiao@linux.intel.com> <20151020155149.GB2772@stefanha-thinkpad.home> <56266B3B.4080407@linux.intel.com> <20151021104937.GD13408@stefanha-thinkpad.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Stefan Hajnoczi , pbonzini@redhat.com, imammedo@redhat.com, gleb@kernel.org, mtosatti@redhat.com, mst@redhat.com, rth@twiddle.net, ehabkost@redhat.com, dan.j.williams@intel.com, kvm@vger.kernel.org, qemu-devel@nongnu.org To: Stefan Hajnoczi Return-path: Received: from mga02.intel.com ([134.134.136.20]:27743 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753731AbbJUNjF (ORCPT ); Wed, 21 Oct 2015 09:39:05 -0400 In-Reply-To: <20151021104937.GD13408@stefanha-thinkpad.redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 10/21/2015 06:49 PM, Stefan Hajnoczi wrote: > On Wed, Oct 21, 2015 at 12:26:35AM +0800, Xiao Guangrong wrote: >> >> >> On 10/20/2015 11:51 PM, Stefan Hajnoczi wrote: >>> On Mon, Oct 19, 2015 at 08:54:14AM +0800, Xiao Guangrong wrote: >>>> +exit: >>>> + /* Write our output result to dsm memory. */ >>>> + ((dsm_out *)dsm_ram_addr)->len =3D out->len; >>> >>> Missing byteswap? >>> >>> I thought you were going to remove this field because it wasn't nee= ded >>> by the guest. >>> >> >> The @len is the size of _DSM result buffer, for example, for the fun= ction of >> DSM_FUN_IMPLEMENTED the result buffer is 8 bytes, and for >> DSM_DEV_FUN_NAMESPACE_LABEL_SIZE the buffer size is 4 bytes. It tell= s ASL code >> how much size of memory we need to return to the _DSM caller. >> >> In _DSM code, it's handled like this: >> >> "RLEN" is @len, =E2=80=9COBUF=E2=80=9D is the left memory in DSM pag= e. >> >> /* get @len*/ >> aml_append(method, aml_store(aml_name("RLEN"), aml_local(6)= )); >> /* @len << 3 to get bits. */ >> aml_append(method, aml_store(aml_shiftleft(aml_local(6), >> aml_int(3)), aml_local(6))); >> >> /* get @len << 3 bits from OBUF, and return it to the calle= r. */ >> aml_append(method, aml_create_field(aml_name("ODAT"), aml_i= nt(0), >> aml_local(6) , "OBUF"))= ; >> >> Since @len is our internally used, it's not return to guest, so i di= d not do >> byteswap here. > > I am not familiar with the ACPI details, but I think this emits bytec= ode > that will be run by the guest's ACPI interpreter? > > You still need to define the endianness of fields since QEMU and the > guest could have different endianness. > > In other words, will the following work if a big-endian ppc host is > running a little-endian x86 guest? > > ((dsm_out *)dsm_ram_addr)->len =3D out->len; > Er... If we do byteswap in QEMU then it is also needed in ASL code, how= ever, ASL lacks this kind of instruction. I guess ACPI interpreter is smart = enough to change value to Littel-Endian for all 2 bytes / 4 bytes / 8 bytes ac= cesses I will do the change in next version, thanks for you pointing it out, S= tefan!