Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933626AbcKIOTq (ORCPT ); Wed, 9 Nov 2016 09:19:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56480 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933557AbcKIOTl (ORCPT ); Wed, 9 Nov 2016 09:19:41 -0500 Date: Wed, 9 Nov 2016 15:19:37 +0100 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Bandan Das , Nadav Amit Subject: Re: [PATCH v3 4/4] KVM: x86: emulate FXSAVE and FXRSTOR Message-ID: <20161109141937.GA32080@potion> References: <20161108195419.4607-1-rkrcmar@redhat.com> <20161108195419.4607-5-rkrcmar@redhat.com> <20161109121200.GA2128@potion> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20161109121200.GA2128@potion> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 09 Nov 2016 14:19:40 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1098 Lines: 27 2016-11-09 13:12+0100, Radim Krčmář: > 2016-11-09 00:25+0100, Paolo Bonzini: >> On 08/11/2016 20:54, Radim Krčmář wrote: >>> +static int em_fxsave(struct x86_emulate_ctxt *ctxt) >>> +{ >>> + struct fxregs_state fx_state; >>> + size_t size = 288; /* up to XMM7 */ >> >> Sorry for noticing this only now; if CR4.OSFXSR is 0, XMM and MXCSR >> should not be saved. > > Intel processors don't save it, but the spec allows saving even when > CR4.OSFXSR is 0: > > If the OSFXSR bit in control register CR4 is not set, the FXSAVE > instruction may not save this register (these registers). > This behavior is implementation dependent. > > I let "implementation dependent" behavior be the one with less code, but > haven't checked AMD spec, which doesn't seem to make it implementation > dependent ... I'll add it. (On intel, OSFXSR gets written with 0 and Nope, Intel always saves and restores MXCSR. I should have access to an AMD machine later today and will implement FXSR to match AMD. > XMM 0-7 isn't modified without OSFXSR, so I'll just assume that AMD > won't break with that.)