All of lore.kernel.org
 help / color / mirror / Atom feed
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
	Geoff Levand <geoff@infradead.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	James Morse <james.morse@arm.com>,
	Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>,
	Dave Young <dyoung@redhat.com>,
	"kexec@lists.infradead.org" <kexec@lists.infradead.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v33 05/14] arm64: mm: allow for unmapping part of kernel mapping
Date: Mon, 27 Mar 2017 22:49:16 +0900	[thread overview]
Message-ID: <20170327134906.GB4454@fireball> (raw)
In-Reply-To: <CAKv+Gu-YCGfymnaWzNfxNyoyPwYGCAkPViC_Lwf0WAgnRPD2WQ@mail.gmail.com>

Ard,

On Fri, Mar 24, 2017 at 10:57:02AM +0000, Ard Biesheuvel wrote:
> On 23 March 2017 at 11:43, AKASHI Takahiro <takahiro.akashi@linaro.org> wrote:
> > On Tue, Mar 21, 2017 at 10:35:53AM +0000, James Morse wrote:
> >> Hi Akashi,
> >>
> >> On 15/03/17 09:59, AKASHI Takahiro wrote:
> >> > create_pgd_mapping() is enhanced here so that it will accept
> >> > PAGE_KERNEL_INVALID protection attribute and unmap a given range of memory.
> >> >
> >> > The feature will be used in a later kdump patch to implement the protection
> >> > against possible corruption of crash dump kernel memory which is to be set
> >> > aside from ther other memory on primary kernel.
> >>
> >> Nit: ther- > the
> >
> > Fix it.
> >
> >> > Note that, in this implementation, it assumes that all the range of memory
> >> > to be processed is mapped in page-level since the only current user is
> >> > kdump where page mappings are also required.
> >>
> >> Using create_pgd_mapping() like this means the mappings will be updated via the
> >> fixmap which is unnecessary as the page tables will be part of mapped memory. In
> >
> > This might be a reason that we would go for (un)map_kernel_range()
> > over create_pgd_mapping() (? not sure)
> >
> 
> Yes, that is why I suggested it. We already use it to unmap the init
> segment at the end of boot, but I do take your point about it being
> documented as operating on kernel VMAs only.
> 
> Looking at the code, it shouldn't matter (it does not touch or reason
> about VMAs at all, it only walks the page tables and unmaps them), but
> I agree it is better not to rely on that.

OK

> But instead of clearing all permissions, which apparently requires
> changes to alloc_init_pte(), and introduces the restriction that the
> region should be mapped down to pages, could we not simply clear
> PTE_VALID on the region, like we do for debug_pagealloc()?

Now that we are only using page-level mappings for crash kernel memory,
__change_page_common() should work and it even has no concerns that
James pointed out.
I will update my patch soon.

Thanks,
-Takahiro AKASHI

