From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] ARM: PIE infrastructure
Date: Mon, 4 Apr 2016 11:00:52 +0100 [thread overview]
Message-ID: <20160404100052.GS19428@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1459668234-16033-2-git-send-email-alexandre.belloni@free-electrons.com>
On Sun, Apr 03, 2016 at 09:23:53AM +0200, Alexandre Belloni wrote:
> +struct pie_chunk *__pie_load_data(struct gen_pool *pool, void *code_start,
> + void *code_end, bool phys)
> +{
> + struct pie_chunk *chunk;
> + unsigned long offset;
> + int ret;
> + size_t code_sz;
> + unsigned long base;
> + phys_addr_t pbase;
> +
> + chunk = kzalloc(sizeof(*chunk), GFP_KERNEL);
> + if (!chunk) {
> + ret = -ENOMEM;
> + goto err;
> + }
> +
> + code_sz = code_end - code_start;
> + chunk->pool = pool;
> + chunk->sz = code_sz;
> +
> + base = gen_pool_alloc(pool, chunk->sz);
> + if (!base) {
> + ret = -ENOMEM;
> + goto err_free;
> + }
> +
> + pbase = gen_pool_virt_to_phys(pool, base);
> + chunk->addr = (unsigned long)__arm_ioremap_exec(pbase, code_sz, false);
> + if (!chunk->addr) {
> + ret = -ENOMEM;
> + goto err_remap;
> + }
> +
> + /* Copy chunk specific code/data */
> + fncpy((char *)chunk->addr, code_start, code_sz);
Sorry, NAK. This abuses fncpy(). There is extensive documentation on
the proper use of this in asm/fncpy.h, and anything that does not
conform, or which uses memcpy() to copy functions, gets an immediate
NAK from me. fncpy() exists to avoid people doing broken things, and
it's written in such a way to help people get it right.
--
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
next prev parent reply other threads:[~2016-04-04 10:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-03 7:23 [PATCH 0/2] Embedding Position Independent Executables Alexandre Belloni
2016-04-03 7:23 ` [PATCH 1/2] ARM: PIE infrastructure Alexandre Belloni
2016-04-04 10:00 ` Russell King - ARM Linux [this message]
2016-04-22 23:15 ` Alexandre Belloni
2016-04-25 10:14 ` Dave P Martin
2016-04-27 19:39 ` Russell King - ARM Linux
2016-04-03 7:23 ` [PATCH 2/2] ARM: at91: pm: switch to the " Alexandre Belloni
2016-04-03 12:16 ` kbuild test robot
2016-04-04 10:02 ` Russell King - ARM Linux
2016-04-04 9:57 ` [PATCH 0/2] Embedding Position Independent Executables Russell King - ARM Linux
2016-04-04 15:11 ` Heiko Stuebner
2016-04-22 22:49 ` Alexandre Belloni
2016-04-23 9:50 ` Afzal Mohammed
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=20160404100052.GS19428@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=linux-arm-kernel@lists.infradead.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).