All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: "Wei Liu" <wei.liu2@citrix.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Cc: Jan Beulich <JBeulich@suse.com>, Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH 2/7] x86/alt: Clean up struct alt_instr and its users
Date: Mon, 12 Feb 2018 17:53:41 +0000	[thread overview]
Message-ID: <57842b04-07e3-3393-0589-2e677bfdc6ad@citrix.com> (raw)
In-Reply-To: <20180212171837.hyhm5ngl7bx4doui@citrix.com>

On 12/02/18 17:18, Wei Liu wrote:
> On Mon, Feb 12, 2018 at 04:52:21PM +0000, Roger Pau Monné wrote:
>> On Mon, Feb 12, 2018 at 11:23:02AM +0000, Andrew Cooper wrote:
>>>  * Rename some fields for consistency and clarity, and use standard types.
>>>  * Don't opencode the use of ALT_{ORIG,REPL}_PTR().
>>>
>>> No functional change.
>>>
>>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
>> Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
>>
>>> ---
>>> CC: Jan Beulich <JBeulich@suse.com>
>>> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>>> CC: Roger Pau Monné <roger.pau@citrix.com>
>>> CC: Wei Liu <wei.liu2@citrix.com>
>>> ---
>>>  xen/arch/x86/alternative.c        | 24 ++++++++++++------------
>>>  xen/include/asm-x86/alternative.h | 12 ++++++------
>>>  2 files changed, 18 insertions(+), 18 deletions(-)
>>>
>>> diff --git a/xen/arch/x86/alternative.c b/xen/arch/x86/alternative.c
>>> index 5c8b6f6..f8ddab5 100644
>>> --- a/xen/arch/x86/alternative.c
>>> +++ b/xen/arch/x86/alternative.c
>>> @@ -163,8 +163,6 @@ void init_or_livepatch apply_alternatives(const struct alt_instr *start,
>>>                                            const struct alt_instr *end)
>>>  {
>>>      const struct alt_instr *a;
>>> -    u8 *instr, *replacement;
>>> -    u8 insnbuf[MAX_PATCH_LEN];
>>>  
>>>      printk(KERN_INFO "alt table %p -> %p\n", start, end);
>>>  
>>> @@ -179,23 +177,25 @@ void init_or_livepatch apply_alternatives(const struct alt_instr *start,
>>>       */
>>>      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));
>>> +        uint8_t *orig = ALT_ORIG_PTR(a);
>>> +        uint8_t *repl = ALT_REPL_PTR(a);
>>> +        uint8_t buf[MAX_PATCH_LEN];
>>> +
>>> +        BUG_ON(a->repl_len > a->orig_len);
>>> +        BUG_ON(a->orig_len > sizeof(buf));
>> Would be nice to have an assembly BUILD_BUG_ON equivalent so that this
>> could be turned into a compile time check and added to ALTINSTR_ENTRY.
>  This function is also used to livepatch the hypervisor.
>
>  I would actually suggest not use BUG_ON here instead but I didn't want
>  to add noise to the problem at hand. :-)

We've got some assembler time checks already, and I've introduced more
in patch 5 which include this sizeof(buf) one.

As for BUG_ON()s, I considered dropping them as well, but the only thing
which will happen if these are skipped is that we will crash in less
obvious ways in the patch points.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-02-12 17:53 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-12 11:23 [PATCH 0/7] x86/alternatives: Support for automatic padding calculations Andrew Cooper
2018-02-12 11:23 ` [PATCH 1/7] x86/alt: Drop unused alternative infrastructure Andrew Cooper
2018-02-12 12:30   ` Wei Liu
2018-02-12 15:56   ` Roger Pau Monné
2018-02-12 15:58     ` Andrew Cooper
2018-02-13 14:22   ` Jan Beulich
2018-02-13 14:41     ` Andrew Cooper
2018-02-13 15:33       ` Jan Beulich
2018-02-14 10:02       ` Jan Beulich
2018-02-12 11:23 ` [PATCH 2/7] x86/alt: Clean up struct alt_instr and its users Andrew Cooper
2018-02-12 12:30   ` Wei Liu
2018-02-12 16:52   ` Roger Pau Monné
2018-02-12 17:18     ` Wei Liu
2018-02-12 17:53       ` Andrew Cooper [this message]
2018-02-13 14:26   ` Jan Beulich
2018-02-21 21:22   ` Konrad Rzeszutek Wilk
2018-02-12 11:23 ` [PATCH 3/7] x86/alt: Clean up the assembly used to generate alternatives Andrew Cooper
2018-02-12 12:30   ` Wei Liu
2018-02-12 17:26   ` Roger Pau Monné
2018-02-12 17:54     ` Andrew Cooper
2018-02-13 14:37   ` Jan Beulich
2018-02-23 14:03     ` Andrew Cooper
2018-02-23 15:12       ` Jan Beulich
2018-02-23 16:24         ` Andrew Cooper
2018-02-23 17:28           ` Jan Beulich
2018-02-12 11:23 ` [PATCH 4/7] x86/asm: Remove opencoded uses of altinstruction_entry Andrew Cooper
2018-02-12 12:30   ` Wei Liu
2018-02-12 12:34     ` Andrew Cooper
2018-02-13  9:56     ` Jan Beulich
2018-02-13 10:07       ` Andrew Cooper
2018-02-13 11:10         ` Jan Beulich
2018-02-12 12:52   ` Wei Liu
2018-02-12 17:46   ` Roger Pau Monné
2018-02-12 17:59     ` Andrew Cooper
2018-02-14  9:53   ` Jan Beulich
2018-02-12 11:23 ` [PATCH 5/7] x86/alt: Support for automatic padding calculations Andrew Cooper
2018-02-12 14:39   ` Wei Liu
2018-02-12 15:04     ` Andrew Cooper
2018-02-12 18:41       ` Roger Pau Monné
2018-02-12 18:45         ` Andrew Cooper
2018-02-12 18:09   ` Roger Pau Monné
2018-02-13  9:45   ` Roger Pau Monné
2018-02-13 10:09     ` Andrew Cooper
2018-02-13 10:26       ` Roger Pau Monné
2018-02-14  9:46   ` Jan Beulich
2018-02-12 11:23 ` [PATCH 6/7] x86/alt: Drop explicit padding of origin sites Andrew Cooper
2018-02-12 14:39   ` Wei Liu
2018-02-12 18:12   ` Roger Pau Monné
2018-02-14  9:53   ` Jan Beulich
2018-02-12 11:23 ` [PATCH 7/7] x86/build: Use new .nop directive when available Andrew Cooper
2018-02-12 14:40   ` Wei Liu
2018-02-13 11:08   ` Roger Pau Monné

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=57842b04-07e3-3393-0589-2e677bfdc6ad@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=roger.pau@citrix.com \
    --cc=wei.liu2@citrix.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 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.