> 
> >> the worst case this adds an extra tlbi for every 2MB of crash image when we map
> >> or unmap it. I don't think this matters.
> >>
> >> This code used to be __init and it is the only user of FIX_PTE, so there won't
> >> be any existing runtime users. The two arch_kexec_unprotect_crashkres() calls in
> >> kexec are both protected by the kexec_mutex, and the call in hibernate happens
> >> after disable_nonboot_cpus(), so these callers can't race with each other.
> >>
> >> This looks safe to me.
> >>
> >>
> >> > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> >> > index d28dbcf596b6..cb359a3927ef 100644
> >> > --- a/arch/arm64/mm/mmu.c
> >> > +++ b/arch/arm64/mm/mmu.c
> >> > @@ -128,7 +128,10 @@ static void alloc_init_pte(pmd_t *pmd, unsigned long addr,
> >> >     do {
> >> >             pte_t old_pte = *pte;
> >> >
> >> > -           set_pte(pte, pfn_pte(pfn, prot));
> >> > +           if (pgprot_val(prot))
> >> > +                   set_pte(pte, pfn_pte(pfn, prot));
> >> > +           else
> >> > +                   pte_clear(null, null, pte);
> >>
> >> Lowercase NULLs? This relies on these values never being used... __set_fixmap()
> >> in the same file passes &init_mm and the address, can we do the same to be
> >> consistent?
> >
> > OK.
> >
> > Thanks,
> > -Takahiro AKASHI
> >
> >>
> >> >             pfn++;
> >> >
> >> >             /*
> >>
> >> Reviewed-by: James Morse <james.morse@arm.com>
> >>
> >>
> >> Thanks,
> >>
> >> James
> >>
> >>
> >
> > _______________________________________________
> > linux-arm-kernel mailing list
> > linux-arm-kernel@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

WARNING: multiple messages have this Message-ID (diff)
From: takahiro.akashi@linaro.org (AKASHI Takahiro)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v33 05/14] arm64: mm: allow for unmapping part of kernel mapping
Date: Mon, 27 Mar 2017 22:49:16 +0900	[thread overview]
Message-ID: <20170327134906.GB4454@fireball> (raw)
In-Reply-To: <CAKv+Gu-YCGfymnaWzNfxNyoyPwYGCAkPViC_Lwf0WAgnRPD2WQ@mail.gmail.com>

Ard,

On Fri, Mar 24, 2017 at 10:57:02AM +0000, Ard Biesheuvel wrote:
> On 23 March 2017 at 11:43, AKASHI Takahiro <takahiro.akashi@linaro.org> wrote:
> > On Tue, Mar 21, 2017 at 10:35:53AM +0000, James Morse wrote:
> >> Hi Akashi,
> >>
> >> On 15/03/17 09:59, AKASHI Takahiro wrote:
> >> > create_pgd_mapping() is enhanced here so that it will accept
> >> > PAGE_KERNEL_INVALID protection attribute and unmap a given range of memory.
> >> >
> >> > The feature will be used in a later kdump patch to implement the protection
> >> > against possible corruption of crash dump kernel memory which is to be set
> >> > aside from ther other memory on primary kernel.
> >>
> >> Nit: ther- > the
> >
> > Fix it.
> >
> >> > Note that, in this implementation, it assumes that all the range of memory
> >> > to be processed is mapped in page-level since the only current user is
> >> > kdump where page mappings are also required.
> >>
> >> Using create_pgd_mapping() like this means the mappings will be updated via the
> >> fixmap which is unnecessary as the page tables will be part of mapped memory. In
> >
> > This might be a reason that we would go for (un)map_kernel_range()
> > over create_pgd_mapping() (? not sure)
> >
> 
> Yes, that is why I suggested it. We already use it to unmap the init
> segment at the end of boot, but I do take your point about it being
> documented as operating on kernel VMAs only.
> 
> Looking at the code, it shouldn't matter (it does not touch or reason
> about VMAs at all, it only walks the page tables and unmaps them), but
> I agree it is better not to rely on that.

OK

> But instead of clearing all permissions, which apparently requires
> changes to alloc_init_pte(), and introduces the restriction that the
> region should be mapped down to pages, could we not simply clear
> PTE_VALID on the region, like we do for debug_pagealloc()?

Now that we are only using page-level mappings for crash kernel memory,
__change_page_common() should work and it even has no concerns that
James pointed out.
I will update my patch soon.

Thanks,
-Takahiro AKASHI

> 
> >> the worst case this adds an extra tlbi for every 2MB of crash image when we map
> >> or unmap it. I don't think this matters.
> >>
> >> This code used to be __init and it is the only user of FIX_PTE, so there won't
> >> be any existing runtime users. The two arch_kexec_unprotect_crashkres() calls in
> >> kexec are both protected by the kexec_mutex, and the call in hibernate happens
> >> after disable_nonboot_cpus(), so these callers can't race with each other.
> >>
> >> This looks safe to me.
> >>
> >>
> >> > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> >> > index d28dbcf596b6..cb359a3927ef 100644
> >> > --- a/arch/arm64/mm/mmu.c
> >> > +++ b/arch/arm64/mm/mmu.c
> >> > @@ -128,7 +128,10 @@ static void alloc_init_pte(pmd_t *pmd, unsigned long addr,
> >> >     do {
> >> >             pte_t old_pte = *pte;
> >> >
> >> > -           set_pte(pte, pfn_pte(pfn, prot));
> >> > +           if (pgprot_val(prot))
> >> > +                   set_pte(pte, pfn_pte(pfn, prot));
> >> > +           else
> >> > +                   pte_clear(null, null, pte);
> >>
> >> Lowercase NULLs? This relies on these values never being used... __set_fixmap()
> >> in the same file passes &init_mm and the address, can we do the same to be
> >> consistent?
> >
> > OK.
> >
> > Thanks,
> > -Takahiro AKASHI
> >
> >>
> >> >             pfn++;
> >> >
> >> >             /*
> >>
> >> Reviewed-by: James Morse <james.morse@arm.com>
> >>
> >>
> >> Thanks,
> >>
> >> James
> >>
> >>
> >
> > _______________________________________________
> > linux-arm-kernel mailing list
> > linux-arm-kernel at lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2017-03-27 13:51 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-15  9:56 [PATCH v33 00/14] add kdump support AKASHI Takahiro
2017-03-15  9:56 ` AKASHI Takahiro
2017-03-15  9:59 ` [PATCH v33 01/14] memblock: add memblock_clear_nomap() AKASHI Takahiro
2017-03-15  9:59   ` AKASHI Takahiro
2017-03-15  9:59   ` AKASHI Takahiro
2017-03-15  9:59 ` [PATCH v33 02/14] memblock: add memblock_cap_memory_range() AKASHI Takahiro
2017-03-15  9:59   ` AKASHI Takahiro
2017-03-15  9:59   ` AKASHI Takahiro
2017-03-15  9:59 ` [PATCH v33 03/14] arm64: limit memory regions based on DT property, usable-memory-range AKASHI Takahiro
2017-03-15  9:59   ` AKASHI Takahiro
2017-03-15  9:59 ` [PATCH v33 04/14] arm64: kdump: reserve memory for crash dump kernel AKASHI Takahiro
2017-03-15  9:59   ` AKASHI Takahiro
2017-03-17 10:46   ` David Woodhouse
2017-03-17 10:46     ` David Woodhouse
2017-03-17 11:31     ` AKASHI Takahiro
2017-03-17 11:31       ` AKASHI Takahiro
2017-03-17 11:32       ` David Woodhouse
2017-03-17 11:32         ` David Woodhouse
2017-03-15  9:59 ` [PATCH v33 05/14] arm64: mm: allow for unmapping part of kernel mapping AKASHI Takahiro
2017-03-15  9:59   ` AKASHI Takahiro
2017-03-21 10:35   ` James Morse
2017-03-21 10:35     ` James Morse
2017-03-23 11:43     ` AKASHI Takahiro
2017-03-23 11:43       ` AKASHI Takahiro
2017-03-24 10:57       ` Ard Biesheuvel
2017-03-24 10:57         ` Ard Biesheuvel
2017-03-27 13:49         ` AKASHI Takahiro [this message]
2017-03-27 13:49           ` AKASHI Takahiro
2017-03-21 11:16   ` Ard Biesheuvel
2017-03-21 11:16     ` Ard Biesheuvel
2017-03-23 10:56     ` AKASHI Takahiro
2017-03-23 10:56       ` AKASHI Takahiro
2017-03-15  9:59 ` [PATCH v33 06/14] arm64: kdump: protect crash dump kernel memory AKASHI Takahiro
2017-03-15  9:59   ` AKASHI Takahiro
2017-03-15  9:59 ` [PATCH v33 07/14] arm64: hibernate: preserve kdump image around hibernation AKASHI Takahiro
2017-03-15  9:59   ` AKASHI Takahiro
2017-03-21 18:25   ` James Morse
2017-03-21 18:25     ` James Morse
2017-03-23 11:29     ` AKASHI Takahiro
2017-03-23 11:29       ` AKASHI Takahiro
2017-03-15  9:59 ` [PATCH v33 08/14] arm64: kdump: implement machine_crash_shutdown() AKASHI Takahiro
2017-03-15  9:59   ` AKASHI Takahiro
2017-03-15  9:59 ` [PATCH v33 09/14] arm64: kdump: add VMCOREINFO's for user-space tools AKASHI Takahiro
2017-03-15  9:59   ` AKASHI Takahiro
2017-03-15  9:59 ` [PATCH v33 10/14] arm64: kdump: provide /proc/vmcore file AKASHI Takahiro
2017-03-15  9:59   ` AKASHI Takahiro
2017-03-15  9:59 ` [PATCH v33 11/14] arm64: kdump: enable kdump in defconfig AKASHI Takahiro
2017-03-15  9:59   ` AKASHI Takahiro
2017-03-15  9:59 ` [PATCH v33 12/14] Documentation: kdump: describe arm64 port AKASHI Takahiro
2017-03-15  9:59   ` AKASHI Takahiro
2017-03-15 10:00 ` [PATCH v33 13/14] Documentation: dt: chosen properties for arm64 kdump AKASHI Takahiro
2017-03-15 10:00   ` AKASHI Takahiro
2017-03-15 10:00   ` AKASHI Takahiro
2017-03-15 10:01 ` [PATCH v33 14/14] efi/libstub/arm*: Set default address and size cells values for an empty dtb AKASHI Takahiro
2017-03-15 10:01   ` AKASHI Takahiro
2017-03-15 10:01   ` AKASHI Takahiro
2017-03-15 11:41 ` [PATCH v33 00/14] add kdump support David Woodhouse
2017-03-15 11:41   ` David Woodhouse
2017-03-16  0:23   ` AKASHI Takahiro
2017-03-16  0:23     ` AKASHI Takahiro
2017-03-16 10:29     ` David Woodhouse
2017-03-16 10:29       ` David Woodhouse
2017-03-17 11:43 ` David Woodhouse
2017-03-17 11:43   ` David Woodhouse
2017-03-17 14:02   ` David Woodhouse
2017-03-17 14:02     ` David Woodhouse
2017-03-17 15:04     ` Mark Rutland
2017-03-17 15:04       ` Mark Rutland
2017-03-17 15:33     ` Mark Rutland
2017-03-17 15:33       ` Mark Rutland
2017-03-17 15:47       ` David Woodhouse
2017-03-17 15:47         ` David Woodhouse
2017-03-17 16:24         ` Mark Rutland
2017-03-17 16:24           ` Mark Rutland
2017-03-17 16:59           ` Marc Zyngier
2017-03-17 16:59             ` Marc Zyngier
2017-03-17 17:10             ` Marc Zyngier
2017-03-17 17:10               ` Marc Zyngier
2017-03-17 20:03               ` David Woodhouse
2017-03-17 20:03                 ` David Woodhouse
2017-03-21  7:34           ` AKASHI Takahiro
2017-03-21  7:34             ` AKASHI Takahiro
2017-03-21  9:42             ` David Woodhouse
2017-03-21  9:42               ` David Woodhouse
2017-03-20 12:42 ` Pratyush Anand
2017-03-20 12:42   ` Pratyush Anand
2017-03-22 16:55 ` Goel, Sameer
2017-03-22 16:55   ` Goel, Sameer

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=20170327134906.GB4454@fireball \
    --to=takahiro.akashi@linaro.org \
    --cc=ard.biesheuvel@linaro.org \
    --cc=bauerman@linux.vnet.ibm.com \
    --cc=catalin.marinas@arm.com \
    --cc=dyoung@redhat.com \
    --cc=geoff@infradead.org \
    --cc=james.morse@arm.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=will.deacon@arm.com \
    /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.