• Yazen Ghannam's avatar
    x86/MCE: Make mce_banks a per-CPU array · b4914508
    Yazen Ghannam authored
    
    
    Current AMD systems have unique MCA banks per logical CPU even though
    the type of the banks may all align to the same bank number. Each CPU
    will have control of a set of MCA banks in the hardware and these are
    not shared with other CPUs.
    
    For example, bank 0 may be the Load-Store Unit on every logical CPU, but
    each bank 0 is a unique structure in the hardware. In other words, there
    isn't a *single* Load-Store Unit at MCA bank 0 that all logical CPUs
    share.
    
    This idea extends even to non-core MCA banks. For example, CPU0 and CPU4
    may see a Unified Memory Controller at bank 15, but each CPU is actually
    seeing a unique hardware structure that is not shared with other CPUs.
    
    Because the MCA banks are all unique hardware structures, it would be
    good to control them in a more granular way. For example, if there is a
    known issue with the Floating Point Unit on CPU5 and a user wishes to
    disable an error type on the Floating Point Unit, then it would be good
    to do this only for CPU5 rather than all CPUs.
    
    Also, future AMD systems may have heterogeneous MCA banks. Meaning
    the bank numbers may not necessarily represent the same types between
    CPUs. For example, bank 20 visible to CPU0 may be a Unified Memory
    Controller and bank 20 visible to CPU4 may be a Coherent Slave. So
    granular control will be even more necessary should the user wish to
    control specific MCA banks.
    
    Split the device attributes from struct mce_bank leaving only the MCA
    bank control fields.
    
    Make struct mce_banks[] per_cpu in order to have more granular control
    over individual MCA banks in the hardware.
    
    Allocate the device attributes statically based on the maximum number of
    MCA banks supported. The sysfs interface will use as many as needed per
    CPU. Currently, this is set to mca_cfg.banks, but will be changed to a
    per_cpu bank count in a future patch.
    
    Allocate the MCA control bits statically. This is in order to avoid
    locking warnings when memory is allocated during secondary CPUs' init
    sequences.
    
    Also, remove the now unnecessary return values from
    __mcheck_cpu_mce_banks_init() and __mcheck_cpu_cap_init().
    
    Redo the sysfs store/show functions to handle the per_cpu mce_banks[].
    
     [ bp: s/mce_banks_percpu/mce_banks_array/g ]
    
    [ Locking issue reported by ]
    Reported-by: default avatarkernel test robot <rong.a.chen@intel.com>
    Signed-off-by: default avatarYazen Ghannam <yazen.ghannam@amd.com>
    Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: "linux-edac@vger.kernel.org" <linux-edac@vger.kernel.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Tony Luck <tony.luck@intel.com>
    Cc: "x86@kernel.org" <x86@kernel.org>
    Link: https://lkml.kernel.org/r/20190607201752.221446-3-Yazen.Ghannam@amd.com
    b4914508
core.c 57.5 KB