Re: [Xen-devel] [PATCH 5/7] x86/alt: Support for automatic padding calculations

2018-02-14 Thread Jan Beulich
>>> On 12.02.18 at 12:23, wrote: > --- a/xen/arch/x86/alternative.c > +++ b/xen/arch/x86/alternative.c > @@ -180,13 +180,37 @@ void init_or_livepatch apply_alternatives(const struct > alt_instr *start, > uint8_t *orig = ALT_ORIG_PTR(a); > uint8_t *repl = ALT_REPL_PTR(a); >

Re: [Xen-devel] [PATCH 5/7] x86/alt: Support for automatic padding calculations

2018-02-13 Thread Roger Pau Monné
On Tue, Feb 13, 2018 at 10:09:15AM +, Andrew Cooper wrote: > On 13/02/2018 09:45, Roger Pau Monné wrote: > > On Mon, Feb 12, 2018 at 11:23:05AM +, Andrew Cooper wrote: > >> .macro ALTERNATIVE oldinstr, newinstr, feature > >> .L\@_orig_s: > >> \oldinstr > >> .L\@_orig_e: > >> + .

Re: [Xen-devel] [PATCH 5/7] x86/alt: Support for automatic padding calculations

2018-02-13 Thread Andrew Cooper
On 13/02/2018 09:45, Roger Pau Monné wrote: > On Mon, Feb 12, 2018 at 11:23:05AM +, Andrew Cooper wrote: >> .macro ALTERNATIVE oldinstr, newinstr, feature >> .L\@_orig_s: >> \oldinstr >> .L\@_orig_e: >> + .skip (-((repl_len(1) - orig_len) > 0) * (repl_len(1) - orig_len)), >> 0x90 >

Re: [Xen-devel] [PATCH 5/7] x86/alt: Support for automatic padding calculations

2018-02-13 Thread Roger Pau Monné
On Mon, Feb 12, 2018 at 11:23:05AM +, Andrew Cooper wrote: > .macro ALTERNATIVE oldinstr, newinstr, feature > .L\@_orig_s: > \oldinstr > .L\@_orig_e: > + .skip (-((repl_len(1) - orig_len) > 0) * (repl_len(1) - orig_len)), 0x90 clang chokes on this expression, because of the negatio

Re: [Xen-devel] [PATCH 5/7] x86/alt: Support for automatic padding calculations

2018-02-12 Thread Andrew Cooper
On 12/02/18 18:41, Roger Pau Monné wrote: > On Mon, Feb 12, 2018 at 03:04:21PM +, Andrew Cooper wrote: >> On 12/02/18 14:39, Wei Liu wrote: >>> On Mon, Feb 12, 2018 at 11:23:05AM +, Andrew Cooper wrote: .macro ALTERNATIVE oldinstr, newinstr, feature .L\@_orig_s: \oldin

Re: [Xen-devel] [PATCH 5/7] x86/alt: Support for automatic padding calculations

2018-02-12 Thread Roger Pau Monné
On Mon, Feb 12, 2018 at 03:04:21PM +, Andrew Cooper wrote: > On 12/02/18 14:39, Wei Liu wrote: > > On Mon, Feb 12, 2018 at 11:23:05AM +, Andrew Cooper wrote: > >> .macro ALTERNATIVE oldinstr, newinstr, feature > >> .L\@_orig_s: > >> \oldinstr > >> .L\@_orig_e: > >> + .skip (-((r

Re: [Xen-devel] [PATCH 5/7] x86/alt: Support for automatic padding calculations

2018-02-12 Thread Roger Pau Monné
On Mon, Feb 12, 2018 at 11:23:05AM +, Andrew Cooper wrote: > The correct amount of padding in an origin patch site can be calculated > automatically, based on the relative lengths of the replacements. > > This requires a bit of trickery to calculate correctly, especially in the > ALTENRATIVE_2

Re: [Xen-devel] [PATCH 5/7] x86/alt: Support for automatic padding calculations

2018-02-12 Thread Andrew Cooper
On 12/02/18 14:39, Wei Liu wrote: > On Mon, Feb 12, 2018 at 11:23:05AM +, Andrew Cooper wrote: >> The correct amount of padding in an origin patch site can be calculated >> automatically, based on the relative lengths of the replacements. >> >> This requires a bit of trickery to calculate corre

Re: [Xen-devel] [PATCH 5/7] x86/alt: Support for automatic padding calculations

2018-02-12 Thread Wei Liu
On Mon, Feb 12, 2018 at 11:23:05AM +, Andrew Cooper wrote: > The correct amount of padding in an origin patch site can be calculated > automatically, based on the relative lengths of the replacements. > > This requires a bit of trickery to calculate correctly, especially in the > ALTENRATIVE_2

[Xen-devel] [PATCH 5/7] x86/alt: Support for automatic padding calculations

2018-02-12 Thread Andrew Cooper
The correct amount of padding in an origin patch site can be calculated automatically, based on the relative lengths of the replacements. This requires a bit of trickery to calculate correctly, especially in the ALTENRATIVE_2 case where a branchless max() calculation in needed. The calculation is