blob: bec4dbe792ce0ddb11951589379d49177e55ef9b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/******************************************************************************
* current.h
*
* Information structure that lives at the bottom of the per-cpu Xen stack.
*/
#ifndef __X86_CURRENT_H__
#define __X86_CURRENT_H__
#include <xen/config.h>
#include <xen/percpu.h>
#include <public/xen.h>
#include <asm/page.h>
struct vcpu;
struct cpu_info {
struct cpu_user_regs guest_cpu_user_regs;
unsigned int processor_id;
struct vcpu *current_vcpu;
unsigned long per_cpu_offset;
/* get_stack_bottom() must be 16-byte aligned */
unsigned long __pad_for_stack_bottom;
};
static inline struct cpu_info *get_cpu_info(void)
{
unsigned long tos;
__asm__ ( "and %%rsp,%0" : "=r" (tos) : "0" (~(STACK_SIZE-1)) );
return (struct cpu_info *)(tos + STACK_SIZE) - 1;
}
#define get_current() (get_cpu_info()->current_vcpu)
#define set_current(vcpu) (get_cpu_info()->current_vcpu = (vcpu))
#define current (get_current())
#define get_processor_id() (get_cpu_info()->processor_id)
#define set_processor_id(id) do { \
struct cpu_info *ci__ = get_cpu_info(); \
ci__->per_cpu_offset = __per_cpu_offset[ci__->processor_id = (id)]; \
} while (0)
#define guest_cpu_user_regs() (&get_cpu_info()->guest_cpu_user_regs)
/*
* Get the bottom-of-stack, as stored in the per-CPU TSS. This actually points
* into the middle of cpu_info.guest_cpu_user_regs, at the section that
* precisely corresponds to a CPU trap frame.
*/
#define get_stack_bottom() \
((unsigned long)&get_cpu_info()->guest_cpu_user_regs.es)
#define reset_stack_and_jump(__fn) \
__asm__ __volatile__ ( \
"mov %0,%%"__OP"sp; jmp %c1" \
: : "r" (guest_cpu_user_regs()), "i" (__fn) : "memory" )
#define schedule_tail(vcpu) (((vcpu)->arch.schedule_tail)(vcpu))
/*
* Which VCPU's state is currently running on each CPU?
* This is not necesasrily the same as 'current' as a CPU may be
* executing a lazy state switch.
*/
DECLARE_PER_CPU(struct vcpu *, curr_vcpu);
#endif /* __X86_CURRENT_H__ */
|