Skip to content

Commit 4c58356

Browse files
jsun26intellijinxia
authored andcommitted
HV: make cpu state table static const
The hardcoded CPU Px Cx table should be read only, so set them to static and const for safety. Signed-off-by: Victor Sun <victor.sun@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 5d6ce37 commit 4c58356

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

hypervisor/arch/x86/cpu_state_tbl.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <hypervisor.h>
88

99
/* The table includes cpu px info of Intel A3960 SoC */
10-
struct cpu_px_data px_a3960[] = {
10+
static const struct cpu_px_data px_a3960[] = {
1111
{0x960, 0, 0xA, 0xA, 0x1800, 0x1800}, /* P0 */
1212
{0x8FC, 0, 0xA, 0xA, 0x1700, 0x1700}, /* P1 */
1313
{0x898, 0, 0xA, 0xA, 0x1600, 0x1600}, /* P2 */
@@ -28,14 +28,14 @@ struct cpu_px_data px_a3960[] = {
2828
};
2929

3030
/* The table includes cpu cx info of Intel A3960 SoC */
31-
struct cpu_cx_data cx_a3960[] = {
31+
static const struct cpu_cx_data cx_a3960[] = {
3232
{{SPACE_FFixedHW, 0x0, 0, 0, 0}, 0x1, 0x1, 0x3E8}, /* C1 */
3333
{{SPACE_SYSTEM_IO, 0x8, 0, 0, 0x415}, 0x2, 0x32, 0x0A}, /* C2 */
3434
{{SPACE_SYSTEM_IO, 0x8, 0, 0, 0x419}, 0x3, 0x96, 0x0A} /* C3 */
3535
};
3636

3737
/* The table includes cpu px info of Intel A3950 SoC */
38-
struct cpu_px_data px_a3950[] = {
38+
static const struct cpu_px_data px_a3950[] = {
3939
{0x7D0, 0, 0xA, 0xA, 0x1400, 0x1400}, /* P0 */
4040
{0x76C, 0, 0xA, 0xA, 0x1300, 0x1300}, /* P1 */
4141
{0x708, 0, 0xA, 0xA, 0x1200, 0x1200}, /* P2 */
@@ -52,7 +52,7 @@ struct cpu_px_data px_a3950[] = {
5252
};
5353

5454
/* The table includes cpu px info of Intel J3455 SoC */
55-
struct cpu_px_data px_j3455[] = {
55+
static const struct cpu_px_data px_j3455[] = {
5656
{0x5DD, 0, 0xA, 0xA, 0x1700, 0x1700}, /* P0 */
5757
{0x5DC, 0, 0xA, 0xA, 0x0F00, 0x0F00}, /* P1 */
5858
{0x578, 0, 0xA, 0xA, 0x0E00, 0x0E00}, /* P2 */
@@ -65,13 +65,13 @@ struct cpu_px_data px_j3455[] = {
6565
};
6666

6767
/* The table includes cpu cx info of Intel J3455 SoC */
68-
struct cpu_cx_data cx_j3455[] = {
68+
static const struct cpu_cx_data cx_j3455[] = {
6969
{{SPACE_FFixedHW, 0x1, 0x2, 0x1, 0x01}, 0x1, 0x1, 0x3E8}, /* C1 */
7070
{{SPACE_FFixedHW, 0x1, 0x2, 0x1, 0x21}, 0x2, 0x32, 0x0A}, /* C2 */
7171
{{SPACE_FFixedHW, 0x1, 0x2, 0x1, 0x60}, 0x3, 0x96, 0x0A} /* C3 */
7272
};
7373

74-
struct cpu_state_table {
74+
static const struct cpu_state_table {
7575
char model_name[64];
7676
struct cpu_state_info state_info;
7777
} cpu_state_tbl[] = {
@@ -111,7 +111,7 @@ static int get_state_tbl_idx(char *cpuname)
111111
void load_cpu_state_data(void)
112112
{
113113
int tbl_idx;
114-
struct cpu_state_info *state_info;
114+
const struct cpu_state_info *state_info;
115115

116116
memset(&boot_cpu_data.state_info, 0,
117117
sizeof(struct cpu_state_info));

hypervisor/include/arch/x86/cpu.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,10 @@ enum feature_word {
213213
};
214214

215215
struct cpu_state_info {
216-
uint8_t px_cnt; /* count of all Px states */
217-
struct cpu_px_data *px_data;
218-
uint8_t cx_cnt; /* count of all Cx entries */
219-
struct cpu_cx_data *cx_data;
216+
uint8_t px_cnt; /* count of all Px states */
217+
const struct cpu_px_data *px_data;
218+
uint8_t cx_cnt; /* count of all Cx entries */
219+
const struct cpu_cx_data *cx_data;
220220
};
221221

222222
struct cpuinfo_x86 {

0 commit comments

Comments
 (0)