Skip to content

Commit 5aea44d

Browse files
committed
AMD DRTM: Add drivier for AMD's PSP to facilitate DRTM
Add a driver to communicate with AMD's PSP. Add functions to perform the following tasks in the DRTM sequence: - Get Capability - Launch - Extend OSSL digest In addition, it adds miscellaneous functions to discover the PSP, issue commands to it, and process response. Signed-off-by: Jagannathan Raman <[email protected]>
1 parent b8f79e1 commit 5aea44d

File tree

3 files changed

+496
-0
lines changed

3 files changed

+496
-0
lines changed

include/pci.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
#define PCI_CONFIG_ADDR_PORT (0x0cf8)
2626
#define PCI_CONFIG_DATA_PORT (0x0cfc)
2727

28+
#define PCI_BUSMAX 255
29+
#define PCI_SLOTMAX 32
30+
#define PCI_FUNCMAX 8
31+
2832
#define PCI_CAPABILITY_LIST 0x34 /* Offset of first capability list entry */
2933

3034
/* PCI capability ID for IOMMU and SVM DEV - AMD Manual */

include/psp.h

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
* Copyright (c) 2022, Oracle and/or its affiliates.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
*
8+
* * Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* * Redistributions in binary form must reproduce the above
11+
* copyright notice, this list of conditions and the following
12+
* disclaimer in the documentation and/or other materials provided
13+
* with the distribution.
14+
* * Neither the name of the Intel Corporation nor the names of its
15+
* contributors may be used to endorse or promote products derived
16+
* from this software without specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29+
* OF THE POSSIBILITY OF SUCH DAMAGE.
30+
*
31+
*/
32+
33+
#ifndef __SKINIT_PSP_H__
34+
#define __SKINIT_PSP_H__
35+
36+
#ifdef AMDSL
37+
38+
#include <stdbool.h>
39+
40+
#define DRTM_MBOX_READY_MASK 0x80000000
41+
#define DRTM_MBOX_TMR_INDEX_ID_MASK 0x0F000000
42+
#define DRTM_MBOX_CMD_MASK 0x00FF0000
43+
#define DRTM_MBOX_STATUS_MASK 0x0000FFFF
44+
45+
#define DRTM_MBOX_CMD_SHIFT 16
46+
47+
#define DRTM_NO_ERROR 0x00000000
48+
#define DRTM_NOT_SUPPORTED 0x00000001
49+
#define DRTM_LAUNCH_ERROR 0x00000002
50+
#define DRTM_TMR_SETUP_FAILED_ERROR 0x00000003
51+
#define DRTM_TMR_DESTROY_FAILED_ERROR 0x00000004
52+
#define DRTM_GET_TCG_LOGS_FAILED_ERROR 0x00000007
53+
#define DRTM_OUT_OF_RESOURCES_ERROR 0x00000008
54+
#define DRTM_GENERIC_ERROR 0x00000009
55+
#define DRTM_INVALID_SERVICE_ID_ERROR 0x0000000A
56+
#define DRTM_MEMORY_UNALIGNED_ERROR 0x0000000B
57+
#define DRTM_MINIMUM_SIZE_ERROR 0x0000000C
58+
#define DRTM_GET_TMR_DESCRIPTOR_FAILED 0x0000000D
59+
#define DRTM_EXTEND_OSSL_DIGEST_FAILED 0x0000000E
60+
#define DRTM_SETUP_NOT_ALLOWED 0x0000000F
61+
#define DRTM_GET_IVRS_TABLE_FAILED 0x00000010
62+
63+
#define DRTM_CMD_GET_CAPABILITY 0x1
64+
#define DRTM_CMD_TMR_SETUP 0x2
65+
#define DRTM_CMD_TMR_RELEASE 0x3
66+
#define DRTM_CMD_LAUNCH 0x4
67+
#define DRTM_CMD_GET_TCG_LOGS 0x7
68+
#define DRTM_CMD_TPM_LOCALITY_ACCESS 0x8
69+
#define DRTM_CMD_GET_TMR_DESCRIPTORS 0x9
70+
#define DRTM_CMD_ALLOCATE_SHARED_MEMORY 0xA
71+
#define DRTM_CMD_EXTEND_OSSL_DIGEST 0xB
72+
#define DRTM_CMD_GET_IVRS_TABLE_INFO 0xC
73+
74+
#define DRTM_TMR_INDEX_0 0
75+
#define DRTM_TMR_INDEX_1 1
76+
#define DRTM_TMR_INDEX_2 2
77+
#define DRTM_TMR_INDEX_3 3
78+
#define DRTM_TMR_INDEX_4 4
79+
#define DRTM_TMR_INDEX_5 5
80+
#define DRTM_TMR_INDEX_6 6
81+
#define DRTM_TMR_INDEX_7 7
82+
83+
#define DRTM_CMD_READY 0
84+
#define DRTM_RESPONSE_READY 1
85+
86+
bool discover_psp(void);
87+
88+
bool drtm_extend_ossl_digest(u64 addr, u64 size);
89+
90+
bool drtm_launch(void);
91+
92+
bool drtm_get_cap(void);
93+
94+
#endif /* AMDSL */
95+
96+
#endif /* __SKINIT_PSP_H__ */

0 commit comments

Comments
 (0)