linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: lauraa@codeaurora.org (Laura Abbott)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv3 5/7] arm64: Factor out fixmap initialiation from ioremap
Date: Mon, 25 Aug 2014 11:34:34 -0700	[thread overview]
Message-ID: <53FB81BA.2040908@codeaurora.org> (raw)
In-Reply-To: <CAGXu5jK64cOKkh0pSj63P3O0ZXuyCJET7w-W=9qd6b74pxRH4w@mail.gmail.com>

On 8/22/2014 10:45 PM, Kees Cook wrote:
> On Wed, Aug 20, 2014 at 6:20 PM, Laura Abbott <lauraa@codeaurora.org> wrote:
>>
>> The fixmap API was originally added for arm64 for
>> early_ioremap purposes. It can be used for other purposes too
>> so move the initialization from ioremap to somewhere more
>> generic. This makes it obvious where the fixmap is being set
>> up and allows for a cleaner implementation of __set_fixmap.
>>
>> Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
>> ---
...
>> +void __init early_fixmap_init(void)
>> +{
>> +       pgd_t *pgd;
>> +       pud_t *pud;
>> +       pmd_t *pmd;
>> +       unsigned long addr = FIXADDR_START;
>> +
>> +       pgd = pgd_offset_k(addr);
>> +       pgd_populate(&init_mm, pgd, bm_pud);
>> +       pud = pud_offset(pgd, addr);
>> +       pud_populate(&init_mm, pud, bm_pmd);
>> +       pmd = pmd_offset(pud, addr);
>> +       pmd_populate_kernel(&init_mm, pmd, bm_pte);
>> +
>> +       /*
>> +        * The boot-ioremap range spans multiple pmds, for which
>> +        * we are not preparted:
>> +        */
>> +       BUILD_BUG_ON((__fix_to_virt(FIX_BTMAP_BEGIN) >> PMD_SHIFT)
>> +                    != (__fix_to_virt(FIX_BTMAP_END) >> PMD_SHIFT));
>> +
>> +       if ((pmd != fixmap_pmd(fix_to_virt(FIX_BTMAP_BEGIN)))
>> +            || pmd != fixmap_pmd(fix_to_virt(FIX_BTMAP_END))) {
>> +               WARN_ON(1);
>> +               pr_warn("pmd %p != %p, %p\n",
>> +                       pmd, fixmap_pmd(fix_to_virt(FIX_BTMAP_BEGIN)),
>> +                       fixmap_pmd(fix_to_virt(FIX_BTMAP_END)));
>> +               pr_warn("fix_to_virt(FIX_BTMAP_BEGIN): %08lx\n",
>> +                       fix_to_virt(FIX_BTMAP_BEGIN));
>> +               pr_warn("fix_to_virt(FIX_BTMAP_END):   %08lx\n",
>> +                       fix_to_virt(FIX_BTMAP_END));
>> +
>> +               pr_warn("FIX_BTMAP_END:       %d\n", FIX_BTMAP_END);
>> +               pr_warn("FIX_BTMAP_BEGIN:     %d\n", FIX_BTMAP_BEGIN);
>> +       }
>> +}
>> +
>> +void __set_fixmap(enum fixed_addresses idx,
>> +                              phys_addr_t phys, pgprot_t flags)
>> +{
>> +       unsigned long addr = __fix_to_virt(idx);
>> +       pte_t *pte;
>> +
>> +       if (idx >= __end_of_fixed_addresses) {
>> +               BUG();
>> +               return;
>> +       }
> 
> Is it worth cleaning this up into BUG_ON instead of BUG; return; ?
> 
> Reviewed-by: Kees Cook <keescook@chromium.org>
> 
> -Kees

I'm guessing this was set up for error handling even if CONFIG_BUG
is turned off.

Thanks,
Laura

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation

  reply	other threads:[~2014-08-25 18:34 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-21  1:20 [PATCHv3 0/7] Better page protections for arm64 Laura Abbott
2014-08-21  1:20 ` [PATCHv3 1/7] arm64: Treat handle_arch_irq as a function pointer Laura Abbott
     [not found]   ` <CAGXu5jLur_gdXs2X5BCmxB6L5HwgyP12jkrufK7bpS0Cxhp_+Q@mail.gmail.com>
2014-08-25 18:23     ` Laura Abbott
2014-08-28 17:02   ` Catalin Marinas
2014-08-21  1:20 ` [PATCHv3 2/7] arm64: Switch to ldr for loading the stub vectors Laura Abbott
2014-08-21  9:30   ` Mark Rutland
2014-08-21  1:20 ` [PATCHv3 3/7] arm64: Move cpu_resume into the text section Laura Abbott
2014-08-25 20:34   ` Stephen Boyd
2014-08-26  0:43     ` Laura Abbott
2014-08-26  1:08       ` Stephen Boyd
2014-08-21  1:20 ` [PATCHv3 4/7] arm64: Move some head.text functions to executable section Laura Abbott
2014-08-21 10:34   ` Mark Rutland
2014-08-21 21:42     ` Laura Abbott
2014-08-22  9:48       ` Mark Rutland
2014-08-26  0:32         ` Laura Abbott
2014-08-26 17:45           ` Mark Rutland
2014-08-21  1:20 ` [PATCHv3 5/7] arm64: Factor out fixmap initialiation from ioremap Laura Abbott
2014-08-23  5:45   ` Kees Cook
2014-08-25 18:34     ` Laura Abbott [this message]
2014-08-21  1:20 ` [PATCHv3 6/7] arm64: use fixmap for text patching when text is RO Laura Abbott
2014-08-23  5:51   ` Kees Cook
2014-08-25 18:38     ` Laura Abbott
2014-08-26 18:36       ` Mark Rutland
2014-08-21  1:20 ` [PATCHv3 7/7] arm64: add better page protections to arm64 Laura Abbott
2014-08-23  5:59   ` Kees Cook
2014-08-25 19:04     ` Laura Abbott

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=53FB81BA.2040908@codeaurora.org \
    --to=lauraa@codeaurora.org \
    --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).