From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
Ross Lagerwall <ross.lagerwall@citrix.com>, Wei Liu <wl@xen.org>,
Anthony PERARD <anthony.perard@citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
George Dunlap <george.dunlap@citrix.com>,
Julien Grall <julien@xen.org>,
Stefano Stabellini <sstabellini@kernel.org>,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH v2 4/5] x86/livepatch: introduce a basic live patch test to gitlab CI
Date: Tue, 5 Dec 2023 14:08:39 +0100 [thread overview]
Message-ID: <ZW8g144id8e1Aoy3@macbook> (raw)
In-Reply-To: <00de64fd-5669-424d-9b32-2342b5936f1a@suse.com>
On Tue, Dec 05, 2023 at 12:49:38PM +0100, Jan Beulich wrote:
> On 28.11.2023 11:03, Roger Pau Monne wrote:
> > Introduce a basic livepatch test using the interface to run self modifying
> > tests. The introduced test relies on changing a function from returning false
> > to returning true.
> >
> > To simplify the burden of keeping a patch that can be provided to
> > livepatch-build-tools, introduce two new files: one containing the unpatched
> > test functions, and another one that contains the patched forms of such
> > functions. Note that only the former is linked into the Xen image, the latter
> > is built but the object file is not consumed afterwards. Do this to assert
> > that the file containing the patched functions continues to build.
> >
> > Since livepatch testing will ensure that the functions are not patched previous
> > the applying the livepatch, allow the livepatch related tests to fail without
> > tainting the hypervisor.
> >
> > Note the livepatch tests are not run as part of the self modifying checks
> > executed during boot, as they would obviously fail.
> >
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> > ---
> > Changes since v1:
> > - New interface & test.
> > ---
> > tools/misc/xen-livepatch.c | 29 +++++++++++++++++++++++++++++
> > xen/arch/x86/Makefile | 2 ++
> > xen/arch/x86/include/asm/test-smc.h | 2 ++
> > xen/arch/x86/setup.c | 2 +-
> > xen/arch/x86/test-smc-lp-alt.c | 23 +++++++++++++++++++++++
> > xen/arch/x86/test-smc-lp.c | 23 +++++++++++++++++++++++
> > xen/arch/x86/test-smc.c | 11 ++++++++++-
> > xen/include/public/sysctl.h | 6 +++++-
> > 8 files changed, 95 insertions(+), 3 deletions(-)
> > create mode 100644 xen/arch/x86/test-smc-lp-alt.c
> > create mode 100644 xen/arch/x86/test-smc-lp.c
>
> Can these (and perhaps also the one file introduced earlier in the series)
> perhaps become xen/arch/x86/test/smc*.c?
Yes, sure, I don't see why not.
> > --- /dev/null
> > +++ b/xen/arch/x86/test-smc-lp-alt.c
> > @@ -0,0 +1,23 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +
> > +#include <asm/test-smc.h>
> > +
> > +/*
> > + * Interesting case because `return false` can be encoded as an xor
> > + * instruction, which is shorter than `return true` which is a mov instruction,
> > + * and also shorter than a jmp instruction.
> > + */
>
> I'm a little wary of this comment: "mov $1, %al" is two bytes only, just like
Don't we need to zero the high part of the register also? Or since
the return type is a bool the compiler could assume it's truncated by
the caller?
> "xor %eax, %eax" is.
GCC 13.2 (from godbolt) generates at -O2:
mov $0x1,%eax
ret
Which is 5 bytes long mov insn.
The return false case is:
xor %eax,%eax
ret
I can adjust to mention this specific behavior.
> > +bool cf_check test_lp_insn_replacement(void)
>
> What's the purpose of the cf_check here?
Because it's added to the array of test functions to call in
test_smc(). Doesn't it need cf_check in that case?
Thanks, Roger.
next prev parent reply other threads:[~2023-12-05 13:09 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-28 10:03 [PATCH v2 0/5] xen/x86: add testing for self modifying code and livepatch Roger Pau Monne
2023-11-28 10:03 ` [PATCH v2 1/5] x86/livepatch: set function alignment to ensure minimal function size Roger Pau Monne
2023-11-30 16:55 ` Jan Beulich
2023-11-30 17:37 ` Roger Pau Monné
2023-12-01 6:53 ` Jan Beulich
2023-12-01 8:50 ` Roger Pau Monné
2023-12-01 9:41 ` Jan Beulich
2023-12-01 10:21 ` Roger Pau Monné
2023-12-01 10:59 ` Jan Beulich
2023-12-01 11:31 ` Roger Pau Monné
2023-12-01 12:59 ` Jan Beulich
2023-12-05 13:42 ` Andrew Cooper
2023-12-05 15:01 ` Roger Pau Monné
2023-12-05 15:14 ` Jan Beulich
2023-12-05 15:36 ` Roger Pau Monné
2023-12-05 15:45 ` Jan Beulich
2023-11-28 10:03 ` [PATCH v2 2/5] automation/alpine: add elfutils-dev Roger Pau Monne
2023-11-30 2:56 ` Stefano Stabellini
2023-11-28 10:03 ` [PATCH v2 3/5] xen/x86: introduce self modifying code test Roger Pau Monne
2023-11-30 2:58 ` Stefano Stabellini
2023-12-01 11:52 ` Roger Pau Monné
2023-11-30 17:02 ` Jan Beulich
2023-12-01 12:08 ` Roger Pau Monné
2023-12-02 2:36 ` Stefano Stabellini
2023-11-28 10:03 ` [PATCH v2 4/5] x86/livepatch: introduce a basic live patch test to gitlab CI Roger Pau Monne
2023-12-05 11:49 ` Jan Beulich
2023-12-05 13:08 ` Roger Pau Monné [this message]
2023-12-05 13:23 ` Jan Beulich
2023-11-28 10:03 ` [PATCH v2 5/5] automation: add x86-64 livepatching test Roger Pau Monne
2023-11-30 3:03 ` Stefano Stabellini
2023-12-13 10:55 ` Roger Pau Monné
2023-12-14 2:08 ` Stefano Stabellini
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=ZW8g144id8e1Aoy3@macbook \
--to=roger.pau@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=konrad.wilk@oracle.com \
--cc=ross.lagerwall@citrix.com \
--cc=sstabellini@kernel.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.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.