Skip to content

Commit

Permalink
*introduce rd_msr/wr_msr helpers for boot kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
mdroth committed Feb 2, 2022
1 parent 207737b commit 982c6c5
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
21 changes: 21 additions & 0 deletions arch/x86/boot/msr.h
@@ -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 */
11 changes: 1 addition & 10 deletions arch/x86/include/asm/msr.h
Expand Up @@ -10,16 +10,7 @@
#include <asm/errno.h>
#include <asm/cpumask.h>
#include <uapi/asm/msr.h>

struct msr {
union {
struct {
u32 l;
u32 h;
};
u64 q;
};
};
#include <asm/shared/msr.h>

struct msr_info {
u32 msr_no;
Expand Down
15 changes: 15 additions & 0 deletions arch/x86/include/asm/shared/msr.h
@@ -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 */

0 comments on commit 982c6c5

Please sign in to comment.