* [PATCH 1/4] hw/pci-bridge: Add pcie_add_dvsec_capability helper
2026-10-29 15:05 [PATCH 0/4] RME-DA capabilities for PCIe Root Port Jim MacArthur
@ 2026-10-29 15:05 ` Jim MacArthur
2026-11-04 19:20 ` Jonathan Cameron
2026-11-09 1:08 ` Gustavo Romero
2026-10-29 15:05 ` [PATCH 2/4] hw/pci: add IDE + TEE capability to PCIe root port Jim MacArthur
` (3 subsequent siblings)
4 siblings, 2 replies; 16+ messages in thread
From: Jim MacArthur @ 2026-10-29 15:05 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael S. Tsirkin, Jim MacArthur
Signed-off-by: Jim MacArthur <jim.macarthur@linaro.org>
---
hw/pci/pcie.c | 16 ++++++++++++++++
include/hw/pci/pcie.h | 4 ++++
2 files changed, 20 insertions(+)
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index 42bcb9206d..42c4997b42 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -1157,6 +1157,22 @@ void pcie_add_capability(PCIDevice *dev,
memset(dev->cmask + offset, 0xFF, size);
}
+/*
+ * Add a DVSEC capability. As per pcie_add_capability, the caller must
+ * ensure (offset, size) does not overlap any other capability or extend
+ * past the extended configuration space.
+ */
+void pcie_add_dvsec_capability(PCIDevice *device, uint16_t capability_id,
+ uint8_t version, uint32_t offset,
+ uint16_t size_bytes, uint16_t vendor_id,
+ uint8_t dvsec_version, uint16_t dvsec_id)
+{
+ const uint32_t header1 = size_bytes << 20 | version << 16 | vendor_id;
+ pcie_add_capability(device, capability_id, version, offset, size_bytes);
+ pci_set_long(device->config + offset + 0x4, header1);
+ pci_set_word(device->config + offset + 0x8, dvsec_id);
+}
+
/*
* Sync the PCIe Link Status negotiated speed and width of a bridge with the
* downstream device. If downstream device is not present, re-write with the
diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h
index ec25e7a7de..86c29f7d8b 100644
--- a/include/hw/pci/pcie.h
+++ b/include/hw/pci/pcie.h
@@ -133,6 +133,10 @@ uint16_t pcie_find_capability(PCIDevice *dev, uint16_t cap_id);
void pcie_add_capability(PCIDevice *dev,
uint16_t cap_id, uint8_t cap_ver,
uint16_t offset, uint16_t size);
+void pcie_add_dvsec_capability(PCIDevice *device, uint16_t capability_id,
+ uint8_t version, uint32_t offset,
+ uint16_t size_bytes, uint16_t vendor_id,
+ uint8_t dvsec_version, uint16_t dvsec_id);
bool pcie_insert_capability(PCIDevice *dev, uint16_t cap_id, uint8_t cap_ver,
uint16_t offset, uint16_t size);
void pcie_sync_bridge_lnk(PCIDevice *dev);
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH 1/4] hw/pci-bridge: Add pcie_add_dvsec_capability helper
2026-10-29 15:05 ` [PATCH 1/4] hw/pci-bridge: Add pcie_add_dvsec_capability helper Jim MacArthur
@ 2026-11-04 19:20 ` Jonathan Cameron
2026-11-09 1:08 ` Gustavo Romero
1 sibling, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2026-11-04 19:20 UTC (permalink / raw)
To: Jim MacArthur; +Cc: qemu-devel, Michael S. Tsirkin
On Thu, 29 Oct 2026 15:05:10 +0000
Jim MacArthur <jim.macarthur@linaro.org> wrote:
Hi Jim,
Some description is always good. Maybe in this case a spec reference
would be appropriate.
> Signed-off-by: Jim MacArthur <jim.macarthur@linaro.org>
> ---
> hw/pci/pcie.c | 16 ++++++++++++++++
> include/hw/pci/pcie.h | 4 ++++
> 2 files changed, 20 insertions(+)
>
> diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
> index 42bcb9206d..42c4997b42 100644
> --- a/hw/pci/pcie.c
> +++ b/hw/pci/pcie.c
> @@ -1157,6 +1157,22 @@ void pcie_add_capability(PCIDevice *dev,
> memset(dev->cmask + offset, 0xFF, size);
> }
>
> +/*
> + * Add a DVSEC capability. As per pcie_add_capability, the caller must
> + * ensure (offset, size) does not overlap any other capability or extend
> + * past the extended configuration space.
> + */
> +void pcie_add_dvsec_capability(PCIDevice *device, uint16_t capability_id,
> + uint8_t version, uint32_t offset,
> + uint16_t size_bytes, uint16_t vendor_id,
> + uint8_t dvsec_version, uint16_t dvsec_id)
> +{
> + const uint32_t header1 = size_bytes << 20 | version << 16 | vendor_id;
I was going to suggest you just use the defines in pci_regs.h but
oddly those were only defined as extraction macros for these fields
not the other way around that you'd need here (or masks that could be used
for that).
I'd add a blank line.
> + pcie_add_capability(device, capability_id, version, offset, size_bytes);
> + pci_set_long(device->config + offset + 0x4, header1);
and just pass the header value in here rather that using the local variable.
If you really want the variable declare it at the top then add the assignment
just before use. Avoids the two getting separated if additional code gets
added here in the long run.
> + pci_set_word(device->config + offset + 0x8, dvsec_id);
> +}
Always nice to justify a new helper by converting a few existing users.
Maybe not strictly necessary though..
> +
> /*
> * Sync the PCIe Link Status negotiated speed and width of a bridge with the
> * downstream device. If downstream device is not present, re-write with the
> diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h
> index ec25e7a7de..86c29f7d8b 100644
> --- a/include/hw/pci/pcie.h
> +++ b/include/hw/pci/pcie.h
> @@ -133,6 +133,10 @@ uint16_t pcie_find_capability(PCIDevice *dev, uint16_t cap_id);
> void pcie_add_capability(PCIDevice *dev,
> uint16_t cap_id, uint8_t cap_ver,
> uint16_t offset, uint16_t size);
> +void pcie_add_dvsec_capability(PCIDevice *device, uint16_t capability_id,
> + uint8_t version, uint32_t offset,
> + uint16_t size_bytes, uint16_t vendor_id,
> + uint8_t dvsec_version, uint16_t dvsec_id);
> bool pcie_insert_capability(PCIDevice *dev, uint16_t cap_id, uint8_t cap_ver,
> uint16_t offset, uint16_t size);
> void pcie_sync_bridge_lnk(PCIDevice *dev);
>
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH 1/4] hw/pci-bridge: Add pcie_add_dvsec_capability helper
2026-10-29 15:05 ` [PATCH 1/4] hw/pci-bridge: Add pcie_add_dvsec_capability helper Jim MacArthur
2026-11-04 19:20 ` Jonathan Cameron
@ 2026-11-09 1:08 ` Gustavo Romero
2026-12-02 12:03 ` Jim MacArthur
1 sibling, 1 reply; 16+ messages in thread
From: Gustavo Romero @ 2026-11-09 1:08 UTC (permalink / raw)
To: Jim MacArthur; +Cc: qemu-devel, Michael S. Tsirkin
Hi Jim,
On Thu, Oct 29, 2026 at 03:05:10PM +0000, Jim MacArthur wrote:
Please add a commit message to this patch. Even for small changes, a few lines
of context help reviewers now and anyone reading the history later. For example:
why a DVSEC helper is needed, what this capability allows, which upcoming patch
uses it, DVSEC meaning, PCIe spec reference, etc.
> Signed-off-by: Jim MacArthur <jim.macarthur@linaro.org>
> ---
> hw/pci/pcie.c | 16 ++++++++++++++++
> include/hw/pci/pcie.h | 4 ++++
> 2 files changed, 20 insertions(+)
>
> diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
> index 42bcb9206d..42c4997b42 100644
> --- a/hw/pci/pcie.c
> +++ b/hw/pci/pcie.c
> @@ -1157,6 +1157,22 @@ void pcie_add_capability(PCIDevice *dev,
> memset(dev->cmask + offset, 0xFF, size);
> }
>
> +/*
> + * Add a DVSEC capability. As per pcie_add_capability, the caller must
> + * ensure (offset, size) does not overlap any other capability or extend
> + * past the extended configuration space.
> + */
> +void pcie_add_dvsec_capability(PCIDevice *device, uint16_t capability_id,
> + uint8_t version, uint32_t offset,
> + uint16_t size_bytes, uint16_t vendor_id,
> + uint8_t dvsec_version, uint16_t dvsec_id)
> +{
> + const uint32_t header1 = size_bytes << 20 | version << 16 | vendor_id;
Header 1 should have 'dvsec_version' in it, not 'version'. As a side effect
'dvsec_version' is left unused here. Also I think it should be 'dvsec_revision',
not 'dvsec_version'.
I also think it's better s/size_bytes/dvsec_length/ and
s/vendor_id/dvsec_vendor_id for consistence.
It's also better to add range checks for 'dvsec_length' and 'dvsec_revision'
since their size don't match, respectively, size 16b and 8b, like:
assert((dvsec_length & ~0xfff) == 0);
assert((dvsec_revision & ~0xf) == 0);
> + pcie_add_capability(device, capability_id, version, offset, size_bytes);
To me, capability_id and version should actually be hardecoded because a DVSEC
is by definition PCI_EXT_CAP_ID_DVSEC with Capability Version 1, so:
pcie_add_capability(dev, PCI_EXT_CAP_ID_DVSEC, 1, offset, dvsec_length);
I'm looking at PCIe spec rev. 7.0.
> + pci_set_long(device->config + offset + 0x4, header1);
Could we use PCI_DVSEC_HEADER1 here instead of 0x4?
> + pci_set_word(device->config + offset + 0x8, dvsec_id);
Could we use PCI_DVSEC_HEADER2 here instead of 0x8?
Cheers,
Gustavo
> +}
> +
> /*
> * Sync the PCIe Link Status negotiated speed and width of a bridge with the
> * downstream device. If downstream device is not present, re-write with the
> diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h
> index ec25e7a7de..86c29f7d8b 100644
> --- a/include/hw/pci/pcie.h
> +++ b/include/hw/pci/pcie.h
> @@ -133,6 +133,10 @@ uint16_t pcie_find_capability(PCIDevice *dev, uint16_t cap_id);
> void pcie_add_capability(PCIDevice *dev,
> uint16_t cap_id, uint8_t cap_ver,
> uint16_t offset, uint16_t size);
> +void pcie_add_dvsec_capability(PCIDevice *device, uint16_t capability_id,
> + uint8_t version, uint32_t offset,
> + uint16_t size_bytes, uint16_t vendor_id,
> + uint8_t dvsec_version, uint16_t dvsec_id);
> bool pcie_insert_capability(PCIDevice *dev, uint16_t cap_id, uint8_t cap_ver,
> uint16_t offset, uint16_t size);
> void pcie_sync_bridge_lnk(PCIDevice *dev);
>
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH 1/4] hw/pci-bridge: Add pcie_add_dvsec_capability helper
2026-11-09 1:08 ` Gustavo Romero
@ 2026-12-02 12:03 ` Jim MacArthur
0 siblings, 0 replies; 16+ messages in thread
From: Jim MacArthur @ 2026-12-02 12:03 UTC (permalink / raw)
To: Gustavo Romero; +Cc: qemu-devel, Michael S. Tsirkin
On Mon, Nov 09, 2026 at 02:08:55AM +0100, Gustavo Romero wrote:
> Hi Jim,
>
> On Thu, Oct 29, 2026 at 03:05:10PM +0000, Jim MacArthur wrote:
>
> Please add a commit message to this patch. Even for small changes, a few lines
> of context help reviewers now and anyone reading the history later. For example:
> why a DVSEC helper is needed, what this capability allows, which upcoming patch
> uses it, DVSEC meaning, PCIe spec reference, etc.
>
>
> > Signed-off-by: Jim MacArthur <jim.macarthur@linaro.org>
> > ---
> > hw/pci/pcie.c | 16 ++++++++++++++++
> > include/hw/pci/pcie.h | 4 ++++
> > 2 files changed, 20 insertions(+)
> >
> > diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
> > index 42bcb9206d..42c4997b42 100644
> > --- a/hw/pci/pcie.c
> > +++ b/hw/pci/pcie.c
> > @@ -1157,6 +1157,22 @@ void pcie_add_capability(PCIDevice *dev,
> > memset(dev->cmask + offset, 0xFF, size);
> > }
> >
> > +/*
> > + * Add a DVSEC capability. As per pcie_add_capability, the caller must
> > + * ensure (offset, size) does not overlap any other capability or extend
> > + * past the extended configuration space.
> > + */
> > +void pcie_add_dvsec_capability(PCIDevice *device, uint16_t capability_id,
> > + uint8_t version, uint32_t offset,
> > + uint16_t size_bytes, uint16_t vendor_id,
> > + uint8_t dvsec_version, uint16_t dvsec_id)
> > +{
> > + const uint32_t header1 = size_bytes << 20 | version << 16 | vendor_id;
>
> Header 1 should have 'dvsec_version' in it, not 'version'. As a side effect
> 'dvsec_version' is left unused here. Also I think it should be 'dvsec_revision',
> not 'dvsec_version'.
>
> I also think it's better s/size_bytes/dvsec_length/ and
> s/vendor_id/dvsec_vendor_id for consistence.
>
> It's also better to add range checks for 'dvsec_length' and 'dvsec_revision'
> since their size don't match, respectively, size 16b and 8b, like:
>
> assert((dvsec_length & ~0xfff) == 0);
> assert((dvsec_revision & ~0xf) == 0);
>
>
> > + pcie_add_capability(device, capability_id, version, offset, size_bytes);
>
> To me, capability_id and version should actually be hardecoded because a DVSEC
> is by definition PCI_EXT_CAP_ID_DVSEC with Capability Version 1, so:
>
> pcie_add_capability(dev, PCI_EXT_CAP_ID_DVSEC, 1, offset, dvsec_length);
>
> I'm looking at PCIe spec rev. 7.0.
>
>
> > + pci_set_long(device->config + offset + 0x4, header1);
>
> Could we use PCI_DVSEC_HEADER1 here instead of 0x4?
>
>
> > + pci_set_word(device->config + offset + 0x8, dvsec_id);
>
> Could we use PCI_DVSEC_HEADER2 here instead of 0x8?
>
>
> Cheers,
> Gustavo
All good points - thanks for the review!
Jim
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 2/4] hw/pci: add IDE + TEE capability to PCIe root port
2026-10-29 15:05 [PATCH 0/4] RME-DA capabilities for PCIe Root Port Jim MacArthur
2026-10-29 15:05 ` [PATCH 1/4] hw/pci-bridge: Add pcie_add_dvsec_capability helper Jim MacArthur
@ 2026-10-29 15:05 ` Jim MacArthur
2026-11-04 19:27 ` Jonathan Cameron
2026-11-09 1:11 ` Gustavo Romero
2026-10-29 15:05 ` [PATCH 3/4] hw/pci: add DVSEC RMEDA " Jim MacArthur
` (2 subsequent siblings)
4 siblings, 2 replies; 16+ messages in thread
From: Jim MacArthur @ 2026-10-29 15:05 UTC (permalink / raw)
To: qemu-devel
Cc: Michael S. Tsirkin, Jim MacArthur, Jim MacArthur,
Pierrick Bouvier
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Adds the TEE flag in the legacy config space, and the IDE
(Integrity & Data Encryption) extended capability. These
will be present when rme-cap=on is specified for the
pcie-root-port device.
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Jim MacArthur <Jim MacArthur@linaro.org>
---
hw/pci-bridge/gen_pcie_root_port.c | 21 ++++++++++++++++++++-
hw/pci/pcie.c | 19 +++++++++++++++++++
include/hw/pci/pcie.h | 3 +++
include/hw/pci/pcie_regs.h | 4 ++++
4 files changed, 46 insertions(+), 1 deletion(-)
diff --git a/hw/pci-bridge/gen_pcie_root_port.c b/hw/pci-bridge/gen_pcie_root_port.c
index 5434d693d9..ab8087da87 100644
--- a/hw/pci-bridge/gen_pcie_root_port.c
+++ b/hw/pci-bridge/gen_pcie_root_port.c
@@ -26,13 +26,16 @@ OBJECT_DECLARE_SIMPLE_TYPE(GenPCIERootPort, GEN_PCIE_ROOT_PORT)
#define GEN_PCIE_ROOT_PORT_AER_OFFSET 0x100
#define GEN_PCIE_ROOT_PORT_ACS_OFFSET \
(GEN_PCIE_ROOT_PORT_AER_OFFSET + PCI_ERR_SIZEOF)
-
+#define GEN_PCIE_ROOT_PORT_ACS_END \
+ (GEN_PCIE_ROOT_PORT_ACS_OFFSET + PCI_ACS_SIZEOF)
#define GEN_PCIE_ROOT_PORT_MSIX_NR_VECTOR 1
#define GEN_PCIE_ROOT_DEFAULT_IO_RANGE 4096
struct GenPCIERootPort {
/*< private >*/
PCIESlot parent_obj;
+ bool rme_caps;
+
/*< public >*/
/* additional resources to reserve */
@@ -71,6 +74,7 @@ static void gen_rp_realize(DeviceState *dev, Error **errp)
GenPCIERootPort *grp = GEN_PCIE_ROOT_PORT(d);
PCIERootPortClass *rpc = PCIE_ROOT_PORT_GET_CLASS(d);
Error *local_err = NULL;
+ uint32_t next_cap_offset = GEN_PCIE_ROOT_PORT_ACS_END;
rpc->parent_realize(dev, &local_err);
if (local_err) {
@@ -100,6 +104,19 @@ static void gen_rp_realize(DeviceState *dev, Error **errp)
d->wmask[PCI_IO_BASE] = 0;
d->wmask[PCI_IO_LIMIT] = 0;
}
+
+ if (grp->rme_caps) {
+ pcie_ide_init(d, next_cap_offset);
+
+ /* Unused value, but may be useful for the next capability */
+ next_cap_offset += PCI_IDE_SIZEOF;
+
+ /*
+ * Set up TEE (in the legacy config space, not an extended
+ * capability)
+ */
+ pcie_cap_tee_init(d);
+ }
}
static const VMStateDescription vmstate_rp_dev = {
@@ -133,6 +150,8 @@ static const Property gen_rp_props[] = {
speed, PCIE_LINK_SPEED_16),
DEFINE_PROP_PCIE_LINK_WIDTH("x-width", PCIESlot,
width, PCIE_LINK_WIDTH_32),
+ DEFINE_PROP_BOOL("rme-caps", GenPCIERootPort,
+ rme_caps, false),
};
static void gen_rp_dev_class_init(ObjectClass *klass, const void *data)
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index 42c4997b42..bf2c184cfc 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -968,6 +968,16 @@ void pcie_cap_flr_write_config(PCIDevice *dev,
}
}
+/*
+ * Set PCI_EXP_DEVCAP_TEE flag in the PCI Express Capability Structure
+ * (in legacy config space) indicating that we support TEE-IO.
+ */
+void pcie_cap_tee_init(PCIDevice *dev)
+{
+ pci_long_test_and_set_mask(dev->config + dev->exp.exp_cap + PCI_EXP_DEVCAP,
+ PCI_EXP_DEVCAP_TEE);
+}
+
/* Alternative Routing-ID Interpretation (ARI)
* forwarding support for root and downstream ports
*/
@@ -1387,6 +1397,15 @@ uint32_t pcie_pri_get_req_alloc(const PCIDevice *dev)
return pci_get_long(dev->config + dev->exp.pri_cap + PCI_PRI_ALLOC_REQ);
}
+/* IDE (Integrity & Data Encryption) */
+void pcie_ide_init(PCIDevice *dev, uint16_t offset)
+{
+ pcie_add_capability(dev, PCI_EXT_CAP_ID_IDE, PCI_IDE_VER,
+ offset, PCI_IDE_SIZEOF);
+ uint32_t cap = PCI_IDE_CAP_SELECTIVE;
+ pci_set_byte(dev->config + offset + PCI_IDE_CAP, cap);
+}
+
bool pcie_pri_enabled(const PCIDevice *dev)
{
if (!pci_is_express(dev) || !dev->exp.pri_cap) {
diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h
index 86c29f7d8b..6c02c846df 100644
--- a/include/hw/pci/pcie.h
+++ b/include/hw/pci/pcie.h
@@ -123,6 +123,8 @@ void pcie_cap_flr_init(PCIDevice *dev);
void pcie_cap_flr_write_config(PCIDevice *dev,
uint32_t addr, uint32_t val, int len);
+void pcie_cap_tee_init(PCIDevice *dev);
+
/* ARI forwarding capability and control */
void pcie_cap_arifwd_init(PCIDevice *dev);
void pcie_cap_arifwd_reset(PCIDevice *dev);
@@ -165,6 +167,7 @@ void pcie_pasid_init(PCIDevice *dev, uint16_t offset, uint8_t pasid_width,
bool exec_perm, bool priv_mod);
void pcie_pri_init(PCIDevice *dev, uint16_t offset, uint32_t outstanding_pr_cap,
bool prg_response_pasid_req);
+void pcie_ide_init(PCIDevice *dev, uint16_t offset);
uint32_t pcie_pri_get_req_alloc(const PCIDevice *dev);
bool pcie_pri_enabled(const PCIDevice *dev);
diff --git a/include/hw/pci/pcie_regs.h b/include/hw/pci/pcie_regs.h
index 33a22229fe..aa21177411 100644
--- a/include/hw/pci/pcie_regs.h
+++ b/include/hw/pci/pcie_regs.h
@@ -182,4 +182,8 @@ typedef enum PCIExpLinkWidth {
#define PCI_DOE_VER 0x1
#define PCI_DOE_SIZEOF 24
+/* IDE */
+#define PCI_IDE_VER 0x1
+#define PCI_IDE_SIZEOF 12
+
#endif /* QEMU_PCIE_REGS_H */
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH 2/4] hw/pci: add IDE + TEE capability to PCIe root port
2026-10-29 15:05 ` [PATCH 2/4] hw/pci: add IDE + TEE capability to PCIe root port Jim MacArthur
@ 2026-11-04 19:27 ` Jonathan Cameron
2026-11-05 11:48 ` Jim MacArthur
2026-11-09 1:11 ` Gustavo Romero
1 sibling, 1 reply; 16+ messages in thread
From: Jonathan Cameron @ 2026-11-04 19:27 UTC (permalink / raw)
To: Jim MacArthur
Cc: qemu-devel, Michael S. Tsirkin, Jim MacArthur, Pierrick Bouvier
On Thu, 29 Oct 2026 15:05:11 +0000
Jim MacArthur <jim.macarthur@linaro.org> wrote:
> From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>
> Adds the TEE flag in the legacy config space, and the IDE
> (Integrity & Data Encryption) extended capability. These
> will be present when rme-cap=on is specified for the
> pcie-root-port device.
>
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> Signed-off-by: Jim MacArthur <Jim MacArthur@linaro.org>
> ---
> hw/pci-bridge/gen_pcie_root_port.c | 21 ++++++++++++++++++++-
> hw/pci/pcie.c | 19 +++++++++++++++++++
> include/hw/pci/pcie.h | 3 +++
> include/hw/pci/pcie_regs.h | 4 ++++
> 4 files changed, 46 insertions(+), 1 deletion(-)
>
> diff --git a/hw/pci-bridge/gen_pcie_root_port.c b/hw/pci-bridge/gen_pcie_root_port.c
> index 5434d693d9..ab8087da87 100644
> --- a/hw/pci-bridge/gen_pcie_root_port.c
> +++ b/hw/pci-bridge/gen_pcie_root_port.c
> @@ -26,13 +26,16 @@ OBJECT_DECLARE_SIMPLE_TYPE(GenPCIERootPort, GEN_PCIE_ROOT_PORT)
> #define GEN_PCIE_ROOT_PORT_AER_OFFSET 0x100
> #define GEN_PCIE_ROOT_PORT_ACS_OFFSET \
> (GEN_PCIE_ROOT_PORT_AER_OFFSET + PCI_ERR_SIZEOF)
> -
> +#define GEN_PCIE_ROOT_PORT_ACS_END \
> + (GEN_PCIE_ROOT_PORT_ACS_OFFSET + PCI_ACS_SIZEOF)
Can't you figure this out from root port class acs offset?
Or if you want it in a fixed place follow that pattern and stash it
in the root class during dev_rp_dev_class_init.
> #define GEN_PCIE_ROOT_PORT_MSIX_NR_VECTOR 1
> #define GEN_PCIE_ROOT_DEFAULT_IO_RANGE 4096
>
> struct GenPCIERootPort {
> /*< private >*/
> PCIESlot parent_obj;
> + bool rme_caps;
> +
> /*< public >*/
>
> /* additional resources to reserve */
> @@ -71,6 +74,7 @@ static void gen_rp_realize(DeviceState *dev, Error **errp)
> GenPCIERootPort *grp = GEN_PCIE_ROOT_PORT(d);
> PCIERootPortClass *rpc = PCIE_ROOT_PORT_GET_CLASS(d);
> Error *local_err = NULL;
> + uint32_t next_cap_offset = GEN_PCIE_ROOT_PORT_ACS_END;
>
> rpc->parent_realize(dev, &local_err);
> if (local_err) {
> @@ -100,6 +104,19 @@ static void gen_rp_realize(DeviceState *dev, Error **errp)
> d->wmask[PCI_IO_BASE] = 0;
> d->wmask[PCI_IO_LIMIT] = 0;
> }
> +
> + if (grp->rme_caps) {
Not arm specific. Can't see any harm in using a generic config name
for this. Actually I'm not seeing a reason not to always include
the ide cap. Maybe less so for setting up tee. Haven't really thought about
that.
> + pcie_ide_init(d, next_cap_offset);
> +
> + /* Unused value, but may be useful for the next capability */
> + next_cap_offset += PCI_IDE_SIZEOF;
> +
> + /*
> + * Set up TEE (in the legacy config space, not an extended
> + * capability)
> + */
> + pcie_cap_tee_init(d);
> + }
> }
>
> static const VMStateDescription vmstate_rp_dev = {
> @@ -133,6 +150,8 @@ static const Property gen_rp_props[] = {
> speed, PCIE_LINK_SPEED_16),
> DEFINE_PROP_PCIE_LINK_WIDTH("x-width", PCIESlot,
> width, PCIE_LINK_WIDTH_32),
> + DEFINE_PROP_BOOL("rme-caps", GenPCIERootPort,
> + rme_caps, false),
> };
>
> static void gen_rp_dev_class_init(ObjectClass *klass, const void *data)
> diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
> index 42c4997b42..bf2c184cfc 100644
> --- a/hw/pci/pcie.c
> +++ b/hw/pci/pcie.c
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH 2/4] hw/pci: add IDE + TEE capability to PCIe root port
2026-11-04 19:27 ` Jonathan Cameron
@ 2026-11-05 11:48 ` Jim MacArthur
2026-11-12 1:38 ` Jonathan Cameron
0 siblings, 1 reply; 16+ messages in thread
From: Jim MacArthur @ 2026-11-05 11:48 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: qemu-devel, Michael S. Tsirkin, Pierrick Bouvier
On Wed, Nov 04, 2026 at 07:27:09PM +0000, Jonathan Cameron wrote:
> On Thu, 29 Oct 2026 15:05:11 +0000
> Jim MacArthur <jim.macarthur@linaro.org> wrote:
>
> > From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> >
> > Adds the TEE flag in the legacy config space, and the IDE
> > (Integrity & Data Encryption) extended capability. These
> > will be present when rme-cap=on is specified for the
> > pcie-root-port device.
> >
> > Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> > Signed-off-by: Jim MacArthur <Jim MacArthur@linaro.org>
> > ---
> > hw/pci-bridge/gen_pcie_root_port.c | 21 ++++++++++++++++++++-
> > hw/pci/pcie.c | 19 +++++++++++++++++++
> > include/hw/pci/pcie.h | 3 +++
> > include/hw/pci/pcie_regs.h | 4 ++++
> > 4 files changed, 46 insertions(+), 1 deletion(-)
> >
> > diff --git a/hw/pci-bridge/gen_pcie_root_port.c b/hw/pci-bridge/gen_pcie_root_port.c
> > index 5434d693d9..ab8087da87 100644
> > --- a/hw/pci-bridge/gen_pcie_root_port.c
> > +++ b/hw/pci-bridge/gen_pcie_root_port.c
> > @@ -26,13 +26,16 @@ OBJECT_DECLARE_SIMPLE_TYPE(GenPCIERootPort, GEN_PCIE_ROOT_PORT)
> > #define GEN_PCIE_ROOT_PORT_AER_OFFSET 0x100
> > #define GEN_PCIE_ROOT_PORT_ACS_OFFSET \
> > (GEN_PCIE_ROOT_PORT_AER_OFFSET + PCI_ERR_SIZEOF)
> > -
> > +#define GEN_PCIE_ROOT_PORT_ACS_END \
> > + (GEN_PCIE_ROOT_PORT_ACS_OFFSET + PCI_ACS_SIZEOF)
>
> Can't you figure this out from root port class acs offset?
>
> Or if you want it in a fixed place follow that pattern and stash it
> in the root class during dev_rp_dev_class_init.
>
There seems to be quite a lot of cases where we're arranging capabilities in
sequential order in memory, but hard-coding the locations. I would rather all
of this be replaced with a dynamic pointer which records the next capability
offset, and it looks like there are attempts to do this with, e.g.
pcie_insert_capability, but that has a lot of caveats and only gets used once.
I'll have another think about this, and in the meantime if anyone knows a good
reason why we do hardcode this, that would be useful.
> > +
> > + if (grp->rme_caps) {
> Not arm specific. Can't see any harm in using a generic config name
> for this. Actually I'm not seeing a reason not to always include
> the ide cap. Maybe less so for setting up tee. Haven't really thought about
> that.
>
Good point, IDE/TEE could be separate named options quite easily. There might
be more Arm RME things included later, but that can be a third option.
Thanks for the review,
Jim
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH 2/4] hw/pci: add IDE + TEE capability to PCIe root port
2026-11-05 11:48 ` Jim MacArthur
@ 2026-11-12 1:38 ` Jonathan Cameron
0 siblings, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2026-11-12 1:38 UTC (permalink / raw)
To: Jim MacArthur; +Cc: qemu-devel, Michael S. Tsirkin, Pierrick Bouvier
On Thu, 5 Nov 2026 11:48:51 +0000
Jim MacArthur <jim.macarthur@linaro.org> wrote:
> On Wed, Nov 04, 2026 at 07:27:09PM +0000, Jonathan Cameron wrote:
> > On Thu, 29 Oct 2026 15:05:11 +0000
> > Jim MacArthur <jim.macarthur@linaro.org> wrote:
> >
> > > From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> > >
> > > Adds the TEE flag in the legacy config space, and the IDE
> > > (Integrity & Data Encryption) extended capability. These
> > > will be present when rme-cap=on is specified for the
> > > pcie-root-port device.
> > >
> > > Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> > > Signed-off-by: Jim MacArthur <Jim MacArthur@linaro.org>
> > > ---
> > > hw/pci-bridge/gen_pcie_root_port.c | 21 ++++++++++++++++++++-
> > > hw/pci/pcie.c | 19 +++++++++++++++++++
> > > include/hw/pci/pcie.h | 3 +++
> > > include/hw/pci/pcie_regs.h | 4 ++++
> > > 4 files changed, 46 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/hw/pci-bridge/gen_pcie_root_port.c b/hw/pci-bridge/gen_pcie_root_port.c
> > > index 5434d693d9..ab8087da87 100644
> > > --- a/hw/pci-bridge/gen_pcie_root_port.c
> > > +++ b/hw/pci-bridge/gen_pcie_root_port.c
> > > @@ -26,13 +26,16 @@ OBJECT_DECLARE_SIMPLE_TYPE(GenPCIERootPort, GEN_PCIE_ROOT_PORT)
> > > #define GEN_PCIE_ROOT_PORT_AER_OFFSET 0x100
> > > #define GEN_PCIE_ROOT_PORT_ACS_OFFSET \
> > > (GEN_PCIE_ROOT_PORT_AER_OFFSET + PCI_ERR_SIZEOF)
> > > -
> > > +#define GEN_PCIE_ROOT_PORT_ACS_END \
> > > + (GEN_PCIE_ROOT_PORT_ACS_OFFSET + PCI_ACS_SIZEOF)
> >
> > Can't you figure this out from root port class acs offset?
> >
> > Or if you want it in a fixed place follow that pattern and stash it
> > in the root class during dev_rp_dev_class_init.
> >
>
> There seems to be quite a lot of cases where we're arranging capabilities in
> sequential order in memory, but hard-coding the locations. I would rather all
> of this be replaced with a dynamic pointer which records the next capability
> offset, and it looks like there are attempts to do this with, e.g.
> pcie_insert_capability, but that has a lot of caveats and only gets used once.
>
> I'll have another think about this, and in the meantime if anyone knows a good
> reason why we do hardcode this, that would be useful.
I also thought about trying to fix this in the past along the lines you describe
but never spent the time to actually do it!
So as far as I'm concerned it would be welcome. I think we would need some
test cases though to check we aren't breaking migration by accidentally moving
stuff around in a new qemu version.
>
> > > +
> > > + if (grp->rme_caps) {
> > Not arm specific. Can't see any harm in using a generic config name
> > for this. Actually I'm not seeing a reason not to always include
> > the ide cap. Maybe less so for setting up tee. Haven't really thought about
> > that.
> >
>
> Good point, IDE/TEE could be separate named options quite easily. There might
> be more Arm RME things included later, but that can be a third option.
>
> Thanks for the review,
>
> Jim
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/4] hw/pci: add IDE + TEE capability to PCIe root port
2026-10-29 15:05 ` [PATCH 2/4] hw/pci: add IDE + TEE capability to PCIe root port Jim MacArthur
2026-11-04 19:27 ` Jonathan Cameron
@ 2026-11-09 1:11 ` Gustavo Romero
1 sibling, 0 replies; 16+ messages in thread
From: Gustavo Romero @ 2026-11-09 1:11 UTC (permalink / raw)
To: Jim MacArthur
Cc: qemu-devel, Michael S. Tsirkin, Jim MacArthur, Pierrick Bouvier
Hi Jim,
On Thu, Oct 29, 2026 at 03:05:11PM +0000, Jim MacArthur wrote:
> From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>
> Adds the TEE flag in the legacy config space, and the IDE
> (Integrity & Data Encryption) extended capability. These
> will be present when rme-cap=on is specified for the
> pcie-root-port device.
This commit message needs some enhancement.
First, it ideally should mention the reason/effect for setting the TEE-IO and
advertising the IDE cap, explaining why it's required. For instance, say
that they go together because both are pieces of PCIe TEE-IO, the framework for
assigning a device directly to a confidential VM, and that, accordingly to the
spec, the TEE-IO presence requires IDE, as per §11.3.29.3 Securing Interconnects
(I'm looking at spec rev. 7), which reads:
"TEE-I/O capable devices must support Integrity and Data Encryption (IDE) to
protect transactions on the interconnect between the device and the Root
Complex. Devices must support selective IDE streams between the Root Complex and
the device."
Second, I think legacy word should be dropped here and in all other parts of the
patch below because I consider it misleading. The first 256 bytes are still
present in the PCIe spec rev. 7. I'm aware the spec mentions this area as
"available on legacy OSs" so accessible from the CAM mechanism, but from a PCIe
device pov it's simply a the PCI Configuration Space. Moreover, the TEE-IO bit
is in that space and TEE-IO is a quite recent addition to the PCIe spec, hence
it's odd to say a bit related to a new feature like this is being set in a
legacy configuration space.
Also, rme-cap=on is not good, as Jonathan said, because we're in the PCIe
context, so it's not restrict to the Arm arch. I think "tee-io=[on/off]" would
fit better, or even "x-tee-io" if we are experimenting with it and not so sure
how the flag would be called at the end.
ah, and although here it says "rme-cap=on" the prop. being added below is
actually "rme-caps".
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> Signed-off-by: Jim MacArthur <Jim MacArthur@linaro.org>
nit: email seems ruined here ------^
> ---
> hw/pci-bridge/gen_pcie_root_port.c | 21 ++++++++++++++++++++-
> hw/pci/pcie.c | 19 +++++++++++++++++++
> include/hw/pci/pcie.h | 3 +++
> include/hw/pci/pcie_regs.h | 4 ++++
> 4 files changed, 46 insertions(+), 1 deletion(-)
>
> diff --git a/hw/pci-bridge/gen_pcie_root_port.c b/hw/pci-bridge/gen_pcie_root_port.c
> index 5434d693d9..ab8087da87 100644
> --- a/hw/pci-bridge/gen_pcie_root_port.c
> +++ b/hw/pci-bridge/gen_pcie_root_port.c
> @@ -26,13 +26,16 @@ OBJECT_DECLARE_SIMPLE_TYPE(GenPCIERootPort, GEN_PCIE_ROOT_PORT)
> #define GEN_PCIE_ROOT_PORT_AER_OFFSET 0x100
> #define GEN_PCIE_ROOT_PORT_ACS_OFFSET \
> (GEN_PCIE_ROOT_PORT_AER_OFFSET + PCI_ERR_SIZEOF)
> -
> +#define GEN_PCIE_ROOT_PORT_ACS_END \
> + (GEN_PCIE_ROOT_PORT_ACS_OFFSET + PCI_ACS_SIZEOF)
> #define GEN_PCIE_ROOT_PORT_MSIX_NR_VECTOR 1
> #define GEN_PCIE_ROOT_DEFAULT_IO_RANGE 4096
>
> struct GenPCIERootPort {
> /*< private >*/
> PCIESlot parent_obj;
> + bool rme_caps;
> +
> /*< public >*/
>
> /* additional resources to reserve */
> @@ -71,6 +74,7 @@ static void gen_rp_realize(DeviceState *dev, Error **errp)
> GenPCIERootPort *grp = GEN_PCIE_ROOT_PORT(d);
> PCIERootPortClass *rpc = PCIE_ROOT_PORT_GET_CLASS(d);
> Error *local_err = NULL;
> + uint32_t next_cap_offset = GEN_PCIE_ROOT_PORT_ACS_END;
>
> rpc->parent_realize(dev, &local_err);
> if (local_err) {
> @@ -100,6 +104,19 @@ static void gen_rp_realize(DeviceState *dev, Error **errp)
> d->wmask[PCI_IO_BASE] = 0;
> d->wmask[PCI_IO_LIMIT] = 0;
> }
> +
> + if (grp->rme_caps) {
See my comment on using rme, which is Arm-specific.
> + pcie_ide_init(d, next_cap_offset);
> +
> + /* Unused value, but may be useful for the next capability */
> + next_cap_offset += PCI_IDE_SIZEOF;
> +
> + /*
> + * Set up TEE (in the legacy config space, not an extended
> + * capability)
> + */
> + pcie_cap_tee_init(d);
> + }
> }
>
> static const VMStateDescription vmstate_rp_dev = {
> @@ -133,6 +150,8 @@ static const Property gen_rp_props[] = {
> speed, PCIE_LINK_SPEED_16),
> DEFINE_PROP_PCIE_LINK_WIDTH("x-width", PCIESlot,
> width, PCIE_LINK_WIDTH_32),
> + DEFINE_PROP_BOOL("rme-caps", GenPCIERootPort,
> + rme_caps, false),
> };
>
> static void gen_rp_dev_class_init(ObjectClass *klass, const void *data)
> diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
> index 42c4997b42..bf2c184cfc 100644
> --- a/hw/pci/pcie.c
> +++ b/hw/pci/pcie.c
> @@ -968,6 +968,16 @@ void pcie_cap_flr_write_config(PCIDevice *dev,
> }
> }
>
> +/*
> + * Set PCI_EXP_DEVCAP_TEE flag in the PCI Express Capability Structure
> + * (in legacy config space) indicating that we support TEE-IO.
> + */
> +void pcie_cap_tee_init(PCIDevice *dev)
> +{
> + pci_long_test_and_set_mask(dev->config + dev->exp.exp_cap + PCI_EXP_DEVCAP,
> + PCI_EXP_DEVCAP_TEE);
> +}
> +
> /* Alternative Routing-ID Interpretation (ARI)
> * forwarding support for root and downstream ports
> */
> @@ -1387,6 +1397,15 @@ uint32_t pcie_pri_get_req_alloc(const PCIDevice *dev)
> return pci_get_long(dev->config + dev->exp.pri_cap + PCI_PRI_ALLOC_REQ);
> }
>
> +/* IDE (Integrity & Data Encryption) */
> +void pcie_ide_init(PCIDevice *dev, uint16_t offset)
> +{
> + pcie_add_capability(dev, PCI_EXT_CAP_ID_IDE, PCI_IDE_VER,
> + offset, PCI_IDE_SIZEOF);
> + uint32_t cap = PCI_IDE_CAP_SELECTIVE;
> + pci_set_byte(dev->config + offset + PCI_IDE_CAP, cap);
I would set PCI_IDE_CAP_SELECTIVE directly and avoid 'cap' var here.
Cheers,
Gustavo
> +}
> +
> bool pcie_pri_enabled(const PCIDevice *dev)
> {
> if (!pci_is_express(dev) || !dev->exp.pri_cap) {
> diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h
> index 86c29f7d8b..6c02c846df 100644
> --- a/include/hw/pci/pcie.h
> +++ b/include/hw/pci/pcie.h
> @@ -123,6 +123,8 @@ void pcie_cap_flr_init(PCIDevice *dev);
> void pcie_cap_flr_write_config(PCIDevice *dev,
> uint32_t addr, uint32_t val, int len);
>
> +void pcie_cap_tee_init(PCIDevice *dev);
> +
> /* ARI forwarding capability and control */
> void pcie_cap_arifwd_init(PCIDevice *dev);
> void pcie_cap_arifwd_reset(PCIDevice *dev);
> @@ -165,6 +167,7 @@ void pcie_pasid_init(PCIDevice *dev, uint16_t offset, uint8_t pasid_width,
> bool exec_perm, bool priv_mod);
> void pcie_pri_init(PCIDevice *dev, uint16_t offset, uint32_t outstanding_pr_cap,
> bool prg_response_pasid_req);
> +void pcie_ide_init(PCIDevice *dev, uint16_t offset);
>
> uint32_t pcie_pri_get_req_alloc(const PCIDevice *dev);
> bool pcie_pri_enabled(const PCIDevice *dev);
> diff --git a/include/hw/pci/pcie_regs.h b/include/hw/pci/pcie_regs.h
> index 33a22229fe..aa21177411 100644
> --- a/include/hw/pci/pcie_regs.h
> +++ b/include/hw/pci/pcie_regs.h
> @@ -182,4 +182,8 @@ typedef enum PCIExpLinkWidth {
> #define PCI_DOE_VER 0x1
> #define PCI_DOE_SIZEOF 24
>
> +/* IDE */
> +#define PCI_IDE_VER 0x1
> +#define PCI_IDE_SIZEOF 12
> +
> #endif /* QEMU_PCIE_REGS_H */
>
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 3/4] hw/pci: add DVSEC RMEDA capability to PCIe root port
2026-10-29 15:05 [PATCH 0/4] RME-DA capabilities for PCIe Root Port Jim MacArthur
2026-10-29 15:05 ` [PATCH 1/4] hw/pci-bridge: Add pcie_add_dvsec_capability helper Jim MacArthur
2026-10-29 15:05 ` [PATCH 2/4] hw/pci: add IDE + TEE capability to PCIe root port Jim MacArthur
@ 2026-10-29 15:05 ` Jim MacArthur
2026-11-04 19:29 ` Jonathan Cameron
2026-11-09 1:12 ` Gustavo Romero
2026-10-29 15:05 ` [PATCH 4/4] hw/pci: More comments in pcie.c Jim MacArthur
2026-11-09 1:13 ` [PATCH 0/4] RME-DA capabilities for PCIe Root Port Gustavo Romero
4 siblings, 2 replies; 16+ messages in thread
From: Jim MacArthur @ 2026-10-29 15:05 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael S. Tsirkin, Jim MacArthur, Pierrick Bouvier
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Again, gated by the rme-cap=on flag for pcie-root-port.
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Jim MacArthur <jim.macarthur@linaro.org>
---
hw/pci-bridge/gen_pcie_root_port.c | 35 +++++++++++++++++++++++++++++++++++
include/hw/pci/pcie_regs.h | 4 ++++
2 files changed, 39 insertions(+)
diff --git a/hw/pci-bridge/gen_pcie_root_port.c b/hw/pci-bridge/gen_pcie_root_port.c
index ab8087da87..fb8dbb7959 100644
--- a/hw/pci-bridge/gen_pcie_root_port.c
+++ b/hw/pci-bridge/gen_pcie_root_port.c
@@ -28,6 +28,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(GenPCIERootPort, GEN_PCIE_ROOT_PORT)
(GEN_PCIE_ROOT_PORT_AER_OFFSET + PCI_ERR_SIZEOF)
#define GEN_PCIE_ROOT_PORT_ACS_END \
(GEN_PCIE_ROOT_PORT_ACS_OFFSET + PCI_ACS_SIZEOF)
+
#define GEN_PCIE_ROOT_PORT_MSIX_NR_VECTOR 1
#define GEN_PCIE_ROOT_DEFAULT_IO_RANGE 4096
@@ -67,6 +68,39 @@ static void gen_rp_interrupts_uninit(PCIDevice *d)
msix_uninit_exclusive_bar(d);
}
+static uint32_t add_rme_dvsec_capability(PCIDevice *device, uint32_t offset)
+{
+ /*
+ * dvsec rme-da
+ * https://developer.arm.com/documentation/den0129/latest/
+ * Arm RME System Architecture
+ * 0x0000 RMEDA_ECH See B3.2.6.2.1 RME-DA Extended Capability Header
+ * 0x0004 RMEDA_HEAD1 See B3.2.6.2.2 RME-DA DVSEC Header 1
+ * 0x0008 RMEDA_HEAD2 See B3.2.6.2.3 RME-DA DVSEC Header 2
+ * 0x000C RMEDA_CTL1 See B3.2.6.2.4 RME-DA Control register 1
+ * 0x0010 RMEDA_CTL2 See B3.2.6.2.5 RME-DA Control register 2
+ */
+ const uint32_t ARM_PCI_VID = 0x13b5;
+ const uint32_t RME_DA_DVSEC_ID = 0;
+ pcie_add_dvsec_capability(device, PCI_EXT_CAP_ID_DVSEC, 1, offset,
+ PCI_RME_DVSEC_SIZE, ARM_PCI_VID,
+ PCI_RME_DVSEC_VER, RME_DA_DVSEC_ID);
+ const uint32_t ctl1 = 0x1; /* support tdisp */
+ const uint32_t ctl2 = 0x0; /* unlocked */
+ pci_set_long(device->config + offset + 0xC, ctl1);
+ pci_set_long(device->config + offset + 0x10, ctl2);
+ device->wmask[offset + 0xC] = 0xff;
+ device->wmask[offset + 0xC + 1] = 0xff;
+ device->wmask[offset + 0xC + 2] = 0xff;
+ device->wmask[offset + 0xC + 3] = 0xff;
+ device->wmask[offset + 0x10] = 0xff;
+ device->wmask[offset + 0x10 + 1] = 0xff;
+ device->wmask[offset + 0x10 + 2] = 0xff;
+ device->wmask[offset + 0x10 + 3] = 0xff;
+ offset += PCI_RME_DVSEC_SIZE;
+ return offset;
+}
+
static void gen_rp_realize(DeviceState *dev, Error **errp)
{
PCIDevice *d = PCI_DEVICE(dev);
@@ -106,6 +140,7 @@ static void gen_rp_realize(DeviceState *dev, Error **errp)
}
if (grp->rme_caps) {
+ next_cap_offset = add_rme_dvsec_capability(d, next_cap_offset);
pcie_ide_init(d, next_cap_offset);
/* Unused value, but may be useful for the next capability */
diff --git a/include/hw/pci/pcie_regs.h b/include/hw/pci/pcie_regs.h
index aa21177411..da812d32ff 100644
--- a/include/hw/pci/pcie_regs.h
+++ b/include/hw/pci/pcie_regs.h
@@ -186,4 +186,8 @@ typedef enum PCIExpLinkWidth {
#define PCI_IDE_VER 0x1
#define PCI_IDE_SIZEOF 12
+/* RME DVSEC */
+#define PCI_RME_DVSEC_VER 0x1
+#define PCI_RME_DVSEC_SIZE 20
+
#endif /* QEMU_PCIE_REGS_H */
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH 3/4] hw/pci: add DVSEC RMEDA capability to PCIe root port
2026-10-29 15:05 ` [PATCH 3/4] hw/pci: add DVSEC RMEDA " Jim MacArthur
@ 2026-11-04 19:29 ` Jonathan Cameron
2026-11-09 1:12 ` Gustavo Romero
1 sibling, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2026-11-04 19:29 UTC (permalink / raw)
To: Jim MacArthur; +Cc: qemu-devel, Michael S. Tsirkin, Pierrick Bouvier
On Thu, 29 Oct 2026 15:05:12 +0000
Jim MacArthur <jim.macarthur@linaro.org> wrote:
> From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>
> Again, gated by the rme-cap=on flag for pcie-root-port.
>
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> Signed-off-by: Jim MacArthur <jim.macarthur@linaro.org>
> ---
> hw/pci-bridge/gen_pcie_root_port.c | 35 +++++++++++++++++++++++++++++++++++
> include/hw/pci/pcie_regs.h | 4 ++++
> 2 files changed, 39 insertions(+)
>
> diff --git a/hw/pci-bridge/gen_pcie_root_port.c b/hw/pci-bridge/gen_pcie_root_port.c
> index ab8087da87..fb8dbb7959 100644
> --- a/hw/pci-bridge/gen_pcie_root_port.c
> +++ b/hw/pci-bridge/gen_pcie_root_port.c
> @@ -28,6 +28,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(GenPCIERootPort, GEN_PCIE_ROOT_PORT)
> (GEN_PCIE_ROOT_PORT_AER_OFFSET + PCI_ERR_SIZEOF)
> #define GEN_PCIE_ROOT_PORT_ACS_END \
> (GEN_PCIE_ROOT_PORT_ACS_OFFSET + PCI_ACS_SIZEOF)
> +
Stray change.
> #define GEN_PCIE_ROOT_PORT_MSIX_NR_VECTOR 1
> #define GEN_PCIE_ROOT_DEFAULT_IO_RANGE 4096
>
> @@ -67,6 +68,39 @@ static void gen_rp_interrupts_uninit(PCIDevice *d)
> msix_uninit_exclusive_bar(d);
> }
>
> +static uint32_t add_rme_dvsec_capability(PCIDevice *device, uint32_t offset)
> +{
> + /*
> + * dvsec rme-da
> + * https://developer.arm.com/documentation/den0129/latest/
> + * Arm RME System Architecture
> + * 0x0000 RMEDA_ECH See B3.2.6.2.1 RME-DA Extended Capability Header
> + * 0x0004 RMEDA_HEAD1 See B3.2.6.2.2 RME-DA DVSEC Header 1
> + * 0x0008 RMEDA_HEAD2 See B3.2.6.2.3 RME-DA DVSEC Header 2
> + * 0x000C RMEDA_CTL1 See B3.2.6.2.4 RME-DA Control register 1
> + * 0x0010 RMEDA_CTL2 See B3.2.6.2.5 RME-DA Control register 2
> + */
> + const uint32_t ARM_PCI_VID = 0x13b5;
> + const uint32_t RME_DA_DVSEC_ID = 0;
> + pcie_add_dvsec_capability(device, PCI_EXT_CAP_ID_DVSEC, 1, offset,
> + PCI_RME_DVSEC_SIZE, ARM_PCI_VID,
> + PCI_RME_DVSEC_VER, RME_DA_DVSEC_ID);
> + const uint32_t ctl1 = 0x1; /* support tdisp */
> + const uint32_t ctl2 = 0x0; /* unlocked */
Why not just pass these values in? The local doesn't seem to add anything to me.
> + pci_set_long(device->config + offset + 0xC, ctl1);
> + pci_set_long(device->config + offset + 0x10, ctl2);
> + device->wmask[offset + 0xC] = 0xff;
> + device->wmask[offset + 0xC + 1] = 0xff;
> + device->wmask[offset + 0xC + 2] = 0xff;
> + device->wmask[offset + 0xC + 3] = 0xff;
> + device->wmask[offset + 0x10] = 0xff;
> + device->wmask[offset + 0x10 + 1] = 0xff;
> + device->wmask[offset + 0x10 + 2] = 0xff;
> + device->wmask[offset + 0x10 + 3] = 0xff;
> + offset += PCI_RME_DVSEC_SIZE;
> + return offset;
Given only updated just above.
return offset + PCI_RME_DVSEC_SIZE;
would I think be slightly more readable.
> +}
> +
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH 3/4] hw/pci: add DVSEC RMEDA capability to PCIe root port
2026-10-29 15:05 ` [PATCH 3/4] hw/pci: add DVSEC RMEDA " Jim MacArthur
2026-11-04 19:29 ` Jonathan Cameron
@ 2026-11-09 1:12 ` Gustavo Romero
1 sibling, 0 replies; 16+ messages in thread
From: Gustavo Romero @ 2026-11-09 1:12 UTC (permalink / raw)
To: Jim MacArthur; +Cc: qemu-devel, Michael S. Tsirkin, Pierrick Bouvier
Hi Jim,
On Thu, Oct 29, 2026 at 03:05:12PM +0000, Jim MacArthur wrote:
> From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>
> Again, gated by the rme-cap=on flag for pcie-root-port.
Please, give some love to the commit messages :)
Yeah, now this cap only makes sense on Arm and on CPUs with FEAT_RME.
So I think it should actually be gated on a different flag, e.g.: "x-rme-da",
this would allow more control considering other platforms.
And then that's ok to keep this code in the generic root port code. Other archs
will gate on different flags.
I think we could then set "x-rme-da" globally at machine level, e.g., virt.c and
sbsa-ref.c, based on CPU's "x-rme" property, so we don't need pass "x-rme-da" to
every root port. Actually we could do that for "x-tee-io" (Patch 2/2) too,
although I think it would be premature to that now for both "x-tee-io"
and "x-rme-da".
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> Signed-off-by: Jim MacArthur <jim.macarthur@linaro.org>
> ---
> hw/pci-bridge/gen_pcie_root_port.c | 35 +++++++++++++++++++++++++++++++++++
> include/hw/pci/pcie_regs.h | 4 ++++
> 2 files changed, 39 insertions(+)
>
> diff --git a/hw/pci-bridge/gen_pcie_root_port.c b/hw/pci-bridge/gen_pcie_root_port.c
> index ab8087da87..fb8dbb7959 100644
> --- a/hw/pci-bridge/gen_pcie_root_port.c
> +++ b/hw/pci-bridge/gen_pcie_root_port.c
> @@ -28,6 +28,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(GenPCIERootPort, GEN_PCIE_ROOT_PORT)
> (GEN_PCIE_ROOT_PORT_AER_OFFSET + PCI_ERR_SIZEOF)
> #define GEN_PCIE_ROOT_PORT_ACS_END \
> (GEN_PCIE_ROOT_PORT_ACS_OFFSET + PCI_ACS_SIZEOF)
> +
> #define GEN_PCIE_ROOT_PORT_MSIX_NR_VECTOR 1
> #define GEN_PCIE_ROOT_DEFAULT_IO_RANGE 4096
>
> @@ -67,6 +68,39 @@ static void gen_rp_interrupts_uninit(PCIDevice *d)
> msix_uninit_exclusive_bar(d);
> }
>
> +static uint32_t add_rme_dvsec_capability(PCIDevice *device, uint32_t offset)
> +{
> + /*
> + * dvsec rme-da
> + * https://developer.arm.com/documentation/den0129/latest/
> + * Arm RME System Architecture
> + * 0x0000 RMEDA_ECH See B3.2.6.2.1 RME-DA Extended Capability Header
> + * 0x0004 RMEDA_HEAD1 See B3.2.6.2.2 RME-DA DVSEC Header 1
> + * 0x0008 RMEDA_HEAD2 See B3.2.6.2.3 RME-DA DVSEC Header 2
> + * 0x000C RMEDA_CTL1 See B3.2.6.2.4 RME-DA Control register 1
> + * 0x0010 RMEDA_CTL2 See B3.2.6.2.5 RME-DA Control register 2
> + */
> + const uint32_t ARM_PCI_VID = 0x13b5;
> + const uint32_t RME_DA_DVSEC_ID = 0;
> + pcie_add_dvsec_capability(device, PCI_EXT_CAP_ID_DVSEC, 1, offset,
> + PCI_RME_DVSEC_SIZE, ARM_PCI_VID,
> + PCI_RME_DVSEC_VER, RME_DA_DVSEC_ID);
> + const uint32_t ctl1 = 0x1; /* support tdisp */
> + const uint32_t ctl2 = 0x0; /* unlocked */
> + pci_set_long(device->config + offset + 0xC, ctl1);
> + pci_set_long(device->config + offset + 0x10, ctl2);
> + device->wmask[offset + 0xC] = 0xff;
> + device->wmask[offset + 0xC + 1] = 0xff;
> + device->wmask[offset + 0xC + 2] = 0xff;
> + device->wmask[offset + 0xC + 3] = 0xff;
> + device->wmask[offset + 0x10] = 0xff;
> + device->wmask[offset + 0x10 + 1] = 0xff;
> + device->wmask[offset + 0x10 + 2] = 0xff;
> + device->wmask[offset + 0x10 + 3] = 0xff;
> + offset += PCI_RME_DVSEC_SIZE;
> + return offset;
> +}
> +
> static void gen_rp_realize(DeviceState *dev, Error **errp)
> {
> PCIDevice *d = PCI_DEVICE(dev);
> @@ -106,6 +140,7 @@ static void gen_rp_realize(DeviceState *dev, Error **errp)
> }
>
> if (grp->rme_caps) {
So it would be something like:
if (tee_io) {
...
if (rme_da) {
add_rme_dvsec_capability(...);
}
}
Cheers,
Gustavo
> + next_cap_offset = add_rme_dvsec_capability(d, next_cap_offset);
> pcie_ide_init(d, next_cap_offset);
>
> /* Unused value, but may be useful for the next capability */
> diff --git a/include/hw/pci/pcie_regs.h b/include/hw/pci/pcie_regs.h
> index aa21177411..da812d32ff 100644
> --- a/include/hw/pci/pcie_regs.h
> +++ b/include/hw/pci/pcie_regs.h
> @@ -186,4 +186,8 @@ typedef enum PCIExpLinkWidth {
> #define PCI_IDE_VER 0x1
> #define PCI_IDE_SIZEOF 12
>
> +/* RME DVSEC */
> +#define PCI_RME_DVSEC_VER 0x1
> +#define PCI_RME_DVSEC_SIZE 20
> +
> #endif /* QEMU_PCIE_REGS_H */
>
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 4/4] hw/pci: More comments in pcie.c
2026-10-29 15:05 [PATCH 0/4] RME-DA capabilities for PCIe Root Port Jim MacArthur
` (2 preceding siblings ...)
2026-10-29 15:05 ` [PATCH 3/4] hw/pci: add DVSEC RMEDA " Jim MacArthur
@ 2026-10-29 15:05 ` Jim MacArthur
2026-11-09 1:12 ` Gustavo Romero
2026-11-09 1:13 ` [PATCH 0/4] RME-DA capabilities for PCIe Root Port Gustavo Romero
4 siblings, 1 reply; 16+ messages in thread
From: Jim MacArthur @ 2026-10-29 15:05 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael S. Tsirkin, Jim MacArthur
Signed-off-by: Jim MacArthur <jim.macarthur@linaro.org>
---
hw/pci/pcie.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index bf2c184cfc..c333ae01b2 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -1017,12 +1017,15 @@ bool pcie_cap_is_arifwd_enabled(const PCIDevice *dev)
* uint16_t ext_cap_size
*/
+/* Looks through the capability list and finds one matching the cap_id */
+
/* Passing a cap_id value > 0xffff will return 0 and put end of list in prev */
static uint16_t pcie_find_capability_list(PCIDevice *dev, uint32_t cap_id,
uint16_t *prev_p)
{
uint16_t prev = 0;
uint16_t next;
+ /* Find the first header, after the main 'config' (legacy) space */
uint32_t header = pci_get_long(dev->config + PCI_CONFIG_SPACE_SIZE);
if (!header) {
@@ -1030,6 +1033,8 @@ static uint16_t pcie_find_capability_list(PCIDevice *dev, uint32_t cap_id,
next = 0;
goto out;
}
+
+ /* Iterate through the PCIe config space, using the next cap offset */
for (next = PCI_CONFIG_SPACE_SIZE; next;
prev = next, next = PCI_EXT_CAP_NEXT(header)) {
@@ -1049,11 +1054,19 @@ out:
return next;
}
+/*
+ * As above, but ignoring the 'prev' parameter.
+ * Returns offset of that capability in the config space.
+ */
uint16_t pcie_find_capability(PCIDevice *dev, uint16_t cap_id)
{
return pcie_find_capability_list(dev, cap_id, NULL);
}
+/*
+ * Given a capability at position pos, set that's capability's
+ * next capability offset to 'next'.
+ */
static void pcie_ext_cap_set_next(PCIDevice *dev, uint16_t pos, uint16_t next)
{
uint32_t header = pci_get_long(dev->config + pos);
@@ -1083,6 +1096,7 @@ static void pcie_ext_cap_set_next(PCIDevice *dev, uint16_t pos, uint16_t next)
bool pcie_insert_capability(PCIDevice *dev, uint16_t cap_id, uint8_t cap_ver,
uint16_t offset, uint16_t size)
{
+ /* Start at the PCI Extended configuration space */
uint16_t pos = PCI_CONFIG_SPACE_SIZE, prev = 0;
uint32_t header;
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH 4/4] hw/pci: More comments in pcie.c
2026-10-29 15:05 ` [PATCH 4/4] hw/pci: More comments in pcie.c Jim MacArthur
@ 2026-11-09 1:12 ` Gustavo Romero
0 siblings, 0 replies; 16+ messages in thread
From: Gustavo Romero @ 2026-11-09 1:12 UTC (permalink / raw)
To: Jim MacArthur; +Cc: qemu-devel, Michael S. Tsirkin
Hi Jim,
On Thu, Oct 29, 2026 at 03:05:13PM +0000, Jim MacArthur wrote:
> Signed-off-by: Jim MacArthur <jim.macarthur@linaro.org>
> ---
> hw/pci/pcie.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
> index bf2c184cfc..c333ae01b2 100644
> --- a/hw/pci/pcie.c
> +++ b/hw/pci/pcie.c
> @@ -1017,12 +1017,15 @@ bool pcie_cap_is_arifwd_enabled(const PCIDevice *dev)
> * uint16_t ext_cap_size
> */
>
> +/* Looks through the capability list and finds one matching the cap_id */
> +
> /* Passing a cap_id value > 0xffff will return 0 and put end of list in prev */
> static uint16_t pcie_find_capability_list(PCIDevice *dev, uint32_t cap_id,
> uint16_t *prev_p)
> {
> uint16_t prev = 0;
> uint16_t next;
> + /* Find the first header, after the main 'config' (legacy) space */
> uint32_t header = pci_get_long(dev->config + PCI_CONFIG_SPACE_SIZE);
Drop "legacy" and call it instead "PCI Configuration Space" as per the names in
the layout in "Figure 7-3 PCI Express Configuration Space Layout", p.
1055, spec rev. 7?
>
> if (!header) {
> @@ -1030,6 +1033,8 @@ static uint16_t pcie_find_capability_list(PCIDevice *dev, uint32_t cap_id,
> next = 0;
> goto out;
> }
> +
> + /* Iterate through the PCIe config space, using the next cap offset */
> for (next = PCI_CONFIG_SPACE_SIZE; next;
> prev = next, next = PCI_EXT_CAP_NEXT(header)) {
>
> @@ -1049,11 +1054,19 @@ out:
> return next;
> }
>
> +/*
> + * As above, but ignoring the 'prev' parameter.
> + * Returns offset of that capability in the config space.
> + */
> uint16_t pcie_find_capability(PCIDevice *dev, uint16_t cap_id)
> {
> return pcie_find_capability_list(dev, cap_id, NULL);
> }
>
> +/*
> + * Given a capability at position pos, set that's capability's
> + * next capability offset to 'next'.
> + */
> static void pcie_ext_cap_set_next(PCIDevice *dev, uint16_t pos, uint16_t next)
> {
> uint32_t header = pci_get_long(dev->config + pos);
> @@ -1083,6 +1096,7 @@ static void pcie_ext_cap_set_next(PCIDevice *dev, uint16_t pos, uint16_t next)
> bool pcie_insert_capability(PCIDevice *dev, uint16_t cap_id, uint8_t cap_ver,
> uint16_t offset, uint16_t size)
> {
> + /* Start at the PCI Extended configuration space */
> uint16_t pos = PCI_CONFIG_SPACE_SIZE, prev = 0;
> uint32_t header;
>
>
> --
> 2.43.0
>
>
Please, enhance the commit title and add a commit message.
Cheers,
Gustavo
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 0/4] RME-DA capabilities for PCIe Root Port
2026-10-29 15:05 [PATCH 0/4] RME-DA capabilities for PCIe Root Port Jim MacArthur
` (3 preceding siblings ...)
2026-10-29 15:05 ` [PATCH 4/4] hw/pci: More comments in pcie.c Jim MacArthur
@ 2026-11-09 1:13 ` Gustavo Romero
4 siblings, 0 replies; 16+ messages in thread
From: Gustavo Romero @ 2026-11-09 1:13 UTC (permalink / raw)
To: Jim MacArthur
Cc: qemu-devel, Michael S. Tsirkin, Jim MacArthur, Pierrick Bouvier
Hi Jim,
On Thu, Oct 29, 2026 at 03:05:09PM +0000, Jim MacArthur wrote:
> This adds optional capabilities for the PCIe Root Port device: the TEE
> flag in legacy config space and two extended capabilties:
> - IDE (Integrity & Data Encryption)
> - The RME-DA DVSEC capability.
>
> All changes are enabled by the rme-cap=on flag for the pcie-root-port
> device.
>
> This is a rearrangement of original work done by Pierrick Bouvier
> <pierrick.bouvier@linaro.org>.
>
> Signed-off-by: Jim MacArthur <jim.macarthur@linaro.org>
> ---
> Jim MacArthur (2):
> hw/pci-bridge: Add pcie_add_dvsec_capability helper
> hw/pci: More comments in pcie.c
>
> Pierrick Bouvier (2):
> hw/pci: add IDE + TEE capability to PCIe root port
> hw/pci: add DVSEC RMEDA capability to PCIe root port
I think the series would read better by adding the TEE bit + IDE, then
the dvsec helper and finally the RMEDA capability.
Cheers,
Gustavo
> hw/pci-bridge/gen_pcie_root_port.c | 54 ++++++++++++++++++++++++++++++++++++++
> hw/pci/pcie.c | 49 ++++++++++++++++++++++++++++++++++
> include/hw/pci/pcie.h | 7 +++++
> include/hw/pci/pcie_regs.h | 8 ++++++
> 4 files changed, 118 insertions(+)
> ---
> base-commit: 5624b266cdd513506fb333e9041778407b6d1ac4
> change-id: 20261022-jmac-pcie-rme-extensions-ecbc501d4d7f
>
> Best regards,
> --
> Jim MacArthur <jim.macarthur@linaro.org>
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread