-
Notifications
You must be signed in to change notification settings - Fork 129
/
rdmsr.h
32 lines (25 loc) · 1.02 KB
/
rdmsr.h
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
///////////////////////////////////////////////////////////////////////////////
// rdmsr.h - 2023
//
/// This module contains Linux-specific, privlidged code (wants to run as root)
/// that utilizes the RDMSR instruction by reading from /dev/cpu/0/msr to
/// discover & report SGX additional capabilities.
///
/// @file rdmsr.h
/// @author Mark Nelson <[email protected]>
///////////////////////////////////////////////////////////////////////////////
#pragma once
#include <stdbool.h> // For bool
#include <inttypes.h> // For PRIx64 uint64_t
#define IA32_FEATURE_CONTROL 0x03A
#define IA32_SGXLEPUBKEYHASH0 0x08C
#define IA32_SGX_SVN_STATUS 0x500
#define MSR_SGXOWNEREPOCH0 0x300
#define IA32_XSS 0xda0
/// On Linux, return true if we are running as root (with CAP_SYS_ADMIN). In
/// all other situations, return false.
bool checkCapabilities( void );
/// Read an MSR on a CPU
bool rdmsr( uint32_t reg, int cpu, uint64_t* pData );
/// Read and print SGX-specific MSRs on a CPU
void read_SGX_MSRs( void );