From: Hendrik Wuethrich <whendrik@google.com>
To: qemu-devel@nongnu.org, Jonathan.Cameron@huawei.com,
eduardo@habkost.net, richard.henderson@linaro.org,
marcel.apfelbaum@gmail.com, mst@redhat.com, pbonzini@redhat.com
Cc: peternewman@google.com, "Hendrik Wüthrich" <whendrik@google.com>
Subject: [PATCH v2 2/8] i386: Add init and realize functionality for RDT device.
Date: Thu, 5 Sep 2024 11:22:31 +0000 [thread overview]
Message-ID: <20240905112237.3586972-3-whendrik@google.com> (raw)
In-Reply-To: <20240905112237.3586972-1-whendrik@google.com>
From: Hendrik Wüthrich <whendrik@google.com>
Add code to initialize all necessary state for the RDT device.
Signed-off-by: Hendrik Wüthrich <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 934f7fbf75..c395ab91a9 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*/
#define RDT_MAX_L3_MASK_COUNT 128
@@ -79,8 +80,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)
@@ -90,6 +119,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);
}
--
2.46.0.469.g59c65b2a67-goog
next prev parent reply other threads:[~2024-09-05 11:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-05 11:22 [PATCH v2 0/8] target:386/ Emulate Intel RDT features needed to mount ResCtrl in Linux Hendrik Wuethrich
2024-09-05 11:22 ` [PATCH v2 1/8] i386: Add Intel RDT device and State to config Hendrik Wuethrich
2024-09-05 11:22 ` Hendrik Wuethrich [this message]
2024-09-05 11:22 ` [PATCH v2 3/8] i386: Add RDT functionality Hendrik Wuethrich
2024-09-05 11:22 ` [PATCH v2 4/8] i386: Add RDT device interface through MSRs Hendrik Wuethrich
2024-09-05 11:22 ` [PATCH v2 5/8] i386: Add CPUID enumeration for RDT Hendrik Wuethrich
2024-11-12 10:28 ` Peter Newman
2024-09-05 11:22 ` [PATCH v2 6/8] i386: Add RDT feature flags Hendrik Wuethrich
2024-09-05 11:22 ` [PATCH v2 7/8] i386/cpu: Adjust CPUID level for RDT features Hendrik Wuethrich
2024-09-05 11:22 ` [PATCH v2 8/8] i386/cpu: Adjust level for RDT on full_cpuid_auto_level Hendrik Wuethrich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240905112237.3586972-3-whendrik@google.com \
--to=whendrik@google.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=eduardo@habkost.net \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peternewman@google.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).