From nobody Wed May 1 02:01:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1669884973; cv=none; d=zohomail.com; s=zohoarc; b=gXrgPaysJM+aITyN7fvk2z6vWa20GkvsuRV4UgaYiEhsBMdud4NsweGakp3T3RbjtFC5MJDzqkj5UbhNTwuCN87Pg2nKIVcKL+QQV+XzdwtMtjGIBXJjft0lxuGQmWovo4CUEdBTn1ZlORUSXfpKigqoUwd2paoR/eGUN1YI6Bg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669884973; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tW86kQAl/mD7xeEeaZttAb+GxpvwXAcNlfgGDQU1u1w=; b=B1seO+8ijtZZOT99xEZLmguKHOd5uW8gL+YEMvAaX3B6ws60DGBhKPJELHiPE8Hb6qKLnBrrDd7m/15RmXCtBTZ0DCQ0+hYTl8nRgcDyV3QrKaOh0RWl3lfS71PHNsdCieGOoHTHq8k2ADRTc95yHUEnYcGmOHRLnFZNka8jh9Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1669884973989391.18898813727094; Thu, 1 Dec 2022 00:56:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0fLK-0002fo-T5; Thu, 01 Dec 2022 03:54:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0fLC-0002dY-1i for qemu-devel@nongnu.org; Thu, 01 Dec 2022 03:54:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0fKt-0003f5-Vt for qemu-devel@nongnu.org; Thu, 01 Dec 2022 03:54:41 -0500 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-626-5EZ_oiLAMfOr84PPO9E2mg-1; Thu, 01 Dec 2022 03:54:25 -0500 Received: by mail-ej1-f69.google.com with SMTP id hc41-20020a17090716a900b007c07a5fc017so912800ejc.9 for ; Thu, 01 Dec 2022 00:54:25 -0800 (PST) Received: from avogadro.local ([2001:b07:6468:f312:e3ec:5559:7c5c:1928]) by smtp.gmail.com with ESMTPSA id sb25-20020a1709076d9900b007ae4717bef1sm1553775ejc.15.2022.12.01.00.54.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 00:54:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669884867; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tW86kQAl/mD7xeEeaZttAb+GxpvwXAcNlfgGDQU1u1w=; b=dMBfumpQ7pNx/8+YDnuZHl06s99KHOF2g9/eiVmhWbjE6AUW2z4QeMpxBBhglY0ovElDMk yCSZ07MnBZdEgY4HRnHJoYghbLKf0G4pTZMGEu+NQYFn7EwVMbXqUCO/MBpScjC3pEg29U oPNG9NnlqwRVJzwtZW8NcnleQweSjUM= X-MC-Unique: 5EZ_oiLAMfOr84PPO9E2mg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tW86kQAl/mD7xeEeaZttAb+GxpvwXAcNlfgGDQU1u1w=; b=pJSTznk2PRkrUI/+UdYWFrvE1DL6jp1bskAo/VBkwc9itjfItIrPc2kR7hJ2o53E+i h2w0bhKfJFL3KxfPRU2iT0ha9U6CQsHMJZIIjMwOlC8qP9hGFB1VVnqMIl8meZFEpW+8 Ju14mvBPiizk5i8ss2iLL73k61RC+LTeERPR2eJypBaYtqzlb/RFQsUBbTBXXqVbcjIM UYRw6uJzYXISmxjQPvx9RqLF9PvsSN7uY5aFiolKVtQhhsUJ9USwDnMYgAxhcclMKr5V Fq5GPXrv6/yxMbCROQIwxeg3igO5pVddC46lNqthqC8kWTajmsJ9MXIVO8YKZyZ0TxDs Wd9g== X-Gm-Message-State: ANoB5pkKypiFCtaR9/Ewz/X8kymZRyZIBVbxdJ9cGrpMzdtC6N89fPdV L6aVwpsjpStQjACRAn9T5pfN1URkdURcm+LXEvAt2N5G4nqzMBk+rGDJwuawr52sa7VO+/9w6fS QnpmJx0qiMAFaDbS1HcNM9kv/3YtVogYpsgTMCEVpu3HrHUJLqz23s3yNBrafL1Spvxk= X-Received: by 2002:a17:906:395:b0:7a0:b505:e8fb with SMTP id b21-20020a170906039500b007a0b505e8fbmr10013490eja.281.1669884864240; Thu, 01 Dec 2022 00:54:24 -0800 (PST) X-Google-Smtp-Source: AA0mqf7IjWlvSe/H1RGQ/a+knOAjC8ovYecQ7p+r2szlP/wvh5DCg6x9TcdLOTB0rsgRUTuo04mnaQ== X-Received: by 2002:a17:906:395:b0:7a0:b505:e8fb with SMTP id b21-20020a170906039500b007a0b505e8fbmr10013466eja.281.1669884863897; Thu, 01 Dec 2022 00:54:23 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 1/2] target/i386: allow MMX instructions with CR4.OSFXSR=0 Date: Thu, 1 Dec 2022 09:54:18 +0100 Message-Id: <20221201085419.146789-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221201085419.146789-1-pbonzini@redhat.com> References: <20221201085419.146789-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1669884975463100003 Content-Type: text/plain; charset="utf-8" MMX state is saved/restored by FSAVE/FRSTOR so the instructions are not illegal opcodes even if CR4.OSFXSR=3D0. Make sure that validate_vex takes into account the prefix and only checks HF_OSFXSR_MASK in the presence of an SSE instruction. Fixes: 20581aadec5e ("target/i386: validate VEX prefixes via the instructio= ns' exception classes", 2022-10-18) Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1350 Reported-by: Helge Konetzka (@hejko on gitlab.com) Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.c.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index e4878b967f0e..80c579164ff2 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -1488,7 +1488,8 @@ static bool validate_vex(DisasContext *s, X86DecodedI= nsn *decode) if (!(s->flags & HF_AVX_EN_MASK)) { goto illegal; } - } else { + } else if (e->special !=3D X86_SPECIAL_MMX || + (s->prefix & (PREFIX_REPZ | PREFIX_REPNZ | PREFIX_DATA)= )) { if (!(s->flags & HF_OSFXSR_MASK)) { goto illegal; } --=20 2.38.1 From nobody Wed May 1 02:01:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1669884959; cv=none; d=zohomail.com; s=zohoarc; b=mO5fp0K/0DR1rtD/Eg2Yo9Yp1hZrQaspDs2O5yyYEQ9YRI4uEFYlcD9KSQm5jTXhN4QFfaGo93AFl7nwchZZAuFfmabSe6VEV7e2pE4p2v2BBKW8a8HKCvoA1ZjL/xj81a2jozZZDP5oeEn3sVj25mt36r81Ei4Spx8wPbrEUSs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669884959; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sc9apsk13PK2+ozugtSAH9pSS99PC+V0tvFuiyMctzg=; b=bRTFZm6y+GL/r44dHToiwUypIT/yhv8xaeeUXtZRE/ZaxHyA1w88xG22MMrtr7ncH3q/Yd+kFcsruBOhqzqKEC7nw1Z89uCVD8xSgwfkDnesLSWixCHr3wxBu3rE9FwIuf0Ki3SNFyAcDJcYLXbW70S3yBMgtWad58R/u1cbguc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1669884959827576.6160552855673; Thu, 1 Dec 2022 00:55:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0fLN-0002kQ-6s; Thu, 01 Dec 2022 03:54:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0fLL-0002gL-5k for qemu-devel@nongnu.org; Thu, 01 Dec 2022 03:54:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0fKx-0003fR-5Q for qemu-devel@nongnu.org; Thu, 01 Dec 2022 03:54:54 -0500 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-563-KeqkLjAONMmNPsBGeFFtWg-1; Thu, 01 Dec 2022 03:54:29 -0500 Received: by mail-ej1-f69.google.com with SMTP id gn36-20020a1709070d2400b007ba3374574dso893593ejc.23 for ; Thu, 01 Dec 2022 00:54:29 -0800 (PST) Received: from avogadro.local ([2001:b07:6468:f312:e3ec:5559:7c5c:1928]) by smtp.gmail.com with ESMTPSA id b23-20020a1709062b5700b007c0991735c0sm1524867ejg.79.2022.12.01.00.54.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 00:54:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669884870; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sc9apsk13PK2+ozugtSAH9pSS99PC+V0tvFuiyMctzg=; b=fHNlB9cqSQHnpfXRZlDLIVkc6aJqRsyFDSII6pjpqBCzx7gnZ1AEb0KUhukR5onSTm/vfX irdgBOL5+taid6hSI3rc2lqx1UakzlmlDMgg3NMGC1IJHIqQJja1nAmChF0YpE+lwVCjAx 3tsZmNxwQTP3oNyddjcLK8dwUsjGFys= X-MC-Unique: KeqkLjAONMmNPsBGeFFtWg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sc9apsk13PK2+ozugtSAH9pSS99PC+V0tvFuiyMctzg=; b=6Wls1bzKPVX26w4HNnB/TIzhDsGi8gcvkJ8QMn2upugDLN+xOhvOp+Z1JGnqivdEdq XRH0xXzZtFtuds7eOHsnaR5qVAJo7s5j5tzd3LbJMptc7Qb6N4XTsLuKSdjxNhQZJrAn q2CD1ulURRly3RIXa9IDV0AOD2qYv0mRYQZ/D3Jya0fq9ZEpA2P+vv9pIMpmOoeptm5f xzB2QTav1iQ4+6vCwSl/SlJmXyoJhI7Ow+AWpb54yHgzU/gloWqlIudDlsNFjSPUe+IK gG+QGIWFw50cTb67JzBU+eeUQ6CtpjbpooKibdBhRM0sHmeBl2LwH+qzBatz5cvxDYxk N2Aw== X-Gm-Message-State: ANoB5pntoXME6Y40qm5+LJOVMmyffq5TTq6AUP8tDAuvFa36+pJi34uA CK6G77Y1ZBzx//9L25JK2y9RHUEU8Na7wD/bvz2sIowx2YpWDeJBfN0V2vWQooI24E6+YkW1a4q sMZrZTnwZ6tDh2iaOZySGsXGqdCoPvYwAMjN9vehlAIaukzLZUWGX3VsklHDxawN3TE8= X-Received: by 2002:a05:6402:3642:b0:459:53dc:adc9 with SMTP id em2-20020a056402364200b0045953dcadc9mr1233520edb.166.1669884867678; Thu, 01 Dec 2022 00:54:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf4/pVAH7sPLcVCLu4l5lq6FPr+J4J9jG7K84hIynLweZOjYnnukR01Ms/zt5nsrdPF+JwrIOg== X-Received: by 2002:a05:6402:3642:b0:459:53dc:adc9 with SMTP id em2-20020a056402364200b0045953dcadc9mr1233510edb.166.1669884867361; Thu, 01 Dec 2022 00:54:27 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , Daniel Hoffman Subject: [PULL 2/2] target/i386: Always completely initialize TranslateFault Date: Thu, 1 Dec 2022 09:54:19 +0100 Message-Id: <20221201085419.146789-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221201085419.146789-1-pbonzini@redhat.com> References: <20221201085419.146789-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1669884961479100003 Content-Type: text/plain; charset="utf-8" From: Richard Henderson In get_physical_address, the canonical address check failed to set TranslateFault.stage2, which resulted in an uninitialized read from the struct when reporting the fault in x86_cpu_tlb_fill. Adjust all error paths to use structure assignment so that the entire struct is always initialized. Reported-by: Daniel Hoffman Fixes: 9bbcf372193a ("target/i386: Reorg GET_HPHYS") Signed-off-by: Richard Henderson Message-Id: <20221201074522.178498-1-richard.henderson@linaro.org> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1324 Signed-off-by: Paolo Bonzini --- target/i386/tcg/sysemu/excp_helper.c | 34 ++++++++++++++++------------ 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/target/i386/tcg/sysemu/excp_helper.c b/target/i386/tcg/sysemu/= excp_helper.c index 405a5d414a14..55bd1194d31b 100644 --- a/target/i386/tcg/sysemu/excp_helper.c +++ b/target/i386/tcg/sysemu/excp_helper.c @@ -71,10 +71,11 @@ static bool ptw_translate(PTETranslate *inout, hwaddr a= ddr) TranslateFault *err =3D inout->err; =20 assert(inout->ptw_idx =3D=3D MMU_NESTED_IDX); - err->exception_index =3D 0; /* unused */ - err->error_code =3D inout->env->error_code; - err->cr2 =3D addr; - err->stage2 =3D S2_GPT; + *err =3D (TranslateFault){ + .error_code =3D inout->env->error_code, + .cr2 =3D addr, + .stage2 =3D S2_GPT, + }; return false; } return true; @@ -431,10 +432,11 @@ do_check_protect_pse36: MMU_NESTED_IDX, true, &pte_trans.haddr, &full, 0); if (unlikely(flags & TLB_INVALID_MASK)) { - err->exception_index =3D 0; /* unused */ - err->error_code =3D env->error_code; - err->cr2 =3D paddr; - err->stage2 =3D S2_GPA; + *err =3D (TranslateFault){ + .error_code =3D env->error_code, + .cr2 =3D paddr, + .stage2 =3D S2_GPA, + }; return false; } =20 @@ -494,10 +496,11 @@ do_check_protect_pse36: } break; } - err->exception_index =3D EXCP0E_PAGE; - err->error_code =3D error_code; - err->cr2 =3D addr; - err->stage2 =3D S2_NONE; + *err =3D (TranslateFault){ + .exception_index =3D EXCP0E_PAGE, + .error_code =3D error_code, + .cr2 =3D addr, + }; return false; } =20 @@ -564,9 +567,10 @@ static bool get_physical_address(CPUX86State *env, vad= dr addr, int shift =3D in.pg_mode & PG_MODE_LA57 ? 56 : 47; int64_t sext =3D (int64_t)addr >> shift; if (sext !=3D 0 && sext !=3D -1) { - err->exception_index =3D EXCP0D_GPF; - err->error_code =3D 0; - err->cr2 =3D addr; + *err =3D (TranslateFault){ + .exception_index =3D EXCP0D_GPF, + .cr2 =3D addr, + }; return false; } } --=20 2.38.1