This series implements RPMB (Replay Protected Memory Block) well-known logical unit emulation (W-LUN 0xc4) for QEMU UFS per JESD220H Section 12.4.
Summary of Changes: - Patch 1: Add SCSI security protocol opcodes and RPMB definitions. - Patch 2: Set bSecurityLU to 0x01, enable RPMB unit descriptor, wire SECURITY PROTOCOL IN/OUT CDB and PRDT buffer capacity validation via ufs_fit_data_buffer(), add Result Register read handling in hw/ufs/rpmb.c, and clear volatile RPMB state in ufs_hce_reset(). - Patch 3: Add qtest case for DeviceDescriptor bSecurityLU, RPMB unit descriptor, CDB, W-LUN dispatch, and PRDT validation. - Patch 4: Add HMAC-SHA256 key programming and write counter read handling. - Patch 5: Add qtest case for key programming and write counter reads. - Patch 6: Add single- and multi-frame authenticated data write and read handling and update docs/system/devices/ufs.rst. - Patch 7: Add qtest case for authenticated data writes, reads, check ordering, general-failure paths, multi-region isolation, and HCE reset state handling. Outside hw/ufs and tests, the series only adds the SECURITY PROTOCOL IN/OUT opcodes to include/scsi/constants.h and RPMB definitions to the UFS-only include/block/ufs.h. There is no change to block layer or SCSI core code. Tested: QEMU ARM64/x86_64 qos-test and Linux guest SDB/MCQ RPMB, pass. Based-on: <[email protected]> Stanley Jhu (7): include/scsi, block/ufs: Add security protocol and RPMB definitions hw/ufs: Add RPMB unit descriptor and SECURITY PROTOCOL IN/OUT dispatch tests/qtest/ufs-test: Add RPMB descriptor and CDB validation test hw/ufs: Add RPMB key programming and write counter read handling tests/qtest/ufs-test: Add RPMB key programming and write counter test hw/ufs: Add RPMB authenticated data write and read handling tests/qtest/ufs-test: Add RPMB authenticated data read and write test docs/system/devices/ufs.rst | 6 +- hw/ufs/lu.c | 34 ++ hw/ufs/meson.build | 2 +- hw/ufs/rpmb.c | 447 +++++++++++++++++ hw/ufs/trace-events | 3 + hw/ufs/ufs.c | 26 +- hw/ufs/ufs.h | 24 + include/block/ufs.h | 58 ++- include/scsi/constants.h | 2 + tests/qtest/ufs-test.c | 959 ++++++++++++++++++++++++++++++++++++ 10 files changed, 1552 insertions(+), 9 deletions(-) create mode 100644 hw/ufs/rpmb.c -- 2.56.0.307.g5fe7bd680c-goog
