live-patching.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Lawrence <joe.lawrence@redhat.com>
To: live-patching@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kbuild@vger.kernel.org
Subject: Re: [RFC PATCH v6 11/12] livepatch/selftests: add data relocations test
Date: Wed, 16 Feb 2022 12:12:12 -0500	[thread overview]
Message-ID: <Yg0wbJNYeFIwaisP@redhat.com> (raw)
In-Reply-To: <20220216163940.228309-12-joe.lawrence@redhat.com>

On Wed, Feb 16, 2022 at 11:39:39AM -0500, Joe Lawrence wrote:
> 
> [ ... snip ... ]
> 
> diff --git a/lib/livepatch/test_klp_convert_data.c b/lib/livepatch/test_klp_convert_data.c
> new file mode 100644
> index 000000000000..142422664159
> --- /dev/null
> +++ b/lib/livepatch/test_klp_convert_data.c
> @@ -0,0 +1,190 @@
> +// SPDX-License-Identifier: GPL-2.0
> +// Copyright (C) 2021 Joe Lawrence <joe.lawrence@redhat.com>
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> +#include <linux/module.h>
> +#include <linux/kernel.h>
> +#include <linux/cache.h>
> +#include <linux/livepatch.h>
> +#include "test_klp_convert.h"
> +
> +/* Small global */
> +int *p_global_small = &global_small;
> +
> +/* Small global (const) */
> +// .rela.data.rel.ro, .rela.rodata supported ???:
> +int * const p_const_global_small = &const_global_small;
> +
> +/* Small file-static */
> +static int *p_static_small = &static_small;
> +
> +/* Small file-static (constant) */
> +static int * const p_static_const_small = &static_const_small;
> +
> +/* Large global */
> +int *p_global_large[4] = {
> +	&global_large[0], &global_large[1],
> +	&global_large[2], &global_large[3],
> +};
> +
> +/* Large global (const) */
> +// .rela.data.rel.ro, .rela.rodata supported ???:
> +int * const p_const_global_large[4] = {
> +	&const_global_large[0], &const_global_large[1],
> +	&const_global_large[2], &const_global_large[3],
> +};
> +
> +/* Large file-static global */
> +static int *p_static_large[4] = {
> +	&static_large[0], &static_large[1],
> +	&static_large[2], &static_large[3],
> +};
> +
> +/* Large file-static (const) */
> +static int * const p_static_const_large[4] = {
> +	&static_const_large[0], &static_const_large[1],
> +	&static_const_large[2], &static_const_large[3],
> +};
> +
> +// .rela.data.rel.ro, .rela.rodata supported ???:
> +static int * __ro_after_init p_static_ro_after_init = &static_ro_after_init;
> +static int * __read_mostly p_static_read_mostly = &static_read_mostly;

This started getting a bit repetitive, and maybe belongs to its own set
of klp-convert unit tests (as the selftests seem closer to integration
type tests).

Anyway, I left in the .rela.<read-only> type relocations as mentioned in
the [RFC PATCH v6 03/12] livepatch: Add klp-convert tool [1].  We can
talk about whether such sections should be supported over there.

As for this test, it currently crashes ppc64le as it generates a late
klp-relocation type R_PPC64_ADDR64 in a section that was marked RO.
(IIRC such ppc64le data relocations to other .rela.<text> sections are
safe as they aren't marked RO.)

[1] https://lore.kernel.org/lkml/Yg0qgtSFNQx5Mo1i@redhat.com/

-- Joe


  reply	other threads:[~2022-02-16 17:12 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-16 16:39 [RFC PATCH v6 00/12] livepatch: klp-convert tool Joe Lawrence
2022-02-16 16:39 ` [RFC PATCH v6 01/12] livepatch: Create and include UAPI headers Joe Lawrence
2022-04-14  8:50   ` Petr Mladek
2022-02-16 16:39 ` [RFC PATCH v6 02/12] kbuild: Support for symbols.klp creation Joe Lawrence
2022-04-14  9:35   ` Petr Mladek
2022-04-14 17:59     ` Nicolas Schier
2022-04-18 18:12       ` Joe Lawrence
2022-02-16 16:39 ` [RFC PATCH v6 03/12] livepatch: Add klp-convert tool Joe Lawrence
2022-02-16 16:46   ` Joe Lawrence
2022-02-16 16:56   ` Joe Lawrence
2022-04-14 15:03   ` elf API: was: " Petr Mladek
2022-04-18 18:01     ` Joe Lawrence
2023-02-06 18:16   ` Marcos Paulo de Souza
2022-02-16 16:39 ` [RFC PATCH v6 04/12] livepatch: Add klp-convert annotation helpers Joe Lawrence
2022-02-16 16:39 ` [RFC PATCH v6 05/12] modpost: Integrate klp-convert Joe Lawrence
2022-02-16 16:39 ` [RFC PATCH v6 06/12] livepatch: Add sample livepatch module Joe Lawrence
2023-02-07 12:52   ` Marcos Paulo de Souza
2022-02-16 16:39 ` [RFC PATCH v6 07/12] documentation: Update on livepatch elf format Joe Lawrence
2022-02-16 16:39 ` [RFC PATCH v6 08/12] livepatch/selftests: add klp-convert Joe Lawrence
2022-02-16 16:39 ` [RFC PATCH v6 09/12] livepatch/selftests: test multiple sections Joe Lawrence
2022-02-16 16:39 ` [RFC PATCH v6 10/12] livepatch/selftests: add __asm__ symbol renaming examples Joe Lawrence
2022-02-16 17:03   ` Joe Lawrence
2022-02-16 16:39 ` [RFC PATCH v6 11/12] livepatch/selftests: add data relocations test Joe Lawrence
2022-02-16 17:12   ` Joe Lawrence [this message]
2022-02-16 16:39 ` [RFC PATCH v6 12/12] livepatch/selftests: add static keys test Joe Lawrence
2022-02-16 17:17 ` [RFC PATCH v6 00/12] livepatch: klp-convert tool Joe Lawrence
2023-02-07 12:57 ` Marcos Paulo de Souza
2023-02-07 15:54   ` Joe Lawrence

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=Yg0wbJNYeFIwaisP@redhat.com \
    --to=joe.lawrence@redhat.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=live-patching@vger.kernel.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).