Skip to content

Commit

Permalink
Changes representative of linux-3.10.0-1160.99.1.el7.tar.xz
Browse files Browse the repository at this point in the history
  • Loading branch information
da-x committed Aug 10, 2023
1 parent 0124fd4 commit a69a2e3
Show file tree
Hide file tree
Showing 18 changed files with 589 additions and 305 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ EXTRAVERSION =
NAME = Unicycling Gorilla
RHEL_MAJOR = 7
RHEL_MINOR = 9
RHEL_RELEASE = 1160.95.1
RHEL_RELEASE = 1160.99.1

#
# DRM backport version
Expand Down
1 change: 1 addition & 0 deletions arch/x86/include/asm/microcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <asm/cpu.h>
#include <linux/earlycpio.h>
#include <linux/initrd.h>
#include <asm/microcode_amd.h>

#define native_rdmsr(msr, val1, val2) \
do { \
Expand Down
4 changes: 3 additions & 1 deletion arch/x86/include/asm/microcode_amd.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ extern void __init load_ucode_amd_bsp(unsigned int family);
extern void load_ucode_amd_ap(void);
extern int __init save_microcode_in_initrd_amd(void);
void reload_ucode_amd(void);
extern void amd_check_microcode(void);
#else
static inline void __init load_ucode_amd_bsp(unsigned int family) {}
static inline void load_ucode_amd_ap(void) {}
static inline int __init save_microcode_in_initrd_amd(void) { return -EINVAL; }
void reload_ucode_amd(void) {}
static inline void reload_ucode_amd(void) {}
static inline void amd_check_microcode(void) {}
#endif

extern bool check_current_patch_level(u32 *rev, bool early);
Expand Down
8 changes: 6 additions & 2 deletions arch/x86/include/asm/msr-index.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,12 @@
#define MSR_AMD64_OSVW_STATUS 0xc0010141
#define MSR_AMD64_LS_CFG 0xc0011020
#define MSR_AMD64_DC_CFG 0xc0011022

#define MSR_AMD64_DE_CFG 0xc0011029
#define MSR_AMD64_DE_CFG_LFENCE_SERIALIZE_BIT 1
#define MSR_AMD64_DE_CFG_LFENCE_SERIALIZE BIT_ULL(MSR_AMD64_DE_CFG_LFENCE_SERIALIZE_BIT)
#define MSR_AMD64_DE_CFG_ZEN2_FP_BACKUP_FIX_BIT 9

#define MSR_AMD64_BU_CFG2 0xc001102a
#define MSR_AMD64_IBSFETCHCTL 0xc0011030
#define MSR_AMD64_IBSFETCHLINAD 0xc0011031
Expand Down Expand Up @@ -447,8 +453,6 @@
#define FAM10H_MMIO_CONF_BASE_MASK 0xfffffffULL
#define FAM10H_MMIO_CONF_BASE_SHIFT 20
#define MSR_FAM10H_NODE_ID 0xc001100c
#define MSR_F10H_DECFG 0xc0011029
#define MSR_F10H_DECFG_LFENCE_SERIALIZE_BIT 1

/* K8 MSRs */
#define MSR_K8_TOP_MEM1 0xc001001a
Expand Down
197 changes: 126 additions & 71 deletions arch/x86/kernel/cpu/amd.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,74 @@
*/
static u32 nodes_per_socket = 1;

/*
* AMD errata checking
*
* Errata are defined as arrays of ints using the AMD_LEGACY_ERRATUM() or
* AMD_OSVW_ERRATUM() macros. The latter is intended for newer errata that
* have an OSVW id assigned, which it takes as first argument. Both take a
* variable number of family-specific model-stepping ranges created by
* AMD_MODEL_RANGE().
*
* Example:
*
* const int amd_erratum_319[] =
* AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x10, 0x2, 0x1, 0x4, 0x2),
* AMD_MODEL_RANGE(0x10, 0x8, 0x0, 0x8, 0x0),
* AMD_MODEL_RANGE(0x10, 0x9, 0x0, 0x9, 0x0));
*/

#define AMD_LEGACY_ERRATUM(...) { -1, __VA_ARGS__, 0 }
#define AMD_OSVW_ERRATUM(osvw_id, ...) { osvw_id, __VA_ARGS__, 0 }
#define AMD_MODEL_RANGE(f, m_start, s_start, m_end, s_end) \
((f << 24) | (m_start << 16) | (s_start << 12) | (m_end << 4) | (s_end))
#define AMD_MODEL_RANGE_FAMILY(range) (((range) >> 24) & 0xff)
#define AMD_MODEL_RANGE_START(range) (((range) >> 12) & 0xfff)
#define AMD_MODEL_RANGE_END(range) ((range) & 0xfff)

static const int amd_erratum_400[] =
AMD_OSVW_ERRATUM(1, AMD_MODEL_RANGE(0xf, 0x41, 0x2, 0xff, 0xf),
AMD_MODEL_RANGE(0x10, 0x2, 0x1, 0xff, 0xf));

static const int amd_erratum_383[] =
AMD_OSVW_ERRATUM(3, AMD_MODEL_RANGE(0x10, 0, 0, 0xff, 0xf));

static const int amd_zenbleed[] =
AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x17, 0x30, 0x0, 0x4f, 0xf),
AMD_MODEL_RANGE(0x17, 0x60, 0x0, 0x7f, 0xf),
AMD_MODEL_RANGE(0x17, 0xa0, 0x0, 0xaf, 0xf));

