History

Merge tag 'for-linus-6.11-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip

Pull xen updates from Juergen Gross: - some trivial cleanups - a fix for the Xen timer - add boot time selectable debug capability to the Xen multicall handling - two fixes for the recently added Xen irqfd handling * tag 'for-linus-6.11-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: x86/xen: remove deprecated xen_nopvspin boot parameter x86/xen: eliminate some private header files x86/xen: make some functions static xen: make multicall debug boot time selectable xen/arm: Convert comma to semicolon xen: privcmd: Fix possible access to a freed kirqfd instance xen: privcmd: Switch from mutex to spinlock for irqfds xen: add missing MODULE_DESCRIPTION() macros x86/xen: Convert comma to semicolon x86/xen/time: Reduce Xen timer tick xen/manage: Constify struct shutdown_handler

Linus Torvalds committed 2 years ago

Commit f83e38f2 parents e55037c 9fe6a8c33 files · +305 −276Browse files

Unified · Split

33 files
  1. Documentation/admin-guide/kernel-parameters.txt +6 −5
  2. arch/arm/xen/p2m.c +1 −1
  3. arch/x86/xen/apic.c +0 −2
  4. arch/x86/xen/debugfs.c +1 −1
  5. arch/x86/xen/debugfs.h +0 −7
  6. arch/x86/xen/enlighten.c +0 −2
  7. arch/x86/xen/enlighten_hvm.c +0 −2
  8. arch/x86/xen/enlighten_pv.c +0 −4
  9. arch/x86/xen/mmu.c +1 −2
  10. arch/x86/xen/mmu.h +0 −28
  11. arch/x86/xen/mmu_hvm.c +1 −1
  12. arch/x86/xen/mmu_pv.c +7 −8
  13. arch/x86/xen/multicalls.c +103 −25
  14. arch/x86/xen/multicalls.h +0 −69
  15. arch/x86/xen/p2m.c +2 −4
  16. arch/x86/xen/pmu.c +0 −1
  17. arch/x86/xen/pmu.h +0 −22
  18. arch/x86/xen/setup.c +0 −1
  19. arch/x86/xen/smp.c +0 −1
  20. arch/x86/xen/smp.h +0 −51
  21. arch/x86/xen/smp_hvm.c +0 −2
  22. arch/x86/xen/smp_pv.c +0 −3
  23. arch/x86/xen/spinlock.c +5 −15
  24. arch/x86/xen/suspend.c +0 −2
  25. arch/x86/xen/time.c +1 −1
  26. arch/x86/xen/xen-ops.h +145 −3
  27. drivers/xen/evtchn.c +1 −0
  28. drivers/xen/manage.c +1 −1
  29. drivers/xen/privcmd-buf.c +1 −0
  30. drivers/xen/privcmd.c +25 −11
  31. drivers/xen/xen-pciback/pci_stub.c +1 −0
  32. include/xen/events.h +2 −0
  33. kernel/locking/qspinlock.c +1 −1
