Jens Nerche wrote:
> + if(nr_currents == 1)
> + {
> + monitor_gdt[i] = current_ds;
> + context->ds = (i << 3) + 3;
> + context->es = (i << 3) + 3;
> + context->fs = (i << 3) + 3;
> + context->gs = (i << 3) + 3;
> + }
I'd prefer not to have the assumption DS == ES == FS == GS
hardcoded into the kernel :-/ Please treat all segment
registers separately.
> /* Mark current CS active */
> + codeseg_activate(vm, cs, 0);
> codeseg_activate(vm, context->cs, 1);
Not really. 'cs' points to some descriptor that has just been regenerated
from the guest GDT; there's no point in modifying it ...
> +emulate_ljmp(vm_t *vm, guest_context_t *context)
> + /* ljmp may be an intersegment call
> + * we have disabled intersegment calls, so we have to emulate them
> + */
> +{
[snip]
> + /* now we have new cs:eip, lets prepare new code segment descriptor (DPL, CODE) */
> + monitor_gdt[new_cs >> 3].dpl = D_DPL3;
> + monitor_gdt[new_cs >> 3].type = D_CODE;
No! If the guest ljmp's to a real data segment, it *should* get a GPF ;-)
You should add a check here (like the one in emulate_call).
If it really is a code segment, you want to to call codeseg_activate on
the new CS (and deactivate the old CS) ...
Bye,
Ulrich
--
Ulrich Weigand,
IMMD 1, Universitaet Erlangen-Nuernberg,
Martensstr. 3, D-91058 Erlangen, Phone: +49 9131 85-27688