xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Feng Wu <feng.wu@intel.com>, xen-devel@lists.xen.org
Cc: keir.xen@gmail.com, JBeulich@suse.com
Subject: Re: [PATCH 1/3] x86: Add definitions for NOP operation
Date: Mon, 26 May 2014 16:04:48 +0100	[thread overview]
Message-ID: <53835810.2010905@citrix.com> (raw)
In-Reply-To: <1401089273-16425-2-git-send-email-feng.wu@intel.com>

On 26/05/2014 08:27, Feng Wu wrote:
> This patch adds definitions for different length of NOP operation.
>
> Signed-off-by: Feng Wu <feng.wu@intel.com>
> ---
>  xen/include/asm-x86/nops.h | 71 ++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 71 insertions(+)
>  create mode 100644 xen/include/asm-x86/nops.h
>
> diff --git a/xen/include/asm-x86/nops.h b/xen/include/asm-x86/nops.h
> new file mode 100644
> index 0000000..f38df58
> --- /dev/null
> +++ b/xen/include/asm-x86/nops.h
> @@ -0,0 +1,71 @@
> +#ifndef __X86_ASM_NOPS_H__
> +#define __X86_ASM_NOPS_H__
> +
> +#include <xen/stringify.h>

It appears that we have two competing ways of performing preprocessor
stringification.  __stringify() from stringify.h, and STR() from config.h

As neither are used very much, it would be nice to consolidate down to
one, although I am not fussed which.

> +
> +/*
> + * Define nops for use with alternative().
> + */
> +
> +/*
> + * Opteron 64bit nops
> + * 1: nop
> + * 2: osp nop
> + * 3: osp osp nop
> + * 4: osp osp osp nop
> + */
> +#define K8_NOP1 0x90
> +#define K8_NOP2 0x66,K8_NOP1
> +#define K8_NOP3 0x66,K8_NOP2
> +#define K8_NOP4 0x66,K8_NOP3
> +#define K8_NOP5 K8_NOP3,K8_NOP2
> +#define K8_NOP6 K8_NOP3,K8_NOP3
> +#define K8_NOP7 K8_NOP4,K8_NOP3
> +#define K8_NOP8 K8_NOP4,K8_NOP4
> +
> +/*
> + * P6 nops
> + * uses eax dependencies (Intel-recommended choice)
> + * 1: nop
> + * 2: osp nop
> + * 3: nopl (%eax)
> + * 4: nopl 0x00(%eax)
> + * 5: nopl 0x00(%eax,%eax,1)
> + * 6: osp nopl 0x00(%eax,%eax,1)
> + * 7: nopl 0x00000000(%eax)
> + * 8: nopl 0x00000000(%eax,%eax,1)
> + *    Note: All the above are assumed to be a single instruction.
> + *          There is kernel code that depends on this.
> + */
> +#define P6_NOP1 0x90
> +#define P6_NOP2 0x66,0x90
> +#define P6_NOP3 0x0f,0x1f,0x00
> +#define P6_NOP4 0x0f,0x1f,0x40,0
> +#define P6_NOP5 0x0f,0x1f,0x44,0x00,0
> +#define P6_NOP6 0x66,0x0f,0x1f,0x44,0x00,0
> +#define P6_NOP7 0x0f,0x1f,0x80,0,0,0,0
> +#define P6_NOP8 0x0f,0x1f,0x84,0x00,0,0,0,0
> +
> +#ifdef __ASSEMBLY__
> +#define _ASM_MK_NOP(x) .byte x
> +#else
> +#define _ASM_MK_NOP(x) ".byte " __stringify(x) "\n"
> +#endif
> +
> +#define ASM_NOP1 _ASM_MK_NOP(K8_NOP1)
> +#define ASM_NOP2 _ASM_MK_NOP(K8_NOP2)
> +#define ASM_NOP3 _ASM_MK_NOP(K8_NOP3)
> +#define ASM_NOP4 _ASM_MK_NOP(K8_NOP4)
> +#define ASM_NOP5 _ASM_MK_NOP(K8_NOP5)
> +#define ASM_NOP6 _ASM_MK_NOP(K8_NOP6)
> +#define ASM_NOP7 _ASM_MK_NOP(K8_NOP7)
> +#define ASM_NOP8 _ASM_MK_NOP(K8_NOP8)
> +
> +#define ASM_NOP_MAX 8
> +
> +#ifndef __ASSEMBLY__
> +extern const unsigned char * const *ideal_nops;
> +extern void arch_init_ideal_nops(void);

No need for extern on a function declaration.

~Andrew

> +#endif
> +
> +#endif /* __X86_ASM_NOPS_H__ */

  reply	other threads:[~2014-05-26 15:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-26  7:27 [PATCH 0/3] x86: Use alternative mechanism to define CLAC/STAC Feng Wu
2014-05-26  7:27 ` [PATCH 1/3] x86: Add definitions for NOP operation Feng Wu
2014-05-26 15:04   ` Andrew Cooper [this message]
2014-05-26  7:27 ` [PATCH 2/3] x86: Port the basic alternative mechanism from Linux to Xen Feng Wu
2014-05-26 15:40   ` Andrew Cooper
2014-05-26 16:16     ` Jan Beulich
2014-05-27  6:13     ` Wu, Feng
2014-05-27  9:30       ` Jan Beulich
2014-05-27 15:35   ` Jan Beulich
2014-05-26  7:27 ` [PATCH 3/3] x86: Use alternative mechanism to define CLAC/STAC Feng Wu
2014-05-26 15:49   ` Andrew Cooper
2014-05-26 16:18     ` Jan Beulich
2014-05-26 16:22       ` Andrew Cooper
2014-05-27  6:24     ` Wu, Feng
2014-05-27 15:42   ` Jan Beulich

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=53835810.2010905@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=feng.wu@intel.com \
    --cc=keir.xen@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).