lkml.org 
[lkml]   [2016]   [Apr]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] ARM: PIE infrastructure
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.

\
 
 \ /
  Last update: 2016-04-04 12:21    [W:0.080 / U:0.144 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site