MCPcopy Create free account
hub / github.com/coreboot/coreboot / rdmsr_from_cpu

Function rdmsr_from_cpu

util/amdtool/cpu.c:124–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124static msr_t rdmsr_from_cpu(int cpu, unsigned long addr)
125{
126 int fd;
127 msr_t msr = { 0xffffffff, 0xffffffff };
128 uint32_t buf[2];
129 char temp_string[50];
130
131 if (open_and_seek(cpu, addr, O_RDONLY, &fd) < 0) {
132 snprintf(temp_string, sizeof(temp_string),
133 "Could not read MSR for CPU#%d", cpu);
134 perror(temp_string);
135 }
136
137 if (read(fd, buf, 8) == 8) {
138 msr.lo = buf[0];
139 msr.hi = buf[1];
140 }
141
142 close(fd);
143
144 return msr;
145}
146
147static int get_number_of_cpus(void)
148{

Callers 3

is_sme_enabledFunction · 0.70
is_sme_hmk_enabledFunction · 0.70
is_sev_snp_enabledFunction · 0.70

Calls 4

perrorFunction · 0.85
readFunction · 0.85
open_and_seekFunction · 0.70
snprintfFunction · 0.50

Tested by

no test coverage detected