Release 4.14 arch/x86/lib/msr.c
// SPDX-License-Identifier: GPL-2.0
#include <linux/export.h>
#include <linux/percpu.h>
#include <linux/preempt.h>
#include <asm/msr.h>
#define CREATE_TRACE_POINTS
#include <asm/msr-trace.h>
struct msr *msrs_alloc(void)
{
struct msr *msrs = NULL;
msrs = alloc_percpu(struct msr);
if (!msrs) {
pr_warn("%s: error allocating msrs\n", __func__);
return NULL;
}
return msrs;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Borislav Petkov | 44 | 100.00% | 2 | 100.00% |
Total | 44 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL(msrs_alloc);
void msrs_free(struct msr *msrs)
{
free_percpu(msrs);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Borislav Petkov | 15 | 100.00% | 1 | 100.00% |
Total | 15 | 100.00% | 1 | 100.00% |
EXPORT_SYMBOL(msrs_free);
/**
* Read an MSR with error handling
*
* @msr: MSR to read
* @m: value to read into
*
* It returns read data only on success, otherwise it doesn't change the output
* argument @m.
*
*/
int msr_read(u32 msr, struct msr *m)
{
int err;
u64 val;
err = rdmsrl_safe(msr, &val);
if (!err)
m->q = val;
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Borislav Petkov | 43 | 100.00% | 1 | 100.00% |
Total | 43 | 100.00% | 1 | 100.00% |
/**
* Write an MSR with error handling
*
* @msr: MSR to write
* @m: value to write
*/
int msr_write(u32 msr, struct msr *m)
{
return wrmsrl_safe(msr, m->q);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Borislav Petkov | 23 | 100.00% | 1 | 100.00% |
Total | 23 | 100.00% | 1 | 100.00% |
static inline int __flip_bit(u32 msr, u8 bit, bool set)
{
struct msr m, m1;
int err = -EINVAL;
if (bit > 63)
return err;
err = msr_read(msr, &m);
if (err)
return err;
m1 = m;
if (set)
m1.q |= BIT_64(bit);
else
m1.q &= ~BIT_64(bit);
if (m1.q == m.q)
return 0;
err = msr_write(msr, &m1);
if (err)
return err;
return 1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Borislav Petkov | 114 | 99.13% | 1 | 50.00% |
Andres Freund | 1 | 0.87% | 1 | 50.00% |
Total | 115 | 100.00% | 2 | 100.00% |
/**
* Set @bit in a MSR @msr.
*
* Retval:
* < 0: An error was encountered.
* = 0: Bit was already set.
* > 0: Hardware accepted the MSR write.
*/
int msr_set_bit(u32 msr, u8 bit)
{
return __flip_bit(msr, bit, true);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Borislav Petkov | 21 | 100.00% | 1 | 100.00% |
Total | 21 | 100.00% | 1 | 100.00% |
/**
* Clear @bit in a MSR @msr.
*
* Retval:
* < 0: An error was encountered.
* = 0: Bit was already cleared.
* > 0: Hardware accepted the MSR write.
*/
int msr_clear_bit(u32 msr, u8 bit)
{
return __flip_bit(msr, bit, false);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Borislav Petkov | 21 | 100.00% | 1 | 100.00% |
Total | 21 | 100.00% | 1 | 100.00% |
#ifdef CONFIG_TRACEPOINTS
void do_trace_write_msr(unsigned int msr, u64 val, int failed)
{
trace_write_msr(msr, val, failed);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andi Kleen | 23 | 95.83% | 1 | 50.00% |
Borislav Petkov | 1 | 4.17% | 1 | 50.00% |
Total | 24 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL(do_trace_write_msr);
EXPORT_TRACEPOINT_SYMBOL(write_msr);
void do_trace_read_msr(unsigned int msr, u64 val, int failed)
{
trace_read_msr(msr, val, failed);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andi Kleen | 23 | 95.83% | 1 | 50.00% |
Borislav Petkov | 1 | 4.17% | 1 | 50.00% |
Total | 24 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL(do_trace_read_msr);
EXPORT_TRACEPOINT_SYMBOL(read_msr);
void do_trace_rdpmc(unsigned counter, u64 val, int failed)
{
trace_rdpmc(counter, val, failed);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andi Kleen | 23 | 100.00% | 1 | 100.00% |
Total | 23 | 100.00% | 1 | 100.00% |
EXPORT_SYMBOL(do_trace_rdpmc);
EXPORT_TRACEPOINT_SYMBOL(rdpmc);
#endif
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Borislav Petkov | 297 | 70.55% | 3 | 37.50% |
Andi Kleen | 110 | 26.13% | 1 | 12.50% |
Alexey Dobriyan | 8 | 1.90% | 1 | 12.50% |
Paul Gortmaker | 4 | 0.95% | 1 | 12.50% |
Andres Freund | 1 | 0.24% | 1 | 12.50% |
Greg Kroah-Hartman | 1 | 0.24% | 1 | 12.50% |
Total | 421 | 100.00% | 8 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.