From nobody Tue May 13 09:08:26 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=1734110895; cv=none; d=zohomail.com; s=zohoarc; b=FIR4+SLWnw7eKj5qlTn0CPb5iHety1Ax0wz6bgMOi2fu9LNjaRb/Wy8CL5xLjBx+Rw0ryClQQG3rgae6T987aPJcpjk5hvGc0wUmfIAWC+zr95ao49ANt6+sDM+Gqc3faRJN+CWAIZW5Rs7kYXS7g6cMp6upQh+HxVtY9bItmik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1734110895; 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=0qxThtaigL4hm6xxENqva0i9sj2hAquO7ovF8w3qP/0=; b=KFdV7Zid4u+Aeh4d/XBU9IGclVISjZmfsVnBm9iN7Jyhgufqv2eiqx8kidS5aQN/eZFHGltdn6jNijMXtBy6NfsENDd7bp7hUcUQ0il6GAEX0XmyrxCUcXQSbaGszKvfgJrZrm15btwiQ+tVv25kqoETvVqiQ6jfezHuXkBRy08= 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=<whendrik@google.com> (p=reject dis=none) Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1734110895969280.12740883451374; Fri, 13 Dec 2024 09:28:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <qemu-devel-bounces@nongnu.org>) id 1tM9RZ-0008TN-0d; Fri, 13 Dec 2024 12:27:13 -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 <3YW5cZwgKCvAoZWfVjacYggYdW.UgeiWem-VWnWdfgfYfm.gjY@flex--whendrik.bounces.google.com>) id 1tM9RS-0008Py-Ut for qemu-devel@nongnu.org; Fri, 13 Dec 2024 12:27:08 -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 <3YW5cZwgKCvAoZWfVjacYggYdW.UgeiWem-VWnWdfgfYfm.gjY@flex--whendrik.bounces.google.com>) id 1tM9RO-0007nV-2G for qemu-devel@nongnu.org; Fri, 13 Dec 2024 12:27:04 -0500 Received: by mail-wm1-x349.google.com with SMTP id 5b1f17b1804b1-43582d49dacso17629675e9.2 for <qemu-devel@nongnu.org>; Fri, 13 Dec 2024 09:26:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1734110817; x=1734715617; 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=0qxThtaigL4hm6xxENqva0i9sj2hAquO7ovF8w3qP/0=; b=jKz6DMkPLUSlDw84ejNeXwx1acnh9qDLcZ+yBV843Wm6OmFLELqKkC5Qh2xGbvntnU B0GDbzQ5/HA5fJpfKmXf5DwB7lKg8vpzXlNY9XsRz8kgny+iAJbn2DFQ1JmOgc1YFeSu vITIm6+Vcmg0a/r26Pe3nQHhTYdwDS2o6NDrX3vOxilBXkbk7zutlYk6zo5C6Mcuui4Y 3VTG2+0dp7aFedrMYssTk4arsFeVAPHnUcq4cMNsivuQl17ihbiPSJJZepvMtu3tATA5 zV70SFu3gtT1fojL1ACvTTVYZN2y+w6CVLHwIWTRkh+JL1k02uYIvK3f29u1UoekkxWH nzPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734110817; x=1734715617; 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=0qxThtaigL4hm6xxENqva0i9sj2hAquO7ovF8w3qP/0=; b=QQth6QlpTIwTmqItaOuKmqItAMLA3WwamUe6rX8sCMzpdCRgFneMfM94ZGHHAgr9g8 FWLyvAcgxYyls/mvwVQ8PU13/QDaW1cxXwYbXm/NdPtBm0mPabWeIIC//Ym12Wp36yoZ 6n1YlCsV0whYPfPO0RjbtxcLLeJD7i3jxZSMeVcuZ/KbijghAIslhlQ5jEbgfdfjotIo x+9faWCp3DXARjkhSm8rkEAG/HAnGtsrjCJvYe5/pf+GMti4oqfEhlfxu4pYG0hahc/Q C8awlSxTvZNJnVrbs0MAtErLrMKB/iutQkxYSBH4q0RcL0fu8JEmuAB0gxSQ98DCGuQZ sVkA== X-Gm-Message-State: AOJu0Yx1/ziVYD8KzDHXBHwL/Wuhj8YkLJkYsF16gWSdR4G8/4319A81 uWgUB5s3ykQLFdKsS7bwkD0DGVkSKixR8tlYXM8Hhsxw77yK27uC1z6pXDkZcek3L7WKwOjb/uY r/z7I8z+FzlqAiOhkCCgfFFXxY6aefDPM/PJue1059FQiNuRBv18GBRhzwXavzuPFf8And0RcWd lVeUbg6pSTyScwKVCk/h0WW+DOUo/yCBNSbdB5etJPLw== X-Google-Smtp-Source: AGHT+IENncRwa8hd6Dw0n9kYhcZmJhMWgrU9EYCmfrVqUteZ6VatKyKp9fps09tz30CVyCAPWNa1l2xUK+XM5A== X-Received: from wmnm21.prod.google.com ([2002:a05:600c:1615:b0:436:1923:6cf5]) (user=whendrik job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:5029:b0:434:a815:2b5d with SMTP id 5b1f17b1804b1-4362aa93dc9mr27447265e9.24.1734110817318; Fri, 13 Dec 2024 09:26:57 -0800 (PST) Date: Fri, 13 Dec 2024 17:26:38 +0000 In-Reply-To: <20241213172645.2751696-1-whendrik@google.com> Mime-Version: 1.0 References: <20241213172645.2751696-1-whendrik@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20241213172645.2751696-2-whendrik@google.com> Subject: [PATCH v5 1/8] i386: Add Intel RDT device and State to config. From: Hendrik Wuethrich <whendrik@google.com> To: qemu-devel@nongnu.org, eduardo@habkost.net, richard.henderson@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com, zhao1.liu@intel.com, xiaoyao.li@intel.com Cc: peternewman@google.com, "=?UTF-8?q?=E2=80=AAHendrik=20W=C3=BCthrich?=" <whendrik@google.com> 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=3YW5cZwgKCvAoZWfVjacYggYdW.UgeiWem-VWnWdfgfYfm.gjY@flex--whendrik.bounces.google.com; helo=mail-wm1-x349.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, 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: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=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: 1734110896472116600 Content-Type: text/plain; charset="utf-8" From: =E2=80=AAHendrik W=C3=BCthrich <whendrik@google.com> 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 <whendrik@google.com> --- hw/i386/Kconfig | 4 ++ hw/i386/meson.build | 1 + hw/i386/rdt.c | 99 +++++++++++++++++++++++++++++++++++++++++++ include/hw/i386/rdt.h | 25 +++++++++++ target/i386/cpu.h | 3 ++ 5 files changed, 132 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 32818480d2..0186b85c3e 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 10bdfde27c..3a697dcc03 100644 --- a/hw/i386/meson.build +++ b/hw/i386/meson.build @@ -22,6 +22,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..b2203197e3 --- /dev/null +++ b/hw/i386/rdt.c @@ -0,0 +1,99 @@ +/* + * 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 + * respective MSRs. + * L3_MASK and L3_mask are architectural limitations. THRTL_COUNT is just + * the space left until the next MSR. + * */ +#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 4c239a6970..0f73c1244d 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -2213,6 +2213,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.1.613.gc27f4b7a9f-goog From nobody Tue May 13 09:08:26 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=1734110942; cv=none; d=zohomail.com; s=zohoarc; b=TxjFCFiPxr0w+nq0sA5VMyghYwrYRYr5NDPfcpBpQALQTOWQMPg5ReCrgm/aADw9sDPsEhMLVTtDdN8wXqG2bd8uBK5J9LY0RKAuU1I47lN5UjnCbLMog4klwW/uLYLVHXPdBtsjAnpjnAlXLkY7eeKy2FmW+5Bl6hoTXAalyD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1734110942; 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=NGf8wLhXTiQ0lyfdQV4U43peDicsASrnc3eX2nyBszM=; b=gPz7dn54wmxLbh5ICWi60wtZUxKUFtju/+MnusiAyF+ASGpwQvbRZJPapSq8w11RrdCLSiIYFNmFQvrZ013Qp7Mp+ZBWBjNBLkT7waVvg65nyrhfrzdVi2E8CEocqnuEx4G8IK6ZLAIKINb4WnZRO4MLf+qA5TayZxztetK0GIU= 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=<whendrik@google.com> (p=reject dis=none) Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1734110942247802.2552487019642; Fri, 13 Dec 2024 09:29:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <qemu-devel-bounces@nongnu.org>) id 1tM9RX-0008Sp-PP; Fri, 13 Dec 2024 12:27:11 -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 <3Y25cZwgKCvIqbYhXlceaiiafY.WigkYgo-XYpYfhihaho.ila@flex--whendrik.bounces.google.com>) id 1tM9RV-0008RN-UE for qemu-devel@nongnu.org; Fri, 13 Dec 2024 12:27:09 -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 <3Y25cZwgKCvIqbYhXlceaiiafY.WigkYgo-XYpYfhihaho.ila@flex--whendrik.bounces.google.com>) id 1tM9RQ-0007oO-Hu for qemu-devel@nongnu.org; Fri, 13 Dec 2024 12:27:09 -0500 Received: by mail-wm1-x349.google.com with SMTP id 5b1f17b1804b1-4361a8fc3bdso11370005e9.2 for <qemu-devel@nongnu.org>; Fri, 13 Dec 2024 09:27:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1734110819; x=1734715619; 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=NGf8wLhXTiQ0lyfdQV4U43peDicsASrnc3eX2nyBszM=; b=j/hVN1A1nGlrnfIy+iF0UbqiUln5HXjkITJh7TipRiOoMIsK09RwUzV/QoFHVt3XYI 0Ph0Lqc5ymIPCbd2a1U3+OBfq3d2qXjNWUQ3rppAADwhHulNOj1iQOvfPXBZuYNj14Xk jYyXjqJG3oRcgg+iOSDrYGMkr3QHHQRsPUMGwEmMGGQ6e/kobe18aIV8jVLKDuXhguAQ ERp7ZppTqByEtCswoAzU0UTDIlCq5XMPfnFUZqLefIRPV750LR6hyES0ec2cBsQ7kp1B SDNnchoGxHtfHVJ3UthrtGU6x+oWueUTfizLIllW60JTcTAyiWS5ihbTNl6ImjSRcHLZ hr4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734110819; x=1734715619; 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=NGf8wLhXTiQ0lyfdQV4U43peDicsASrnc3eX2nyBszM=; b=IgjdRjNdytdIZnXFpeNDS2GkUN+aXGQvdd7ZqvgTGZFccv3WCellLpghud+kdTROd3 85FI4YKy/bkUJufSW4UWz+WKCGjsZ9k2VtmTN0YHpgXxFt7EA1vKyssDGJO96d9AYaYi VWXaw4Rra+N6u6OBUb5UGGB3miwswcB4rzDWG0iLJYKsexTP3KAE0PeVyefHRM9LVaeK 2mHsyklZ0uw9WgtpWAVGwl0QgUDVvnYNO9F//TjKOIvbhfVnxMDnck6JHGAnN15X5blI VtN7dvjisYOKgjbDuTvHvz1w3in9DWsJKJ6fCIS1f1XQFXWOUrdon7aF8xJxazo92cXc Wt8g== X-Gm-Message-State: AOJu0YzgUObEviBUGKqjNopP59N4CV3W4s18Lub4YoPmfvlTMrmWYAdc fbfibcKJQFP6wtuS9SGo8OF6yyV/7haj6xZrrYuYZGMYLC7SQDrpKLegszCAlzUV7c1ce0FmXTe rxKXo2yPWId1SxqOQ6qDvTq33JnEgE99fo5yhZqdLV2mh7Hyg5yk8u7Ifh5iRav11FW+6RTIXZa oik1hvEherZJTcAWQJyRikf0bPomrRYQLHRtnYsT2MSw== X-Google-Smtp-Source: AGHT+IGpjpi7dRbaMmYXtqxJoLZTqnue9rQ8lCMvq97+ObLJmBo1h/rqANrAbnUnEt/6auhX3b1W1eI+ZUsaFw== X-Received: from wmhp10.prod.google.com ([2002:a05:600c:418a:b0:434:eba6:52fa]) (user=whendrik job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:4f07:b0:434:a711:ace4 with SMTP id 5b1f17b1804b1-4362aa50f6emr31900055e9.17.1734110819437; Fri, 13 Dec 2024 09:26:59 -0800 (PST) Date: Fri, 13 Dec 2024 17:26:39 +0000 In-Reply-To: <20241213172645.2751696-1-whendrik@google.com> Mime-Version: 1.0 References: <20241213172645.2751696-1-whendrik@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20241213172645.2751696-3-whendrik@google.com> Subject: [PATCH v5 2/8] i386: Add init and realize functionality for RDT device. From: Hendrik Wuethrich <whendrik@google.com> To: qemu-devel@nongnu.org, eduardo@habkost.net, richard.henderson@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com, zhao1.liu@intel.com, xiaoyao.li@intel.com Cc: peternewman@google.com, "=?UTF-8?q?=E2=80=AAHendrik=20W=C3=BCthrich?=" <whendrik@google.com> 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=3Y25cZwgKCvIqbYhXlceaiiafY.WigkYgo-XYpYfhihaho.ila@flex--whendrik.bounces.google.com; helo=mail-wm1-x349.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, 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: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=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: 1734110942495116600 Content-Type: text/plain; charset="utf-8" From: =E2=80=AAHendrik W=C3=BCthrich <whendrik@google.com> Add code to initialize all necessary state for the RDT device. Signed-off-by: Hendrik W=C3=BCthrich <whendrik@google.com> --- hw/i386/rdt.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/hw/i386/rdt.c b/hw/i386/rdt.c index b2203197e3..920e9c5dbe 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 * respective MSRs. @@ -83,8 +84,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) @@ -94,6 +123,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.1.613.gc27f4b7a9f-goog From nobody Tue May 13 09:08:26 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=1734110868; cv=none; d=zohomail.com; s=zohoarc; b=nGQ0kQXDYUlyksgq+kGyMuAyueS/upST2OXrBKXbk5M3bUEebP95v7HsORuOVEt/r11TnH4rBuCrxD7AadJPj875lvulWJ5fPnUotKHqGHKuwdco63yjupqXUKFcPowiuZLiZeD2pCi/RTbEhol+EpFB+WNKDV4nV7tZ0aXt5hY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1734110868; 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=wHkF/WN4dNFxkLkmakBOXW7PVPtTgVOdWntjSAqATHM=; b=kLMisnNrULPiBcQo1auS+ofWZM8CECRzlRHZkCBZ1XQKP5qOufvUUovD29Baytgj0Xnafp2nqZ9wmZG7T3L7MuFjlCn1ZI71VCl1jf4hBqeBGb2D0JXjr2L20zogO7+ystZrI9UWIw6DSX0FNci+EuiOArzAc2LLqnO6hLm9W2I= 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=<whendrik@google.com> (p=reject dis=none) Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 173411086829164.8666258681485; Fri, 13 Dec 2024 09:27:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <qemu-devel-bounces@nongnu.org>) id 1tM9RY-0008T6-EB; Fri, 13 Dec 2024 12:27:13 -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 <3ZW5cZwgKCvQsdajZnegckkcha.Ykimaiq-Zarahjkjcjq.knc@flex--whendrik.bounces.google.com>) id 1tM9RX-0008Sa-2x for qemu-devel@nongnu.org; Fri, 13 Dec 2024 12:27:11 -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 <3ZW5cZwgKCvQsdajZnegckkcha.Ykimaiq-Zarahjkjcjq.knc@flex--whendrik.bounces.google.com>) id 1tM9RU-0007ow-A9 for qemu-devel@nongnu.org; Fri, 13 Dec 2024 12:27:10 -0500 Received: by mail-wm1-x349.google.com with SMTP id 5b1f17b1804b1-436225d4389so12028125e9.1 for <qemu-devel@nongnu.org>; Fri, 13 Dec 2024 09:27:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1734110821; x=1734715621; 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=wHkF/WN4dNFxkLkmakBOXW7PVPtTgVOdWntjSAqATHM=; b=4nel8UJVC7z0wX52nJV1EtcfgOv9rxFm2O4tZAwziontV9CA/LfcPtwKiQ1Gw7d3BO VqVE8MdvKbOAyUSu4z9axLe4WUzoX3RUDif9PPRyhdQbu95L+vdTIO/SLYc+l9g5t1aE n3hh77gFfQKav5JPzrmLZCRnB5imAeb/xHbRWWome6JXhL1UDY2h2Lhl+aWG+E3HJWcN fQ5LVCnCF9fS2UdMaRyeAKWU7Nq3Nwgu+BX+ConLsqch7kkU3DsRGYP3HObSrLFK1oOS y81tNVud8aruNghuQRZanWihUr6p2vG78Ax7AKX7GYd8mqHFkumFDZtzI1n2iTCZxssz AtQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734110821; x=1734715621; 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=wHkF/WN4dNFxkLkmakBOXW7PVPtTgVOdWntjSAqATHM=; b=mX5aoD1ZSOEjArQF37HjHmJj6MNW34rcFuprkiLpCWP/GRt+UuLUGUCXjl00kYXnfv nB7UBA2uJNdjCe0+df56FDPTsxmrOIKPaCvXuKj/KDFBwWszWbDfWEl3IyAtmty/OTF2 0hlBLy7UkgpiLMwagWWkELZGUOklyEdHC/XVzsdeyLNdHvTthSwIig7iTt4qlCL6s+pN 14NdVoaZIJMIlbJ1wTzzNbRgYwGOU3H+QVKFWMvMa4dVvg/HVdKXbGGgRBH+gly+3Nkt +0I+E2Fd2mYmvxsPqy8L4Nda9D7TLU2twSLXstXrwVzVgKkMHs03ipFTkeyH8lOeKodW Kizw== X-Gm-Message-State: AOJu0YzCuEXDE/uVjAPXbwjv9LXKMt5Aprgz8Ur4idG2iuTvJIzoWdVd hyhdv6viv1ixZC4D71iDvNwKZBYj0tFN7YpImrmgQ5LLSLx2Jxqkr+C9cD0MfkMjaoHHJaRTfCg PsyWfavFhuCjxdotM6cl6ac8zaEB1cuxH4UdRMXdspAAmT8f7T5amaQ/KrveEw3yvvns6HnBRMx LvaYu1RUaOZQQo0sY1HGMxozug6Md0zeGUdQQljR2WVA== X-Google-Smtp-Source: AGHT+IEMkZfiEnVCAyo4k+UhSr0cGRiRQ+sCypTfbN+MSmfiRcGk0iUpUbI+RfTJZ0x2zF6MW4xRf+cjS3NhXA== X-Received: from wmsk11.prod.google.com ([2002:a05:600c:1c8b:b0:434:ef30:4be3]) (user=whendrik job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:1551:b0:435:1a2:262a with SMTP id 5b1f17b1804b1-4362b10271amr27866945e9.3.1734110821229; Fri, 13 Dec 2024 09:27:01 -0800 (PST) Date: Fri, 13 Dec 2024 17:26:40 +0000 In-Reply-To: <20241213172645.2751696-1-whendrik@google.com> Mime-Version: 1.0 References: <20241213172645.2751696-1-whendrik@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20241213172645.2751696-4-whendrik@google.com> Subject: [PATCH v5 3/8] i386: Add RDT functionality From: Hendrik Wuethrich <whendrik@google.com> To: qemu-devel@nongnu.org, eduardo@habkost.net, richard.henderson@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com, zhao1.liu@intel.com, xiaoyao.li@intel.com Cc: peternewman@google.com, "=?UTF-8?q?=E2=80=AAHendrik=20W=C3=BCthrich?=" <whendrik@google.com> 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=3ZW5cZwgKCvQsdajZnegckkcha.Ykimaiq-Zarahjkjcjq.knc@flex--whendrik.bounces.google.com; helo=mail-wm1-x349.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, 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: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=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: 1734110870342116600 Content-Type: text/plain; charset="utf-8" From: =E2=80=AAHendrik W=C3=BCthrich <whendrik@google.com> 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 <whendrik@google.com> --- hw/i386/rdt.c | 123 ++++++++++++++++++++++++++++++++++++++++++ include/hw/i386/rdt.h | 16 ++++++ 2 files changed, 139 insertions(+) diff --git a/hw/i386/rdt.c b/hw/i386/rdt.c index 920e9c5dbe..01bee79cbe 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 * respective MSRs. * L3_MASK and L3_mask are architectural limitations. THRTL_COUNT is just @@ -33,6 +38,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 { @@ -73,6 +81,121 @@ 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; + + return rdt->rdtstate->msr_L3_ia32_mask_n[pos]; +} + +uint32_t rdt_read_l2_mask(uint32_t pos) +{ + X86CPU *cpu =3D X86_CPU(current_cpu); + RDTStatePerCore *rdt =3D cpu->rdt; + + return rdt->rdtstate->msr_L2_ia32_mask_n[pos]; +} + +uint32_t rdt_read_mba_thrtl(uint32_t pos) +{ + X86CPU *cpu =3D X86_CPU(current_cpu); + RDTStatePerCore *rdt =3D cpu->rdt; + + return rdt->rdtstate->ia32_L2_qos_ext_bw_thrtl_n[pos]; +} + +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; + case RDT_EVENT_L3_REMOTE_BW: + return count_remote =3D=3D 0 ? QM_CTR_UNAVAILABLE : count_remote; + case RDT_EVENT_L3_LOCAL_BW: + return count_local =3D=3D 0 ? QM_CTR_UNAVAILABLE : count_local; + 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..14b1c64b72 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 <stdbool.h> +#include <stdint.h> + typedef struct RDTState RDTState; typedef struct RDTStatePerCore RDTStatePerCore; typedef struct RDTMonitor RDTMonitor; typedef struct RDTAllocation RDTAllocation; =20 +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); + #endif --=20 2.47.1.613.gc27f4b7a9f-goog From nobody Tue May 13 09:08:26 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=1734111030; cv=none; d=zohomail.com; s=zohoarc; b=MN08aeVf9veJpYgchyjul/WXfCPRuTWQQyWmZZTwUELUfwNDa2zpjoyEiCu4gVpxnR9Bw0hDevht+biwlhnThPQOxRX3BPdg9lkcamp/3mPEsgJsiPNj+tif9z0XriwJ6a2Pt/Pbj9Ubrb98th2A1vWdKuW50Vt2T8RLq5fdx7Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1734111030; 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=YqWaCzV/pnA2MoZa7zZ2F5Y69vMXA/gibLEg3WL4oEA=; b=DRLaWGRnrXsKtPDQvWyI7Jy/+0dXphhutPzLCeQAvTdkrjs8j2Gt9dh0Cucgb59FRe2m8tfn28JGfIB8LYi4VXSPEGoskTIiATK13A07zsDRkGgDN/Msf0Q72tOdjdZBPZuSKQ+TjEmfbEFcnKvUs34YWCiuE6F/4ipveDKZaJA= 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=<whendrik@google.com> (p=reject dis=none) Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1734111030162571.7945978291065; Fri, 13 Dec 2024 09:30:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <qemu-devel-bounces@nongnu.org>) id 1tM9Re-0008Va-DM; Fri, 13 Dec 2024 12:27:18 -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 <3Z25cZwgKCvYufclbpgiemmejc.amkocks-bctcjlmlels.mpe@flex--whendrik.bounces.google.com>) id 1tM9Ra-0008U4-CN for qemu-devel@nongnu.org; Fri, 13 Dec 2024 12:27:14 -0500 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3Z25cZwgKCvYufclbpgiemmejc.amkocks-bctcjlmlels.mpe@flex--whendrik.bounces.google.com>) id 1tM9RU-0007pZ-K5 for qemu-devel@nongnu.org; Fri, 13 Dec 2024 12:27:14 -0500 Received: by mail-wr1-x44a.google.com with SMTP id ffacd0b85a97d-3878ad4bf8cso1306102f8f.1 for <qemu-devel@nongnu.org>; Fri, 13 Dec 2024 09:27:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1734110823; x=1734715623; 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=YqWaCzV/pnA2MoZa7zZ2F5Y69vMXA/gibLEg3WL4oEA=; b=EEG8Zy1oufzB1GjoElx/BpFqWBjCqRTovb0tj09DmfXKGUc87zT4mXugLML/K+3nPD g0SGsqVyAsMJdZZFGjXQhO/0cEcAoFD91ibP1lqd8yVegWV9xy2P1HEXpb6uJM7uKWUL yZtqhLHZkqdvLj4lCVYSEq5TyXJwXIaNrHTYhNv0mNQufVnJZ9UpWBrVJVkciXJYDqR5 dGFfHAyj/zsN1J2nTkGuDp5yrqCpYzFOjuUfRvLmi8uBvUBAkZrGcFcHFhS1HvaMfsKw tos5TOWUQIjrJnsfasDYRWcOKwsluVQtwAU0rouHhe/QenX6NQN+nqFmfW8C8XoU6qMH am8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734110823; x=1734715623; 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=YqWaCzV/pnA2MoZa7zZ2F5Y69vMXA/gibLEg3WL4oEA=; b=Ger6LGfVJIs6pYSwqENILeZgSJNzk4gqim8Jbwok/QIBCYxGASBbz816fQOItKRltS 3CIbpNK9A3xcjYfFr+VrxByb7Xe3nIviWiXd2W+NAu3CdggRKpBDONOItUOqgkdbchNS kVqNxL9zfEfelZfXZpwDCRxW+vg0RY9uQsI23S+PG/0/blL7I8aUwMAmgBxOh+TZ6Mfs mMyx5AZ3uMyOUR5q/dXSFIATUY9pP9sqkaM5acd9blZoTAv2QwjfBcW3j5qFJb7XIc1w SgSsqzSBE2R1z8+0eX0qQp+3/XGIfKN/dVmg2phlgVFQAtsRq4Em3sQMmFDK9BeDhyWn zdlA== X-Gm-Message-State: AOJu0Yxj9j+oEsdOLMZ7qZS3Aj7rL8A3fZ3qnVj0FIz2JsmvsB/8UpFq d3qQJNEG9x3cQBROUOIm6v0Ajjhi3aaJ4h+Oi0q/Fr6fqWPCo79asA9jEf8+aqwDuJWzL+OBkLt fhIim1XS4wu3pxoGlWpWPyiMtddKsHE8i/y8LG4MNyVzuMt5i6qXa6H+8Vmu6D20te+0486xs+p 12ygBeMxQpiuPzJPkcJaVhM6hzgcczvfrGc+piCTn+9A== X-Google-Smtp-Source: AGHT+IF3YsIgjmZoIK4dEn/RQaITQ9Ymxk34HWnChtWLuyv0TJGiWDew8SsQcsJ1qkTzWxUZ9Gzoq4jJWOP0dA== X-Received: from wmro18.prod.google.com ([2002:a05:600c:3792:b0:434:a045:c681]) (user=whendrik job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:a19:b0:385:ef39:6cf7 with SMTP id ffacd0b85a97d-3888e0bb9d7mr2642313f8f.32.1734110823070; Fri, 13 Dec 2024 09:27:03 -0800 (PST) Date: Fri, 13 Dec 2024 17:26:41 +0000 In-Reply-To: <20241213172645.2751696-1-whendrik@google.com> Mime-Version: 1.0 References: <20241213172645.2751696-1-whendrik@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20241213172645.2751696-5-whendrik@google.com> Subject: [PATCH v5 4/8] i386: Add RDT device interface through MSRs From: Hendrik Wuethrich <whendrik@google.com> To: qemu-devel@nongnu.org, eduardo@habkost.net, richard.henderson@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com, zhao1.liu@intel.com, xiaoyao.li@intel.com Cc: peternewman@google.com, "=?UTF-8?q?=E2=80=AAHendrik=20W=C3=BCthrich?=" <whendrik@google.com> 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::44a; envelope-from=3Z25cZwgKCvYufclbpgiemmejc.amkocks-bctcjlmlels.mpe@flex--whendrik.bounces.google.com; helo=mail-wr1-x44a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, 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: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=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: 1734111030955116600 Content-Type: text/plain; charset="utf-8" From: =E2=80=AAHendrik W=C3=BCthrich <whendrik@google.com> 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 <whendrik@google.com> --- hw/i386/rdt.c | 4 ++ include/hw/i386/rdt.h | 4 ++ target/i386/cpu.h | 14 +++++ target/i386/tcg/sysemu/misc_helper.c | 81 ++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+) diff --git a/hw/i386/rdt.c b/hw/i386/rdt.c index 01bee79cbe..3a37341bd6 100644 --- a/hw/i386/rdt.c +++ b/hw/i386/rdt.c @@ -81,6 +81,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); diff --git a/include/hw/i386/rdt.h b/include/hw/i386/rdt.h index 14b1c64b72..ec82a149f2 100644 --- a/include/hw/i386/rdt.h +++ b/include/hw/i386/rdt.h @@ -25,6 +25,10 @@ typedef struct RDTStatePerCore RDTStatePerCore; typedef struct RDTMonitor RDTMonitor; typedef struct RDTAllocation RDTAllocation; =20 +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); diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 0f73c1244d..64a53efa30 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -576,6 +576,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 @@ -1839,6 +1850,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..a6c6b11a29 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,45 @@ 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 +512,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; --=20 2.47.1.613.gc27f4b7a9f-goog From nobody Tue May 13 09:08:26 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=1734110868; cv=none; d=zohomail.com; s=zohoarc; b=DZZ9n171+8eR1G7Wn6emKcRpzAkg8borjAF7grs2j+rAG2dPCzUeiXN1YGL6+mv8kP5fPROyufd9DTWAMJYI02Kg1vhje3gMxexFz6o0x3GI6cxJpN+nkNJm+HFCwiC4vKAkegljQA0QBfzSHT4MyVFWUBDx6E/YeTV9/ZaEXXs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1734110868; 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=pGGndzlyEmTL5r3SwAzymXOwQXZlbBFF+E9VZuGkaIQ=; b=belCDIH7tQo1WVulS57ejv5ndKrRyKXcHmlXfeIlCDkfdmTKcXFjS4yeDZDwNdQPnY9AzXXwsKwL9gj5whfI5FJbv+pb+aMHtc6lFdhht0SLTMmuY5uLeZVGpU0QKuW01trB/h91KwxOrmhNByGJo60aVtTbdLYpHdDAYegH/kg= 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=<whendrik@google.com> (p=reject dis=none) Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1734110868461998.2096050749634; Fri, 13 Dec 2024 09:27:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <qemu-devel-bounces@nongnu.org>) id 1tM9Rb-0008UT-Ql; Fri, 13 Dec 2024 12:27:15 -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 <3aG5cZwgKCvcvgdmcqhjfnnfkd.bnlpdlt-cdudkmnmfmt.nqf@flex--whendrik.bounces.google.com>) id 1tM9RY-0008TE-Ln for qemu-devel@nongnu.org; Fri, 13 Dec 2024 12:27:12 -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 <3aG5cZwgKCvcvgdmcqhjfnnfkd.bnlpdlt-cdudkmnmfmt.nqf@flex--whendrik.bounces.google.com>) id 1tM9RT-0007q8-KO for qemu-devel@nongnu.org; Fri, 13 Dec 2024 12:27:12 -0500 Received: by mail-wm1-x34a.google.com with SMTP id 5b1f17b1804b1-4362b9c15d8so4858625e9.3 for <qemu-devel@nongnu.org>; Fri, 13 Dec 2024 09:27:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1734110825; x=1734715625; 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=pGGndzlyEmTL5r3SwAzymXOwQXZlbBFF+E9VZuGkaIQ=; b=kKogyAvf2Q0a9Ycmp8LQoQMKAaL16UlfpMz/mWgAE3mfm/RAhUEgEtxwVsrVdOGYS/ gh0jBZcPxhp5T+TDZZpi0ROm/GPJKC2CT9Bc8dU5lwVxQOLqfskly5YQ6oJ0K+bdL6Gx OLefz1csvszcy8fMTJaVzHd5yy3h25CY96pwdXBt5Q5+eOVP057ec6zfqgmOo/SNehp2 HXMAf3Rp7E+DRTSo0zu1o987KR1Xq7RDk1V5/jRQJnn+GrEMMNYf66/vdBNEByc/zjhY UdZuKPOfNxL3lMpFLDnZJ/mgNwNa8va8E1CbWdT7DtBF8U25P771ver8u/2laE1WUJ/m zQfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734110825; x=1734715625; 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=pGGndzlyEmTL5r3SwAzymXOwQXZlbBFF+E9VZuGkaIQ=; b=iCRfJHwOmQeyPzEel0g13wrblBTDu/PhVLi+3rxUpQfEZXj8BfJgEDjFQQ96wYpcpY PEcxjKhNJaa4C1rULa7DDgjh2lO8NiRyMX5dWOM7wys1XkkT02dAIMfJ4jJbfKkx/yH9 3YQbn1wxhAY/fKNWIiYx4ce44lFE3VBD+HtUCNCU13mhgZV2T/jpzQNRRC9InIqVy6n5 nz8KkMKT6lsim+Y2MUBvquOlcb3h5+ntCgDjaekxfIDQdjEBxXmkgYk7+7490AUE0vwl aJ6iyqFJ7bt+bJFqYkh9ijYzCTXD4bmvHSZU43XQU1PB6nmfVFnBAAb4Gas79nR1kT3z 0d6w== X-Gm-Message-State: AOJu0YxYVLY4ZqKICuZ3edtl0ut0pqCtaYi/Rm+4tHOhbhi8YF5iPcBf A9IT0ErsCzm40J3MFZsdREcdx2/YFJ+GURgRTVqzfJPQyTFGKsSh//rpiRRhYuQqR/3+Sznab4x AHt+tHaLQ/+Z7jYGZTarjF5bNRMLEQLyjgFKCSyjVMD2r+/e8KDETPnaK6kPS4l9+6wQXhZ8FcA Rogz54HkAw4cioY1r9oXw1Ea6xeV+bHlSqLDiAE+Sfcg== X-Google-Smtp-Source: AGHT+IGhvN4/1yno2Lnqg3uB4M24JpY5kItm0P2r0QcNdzXCqBkl2Jr1zxIh9qssRj4MSfswc3OdK0w0qS+agg== X-Received: from wmna1.prod.google.com ([2002:a05:600c:681:b0:434:a2a5:1fb5]) (user=whendrik job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:1d86:b0:435:136:75f6 with SMTP id 5b1f17b1804b1-4362a98815cmr33545565e9.0.1734110824963; Fri, 13 Dec 2024 09:27:04 -0800 (PST) Date: Fri, 13 Dec 2024 17:26:42 +0000 In-Reply-To: <20241213172645.2751696-1-whendrik@google.com> Mime-Version: 1.0 References: <20241213172645.2751696-1-whendrik@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20241213172645.2751696-6-whendrik@google.com> Subject: [PATCH v5 5/8] i386: Add CPUID enumeration for RDT From: Hendrik Wuethrich <whendrik@google.com> To: qemu-devel@nongnu.org, eduardo@habkost.net, richard.henderson@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com, zhao1.liu@intel.com, xiaoyao.li@intel.com Cc: peternewman@google.com, "=?UTF-8?q?=E2=80=AAHendrik=20W=C3=BCthrich?=" <whendrik@google.com> 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=3aG5cZwgKCvcvgdmcqhjfnnfkd.bnlpdlt-cdudkmnmfmt.nqf@flex--whendrik.bounces.google.com; helo=mail-wm1-x34a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01, 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: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=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: 1734110870344116600 Content-Type: text/plain; charset="utf-8" From: =E2=80=AAHendrik W=C3=BCthrich <whendrik@google.com> 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 <whendrik@google.com> --- hw/i386/rdt.c | 30 ++++++++++++++++++ include/hw/i386/rdt.h | 31 +++++++++++++++++++ target/i386/cpu.c | 71 +++++++++++++++++++++++++++++++++++++++++++ target/i386/cpu.h | 5 +++ 4 files changed, 137 insertions(+) diff --git a/hw/i386/rdt.c b/hw/i386/rdt.c index 3a37341bd6..7c9170559d 100644 --- a/hw/i386/rdt.c +++ b/hw/i386/rdt.c @@ -35,6 +35,17 @@ #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) +/* RDT L2 Allocation features*/ +#define CPUID_10_2_EAX_CBM_LENGTH 0xf +#define CPUID_10_2_EBX_CBM 0x0 +/* RDT MBA features */ +#define CPUID_10_3_EAX_THRTL_MAX 89 +#define CPUID_10_3_ECX_LINEAR_RESPONSE (1U << 2) + #define TYPE_RDT "rdt" #define RDT_NUM_RMID_PROP "rmids" =20 @@ -81,8 +92,27 @@ struct RDTState { struct RDTStateClass { }; =20 +uint32_t rdt_get_cpuid_F_0_edx_l3(void) { return CPUID_F_1_EDX_L3_OCCUPANC= Y | CPUID_F_1_EDX_L3_TOTAL_BW | CPUID_F_1_EDX_L3_LOCAL_BW; } + +uint32_t rdt_cpuid_F_1_edx_l3_total_bw_enabled(void) { return CPUID_F_1_ED= X_L3_TOTAL_BW; } +uint32_t rdt_cpuid_F_1_edx_l3_local_bw_enabled(void) { return CPUID_F_1_ED= X_L3_LOCAL_BW; } +uint32_t rdt_cpuid_F_1_edx_l3_occupancy_enabled(void) { return CPUID_F_1_E= DX_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..859fb4871c 100644 --- a/include/hw/i386/rdt.h +++ b/include/hw/i386/rdt.h @@ -20,13 +20,44 @@ #include <stdbool.h> #include <stdint.h> =20 +/* RDT L3 Cache Monitoring Technology */ +#define CPUID_F_0_EDX_L3 (1U << 1) +#define CPUID_F_1_EDX_L3_OCCUPANCY (1U << 0) +#define CPUID_F_1_EDX_L3_TOTAL_BW (1U << 1) +#define CPUID_F_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_F_0_edx_l3(void); + +uint32_t rdt_cpuid_F_1_edx_l3_total_bw_enabled(void); +uint32_t rdt_cpuid_F_1_edx_l3_local_bw_enabled(void); +uint32_t rdt_cpuid_F_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 3725dbbc4b..c6e6cff19d 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -41,6 +41,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" @@ -6725,6 +6726,76 @@ 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 rdt device not used"); + break; + } + /* Non-zero count is ResId */ + switch (count) { + /* Monitoring Resource Type Enumeration */ + case 0: + *edx =3D env->features[FEAT_RDT_F_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_F_1_edx_l3_total_bw_enabled() | + rdt_cpuid_F_1_edx_l3_local_bw_enabled() | + rdt_cpuid_F_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 rdt 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 64a53efa30..a1ec2d5dde 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -678,6 +678,7 @@ typedef enum FeatureWord { FEAT_7_1_EDX, /* CPUID[EAX=3D7,ECX=3D1].EDX */ FEAT_7_2_EDX, /* CPUID[EAX=3D7,ECX=3D2].EDX */ FEAT_24_0_EBX, /* CPUID[EAX=3D0x24,ECX=3D0].EBX */ + FEAT_RDT_F_0_EDX, /* CPUID[EAX=3D0xf,ECX=3D0].EDX (RDT CMT/MBM) */ FEATURE_WORDS, } FeatureWord; =20 @@ -852,8 +853,12 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *cp= u, FeatureWord w); #define CPUID_7_0_EBX_RTM (1U << 11) /* Zero out FPU CS and FPU DS */ #define CPUID_7_0_EBX_ZERO_FCS_FDS (1U << 13) +/* 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.1.613.gc27f4b7a9f-goog From nobody Tue May 13 09:08:26 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=1734111031; cv=none; d=zohomail.com; s=zohoarc; b=mlJXBLJitYHupFzZ9Y/9ttbPFt5jzz5pf04xTk8oFwIvofIt+IGwMLmum4vNaP9L0Yw3jOGsrs4OnHdKMLr4BMnLBy/q+4IVPBlBvIJ+zqchKpzQlRwiML2uw8lzxej4XMOfidg1Oe8YFLzS6nb0RNNdKWF8+U49nYbz4YBzzIo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1734111031; 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=yrlaSRZ8054fQhMNBYWcK8NfFEF1eZz8tbpXey1V4pI=; b=la6uVmdHa1wkd+huymE2w/Vx8AAk84OEQ/P/1DEtUHcZJSvfDcw5pufjMvEO1PvdOCe/fcTArFK6HTwYZPwsqbZ2IYEAoJGfYwg7qX7OjkKKlZ4nbYnHpcOyAdmyMg6ARlFtpjLUagquE+1uno9/Ykt59n47y3dGAVzPzOa2IvE= 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=<whendrik@google.com> (p=reject dis=none) Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1734111031547979.8621830602813; Fri, 13 Dec 2024 09:30:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <qemu-devel-bounces@nongnu.org>) id 1tM9Rb-0008UI-0C; Fri, 13 Dec 2024 12:27:15 -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 <3am5cZwgKCvkxifoesjlhpphmf.dpnrfnv-efwfmopohov.psh@flex--whendrik.bounces.google.com>) id 1tM9RY-0008T3-5Q for qemu-devel@nongnu.org; Fri, 13 Dec 2024 12:27:12 -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 <3am5cZwgKCvkxifoesjlhpphmf.dpnrfnv-efwfmopohov.psh@flex--whendrik.bounces.google.com>) id 1tM9RU-0007qy-QK for qemu-devel@nongnu.org; Fri, 13 Dec 2024 12:27:11 -0500 Received: by mail-wm1-x349.google.com with SMTP id 5b1f17b1804b1-4361fc2b2d6so4807785e9.3 for <qemu-devel@nongnu.org>; Fri, 13 Dec 2024 09:27:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1734110827; x=1734715627; 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=yrlaSRZ8054fQhMNBYWcK8NfFEF1eZz8tbpXey1V4pI=; b=Lf+e2c979bY9R5Ft8UicjZqLS80RbJnP7BODBNImlKZO/rGXEHoQrirkOcHx5r8cMr 4c0fqI4603KBiyN9iprZJQ9FkBhbrgX8o/V9Lwu+hJT/rGbx7iJKDTIhEp+q7CR3qELd SFMA4XBuy8Y5DRCh92rCcm8sy3dbRzv8wTV/QurGsdj/Yq+QTLJA9CfRjOdKiIw5gZJ4 xXRbAx+RI27hZgYojSm7VB6ockVv/YJiu4+2BY/lZ0O1EQM8Sks3mEVXbwwDG7a+bpmw Mqgi1tLyKXkksI7RxXqjG25qIAkstkHh98ZNco7KTw09iz0/YNCz950W/dLEM5Zfp/r2 e1eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734110827; x=1734715627; 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=yrlaSRZ8054fQhMNBYWcK8NfFEF1eZz8tbpXey1V4pI=; b=izmpDpfnGmKPs+3cjvh///A9JkbAl+cFUCBklJKegbOEZvei73mJVSGFB3nWq3ibQl RsIOaVVcdv3qnTWssbJPEB/nxld/D6DfHaJC3YAtBijO7GFmGatl4+fJsKarpJ89Rqfa GIqfUNsoteO85wZnHM7zLpcWnMMsWSat63vL6oAZp041P5pwYKoMh9wd+p0W3zt2epv0 rm2lxnn8McwUG4AjiK2RwqrnvCblISUl3ewlYxqeNaU2HLfIhMrKqRTiba3H6BnLxJWd 0zhJ9bdtxHti3Zws07Fx7ajE55SgPLPVK7Nvi62jmo4lNOqn1JkydbqJ4D6bgRsJnOiT SlDA== X-Gm-Message-State: AOJu0YzYn60XKsPPXGGSBtfeBu8Ne6KUbPC949sUlY9WUi/fUjEdutIQ KLmhW2gLZwIo/ri2AS0EoV/rmwLK7b/O4pig6k68A0iOxtAa6dik7Qemf72Jdrnd5HwHX8Y18Er i2akk5NuvagiGZxi8JaxB+BTixKFX7oWKuGA+jEvVbO0j083xnTHmJ6AJqxmlgZNfoFC7I0wkdg nRsY1N3KeuMiiIvfsydo3kd5mObgTynp7YIdNNzH561Q== X-Google-Smtp-Source: AGHT+IF1uhcvW9S0LazRXQZHbdrAITOaDVFpxoz+PguqWxBwML68Z6leHlztMWP9/O+shy9MpFS0Upj179NJMw== X-Received: from wmot11.prod.google.com ([2002:a05:600c:450b:b0:434:fc6f:e8c3]) (user=whendrik job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:4f4f:b0:436:346a:fa9b with SMTP id 5b1f17b1804b1-436346afda1mr11215495e9.20.1734110826981; Fri, 13 Dec 2024 09:27:06 -0800 (PST) Date: Fri, 13 Dec 2024 17:26:43 +0000 In-Reply-To: <20241213172645.2751696-1-whendrik@google.com> Mime-Version: 1.0 References: <20241213172645.2751696-1-whendrik@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20241213172645.2751696-7-whendrik@google.com> Subject: [PATCH v5 6/8] i386: Add RDT feature flags. From: Hendrik Wuethrich <whendrik@google.com> To: qemu-devel@nongnu.org, eduardo@habkost.net, richard.henderson@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com, zhao1.liu@intel.com, xiaoyao.li@intel.com Cc: peternewman@google.com, "=?UTF-8?q?=E2=80=AAHendrik=20W=C3=BCthrich?=" <whendrik@google.com> 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=3am5cZwgKCvkxifoesjlhpphmf.dpnrfnv-efwfmopohov.psh@flex--whendrik.bounces.google.com; helo=mail-wm1-x349.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, 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: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=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: 1734111033037116600 Content-Type: text/plain; charset="utf-8" From: =E2=80=AAHendrik W=C3=BCthrich <whendrik@google.com> Add RDT features to feature word / TCG. Signed-off-by: Hendrik W=C3=BCthrich <whendrik@google.com> --- 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 c6e6cff19d..6f14d6fc62 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -869,7 +869,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 */ @@ -906,6 +907,7 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t vendo= r1, #define TCG_SGX_12_0_EBX_FEATURES 0 #define TCG_SGX_12_1_EAX_FEATURES 0 #define TCG_24_0_EBX_FEATURES 0 +#define TCG_RDT_F_0_EDX_FEATURES CPUID_F_0_EDX_L3 =20 #if defined CONFIG_USER_ONLY #define CPUID_8000_0008_EBX_KERNEL_FEATURES (CPUID_8000_0008_EBX_IBPB | \ @@ -1063,7 +1065,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D { "fsgsbase", "tsc-adjust", "sgx", "bmi1", "hle", "avx2", "fdp-excptn-only", "smep", "bmi2", "erms", "invpcid", "rtm", - NULL, "zero-fcs-fds", "mpx", NULL, + "rdt-m", "zero-fcs-fds", "mpx", "rdt-a", "avx512f", "avx512dq", "rdseed", "adx", "smap", "avx512ifma", "pcommit", "clflushopt", "clwb", "intel-pt", "avx512pf", "avx512er", @@ -1651,6 +1653,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_F_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_F_0_EDX_FEATURES, + }, }; =20 typedef struct FeatureMask { diff --git a/target/i386/cpu.h b/target/i386/cpu.h index a1ec2d5dde..2b5a5986de 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -678,7 +678,9 @@ typedef enum FeatureWord { FEAT_7_1_EDX, /* CPUID[EAX=3D7,ECX=3D1].EDX */ FEAT_7_2_EDX, /* CPUID[EAX=3D7,ECX=3D2].EDX */ FEAT_24_0_EBX, /* CPUID[EAX=3D0x24,ECX=3D0].EBX */ + FEAT_RDT_F_0_EBX, /* CPUID[EAX=3D0xf,ECX=3D0].EBX (RDT CMT/MBM) */ FEAT_RDT_F_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.1.613.gc27f4b7a9f-goog From nobody Tue May 13 09:08:26 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=1734110962; cv=none; d=zohomail.com; s=zohoarc; b=QvlCXnvE52z1wp//VgMbwnrtBtRdNaZdbIDhJyLUEAky/q3jYgpeBnaKcn3p/+pXQIXsKZDRXIcLUZbolu1XpaJO6OL0/g/fYwDa+ibDS1UKG3VBIA+QLgq5YYtAEIk7SkQAdSnszgYhm+gX9SfkIToxUnTdCvVtxyruboq/wGM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1734110962; 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=rAiCO/dJHydeGND4wPl0sH4es7qWQmf2yOCvmsYbaR4=; b=hFGGbUxUeFseip7CGVSp5ms4hVSOYpmH5TF3ne/k7yowXH4MRYjfowCmRbYF9PaszZbR0lEn0Kho/HydfcqA7UkTDhViD3TB6be3RA0Qw3I/LewxqYtvNgo0OJKnTZxM9k6HML1LINCfSNEM1A5JUvFeCbKd6WKvRUoejq7hQtY= 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=<whendrik@google.com> (p=reject dis=none) Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1734110962561236.99886549915277; Fri, 13 Dec 2024 09:29:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <qemu-devel-bounces@nongnu.org>) id 1tM9Ra-0008UD-Th; Fri, 13 Dec 2024 12:27:14 -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 <3bG5cZwgKCvszkhqgulnjrrjoh.frpthpx-ghyhoqrqjqx.ruj@flex--whendrik.bounces.google.com>) id 1tM9RY-0008TQ-UI for qemu-devel@nongnu.org; Fri, 13 Dec 2024 12:27:12 -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 <3bG5cZwgKCvszkhqgulnjrrjoh.frpthpx-ghyhoqrqjqx.ruj@flex--whendrik.bounces.google.com>) id 1tM9RW-0007rP-EM for qemu-devel@nongnu.org; Fri, 13 Dec 2024 12:27:12 -0500 Received: by mail-wm1-x349.google.com with SMTP id 5b1f17b1804b1-4361ac8b25fso11771485e9.2 for <qemu-devel@nongnu.org>; Fri, 13 Dec 2024 09:27:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1734110829; x=1734715629; 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=rAiCO/dJHydeGND4wPl0sH4es7qWQmf2yOCvmsYbaR4=; b=ADEpNpr7egex4czb0dEAfzd6/BJUd9aXjTeewWF5sjEX1Utl4Iy5pMMS2280/kNwlf Gp5reiAHh36FSRvFsyw4kjYi14LoUQtgUEtThJfipgk6Lm8MKPwSB3aoc0HhZE1VKrgH AXnYrH5gTQfficdvKuCd+n8fMWu3rCQXFJAPYrb4eLraPpYbhM5KEIl9DHXuUvVzViUi HZL4mKWfHs1qIPnb+pP5FgVsphgA52lxgb1TXyVv2ixIIyeqH9K16YU4Xgle8I+dk/aV l6/YTeB4bgoef9DN9DaKeqVFe+UnPbxZ1wO4z9p+EeS84KLEstSlq7r/Wm8tUG+GyKzn Y+Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734110829; x=1734715629; 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=rAiCO/dJHydeGND4wPl0sH4es7qWQmf2yOCvmsYbaR4=; b=JE4PvPRDRIWqxElCXZroMNOh6crHYBwy9bPxmJx3o3Jtlqt1iLEu7IjCeYGjkSFnml VBmUF6f/SzGtoiISFLODixXMkLdvPUsjYqP3rui2OxXAB1sSuWwuxc3uWVoExSBY2Irm LnOYFdpngxCuD+jJGx9vkjnpbtWmpcweM6rYRANkoR38N2zBkf+jkte8N3T4iZjFwJoM fN5rYHK0QdwZg1CD4nWTXxbXzhdAZinWMzHT8gDli0ynEbSbb+Mbz+pDgVT8elRHRItt /LrV1VLEBhv5mVJ4xxrfJOVpwIvDwVi5/s+DjG4w77DmluijBBKcUnZ95CQ4jmsyqHGn 2d1w== X-Gm-Message-State: AOJu0YzaR2PovA3Mgn3ddNRPPMMqhD290TqVfzTk9MQaa1EJYorZjnLa ds8yhaBbFAR2jGMf2r0ysNCC+fHU0JpgwLGZB/UkY4DWUJvYaQufTnHVmmIiBU8LXzUlkl8OMuH 0RsSpm1rOzbPfmHibIm7iYS8sWIq/Iejr8klK7A+wq7agR3YkpCuNvBho1KayA5hKZM/PVUuKHQ mzsuxO3N4BK6ZEikm8M2lYQtsPD1nfEygKSirt0dmLhw== X-Google-Smtp-Source: AGHT+IE1ragnyyWr0MXKVjbyEQ3QqEpfY6srZsIuxKvmbQY2Pe5BVPEmwej/4kMyKUBBhuGqHCS+n5LOG9kASQ== X-Received: from wmos10.prod.google.com ([2002:a05:600c:45ca:b0:434:fa72:f1bf]) (user=whendrik job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:4ed4:b0:434:fb65:ebbb with SMTP id 5b1f17b1804b1-4362aa66874mr34466575e9.17.1734110828833; Fri, 13 Dec 2024 09:27:08 -0800 (PST) Date: Fri, 13 Dec 2024 17:26:44 +0000 In-Reply-To: <20241213172645.2751696-1-whendrik@google.com> Mime-Version: 1.0 References: <20241213172645.2751696-1-whendrik@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20241213172645.2751696-8-whendrik@google.com> Subject: [PATCH v5 7/8] i386/cpu: Adjust CPUID level for RDT features From: Hendrik Wuethrich <whendrik@google.com> To: qemu-devel@nongnu.org, eduardo@habkost.net, richard.henderson@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com, zhao1.liu@intel.com, xiaoyao.li@intel.com Cc: peternewman@google.com, "=?UTF-8?q?=E2=80=AAHendrik=20W=C3=BCthrich?=" <whendrik@google.com> 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=3bG5cZwgKCvszkhqgulnjrrjoh.frpthpx-ghyhoqrqjqx.ruj@flex--whendrik.bounces.google.com; helo=mail-wm1-x349.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, 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: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=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: 1734110964601116600 Content-Type: text/plain; charset="utf-8" From: =E2=80=AAHendrik W=C3=BCthrich <whendrik@google.com> 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 <whendrik@google.com> --- target/i386/cpu.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 6f14d6fc62..f7904870ed 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7719,6 +7719,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.1.613.gc27f4b7a9f-goog From nobody Tue May 13 09:08:26 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=1734110970; cv=none; d=zohomail.com; s=zohoarc; b=fRKxLYpW6tHCjd5iYoHcQ9NDV3k0UdfOE8ZUxkH+AFd7J25rmPLH1s7btlu+v7xIENcbBFp4s8yzHaIsQeiCVE4MV7ZsYjfYi4kMowOTCLsXwEqacFtQorDcEra8OjtWv+Bgjmq6lETqNGyO3SqTFQVCEsCjTMiaDXCVD8lLzTU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1734110970; 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=ZYv+pg+UZazKGCKy29BkEC26GYqoLpWfMbrkqDY73z8=; b=C48hWNjslWeIZoLNoaRtNlPU2Ss205VlsckUYH8UAo8QoM0I6S7Xwn1xaHl33l18+7pULqMC0pc7cUSbgCDI7w1PqtiH373kFo0s6Q7jUtofcmTu4RPPZ8ctTZQGQgVQJazP3u9swuY9GxEeU7aUML09Q4svOjj2AlKhU/NFZF8= 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=<whendrik@google.com> (p=reject dis=none) Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1734110970006400.5994278599386; Fri, 13 Dec 2024 09:29:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <qemu-devel-bounces@nongnu.org>) id 1tM9Rd-0008VT-Ok; Fri, 13 Dec 2024 12:27: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 <3bm5cZwgKCv01mjsiwnplttlqj.htrvjrz-ij0jqstslsz.twl@flex--whendrik.bounces.google.com>) id 1tM9Ra-0008U5-IN for qemu-devel@nongnu.org; Fri, 13 Dec 2024 12:27:14 -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 <3bm5cZwgKCv01mjsiwnplttlqj.htrvjrz-ij0jqstslsz.twl@flex--whendrik.bounces.google.com>) id 1tM9RY-0007s5-Ka for qemu-devel@nongnu.org; Fri, 13 Dec 2024 12:27:14 -0500 Received: by mail-wm1-x349.google.com with SMTP id 5b1f17b1804b1-434fe2b605eso11611945e9.2 for <qemu-devel@nongnu.org>; Fri, 13 Dec 2024 09:27:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1734110831; x=1734715631; 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=ZYv+pg+UZazKGCKy29BkEC26GYqoLpWfMbrkqDY73z8=; b=WgvxMIWp0xLa5CQibV4Jn2aG7ii1ixPxLqPQckV9L1HrRcjo2lopGPd02VHGeOdW8m fv0+4zl0y3j1FznCQNV4CfeOlFbhoYma4oyhRMtyFT6eT+Nbfj6m87t0a/RUEfEgFZMQ eqDN4sy0NpjALwQ9bEer01xblo/g3++cZapeczz1AIOJUfKNvs9IPnubhVvv+o6bUryp U6aBQ7y6/bdyK1EbJpb15H1HqCDCREik64Fw25OepCAjXg95Q2N3yiqYj7iHSb36VQB/ ZooGLGolRkVOh0Ne5rjh+4gWTVC6rJNTdmA5fKO+kNxJSGNxJKGFnLuqqwykAu4ZBstX yaCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734110831; x=1734715631; 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=ZYv+pg+UZazKGCKy29BkEC26GYqoLpWfMbrkqDY73z8=; b=MYr/hnDaRou4TNsZzyQ0Ubix3E37wmi1pmlcXQgKGERkGowEA0ouPZFKQpr88PZ6DA DdXXSew0iUiM4e4O6vSVfn+LU3YCvYRLKkRZPIZ7njSLMAMtImQWYLeG1kphwCWTRWq8 N1HIYgUJt1YNaO0WUG5HDxqJ/D1QxMSEXFG9Kx+nT9iNONdyXqSg1RRtESQWW1oVgo4u dybORSqbw9l6KewUp6ijVfidIfdXXdW7yTsjBN/97Vl2ASh0F/S2WMJhKcRwkJ4+nLRU gd/pHTmv9doohDGFQGF3V+QmhtLaHWDEr92USXIK4kXF97QZU8xb6CwFpNZBN/HLp8bx CBrg== X-Gm-Message-State: AOJu0YzOuRfWFQEYwwZ6VNyObHCR6UoHofEVcKr6IYrwgy09k1ojljT0 DYO2UvUNBQ/dewXRX0PV98lRUoj5/w9v1yrNNTQURSbjrqrgknfQCJybOujty5A0OpxBRZTi+gj QR38GGWmxMFeHeDZBOMApFuRYOh2yDB3CfdSm2MGwFy21KbqQlve/6iFdxQkzwsclJZEjRu8S47 yIm6813mW1gn6pBYrEaCCVvw91WxItsjHkRFxQCG17dg== X-Google-Smtp-Source: AGHT+IFy5d157S59NX6/IVic3hAaUU1ydX7QiydKmzSAfk5UGHdRLcDdjm3M8VRzNTQoXC72FxRr0dUevUNaEA== X-Received: from wmbdx22.prod.google.com ([2002:a05:600c:63d6:b0:436:3ea:c491]) (user=whendrik job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:cc9:b0:434:f739:7ce3 with SMTP id 5b1f17b1804b1-4362aa2881bmr28110425e9.8.1734110830711; Fri, 13 Dec 2024 09:27:10 -0800 (PST) Date: Fri, 13 Dec 2024 17:26:45 +0000 In-Reply-To: <20241213172645.2751696-1-whendrik@google.com> Mime-Version: 1.0 References: <20241213172645.2751696-1-whendrik@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20241213172645.2751696-9-whendrik@google.com> Subject: [PATCH v5 8/8] i386/cpu: Adjust level for RDT on full_cpuid_auto_level From: Hendrik Wuethrich <whendrik@google.com> To: qemu-devel@nongnu.org, eduardo@habkost.net, richard.henderson@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com, zhao1.liu@intel.com, xiaoyao.li@intel.com Cc: peternewman@google.com, "=?UTF-8?q?=E2=80=AAHendrik=20W=C3=BCthrich?=" <whendrik@google.com> 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=3bm5cZwgKCv01mjsiwnplttlqj.htrvjrz-ij0jqstslsz.twl@flex--whendrik.bounces.google.com; helo=mail-wm1-x349.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, 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: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=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: 1734110970616116600 Content-Type: text/plain; charset="utf-8" From: =E2=80=AAHendrik W=C3=BCthrich <whendrik@google.com> Make sure that RDT monitoring and allocation features are included in in full_cpuid_auto_level. Signed-off-by: Hendrik W=C3=BCthrich <whendrik@google.com> --- target/i386/cpu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index f7904870ed..4f1493043e 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -880,6 +880,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 | \ @@ -7672,6 +7673,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_F_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.1.613.gc27f4b7a9f-goog