From: Shuai Ruan Subject: Re: [V8 2/4] x86/xsaves: enable xsaves/xrstors/xsavec in xen Date: Tue, 27 Oct 2015 17:01:27 +0800 Message-ID: <33872.9813033298$1445936601@news.gmane.org> References: <1445593701-5300-1-git-send-email-shuai.ruan@linux.intel.com> <1445593701-5300-3-git-send-email-shuai.ruan@linux.intel.com> <562E40DB02000078000AEA42@prv-mh.provo.novell.com> <20151027010626.GA13229@shuai.ruan@linux.intel.com> <562F401F02000078000AEF02@prv-mh.provo.novell.com> Reply-To: Shuai Ruan Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <562F401F02000078000AEF02@prv-mh.provo.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: kevin.tian@intel.com, wei.liu2@citrix.com, Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, xen-devel@lists.xen.org, jun.nakajima@intel.com, keir@xen.org List-Id: xen-devel@lists.xenproject.org On Tue, Oct 27, 2015 at 02:13:03AM -0600, Jan Beulich wrote: > >> > + > >> > + ((struct xsave_struct *)dest)->xsave_hdr.xstate_bv = xstate_bv; > >> > + ((struct xsave_struct *)dest)->xsave_hdr.xcomp_bv = 0; > >> > >> Wouldn't it be more logical to also memcpy() the header? Which > >> would do away with at least one of these ugly casts, would > >> allow folding with the memcpy() done right before, _and_ would > >> eliminate an (apparent or real I'm not sure without looking in > >> more detail) information leak (the remainder of the header). > >> > > For machine with no-xsaves support, xcomp_bv should be zero or it will cause > > GP fault. So we can not just memcpy the header when perform save. > > See how I limited my reply by saying "at least one", which I added > after realizing that fact? IOW I'd expect you to use memcpy() and > then only zero that one field. Or you'd memset() the whole header > to zero, and then only store xstate_bv. As said, otherwise it looks > like you're adding an information leak. > > Jan Ok And sorry for misunderstanding your meaning. > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel >