Skip to content
Permalink
Browse files

arch/x86: update msr.h to be safe with CONFIG_X86_LONGMODE

Don't allow inadvertent use of the existing z_x86_msr_read() when
compiled in long mode (CONFIG_X86_LONGMODE) as it won't work.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
  • Loading branch information...
Charles E. Youse authored and nashif committed Jun 28, 2019
1 parent 7f0ab52 commit 15dac5b6ab26ae311d3540f30284e57e29fd2814
Showing with 8 additions and 13 deletions.
  1. +8 −13 include/arch/x86/msr.h
@@ -27,13 +27,11 @@
extern "C" {
#endif

/**
* @brief Write to a model specific register (MSR)
*
* This function is used to write to an MSR.
*
* @return N/A
/*
* z_x86_msr_write() is shared between 32- and 64-bit implementations, but
* due to ABI differences with long return values, z_x86_msr_read() is not.
*/

static inline void z_x86_msr_write(unsigned int msr, u64_t data)
{
u32_t high = data >> 32;
@@ -42,13 +40,8 @@ static inline void z_x86_msr_write(unsigned int msr, u64_t data)
__asm__ volatile ("wrmsr" : : "c"(msr), "a"(low), "d"(high));
}

/**
* @brief Read from a model specific register (MSR)
*
* This function is used to read from an MSR.
*
* @return N/A
*/
#ifndef CONFIG_X86_LONGMODE

static inline u64_t z_x86_msr_read(unsigned int msr)
{
u64_t ret;
@@ -58,6 +51,8 @@ static inline u64_t z_x86_msr_read(unsigned int msr)
return ret;
}

#endif

#ifdef __cplusplus
}
#endif

0 comments on commit 15dac5b

Please sign in to comment.
You can’t perform that action at this time.