static bool cpu_has_amd_erratum(struct cpuinfo_x86 *cpu, const int *erratum)
{
int osvw_id = *erratum++;
u32 range;
u32 ms;

if (osvw_id >= 0 && osvw_id < 65536 &&
cpu_has(cpu, X86_FEATURE_OSVW)) {
u64 osvw_len;

rdmsrl(MSR_AMD64_OSVW_ID_LENGTH, osvw_len);
if (osvw_id < osvw_len) {
u64 osvw_bits;

rdmsrl(MSR_AMD64_OSVW_STATUS + (osvw_id >> 6),
osvw_bits);
return osvw_bits & (1ULL << (osvw_id & 0x3f));
}
}

/* OSVW unavailable or ID unknown, match family-model-stepping range */
ms = (cpu->x86_model << 4) | cpu->x86_mask;
while ((range = *erratum++))
if ((cpu->x86 == AMD_MODEL_RANGE_FAMILY(range)) &&
(ms >= AMD_MODEL_RANGE_START(range)) &&
(ms <= AMD_MODEL_RANGE_END(range)))
return true;

return false;
}

static inline int rdmsrl_amd_safe(unsigned msr, unsigned long long *p)
{
u32 gprs[8] = { 0 };
Expand Down Expand Up @@ -637,10 +705,6 @@ static void early_init_amd(struct cpuinfo_x86 *c)
amd_get_topology_early(c);
}

static const int amd_erratum_383[];
static const int amd_erratum_400[];
static bool cpu_has_amd_erratum(struct cpuinfo_x86 *cpu, const int *erratum);

void init_spectral_chicken(struct cpuinfo_x86 *c)
{
u64 value;
Expand Down Expand Up @@ -689,6 +753,47 @@ static void init_amd_zn(struct cpuinfo_x86 *c)
}
}

static bool cpu_has_zenbleed_microcode(void)
{
u32 good_rev = 0;

switch (boot_cpu_data.x86_model) {
case 0x30 ... 0x3f: good_rev = 0x0830107a; break;
case 0x60 ... 0x67: good_rev = 0x0860010b; break;
case 0x68 ... 0x6f: good_rev = 0x08608105; break;
case 0x70 ... 0x7f: good_rev = 0x08701032; break;
case 0xa0 ... 0xaf: good_rev = 0x08a00008; break;

default:
return false;
break;
}

if (boot_cpu_data.microcode < good_rev)
return false;

return true;
}

