irq fixes for 5.6-rc3
Subsystems (4)
Linus,
please pull the latest irq/urgent branch from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq-urgent-2020-02-22
up to: 2546287c5fb3: genirq/irqdomain: Make sure all irq domain flags are distinct
Two fixes for the irq core code which are follow ups to the recent MSI fixes:
- The WARN_ON which was put into the MSI setaffinity callback for paranoia reasons actually triggered via a callchain which escaped when all the possible ways to reach that code were analyzed.
The proc/irq/$N/*affinity interfaces have a quirk which came in when ALPHA moved to the generic interface: In case that the written affinity mask does not contain any online CPU it calls into ALPHAs magic auto affinity setting code.
A few years later this mechanism was also made available to x86 for no good reasons and in a way which circumvents all sanity checks for interrupts which cannot have their affinity set from process context on X86 due to the way the X86 interrupt delivery works.
It would be possible to make this work properly, but there is no point in doing so. If the interrupt is not yet started then the affinity setting has no effect and if it is started already then it is already assigned to an online CPU so there is no point to randomly move it to some other CPU. Just return EINVAL as the code has done before that change forever.
- The new MSI quirk bit in the irq domain flags turned out to be already occupied, which escaped the author and the reviewers because the already in use bits were 0,6,2,3,4,5 listed in that order. That bit 6 was simply overlooked because the ordering was straight forward linear otherwise. So the new bit ended up being a duplicate. Fix it up by switching the oddball 6 to the obvious 1.
Thanks,
tglx
------------------>
Thomas Gleixner (1):
genirq/proc: Reject invalid affinity masks (again)
Zenghui Yu (1):
genirq/irqdomain: Make sure all irq domain flags are distinct
include/linux/irqdomain.h | 2 +- kernel/irq/internals.h | 2 -- kernel/irq/manage.c | 18 ++---------------- kernel/irq/proc.c | 22 ++++++++++++++++++++++ 4 files changed, 25 insertions(+), 19 deletions(-)
include/linux/irqdomain.h +1 -1
@@ -192,7 +192,7 @@ enum {IRQ_DOMAIN_FLAG_HIERARCHY = (1 <<0 ),/* Irq domain name was allocated in __irq_domain_add() */ -IRQ_DOMAIN_NAME_ALLOCATED = (1 <<6 ), +IRQ_DOMAIN_NAME_ALLOCATED = (1 <<1 ),/* Irq domain is an IPI domain with virq per cpu */ IRQ_DOMAIN_FLAG_IPI_PER_CPU = (1 << 2),
kernel/irq/internals.h +0 -2
@@ -128,8 +128,6 @@ static inline void unregister_handler_proc(unsigned int irq,extern bool irq_can_set_affinity_usr (unsigned int irq); -extern int irq_select_affinity_usr (unsigned int irq); -extern void irq_set_thread_affinity (struct irq_desc *desc); extern int irq_do_set_affinity(struct irq_data *data,
kernel/irq/manage.c +2 -16
@@ -481,23 +481,9 @@ int irq_setup_affinity(struct irq_desc *desc) {return irq_select_affinity (irq_desc_get_irq (desc)); } -#endif +#endif /* CONFIG_AUTO_IRQ_AFFINITY */ +#endif /* CONFIG_SMP */ -/* -* Called when a bogus affinity is set via /proc/irq -*/ -int irq_select_affinity_usr (unsigned int irq) -{ -struct irq_desc *desc =irq_to_desc (irq); -unsigned long flags; -int ret; - -raw_spin_lock_irqsave (&desc->lock, flags); - ret =irq_setup_affinity (desc); -raw_spin_unlock_irqrestore (&desc->lock, flags); -return ret; -} -#endif /** * irq_set_vcpu_affinity - Set vcpu affinity for the interrupt
kernel/irq/proc.c +22 -0
@@ -111,6 +111,28 @@ static int irq_affinity_list_proc_show(struct seq_file *m, void *v)return show_irq_affinity (AFFINITY_LIST , m); } +#ifndef CONFIG_AUTO_IRQ_AFFINITY +static inline int irq_select_affinity_usr (unsigned int irq) +{ +/* +* If the interrupt is started up already then this fails. The +* interrupt is assigned to an online CPU already. There is no +* point to move it around randomly. Tell user space that the +* selected mask is bogus. +* +* If not then any change to the affinity is pointless because the +* startup code invokes irq_setup_affinity() which will select +* a online CPU anyway. +*/ +return -EINVAL ; +} +#else +/* ALPHA magic affinity auto selector. Keep it for historical reasons. */ +static inline int irq_select_affinity_usr (unsigned int irq) +{ +return irq_select_affinity (irq); +} +#endif static ssize_t write_irq_affinity (int type,struct file *file,const char __user *buffer,size_t count,loff_t *pos)
[GIT pull] x86 fixes for 5.6-rc3
Linus,
please pull the latest x86/urgent branch from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-urgent-2020-02-22
up to: 21b5ee59ef18: x86/cpu/amd: Enable the fixed Instructions Retired counter IRPERF
Two fixes for x86:
- Remove the __force_oder definiton from the kaslr boot code as it is already defined in the page table code which makes GCC 10 builds fail because it changed the default to -fno-common.
- Address the AMD erratum 1054 concerning the IRPERF capability and enable the Instructions Retired fixed counter on machines which are not affected by the erratum.
Thanks,
tglx
------------------>
H.J. Lu (1):
x86/boot/compressed: Don't declare __force_order in kaslr_64.c
Kim Phillips (1):
x86/cpu/amd: Enable the fixed Instructions Retired counter IRPERF
arch/x86/boot/compressed/kaslr_64.c | 3 --- arch/x86/include/asm/msr-index.h | 2 ++ arch/x86/kernel/cpu/amd.c | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-)
arch/x86/boot/compressed/kaslr_64.c +0 -3
@@ -29,9 +29,6 @@#define __PAGE_OFFSET __PAGE_OFFSET_BASE#include "../../mm/ident_map.c" -/* Used by pgtable.h asm code to force instruction serialization. */ -unsigned long __force_order; -/* Used to track our page table allocation area. */ struct alloc_pgt_data {unsigned char *pgt_buf;
arch/x86/include/asm/msr-index.h +2 -0
@@ -512,6 +512,8 @@#define MSR_K7_HWCR 0xc0010015#define MSR_K7_HWCR_SMMLOCK_BIT 0#define MSR_K7_HWCR_SMMLOCK BIT_ULL(MSR_K7_HWCR_SMMLOCK_BIT) +#define MSR_K7_HWCR_IRPERF_EN_BIT 30 +#define MSR_K7_HWCR_IRPERF_EN BIT_ULL(MSR_K7_HWCR_IRPERF_EN_BIT)#define MSR_K7_FID_VID_CTL 0xc0010041#define MSR_K7_FID_VID_STATUS 0xc0010042
arch/x86/kernel/cpu/amd.c +14 -0
@@ -28,6 +28,7 @@static const int amd_erratum_383[];static const int amd_erratum_400[]; +static const int amd_erratum_1054[];static bool cpu_has_amd_erratum (struct cpuinfo_x86 *cpu,const int *erratum);/*
@@ -972,6 +973,15 @@ static void init_amd(struct cpuinfo_x86 *c)/* AMD CPUs don't reset SS attributes on SYSRET, Xen does. */ if (!cpu_has (c,X86_FEATURE_XENPV ))set_cpu_bug (c,X86_BUG_SYSRET_SS_ATTRS ); + +/* +* Turn on the Instructions Retired free counter on machines not +* susceptible to erratum #1054 "Instructions Retired Performance +* Counter May Be Inaccurate". +*/ +if (cpu_has (c,X86_FEATURE_IRPERF ) && + !cpu_has_amd_erratum (c, amd_erratum_1054)) +msr_set_bit (MSR_K7_HWCR ,MSR_K7_HWCR_IRPERF_EN_BIT ); }#ifdef CONFIG_X86_32
@@ -1099,6 +1109,10 @@ static const int amd_erratum_400[] =static const int amd_erratum_383[] =AMD_OSVW_ERRATUM (3 ,AMD_MODEL_RANGE (0x10 ,0 ,0 ,0xff ,0xf )); +/* #1054: Instructions Retired Performance Counter May Be Inaccurate */ +static const int amd_erratum_1054[] = +AMD_OSVW_ERRATUM (0 ,AMD_MODEL_RANGE (0x17 ,0 ,0 ,0x2f ,0xf )); +static bool cpu_has_amd_erratum (struct cpuinfo_x86 *cpu,const int *erratum) {
Re: [GIT pull] x86 fixes for 5.6-rc3
The pull request you sent on Sat, 22 Feb 2020 21:00:04 -0000:
The pull request you sent on Sat, 22 Feb 2020 21:00:04 -0000:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gitx86-urgent-2020-02-22
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/fca1037864a9fb75c9c48cb65649b24de8101ec4
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
[GIT pull] ras fixes for 5.6-rc3
In reply to Thomas GleixnerLinus,
please pull the latest ras/urgent branch from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git ras-urgent-2020-02-22
up to: 51dede9c05df: x86/mce/amd: Fix kobject lifetime
Two fixes for the AMD MCE driver:
- Populate the per CPU MCA bank descriptor pointer only after it has been completely set up to prevent a use-after-free in case that one of the subsequent initialization step fails
- Implement a proper release function for the sysfs entries of MCA threshold controls instead of freeing the memory right in the CPU teardown code, which leads to another use-after-free when the associated sysfs file is opened and accessed.
Thanks,
tglx
------------------>
Borislav Petkov (1):
x86/mce/amd: Publish the bank pointer only after setup has succeeded
Thomas Gleixner (1):
x86/mce/amd: Fix kobject lifetime
arch/x86/kernel/cpu/mce/amd.c | 50 +++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 23 deletions(-)
arch/x86/kernel/cpu/mce/amd.c +27 -23
@@ -1163,9 +1163,12 @@ static const struct sysfs_ops threshold_ops = { .store = store, }; +static void threshold_block_release (struct kobject *kobj); +static struct kobj_type threshold_ktype = { .sysfs_ops = &threshold_ops, .default_attrs = default_attrs, + .release = threshold_block_release, };static const char *get_name (unsigned int bank,struct threshold_block *b)
@@ -1198,8 +1201,9 @@ static const char *get_name(unsigned int bank, struct threshold_block *b)return buf_mcatype; } -static int allocate_threshold_blocks (unsigned int cpu,unsigned int bank, -unsigned int block,u32 address) +static int allocate_threshold_blocks (unsigned int cpu,struct threshold_bank *tb, +unsigned int bank,unsigned int block, +u32 address) {struct threshold_block *b =NULL ;u32 low, high;
@@ -1243,16 +1247,12 @@ static int allocate_threshold_blocks(unsigned int cpu, unsigned int bank,INIT_LIST_HEAD (&b->miscj); -if (per_cpu (threshold_banks, cpu)[bank]->blocks) { -list_add (&b->miscj, - &per_cpu (threshold_banks, cpu)[bank]->blocks->miscj); - }else { -per_cpu (threshold_banks, cpu)[bank]->blocks = b; - } +if (tb->blocks) +list_add (&b->miscj, &tb->blocks->miscj); +else + tb->blocks = b; - err =kobject_init_and_add (&b->kobj, &threshold_ktype, -per_cpu (threshold_banks, cpu)[bank]->kobj, -get_name (bank, b)); + err =kobject_init_and_add (&b->kobj, &threshold_ktype, tb->kobj,get_name (bank, b));if (err) goto out_free; recurse:
@@ -1260,7 +1260,7 @@ static int allocate_threshold_blocks(unsigned int cpu, unsigned int bank,if (!address)return 0 ; - err =allocate_threshold_blocks (cpu, bank, block, address); + err =allocate_threshold_blocks (cpu, tb, bank, block, address);if (err) goto out_free;
@@ -1345,8 +1345,6 @@ static int threshold_create_bank(unsigned int cpu, unsigned int bank) goto out_free; } -per_cpu (threshold_banks, cpu)[bank] = b; -if (is_shared_bank (bank)) {refcount_set (&b->cpus,1 );
@@ -1357,9 +1355,13 @@ static int threshold_create_bank(unsigned int cpu, unsigned int bank) } } - err =allocate_threshold_blocks (cpu, bank,0 , msr_ops.misc (bank)); -if (!err) - goto out; + err =allocate_threshold_blocks (cpu, b, bank,0 , msr_ops.misc (bank)); +if (err) + goto out_free; + +per_cpu (threshold_banks, cpu)[bank] = b; + +return 0 ; out_free:kfree (b);
@@ -1368,8 +1370,12 @@ static int threshold_create_bank(unsigned int cpu, unsigned int bank)return err; } -static void deallocate_threshold_block (unsigned int cpu, -unsigned int bank) +static void threshold_block_release (struct kobject *kobj) +{ +kfree (to_block (kobj)); +} + +static void deallocate_threshold_block (unsigned int cpu,unsigned int bank) {struct threshold_block *pos =NULL ;struct threshold_block *tmp =NULL ;
@@ -1379,13 +1385,11 @@ static void deallocate_threshold_block(unsigned int cpu,return ;list_for_each_entry_safe (pos, tmp, &head->blocks->miscj, miscj) { -kobject_put (&pos->kobj);list_del (&pos->miscj); -kfree (pos); +kobject_put (&pos->kobj); } -kfree (per_cpu (threshold_banks, cpu)[bank]->blocks); -per_cpu (threshold_banks, cpu)[bank]->blocks =NULL ; +kobject_put (&head->blocks->kobj); }static void __threshold_remove_blocks (struct threshold_bank *b)
Re: [GIT pull] ras fixes for 5.6-rc3
The pull request you sent on Sat, 22 Feb 2020 21:00:04 -0000:
The pull request you sent on Sat, 22 Feb 2020 21:00:04 -0000:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gitras-urgent-2020-02-22
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/dca132a60f226f4cbaa98807518a5ca6cff112ce
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
The pull request you sent on Sat, 22 Feb 2020 21:00:04 -0000:
The pull request you sent on Sat, 22 Feb 2020 21:00:04 -0000:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gitirq-urgent-2020-02-22
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/f3cc24942e955604232e3b4b0dac6a54cbc7c679
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker