lspci: Adding TDISP, IDE
Subsystems (2)
v2 cover lspci: Adding TDISP, IDE
Here is a couple of patches for TDISP/IDE capable PCIe devices. IDE enables PCIe link encryption and TDISP enables secure pass-through of PCI devices into confidentional virtual machines running under Linux KVM on supported hardware.
This is based on sha1
2ef5809 Martin Mares "maint/README: Mention maint/push-to-public".
Please comment. Thanks.
Alexey Kardashevskiy (2):
ls-ecaps: Add decode support for IDE Extended Capability
lspci: Add TEE-IO extended capability bit
lib/header.h | 63 ++++ ls-caps.c | 1 + ls-ecaps.c | 192 +++++++++++ setpci.c | 1 + tests/cap-ide | 346 ++++++++++++++++++++ 5 files changed, 603 insertions(+) create mode 100644 tests/cap-ide
Signature · 1 line
2.41.0
PATCH v2 1/2 ls-ecaps: Add decode support for IDE Extended Capability
IDE (Integrity & Data Encryption) Extended Capability defined in [1] implements control of the PCI link encryption. The verbose level > 2 prints offsets of the fields to make running setpci easier.
The example output is:
Capabilities: [830 v1] Integrity & Data Encryption
IDECap: Lnk=0 Sel=1 FlowThru- PartHdr- Aggr- PCPC- IDE_KM+ Alg='AES-GCM-256-96b' TCs=8 TeeLim+
IDECtl: FTEn-
SelectiveIDE#0 Cap: RID#=1
SelectiveIDE#0 Ctl: En- NPR- PR- CPL- PCRC- HdrEnc=no Alg='AES-GCM-256-96b' TC0 ID0 SelectiveIDE#0 Sta: insecure RecvChkFail-
SelectiveIDE#0 RID: Valid- Base=0 Limit=0 SegBase=0
SelectiveIDE#0 RID#0: Valid- Base=0 Limit=0
[1] PCIe r6.0.1, sections 6.33, 7.9.26
---
Changes:
v2:
* added 0x30 cap to setpci
* added/fixed some flags
* added a test
--- lib/header.h | 62 ++++ ls-ecaps.c | 192 +++++++++++ setpci.c | 1 + tests/cap-ide | 346 ++++++++++++++++++++ 4 files changed, 601 insertions(+)
lib/header.h +62 -0
@@ -256,6 +256,7 @@#define PCI_EXT_CAP_ID_NPEM 0x29/* Native PCIe Enclosure Management */ #define PCI_EXT_CAP_ID_32GT 0x2a/* Physical Layer 32.0 GT/s */ #define PCI_EXT_CAP_ID_DOE 0x2e/* Data Object Exchange */ +#define PCI_EXT_CAP_ID_IDE 0x30/* Integrity and Data Encryption */ /*** Definitions of capabilities ***/
@@ -1422,6 +1423,67 @@#define PCI_LMR_PORT_STS_READY 0x1/* Margining Ready */ #define PCI_LMR_PORT_STS_SOFT_READY 0x2/* Margining Software Ready */ +/* Integrity and Data Encryption Extended Capability */ +#define PCI_IDE_CAP 0x4 +#define PCI_IDE_CAP_LINK_IDE_SUPP 0x1/* Link IDE Stream Supported */ +#define PCI_IDE_CAP_SELECTIVE_IDE_SUPP 0x2/* Selective IDE Streams Supported */ +#define PCI_IDE_CAP_FLOWTHROUGH_IDE_SUPP 0x4/* Flow-Through IDE Stream Supported */ +#define PCI_IDE_CAP_PARTIAL_HEADER_ENC_SUPP 0x8/* Partial Header Encryption Supported */ +#define PCI_IDE_CAP_AGGREGATION_SUPP 0x10/* Aggregation Supported */ +#define PCI_IDE_CAP_PCRC_SUPP 0x20/* PCRC Supported */ +#define PCI_IDE_CAP_IDE_KM_SUPP 0x40/* IDE_KM Protocol Supported */ +#define PCI_IDE_CAP_ALG (x) (((x) >> 8) & 0x1f)/* Supported Algorithms */ +#define PCI_IDE_CAP_ALG_AES_GCM_256 0/* AES-GCM 256 key size, 96b MAC */ +#define PCI_IDE_CAP_LINK_TC_NUM (x) (((x) >> 13) & 0x7)/* Number of TCs Supported for Link IDE */ +#define PCI_IDE_CAP_SELECTIVE_STREAMS_NUM (x) (((x) >> 16) & 0xff)/* Number of Selective IDE Streams Supported */ +#define PCI_IDE_CAP_TEE_LIMITED_SUPP 0x1000000/* TEE-Limited Stream Supported */ +#define PCI_IDE_CTL 0x8 +#define PCI_IDE_CTL_FLOWTHROUGH_IDE 0x4/* Flow-Through IDE Stream Enabled */ +#define PCI_IDE_LINK_STREAM 0xC +/* Link IDE Stream block, up to PCI_IDE_CAP_LINK_TC_NUM */ +/* Link IDE Stream Control Register */ +#define PCI_IDE_LINK_CTL_EN 0x1/* Link IDE Stream Enable */ +#define PCI_IDE_LINK_CTL_TX_AGGR_NPR (x)(((x) >> 2) & 0x3)/* Tx Aggregation Mode NPR */ +#define PCI_IDE_LINK_CTL_TX_AGGR_PR (x) (((x) >> 4) & 0x3)/* Tx Aggregation Mode PR */ +#define PCI_IDE_LINK_CTL_TX_AGGR_CPL (x)(((x) >> 6) & 0x3)/* Tx Aggregation Mode CPL */ +#define PCI_IDE_LINK_CTL_PCRC_EN 0x100/* PCRC Enable */ +#define PCI_IDE_LINK_CTL_PART_ENC (x) (((x) >> 10) & 0xf)/* Partial Header Encryption Mode */ +#define PCI_IDE_LINK_CTL_ALG (x) (((x) >> 14) & 0x1f)/* Selected Algorithm */ +#define PCI_IDE_LINK_CTL_TC (x) (((x) >> 19) & 0x7)/* Traffic Class */ +#define PCI_IDE_LINK_CTL_ID (x) (((x) >> 24) & 0xff)/* Stream ID */ +/* Link IDE Stream Status Register */ +#define PCI_IDE_LINK_STS_STATUS (x) ((x) & 0xf)/* Link IDE Stream State */ +#define PCI_IDE_LINK_STS_RECVD_INTEGRITY_CHECK 0x80000000/* Received Integrity Check Fail Message */ +/* Selective IDE Stream block, up to PCI_IDE_CAP_SELECTIVE_STREAMS_NUM */ +/* Selective IDE Stream Capability Register */ +#define PCI_IDE_SEL_CAP_BLOCKS_NUM (x) ((x) & 0xf)/* Number of Address Association Register Blocks */ +/* Selective IDE Stream Control Register */ +#define PCI_IDE_SEL_CTL_EN 0x1/* Selective IDE Stream Enable */ +#define PCI_IDE_SEL_CTL_TX_AGGR_NPR (x) (((x) >> 2) & 0x3)/* Tx Aggregation Mode NPR */ +#define PCI_IDE_SEL_CTL_TX_AGGR_PR (x) (((x) >> 4) & 0x3)/* Tx Aggregation Mode PR */ +#define PCI_IDE_SEL_CTL_TX_AGGR_CPL (x) (((x) >> 6) & 0x3)/* Tx Aggregation Mode CPL */ +#define PCI_IDE_SEL_CTL_PCRC_EN 0x100/* PCRC Enable */ +#define PCI_IDE_SEL_CTL_PART_ENC (x) (((x) >> 10) & 0xf)/* Partial Header Encryption Mode */ +#define PCI_IDE_SEL_CTL_ALG (x) (((x) >> 14) & 0x1f)/* Selected Algorithm */ +#define PCI_IDE_SEL_CTL_TC (x) (((x) >> 19) & 0x7)/* Traffic Class */ +#define PCI_IDE_SEL_CTL_DEFAULT 0x400000/* Default Stream */ +#define PCI_IDE_SEL_CTL_ID (x) (((x) >> 24) & 0xff)/* Stream ID */ +/* Selective IDE Stream Status Register */ +#define PCI_IDE_SEL_STS_STATUS (x) ((x) & 0xf)/* Selective IDE Stream State */ +#define PCI_IDE_SEL_STS_RECVD_INTEGRITY_CHECK 0x80000000/* Received Integrity Check Fail Message */ +/* IDE RID Association Register 1 */ +#define PCI_IDE_SEL_RID_1_LIMIT (x) (((x) >> 8) & 0xffff)/* RID Limit */ +/* IDE RID Association Register 2 */ +#define PCI_IDE_SEL_RID_2_VALID 0x1/* Valid */ +#define PCI_IDE_SEL_RID_2_BASE (x) (((x) >> 8) & 0xffff)/* RID Base */ +#define PCI_IDE_SEL_RID_2_SEG_BASE (x) (((x) >> 24) & 0xff)/* Segmeng Base */ +/* Selective IDE Address Association Register Block, up to PCI_IDE_SEL_CAP_BLOCKS_NUM */ +#define PCI_IDE_SEL_ADDR_1_VALID 0x1/* Valid */ +#define PCI_IDE_SEL_ADDR_1_BASE_LOW (x) (((x) >> 8) & 0xfff)/* Memory Base Lower */ +#define PCI_IDE_SEL_ADDR_1_LIMIT_LOW (x)(((x) >> 20) & 0xfff)/* Memory Limit Lower */ +/* IDE Address Association Register 2 is "Memory Limit Upper" */ +/* IDE Address Association Register 3 is "Memory Base Upper" */ +/* * The PCI interface treats multi-function devices as independent * devices. The slot/function address of each device is encoded
ls-ecaps.c +192 -0
204 lines not on this page · raw message
setpci.c +1 -0
@@ -396,6 +396,7 @@ static const struct reg_name pci_reg_names[] = { { 0x20027, 0, 0, 0x0, "ECAP_LMR" }, { 0x20028, 0, 0, 0x0, "ECAP_HIER_ID" }, { 0x20029, 0, 0, 0x0, "ECAP_NPEM" }, + { 0x20030, 0, 0, 0x0, "ECAP_IDE" }, { 0, 0, 0, 0x0, NULL } };
tests/cap-ide new file +346 -0
346 lines not on this page · raw message
Signature · 1 line
2.41.0
Re: [PATCH pciutils v2 1/2] ls-ecaps: Add decode support for IDE Extended Capability
Quoted 8 lines · Alexey Kardashevskiy
IDE (Integrity & Data Encryption) Extended Capability defined in [1] implements control of the PCI link encryption. The verbose level > 2 prints offsets of the fields to make running setpci easier.
The example output is:
Capabilities: [830 v1] Integrity & Data Encryption
IDECap: Lnk=0 Sel=1 FlowThru- PartHdr- Aggr- PCPC- IDE_KM+ Alg='AES-GCM-256-96b' TCs=8 TeeLim+
Hm, I'm wondering if the Supported Algorithms should be listed on a line by themselves, each enumerated with a '+' or '-' indicator? Maybe that's easier to parse?
In general, I'd prefer it if the output was linewrapped at 80 chars, (i.e. begin a new line and indent as appropriate).
Thanks,
Lukas
Re: [PATCH pciutils v2 1/2] ls-ecaps: Add decode support for IDE Extended Capability
Quoted 5 lines · Lukas Wunner
Quoted 4 lines · Alexey Kardashevskiy
IDE (Integrity & Data Encryption) Extended Capability defined in [1] implements control of the PCI link encryption. The verbose level > 2 prints offsets of the fields to make running setpci easier.
Quoted 8 lines
Quoted 4 lines
The example output is:
Capabilities: [830 v1] Integrity & Data Encryption
IDECap: Lnk=0 Sel=1 FlowThru- PartHdr- Aggr- PCPC- IDE_KM+ Alg='AES-GCM-256-96b' TCs=8 TeeLim+Hm, I'm wondering if the Supported Algorithms should be listed on a line by themselves, each enumerated with a '+' or '-' indicator? Maybe that's easier to parse?
I'd leave this for later when PCIe defines another one (or more). And I was hoping someone suggested better (==shorter) acronym for the algorithm, may be just call it "AES256"?
Quoted 2 lines
In general, I'd prefer it if the output was linewrapped at 80 chars, (i.e. begin a new line and indent as appropriate).
Well, too late, there are examples in "tests" 114 chars long. It is 2024 after all, everyone got a big screen, even Linus :) Thanks,
Quoted 4 lines
Thanks,
Lukas
Signature · 1 line
Alexey
PATCH v2 2/2 lspci: Add TEE-IO extended capability bit
In reply to Alexey KardashevskiyPCIe r6.1, sec 7.5.3.3 defines "TEE-IO Supported" in the PCI Express Device Capabilities Register which indicates that the function implements the TEE-IO functionality as described by the TEE Device Interface Security Protocol (TDISP, PCIe r6.1, chapter 11).
tests/cap-ide is an example of such device.
---
Changes:
v2:
* added the section number to the commit log
--- lib/header.h | 1 + ls-caps.c | 1 + 2 files changed, 2 insertions(+)
lib/header.h +1 -0
@@ -777,6 +777,7 @@#define PCI_EXP_DEVCAP_PWR_VAL 0x3fc0000/* Slot Power Limit Value */ #define PCI_EXP_DEVCAP_PWR_SCL 0xc000000/* Slot Power Limit Scale */ #define PCI_EXP_DEVCAP_FLRESET 0x10000000/* Function-Level Reset */ +#define PCI_EXP_DEVCAP_TEE_IO 0x40000000/* TEE-IO Supported (TDISP) */ #define PCI_EXP_DEVCTL 0x8/* Device Control */ #define PCI_EXP_DEVCTL_CERE 0x0001/* Correctable Error Reporting En. */ #define PCI_EXP_DEVCTL_NFERE 0x0002/* Non-Fatal Error Reporting Enable */
ls-caps.c +1 -0
@@ -717,6 +717,7 @@ static void cap_express_dev(struct device *d, int where, int type)printf (" SlotPowerLimit " );show_power_limit ((t &PCI_EXP_DEVCAP_PWR_VAL ) >>18 , (t &PCI_EXP_DEVCAP_PWR_SCL ) >>26 ); } +printf (" TEE-IO%c" ,FLAG (t,PCI_EXP_DEVCAP_TEE_IO ));printf ("\n" ); w =get_conf_word (d, where +PCI_EXP_DEVCTL );
Signature · 1 line
2.41.0
Martin Mareš
AppliedHello!
Quoted 4 lines
Here is a couple of patches for TDISP/IDE capable PCIe devices. IDE enables PCIe link encryption and TDISP enables secure pass-through of PCI devices into confidentional virtual machines running under Linux KVM on supported hardware.
Thanks, applied.
Martin