static void zenbleed_check(struct cpuinfo_x86 *c)
{
if (!cpu_has_amd_erratum(c, amd_zenbleed))
return;

if (cpu_has(c, X86_FEATURE_HYPERVISOR))
return;

if (!cpu_has(c, X86_FEATURE_AVX))
return;

if (!cpu_has_zenbleed_microcode()) {
pr_notice_once("Zenbleed: please update your microcode for the most optimal fix\n");
msr_set_bit(MSR_AMD64_DE_CFG, MSR_AMD64_DE_CFG_ZEN2_FP_BACKUP_FIX_BIT);
} else {
msr_clear_bit(MSR_AMD64_DE_CFG, MSR_AMD64_DE_CFG_ZEN2_FP_BACKUP_FIX_BIT);
}
}

static void init_amd(struct cpuinfo_x86 *c)
{
unsigned long long value;
Expand Down Expand Up @@ -819,10 +924,10 @@ static void init_amd(struct cpuinfo_x86 *c)
* but msr_set_bit() uses rdmsrl_safe() and wrmsrl_safe().
*/
if (c->x86 > 0xf)
msr_set_bit(MSR_F10H_DECFG,
MSR_F10H_DECFG_LFENCE_SERIALIZE_BIT);
msr_set_bit(MSR_AMD64_DE_CFG,
MSR_AMD64_DE_CFG_LFENCE_SERIALIZE_BIT);

/* LFENCE with MSR_F10H_DECFG[1]=1 stops RDTSC speculation */
/* A serializing LFENCE stops RDTSC speculation */
set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC);
}

Expand Down Expand Up @@ -903,6 +1008,8 @@ static void init_amd(struct cpuinfo_x86 *c)

if (c->x86 == 0x10 || c->x86 == 0x12)
set_cpu_cap(c, X86_FEATURE_IBP_DISABLE);

zenbleed_check(c);
}

#ifdef CONFIG_X86_32
Expand Down Expand Up @@ -1009,70 +1116,6 @@ static const struct cpu_dev amd_cpu_dev = {

cpu_dev_register(amd_cpu_dev);

/*
* AMD errata checking
*
* Errata are defined as arrays of ints using the AMD_LEGACY_ERRATUM() or
* AMD_OSVW_ERRATUM() macros. The latter is intended for newer errata that
* have an OSVW id assigned, which it takes as first argument. Both take a
* variable number of family-specific model-stepping ranges created by
* AMD_MODEL_RANGE().
*
* Example:
*
* const int amd_erratum_319[] =
* AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x10, 0x2, 0x1, 0x4, 0x2),
* AMD_MODEL_RANGE(0x10, 0x8, 0x0, 0x8, 0x0),
* AMD_MODEL_RANGE(0x10, 0x9, 0x0, 0x9, 0x0));
*/

#define AMD_LEGACY_ERRATUM(...) { -1, __VA_ARGS__, 0 }
#define AMD_OSVW_ERRATUM(osvw_id, ...) { osvw_id, __VA_ARGS__, 0 }
#define AMD_MODEL_RANGE(f, m_start, s_start, m_end, s_end) \
((f << 24) | (m_start << 16) | (s_start << 12) | (m_end << 4) | (s_end))
#define AMD_MODEL_RANGE_FAMILY(range) (((range) >> 24) & 0xff)
#define AMD_MODEL_RANGE_START(range) (((range) >> 12) & 0xfff)
#define AMD_MODEL_RANGE_END(range) ((range) & 0xfff)

static const int amd_erratum_400[] =
AMD_OSVW_ERRATUM(1, AMD_MODEL_RANGE(0xf, 0x41, 0x2, 0xff, 0xf),
AMD_MODEL_RANGE(0x10, 0x2, 0x1, 0xff, 0xf));

static const int amd_erratum_383[] =
AMD_OSVW_ERRATUM(3, AMD_MODEL_RANGE(0x10, 0, 0, 0xff, 0xf));


static bool cpu_has_amd_erratum(struct cpuinfo_x86 *cpu, const int *erratum)
{
int osvw_id = *erratum++;
u32 range;
u32 ms;

if (osvw_id >= 0 && osvw_id < 65536 &&
cpu_has(cpu, X86_FEATURE_OSVW)) {
u64 osvw_len;

rdmsrl(MSR_AMD64_OSVW_ID_LENGTH, osvw_len);
if (osvw_id < osvw_len) {
u64 osvw_bits;

rdmsrl(MSR_AMD64_OSVW_STATUS + (osvw_id >> 6),
osvw_bits);
return osvw_bits & (1ULL << (osvw_id & 0x3f));
}
}

/* OSVW unavailable or ID unknown, match family-model-stepping range */
ms = (cpu->x86_model << 4) | cpu->x86_mask;
while ((range = *erratum++))
if ((cpu->x86 == AMD_MODEL_RANGE_FAMILY(range)) &&
(ms >= AMD_MODEL_RANGE_START(range)) &&
(ms <= AMD_MODEL_RANGE_END(range)))
return true;

return false;
}

void set_dr_addr_mask(unsigned long mask, int dr)
{
if (!cpu_has_bpext)
Expand All @@ -1091,3 +1134,15 @@ void set_dr_addr_mask(unsigned long mask, int dr)
break;
}
}

