From patchwork Wed Jul 31 11:17:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13748554 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5E820C52D70 for ; Wed, 31 Jul 2024 11:19:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZ7LX-0004pD-A7; Wed, 31 Jul 2024 07:18:19 -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 1sZ7LV-0004oY-KI for qemu-devel@nongnu.org; Wed, 31 Jul 2024 07:18:17 -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 1sZ7LU-0006l2-55 for qemu-devel@nongnu.org; Wed, 31 Jul 2024 07:18:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722424695; 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=cJcXNK/y8GUg9fYFr/3hXtvxWP19H58fRdjkvKirAyQ=; b=ZQSWovgG7UiDPSRjy0++QbTdXLRVvbmUdqqiOPAjNQv2cz4mEW+3c9jcvXga69M7YydS14 AODTBgsmtkjX2eMxwSfARZRC5K1Wu89m7EEcRs2UnNJg09KihCcnP6QphPHAaFQtX7L8rf NdKMvIY147dq4lFPNel2MlSIJqKERKk= 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-207-2UQTITpJP4-rNxeh31SVVw-1; Wed, 31 Jul 2024 07:18:13 -0400 X-MC-Unique: 2UQTITpJP4-rNxeh31SVVw-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5a113d5cd1eso3589893a12.1 for ; Wed, 31 Jul 2024 04:18:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722424692; x=1723029492; 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=cJcXNK/y8GUg9fYFr/3hXtvxWP19H58fRdjkvKirAyQ=; b=oz9CeKZsy6DMGGd9agCM9jXopFlcDSjodK5JtiF9rllsTHvNTEybxky/Mxn//wnO0/ h++BQSo2/IGcirvLqzQJdKGz2Vmak4otGkIENkAMlcCdbC1gUmheOlR9QZiGL2EmmSht 3mWH3I50XrIlZnk0zrosEu8AfM0CUTNTBjexyDPSLT3938OjeL0ngh5d9BIr+1VLWvM3 rCKiSNlkQ0bCUqj9bdu0SEQXaZU20xUTFrmjuCSl98QGYJbMO0dh/DGW6S9AmpwH3pgv 3KNz5ZnuWhHYLMVrErkAASQ6kmL5B9NaCRYWvk5xyHl+TU6n2ALuaFyeb4S5E1QeEhNo L3JQ== X-Gm-Message-State: AOJu0YwpoQM+1FTqrI+4Tuh2QEcapcK04ByOSWfctyuRLPzBQ5FIHgx5 ix10RZuTUbJYEEvjZ3sKuEb3LzhArj/c/Xns5WNPW5AFkhY/bV/4AjIByqw8Ce86D9hmTdyBR41 rYCkOuzoiZEc3yYG8ppVYYdvA4X1r9rFlHlKqwZCpvQhNW3TWR28QX2oyN3IjoicYZ/SUxlrQ1Q s7d67kmGgfy9LLy0CYP4s7PFMAa+KxrPZfW3Am X-Received: by 2002:a05:6402:1e93:b0:5a2:97d7:c728 with SMTP id 4fb4d7f45d1cf-5b01d84be21mr14234840a12.0.1722424692124; Wed, 31 Jul 2024 04:18:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvSQ9s2SmCECaS66Hpze2CS/qV9pFevKhYb8Djj58QrRlhZfgEP7EiphYbvEL0xx+WJjMStg== X-Received: by 2002:a05:6402:1e93:b0:5a2:97d7:c728 with SMTP id 4fb4d7f45d1cf-5b01d84be21mr14234814a12.0.1722424691455; Wed, 31 Jul 2024 04:18:11 -0700 (PDT) Received: from avogadro.local ([151.95.101.29]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5afb9422c41sm6936753a12.82.2024.07.31.04.18.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 04:18:11 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 01/10] tests/vm/openbsd: Install tomli Date: Wed, 31 Jul 2024 13:17:57 +0200 Message-ID: <20240731111806.167225-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240731111806.167225-1-pbonzini@redhat.com> References: <20240731111806.167225-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.126, 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_H3=0.001, RCVD_IN_MSPIKE_WL=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Richard Henderson OpenBSD still defaults to python 3.10, therefore tomli is now required by configure. Signed-off-by: Richard Henderson Link: https://lore.kernel.org/r/20240729051244.436851-1-richard.henderson@linaro.org Signed-off-by: Paolo Bonzini --- tests/vm/openbsd | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/vm/openbsd b/tests/vm/openbsd index 5e646f7c51e..49cab087825 100755 --- a/tests/vm/openbsd +++ b/tests/vm/openbsd @@ -32,6 +32,7 @@ class OpenBSDVM(basevm.BaseVM): "pkgconf", "bzip2", "xz", "ninja", + "py3-tomli", # gnu tools "bash", From patchwork Wed Jul 31 11:17:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13748560 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1525CC3DA7F for ; Wed, 31 Jul 2024 11:19:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZ7LZ-0004zS-Ua; Wed, 31 Jul 2024 07:18:21 -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 1sZ7LY-0004uM-HD for qemu-devel@nongnu.org; Wed, 31 Jul 2024 07:18:20 -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 1sZ7LW-0006lT-VC for qemu-devel@nongnu.org; Wed, 31 Jul 2024 07:18:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722424698; 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=aYyzfF6IqNI/L5NVj2X9zCG1qLPKn4/0ehGgl/Nh5hs=; b=EuiOMw1o1DolyvdA5smgeeZ/LDYgJiujcLPAomvxR2zPfOXmTdMgnMkYfuvgSCwTYO31Wy REkdYr8an0zLOJwxfqRbyb1MWeu0bZPnlFtQRqYmlS+scVKUySRJt7k0BxUg/2fgc+LudV xwcBV/goP0vYt8IfHvpIbnxijPMwuoY= 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-304-bhX0ubxlOEi-_9zCJzCpGg-1; Wed, 31 Jul 2024 07:18:16 -0400 X-MC-Unique: bhX0ubxlOEi-_9zCJzCpGg-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5a766a51b0dso6173771a12.1 for ; Wed, 31 Jul 2024 04:18:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722424694; x=1723029494; 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=aYyzfF6IqNI/L5NVj2X9zCG1qLPKn4/0ehGgl/Nh5hs=; b=KAZjc8R5N58hHkBsaDlS1GM/UAP27pRIgqtRoLUo2gwz87NTb80Hm+MZohzDlQqUgM e6EDE7Vf7i2liEb+bjesw+AA45pxQd6Hxxp5lCiyd4Rxsw6KM7wwqz95yrXqG7Fzc8Ae 9AtZEkVElj6f1Ba9fgOdvYfj7MBEeDlCYAkKBhNJkFKRnLYnZZECJe2zhl/AjKzC8mCJ 92M/iOFu2xm2/fonvP1066zlAQdh0o87rBNM7977Jd9HIvTBb4R65XCENH0yyjfsG9Js XFDXp7lx7Zq2Z5WRr8cvsjvhSh23GPSqV5fOnYXkezZWVpSypyws/wg/wlC1mKxaSLC1 V8Ow== X-Gm-Message-State: AOJu0YxpOLFMscu6j2NVxnhyP8VdDu8cgPF5o3Gxdx7rHx6wMcevcZcT OjUT1JBUIJt5LCbqr1QzCkML1E0xPzfLcQUUwwmH4xpatTzHuRnGJAMKKqZ3tLOk9Zqk5wdTPgk 62pjkdtTrpKyKjbhcJiurDpc3kYIwiUwnl+dqdFHRBKuch/Vx4GuQgD+3P8QOehqogcmvdRIXMw 6ROE1GHXnPZGg+bpovpfeuPiCjbj/Gz6Oj+0rb X-Received: by 2002:a50:d4d5:0:b0:5af:874d:1b7b with SMTP id 4fb4d7f45d1cf-5b02000c604mr9118256a12.1.1722424694534; Wed, 31 Jul 2024 04:18:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHscWNXIyOaWDoq+cl3VgCRoKNVrM48mtyCKBkDpOwgWt1IUGSvzqZe7lPZBmQ5SWbYdV/rKQ== X-Received: by 2002:a50:d4d5:0:b0:5af:874d:1b7b with SMTP id 4fb4d7f45d1cf-5b02000c604mr9118231a12.1.1722424694044; Wed, 31 Jul 2024 04:18:14 -0700 (PDT) Received: from avogadro.local ([151.95.101.29]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ac6358fa5esm8548783a12.32.2024.07.31.04.18.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 04:18:13 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Xiong Zhang Subject: [PULL 02/10] target/i386: Change unavail from u32 to u64 Date: Wed, 31 Jul 2024 13:17:58 +0200 Message-ID: <20240731111806.167225-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240731111806.167225-1-pbonzini@redhat.com> References: <20240731111806.167225-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.126, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Xiong Zhang The feature word 'r' is a u64, and "unavail" is a u32, the operation 'r &= ~unavail' clears the high 32 bits of 'r'. This causes many vmx cases in kvm-unit-tests to fail. Changing 'unavail' from u32 to u64 fixes this issue. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2442 Fixes: 0b2757412cb1 ("target/i386: drop AMD machine check bits from Intel CPUID") Signed-off-by: Xiong Zhang Link: https://lore.kernel.org/r/20240730082927.250180-1-xiong.y.zhang@linux.intel.com Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 4688d140c2d..ef06da54c63 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6039,7 +6039,7 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *cpu, FeatureWord w) { FeatureWordInfo *wi = &feature_word_info[w]; uint64_t r = 0; - uint32_t unavail = 0; + uint64_t unavail = 0; if (kvm_enabled()) { switch (wi->type) { From patchwork Wed Jul 31 11:17:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13748555 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 59BFFC52D6F for ; Wed, 31 Jul 2024 11:19:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZ7Lc-0005BR-Qm; Wed, 31 Jul 2024 07:18:24 -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 1sZ7Lb-00056R-JU for qemu-devel@nongnu.org; Wed, 31 Jul 2024 07:18:23 -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 1sZ7LZ-0006ly-Ug for qemu-devel@nongnu.org; Wed, 31 Jul 2024 07:18:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722424700; 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=UXQp/6q+UgrnD2vb9HkCYwGfgn5PjByeKn38gVNGzJM=; b=RqvWZ8WmGA1WDfRE21p71VvSIAlCnjdvXhgATWv4+csRDQvIrZSjk9nWaOCzH9odXuIKMf axPBmHBMmLQnk4JeZK2A1RTDP2vAkVeg5sqlsr8ZBJCKmt7CEPixImBpmRRS3pwedf8r51 Uu4khnxyKprIZoaHscdFZVhT7bG8OaM= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-404-HyYRgSHOPsiakK2bnpQqng-1; Wed, 31 Jul 2024 07:18:19 -0400 X-MC-Unique: HyYRgSHOPsiakK2bnpQqng-1 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-52eff10441fso6390606e87.3 for ; Wed, 31 Jul 2024 04:18:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722424697; x=1723029497; 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=UXQp/6q+UgrnD2vb9HkCYwGfgn5PjByeKn38gVNGzJM=; b=PbfGVMIUkT5FbfKlu+cz0fJsjKYCqcCSXHcPShdg2hhBNxEQcCF2Kum8nJJUZADJYe +G39AMdWcygcesPH9NfFmu7EtbrQe7aCJOXunzuD9enWNAi+myfky0BYG+/goa4monIh D2Iu6i2yMJw+Oi1i+eNcbWypNb1/FK0QfTQvRTrhP6TpSuJonzukfFwbUk5N74yOYGxD FqAgsVoEgYLI54nbS5vNqFCAxVFOFnAfVqG91S03ufQba5Mvi4ek1qLSb42fR4Q0A9ds 1nAc6pf3NytJUBj9AfH0ddL/awTMYq0o3318pB9Ti30hZLZ1NQ12WbbYW6aqhn0tIdpo 7veQ== X-Gm-Message-State: AOJu0Yy7DBkE6lc/5Evmr+2eU1s4MI3l37nHaknn/YcVqmVVbL0Kqt5E 2MwRlUH1Kwt/bVxRq2+3K3ounKlEEW+AyLrU98izzfAoO6FZQtr/giiSWXN8dAX2B1MsXg+jXdQ NMYCckR05FZA6lJQ/CuK7T2J+1RUpk7vc/kHl6FvBPjGTgDtKIW4Wzr+T/oEgs3IXZ39M/1/6e0 rSN2zEBCGN7NNDjvQ5bzJ4fp9m2FiluSXjXY8k X-Received: by 2002:a05:6512:286:b0:52f:c2ef:a76a with SMTP id 2adb3069b0e04-5309b2720a2mr7918448e87.18.1722424697394; Wed, 31 Jul 2024 04:18:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IERpqr58GDaaFTu+Ox4BYb5uKLqIsNilOjryoHAFCWA5/YvTgu4GL8ve4O+U+WZWCL7g19peQ== X-Received: by 2002:a05:6512:286:b0:52f:c2ef:a76a with SMTP id 2adb3069b0e04-5309b2720a2mr7918438e87.18.1722424696873; Wed, 31 Jul 2024 04:18:16 -0700 (PDT) Received: from avogadro.local ([151.95.101.29]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ac63590cedsm8530617a12.29.2024.07.31.04.18.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 04:18:16 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Zhao Liu Subject: [PULL 03/10] target/i386/cpu: Remove unnecessary SGX feature words checks Date: Wed, 31 Jul 2024 13:17:59 +0200 Message-ID: <20240731111806.167225-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240731111806.167225-1-pbonzini@redhat.com> References: <20240731111806.167225-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.126, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Zhao Liu CPUID.0x7.0.ebx and CPUID.0x7.0.ecx leaves have been expressed as the feature word lists, and the Host capability support has been checked in x86_cpu_filter_features(). Therefore, such checks on SGX feature "words" are redundant, and the follow-up adjustments to those feature "words" will not actually take effect. Remove unnecessary SGX feature words related checks. Signed-off-by: Zhao Liu Link: https://lore.kernel.org/r/20240730045544.2516284-2-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index ef06da54c63..a9535284aa9 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6537,8 +6537,6 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, case 7: /* Structured Extended Feature Flags Enumeration Leaf */ if (count == 0) { - uint32_t eax_0_unused, ebx_0, ecx_0, edx_0_unused; - /* Maximum ECX value for sub-leaves */ *eax = env->cpuid_level_func7; *ebx = env->features[FEAT_7_0_EBX]; /* Feature flags */ @@ -6548,20 +6546,8 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, } *edx = env->features[FEAT_7_0_EDX]; /* Feature flags */ - /* - * SGX cannot be emulated in software. If hardware does not - * support enabling SGX and/or SGX flexible launch control, - * then we need to update the VM's CPUID values accordingly. - */ - x86_cpu_get_supported_cpuid(0x7, 0, - &eax_0_unused, &ebx_0, - &ecx_0, &edx_0_unused); - if ((*ebx & CPUID_7_0_EBX_SGX) && !(ebx_0 & CPUID_7_0_EBX_SGX)) { - *ebx &= ~CPUID_7_0_EBX_SGX; - } - if ((*ecx & CPUID_7_0_ECX_SGX_LC) - && (!(*ebx & CPUID_7_0_EBX_SGX) || !(ecx_0 & CPUID_7_0_ECX_SGX_LC))) { + && (!(*ebx & CPUID_7_0_EBX_SGX))) { *ecx &= ~CPUID_7_0_ECX_SGX_LC; } } else if (count == 1) { From patchwork Wed Jul 31 11:18:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13748558 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2EB65C3DA7F for ; Wed, 31 Jul 2024 11:19:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZ7Lf-0005KJ-7A; Wed, 31 Jul 2024 07:18:27 -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 1sZ7Ld-0005Dv-FF for qemu-devel@nongnu.org; Wed, 31 Jul 2024 07:18:25 -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 1sZ7Lb-0006mG-SJ for qemu-devel@nongnu.org; Wed, 31 Jul 2024 07:18:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722424703; 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=YVLZx9cxauGLNxxqCHWm1ysmO8J+eGcn2LcW4LTM8N0=; b=gGrEDrZZIkaqpH9/4Uz1Md1Kgo2bMOEKJutUU+0l7Jtw5rW0OPAJe3WLbDzcvN7AEb9oSR ms3xDc3TyHYbw+m6JH9mfUk4lZ1D16UmJm9sfgcqqU911BspupMLXzqpjRajiXQpyzCaLv B4kOU0K2g5TeUn1cLeOqX02R3n+zdjs= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-428-JmyQJ760P1OasYS_1BeFMw-1; Wed, 31 Jul 2024 07:18:22 -0400 X-MC-Unique: JmyQJ760P1OasYS_1BeFMw-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-530ad977bccso1388905e87.0 for ; Wed, 31 Jul 2024 04:18:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722424700; x=1723029500; 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=YVLZx9cxauGLNxxqCHWm1ysmO8J+eGcn2LcW4LTM8N0=; b=Nc13yNIDUfnjoUSbrSCHHnDAWI++Y1xWoNe21mBGjE49qlP9+lpcQM/jQl5KF0wxKy /a/j24X/koOgBriIqSk9LvQMsZ6x/jxIa6gV83rLPNpwNbFqXIm3KrITFpGx5yO5ES8e vdpY51ZCKggWgDSG1SlDSW4SzOxN0hMH6btL7s8tQEj6fqzNg7NvYFvRmjkhRbfKOaNP d7xOMpucpbNjHaDKWLQ0FGPrzUd8YQZI+TMfAgocHNIN7CFLRZxpLp6dzE1nNYflsVeK SHHj/E6b+UaxVNDAIdaZp+M9nW/l7VK8NI2R4D5yvs6+o6hkU82BQN2VIPmKAelwxaUu XJGQ== X-Gm-Message-State: AOJu0YwSyGWBX5CzICHfnlMRM7pNHPcnCz5Ssw2CV9C6IilJXW4yoIua cqmHA5MqttpUgR8HOj9KH8H9sA3m8KY/PCEC0btt3rKLwlAB3ndPjdTa2Nr1Q1pAdQe4Qj0gqrk +Hy4OvmKeuVwIi9rY+Ejvez1Ri5Yzjl8zeGcW4lfJglYVRMfMK8kRRJY6j9emkG7M5G6snePK8R Zw/r0AxlL6TPspEoAO5KrJMIO5DM8Uiav5fZpb X-Received: by 2002:ac2:4d19:0:b0:52c:dbc6:8eb0 with SMTP id 2adb3069b0e04-5309b27227dmr7613412e87.21.1722424700072; Wed, 31 Jul 2024 04:18:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGbGV33v66AXlYzL0Rxv2r3llQ3tFveEhGcUPGUm69usdUj9r72dpteDIYmB5t0Pb09dk4FIg== X-Received: by 2002:ac2:4d19:0:b0:52c:dbc6:8eb0 with SMTP id 2adb3069b0e04-5309b27227dmr7613394e87.21.1722424699512; Wed, 31 Jul 2024 04:18:19 -0700 (PDT) Received: from avogadro.local ([151.95.101.29]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7d8288832fsm217166966b.6.2024.07.31.04.18.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 04:18:19 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Zhao Liu Subject: [PULL 04/10] target/i386/cpu: Explicitly express SGX_LC and SGX feature words dependency Date: Wed, 31 Jul 2024 13:18:00 +0200 Message-ID: <20240731111806.167225-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240731111806.167225-1-pbonzini@redhat.com> References: <20240731111806.167225-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.126, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Zhao Liu At present, cpu_x86_cpuid() silently masks off SGX_LC if SGX is absent. This is not proper because the user is not told about the dependency between the two. So explicitly define the dependency between SGX_LC and SGX feature words, so that user could get a warning when SGX_LC is enabled but SGX is absent. Signed-off-by: Zhao Liu Link: https://lore.kernel.org/r/20240730045544.2516284-3-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index a9535284aa9..e864f55d4fc 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1730,6 +1730,10 @@ static FeatureDep feature_dependencies[] = { .from = { FEAT_7_1_EAX, CPUID_7_1_EAX_WRMSRNS }, .to = { FEAT_7_1_EAX, CPUID_7_1_EAX_FRED }, }, + { + .from = { FEAT_7_0_EBX, CPUID_7_0_EBX_SGX }, + .to = { FEAT_7_0_ECX, CPUID_7_0_ECX_SGX_LC }, + }, }; typedef struct X86RegisterInfo32 { @@ -6545,11 +6549,6 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *ecx |= CPUID_7_0_ECX_OSPKE; } *edx = env->features[FEAT_7_0_EDX]; /* Feature flags */ - - if ((*ecx & CPUID_7_0_ECX_SGX_LC) - && (!(*ebx & CPUID_7_0_EBX_SGX))) { - *ecx &= ~CPUID_7_0_ECX_SGX_LC; - } } else if (count == 1) { *eax = env->features[FEAT_7_1_EAX]; *edx = env->features[FEAT_7_1_EDX]; From patchwork Wed Jul 31 11:18:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13748552 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A5485C3DA64 for ; Wed, 31 Jul 2024 11:19:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZ7Lj-0005a1-Tf; Wed, 31 Jul 2024 07:18:31 -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 1sZ7Lh-0005UE-FD for qemu-devel@nongnu.org; Wed, 31 Jul 2024 07:18: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 1sZ7Lf-0006mc-L4 for qemu-devel@nongnu.org; Wed, 31 Jul 2024 07:18:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722424706; 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=0Bnh2khxE06uRGlglbrZqD8PmhxT2BPf5aSSDHqB2mU=; b=CjPFQs2wxwhMap8AsvibqOvY1J1QoG3895JwWrDgPD800vSE4Yg1gqS3WBlKumopaEJeNy uFjqYbcySFoCKZyEDaVt2DXu1Kr+bigvaoMLk4oIgBqILh5oQgiZDoweVqm0AgheDYGCeT D1Yv1L85+odSTQvjEd3CakbUjkUFvjc= 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-307-SDkhY_fPN9OugKcDUiKjQg-1; Wed, 31 Jul 2024 07:18:24 -0400 X-MC-Unique: SDkhY_fPN9OugKcDUiKjQg-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a7aa56d8b14so502985566b.1 for ; Wed, 31 Jul 2024 04:18:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722424702; x=1723029502; 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=0Bnh2khxE06uRGlglbrZqD8PmhxT2BPf5aSSDHqB2mU=; b=MW8mwkk6bhTGA7zi/ev0kmX2VfkF4+xooeoplEyozqtCDygT4WT2Sy04JdlHgzHWjm qaTe2m29QLxI1oxa8tyhS3iJ9DHXMp8d/RF4RxVXwcLDCximYmvPVH7I5R+DhwOCMjxB Q+Y2rqXeQU69wVlcZQrQDf6EvLqs4WT8Pn/pRxkMu530mx1FXPjqJBIHdsa4Rr4anAVI D4YFBXkJAxgsN4HfxGOcRGQSBJLgl7ZY/hb2GxhRnNEISDL1GgE2XXYNORPhrJNKfcIm dQL/aPa1R7bG6UkeF/10IjyM9/MZINlHdgrgXnb5igUEqM50m2GeaJtZFmUz7mDGjvgB TOtA== X-Gm-Message-State: AOJu0YyNI+3pmJ6CEqrsy1BYqZ1xItcLsvjzYZw6NjIhcEdjrTNk8aQY 9a/Y0RrzF/qQgXCqIau+sbYLVjF/Tb+8WH98KIcvxKo6weF9AL/QNUdQ80293Jjx9nfrhKxl24T qftnsEttxKJHnHHXywe9P14LDd55qLG0RftxyqumiFxPBD/MURzG12J1xfctKN/W62QSs9UPceq BZMkNeGwIJezq05IGErtLtXTAi8A64iPBYK8vx X-Received: by 2002:a17:907:3f23:b0:a7a:a4be:2f95 with SMTP id a640c23a62f3a-a7d3fdb6696mr1138242266b.5.1722424702632; Wed, 31 Jul 2024 04:18:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGRYsE9dnpqXe/IuPJvNHRIYHejj7MEooJagaN1SWluCATfzErb1yyMtGrZsLLtGG4jxTvgIA== X-Received: by 2002:a17:907:3f23:b0:a7a:a4be:2f95 with SMTP id a640c23a62f3a-a7d3fdb6696mr1138239866b.5.1722424702200; Wed, 31 Jul 2024 04:18:22 -0700 (PDT) Received: from avogadro.local ([151.95.101.29]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acada27ddsm749995166b.184.2024.07.31.04.18.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 04:18:21 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Zhao Liu Subject: [PULL 05/10] target/i386/cpu: Add dependencies of CPUID 0x12 leaves Date: Wed, 31 Jul 2024 13:18:01 +0200 Message-ID: <20240731111806.167225-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240731111806.167225-1-pbonzini@redhat.com> References: <20240731111806.167225-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.126, 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_H3=0.001, RCVD_IN_MSPIKE_WL=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Zhao Liu As SDM stated, CPUID 0x12 leaves depend on CPUID_7_0_EBX_SGX (SGX feature word). Since FEAT_SGX_12_0_EAX, FEAT_SGX_12_0_EBX and FEAT_SGX_12_1_EAX define multiple feature words, add the dependencies of those registers to report the warning to user if SGX is absent. Signed-off-by: Zhao Liu Link: https://lore.kernel.org/r/20240730045544.2516284-4-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index e864f55d4fc..28b46ef536f 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1734,6 +1734,18 @@ static FeatureDep feature_dependencies[] = { .from = { FEAT_7_0_EBX, CPUID_7_0_EBX_SGX }, .to = { FEAT_7_0_ECX, CPUID_7_0_ECX_SGX_LC }, }, + { + .from = { FEAT_7_0_EBX, CPUID_7_0_EBX_SGX }, + .to = { FEAT_SGX_12_0_EAX, ~0ull }, + }, + { + .from = { FEAT_7_0_EBX, CPUID_7_0_EBX_SGX }, + .to = { FEAT_SGX_12_0_EBX, ~0ull }, + }, + { + .from = { FEAT_7_0_EBX, CPUID_7_0_EBX_SGX }, + .to = { FEAT_SGX_12_1_EAX, ~0ull }, + }, }; typedef struct X86RegisterInfo32 { From patchwork Wed Jul 31 11:18:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13748561 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BFE7CC3DA64 for ; Wed, 31 Jul 2024 11:20:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZ7Ls-00063K-Nr; Wed, 31 Jul 2024 07:18:40 -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 1sZ7Lp-0005qn-7z for qemu-devel@nongnu.org; Wed, 31 Jul 2024 07:18:37 -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 1sZ7Ln-0006n6-FN for qemu-devel@nongnu.org; Wed, 31 Jul 2024 07:18:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722424714; 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=D3GWXk89dFoCnN0qZrsb3fQ2QxGZwcvcR/+7hFQmEt0=; b=R8MN1KnpJu51lprFVhmlyyR3c3qgPHiwwdUmhGhKZuqxerfTWKrmmuXrLT4Av8O/v8DjGS 26jIXASiU0pjVXlanHMEkHdm0dJLBWw6/nd/kWJztxdPVALIYgcgb1a3h4IuUfGQoj/b/X +Dmqd2I/MGQhxyyF2Vj22DFKWGGFKtA= 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-328-7KxeTYmOMqqjzgSRFg7Ccg-1; Wed, 31 Jul 2024 07:18:28 -0400 X-MC-Unique: 7KxeTYmOMqqjzgSRFg7Ccg-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5a7b5bd019cso5549982a12.0 for ; Wed, 31 Jul 2024 04:18:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722424705; x=1723029505; 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=D3GWXk89dFoCnN0qZrsb3fQ2QxGZwcvcR/+7hFQmEt0=; b=BVZwBScqx5iEo9N1p/9T76fHVZ3rIXsni8kFcMAQBhbE1wBiFEotlODOm3oHaFudF/ DZoFNfpnoVCVz+hQp9LH8AHxFpMnJkPNTu8Dywh7MH/yu2qsUrZ14jfJips3Oz1omo0f Sais+JcEkdHtGtsyq2Bs0+reMqGzmW4sUD+4KnnuUcIaxhdYrZ75HKARb/gMx5mHsD0T t0NHRiTf3mDHe2GaYL7VFbqjxrsxi8H4CuIDfSEbwcAKJiZkH2xU5LM75A6KOTgLY3Ww 9MC2QY1tNocK3UwZz7H3x+gWgc1MMxclK54Q0AZ7ogHBIwVogI3XOJu51AjRX6jVlz7w S3PA== X-Gm-Message-State: AOJu0YxixkrhalqkIPZK1dM87TE6LLz0DNQl8jjFvWajGrHq6xPbgOXr ODm9Hx8/2I6nysWSENM9//ZE0q9FZtTvoXCTgy05b9RsbjRBmdM92rOXk1AJrQi0nNkkIBzeyva XTjGC4U8w3Ndsxls3IaMGRareZ3VPbjyklAU7vGdw2rP1I2/Be43HYSFUq+hLKnLthaCdvlteH4 d2JRKGkxC8iye19nWsZFofb0N8lNUEmp0g0gIX X-Received: by 2002:a50:9504:0:b0:57d:4f47:d9ee with SMTP id 4fb4d7f45d1cf-5b0221f0afcmr9571326a12.31.1722424705606; Wed, 31 Jul 2024 04:18:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFcF+AFAG7W2hYI8niZxggMhrLUEleNnv0O4IkDAX34xFe9ShitPIMxEIT5xLTQJuNUC3AWGg== X-Received: by 2002:a50:9504:0:b0:57d:4f47:d9ee with SMTP id 4fb4d7f45d1cf-5b0221f0afcmr9571305a12.31.1722424704991; Wed, 31 Jul 2024 04:18:24 -0700 (PDT) Received: from avogadro.local ([151.95.101.29]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ac65481320sm8494703a12.81.2024.07.31.04.18.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 04:18:24 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Zhao Liu Subject: [PULL 06/10] target/i386/cpu: Mask off SGX/SGX_LC feature words for non-PC machine Date: Wed, 31 Jul 2024 13:18:02 +0200 Message-ID: <20240731111806.167225-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240731111806.167225-1-pbonzini@redhat.com> References: <20240731111806.167225-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.126, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Zhao Liu Only PC machine supports SGX, so mask off SGX related feature words for non-PC machine (microvm). Signed-off-by: Zhao Liu Link: https://lore.kernel.org/r/20240730045544.2516284-5-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini --- include/hw/i386/sgx-epc.h | 1 + hw/i386/sgx-stub.c | 5 +++++ hw/i386/sgx.c | 8 ++++++++ target/i386/cpu.c | 15 +++++++++++++++ 4 files changed, 29 insertions(+) diff --git a/include/hw/i386/sgx-epc.h b/include/hw/i386/sgx-epc.h index 3e00efd870c..41d55da4799 100644 --- a/include/hw/i386/sgx-epc.h +++ b/include/hw/i386/sgx-epc.h @@ -58,6 +58,7 @@ typedef struct SGXEPCState { int nr_sections; } SGXEPCState; +bool check_sgx_support(void); bool sgx_epc_get_section(int section_nr, uint64_t *addr, uint64_t *size); void sgx_epc_build_srat(GArray *table_data); diff --git a/hw/i386/sgx-stub.c b/hw/i386/sgx-stub.c index 16b1dfd90bb..38ff75e9f37 100644 --- a/hw/i386/sgx-stub.c +++ b/hw/i386/sgx-stub.c @@ -32,6 +32,11 @@ void pc_machine_init_sgx_epc(PCMachineState *pcms) memset(&pcms->sgx_epc, 0, sizeof(SGXEPCState)); } +bool check_sgx_support(void) +{ + return false; +} + bool sgx_epc_get_section(int section_nr, uint64_t *addr, uint64_t *size) { return true; diff --git a/hw/i386/sgx.c b/hw/i386/sgx.c index 849472a1286..4900dd414a1 100644 --- a/hw/i386/sgx.c +++ b/hw/i386/sgx.c @@ -266,6 +266,14 @@ void hmp_info_sgx(Monitor *mon, const QDict *qdict) size); } +bool check_sgx_support(void) +{ + if (!object_dynamic_cast(qdev_get_machine(), TYPE_PC_MACHINE)) { + return false; + } + return true; +} + bool sgx_epc_get_section(int section_nr, uint64_t *addr, uint64_t *size) { PCMachineState *pcms = diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 28b46ef536f..85ef7452c04 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6103,6 +6103,21 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *cpu, FeatureWord w) } break; + case FEAT_7_0_EBX: +#ifndef CONFIG_USER_ONLY + if (!check_sgx_support()) { + unavail = CPUID_7_0_EBX_SGX; + } +#endif + break; + case FEAT_7_0_ECX: +#ifndef CONFIG_USER_ONLY + if (!check_sgx_support()) { + unavail = CPUID_7_0_ECX_SGX_LC; + } +#endif + break; + default: break; } From patchwork Wed Jul 31 11:18:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13748553 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BC649C52D54 for ; Wed, 31 Jul 2024 11:19:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZ7Lp-0005qv-QM; Wed, 31 Jul 2024 07:18: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 1sZ7Ln-0005q1-Lo for qemu-devel@nongnu.org; Wed, 31 Jul 2024 07:18: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 1sZ7Ll-0006mr-IF for qemu-devel@nongnu.org; Wed, 31 Jul 2024 07:18:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722424712; 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=DLy0sdEp2Wnrm9eD4P6E+5mw/BzvIrbLw2Ba6SR4iAA=; b=WH8X/Kw0bUHLndjXJ4rzcAxeLe1My41r1A4oFvemydKfgPUeikb+w+K/WjBGEf8r3MWsN2 Qbddw8wrWoHOD0w3vHhDbp9lezmMJMyRxlqvcMssDQ4pweBg3trhPqrH7q/zjJ3Kk/efZl H2xkEcTSz3Y1IMn/PgB4/nmHI2efH/s= 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-402-uITCLyngOCqMHzmmev9jOw-1; Wed, 31 Jul 2024 07:18:29 -0400 X-MC-Unique: uITCLyngOCqMHzmmev9jOw-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a7275e17256so568537866b.0 for ; Wed, 31 Jul 2024 04:18:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722424708; x=1723029508; 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=DLy0sdEp2Wnrm9eD4P6E+5mw/BzvIrbLw2Ba6SR4iAA=; b=Tuthy6cmqdPy0VgwodP7D3jPnYkWCu7xUnE9nPWSczjzXuRXszfCaRNGKoRW8+63xe F3XR0VM4rxmcK4r/uIJ40MDrIcQGKb0SzmbWPOzXHZInAMklIgYCFQNx2gEDAsQDSOgI WAuE6cN5pQ1cnh/qMchFUmXKODSzORyOWKhxzuMisyggubuAns0KGw9pu/onCfppbRS4 IYJpYpLGNH5Ii55IHqNzVVYyZOJRXhV9K6TmBGBWsWLMGD7YNoZXrhdA0mhfgjgbJ3LL GqATYZCvqLgP6rD6OR8U5sCeVZFBJaYVMqS641Vbft3nJJWZoaiwGg6nX2bEvrcNJr9I HhVA== X-Gm-Message-State: AOJu0YxT3EunkmXVwLiAo8t6AIrD2S5sziz8CpWXGEyiACVe+IM9iQSx qBY+fqM0i56FRGI6+Rg9iu4u8KSIRuiNk9atzwXip2Wc3imV0zxzl5gDIq4uDPZGlplgGuuKggm IHCoBIWai+9KcaCLajvRT71Sk09hTdLw3k186PTmm428cqgXlLDESHhbhZ0GPwtsNEmzGY3fR0r BRwFK3ZIMbLDWEXmjNinc2NXuxPmOr2gDrzd/G X-Received: by 2002:a17:906:d54f:b0:a77:de2a:aef7 with SMTP id a640c23a62f3a-a7d40150ad2mr1032012266b.44.1722424708137; Wed, 31 Jul 2024 04:18:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEd6FvfL4RnnSElTY80AYlYfZV9d1vWEZnrHe6i02iCVhI11f10D2a8OGal0TNReq4Uh8ed2g== X-Received: by 2002:a17:906:d54f:b0:a77:de2a:aef7 with SMTP id a640c23a62f3a-a7d40150ad2mr1032010766b.44.1722424707768; Wed, 31 Jul 2024 04:18:27 -0700 (PDT) Received: from avogadro.local ([151.95.101.29]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7d9043ca41sm148185366b.72.2024.07.31.04.18.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 04:18:27 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Anthony Harivel Subject: [PULL 07/10] target/i386: Fix typo that assign same value twice Date: Wed, 31 Jul 2024 13:18:03 +0200 Message-ID: <20240731111806.167225-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240731111806.167225-1-pbonzini@redhat.com> References: <20240731111806.167225-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.126, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Anthony Harivel Should fix: CID 1558553 Signed-off-by: Anthony Harivel Link: https://lore.kernel.org/r/20240726102632.1324432-2-aharivel@redhat.com Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index b4aab9a410b..31f149c9902 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -2694,8 +2694,8 @@ static void *kvm_msr_energy_thread(void *data) while (true) { /* Get all qemu threads id */ - g_autofree pid_t *thread_ids = - thread_ids = vmsr_get_thread_ids(vmsr->pid, &num_threads); + g_autofree pid_t *thread_ids + = vmsr_get_thread_ids(vmsr->pid, &num_threads); if (thread_ids == NULL) { goto clean; From patchwork Wed Jul 31 11:18:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13748556 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2A479C3DA7F for ; Wed, 31 Jul 2024 11:19:36 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZ7Lq-0005vk-Ty; Wed, 31 Jul 2024 07:18: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 1sZ7Lo-0005qU-Q8 for qemu-devel@nongnu.org; Wed, 31 Jul 2024 07:18:37 -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 1sZ7Lm-0006n0-Jd for qemu-devel@nongnu.org; Wed, 31 Jul 2024 07:18:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722424714; 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=18y0TLtURaACI8V2aaTdx66LDye0ViTKACpdUCycGOc=; b=MWZoVF8MdPGpmVoW8Wn9/uDMXVOF1K/IAjxEw6A7SHzWGRZhbHe9uwT18yBASJcExJpxpN IekJvWH0yPpN6A1cabhEvvJWpq2MuLq5CJhAbDSnek/lEOCFtqhQGpOIjH0kCsZyKFilsM bH8j1TofYkxQCv5SSIMgeUR8Sj2/8Mc= 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-62-mZP7SxbPNEe1Dib0YLDEdA-1; Wed, 31 Jul 2024 07:18:32 -0400 X-MC-Unique: mZP7SxbPNEe1Dib0YLDEdA-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a7d2f42df2dso112414866b.1 for ; Wed, 31 Jul 2024 04:18:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722424711; x=1723029511; 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=18y0TLtURaACI8V2aaTdx66LDye0ViTKACpdUCycGOc=; b=b5Jr5BQUvuKhIi22yqDengmRDEgJ/nc67LXhACCXOWyCfrVvReLOeIKBUn5teyG5aW D4Ubk4J1AKyLSImTyCTtgkWH4im8tvbcEqcMGUgtGY/rNFqHSQdl95c1wIlZuNbGQOQ3 /n/nKBdsKza6elEzSWvPxEQyx9BzYL21C2ec5qqBSStZspBxp8soUnFYeKfVnuioo1at GQ+xSTS+83qFSNCjb2RsbF8FBanL8hoks74yPPuVH6eb0XMyiu4IcWkbxE4DxmzkOIPO phclIP1RuHMnDL4vrbgilJJc+ULeYCAtDkWdNgYQ5hf0d7881t7Y9X0coDrCRpbOoSo9 a+gA== X-Gm-Message-State: AOJu0Yx+WOXXAxKxZJiYZ2MXADuhJYPJ0hITYpoEvl61Eo2oeHi6nIRA Zv9dgIWcISc4QuFulqra8Al+dMBVvnkuou3PpvvvldM/akth/bejOKMpbDRHQX0NimcFanvwIRJ P2tCzSvnI8uCNYZf41NduKgiflXd9azS+vVtVgPt8UffrSs3q8Je2NGIk22DxralEuFIPfinqT0 Gc/kiNkjpESXpbzBai5ZLJgurP8CtC8dWN0bTX X-Received: by 2002:a17:906:ee88:b0:a72:7b17:5d68 with SMTP id a640c23a62f3a-a7d858bb113mr453611066b.3.1722424710969; Wed, 31 Jul 2024 04:18:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGFrpNWcr2QiySQj46ryyYBfW4GM0BDhjlW41oxX5veSGug3PpZi9xTYcCb6m1pC3vXggA/FA== X-Received: by 2002:a17:906:ee88:b0:a72:7b17:5d68 with SMTP id a640c23a62f3a-a7d858bb113mr453609066b.3.1722424710518; Wed, 31 Jul 2024 04:18:30 -0700 (PDT) Received: from avogadro.local ([151.95.101.29]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acadb9a12sm753487266b.213.2024.07.31.04.18.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 04:18:30 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Anthony Harivel Subject: [PULL 08/10] target/i386: Clean up error cases for vmsr_read_thread_stat() Date: Wed, 31 Jul 2024 13:18:04 +0200 Message-ID: <20240731111806.167225-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240731111806.167225-1-pbonzini@redhat.com> References: <20240731111806.167225-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.126, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Anthony Harivel Fix leaking memory of file handle in case of error Erase unused "pid = -1" Add clearer error_report Should fix Coverity CID 1558557. Signed-off-by: Anthony Harivel Link: https://lore.kernel.org/r/20240726102632.1324432-3-aharivel@redhat.com Signed-off-by: Paolo Bonzini --- target/i386/kvm/vmsr_energy.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/target/i386/kvm/vmsr_energy.c b/target/i386/kvm/vmsr_energy.c index a1d78f2f2ae..7e064c5aef3 100644 --- a/target/i386/kvm/vmsr_energy.c +++ b/target/i386/kvm/vmsr_energy.c @@ -270,7 +270,7 @@ void vmsr_read_thread_stat(pid_t pid, FILE *file = fopen(path, "r"); if (file == NULL) { - pid = -1; + error_report("Error opening %s", path_name); return; } @@ -279,7 +279,8 @@ void vmsr_read_thread_stat(pid_t pid, " %*u %*u %*u %*u %*u %*u %*u %*u %*u %*d %*u %*u %u", utime, stime, cpu_id) != 3) { - pid = -1; + fclose(file); + error_report("Error fscanf did not report the right amount of items"); return; } From patchwork Wed Jul 31 11:18:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13748559 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5D565C3DA7F for ; Wed, 31 Jul 2024 11:19:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZ7MC-0006fN-93; Wed, 31 Jul 2024 07:19:00 -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 1sZ7MA-0006dl-Rn for qemu-devel@nongnu.org; Wed, 31 Jul 2024 07:18:58 -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 1sZ7M9-0006pr-GF for qemu-devel@nongnu.org; Wed, 31 Jul 2024 07:18:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722424736; 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=mVez8TyHo7hNenUkEAcWhE2tawtL+vOCnY0ZoqSQIew=; b=d6k+dRs44Yfz4ThblBHX604BeXMa4X6z8yuTuK4l1dFYGBS92sAlzxSn1D6yIZ1BF1TFFL yreNLkbo6TvCnRyhnTbj2RGZqPmWhGO4SQeo0nwFCXHTle4QGiBACU6OOktyocEMlwmmv0 sgIm2rCrpibisPeBfhZS1o1uYUSbL1E= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-605-p-ww0tNsMAyJTxLCtZZq1g-1; Wed, 31 Jul 2024 07:18:53 -0400 X-MC-Unique: p-ww0tNsMAyJTxLCtZZq1g-1 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-5a2ceb035f9so1157871a12.0 for ; Wed, 31 Jul 2024 04:18:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722424732; x=1723029532; 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=mVez8TyHo7hNenUkEAcWhE2tawtL+vOCnY0ZoqSQIew=; b=HwG9HH/JJcDzC76SxeHNqIguO7C3OygGQYXBkUcHLP+WnNP2dhVlPVWeChS+uUlgO2 ioqaHXRugfl/ZO5eKBuIkUxi7nJIYtimdBCE368vyIPmcuY1B50BaYnRu9FmTbC0H01i BmO6Zu98XEvhwRERGAAdzW+Jhh1OSu6wAS4oYOV+zI153Ni8AwiXv9N3BjfJz0Cjuquu fDh1SxhaUjhdNjP1f3x9WaflJreXOF2krwSKTX7NU9SNOGEeUFeIYdx7tX276MICyocu RXR5NKFQGYhXEws7ljU5lZLdBuk2QiamXqGseBJzVnsMEL5W+ZAEmnq0rwnG1o/fJGJv cHQQ== X-Gm-Message-State: AOJu0YyLx7Pxjo47wEtxeRYTyRwOJIdrkpMzYyQmPQmx718mDmP5LJOK vn8J/4ZxxSGuk5Xw50jkqo9dI/uoPO2nRShdw9I4k1oI/LWkV0YXxi5E0HFPwO2iyK9kaqo0Jqc MUcV8HF7qavLuS2ISUj0e+YzkgQCINYXb/zJTev3apZVizY0+GfTEsXOqvhJwsXQ5Uk7eXdxSUn ZsteOJ8+fg0wEb+NKwqh2idlNsv8y1OO4zWhCR X-Received: by 2002:a50:c08a:0:b0:59c:50c3:af65 with SMTP id 4fb4d7f45d1cf-5b46ca289c3mr4398819a12.14.1722424732041; Wed, 31 Jul 2024 04:18:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF0/9R4hN4m/6w66/xqgyBcFI3rVGskcB8eVM72vvXb/NGiYh5ZQvZUY+xl7gLxdI/zlM7epA== X-Received: by 2002:a50:c08a:0:b0:59c:50c3:af65 with SMTP id 4fb4d7f45d1cf-5b46ca289c3mr4398182a12.14.1722424713579; Wed, 31 Jul 2024 04:18:33 -0700 (PDT) Received: from avogadro.local ([151.95.101.29]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5b52ab8f09dsm1517584a12.26.2024.07.31.04.18.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 04:18:32 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 09/10] qemu-vmsr-helper: fix socket loop breakage Date: Wed, 31 Jul 2024 13:18:05 +0200 Message-ID: <20240731111806.167225-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240731111806.167225-1-pbonzini@redhat.com> References: <20240731111806.167225-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.126, 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_H3=0.001, RCVD_IN_MSPIKE_WL=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Between v5 and v6 of the series, the socket loop of qemu-vmsr-helper was changed to allow sending multiple requests on the same socket. Unfortunately, the condition of the while loop is botched and the loop will never be entered. Clean it up, and also unify the handling of error reporting. Signed-off-by: Paolo Bonzini --- tools/i386/qemu-vmsr-helper.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tools/i386/qemu-vmsr-helper.c b/tools/i386/qemu-vmsr-helper.c index ebf562c3ff8..585eaf88b37 100644 --- a/tools/i386/qemu-vmsr-helper.c +++ b/tools/i386/qemu-vmsr-helper.c @@ -227,19 +227,17 @@ static void coroutine_fn vh_co_entry(void *opaque) &peer_pid, &local_err); if (r < 0) { - error_report_err(local_err); goto out; } - while (r < 0) { + for (;;) { /* * Read the requested MSR * Only RAPL MSR in rapl-msr-index.h is allowed */ - r = qio_channel_read_all(QIO_CHANNEL(client->ioc), - (char *) &request, sizeof(request), &local_err); - if (r < 0) { - error_report_err(local_err); + r = qio_channel_read_all_eof(QIO_CHANNEL(client->ioc), + (char *) &request, sizeof(request), &local_err); + if (r <= 0) { break; } @@ -261,11 +259,15 @@ static void coroutine_fn vh_co_entry(void *opaque) sizeof(vmsr), &local_err); if (r < 0) { - error_report_err(local_err); break; } } + out: + if (local_err) { + error_report_err(local_err); + } + object_unref(OBJECT(client->ioc)); g_free(client); } From patchwork Wed Jul 31 11:18:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13748562 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F10D1C3DA64 for ; Wed, 31 Jul 2024 11:20:13 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZ7MD-0006iL-2K; Wed, 31 Jul 2024 07:19:01 -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 1sZ7MC-0006eu-1a for qemu-devel@nongnu.org; Wed, 31 Jul 2024 07:19:00 -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 1sZ7MA-0006pz-Lj for qemu-devel@nongnu.org; Wed, 31 Jul 2024 07:18:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722424738; 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=EV2mr0xjlD8I0ffhcoIthBmy7Vwwm1tNrboAunzoeDA=; b=LKPwr/pck0uaFPWXR8d7T+7LpPw3p+7sCoyaQ53jFaO61ph1OavMEA1wTJvzFIDg+bhl4b lpty99bkKNpUSiLCsbYuzGTs/QkQ+4Omq35VdSblefmy/La86BiN9efjiBkjW7AjLaIz3e Fo7Uarh1D66ow6gp+BL5LjVtuV9W73Q= 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-629-r-7XXpaIO0qX3M_Oy2I2Kw-1; Wed, 31 Jul 2024 07:18:56 -0400 X-MC-Unique: r-7XXpaIO0qX3M_Oy2I2Kw-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a7a8a38a4bcso248894366b.0 for ; Wed, 31 Jul 2024 04:18:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722424734; x=1723029534; 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=EV2mr0xjlD8I0ffhcoIthBmy7Vwwm1tNrboAunzoeDA=; b=uEvjmnDGRZwyNDRhwPP1awM13cWCCh9gChQ1OuSSd2QCloC7Z6vL4fZaWLD/Di7nZJ Orwo2x/8pAj14NDM6XMGvfYqWzlSqWqSnKaUYTrmiLDlYWw9XaGA/EJTJFCpq4Ln748c plT3TUGJG/NmQ6jfDwjInAnP567pAIWJfnqmSeNQXAEIaa6+DIWLEuO+Ffdt64aVvZpv 9Sdc48mhjCR1o+p1ojgCz2oEMxyspiv7AC2IT1fZKxNkVFuiCaiRLZE/sfFO8z63dLWv JQrlqFLGlubiUvMB+ka1RpOjylKUsXPCmcsEw3o+aiUDkycMvKXQwwipU/LDQTTVBeCx Rbgg== X-Gm-Message-State: AOJu0YxSv6CZLM6GRKVNi1xXb8tBNFjW+dfLTcWnValFyErSt/r3cU/v 9Qxt9c+0Ecxx3GL4vhAR9w34iQUDIDb8joWlhCbWfzUVwMSaPgS2GxdYnlH8//FGIZfUNZtLFEv 2UP+XHsglI+wfe9GjS7fdHhsoZLVBksPDCDz7MRN4gTUxDM+vlUAbCdogYdY6N8GH9xU+ceB9az LbgmgKrzGTW4o+UnAO/bKNTo+6lREf67ObRyHp X-Received: by 2002:a05:6402:26d6:b0:57d:669:caf2 with SMTP id 4fb4d7f45d1cf-5b02317d0a3mr14495172a12.25.1722424734653; Wed, 31 Jul 2024 04:18:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH7zHnVt7DRPrWIor5mqy5dZIgpU/a4Mw86c+ii0dl1hXAuomGRwncvq1aI6v6Bj/amnhQYZw== X-Received: by 2002:a05:6402:26d6:b0:57d:669:caf2 with SMTP id 4fb4d7f45d1cf-5b02317d0a3mr14495160a12.25.1722424734273; Wed, 31 Jul 2024 04:18:54 -0700 (PDT) Received: from avogadro.local ([151.95.101.29]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5afc05c7a44sm6913068a12.6.2024.07.31.04.18.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 04:18:53 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 10/10] qemu-vmsr-helper: implement --verbose/-v Date: Wed, 31 Jul 2024 13:18:06 +0200 Message-ID: <20240731111806.167225-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240731111806.167225-1-pbonzini@redhat.com> References: <20240731111806.167225-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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.126, 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_H3=0.001, RCVD_IN_MSPIKE_WL=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Similar to qemu-pr-helper, do not print errors from the socket handling loop unless a --verbose or -v option is provided explicitly on the command line. Signed-off-by: Paolo Bonzini --- tools/i386/qemu-vmsr-helper.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/i386/qemu-vmsr-helper.c b/tools/i386/qemu-vmsr-helper.c index 585eaf88b37..a35dcb88a3f 100644 --- a/tools/i386/qemu-vmsr-helper.c +++ b/tools/i386/qemu-vmsr-helper.c @@ -54,6 +54,7 @@ static enum { RUNNING, TERMINATE, TERMINATING } state; static QIOChannelSocket *server_ioc; static int server_watch; static int num_active_sockets = 1; +static bool verbose; #ifdef CONFIG_LIBCAP_NG static int uid = -1; @@ -265,7 +266,11 @@ static void coroutine_fn vh_co_entry(void *opaque) out: if (local_err) { - error_report_err(local_err); + if (!verbose) { + error_free(local_err); + } else { + error_report_err(local_err); + } } object_unref(OBJECT(client->ioc)); @@ -431,6 +436,9 @@ int main(int argc, char **argv) case 'd': daemonize = true; break; + case 'v': + verbose = true; + break; case 'T': trace_opt_parse(optarg); break;