# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID e04b0805febb44a922fcdd4744b9e71a65064417
# Parent f069a06e650f773a7eba6ecf19fe30c241db5dc2
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@xxxxxxxxx>
Signed-off-by: Asit Mallick <asit.k.mallick@xxxxxxxxx>
diff -r f069a06e650f -r e04b0805febb tools/firmware/vmxassist/vm86.c
--- a/tools/firmware/vmxassist/vm86.c Wed Sep 28 21:18:30 2005
+++ b/tools/firmware/vmxassist/vm86.c Thu Sep 29 08:59:46 2005
@@ -470,10 +470,21 @@
unsigned long long entry;
/* protected mode: use seg as index into gdt */
- if (sel == 0 || sel > oldctx.gdtr_limit)
+ if (sel > oldctx.gdtr_limit)
return 0;
+ if (sel == 0) {
+ arbytes->fields.null_bit = 1;
+ return 1;
+ }
+
entry = ((unsigned long long *) oldctx.gdtr_base)[sel >> 3];
+
+ /* Check the P bit fisrt*/
+ if (!((entry >> (15+32)) & 0x1) && sel != 0) {
+ return 0;
+ }
+
*base = (((entry >> (56-24)) & 0xFF000000) |
((entry >> (32-16)) & 0x00FF0000) |
((entry >> ( 16)) & 0x0000FFFF));
@@ -519,22 +530,42 @@
if (load_seg(regs->ves, &oldctx.es_base,
&oldctx.es_limit, &oldctx.es_arbytes))
oldctx.es_sel = regs->ves;
+ else {
+ load_seg(0, &oldctx.es_base,&oldctx.es_limit, &oldctx.es_arbytes);
+ oldctx.es_sel = 0;
+ }
if (load_seg(regs->uss, &oldctx.ss_base,
&oldctx.ss_limit, &oldctx.ss_arbytes))
oldctx.ss_sel = regs->uss;
+ else {
+ load_seg(0, &oldctx.ss_base, &oldctx.ss_limit, &oldctx.ss_arbytes);
+ oldctx.ss_sel = 0;
+ }
if (load_seg(regs->vds, &oldctx.ds_base,
&oldctx.ds_limit, &oldctx.ds_arbytes))
oldctx.ds_sel = regs->vds;
+ else {
+ load_seg(0, &oldctx.ds_base, &oldctx.ds_limit, &oldctx.ds_arbytes);
+ oldctx.ds_sel = 0;
+ }
if (load_seg(regs->vfs, &oldctx.fs_base,
&oldctx.fs_limit, &oldctx.fs_arbytes))
oldctx.fs_sel = regs->vfs;
+ else {
+ load_seg(0, &oldctx.fs_base, &oldctx.fs_limit, &oldctx.fs_arbytes);
+ oldctx.fs_sel = 0;
+ }
if (load_seg(regs->vgs, &oldctx.gs_base,
&oldctx.gs_limit, &oldctx.gs_arbytes))
oldctx.gs_sel = regs->vgs;
+ else {
+ load_seg(0, &oldctx.gs_base, &oldctx.gs_limit, &oldctx.gs_arbytes);
+ oldctx.gs_sel = 0;
+ }
/* initialize jump environment to warp back to protected mode */
regs->cs = CODE_SELECTOR;
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|