Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+98 -16
+2 -1
arch/x86/xen/smp.c
··· 441 441 irq_ctx_init(cpu); 442 442 #else 443 443 clear_tsk_thread_flag(idle, TIF_FORK); 444 + #endif 444 445 per_cpu(kernel_stack, cpu) = 445 446 (unsigned long)task_stack_page(idle) - 446 447 KERNEL_STACK_OFFSET + THREAD_SIZE; 447 - #endif 448 + 448 449 xen_setup_runstate_info(cpu); 449 450 xen_setup_timer(cpu); 450 451 xen_init_lock_cpu(cpu);
+4 -1
arch/x86/xen/spinlock.c
··· 274 274 printk(KERN_DEBUG "xen: PV spinlocks disabled\n"); 275 275 return; 276 276 } 277 - 277 + printk(KERN_DEBUG "xen: PV spinlocks enabled\n"); 278 278 pv_lock_ops.lock_spinning = PV_CALLEE_SAVE(xen_lock_spinning); 279 279 pv_lock_ops.unlock_kick = xen_unlock_kick; 280 280 } ··· 288 288 static __init int xen_init_spinlocks_jump(void) 289 289 { 290 290 if (!xen_pvspin) 291 + return 0; 292 + 293 + if (!xen_domain()) 291 294 return 0; 292 295 293 296 static_key_slow_inc(&paravirt_ticketlocks_enabled);
+17 -8
arch/x86/xen/xen-asm_32.S
··· 75 75 * stack state in whatever form its in, we keep things simple by only 76 76 * using a single register which is pushed/popped on the stack. 77 77 */ 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 + 78 89 ENTRY(xen_iret) 79 90 /* test eflags for special cases */ 80 91 testl $(X86_EFLAGS_VM | XEN_EFLAGS_NMI), 8(%esp) ··· 94 83 push %eax 95 84 ESP_OFFSET=4 # bytes pushed onto stack 96 85 97 - /* 98 - * Store vcpu_info pointer for easy access. Do it this way to 99 - * avoid having to reload %fs 100 - */ 86 + /* Store vcpu_info pointer for easy access */ 101 87 #ifdef CONFIG_SMP 102 - GET_THREAD_INFO(%eax) 103 - movl %ss:TI_cpu(%eax), %eax 104 - movl %ss:__per_cpu_offset(,%eax,4), %eax 105 - mov %ss:xen_vcpu(%eax), %eax 88 + pushw %fs 89 + movl $(__KERNEL_PERCPU), %eax 90 + movl %eax, %fs 91 + movl %fs:xen_vcpu, %eax 92 + POP_FS 106 93 #else 107 94 movl %ss:xen_vcpu, %eax 108 95 #endif
+30 -2
drivers/xen/manage.c
··· 198 198 void (*cb)(void); 199 199 }; 200 200 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 + } 201 213 static void do_poweroff(void) 202 214 { 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 + } 205 227 } 206 228 207 229 static void do_reboot(void) ··· 329 307 .callback = shutdown_handler 330 308 }; 331 309 310 + static struct notifier_block xen_reboot_nb = { 311 + .notifier_call = poweroff_nb, 312 + }; 313 + 332 314 static int setup_shutdown_watcher(void) 333 315 { 334 316 int err; ··· 342 316 pr_err("Failed to set shutdown watcher\n"); 343 317 return err; 344 318 } 319 + 345 320 346 321 #ifdef CONFIG_MAGIC_SYSRQ 347 322 err = register_xenbus_watch(&sysrq_watch); ··· 372 345 if (!xen_domain()) 373 346 return -ENODEV; 374 347 register_xenstore_notifier(&xenstore_notifier); 348 + register_reboot_notifier(&xen_reboot_nb); 375 349 376 350 return 0; 377 351 }
+2 -1
drivers/xen/xen-pciback/pciback_ops.c
··· 217 217 if (result == 0) { 218 218 for (i = 0; i < op->value; i++) { 219 219 op->msix_entries[i].entry = entries[i].entry; 220 - if (entries[i].vector) 220 + if (entries[i].vector) { 221 221 op->msix_entries[i].vector = 222 222 xen_pirq_from_irq(entries[i].vector); 223 223 if (unlikely(verbose_request)) ··· 225 225 "MSI-X[%d]: %d\n", 226 226 pci_name(dev), i, 227 227 op->msix_entries[i].vector); 228 + } 228 229 } 229 230 } else 230 231 pr_warn_ratelimited("%s: error enabling MSI-X for guest %u: err %d!\n",
+2
drivers/xen/xen-pciback/vpci.c
··· 137 137 /* Publish this device. */ 138 138 if (!err) 139 139 err = publish_cb(pdev, 0, 0, PCI_DEVFN(slot, func), devid); 140 + else 141 + kfree(dev_entry); 140 142 141 143 out: 142 144 return err;
+41 -3
drivers/xen/xenbus/xenbus_xs.c
··· 50 50 #include <xen/xenbus.h> 51 51 #include <xen/xen.h> 52 52 #include "xenbus_comms.h" 53 + #include "xenbus_probe.h" 53 54 54 55 struct xs_stored_msg { 55 56 struct list_head list; ··· 140 139 return xsd_errors[i].errnum; 141 140 } 142 141 142 + static bool xenbus_ok(void) 143 + { 144 + switch (xen_store_domain_type) { 145 + case XS_LOCAL: 146 + switch (system_state) { 147 + case SYSTEM_POWER_OFF: 148 + case SYSTEM_RESTART: 149 + case SYSTEM_HALT: 150 + return false; 151 + default: 152 + break; 153 + } 154 + return true; 155 + case XS_PV: 156 + case XS_HVM: 157 + /* FIXME: Could check that the remote domain is alive, 158 + * but it is normally initial domain. */ 159 + return true; 160 + default: 161 + break; 162 + } 163 + return false; 164 + } 143 165 static void *read_reply(enum xsd_sockmsg_type *type, unsigned int *len) 144 166 { 145 167 struct xs_stored_msg *msg; ··· 172 148 173 149 while (list_empty(&xs_state.reply_list)) { 174 150 spin_unlock(&xs_state.reply_lock); 175 - /* XXX FIXME: Avoid synchronous wait for response here. */ 176 - wait_event(xs_state.reply_waitq, 177 - !list_empty(&xs_state.reply_list)); 151 + if (xenbus_ok()) 152 + /* XXX FIXME: Avoid synchronous wait for response here. */ 153 + wait_event_timeout(xs_state.reply_waitq, 154 + !list_empty(&xs_state.reply_list), 155 + msecs_to_jiffies(500)); 156 + else { 157 + /* 158 + * If we are in the process of being shut-down there is 159 + * no point of trying to contact XenBus - it is either 160 + * killed (xenstored application) or the other domain 161 + * has been killed or is unreachable. 162 + */ 163 + return ERR_PTR(-EIO); 164 + } 178 165 spin_lock(&xs_state.reply_lock); 179 166 } 180 167 ··· 249 214 ret = read_reply(&msg->type, &msg->len); 250 215 251 216 mutex_unlock(&xs_state.request_mutex); 217 + 218 + if (IS_ERR(ret)) 219 + return ret; 252 220 253 221 if ((msg->type == XS_TRANSACTION_END) || 254 222 ((req_msg.type == XS_TRANSACTION_START) &&