Skip to content

Commit 88a174a

Browse files
committed
Merge tag 'for-linus-6.6a-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull xen fixes from Juergen Gross: - remove some unused functions in the Xen event channel handling - fix a regression (introduced during the merge window) when booting as Xen PV guest - small cleanup removing another strncpy() instance * tag 'for-linus-6.6a-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: xen/efi: refactor deprecated strncpy x86/xen: allow nesting of same lazy mode x86/xen: move paravirt lazy code arm/xen: remove lazy mode related definitions xen: simplify evtchn_do_upcall() call maze
2 parents fb8b1b9 + 0fc6ff5 commit 88a174a

File tree

16 files changed

+123
-155
lines changed

16 files changed

+123
-155
lines changed

arch/arm/xen/enlighten.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static void xen_power_off(void)
207207

208208
static irqreturn_t xen_arm_callback(int irq, void *arg)
209209
{
210-
xen_hvm_evtchn_do_upcall();
210+
xen_evtchn_do_upcall();
211211
return IRQ_HANDLED;
212212
}
213213

arch/x86/entry/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ static void __xen_pv_evtchn_do_upcall(struct pt_regs *regs)
294294

295295
inc_irq_stat(irq_hv_callback_count);
296296

297-
xen_hvm_evtchn_do_upcall();
297+
xen_evtchn_do_upcall();
298298

299299
set_irq_regs(old_regs);
300300
}

arch/x86/include/asm/paravirt_types.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ struct paravirt_patch_site {
99
u8 type; /* type of this instruction */
1010
u8 len; /* length of original instruction */
1111
};
12-
13-
/* Lazy mode for batching updates / context switch */
14-
enum paravirt_lazy_mode {
15-
PARAVIRT_LAZY_NONE,
16-
PARAVIRT_LAZY_MMU,
17-
PARAVIRT_LAZY_CPU,
18-
};
1912
#endif
2013

2114
#ifdef CONFIG_PARAVIRT
@@ -549,14 +542,6 @@ int paravirt_disable_iospace(void);
549542
__PVOP_VCALL(op, PVOP_CALL_ARG1(arg1), PVOP_CALL_ARG2(arg2), \
550543
PVOP_CALL_ARG3(arg3), PVOP_CALL_ARG4(arg4))
551544

552-
enum paravirt_lazy_mode paravirt_get_lazy_mode(void);
553-
void paravirt_start_context_switch(struct task_struct *prev);
554-
void paravirt_end_context_switch(struct task_struct *next);
555-
556-
void paravirt_enter_lazy_mmu(void);
557-
void paravirt_leave_lazy_mmu(void);
558-
void paravirt_flush_lazy_mmu(void);
559-
560545
void _paravirt_nop(void);
561546
void paravirt_BUG(void);
562547
unsigned long paravirt_ret0(void);

arch/x86/include/asm/xen/hypervisor.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
extern struct shared_info *HYPERVISOR_shared_info;
3737
extern struct start_info *xen_start_info;
3838

39+
#include <asm/bug.h>
3940
#include <asm/processor.h>
4041

4142
#define XEN_SIGNATURE "XenVMMXenVMM"
@@ -63,4 +64,40 @@ void __init xen_pvh_init(struct boot_params *boot_params);
6364
void __init mem_map_via_hcall(struct boot_params *boot_params_p);
6465
#endif
6566

67+
/* Lazy mode for batching updates / context switch */
68+
enum xen_lazy_mode {
69+
XEN_LAZY_NONE,
70+
XEN_LAZY_MMU,
71+
XEN_LAZY_CPU,
72+
};
73+
74+
DECLARE_PER_CPU(enum xen_lazy_mode, xen_lazy_mode);
75+
DECLARE_PER_CPU(unsigned int, xen_lazy_nesting);
76+
77+
static inline void enter_lazy(enum xen_lazy_mode mode)
78+
{
79+
enum xen_lazy_mode old_mode = this_cpu_read(xen_lazy_mode);
80+
81+
if (mode == old_mode) {
82+
this_cpu_inc(xen_lazy_nesting);
83+
return;
84+
}
85+
86+
BUG_ON(old_mode != XEN_LAZY_NONE);
87+
88+
this_cpu_write(xen_lazy_mode, mode);
89+
}
90+
91+
static inline void leave_lazy(enum xen_lazy_mode mode)
92+
{
93+
BUG_ON(this_cpu_read(xen_lazy_mode) != mode);
94+
95+
if (this_cpu_read(xen_lazy_nesting) == 0)
96+
this_cpu_write(xen_lazy_mode, XEN_LAZY_NONE);
97+
else
98+
this_cpu_dec(xen_lazy_nesting);
99+
}
100+
101+
enum xen_lazy_mode xen_get_lazy_mode(void);
102+
66103
#endif /* _ASM_X86_XEN_HYPERVISOR_H */

