]> xenbits.xensource.com Git - xen.git/commitdiff
x86_emulate: HVM emulation of REP instructions should inject #PF only
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 26 Mar 2008 15:50:45 +0000 (15:50 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 26 Mar 2008 15:50:45 +0000 (15:50 +0000)
if virt-to-phys lookup fails for the first repetition.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen/arch/x86/hvm/emulate.c

index 9c1a2daeb6026e87607dc89b5da4af3a6e2135c1..590ce01451427a1486dbab53bf6f9094fc074b1a 100644 (file)
@@ -74,18 +74,19 @@ static int hvmemul_linear_to_phys(
     for ( i = 1; done < todo; i++ )
     {
         /* Get the next PFN in the range. */
-        if ( (npfn = paging_gva_to_gfn(curr, addr, &pfec)) == INVALID_GFN )
-        {
-            hvm_inject_exception(TRAP_page_fault, pfec, addr);
-            return X86EMUL_EXCEPTION;
-        }
+        npfn = paging_gva_to_gfn(curr, addr, &pfec);
 
         /* Is it contiguous with the preceding PFNs? If not then we're done. */
-        if ( npfn != (pfn + i) )
+        if ( (npfn == INVALID_GFN) || (npfn != (pfn + i)) )
         {
             done /= bytes_per_rep;
             if ( done == 0 )
-                return X86EMUL_UNHANDLEABLE;
+            {
+                if ( npfn != INVALID_GFN )
+                    return X86EMUL_UNHANDLEABLE;
+                hvm_inject_exception(TRAP_page_fault, pfec, addr);
+                return X86EMUL_EXCEPTION;
+            }
             *reps = done;
             break;
         }