Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5353C433DF for ; Tue, 4 Aug 2020 14:46:44 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BEF382086A for ; Tue, 4 Aug 2020 14:46:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="fJkEx+Ps" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BEF382086A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k2yCs-0006nL-Ay; Tue, 04 Aug 2020 14:46:22 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k2yCq-0006nG-Ki for xen-devel@lists.xenproject.org; Tue, 04 Aug 2020 14:46:20 +0000 X-Inumbo-ID: 58a3ea34-5590-469c-92f7-2325a1158269 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 58a3ea34-5590-469c-92f7-2325a1158269; Tue, 04 Aug 2020 14:46:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1596552379; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=Nq19iTNJmoNA2xjrkYq5ivLgI2YhtNvzGmirNBmBNso=; b=fJkEx+PsQ43Y/v1Pjd/yc3Fm8PBUL08fft4bjm6ufihMZCTAPnnBXPSA xk5DhnzRYr/Riv5ojbI59ZPNDOwJh9g34QhuQTORDUmW8eMknh7OdfKYd mjBsHPD8p9wimc89WZ5p26dUS5xyuv7o6AM/JH4R3CEX/0pPcIHoT/IDG Y=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: beRNKA3wdJ5hUdlqiUrNMXJuSmfctF21FctbsPOZor/2dTnkJFl39VCUnyFmuYVuDS8fJP6etC Usiv4Gz3wF+ovQV6ZjWqznQkoHgC73nubS2qOAYx7QCqH83Q81Pt5q871MgY4IUqZ5nGkHTf3R FDNrrzgJ2mGTv6tmrFX6QR0Bmagtoo1NE4L0lyq1nFCiaMKhXZQOUMi/48fuUDzVhrWbu8vpyL Rh7PTEO5Wks5Zij9aYxnTGGoxVTTOqI1i3qbLmUK6OPJ8pJv4uWEE29kiGiAB05neAk9HGldJS B+0= X-SBRS: 3.7 X-MesageID: 23809598 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.75,434,1589256000"; d="scan'208";a="23809598" Subject: Re: [PATCH] x86emul: further FPU env testing relaxation for AMD-like CPUs To: Jan Beulich , "xen-devel@lists.xenproject.org" References: From: Andrew Cooper Message-ID: <91e628c6-cbbc-2023-51be-674de4901704@citrix.com> Date: Tue, 4 Aug 2020 15:46:13 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Language: en-GB X-ClientProxiedBy: AMSPEX02CAS02.citrite.net (10.69.22.113) To AMSPEX02CL02.citrite.net (10.69.22.126) X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On 04/08/2020 10:36, Jan Beulich wrote: > See the code comment that's being extended. Additionally a few more > zap_fpsel() invocations are needed - whenever we stored state after > there potentially having been a context switch behind our backs. > > Reported-by: Andrew Cooper > Signed-off-by: Jan Beulich Acked-by: Andrew Cooper Tested-by: Andrew Cooper > > --- a/tools/tests/x86_emulator/test_x86_emulator.c > +++ b/tools/tests/x86_emulator/test_x86_emulator.c > @@ -752,6 +752,13 @@ static struct x86_emulate_ops emulops = > * 64-bit OSes may not (be able to) properly restore the two selectors in > * the FPU environment. Zap them so that memcmp() on two saved images will > * work regardless of whether a context switch occurred in the middle. > + * > + * Additionally on AMD-like CPUs FDP/FIP/FOP may get lost across context > + * switches, when there's no unmasked pending FP exception: With I think you want a full stop rather than a colon, and ... > + * CPUID[80000008].EBX[2] clear, the fields don't get written/read by > + * {F,}XSAVE / {F,}XRSTOR, which OSes often compensate for by invoking an > + * insn forcing the fields to gain a deterministic value. Whereas with said ... a comma here rather than a full stop. Having "whereas" at the beginning of a sentence like this is weird, given that you're contrasting the behaviour of the CPUID bit. Also, the more usual CPUID syntax would be CPUID.0x80000008.EBX[2]. ~Andrew > + * bit set, zeroes will get written (and hence later restored). > */ > static void zap_fpsel(unsigned int *env, bool is_32bit) > { >