From patchwork Sun Jun 18 21:51:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1796275 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ewPUg2zI; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qkmny1NCYz20XZ for ; Mon, 19 Jun 2023 07:52:04 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qB0Iw-0002nl-Sh; Sun, 18 Jun 2023 17:51:26 -0400 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 1qB0Iv-0002nW-DZ for qemu-devel@nongnu.org; Sun, 18 Jun 2023 17:51:25 -0400 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 1qB0It-0006VO-U0 for qemu-devel@nongnu.org; Sun, 18 Jun 2023 17:51:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687125083; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lgxeCtFMSIiD02O7MZKA8Zu+VBfme7I0NGA2UZarPVQ=; b=ewPUg2zIxw+1tufK6WICvMXd1zo6dgGUlx5DRqqPpPndZG8FLRmJv1b/uc/hyAvnsHCY8h cJ9FMtMizf8flAMmCER1Zz1nwIRQyPlILP+fo5dWJa6Hmw4OPQyw/DE8MgQ2Z7+U/aHk15 FpSBKbMftkwHT0e0As6t2hEkvOuFLVQ= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-159-jiViesAxPmy4HOdwUCrLLQ-1; Sun, 18 Jun 2023 17:51:21 -0400 X-MC-Unique: jiViesAxPmy4HOdwUCrLLQ-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-988907e1b15so60644766b.3 for ; Sun, 18 Jun 2023 14:51:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687125080; x=1689717080; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lgxeCtFMSIiD02O7MZKA8Zu+VBfme7I0NGA2UZarPVQ=; b=GuDuntrPAR4vEuozjnPHE8zpAaC1rKobURG8PMJpRmfqif6fvkFhON3jUk39m/okbX hB1L6EcnBN4jUED9px58pbzeHkIeQyGwvqOOo2i2GU+ifPCV1HTDk6IOItl9buGGlARR F6ZJFmxIvJGos9u7SpPI+PjUDrv5LxvsoPtGMKnscubyvFEOYJV4xZQHma16ZOpVGlF5 HVGc6Qc900Apc9LwK9zjDrhrFd5xXKsFaYxupwUkA07BZz2hqL66nD9+ImLFxGszO74V BbcYS9OglGmfW3Nk/HhSqw4fsbbvuMmUsYvnRkxNtRngQKnjPYdtVjrsnksOC6K1/6fz p9RA== X-Gm-Message-State: AC+VfDwxmIJgKdCpmlv3vH6gPid2D7yocbJFHgVNjeqWi9c0Nbd+G9ns fcfQb8/TFESVls4HQacfd6Uu0okmO6SVbsW383p+TCPT7+jWAgmUk3WMSz7QYAzwS4qZGSjD9I8 vnPdPL3553DU1x83A9xSW/4OcC/ySaQ3UJ6ftP2tD+OCDe7s0VEovvpYlDoIzXQKuDc2lPv44Hr edig== X-Received: by 2002:a17:907:8a15:b0:988:acb4:f74 with SMTP id sc21-20020a1709078a1500b00988acb40f74mr1027882ejc.34.1687125079812; Sun, 18 Jun 2023 14:51:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ClbIayv+vuXIqlUUyEIzddl/VZ/URgulQ9+Ri3rfoEHiWCq95ItBuGYRKs+HVVYkZ4LwM7A== X-Received: by 2002:a17:907:8a15:b0:988:acb4:f74 with SMTP id sc21-20020a1709078a1500b00988acb40f74mr1027869ejc.34.1687125079480; Sun, 18 Jun 2023 14:51:19 -0700 (PDT) Received: from [192.168.60.219] (server.hotelpassage.eu. [88.146.207.194]) by smtp.gmail.com with ESMTPSA id n25-20020a170906379900b00977cc473b41sm13985984ejc.142.2023.06.18.14.51.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jun 2023 14:51:19 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 1/7] target/i386: fix INVD vmexit Date: Sun, 18 Jun 2023 23:51:08 +0200 Message-Id: <20230618215114.107337-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230618215114.107337-1-pbonzini@redhat.com> References: <20230618215114.107337-1-pbonzini@redhat.com> MIME-Version: 1.0 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_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Due to a typo or perhaps a brain fart, the INVD vmexit was never generated. Fix it (but not that fixing just the typo would break both INVD and WBINVD, due to a case of two wrongs making a right). Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/tcg/translate.c | 2 +- 1 file changed, 1 insertions(+), 1 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 5cf14311a60..9783fe80a30 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -6119,7 +6119,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) case 0x108: /* invd */ case 0x109: /* wbinvd */ if (check_cpl0(s)) { - gen_svm_check_intercept(s, (b & 2) ? SVM_EXIT_INVD : SVM_EXIT_WBINVD); + gen_svm_check_intercept(s, (b & 1) ? SVM_EXIT_WBINVD : SVM_EXIT_INVD); /* nothing to do */ } break; From patchwork Sun Jun 18 21:51:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1796279 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MkmP2KG9; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qkmpb3nwtz20XZ for ; Mon, 19 Jun 2023 07:52:39 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qB0Iy-0002oA-9h; Sun, 18 Jun 2023 17:51:28 -0400 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 1qB0Ix-0002nm-5o for qemu-devel@nongnu.org; Sun, 18 Jun 2023 17:51:27 -0400 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 1qB0Iv-0006Vh-NJ for qemu-devel@nongnu.org; Sun, 18 Jun 2023 17:51:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687125084; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8VBSHWK3C4o/OpcNsqQu+B6EL43Z871mwHgC4743Mmk=; b=MkmP2KG95lkeU3WaBBXLSXzAUZMgk0obUWmz/ayUthyAYywgogPdEsYmbchF21EkKPxLRr 3uzqOc8PM4/z0chS4cqaJtfQnoC8C/8eaPooTNM91iG7+ItGAOwvFd3rJocY78FtZ9OMQS ansRZ1GHZMu8ilTJVAEzfxgf3fz3XVc= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-623-hEN3owDDPmuS-17MxLF78g-1; Sun, 18 Jun 2023 17:51:23 -0400 X-MC-Unique: hEN3owDDPmuS-17MxLF78g-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-98890dda439so41882366b.1 for ; Sun, 18 Jun 2023 14:51:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687125081; x=1689717081; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8VBSHWK3C4o/OpcNsqQu+B6EL43Z871mwHgC4743Mmk=; b=dq29gRe2WsLhE5erIggNCdxSXUosyFTalLX6X1TlklwUqw4eW8lsyIlZQCDrAHbK/2 /9/OQ/gj/i++9TRUYjqzumz+eD/l+6C8lSHVrCM4GzX8/vFZm6X4oXtvWlIWTIgUbssS ePmr3a2RBqHVihHMACnSi2JQn6NPYdO+BEXDOvAEkhRWBHLT+6KSbEDCCD4DcScQkpbi C4McY4Y5PxUsNyiehI4JhL6hEANwueJoD83GofmUo4yREdU5FpRuFQzsE91DhI0kq8lY PPyEIvdsF0ju86m/4F7gOQ1s59uN8lcqXG/XYzDS5gwXkIgIGj3s3RRb6bQ9H1w5WhzQ 8LaA== X-Gm-Message-State: AC+VfDzVg1xwUm2euaxZJ4lqXZB3NvblPbM5mph8WyBeHbjZg1OvBUu9 D2o9WS/uBOcukjPbp1GNTy+Tqtfpqt7V9aEEafk0e3P2Es2EwVzHAv65hiJpRk/vfXkGQhYVvHK RKOnSuY7+GkIi/xbGQuatAggHTaKhAYoGfKgH7j+KGy59fStuOUTUEEUk803mP/Rwsx1lkN2XeT 7LiA== X-Received: by 2002:a17:907:968c:b0:988:b204:66a7 with SMTP id hd12-20020a170907968c00b00988b20466a7mr655833ejc.74.1687125081746; Sun, 18 Jun 2023 14:51:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4vaXPyy94JjCNz2sPwo6aW6NAlSPnofn034NQ/EX17vBbh4sUJSNfOsms2Z5v5uLTwp7K0mw== X-Received: by 2002:a17:907:968c:b0:988:b204:66a7 with SMTP id hd12-20020a170907968c00b00988b20466a7mr655824ejc.74.1687125081418; Sun, 18 Jun 2023 14:51:21 -0700 (PDT) Received: from [192.168.60.219] (server.hotelpassage.eu. [88.146.207.194]) by smtp.gmail.com with ESMTPSA id d7-20020a170906040700b0098860721959sm1667654eja.198.2023.06.18.14.51.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jun 2023 14:51:21 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 2/7] target/i386: TCG supports 3DNow! prefetch(w) Date: Sun, 18 Jun 2023 23:51:09 +0200 Message-Id: <20230618215114.107337-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230618215114.107337-1-pbonzini@redhat.com> References: <20230618215114.107337-1-pbonzini@redhat.com> MIME-Version: 1.0 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_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The AMD prefetch(w) instructions have not been deprecated together with the rest of 3DNow!, and in fact are even supported by newer Intel processor. Mark them as supported by TCG, as it supports all of 3DNow!. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/cpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 1242bd541a5..ff3dcd02dcb 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -647,7 +647,8 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1, CPUID_EXT2_3DNOW | CPUID_EXT2_3DNOWEXT | CPUID_EXT2_PDPE1GB | \ TCG_EXT2_X86_64_FEATURES) #define TCG_EXT3_FEATURES (CPUID_EXT3_LAHF_LM | CPUID_EXT3_SVM | \ - CPUID_EXT3_CR8LEG | CPUID_EXT3_ABM | CPUID_EXT3_SSE4A) + CPUID_EXT3_CR8LEG | CPUID_EXT3_ABM | CPUID_EXT3_SSE4A | \ + CPUID_EXT3_3DNOWPREFETCH) #define TCG_EXT4_FEATURES 0 #define TCG_SVM_FEATURES (CPUID_SVM_NPT | CPUID_SVM_VGIF | \ CPUID_SVM_SVME_ADDR_CHK) From patchwork Sun Jun 18 21:51:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1796278 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=A8MF29ts; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QkmpG3pk1z20XZ for ; Mon, 19 Jun 2023 07:52:22 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qB0J0-0002ob-F3; Sun, 18 Jun 2023 17:51:30 -0400 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 1qB0Iz-0002oQ-1z for qemu-devel@nongnu.org; Sun, 18 Jun 2023 17:51:29 -0400 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 1qB0Ix-0006W0-Lg for qemu-devel@nongnu.org; Sun, 18 Jun 2023 17:51:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687125087; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oP1MubZhPu+IU33FcEr2ztQqoz4mfwTSrVTYTsYuNNs=; b=A8MF29tsrJ6M6CMVVTBGZWAhrN7FZKCd7N1LLchoDuvg9vPFPL7CFZStTVLqFoU/Iutxtw +fxcWwQOjqhF/jD3SvTqGWIdlXjJFiHzbjEzrdeeSxBBlDeT7CGn96b0Zbv3ImfiHfCPCA UgzFllhVUI7SJrVMMe15KdyWvbPCSA0= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-631-FhUMu_dyO8e5ehSL9sQWDA-1; Sun, 18 Jun 2023 17:51:25 -0400 X-MC-Unique: FhUMu_dyO8e5ehSL9sQWDA-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-982180ac15cso221774266b.2 for ; Sun, 18 Jun 2023 14:51:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687125084; x=1689717084; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oP1MubZhPu+IU33FcEr2ztQqoz4mfwTSrVTYTsYuNNs=; b=iDCHfn5RCSWgIAbJ44UenFhWuiZlXBfNDqQySss6iH6SLYOiiCFeINHY9s5GrV+yea VFacV7Fzfm2KB0fH1lokQomnYbSzkIk5AxvJHXrDn8DhTRAGSba1Rwi2hnd13KNk9Na4 MRMcpGASn0M9WJh8v88hdyg16+txc9DgLEtYn5muURJt3bl9bs3PcUxZSaf6/mgqL2Y2 PSByo08EkuCz3jqdJMJimRAcX3kOx0Ppt4ZC4lZP/UQ+k1dfXEOVDh7gN+39BIygVoEG bS0jn85LOD+f5BWt9gnXrOA29yCUbjR5bgOrmApg9GEMS5vxAYsFs40GL3t64fqBL1HG 8EMw== X-Gm-Message-State: AC+VfDz4ZIA/i6QFXsrgkafVv9BIztxQiBoKKg+pbmcChWTmDfnIYze/ tEpq4T8ukRC51O1V4QHVYgpdR5ga/uAnKwMQ3yUtRyUgayeuESBC1JTHAlluPA/mWIvuvlhnvW8 tzHxT8ohi+r2Ee2t9fMVevg4g8Q6BOcD3728gbuUoMhxVFtG4aPBaRc06v4dDdEMTDu+q/S+npW XVmw== X-Received: by 2002:a17:906:4fd1:b0:97e:bfb5:9344 with SMTP id i17-20020a1709064fd100b0097ebfb59344mr8101420ejw.8.1687125084182; Sun, 18 Jun 2023 14:51:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ58mReNFLcDeC9eAWSLPHTwHBBQqMVOlCUfOIejmHXhHcoYVMiV13lImxlsatBWNgpzsCmmjQ== X-Received: by 2002:a17:906:4fd1:b0:97e:bfb5:9344 with SMTP id i17-20020a1709064fd100b0097ebfb59344mr8101411ejw.8.1687125083935; Sun, 18 Jun 2023 14:51:23 -0700 (PDT) Received: from [192.168.60.219] (server.hotelpassage.eu. [88.146.207.194]) by smtp.gmail.com with ESMTPSA id gv19-20020a170906f11300b00988a0765e29sm692949ejb.104.2023.06.18.14.51.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jun 2023 14:51:23 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 3/7] target/i386: TCG supports RDSEED Date: Sun, 18 Jun 2023 23:51:10 +0200 Message-Id: <20230618215114.107337-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230618215114.107337-1-pbonzini@redhat.com> References: <20230618215114.107337-1-pbonzini@redhat.com> MIME-Version: 1.0 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_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org TCG implements RDSEED, and in fact uses qcrypto_random_bytes which is secure enough to match hardware behavior. Expose it to guests. Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index ff3dcd02dcb..fc4246223d4 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -657,11 +657,10 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1, CPUID_7_0_EBX_BMI1 | CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ADX | \ CPUID_7_0_EBX_PCOMMIT | CPUID_7_0_EBX_CLFLUSHOPT | \ CPUID_7_0_EBX_CLWB | CPUID_7_0_EBX_MPX | CPUID_7_0_EBX_FSGSBASE | \ - CPUID_7_0_EBX_ERMS | CPUID_7_0_EBX_AVX2) + CPUID_7_0_EBX_ERMS | CPUID_7_0_EBX_AVX2 | CPUID_7_0_EBX_RDSEED) /* missing: CPUID_7_0_EBX_HLE - CPUID_7_0_EBX_INVPCID, CPUID_7_0_EBX_RTM, - CPUID_7_0_EBX_RDSEED */ + CPUID_7_0_EBX_INVPCID, CPUID_7_0_EBX_RTM */ #define TCG_7_0_ECX_FEATURES (CPUID_7_0_ECX_UMIP | CPUID_7_0_ECX_PKU | \ /* CPUID_7_0_ECX_OSPKE is dynamic */ \ CPUID_7_0_ECX_LA57 | CPUID_7_0_ECX_PKS | CPUID_7_0_ECX_VAES) From patchwork Sun Jun 18 21:51:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1796281 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=WdFOO6GE; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qkmpk2GXQz20XZ for ; Mon, 19 Jun 2023 07:52:46 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qB0J3-0002pJ-3o; Sun, 18 Jun 2023 17:51:33 -0400 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 1qB0J1-0002ow-3I for qemu-devel@nongnu.org; Sun, 18 Jun 2023 17:51:31 -0400 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 1qB0Iz-0006WA-MN for qemu-devel@nongnu.org; Sun, 18 Jun 2023 17:51:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687125088; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JRGs/jbwLnsIqHw/AeAVPF4p+wqrWG7JPYbu6wKGhMU=; b=WdFOO6GELu9lsekKv/vogFlZDGAfUZiEcCwia5GvfAZJJodbU0wfqfON0RGwiYdsL3i2K0 pwcHPqMv8rTkHJKs8Rppxc07Ijp83yHqpAEJN3uyoiNy3CBGRkvLfrfKgUhPoJlXz8nThR 1q4jrbP871KX4Pq5EEpP1P+RHcvuQoQ= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-608-ltB8sgGDOLahWMbPUH6gEA-1; Sun, 18 Jun 2023 17:51:27 -0400 X-MC-Unique: ltB8sgGDOLahWMbPUH6gEA-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-51a2d736a25so1984158a12.3 for ; Sun, 18 Jun 2023 14:51:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687125086; x=1689717086; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JRGs/jbwLnsIqHw/AeAVPF4p+wqrWG7JPYbu6wKGhMU=; b=KvLY2byyDAUgMRsfyxZJTPWTsWqOnl31sJFMLc2lie/WrL+HdOP2B4btL4caj4XN9Q 0iRnODOolHBZVRujriX77LUmHi0sjrSYATy1eeVGm7j2Px1gqenPAAAe6TJcmggmlwJS LpgXLauI7kBnJr6lL+HvgXt09pFCS/529LPK8tIyHpadRUT01yXufH6dKzZemwy5KYes ORkgmaicA8bHG1nEzyzGH8QVJ4mEMFK0GL+Y/MZ9AjuyfwTcGkzlb4Tr5kkZqA8DHKJ1 sNrRccSXIJ+Z0Xi+9zmKBZmNlgyPBfKkJGSCCvOu3vl/mbjD+0S1Q8A0rH5lJbzdx/cn nUBg== X-Gm-Message-State: AC+VfDyiHuZUR1q1cK9joUzK0mtKzVMqGEvJYW8bq4grQnIQCgdw/OlE jStG+8a+2GiUCETLweibyRBPeg6l4tnWWvuAw0tSnIG5WVsw1U2Ir7fgHPvBOHo0+A8gi0kTigP ZZRYxPuj8aDIu8go2Emczuw6g5AbPasYyPut8DM0T8OJQrA/BIvYfS/Eg73rJ7GIfnIo/mm/Kwa uqJA== X-Received: by 2002:a17:907:2da4:b0:988:806c:62da with SMTP id gt36-20020a1709072da400b00988806c62damr2182908ejc.58.1687125085884; Sun, 18 Jun 2023 14:51:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ47W3mYb73KxDSyy/WRMxZIGDDb4ckm4T5yGrBRJMYh29pyT9Osbo7mgS0jTXfXg3hh8B+lzg== X-Received: by 2002:a17:907:2da4:b0:988:806c:62da with SMTP id gt36-20020a1709072da400b00988806c62damr2182895ejc.58.1687125085617; Sun, 18 Jun 2023 14:51:25 -0700 (PDT) Received: from [192.168.60.219] (server.hotelpassage.eu. [88.146.207.194]) by smtp.gmail.com with ESMTPSA id t4-20020a170906178400b00982be08a9besm4815250eje.172.2023.06.18.14.51.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jun 2023 14:51:25 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 4/7] target/i386: TCG supports 32-bit SYSCALL Date: Sun, 18 Jun 2023 23:51:11 +0200 Message-Id: <20230618215114.107337-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230618215114.107337-1-pbonzini@redhat.com> References: <20230618215114.107337-1-pbonzini@redhat.com> MIME-Version: 1.0 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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org TCG supports both 32-bit and 64-bit SYSCALL, so expose it with "-cpu max" even for 32-bit emulators. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/cpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index fc4246223d4..be16c66341d 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -637,7 +637,7 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1, CPUID_EXT_X2APIC, CPUID_EXT_TSC_DEADLINE_TIMER */ #ifdef TARGET_X86_64 -#define TCG_EXT2_X86_64_FEATURES (CPUID_EXT2_SYSCALL | CPUID_EXT2_LM) +#define TCG_EXT2_X86_64_FEATURES CPUID_EXT2_LM #else #define TCG_EXT2_X86_64_FEATURES 0 #endif @@ -645,7 +645,7 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1, #define TCG_EXT2_FEATURES ((TCG_FEATURES & CPUID_EXT2_AMD_ALIASES) | \ CPUID_EXT2_NX | CPUID_EXT2_MMXEXT | CPUID_EXT2_RDTSCP | \ CPUID_EXT2_3DNOW | CPUID_EXT2_3DNOWEXT | CPUID_EXT2_PDPE1GB | \ - TCG_EXT2_X86_64_FEATURES) + CPUID_EXT2_SYSCALL | TCG_EXT2_X86_64_FEATURES) #define TCG_EXT3_FEATURES (CPUID_EXT3_LAHF_LM | CPUID_EXT3_SVM | \ CPUID_EXT3_CR8LEG | CPUID_EXT3_ABM | CPUID_EXT3_SSE4A | \ CPUID_EXT3_3DNOWPREFETCH) From patchwork Sun Jun 18 21:51:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1796282 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Ic06LZas; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qkmpr50tNz20XZ for ; Mon, 19 Jun 2023 07:52:52 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qB0J7-0002s5-IB; Sun, 18 Jun 2023 17:51:37 -0400 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 1qB0J5-0002q4-Ej for qemu-devel@nongnu.org; Sun, 18 Jun 2023 17:51:35 -0400 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 1qB0J4-0006Wb-2s for qemu-devel@nongnu.org; Sun, 18 Jun 2023 17:51:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687125093; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o9Faz8JkOAqTEvYHb2f7jU89r8nve7Zdfl/atjBRxOM=; b=Ic06LZas1W7xglXemv3sCdcai3pjsqhksSz3FLjyd4jIUNzpBZIw0RUqps84VWhN4uzUsl j442bkHlISfVQuObxLVLwCsvq/m7VM1IHf7+tPDHnm7zFTzAdm0Iveq+N6LmhOY/eHuoKb qf1gR/1bAJhWdvtYzCFbxFLwjgsXOAI= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-250-5WsVmBBeNGeaYWutm5ctgA-1; Sun, 18 Jun 2023 17:51:31 -0400 X-MC-Unique: 5WsVmBBeNGeaYWutm5ctgA-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-51a4a83d597so895714a12.2 for ; Sun, 18 Jun 2023 14:51:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687125088; x=1689717088; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o9Faz8JkOAqTEvYHb2f7jU89r8nve7Zdfl/atjBRxOM=; b=Kjqecy5p60lf44BRh4vVSQ8qKOJYTD2YRrga/YkNT/eNOKGfn7WHGXBRpdpJcxd9IT jimPywYnbDHKVVj9T7BiaDb9Oumhtf4VJruiN8YHtIr0JMqvIGpt2H1DEQVlGaddeSz0 YxjV0HYxXc+V5jYIsM/JL47Jvyzhnitvg5h3iRWb/EmVjAzB5KWWZFJuU/zcQu7iEMHC Zhq7+Zy34qtXSAFsShsEA0c3oM3VlB9Pxv0aUtEbwn8Xz326sv7F6THBp+YnH4x70wOj vZ7fWW+GWHXTdOsJYKAuSiAdJhqQ2y+9X0mbA0yNvK2S2u+IPhUUmrUvauHqfAhdBF+v q2NA== X-Gm-Message-State: AC+VfDxypMMCxov9vqroHCZmo93gvE7SHQffUq6ey32MGqp+XExq7hQI zuD3+/kz48kP9dcoHtanwXHM36KZZgGudX59ZMr58DuBHTiyMdteR2C5bgUfDXc0cOjDAxcNp4q gP5XyxuZBsfOqrdtcFyp21UZ1VJutrvT0du9aRKAYG3cwmBVK2Rwum4F6dkTemkYf3D18TgxEqM NdRg== X-Received: by 2002:aa7:c55a:0:b0:51a:4d8d:e4db with SMTP id s26-20020aa7c55a000000b0051a4d8de4dbmr2199511edr.23.1687125088003; Sun, 18 Jun 2023 14:51:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5fxvQIIibckQjU+Vmq7HLAC91JCrZM1IngO5a3sfUMl2iGMkegdKHV5YD19cyx4IZHP80wQw== X-Received: by 2002:aa7:c55a:0:b0:51a:4d8d:e4db with SMTP id s26-20020aa7c55a000000b0051a4d8de4dbmr2199505edr.23.1687125087779; Sun, 18 Jun 2023 14:51:27 -0700 (PDT) Received: from [192.168.60.219] (server.hotelpassage.eu. [88.146.207.194]) by smtp.gmail.com with ESMTPSA id bc24-20020a056402205800b0051632dc69absm1509347edb.86.2023.06.18.14.51.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jun 2023 14:51:27 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 5/7] target/i386: TCG supports XSAVEERPTR Date: Sun, 18 Jun 2023 23:51:12 +0200 Message-Id: <20230618215114.107337-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230618215114.107337-1-pbonzini@redhat.com> References: <20230618215114.107337-1-pbonzini@redhat.com> MIME-Version: 1.0 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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org XSAVEERPTR is actually a fix for an errata; TCG does not have the issue. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/cpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index be16c66341d..8e12616db5e 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -678,6 +678,8 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1, #define TCG_SGX_12_0_EBX_FEATURES 0 #define TCG_SGX_12_1_EAX_FEATURES 0 +#define TCG_8000_0008_EBX CPUID_8000_0008_EBX_XSAVEERPTR + FeatureWordInfo feature_word_info[FEATURE_WORDS] = { [FEAT_1_EDX] = { .type = CPUID_FEATURE_WORD, @@ -939,7 +941,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = { "amd-psfd", NULL, NULL, NULL, }, .cpuid = { .eax = 0x80000008, .reg = R_EBX, }, - .tcg_features = 0, + .tcg_features = TCG_8000_0008_EBX, .unmigratable_flags = 0, }, [FEAT_8000_0021_EAX] = { From patchwork Sun Jun 18 21:51:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1796280 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=OI99Pfvv; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qkmpj0J8Dz20XZ for ; Mon, 19 Jun 2023 07:52:45 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qB0J8-0002sU-2Z; Sun, 18 Jun 2023 17:51:38 -0400 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 1qB0J6-0002qK-6O for qemu-devel@nongnu.org; Sun, 18 Jun 2023 17:51:36 -0400 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 1qB0J4-0006Wh-GY for qemu-devel@nongnu.org; Sun, 18 Jun 2023 17:51:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687125093; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nqH8fjFr8PPgqeNcfvETyMoXCnQjhczLQPGBIBmp9lg=; b=OI99Pfvv7UDI//jInRrB742yPnXj2rWeIvB0Wmti2MVhGJWxi9o4t8Wr5d5hh5cTfKetXQ J/fpmkgE8ZiWKPzbVTrLnMVXZVGRcYYbYhkWbpgWGIyhBATPya4tC2F2xd/ZE1Prm2B/np dVFEHmy75SRseKRxqyREil/pgbIvwlU= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-41-DR3VJ9AoNWiVBeyMvcwOTQ-1; Sun, 18 Jun 2023 17:51:32 -0400 X-MC-Unique: DR3VJ9AoNWiVBeyMvcwOTQ-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-31126581e13so3829740f8f.2 for ; Sun, 18 Jun 2023 14:51:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687125090; x=1689717090; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nqH8fjFr8PPgqeNcfvETyMoXCnQjhczLQPGBIBmp9lg=; b=lpI8cNVGhLWueWdYvIsGoxJrUfwZ1KUcxYM20h/ySiDi4RtIkz4aQkg+nDrzGsLwh+ AcHBi3hBLw9DfHkumngUPdgnyfJ63cn7ofn7cnaMxjZIebJWimhSk3wj+LqKUlwXj9J+ WsWTY9kwIn/8QEgTPVTlj7AyO0p0zQab+RCiiGhFONrg45mO2AdBavdjyREMM+5CREej VEWIQYe0ycY+GA3IaBQSEIzUqDmYSd0BO2WUYcTK7WOirRyi4EymDu7gChvuYKh88EE4 PPRZlqULOgyg3NubKdAL2HSpjF6dI7+GNOvznK930tLMJctnYstMrQ602Oqq4vxUn6nE grjQ== X-Gm-Message-State: AC+VfDx/hs6290p4Xz8bKmxsdA9Ci/l0nS1BpC1yK8czlfu3qAds3qi8 Ky7om2y+8+N6ElR/pGaYbUnOexJ/CvbFfdwOc+JuwpVMzsrYtrefoeCIUqRAnTaQZbFP5MVDyFR YncVmaQW8P/O6thiNero5Tu6ZFmf0AQKFdJLf6AlEX8Vu9jj/bVDO/9mifZBnHZbCl8B9gcEHrf DjBg== X-Received: by 2002:a5d:5272:0:b0:307:8651:258e with SMTP id l18-20020a5d5272000000b003078651258emr7375330wrc.21.1687125090607; Sun, 18 Jun 2023 14:51:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6KXr+S8bypWqTMPU8Q2EZTY/oTovP7SdgvPiKTUVivFSLAeznXLjk5hix9A1iAn0MljUt0IA== X-Received: by 2002:a5d:5272:0:b0:307:8651:258e with SMTP id l18-20020a5d5272000000b003078651258emr7375309wrc.21.1687125090077; Sun, 18 Jun 2023 14:51:30 -0700 (PDT) Received: from [192.168.60.219] (server.hotelpassage.eu. [88.146.207.194]) by smtp.gmail.com with ESMTPSA id eh9-20020a0564020f8900b0050a276e7ba8sm12272077edb.36.2023.06.18.14.51.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jun 2023 14:51:29 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 6/7] target/i386: implement RDPID in TCG Date: Sun, 18 Jun 2023 23:51:13 +0200 Message-Id: <20230618215114.107337-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230618215114.107337-1-pbonzini@redhat.com> References: <20230618215114.107337-1-pbonzini@redhat.com> MIME-Version: 1.0 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_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org RDPID corresponds to a RDMSR(TSC_AUX); however, it is unprivileged so for user-mode emulation we must provide the value that the kernel places in the MSR. For Linux, it is a combination of the current CPU and the current NUMA node, both of which can be retrieved with getcpu(2). For BSD, just return 0. RDTSCP is reimplemented as RDTSC + RDPID ECX; the differences in terms of serializability are not relevant to QEMU. Signed-off-by: Paolo Bonzini --- linux-user/i386/target_cpu.h | 8 ++++++++ linux-user/x86_64/target_cpu.h | 1 + target/i386/cpu.c | 10 +++++++++- target/i386/helper.h | 2 +- target/i386/tcg/misc_helper.c | 21 +++++++++++++++------ target/i386/tcg/translate.c | 15 +++++++++++++-- 6 files changed, 47 insertions(+), 10 deletions(-) diff --git a/linux-user/i386/target_cpu.h b/linux-user/i386/target_cpu.h index 52caf788cc3..3539f790222 100644 --- a/linux-user/i386/target_cpu.h +++ b/linux-user/i386/target_cpu.h @@ -54,4 +54,12 @@ static inline abi_ulong get_sp_from_cpustate(CPUX86State *state) { return state->regs[R_ESP]; } + +static inline uint32_t get_cpunode(void) +{ + unsigned cpu, node; + getcpu(&cpu, &node); + return (node << 12) | (cpu & 0xfff); +} + #endif /* I386_TARGET_CPU_H */ diff --git a/linux-user/x86_64/target_cpu.h b/linux-user/x86_64/target_cpu.h index 9ec7cbb7a4c..dec2e24f5a3 100644 --- a/linux-user/x86_64/target_cpu.h +++ b/linux-user/x86_64/target_cpu.h @@ -1 +1,2 @@ +#include "target_syscall.h" #include "../i386/target_cpu.h" diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 8e12616db5e..68218103108 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -661,9 +661,17 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1, /* missing: CPUID_7_0_EBX_HLE CPUID_7_0_EBX_INVPCID, CPUID_7_0_EBX_RTM */ + +#if defined CONFIG_SOFTMMU || defined CONFIG_LINUX +#define TCG_7_0_ECX_RDPID CPUID_7_0_ECX_RDPID +#else +#define TCG_7_0_ECX_RDPID 0 +#endif #define TCG_7_0_ECX_FEATURES (CPUID_7_0_ECX_UMIP | CPUID_7_0_ECX_PKU | \ /* CPUID_7_0_ECX_OSPKE is dynamic */ \ - CPUID_7_0_ECX_LA57 | CPUID_7_0_ECX_PKS | CPUID_7_0_ECX_VAES) + CPUID_7_0_ECX_LA57 | CPUID_7_0_ECX_PKS | CPUID_7_0_ECX_VAES | \ + TCG_7_0_ECX_RDPID) + #define TCG_7_0_EDX_FEATURES CPUID_7_0_EDX_FSRM #define TCG_7_1_EAX_FEATURES (CPUID_7_1_EAX_FZRM | CPUID_7_1_EAX_FSRS | \ CPUID_7_1_EAX_FSRC) diff --git a/target/i386/helper.h b/target/i386/helper.h index e627a931073..4e308aae643 100644 --- a/target/i386/helper.h +++ b/target/i386/helper.h @@ -69,8 +69,8 @@ DEF_HELPER_2(into, void, env, int) DEF_HELPER_FLAGS_1(single_step, TCG_CALL_NO_WG, noreturn, env) DEF_HELPER_1(rechecking_single_step, void, env) DEF_HELPER_1(cpuid, void, env) +DEF_HELPER_FLAGS_1(rdpid, TCG_CALL_NO_WG, tl, env) DEF_HELPER_1(rdtsc, void, env) -DEF_HELPER_1(rdtscp, void, env) DEF_HELPER_FLAGS_1(rdpmc, TCG_CALL_NO_WG, noreturn, env) #ifndef CONFIG_USER_ONLY diff --git a/target/i386/tcg/misc_helper.c b/target/i386/tcg/misc_helper.c index 5f7a3061ca5..9bcbf6fd60d 100644 --- a/target/i386/tcg/misc_helper.c +++ b/target/i386/tcg/misc_helper.c @@ -24,6 +24,10 @@ #include "exec/exec-all.h" #include "helper-tcg.h" +#if defined CONFIG_USER_ONLY && defined CONFIG_LINUX +#include "target_cpu.h" +#endif + /* * NOTE: the translator must set DisasContext.cc_op to CC_OP_EFLAGS * after generating a call to a helper that uses this. @@ -75,12 +79,6 @@ void helper_rdtsc(CPUX86State *env) env->regs[R_EDX] = (uint32_t)(val >> 32); } -void helper_rdtscp(CPUX86State *env) -{ - helper_rdtsc(env); - env->regs[R_ECX] = (uint32_t)(env->tsc_aux); -} - G_NORETURN void helper_rdpmc(CPUX86State *env) { if (((env->cr[4] & CR4_PCE_MASK) == 0 ) && @@ -137,3 +135,14 @@ void helper_wrpkru(CPUX86State *env, uint32_t ecx, uint64_t val) env->pkru = val; tlb_flush(cs); } + +target_ulong HELPER(rdpid)(CPUX86State *env) +{ +#if defined CONFIG_SOFTMMU + return env->tsc_aux; +#elif defined CONFIG_LINUX + return get_cpunode(); +#else + return 0; +#endif +} diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 9783fe80a30..9023f47fa69 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -3924,7 +3924,16 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_cmpxchg8b(s, env, modrm); break; - case 7: /* RDSEED */ + case 7: /* RDSEED, RDPID with f3 prefix */ + if (mod == 3 && !(s->prefix & PREFIX_LOCK) && + (s->prefix & PREFIX_REPZ) && + (s->cpuid_ext_features & CPUID_7_0_ECX_RDPID)) { + gen_helper_rdpid(s->T0, cpu_env); + rm = (modrm & 7) | REX_B(s); + gen_op_mov_reg_v(s, dflag, rm, s->T0); + break; + } + /* fallthrough */ case 6: /* RDRAND */ if (mod != 3 || (s->prefix & (PREFIX_LOCK | PREFIX_REPZ | PREFIX_REPNZ)) || @@ -6108,7 +6117,9 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) gen_update_cc_op(s); gen_update_eip_cur(s); translator_io_start(&s->base); - gen_helper_rdtscp(cpu_env); + gen_helper_rdtsc(cpu_env); + gen_helper_rdpid(s->T0, cpu_env); + gen_op_mov_reg_v(s, dflag, R_ECX, s->T0); break; default: From patchwork Sun Jun 18 21:51:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1796277 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=WhSpZem9; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qkmnz2YN9z20XZ for ; Mon, 19 Jun 2023 07:52:07 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qB0J9-0002sw-SK; Sun, 18 Jun 2023 17:51:39 -0400 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 1qB0J8-0002sa-BD for qemu-devel@nongnu.org; Sun, 18 Jun 2023 17:51:38 -0400 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 1qB0J6-0006XD-M8 for qemu-devel@nongnu.org; Sun, 18 Jun 2023 17:51:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687125096; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pwhgzbvG7T4FJXqSfC+4/m2TD+a0zefm3IPCck6mj44=; b=WhSpZem96XVRGBzXeNL1bBPEr1Jpjc0YOS/lepbVHbWHqmHZQ0CaWfrzQ4WP2VQA2tr5fq XbLb5Ijx3w56ZALB2v9zcgIou8Rb7Pp443w2agwCUWdpu3HyAwq54SgljDqmZd0j6stQhL aDcfy4cE4DjkxVzs5EGDlk9NzoZmdM4= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-115-cfaI9g8EP_u3LfjYh_JXrA-1; Sun, 18 Jun 2023 17:51:34 -0400 X-MC-Unique: cfaI9g8EP_u3LfjYh_JXrA-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-94a35b0d4ceso161385666b.3 for ; Sun, 18 Jun 2023 14:51:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687125093; x=1689717093; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pwhgzbvG7T4FJXqSfC+4/m2TD+a0zefm3IPCck6mj44=; b=jV7WHTloz26diSWlZ3GfiH+Y07udO1q1LaE9c1Ghn9IKIfIYdKIGpqzQXIFP4XmMYQ EhBgdDy/+tLklFmSfOK0BmApbqoZIgzT4+CGdiVQSRI80vj9sM2KCm+sfex7ZfCxE8AR nNG0SD/NeNwESZwcYKriziimri+UhecmMdR6waDqqyH7eyQ0JYQYczRNMr+oNHLer9bq JlUNM2UGWWj0SlHUZVT7y1GKJuOZPEzFYUR5C7gWNXvGoSdYKmFHIEzKeLlDLIFlIIog HX1ihMeHGmPdenKgJpIqZYgy9+tnQTvl7byg1IPCA/BrN1sLS85iYpyiWuqdsLr+xFfM nBHg== X-Gm-Message-State: AC+VfDwXGEktAT9+DWJnOg11XPQWGDIu8pdVURnfSINRv2hthgXxRo7Z vWo6r7Bvi6BS+KvCzxOg07XqGIzpdNqI8wHuy+/OPrJIn1LwY66x8+wZGpkXgXgJIlqw/+WLsnP zuIy0JFzX+ygn17Pd8fudND1bkUwWEoyX4x58Ig66YvIR4NOv+VdzbQFoxSVyClRTu952c86naH 32RA== X-Received: by 2002:aa7:dcd2:0:b0:51a:5af9:36f6 with SMTP id w18-20020aa7dcd2000000b0051a5af936f6mr529033edu.29.1687125092825; Sun, 18 Jun 2023 14:51:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7hCh2qfesAe+3FhUSwah332tL346fJOFTDC5RjhVwTAwgii9DbIyjCNuO4V/ptJCQTB4tPVg== X-Received: by 2002:aa7:dcd2:0:b0:51a:5af9:36f6 with SMTP id w18-20020aa7dcd2000000b0051a5af936f6mr529029edu.29.1687125092484; Sun, 18 Jun 2023 14:51:32 -0700 (PDT) Received: from [192.168.60.219] (server.hotelpassage.eu. [88.146.207.194]) by smtp.gmail.com with ESMTPSA id j19-20020a50ed13000000b0051a216e7df7sm4252072eds.87.2023.06.18.14.51.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jun 2023 14:51:32 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 7/7] target/i386: implement WBNOINVD in TCG Date: Sun, 18 Jun 2023 23:51:14 +0200 Message-Id: <20230618215114.107337-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230618215114.107337-1-pbonzini@redhat.com> References: <20230618215114.107337-1-pbonzini@redhat.com> MIME-Version: 1.0 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_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org WBNOINVD is the same as INVD or WBINVD as far as TCG is concerned, but it does not generate a vmexit if the processor supports it. If it does not, it is treated as WBINVD and generates a vmexit. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/cpu.c | 3 ++- target/i386/tcg/translate.c | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 68218103108..dec376ab56d 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -686,7 +686,8 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1, #define TCG_SGX_12_0_EBX_FEATURES 0 #define TCG_SGX_12_1_EAX_FEATURES 0 -#define TCG_8000_0008_EBX CPUID_8000_0008_EBX_XSAVEERPTR +#define TCG_8000_0008_EBX (CPUID_8000_0008_EBX_XSAVEERPTR | \ + CPUID_8000_0008_EBX_WBNOINVD) FeatureWordInfo feature_word_info[FEATURE_WORDS] = { [FEAT_1_EDX] = { diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 9023f47fa69..c3d4410cdf1 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -122,6 +122,7 @@ typedef struct DisasContext { int cpuid_ext3_features; int cpuid_7_0_ebx_features; int cpuid_7_0_ecx_features; + int cpuid_8000_0008_ebx_features; int cpuid_xsave_features; /* TCG local temps */ @@ -6127,8 +6128,14 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) } break; + case 0x109: /* wbinvd; wbnoinvd with REPZ prefix */ + if ((s->cpuid_8000_0008_ebx_features & CPUID_8000_0008_EBX_WBNOINVD) && + s->prefix & PREFIX_REPZ) { + check_cpl0(s); + break; + } + /* fallthrough */ case 0x108: /* invd */ - case 0x109: /* wbinvd */ if (check_cpl0(s)) { gen_svm_check_intercept(s, (b & 1) ? SVM_EXIT_WBINVD : SVM_EXIT_INVD); /* nothing to do */ @@ -6936,6 +6943,7 @@ static void i386_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cpu) dc->cpuid_7_0_ebx_features = env->features[FEAT_7_0_EBX]; dc->cpuid_7_0_ecx_features = env->features[FEAT_7_0_ECX]; dc->cpuid_xsave_features = env->features[FEAT_XSAVE]; + dc->cpuid_8000_0008_ebx_features = env->features[FEAT_8000_0008_EBX]; dc->jmp_opt = !((cflags & CF_NO_GOTO_TB) || (flags & (HF_TF_MASK | HF_INHIBIT_IRQ_MASK))); /*