Skip to content

Commit 88764e0

Browse files
committed
Merge tag 'stable/for-linus-3.15-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull Xen fixes from David Vrabel: "Xen regression and bug fixes for 3.15-rc1: - fix completely broken 32-bit PV guests caused by x86 refactoring 32-bit thread_info. - only enable ticketlock slow path on Xen (not bare metal) - fix two bugs with PV guests not shutting down when requested - fix a minor memory leak in xen-pciback error path" * tag 'stable/for-linus-3.15-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: xen/manage: Poweroff forcefully if user-space is not yet up. xen/xenbus: Avoid synchronous wait on XenBus stalling shutdown/restart. xen/spinlock: Don't enable them unconditionally. xen-pciback: silence an unwanted debug printk xen: fix memory leak in __xen_pcibk_add_pci_dev() x86/xen: Fix 32-bit PV guests's usage of kernel_stack
2 parents 23c1a60 + eb47f71 commit 88764e0

7 files changed

Lines changed: 98 additions & 16 deletions

File tree

‎arch/x86/xen/smp.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,11 @@ static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
441441
irq_ctx_init(cpu);
442442
#else
443443
clear_tsk_thread_flag(idle, TIF_FORK);
444+
#endif
444445
per_cpu(kernel_stack, cpu) =
445446
(unsigned long)task_stack_page(idle) -
446447
KERNEL_STACK_OFFSET + THREAD_SIZE;
447-
#endif
448+
448449
xen_setup_runstate_info(cpu);
449450
xen_setup_timer(cpu);
450451
xen_init_lock_cpu(cpu);

‎arch/x86/xen/spinlock.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ void __init xen_init_spinlocks(void)
274274
printk(KERN_DEBUG "xen: PV spinlocks disabled\n");
275275
return;
276276
}
277-
277+
printk(KERN_DEBUG "xen: PV spinlocks enabled\n");
278278
pv_lock_ops.lock_spinning = PV_CALLEE_SAVE(xen_lock_spinning);
279279
pv_lock_ops.unlock_kick = xen_unlock_kick;
280280
}
@@ -290,6 +290,9 @@ static __init int xen_init_spinlocks_jump(void)
290290
if (!xen_pvspin)
291291
return 0;
292292

293+
if (!xen_domain())
294+
return 0;
295+
293296
static_key_slow_inc(&paravirt_ticketlocks_enabled);
294297
return 0;
295298
}

‎arch/x86/xen/xen-asm_32.S‎

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ ENDPROC(xen_sysexit)
7575
* stack state in whatever form its in, we keep things simple by only
7676
* using a single register which is pushed/popped on the stack.
7777
*/
78+
79+
.macro POP_FS
80+
1:
81+
popw %fs
82+
.pushsection .fixup, "ax"
83+
2: movw $0, (%esp)
84+
jmp 1b
85+
.popsection
86+
_ASM_EXTABLE(1b,2b)
87+
.endm
88+
7889
ENTRY(xen_iret)
7990
/* test eflags for special cases */
8091
testl $(X86_EFLAGS_VM | XEN_EFLAGS_NMI), 8(%esp)
@@ -83,15 +94,13 @@ ENTRY(xen_iret)
8394
push %eax
8495
ESP_OFFSET=4 # bytes pushed onto stack
8596

86-
/*
87-
* Store vcpu_info pointer for easy access. Do it this way to
88-
* avoid having to reload %fs
89-
*/
97+
/* Store vcpu_info pointer for easy access */
9098
#ifdef CONFIG_SMP
91-
GET_THREAD_INFO(%eax)
92-
movl %ss:TI_cpu(%eax), %eax
93-
movl %ss:__per_cpu_offset(,%eax,4), %eax
94-
mov %ss:xen_vcpu(%eax), %eax
99+
pushw %fs
100+
movl $(__KERNEL_PERCPU), %eax
101+
movl %eax, %fs
102+
movl %fs:xen_vcpu, %eax
103+
POP_FS
95104
#else
96105
movl %ss:xen_vcpu, %eax
97106
#endif

‎drivers/xen/manage.c‎

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,32 @@ struct shutdown_handler {
198198
void (*cb)(void);
199199
};
200200

201+
static int poweroff_nb(struct notifier_block *cb, unsigned long code, void *unused)
202+
{
203+
switch (code) {
204+
case SYS_DOWN:
205+
case SYS_HALT:
206+
case SYS_POWER_OFF:
207+
shutting_down = SHUTDOWN_POWEROFF;
208+
default:
209+
break;
210+
}
211+
return NOTIFY_DONE;
212+
}
201213
static void do_poweroff(void)
202214
{
203-
shutting_down = SHUTDOWN_POWEROFF;
204-
orderly_poweroff(false);
215+
switch (system_state) {
216+
case SYSTEM_BOOTING:
217+
orderly_poweroff(true);
218+
break;
219+
case SYSTEM_RUNNING:
220+
orderly_poweroff(false);
221+
break;
222+
default:
223+
/* Don't do it when we are halting/rebooting. */
224+
pr_info("Ignoring Xen toolstack shutdown.\n");
225+
break;
226+
}
205227
}
206228

