VirtualBox

source: vbox/trunk/src/VBox/Devices/PC/vbox-tpm.dsl

Last change on this file was 105047, checked in by vboxsync, 4 weeks ago

Devices/ACPI/vbox-tpm.dsl: Implement the Physical Presence Interface (PPI) as required by Windows, bugref:10701 [scm]

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.8 KB
Line 
1/* $Id: vbox-tpm.dsl 105047 2024-06-27 09:05:56Z vboxsync $ */
2/** @file
3 * VirtualBox ACPI - TPM ACPI device.
4 */
5
6/*
7 * Copyright (C) 2021-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28DefinitionBlock ("SSDT.aml", "SSDT", 1, "VBOX ", "VBOXTPMT", 2)
29{
30 External(DBG, MethodObj, ,)
31
32 Scope (\_SB)
33 {
34 Device (TPM)
35 {
36 Method (_HID, 0, NotSerialized)
37 {
38 If (LEqual(IFID, One))
39 {
40 Return ("PNP0C31")
41 }
42 Else
43 {
44 Return ("MSFT0101")
45 }
46 }
47
48 Method (_CID, 0, NotSerialized)
49 {
50 If (LEqual(IFID, One))
51 {
52 Return ("PNP0C31")
53 }
54 Else
55 {
56 Return ("MSFT0101")
57 }
58 }
59
60 Method (_STR, 0, NotSerialized)
61 {
62 If (LEqual(IFID, One))
63 {
64 Return (Unicode ("TPM 1.2 Device"))
65 }
66 Else
67 {
68 Return (Unicode ("TPM 2.0 Device"))
69 }
70 }
71
72 Method (_STA, 0, NotSerialized)
73 {
74 Return (0x0F)
75 }
76
77 OperationRegion (TPMR, SystemMemory, 0xFED40000, 0x5000)
78 Field(TPMR, AnyAcc, NoLock, Preserve)
79 {
80 Offset(0x30),
81 IFID, 1,
82 }
83
84 Name(RES, ResourceTemplate()
85 {
86 Memory32Fixed (ReadWrite, 0xfed40000, 0x5000, REG1)
87 })
88
89 Method (_CRS, 0, Serialized)
90 {
91 Return (RES)
92 }
93
94 Method (TPFS, 1, Serialized)
95 {
96 If (LGreaterEqual(Arg0, 0x100))
97 {
98 Return (Zero)
99 }
100
101 OperationRegion (TPP1, SystemMemory, Add(0xFED45000, Arg0), One)
102 Field (TPP1, ByteAcc, NoLock, Preserve)
103 {
104 TPPF, 8
105 }
106
107 Return (TPPF)
108 }
109
110 /**
111 * Device-Specific Method
112 */
113 Method (_DSM, 4, Serialized)
114 {
115 /**
116 * The TPM Physical Presence Interface MMIO region.
117 */
118 OperationRegion (TPMP, SystemMemory, 0xFED45100, 0x5A)
119 Field (TPMP, AnyAcc, NoLock, Preserve)
120 {
121 PPIN, 8,
122 PPIP, 32,
123 PPRP, 32,
124 PPRQ, 32,
125 PPRM, 32,
126 LPPR, 32
127 }
128
129 Name (TPB2, Package (0x02)
130 {
131 Zero,
132 Zero
133 })
134
135 Name (TPB3, Package (0x03)
136 {
137 Zero,
138 Zero,
139 Zero
140 })
141
142 /**
143 * Physical Presence Interface Specification PPI.
144 */
145 If (LEqual (Arg0, ToUUID("3dddfaa6-361b-4eb4-a424-8d10089d1653")))
146 {
147 /**
148 * Standard _DSM query function.
149 */
150 If (LEqual (Arg2, Zero))
151 {
152 DBG("_DSM: Query\n")
153 Return (Buffer (0x02) { 0xFF, 0x01 })
154 }
155
156 /**
157 * Query supported PPI revision.
158 *
159 * Result:
160 * 1.3 (string).
161 */
162 If (LEqual (Arg2, One))
163 {
164 DBG("_DSM: PPI Revision\n")
165 Return ("1.3")
166 }
167
168 /**
169 * Submit TPM Operation Request to pre-OS environment.
170 *
171 * Input:
172 * Package[0] - Operation value of the request
173 * Result:
174 * - 0: Success
175 * - 1: Operation value of the request not supported.
176 * - 2: General failure
177 */
178 If (LEqual (Arg2, 0x02))
179 {
180 DBG("_DSM: Submit TPM Operation Request\n")
181
182 Store(DerefOf(Index(Arg3, Zero)), Local0)
183 Store(TPFS(Local0), Local1)
184 If (LEqual(And(Local1, 0x07), Zero))
185 {
186 Return (One)
187 }
188
189 Store(Local0, PPRQ)
190 Store(Zero, PPRM)
191 Return (Zero)
192 }
193
194 /**
195 * Get Pending TPM Operation Requested by the OS.
196 *
197 * Result:
198 * Package[0] - Function Return Code:
199 * - 0: Success
200 * - 1: General Failure
201 * Package[1] - Pending operation requested by the OS:
202 * - 0: None
203 * - >0: Operation value of the pending request
204 * Package[2] - Optional argument to pending operation requested by the OS:
205 * - 0: None
206 * - >0: Argument value of the pending request
207 */
208 If (LEqual (Arg2, 0x03))
209 {
210 DBG("_DSM: Get Pending TPM Operation Request\n")
211
212 if (LEqual(Arg1, One))
213 {
214 Store(PPRQ, Index(TPB2, One))
215 Return (TPB2)
216 }
217
218 if (LEqual(Arg1, 0x02))
219 {
220 Store(PPRQ, Index(TPB3, One))
221 Store(PPRM, Index(TPB3, 0x02))
222 Return (TPB3)
223 }
224
225 Return (TPB3)
226 }
227
228 /**
229 * Get Platform-Specific Action to Transition to Pre-OS Environment.
230 *
231 * Result:
232 * - 0: None
233 * - 1: Shutdown
234 * - 2: Reboot
235 * - 3: OS vendor specific
236 */
237 If (LEqual (Arg2, 0x04))
238 {
239 DBG("_DSM: Get Platform-Specific Action to Transition to Pre-OS Environment\n")
240
241 Return (0x02)
242 }
243
244 /**
245 * Return TPM Operation Response to OS Environment.
246 */
247 If (LEqual (Arg2, 0x05))
248 {
249 DBG("_DSM: Return TPM Operation Response to OS Environment\n")
250
251 Store (LPPR, Index (TPB3, One))
252 Store (PPRP, Index (TPB3, 0x02))
253 Return (TPB3)
254 }
255
256 /**
257 * Submit preferred user language - deprecated
258 *
259 * Result:
260 * - 3: Not implemented
261 */
262 If (LEqual (Arg2, 0x06))
263 {
264 DBG("_DSM: Submit preferred user language\n")
265
266 Return (0x03)
267 }
268
269 /**
270 * Submit TPM Operation Request to Pre-OS Environment 2
271 */
272 If (LEqual (Arg2, 0x07))
273 {
274 DBG("_DSM: Submit TPM Operation Request 2\n")
275
276 Store(DerefOf(Index(Arg3, Zero)), Local0) /* Local0 = *Arg3[0] (Arg3 is a Package) */
277 Store(TPFS(Local0), Local1) /* Local1 = TPFS(Local0) */
278 Store(And(Local1, 0x07), Local1) /* Local1 &= 0x7 */
279 If (LEqual(Local1, Zero))
280 {
281 Return (One) /* Operation not implemented */
282 }
283
284 If (LEqual(Local1, 0x02))
285 {
286 Return (0x03) /* Operation blocked by current firmware settings */
287 }
288
289 If (LEqual(Arg1, One))
290 {
291 Store(Local0, PPRQ)
292 Store(Zero, PPRM)
293 }
294
295 If (LEqual(Arg1, 0x02))
296 {
297 Store(DerefOf(Index(Arg3, One)), Local2) /* Local2 = *Arg3[1] (Arg3 is a Package) */
298
299 Store(Local0, PPRQ)
300 Store(Local2, PPRM)
301 }
302
303 Return (Zero)
304 }
305
306 /**
307 * Get User Confirmation Status for Operation.
308 *
309 * Input is the operation value maybe needing user confirmation
310 * Result:
311 * - 0: Not implemented
312 * - 1: Firmware only
313 * - 2: Blocked for OS by firmware configuration.
314 * - 3: Allowed and physically present user required
315 * - 4: Allowed and physically present user not required.
316 */
317 If (LEqual (Arg2, 0x08))
318 {
319 DBG("_DSM: Get user confirmation status for operation\n")
320
321 Store(DerefOf(Index(Arg3, Zero)), Local0)
322 Store(TPFS(Local0), Local1)
323
324 Return (And(Local1, 0x7))
325 }
326
327 DBG("TPM_DSM: Unknown function\n")
328 Return (Buffer (One) { 0x00 })
329 }
330
331 /**
332 * TCG Platform Reset Attack Mitigation Specification interface.
333 */
334 If (LEqual (Arg0, ToUUID("376054ed-cc13-4675-901c-4756d7f2d45d")))
335 {
336 /**
337 * Standard _DSM query function.
338 */
339 If (LEqual (Arg2, Zero))
340 {
341 Return (Buffer (One) { 0x03 })
342 }
343
344 /**
345 * Set Memory Overwrite Request (MOR) bit to specified value.
346 */
347 If (LEqual (Arg2, One))
348 {
349 /* Memory is always zeroed on reset. */
350 Return (Zero)
351 }
352
353 Return (Buffer (One) { 0x00 })
354 }
355
356 Return (Buffer (One) { 0x00 })
357 }
358 }
359 }
360}
361
362/*
363 * Local Variables:
364 * comment-start: "//"
365 * End:
366 */
367
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use