# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1219168324 -3600
# Node ID 504e5334f1a2f8ff1ba53deec7475371c52ad29a
# Parent e6a4f6a682ba534ce052cc9856cf53b03c24a95e
x86 hvm: Add clarifying comments about clipping repeated string
instructions to 4096 iterations.
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
xen/arch/x86/hvm/emulate.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletion(-)
diff -r e6a4f6a682ba -r 504e5334f1a2 xen/arch/x86/hvm/emulate.c
--- a/xen/arch/x86/hvm/emulate.c Tue Aug 19 18:47:01 2008 +0100
+++ b/xen/arch/x86/hvm/emulate.c Tue Aug 19 18:52:04 2008 +0100
@@ -210,7 +210,10 @@ static int hvmemul_linear_to_phys(
unsigned long pfn, npfn, done, todo, i;
int reverse;
- /* Clip repetitions to a sensible maximum. */
+ /*
+ * Clip repetitions to a sensible maximum. This avoids extensive looping in
+ * this function while still amortising the cost of I/O trap-and-emulate.
+ */
*reps = min_t(unsigned long, *reps, 4096);
/* With no paging it's easy: linear == physical. */
@@ -297,7 +300,13 @@ static int hvmemul_virtual_to_linear(
return X86EMUL_OKAY;
}
+ /*
+ * Clip repetitions to avoid overflow when multiplying by @bytes_per_rep.
+ * The chosen maximum is very conservative but it's what we use in
+ * hvmemul_linear_to_phys() so there is no point in using a larger value.
+ */
*reps = min_t(unsigned long, *reps, 4096);
+
reg = hvmemul_get_seg_reg(seg, hvmemul_ctxt);
if ( (hvmemul_ctxt->ctxt.regs->eflags & X86_EFLAGS_DF) && (*reps > 1) )
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|