lkml.org 
[lkml]   [2009]   [Oct]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH 3/4] mce-inject: change msr_to_offset() to mce_get_fake_reg()
    Introduce mce_get_fake_reg() which returns address of variable for
    faked register.

    Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
    ---
    arch/x86/kernel/cpu/mcheck/mce.c | 30 +++++++++++++++---------------
    1 files changed, 15 insertions(+), 15 deletions(-)

    diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
    index 5a6f17d..edd2a82 100644
    --- a/arch/x86/kernel/cpu/mcheck/mce.c
    +++ b/arch/x86/kernel/cpu/mcheck/mce.c
    @@ -301,20 +301,22 @@ static void mce_panic(char *msg, struct mce *final, char *exp)

    /* Support code for software error injection */

    -static int msr_to_offset(u32 msr)
    +static u64 *mce_get_fake_reg(u32 msr)
    {
    unsigned bank = __get_cpu_var(mce_fake_banks).bank;
    +
    if (msr == rip_msr)
    - return offsetof(struct mce_fake_banks, ip);
    + return &__get_cpu_var(mce_fake_banks).ip;
    if (msr == MSR_IA32_MCx_STATUS(bank))
    - return offsetof(struct mce_fake_banks, status);
    + return &__get_cpu_var(mce_fake_banks).status;
    if (msr == MSR_IA32_MCx_ADDR(bank))
    - return offsetof(struct mce_fake_banks, addr);
    + return &__get_cpu_var(mce_fake_banks).addr;
    if (msr == MSR_IA32_MCx_MISC(bank))
    - return offsetof(struct mce_fake_banks, misc);
    + return &__get_cpu_var(mce_fake_banks).misc;
    if (msr == MSR_IA32_MCG_STATUS)
    - return offsetof(struct mce_fake_banks, mcgstatus);
    - return -1;
    + return &__get_cpu_var(mce_fake_banks).mcgstatus;
    +
    + return NULL;
    }

    /* MSR access wrappers used for error injection */
    @@ -323,12 +325,11 @@ static u64 mce_rdmsrl(u32 msr)
    u64 v;

    if (__get_cpu_var(mce_fake_banks).valid) {
    - int offset = msr_to_offset(msr);
    - char *m = (char *)&__get_cpu_var(mce_fake_banks);
    + u64 *reg = mce_get_fake_reg(msr);

    - if (offset < 0)
    + if (!reg)
    return 0;
    - return *(u64 *)(m + offset);
    + return *reg;
    }

    if (rdmsrl_safe(msr, &v)) {
    @@ -347,11 +348,10 @@ static u64 mce_rdmsrl(u32 msr)
    static void mce_wrmsrl(u32 msr, u64 v)
    {
    if (__get_cpu_var(mce_fake_banks).valid) {
    - int offset = msr_to_offset(msr);
    - char *m = (char *)&__get_cpu_var(mce_fake_banks);
    + u64 *reg = mce_get_fake_reg(msr);

    - if (offset >= 0)
    - *(u64 *)(m + offset) = v;
    + if (reg)
    + *reg = v;
    return;
    }
    wrmsrl(msr, v);
    --
    1.6.2.2



    \
     
     \ /
      Last update: 2009-10-09 07:57    [W:0.024 / U:0.516 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site