| To: | <xen-devel@xxxxxxxxxxxxxxxxxxx> |
|---|---|
| Subject: | [Xen-devel] [PATCH] fix undefined bit shifting in mmio emulation path |
| From: | "He, Qing" <qing.he@xxxxxxxxx> |
| Date: | 2007年3月23日 18:05:45 +0800 |
| Delivery-date: | 2007年3月23日 03:05:05 -0700 |
| Envelope-to: | www-data@xxxxxxxxxxxxxxxxxx |
| List-help: | <mailto:xen-devel-request@lists.xensource.com?subject=help> |
| List-id: | Xen developer discussion <xen-devel.lists.xensource.com> |
| List-post: | <mailto:xen-devel@lists.xensource.com> |
| List-subscribe: | <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe> |
| List-unsubscribe: | <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe> |
| Sender: | xen-devel-bounces@xxxxxxxxxxxxxxxxxxx |
| Thread-index: | AcdtMtJ5C4EEucW2S3ysRNJgN9bDjQ== |
| Thread-topic: | [PATCH] fix undefined bit shifting in mmio emulation path |
In functions set_eflags_* (xen/arch/x86/hvm/io.c), if the first argument "size" equals sizeof(long), the following code will produce unintended and invalid result: unsigned long mask = (1 << (8 * size)) - 1; In ANSI C, if the shift amount is greater or equal to the width of the data type, the result is undefined. Specifically on x86, a bit mask is applied to the shift amount, so that more significant bits are ignored. So the above expression results 0x0 instead of the intended ~0UL. This patch fixes this issue. Because size=0 is not a valid parameter, rewriting the code using right shift avoids an additional condition check. Signed-off-by: Qing He <qing.he@xxxxxxxxx>
Attachment:
mmio_instr_emu_safe_shift.patch
Description: mmio_instr_emu_safe_shift.patch
_______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: [Xen-users] Live Migration performace analysis , James Youngman |
|---|---|
| Next by Date: | Re: [Xen-devel] question about gmfn_to_mfn() , Keir Fraser |
| Previous by Thread: | [Xen-devel] [PATCH] linux: fix a compiler warning , Jan Beulich |
| Next by Thread: | [Xen-devel] [PATCH][SVM]Rename reset_to_realmode. , Petersson, Mats |
| Indexes: | [Date] [Thread] [Top] [All Lists] |