forked from torvalds/linux
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
*introduce rd_msr/wr_msr helpers for boot kernel
- Loading branch information
Showing
3 changed files
with
37 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
/* | ||
* Helpers/definitions related to MSR access. | ||
*/ | ||
|
||
#ifndef BOOT_MSR_H | ||
#define BOOT_MSR_H | ||
|
||
#include <asm/shared/msr.h> | ||
|
||
static inline void rd_msr(unsigned int msr, struct msr *m) | ||
{ | ||
asm volatile("rdmsr" : "=a" (m->l), "=d" (m->h) : "c" (msr)); | ||
} | ||
|
||
static inline void wr_msr(unsigned int msr, const struct msr *m) | ||
{ | ||
asm volatile("wrmsr" : : "c" (msr), "a"(m->l), "d" (m->h) : "memory"); | ||
} | ||
|
||
#endif /* BOOT_MSR_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#ifndef _ASM_X86_SHARED_MSR_H | ||
#define _ASM_X86_SHARED_MSR_H | ||
|
||
struct msr { | ||
union { | ||
struct { | ||
u32 l; | ||
u32 h; | ||
}; | ||
u64 q; | ||
}; | ||
}; | ||
|
||
#endif /* _ASM_X86_SHARED_MSR_H */ |