From: Eduardo Habkost Subject: Re: [Qemu-devel] [for-2.6 PATCH 1/3] target-i386: Define structs for layout of xsave area Date: Tue, 1 Dec 2015 16:34:41 -0200 Message-ID: <20151201183441.GO23717@thinpad.lan.raisama.net> References: <1448740611-3096-1-git-send-email-ehabkost@redhat.com> <1448740611-3096-2-git-send-email-ehabkost@redhat.com> <565C3089.4070101@redhat.com> <565DD45B.3070505@twiddle.net> <20151201171550.GN23717@thinpad.lan.raisama.net> <565DD6E9.1040906@twiddle.net> <565DD875.7090108@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Richard Henderson , qemu-devel@nongnu.org, Huaitong Han , kvm@vger.kernel.org To: Paolo Bonzini Return-path: Received: from mx1.redhat.com ([209.132.183.28]:54916 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756148AbbLASeo (ORCPT ); Tue, 1 Dec 2015 13:34:44 -0500 Content-Disposition: inline In-Reply-To: <565DD875.7090108@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Dec 01, 2015 at 06:27:17PM +0100, Paolo Bonzini wrote: > On 01/12/2015 18:20, Richard Henderson wrote: > >> > >> X86XSaveArea will be used only when loading/saving state using > >> xsave, not for executing regular instructions. > > > > ... like the regular instruction xsave? > > > > https://patchwork.ozlabs.org/patch/493318/ > > Right, but that's a helper anyway. > > >> In X86CPU, the > >> data is already stored as XMMReg unions (the one with the > >> XMM_[BWDQ] helpers). > > > > Of course. But those unions are arranged to be in big-endian format on > > big-endian hosts. So we need to swap the data back to little-endian > > format for storage into guest memory. > > Yes, you can use byte moves with XMM_B (more obvious), or stq_le_p with > XMM_Q (faster I guess---though the compiler might optimize the former on > little-endian hosts). Either works with an uint8_t[] destination. stq_le_p() (more exactly, stq_p()) is exactly what is already done by kvm_{get,put}_xsave(), using uint8_t pointers. BTW, if we are going to implement xsave in TCG, the X86CPU<->xsave translation logic in kvm_{get,put}_xsave() could be moved to generic code and reused by TCG instead of being reimplemented. -- Eduardo