[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] x86emul: avoid numeric literals for EFLAGS values
Make the code use EFLG_* constants instead. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -429,6 +429,7 @@ typedef union { #define CR4_OSXSAVE (1<<18) /* EFLAGS bit definitions. */ +#define EFLG_ID (1<<21) #define EFLG_VIP (1<<20) #define EFLG_VIF (1<<19) #define EFLG_AC (1<<18) @@ -444,6 +445,7 @@ typedef union { #define EFLG_ZF (1<<6) #define EFLG_AF (1<<4) #define EFLG_PF (1<<2) +#define EFLG_MBS (1<<1) #define EFLG_CF (1<<0) /* MXCSR bit definitions. */ @@ -499,6 +501,13 @@ typedef union { */ #define EFLAGS_MASK (EFLG_OF|EFLG_SF|EFLG_ZF|EFLG_AF|EFLG_PF|EFLG_CF) +/* + * These EFLAGS bits are modifiable (by POPF and IRET), possibly subject + * to further CPL and IOPL constraints. + */ +#define EFLAGS_MODIFIABLE (EFLG_ID|EFLG_AC|EFLG_RF|EFLG_NT|EFLG_IOPL| \ + EFLG_DF|EFLG_IF|EFLG_TF|EFLAGS_MASK) + /* Before executing instruction: restore necessary bits in EFLAGS. */ #define _PRE_EFLAGS(_sav, _msk, _tmp) \ /* EFLAGS = (_sav & _msk) | (EFLAGS & ~_msk); _sav &= ~_msk; */ \ @@ -3163,18 +3172,19 @@ x86_emulate( goto done; if ( op_bytes == 2 ) dst.val = (uint16_t)dst.val | (_regs.eflags & 0xffff0000u); - dst.val &= 0x257fd5; + dst.val &= EFLAGS_MODIFIABLE; _regs.eflags &= mask; - _regs.eflags |= (uint32_t)(dst.val & ~mask) | 0x02; + _regs.eflags |= (uint32_t)(dst.val & ~mask) | EFLG_MBS; break; } case 0x9e: /* sahf */ - *(uint8_t *)&_regs.eflags = (((uint8_t *)&_regs.eax)[1] & 0xd7) | 0x02; + *(uint8_t *)&_regs.eflags = (((uint8_t *)&_regs.eax)[1] & + EFLAGS_MASK) | EFLG_MBS; break; case 0x9f: /* lahf */ - ((uint8_t *)&_regs.eax)[1] = (_regs.eflags & 0xd7) | 0x02; + ((uint8_t *)&_regs.eax)[1] = (_regs.eflags & EFLAGS_MASK) | EFLG_MBS; break; case 0xa4 ... 0xa5: /* movs */ { @@ -3453,9 +3463,9 @@ x86_emulate( goto done; if ( op_bytes == 2 ) eflags = (uint16_t)eflags | (_regs.eflags & 0xffff0000u); - eflags &= 0x257fd5; + eflags &= EFLAGS_MODIFIABLE; _regs.eflags &= mask; - _regs.eflags |= (eflags & ~mask) | 0x02; + _regs.eflags |= (eflags & ~mask) | EFLG_MBS; if ( (rc = load_seg(x86_seg_cs, sel, 1, &cs, ctxt, ops)) || (rc = commit_far_branch(&cs, (uint32_t)eip)) ) goto done; Attachment:
x86emul-EFLAGS-modifiable.patch _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |