From: cdall@cs.columbia.edu (Christoffer Dall)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/7] ARM: KVM: enforce page alignment for identity mapped code
Date: Wed, 3 Apr 2013 16:15:04 -0700 [thread overview]
Message-ID: <20130403231504.GD29227@gmail.com> (raw)
In-Reply-To: <515BFDC7.9020401@arm.com>
On Wed, Apr 03, 2013 at 11:00:39AM +0100, Marc Zyngier wrote:
> On 03/04/13 10:50, Will Deacon wrote:
> > On Tue, Apr 02, 2013 at 02:25:12PM +0100, Marc Zyngier wrote:
> >> We're about to move to a init procedure where we rely on the
> >> fact that the init code fits in a single page. Make sure we
> >> align the idmap text on a page boundary, and that the code is
> >> not bigger than a single page.
> >>
> >> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
> >> ---
> >> arch/arm/kernel/vmlinux.lds.S | 2 +-
> >> arch/arm/kvm/init.S | 7 +++++++
> >> 2 files changed, 8 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
> >> index b571484..d9dd265 100644
> >> --- a/arch/arm/kernel/vmlinux.lds.S
> >> +++ b/arch/arm/kernel/vmlinux.lds.S
> >> @@ -20,7 +20,7 @@
> >> VMLINUX_SYMBOL(__idmap_text_start) = .; \
> >> *(.idmap.text) \
> >> VMLINUX_SYMBOL(__idmap_text_end) = .; \
> >> - ALIGN_FUNCTION(); \
> >> + . = ALIGN(PAGE_SIZE); \
> >> VMLINUX_SYMBOL(__hyp_idmap_text_start) = .; \
> >> *(.hyp.idmap.text) \
> >> VMLINUX_SYMBOL(__hyp_idmap_text_end) = .;
> >> diff --git a/arch/arm/kvm/init.S b/arch/arm/kvm/init.S
> >> index 9f37a79..35a463f 100644
> >> --- a/arch/arm/kvm/init.S
> >> +++ b/arch/arm/kvm/init.S
> >> @@ -111,4 +111,11 @@ __do_hyp_init:
> >> .globl __kvm_hyp_init_end
> >> __kvm_hyp_init_end:
> >>
> >> + /*
> >> + * The above code *must* fit in a single page for the trampoline
> >> + * madness to work. Whoever decides to change it must make sure
> >> + * we map the right amount of memory for the trampoline to work.
> >> + * The line below ensures any breakage will get noticed.
This comment is a little funny. What's this about changing it? And why
madness? OK, it's a little mad.
I think the nice thing to explain here is why .org would complain - I
had to look in the AS reference to figure out that it will complain if
the location pointer is forwarded outside the section - if that is the
right reason?
> >> + */
> >> + .org __kvm_hyp_init + PAGE_SIZE
> >> .popsection
> >
> > What effect does this have on the size of the kernel image? I'd expect the
> > idmap code to be pretty small, so aligning to a page might be overkill a lot
> > of the time.
>
> So we're indeed wasting memory between the kernel and the HYP idmaps.
> The reason for this is to ensure that the init code is not spread across
> two pages, which would make the trampoline harder to allocate.
>
> If there's a way to ensure that the init.S code will fit a single page,
> then we can remove this ALIGN(PAGE_SIZE).
Just allocate a temporary page and copy the bit of code into there? It
should be easy enough to make sure it's location independent. We can
even give that page back later if we want and re-do the trick when a CPU
gets hot-plugged if we want. No?
-Christoffer
next prev parent reply other threads:[~2013-04-03 23:15 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-02 13:25 [PATCH 0/7] ARM: KVM: Revamping the HYP init code for fun and profit Marc Zyngier
2013-04-02 13:25 ` [PATCH 1/7] ARM: KVM: simplify HYP mapping population Marc Zyngier
2013-04-03 23:13 ` Christoffer Dall
2013-04-04 12:35 ` Marc Zyngier
2013-04-02 13:25 ` [PATCH 2/7] ARM: KVM: fix HYP mapping limitations around zero Marc Zyngier
2013-04-03 23:14 ` Christoffer Dall
2013-04-04 12:40 ` Marc Zyngier
2013-04-02 13:25 ` [PATCH 3/7] ARM: KVM: move to a KVM provided HYP idmap Marc Zyngier
2013-04-03 9:43 ` Will Deacon
2013-04-03 9:46 ` Marc Zyngier
2013-04-03 23:14 ` Christoffer Dall
2013-04-02 13:25 ` [PATCH 4/7] ARM: KVM: enforce page alignment for identity mapped code Marc Zyngier
2013-04-03 9:50 ` Will Deacon
2013-04-03 10:00 ` Marc Zyngier
2013-04-03 23:15 ` Christoffer Dall [this message]
2013-04-04 10:47 ` Marc Zyngier
2013-04-04 15:32 ` Christoffer Dall
2013-04-02 13:25 ` [PATCH 5/7] ARM: KVM: parametrize HYP page table freeing Marc Zyngier
2013-04-03 23:15 ` Christoffer Dall
2013-04-02 13:25 ` [PATCH 6/7] ARM: KVM: switch to a dual-step HYP init code Marc Zyngier
2013-04-03 10:07 ` Will Deacon
2013-04-03 10:38 ` Marc Zyngier
2013-04-03 23:15 ` Christoffer Dall
2013-04-04 11:05 ` Marc Zyngier
2013-04-03 23:15 ` Christoffer Dall
2013-04-04 12:52 ` Marc Zyngier
2013-04-04 22:10 ` Geoff Levand
2013-04-05 9:08 ` Marc Zyngier
2013-04-05 16:46 ` Geoff Levand
2013-04-05 16:54 ` Marc Zyngier
2013-04-18 15:54 ` Russell King - ARM Linux
2013-04-18 16:01 ` Marc Zyngier
2013-04-02 13:25 ` [PATCH 7/7] ARM: KVM: perform HYP initilization for hotplugged CPUs Marc Zyngier
2013-04-03 23:16 ` Christoffer Dall
2013-04-03 23:18 ` [PATCH 0/7] ARM: KVM: Revamping the HYP init code for fun and profit Christoffer Dall
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=20130403231504.GD29227@gmail.com \
--to=cdall@cs.columbia.edu \
--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).