[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] x86/hvm: clean up segment validation



commit a02b0fc87cddc60327bf127491df7aa961059680
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Tue Nov 26 09:54:48 2013 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue Nov 26 09:54:48 2013 +0100

    x86/hvm: clean up segment validation
    
    Use _SEGMENT_* instead of plain numbers where feasible.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/arch/x86/hvm/hvm.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index d80c166..af249f7 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -2259,7 +2259,7 @@ static int hvm_load_segment_selector(
         desc = *pdesc;
 
         /* Segment present in memory? */
-        if ( !(desc.b & (1u<<15)) )
+        if ( !(desc.b & _SEGMENT_P) )
         {
             fault_type = TRAP_no_segment;
             goto unmap_and_fail;
@@ -2277,7 +2277,7 @@ static int hvm_load_segment_selector(
         {
         case x86_seg_cs:
             /* Code segment? */
-            if ( !(desc.b & (1u<<11)) )
+            if ( !(desc.b & _SEGMENT_CODE) )
                 goto unmap_and_fail;
             /* Non-conforming segment: check DPL against RPL. */
             if ( !(desc.b & _SEGMENT_EC) && (dpl != rpl) )
@@ -2285,19 +2285,19 @@ static int hvm_load_segment_selector(
             break;
         case x86_seg_ss:
             /* Writable data segment? */
-            if ( (desc.b & (5u<<9)) != (1u<<9) )
+            if ( (desc.b & (_SEGMENT_CODE|_SEGMENT_WR)) != _SEGMENT_WR )
                 goto unmap_and_fail;
             if ( (dpl != cpl) || (dpl != rpl) )
                 goto unmap_and_fail;
             break;
         case x86_seg_ldtr:
             /* LDT system segment? */
-            if ( (desc.b & (15u<<8)) != (2u<<8) )
+            if ( (desc.b & _SEGMENT_TYPE) != (2u<<8) )
                 goto unmap_and_fail;
             goto skip_accessed_flag;
         default:
             /* Readable code or data segment? */
-            if ( (desc.b & (5u<<9)) == (4u<<9) )
+            if ( (desc.b & (_SEGMENT_CODE|_SEGMENT_WR)) == _SEGMENT_CODE )
                 goto unmap_and_fail;
             /*
              * Data or non-conforming code segment:
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.