1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/include/usr/secureboot/header.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2013,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
/* you may not use this file except in compliance with the License. */
/* You may obtain a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
/* implied. See the License for the specific language governing */
/* permissions and limitations under the License. */
/* */
/* IBM_PROLOG_END_TAG */
#ifndef __SECUREBOOT_HEADER_H
#define __SECUREBOOT_HEADER_H
#include <stdint.h>
#include <pnor/pnorif.H>
#include <util/singleton.H>
/** @file header.H
*
* @brief Class for manipulating the base image (HBB) secureboot header.
*/
namespace SECUREBOOT
{
/** @class Header
* @brief Class for storing the base image (HBB) header for later use.
*/
class Header
{
public:
/**
* @brief Build a base image (HBB) header object
*/
Header()
: iv_data(NULL)
{
}
/**
* @brief Destroy a base image (HBB) header object, including any
* cached header page
*/
~Header()
{
free(const_cast<void*>(iv_data));
iv_data=NULL;
}
// @TODO RTC 178520 Converge to single method of reading
// secure header
/**
* @brief Extracts base image (HBB) header (ECC removed) from
* security area preserved across the bootloader to HBB
* handoff to support extending HBB measurements to TPM in
* secure mode.
*
* @warning Asserts if header is already cached (code bug)
*/
void loadSecurely();
// @TODO RTC 178520 Converge to single method of reading
// secure header
/**
* @brief Caches non-secure PNOR copy of the base image (HBB)
* header (ECC removed) to support extending HBB measurements
* to TPM in non-secure mode.
*
* @param[in] i_pHeader Pointer to non-secure 4k HBB header
* extracted from PNOR.
*
* @warning Carries all the same warnings as _set
*/
void setNonSecurely(
const void* i_pHeader);
/**
* @brief Return pointer to base image (HBB) header.
*
* @par Detailed Description:
* During boot, SBE copies the boot loader (HBBL) into the cache
* and hands off control to it. The boot loader then loads the
* base image (HBB), including its secure header. After
* verifying HBB, the boot loader copies hostboot to the trusted
* memory location and passes control to HBB, which locates and
* preserves the secure header (among other things) before
* initializing the other non-preserved areas of the cache. In
* secure mode, HBB then initializes this header object with the
* preserved secure header.
*
* In non-secure mode, Hostboot pulls the header from PNOR and
* and writes it into this object.
*
* This API then returns the addresses of the cached header.
*
* @param[out] o_pHeader Pointer to HBB header
*
* @warning Asserts if HBB header not loaded (code bug)
*/
void getHeader(
const void*& o_pHeader) const;
private:
/**
* @brief Populate the base image (HBB) header (ECC removed)
* to support extending HBB measurements to TPM
*
* @param[in] i_pHeader Pointer to 4k HBB header
*
* @warning Asserts if input pointer is NULL (code bug)
* @warning Asserts if header already cached (code bug)
* @warning Memory violation if buffer data is less than 4k in size
* (code bug)
* @warning Ignores buffer data beyond 4k in size
*/
void _set(
const void* i_pHeader);
// Pointer to copy of the base image's (HBB's) secureboot header
const void* iv_data;
// Don't allow copies / assignments
Header(const Header& that);
Header& operator=(const Header&);
};
/**
* @brief Returns the base image (HBB) header singleton
*
* @return Header Reference to base image (HBB) header object
*/
Header& baseHeader();
};
#endif
|