From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Tim Deegan <tim@xen.org>, xen-devel@lists.xen.org
Cc: Keir Fraser <keir@xen.org>, Jan Beulich <jbeulich@suse.com>
Subject: Re: [PATCH v2] x86_emulate: split the {reg, mem} union in struct operand.
Date: Thu, 26 Mar 2015 12:42:14 +0000 [thread overview]
Message-ID: <5513FEA6.70909@citrix.com> (raw)
In-Reply-To: <1427373657-6977-1-git-send-email-tim@xen.org>
On 26/03/15 12:40, Tim Deegan wrote:
> In the hopes of making any future errors along the lines of XSA-123
> into clean crashes instead of memory corruption bugs.
>
> Signed-off-by: Tim Deegan <tim@xen.org>
> CC: Keir Fraser <keir@xen.org>
> CC: Jan Beulich <jbeulich@suse.com>
> CC: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> v2: tweak poison values (Andrew Cooper)
> ---
> xen/arch/x86/x86_emulate/x86_emulate.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c
> index c082c9e..9dbf063 100644
> --- a/xen/arch/x86/x86_emulate/x86_emulate.c
> +++ b/xen/arch/x86/x86_emulate/x86_emulate.c
> @@ -319,7 +319,7 @@ struct operand {
> /* Original operand value. */
> unsigned long orig_val;
>
> - union {
> + struct {
> /* OP_REG: Pointer to register field. */
> unsigned long *reg;
> /* OP_MEM: Segment and offset. */
> @@ -329,6 +329,11 @@ struct operand {
> } mem;
> };
> };
> +#ifdef __x86_64__
> +#define REG_POISON ((unsigned long *) 0x8086000000008086UL) /* non-canonical */
> +#else
> +#define REG_POISON NULL /* 32-bit builds are for user-space, so NULL is OK. */
> +#endif
>
> typedef union {
> uint64_t mmx;
> @@ -1447,14 +1452,15 @@ x86_emulate(
> unsigned int op_bytes, def_op_bytes, ad_bytes, def_ad_bytes;
> bool_t lock_prefix = 0;
> int override_seg = -1, rc = X86EMUL_OKAY;
> - struct operand src, dst;
> + struct operand src = { .reg = REG_POISON };
> + struct operand dst = { .reg = REG_POISON };
> enum x86_swint_type swint_type;
> DECLARE_ALIGNED(mmval_t, mmval);
> /*
> * Data operand effective address (usually computed from ModRM).
> * Default is a memory operand relative to segment DS.
> */
> - struct operand ea = { .type = OP_MEM };
> + struct operand ea = { .type = OP_MEM, .reg = REG_POISON };
> ea.mem.seg = x86_seg_ds; /* gcc may reject anon union initializer */
>
> ctxt->retire.byte = 0;
next prev parent reply other threads:[~2015-03-26 12:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-26 12:16 [PATCH] x86_emulate: split the {reg, mem} union in struct operand Tim Deegan
2015-03-26 12:25 ` Andrew Cooper
2015-03-26 12:34 ` Tim Deegan
2015-03-26 12:40 ` [PATCH v2] " Tim Deegan
2015-03-26 12:42 ` Andrew Cooper [this message]
2015-03-27 14:31 ` Jan Beulich
2015-03-27 14:44 ` [PATCH v3] " Tim Deegan
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=5513FEA6.70909@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=keir@xen.org \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.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.