Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1370520
| From | Russell King - ARM Linux <linux@arm.linux.org.uk> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 1/2] ARM: PIE infrastructure |
| Date | 2016-04-04 12:10 +0200 |
| Message-ID | <rk9Ck-1sf-47@gated-at.bofh.it> (permalink) |
| References | <rjKDT-8qi-13@gated-at.bofh.it> <rjKDT-8qi-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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.
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH 1/2] ARM: PIE infrastructure Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2016-04-03 09:30 +0200 Re: [PATCH 1/2] ARM: PIE infrastructure Russell King - ARM Linux <linux@arm.linux.org.uk> - 2016-04-04 12:10 +0200
csiph-web