From: Alexander Graf <agraf@csgraf.de>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
qemu-arm@nongnu.org, "Yanan Wang" <wangyanan55@huawei.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Shashi Mallela" <shashi.mallela@linaro.org>,
"Eric Auger" <eric.auger@redhat.com>,
"Neil Armstrong" <narmstrong@baylibre.com>
Subject: [PATCH 1/2] hw/intc/arm_gicv3: Make ITT entry size configurable
Date: Fri, 23 Dec 2022 09:50:46 +0100 [thread overview]
Message-ID: <20221223085047.94832-2-agraf@csgraf.de> (raw)
In-Reply-To: <20221223085047.94832-1-agraf@csgraf.de>
An ITT entry is opaque to the OS. The only thing it does get told by HW is
its size. In theory, that size can be any byte aligned number, in practice
HW will always use power of 2s to simplify offset calculation. We currently
expose the size as 12, which is not a power of 2.
To prepare for a future where we expose power of 2 sized entry sizes, let's
make the size itself configurable. We only need to watch out that we don't
have an entry be smaller than the fields we want to access inside. Bigger
is always fine.
Signed-off-by: Alexander Graf <agraf@csgraf.de>
---
hw/intc/arm_gicv3_its.c | 14 +++++++++++---
hw/intc/gicv3_internal.h | 2 +-
include/hw/intc/arm_gicv3_its_common.h | 1 +
3 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
index 57c79da5c5..e7cabeb46c 100644
--- a/hw/intc/arm_gicv3_its.c
+++ b/hw/intc/arm_gicv3_its.c
@@ -215,7 +215,7 @@ static bool update_ite(GICv3ITSState *s, uint32_t eventid, const DTEntry *dte,
{
AddressSpace *as = &s->gicv3->dma_as;
MemTxResult res = MEMTX_OK;
- hwaddr iteaddr = dte->ittaddr + eventid * ITS_ITT_ENTRY_SIZE;
+ hwaddr iteaddr = dte->ittaddr + eventid * s->itt_entry_size;
uint64_t itel = 0;
uint32_t iteh = 0;
@@ -253,7 +253,7 @@ static MemTxResult get_ite(GICv3ITSState *s, uint32_t eventid,
MemTxResult res = MEMTX_OK;
uint64_t itel;
uint32_t iteh;
- hwaddr iteaddr = dte->ittaddr + eventid * ITS_ITT_ENTRY_SIZE;
+ hwaddr iteaddr = dte->ittaddr + eventid * s->itt_entry_size;
itel = address_space_ldq_le(as, iteaddr, MEMTXATTRS_UNSPECIFIED, &res);
if (res != MEMTX_OK) {
@@ -1934,6 +1934,12 @@ static void gicv3_arm_its_realize(DeviceState *dev, Error **errp)
}
}
+ if (s->itt_entry_size < MIN_ITS_ITT_ENTRY_SIZE) {
+ error_setg(errp, "ITT entry size must be at least %d",
+ MIN_ITS_ITT_ENTRY_SIZE);
+ return;
+ }
+
gicv3_add_its(s->gicv3, dev);
gicv3_its_init_mmio(s, &gicv3_its_control_ops, &gicv3_its_translation_ops);
@@ -1941,7 +1947,7 @@ static void gicv3_arm_its_realize(DeviceState *dev, Error **errp)
/* set the ITS default features supported */
s->typer = FIELD_DP64(s->typer, GITS_TYPER, PHYSICAL, 1);
s->typer = FIELD_DP64(s->typer, GITS_TYPER, ITT_ENTRY_SIZE,
- ITS_ITT_ENTRY_SIZE - 1);
+ s->itt_entry_size - 1);
s->typer = FIELD_DP64(s->typer, GITS_TYPER, IDBITS, ITS_IDBITS);
s->typer = FIELD_DP64(s->typer, GITS_TYPER, DEVBITS, ITS_DEVBITS);
s->typer = FIELD_DP64(s->typer, GITS_TYPER, CIL, 1);
@@ -2008,6 +2014,8 @@ static void gicv3_its_post_load(GICv3ITSState *s)
static Property gicv3_its_props[] = {
DEFINE_PROP_LINK("parent-gicv3", GICv3ITSState, gicv3, "arm-gicv3",
GICv3State *),
+ DEFINE_PROP_UINT8("itt-entry-size", GICv3ITSState, itt_entry_size,
+ MIN_ITS_ITT_ENTRY_SIZE),
DEFINE_PROP_END_OF_LIST(),
};
diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h
index 29d5cdc1b6..2aca1ba095 100644
--- a/hw/intc/gicv3_internal.h
+++ b/hw/intc/gicv3_internal.h
@@ -450,7 +450,7 @@ FIELD(VINVALL_1, VPEID, 32, 16)
* the value of that field in memory cannot be relied upon -- older
* versions of QEMU did not correctly write to that memory.)
*/
-#define ITS_ITT_ENTRY_SIZE 0xC
+#define MIN_ITS_ITT_ENTRY_SIZE 0xC
FIELD(ITE_L, VALID, 0, 1)
FIELD(ITE_L, INTTYPE, 1, 1)
diff --git a/include/hw/intc/arm_gicv3_its_common.h b/include/hw/intc/arm_gicv3_its_common.h
index a11a0f6654..e730a5482c 100644
--- a/include/hw/intc/arm_gicv3_its_common.h
+++ b/include/hw/intc/arm_gicv3_its_common.h
@@ -66,6 +66,7 @@ struct GICv3ITSState {
int dev_fd; /* kvm device fd if backed by kvm vgic support */
uint64_t gits_translater_gpa;
bool translater_gpa_known;
+ uint8_t itt_entry_size;
/* Registers */
uint32_t ctlr;
--
2.37.1 (Apple Git-137.1)
next prev parent reply other threads:[~2022-12-23 8:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-23 8:50 [PATCH 0/2] hw/intc/arm_gicv3: Bump ITT entry size to 16 Alexander Graf
2022-12-23 8:50 ` Alexander Graf [this message]
2023-03-10 4:55 ` [PATCH 1/2] hw/intc/arm_gicv3: Make ITT entry size configurable Joelle van Dyne
2022-12-23 8:50 ` [PATCH 2/2] hw/intc/arm_gicv3: Bump ITT entry size to 16 Alexander Graf
2022-12-23 10:14 ` [PATCH 0/2] " Philippe Mathieu-Daudé
2023-01-03 17:41 ` Peter Maydell
2023-01-03 19:30 ` Alexander Graf
2023-03-10 13:48 ` Alexander Graf
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=20221223085047.94832-2-agraf@csgraf.de \
--to=agraf@csgraf.de \
--cc=eduardo@habkost.net \
--cc=eric.auger@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=narmstrong@baylibre.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=shashi.mallela@linaro.org \
--cc=wangyanan55@huawei.com \
/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).