From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
keir@xen.org, David Binderman <dcb314@hotmail.com>,
Tim Deegan <tim@xen.org>
Subject: Re: [PATCH v4 2/2] x86/hvm: clean up segment validation
Date: Fri, 22 Nov 2013 14:27:19 +0000 [thread overview]
Message-ID: <528F69C7.7010902@citrix.com> (raw)
In-Reply-To: <528F766E0200007800105E45@nat28.tlf.novell.com>
On 22/11/13 14:21, Jan Beulich wrote:
> Use _SEGMENT_* instead of plain numbers where feasible.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
>
> --- 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:
>
>
>
prev parent reply other threads:[~2013-11-22 14:27 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-21 11:45 xen-4.3.1:hvm.c: 2 * possible bad if tests ? David Binderman
2013-11-21 11:54 ` Andrew Cooper
2013-11-21 15:03 ` [PATCH] " Tim Deegan
2013-11-21 15:07 ` Andrew Cooper
2013-11-21 15:13 ` Tim Deegan
2013-11-21 15:19 ` Keir Fraser
2013-11-21 15:32 ` Tim Deegan
2013-11-21 18:56 ` Andrew Cooper
2013-11-22 11:50 ` Jan Beulich
2013-11-22 11:54 ` Tim Deegan
2013-11-22 14:20 ` [PATCH v4 1/2] x86/hvm: fix segment validation Jan Beulich
2013-11-22 14:25 ` Andrew Cooper
2013-11-22 14:21 ` [PATCH v4 2/2] x86/hvm: clean up " Jan Beulich
2013-11-22 14:27 ` Andrew Cooper [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=528F69C7.7010902@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=dcb314@hotmail.com \
--cc=keir@xen.org \
--cc=tim@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.