From nobody Fri Dec 19 17:32:24 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1733302161; cv=none; d=zohomail.com; s=zohoarc; b=nishLR/gkQAqv2gOpdFiw3If3+gqzDE8+peR5/XYizlmyM40HDIykkng45u7DGDQxlK6l1wwYMdOapR/F87gCVgSDv1yzGyf7r/gRZJCPSpiFCS7q5s44kmKgYYm78ZL3JMQShbfMPiix+UVfK1j3eu0kj73MhH20BpNmGQBiaE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1733302161; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=139eJ467S0+ud6wwoqOA+04OQp0idjTX9nXsFXEiqo4=; b=aE4CAju99raMEhZJEGcgwv5OZTdd4pJCoRykNWfv3uQAPr0MLGR7uish60IyLfj51umHCO5UiduC2gxufNEh7I8Na/LlppB4BNweXmXBjaXX3EqoxIfv+ADVdgGk2h/XbB4APJ4VTRxfNhbO/CAuNGAZrYNgWsPc3WM7DUYKPm0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1733302161906603.6723636220422; Wed, 4 Dec 2024 00:49:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIl3z-00008x-V8; Wed, 04 Dec 2024 03:48:51 -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 <3bRdQZwgKCh4QB8H7LCEAIIAF8.6IGK8GO-78P8FHIHAHO.ILA@flex--whendrik.bounces.google.com>) id 1tIl3x-00005c-Jr for qemu-devel@nongnu.org; Wed, 04 Dec 2024 03:48:49 -0500 Received: from mail-wm1-x34a.google.com ([2a00:1450:4864:20::34a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3bRdQZwgKCh4QB8H7LCEAIIAF8.6IGK8GO-78P8FHIHAHO.ILA@flex--whendrik.bounces.google.com>) id 1tIl3v-00010j-RR for qemu-devel@nongnu.org; Wed, 04 Dec 2024 03:48:49 -0500 Received: by mail-wm1-x34a.google.com with SMTP id 5b1f17b1804b1-4349e97bfc4so60197595e9.3 for ; Wed, 04 Dec 2024 00:48:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733302126; x=1733906926; darn=nongnu.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=139eJ467S0+ud6wwoqOA+04OQp0idjTX9nXsFXEiqo4=; b=3xol754HROCyFX3Oimb4AhCARlm6IREMjJ+JEndwCWEqu3n7ZFKEs7U2R5aYmbezAD 7Q5b8D72ytuxTTZnUuXQRVzFUzhS+SGetkhmfFm/mkVC1VnIwGGjyNkgC4oUbibQaWwV /znr0bGsziB5JSjbkMZiQEa+R4szbF7T9rED76144bHji2FW5BgJX0KrWyvOqbSVnpjt nJ9tGuOsH0DFrLYiK3ylRd2X5uULV9SQsazgMRDJf5xTbiOcq94FZCyI/J0AsLBTa1fU CA1Anjs/BI0zn6mJuBEzw+Uj5D/J75I8ooyRKKbSAssnLAmGlXt92b4uH264lwOOiVH+ yDaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733302126; x=1733906926; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=139eJ467S0+ud6wwoqOA+04OQp0idjTX9nXsFXEiqo4=; b=YWhXPCugJTI1a/N5bqaEAfdlAG5vtUrKH9UYrqeN4pdtg1vaDTuyDOk+R5EpeLZU7c 7g0k9/E7w9D3MZP5aW3xDn1r1CAab+cFoCVMMf7IdnuYODgoozCqikTrZheSsKm9/KzE yxmlunMQ2YZSAEQYhSBrXK1AOxB7xmpvS3/e2/h9NCjV0PF54YExDlLnZuC+u5krrHCZ yeKjgeyjNbcxOs/8WGmxf3n437anrtxVlSsgAHZ6mF8Qm7VNzx7TA8Dj/I2M/YLj/Cig Vm9M85zLSYexU3bVtz4JZcXFiNdGnrSNn1gRJ7g1Whkjf0NXN3Czk0k1q12Qls6Q+AGj 2KqA== X-Gm-Message-State: AOJu0Ywm3oyNJhQGLWfYPfSvE78e9y1q/pbz7Th0/7tBVxD4GXkB3fTJ beumAinUs81khMIlU2uFYU8BH/yoAxCTA/Ku3vwtNQdghH9uv5K09esQNwHgDYEdBfTxJPkRnCO V3HWR3JcATeEgTyjNVWSuX0KUw7GqgyRFXidfvjUPzNi+MwiWrWwf3vx1D3A0aVXtpDDUtM31lc 445z4sI5Y9VnivSbs+PmWc2SxqkMNZp67z/o/owUcGXw== X-Google-Smtp-Source: AGHT+IGn3gBumleApIgsT05daGDt4z2wpuEy2AgXXAFxJQI/PZ6KbE2dtn9k06oiivsHp+xhuhwi72t/EgRhOg== X-Received: from wmil16.prod.google.com ([2002:a7b:c450:0:b0:434:a08d:7adb]) (user=whendrik job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:4fc9:b0:434:a986:11cf with SMTP id 5b1f17b1804b1-434d09c0faamr50818825e9.8.1733302125840; Wed, 04 Dec 2024 00:48:45 -0800 (PST) Date: Wed, 4 Dec 2024 08:48:30 +0000 In-Reply-To: <20241204084837.517299-1-whendrik@google.com> Mime-Version: 1.0 References: <20241204084837.517299-1-whendrik@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241204084837.517299-2-whendrik@google.com> Subject: [PATCH v3 1/8] i386: Add Intel RDT device and State to config. From: Hendrik Wuethrich To: qemu-devel@nongnu.org, Jonathan.Cameron@huawei.com, eduardo@habkost.net, richard.henderson@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com Cc: peternewman@google.com, "=?UTF-8?q?=E2=80=AAHendrik=20W=C3=BCthrich?=" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::34a; envelope-from=3bRdQZwgKCh4QB8H7LCEAIIAF8.6IGK8GO-78P8FHIHAHO.ILA@flex--whendrik.bounces.google.com; helo=mail-wm1-x34a.google.com X-Spam_score_int: -100 X-Spam_score: -10.1 X-Spam_bar: ---------- X-Spam_report: (-10.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.453, 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, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1733302162648116600 Content-Type: text/plain; charset="utf-8" From: =E2=80=AAHendrik W=C3=BCthrich Change config to show RDT, add minimal code to the rdt.c module to make sure things still compile. Signed-off-by: Hendrik W=C3=BCthrich --- hw/i386/Kconfig | 4 ++ hw/i386/meson.build | 1 + hw/i386/rdt.c | 96 +++++++++++++++++++++++++++++++++++++++++++ include/hw/i386/rdt.h | 25 +++++++++++ target/i386/cpu.h | 3 ++ 5 files changed, 129 insertions(+) create mode 100644 hw/i386/rdt.c create mode 100644 include/hw/i386/rdt.h diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig index f4a33b6c08..4dd05ed6f2 100644 --- a/hw/i386/Kconfig +++ b/hw/i386/Kconfig @@ -10,6 +10,9 @@ config SGX bool depends on KVM =20 +config RDT + bool + config PC bool imply APPLESMC @@ -26,6 +29,7 @@ config PC imply QXL imply SEV imply SGX + imply RDT imply TEST_DEVICES imply TPM_CRB imply TPM_TIS_ISA diff --git a/hw/i386/meson.build b/hw/i386/meson.build index 03aad10df7..fdbf5962b5 100644 --- a/hw/i386/meson.build +++ b/hw/i386/meson.build @@ -21,6 +21,7 @@ i386_ss.add(when: 'CONFIG_VMPORT', if_true: files('vmport= .c')) i386_ss.add(when: 'CONFIG_VTD', if_true: files('intel_iommu.c')) i386_ss.add(when: 'CONFIG_SGX', if_true: files('sgx-epc.c','sgx.c'), if_false: files('sgx-stub.c')) +i386_ss.add(when: 'CONFIG_RDT', if_true: files('rdt.c')) =20 i386_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-common.c')) i386_ss.add(when: 'CONFIG_PC', if_true: files( diff --git a/hw/i386/rdt.c b/hw/i386/rdt.c new file mode 100644 index 0000000000..d0afbd04fb --- /dev/null +++ b/hw/i386/rdt.c @@ -0,0 +1,96 @@ +/* + * Intel Resource Director Technology (RDT). + * + * Copyright 2024 Google LLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WIT= HOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "hw/i386/rdt.h" +#include "qemu/osdep.h" /* Needs to be included before isa.h */ +#include "hw/isa/isa.h" +#include "hw/qdev-properties.h" +#include "qom/object.h" + +/* Max counts for allocation masks or CBMs. In other words, the size of re= spective MSRs*/ +#define RDT_MAX_L3_MASK_COUNT 127 +#define RDT_MAX_L2_MASK_COUNT 63 +#define RDT_MAX_MBA_THRTL_COUNT 63 + +#define TYPE_RDT "rdt" +#define RDT_NUM_RMID_PROP "rmids" + +OBJECT_DECLARE_TYPE(RDTState, RDTStateClass, RDT); + +struct RDTMonitor { + uint64_t count_local; + uint64_t count_remote; + uint64_t count_l3; +}; + +struct RDTAllocation { + uint32_t active_cos; +}; + +struct RDTStatePerCore { + uint32_t active_rmid; + GArray *monitors; + + /*Parent RDTState*/ + RDTState *rdtstate; +}; + +/*One instance of RDT-internal state to be shared by all cores*/ +struct RDTState { + ISADevice parent; + + /*Max amount of RMIDs*/ + uint32_t rmids; + + /*Per core state*/ + RDTStatePerCore *rdtInstances; + RDTAllocation *allocations; + + /*RDT Allocation bitmask MSRs*/ + uint32_t msr_L3_ia32_mask_n[RDT_MAX_L3_MASK_COUNT]; + uint32_t msr_L2_ia32_mask_n[RDT_MAX_L2_MASK_COUNT]; + uint32_t ia32_L2_qos_ext_bw_thrtl_n[RDT_MAX_MBA_THRTL_COUNT]; +}; + +struct RDTStateClass { +}; + +OBJECT_DEFINE_TYPE(RDTState, rdt, RDT, ISA_DEVICE); + +static Property rdt_properties[] =3D { + DEFINE_PROP_UINT32(RDT_NUM_RMID_PROP, RDTState, rmids, 256), + DEFINE_PROP_END_OF_LIST(), +}; + +static void rdt_init(Object *obj) +{ +} + +static void rdt_finalize(Object *obj) +{ +} + +static void rdt_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->hotpluggable =3D false; + dc->desc =3D "RDT"; + dc->user_creatable =3D true; + + device_class_set_props(dc, rdt_properties); +} + diff --git a/include/hw/i386/rdt.h b/include/hw/i386/rdt.h new file mode 100644 index 0000000000..a21d95b265 --- /dev/null +++ b/include/hw/i386/rdt.h @@ -0,0 +1,25 @@ +/* + * Intel Resource Director Technology (RDT). + * + * Copyright 2024 Google LLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WIT= HOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#ifndef HW_RDT_H +#define HW_RDT_H + +typedef struct RDTState RDTState; +typedef struct RDTStatePerCore RDTStatePerCore; +typedef struct RDTMonitor RDTMonitor; +typedef struct RDTAllocation RDTAllocation; + +#endif diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 1e121acef5..a2941f98eb 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -2143,6 +2143,9 @@ struct ArchCPU { struct MemoryRegion *cpu_as_root, *cpu_as_mem, *smram; Notifier machine_done; =20 + /* Help the RDT MSRs find the RDT device */ + struct RDTStatePerCore *rdt; + struct kvm_msrs *kvm_msr_buf; =20 int32_t node_id; /* NUMA node this CPU belongs to */ --=20 2.47.0.338.g60cca15819-goog From nobody Fri Dec 19 17:32:24 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1733302156; cv=none; d=zohomail.com; s=zohoarc; b=GtuB9XI6ioTTDD1YDRM14DzaK4NYyFONqKbdVsjVZrE9JkG/KpZSCeqhJPLa7/3sDRlJoJx/aZSeIzAPFSal0KkOIwtrYmY+hy9sYyxPvxbqsgtRet5a5RzD+cqG2BAs8O/Jmvyw1qL/zvo6/cVs2une+Wlby+HCvvpA9cqwOVc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1733302156; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=eXFyctxkBvRei3YT2F3Psi/6Kuihl3jqAhbmBpNvGuM=; b=NlSrLiZAZ/fXe6hk0fzmwwatPdA5T1ERZBXAH34nb9HqkeDNEiytzNneLTt2LTaOTDX4Dx04WQWPJhM5SluM1igv1JXFGops078MZLlxq281V26vYX+pFBmOWoXcj6VjHwwEOzsUNWdy0RO7SPo8cDPphnRG8bxLg1ZcjWWJBWM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1733302156934382.12136963978946; Wed, 4 Dec 2024 00:49:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIl41-00009X-NJ; Wed, 04 Dec 2024 03:48:53 -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 <3bxdQZwgKCiASDAJ9NEGCKKCHA.8KIMAIQ-9ARAHJKJCJQ.KNC@flex--whendrik.bounces.google.com>) id 1tIl3z-00008p-Ew for qemu-devel@nongnu.org; Wed, 04 Dec 2024 03:48:51 -0500 Received: from mail-wm1-x349.google.com ([2a00:1450:4864:20::349]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3bxdQZwgKCiASDAJ9NEGCKKCHA.8KIMAIQ-9ARAHJKJCJQ.KNC@flex--whendrik.bounces.google.com>) id 1tIl3x-00010v-Nb for qemu-devel@nongnu.org; Wed, 04 Dec 2024 03:48:50 -0500 Received: by mail-wm1-x349.google.com with SMTP id 5b1f17b1804b1-43499c1342aso46239015e9.1 for ; Wed, 04 Dec 2024 00:48:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733302127; x=1733906927; darn=nongnu.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=eXFyctxkBvRei3YT2F3Psi/6Kuihl3jqAhbmBpNvGuM=; b=TZlE80/nNO5oWSlfgELYc5IL/qzL7x9budUAwZq5L3Ir1UCYJb6V3vfWeKpU8gj96Z JGKYXlhaV8MA1V1fvl41/8p3SnvwWvj7zRheyXcuD7JKX+u2KL1ijZTXkWCX/vfcWycF HHaj6UIKrR7MIJC6y4/DeOMRQ0enEJG2RI6mu48lKDIOYdIbCJ9S5mSBUAmRUwT0Ra4N WBozmKoHGnfyY9NUMo5RuoavbUvuJnVKw+J4T9zkt2bbShDiKuiD5bW81wY6gFptsuaY eWkt8ePoHsD9+v33JFUVkfSlJ7Cei1Yw2WcsbdWKIaVoiwuuUL20R4XVqhNjUwKLey/t fRTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733302127; x=1733906927; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=eXFyctxkBvRei3YT2F3Psi/6Kuihl3jqAhbmBpNvGuM=; b=mZZcDvIqrkD3qyvsrbbKmgDYX1JU6MiQ8sr7vlN9d0jrBDDZL4ymUuAPAVVfJ3AEfR aM+41JN2eywI+iI6xRA+nXWByvFXvjgX5+9TbDtq/m+Shjn9QvnmXAM00q05tLQJCWUP FAxpXyG77KUIbZ58w0UKz+WhQI+M3Vng7tIgqRn7lo20qY78t1GhGQmb2T/Cgm3/F4fI NuhAZmraEfDb8UPyumXVfaGTjnimkQVTGandrZChx48TCzENOhNM0WdsYUFpZd/8sFeP uXbFxIWPhhGb6ULbEg0cY3a+YQbfxdsAduOXPrMcpvq10DGehZrFwjZjrakQLieXJkc7 +Viw== X-Gm-Message-State: AOJu0Yy1+3gcD7A2Putw1Bu451LVkLwIcdMSQg2gYZ8lFnTQo0PvKLCN 1GdxPHkcHfa2TTDE7GapX38uNohztZiXgdMADdfqkxupKeGZ63we+PV/vEn3A2w10MdS9BOvUE8 0nLkLCb7AKzMXRsGMdka+jgZA5YpLfILHW7SSElpjyl/B5BfRo2jMGBHHAW0TY8t2QdJiw1bnI1 00Pczk5Z+qeaPDaG2ZNrtM9Gmzpg4augXKGSydJPDOTg== X-Google-Smtp-Source: AGHT+IEeb/qA9CjVD/EtGV5Vv6wdQVNVRuFh1CKbS4Mk09hSGcPizyl7dIPDUDGbepSk2jFZemgSweIeW5KIzg== X-Received: from wmo26.prod.google.com ([2002:a05:600c:231a:b0:434:a028:7b9a]) (user=whendrik job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:3ba1:b0:434:9dfe:20e6 with SMTP id 5b1f17b1804b1-434d4102563mr24065855e9.23.1733302127655; Wed, 04 Dec 2024 00:48:47 -0800 (PST) Date: Wed, 4 Dec 2024 08:48:31 +0000 In-Reply-To: <20241204084837.517299-1-whendrik@google.com> Mime-Version: 1.0 References: <20241204084837.517299-1-whendrik@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241204084837.517299-3-whendrik@google.com> Subject: [PATCH v3 2/8] i386: Add init and realize funciontality for RDT device. From: Hendrik Wuethrich To: qemu-devel@nongnu.org, Jonathan.Cameron@huawei.com, eduardo@habkost.net, richard.henderson@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com Cc: peternewman@google.com, "=?UTF-8?q?=E2=80=AAHendrik=20W=C3=BCthrich?=" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::349; envelope-from=3bxdQZwgKCiASDAJ9NEGCKKCHA.8KIMAIQ-9ARAHJKJCJQ.KNC@flex--whendrik.bounces.google.com; helo=mail-wm1-x349.google.com X-Spam_score_int: -100 X-Spam_score: -10.1 X-Spam_bar: ---------- X-Spam_report: (-10.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.453, 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, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1733302158512116600 Content-Type: text/plain; charset="utf-8" From: =E2=80=AAHendrik W=C3=BCthrich Add code to initialize all necessary state for the RDT device. Signed-off-by: Hendrik W=C3=BCthrich --- hw/i386/rdt.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/hw/i386/rdt.c b/hw/i386/rdt.c index d0afbd04fb..2fb9fb476b 100644 --- a/hw/i386/rdt.c +++ b/hw/i386/rdt.c @@ -19,6 +19,7 @@ #include "hw/isa/isa.h" #include "hw/qdev-properties.h" #include "qom/object.h" +#include "target/i386/cpu.h" =20 /* Max counts for allocation masks or CBMs. In other words, the size of re= spective MSRs*/ #define RDT_MAX_L3_MASK_COUNT 127 @@ -79,8 +80,36 @@ static void rdt_init(Object *obj) { } =20 +static void rdt_realize(DeviceState *dev, Error **errp) +{ + CPUState *cs =3D first_cpu; + RDTState *rdtDev =3D RDT(dev); + + rdtDev->rdtInstances =3D g_malloc(sizeof(RDTStatePerCore) * cs->nr_cor= es); + CPU_FOREACH(cs) { + RDTStatePerCore *rdt =3D &rdtDev->rdtInstances[cs->cpu_index]; + X86CPU *cpu =3D X86_CPU(cs); + + rdt->rdtstate =3D rdtDev; + cpu->rdt =3D rdt; + + rdt->monitors =3D g_malloc(sizeof(RDTMonitor) * rdtDev->rmids); + rdt->rdtstate->allocations =3D g_malloc(sizeof(RDTAllocation) * rd= tDev->rmids); + } +} + static void rdt_finalize(Object *obj) { + CPUState *cs; + RDTState *rdt =3D RDT(obj); + + CPU_FOREACH(cs) { + RDTStatePerCore *rdtInstance =3D &rdt->rdtInstances[cs->cpu_index]; + g_free(rdtInstance->monitors); + g_free(rdtInstance->rdtstate->allocations); + } + + g_free(rdt->rdtInstances); } =20 static void rdt_class_init(ObjectClass *klass, void *data) @@ -90,6 +119,7 @@ static void rdt_class_init(ObjectClass *klass, void *dat= a) dc->hotpluggable =3D false; dc->desc =3D "RDT"; dc->user_creatable =3D true; + dc->realize =3D rdt_realize; =20 device_class_set_props(dc, rdt_properties); } --=20 2.47.0.338.g60cca15819-goog From nobody Fri Dec 19 17:32:24 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1733302166; cv=none; d=zohomail.com; s=zohoarc; b=PkOTRmyJGbIV/a5n7B+EKoRPqTQb3rkugjyAnkZUR2WqytKcGm/PHMsSYoB7Tk+wpymehXlIqeIo7VRbKJbOXlFubi5PPvCExQtrYaidalLhV+llp/Wi9KMuygrl7xppheez2stxFR2EznGRfjcvybvUykCRwtWxeWxSEFH3FCA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1733302166; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sCZcKH4Kr7ShBFnIBULtC4cA/q7iBWqSRHDgtiBni9Y=; b=Cl/85rNFeZfn9hhSrubUYESS5GPUowN6f931YBHcWwq8rJb7fro9LgENScnG7j18yCNEQOJm/cGKU1+ZXOQ+r9qO0UnJ67HV2LGiupmXr4fQ+OCKC06PlTDBa9L+LXh1iZkXiOdKuydnZMMThAUyIa5qPm83d82/gA/IddXT+u0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1733302166399652.7866477923614; Wed, 4 Dec 2024 00:49:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIl42-0000Am-JX; Wed, 04 Dec 2024 03:48:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3cRdQZwgKCiIUFCLBPGIEMMEJC.AMKOCKS-BCTCJLMLELS.MPE@flex--whendrik.bounces.google.com>) id 1tIl41-00009a-G9 for qemu-devel@nongnu.org; Wed, 04 Dec 2024 03:48:53 -0500 Received: from mail-wm1-x34a.google.com ([2a00:1450:4864:20::34a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3cRdQZwgKCiIUFCLBPGIEMMEJC.AMKOCKS-BCTCJLMLELS.MPE@flex--whendrik.bounces.google.com>) id 1tIl3z-000115-MJ for qemu-devel@nongnu.org; Wed, 04 Dec 2024 03:48:53 -0500 Received: by mail-wm1-x34a.google.com with SMTP id 5b1f17b1804b1-434941aa9c2so36879785e9.3 for ; Wed, 04 Dec 2024 00:48:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733302129; x=1733906929; darn=nongnu.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=sCZcKH4Kr7ShBFnIBULtC4cA/q7iBWqSRHDgtiBni9Y=; b=hd+o41kHBUb0hFBS+zNinEa24Ugbk01G0pTbrvp45nhKc0WP4dvCatb66Ag6NI8mAZ dO0LAvYtGcZSv24eY7SVAqkhcZNUldrCsknwGQr716hdbuP21/rLwwWByYCjP/HF+LSy 0O4CMI3roAlDnVIGpx5TBZvsWyvV84p7hULYn/GMbCfJkNhCrQsW2Yh+dBoFCEgmSTm4 1gOgKiNp/8gw1FQTbSehiMMIfNNsqeKtU4y4vqCU7Ysr8qkpt3i+r8bO/8TWOo7ITdHv Xo8oCZYg5rAicpZFBP2tipiqIYcex7w4A/qR4DeVYBlCatVVvr28KnKqczZ17hIIMBA9 Y2Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733302129; x=1733906929; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=sCZcKH4Kr7ShBFnIBULtC4cA/q7iBWqSRHDgtiBni9Y=; b=vU2So0IF198x6cHnEeNR4UPSgddxTJRl6m2ngyGyZI5Gw8N8NdtYPQ1Gu6hKiQofMC tyGT/sXki9rH4iMZJsrfs4ZOcyOcVm2Fb2Dg4UQXbgHDgJo5ncpx2zBHsqycTv3d9nLV kMrRSEnjUjvZ6/KssRUJjBcFM4cWGjVDu6uYIdeRMMw7g2n2nHYIZ8y8GwwReNRt2UKg V3LTMlW2h/CgBSv6BysGILMn3zWLzH5HlzMOz1WL9ce64Az9NWWzbje69E3IDcIXcb4u e5BWB/UiHRf0HsS6TXyvPDHgbNuhidG8qfPj4ElGpu4G02FHjd+Fd/3Xz+1lNw0KXYzW gIUg== X-Gm-Message-State: AOJu0Yx3uoP/058T0ISXUA2Atj8IKfkXSjPnSDZOpbfMnZJZWqCsdzOO 2SyUcVDsT90nuCPleUuWZlh58k748F4/wJyCJg1LcAonEdyDyoutSnVN4u8SISNZd7+dcL1PahA n+CQ5UX/H40TewUKgOE6EMBgeHXcn2j/rXSxIw/QvSDCTp0U/9w+Gpp9UZuXeHHWrpZCT2IBKrC m+zvjtlj8YWeoXLAQd4bT1mNkqj1/yDalhNe2oLl6u6A== X-Google-Smtp-Source: AGHT+IGORsmFmY/qcnvRgJKrupRQH9HUbV1wIJx8SptaX+RkwHAOAdkvgqFCIHwY6qETcjnoMvvhxXxV71SgsQ== X-Received: from wmpb42.prod.google.com ([2002:a05:600c:4aaa:b0:434:a3bc:96d2]) (user=whendrik job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:1e21:b0:434:9934:575 with SMTP id 5b1f17b1804b1-434d3fae14dmr30406485e9.16.1733302129595; Wed, 04 Dec 2024 00:48:49 -0800 (PST) Date: Wed, 4 Dec 2024 08:48:32 +0000 In-Reply-To: <20241204084837.517299-1-whendrik@google.com> Mime-Version: 1.0 References: <20241204084837.517299-1-whendrik@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241204084837.517299-4-whendrik@google.com> Subject: [PATCH v3 3/8] i386: Add RDT functionality From: Hendrik Wuethrich To: qemu-devel@nongnu.org, Jonathan.Cameron@huawei.com, eduardo@habkost.net, richard.henderson@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com Cc: peternewman@google.com, "=?UTF-8?q?=E2=80=AAHendrik=20W=C3=BCthrich?=" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::34a; envelope-from=3cRdQZwgKCiIUFCLBPGIEMMEJC.AMKOCKS-BCTCJLMLELS.MPE@flex--whendrik.bounces.google.com; helo=mail-wm1-x34a.google.com X-Spam_score_int: -100 X-Spam_score: -10.1 X-Spam_bar: ---------- X-Spam_report: (-10.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.453, 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, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1733302168482116600 Content-Type: text/plain; charset="utf-8" From: =E2=80=AAHendrik W=C3=BCthrich Add RDT code to Associate CLOSID with RMID / set RMID for monitoring, write COS, and read monitoring data. This patch does not add code for the guest to interact through these things with MSRs, only the actual ability for the RDT device to do them. Signed-off-by: Hendrik W=C3=BCthrich --- hw/i386/rdt.c | 124 ++++++++++++++++++++++++++++++++++++++++++ include/hw/i386/rdt.h | 16 ++++++ 2 files changed, 140 insertions(+) diff --git a/hw/i386/rdt.c b/hw/i386/rdt.c index 2fb9fb476b..19fea8999a 100644 --- a/hw/i386/rdt.c +++ b/hw/i386/rdt.c @@ -21,6 +21,11 @@ #include "qom/object.h" #include "target/i386/cpu.h" =20 +/* RDT Monitoring Event Codes */ +#define RDT_EVENT_L3_OCCUPANCY 1 +#define RDT_EVENT_L3_REMOTE_BW 2 +#define RDT_EVENT_L3_LOCAL_BW 3 + /* Max counts for allocation masks or CBMs. In other words, the size of re= spective MSRs*/ #define RDT_MAX_L3_MASK_COUNT 127 #define RDT_MAX_L2_MASK_COUNT 63 @@ -29,6 +34,9 @@ #define TYPE_RDT "rdt" #define RDT_NUM_RMID_PROP "rmids" =20 +#define QM_CTR_ERROR (1ULL << 63) +#define QM_CTR_UNAVAILABLE (1ULL << 62) + OBJECT_DECLARE_TYPE(RDTState, RDTStateClass, RDT); =20 struct RDTMonitor { @@ -69,6 +77,122 @@ struct RDTState { struct RDTStateClass { }; =20 +bool rdt_associate_rmid_cos(uint64_t msr_ia32_pqr_assoc) { + X86CPU *cpu =3D X86_CPU(current_cpu); + RDTStatePerCore *rdt =3D cpu->rdt; + RDTAllocation *alloc; + + uint32_t cos_id =3D (msr_ia32_pqr_assoc & 0xffff0000) >> 16; + uint32_t rmid =3D msr_ia32_pqr_assoc & 0xffff; + + if (cos_id > RDT_MAX_L3_MASK_COUNT || cos_id > RDT_MAX_L2_MASK_COUNT || + cos_id > RDT_MAX_MBA_THRTL_COUNT || rmid > rdt_max_rmid(rdt)) { + return false; + } + + rdt->active_rmid =3D rmid; + + alloc =3D &rdt->rdtstate->allocations[rmid]; + + alloc->active_cos =3D cos_id; + + return true; +} + +uint32_t rdt_read_l3_mask(uint32_t pos) +{ + X86CPU *cpu =3D X86_CPU(current_cpu); + RDTStatePerCore *rdt =3D cpu->rdt; + + uint32_t val =3D rdt->rdtstate->msr_L3_ia32_mask_n[pos]; + return val; +} + +uint32_t rdt_read_l2_mask(uint32_t pos) +{ + X86CPU *cpu =3D X86_CPU(current_cpu); + RDTStatePerCore *rdt =3D cpu->rdt; + + uint32_t val =3D rdt->rdtstate->msr_L2_ia32_mask_n[pos]; + return val; +} + +uint32_t rdt_read_mba_thrtl(uint32_t pos) +{ + X86CPU *cpu =3D X86_CPU(current_cpu); + RDTStatePerCore *rdt =3D cpu->rdt; + + uint32_t val =3D rdt->rdtstate->ia32_L2_qos_ext_bw_thrtl_n[pos]; + return val; +} + +void rdt_write_msr_l3_mask(uint32_t pos, uint32_t val) { + X86CPU *cpu =3D X86_CPU(current_cpu); + RDTStatePerCore *rdt =3D cpu->rdt; + + rdt->rdtstate->msr_L3_ia32_mask_n[pos] =3D val; +} + +void rdt_write_msr_l2_mask(uint32_t pos, uint32_t val) { + X86CPU *cpu =3D X86_CPU(current_cpu); + RDTStatePerCore *rdt =3D cpu->rdt; + + rdt->rdtstate->msr_L2_ia32_mask_n[pos] =3D val; +} + +void rdt_write_mba_thrtl(uint32_t pos, uint32_t val) { + X86CPU *cpu =3D X86_CPU(current_cpu); + RDTStatePerCore *rdt =3D cpu->rdt; + + rdt->rdtstate->ia32_L2_qos_ext_bw_thrtl_n[pos] =3D val; +} + +uint32_t rdt_max_rmid(RDTStatePerCore *rdt) +{ + RDTState *rdtdev =3D rdt->rdtstate; + return rdtdev->rmids - 1; +} + +uint64_t rdt_read_event_count(RDTStatePerCore *rdtInstance, uint32_t rmid,= uint32_t event_id) +{ + CPUState *cs; + RDTMonitor *mon; + RDTState *rdt =3D rdtInstance->rdtstate; + + uint32_t count_l3 =3D 0; + uint32_t count_local=3D 0; + uint32_t count_remote =3D 0; + + if (!rdt) { + return 0; + } + + CPU_FOREACH(cs) { + rdtInstance =3D &rdt->rdtInstances[cs->cpu_index]; + if (rmid >=3D rdtInstance->monitors->len) { + return QM_CTR_ERROR; + } + mon =3D &g_array_index(rdtInstance->monitors, RDTMonitor, rmid); + count_l3 +=3D mon->count_l3; + count_local +=3D mon->count_local; + count_remote +=3D mon->count_remote; + } + + switch (event_id) { + case RDT_EVENT_L3_OCCUPANCY: + return count_l3 =3D=3D 0 ? QM_CTR_UNAVAILABLE : count_l3; + break; + case RDT_EVENT_L3_REMOTE_BW: + return count_remote =3D=3D 0 ? QM_CTR_UNAVAILABLE : count_remo= te; + break; + case RDT_EVENT_L3_LOCAL_BW: + return count_local =3D=3D 0 ? QM_CTR_UNAVAILABLE : count_local; + break; + default: + return QM_CTR_ERROR; + } +} + OBJECT_DEFINE_TYPE(RDTState, rdt, RDT, ISA_DEVICE); =20 static Property rdt_properties[] =3D { diff --git a/include/hw/i386/rdt.h b/include/hw/i386/rdt.h index a21d95b265..875142bad8 100644 --- a/include/hw/i386/rdt.h +++ b/include/hw/i386/rdt.h @@ -17,9 +17,25 @@ #ifndef HW_RDT_H #define HW_RDT_H =20 +#include +#include + typedef struct RDTState RDTState; typedef struct RDTStatePerCore RDTStatePerCore; typedef struct RDTMonitor RDTMonitor; typedef struct RDTAllocation RDTAllocation; =20 #endif +bool rdt_associate_rmid_cos(uint64_t msr_ia32_pqr_assoc); + +void rdt_write_msr_l3_mask(uint32_t pos, uint32_t val); +void rdt_write_msr_l2_mask(uint32_t pos, uint32_t val); +void rdt_write_mba_thrtl(uint32_t pos, uint32_t val); + +uint32_t rdt_read_l3_mask(uint32_t pos); +uint32_t rdt_read_l2_mask(uint32_t pos); +uint32_t rdt_read_mba_thrtl(uint32_t pos); + +uint64_t rdt_read_event_count(RDTStatePerCore *rdt, uint32_t rmid, uint32_= t event_id); +uint32_t rdt_max_rmid(RDTStatePerCore *rdt); + --=20 2.47.0.338.g60cca15819-goog From nobody Fri Dec 19 17:32:24 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1733302174; cv=none; d=zohomail.com; s=zohoarc; b=UfgUriy9Bto/QjS6dPZ/RmRkwxb3n5iQv2pHZSOKgDI5ZKGuu+JWs/dTIJ1YPsoUbH52rL69H25Kn1Z3buCTDa4I0rAYmVfUVO5PpZbMNE091P8UsVXeIFDFb5zMiy2y/As6D6jKflKkLFRlQ0J5kE/ms1XVCl0r6ORoNZ842QQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1733302174; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cNAdBMjdTz7ImCpTTY8WArjOvkh3ADfd5YtDzq7u3Yc=; b=VNi8fgTnyT1OKaHYGjLml2kPaEQJ6+RDr12nYjcLVPUJpwD6LKY4zQnBjcBuTH5rffOkyx2X+nsnQylq3+lUnx7NuFX5DrKDLYWhciJgQXn6jtXUOJDrGeD3uSAiviFJEg3olujrbsieefmKeLxWayynwUXuSIxg1O5EeJNQFbE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1733302174284761.2993728559171; Wed, 4 Dec 2024 00:49:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIl44-0000BV-SH; Wed, 04 Dec 2024 03:48:56 -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 <3cxdQZwgKCiQWHENDRIKGOOGLE.COMQEMU-DEVELNONGNU.ORG@flex--whendrik.bounces.google.com>) id 1tIl43-0000B4-1s for qemu-devel@nongnu.org; Wed, 04 Dec 2024 03:48:55 -0500 Received: from mail-wm1-x34a.google.com ([2a00:1450:4864:20::34a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3cxdQZwgKCiQWHENDRIKGOOGLE.COMQEMU-DEVELNONGNU.ORG@flex--whendrik.bounces.google.com>) id 1tIl41-00011H-5Y for qemu-devel@nongnu.org; Wed, 04 Dec 2024 03:48:54 -0500 Received: by mail-wm1-x34a.google.com with SMTP id 5b1f17b1804b1-434a6483514so46488335e9.0 for ; Wed, 04 Dec 2024 00:48:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733302131; x=1733906931; darn=nongnu.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=cNAdBMjdTz7ImCpTTY8WArjOvkh3ADfd5YtDzq7u3Yc=; b=Q7fUZlqQH1SCxPqVRk7pwNN3L3aGwyUwVVmtsZktrnynhYy8wrZCdFMkWWn58cEkyv LUbAgcvu/5cn0d7NAGU17seCLYxHFubDYqnub8kbfdWgb6veT2EO5C7sV4nXenVu+iiW MSAAYuPmwWu1J00uR/OkrQoCfe1KjErVbr9XaZqr2r+v0fIeJJ7MoOfHpeBlN6sqqMml 9a3m0BhcKIuJBOM9T5Z7yayDpAmtEoJI7iXlw+WzVXbufJIb/Pu58uX1wtTzgXYsRjmo BsNfQpCKsSw6T5NmQpHEXOlYO3I97+PZ5OJpoRCkNmJXXUVFJFTKPQHBJu6fHKfGdCeo HOpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733302131; x=1733906931; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=cNAdBMjdTz7ImCpTTY8WArjOvkh3ADfd5YtDzq7u3Yc=; b=F75GKNFmJGIo2U0+Juf+Du1LH7/hsljsiJPPli5TBWBUtNNh36LESdBQDQ3kC9dSqw TgEB49TM/gsTocqkOPnl6D26Ur4WB++lGgc1jQPCakSu0jNI+3Qj8R+iGPc5rJAtMuE8 OUSQ/0y4Q4dwHh0+tOsp+zH9TtdSi01R/OJeLtztC6Le0SgyOr6nVg+RWIIr98NHsowu dFWWIQN4rqQzaLNav+C3yp4W+CfXtb8Bln1DkE23SbXxBgKV3yXowWJ8LqQfvsnvft3n fVHSxD+LJ0R6s7n+o7+xxxXIv+ErG1w3nFhkV+bjZK5tpODP2CaTgU09UNpZNYSwaEhF 05uQ== X-Gm-Message-State: AOJu0YwYyO1DTxUxut1XLx8zf47F1+h5oKQbVd3PsUrzsvubu5UZaKcV 6LPh0NojdHcDrR0BZCeQRVLvLsb9Y3m5qfzQqdMBPY+2cPQGOJzol9fRHPTNURzejKyVzC21lDx IoBR+MAb9PDIWNhY2gKm7djLci3BM5Y0DMrJ6mlT6M6xXN66XQDQtobOzX0tQpE9nAT7c+qH5E4 YciIphXZ6zgJRgQE0LlOjTh0K2JZfkOVzIpSni9d73sg== X-Google-Smtp-Source: AGHT+IGTUOOXIXwe1YqkSm+6GIDITjT5VyV+o/D3rKj6x1DYi3Jo/Ofuu7BdxpMXYun0kCTVubT4nj2pTXAikA== X-Received: from wmlm7.prod.google.com ([2002:a7b:ca47:0:b0:434:b9c7:8907]) (user=whendrik job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:35c9:b0:434:a5b6:273c with SMTP id 5b1f17b1804b1-434d09b1464mr46502835e9.2.1733302131492; Wed, 04 Dec 2024 00:48:51 -0800 (PST) Date: Wed, 4 Dec 2024 08:48:33 +0000 In-Reply-To: <20241204084837.517299-1-whendrik@google.com> Mime-Version: 1.0 References: <20241204084837.517299-1-whendrik@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241204084837.517299-5-whendrik@google.com> Subject: [PATCH v3 4/8] i386: Add RDT device interface through MSRs From: Hendrik Wuethrich To: qemu-devel@nongnu.org, Jonathan.Cameron@huawei.com, eduardo@habkost.net, richard.henderson@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com Cc: peternewman@google.com, "=?UTF-8?q?=E2=80=AAHendrik=20W=C3=BCthrich?=" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::34a; envelope-from=3cxdQZwgKCiQWHENDRIKGOOGLE.COMQEMU-DEVELNONGNU.ORG@flex--whendrik.bounces.google.com; helo=mail-wm1-x34a.google.com X-Spam_score_int: -100 X-Spam_score: -10.1 X-Spam_bar: ---------- X-Spam_report: (-10.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.453, 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, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1733302174541116600 Content-Type: text/plain; charset="utf-8" From: =E2=80=AAHendrik W=C3=BCthrich Implement rdmsr and wrmsr for the following MSRs: * MSR_IA32_PQR_ASSOC * MSR_IA32_QM_EVTSEL * MSR_IA32_QM_CTR * IA32_L3_QOS_Mask_n * IA32_L2_QOS_Mask_n * IA32_L2_QoS_Ext_BW_Thrtl_n This allows for the guest to call RDT-internal functions to associate an RMID with a CLOSID / set an active RMID for monitoring, read monitoring data, and set classes of service. Signed-off-by: Hendrik W=C3=BCthrich --- hw/i386/rdt.c | 22 ++++---- include/hw/i386/rdt.h | 6 +- target/i386/cpu.h | 14 +++++ target/i386/tcg/sysemu/misc_helper.c | 84 ++++++++++++++++++++++++++++ 4 files changed, 113 insertions(+), 13 deletions(-) diff --git a/hw/i386/rdt.c b/hw/i386/rdt.c index 19fea8999a..f295273aec 100644 --- a/hw/i386/rdt.c +++ b/hw/i386/rdt.c @@ -77,6 +77,10 @@ struct RDTState { struct RDTStateClass { }; =20 +uint32_t rdt_get_cpuid_10_1_edx_cos_max(void) { return RDT_MAX_L3_MASK_COU= NT; } +uint32_t rdt_get_cpuid_10_2_edx_cos_max(void) { return RDT_MAX_L2_MASK_COU= NT; } +uint32_t rdt_get_cpuid_10_3_edx_cos_max(void) { return RDT_MAX_MBA_THRTL_C= OUNT; } + bool rdt_associate_rmid_cos(uint64_t msr_ia32_pqr_assoc) { X86CPU *cpu =3D X86_CPU(current_cpu); RDTStatePerCore *rdt =3D cpu->rdt; @@ -86,7 +90,7 @@ bool rdt_associate_rmid_cos(uint64_t msr_ia32_pqr_assoc) { uint32_t rmid =3D msr_ia32_pqr_assoc & 0xffff; =20 if (cos_id > RDT_MAX_L3_MASK_COUNT || cos_id > RDT_MAX_L2_MASK_COUNT || - cos_id > RDT_MAX_MBA_THRTL_COUNT || rmid > rdt_max_rmid(rdt)) { + cos_id > RDT_MAX_MBA_THRTL_COUNT || rmid > rdt_max_rmid(rdt)) { return false; } =20 @@ -104,8 +108,7 @@ uint32_t rdt_read_l3_mask(uint32_t pos) X86CPU *cpu =3D X86_CPU(current_cpu); RDTStatePerCore *rdt =3D cpu->rdt; =20 - uint32_t val =3D rdt->rdtstate->msr_L3_ia32_mask_n[pos]; - return val; + return rdt->rdtstate->msr_L3_ia32_mask_n[pos]; } =20 uint32_t rdt_read_l2_mask(uint32_t pos) @@ -113,8 +116,7 @@ uint32_t rdt_read_l2_mask(uint32_t pos) X86CPU *cpu =3D X86_CPU(current_cpu); RDTStatePerCore *rdt =3D cpu->rdt; =20 - uint32_t val =3D rdt->rdtstate->msr_L2_ia32_mask_n[pos]; - return val; + return rdt->rdtstate->msr_L2_ia32_mask_n[pos]; } =20 uint32_t rdt_read_mba_thrtl(uint32_t pos) @@ -122,8 +124,7 @@ uint32_t rdt_read_mba_thrtl(uint32_t pos) X86CPU *cpu =3D X86_CPU(current_cpu); RDTStatePerCore *rdt =3D cpu->rdt; =20 - uint32_t val =3D rdt->rdtstate->ia32_L2_qos_ext_bw_thrtl_n[pos]; - return val; + return rdt->rdtstate->ia32_L2_qos_ext_bw_thrtl_n[pos]; } =20 void rdt_write_msr_l3_mask(uint32_t pos, uint32_t val) { @@ -153,7 +154,8 @@ uint32_t rdt_max_rmid(RDTStatePerCore *rdt) return rdtdev->rmids - 1; } =20 -uint64_t rdt_read_event_count(RDTStatePerCore *rdtInstance, uint32_t rmid,= uint32_t event_id) +uint64_t rdt_read_event_count(RDTStatePerCore *rdtInstance, + uint32_t rmid, uint32_t event_id) { CPUState *cs; RDTMonitor *mon; @@ -181,13 +183,10 @@ uint64_t rdt_read_event_count(RDTStatePerCore *rdtIns= tance, uint32_t rmid, uint3 switch (event_id) { case RDT_EVENT_L3_OCCUPANCY: return count_l3 =3D=3D 0 ? QM_CTR_UNAVAILABLE : count_l3; - break; case RDT_EVENT_L3_REMOTE_BW: return count_remote =3D=3D 0 ? QM_CTR_UNAVAILABLE : count_remo= te; - break; case RDT_EVENT_L3_LOCAL_BW: return count_local =3D=3D 0 ? QM_CTR_UNAVAILABLE : count_local; - break; default: return QM_CTR_ERROR; } @@ -247,4 +246,3 @@ static void rdt_class_init(ObjectClass *klass, void *da= ta) =20 device_class_set_props(dc, rdt_properties); } - diff --git a/include/hw/i386/rdt.h b/include/hw/i386/rdt.h index 875142bad8..ec82a149f2 100644 --- a/include/hw/i386/rdt.h +++ b/include/hw/i386/rdt.h @@ -25,7 +25,10 @@ typedef struct RDTStatePerCore RDTStatePerCore; typedef struct RDTMonitor RDTMonitor; typedef struct RDTAllocation RDTAllocation; =20 -#endif +uint32_t rdt_get_cpuid_10_1_edx_cos_max(void); +uint32_t rdt_get_cpuid_10_2_edx_cos_max(void); +uint32_t rdt_get_cpuid_10_3_edx_cos_max(void); + bool rdt_associate_rmid_cos(uint64_t msr_ia32_pqr_assoc); =20 void rdt_write_msr_l3_mask(uint32_t pos, uint32_t val); @@ -39,3 +42,4 @@ uint32_t rdt_read_mba_thrtl(uint32_t pos); uint64_t rdt_read_event_count(RDTStatePerCore *rdt, uint32_t rmid, uint32_= t event_id); uint32_t rdt_max_rmid(RDTStatePerCore *rdt); =20 +#endif diff --git a/target/i386/cpu.h b/target/i386/cpu.h index a2941f98eb..d7d5ad37fd 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -574,6 +574,17 @@ typedef enum X86Seg { #define MSR_IA32_VMX_TRUE_ENTRY_CTLS 0x00000490 #define MSR_IA32_VMX_VMFUNC 0x00000491 =20 +#define MSR_IA32_QM_EVTSEL 0x0c8d +#define MSR_IA32_QM_CTR 0x0c8e +#define MSR_IA32_PQR_ASSOC 0x0c8f + +#define MSR_IA32_L3_CBM_BASE 0x0c90 +#define MSR_IA32_L3_MASKS_END 0x0d0f +#define MSR_IA32_L2_CBM_BASE 0x0d10 +#define MSR_IA32_L2_CBM_END 0x0d4f +#define MSR_IA32_L2_QOS_Ext_BW_Thrtl_BASE 0xd50 +#define MSR_IA32_L2_QOS_Ext_BW_Thrtl_END 0xd8f + #define MSR_APIC_START 0x00000800 #define MSR_APIC_END 0x000008ff =20 @@ -1778,6 +1789,9 @@ typedef struct CPUArchState { uint64_t msr_ia32_feature_control; uint64_t msr_ia32_sgxlepubkeyhash[4]; =20 + uint64_t msr_ia32_qm_evtsel; + uint64_t msr_ia32_pqr_assoc; + uint64_t msr_fixed_ctr_ctrl; uint64_t msr_global_ctrl; uint64_t msr_global_status; diff --git a/target/i386/tcg/sysemu/misc_helper.c b/target/i386/tcg/sysemu/= misc_helper.c index 094aa56a20..707cd3dc81 100644 --- a/target/i386/tcg/sysemu/misc_helper.c +++ b/target/i386/tcg/sysemu/misc_helper.c @@ -25,6 +25,7 @@ #include "exec/address-spaces.h" #include "exec/exec-all.h" #include "tcg/helper-tcg.h" +#include "hw/i386/rdt.h" #include "hw/i386/apic.h" =20 void helper_outb(CPUX86State *env, uint32_t port, uint32_t data) @@ -293,6 +294,47 @@ void helper_wrmsr(CPUX86State *env) env->msr_bndcfgs =3D val; cpu_sync_bndcs_hflags(env); break; + case MSR_IA32_QM_EVTSEL: + env->msr_ia32_qm_evtsel =3D val; + break; + case MSR_IA32_PQR_ASSOC: + { + env->msr_ia32_pqr_assoc =3D val; + + if (!rdt_associate_rmid_cos(val)) + goto error; + break; + } + case MSR_IA32_L3_CBM_BASE ... MSR_IA32_L3_MASKS_END: + { + uint32_t pos =3D (uint32_t)env->regs[R_ECX] - MSR_IA32_L3_CBM_BASE; + + if (pos > rdt_get_cpuid_10_1_edx_cos_max()) { + goto error; + } + rdt_write_msr_l3_mask(pos, val); + break; + } + case MSR_IA32_L2_CBM_BASE ... MSR_IA32_L2_CBM_END: + { + uint32_t pos =3D (uint32_t)env->regs[R_ECX] - MSR_IA32_L2_CBM_BASE; + + if (pos > rdt_get_cpuid_10_2_edx_cos_max()) { + goto error; + } + rdt_write_msr_l2_mask(pos, val); + break; + } + case MSR_IA32_L2_QOS_Ext_BW_Thrtl_BASE ... MSR_IA32_L2_QOS_Ext_BW_Thrt= l_END: + { + uint32_t pos =3D (uint32_t)env->regs[R_ECX] - MSR_IA32_L2_QOS_Ext_= BW_Thrtl_BASE; + + if (pos > rdt_get_cpuid_10_3_edx_cos_max()) { + goto error; + } + rdt_write_mba_thrtl(pos, val); + break; + } case MSR_APIC_START ... MSR_APIC_END: { int ret; int index =3D (uint32_t)env->regs[R_ECX] - MSR_APIC_START; @@ -472,6 +514,47 @@ void helper_rdmsr(CPUX86State *env) val =3D (cs->nr_threads * cs->nr_cores) | (cs->nr_cores << 16); break; } + case MSR_IA32_QM_CTR: + val =3D rdt_read_event_count(x86_cpu->rdt, + (env->msr_ia32_qm_evtsel >> 32) & 0xff, + env->msr_ia32_qm_evtsel & 0xff); + break; + case MSR_IA32_QM_EVTSEL: + val =3D env->msr_ia32_qm_evtsel; + break; + case MSR_IA32_PQR_ASSOC: + val =3D env->msr_ia32_pqr_assoc; + break; + case MSR_IA32_L3_CBM_BASE ... MSR_IA32_L3_MASKS_END: + { + uint32_t pos =3D (uint32_t)env->regs[R_ECX] - MSR_IA32_L3_CBM_BASE; + + if (pos >=3D rdt_get_cpuid_10_1_edx_cos_max()) { + raise_exception_err_ra(env, EXCP0D_GPF, 0, GETPC()); + } + val =3D rdt_read_l3_mask(pos); + break; + } + case MSR_IA32_L2_CBM_BASE ... MSR_IA32_L2_CBM_END: + { + uint32_t pos =3D (uint32_t)env->regs[R_ECX] - MSR_IA32_L2_CBM_BASE; + + if (pos >=3D rdt_get_cpuid_10_2_edx_cos_max()) { + raise_exception_err_ra(env, EXCP0D_GPF, 0, GETPC()); + } + val =3D rdt_read_l2_mask(pos); + break; + } + case MSR_IA32_L2_QOS_Ext_BW_Thrtl_BASE ... MSR_IA32_L2_QOS_Ext_BW_Thrt= l_END: + { + uint32_t pos =3D (uint32_t)env->regs[R_ECX] - MSR_IA32_L2_QOS_Ext_= BW_Thrtl_BASE; + + if (pos >=3D rdt_get_cpuid_10_3_edx_cos_max()) { + raise_exception_err_ra(env, EXCP0D_GPF, 0, GETPC()); + } + val =3D rdt_read_mba_thrtl(pos); + break; + } case MSR_APIC_START ... MSR_APIC_END: { int ret; int index =3D (uint32_t)env->regs[R_ECX] - MSR_APIC_START; @@ -499,6 +582,7 @@ void helper_rdmsr(CPUX86State *env) } env->regs[R_EAX] =3D (uint32_t)(val); env->regs[R_EDX] =3D (uint32_t)(val >> 32); + return; } =20 void helper_flush_page(CPUX86State *env, target_ulong addr) --=20 2.47.0.338.g60cca15819-goog From nobody Fri Dec 19 17:32:24 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1733302150; cv=none; d=zohomail.com; s=zohoarc; b=aeXzdaTT8uX+egB2vfxmJkC4RjMLTdcdtjuxUyPVP9FPt2CCKPjHbntL9p5TRw9hhAsRJbWDR6OP8mTaE7rDx4hVOlabh6qlrhRJkwwNKZk79nJQ1O0zrnS4pbOU+EymBhPWj5MM5NrylRdoIaYK2GF2Vuunr3vhjuHg6Nc4vNI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1733302150; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=b3xdx0BtyJ8+TSPEvjOg1rRfuqizDB0vQT6QT3cRbVk=; b=ECpY/FRSEBznyI+ojFCmW0udtQ6omTmfDRjoqCph6qJ/ZEuWam3H8aWxPEP1kUoqVhwhoo0jNQwOcVdPRn16qEPBToflQsVL3RrL9RQiKh/JfmFfen+7BxmVorZIvRgQyXT44CGrTyFivHD6LdkVDrWd0fM5qUW8omV3WMbVxMI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1733302150371804.0370096559878; Wed, 4 Dec 2024 00:49:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIl49-0000Gr-8B; Wed, 04 Dec 2024 03:49:01 -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 <3dRdQZwgKCiYYJGPFTKMIQQING.EQOSGOW-FGXGNPQPIPW.QTI@flex--whendrik.bounces.google.com>) id 1tIl47-0000FZ-9l for qemu-devel@nongnu.org; Wed, 04 Dec 2024 03:48:59 -0500 Received: from mail-wm1-x34a.google.com ([2a00:1450:4864:20::34a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3dRdQZwgKCiYYJGPFTKMIQQING.EQOSGOW-FGXGNPQPIPW.QTI@flex--whendrik.bounces.google.com>) id 1tIl45-00011a-5e for qemu-devel@nongnu.org; Wed, 04 Dec 2024 03:48:59 -0500 Received: by mail-wm1-x34a.google.com with SMTP id 5b1f17b1804b1-434941aa9c2so36880135e9.3 for ; Wed, 04 Dec 2024 00:48:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733302133; x=1733906933; darn=nongnu.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=b3xdx0BtyJ8+TSPEvjOg1rRfuqizDB0vQT6QT3cRbVk=; b=fDaFemuoCkF/QkkrNE/oQAMwWK8eoz3D0Wra8MFq1F/ZlyflD7iQ7PMpFURS62c0zh Wucgwq3IepQ0eceIGhXCao8EeFgZLWX3eIuJ3cnS2+soBo7J1phtSJcvqCKeHdsSeirf rUCrIfh1EJWoFCZzvltFSwehWyHd7d8uHrvn2tWOA15FCOUbtpLcYxqV1YHACaI/Mo0q StDoFrA283/0m5cfFbGnhgnYtaGafVaEbGlLKw2Q6uOE4wtnd5VH4ZGYUeQFX3nU7g63 enN7q883GOaKxayZ3To/sTzSi0Uld87eoyEa6F5jvKLCWossdXRkWVoY8g0HqJV/HW5A 1XVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733302133; x=1733906933; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=b3xdx0BtyJ8+TSPEvjOg1rRfuqizDB0vQT6QT3cRbVk=; b=phdBKA6e9fHVPCVE+MNiymxumbQxWax6MyoE6gL05k/8gYu1YJZ6Ve+OPrIMFa5a4O Xc7kG66yosPA2+cqd+8idoHP2a0/sHy2Z/l3Au7ss4x8khvhRp+5JsDrC28liELA7ci5 fsEHQ5517pbgK+YwwlfQyR5ZlSDQ2nsrN03qv4Nay1qwv77yeBLh/Qs/oBNlhkoVbhRb pCiKORg99jyT1NLQtkux3PMvQnvprrZMB3W6VI+zSwQR+j2IzwQp509vlXEutodQcIwR J1+XvD+4ELaWa0bCcFQbr4bvtgbVEz3pHu2W9nnzguhMkqYOCSMwnIkrQr9TyotDmrI3 GAbA== X-Gm-Message-State: AOJu0YzLAoSAMhC/lMxd3n5Zf+UPhwZWBvFKUsSzLJ/mkB+PEFdFV3Me 788UJYVS8bFzFAtBW9dJ7u9M7CaGKygmrtyrYb4pr71wkJkvoff52UhARKPgnF0PojKWwT6Udyv 2QuhlwQRXJL378qdLoG9BcJABw1Rx6FNbkPT6smOUS28/W2fDbl/xgwdas90lqOTWTPYPhASw1Y pUw7TgiprapMML+O4MMECLfWWKexsIlMjn0tVl2/mmKw== X-Google-Smtp-Source: AGHT+IHhIGNjKTtOJmX/9FVIDvNs2Zul7pAEVFuzNKXKUYNhB7VtLRUxbMaXPR1H+XJNpfxOiKDAEO0Xg2lVMg== X-Received: from wmba12.prod.google.com ([2002:a05:600c:6dcc:b0:434:9ed7:8b97]) (user=whendrik job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:3b29:b0:434:a4b3:5ebe with SMTP id 5b1f17b1804b1-434d3fcc4e6mr27415265e9.24.1733302133323; Wed, 04 Dec 2024 00:48:53 -0800 (PST) Date: Wed, 4 Dec 2024 08:48:34 +0000 In-Reply-To: <20241204084837.517299-1-whendrik@google.com> Mime-Version: 1.0 References: <20241204084837.517299-1-whendrik@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241204084837.517299-6-whendrik@google.com> Subject: [PATCH v3 5/8] i386: Add CPUID enumeration for RDT From: Hendrik Wuethrich To: qemu-devel@nongnu.org, Jonathan.Cameron@huawei.com, eduardo@habkost.net, richard.henderson@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com Cc: peternewman@google.com, "=?UTF-8?q?=E2=80=AAHendrik=20W=C3=BCthrich?=" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::34a; envelope-from=3dRdQZwgKCiYYJGPFTKMIQQING.EQOSGOW-FGXGNPQPIPW.QTI@flex--whendrik.bounces.google.com; helo=mail-wm1-x34a.google.com X-Spam_score_int: -100 X-Spam_score: -10.1 X-Spam_bar: ---------- X-Spam_report: (-10.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.453, 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, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1733302152598116600 Content-Type: text/plain; charset="utf-8" From: =E2=80=AAHendrik W=C3=BCthrich Add CPUID enumeration for intel RDT monitoring and allocation, as well as the flags used in the enumeration code. Signed-off-by: Hendrik W=C3=BCthrich --- hw/i386/rdt.c | 33 +++++++++++++++++++++ include/hw/i386/rdt.h | 31 +++++++++++++++++++ target/i386/cpu.c | 69 +++++++++++++++++++++++++++++++++++++++++++ target/i386/cpu.h | 5 ++++ 4 files changed, 138 insertions(+) diff --git a/hw/i386/rdt.c b/hw/i386/rdt.c index f295273aec..a3c748c127 100644 --- a/hw/i386/rdt.c +++ b/hw/i386/rdt.c @@ -31,6 +31,20 @@ #define RDT_MAX_L2_MASK_COUNT 63 #define RDT_MAX_MBA_THRTL_COUNT 63 =20 +/* RDT L3 Allocation features */ +#define CPUID_10_1_EAX_CBM_LENGTH 0xf +#define CPUID_10_1_EBX_CBM 0x0 +#define CPUID_10_1_ECX_CDP 0x0 // to enable, it would be (1U = << 2) +#define CPUID_10_1_EDX_COS_MAX MAX_L3_MASK_COUNT +/* RDT L2 Allocation features*/ +#define CPUID_10_2_EAX_CBM_LENGTH 0xf +#define CPUID_10_2_EBX_CBM 0x0 +#define CPUID_10_2_EDX_COS_MAX MAX_L2_MASK_COUNT +/* RDT MBA features */ +#define CPUID_10_3_EAX_THRTL_MAX 89 +#define CPUID_10_3_ECX_LINEAR_RESPONSE (1U << 2) +#define CPUID_10_3_EDX_COS_MAX MAX_MBA_THRTL_COUNT + #define TYPE_RDT "rdt" #define RDT_NUM_RMID_PROP "rmids" =20 @@ -77,8 +91,27 @@ struct RDTState { struct RDTStateClass { }; =20 +uint32_t rdt_get_cpuid_15_0_edx_l3(void) { return CPUID_15_1_EDX_L3_OCCUPA= NCY | CPUID_15_1_EDX_L3_TOTAL_BW | CPUID_15_1_EDX_L3_LOCAL_BW; } + +uint32_t rdt_cpuid_15_1_edx_l3_total_bw_enabled(void) { return CPUID_15_1_= EDX_L3_TOTAL_BW; } +uint32_t rdt_cpuid_15_1_edx_l3_local_bw_enabled(void) { return CPUID_15_1_= EDX_L3_LOCAL_BW; } +uint32_t rdt_cpuid_15_1_edx_l3_occupancy_enabled(void) { return CPUID_15_1= _EDX_L3_OCCUPANCY; } + +uint32_t rdt_cpuid_10_0_ebx_l3_cat_enabled(void) { return CPUID_10_0_EBX_L= 3_CAT; } +uint32_t rdt_cpuid_10_0_ebx_l2_cat_enabled(void) { return CPUID_10_0_EBX_L= 2_CAT; } +uint32_t rdt_cpuid_10_0_ebx_l2_mba_enabled(void) { return CPUID_10_0_EBX_M= BA; } + +uint32_t rdt_get_cpuid_10_1_eax_cbm_length(void) { return CPUID_10_1_EAX_C= BM_LENGTH; } +uint32_t rdt_cpuid_10_1_ebx_cbm_enabled(void) { return CPUID_10_1_EBX_CBM;= } +uint32_t rdt_cpuid_10_1_ecx_cdp_enabled(void) { return CPUID_10_1_ECX_CDP;= } uint32_t rdt_get_cpuid_10_1_edx_cos_max(void) { return RDT_MAX_L3_MASK_COU= NT; } + +uint32_t rdt_get_cpuid_10_2_eax_cbm_length(void) { return CPUID_10_2_EAX_C= BM_LENGTH; } +uint32_t rdt_cpuid_10_2_ebx_cbm_enabled(void) { return CPUID_10_2_EBX_CBM;= } uint32_t rdt_get_cpuid_10_2_edx_cos_max(void) { return RDT_MAX_L2_MASK_COU= NT; } + +uint32_t rdt_get_cpuid_10_3_eax_thrtl_max(void) { return CPUID_10_3_EAX_TH= RTL_MAX; } +uint32_t rdt_cpuid_10_3_eax_linear_response_enabled(void) { return CPUID_1= 0_3_ECX_LINEAR_RESPONSE; } uint32_t rdt_get_cpuid_10_3_edx_cos_max(void) { return RDT_MAX_MBA_THRTL_C= OUNT; } =20 bool rdt_associate_rmid_cos(uint64_t msr_ia32_pqr_assoc) { diff --git a/include/hw/i386/rdt.h b/include/hw/i386/rdt.h index ec82a149f2..57d2fa5b77 100644 --- a/include/hw/i386/rdt.h +++ b/include/hw/i386/rdt.h @@ -20,13 +20,44 @@ #include #include =20 +/* RDT L3 Cache Monitoring Technology */ +#define CPUID_15_0_EDX_L3 (1U << 1) +#define CPUID_15_1_EDX_L3_OCCUPANCY (1U << 0) +#define CPUID_15_1_EDX_L3_TOTAL_BW (1U << 1) +#define CPUID_15_1_EDX_L3_LOCAL_BW (1U << 2) + +/* RDT Cache Allocation Technology */ +#define CPUID_10_0_EBX_L3_CAT (1U << 1) +#define CPUID_10_0_EBX_L2_CAT (1U << 2) +#define CPUID_10_0_EBX_MBA (1U << 3) +#define CPUID_10_0_EDX CPUID_10_0_EBX_L3_CAT | CPUID_10_0_EBX_L2_CAT | CPU= ID_10_0_EBX_MBA + typedef struct RDTState RDTState; typedef struct RDTStatePerCore RDTStatePerCore; typedef struct RDTMonitor RDTMonitor; typedef struct RDTAllocation RDTAllocation; =20 +uint32_t rdt_get_cpuid_15_0_edx_l3(void); + +uint32_t rdt_cpuid_15_1_edx_l3_total_bw_enabled(void); +uint32_t rdt_cpuid_15_1_edx_l3_local_bw_enabled(void); +uint32_t rdt_cpuid_15_1_edx_l3_occupancy_enabled(void); + +uint32_t rdt_cpuid_10_0_ebx_l3_cat_enabled(void); +uint32_t rdt_cpuid_10_0_ebx_l2_cat_enabled(void); +uint32_t rdt_cpuid_10_0_ebx_l2_mba_enabled(void); + +uint32_t rdt_get_cpuid_10_1_eax_cbm_length(void); +uint32_t rdt_cpuid_10_1_ebx_cbm_enabled(void); +uint32_t rdt_cpuid_10_1_ecx_cdp_enabled(void); uint32_t rdt_get_cpuid_10_1_edx_cos_max(void); + +uint32_t rdt_get_cpuid_10_2_eax_cbm_length(void); +uint32_t rdt_cpuid_10_2_ebx_cbm_enabled(void); uint32_t rdt_get_cpuid_10_2_edx_cos_max(void); + +uint32_t rdt_get_cpuid_10_3_eax_thrtl_max(void); +uint32_t rdt_cpuid_10_3_eax_linear_response_enabled(void); uint32_t rdt_get_cpuid_10_3_edx_cos_max(void); =20 bool rdt_associate_rmid_cos(uint64_t msr_ia32_pqr_assoc); diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 4688d140c2..a8198fe5a7 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -42,6 +42,7 @@ #include "hw/boards.h" #include "hw/i386/sgx-epc.h" #endif +#include "hw/i386/rdt.h" =20 #include "disas/capstone.h" #include "cpu-internal.h" @@ -6629,6 +6630,74 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,= uint32_t count, assert(!(*eax & ~0x1f)); *ebx &=3D 0xffff; /* The count doesn't need to be reliable. */ break; +#ifndef CONFIG_USER_ONLY + case 0xF: + /* Shared Resource Monitoring Enumeration Leaf */ + *eax =3D 0; + *ebx =3D 0; + *ecx =3D 0; + *edx =3D 0; + if (!(env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_PQM)) + break; + if (!(cpu->rdt)) { + warn_report("Intel RDT features enabled in commandline, but rd= t device not used"); + break; + } + /* Non-zero count is ResId */ + switch (count) { + /* Monitoring Resource Type Enumeration */ + case 0: + *edx =3D env->features[FEAT_RDT_15_0_EDX]; + *ebx =3D rdt_max_rmid(cpu->rdt); + break; + case 1: + *ebx =3D 1; + *ecx =3D rdt_max_rmid(cpu->rdt); + *edx =3D rdt_cpuid_15_1_edx_l3_total_bw_enabled() | + rdt_cpuid_15_1_edx_l3_local_bw_enabled() | + rdt_cpuid_15_1_edx_l3_occupancy_enabled(); + break; + } + break; + case 0x10: + /* Shared Resource Director Technology Allocation Enumeration Leaf= */ + *eax =3D 0; + *ebx =3D 0; + *ecx =3D 0; + *edx =3D 0; + if (!(env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_PQE)) + break; + if (!(cpu->rdt)) { + warn_report("Intel RDT features enabled in commandline, but rd= t device not used"); + break; + } + /* Non-zero count is ResId */ + switch (count) { + /* Cache Allocation Technology Available Resource Types */ + case 0: + *ebx |=3D rdt_cpuid_10_0_ebx_l3_cat_enabled(); + *ebx |=3D rdt_cpuid_10_0_ebx_l2_cat_enabled(); + *ebx |=3D rdt_cpuid_10_0_ebx_l2_mba_enabled(); + break; + case 1: + *eax =3D rdt_get_cpuid_10_1_eax_cbm_length(); + *ebx =3D rdt_cpuid_10_1_ebx_cbm_enabled(); + *ecx |=3D rdt_cpuid_10_1_ecx_cdp_enabled(); + *edx =3D rdt_get_cpuid_10_1_edx_cos_max(); + break; + case 2: + *eax =3D rdt_get_cpuid_10_2_eax_cbm_length(); + *ebx =3D rdt_cpuid_10_2_ebx_cbm_enabled(); + *edx =3D rdt_get_cpuid_10_2_edx_cos_max(); + break; + case 3: + *eax =3D rdt_get_cpuid_10_3_eax_thrtl_max(); + *ecx =3D rdt_cpuid_10_3_eax_linear_response_enabled(); + *edx =3D rdt_get_cpuid_10_3_edx_cos_max(); + break; + } + break; +#endif case 0x1C: if (cpu->enable_pmu && (env->features[FEAT_7_0_EDX] & CPUID_7_0_ED= X_ARCH_LBR)) { x86_cpu_get_supported_cpuid(0x1C, 0, eax, ebx, ecx, edx); diff --git a/target/i386/cpu.h b/target/i386/cpu.h index d7d5ad37fd..1520a93927 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -673,6 +673,7 @@ typedef enum FeatureWord { FEAT_XSAVE_XSS_HI, /* CPUID[EAX=3D0xd,ECX=3D1].EDX */ FEAT_7_1_EDX, /* CPUID[EAX=3D7,ECX=3D1].EDX */ FEAT_7_2_EDX, /* CPUID[EAX=3D7,ECX=3D2].EDX */ + FEAT_RDT_15_0_EDX, /* CPUID[EAX=3D0xf,ECX=3D0].EDX (RDT CMT/MBM) */ FEATURE_WORDS, } FeatureWord; =20 @@ -843,8 +844,12 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *cp= u, FeatureWord w); #define CPUID_7_0_EBX_INVPCID (1U << 10) /* Restricted Transactional Memory */ #define CPUID_7_0_EBX_RTM (1U << 11) +/* Resource Director Technology Monitoring */ +#define CPUID_7_0_EBX_PQM (1U << 12) /* Memory Protection Extension */ #define CPUID_7_0_EBX_MPX (1U << 14) +/* Resource Director Technology Allocation */ +#define CPUID_7_0_EBX_PQE (1U << 15) /* AVX-512 Foundation */ #define CPUID_7_0_EBX_AVX512F (1U << 16) /* AVX-512 Doubleword & Quadword Instruction */ --=20 2.47.0.338.g60cca15819-goog From nobody Fri Dec 19 17:32:24 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1733302212; cv=none; d=zohomail.com; s=zohoarc; b=G+mmSdzq60fK3LBLITX2ZUDNt7E9DGCk5rwY2Px5Su11Dq/h1HfU+xtlgurcA/lsR5m65up9FLjHmIJbdWQDsr6GeUIi8tgzksBKNsDJfWozq3rEcW5pZQPb6Rw3uvzWpoAQMURxanmOIHbuwebOwkk2Lgnd4tI71wrZuy0V//A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1733302212; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=g/43FrCAIP7tilQQ4ftObjxWWc8+9Zv1Klu0cOiIC/o=; b=FyWKvon3CjPDn59MaW+w6tcp/AUUY4MkrABLXwl10cKCsw+1mcdEXQQdJyaeQ9mYpo3tcEK+XX6SXDZEaQOW2csY3c0Tgv06f8cMB3+SIoEdOUWlqBLEyHjG6Lwm3k+PqMuCdwwWuEb7TQ9KtT8BchLSoBStY9OfSnsrfnQZOR8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1733302212197627.9641004356478; Wed, 4 Dec 2024 00:50:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIl48-0000GK-Ct; Wed, 04 Dec 2024 03:49:00 -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 <3dxdQZwgKCigaLIRHVMOKSSKPI.GSQUIQY-HIZIPRSRKRY.SVK@flex--whendrik.bounces.google.com>) id 1tIl46-0000Dr-AY for qemu-devel@nongnu.org; Wed, 04 Dec 2024 03:48:58 -0500 Received: from mail-wm1-x34a.google.com ([2a00:1450:4864:20::34a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3dxdQZwgKCigaLIRHVMOKSSKPI.GSQUIQY-HIZIPRSRKRY.SVK@flex--whendrik.bounces.google.com>) id 1tIl44-00011p-O3 for qemu-devel@nongnu.org; Wed, 04 Dec 2024 03:48:58 -0500 Received: by mail-wm1-x34a.google.com with SMTP id 5b1f17b1804b1-434941aa9c2so36880235e9.3 for ; Wed, 04 Dec 2024 00:48:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733302135; x=1733906935; darn=nongnu.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=g/43FrCAIP7tilQQ4ftObjxWWc8+9Zv1Klu0cOiIC/o=; b=H48f93johlmib/bSicqjm0IWnsKuYskvohoCPdRmwYVC6/2QDhOxq24V5N4LDNyHkY aYzLMBRitJLhnYwX3FjBJUZG5Wrsrj0J3iQOxOWERA9rEORIDuX1L0xR0Is2Byp9qqgS MOoo+eBiMt46BFrs+yskgOENlPj7hVUXJXmx49gglDhSp7Zg980nzr2N7jaFY9BKU36H 6UNnfElVFMwVIfS5VXK1yhQOUrW1/imIK16GotObPas+EI8SxYejn7jHhGFIjauPONzS 1/9qxpBA3BYjOlLNvObx+yF2Lnaw9wOK2Wz2Rxd3/zCfw7V8nJklDtkr042GmuF5BnsP yWlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733302135; x=1733906935; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=g/43FrCAIP7tilQQ4ftObjxWWc8+9Zv1Klu0cOiIC/o=; b=mDz2Qg2oIC5ybycz3Ed3r4cX2eTtHWx721EV9oatqWL9rDL4ayTBb3lR6x5uYf1VDg XB4BEAsjmBHYDG8x/jAU9VOXRCPnNrWxjpDL61UhjuBlL5GePJBgmbVZk131nbbZ+hHZ GoHZSeweLPU5+7wMZ5hHfA0Axv35n+H2Vw0bqhHXaVMDI+xO1SuKEGvAX4AxPViHt9A9 nik9eRcBMrmefPWVSe8rsBQR/pBLPFAtoA9NgFgExa4o0kzj3HolC4KuOeebxFgfFk9h kFekdEw6ZoU3xSmCBWPyz8teF0z9jV62s5n5hasiS7L8Z5MxUtT8RpnnanLl9pbMnhAJ wmHw== X-Gm-Message-State: AOJu0YwKK0NsQmtj2SaVhteifRprQ7SWZId1tguNZsxImaub2dNtdxp1 YVYLyRlBGDGBk8ml46l1nVAK4EPY4PSLVSm8MNA2ZXbfluzFS6n8v/5nkJDLy4lPfhXYvNedmZL 1Sr2GyryNR9aQdz+7mnvXpsP9vQYiD6HRK/zTRCDN71Mbt+V/oPuUOhdhTh2orBZfF1GM5S2E1o jI7RjIwdWLG6DhczCfqzOqzuN2YXmBRzj9aKi2ta1bnA== X-Google-Smtp-Source: AGHT+IEoNa5lbp+yB1lR8X3nOxTj/60abWf03MIdC0rAKhGdBI8uy3ygNFy9BrLG0Xh97u9Okc/IA3p8QvoNRA== X-Received: from wmjy25.prod.google.com ([2002:a7b:cd99:0:b0:431:1c66:db91]) (user=whendrik job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:4ed0:b0:434:a929:42bb with SMTP id 5b1f17b1804b1-434d3fae263mr30023885e9.18.1733302135205; Wed, 04 Dec 2024 00:48:55 -0800 (PST) Date: Wed, 4 Dec 2024 08:48:35 +0000 In-Reply-To: <20241204084837.517299-1-whendrik@google.com> Mime-Version: 1.0 References: <20241204084837.517299-1-whendrik@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241204084837.517299-7-whendrik@google.com> Subject: [PATCH v3 6/8] i386: Add RDT feature flags. From: Hendrik Wuethrich To: qemu-devel@nongnu.org, Jonathan.Cameron@huawei.com, eduardo@habkost.net, richard.henderson@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com Cc: peternewman@google.com, "=?UTF-8?q?=E2=80=AAHendrik=20W=C3=BCthrich?=" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::34a; envelope-from=3dxdQZwgKCigaLIRHVMOKSSKPI.GSQUIQY-HIZIPRSRKRY.SVK@flex--whendrik.bounces.google.com; helo=mail-wm1-x34a.google.com X-Spam_score_int: -100 X-Spam_score: -10.1 X-Spam_bar: ---------- X-Spam_report: (-10.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.453, 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, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1733302212793116600 Content-Type: text/plain; charset="utf-8" From: =E2=80=AAHendrik W=C3=BCthrich Add RDT features to feature word / TCG. Signed-off-by: Hendrik W=C3=BCthrich --- target/i386/cpu.c | 30 ++++++++++++++++++++++++++++-- target/i386/cpu.h | 2 ++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index a8198fe5a7..af1da35985 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -864,7 +864,8 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t vendo= r1, 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_RDSEED |= \ - CPUID_7_0_EBX_SHA_NI | CPUID_7_0_EBX_KERNEL_FEATURES) + CPUID_7_0_EBX_SHA_NI | CPUID_7_0_EBX_KERNEL_FEATURES | \ + CPUID_7_0_EBX_PQM | CPUID_7_0_EBX_PQE) /* missing: CPUID_7_0_EBX_HLE CPUID_7_0_EBX_INVPCID, CPUID_7_0_EBX_RTM */ @@ -900,6 +901,7 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t vendo= r1, #define TCG_SGX_12_0_EAX_FEATURES 0 #define TCG_SGX_12_0_EBX_FEATURES 0 #define TCG_SGX_12_1_EAX_FEATURES 0 +#define TCG_RDT_15_0_EDX_FEATURES CPUID_15_0_EDX_L3 =20 #if defined CONFIG_USER_ONLY #define CPUID_8000_0008_EBX_KERNEL_FEATURES (CPUID_8000_0008_EBX_IBPB | \ @@ -1057,7 +1059,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D { "fsgsbase", "tsc-adjust", "sgx", "bmi1", "hle", "avx2", NULL, "smep", "bmi2", "erms", "invpcid", "rtm", - NULL, NULL, "mpx", NULL, + "rdt-m", NULL, "mpx", "rdt-a", "avx512f", "avx512dq", "rdseed", "adx", "smap", "avx512ifma", "pcommit", "clflushopt", "clwb", "intel-pt", "avx512pf", "avx512er", @@ -1607,6 +1609,30 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D= { }, .tcg_features =3D TCG_SGX_12_1_EAX_FEATURES, }, + + [FEAT_RDT_10_0_EBX] =3D { + .type =3D CPUID_FEATURE_WORD, + .feat_names =3D { + NULL, "l3-cat", "l2-cat", "mba" + }, + .cpuid =3D { + .eax =3D 0x10, + .needs_ecx =3D true, .ecx =3D 0, + .reg =3D R_EBX, + } + }, + [FEAT_RDT_15_0_EDX] =3D { + .type =3D CPUID_FEATURE_WORD, + .feat_names =3D { + [1] =3D "l3-cmt" + }, + .cpuid =3D { + .eax =3D 0xf, + .needs_ecx =3D true, .ecx =3D 0, + .reg =3D R_EDX, + }, + .tcg_features =3D TCG_RDT_15_0_EDX_FEATURES, + }, }; =20 typedef struct FeatureMask { diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 1520a93927..b9d78f4d4e 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -673,7 +673,9 @@ typedef enum FeatureWord { FEAT_XSAVE_XSS_HI, /* CPUID[EAX=3D0xd,ECX=3D1].EDX */ FEAT_7_1_EDX, /* CPUID[EAX=3D7,ECX=3D1].EDX */ FEAT_7_2_EDX, /* CPUID[EAX=3D7,ECX=3D2].EDX */ + FEAT_RDT_15_0_EBX, /* CPUID[EAX=3D0xf,ECX=3D0].EBX (RDT CMT/MBM) */ FEAT_RDT_15_0_EDX, /* CPUID[EAX=3D0xf,ECX=3D0].EDX (RDT CMT/MBM) */ + FEAT_RDT_10_0_EBX, /* CPUID[EAX=3D0x10,ECX=3D0].EBX (RDT CAT/MBA) */ FEATURE_WORDS, } FeatureWord; =20 --=20 2.47.0.338.g60cca15819-goog From nobody Fri Dec 19 17:32:24 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1733302219; cv=none; d=zohomail.com; s=zohoarc; b=n9sRc10Y+V5E4nEqRIj7SnJHzX8dzpacV7xoarjtD46GReVjTkp1pCWjEZOzPxUgQB/fTEMwUbGPh3lsqNdn23UjYQeDpo0sote2YLckutwYCpi3ejlGsLSu+VDOmZYgVvdIyI7n3Gs93tsAOddoZcGQe99JtRrwRjjaP1pL/e0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1733302219; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sAy6WBlDUJU2NNDa5pmhSI6Kdop6GN6BvVyL+oarK/U=; b=HHxcGy8yjbUby2Zl8ZdHw+bWJP62Obni+3zAvOCt9bJbe6xJidTaKt0okPdanYFx2rEAfKVMYFLjdJGuSY1WjFVSQ3ip2aW8exfiiX3H2ujxv+DVvDQxty8bBoar//5DHHGHQjdzkbyQDklV+brHZkflHrYcXlwmjzbocFSfdpg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1733302219087613.979799096323; Wed, 4 Dec 2024 00:50:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIl4A-0000HL-Na; Wed, 04 Dec 2024 03:49:02 -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 <3eRdQZwgKCiocNKTJXOQMUUMRK.IUSWKSa-JKbKRTUTMTa.UXM@flex--whendrik.bounces.google.com>) id 1tIl48-0000GO-VF for qemu-devel@nongnu.org; Wed, 04 Dec 2024 03:49:00 -0500 Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3eRdQZwgKCiocNKTJXOQMUUMRK.IUSWKSa-JKbKRTUTMTa.UXM@flex--whendrik.bounces.google.com>) id 1tIl47-00012G-EE for qemu-devel@nongnu.org; Wed, 04 Dec 2024 03:49:00 -0500 Received: by mail-wr1-x449.google.com with SMTP id ffacd0b85a97d-385dcadffebso2475724f8f.0 for ; Wed, 04 Dec 2024 00:48:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733302137; x=1733906937; darn=nongnu.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=sAy6WBlDUJU2NNDa5pmhSI6Kdop6GN6BvVyL+oarK/U=; b=oaLTPF1xiC8bS+WUy8UH1tZgE0o5SA+xvdewouQEZYZ5YdBkmuVS16bmoSOZcHvB2X 8rf5xEUvqxVHvHCA32CYHvhCcOMp4zkpW/bFln63bZoPSNWRwmXdDvxnnYlEii7TS7Ap LypOqm0IETNhVUu49c6wbfWeIbGY/gNCQi93U0vA774HOwV03OMQjWsbV7AMLD4/kudJ 5Dm1Wy3RW86ANAd4taVF52IEoUm/+Z0ieoFv961vyjiCcTvo0wOsofhKzKnOVgFNWhqN OHgO9ui3MLdEcre0jU0g0Ec86x67fQ1PhbLu6i7N1uqriD2Q2P+2U5ct16Z4tEbZZIxx 9CCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733302137; x=1733906937; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=sAy6WBlDUJU2NNDa5pmhSI6Kdop6GN6BvVyL+oarK/U=; b=KjlIV1H+Exzx3g0xReLVLj9fVB4EBwGsASvpNQxVSNSuqT8YKSyLvnBr8/CVfcyK9h ApwPuMYAxMK1kjhx65Dum+beynV1zgxSPDRG9gDWpC/Gi73hhAfjpWX+CcDTtPYJR4QP x76Qn1diZHBbtMPH5h7YvD+G+uUy8dQaSd4OEbn88wv9jmsrVjA+gaG53EvCB3RETtK+ RP2GkxHODhtcxwebjM2JeCB1hWJ9WUujnnNsUMZ4jXEk24EK7Jsw/qTLFgbWkwph4SS0 38dgqwZsTNWuVhgPoUxIDGK15fLlTo3x6uQ8+568+ZCAa5QGm7IbaqWuT+mVS84PgI1m dlCg== X-Gm-Message-State: AOJu0YxRUQFMxONM1cQxnS3hfpB56R+l2NDJvPhcFSt0QSuYXxU+y7Dp Zf2b+G5BduGhE2ShgbVnFZXqFYt09KlYspBF2tlPzTa1BabxV5ajus7qagrn+B30FnjUNWyB1zq ZE73JCgifpmEFB2qcENYvcGM2eyHJOD7NpC2qZCG/dceGthSBJvcp05orc5pxbLt8iZSH6IOrdJ 3jYRwuZjwgk9K04CmTU197fkAU0Jbtsirl/VCll+5ywg== X-Google-Smtp-Source: AGHT+IHeOcCTN8SgfHSKABPFP8lqTxjMXzScT7YaQJKMdLftVPC0GriXpqh96Js7Hm4qS63zJYiL1UjAvBf0Pw== X-Received: from wmfu12.prod.google.com ([2002:a05:600c:138c:b0:434:a7cd:517a]) (user=whendrik job=prod-delivery.src-stubby-dispatcher) by 2002:a5d:648f:0:b0:385:e36a:e19f with SMTP id ffacd0b85a97d-385fd419194mr4068540f8f.41.1733302137330; Wed, 04 Dec 2024 00:48:57 -0800 (PST) Date: Wed, 4 Dec 2024 08:48:36 +0000 In-Reply-To: <20241204084837.517299-1-whendrik@google.com> Mime-Version: 1.0 References: <20241204084837.517299-1-whendrik@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241204084837.517299-8-whendrik@google.com> Subject: [PATCH v3 7/8] i386/cpu: Adjust CPUID level for RDT features From: Hendrik Wuethrich To: qemu-devel@nongnu.org, Jonathan.Cameron@huawei.com, eduardo@habkost.net, richard.henderson@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com Cc: peternewman@google.com, "=?UTF-8?q?=E2=80=AAHendrik=20W=C3=BCthrich?=" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::449; envelope-from=3eRdQZwgKCiocNKTJXOQMUUMRK.IUSWKSa-JKbKRTUTMTa.UXM@flex--whendrik.bounces.google.com; helo=mail-wr1-x449.google.com X-Spam_score_int: -100 X-Spam_score: -10.1 X-Spam_bar: ---------- X-Spam_report: (-10.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.453, 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, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1733302220754116600 Content-Type: text/plain; charset="utf-8" From: =E2=80=AAHendrik W=C3=BCthrich Adjust minimum CPUID level if RDT monitoring or allocation features are enabled to ensure that CPUID will return them. Signed-off-by: Hendrik W=C3=BCthrich --- target/i386/cpu.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index af1da35985..a400839216 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7568,6 +7568,16 @@ void x86_cpu_expand_features(X86CPU *cpu, Error **er= rp) if (env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_SGX) { x86_cpu_adjust_level(cpu, &env->cpuid_min_level, 0x12); } + + /* RDT monitoring requires CPUID[0xF] */ + if (env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_PQM) { + x86_cpu_adjust_level(cpu, &env->cpuid_min_level, 0xF); + } + + /* RDT allocation requires CPUID[0x10] */ + if (env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_PQE) { + x86_cpu_adjust_level(cpu, &env->cpuid_min_level, 0x10); + } } =20 /* Set cpuid_*level* based on cpuid_min_*level, if not explicitly set = */ --=20 2.47.0.338.g60cca15819-goog From nobody Fri Dec 19 17:32:24 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1733302168; cv=none; d=zohomail.com; s=zohoarc; b=APWljs2+W8ONGctJrMCJLdXWb6TXhV3hfFd4KFxq7JSNpQNPdQQ8OpVN+klT3CA44Ex1hlIl+uZdQxMxMEl1hNUP4MV00xAa+wXEI0LgZOhQqhzuaHleFQ1vvwIAS7xlUT0Vy2nZt4gvp3gFk8V8BFq4Tz76FEMLMSRoYgMFIOk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1733302168; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iToU4ifoTogZaZYEzFXGtcqpRLmu4bvhKXXyDGHPJUw=; b=E4wLy1jSIdbWkAR/dO/Y8et7GPSTBkmJuo7KtLdyyoE79A/8cYAPJKvMJTV5QIln0aNn2w/8vAP4ibf1QJaXW6ngSgdgITd7zyjw1yXo5K7hWYCvO1TZxU07x3NP27Hcq2nhz7nKDuoPDnrMqety2E4gnJZLpaM5F8uEIu4y3qA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1733302168105504.2943887724107; Wed, 4 Dec 2024 00:49:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIl4C-0000Ni-SG; Wed, 04 Dec 2024 03:49:05 -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 <3exdQZwgKCiwePMVLZQSOWWOTM.KWUYMUc-LMdMTVWVOVc.WZO@flex--whendrik.bounces.google.com>) id 1tIl4B-0000Ly-ND for qemu-devel@nongnu.org; Wed, 04 Dec 2024 03:49:03 -0500 Received: from mail-wm1-x349.google.com ([2a00:1450:4864:20::349]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3exdQZwgKCiwePMVLZQSOWWOTM.KWUYMUc-LMdMTVWVOVc.WZO@flex--whendrik.bounces.google.com>) id 1tIl4A-00015g-6E for qemu-devel@nongnu.org; Wed, 04 Dec 2024 03:49:03 -0500 Received: by mail-wm1-x349.google.com with SMTP id 5b1f17b1804b1-434a195814fso48709325e9.3 for ; Wed, 04 Dec 2024 00:49:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733302139; x=1733906939; darn=nongnu.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=iToU4ifoTogZaZYEzFXGtcqpRLmu4bvhKXXyDGHPJUw=; b=aFfCB/r1W+PYfOT8JOtbQDeY3W0bjU2tkn+Vtd5miUCGVIvEEWXR9KvCde/GXSPJo/ VPufqE6YcwLCbBYGr533oYw2rFqT+nV1r87/ZEGTkIdmZ4reA7TiQKvR0OSTO4FXwgZN mvTXpoYP+ydy6xZxeINE/pzLf9EXlpo/IAq/K0nw9x8LATk+DMxTkzD+VnAnwcX7o7cT F71GiVF8zEjFPsoRVsUH+GvbJuZbMw5HLi8IKk/zsHuPwl0nH8c007nrSakdu8atl6/d EpYJVFMzaw6uAiGIe1WhkjEN8bQU6r0fy5D0JKONOrZIJr+jYFTLRfuJKhAHeXhi10pa mHQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733302139; x=1733906939; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=iToU4ifoTogZaZYEzFXGtcqpRLmu4bvhKXXyDGHPJUw=; b=rBdlwGx/yw5dVRUOBjw6EUAYBwlFlcY0znKaFon69AcO4AqlvFDOlHHZoO6KiVv7kN 3ixMkLahY+2DNY65JCZE+l3/98KYEhrC4HM6PidCVoPqpjnqYqcU5TOhVySwmizZ6KX3 AfUroIXvfzD13/Pp/WmrTn8RzlNiuS1rSdXhyD8IcohJ6uWq14Jht4CBxpsZqn7n5lC9 iyBlgRt2YG/tmG5xSShHYZkM7kqWoTgIoBFzKbDVMKx6TkhPPiGvD+x28oTDx/4ow5jR uqXkpshv0HvHZu5gIFa18OOLlVgnmaYYC1HGwpDtrsDYH54w4U5aKJdtpQHqHVzOVrxD 8QZg== X-Gm-Message-State: AOJu0YxPw5u/GTkfQSXtCsp8K0c+wg9UtB3o8xOLRzPSPstz+9tyP0c1 VdTCZgfiIikV65C0RxpM37p5DiVe2XOYi0UA61+LO2EuoOUpV74HR3e/phn4m4m1SobXEITWTmN Y4131eL4/B+3Vide8b+HLeCGSe6JJplURluZesOVSlx9415TlcRsxnh4EK8p/zTe7ykUDDX3ZBI wG0E3hags8ZkbJ0binZnF8N8HZcazCXhEYd6nGr/R5rA== X-Google-Smtp-Source: AGHT+IHOGBM2ZkXOs7Twgi1Hm4IPflsO3ws7GO+JLAnrUNLckMKMfR2gCWONU49AFOsL6/CBIWcOJFYUeexftg== X-Received: from wmow13.prod.google.com ([2002:a05:600c:474d:b0:434:9f2c:eb0f]) (user=whendrik job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:4745:b0:434:a5b3:8fee with SMTP id 5b1f17b1804b1-434d0a07c49mr42095765e9.26.1733302139239; Wed, 04 Dec 2024 00:48:59 -0800 (PST) Date: Wed, 4 Dec 2024 08:48:37 +0000 In-Reply-To: <20241204084837.517299-1-whendrik@google.com> Mime-Version: 1.0 References: <20241204084837.517299-1-whendrik@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241204084837.517299-9-whendrik@google.com> Subject: [PATCH v3 8/8] i386/cpu: Adjust level for RDT on full_cpuid_auto_level From: Hendrik Wuethrich To: qemu-devel@nongnu.org, Jonathan.Cameron@huawei.com, eduardo@habkost.net, richard.henderson@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com Cc: peternewman@google.com, "=?UTF-8?q?=E2=80=AAHendrik=20W=C3=BCthrich?=" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::349; envelope-from=3exdQZwgKCiwePMVLZQSOWWOTM.KWUYMUc-LMdMTVWVOVc.WZO@flex--whendrik.bounces.google.com; helo=mail-wm1-x349.google.com X-Spam_score_int: -100 X-Spam_score: -10.1 X-Spam_bar: ---------- X-Spam_report: (-10.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.453, 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, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1733302168516116600 Content-Type: text/plain; charset="utf-8" From: =E2=80=AAHendrik W=C3=BCthrich Make sure that RDT monitoring and allocation features are included in in full_cpuid_auto_level. Signed-off-by: Hendrik W=C3=BCthrich --- target/i386/cpu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index a400839216..787bb5ba92 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -875,6 +875,7 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t vendo= r1, #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 | \ @@ -7526,6 +7527,8 @@ void x86_cpu_expand_features(X86CPU *cpu, Error **err= p) x86_cpu_adjust_feat_level(cpu, FEAT_C000_0001_EDX); x86_cpu_adjust_feat_level(cpu, FEAT_SVM); x86_cpu_adjust_feat_level(cpu, FEAT_XSAVE); + x86_cpu_adjust_feat_level(cpu, FEAT_RDT_15_0_EDX); + x86_cpu_adjust_feat_level(cpu, FEAT_RDT_10_0_EBX); =20 /* Intel Processor Trace requires CPUID[0x14] */ if ((env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT)) { --=20 2.47.0.338.g60cca15819-goog