From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH 4/5] x86/HVM: properly deal with hvm_copy_*_guest_phys() errors Date: Mon, 30 Sep 2013 14:07:38 +0100 Message-ID: <5249779A.8020803@citrix.com> References: <52498FFC02000078000F8068@nat28.tlf.novell.com> <524991B202000078000F8083@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2066788818389461265==" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VQdEN-0005Dj-Ku for xen-devel@lists.xenproject.org; Mon, 30 Sep 2013 13:09:43 +0000 In-Reply-To: <524991B202000078000F8083@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: xen-devel , Keir Fraser List-Id: xen-devel@lists.xenproject.org --===============2066788818389461265== Content-Type: multipart/alternative; boundary="------------040707040007030806020106" --------------040707040007030806020106 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit On 30/09/13 13:58, Jan Beulich wrote: > In memory read/write handling the default case should tell the caller > that the operation cannot be handled rather than the operation having > succeeded, so that when new HVMCOPY_* states get added not handling > them explicitly will not result in errors being ignored. > > In task switch emulation code stop handling some errors, but not > others. > > Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper > > --- a/xen/arch/x86/hvm/emulate.c > +++ b/xen/arch/x86/hvm/emulate.c > @@ -504,10 +504,10 @@ static int __hvmemul_read( > > switch ( rc ) > { > + case HVMCOPY_okay: > + break; > case HVMCOPY_bad_gva_to_gfn: > return X86EMUL_EXCEPTION; > - case HVMCOPY_unhandleable: > - return X86EMUL_UNHANDLEABLE; > case HVMCOPY_bad_gfn_to_mfn: > if ( access_type == hvm_access_insn_fetch ) > return X86EMUL_UNHANDLEABLE; > @@ -535,11 +535,10 @@ static int __hvmemul_read( > } > return rc; > case HVMCOPY_gfn_paged_out: > - return X86EMUL_RETRY; > case HVMCOPY_gfn_shared: > return X86EMUL_RETRY; > default: > - break; > + return X86EMUL_UNHANDLEABLE; > } > > return X86EMUL_OKAY; > @@ -634,10 +633,10 @@ static int hvmemul_write( > > switch ( rc ) > { > + case HVMCOPY_okay: > + break; > case HVMCOPY_bad_gva_to_gfn: > return X86EMUL_EXCEPTION; > - case HVMCOPY_unhandleable: > - return X86EMUL_UNHANDLEABLE; > case HVMCOPY_bad_gfn_to_mfn: > rc = hvmemul_linear_to_phys(addr, &gpa, chunk, &reps, pfec, > hvmemul_ctxt); > @@ -663,11 +662,10 @@ static int hvmemul_write( > } > return rc; > case HVMCOPY_gfn_paged_out: > - return X86EMUL_RETRY; > case HVMCOPY_gfn_shared: > return X86EMUL_RETRY; > default: > - break; > + return X86EMUL_UNHANDLEABLE; > } > > return X86EMUL_OKAY; > --- a/xen/arch/x86/hvm/hvm.c > +++ b/xen/arch/x86/hvm/hvm.c > @@ -2345,11 +2345,7 @@ void hvm_task_switch( > > rc = hvm_copy_to_guest_virt( > prev_tr.base, &tss, sizeof(tss), PFEC_page_present); > - if ( rc == HVMCOPY_bad_gva_to_gfn ) > - goto out; > - if ( rc == HVMCOPY_gfn_paged_out ) > - goto out; > - if ( rc == HVMCOPY_gfn_shared ) > + if ( rc != HVMCOPY_okay ) > goto out; > > rc = hvm_copy_from_guest_virt( > @@ -2396,9 +2392,7 @@ void hvm_task_switch( > tr.base, &tss, sizeof(tss), PFEC_page_present); > if ( rc == HVMCOPY_bad_gva_to_gfn ) > exn_raised = 1; > - if ( rc == HVMCOPY_gfn_paged_out ) > - goto out; > - if ( rc == HVMCOPY_gfn_shared ) > + else if ( rc != HVMCOPY_okay ) > goto out; > > if ( (tss.trace & 1) && !exn_raised ) > > > > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel --------------040707040007030806020106 Content-Type: text/html; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit
On 30/09/13 13:58, Jan Beulich wrote:
In memory read/write handling the default case should tell the caller
that the operation cannot be handled rather than the operation having
succeeded, so that when new HVMCOPY_* states get added not handling
them explicitly will not result in errors being ignored.

In task switch emulation code stop handling some errors, but not
others.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>


--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -504,10 +504,10 @@ static int __hvmemul_read(
 
     switch ( rc )
     {
+    case HVMCOPY_okay:
+        break;
     case HVMCOPY_bad_gva_to_gfn:
         return X86EMUL_EXCEPTION;
-    case HVMCOPY_unhandleable:
-        return X86EMUL_UNHANDLEABLE;
     case HVMCOPY_bad_gfn_to_mfn:
         if ( access_type == hvm_access_insn_fetch )
             return X86EMUL_UNHANDLEABLE;
@@ -535,11 +535,10 @@ static int __hvmemul_read(
         }
         return rc;
     case HVMCOPY_gfn_paged_out:
-        return X86EMUL_RETRY;
     case HVMCOPY_gfn_shared:
         return X86EMUL_RETRY;
     default:
-        break;
+        return X86EMUL_UNHANDLEABLE;
     }
 
     return X86EMUL_OKAY;
@@ -634,10 +633,10 @@ static int hvmemul_write(
 
     switch ( rc )
     {
+    case HVMCOPY_okay:
+        break;
     case HVMCOPY_bad_gva_to_gfn:
         return X86EMUL_EXCEPTION;
-    case HVMCOPY_unhandleable:
-        return X86EMUL_UNHANDLEABLE;
     case HVMCOPY_bad_gfn_to_mfn:
         rc = hvmemul_linear_to_phys(addr, &gpa, chunk, &reps, pfec,
                                     hvmemul_ctxt);
@@ -663,11 +662,10 @@ static int hvmemul_write(
         }
         return rc;
     case HVMCOPY_gfn_paged_out:
-        return X86EMUL_RETRY;
     case HVMCOPY_gfn_shared:
         return X86EMUL_RETRY;
     default:
-        break;
+        return X86EMUL_UNHANDLEABLE;
     }
 
     return X86EMUL_OKAY;
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -2345,11 +2345,7 @@ void hvm_task_switch(
 
     rc = hvm_copy_to_guest_virt(
         prev_tr.base, &tss, sizeof(tss), PFEC_page_present);
-    if ( rc == HVMCOPY_bad_gva_to_gfn )
-        goto out;
-    if ( rc == HVMCOPY_gfn_paged_out )
-        goto out;
-    if ( rc == HVMCOPY_gfn_shared )
+    if ( rc != HVMCOPY_okay )
         goto out;
 
     rc = hvm_copy_from_guest_virt(
@@ -2396,9 +2392,7 @@ void hvm_task_switch(
         tr.base, &tss, sizeof(tss), PFEC_page_present);
     if ( rc == HVMCOPY_bad_gva_to_gfn )
         exn_raised = 1;
-    if ( rc == HVMCOPY_gfn_paged_out )
-        goto out;
-    if ( rc == HVMCOPY_gfn_shared )
+    else if ( rc != HVMCOPY_okay )
         goto out;
 
     if ( (tss.trace & 1) && !exn_raised )





_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

--------------040707040007030806020106-- --===============2066788818389461265== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============2066788818389461265==--