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=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,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 1F427C433E0 for ; Mon, 6 Jul 2020 15:14:43 +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 EB8D320715 for ; Mon, 6 Jul 2020 15:14:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EB8D320715 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.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 1jsSpB-00044O-Ba; Mon, 06 Jul 2020 15:14:29 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jsSp9-00044B-HM for xen-devel@lists.xenproject.org; Mon, 06 Jul 2020 15:14:27 +0000 X-Inumbo-ID: 61688384-bf9b-11ea-b7bb-bc764e2007e4 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 61688384-bf9b-11ea-b7bb-bc764e2007e4; Mon, 06 Jul 2020 15:14:26 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 553E7AAD0; Mon, 6 Jul 2020 15:14:26 +0000 (UTC) To: "xen-devel@lists.xenproject.org" From: Jan Beulich Subject: [PATCH] x86emul: fix FXRSTOR test for most AMD CPUs Message-ID: <29986a8f-47bf-43c2-98e9-e08c1c5925af@suse.com> Date: Mon, 6 Jul 2020 17:14:24 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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: Andrew Cooper , Paul Durrant , Wei Liu , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" AMD CPUs that we classify as X86_BUG_FPU_PTRS don't touch the selector/ offset portion of the save image during FXSAVE unless an unmasked exception is pending. Hence the selector zapping done between the initial FXSAVE and the emulated FXRSTOR needs to be mirrored onto the second FXSAVE, output of which gets fed into memcmp() to compare with the input image. Reported-by: Andrew Cooper Signed-off-by: Jan Beulich --- a/tools/tests/x86_emulator/test_x86_emulator.c +++ b/tools/tests/x86_emulator/test_x86_emulator.c @@ -2577,6 +2577,7 @@ int main(int argc, char **argv) regs.ecx = (unsigned long)(res + 0x81); rc = x86_emulate(&ctxt, &emulops); asm volatile ( "fxsave %0" : "=m" (res[0x100]) :: "memory" ); + zap_xfpsel(&res[0x100]); if ( (rc != X86EMUL_OKAY) || memcmp(res + 0x100, res + 0x80, 0x200) || (regs.eip != (unsigned long)&instr[4]) )