arch/x86/kernel/paravirt.c

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -143,66 +143,7 @@ int paravirt_disable_iospace(void)
143143
return request_resource(&ioport_resource, &reserve_ioports);
144144
}
145145

146-
static DEFINE_PER_CPU(enum paravirt_lazy_mode, paravirt_lazy_mode) = PARAVIRT_LAZY_NONE;
147-
148-
static inline void enter_lazy(enum paravirt_lazy_mode mode)
149-
{
150-
BUG_ON(this_cpu_read(paravirt_lazy_mode) != PARAVIRT_LAZY_NONE);
151-
152-
this_cpu_write(paravirt_lazy_mode, mode);
153-
}
154-
155-
static void leave_lazy(enum paravirt_lazy_mode mode)
156-
{
157-
BUG_ON(this_cpu_read(paravirt_lazy_mode) != mode);
158-
159-
this_cpu_write(paravirt_lazy_mode, PARAVIRT_LAZY_NONE);
160-
}
161-
162-
void paravirt_enter_lazy_mmu(void)
163-
{
164-
enter_lazy(PARAVIRT_LAZY_MMU);
165-
}
166-
167-
void paravirt_leave_lazy_mmu(void)
168-
{
169-
leave_lazy(PARAVIRT_LAZY_MMU);
170-
}
171-
172-
void paravirt_flush_lazy_mmu(void)
173-
{
174-
preempt_disable();
175-
176-
if (paravirt_get_lazy_mode() == PARAVIRT_LAZY_MMU) {
177-
arch_leave_lazy_mmu_mode();
178-
arch_enter_lazy_mmu_mode();
179-
}
180-
181-
preempt_enable();
182-
}
183-
184146
#ifdef CONFIG_PARAVIRT_XXL
185-
void paravirt_start_context_switch(struct task_struct *prev)
186-
{
187-
BUG_ON(preemptible());
188-
189-
if (this_cpu_read(paravirt_lazy_mode) == PARAVIRT_LAZY_MMU) {
190-
arch_leave_lazy_mmu_mode();
191-
set_ti_thread_flag(task_thread_info(prev), TIF_LAZY_MMU_UPDATES);
192-
}
193-
enter_lazy(PARAVIRT_LAZY_CPU);
194-
}
195-
196-
void paravirt_end_context_switch(struct task_struct *next)
197-
{
198-
BUG_ON(preemptible());
199-
200-
leave_lazy(PARAVIRT_LAZY_CPU);
201-
202-
if (test_and_clear_ti_thread_flag(task_thread_info(next), TIF_LAZY_MMU_UPDATES))
203-
arch_enter_lazy_mmu_mode();
204-
}
205-
206147
static noinstr void pv_native_write_cr2(unsigned long val)
207148
{
208149
native_write_cr2(val);
@@ -229,14 +170,6 @@ static noinstr void pv_native_safe_halt(void)
229170
}
230171
#endif
231172

232-
enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
233-
{
234-
if (in_interrupt())
235-
return PARAVIRT_LAZY_NONE;
236-
237-
return this_cpu_read(paravirt_lazy_mode);
238-
}
239-
240173
struct pv_info pv_info = {
241174
.name = "bare hardware",
242175
#ifdef CONFIG_PARAVIRT_XXL

arch/x86/xen/efi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void __init xen_efi_init(struct boot_params *boot_params)
138138
if (efi_systab_xen == NULL)
139139
return;
140140

141-
strncpy((char *)&boot_params->efi_info.efi_loader_signature, "Xen",
141+
strscpy((char *)&boot_params->efi_info.efi_loader_signature, "Xen",
142142
sizeof(boot_params->efi_info.efi_loader_signature));
143143
boot_params->efi_info.efi_systab = (__u32)__pa(efi_systab_xen);
144144
boot_params->efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32);

arch/x86/xen/enlighten.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ EXPORT_SYMBOL_GPL(hypercall_page);
3232
* &HYPERVISOR_shared_info->vcpu_info[cpu]. See xen_hvm_init_shared_info
3333
* and xen_vcpu_setup for details. By default it points to share_info->vcpu_info
3434
* but during boot it is switched to point to xen_vcpu_info.
35-
* The pointer is used in __xen_evtchn_do_upcall to acknowledge pending events.
35+
* The pointer is used in xen_evtchn_do_upcall to acknowledge pending events.
3636
*/
3737
DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu);
3838
DEFINE_PER_CPU(struct vcpu_info, xen_vcpu_info);

arch/x86/xen/enlighten_hvm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_xen_hvm_callback)
136136

137137
inc_irq_stat(irq_hv_callback_count);
138138

139-
xen_hvm_evtchn_do_upcall();
139+
xen_evtchn_do_upcall();
140140