static void zenbleed_check_cpu(void *unused)
{
struct cpuinfo_x86 *c = &cpu_data(smp_processor_id());

zenbleed_check(c);
}

void amd_check_microcode(void)
{
on_each_cpu(zenbleed_check_cpu, NULL, 1);
}
2 changes: 2 additions & 0 deletions arch/x86/kernel/cpu/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1958,4 +1958,6 @@ void cpu_init(void)
void microcode_check(void)
{
perf_check_microcode();

amd_check_microcode();
}
39 changes: 8 additions & 31 deletions fs/gfs2/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,23 +366,17 @@ static __be64 *gfs2_dir_get_hash_table(struct gfs2_inode *ip)

ret = gfs2_dir_read_data(ip, hc, hsize);
if (ret < 0) {
if (is_vmalloc_addr(hc))
vfree(hc);
else
kfree(hc);
kvfree(hc);
return ERR_PTR(ret);
}

spin_lock(&inode->i_lock);
if (ip->i_hash_cache) {
if (is_vmalloc_addr(hc))
vfree(hc);
else
kfree(hc);
} else {
if (likely(!ip->i_hash_cache)) {
ip->i_hash_cache = hc;
hc = NULL;
}
spin_unlock(&inode->i_lock);
kvfree(hc);

return ip->i_hash_cache;
}
Expand All @@ -400,10 +394,7 @@ void gfs2_dir_hash_inval(struct gfs2_inode *ip)
spin_lock(&ip->i_inode.i_lock);
hc = ip->i_hash_cache;
ip->i_hash_cache = NULL;
if (is_vmalloc_addr(hc))
vfree(hc);
else
kfree(hc);
kvfree(hc);
spin_unlock(&ip->i_inode.i_lock);
}

Expand Down Expand Up @@ -1216,10 +1207,7 @@ static int dir_double_exhash(struct gfs2_inode *dip)
gfs2_dinode_out(dip, dibh->b_data);
brelse(dibh);
out_kfree:
if (is_vmalloc_addr(hc2))
vfree(hc2);
else
kfree(hc2);
kvfree(hc2);
return error;
}

Expand Down Expand Up @@ -1355,14 +1343,6 @@ static void *gfs2_alloc_sort_buffer(unsigned size)
return ptr;
}

static void gfs2_free_sort_buffer(void *ptr)
{
if (is_vmalloc_addr(ptr))
vfree(ptr);
else
kfree(ptr);
}

static int gfs2_set_cookies(struct gfs2_sbd *sdp, struct buffer_head *bh,
unsigned leaf_nr, struct gfs2_dirent **darr,
unsigned entries)
Expand Down Expand Up @@ -1493,7 +1473,7 @@ static int gfs2_dir_read_leaf(struct inode *inode, u64 *offset, void *opaque,
for(i = 0; i < leaf; i++)
if (larr[i])
brelse(larr[i]);
gfs2_free_sort_buffer(larr);
kvfree(larr);
out:
return error;
}
Expand Down Expand Up @@ -2097,10 +2077,7 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
gfs2_rlist_free(&rlist);
gfs2_quota_unhold(dip);
out:
if (is_vmalloc_addr(ht))
vfree(ht);
else
kfree(ht);
kvfree(ht);
return error;
}

Expand Down
Loading

0 comments on commit a69a2e3

Please sign in to comment.