diff options
author | Glauber de Oliveira Costa <gcosta@redhat.com> | 2008-01-07 08:05:32 -0500 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2008-01-30 06:50:11 -0500 |
commit | a53a35a8b485b9c16b73e5177bddaa4321971199 (patch) | |
tree | 8ed96838cb47d1263f63aba6dd6921b3c811f46c /drivers/lguest/interrupts_and_traps.c | |
parent | a3863f68b0d7fe2073c0f4efe534ec87a685c4fa (diff) |
lguest: make registers per-vcpu
This is the most obvious per-vcpu field: registers.
So this patch moves it from struct lguest to struct vcpu,
and patch the places in which they are used, accordingly
Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/lguest/interrupts_and_traps.c')
-rw-r--r-- | drivers/lguest/interrupts_and_traps.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/lguest/interrupts_and_traps.c b/drivers/lguest/interrupts_and_traps.c index 8f59232f458b..468faf8233d6 100644 --- a/drivers/lguest/interrupts_and_traps.c +++ b/drivers/lguest/interrupts_and_traps.c | |||
@@ -70,7 +70,7 @@ static void set_guest_interrupt(struct lg_cpu *cpu, u32 lo, u32 hi, int has_err) | |||
70 | /* There are two cases for interrupts: one where the Guest is already | 70 | /* There are two cases for interrupts: one where the Guest is already |
71 | * in the kernel, and a more complex one where the Guest is in | 71 | * in the kernel, and a more complex one where the Guest is in |
72 | * userspace. We check the privilege level to find out. */ | 72 | * userspace. We check the privilege level to find out. */ |
73 | if ((lg->regs->ss&0x3) != GUEST_PL) { | 73 | if ((cpu->regs->ss&0x3) != GUEST_PL) { |
74 | /* The Guest told us their kernel stack with the SET_STACK | 74 | /* The Guest told us their kernel stack with the SET_STACK |
75 | * hypercall: both the virtual address and the segment */ | 75 | * hypercall: both the virtual address and the segment */ |
76 | virtstack = lg->esp1; | 76 | virtstack = lg->esp1; |
@@ -81,12 +81,12 @@ static void set_guest_interrupt(struct lg_cpu *cpu, u32 lo, u32 hi, int has_err) | |||
81 | * stack: when the Guest does an "iret" back from the interrupt | 81 | * stack: when the Guest does an "iret" back from the interrupt |
82 | * handler the CPU will notice they're dropping privilege | 82 | * handler the CPU will notice they're dropping privilege |
83 | * levels and expect these here. */ | 83 | * levels and expect these here. */ |
84 | push_guest_stack(lg, &gstack, lg->regs->ss); | 84 | push_guest_stack(lg, &gstack, cpu->regs->ss); |
85 | push_guest_stack(lg, &gstack, lg->regs->esp); | 85 | push_guest_stack(lg, &gstack, cpu->regs->esp); |
86 | } else { | 86 | } else { |
87 | /* We're staying on the same Guest (kernel) stack. */ | 87 | /* We're staying on the same Guest (kernel) stack. */ |
88 | virtstack = lg->regs->esp; | 88 | virtstack = cpu->regs->esp; |
89 | ss = lg->regs->ss; | 89 | ss = cpu->regs->ss; |
90 | 90 | ||
91 | origstack = gstack = guest_pa(lg, virtstack); | 91 | origstack = gstack = guest_pa(lg, virtstack); |
92 | } | 92 | } |
@@ -95,7 +95,7 @@ static void set_guest_interrupt(struct lg_cpu *cpu, u32 lo, u32 hi, int has_err) | |||
95 | * the "Interrupt Flag" bit is always set. We copy that bit from the | 95 | * the "Interrupt Flag" bit is always set. We copy that bit from the |
96 | * Guest's "irq_enabled" field into the eflags word: we saw the Guest | 96 | * Guest's "irq_enabled" field into the eflags word: we saw the Guest |
97 | * copy it back in "lguest_iret". */ | 97 | * copy it back in "lguest_iret". */ |
98 | eflags = lg->regs->eflags; | 98 | eflags = cpu->regs->eflags; |
99 | if (get_user(irq_enable, &lg->lguest_data->irq_enabled) == 0 | 99 | if (get_user(irq_enable, &lg->lguest_data->irq_enabled) == 0 |
100 | && !(irq_enable & X86_EFLAGS_IF)) | 100 | && !(irq_enable & X86_EFLAGS_IF)) |
101 | eflags &= ~X86_EFLAGS_IF; | 101 | eflags &= ~X86_EFLAGS_IF; |
@@ -104,19 +104,19 @@ static void set_guest_interrupt(struct lg_cpu *cpu, u32 lo, u32 hi, int has_err) | |||
104 | * "eflags" word, the old code segment, and the old instruction | 104 | * "eflags" word, the old code segment, and the old instruction |
105 | * pointer. */ | 105 | * pointer. */ |
106 | push_guest_stack(lg, &gstack, eflags); | 106 | push_guest_stack(lg, &gstack, eflags); |
107 | push_guest_stack(lg, &gstack, lg->regs->cs); | 107 | push_guest_stack(lg, &gstack, cpu->regs->cs); |
108 | push_guest_stack(lg, &gstack, lg->regs->eip); | 108 | push_guest_stack(lg, &gstack, cpu->regs->eip); |
109 | 109 | ||
110 | /* For the six traps which supply an error code, we push that, too. */ | 110 | /* For the six traps which supply an error code, we push that, too. */ |
111 | if (has_err) | 111 | if (has_err) |
112 | push_guest_stack(lg, &gstack, lg->regs->errcode); | 112 | push_guest_stack(lg, &gstack, cpu->regs->errcode); |
113 | 113 | ||
114 | /* Now we've pushed all the old state, we change the stack, the code | 114 | /* Now we've pushed all the old state, we change the stack, the code |
115 | * segment and the address to execute. */ | 115 | * segment and the address to execute. */ |
116 | lg->regs->ss = ss; | 116 | cpu->regs->ss = ss; |
117 | lg->regs->esp = virtstack + (gstack - origstack); | 117 | cpu->regs->esp = virtstack + (gstack - origstack); |
118 | lg->regs->cs = (__KERNEL_CS|GUEST_PL); | 118 | cpu->regs->cs = (__KERNEL_CS|GUEST_PL); |
119 | lg->regs->eip = idt_address(lo, hi); | 119 | cpu->regs->eip = idt_address(lo, hi); |
120 | 120 | ||
121 | /* There are two kinds of interrupt handlers: 0xE is an "interrupt | 121 | /* There are two kinds of interrupt handlers: 0xE is an "interrupt |
122 | * gate" which expects interrupts to be disabled on entry. */ | 122 | * gate" which expects interrupts to be disabled on entry. */ |
@@ -157,7 +157,7 @@ void maybe_do_interrupt(struct lg_cpu *cpu) | |||
157 | 157 | ||
158 | /* They may be in the middle of an iret, where they asked us never to | 158 | /* They may be in the middle of an iret, where they asked us never to |
159 | * deliver interrupts. */ | 159 | * deliver interrupts. */ |
160 | if (lg->regs->eip >= lg->noirq_start && lg->regs->eip < lg->noirq_end) | 160 | if (cpu->regs->eip >= lg->noirq_start && cpu->regs->eip < lg->noirq_end) |
161 | return; | 161 | return; |
162 | 162 | ||
163 | /* If they're halted, interrupts restart them. */ | 163 | /* If they're halted, interrupts restart them. */ |