From patchwork Thu Dec 5 20:00:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hendrik Wuethrich X-Patchwork-Id: 13895969 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D8D04E77170 for ; Thu, 5 Dec 2024 20:01:22 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJI1j-0002rI-9L; Thu, 05 Dec 2024 15:00:43 -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 <3XgZSZwgKCvMrcZiYmdfbjjbgZ.XjhlZhp-YZqZgijibip.jmb@flex--whendrik.bounces.google.com>) id 1tJI1g-0002qf-11 for qemu-devel@nongnu.org; Thu, 05 Dec 2024 15:00:40 -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 <3XgZSZwgKCvMrcZiYmdfbjjbgZ.XjhlZhp-YZqZgijibip.jmb@flex--whendrik.bounces.google.com>) id 1tJI1Y-0001d9-PQ for qemu-devel@nongnu.org; Thu, 05 Dec 2024 15:00:34 -0500 Received: by mail-wm1-x34a.google.com with SMTP id 5b1f17b1804b1-434a96889baso8143985e9.2 for ; Thu, 05 Dec 2024 12:00:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733428831; x=1734033631; 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=sczQpCntEV4pWQdfCwwJkDKiQSND8KcLmMCFvvS8Q/4=; b=KOwJRqaDLRGv8LXk4jtQxJQTkqjwldfrjxQuqymZ/qi4P07e3s0xG3t4rlkIrRQBC2 QODL0eUmTGuTbGzCJmYJbA6NcOxa7wyGoW/mxh/2pPnW/OlQFDs4We1ZYFK1lu+0Seqp DAooVyD3d3cU0KHxwCyPYwOjTbis6V9CdGuvNz+WRO7EMq6bHROzzF8sUSerTetT4ZWh AeVTKiegMrqirv7AdF9f1pTFbLpj61Xq7eT2HJzmdLZJlBnS+/JeReyNOq4rW0912T5s lv9LTQWSYwbLMNxzxJrJSM0ilETTeXv1OexeMRUZIpRstxo/3thDmSo3TYr8oVrGXZvP UzNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733428831; x=1734033631; 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=sczQpCntEV4pWQdfCwwJkDKiQSND8KcLmMCFvvS8Q/4=; b=PP7nCEdAxuHrq7yWafUee4OlrJNuiCNZL6UOd9IBc2ps6hMVaxIAQqWnXVy8hQYy4F KZqGRgR9kTvW1XYqqamWVwEjjQxDimkBpLA/eGr6H4NJrcwKXnW4Ho3QD/+kUdX43Hwd OBGNbT/0Pc9alryp9nbe4dDB3nQOcnY7aOVKEEQqscpSWFuoZMQqjV7etROi2AgJeXdw iCU7zUS00uRy3zbsWN0BHGMj0F4eR8bKIxgq1LLpT2AplOA4cut3FsRn92oZ/H0n3aIv HYw4hh9MfbIz9RApYcBW/4zza2zOfaQ5DXFCnJp47ynEwyBm9C4i+zuIYO1CpAliqM1D WJoA== X-Gm-Message-State: AOJu0YxP8Oct1dOkPU5bZaY6GhKIwsqjR53mcGS/Bmj0WhN4Uq//6X3F YjQRY20CF898lOHqQEeU+AmIB9QQh1rSaR+qVZ1WvVluz517Q8oPEeJWI7oZxeGz6m73Gkuvgpn Jz6ZtMZN4G7SEsdvK8YiC1LMz/QghoqltgROMi23f43Xt9mAy9Mcgp4ExEzuOvptnLfeXfvHMVg T4Saw+Q1e6WKs2vSXLx62YaYwNBw91J95IXvdHG9n4ig== X-Google-Smtp-Source: AGHT+IFwRDUkPdK2A5S2YS1TruDhZDlph6latXsv8JuEy+hzMxCjJhZ6jVRl2TZTQbRVldVI4sZVn9tK8obtdw== X-Received: from wmsl24.prod.google.com ([2002:a05:600c:1d18:b0:434:a90a:3986]) (user=whendrik job=prod-delivery.src-stubby-dispatcher) by 2002:a5d:5f8c:0:b0:385:e67d:9e0 with SMTP id ffacd0b85a97d-3862b37d51amr245577f8f.29.1733428830448; Thu, 05 Dec 2024 12:00:30 -0800 (PST) Date: Thu, 5 Dec 2024 20:00:18 +0000 In-Reply-To: <20241205200025.2081863-1-whendrik@google.com> Mime-Version: 1.0 References: <20241205200025.2081863-1-whendrik@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241205200025.2081863-2-whendrik@google.com> Subject: [PATCH v4 1/8] i386: Add Intel RDT device and State to config. From: Hendrik Wuethrich To: qemu-devel@nongnu.org, eduardo@habkost.net, richard.henderson@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com Cc: peternewman@google.com, " =?utf-8?b?4oCqSGVuZHJpayBXw7x0aHJpY2g=?= " Received-SPF: pass client-ip=2a00:1450:4864:20::34a; envelope-from=3XgZSZwgKCvMrcZiYmdfbjjbgZ.XjhlZhp-YZqZgijibip.jmb@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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: ‪Hendrik Wüthrich Change config to show RDT, add minimal code to the rdt.c module to make sure things still compile. Signed-off-by: Hendrik Wüthrich --- 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 +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')) 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 WITHOUT + * 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[] = { + 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 = DEVICE_CLASS(klass); + + dc->hotpluggable = false; + dc->desc = "RDT"; + dc->user_creatable = 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 WITHOUT + * 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; + /* Help the RDT MSRs find the RDT device */ + struct RDTStatePerCore *rdt; + struct kvm_msrs *kvm_msr_buf; int32_t node_id; /* NUMA node this CPU belongs to */ From patchwork Thu Dec 5 20:00:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hendrik Wuethrich X-Patchwork-Id: 13895970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D7609E7716E for ; Thu, 5 Dec 2024 20:01:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJI2F-0002yG-GW; Thu, 05 Dec 2024 15:01: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 <3YAZSZwgKCvUtebkaofhdlldib.Zljnbjr-absbiklkdkr.lod@flex--whendrik.bounces.google.com>) id 1tJI1i-0002rH-VA for qemu-devel@nongnu.org; Thu, 05 Dec 2024 15:00:42 -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 <3YAZSZwgKCvUtebkaofhdlldib.Zljnbjr-absbiklkdkr.lod@flex--whendrik.bounces.google.com>) id 1tJI1f-0001dS-KP for qemu-devel@nongnu.org; Thu, 05 Dec 2024 15:00:42 -0500 Received: by mail-wm1-x34a.google.com with SMTP id 5b1f17b1804b1-434a29a93cdso11018155e9.1 for ; Thu, 05 Dec 2024 12:00:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733428832; x=1734033632; 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=WdDRNCpvhyFf5ymMFmEKsE00vimCuFTsFl7VJrJoo7A=; b=JY8Q5wuM2BvYvMpZ5nnHllRpDjOTC8SldftmkljBkUPENm18XE7bxMeGYVgCaUEh3I XsRun27WaQSG2AwTxMjYYhvTCS+aBxuC8hH8n8wiGw2KandCMxI3yz49PvSQkuUZujHn VyxT7AbxZ5w5N5cM5qQ9ZfQEg2qf5gQ0Sca4SPEFCSlPaaM1t//Z2AeOwjpHTErzuhqQ oirQ+gx6QRTsOU+CjXaBm/6XBNQwElhIRTDqomqNtx/ElHXN6Ey+6WQMJ/HafCb4tWRQ wK0fdQNd3dit3Sd/q0cEAtLK89SLb1sgJM3k91zndqQ1qGv+kzPgx5wlO7goPV359xiP WyvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733428832; x=1734033632; 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=WdDRNCpvhyFf5ymMFmEKsE00vimCuFTsFl7VJrJoo7A=; b=M30wJhQfYSE+0e9aremuIq6oMldLFcil0CTJQgKLLBHgBhmwb+aHcNvoeH7TT/atE2 Yu8ph0824zIR2HQJmT2sLrNheSG+5Q/O3U8xkkfQaBlNnzfRzr4kMlSlyo8a8doPI9YU 51thIU6o2gPAYGCS44eDtKMk220OR9X3eYRBsLudHmLHOJ71SVwtepoF9tQPWFSy9HBQ Dh6yCcBbUpa6QmnQ9pMR82XB2Q0CNMmuv7om2Rq0lhI2bRBltmM8z6V4h72tH2IhVIpJ PSFmHcxDrRD6thBs/1pV38eLWGOaJdyBIvvfUsY7uOomlF6dg1XyB3vRQsbkXjiilnfX uHQQ== X-Gm-Message-State: AOJu0YyU8+yQgyQNcpp9K8QoAeNUfJKPntDBueKIq+68/MB/ADfo3xKD RePI44TbQHalumScvxnhf44dCeCil3/1uHJ2flwP4EplJY31kBdIGHvRJLThYEUW7H4a0Fei3EI CPebFSTNLONuz0gkoaq+uQ1X8QkP1y2q1LDrStMbGebIxEGVyz90FdFSW0YxIEHsVtPZUrh4gj2 5x/ugfPnE1ovd9RsSuZTcfCsQgaOPhHhQuPNESIk3Sow== X-Google-Smtp-Source: AGHT+IHG7XNoJTIFl6Dp6p5xr39MiMesFUfdc+FZPX2nYgS2ioWLM/vcC4jLEr7WqEWWrLNZGsTSNgWn2F8q6Q== X-Received: from wmbhi5.prod.google.com ([2002:a05:600c:5345:b0:434:a735:35ac]) (user=whendrik job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:19cb:b0:434:a5b3:8fee with SMTP id 5b1f17b1804b1-434dded66aamr4371655e9.26.1733428832237; Thu, 05 Dec 2024 12:00:32 -0800 (PST) Date: Thu, 5 Dec 2024 20:00:19 +0000 In-Reply-To: <20241205200025.2081863-1-whendrik@google.com> Mime-Version: 1.0 References: <20241205200025.2081863-1-whendrik@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241205200025.2081863-3-whendrik@google.com> Subject: [PATCH v4 2/8] i386: Add init and realize functionality for RDT device. From: Hendrik Wuethrich To: qemu-devel@nongnu.org, eduardo@habkost.net, richard.henderson@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com Cc: peternewman@google.com, " =?utf-8?b?4oCqSGVuZHJpayBXw7x0aHJpY2g=?= " Received-SPF: pass client-ip=2a00:1450:4864:20::34a; envelope-from=3YAZSZwgKCvUtebkaofhdlldib.Zljnbjr-absbiklkdkr.lod@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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: ‪Hendrik Wüthrich Add code to initialize all necessary state for the RDT device. Signed-off-by: Hendrik Wüthrich --- 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" /* 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) { } +static void rdt_realize(DeviceState *dev, Error **errp) +{ + CPUState *cs = first_cpu; + RDTState *rdtDev = RDT(dev); + + rdtDev->rdtInstances = g_malloc(sizeof(RDTStatePerCore) * cs->nr_cores); + CPU_FOREACH(cs) { + RDTStatePerCore *rdt = &rdtDev->rdtInstances[cs->cpu_index]; + X86CPU *cpu = X86_CPU(cs); + + rdt->rdtstate = rdtDev; + cpu->rdt = rdt; + + rdt->monitors = g_malloc(sizeof(RDTMonitor) * rdtDev->rmids); + rdt->rdtstate->allocations = g_malloc(sizeof(RDTAllocation) * rdtDev->rmids); + } +} + static void rdt_finalize(Object *obj) { + CPUState *cs; + RDTState *rdt = RDT(obj); + + CPU_FOREACH(cs) { + RDTStatePerCore *rdtInstance = &rdt->rdtInstances[cs->cpu_index]; + g_free(rdtInstance->monitors); + g_free(rdtInstance->rdtstate->allocations); + } + + g_free(rdt->rdtInstances); } static void rdt_class_init(ObjectClass *klass, void *data) @@ -94,6 +123,7 @@ static void rdt_class_init(ObjectClass *klass, void *data) dc->hotpluggable = false; dc->desc = "RDT"; dc->user_creatable = true; + dc->realize = rdt_realize; device_class_set_props(dc, rdt_properties); } From patchwork Thu Dec 5 20:00:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hendrik Wuethrich X-Patchwork-Id: 13895974 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0D412E77170 for ; Thu, 5 Dec 2024 20:02:09 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJI20-0002v2-3e; Thu, 05 Dec 2024 15:01: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 <3YgZSZwgKCvcvgdmcqhjfnnfkd.bnlpdlt-cdudkmnmfmt.nqf@flex--whendrik.bounces.google.com>) id 1tJI1m-0002sc-2e for qemu-devel@nongnu.org; Thu, 05 Dec 2024 15:00:47 -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 <3YgZSZwgKCvcvgdmcqhjfnnfkd.bnlpdlt-cdudkmnmfmt.nqf@flex--whendrik.bounces.google.com>) id 1tJI1j-0001de-Vv for qemu-devel@nongnu.org; Thu, 05 Dec 2024 15:00:45 -0500 Received: by mail-wr1-x449.google.com with SMTP id ffacd0b85a97d-3862a49fbdaso67742f8f.1 for ; Thu, 05 Dec 2024 12:00:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733428834; x=1734033634; 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=L0Vl0lgng4jKpAj1S2pwpVZ8cBNzdb9nnkfVpbstCPM=; b=BF8HjJ6cgMZrGR1F+RYxHIW1EkcKAh0rzqWWATi0i4Ai5ygobaow93gjRMf8DBmfVD WIfa5MMKtdinIsG5/w2gxK7kcuv4MtTDexEBz0GpcuCAEbPGPX15BKWPNB40l5hfhozs iFqldhtkdnJdr9Uus5/DqHHtRRCqlN1WGe62atmbU+ft5KseWhRJyswW7vzs/iaLOJAZ JDr4k9MIenqQKfeFesR1hKK1uF5HlHIti4tDBl+NTsCJPaiwbN4BPRg88i+qw54c3o8i 8WFj7RaxIawaG48AybTo6B9/75/b81nGCLovZTF74Pjzrc/CODVJIirCggflm3NQDLaZ B4pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733428834; x=1734033634; 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=L0Vl0lgng4jKpAj1S2pwpVZ8cBNzdb9nnkfVpbstCPM=; b=KoXIoivBFkvqWdDfzQ92c8XvEUjXhD4SIVgc3dq9CSOud72tbEL9wTeFRYFhMllbsO CEhoSrMdX7UyWDUQYfp2WrDlhUtx/KovuVesVDklMBUpTNYDfz5QpdgpcUcz/xoncahx Fp7gm26EfYeOngI2Uv0REO4EG8PUGhfSUlOQz9EiRI1oTkJLed8aaexwghHWhtBMz6BT 1FbK0SJIX5gfSByiyer8TTfj5+t1aiOg8b9bPYyDhN8cIjSFyVJErPkZQKVFV8+Hezuh UBZM270eN8RR+5syzJ6ia2vcJU79LMSN+MEWbOvSXUykNEjj4pAAW2WjTEMugCKHW5yY Vj2Q== X-Gm-Message-State: AOJu0YxfxOwZ0cQWzSmNv4rstLf3Dy2VOghnBgDzfBPRHnRIJPPa8TGd gbBpQHr5QerLg17wZjlg/X1IpUnY/EJWrlG9o72ZRTVzZEAFonVG1q76oFb93xPp55tigO0ZCO6 xGhaoQDJhMuXCjipydpgrsjdTxf2SHzifnMi1A7NcmEp/tkeRhD85pooa05m3FtkrCj5/nYUygo xV7Kdne66Q8VqasNfZEK3MXxpu9dTWYSsEekgr48mftg== X-Google-Smtp-Source: AGHT+IFbU++A+uXAqwDDUJOvkgHLl8bAA57ohJDZvEPUuBXvobDV2395uwyYzQevzW24y3sUzyrl3tHeEHaaYg== X-Received: from wmim9.prod.google.com ([2002:a7b:cb89:0:b0:434:9cfd:391e]) (user=whendrik job=prod-delivery.src-stubby-dispatcher) by 2002:a5d:6c69:0:b0:385:fb2c:6021 with SMTP id ffacd0b85a97d-3862b3d5ad0mr283355f8f.39.1733428834109; Thu, 05 Dec 2024 12:00:34 -0800 (PST) Date: Thu, 5 Dec 2024 20:00:20 +0000 In-Reply-To: <20241205200025.2081863-1-whendrik@google.com> Mime-Version: 1.0 References: <20241205200025.2081863-1-whendrik@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241205200025.2081863-4-whendrik@google.com> Subject: [PATCH v4 3/8] i386: Add RDT functionality From: Hendrik Wuethrich To: qemu-devel@nongnu.org, eduardo@habkost.net, richard.henderson@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com Cc: peternewman@google.com, " =?utf-8?b?4oCqSGVuZHJpayBXw7x0aHJpY2g=?= " Received-SPF: pass client-ip=2a00:1450:4864:20::449; envelope-from=3YgZSZwgKCvcvgdmcqhjfnnfkd.bnlpdlt-cdudkmnmfmt.nqf@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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: ‪Hendrik Wüthrich 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üthrich --- 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" +/* 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" +#define QM_CTR_ERROR (1ULL << 63) +#define QM_CTR_UNAVAILABLE (1ULL << 62) + OBJECT_DECLARE_TYPE(RDTState, RDTStateClass, RDT); struct RDTMonitor { @@ -73,6 +81,121 @@ struct RDTState { struct RDTStateClass { }; +bool rdt_associate_rmid_cos(uint64_t msr_ia32_pqr_assoc) +{ + X86CPU *cpu = X86_CPU(current_cpu); + RDTStatePerCore *rdt = cpu->rdt; + RDTAllocation *alloc; + + uint32_t cos_id = (msr_ia32_pqr_assoc & 0xffff0000) >> 16; + uint32_t rmid = 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 = rmid; + + alloc = &rdt->rdtstate->allocations[rmid]; + + alloc->active_cos = cos_id; + + return true; +} + +uint32_t rdt_read_l3_mask(uint32_t pos) +{ + X86CPU *cpu = X86_CPU(current_cpu); + RDTStatePerCore *rdt = cpu->rdt; + + return rdt->rdtstate->msr_L3_ia32_mask_n[pos]; +} + +uint32_t rdt_read_l2_mask(uint32_t pos) +{ + X86CPU *cpu = X86_CPU(current_cpu); + RDTStatePerCore *rdt = cpu->rdt; + + return rdt->rdtstate->msr_L2_ia32_mask_n[pos]; +} + +uint32_t rdt_read_mba_thrtl(uint32_t pos) +{ + X86CPU *cpu = X86_CPU(current_cpu); + RDTStatePerCore *rdt = 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 = X86_CPU(current_cpu); + RDTStatePerCore *rdt = cpu->rdt; + + rdt->rdtstate->msr_L3_ia32_mask_n[pos] = val; +} + +void rdt_write_msr_l2_mask(uint32_t pos, uint32_t val) +{ + X86CPU *cpu = X86_CPU(current_cpu); + RDTStatePerCore *rdt = cpu->rdt; + + rdt->rdtstate->msr_L2_ia32_mask_n[pos] = val; +} + +void rdt_write_mba_thrtl(uint32_t pos, uint32_t val) +{ + X86CPU *cpu = X86_CPU(current_cpu); + RDTStatePerCore *rdt = cpu->rdt; + + rdt->rdtstate->ia32_L2_qos_ext_bw_thrtl_n[pos] = val; +} + +uint32_t rdt_max_rmid(RDTStatePerCore *rdt) +{ + RDTState *rdtdev = 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 = rdtInstance->rdtstate; + + uint32_t count_l3 = 0; + uint32_t count_local = 0; + uint32_t count_remote = 0; + + if (!rdt) { + return 0; + } + + CPU_FOREACH(cs) { + rdtInstance = &rdt->rdtInstances[cs->cpu_index]; + if (rmid >= rdtInstance->monitors->len) { + return QM_CTR_ERROR; + } + mon = &g_array_index(rdtInstance->monitors, RDTMonitor, rmid); + count_l3 += mon->count_l3; + count_local += mon->count_local; + count_remote += mon->count_remote; + } + + switch (event_id) { + case RDT_EVENT_L3_OCCUPANCY: + return count_l3 == 0 ? QM_CTR_UNAVAILABLE : count_l3; + case RDT_EVENT_L3_REMOTE_BW: + return count_remote == 0 ? QM_CTR_UNAVAILABLE : count_remote; + case RDT_EVENT_L3_LOCAL_BW: + return count_local == 0 ? QM_CTR_UNAVAILABLE : count_local; + default: + return QM_CTR_ERROR; + } +} + OBJECT_DEFINE_TYPE(RDTState, rdt, RDT, ISA_DEVICE); static Property rdt_properties[] = { 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 +#include +#include + typedef struct RDTState RDTState; typedef struct RDTStatePerCore RDTStatePerCore; typedef struct RDTMonitor RDTMonitor; typedef struct RDTAllocation RDTAllocation; +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 From patchwork Thu Dec 5 20:00:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hendrik Wuethrich X-Patchwork-Id: 13895973 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0F31CE7716E for ; Thu, 5 Dec 2024 20:02:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJI20-0002vB-Dn; Thu, 05 Dec 2024 15:01: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 <3YwZSZwgKCvg1mjsiwnplttlqj.htrvjrz-ij0jqstslsz.twl@flex--whendrik.bounces.google.com>) id 1tJI1k-0002s0-Ll for qemu-devel@nongnu.org; Thu, 05 Dec 2024 15:00:45 -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 <3YwZSZwgKCvg1mjsiwnplttlqj.htrvjrz-ij0jqstslsz.twl@flex--whendrik.bounces.google.com>) id 1tJI1i-0001du-LL for qemu-devel@nongnu.org; Thu, 05 Dec 2024 15:00:44 -0500 Received: by mail-wr1-x449.google.com with SMTP id ffacd0b85a97d-385e9c69929so569033f8f.1 for ; Thu, 05 Dec 2024 12:00:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733428836; x=1734033636; 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=n2k3Kj++lpw+/t0tRPKUWKSRAwMCFCHVv44hybRHn4A=; b=v2RqZTOGsW5UZ4uFgmMYiAfMQN5jyAxeUWrYtyrjOtqCJlrkcW7hn8Uugwx3/amWT9 fcnl9cYVmXJu2dSZvInLLNI6lXRAlt1l6K4JeTpjVh33ESBQu5r+n5tHcd8GwHuRTQON J2TXIsVfR2EXGC6YcS7z2WURehrlwNR3xILNmuY9v6afGhA5vZj1HQwNiVgygWj5cWhG VJHOyZMnZpuB6TMILf7GecGEYsRYYDcFvjW/I6KPTvdUH7lT40EKhxvH/b7HWuoOZI+B N+/afu+MNbYEtn5GTUw6AaKYsJPTKD5LpExW5y6hakaJLJ48saCmnTrKY+YzMcBXII2O 11yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733428836; x=1734033636; 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=n2k3Kj++lpw+/t0tRPKUWKSRAwMCFCHVv44hybRHn4A=; b=o66G1VvZ1Bs+ePY8oS71EVmSjxRx0VCCMVchZCfcShJMQIV+UmmnQUI6CyyQ6sjBEU /EmHTXFMT34f87NbKFqw0WPAjsTxhEiswCtBGBOstYOcdA02Nje9CdVgJwfCNFoiLx9w 6smIt05XBr5SwPNH9YeBx0DxEr/kjLOFV+OnTmKO1jAeltXXX2clErLBHq+cggtbqRHX 30I+4LZVm3ttrfE1tUJMgdNjXMY0xjbsuyRTY7B7iVRhJYPuGXoUJVm+i2ZXbfCLixwj BIARqo3UBSrIEqCOqmVL2YtvkoQV8oBBlTVn0sfFNDXiUJ6p5CDUaL2itRDXWq4vFTR9 7M2g== X-Gm-Message-State: AOJu0YzqEvWjhvk8kinjvGbh1VlhFpFFDaT9gBGBlCjOfN4Sc1Ppkz8Z bDcP5/Bht56U4k8utLwEh26lbYqh9ckdVfGpGXI95brCeDGsO4TaoQV+jr4y5DevEkR1fEr7hTN OJxTury/KKDC1120g6/WH8LFz9nuczjsIePtRDYerWa3WAbhgozVQdeJ/nQNHtCHrVk4vVou4gj CQxgbgtZ5Lx4pBPruKZrpgfDIlFvOhRQWOtDl/Dnto2w== X-Google-Smtp-Source: AGHT+IFn99Rmv5S1XumH2jBaxIAluPe3SSF7qp6sRMvWaFEB5hGr/PCAvDGEpy3p5QRiiOK92ZpEmijKy2XgeA== X-Received: from wmjv14.prod.google.com ([2002:a7b:cb4e:0:b0:42c:b22f:f7f7]) (user=whendrik job=prod-delivery.src-stubby-dispatcher) by 2002:a5d:6f0d:0:b0:385:faad:bfb9 with SMTP id ffacd0b85a97d-3862b33b7bfmr399884f8f.8.1733428835908; Thu, 05 Dec 2024 12:00:35 -0800 (PST) Date: Thu, 5 Dec 2024 20:00:21 +0000 In-Reply-To: <20241205200025.2081863-1-whendrik@google.com> Mime-Version: 1.0 References: <20241205200025.2081863-1-whendrik@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241205200025.2081863-5-whendrik@google.com> Subject: [PATCH v4 4/8] i386: Add RDT device interface through MSRs From: Hendrik Wuethrich To: qemu-devel@nongnu.org, eduardo@habkost.net, richard.henderson@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com Cc: peternewman@google.com, " =?utf-8?b?4oCqSGVuZHJpayBXw7x0aHJpY2g=?= " Received-SPF: pass client-ip=2a00:1450:4864:20::449; envelope-from=3YwZSZwgKCvg1mjsiwnplttlqj.htrvjrz-ij0jqstslsz.twl@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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: ‪Hendrik Wüthrich 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üthrich --- 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 { }; +uint32_t rdt_get_cpuid_10_1_edx_cos_max(void) { return RDT_MAX_L3_MASK_COUNT; } +uint32_t rdt_get_cpuid_10_2_edx_cos_max(void) { return RDT_MAX_L2_MASK_COUNT; } +uint32_t rdt_get_cpuid_10_3_edx_cos_max(void) { return RDT_MAX_MBA_THRTL_COUNT; } + bool rdt_associate_rmid_cos(uint64_t msr_ia32_pqr_assoc) { X86CPU *cpu = 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; +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); 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 +#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 @@ -1839,6 +1850,9 @@ typedef struct CPUArchState { uint64_t msr_ia32_feature_control; uint64_t msr_ia32_sgxlepubkeyhash[4]; + 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" void helper_outb(CPUX86State *env, uint32_t port, uint32_t data) @@ -293,6 +294,45 @@ void helper_wrmsr(CPUX86State *env) env->msr_bndcfgs = val; cpu_sync_bndcs_hflags(env); break; + case MSR_IA32_QM_EVTSEL: + env->msr_ia32_qm_evtsel = val; + break; + case MSR_IA32_PQR_ASSOC: + env->msr_ia32_pqr_assoc = val; + + if (!rdt_associate_rmid_cos(val)) + goto error; + break; + case MSR_IA32_L3_CBM_BASE ... MSR_IA32_L3_MASKS_END: + { + uint32_t pos = (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 = (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_Thrtl_END: + { + uint32_t pos = (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 = (uint32_t)env->regs[R_ECX] - MSR_APIC_START; @@ -472,6 +512,47 @@ void helper_rdmsr(CPUX86State *env) val = (cs->nr_threads * cs->nr_cores) | (cs->nr_cores << 16); break; } + case MSR_IA32_QM_CTR: + val = 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 = env->msr_ia32_qm_evtsel; + break; + case MSR_IA32_PQR_ASSOC: + val = env->msr_ia32_pqr_assoc; + break; + case MSR_IA32_L3_CBM_BASE ... MSR_IA32_L3_MASKS_END: + { + uint32_t pos = (uint32_t)env->regs[R_ECX] - MSR_IA32_L3_CBM_BASE; + + if (pos >= rdt_get_cpuid_10_1_edx_cos_max()) { + raise_exception_err_ra(env, EXCP0D_GPF, 0, GETPC()); + } + val = rdt_read_l3_mask(pos); + break; + } + case MSR_IA32_L2_CBM_BASE ... MSR_IA32_L2_CBM_END: + { + uint32_t pos = (uint32_t)env->regs[R_ECX] - MSR_IA32_L2_CBM_BASE; + + if (pos >= rdt_get_cpuid_10_2_edx_cos_max()) { + raise_exception_err_ra(env, EXCP0D_GPF, 0, GETPC()); + } + val = rdt_read_l2_mask(pos); + break; + } + case MSR_IA32_L2_QOS_Ext_BW_Thrtl_BASE ... MSR_IA32_L2_QOS_Ext_BW_Thrtl_END: + { + uint32_t pos = (uint32_t)env->regs[R_ECX] - MSR_IA32_L2_QOS_Ext_BW_Thrtl_BASE; + + if (pos >= rdt_get_cpuid_10_3_edx_cos_max()) { + raise_exception_err_ra(env, EXCP0D_GPF, 0, GETPC()); + } + val = rdt_read_mba_thrtl(pos); + break; + } case MSR_APIC_START ... MSR_APIC_END: { int ret; int index = (uint32_t)env->regs[R_ECX] - MSR_APIC_START; From patchwork Thu Dec 5 20:00:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hendrik Wuethrich X-Patchwork-Id: 13895972 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6789DE77170 for ; Thu, 5 Dec 2024 20:01:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJI26-0002wD-V3; Thu, 05 Dec 2024 15:01:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3ZQZSZwgKCvoyjgpftkmiqqing.eqosgow-fgxgnpqpipw.qti@flex--whendrik.bounces.google.com>) id 1tJI1n-0002sy-P3 for qemu-devel@nongnu.org; Thu, 05 Dec 2024 15:00:48 -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 <3ZQZSZwgKCvoyjgpftkmiqqing.eqosgow-fgxgnpqpipw.qti@flex--whendrik.bounces.google.com>) id 1tJI1k-0001e9-EI for qemu-devel@nongnu.org; Thu, 05 Dec 2024 15:00:47 -0500 Received: by mail-wm1-x349.google.com with SMTP id 5b1f17b1804b1-43499388faaso10686035e9.3 for ; Thu, 05 Dec 2024 12:00:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733428837; x=1734033637; 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=pWkgJolpx+mZqKbhYNxiZ9/l5hMtBVxFSqBoV7MfHSM=; b=hgmphFZxTQS/cxj5mVra/8LfSxog1R/tKvlHzaVCbUW+CtyCN3phGCGjlUQjuoae2Y sR0QuWlU5TBbh26UM+HdlJt+sMrMfVWD8nWoj5Wui7l4NbXmWZuMxhBorecIcvqdJDVi OCptnrelTOEpv4JWjOoT6LMo9zzpXoIB/IT1YlRmzt1TqIFwtlOuV5zU/A+Gkj/j8bQx ZJGFM0QRIu7R9rFNyFLBN9qeGblAYiLcaK9bvB20rNTcD8k7UUFqtjsA2PbazZ0O1m48 4bZsk4TcgCvhGKqSK+gAxisYU3E25sseklGl1/EzyTAW7Xlkan+Xj8MRt+jMW6PW6KIf verA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733428837; x=1734033637; 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=pWkgJolpx+mZqKbhYNxiZ9/l5hMtBVxFSqBoV7MfHSM=; b=a28sakqJRy+akly3CvEVD8ziQ7bu1JwvW3QcPzTYzLnQns/xIyrgC5o9lsnPf7vCjC Yd1iGqkRJXOTVB/pkM68rW9CIlKQOgpF64ckpp72SB+EAycMHKN5+xqttb8p/25RWcZY 6PY9ifVVO0mZUoQcD9SLzaYYlUnRNmhE2q574DKOV6Op9Gy5L/8R+wBJ43CkhEru2U8U rb8mkqV4zDQZ/1L8qhi+wzVbN9urXTU0saDfE3BovW7tbfVxJC4LycUbVoOaxIdKKluC mnPC+TGaZtS7CKxlF2KcIMhTMI34XE9Mi6TA3um03BEEII+IEiaH6InixJCRoytwNmby gM9w== X-Gm-Message-State: AOJu0YxQmcN24f/u1qLyLHRWiZ8KcAZwVb6CG4KDlpKiMQ5hIP2M0haZ Dzr71BT/S8zXtS7orN7MYjSASYuyzTBBbhOYbVEmFmiZDdt1DJP3jBGdvFcuy4G0VChgvWMNhSF R2SVAczBhOf3IaQxYOHOtv3LQMXRxNYP2K0+auVNnSDsiZ008mvkRt2AzQ3O3TG+9kyOgMqlHrL hyL2+a7ESALJiPeyiag9mYGqw68py04wuPNL+J76kzJg== X-Google-Smtp-Source: AGHT+IFVN+t5AaK9w5yosMHze73Ql178pSVRUsvxdVCTC54i5jsi7nFSQby/ALy/jmQQJJTpBUkk9Kcw2PLGmw== X-Received: from wmpq23.prod.google.com ([2002:a05:600c:3317:b0:42c:b336:8685]) (user=whendrik job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:358f:b0:42c:de2f:da27 with SMTP id 5b1f17b1804b1-434ddeadeeemr4801105e9.2.1733428837804; Thu, 05 Dec 2024 12:00:37 -0800 (PST) Date: Thu, 5 Dec 2024 20:00:22 +0000 In-Reply-To: <20241205200025.2081863-1-whendrik@google.com> Mime-Version: 1.0 References: <20241205200025.2081863-1-whendrik@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241205200025.2081863-6-whendrik@google.com> Subject: [PATCH v4 5/8] i386: Add CPUID enumeration for RDT From: Hendrik Wuethrich To: qemu-devel@nongnu.org, eduardo@habkost.net, richard.henderson@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com Cc: peternewman@google.com, " =?utf-8?b?4oCqSGVuZHJpayBXw7x0aHJpY2g=?= " Received-SPF: pass client-ip=2a00:1450:4864:20::349; envelope-from=3ZQZSZwgKCvoyjgpftkmiqqing.eqosgow-fgxgnpqpipw.qti@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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: ‪Hendrik Wüthrich Add CPUID enumeration for intel RDT monitoring and allocation, as well as the flags used in the enumeration code. Signed-off-by: Hendrik Wüthrich --- 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..1409f9a904 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 +/* 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" @@ -81,8 +92,27 @@ struct RDTState { struct RDTStateClass { }; +uint32_t rdt_get_cpuid_15_0_edx_l3(void) { return CPUID_15_1_EDX_L3_OCCUPANCY | 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_L3_CAT; } +uint32_t rdt_cpuid_10_0_ebx_l2_cat_enabled(void) { return CPUID_10_0_EBX_L2_CAT; } +uint32_t rdt_cpuid_10_0_ebx_l2_mba_enabled(void) { return CPUID_10_0_EBX_MBA; } + +uint32_t rdt_get_cpuid_10_1_eax_cbm_length(void) { return CPUID_10_1_EAX_CBM_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_COUNT; } + +uint32_t rdt_get_cpuid_10_2_eax_cbm_length(void) { return CPUID_10_2_EAX_CBM_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_COUNT; } + +uint32_t rdt_get_cpuid_10_3_eax_thrtl_max(void) { return CPUID_10_3_EAX_THRTL_MAX; } +uint32_t rdt_cpuid_10_3_eax_linear_response_enabled(void) { return CPUID_10_3_ECX_LINEAR_RESPONSE; } uint32_t rdt_get_cpuid_10_3_edx_cos_max(void) { return RDT_MAX_MBA_THRTL_COUNT; } 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 +/* 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 | CPUID_10_0_EBX_MBA + typedef struct RDTState RDTState; typedef struct RDTStatePerCore RDTStatePerCore; typedef struct RDTMonitor RDTMonitor; typedef struct RDTAllocation RDTAllocation; +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); 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..bbe2da8ebb 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" #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 &= 0xffff; /* The count doesn't need to be reliable. */ break; +#ifndef CONFIG_USER_ONLY + case 0xF: + /* Shared Resource Monitoring Enumeration Leaf */ + *eax = 0; + *ebx = 0; + *ecx = 0; + *edx = 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 = env->features[FEAT_RDT_15_0_EDX]; + *ebx = rdt_max_rmid(cpu->rdt); + break; + case 1: + *ebx = 1; + *ecx = rdt_max_rmid(cpu->rdt); + *edx = 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 = 0; + *ebx = 0; + *ecx = 0; + *edx = 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 |= rdt_cpuid_10_0_ebx_l3_cat_enabled(); + *ebx |= rdt_cpuid_10_0_ebx_l2_cat_enabled(); + *ebx |= rdt_cpuid_10_0_ebx_l2_mba_enabled(); + break; + case 1: + *eax = rdt_get_cpuid_10_1_eax_cbm_length(); + *ebx = rdt_cpuid_10_1_ebx_cbm_enabled(); + *ecx |= rdt_cpuid_10_1_ecx_cdp_enabled(); + *edx = rdt_get_cpuid_10_1_edx_cos_max(); + break; + case 2: + *eax = rdt_get_cpuid_10_2_eax_cbm_length(); + *ebx = rdt_cpuid_10_2_ebx_cbm_enabled(); + *edx = rdt_get_cpuid_10_2_edx_cos_max(); + break; + case 3: + *eax = rdt_get_cpuid_10_3_eax_thrtl_max(); + *ecx = rdt_cpuid_10_3_eax_linear_response_enabled(); + *edx = 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_EDX_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..98407c8e18 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -678,6 +678,7 @@ typedef enum FeatureWord { FEAT_7_1_EDX, /* CPUID[EAX=7,ECX=1].EDX */ FEAT_7_2_EDX, /* CPUID[EAX=7,ECX=2].EDX */ FEAT_24_0_EBX, /* CPUID[EAX=0x24,ECX=0].EBX */ + FEAT_RDT_15_0_EDX, /* CPUID[EAX=0xf,ECX=0].EDX (RDT CMT/MBM) */ FEATURE_WORDS, } FeatureWord; @@ -852,8 +853,12 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *cpu, 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 */ From patchwork Thu Dec 5 20:00:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hendrik Wuethrich X-Patchwork-Id: 13895971 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 36842E7716E for ; Thu, 5 Dec 2024 20:01:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJI26-0002wE-W3; Thu, 05 Dec 2024 15:01:10 -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 <3ZwZSZwgKCvw0lirhvmoksskpi.gsquiqy-hiziprsrkry.svk@flex--whendrik.bounces.google.com>) id 1tJI1l-0002sa-Hd for qemu-devel@nongnu.org; Thu, 05 Dec 2024 15:00:47 -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 <3ZwZSZwgKCvw0lirhvmoksskpi.gsquiqy-hiziprsrkry.svk@flex--whendrik.bounces.google.com>) id 1tJI1j-0001eO-EJ for qemu-devel@nongnu.org; Thu, 05 Dec 2024 15:00:44 -0500 Received: by mail-wm1-x34a.google.com with SMTP id 5b1f17b1804b1-434a6483514so9134535e9.0 for ; Thu, 05 Dec 2024 12:00:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733428840; x=1734033640; 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=7qkRo9GTsyKbClSjG0dkX08UrT2dSZJ8wMtYShWt/zI=; b=Z+uG5nOzNN+/zBPbSnwsF3mpP2D5A1AlJ+9QGG5pTjCU/Ow25p1CslCVdk7f/nltjs HyCFoUyiYUpmwV4nlBmUaaEDMuTU1KhUjujji13q/W8ehhBTveX/xaPFkIjMBrOSUYQB egJbGED9RaPmJu7gdqk8ZNzYo+B2Y351X8oU0vZIiZji4VXdV5PdDZdUwKHnHUVhKCni 7M9L22k7/Fwp2OLbYDxXhsOXW8AIw/jDzkZU1X9UOVGfo+bqCZsEJiAa1JRYTtvOM1PS II1qMdMVRDuP30FJuNl9eMe3TUaeMVpbu/Vf6TyIdvsGpBs7AlwA1eW7zNzEQCdtTIE1 iSJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733428840; x=1734033640; 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=7qkRo9GTsyKbClSjG0dkX08UrT2dSZJ8wMtYShWt/zI=; b=e7+6qt8W1qw4FJiVp31VfDhQ/EvMfq9GRVN/9EMpyfCbxh3SXGXJeTtWffNgUAiYty wooh2M5zpSf4QnQERdPqhBUZK9dqnQThcuhJchfIWTkt3Z+7k/XS1SOZtX3I2j+WwQeh 8jbE41gqcpUB2qApyokDCmmLmvmVR7wU5BZkup1heOdTnBn8vGVZmzy2KgB3VHRqYwf1 FrX++R+A4E5ILg1HaH25xeBN8WbeunTUobYOJ8Zp94L+atc1vUSeKSg8ENGyuEkJcNsI RNB5IcZ/mjk832xEXNTuGuZhSO+eiQfPCM5V7IONlkLQFLy9rmBEDOc9hftR4LTMW5Ew mBNw== X-Gm-Message-State: AOJu0YwwMijm9QCkiBDjs7gROPiY+HPyl1YutBpOFAgHHdNnK5TpV2C/ OyKLXHfnMeh8W75VcR54C9J269gqrefKzKZQFcBnu96+HyTmksNiJZRkqbTIAUofu6GbowNFf9h nmF0WxK+oiTvFyXinP6XNFtcLR9UW4D6yqQsnXHTLNzDpOx876fCNlsaz0owMigdQ8REcgoyWiK ZlAt+REpP8rusdQUVFa7aACEKdp+Uy93fgTkkprSK/Pg== X-Google-Smtp-Source: AGHT+IE2ePZrmIof0uuVPjsnXH1WzZRn75B4xay2aMef0yXetZrYOWfHuqL9OeAVX09Fm3Y/VtEKKOi61ifxCQ== 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:a41:b0:434:9e1d:7629 with SMTP id 5b1f17b1804b1-434ddedbb2cmr4266825e9.33.1733428839839; Thu, 05 Dec 2024 12:00:39 -0800 (PST) Date: Thu, 5 Dec 2024 20:00:23 +0000 In-Reply-To: <20241205200025.2081863-1-whendrik@google.com> Mime-Version: 1.0 References: <20241205200025.2081863-1-whendrik@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241205200025.2081863-7-whendrik@google.com> Subject: [PATCH v4 6/8] i386: Add RDT feature flags. From: Hendrik Wuethrich To: qemu-devel@nongnu.org, eduardo@habkost.net, richard.henderson@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com Cc: peternewman@google.com, " =?utf-8?b?4oCqSGVuZHJpayBXw7x0aHJpY2g=?= " Received-SPF: pass client-ip=2a00:1450:4864:20::34a; envelope-from=3ZwZSZwgKCvw0lirhvmoksskpi.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: ‪Hendrik Wüthrich Add RDT features to feature word / TCG. Signed-off-by: Hendrik Wüthrich --- 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 bbe2da8ebb..5e29bf341c 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -869,7 +869,8 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1, 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 vendor1, #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_15_0_EDX_FEATURES CPUID_15_0_EDX_L3 #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] = { "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] = { }, .tcg_features = TCG_SGX_12_1_EAX_FEATURES, }, + + [FEAT_RDT_10_0_EBX] = { + .type = CPUID_FEATURE_WORD, + .feat_names = { + NULL, "l3-cat", "l2-cat", "mba" + }, + .cpuid = { + .eax = 0x10, + .needs_ecx = true, .ecx = 0, + .reg = R_EBX, + } + }, + [FEAT_RDT_15_0_EDX] = { + .type = CPUID_FEATURE_WORD, + .feat_names = { + [1] = "l3-cmt" + }, + .cpuid = { + .eax = 0xf, + .needs_ecx = true, .ecx = 0, + .reg = R_EDX, + }, + .tcg_features = TCG_RDT_15_0_EDX_FEATURES, + }, }; typedef struct FeatureMask { diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 98407c8e18..37dc451e39 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -678,7 +678,9 @@ typedef enum FeatureWord { FEAT_7_1_EDX, /* CPUID[EAX=7,ECX=1].EDX */ FEAT_7_2_EDX, /* CPUID[EAX=7,ECX=2].EDX */ FEAT_24_0_EBX, /* CPUID[EAX=0x24,ECX=0].EBX */ + FEAT_RDT_15_0_EBX, /* CPUID[EAX=0xf,ECX=0].EBX (RDT CMT/MBM) */ FEAT_RDT_15_0_EDX, /* CPUID[EAX=0xf,ECX=0].EDX (RDT CMT/MBM) */ + FEAT_RDT_10_0_EBX, /* CPUID[EAX=0x10,ECX=0].EBX (RDT CAT/MBA) */ FEATURE_WORDS, } FeatureWord; From patchwork Thu Dec 5 20:00:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hendrik Wuethrich X-Patchwork-Id: 13895976 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F103FE77170 for ; Thu, 5 Dec 2024 20:02:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJI21-0002vG-5G; Thu, 05 Dec 2024 15:01: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 <3aQZSZwgKCv42nktjxoqmuumrk.iuswks0-jk1krtutmt0.uxm@flex--whendrik.bounces.google.com>) id 1tJI1m-0002sj-Jp for qemu-devel@nongnu.org; Thu, 05 Dec 2024 15:00:47 -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 <3aQZSZwgKCv42nktjxoqmuumrk.iuswks0-jk1krtutmt0.uxm@flex--whendrik.bounces.google.com>) id 1tJI1k-0001eU-Dl for qemu-devel@nongnu.org; Thu, 05 Dec 2024 15:00:46 -0500 Received: by mail-wm1-x349.google.com with SMTP id 5b1f17b1804b1-4349eeeb841so8996875e9.3 for ; Thu, 05 Dec 2024 12:00:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733428842; x=1734033642; 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=y/EyZcmrposqvK7v6eP2KNJq/oTP0txZto7n4zafF4w=; b=BJOV7/6CrhWp9EfyJ2uP3YPzwMOyOyHqO9Lm+w9ZdKZFaOkMRIzp4R98kBYRubrZWb th+2ro5xtC2XdRjGAYTUbYp8WNOyovX8T7Z4YKJz6KJEP+XyhEEEkpIm5uftIvlP9etS ogiR0Y54YR8audte2S2jHHxf19VxN32bQRywxAz4T2f0xjF9ETIRzvpsZVAmf326SLH/ UwneE4JEg9GXqWZbxxtuE7SoQafrKWPFrQpKvjpqbWdx9hLfW2zoCHmhC6w0sZ9kC+Op KYUPA8XvpKcS9bvAELRRNLHD9mWX5o8+jRp/0pFJnIw863daMRhiNJYt2ZQCBgKYV0Kk gUWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733428842; x=1734033642; 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=y/EyZcmrposqvK7v6eP2KNJq/oTP0txZto7n4zafF4w=; b=HmJ+G90toleTDV9M5OtD/Y60c4Kn+LnOjCagWQ9E/0q3+dgLA1UhxuQL8CE9DsR2WH EwfkfFoxqNHeLLAyaI72E7pXFB3BT1WITMtuv76KPkGvstF4ubyImKnNIgtlnnd7Ra0u 3nPcDIOHyCSVxAupncjpMjEw79eNhcJ7KIrRWkL/VnOhbUtipqHxFJk2xnNz4YZi74+t HWBevJDET19SYPLqF/HgxAh0elGG+Awm2VhVRo90oBdm4P9MuZ5UwJYRALPjyqgQU6Nh aZkV0pdlQttqKhPRFkSxkvOVYS39kjyrvRhKt8ua8WcKbWF81CFB3oVFm6W5sRzVfX4D AbWA== X-Gm-Message-State: AOJu0YyXz1Kfg/4+J9BmtLb7HAHwPQ0BLzWZhzJWZsP1UBKX/LNMPq1F unf+UhfEwFuhnhE7KDXhSKFTzo8l9A/XoZhpoyNNN9vGn6uetN5Kc+kFCa05UDf2Uy5zxl5NCM0 McgB3VM8ZhclM2n502FzkHP2LEaG8/4GkoLfn4kbETGKATXKdoEgcKJuvTmWpcFmcfHJCPG8nNX g2UIB1LQYyFxcpnll2lM9dB+d/OAYx+yPrhRmIJ5gaxA== X-Google-Smtp-Source: AGHT+IHTSTZmmHmeM6XYplaTA7zqIf5wCrVJEUJSykh7I/4p4C22l632QtWBjHoGo8EzU32FNJN1cYnBg8+x7g== X-Received: from wmso25.prod.google.com ([2002:a05:600c:5119:b0:434:9e9b:cd19]) (user=whendrik job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:4f87:b0:431:40ca:ce5d with SMTP id 5b1f17b1804b1-434dded699cmr4496965e9.23.1733428841952; Thu, 05 Dec 2024 12:00:41 -0800 (PST) Date: Thu, 5 Dec 2024 20:00:24 +0000 In-Reply-To: <20241205200025.2081863-1-whendrik@google.com> Mime-Version: 1.0 References: <20241205200025.2081863-1-whendrik@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241205200025.2081863-8-whendrik@google.com> Subject: [PATCH v4 7/8] i386/cpu: Adjust CPUID level for RDT features From: Hendrik Wuethrich To: qemu-devel@nongnu.org, eduardo@habkost.net, richard.henderson@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com Cc: peternewman@google.com, " =?utf-8?b?4oCqSGVuZHJpayBXw7x0aHJpY2g=?= " Received-SPF: pass client-ip=2a00:1450:4864:20::349; envelope-from=3aQZSZwgKCv42nktjxoqmuumrk.iuswks0-jk1krtutmt0.uxm@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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: ‪Hendrik Wüthrich Adjust minimum CPUID level if RDT monitoring or allocation features are enabled to ensure that CPUID will return them. Signed-off-by: Hendrik Wüthrich --- target/i386/cpu.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 5e29bf341c..045705884a 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7719,6 +7719,16 @@ void x86_cpu_expand_features(X86CPU *cpu, Error **errp) 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); + } } /* Set cpuid_*level* based on cpuid_min_*level, if not explicitly set */ From patchwork Thu Dec 5 20:00:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hendrik Wuethrich X-Patchwork-Id: 13895977 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 18E9EE77170 for ; Thu, 5 Dec 2024 20:02:43 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJI1y-0002us-Pe; Thu, 05 Dec 2024 15:00:58 -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 <3awZSZwgKCgIyjgpftkmiqqing.eqosgow-fgxgnpqpipw.qti@flex--whendrik.bounces.google.com>) id 1tJI1n-0002sw-AK for qemu-devel@nongnu.org; Thu, 05 Dec 2024 15:00:48 -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 <3awZSZwgKCgIyjgpftkmiqqing.eqosgow-fgxgnpqpipw.qti@flex--whendrik.bounces.google.com>) id 1tJI1l-0001fF-ME for qemu-devel@nongnu.org; Thu, 05 Dec 2024 15:00:47 -0500 Received: by mail-wr1-x449.google.com with SMTP id ffacd0b85a97d-385dcadffebso617423f8f.0 for ; Thu, 05 Dec 2024 12:00:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733428844; x=1734033644; 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=by/qrvvh7ycM+T3SHAtA87KxLdghdr+xZxH/HpZ0IE8=; b=W/VsBgR7yqm3sW+tP+fkk9QVcRgjjVXGKGQDzHneT+SPqiXO+byN78x8VrJWtHQ2CP D95HZwA5eJvP/G9ISudbNgzHENglugZ0xPaFTn1MZs7sRPzK5atTUpnVQxeukVufYrKw L4fo1QqVZGc74AjLnsBjerNdRrVTn2cw0OncoJO3NhyXwWzHM1wNwjSqtXURUXRgjrzv JveXVSmmSA/W6NtQNqJMZvlJQYsO1EBYYxW3Xl5fV4C9N+GAoNeRMeeoz1iwe4N1hBQl oD26/R4a2eg76yhTfnwIsqKD9f18O7+AHPRKAgPYtdIbktNukxovpHrimQwBuW0igKIy bMNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733428844; x=1734033644; 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=by/qrvvh7ycM+T3SHAtA87KxLdghdr+xZxH/HpZ0IE8=; b=IGOna4Q/hSJXvKgaV6ovtBvFZkpNvlWryZWGg1LbSiTwwxePsbIxhYD22lFWfnq31X 2XJ94GaPMHT9iOq3tZHWEkYCw0hxMnkQ5J+uqgRhkdNdZrvbSJe3tgIP8OxxixdH2oQ1 z1Go4hrDPHVuMDa8SxPzR3T5ljV5rKx36JY1xW5q4HfUYo4bCKOUElKBD21Dljyyl6vE eN0vRvgFku02Ex1n0GrvSPPEP6kNBPNx7WsbLLYfwk4/k4fItMwQh6fJ0IvjQF5FqRQO DEDIL9zMw80GhZTTdlDJLE2qKDnqRoYwLBi4qjr/DlvvCzRIKrkEKlLoqTHYQfL82iUd vM+g== X-Gm-Message-State: AOJu0YxeKIxPislOU8pUBU419U+uc+ZxPH6FZYM80+iuIC+21sQ4Ez8U CxmV8BKosfjtnWv4C9SeJ6D44bUrik0MCl8W6bNvxXPc1QqxH4+ul6/LaZ6sAX2dBOVXKk1qIu4 6odWLngrv5mcclNxd4Rb3snr3RfeZj1abPg0qz2RVp5vm1rZ2GgibNkOmV5U0vURvwbu46WO3Jx EJHmLZZNpnEUMAagjVodlzd6dJnV6jJCC666Jj/4rfJw== X-Google-Smtp-Source: AGHT+IGDO235tesWn38CI5l1mG4SH29DPsEeCjUEtDES5yaJo7RdiS4BaHIBoNFVga8bByvA7DqukIeMMpOmQA== X-Received: from wmaw15.prod.google.com ([2002:a05:600c:6d4f:b0:434:a158:2c03]) (user=whendrik job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:1ac8:b0:385:e204:b30b with SMTP id ffacd0b85a97d-3862b3f29admr264650f8f.53.1733428843785; Thu, 05 Dec 2024 12:00:43 -0800 (PST) Date: Thu, 5 Dec 2024 20:00:25 +0000 In-Reply-To: <20241205200025.2081863-1-whendrik@google.com> Mime-Version: 1.0 References: <20241205200025.2081863-1-whendrik@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241205200025.2081863-9-whendrik@google.com> Subject: [PATCH v4 8/8] i386/cpu: Adjust level for RDT on full_cpuid_auto_level From: Hendrik Wuethrich To: qemu-devel@nongnu.org, eduardo@habkost.net, richard.henderson@linaro.org, marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com Cc: peternewman@google.com, " =?utf-8?b?4oCqSGVuZHJpayBXw7x0aHJpY2g=?= " Received-SPF: pass client-ip=2a00:1450:4864:20::449; envelope-from=3awZSZwgKCgIyjgpftkmiqqing.eqosgow-fgxgnpqpipw.qti@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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: ‪Hendrik Wüthrich Make sure that RDT monitoring and allocation features are included in in full_cpuid_auto_level. Signed-off-by: Hendrik Wüthrich --- target/i386/cpu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 045705884a..e3f82571df 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -880,6 +880,7 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1, #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 **errp) 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); /* Intel Processor Trace requires CPUID[0x14] */ if ((env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT)) {