• R/O
  • HTTP
  • SSH
  • HTTPS

BrynKernel-AOSP: 提交

https://bryn-lab.my.id/kernel.html


Commit MetaInfo

修订版cb3c705cfaec87b0ce197444b113ad3e4cab51a4 (tree)
时间2020-11-19 02:26:31
作者Juergen Gross <jgross@suse...>
CommiterGreg Kroah-Hartman

Log Message

xen/events: use a common cpu hotplug hook for event channels

commit 7beb290caa2adb0a399e735a1e175db9aae0523a upstream.

Today only fifo event channels have a cpu hotplug callback. In order
to prepare for more percpu (de)init work move that callback into
events_base.c and add percpu_init() and percpu_deinit() hooks to
struct evtchn_ops.

This is part of XSA-332.

Cc: stable@vger.kernel.org
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Wei Liu <wl@xen.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

更改概述

差异

--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -33,6 +33,7 @@
3333 #include <linux/irqnr.h>
3434 #include <linux/pci.h>
3535 #include <linux/spinlock.h>
36+#include <linux/cpuhotplug.h>
3637
3738 #ifdef CONFIG_X86
3839 #include <asm/desc.h>
@@ -1833,6 +1834,26 @@ void xen_callback_vector(void) {}
18331834 static bool fifo_events = true;
18341835 module_param(fifo_events, bool, 0);
18351836
1837+static int xen_evtchn_cpu_prepare(unsigned int cpu)
1838+{
1839+ int ret = 0;
1840+
1841+ if (evtchn_ops->percpu_init)
1842+ ret = evtchn_ops->percpu_init(cpu);
1843+
1844+ return ret;
1845+}
1846+
1847+static int xen_evtchn_cpu_dead(unsigned int cpu)
1848+{
1849+ int ret = 0;
1850+
1851+ if (evtchn_ops->percpu_deinit)
1852+ ret = evtchn_ops->percpu_deinit(cpu);
1853+
1854+ return ret;
1855+}
1856+
18361857 void __init xen_init_IRQ(void)
18371858 {
18381859 int ret = -EINVAL;
@@ -1842,6 +1863,10 @@ void __init xen_init_IRQ(void)
18421863 if (ret < 0)
18431864 xen_evtchn_2l_init();
18441865
1866+ cpuhp_setup_state_nocalls(CPUHP_XEN_EVTCHN_PREPARE,
1867+ "CPUHP_XEN_EVTCHN_PREPARE",
1868+ xen_evtchn_cpu_prepare, xen_evtchn_cpu_dead);
1869+
18451870 evtchn_to_irq = kcalloc(EVTCHN_ROW(xen_evtchn_max_channels()),
18461871 sizeof(*evtchn_to_irq), GFP_KERNEL);
18471872 BUG_ON(!evtchn_to_irq);
--- a/drivers/xen/events/events_fifo.c
+++ b/drivers/xen/events/events_fifo.c
@@ -386,21 +386,6 @@ static void evtchn_fifo_resume(void)
386386 event_array_pages = 0;
387387 }
388388
389-static const struct evtchn_ops evtchn_ops_fifo = {
390- .max_channels = evtchn_fifo_max_channels,
391- .nr_channels = evtchn_fifo_nr_channels,
392- .setup = evtchn_fifo_setup,
393- .bind_to_cpu = evtchn_fifo_bind_to_cpu,
394- .clear_pending = evtchn_fifo_clear_pending,
395- .set_pending = evtchn_fifo_set_pending,
396- .is_pending = evtchn_fifo_is_pending,
397- .test_and_set_mask = evtchn_fifo_test_and_set_mask,
398- .mask = evtchn_fifo_mask,
399- .unmask = evtchn_fifo_unmask,
400- .handle_events = evtchn_fifo_handle_events,
401- .resume = evtchn_fifo_resume,
402-};
403-
404389 static int evtchn_fifo_alloc_control_block(unsigned cpu)
405390 {
406391 void *control_block = NULL;
@@ -423,19 +408,36 @@ static int evtchn_fifo_alloc_control_block(unsigned cpu)
423408 return ret;
424409 }
425410
426-static int xen_evtchn_cpu_prepare(unsigned int cpu)
411+static int evtchn_fifo_percpu_init(unsigned int cpu)
427412 {
428413 if (!per_cpu(cpu_control_block, cpu))
429414 return evtchn_fifo_alloc_control_block(cpu);
430415 return 0;
431416 }
432417
433-static int xen_evtchn_cpu_dead(unsigned int cpu)
418+static int evtchn_fifo_percpu_deinit(unsigned int cpu)
434419 {
435420 __evtchn_fifo_handle_events(cpu, true);
436421 return 0;
437422 }
438423
424+static const struct evtchn_ops evtchn_ops_fifo = {
425+ .max_channels = evtchn_fifo_max_channels,
426+ .nr_channels = evtchn_fifo_nr_channels,
427+ .setup = evtchn_fifo_setup,
428+ .bind_to_cpu = evtchn_fifo_bind_to_cpu,
429+ .clear_pending = evtchn_fifo_clear_pending,
430+ .set_pending = evtchn_fifo_set_pending,
431+ .is_pending = evtchn_fifo_is_pending,
432+ .test_and_set_mask = evtchn_fifo_test_and_set_mask,
433+ .mask = evtchn_fifo_mask,
434+ .unmask = evtchn_fifo_unmask,
435+ .handle_events = evtchn_fifo_handle_events,
436+ .resume = evtchn_fifo_resume,
437+ .percpu_init = evtchn_fifo_percpu_init,
438+ .percpu_deinit = evtchn_fifo_percpu_deinit,
439+};
440+
439441 int __init xen_evtchn_fifo_init(void)
440442 {
441443 int cpu = get_cpu();
@@ -449,9 +451,6 @@ int __init xen_evtchn_fifo_init(void)
449451
450452 evtchn_ops = &evtchn_ops_fifo;
451453
452- cpuhp_setup_state_nocalls(CPUHP_XEN_EVTCHN_PREPARE,
453- "CPUHP_XEN_EVTCHN_PREPARE",
454- xen_evtchn_cpu_prepare, xen_evtchn_cpu_dead);
455454 out:
456455 put_cpu();
457456 return ret;
--- a/drivers/xen/events/events_internal.h
+++ b/drivers/xen/events/events_internal.h
@@ -71,6 +71,9 @@ struct evtchn_ops {
7171
7272 void (*handle_events)(unsigned cpu);
7373 void (*resume)(void);
74+
75+ int (*percpu_init)(unsigned int cpu);
76+ int (*percpu_deinit)(unsigned int cpu);
7477 };
7578
7679 extern const struct evtchn_ops *evtchn_ops;
Show on old repository browser