From: "Jan Beulich" <JBeulich@suse.com>
To: Feng Wu <feng.wu@intel.com>
Cc: keir.xen@gmail.com, xen-devel@lists.xen.org
Subject: Re: [PATCH 2/3] x86: Port the basic alternative mechanism from Linux to Xen
Date: Tue, 27 May 2014 16:35:10 +0100 [thread overview]
Message-ID: <5384CCCE0200007800016027@mail.emea.novell.com> (raw)
In-Reply-To: <1401089273-16425-3-git-send-email-feng.wu@intel.com>
>>> On 26.05.14 at 09:27, <feng.wu@intel.com> wrote:
> +void __init arch_init_ideal_nops(void)
> +{
> + switch (boot_cpu_data.x86_vendor)
> + {
> + case X86_VENDOR_INTEL:
> + /*
> + * Due to a decoder implementation quirk, some
> + * specific Intel CPUs actually perform better with
> + * the "k8_nops" than with the SDM-recommended NOPs.
> + */
> + if ( boot_cpu_data.x86 == 6 &&
> + boot_cpu_data.x86_model >= 0x0f &&
> + boot_cpu_data.x86_model != 0x1c &&
> + boot_cpu_data.x86_model != 0x26 &&
> + boot_cpu_data.x86_model != 0x27 &&
> + boot_cpu_data.x86_model < 0x30 )
Indentation.
> +static void __init add_nops(void *insns, unsigned int len)
> +{
> + while ( len > 0 )
> + {
> + unsigned int noplen = len;
> + if ( noplen > ASM_NOP_MAX )
> + noplen = ASM_NOP_MAX;
Again.
> +static void __init apply_alternatives(struct alt_instr *start, struct alt_instr *end)
> +{
> + struct alt_instr *a;
> + u8 *instr, *replacement;
> + u8 insnbuf[MAX_PATCH_LEN];
> +
> + printk("%s: alt table %p -> %p\n", __func__, start, end);
This should be at most INFO level, and likely doesn't need the __func__
prefix.
> + /*
> + * The scan order should be from start to end. A later scanned
> + * alternative code can overwrite a previous scanned alternative code.
> + * Some kernel functions (e.g. memcpy, memset, etc) use this order to
> + * patch code.
> + *
> + * So be careful if you want to change the scan order to any other
> + * order.
> + */
> + for ( a = start; a < end; a++ )
> + {
> + instr = (u8 *)&a->instr_offset + a->instr_offset;
> + replacement = (u8 *)&a->repl_offset + a->repl_offset;
> + BUG_ON(a->replacementlen > a->instrlen);
> + BUG_ON(a->instrlen > sizeof(insnbuf));
> + BUG_ON(a->cpuid >= NCAPINTS * 32);
> + if ( !boot_cpu_has(a->cpuid) )
> + continue;
> +
> + memcpy(insnbuf, replacement, a->replacementlen);
> +
> + /* 0xe8 is a relative jump; fix the offset. */
> + if ( *insnbuf == 0xe8 && a->replacementlen == 5 )
So as said in the conversation with Andrew already, either fix the
comment or make the code match it (by masking the low bit).
Jan
next prev parent reply other threads:[~2014-05-27 15:35 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
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 [this message]
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=5384CCCE0200007800016027@mail.emea.novell.com \
--to=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).