207229
static void do_reboot(void)
@@ -307,6 +329,10 @@ static struct xenbus_watch shutdown_watch = {
307329
.callback = shutdown_handler
308330
};
309331

332+
static struct notifier_block xen_reboot_nb = {
333+
.notifier_call = poweroff_nb,
334+
};
335+
310336
static int setup_shutdown_watcher(void)
311337
{
312338
int err;
@@ -317,6 +343,7 @@ static int setup_shutdown_watcher(void)
317343
return err;
318344
}
319345

346+
320347
#ifdef CONFIG_MAGIC_SYSRQ
321348
err = register_xenbus_watch(&sysrq_watch);
322349
if (err) {
@@ -345,6 +372,7 @@ int xen_setup_shutdown_event(void)
345372
if (!xen_domain())
346373
return -ENODEV;
347374
register_xenstore_notifier(&xenstore_notifier);
375+
register_reboot_notifier(&xen_reboot_nb);
348376

349377
return 0;
350378
}

‎drivers/xen/xen-pciback/pciback_ops.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,15 @@ int xen_pcibk_enable_msix(struct xen_pcibk_device *pdev,
217217
if (result == 0) {
218218
for (i = 0; i < op->value; i++) {
219219
op->msix_entries[i].entry = entries[i].entry;
220-
if (entries[i].vector)
220+
if (entries[i].vector) {
221221
op->msix_entries[i].vector =
222222
xen_pirq_from_irq(entries[i].vector);
223223
if (unlikely(verbose_request))
224224
printk(KERN_DEBUG DRV_NAME ": %s: " \
225225
"MSI-X[%d]: %d\n",
226226
pci_name(dev), i,
227227
op->msix_entries[i].vector);
228+
}
228229
}
229230
} else
230231
pr_warn_ratelimited("%s: error enabling MSI-X for guest %u: err %d!\n",

‎drivers/xen/xen-pciback/vpci.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ static int __xen_pcibk_add_pci_dev(struct xen_pcibk_device *pdev,
137137
/* Publish this device. */
138138
if (!err)
139139
err = publish_cb(pdev, 0, 0, PCI_DEVFN(slot, func), devid);
140+
else
141+
kfree(dev_entry);
140142

141143
out:
142144
return err;

‎drivers/xen/xenbus/xenbus_xs.c‎

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include <xen/xenbus.h>
5151
#include <xen/xen.h>
5252
#include "xenbus_comms.h"
53+
#include "xenbus_probe.h"
5354

5455
struct xs_stored_msg {
5556
struct list_head list;
@@ -139,6 +140,29 @@ static int get_error(const char *errorstring)
139140
return xsd_errors[i].errnum;
140141
}
141142

143+
static bool xenbus_ok(void)
144+
{
145+
switch (xen_store_domain_type) {
146+
case XS_LOCAL:
147+
switch (system_state) {
148+
case SYSTEM_POWER_OFF:
149+
case SYSTEM_RESTART:
150+
case SYSTEM_HALT:
151+
return false;
152+
default:
153+
break;
154+
}
155+
return true;
156+
case XS_PV:
157+
case XS_HVM:
158+
/* FIXME: Could check that the remote domain is alive,
159+
* but it is normally initial domain. */
160+
return true;
161+
default:
162+
break;
163+
}
164+
return false;
165+
}
142166
static void *read_reply(enum xsd_sockmsg_type *type, unsigned int *len)
143167
{
144168
struct xs_stored_msg *msg;
@@ -148,9 +172,20 @@ static void *read_reply(enum xsd_sockmsg_type *type, unsigned int *len)
148172

149173
while (list_empty(&xs_state.reply_list)) {
150174
spin_unlock(&xs_state.reply_lock);
151-
/* XXX FIXME: Avoid synchronous wait for response here. */
152-
wait_event(xs_state.reply_waitq,
153-
!list_empty(&xs_state.reply_list));
175+
if (xenbus_ok())
176+
/* XXX FIXME: Avoid synchronous wait for response here. */
177+
wait_event_timeout(xs_state.reply_waitq,
178+
!list_empty(&xs_state.reply_list),
179+
msecs_to_jiffies(500));
180+
else {
181+
/*
182+
* If we are in the process of being shut-down there is
183+
* no point of trying to contact XenBus - it is either
184+
* killed (xenstored application) or the other domain
185+
* has been killed or is unreachable.
186+
*/
187+
return ERR_PTR(-EIO);
188+
}
154189
spin_lock(&xs_state.reply_lock);
155190
}
156191

@@ -215,6 +250,9 @@ void *xenbus_dev_request_and_reply(struct xsd_sockmsg *msg)
215250

216251
mutex_unlock(&xs_state.request_mutex);
217252

253+
if (IS_ERR(ret))
254+
return ret;
255+
218256
if ((msg->type == XS_TRANSACTION_END) ||
219257
((req_msg.type == XS_TRANSACTION_START) &&
220258
(msg->type == XS_ERROR)))

0 commit comments

Comments
 (0)