Skip to content

Commit 4461bbc

Browse files
Boris OstrovskyDavid Vrabel
authored andcommitted
x86/xen: Fix 32-bit PV guests's usage of kernel_stack
Commit 198d208 ("x86: Keep thread_info on thread stack in x86_32") made 32-bit kernels use kernel_stack to point to thread_info. That change missed a couple of updates needed by Xen's 32-bit PV guests: 1. kernel_stack needs to be initialized for secondary CPUs 2. GET_THREAD_INFO() now uses %fs register which may not be the kernel's version when executing xen_iret(). With respect to the second issue, we don't need GET_THREAD_INFO() anymore: we used it as an intermediate step to get to per_cpu xen_vcpu and avoid referencing %fs. Now that we are going to use %fs anyway we may as well go directly to xen_vcpu. Signed-off-by: Boris Ostrovsky <[email protected]> Signed-off-by: David Vrabel <[email protected]>
1 parent d06eb3e commit 4461bbc

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

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/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

0 commit comments

Comments
 (0)