ia64/xen-unstable

changeset 7125:e04b0805febb

Set guest selectors to be null if it's not valid when switch to
protected-mode in the guest firmware.

Signed-off-by: Chengyuan Li <chengyuan.li@intel.com>
Signed-off-by: Asit Mallick <asit.k.mallick@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Sep 29 09:59:46 2005 +0100 (2005-09-29)
parents f069a06e650f
children c317e0aca9f1
files tools/firmware/vmxassist/vm86.c
line diff
     1.1 --- a/tools/firmware/vmxassist/vm86.c	Wed Sep 28 22:18:30 2005 +0100
     1.2 +++ b/tools/firmware/vmxassist/vm86.c	Thu Sep 29 09:59:46 2005 +0100
     1.3 @@ -470,10 +470,21 @@ load_seg(unsigned long sel, u32 *base, u
     1.4  	unsigned long long entry;
     1.5  
     1.6  	/* protected mode: use seg as index into gdt */
     1.7 -	if (sel == 0 || sel > oldctx.gdtr_limit)
     1.8 +	if (sel > oldctx.gdtr_limit)
     1.9  		return 0;
    1.10  
    1.11 +    if (sel == 0) {
    1.12 +        arbytes->fields.null_bit = 1;
    1.13 +        return 1;
    1.14 +    }
    1.15 +
    1.16  	entry =  ((unsigned long long *) oldctx.gdtr_base)[sel >> 3];
    1.17 +
    1.18 +    /* Check the P bit fisrt*/
    1.19 +    if (!((entry >> (15+32)) & 0x1) && sel != 0) {
    1.20 +        return 0;
    1.21 +    }
    1.22 +
    1.23  	*base =  (((entry >> (56-24)) & 0xFF000000) |
    1.24  		  ((entry >> (32-16)) & 0x00FF0000) |
    1.25  		  ((entry >> (   16)) & 0x0000FFFF));
    1.26 @@ -519,22 +530,42 @@ protected_mode(struct regs *regs)
    1.27  	if (load_seg(regs->ves, &oldctx.es_base,
    1.28  				&oldctx.es_limit, &oldctx.es_arbytes))
    1.29  		oldctx.es_sel = regs->ves;
    1.30 +    else {
    1.31 +        load_seg(0, &oldctx.es_base,&oldctx.es_limit, &oldctx.es_arbytes);
    1.32 +        oldctx.es_sel = 0;
    1.33 +    }
    1.34  
    1.35  	if (load_seg(regs->uss, &oldctx.ss_base,
    1.36  				&oldctx.ss_limit, &oldctx.ss_arbytes))
    1.37  		oldctx.ss_sel = regs->uss;
    1.38 +    else {
    1.39 +        load_seg(0, &oldctx.ss_base, &oldctx.ss_limit, &oldctx.ss_arbytes);
    1.40 +        oldctx.ss_sel = 0;
    1.41 +    }
    1.42  
    1.43  	if (load_seg(regs->vds, &oldctx.ds_base,
    1.44  				&oldctx.ds_limit, &oldctx.ds_arbytes))
    1.45  		oldctx.ds_sel = regs->vds;
    1.46 +    else {
    1.47 +        load_seg(0, &oldctx.ds_base, &oldctx.ds_limit, &oldctx.ds_arbytes);
    1.48 +        oldctx.ds_sel = 0;
    1.49 +    }
    1.50  
    1.51  	if (load_seg(regs->vfs, &oldctx.fs_base,
    1.52  				&oldctx.fs_limit, &oldctx.fs_arbytes))
    1.53  		oldctx.fs_sel = regs->vfs;
    1.54 +    else {
    1.55 +        load_seg(0, &oldctx.fs_base, &oldctx.fs_limit, &oldctx.fs_arbytes);
    1.56 +        oldctx.fs_sel = 0;
    1.57 +    }
    1.58  
    1.59  	if (load_seg(regs->vgs, &oldctx.gs_base,
    1.60  				&oldctx.gs_limit, &oldctx.gs_arbytes))
    1.61  		oldctx.gs_sel = regs->vgs;
    1.62 +    else {
    1.63 +        load_seg(0, &oldctx.gs_base, &oldctx.gs_limit, &oldctx.gs_arbytes);
    1.64 +        oldctx.gs_sel = 0;
    1.65 +    }
    1.66  
    1.67  	/* initialize jump environment to warp back to protected mode */
    1.68  	regs->cs = CODE_SELECTOR;