brintos

brintos / linux-shallow public Read only

0
0
Text · 679 B · 88fdd2a Raw
41 lines · c
1// SPDX-License-Identifier: GPL-2.02#include <math.h>3#include <unistd.h>4#include <stdio.h>5#include <stdlib.h>6#include <sys/types.h>7#include <sys/stat.h>8#include <fcntl.h>9#include <sys/timeb.h>10#include <sched.h>11#include <errno.h>12 13 14int main(int argc, char **argv) {15	int cpu, fd;16	long long msr;17	char msr_file_name[64];18 19	if (argc != 2)20		return 1;21 22	errno = 0;23	cpu = strtol(argv[1], (char **) NULL, 10);24 25	if (errno)26		return 1;27 28	sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu);29	fd = open(msr_file_name, O_RDONLY);30 31	if (fd == -1) {32		perror("Failed to open");33		return 1;34	}35 36	pread(fd, &msr,  sizeof(msr), 0x199);37 38	printf("msr 0x199: 0x%llx\n", msr);39	return 0;40}41