From: jamie@jamieiles.com (Jamie Iles)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC 4/5] ARM: P2V: introduce phys_to_virt/virt_to_phys runtime patching
Date: Wed, 9 Feb 2011 12:17:01 +0000 [thread overview]
Message-ID: <20110209121701.GD2818@pulham.picochip.com> (raw)
In-Reply-To: <E1PaDPa-00023l-CR@rmk-PC.arm.linux.org.uk>
Hi Russell,
I haven't been using the runtime patching, but building picoxcell based
off of todays next I'm seeing a pretty harmless warning. Fixup below.
Jamie
On Tue, Jan 04, 2011 at 08:23:18PM +0000, Russell King - ARM Linux wrote:
> This idea came from Nicolas, Eric Miao produced an initial version,
> which was then rewritten into this.
>
> Patch the physical to virtual translations at runtime. As we modify
> the code, this makes it incompatible with XIP kernels, but on allows
> is to achieve this with minimal loss of performance.
>
> As many translations are of the form:
>
> physical = virtual + (PHYS_OFFSET - PAGE_OFFSET)
> virtual = physical - (PHYS_OFFSET - PAGE_OFFSET)
>
> we generate an 'add' instruction for __virt_to_phys(), and a 'sub'
> instruction for __phys_to_virt(). We calculate at run time (PHYS_OFFSET
> - PAGE_OFFSET) by comparing the address prior to MMU initialization with
> where it should be once the MMU has been initialized, and place this
> constant into the above add/sub instructions.
>
> Once we have (PHYS_OFFSET - PAGE_OFFSET), we can calcuate the real
> PHYS_OFFSET as PAGE_OFFSET is a build-time constant, and save this for
> the C-mode PHYS_OFFSET variable definition to use.
>
> At present, we are unable to support Realview with Sparsemem enabled
> as this uses a complex mapping function, and MSM as this requires a
> constant which will not fit in our math instruction.
>
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> ---
> arch/arm/Kconfig | 14 +++++++++
> arch/arm/include/asm/memory.h | 55 ++++++++++++++++++++++++++++--------
> arch/arm/kernel/head.S | 63 +++++++++++++++++++++++++++++++++++++++++
> arch/arm/kernel/module.c | 23 ++++++++++++++-
> arch/arm/kernel/setup.c | 2 +-
> arch/arm/kernel/vmlinux.lds.S | 4 ++
> 6 files changed, 147 insertions(+), 14 deletions(-)
>
[...]
> diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
> index 0c1bb68..6a42e17 100644
> --- a/arch/arm/kernel/module.c
> +++ b/arch/arm/kernel/module.c
> @@ -276,12 +276,28 @@ struct mod_unwind_map {
> const Elf_Shdr *txt_sec;
> };
>
> +static const Elf_Shdr *find_mod_section(const Elf32_Ehdr *hdr,
> + const Elf_Shdr *sechdrs, const char *name)
> +{
> + const Elf_Shdr *s, *se;
> + const char *secstrs = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
> +
> + for (s = sechdrs, se = sechdrs + hdr->e_shnum; s < se; s++)
> + if (strcmp(name, secstrs + s->sh_name) == 0)
> + return s;
> +
> + return NULL;
> +}
> +
> +extern void fixup_pv_table(const void *, unsigned long);
> +
> int module_finalize(const Elf32_Ehdr *hdr, const Elf_Shdr *sechdrs,
> struct module *mod)
> {
> + const Elf_Shdr *s = NULL;
> #ifdef CONFIG_ARM_UNWIND
> const char *secstrs = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
> - const Elf_Shdr *s, *sechdrs_end = sechdrs + hdr->e_shnum;
> + const Elf_Shdr *sechdrs_end = sechdrs + hdr->e_shnum;
> struct mod_unwind_map maps[ARM_SEC_MAX];
> int i;
>
> @@ -323,6 +339,11 @@ int module_finalize(const Elf32_Ehdr *hdr, const Elf_Shdr *sechdrs,
> maps[i].txt_sec->sh_addr,
> maps[i].txt_sec->sh_size);
> #endif
> +#ifdef CONFIG_ARM_PATCH_PHYS_VIRT
> + s = find_mod_section(hdr, sechdrs, ".pv_table");
> + if (s)
> + fixup_pv_table((void *)s->sh_addr, s->sh_size);
> +#endif
If we don't have CONFIG_ARM_PATCH_PHYS_VIRT defined then we get:
arch/arm/kernel/module.c:272: warning: ?find_mod_section? defined but not used
8<------
diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
index 74e25ab..ba65805 100644
--- a/arch/arm/kernel/module.c
+++ b/arch/arm/kernel/module.c
@@ -269,6 +269,7 @@ struct mod_unwind_map {
const Elf_Shdr *txt_sec;
};
+#ifdef CONFIG_ARM_PATCH_PHYS_VIRT
static const Elf_Shdr *find_mod_section(const Elf32_Ehdr *hdr,
const Elf_Shdr *sechdrs, const char *name)
{
@@ -281,6 +282,7 @@ static const Elf_Shdr *find_mod_section(const Elf32_Ehdr *hdr,
return NULL;
}
+#endif
extern void fixup_pv_table(const void *, unsigned long);
next prev parent reply other threads:[~2011-02-09 12:17 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-04 20:20 [RFC 0/5] runtime P2V translations Russell King - ARM Linux
2011-01-04 20:20 ` Russell King - ARM Linux
2011-01-04 20:22 ` [RFC 1/5] ARM: P2V: separate PHYS_OFFSET from platform definitions Russell King - ARM Linux
2011-01-04 20:22 ` Russell King - ARM Linux
2011-01-04 21:10 ` Nicolas Pitre
2011-01-04 21:10 ` Nicolas Pitre
2011-01-05 22:30 ` Russell King - ARM Linux
2011-01-05 22:30 ` Russell King - ARM Linux
2011-01-04 21:23 ` Uwe Kleine-König
2011-01-04 21:23 ` Uwe Kleine-König
2011-01-05 0:04 ` Russell King - ARM Linux
2011-01-05 0:04 ` Russell King - ARM Linux
2011-01-05 6:25 ` Uwe Kleine-König
2011-01-05 6:25 ` Uwe Kleine-König
2011-01-05 3:28 ` viresh kumar
2011-01-05 3:28 ` viresh kumar
2011-01-05 17:04 ` H Hartley Sweeten
2011-01-05 17:04 ` H Hartley Sweeten
2011-01-06 5:02 ` Magnus Damm
2011-01-06 5:02 ` Magnus Damm
2011-02-07 15:57 ` Tony Lindgren
2011-02-07 15:57 ` Tony Lindgren
2011-02-07 16:36 ` Jean-Christophe PLAGNIOL-VILLARD
2011-02-07 16:36 ` Jean-Christophe PLAGNIOL-VILLARD
2011-02-08 11:22 ` Wan ZongShun
2011-02-08 11:22 ` Wan ZongShun
2011-02-17 5:33 ` Kukjin Kim
2011-02-17 5:33 ` Kukjin Kim
2011-02-17 15:16 ` Eric Miao
2011-02-17 15:16 ` Eric Miao
2011-02-17 18:07 ` JD (Jiandong) Zheng
2011-02-17 18:07 ` JD (Jiandong) Zheng
2011-01-04 20:22 ` [RFC 2/5] ARM: P2V: avoid initializers and assembly using PHYS_OFFSET Russell King - ARM Linux
2011-01-04 20:22 ` Russell King - ARM Linux
2011-01-04 21:12 ` Nicolas Pitre
2011-01-04 21:12 ` Nicolas Pitre
2011-01-06 8:51 ` Sascha Hauer
2011-01-06 8:51 ` Sascha Hauer
2011-01-06 9:08 ` Russell King - ARM Linux
2011-01-06 9:08 ` Russell King - ARM Linux
2011-02-07 15:59 ` Tony Lindgren
2011-02-07 15:59 ` Tony Lindgren
2011-02-07 16:51 ` Uwe Kleine-König
2011-02-07 16:51 ` Uwe Kleine-König
2011-02-07 16:52 ` Uwe Kleine-König
2011-02-07 16:52 ` Uwe Kleine-König
2011-02-17 5:36 ` Kukjin Kim
2011-02-17 5:36 ` Kukjin Kim
2011-02-17 14:11 ` Russell King - ARM Linux
2011-02-17 14:11 ` Russell King - ARM Linux
2011-02-17 16:19 ` David Brown
2011-02-17 16:19 ` David Brown
2011-02-17 15:16 ` Eric Miao
2011-02-17 15:16 ` Eric Miao
2011-01-04 20:22 ` [RFC 3/5] ARM: P2V: make head.S use PLAT_PHYS_OFFSET Russell King - ARM Linux
2011-01-04 21:13 ` Nicolas Pitre
2011-02-07 16:12 ` Tony Lindgren
2011-01-04 20:23 ` [RFC 4/5] ARM: P2V: introduce phys_to_virt/virt_to_phys runtime patching Russell King - ARM Linux
2011-01-04 21:27 ` Nicolas Pitre
2011-01-05 0:08 ` Russell King - ARM Linux
2011-02-07 16:15 ` Tony Lindgren
2011-02-09 12:17 ` Jamie Iles [this message]
2011-02-09 13:06 ` Russell King - ARM Linux
2011-01-04 20:23 ` [RFC 5/5] ARM: P2V: extend to 16-bit translation offsets Russell King - ARM Linux
2011-01-04 21:41 ` Nicolas Pitre
2011-01-05 0:15 ` Russell King - ARM Linux
2011-01-04 23:14 ` David Brown
2011-01-04 23:18 ` David Brown
2011-01-05 0:13 ` Russell King - ARM Linux
2011-02-07 16:19 ` Tony Lindgren
2011-02-17 14:15 ` [RFC 0/5] runtime P2V translations Russell King - ARM Linux
2011-02-17 14:15 ` Russell King - ARM Linux
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=20110209121701.GD2818@pulham.picochip.com \
--to=jamie@jamieiles.com \
--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 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.