From nobody Fri Mar 29 06:04:25 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1675259913; cv=none; d=zohomail.com; s=zohoarc; b=mHXo8u9azftFXBje/OYNJH64+fTQuqdFVGp/adWNtCJ5yiV7D2PBeDeTBjI8rGa71qc2SA2b/lgW7VBxmMD8SA9UUjKoAL1aHv6yipsBr2ZgdHs+BaXL+Kjj/jiRI5GbqZgJOtv+9ZFkHBab7BZsh9zjtGBoK85C+Bw3FRCGmFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675259913; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LAlEK0K4mv11Ts4OUBYTr/ODe+SOQ3ZBS+suwD9zHOc=; b=n3+g6m5ve8Fr7Uhenyd772P18jygMj/Lg+v5yJu7jRelts6RoSlDqgLYZyH+RxYrdvBI6uvVMcG9No97YIFWqqeUYNyjD3TdnD/XwHYYsvY+rl5jGoBgGY24g8dxcQ6hv66FahSnm4NOXBGW+vW7Mq+l0IBlk/jBRWF/kAO/t0M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675259913477522.1369291189008; Wed, 1 Feb 2023 05:58:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNDcm-0006Wr-4v; Wed, 01 Feb 2023 08:58:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNDcj-0006RM-VK for qemu-devel@nongnu.org; Wed, 01 Feb 2023 08:58:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNDci-000308-AG for qemu-devel@nongnu.org; Wed, 01 Feb 2023 08:58:05 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-564-dhNNBnUbNMKodu4UHWu8hQ-1; Wed, 01 Feb 2023 08:58:02 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BD6C9100DEA1; Wed, 1 Feb 2023 13:58:01 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8642640ED784; Wed, 1 Feb 2023 13:58:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675259883; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LAlEK0K4mv11Ts4OUBYTr/ODe+SOQ3ZBS+suwD9zHOc=; b=Vd2J4vvl91Nrnp/ttW/247Q/9jJdpXozyl7xsiKJiUZCOMylWg5wNWTwpfItjHnJFyhgHi uNGOe2OIIyf4pED31P6ofzINk7kO3Pq37ULS2B4UWu/5VJk0a99KbdmoI/E8HwCXhH3ngk 1RYSwxNZlsDoPcE+lMM49keNDoGyP48= X-MC-Unique: dhNNBnUbNMKodu4UHWu8hQ-1 From: Emanuele Giuseppe Esposito To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Richard Henderson , Maxim Levitsky , Yang Zhong , Vitaly Kuznetsov , Jing Liu , Emanuele Giuseppe Esposito Subject: [PATCH 1/2] target/i386: add support for FLUSH_L1D feature Date: Wed, 1 Feb 2023 08:57:58 -0500 Message-Id: <20230201135759.555607-2-eesposit@redhat.com> In-Reply-To: <20230201135759.555607-1-eesposit@redhat.com> References: <20230201135759.555607-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eesposit@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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1675259915021100005 Content-Type: text/plain; charset="utf-8" As reported by Intel's doc: "L1D_FLUSH: Writeback and invalidate the L1 data cache" If this cpu feature is present in host, allow QEMU to choose whether to show it to the guest too. One disadvantage of not exposing it is that the guest will report a non existing vulnerability in /sys/devices/system/cpu/vulnerabilities/mmio_stale_data because the mitigation is present only when the cpu has (FLUSH_L1D and MD_CLEAR) or FB_CLEAR features enabled. Signed-off-by: Emanuele Giuseppe Esposito --- target/i386/cpu.h | 2 ++ target/i386/cpu.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index d4bc19577a..4948130900 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -889,6 +889,8 @@ uint64_t x86_cpu_get_supported_feature_word(FeatureWord= w, #define CPUID_7_0_EDX_SPEC_CTRL (1U << 26) /* Single Thread Indirect Branch Predictors */ #define CPUID_7_0_EDX_STIBP (1U << 27) +/* Flush L1D cache */ +#define CPUID_7_0_EDX_FLUSH_L1D (1U << 28) /* Arch Capabilities */ #define CPUID_7_0_EDX_ARCH_CAPABILITIES (1U << 29) /* Core Capability */ diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 4d2b8d0444..390120cad8 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -858,7 +858,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D { "tsx-ldtrk", NULL, NULL /* pconfig */, "arch-lbr", NULL, NULL, "amx-bf16", "avx512-fp16", "amx-tile", "amx-int8", "spec-ctrl", "stibp", - NULL, "arch-capabilities", "core-capability", "ssbd", + "flush-l1d", "arch-capabilities", "core-capability", "ssbd", }, .cpuid =3D { .eax =3D 7, --=20 2.39.1 From nobody Fri Mar 29 06:04:25 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1675259914; cv=none; d=zohomail.com; s=zohoarc; b=WgMyWkfj+5DoU3SODb3GDyUTpJaJwBBOAIiMByX7/UJHMcKYu4O2gcClY0sFiLR/mshNecZQvar9Jv4My7Akva5Ay8D470jwhke6NvdhgzjRNPgWyqFmYQLIio1mFTBIuEkcczEBUAxYYLMbeuTGYDjmmn5OnMV1OqCy5Y+saB8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675259914; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6E43QDqsPyPDXX60KATrLVlrphoW+MpFw34uTLFnIbA=; b=k+vkVurRc2buqzWgDgnVQQpGp1bkwOO3qfbn5R5iFV00DuIvz6r+proDvucQSaA4l6hyYa3vCRZZJfTM5Q+L6Dp47eGw+pAz4xJjlsMBLfLOOnFi9nYwHrYKd3o2jwd97QICqk3KnW8k98SVSrfvc9wBK5TgW6DM5dC/8Ykr02Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16752599142761.6446235361656818; Wed, 1 Feb 2023 05:58:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNDcv-0006lj-6O; Wed, 01 Feb 2023 08:58:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNDct-0006l7-9m for qemu-devel@nongnu.org; Wed, 01 Feb 2023 08:58:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNDcr-00033r-RA for qemu-devel@nongnu.org; Wed, 01 Feb 2023 08:58:15 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-464-ufRD_46yOUerd24msxYMvA-1; Wed, 01 Feb 2023 08:58:02 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 09D5F3C218A0; Wed, 1 Feb 2023 13:58:02 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6AE040E4314; Wed, 1 Feb 2023 13:58:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675259893; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6E43QDqsPyPDXX60KATrLVlrphoW+MpFw34uTLFnIbA=; b=HwU/qCEqsWv8OFY/RCRfcyy09t+OfQ/Puu5p+NCaIEprf9tPoczE45wcdM8TLa0JhZmAl2 v9cEGXBo881iZU0IuXy1yK7WCFCa0Y5LDGqs5Ox3MVdygxgyHMYcuLw9cybZVGnql+67rx nym2jmLSSyywjpwhXlVEdN3rz4kGSPM= X-MC-Unique: ufRD_46yOUerd24msxYMvA-1 From: Emanuele Giuseppe Esposito To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Richard Henderson , Maxim Levitsky , Yang Zhong , Vitaly Kuznetsov , Jing Liu , Emanuele Giuseppe Esposito Subject: [PATCH 2/2] target/i386: add support for FB_CLEAR feature Date: Wed, 1 Feb 2023 08:57:59 -0500 Message-Id: <20230201135759.555607-3-eesposit@redhat.com> In-Reply-To: <20230201135759.555607-1-eesposit@redhat.com> References: <20230201135759.555607-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eesposit@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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1675259915022100006 Content-Type: text/plain; charset="utf-8" As reported by the Intel's doc: "FB_CLEAR: The processor will overwrite fill buffer values as part of MD_CLEAR operations with the VERW instruction. On these processors, L1D_FLUSH does not overwrite fill buffer values." If this cpu feature is present in host, allow QEMU to choose whether to show it to the guest too. One disadvantage of not exposing it is that the guest will report a non existing vulnerability in /sys/devices/system/cpu/vulnerabilities/mmio_stale_data because the mitigation is present only when the cpu has (FLUSH_L1D and MD_CLEAR) or FB_CLEAR features enabled. Signed-off-by: Emanuele Giuseppe Esposito --- target/i386/cpu.h | 1 + target/i386/cpu.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 4948130900..68a6ded0d7 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -975,6 +975,7 @@ uint64_t x86_cpu_get_supported_feature_word(FeatureWord= w, #define MSR_ARCH_CAP_PSCHANGE_MC_NO (1U << 6) #define MSR_ARCH_CAP_TSX_CTRL_MSR (1U << 7) #define MSR_ARCH_CAP_TAA_NO (1U << 8) +#define MSR_ARCH_CAP_FB_CLEAR (1U << 17) =20 #define MSR_CORE_CAP_SPLIT_LOCK_DETECT (1U << 5) =20 diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 390120cad8..1405eb42d6 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1010,7 +1010,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D { "ssb-no", "mds-no", "pschange-mc-no", "tsx-ctrl", "taa-no", NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, + NULL, "fb-clear", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, --=20 2.39.1