From 6b09bceb66828daed2c1fcc8b3c6fae56ce1d147 Mon Sep 17 00:00:00 2001 From: Veselin Georgiev Date: Sat, 17 Oct 2015 02:53:38 +0300 Subject: [PATCH] Implement cpu_msr_driver_open_core() on Mac OS X and Windows (dummies). On Windows, we don't have the API that Linux provides, which can be used to query MSRs of particular CPU cores. However, the same behaviour can be emulated. Say that the driver handle object also stores 'dedicated thread index'. When you call 'cpu_msr_driver_open()', this index is set to -1, so further API functions do not force which core should be executing RDMSR code. I.e. "I don't care on which core I run". However, if this is non-negative number, the subsequent functions like cpu_rdmsr() are forced to pass through this core by using temporary affinity mask. --- libcpuid/rdmsr.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libcpuid/rdmsr.c b/libcpuid/rdmsr.c index 4aadf1b..ebc9222 100644 --- a/libcpuid/rdmsr.c +++ b/libcpuid/rdmsr.c @@ -42,6 +42,12 @@ struct msr_driver_t* cpu_msr_driver_open(void) return NULL; } +struct msr_driver_t* cpu_msr_driver_open_core(int core_num) +{ + set_error(ERR_NOT_IMP); + return NULL; +} + int cpu_rdmsr(struct msr_driver_t* driver, int msr_index, uint64_t* result) { return set_error(ERR_NOT_IMP); @@ -176,6 +182,12 @@ struct msr_driver_t* cpu_msr_driver_open(void) return drv; } +struct msr_driver_t* cpu_msr_driver_open_core(int core_num) +{ + warnf(1, "cpu_msr_driver_open_core(): parameter ignored (function is the same as cpu_msr_driver_open)\n"); + return cpu_msr_driver_open(); +} + typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); static BOOL is_running_x64(void) {