Documentation/admin-guide/kernel-parameters.txt+6−5
@@ -7420,17 +7420,18 @@ · 7419 unmodified lines
74207420 Crash from Xen panic notifier, without executing late
74217421 panic() code such as dumping handler.
74227422
7423+ xen_mc_debug [X86,XEN,EARLY]
7424+ Enable multicall debugging when running as a Xen PV guest.
7425+ Enabling this feature will reduce performance a little
7426+ bit, so it should only be enabled for obtaining extended
7427+ debug data in case of multicall errors.
7428+
74237429 xen_msr_safe= [X86,XEN,EARLY]
74247430 Format: <bool>
74257431 Select whether to always use non-faulting (safe) MSR
74267432 access functions when running as Xen PV guest. The
74277433 default value is controlled by CONFIG_XEN_PV_MSR_SAFE.
74287434
7429− xen_nopvspin [X86,XEN,EARLY]
7430− Disables the qspinlock slowpath using Xen PV optimizations.
7431− This parameter is obsoleted by "nopvspin" parameter, which
7432− has equivalent effect for XEN platform.
7433−
74347435 xen_nopv [X86]
74357436 Disables the PV optimizations forcing the HVM guest to
74367437 run as generic HVM guest with no PV drivers.
arch/arm/xen/p2m.c+1−1
@@ -109,7 +109,7 @@ int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops, · 108 unmodified lines
109109 * immediate unmapping.
110110 */
111111 map_ops[i].status = GNTST_general_error;
112− unmap.host_addr = map_ops[i].host_addr,
112+ unmap.host_addr = map_ops[i].host_addr;
113113 unmap.handle = map_ops[i].handle;
114114 map_ops[i].handle = INVALID_GRANT_HANDLE;
115115 if (map_ops[i].flags & GNTMAP_device_map)
arch/x86/xen/apic.c+0−2
@@ -10,8 +10,6 @@ · 9 unmodified lines
1010 #include <xen/xen.h>
1111 #include <xen/interface/physdev.h>
1212 #include "xen-ops.h"
13−#include "pmu.h"
14−#include "smp.h"
1513
1614 static unsigned int xen_io_apic_read(unsigned apic, unsigned reg)
1715 {
arch/x86/xen/debugfs.c+1−1
@@ -3,7 +3,7 @@ · 2 unmodified lines
33 #include <linux/debugfs.h>
44 #include <linux/slab.h>
55
6−#include "debugfs.h"
6+#include "xen-ops.h"
77
88 static struct dentry *d_xen_debug;
99
arch/x86/xen/debugfs.h+0−7
@@ -1,7 +0,0 @@
1−/* SPDX-License-Identifier: GPL-2.0 */
2−#ifndef _XEN_DEBUGFS_H
3−#define _XEN_DEBUGFS_H
4−
5−struct dentry * __init xen_init_debugfs(void);
6−
7−#endif /* _XEN_DEBUGFS_H */
arch/x86/xen/enlighten.c+0−2
@@ -20,8 +20,6 @@ · 19 unmodified lines
2020 #include <asm/setup.h>
2121
2222 #include "xen-ops.h"
23−#include "smp.h"
24−#include "pmu.h"
2523
2624 EXPORT_SYMBOL_GPL(hypercall_page);
2725
arch/x86/xen/enlighten_hvm.c+0−2
@@ -28,8 +28,6 @@ · 27 unmodified lines
2828 #include <asm/xen/page.h>
2929
3030 #include "xen-ops.h"
31−#include "mmu.h"
32−#include "smp.h"
3331
3432 static unsigned long shared_info_pfn;
3533
arch/x86/xen/enlighten_pv.c+0−4
@@ -85,10 +85,6 @@ · 84 unmodified lines
8585 #endif
8686
8787 #include "xen-ops.h"
88−#include "mmu.h"
89−#include "smp.h"
90−#include "multicalls.h"
91−#include "pmu.h"
9288
9389 #include "../kernel/cpu/cpu.h" /* get_cpu_cap() */
9490
arch/x86/xen/mmu.c+1−2
@@ -5,8 +5,7 @@ · 4 unmodified lines
55 #include <asm/xen/hypercall.h>
66 #include <xen/interface/memory.h>
77
8−#include "multicalls.h"
9−#include "mmu.h"
8+#include "xen-ops.h"
109
1110 unsigned long arbitrary_virt_to_mfn(void *vaddr)
1211 {
arch/x86/xen/mmu.h+0−28
@@ -1,28 +0,0 @@
1−/* SPDX-License-Identifier: GPL-2.0 */
2−#ifndef _XEN_MMU_H
3−
4−#include <linux/linkage.h>
5−#include <asm/page.h>
6−
7−enum pt_level {
8− PT_PGD,
9− PT_P4D,
10− PT_PUD,
11− PT_PMD,
12− PT_PTE
13−};
14−
15−
16−bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn);
17−
18−void set_pte_mfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags);
19−
20−pte_t xen_ptep_modify_prot_start(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep);
21−void xen_ptep_modify_prot_commit(struct vm_area_struct *vma, unsigned long addr,
22− pte_t *ptep, pte_t pte);
23−
24−unsigned long xen_read_cr2_direct(void);
25−
26−extern void xen_init_mmu_ops(void);
27−extern void xen_hvm_init_mmu_ops(void);
28−#endif /* _XEN_MMU_H */
arch/x86/xen/mmu_hvm.c+1−1
@@ -5,7 +5,7 @@ · 4 unmodified lines
55 #include <xen/interface/xen.h>
66 #include <xen/hvm.h>
77
8−#include "mmu.h"
8+#include "xen-ops.h"
99
1010 #ifdef CONFIG_PROC_VMCORE
1111 /*
arch/x86/xen/mmu_pv.c+7−8
@@ -82,9 +82,7 @@ · 81 unmodified lines
8282 #include <xen/hvc-console.h>
8383 #include <xen/swiotlb-xen.h>
8484
85−#include "multicalls.h"
86−#include "mmu.h"
87−#include "debugfs.h"
85+#include "xen-ops.h"
8886
8987 /*
9088 * Prototypes for functions called via PV_CALLEE_SAVE_REGS_THUNK() in order
@@ -128,7 +126,7 @@ static DEFINE_SPINLOCK(xen_reservation_lock); · 37 unmodified lines
128126 * looking at another vcpu's cr3 value, it should use this variable.
129127 */
130128 DEFINE_PER_CPU(unsigned long, xen_cr3); /* cr3 stored as physaddr */
131−DEFINE_PER_CPU(unsigned long, xen_current_cr3); /* actual vcpu cr3 */
129+static DEFINE_PER_CPU(unsigned long, xen_current_cr3); /* actual vcpu cr3 */
132130
133131 static phys_addr_t xen_pt_base, xen_pt_size __initdata;
134132
@@ -305,16 +303,17 @@ static void xen_set_pte(pte_t *ptep, pte_t pteval) · 170 unmodified lines
305303 __xen_set_pte(ptep, pteval);
306304 }
307305
308−pte_t xen_ptep_modify_prot_start(struct vm_area_struct *vma,
309− unsigned long addr, pte_t *ptep)
306+static pte_t xen_ptep_modify_prot_start(struct vm_area_struct *vma,
307+ unsigned long addr, pte_t *ptep)
310308 {
311309 /* Just return the pte as-is. We preserve the bits on commit */
312310 trace_xen_mmu_ptep_modify_prot_start(vma->vm_mm, addr, ptep, *ptep);
313311 return *ptep;
314312 }
315313
316−void xen_ptep_modify_prot_commit(struct vm_area_struct *vma, unsigned long addr,
317− pte_t *ptep, pte_t pte)
314+static void xen_ptep_modify_prot_commit(struct vm_area_struct *vma,
315+ unsigned long addr,
316+ pte_t *ptep, pte_t pte)
318317 {
319318 struct mmu_update u;
320319
arch/x86/xen/multicalls.c+103−25
@@ -23,26 +23,21 @@ · 22 unmodified lines
2323 #include <linux/percpu.h>
2424 #include <linux/hardirq.h>
2525 #include <linux/debugfs.h>
26+#include <linux/jump_label.h>
27+#include <linux/printk.h>
2628
2729 #include <asm/xen/hypercall.h>
2830
29−#include "multicalls.h"
30−#include "debugfs.h"
31+#include "xen-ops.h"
3132
3233 #define MC_BATCH 32
3334
34−#define MC_DEBUG 0
35−
3635 #define MC_ARGS (MC_BATCH * 16)
3736
3837
3938 struct mc_buffer {
4039 unsigned mcidx, argidx, cbidx;
4140 struct multicall_entry entries[MC_BATCH];
42−#if MC_DEBUG
43− struct multicall_entry debug[MC_BATCH];
44− void *caller[MC_BATCH];
45−#endif
4641 unsigned char args[MC_ARGS];
4742 struct callback {
4843 void (*fn)(void *);
@@ -50,13 +45,98 @@ struct mc_buffer { · 1 unmodified line
5045 } callbacks[MC_BATCH];
5146 };
5247
48+struct mc_debug_data {
49+ struct multicall_entry entries[MC_BATCH];
50+ void *caller[MC_BATCH];
51+ size_t argsz[MC_BATCH];
52+ unsigned long *args[MC_BATCH];
53+};
54+
5355 static DEFINE_PER_CPU(struct mc_buffer, mc_buffer);
56+static struct mc_debug_data mc_debug_data_early __initdata;
57+static struct mc_debug_data __percpu *mc_debug_data __refdata =
58+ &mc_debug_data_early;
5459 DEFINE_PER_CPU(unsigned long, xen_mc_irq_flags);
5560
61+static struct static_key mc_debug __ro_after_init;
62+static bool mc_debug_enabled __initdata;
63+
64+static int __init xen_parse_mc_debug(char *arg)
65+{
66+ mc_debug_enabled = true;
67+ static_key_slow_inc(&mc_debug);
68+
69+ return 0;
70+}
71+early_param("xen_mc_debug", xen_parse_mc_debug);
72+
73+static int __init mc_debug_enable(void)
74+{
75+ struct mc_debug_data __percpu *mcdb;
76+ unsigned long flags;
77+
78+ if (!mc_debug_enabled)
79+ return 0;
80+
81+ mcdb = alloc_percpu(struct mc_debug_data);
82+ if (!mcdb) {
83+ pr_err("xen_mc_debug inactive\n");
84+ static_key_slow_dec(&mc_debug);
85+ return -ENOMEM;
86+ }
87+
88+ /* Be careful when switching to percpu debug data. */
89+ local_irq_save(flags);
90+ xen_mc_flush();
91+ mc_debug_data = mcdb;
92+ local_irq_restore(flags);
93+
94+ pr_info("xen_mc_debug active\n");
95+
96+ return 0;
97+}
98+early_initcall(mc_debug_enable);
99+
100+/* Number of parameters of hypercalls used via multicalls. */
101+static const uint8_t hpcpars[] = {
102+ [__HYPERVISOR_mmu_update] = 4,
103+ [__HYPERVISOR_stack_switch] = 2,
104+ [__HYPERVISOR_fpu_taskswitch] = 1,
105+ [__HYPERVISOR_update_descriptor] = 2,
106+ [__HYPERVISOR_update_va_mapping] = 3,
107+ [__HYPERVISOR_mmuext_op] = 4,
108+};
109+
110+static void print_debug_data(struct mc_buffer *b, struct mc_debug_data *mcdb,
111+ int idx)
112+{
113+ unsigned int arg;
114+ unsigned int opidx = mcdb->entries[idx].op & 0xff;
115+ unsigned int pars = 0;
116+
117+ pr_err(" call %2d: op=%lu result=%ld caller=%pS ", idx + 1,
118+ mcdb->entries[idx].op, b->entries[idx].result,
119+ mcdb->caller[idx]);
120+ if (opidx < ARRAY_SIZE(hpcpars))
121+ pars = hpcpars[opidx];
122+ if (pars) {
123+ pr_cont("pars=");
124+ for (arg = 0; arg < pars; arg++)
125+ pr_cont("%lx ", mcdb->entries[idx].args[arg]);
126+ }
127+ if (mcdb->argsz[idx]) {
128+ pr_cont("args=");
129+ for (arg = 0; arg < mcdb->argsz[idx] / 8; arg++)
130+ pr_cont("%lx ", mcdb->args[idx][arg]);
131+ }
132+ pr_cont("\n");
133+}
134+
56135 void xen_mc_flush(void)
57136 {
58137 struct mc_buffer *b = this_cpu_ptr(&mc_buffer);
59138 struct multicall_entry *mc;
139+ struct mc_debug_data *mcdb = NULL;
60140 int ret = 0;
61141 unsigned long flags;
62142 int i;
@@ -69,10 +149,11 @@ void xen_mc_flush(void) · 6 unmodified lines
69149
70150 trace_xen_mc_flush(b->mcidx, b->argidx, b->cbidx);
71151
72−#if MC_DEBUG
73− memcpy(b->debug, b->entries,
74− b->mcidx * sizeof(struct multicall_entry));
75−#endif
152+ if (static_key_false(&mc_debug)) {
153+ mcdb = this_cpu_ptr(mc_debug_data);
154+ memcpy(mcdb->entries, b->entries,
155+ b->mcidx * sizeof(struct multicall_entry));
156+ }
76157
77158 switch (b->mcidx) {
78159 case 0:
@@ -103,21 +184,14 @@ void xen_mc_flush(void) · 24 unmodified lines
103184 pr_err("%d of %d multicall(s) failed: cpu %d\n",
104185 ret, b->mcidx, smp_processor_id());
105186 for (i = 0; i < b->mcidx; i++) {
106− if (b->entries[i].result < 0) {
107−#if MC_DEBUG
108− pr_err(" call %2d: op=%lu arg=[%lx] result=%ld\t%pS\n",
109− i + 1,
110− b->debug[i].op,
111− b->debug[i].args[0],
112− b->entries[i].result,
113− b->caller[i]);
114−#else
187+ if (static_key_false(&mc_debug)) {
188+ print_debug_data(b, mcdb, i);
189+ } else if (b->entries[i].result < 0) {
115190 pr_err(" call %2d: op=%lu arg=[%lx] result=%ld\n",
116191 i + 1,
117192 b->entries[i].op,
118193 b->entries[i].args[0],
119194 b->entries[i].result);
120−#endif
121195 }
122196 }
123197 }
@@ -155,9 +229,13 @@ struct multicall_space __xen_mc_entry(size_t args) · 31 unmodified lines
155229 }
156230
157231 ret.mc = &b->entries[b->mcidx];
158−#if MC_DEBUG
159− b->caller[b->mcidx] = __builtin_return_address(0);
160−#endif
232+ if (static_key_false(&mc_debug)) {
233+ struct mc_debug_data *mcdb = this_cpu_ptr(mc_debug_data);
234+
235+ mcdb->caller[b->mcidx] = __builtin_return_address(0);
236+ mcdb->argsz[b->mcidx] = args;
237+ mcdb->args[b->mcidx] = (unsigned long *)(&b->args[argidx]);
238+ }
161239 b->mcidx++;
162240 ret.args = &b->args[argidx];
163241 b->argidx = argidx + args;
arch/x86/xen/multicalls.h+0−69
@@ -1,69 +0,0 @@
1−/* SPDX-License-Identifier: GPL-2.0 */
2−#ifndef _XEN_MULTICALLS_H
3−#define _XEN_MULTICALLS_H
4−
5−#include <trace/events/xen.h>
6−
7−#include "xen-ops.h"
8−
9−/* Multicalls */
10−struct multicall_space
11−{
12− struct multicall_entry *mc;
13− void *args;
14−};
15−
16−/* Allocate room for a multicall and its args */
17−struct multicall_space __xen_mc_entry(size_t args);
18−
19−DECLARE_PER_CPU(unsigned long, xen_mc_irq_flags);
20−
21−/* Call to start a batch of multiple __xen_mc_entry()s. Must be
22− paired with xen_mc_issue() */
23−static inline void xen_mc_batch(void)
24−{
25− unsigned long flags;
26−
27− /* need to disable interrupts until this entry is complete */
28− local_irq_save(flags);
29− trace_xen_mc_batch(xen_get_lazy_mode());
30− __this_cpu_write(xen_mc_irq_flags, flags);
31−}
32−
33−static inline struct multicall_space xen_mc_entry(size_t args)
34−{
35− xen_mc_batch();
36− return __xen_mc_entry(args);
37−}
38−
39−/* Flush all pending multicalls */
40−void xen_mc_flush(void);
41−
42−/* Issue a multicall if we're not in a lazy mode */
43−static inline void xen_mc_issue(unsigned mode)
44−{
45− trace_xen_mc_issue(mode);
46−
47− if ((xen_get_lazy_mode() & mode) == 0)
48− xen_mc_flush();
49−
50− /* restore flags saved in xen_mc_batch */
51− local_irq_restore(this_cpu_read(xen_mc_irq_flags));
52−}
53−
54−/* Set up a callback to be called when the current batch is flushed */
55−void xen_mc_callback(void (*fn)(void *), void *data);
56−
57−/*
58− * Try to extend the arguments of the previous multicall command. The
59− * previous command's op must match. If it does, then it attempts to
60− * extend the argument space allocated to the multicall entry by
61− * arg_size bytes.
62− *
63− * The returned multicall_space will return with mc pointing to the
64− * command on success, or NULL on failure, and args pointing to the
65− * newly allocated space.
66− */
67−struct multicall_space xen_mc_extend_args(unsigned long op, size_t arg_size);
68−
69−#endif /* _XEN_MULTICALLS_H */
arch/x86/xen/p2m.c+2−4
@@ -81,7 +81,6 @@ · 80 unmodified lines
8181 #include <xen/balloon.h>
8282 #include <xen/grant_table.h>
8383
84−#include "multicalls.h"
8584 #include "xen-ops.h"
8685
8786 #define P2M_MID_PER_PAGE (PAGE_SIZE / sizeof(unsigned long *))
@@ -730,7 +729,7 @@ int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops, · 642 unmodified lines
730729 * immediate unmapping.
731730 */
732731 map_ops[i].status = GNTST_general_error;
733− unmap[0].host_addr = map_ops[i].host_addr,
732+ unmap[0].host_addr = map_ops[i].host_addr;
734733 unmap[0].handle = map_ops[i].handle;
735734 map_ops[i].handle = INVALID_GRANT_HANDLE;
736735 if (map_ops[i].flags & GNTMAP_device_map)
@@ -740,7 +739,7 @@ int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops, · 3 unmodified lines
740739
741740 if (kmap_ops) {
742741 kmap_ops[i].status = GNTST_general_error;
743− unmap[1].host_addr = kmap_ops[i].host_addr,
742+ unmap[1].host_addr = kmap_ops[i].host_addr;
744743 unmap[1].handle = kmap_ops[i].handle;
745744 kmap_ops[i].handle = INVALID_GRANT_HANDLE;
746745 if (kmap_ops[i].flags & GNTMAP_device_map)
@@ -795,7 +794,6 @@ int clear_foreign_p2m_mapping(struct gnttab_unmap_grant_ref *unmap_ops, · 48 unmodified lines
795794
796795 #ifdef CONFIG_XEN_DEBUG_FS
797796 #include <linux/debugfs.h>
798−#include "debugfs.h"
799797 static int p2m_dump_show(struct seq_file *m, void *v)
800798 {
801799 static const char * const type_name[] = {
arch/x86/xen/pmu.c+0−1
@@ -10,7 +10,6 @@ · 9 unmodified lines
1010 #include <xen/interface/xenpmu.h>
1111
1212 #include "xen-ops.h"
13−#include "pmu.h"
1413
1514 /* x86_pmu.handle_irq definition */
1615 #include "../events/perf_event.h"
arch/x86/xen/pmu.h+0−22
@@ -1,22 +0,0 @@
1−/* SPDX-License-Identifier: GPL-2.0 */
2−#ifndef __XEN_PMU_H
3−#define __XEN_PMU_H
4−
5−#include <xen/interface/xenpmu.h>
6−
7−extern bool is_xen_pmu;
8−
9−irqreturn_t xen_pmu_irq_handler(int irq, void *dev_id);
10−#ifdef CONFIG_XEN_HAVE_VPMU
11−void xen_pmu_init(int cpu);
12−void xen_pmu_finish(int cpu);
13−#else
14−static inline void xen_pmu_init(int cpu) {}
15−static inline void xen_pmu_finish(int cpu) {}
16−#endif
17−bool pmu_msr_read(unsigned int msr, uint64_t *val, int *err);
18−bool pmu_msr_write(unsigned int msr, uint32_t low, uint32_t high, int *err);
19−int pmu_apic_update(uint32_t reg);
20−unsigned long long xen_read_pmc(int counter);
21−
22−#endif /* __XEN_PMU_H */
arch/x86/xen/setup.c+0−1
@@ -34,7 +34,6 @@ · 33 unmodified lines
3434 #include <xen/features.h>
3535 #include <xen/hvc-console.h>
3636 #include "xen-ops.h"
37−#include "mmu.h"
3837
3938 #define GB(x) ((uint64_t)(x) * 1024 * 1024 * 1024)
4039
arch/x86/xen/smp.c+0−1
@@ -9,7 +9,6 @@ · 8 unmodified lines
99
1010 #include <xen/hvc-console.h>
1111 #include "xen-ops.h"
12−#include "smp.h"
1312
1413 static DEFINE_PER_CPU(struct xen_common_irq, xen_resched_irq) = { .irq = -1 };
1514 static DEFINE_PER_CPU(struct xen_common_irq, xen_callfunc_irq) = { .irq = -1 };
arch/x86/xen/smp.h+0−51
@@ -1,51 +0,0 @@
1−/* SPDX-License-Identifier: GPL-2.0 */
2−#ifndef _XEN_SMP_H
3−
4−#ifdef CONFIG_SMP
5−
6−void asm_cpu_bringup_and_idle(void);
7−asmlinkage void cpu_bringup_and_idle(void);
8−
9−extern void xen_send_IPI_mask(const struct cpumask *mask,
10− int vector);
11−extern void xen_send_IPI_mask_allbutself(const struct cpumask *mask,
12− int vector);
13−extern void xen_send_IPI_allbutself(int vector);
14−extern void xen_send_IPI_all(int vector);
15−extern void xen_send_IPI_self(int vector);
16−
17−extern int xen_smp_intr_init(unsigned int cpu);
18−extern void xen_smp_intr_free(unsigned int cpu);
19−int xen_smp_intr_init_pv(unsigned int cpu);
20−void xen_smp_intr_free_pv(unsigned int cpu);
21−
22−void xen_smp_count_cpus(void);
23−void xen_smp_cpus_done(unsigned int max_cpus);
24−
25−void xen_smp_send_reschedule(int cpu);
26−void xen_smp_send_call_function_ipi(const struct cpumask *mask);
27−void xen_smp_send_call_function_single_ipi(int cpu);
28−
29−void __noreturn xen_cpu_bringup_again(unsigned long stack);
30−
31−struct xen_common_irq {
32− int irq;
33− char *name;
34−};
35−#else /* CONFIG_SMP */
36−
37−static inline int xen_smp_intr_init(unsigned int cpu)
38−{
39− return 0;
40−}
41−static inline void xen_smp_intr_free(unsigned int cpu) {}
42−
43−static inline int xen_smp_intr_init_pv(unsigned int cpu)
44−{
45− return 0;
46−}
47−static inline void xen_smp_intr_free_pv(unsigned int cpu) {}
48−static inline void xen_smp_count_cpus(void) { }
49−#endif /* CONFIG_SMP */
50−
51−#endif
arch/x86/xen/smp_hvm.c+0−2
@@ -5,8 +5,6 @@ · 4 unmodified lines
55 #include <xen/events.h>
66
77 #include "xen-ops.h"
8−#include "smp.h"
9−
108
119 static void __init xen_hvm_smp_prepare_boot_cpu(void)
1210 {
arch/x86/xen/smp_pv.c+0−3
@@ -46,9 +46,6 @@ · 45 unmodified lines
4646
4747 #include <xen/hvc-console.h>
4848 #include "xen-ops.h"
49−#include "mmu.h"
50−#include "smp.h"
51−#include "pmu.h"
5249
5350 cpumask_var_t xen_cpu_initialized_map;
5451
arch/x86/xen/spinlock.c+5−15
@@ -18,7 +18,6 @@ · 17 unmodified lines
1818 static DEFINE_PER_CPU(int, lock_kicker_irq) = -1;
1919 static DEFINE_PER_CPU(char *, irq_name);
2020 static DEFINE_PER_CPU(atomic_t, xen_qlock_wait_nest);
21−static bool xen_pvspin = true;
2221
2322 static void xen_qlock_kick(int cpu)
2423 {
@@ -68,7 +67,7 @@ void xen_init_lock_cpu(int cpu) · 43 unmodified lines
6867 int irq;
6968 char *name;
7069
71− if (!xen_pvspin)
70+ if (nopvspin)
7271 return;
7372
7473 WARN(per_cpu(lock_kicker_irq, cpu) >= 0, "spinlock on CPU%d exists on IRQ%d!\n",
@@ -95,7 +94,7 @@ void xen_uninit_lock_cpu(int cpu) · 20 unmodified lines
9594 {
9695 int irq;
9796
98− if (!xen_pvspin)
97+ if (nopvspin)
9998 return;
10099
101100 kfree(per_cpu(irq_name, cpu));
@@ -125,10 +124,10 @@ PV_CALLEE_SAVE_REGS_THUNK(xen_vcpu_stolen); · 23 unmodified lines
125124 void __init xen_init_spinlocks(void)
126125 {
127126 /* Don't need to use pvqspinlock code if there is only 1 vCPU. */
128− if (num_possible_cpus() == 1 || nopvspin)
129− xen_pvspin = false;
127+ if (num_possible_cpus() == 1)
128+ nopvspin = true;
130129
131− if (!xen_pvspin) {
130+ if (nopvspin) {
132131 printk(KERN_DEBUG "xen: PV spinlocks disabled\n");
133132 static_branch_disable(&virt_spin_lock_key);
134133 return;
@@ -143,12 +142,3 @@ void __init xen_init_spinlocks(void) · 8 unmodified lines
143142 pv_ops.lock.kick = xen_qlock_kick;
144143 pv_ops.lock.vcpu_is_preempted = PV_CALLEE_SAVE(xen_vcpu_stolen);
145144 }
146−
147−static __init int xen_parse_nopvspin(char *arg)
148−{
149− pr_notice("\"xen_nopvspin\" is deprecated, please use \"nopvspin\" instead\n");
150− xen_pvspin = false;
151− return 0;
152−}
153−early_param("xen_nopvspin", xen_parse_nopvspin);
154−
arch/x86/xen/suspend.c+0−2
@@ -15,8 +15,6 @@ · 14 unmodified lines
1515 #include <asm/fixmap.h>
1616
1717 #include "xen-ops.h"
18−#include "mmu.h"
19−#include "pmu.h"
2018
2119 static DEFINE_PER_CPU(u64, spec_ctrl);
2220
arch/x86/xen/time.c+1−1
@@ -30,7 +30,7 @@ · 29 unmodified lines
3030 #include "xen-ops.h"
3131
3232 /* Minimum amount of time until next clock event fires */
33−#define TIMER_SLOP 100000
33+#define TIMER_SLOP 1
3434
3535 static u64 xen_sched_clock_offset __read_mostly;
3636
arch/x86/xen/xen-ops.h+145−3
@@ -5,8 +5,15 @@ · 4 unmodified lines
55 #include <linux/init.h>
66 #include <linux/clocksource.h>
77 #include <linux/irqreturn.h>
8+#include <linux/linkage.h>
9+
10+#include <xen/interface/xenpmu.h>
811 #include <xen/xen-ops.h>
912
13+#include <asm/page.h>
14+
15+#include <trace/events/xen.h>
16+
1017 /* These are code, but not functions. Defined in entry.S */
1118 extern const char xen_failsafe_callback[];
1219
@@ -23,14 +30,11 @@ void xen_copy_trap_info(struct trap_info *traps); · 10 unmodified lines
2330
2431 DECLARE_PER_CPU_ALIGNED(struct vcpu_info, xen_vcpu_info);
2532 DECLARE_PER_CPU(unsigned long, xen_cr3);
26−DECLARE_PER_CPU(unsigned long, xen_current_cr3);
2733
2834 extern struct start_info *xen_start_info;
2935 extern struct shared_info xen_dummy_shared_info;
3036 extern struct shared_info *HYPERVISOR_shared_info;
3137
32−extern bool xen_fifo_events;
33−
3438 void xen_setup_mfn_list_list(void);
3539 void xen_build_mfn_list_list(void);
3640 void xen_setup_machphys_mapping(void);
@@ -177,4 +181,142 @@ static inline void xen_hvm_post_suspend(int suspend_cancelled) {} · 140 unmodified lines
177181
178182 void xen_add_extra_mem(unsigned long start_pfn, unsigned long n_pfns);
179183
184+struct dentry * __init xen_init_debugfs(void);
185+
186+enum pt_level {
187+ PT_PGD,
188+ PT_P4D,
189+ PT_PUD,
190+ PT_PMD,
191+ PT_PTE
192+};
193+
194+bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn);
195+void set_pte_mfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags);
196+unsigned long xen_read_cr2_direct(void);
197+void xen_init_mmu_ops(void);
198+void xen_hvm_init_mmu_ops(void);
199+
200+/* Multicalls */
201+struct multicall_space
202+{
203+ struct multicall_entry *mc;
204+ void *args;
205+};
206+
207+/* Allocate room for a multicall and its args */
208+struct multicall_space __xen_mc_entry(size_t args);
209+
210+DECLARE_PER_CPU(unsigned long, xen_mc_irq_flags);
211+
212+/* Call to start a batch of multiple __xen_mc_entry()s. Must be
213+ paired with xen_mc_issue() */
214+static inline void xen_mc_batch(void)
215+{
216+ unsigned long flags;
217+
218+ /* need to disable interrupts until this entry is complete */
219+ local_irq_save(flags);
220+ trace_xen_mc_batch(xen_get_lazy_mode());
221+ __this_cpu_write(xen_mc_irq_flags, flags);
222+}
223+
224+static inline struct multicall_space xen_mc_entry(size_t args)
225+{
226+ xen_mc_batch();
227+ return __xen_mc_entry(args);
228+}
229+
230+/* Flush all pending multicalls */
231+void xen_mc_flush(void);
232+
233+/* Issue a multicall if we're not in a lazy mode */
234+static inline void xen_mc_issue(unsigned mode)
235+{
236+ trace_xen_mc_issue(mode);
237+
238+ if ((xen_get_lazy_mode() & mode) == 0)
239+ xen_mc_flush();
240+
241+ /* restore flags saved in xen_mc_batch */
242+ local_irq_restore(this_cpu_read(xen_mc_irq_flags));
243+}
244+
245+/* Set up a callback to be called when the current batch is flushed */
246+void xen_mc_callback(void (*fn)(void *), void *data);
247+
248+/*
249+ * Try to extend the arguments of the previous multicall command. The
250+ * previous command's op must match. If it does, then it attempts to
251+ * extend the argument space allocated to the multicall entry by
252+ * arg_size bytes.
253+ *
254+ * The returned multicall_space will return with mc pointing to the
255+ * command on success, or NULL on failure, and args pointing to the
256+ * newly allocated space.
257+ */
258+struct multicall_space xen_mc_extend_args(unsigned long op, size_t arg_size);
259+
260+extern bool is_xen_pmu;
261+
262+irqreturn_t xen_pmu_irq_handler(int irq, void *dev_id);
263+#ifdef CONFIG_XEN_HAVE_VPMU
264+void xen_pmu_init(int cpu);
265+void xen_pmu_finish(int cpu);
266+#else
267+static inline void xen_pmu_init(int cpu) {}
268+static inline void xen_pmu_finish(int cpu) {}
269+#endif
270+bool pmu_msr_read(unsigned int msr, uint64_t *val, int *err);
271+bool pmu_msr_write(unsigned int msr, uint32_t low, uint32_t high, int *err);
272+int pmu_apic_update(uint32_t reg);
273+unsigned long long xen_read_pmc(int counter);
274+
275+#ifdef CONFIG_SMP
276+
277+void asm_cpu_bringup_and_idle(void);
278+asmlinkage void cpu_bringup_and_idle(void);
279+
280+extern void xen_send_IPI_mask(const struct cpumask *mask,
281+ int vector);
282+extern void xen_send_IPI_mask_allbutself(const struct cpumask *mask,
283+ int vector);
284+extern void xen_send_IPI_allbutself(int vector);
285+extern void xen_send_IPI_all(int vector);
286+extern void xen_send_IPI_self(int vector);
287+
288+extern int xen_smp_intr_init(unsigned int cpu);
289+extern void xen_smp_intr_free(unsigned int cpu);
290+int xen_smp_intr_init_pv(unsigned int cpu);
291+void xen_smp_intr_free_pv(unsigned int cpu);
292+
293+void xen_smp_count_cpus(void);
294+void xen_smp_cpus_done(unsigned int max_cpus);
295+
296+void xen_smp_send_reschedule(int cpu);
297+void xen_smp_send_call_function_ipi(const struct cpumask *mask);
298+void xen_smp_send_call_function_single_ipi(int cpu);
299+
300+void __noreturn xen_cpu_bringup_again(unsigned long stack);
301+
302+struct xen_common_irq {
303+ int irq;
304+ char *name;
305+};
306+#else /* CONFIG_SMP */
307+
308+static inline int xen_smp_intr_init(unsigned int cpu)
309+{
310+ return 0;
311+}
312+static inline void xen_smp_intr_free(unsigned int cpu) {}
313+
314+static inline int xen_smp_intr_init_pv(unsigned int cpu)
315+{
316+ return 0;
317+}
318+static inline void xen_smp_intr_free_pv(unsigned int cpu) {}
319+static inline void xen_smp_count_cpus(void) { }
320+#endif /* CONFIG_SMP */
321+
180322 #endif /* XEN_OPS_H */
drivers/xen/evtchn.c+1−0
@@ -729,4 +729,5 @@ static void __exit evtchn_cleanup(void) · 728 unmodified lines
729729 module_init(evtchn_init);
730730 module_exit(evtchn_cleanup);
731731
732+MODULE_DESCRIPTION("Xen /dev/xen/evtchn device driver");
732733 MODULE_LICENSE("GPL");
drivers/xen/manage.c+1−1
@@ -208,7 +208,7 @@ static void do_reboot(void) · 207 unmodified lines
208208 orderly_reboot();
209209 }
210210
211−static struct shutdown_handler shutdown_handlers[] = {
211+static const struct shutdown_handler shutdown_handlers[] = {
212212 { "poweroff", true, do_poweroff },
213213 { "halt", false, do_poweroff },
214214 { "reboot", true, do_reboot },
drivers/xen/privcmd-buf.c+1−0
@@ -19,6 +19,7 @@ · 18 unmodified lines
1919
2020 #include "privcmd.h"
2121
22+MODULE_DESCRIPTION("Xen Mmap of hypercall buffers");
2223 MODULE_LICENSE("GPL");
2324
2425 struct privcmd_buf_private {
drivers/xen/privcmd.c+25−11
@@ -17,6 +17,7 @@ · 16 unmodified lines
1717 #include <linux/poll.h>
1818 #include <linux/sched.h>
1919 #include <linux/slab.h>
20+#include <linux/srcu.h>
2021 #include <linux/string.h>
2122 #include <linux/workqueue.h>
2223 #include <linux/errno.h>
@@ -48,6 +49,7 @@ · 25 unmodified lines
4849
4950 #include "privcmd.h"
5051
52+MODULE_DESCRIPTION("Xen hypercall passthrough driver");
5153 MODULE_LICENSE("GPL");
5254
5355 #define PRIV_VMA_LOCKED ((void *)1)
@@ -845,7 +847,8 @@ out: · 791 unmodified lines
845847 #ifdef CONFIG_XEN_PRIVCMD_EVENTFD
846848 /* Irqfd support */
847849 static struct workqueue_struct *irqfd_cleanup_wq;
848−static DEFINE_MUTEX(irqfds_lock);
850+static DEFINE_SPINLOCK(irqfds_lock);
851+DEFINE_STATIC_SRCU(irqfds_srcu);
849852 static LIST_HEAD(irqfds_list);
850853
851854 struct privcmd_kernel_irqfd {
@@ -873,6 +876,9 @@ static void irqfd_shutdown(struct work_struct *work) · 21 unmodified lines
873876 container_of(work, struct privcmd_kernel_irqfd, shutdown);
874877 u64 cnt;
875878
879+ /* Make sure irqfd has been initialized in assign path */
880+ synchronize_srcu(&irqfds_srcu);
881+
876882 eventfd_ctx_remove_wait_queue(kirqfd->eventfd, &kirqfd->wait, &cnt);
877883 eventfd_ctx_put(kirqfd->eventfd);
878884 kfree(kirqfd);
@@ -909,9 +915,11 @@ irqfd_wakeup(wait_queue_entry_t *wait, unsigned int mode, int sync, void *key) · 30 unmodified lines
909915 irqfd_inject(kirqfd);
910916
911917 if (flags & EPOLLHUP) {
912− mutex_lock(&irqfds_lock);
918+ unsigned long flags;
919+
920+ spin_lock_irqsave(&irqfds_lock, flags);
913921 irqfd_deactivate(kirqfd);
914− mutex_unlock(&irqfds_lock);
922+ spin_unlock_irqrestore(&irqfds_lock, flags);
915923 }
916924
917925 return 0;
@@ -929,10 +937,11 @@ irqfd_poll_func(struct file *file, wait_queue_head_t *wqh, poll_table *pt) · 11 unmodified lines
929937 static int privcmd_irqfd_assign(struct privcmd_irqfd *irqfd)
930938 {
931939 struct privcmd_kernel_irqfd *kirqfd, *tmp;
940+ unsigned long flags;
932941 __poll_t events;
933942 struct fd f;
934943 void *dm_op;
935− int ret;
944+ int ret, idx;
936945
937946 kirqfd = kzalloc(sizeof(*kirqfd) + irqfd->size, GFP_KERNEL);
938947 if (!kirqfd)
@@ -968,18 +977,19 @@ static int privcmd_irqfd_assign(struct privcmd_irqfd *irqfd) · 29 unmodified lines
968977 init_waitqueue_func_entry(&kirqfd->wait, irqfd_wakeup);
969978 init_poll_funcptr(&kirqfd->pt, irqfd_poll_func);
970979
971− mutex_lock(&irqfds_lock);
980+ spin_lock_irqsave(&irqfds_lock, flags);
972981
973982 list_for_each_entry(tmp, &irqfds_list, list) {
974983 if (kirqfd->eventfd == tmp->eventfd) {
975984 ret = -EBUSY;
976− mutex_unlock(&irqfds_lock);
985+ spin_unlock_irqrestore(&irqfds_lock, flags);
977986 goto error_eventfd;
978987 }
979988 }
980989
990+ idx = srcu_read_lock(&irqfds_srcu);
981991 list_add_tail(&kirqfd->list, &irqfds_list);
982− mutex_unlock(&irqfds_lock);
992+ spin_unlock_irqrestore(&irqfds_lock, flags);
983993
984994 /*
985995 * Check if there was an event already pending on the eventfd before we
@@ -989,6 +999,8 @@ static int privcmd_irqfd_assign(struct privcmd_irqfd *irqfd) · 3 unmodified lines
989999 if (events & EPOLLIN)
9901000 irqfd_inject(kirqfd);
9911001
1002+ srcu_read_unlock(&irqfds_srcu, idx);
1003+
9921004 /*
9931005 * Do not drop the file until the kirqfd is fully initialized, otherwise
9941006 * we might race against the EPOLLHUP.
@@ -1011,12 +1023,13 @@ static int privcmd_irqfd_deassign(struct privcmd_irqfd *irqfd) · 16 unmodified lines
10111023 {
10121024 struct privcmd_kernel_irqfd *kirqfd;
10131025 struct eventfd_ctx *eventfd;
1026+ unsigned long flags;
10141027
10151028 eventfd = eventfd_ctx_fdget(irqfd->fd);
10161029 if (IS_ERR(eventfd))
10171030 return PTR_ERR(eventfd);
10181031
1019− mutex_lock(&irqfds_lock);
1032+ spin_lock_irqsave(&irqfds_lock, flags);
10201033
10211034 list_for_each_entry(kirqfd, &irqfds_list, list) {
10221035 if (kirqfd->eventfd == eventfd) {
@@ -1025,7 +1038,7 @@ static int privcmd_irqfd_deassign(struct privcmd_irqfd *irqfd) · 2 unmodified lines
10251038 }
10261039 }
10271040
1028− mutex_unlock(&irqfds_lock);
1041+ spin_unlock_irqrestore(&irqfds_lock, flags);
10291042
10301043 eventfd_ctx_put(eventfd);
10311044
@@ -1073,13 +1086,14 @@ static int privcmd_irqfd_init(void) · 41 unmodified lines
10731086 static void privcmd_irqfd_exit(void)
10741087 {
10751088 struct privcmd_kernel_irqfd *kirqfd, *tmp;
1089+ unsigned long flags;
10761090
1077− mutex_lock(&irqfds_lock);
1091+ spin_lock_irqsave(&irqfds_lock, flags);
10781092
10791093 list_for_each_entry_safe(kirqfd, tmp, &irqfds_list, list)
10801094 irqfd_deactivate(kirqfd);
10811095
1082− mutex_unlock(&irqfds_lock);
1096+ spin_unlock_irqrestore(&irqfds_lock, flags);
10831097
10841098 destroy_workqueue(irqfd_cleanup_wq);
10851099 }
drivers/xen/xen-pciback/pci_stub.c+1−0
@@ -1708,5 +1708,6 @@ static void __exit xen_pcibk_cleanup(void) · 1707 unmodified lines
17081708 module_init(xen_pcibk_init);
17091709 module_exit(xen_pcibk_cleanup);
17101710
1711+MODULE_DESCRIPTION("Xen PCI-device stub driver");
17111712 MODULE_LICENSE("Dual BSD/GPL");
17121713 MODULE_ALIAS("xen-backend:pci");
include/xen/events.h+2−0
@@ -144,4 +144,6 @@ static inline void xen_evtchn_close(evtchn_port_t port) · 143 unmodified lines
144144 BUG();
145145 }
146146
147+extern bool xen_fifo_events;
148+
147149 #endif /* _XEN_EVENTS_H */
kernel/locking/qspinlock.c+1−1
@@ -583,7 +583,7 @@ EXPORT_SYMBOL(queued_spin_lock_slowpath); · 582 unmodified lines
583583 #include "qspinlock_paravirt.h"
584584 #include "qspinlock.c"
585585
586−bool nopvspin __initdata;
586+bool nopvspin;
587587 static __init int parse_nopvspin(char *arg)
588588 {
589589 nopvspin = true;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t