Skip to content

Commit e39e2ca

Browse files
authored
Logical Secure Partition Patch Update (#1379)
## Description Update the LSP patch to hard code the TPM service UUID rather than use the byte swapping method. This was causing issues on patina-qemu as the bytes would show up differently and the communication between the LSP and the TPM service would fail. For details on how to complete these options and their meaning refer to [CONTRIBUTING.md](https://github.com/microsoft/mu/blob/HEAD/CONTRIBUTING.md). - [x] Impacts functionality? - [ ] Impacts security? - [ ] Breaking change? - [ ] Includes tests? - [ ] Includes documentation? ## How This Was Tested Built QEMU SBSA with TPM enabled. Verified TPM communication and boot to UEFI shell. ## Integration Instructions N/A
1 parent a34b7b1 commit e39e2ca

File tree

1 file changed

+6
-48
lines changed

1 file changed

+6
-48
lines changed

Platforms/QemuSbsaPkg/tfa_patches/0003-Added-support-for-logical-secure-partitions-in-TF-A.patch

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ new file mode 100644
9898
index 000000000..a0fa51b91
9999
--- /dev/null
100100
+++ b/plat/qemu/qemu_sbsa/qemu_sbsa_spmd_logical_sp.c
101-
@@ -0,0 +1,141 @@
101+
@@ -0,0 +1,099 @@
102102
+/*
103103
+ * QEMU SBSA Logical Secure Partition - DRTM/TPM
104104
+ *
@@ -118,7 +118,6 @@ index 000000000..a0fa51b91
118118
+#define SPMD_PARTITION_PROPERTIES FFA_PARTITION_DIRECT_REQ2_SEND
119119
+
120120
+#define MSSP_ID 0x8002
121-
+#define TPM_GUID { 0x17, 0xb8, 0x62, 0xa4, 0x18, 0x06, 0x4f, 0xaf, 0x86, 0xb3, 0x08, 0x9a, 0x58, 0x35, 0x38, 0x61 }
122121
+#define GET_INTERFACE_VERSION_CMD 0x0f000001
123122
+#define START_CMD 0x0f000201
124123
+#define TPM_START_PROCESS_OPEN_LOC 0x100
@@ -127,37 +126,6 @@ index 000000000..a0fa51b91
127126
+#define MANAGE_LOCALITY_OPEN 0
128127
+#define MANAGE_LOCALITY_CLOSE 1
129128
+
130-
+static uint16_t SwapBytes16 (uint16_t Value)
131-
+{
132-
+ return (uint16_t) ((Value << 8) | (Value >> 8));
133-
+}
134-
+
135-
+static uint32_t SwapBytes32 (uint32_t Value)
136-
+{
137-
+ uint32_t LowerBytes;
138-
+ uint32_t HigherBytes;
139-
+
140-
+ LowerBytes = (uint32_t) SwapBytes16 ((uint16_t) Value);
141-
+ HigherBytes = (uint32_t) SwapBytes16 ((uint16_t) (Value >> 16));
142-
+ return (LowerBytes << 16 | HigherBytes);
143-
+}
144-
+
145-
+static void PrepareUuid (uint8_t* Uuid)
146-
+{
147-
+ uint32_t *Data32;
148-
+ uint16_t *Data16;
149-
+
150-
+ if (Uuid == NULL) {
151-
+ return;
152-
+ }
153-
+
154-
+ Data32 = (uint32_t *)Uuid;
155-
+ Data32[0] = SwapBytes32 (Data32[0]);
156-
+ Data16 = (uint16_t *)&Data32[1];
157-
+ Data16[0] = SwapBytes16 (Data16[0]);
158-
+ Data16[1] = SwapBytes16 (Data16[1]);
159-
+}
160-
+
161129
+static int32_t qemu_sbsa_spmd_logical_partition_init(void)
162130
+{
163131
+ INFO("QEMU SBSA SPMD LSP: Init function called.\n");
@@ -172,23 +140,18 @@ index 000000000..a0fa51b91
172140
+ qemu_sbsa_spmd_lsp_close_locality(3);
173141
+ qemu_sbsa_spmd_lsp_close_locality(4);
174142
+
175-
+ return 0;
143+
+ return 0;
176144
+}
177145
+
178146
+int32_t qemu_sbsa_spmd_lsp_open_locality(uint8_t locality)
179147
+{
180148
+ struct ffa_value Message = {0};
181149
+ struct ffa_value Return;
182-
+ uint64_t* UuidHiLo;
183-
+ uint8_t Uuid[] = TPM_GUID;
184-
+ PrepareUuid(Uuid);
185-
+
186-
+ UuidHiLo = (uint64_t*)Uuid;
187150
+
188151
+ Message.func = FFA_MSG_SEND_DIRECT_REQ2_SMC64;
189152
+ Message.arg1 = ((uint64_t)SPMD_LP_PARTITION_ID << 16) | (uint64_t)MSSP_ID;
190-
+ Message.arg2 = UuidHiLo[0];
191-
+ Message.arg3 = UuidHiLo[1];
153+
+ Message.arg2 = 0xAF4F0618A462B817; // TPM_UUID LO
154+
+ Message.arg3 = 0x613835589A08B386; // TPM UUID HI
192155
+ Message.arg4 = MANAGE_LOCALITY_CMD;
193156
+ Message.arg5 = MANAGE_LOCALITY_OPEN;
194157
+ Message.arg6 = locality;
@@ -205,16 +168,11 @@ index 000000000..a0fa51b91
205168
+{
206169
+ struct ffa_value Message = {0};
207170
+ struct ffa_value Return;
208-
+ uint64_t* UuidHiLo;
209-
+ uint8_t Uuid[] = TPM_GUID;
210-
+ PrepareUuid(Uuid);
211-
+
212-
+ UuidHiLo = (uint64_t*)Uuid;
213171
+
214172
+ Message.func = FFA_MSG_SEND_DIRECT_REQ2_SMC64;
215173
+ Message.arg1 = ((uint64_t)SPMD_LP_PARTITION_ID << 16) | (uint64_t)MSSP_ID;
216-
+ Message.arg2 = UuidHiLo[0];
217-
+ Message.arg3 = UuidHiLo[1];
174+
+ Message.arg2 = 0xAF4F0618A462B817; // TPM_UUID LO
175+
+ Message.arg3 = 0x613835589A08B386; // TPM UUID HI
218176
+ Message.arg4 = MANAGE_LOCALITY_CMD;
219177
+ Message.arg5 = MANAGE_LOCALITY_CLOSE;
220178
+ Message.arg6 = locality;

0 commit comments

Comments
 (0)