141141
set_irq_regs(old_regs);
142142
}

arch/x86/xen/enlighten_pv.c

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ struct tls_descs {
101101
struct desc_struct desc[3];
102102
};
103103

104+
DEFINE_PER_CPU(enum xen_lazy_mode, xen_lazy_mode) = XEN_LAZY_NONE;
105+
DEFINE_PER_CPU(unsigned int, xen_lazy_nesting);
106+
107+
enum xen_lazy_mode xen_get_lazy_mode(void)
108+
{
109+
if (in_interrupt())
110+
return XEN_LAZY_NONE;
111+
112+
return this_cpu_read(xen_lazy_mode);
113+
}
114+
104115
/*
105116
* Updating the 3 TLS descriptors in the GDT on every task switch is
106117
* surprisingly expensive so we avoid updating them if they haven't
@@ -362,10 +373,25 @@ static noinstr unsigned long xen_get_debugreg(int reg)
362373
return HYPERVISOR_get_debugreg(reg);
363374
}
364375

376+
static void xen_start_context_switch(struct task_struct *prev)
377+
{
378+
BUG_ON(preemptible());
379+
380+
if (this_cpu_read(xen_lazy_mode) == XEN_LAZY_MMU) {
381+
arch_leave_lazy_mmu_mode();
382+
set_ti_thread_flag(task_thread_info(prev), TIF_LAZY_MMU_UPDATES);
383+
}
384+
enter_lazy(XEN_LAZY_CPU);
385+
}
386+
365387
static void xen_end_context_switch(struct task_struct *next)
366388
{
389+
BUG_ON(preemptible());
390+
367391
xen_mc_flush();
368-
paravirt_end_context_switch(next);
392+
leave_lazy(XEN_LAZY_CPU);
393+
if (test_and_clear_ti_thread_flag(task_thread_info(next), TIF_LAZY_MMU_UPDATES))
394+
arch_enter_lazy_mmu_mode();
369395
}
370396

371397
static unsigned long xen_store_tr(void)
@@ -472,7 +498,7 @@ static void xen_set_ldt(const void *addr, unsigned entries)
472498

473499
MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF);
474500

475-
xen_mc_issue(PARAVIRT_LAZY_CPU);
501+
xen_mc_issue(XEN_LAZY_CPU);
476502
}
477503

478504
static void xen_load_gdt(const struct desc_ptr *dtr)
@@ -568,7 +594,7 @@ static void xen_load_tls(struct thread_struct *t, unsigned int cpu)
568594
* exception between the new %fs descriptor being loaded and
569595
* %fs being effectively cleared at __switch_to().
570596
*/
571-
if (paravirt_get_lazy_mode() == PARAVIRT_LAZY_CPU)
597+
if (xen_get_lazy_mode() == XEN_LAZY_CPU)
572598
loadsegment(fs, 0);
573599

574600
xen_mc_batch();
@@ -577,7 +603,7 @@ static void xen_load_tls(struct thread_struct *t, unsigned int cpu)
577603
load_TLS_descriptor(t, cpu, 1);
578604
load_TLS_descriptor(t, cpu, 2);
579605

580-
xen_mc_issue(PARAVIRT_LAZY_CPU);
606+
xen_mc_issue(XEN_LAZY_CPU);
581607
}
582608

583609
static void xen_load_gs_index(unsigned int idx)
@@ -909,7 +935,7 @@ static void xen_load_sp0(unsigned long sp0)
909935

910936
mcs = xen_mc_entry(0);
911937
MULTI_stack_switch(mcs.mc, __KERNEL_DS, sp0);
912-
xen_mc_issue(PARAVIRT_LAZY_CPU);
938+
xen_mc_issue(XEN_LAZY_CPU);
913939
this_cpu_write(cpu_tss_rw.x86_tss.sp0, sp0);
914940
}
915941

@@ -973,7 +999,7 @@ static void xen_write_cr0(unsigned long cr0)
973999

9741000
MULTI_fpu_taskswitch(mcs.mc, (cr0 & X86_CR0_TS) != 0);
9751001

976-
xen_mc_issue(PARAVIRT_LAZY_CPU);
1002+
xen_mc_issue(XEN_LAZY_CPU);
9771003
}
9781004

9791005
static void xen_write_cr4(unsigned long cr4)
@@ -1156,7 +1182,7 @@ static const typeof(pv_ops) xen_cpu_ops __initconst = {
11561182
#endif
11571183
.io_delay = xen_io_delay,
11581184

1159-
.start_context_switch = paravirt_start_context_switch,
1185+
.start_context_switch = xen_start_context_switch,
11601186
.end_context_switch = xen_end_context_switch,
11611187
},
11621188
};

0 commit comments

Comments
 (0)