aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-08-19 18:52:04 +0100
committerKeir Fraser <keir.fraser@citrix.com>2008-08-19 18:52:04 +0100
commitaa6af210f6a8684e7a5a8c7e66b44d482902b01c (patch)
tree7d80c99ffa8c6510037732cfe34496e584587289
parent1e827f9eab121b7371b7f07842cbecae561f991a (diff)
downloadxen-aa6af210f6a8684e7a5a8c7e66b44d482902b01c.tar.gz
xen-aa6af210f6a8684e7a5a8c7e66b44d482902b01c.tar.bz2
xen-aa6af210f6a8684e7a5a8c7e66b44d482902b01c.zip
x86 hvm: Add clarifying comments about clipping repeated string
instructions to 4096 iterations. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
-rw-r--r--xen/arch/x86/hvm/emulate.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index 7b7ac5b09c..60a815c7e5 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -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) )