* [REVIEW][PATCH 9/9] signal/powerpc: Use force_sig_fault where appropriate
From: Eric W. Biederman @ 2018-09-18 17:58 UTC (permalink / raw)
To: linux-kernel
Cc: linux-arch, linuxppc-dev, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, Eric W. Biederman
In-Reply-To: <878t3yitze.fsf@xmission.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
arch/powerpc/kernel/process.c | 9 +-------
arch/powerpc/mm/fault.c | 9 +-------
arch/powerpc/platforms/cell/spu_base.c | 4 ++--
arch/powerpc/platforms/cell/spufs/fault.c | 26 +++++++----------------
4 files changed, 12 insertions(+), 36 deletions(-)
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 913c5725cdb2..553a396e7fc1 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -620,8 +620,6 @@ void do_send_trap(struct pt_regs *regs, unsigned long address,
void do_break (struct pt_regs *regs, unsigned long address,
unsigned long error_code)
{
- siginfo_t info;
-
current->thread.trap_nr = TRAP_HWBKPT;
if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code,
11, SIGSEGV) == NOTIFY_STOP)
@@ -634,12 +632,7 @@ void do_break (struct pt_regs *regs, unsigned long address,
hw_breakpoint_disable();
/* Deliver the signal to userspace */
- clear_siginfo(&info);
- info.si_signo = SIGTRAP;
- info.si_errno = 0;
- info.si_code = TRAP_HWBKPT;
- info.si_addr = (void __user *)address;
- force_sig_info(SIGTRAP, &info, current);
+ force_sig_fault(SIGTRAP, TRAP_HWBKPT, (void __user *)address, current);
}
#endif /* CONFIG_PPC_ADV_DEBUG_REGS */
diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
index 406d0e0ef096..1697e903bbf2 100644
--- a/arch/powerpc/mm/fault.c
+++ b/arch/powerpc/mm/fault.c
@@ -165,17 +165,10 @@ static noinline int bad_access(struct pt_regs *regs, unsigned long address)
static int do_sigbus(struct pt_regs *regs, unsigned long address,
vm_fault_t fault)
{
- siginfo_t info;
-
if (!user_mode(regs))
return SIGBUS;
current->thread.trap_nr = BUS_ADRERR;
- clear_siginfo(&info);
- info.si_signo = SIGBUS;
- info.si_errno = 0;
- info.si_code = BUS_ADRERR;
- info.si_addr = (void __user *)address;
#ifdef CONFIG_MEMORY_FAILURE
if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
unsigned int lsb = 0; /* shutup gcc */
@@ -194,7 +187,7 @@ static int do_sigbus(struct pt_regs *regs, unsigned long address,
}
#endif
- force_sig_info(SIGBUS, &info, current);
+ force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *)address, current);
return 0;
}
diff --git a/arch/powerpc/platforms/cell/spu_base.c b/arch/powerpc/platforms/cell/spu_base.c
index 0c45cdbac4cf..7f12c7b78c0f 100644
--- a/arch/powerpc/platforms/cell/spu_base.c
+++ b/arch/powerpc/platforms/cell/spu_base.c
@@ -50,11 +50,11 @@ struct cbe_spu_info cbe_spu_info[MAX_NUMNODES];
EXPORT_SYMBOL_GPL(cbe_spu_info);
/*
- * The spufs fault-handling code needs to call force_sig_info to raise signals
+ * The spufs fault-handling code needs to call force_sig_fault to raise signals
* on DMA errors. Export it here to avoid general kernel-wide access to this
* function
*/
-EXPORT_SYMBOL_GPL(force_sig_info);
+EXPORT_SYMBOL_GPL(force_sig_fault);
/*
* Protects cbe_spu_info and spu->number.
diff --git a/arch/powerpc/platforms/cell/spufs/fault.c b/arch/powerpc/platforms/cell/spufs/fault.c
index 83cf58daaa79..971ac43b5d60 100644
--- a/arch/powerpc/platforms/cell/spufs/fault.c
+++ b/arch/powerpc/platforms/cell/spufs/fault.c
@@ -36,42 +36,32 @@
static void spufs_handle_event(struct spu_context *ctx,
unsigned long ea, int type)
{
- siginfo_t info;
-
if (ctx->flags & SPU_CREATE_EVENTS_ENABLED) {
ctx->event_return |= type;
wake_up_all(&ctx->stop_wq);
return;
}
- clear_siginfo(&info);
-
switch (type) {
case SPE_EVENT_INVALID_DMA:
- info.si_signo = SIGBUS;
- info.si_code = BUS_OBJERR;
+ force_sig_fault(SIGBUS, BUS_OBJERR, NULL, current);
break;
case SPE_EVENT_SPE_DATA_STORAGE:
- info.si_signo = SIGSEGV;
- info.si_addr = (void __user *)ea;
- info.si_code = SEGV_ACCERR;
ctx->ops->restart_dma(ctx);
+ force_sig_fault(SIGSEGV, SEGV_ACCERR, (void __user *)ea,
+ current);
break;
case SPE_EVENT_DMA_ALIGNMENT:
- info.si_signo = SIGBUS;
/* DAR isn't set for an alignment fault :( */
- info.si_code = BUS_ADRALN;
+ force_sig_fault(SIGBUS, BUS_ADRALN, NULL, current);
break;
case SPE_EVENT_SPE_ERROR:
- info.si_signo = SIGILL;
- info.si_addr = (void __user *)(unsigned long)
- ctx->ops->npc_read(ctx) - 4;
- info.si_code = ILL_ILLOPC;
+ force_sig_fault(
+ SIGILL, ILL_ILLOPC,
+ (void __user *)(unsigned long)
+ ctx->ops->npc_read(ctx) - 4, current);
break;
}
-
- if (info.si_signo)
- force_sig_info(info.si_signo, &info, current);
}
int spufs_handle_class0(struct spu_context *ctx)
--
2.17.1
^ permalink raw reply related
* Re: [PATCH 3/3] scripts/dtc: Update to upstream version v1.4.7-14-gc86da84d30e4
From: Rob Herring @ 2018-09-18 18:55 UTC (permalink / raw)
To: Frank Rowand
Cc: devicetree, linux-kernel@vger.kernel.org,
moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
linuxppc-dev
In-Reply-To: <f9684222-fae0-c305-d48a-be77ebb985a3@gmail.com>
On Fri, Sep 14, 2018 at 2:32 PM Frank Rowand <frowand.list@gmail.com> wrote:
>
> On 09/13/18 13:28, Rob Herring wrote:
> > Major changes are I2C and SPI bus checks, YAML output format (for
> > future validation), some new libfdt functions, and more libfdt
> > validation of dtbs.
> >
> > The YAML addition adds an optional dependency on libyaml. pkg-config is
> > used to test for it and pkg-config became a kconfig dependency in 4.18.
>
> For Ubuntu, the libyaml dependency is provided by the packages:
>
> libyaml-0-2
> libyaml-dev
Yes, but as it is not yet required by anything in the kernel I don't
think that needs to be documented yet. Also, offhand, I don't think we
generally document in the kernel distro specifics like package names.
Rob
^ permalink raw reply
* [REVIEW][PATCH 0/9] signal/powerpc: siginfo cleanups
From: Eric W. Biederman @ 2018-09-18 17:41 UTC (permalink / raw)
To: linux-kernel
Cc: linux-arch, linuxppc-dev, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman
This is the continuation of my work to sort out signaling of exceptions
with siginfo. The old functions by passing siginfo resulted in many
cases of fields of siginfo that were not initialized and then passed to
userspace, and also resulted in callers getting confused and
initializing the wrong fields. My remedy is to have specific functions
for sending each different kind of signal with siginfo. Those functions
take the information needed to fill in siginfo and do the work
themselves.
This is my set of changes to update powerpc to use those functions.
Along with some refactoring so those functions can be cleanly used.
Folks please review and double check me. I think I have kept these
changes simple and obviously correct but I am human and mess up
sometimes.
After these patches have had a chance to be reviewed I plan to merge
them by my siginfo tree. If you would rather take them in the powerpc
tree let me know. All of the prerequisites should have been merged
through Linus's tree several releases ago.
Eric W. Biederman (9):
signal/powerpc: Use force_sig_mceerr as appropriate
signal/powerpc: Remove pkey parameter from __bad_area
signal/powerpc: Call _exception_pkey directly from bad_key_fault_exception
signal/powerpc: Remove pkey parameter from __bad_area_nosemaphore
signal/powerpc: Factor the common exception code into exception_common
signal/powerpc: Call force_sig_fault from _exception
signal/poewrpc: Specialize _exception_pkey for handling pkey exceptions
signal/powerpc: Simplify _exception_pkey by using force_sig_pkuerr
signal/powerpc: Use force_sig_fault where appropriate
arch/powerpc/include/asm/bug.h | 2 +-
arch/powerpc/kernel/process.c | 9 +----
arch/powerpc/kernel/traps.c | 27 ++++++++-------
arch/powerpc/mm/fault.c | 55 +++++++++++++++++--------------
arch/powerpc/platforms/cell/spu_base.c | 4 +--
arch/powerpc/platforms/cell/spufs/fault.c | 26 +++++----------
6 files changed, 57 insertions(+), 66 deletions(-)
Eric
^ permalink raw reply
* Re: [PATCH 3/3] scripts/dtc: Update to upstream version v1.4.7-14-gc86da84d30e4
From: Frank Rowand @ 2018-09-18 20:09 UTC (permalink / raw)
To: Rob Herring
Cc: devicetree, linux-kernel@vger.kernel.org,
moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
linuxppc-dev
In-Reply-To: <CAL_JsqLTcLVGCmjTMi8GojomP=VbFQ5EqKcGnOPo=Wwh5Lc_mw@mail.gmail.com>
On 09/18/18 11:55, Rob Herring wrote:
> On Fri, Sep 14, 2018 at 2:32 PM Frank Rowand <frowand.list@gmail.com> wrote:
>>
>> On 09/13/18 13:28, Rob Herring wrote:
>>> Major changes are I2C and SPI bus checks, YAML output format (for
>>> future validation), some new libfdt functions, and more libfdt
>>> validation of dtbs.
>>>
>>> The YAML addition adds an optional dependency on libyaml. pkg-config is
>>> used to test for it and pkg-config became a kconfig dependency in 4.18.
>>
>> For Ubuntu, the libyaml dependency is provided by the packages:
>>
>> libyaml-0-2
>> libyaml-dev
>
> Yes, but as it is not yet required by anything in the kernel I don't
> think that needs to be documented yet. Also, offhand, I don't think we
> generally document in the kernel distro specifics like package names.
>
> Rob
>
Agreed. I was providing information that might save other people a bit
of research. It is sufficiently visible in the email thread and does
not need to be in the commit message.
^ permalink raw reply
* Re: [PATCH RFC 1/4] PCI: hotplug: Add parameter to put devices to reset during rescan
From: Bjorn Helgaas @ 2018-09-18 21:10 UTC (permalink / raw)
To: Sergey Miroshnichenko
Cc: Sam Bobroff, linux-pci, Bjorn Helgaas, linux, Russell Currey,
linuxppc-dev, Benjamin Herrenschmidt, Oliver OHalloran
In-Reply-To: <b3963047-e3c1-5612-1bcf-04c9e81dacd2@yadro.com>
On Tue, Sep 18, 2018 at 05:01:48PM +0300, Sergey Miroshnichenko wrote:
> On 9/18/18 1:59 AM, Bjorn Helgaas wrote:
> > On Mon, Sep 17, 2018 at 11:55:43PM +0300, Sergey Miroshnichenko wrote:
> >> On 9/17/18 8:28 AM, Sam Bobroff wrote:
> >>> On Fri, Sep 14, 2018 at 07:14:01PM +0300, Sergey Miroshnichenko wrote:
> >>>> Introduce a new command line option "pci=pcie_movable_bars"
> >>>> that indicates support of PCIe hotplug without prior
> >>>> reservation of memory regions by BIOS/bootloader.
> >>> What about devices with drivers that don't have reset_prepare()? It
> >>> looks like it will just reconfigure them anyway. Is that right?
> >>
> >> It is possible that unprepared driver without these hooks will get BARs
> >> moved, I should put a warning message there. There three ways we can see
> >> to make this safe:
> >> - add the reset_prepare()/reset_done() hooks to *every* PCIe driver;
> >> - refuse BAR movement if at least one unprepared driver has been
> >> encountered during rescan;
> >> - reduce the number of drivers which can be affected to some
> >> controllable value and prepare them on demand.
> >>
> >> Applying the second proposal as a major restriction seems fairly
> >> reasonable, but for our particular setups and use-cases it is probably
> >> too stiff:
> >> - we've noticed that devices connected directly to the root bridge
> >> don't get moved BARs, and this covers our x86_64 servers: we only
> >> insert/remove devices into "second-level" and "lower" bridges there, but
> >> not root;
> >> - on PowerNV we have system devices (network interfaces, USB hub, etc.)
> >> grouped into dedicated domain, with all other domains ready for hotplug,
> >> and only these domains can be rescanned.
> >>
> >> With our scenarios currently reduced to these two, we can live with just
> >> a few drivers "prepared" for now: NVME and few Ethernet adapters, this
> >> gives us a possibility to use this feature before "converting" *all* the
> >> drivers, and even have the NVidia cards running on a closed proprietary
> >> driver.
> >>
> >> Should we make this behavior adjustable with something like
> >> "pcie_movable_bars=safe" and "pcie_movable_bars=always" ?
> >
> > I like the overall idea of this a lot.
> >
> > - Why do we need a command line parameter to enable this? Can't we
> > do it unconditionally and automatically when it's possible? We
> > could have a chicken switch to *disable* it in case this breaks
> > something horribly, but I would like this functionality to be
> > always available without a special option.
>
> After making this feature completely safe we could activate it with the
> existing option "pci=realloc".
That *sounds* good, but in practice it never happens that we decide a
feature is completely safe and somebody makes it the default. If
we're going to do this, I think we need to commit to making it work
100% of the time, with no option needed.
> > - I'm not sure the existence of .reset_done() is evidence that a
> > driver is prepared for its BARs to move. I don't see any
> > documentation that refers to BAR movement, and I doubt it's been
> > tested. But I only see 5 implementations in the tree, so it'd be
> > easy to verify.
>
> You are right, and we should clarify the description:
> - drivers which have the .reset_done() already - none of them are aware
> of movable BARs yet;
> - the rest of the drivers should both be able to pause and handle the
> changes in BARs.
This doesn't clarify it for me. If you want to update all existing
.reset_done() methods so they deal with BAR changes, that would be
fine with me. That would be done by preliminary patches in the series
that adds the feature.
> > - I think your second proposal above sounds right: we should regard
> > any device whose driver lacks .reset_done() as immovable. We will
> > likely be able to move some devices but not others. Implementing
> > .reset_done() will increase flexibility but it shouldn't be a
> > requirement for all drivers.
>
> Thanks for the advice! This is more flexible and doesn't have any
> prerequisites. In this case the greater the "movable"/"immovable" ratio
> of the devices that was working before the hotplug event - the higher
> the probability to free some space for new BARs. But even a single
> "immovable" device at an undesirable place can block the re-arrangement,
> in this case all we can is just give up and print an error message.
Right. There's nothing we can do about that except make the relevant
drivers smarter.
> This patchset in its current form doesn't support marking a choosen BAR
> as immovable (just releasing all the resources of the root bridge and
> trying to sort and re-assign them back), so I'll have to implement that.
The current IORESOURCE_PCI_FIXED usage is for things that literally
*cannot* be moved because there is no BAR at all (VGA or IDE legacy,
enhanced allocation (see pci_ea_read()) or there's some platform
quirk.
It *might* make sense to also use it for devices where the *driver*
isn't smart enough to deal with moving it, but I'm not sure. That
would have to be done at driver probe time, I guess.
^ permalink raw reply
* Re: [PATCH v1 1/6] mm/memory_hotplug: make remove_memory() take the device_hotplug_lock
From: Rafael J. Wysocki @ 2018-09-18 21:18 UTC (permalink / raw)
To: David Hildenbrand
Cc: Linux Memory Management List, Linux Kernel Mailing List,
open list:DOCUMENTATION, linuxppc-dev, ACPI Devel Maling List,
xen-devel, devel, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, Rafael J. Wysocki, Len Brown, rashmica.g,
Michael Neuling, Balbir Singh, nfont, jallen, Andrew Morton,
Michal Hocko, Dan Williams, Joonsoo Kim, Vlastimil Babka,
Pavel Tatashin, Greg Kroah-Hartman, osalvador, yasu.isimatu,
malat
In-Reply-To: <20180918114822.21926-2-david@redhat.com>
On Tue, Sep 18, 2018 at 1:48 PM David Hildenbrand <david@redhat.com> wrote:
>
> remove_memory() is exported right now but requires the
> device_hotplug_lock, which is not exported. So let's provide a variant
> that takes the lock and only export that one.
>
> The lock is already held in
> arch/powerpc/platforms/pseries/hotplug-memory.c
> drivers/acpi/acpi_memhotplug.c
> So, let's use the locked variant.
>
> The lock is not held (but taken in)
> arch/powerpc/platforms/powernv/memtrace.c
> So let's keep using the (now) locked variant.
>
> Apart from that, there are not other users in the tree.
>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Len Brown <lenb@kernel.org>
> Cc: Rashmica Gupta <rashmica.g@gmail.com>
> Cc: Michael Neuling <mikey@neuling.org>
> Cc: Balbir Singh <bsingharora@gmail.com>
> Cc: Nathan Fontenot <nfont@linux.vnet.ibm.com>
> Cc: John Allen <jallen@linux.vnet.ibm.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Michal Hocko <mhocko@suse.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> Cc: Vlastimil Babka <vbabka@suse.cz>
> Cc: Pavel Tatashin <pasha.tatashin@oracle.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Oscar Salvador <osalvador@suse.de>
> Cc: YASUAKI ISHIMATSU <yasu.isimatu@gmail.com>
> Cc: Mathieu Malaterre <malat@debian.org>
> Reviewed-by: Pavel Tatashin <pavel.tatashin@microsoft.com>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
> arch/powerpc/platforms/powernv/memtrace.c | 2 --
> arch/powerpc/platforms/pseries/hotplug-memory.c | 6 +++---
> drivers/acpi/acpi_memhotplug.c | 2 +-
> include/linux/memory_hotplug.h | 3 ++-
> mm/memory_hotplug.c | 9 ++++++++-
> 5 files changed, 14 insertions(+), 8 deletions(-)
>
> diff --git a/arch/powerpc/platforms/powernv/memtrace.c b/arch/powerpc/platforms/powernv/memtrace.c
> index 51dc398ae3f7..8f1cd4f3bfd5 100644
> --- a/arch/powerpc/platforms/powernv/memtrace.c
> +++ b/arch/powerpc/platforms/powernv/memtrace.c
> @@ -90,9 +90,7 @@ static bool memtrace_offline_pages(u32 nid, u64 start_pfn, u64 nr_pages)
> walk_memory_range(start_pfn, end_pfn, (void *)MEM_OFFLINE,
> change_memblock_state);
>
> - lock_device_hotplug();
> remove_memory(nid, start_pfn << PAGE_SHIFT, nr_pages << PAGE_SHIFT);
> - unlock_device_hotplug();
>
> return true;
> }
> diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
> index c1578f54c626..b3f54466e25f 100644
> --- a/arch/powerpc/platforms/pseries/hotplug-memory.c
> +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
> @@ -334,7 +334,7 @@ static int pseries_remove_memblock(unsigned long base, unsigned int memblock_siz
> nid = memory_add_physaddr_to_nid(base);
>
> for (i = 0; i < sections_per_block; i++) {
> - remove_memory(nid, base, MIN_MEMORY_BLOCK_SIZE);
> + __remove_memory(nid, base, MIN_MEMORY_BLOCK_SIZE);
> base += MIN_MEMORY_BLOCK_SIZE;
> }
>
> @@ -423,7 +423,7 @@ static int dlpar_remove_lmb(struct drmem_lmb *lmb)
> block_sz = pseries_memory_block_size();
> nid = memory_add_physaddr_to_nid(lmb->base_addr);
>
> - remove_memory(nid, lmb->base_addr, block_sz);
> + __remove_memory(nid, lmb->base_addr, block_sz);
>
> /* Update memory regions for memory remove */
> memblock_remove(lmb->base_addr, block_sz);
> @@ -710,7 +710,7 @@ static int dlpar_add_lmb(struct drmem_lmb *lmb)
>
> rc = dlpar_online_lmb(lmb);
> if (rc) {
> - remove_memory(nid, lmb->base_addr, block_sz);
> + __remove_memory(nid, lmb->base_addr, block_sz);
> dlpar_remove_device_tree_lmb(lmb);
> } else {
> lmb->flags |= DRCONF_MEM_ASSIGNED;
> diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
> index 6b0d3ef7309c..811148415993 100644
> --- a/drivers/acpi/acpi_memhotplug.c
> +++ b/drivers/acpi/acpi_memhotplug.c
> @@ -282,7 +282,7 @@ static void acpi_memory_remove_memory(struct acpi_memory_device *mem_device)
> nid = memory_add_physaddr_to_nid(info->start_addr);
>
> acpi_unbind_memory_blocks(info);
> - remove_memory(nid, info->start_addr, info->length);
> + __remove_memory(nid, info->start_addr, info->length);
> list_del(&info->list);
> kfree(info);
> }
> diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
> index 34a28227068d..1f096852f479 100644
> --- a/include/linux/memory_hotplug.h
> +++ b/include/linux/memory_hotplug.h
> @@ -301,6 +301,7 @@ extern bool is_mem_section_removable(unsigned long pfn, unsigned long nr_pages);
> extern void try_offline_node(int nid);
> extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages);
> extern void remove_memory(int nid, u64 start, u64 size);
> +extern void __remove_memory(int nid, u64 start, u64 size);
>
> #else
> static inline bool is_mem_section_removable(unsigned long pfn,
> @@ -317,6 +318,7 @@ static inline int offline_pages(unsigned long start_pfn, unsigned long nr_pages)
> }
>
> static inline void remove_memory(int nid, u64 start, u64 size) {}
> +static inline void __remove_memory(int nid, u64 start, u64 size) {}
> #endif /* CONFIG_MEMORY_HOTREMOVE */
>
> extern void __ref free_area_init_core_hotplug(int nid);
> @@ -330,7 +332,6 @@ extern void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn,
> unsigned long nr_pages, struct vmem_altmap *altmap);
> extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages);
> extern bool is_memblock_offlined(struct memory_block *mem);
> -extern void remove_memory(int nid, u64 start, u64 size);
> extern int sparse_add_one_section(struct pglist_data *pgdat,
> unsigned long start_pfn, struct vmem_altmap *altmap);
> extern void sparse_remove_one_section(struct zone *zone, struct mem_section *ms,
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 38d94b703e9d..b8b1bd970322 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -1873,7 +1873,7 @@ EXPORT_SYMBOL(try_offline_node);
> * and online/offline operations before this call, as required by
> * try_offline_node().
> */
> -void __ref remove_memory(int nid, u64 start, u64 size)
> +void __ref __remove_memory(int nid, u64 start, u64 size)
> {
> int ret;
>
> @@ -1902,5 +1902,12 @@ void __ref remove_memory(int nid, u64 start, u64 size)
>
> mem_hotplug_done();
> }
> +
> +void remove_memory(int nid, u64 start, u64 size)
> +{
> + lock_device_hotplug();
> + __remove_memory(nid, start, size);
> + unlock_device_hotplug();
> +}
> EXPORT_SYMBOL_GPL(remove_memory);
> #endif /* CONFIG_MEMORY_HOTREMOVE */
> --
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
^ permalink raw reply
* Re: [PATCH v1 2/6] mm/memory_hotplug: make add_memory() take the device_hotplug_lock
From: Rafael J. Wysocki @ 2018-09-18 21:19 UTC (permalink / raw)
To: David Hildenbrand
Cc: Linux Memory Management List, Linux Kernel Mailing List,
open list:DOCUMENTATION, linuxppc-dev, ACPI Devel Maling List,
xen-devel, devel, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, Rafael J. Wysocki, Len Brown,
Greg Kroah-Hartman, Boris Ostrovsky, Juergen Gross, nfont, jallen,
Andrew Morton, Michal Hocko, Dan Williams, Joonsoo Kim,
Vlastimil Babka, osalvador, malat, pavel.tatashin, yasu.isimatu
In-Reply-To: <20180918114822.21926-3-david@redhat.com>
On Tue, Sep 18, 2018 at 1:48 PM David Hildenbrand <david@redhat.com> wrote:
>
> add_memory() currently does not take the device_hotplug_lock, however
> is aleady called under the lock from
> arch/powerpc/platforms/pseries/hotplug-memory.c
> drivers/acpi/acpi_memhotplug.c
> to synchronize against CPU hot-remove and similar.
>
> In general, we should hold the device_hotplug_lock when adding memory
> to synchronize against online/offline request (e.g. from user space) -
> which already resulted in lock inversions due to device_lock() and
> mem_hotplug_lock - see 30467e0b3be ("mm, hotplug: fix concurrent memory
> hot-add deadlock"). add_memory()/add_memory_resource() will create memory
> block devices, so this really feels like the right thing to do.
>
> Holding the device_hotplug_lock makes sure that a memory block device
> can really only be accessed (e.g. via .online/.state) from user space,
> once the memory has been fully added to the system.
>
> The lock is not held yet in
> drivers/xen/balloon.c
> arch/powerpc/platforms/powernv/memtrace.c
> drivers/s390/char/sclp_cmd.c
> drivers/hv/hv_balloon.c
> So, let's either use the locked variants or take the lock.
>
> Don't export add_memory_resource(), as it once was exported to be used
> by XEN, which is never built as a module. If somebody requires it, we
> also have to export a locked variant (as device_hotplug_lock is never
> exported).
>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Len Brown <lenb@kernel.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Cc: Juergen Gross <jgross@suse.com>
> Cc: Nathan Fontenot <nfont@linux.vnet.ibm.com>
> Cc: John Allen <jallen@linux.vnet.ibm.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Michal Hocko <mhocko@suse.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> Cc: Vlastimil Babka <vbabka@suse.cz>
> Cc: Oscar Salvador <osalvador@suse.de>
> Cc: Mathieu Malaterre <malat@debian.org>
> Cc: Pavel Tatashin <pavel.tatashin@microsoft.com>
> Cc: YASUAKI ISHIMATSU <yasu.isimatu@gmail.com>
> Reviewed-by: Pavel Tatashin <pavel.tatashin@microsoft.com>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
> .../platforms/pseries/hotplug-memory.c | 2 +-
> drivers/acpi/acpi_memhotplug.c | 2 +-
> drivers/base/memory.c | 9 ++++++--
> drivers/xen/balloon.c | 3 +++
> include/linux/memory_hotplug.h | 1 +
> mm/memory_hotplug.c | 22 ++++++++++++++++---
> 6 files changed, 32 insertions(+), 7 deletions(-)
>
> diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
> index b3f54466e25f..2e6f41dc103a 100644
> --- a/arch/powerpc/platforms/pseries/hotplug-memory.c
> +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
> @@ -702,7 +702,7 @@ static int dlpar_add_lmb(struct drmem_lmb *lmb)
> nid = memory_add_physaddr_to_nid(lmb->base_addr);
>
> /* Add the memory */
> - rc = add_memory(nid, lmb->base_addr, block_sz);
> + rc = __add_memory(nid, lmb->base_addr, block_sz);
> if (rc) {
> dlpar_remove_device_tree_lmb(lmb);
> return rc;
> diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
> index 811148415993..8fe0960ea572 100644
> --- a/drivers/acpi/acpi_memhotplug.c
> +++ b/drivers/acpi/acpi_memhotplug.c
> @@ -228,7 +228,7 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
> if (node < 0)
> node = memory_add_physaddr_to_nid(info->start_addr);
>
> - result = add_memory(node, info->start_addr, info->length);
> + result = __add_memory(node, info->start_addr, info->length);
>
> /*
> * If the memory block has been used by the kernel, add_memory()
> diff --git a/drivers/base/memory.c b/drivers/base/memory.c
> index 817320c7c4c1..40cac122ec73 100644
> --- a/drivers/base/memory.c
> +++ b/drivers/base/memory.c
> @@ -519,15 +519,20 @@ memory_probe_store(struct device *dev, struct device_attribute *attr,
> if (phys_addr & ((pages_per_block << PAGE_SHIFT) - 1))
> return -EINVAL;
>
> + ret = lock_device_hotplug_sysfs();
> + if (ret)
> + goto out;
> +
> nid = memory_add_physaddr_to_nid(phys_addr);
> - ret = add_memory(nid, phys_addr,
> - MIN_MEMORY_BLOCK_SIZE * sections_per_block);
> + ret = __add_memory(nid, phys_addr,
> + MIN_MEMORY_BLOCK_SIZE * sections_per_block);
>
> if (ret)
> goto out;
>
> ret = count;
> out:
> + unlock_device_hotplug();
> return ret;
> }
>
> diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
> index e12bb256036f..6bab019a82b1 100644
> --- a/drivers/xen/balloon.c
> +++ b/drivers/xen/balloon.c
> @@ -395,7 +395,10 @@ static enum bp_state reserve_additional_memory(void)
> * callers drop the mutex before trying again.
> */
> mutex_unlock(&balloon_mutex);
> + /* add_memory_resource() requires the device_hotplug lock */
> + lock_device_hotplug();
> rc = add_memory_resource(nid, resource, memhp_auto_online);
> + unlock_device_hotplug();
> mutex_lock(&balloon_mutex);
>
> if (rc) {
> diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
> index 1f096852f479..ffd9cd10fcf3 100644
> --- a/include/linux/memory_hotplug.h
> +++ b/include/linux/memory_hotplug.h
> @@ -324,6 +324,7 @@ static inline void __remove_memory(int nid, u64 start, u64 size) {}
> extern void __ref free_area_init_core_hotplug(int nid);
> extern int walk_memory_range(unsigned long start_pfn, unsigned long end_pfn,
> void *arg, int (*func)(struct memory_block *, void *));
> +extern int __add_memory(int nid, u64 start, u64 size);
> extern int add_memory(int nid, u64 start, u64 size);
> extern int add_memory_resource(int nid, struct resource *resource, bool online);
> extern int arch_add_memory(int nid, u64 start, u64 size,
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index b8b1bd970322..ef5444145c88 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -1111,7 +1111,12 @@ static int online_memory_block(struct memory_block *mem, void *arg)
> return device_online(&mem->dev);
> }
>
> -/* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */
> +/*
> + * NOTE: The caller must call lock_device_hotplug() to serialize hotplug
> + * and online/offline operations (triggered e.g. by sysfs).
> + *
> + * we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG
> + */
> int __ref add_memory_resource(int nid, struct resource *res, bool online)
> {
> u64 start, size;
> @@ -1180,9 +1185,9 @@ int __ref add_memory_resource(int nid, struct resource *res, bool online)
> mem_hotplug_done();
> return ret;
> }
> -EXPORT_SYMBOL_GPL(add_memory_resource);
>
> -int __ref add_memory(int nid, u64 start, u64 size)
> +/* requires device_hotplug_lock, see add_memory_resource() */
> +int __ref __add_memory(int nid, u64 start, u64 size)
> {
> struct resource *res;
> int ret;
> @@ -1196,6 +1201,17 @@ int __ref add_memory(int nid, u64 start, u64 size)
> release_memory_resource(res);
> return ret;
> }
> +
> +int add_memory(int nid, u64 start, u64 size)
> +{
> + int rc;
> +
> + lock_device_hotplug();
> + rc = __add_memory(nid, start, size);
> + unlock_device_hotplug();
> +
> + return rc;
> +}
> EXPORT_SYMBOL_GPL(add_memory);
>
> #ifdef CONFIG_MEMORY_HOTREMOVE
> --
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
^ permalink raw reply
* Re: [PATCH] MAINTAINERS: Add PPC contacts for PCI core error handling
From: Bjorn Helgaas @ 2018-09-18 21:58 UTC (permalink / raw)
To: linux-pci, Russell Currey, linuxppc-dev
Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
linux-kernel
In-Reply-To: <153677132617.23091.12307288405707171077.stgit@bhelgaas-glaptop.roam.corp.google.com>
On Wed, Sep 12, 2018 at 11:55:26AM -0500, Bjorn Helgaas wrote:
> From: Bjorn Helgaas <bhelgaas@google.com>
>
> The original PCI error recovery functionality was for the powerpc-specific
> IBM EEH feature. PCIe subsequently added some similar features, including
> AER and DPC, that can be used on any architecture.
>
> We want the generic PCI core error handling support to work with all of
> these features. Driver error recovery callbacks should be independent of
> which feature the platform provides.
>
> Add the generic PCI core error recovery files to the powerpc EEH
> MAINTAINERS entry so the powerpc folks will be copied on changes to the
> generic PCI error handling strategy.
>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
I applied the following to for-linus for v4.19. Russell, if you want
to be removed, let me know and I'll do that.
commit 3fed0e04026c
Author: Bjorn Helgaas <bhelgaas@google.com>
Date: Wed Sep 12 11:55:26 2018 -0500
MAINTAINERS: Update PPC contacts for PCI core error handling
The original PCI error recovery functionality was for the powerpc-specific
IBM EEH feature. PCIe subsequently added some similar features, including
AER and DPC, that can be used on any architecture.
We want the generic PCI core error handling support to work with all of
these features. Driver error recovery callbacks should be independent of
which feature the platform provides.
Add the generic PCI core error recovery files to the powerpc EEH
MAINTAINERS entry so the powerpc folks will be copied on changes to the
generic PCI error handling strategy.
Add Sam and Oliver as maintainers for this area.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
diff --git a/MAINTAINERS b/MAINTAINERS
index 4ece30f15777..f23244003836 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11203,8 +11203,14 @@ F: tools/pci/
PCI ENHANCED ERROR HANDLING (EEH) FOR POWERPC
M: Russell Currey <ruscur@russell.cc>
+M: Sam Bobroff <sbobroff@linux.ibm.com>
+M: Oliver O'Halloran <oliveroh@au1.ibm.com>
L: linuxppc-dev@lists.ozlabs.org
S: Supported
+F: Documentation/PCI/pci-error-recovery.txt
+F: drivers/pci/pcie/aer.c
+F: drivers/pci/pcie/dpc.c
+F: drivers/pci/pcie/err.c
F: Documentation/powerpc/eeh-pci-error-recovery.txt
F: arch/powerpc/kernel/eeh*.c
F: arch/powerpc/platforms/*/eeh*.c
^ permalink raw reply related
* Re: [PATCH] powerpc/mpc85xx: fix issues in clock node
From: Scott Wood @ 2018-09-18 22:24 UTC (permalink / raw)
To: andy.tang; +Cc: robh+dt, mark.rutland, benh, devicetree, linuxppc-dev
In-Reply-To: <20180911021224.30558-1-andy.tang@nxp.com>
On Tue, 2018-09-11 at 10:12 +0800, andy.tang@nxp.com wrote:
> From: Yuantian Tang <andy.tang@nxp.com>
>
> The compatible string is not correct in the clock node.
> The clocks property refers to the wrong node too.
> This patch is to fix them.
>
> Signed-off-by: Tang Yuantian <andy.tang@nxp.com>
> ---
> arch/powerpc/boot/dts/fsl/t1023si-post.dtsi | 8 ++++----
> 1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/powerpc/boot/dts/fsl/t1023si-post.dtsi
> b/arch/powerpc/boot/dts/fsl/t1023si-post.dtsi
> index 4908af5..763caf4 100644
> --- a/arch/powerpc/boot/dts/fsl/t1023si-post.dtsi
> +++ b/arch/powerpc/boot/dts/fsl/t1023si-post.dtsi
> @@ -348,7 +348,7 @@
> mux0: mux0@0 {
> #clock-cells = <0>;
> reg = <0x0 4>;
> - compatible = "fsl,core-mux-clock";
> + compatible = "fsl,qoriq-core-mux-2.0";
> clocks = <&pll0 0>, <&pll0 1>;
> clock-names = "pll0_0", "pll0_1";
> clock-output-names = "cmux0";
> @@ -356,9 +356,9 @@
> mux1: mux1@20 {
> #clock-cells = <0>;
> reg = <0x20 4>;
> - compatible = "fsl,core-mux-clock";
> - clocks = <&pll0 0>, <&pll0 1>;
> - clock-names = "pll0_0", "pll0_1";
> + compatible = "fsl,qoriq-core-mux-2.0";
> + clocks = <&pll1 0>, <&pll1 1>;
> + clock-names = "pll1_0", "pll1_1";
> clock-output-names = "cmux1";
> };
> };
These are the legacy nodes. Why not just remove them instead of fixing them?
Now that the cpufreq driver is fixed we could get rid of the legacy nodes for
all the chips.
-Scott
^ permalink raw reply
* [PATCH] lib/xz: Fix powerpc build with KERNEL_XZ
From: Joel Stanley @ 2018-09-18 23:07 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Herbert Xu, linux-kernel, Michael Ellerman, Oliver O'Halloran,
linuxppc-dev
This partially reverts faa16bc404d72a5 ("lib: Use existing define with
polynomial").
The cleanup added a dependency on include/linux, which broke the PowerPC
boot wrapper/decompresser when KERNEL_XZ is enabled:
BOOTCC arch/powerpc/boot/decompress.o
In file included from arch/powerpc/boot/../../../lib/decompress_unxz.c:233,
from arch/powerpc/boot/decompress.c:42:
arch/powerpc/boot/../../../lib/xz/xz_crc32.c:18:10: fatal error:
linux/crc32poly.h: No such file or directory
#include <linux/crc32poly.h>
^~~~~~~~~~~~~~~~~~~
The powerpc decompressor is a hairy corner of the kernel. Even while building
a 64-bit kernel it needs to build a 32-bit binary and therefore avoid including
files from include/linux.
Fixes: faa16bc404d7 ("lib: Use existing define with polynomial")
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
We need to clean up the powerpc boot decompresser but that work will be
more involved than we would include in a late -rc. Please consider
merging this fix for 4.19. Thanks!
lib/xz/xz_crc32.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lib/xz/xz_crc32.c b/lib/xz/xz_crc32.c
index 25a5d87e2e4c..34532d14fd4c 100644
--- a/lib/xz/xz_crc32.c
+++ b/lib/xz/xz_crc32.c
@@ -15,7 +15,6 @@
* but they are bigger and use more memory for the lookup table.
*/
-#include <linux/crc32poly.h>
#include "xz_private.h"
/*
@@ -30,7 +29,7 @@ STATIC_RW_DATA uint32_t xz_crc32_table[256];
XZ_EXTERN void xz_crc32_init(void)
{
- const uint32_t poly = CRC32_POLY_LE;
+ const uint32_t poly = 0xEDB88320;
uint32_t i;
uint32_t j;
--
2.17.1
^ permalink raw reply related
* Re: MPC83xx reset status register (RSR, offset 0x910)
From: Radu Rendec @ 2018-09-19 1:19 UTC (permalink / raw)
To: Christophe LEROY; +Cc: linuxppc-dev, oss, mpe, eric.miao
In-Reply-To: <d30e4a1e-187b-2a07-ec9c-50f889375cde@c-s.fr>
Hi Christophe,
On Thu, 2018-09-13 at 10:21 +0200, Christophe LEROY wrote:
>
> Le 11/09/2018 à 00:17, Radu Rendec a écrit :
> >
> > The MPC83xx also has a watchdog and the kernel driver (mpc8xxx_wdt.c)
> > could also be improved to support the WDIOC_GETBOOTSTATUS ioctl and
> > properly report if the system rebooted due to a watchdog.
>
> Very good idea.
>
> I just submitted a patch for that. Please look at it.
> I'm sure any driver which needs reset status information can do the same.
Thanks for submitting the patch and sorry for the late reply! I followed
the conversation between you and Guenter and it seems your patches are
almost accepted. That's a good thing.
> If we want to do something more central, maybe we should look at what
> was done on ARM:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=04fef228fb00
Thanks for pointing out that commit. It's very similar to what I wanted
to do (for MPC83xx) in the first place: read the RSR value on start-up
into a variable and export it as a symbol to make it available to other
drivers.
I would take on the work to implement something similar for PowerPC, but
I need some guidance as to what goes where. For instance, what would be
the PowerPC equivalent of arch/arm/mach-pxa/reset.c, which defines the
reset_status variable?
Another question is if the device tree should be used. We already have
separate directories for each platform in arch/powerpc/platforms and I
guess for each platform the RSR is always there and at a fixed, well
known address.
Thanks,
Radu
^ permalink raw reply
* Re: [PATCH v1 0/6] mm: online/offline_pages called w.o. mem_hotplug_lock
From: Balbir Singh @ 2018-09-19 1:22 UTC (permalink / raw)
To: David Hildenbrand
Cc: linux-mm, linux-kernel, linux-doc, linuxppc-dev, linux-acpi,
xen-devel, devel, Andrew Morton, Benjamin Herrenschmidt,
Boris Ostrovsky, Dan Williams, Greg Kroah-Hartman, Haiyang Zhang,
Heiko Carstens, John Allen, Jonathan Corbet, Joonsoo Kim,
Juergen Gross, Kate Stewart, K. Y. Srinivasan, Len Brown,
Martin Schwidefsky, Mathieu Malaterre, Michael Ellerman,
Michael Neuling, Michal Hocko, Nathan Fontenot, Oscar Salvador,
Paul Mackerras, Pavel Tatashin, Pavel Tatashin,
Philippe Ombredanne, Rafael J. Wysocki, Rashmica Gupta,
Stephen Hemminger, Thomas Gleixner, Vlastimil Babka,
YASUAKI ISHIMATSU
In-Reply-To: <20180918114822.21926-1-david@redhat.com>
On Tue, Sep 18, 2018 at 01:48:16PM +0200, David Hildenbrand wrote:
> Reading through the code and studying how mem_hotplug_lock is to be used,
> I noticed that there are two places where we can end up calling
> device_online()/device_offline() - online_pages()/offline_pages() without
> the mem_hotplug_lock. And there are other places where we call
> device_online()/device_offline() without the device_hotplug_lock.
>
> While e.g.
> echo "online" > /sys/devices/system/memory/memory9/state
> is fine, e.g.
> echo 1 > /sys/devices/system/memory/memory9/online
> Will not take the mem_hotplug_lock. However the device_lock() and
> device_hotplug_lock.
>
> E.g. via memory_probe_store(), we can end up calling
> add_memory()->online_pages() without the device_hotplug_lock. So we can
> have concurrent callers in online_pages(). We e.g. touch in online_pages()
> basically unprotected zone->present_pages then.
>
> Looks like there is a longer history to that (see Patch #2 for details),
> and fixing it to work the way it was intended is not really possible. We
> would e.g. have to take the mem_hotplug_lock in device/base/core.c, which
> sounds wrong.
>
> Summary: We had a lock inversion on mem_hotplug_lock and device_lock().
> More details can be found in patch 3 and patch 6.
>
> I propose the general rules (documentation added in patch 6):
>
> 1. add_memory/add_memory_resource() must only be called with
> device_hotplug_lock.
> 2. remove_memory() must only be called with device_hotplug_lock. This is
> already documented and holds for all callers.
> 3. device_online()/device_offline() must only be called with
> device_hotplug_lock. This is already documented and true for now in core
> code. Other callers (related to memory hotplug) have to be fixed up.
> 4. mem_hotplug_lock is taken inside of add_memory/remove_memory/
> online_pages/offline_pages.
>
> To me, this looks way cleaner than what we have right now (and easier to
> verify). And looking at the documentation of remove_memory, using
> lock_device_hotplug also for add_memory() feels natural.
>
That seems reasonable, but also implies that device_online() would hold
back add/remove memory, could you please also document what mode
read/write the locks need to be held? For example can the device_hotplug_lock
be held in read mode while add/remove memory via (mem_hotplug_lock) is held
in write mode?
Balbir Singh.
^ permalink raw reply
* Re: [PATCH] MAINTAINERS: Add PPC contacts for PCI core error handling
From: Russell Currey @ 2018-09-19 1:49 UTC (permalink / raw)
To: Bjorn Helgaas, linux-pci, linuxppc-dev
Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
linux-kernel, oohall, sbobroff
In-Reply-To: <20180918215854.GH13616@bhelgaas-glaptop.roam.corp.google.com>
On Tue, 2018-09-18 at 16:58 -0500, Bjorn Helgaas wrote:
> On Wed, Sep 12, 2018 at 11:55:26AM -0500, Bjorn Helgaas wrote:
> > From: Bjorn Helgaas <bhelgaas@google.com>
> >
> > The original PCI error recovery functionality was for the powerpc-specific
> > IBM EEH feature. PCIe subsequently added some similar features, including
> > AER and DPC, that can be used on any architecture.
> >
> > We want the generic PCI core error handling support to work with all of
> > these features. Driver error recovery callbacks should be independent of
> > which feature the platform provides.
> >
> > Add the generic PCI core error recovery files to the powerpc EEH
> > MAINTAINERS entry so the powerpc folks will be copied on changes to the
> > generic PCI error handling strategy.
> >
> > Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>
> I applied the following to for-linus for v4.19. Russell, if you want
> to be removed, let me know and I'll do that.
Oliver's email address for kernel stuff is oohall@gmail.com, I think benh has been
CCing his IBM address. But other than that,
Acked-by: Russell Currey <ruscur@russell.cc>
Thanks for this, Bjorn.
- Russell
>
> commit 3fed0e04026c
> Author: Bjorn Helgaas <bhelgaas@google.com>
> Date: Wed Sep 12 11:55:26 2018 -0500
>
> MAINTAINERS: Update PPC contacts for PCI core error handling
>
> The original PCI error recovery functionality was for the powerpc-specific
> IBM EEH feature. PCIe subsequently added some similar features, including
> AER and DPC, that can be used on any architecture.
>
> We want the generic PCI core error handling support to work with all of
> these features. Driver error recovery callbacks should be independent of
> which feature the platform provides.
>
> Add the generic PCI core error recovery files to the powerpc EEH
> MAINTAINERS entry so the powerpc folks will be copied on changes to the
> generic PCI error handling strategy.
>
> Add Sam and Oliver as maintainers for this area.
>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 4ece30f15777..f23244003836 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -11203,8 +11203,14 @@ F: tools/pci/
>
> PCI ENHANCED ERROR HANDLING (EEH) FOR POWERPC
> M: Russell Currey <ruscur@russell.cc>
> +M: Sam Bobroff <sbobroff@linux.ibm.com>
> +M: Oliver O'Halloran <oliveroh@au1.ibm.com>
> L: linuxppc-dev@lists.ozlabs.org
> S: Supported
> +F: Documentation/PCI/pci-error-recovery.txt
> +F: drivers/pci/pcie/aer.c
> +F: drivers/pci/pcie/dpc.c
> +F: drivers/pci/pcie/err.c
> F: Documentation/powerpc/eeh-pci-error-recovery.txt
> F: arch/powerpc/kernel/eeh*.c
> F: arch/powerpc/platforms/*/eeh*.c
^ permalink raw reply
* [PATCH crypto-next 13/23] crypto: vmx - Remove VLA usage of skcipher
From: Kees Cook @ 2018-09-19 2:10 UTC (permalink / raw)
To: Herbert Xu
Cc: Kees Cook, Leonidas S. Barbosa, Paulo Flabiano Smorigo,
Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
linuxppc-dev, Ard Biesheuvel, Eric Biggers, linux-crypto,
Linux Kernel Mailing List
In-Reply-To: <20180919021100.3380-1-keescook@chromium.org>
In the quest to remove all stack VLA usage from the kernel[1], this
replaces struct crypto_skcipher and SKCIPHER_REQUEST_ON_STACK() usage
with struct crypto_sync_skcipher and SYNC_SKCIPHER_REQUEST_ON_STACK(),
which uses a fixed stack size.
[1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com
Cc: "Leonidas S. Barbosa" <leosilva@linux.vnet.ibm.com>
Cc: Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
drivers/crypto/vmx/aes_cbc.c | 22 +++++++++++-----------
drivers/crypto/vmx/aes_ctr.c | 18 +++++++++---------
drivers/crypto/vmx/aes_xts.c | 18 +++++++++---------
3 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/drivers/crypto/vmx/aes_cbc.c b/drivers/crypto/vmx/aes_cbc.c
index b71895871be3..c5c5ff82b52e 100644
--- a/drivers/crypto/vmx/aes_cbc.c
+++ b/drivers/crypto/vmx/aes_cbc.c
@@ -32,7 +32,7 @@
#include "aesp8-ppc.h"
struct p8_aes_cbc_ctx {
- struct crypto_skcipher *fallback;
+ struct crypto_sync_skcipher *fallback;
struct aes_key enc_key;
struct aes_key dec_key;
};
@@ -40,11 +40,11 @@ struct p8_aes_cbc_ctx {
static int p8_aes_cbc_init(struct crypto_tfm *tfm)
{
const char *alg = crypto_tfm_alg_name(tfm);
- struct crypto_skcipher *fallback;
+ struct crypto_sync_skcipher *fallback;
struct p8_aes_cbc_ctx *ctx = crypto_tfm_ctx(tfm);
- fallback = crypto_alloc_skcipher(alg, 0,
- CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK);
+ fallback = crypto_alloc_sync_skcipher(alg, 0,
+ CRYPTO_ALG_NEED_FALLBACK);
if (IS_ERR(fallback)) {
printk(KERN_ERR
@@ -53,7 +53,7 @@ static int p8_aes_cbc_init(struct crypto_tfm *tfm)
return PTR_ERR(fallback);
}
- crypto_skcipher_set_flags(
+ crypto_sync_skcipher_set_flags(
fallback,
crypto_skcipher_get_flags((struct crypto_skcipher *)tfm));
ctx->fallback = fallback;
@@ -66,7 +66,7 @@ static void p8_aes_cbc_exit(struct crypto_tfm *tfm)
struct p8_aes_cbc_ctx *ctx = crypto_tfm_ctx(tfm);
if (ctx->fallback) {
- crypto_free_skcipher(ctx->fallback);
+ crypto_free_sync_skcipher(ctx->fallback);
ctx->fallback = NULL;
}
}
@@ -86,7 +86,7 @@ static int p8_aes_cbc_setkey(struct crypto_tfm *tfm, const u8 *key,
pagefault_enable();
preempt_enable();
- ret += crypto_skcipher_setkey(ctx->fallback, key, keylen);
+ ret += crypto_sync_skcipher_setkey(ctx->fallback, key, keylen);
return ret;
}
@@ -100,8 +100,8 @@ static int p8_aes_cbc_encrypt(struct blkcipher_desc *desc,
crypto_tfm_ctx(crypto_blkcipher_tfm(desc->tfm));
if (in_interrupt()) {
- SKCIPHER_REQUEST_ON_STACK(req, ctx->fallback);
- skcipher_request_set_tfm(req, ctx->fallback);
+ SYNC_SKCIPHER_REQUEST_ON_STACK(req, ctx->fallback);
+ skcipher_request_set_sync_tfm(req, ctx->fallback);
skcipher_request_set_callback(req, desc->flags, NULL, NULL);
skcipher_request_set_crypt(req, src, dst, nbytes, desc->info);
ret = crypto_skcipher_encrypt(req);
@@ -139,8 +139,8 @@ static int p8_aes_cbc_decrypt(struct blkcipher_desc *desc,
crypto_tfm_ctx(crypto_blkcipher_tfm(desc->tfm));
if (in_interrupt()) {
- SKCIPHER_REQUEST_ON_STACK(req, ctx->fallback);
- skcipher_request_set_tfm(req, ctx->fallback);
+ SYNC_SKCIPHER_REQUEST_ON_STACK(req, ctx->fallback);
+ skcipher_request_set_sync_tfm(req, ctx->fallback);
skcipher_request_set_callback(req, desc->flags, NULL, NULL);
skcipher_request_set_crypt(req, src, dst, nbytes, desc->info);
ret = crypto_skcipher_decrypt(req);
diff --git a/drivers/crypto/vmx/aes_ctr.c b/drivers/crypto/vmx/aes_ctr.c
index cd777c75291d..8a2fe092cb8e 100644
--- a/drivers/crypto/vmx/aes_ctr.c
+++ b/drivers/crypto/vmx/aes_ctr.c
@@ -32,18 +32,18 @@
#include "aesp8-ppc.h"
struct p8_aes_ctr_ctx {
- struct crypto_skcipher *fallback;
+ struct crypto_sync_skcipher *fallback;
struct aes_key enc_key;
};
static int p8_aes_ctr_init(struct crypto_tfm *tfm)
{
const char *alg = crypto_tfm_alg_name(tfm);
- struct crypto_skcipher *fallback;
+ struct crypto_sync_skcipher *fallback;
struct p8_aes_ctr_ctx *ctx = crypto_tfm_ctx(tfm);
- fallback = crypto_alloc_skcipher(alg, 0,
- CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK);
+ fallback = crypto_alloc_sync_skcipher(alg, 0,
+ CRYPTO_ALG_NEED_FALLBACK);
if (IS_ERR(fallback)) {
printk(KERN_ERR
"Failed to allocate transformation for '%s': %ld\n",
@@ -51,7 +51,7 @@ static int p8_aes_ctr_init(struct crypto_tfm *tfm)
return PTR_ERR(fallback);
}
- crypto_skcipher_set_flags(
+ crypto_sync_skcipher_set_flags(
fallback,
crypto_skcipher_get_flags((struct crypto_skcipher *)tfm));
ctx->fallback = fallback;
@@ -64,7 +64,7 @@ static void p8_aes_ctr_exit(struct crypto_tfm *tfm)
struct p8_aes_ctr_ctx *ctx = crypto_tfm_ctx(tfm);
if (ctx->fallback) {
- crypto_free_skcipher(ctx->fallback);
+ crypto_free_sync_skcipher(ctx->fallback);
ctx->fallback = NULL;
}
}
@@ -83,7 +83,7 @@ static int p8_aes_ctr_setkey(struct crypto_tfm *tfm, const u8 *key,
pagefault_enable();
preempt_enable();
- ret += crypto_skcipher_setkey(ctx->fallback, key, keylen);
+ ret += crypto_sync_skcipher_setkey(ctx->fallback, key, keylen);
return ret;
}
@@ -119,8 +119,8 @@ static int p8_aes_ctr_crypt(struct blkcipher_desc *desc,
crypto_tfm_ctx(crypto_blkcipher_tfm(desc->tfm));
if (in_interrupt()) {
- SKCIPHER_REQUEST_ON_STACK(req, ctx->fallback);
- skcipher_request_set_tfm(req, ctx->fallback);
+ SYNC_SKCIPHER_REQUEST_ON_STACK(req, ctx->fallback);
+ skcipher_request_set_sync_tfm(req, ctx->fallback);
skcipher_request_set_callback(req, desc->flags, NULL, NULL);
skcipher_request_set_crypt(req, src, dst, nbytes, desc->info);
ret = crypto_skcipher_encrypt(req);
diff --git a/drivers/crypto/vmx/aes_xts.c b/drivers/crypto/vmx/aes_xts.c
index e9954a7d4694..ecd64e5cc5bb 100644
--- a/drivers/crypto/vmx/aes_xts.c
+++ b/drivers/crypto/vmx/aes_xts.c
@@ -33,7 +33,7 @@
#include "aesp8-ppc.h"
struct p8_aes_xts_ctx {
- struct crypto_skcipher *fallback;
+ struct crypto_sync_skcipher *fallback;
struct aes_key enc_key;
struct aes_key dec_key;
struct aes_key tweak_key;
@@ -42,11 +42,11 @@ struct p8_aes_xts_ctx {
static int p8_aes_xts_init(struct crypto_tfm *tfm)
{
const char *alg = crypto_tfm_alg_name(tfm);
- struct crypto_skcipher *fallback;
+ struct crypto_sync_skcipher *fallback;
struct p8_aes_xts_ctx *ctx = crypto_tfm_ctx(tfm);
- fallback = crypto_alloc_skcipher(alg, 0,
- CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK);
+ fallback = crypto_alloc_sync_skcipher(alg, 0,
+ CRYPTO_ALG_NEED_FALLBACK);
if (IS_ERR(fallback)) {
printk(KERN_ERR
"Failed to allocate transformation for '%s': %ld\n",
@@ -54,7 +54,7 @@ static int p8_aes_xts_init(struct crypto_tfm *tfm)
return PTR_ERR(fallback);
}
- crypto_skcipher_set_flags(
+ crypto_sync_skcipher_set_flags(
fallback,
crypto_skcipher_get_flags((struct crypto_skcipher *)tfm));
ctx->fallback = fallback;
@@ -67,7 +67,7 @@ static void p8_aes_xts_exit(struct crypto_tfm *tfm)
struct p8_aes_xts_ctx *ctx = crypto_tfm_ctx(tfm);
if (ctx->fallback) {
- crypto_free_skcipher(ctx->fallback);
+ crypto_free_sync_skcipher(ctx->fallback);
ctx->fallback = NULL;
}
}
@@ -92,7 +92,7 @@ static int p8_aes_xts_setkey(struct crypto_tfm *tfm, const u8 *key,
pagefault_enable();
preempt_enable();
- ret += crypto_skcipher_setkey(ctx->fallback, key, keylen);
+ ret += crypto_sync_skcipher_setkey(ctx->fallback, key, keylen);
return ret;
}
@@ -109,8 +109,8 @@ static int p8_aes_xts_crypt(struct blkcipher_desc *desc,
crypto_tfm_ctx(crypto_blkcipher_tfm(desc->tfm));
if (in_interrupt()) {
- SKCIPHER_REQUEST_ON_STACK(req, ctx->fallback);
- skcipher_request_set_tfm(req, ctx->fallback);
+ SYNC_SKCIPHER_REQUEST_ON_STACK(req, ctx->fallback);
+ skcipher_request_set_sync_tfm(req, ctx->fallback);
skcipher_request_set_callback(req, desc->flags, NULL, NULL);
skcipher_request_set_crypt(req, src, dst, nbytes, desc->info);
ret = enc? crypto_skcipher_encrypt(req) : crypto_skcipher_decrypt(req);
--
2.17.1
^ permalink raw reply related
* Re: [PATCH net-next] net: ibm: fix return type of ndo_start_xmit function
From: David Miller @ 2018-09-19 3:03 UTC (permalink / raw)
To: yuehaibing
Cc: dougmill, benh, paulus, mpe, tlfalcon, jallen, ivan, chunkeey,
keescook, linux-kernel, netdev, linuxppc-dev
In-Reply-To: <20180918063547.25644-1-yuehaibing@huawei.com>
From: YueHaibing <yuehaibing@huawei.com>
Date: Tue, 18 Sep 2018 14:35:47 +0800
> The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
> which is a typedef for an enum type, so make sure the implementation in
> this driver has returns 'netdev_tx_t' value, and change the function
> return type to netdev_tx_t.
>
> Found by coccinelle.
>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Applied.
^ permalink raw reply
* Re: [PATCH v4 15/20] powerpc/mm: Avoid useless lock with single page fragments
From: Aneesh Kumar K.V @ 2018-09-19 2:56 UTC (permalink / raw)
To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, aneesh.kumar
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <7efec0c76fa692513c806871151a7ae20e99fe05.1537288312.git.christophe.leroy@c-s.fr>
On 9/18/18 10:27 PM, Christophe Leroy wrote:
> There is no point in taking the page table lock as
> pte_frag is always NULL when we have only one fragment.
>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
> arch/powerpc/mm/pgtable-frag.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/powerpc/mm/pgtable-frag.c b/arch/powerpc/mm/pgtable-frag.c
> index bc924822dcd6..ab4910e92aaf 100644
> --- a/arch/powerpc/mm/pgtable-frag.c
> +++ b/arch/powerpc/mm/pgtable-frag.c
> @@ -85,6 +85,9 @@ static pte_t *get_pte_from_cache(struct mm_struct *mm)
> {
> void *pte_frag, *ret;
>
> + if (PTE_FRAG_NR == 1)
> + return NULL;
> +
> spin_lock(&mm->page_table_lock);
> ret = mm->context.pte_frag;
> if (ret) {
>
May be update get_pmd_from_cache too?
-aneesh
^ permalink raw reply
* Re: [PATCH v4 16/20] powerpc/mm: Extend pte_fragment functionality to nohash/32
From: Aneesh Kumar K.V @ 2018-09-19 3:03 UTC (permalink / raw)
To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, aneesh.kumar
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <a2f88be3bdaddc54a5836d6049c616b1739aef42.1537288312.git.christophe.leroy@c-s.fr>
On 9/18/18 10:27 PM, Christophe Leroy wrote:
> In order to allow the 8xx to handle pte_fragments, this patch
> extends the use of pte_fragments to nohash/32 platforms.
>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
> arch/powerpc/include/asm/mmu-40x.h | 1 +
> arch/powerpc/include/asm/mmu-44x.h | 1 +
> arch/powerpc/include/asm/mmu-8xx.h | 1 +
> arch/powerpc/include/asm/mmu-book3e.h | 1 +
> arch/powerpc/include/asm/mmu_context.h | 2 +-
> arch/powerpc/include/asm/nohash/32/pgalloc.h | 43 +++++++++++-----------------
> arch/powerpc/include/asm/nohash/32/pgtable.h | 7 +++--
> arch/powerpc/include/asm/page.h | 6 +---
> arch/powerpc/include/asm/pgtable.h | 8 ++++++
> arch/powerpc/mm/Makefile | 3 ++
> arch/powerpc/mm/mmu_context_nohash.c | 1 +
> arch/powerpc/mm/pgtable-frag.c | 6 ++++
> arch/powerpc/mm/pgtable_32.c | 8 ++++--
> 13 files changed, 51 insertions(+), 37 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/mmu-40x.h b/arch/powerpc/include/asm/mmu-40x.h
> index 74f4edb5916e..7c77ceed71d6 100644
> --- a/arch/powerpc/include/asm/mmu-40x.h
> +++ b/arch/powerpc/include/asm/mmu-40x.h
> @@ -58,6 +58,7 @@ typedef struct {
> unsigned int id;
> unsigned int active;
> unsigned long vdso_base;
> + void *pte_frag;
> } mm_context_t;
>
> #endif /* !__ASSEMBLY__ */
> diff --git a/arch/powerpc/include/asm/mmu-44x.h b/arch/powerpc/include/asm/mmu-44x.h
> index 295b3dbb2698..3d72e889ae7b 100644
> --- a/arch/powerpc/include/asm/mmu-44x.h
> +++ b/arch/powerpc/include/asm/mmu-44x.h
> @@ -109,6 +109,7 @@ typedef struct {
> unsigned int id;
> unsigned int active;
> unsigned long vdso_base;
> + void *pte_frag;
> } mm_context_t;
>
> #endif /* !__ASSEMBLY__ */
> diff --git a/arch/powerpc/include/asm/mmu-8xx.h b/arch/powerpc/include/asm/mmu-8xx.h
> index fa05aa566ece..750cef6f65e3 100644
> --- a/arch/powerpc/include/asm/mmu-8xx.h
> +++ b/arch/powerpc/include/asm/mmu-8xx.h
> @@ -179,6 +179,7 @@ typedef struct {
> unsigned int id;
> unsigned int active;
> unsigned long vdso_base;
> + void *pte_frag;
> #ifdef CONFIG_PPC_MM_SLICES
> u16 user_psize; /* page size index */
> unsigned char low_slices_psize[SLICE_ARRAY_SIZE];
> diff --git a/arch/powerpc/include/asm/mmu-book3e.h b/arch/powerpc/include/asm/mmu-book3e.h
> index e20072972e35..8e8aad5172ab 100644
> --- a/arch/powerpc/include/asm/mmu-book3e.h
> +++ b/arch/powerpc/include/asm/mmu-book3e.h
> @@ -230,6 +230,7 @@ typedef struct {
> unsigned int id;
> unsigned int active;
> unsigned long vdso_base;
> + void *pte_frag;
> } mm_context_t;
>
> /* Page size definitions, common between 32 and 64-bit
> diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h
> index b2f89b621b15..7f2c37a3f99d 100644
> --- a/arch/powerpc/include/asm/mmu_context.h
> +++ b/arch/powerpc/include/asm/mmu_context.h
> @@ -222,7 +222,7 @@ static inline int arch_dup_mmap(struct mm_struct *oldmm,
> return 0;
> }
>
> -#ifndef CONFIG_PPC_BOOK3S_64
> +#if defined(CONFIG_PPC_BOOK3E_64) || defined(CONFIG_PPC_BOOK3S_32)
> static inline void arch_exit_mmap(struct mm_struct *mm)
> {
> }
> diff --git a/arch/powerpc/include/asm/nohash/32/pgalloc.h b/arch/powerpc/include/asm/nohash/32/pgalloc.h
> index f3fec9052f31..e69423ad8e2e 100644
> --- a/arch/powerpc/include/asm/nohash/32/pgalloc.h
> +++ b/arch/powerpc/include/asm/nohash/32/pgalloc.h
> @@ -27,6 +27,9 @@ extern void __bad_pte(pmd_t *pmd);
> extern struct kmem_cache *pgtable_cache[];
> #define PGT_CACHE(shift) pgtable_cache[shift]
>
> +pte_t *pte_fragment_alloc(struct mm_struct *mm, unsigned long vmaddr, int kernel);
> +void pte_fragment_free(unsigned long *table, int kernel);
> +
> static inline pgd_t *pgd_alloc(struct mm_struct *mm)
> {
> return kmem_cache_alloc(PGT_CACHE(PGD_INDEX_SIZE),
> @@ -58,11 +61,10 @@ static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp,
> static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmdp,
> pgtable_t pte_page)
> {
> - *pmdp = __pmd((page_to_pfn(pte_page) << PAGE_SHIFT) | _PMD_USER |
> - _PMD_PRESENT);
> + *pmdp = __pmd(__pa(pte_page) | _PMD_USER | _PMD_PRESENT);
> }
>
> -#define pmd_pgtable(pmd) pmd_page(pmd)
> +#define pmd_pgtable(pmd) ((pgtable_t)pmd_page_vaddr(pmd))
> #else
>
> static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp,
> @@ -74,49 +76,38 @@ static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp,
> static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmdp,
> pgtable_t pte_page)
> {
> - *pmdp = __pmd((unsigned long)lowmem_page_address(pte_page) | _PMD_PRESENT);
> + *pmdp = __pmd((unsigned long)pte_page | _PMD_PRESENT);
> }
>
> -#define pmd_pgtable(pmd) pmd_page(pmd)
> +#define pmd_pgtable(pmd) ((pgtable_t)pmd_page_vaddr(pmd))
> #endif
>
> -static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
> +static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
> + unsigned long address)
> {
> - return (pte_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
> + return (pte_t *)pte_fragment_alloc(mm, address, 1);
> }
>
> -static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address)
> +static inline pgtable_t pte_alloc_one(struct mm_struct *mm,
> + unsigned long address)
> {
> - struct page *ptepage;
> -
> - gfp_t flags = GFP_KERNEL | __GFP_ZERO | __GFP_ACCOUNT;
> -
> - ptepage = alloc_pages(flags, 0);
> - if (!ptepage)
> - return NULL;
> - if (!pgtable_page_ctor(ptepage)) {
> - __free_page(ptepage);
> - return NULL;
> - }
> - return ptepage;
> + return (pgtable_t)pte_fragment_alloc(mm, address, 0);
> }
>
> static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
> {
> - free_page((unsigned long)pte);
> + pte_fragment_free((unsigned long *)pte, 1);
> }
>
> static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage)
> {
> - pgtable_page_dtor(ptepage);
> - __free_page(ptepage);
> + pte_fragment_free((unsigned long *)ptepage, 0);
> }
>
> static inline void pgtable_free(void *table, unsigned index_size)
> {
> if (!index_size) {
> - pgtable_page_dtor(virt_to_page(table));
> - free_page((unsigned long)table);
> + pte_fragment_free((unsigned long *)table, 0);
> } else {
> BUG_ON(index_size > MAX_PGTABLE_INDEX_SIZE);
> kmem_cache_free(PGT_CACHE(index_size), table);
> @@ -155,6 +146,6 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,
> unsigned long address)
> {
> tlb_flush_pgtable(tlb, address);
> - pgtable_free_tlb(tlb, page_address(table), 0);
> + pgtable_free_tlb(tlb, table, 0);
> }
> #endif /* _ASM_POWERPC_PGALLOC_32_H */
> diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h
> index d2908a8038e8..73e2b1fbdb36 100644
> --- a/arch/powerpc/include/asm/nohash/32/pgtable.h
> +++ b/arch/powerpc/include/asm/nohash/32/pgtable.h
> @@ -336,12 +336,12 @@ static inline int pte_young(pte_t pte)
> */
> #ifndef CONFIG_BOOKE
> #define pmd_page_vaddr(pmd) \
> - ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
> + ((unsigned long)__va(pmd_val(pmd) & ~(PTE_TABLE_SIZE - 1)))
> #define pmd_page(pmd) \
> pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT)
> #else
> #define pmd_page_vaddr(pmd) \
> - ((unsigned long) (pmd_val(pmd) & PAGE_MASK))
> + ((unsigned long)(pmd_val(pmd) & ~(PTE_TABLE_SIZE - 1)))
> #define pmd_page(pmd) \
> pfn_to_page((__pa(pmd_val(pmd)) >> PAGE_SHIFT))
> #endif
> @@ -360,7 +360,8 @@ static inline int pte_young(pte_t pte)
> (pmd_bad(*(dir)) ? NULL : (pte_t *)pmd_page_vaddr(*(dir)) + \
> pte_index(addr))
> #define pte_offset_map(dir, addr) \
> - ((pte_t *) kmap_atomic(pmd_page(*(dir))) + pte_index(addr))
> + ((pte_t *)(kmap_atomic(pmd_page(*(dir))) + \
> + (pmd_page_vaddr(*(dir)) & ~PAGE_MASK)) + pte_index(addr))
> #define pte_unmap(pte) kunmap_atomic(pte)
>
> /*
> diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
> index f6a1265face2..27d1c16601ee 100644
> --- a/arch/powerpc/include/asm/page.h
> +++ b/arch/powerpc/include/asm/page.h
> @@ -335,7 +335,7 @@ void arch_free_page(struct page *page, int order);
> #endif
>
> struct vm_area_struct;
> -#ifdef CONFIG_PPC_BOOK3S_64
> +#if !defined(CONFIG_PPC_BOOK3E_64) && !defined(CONFIG_PPC_BOOK3S_32)
> /*
> * For BOOK3s 64 with 4k and 64K linux page size
> * we want to use pointers, because the page table
> @@ -343,12 +343,8 @@ struct vm_area_struct;
> */
> typedef pte_t *pgtable_t;
> #else
> -#if defined(CONFIG_PPC_64K_PAGES) && defined(CONFIG_PPC64)
> -typedef pte_t *pgtable_t;
> -#else
> typedef struct page *pgtable_t;
> #endif
> -#endif
>
Now that is getting complicated. Is there a way to move that to platform
header instead of that complicated #if?
> #include <asm-generic/memory_model.h>
> #endif /* __ASSEMBLY__ */
> diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
> index 8b38f7730211..1865a3e4ab8c 100644
> --- a/arch/powerpc/include/asm/pgtable.h
> +++ b/arch/powerpc/include/asm/pgtable.h
> @@ -94,12 +94,20 @@ unsigned long vmalloc_to_phys(void *vmalloc_addr);
> void pgtable_cache_add(unsigned int shift);
> void pgtable_cache_init(void);
>
> +pte_t *early_alloc_pte(void);
> +
> #if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_PPC32)
> void mark_initmem_nx(void);
> #else
> static inline void mark_initmem_nx(void) { }
> #endif
>
> +#ifndef PTE_FRAG_NR
> +#define PTE_FRAG_NR 1
> +#define PTE_FRAG_SIZE_SHIFT PAGE_SHIFT
> +#define PTE_FRAG_SIZE PAGE_SIZE
> +#endif
> +
IMHO we should avoid that. The #ifndef challenge is that we should
always make sure the header inclusion is correct so that platform
headers get included before. Why not move it to the platform that want
to use pte fragmentation?
> #endif /* __ASSEMBLY__ */
>
> #endif /* _ASM_POWERPC_PGTABLE_H */
> diff --git a/arch/powerpc/mm/Makefile b/arch/powerpc/mm/Makefile
> index bd43b3ee52cb..e1deb15fe85e 100644
> --- a/arch/powerpc/mm/Makefile
> +++ b/arch/powerpc/mm/Makefile
> @@ -18,6 +18,9 @@ obj-$(CONFIG_PPC_BOOK3E_64) += pgtable-book3e.o
> obj-$(CONFIG_PPC_BOOK3S_64) += pgtable-hash64.o hash_utils_64.o slb_low.o slb.o \
> $(hash64-y) mmu_context_book3s64.o pgtable-book3s64.o \
> pgtable-frag.o
> +ifndef CONFIG_PPC_BOOK3S_32
> +obj-$(CONFIG_PPC32) += pgtable-frag.o
> +endif
> obj-$(CONFIG_PPC_RADIX_MMU) += pgtable-radix.o tlb-radix.o
> obj-$(CONFIG_PPC_STD_MMU_32) += ppc_mmu_32.o hash_low_32.o mmu_context_hash32.o
> obj-$(CONFIG_PPC_STD_MMU) += tlb_hash$(BITS).o
> diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
> index 4d80239ef83c..98f0ef463dc8 100644
> --- a/arch/powerpc/mm/mmu_context_nohash.c
> +++ b/arch/powerpc/mm/mmu_context_nohash.c
> @@ -385,6 +385,7 @@ int init_new_context(struct task_struct *t, struct mm_struct *mm)
> #endif
> mm->context.id = MMU_NO_CONTEXT;
> mm->context.active = 0;
> + mm->context.pte_frag = NULL;
> return 0;
> }
>
> diff --git a/arch/powerpc/mm/pgtable-frag.c b/arch/powerpc/mm/pgtable-frag.c
> index ab4910e92aaf..d554a1cbc56d 100644
> --- a/arch/powerpc/mm/pgtable-frag.c
> +++ b/arch/powerpc/mm/pgtable-frag.c
> @@ -30,6 +30,7 @@ static void pte_frag_destroy(void *pte_frag)
> }
> }
>
> +#ifdef CONFIG_PPC_BOOK3S_64
> static void pmd_frag_destroy(void *pmd_frag)
> {
> int count;
> @@ -44,6 +45,7 @@ static void pmd_frag_destroy(void *pmd_frag)
> __free_page(page);
> }
> }
> +#endif
>
> static void destroy_pagetable_cache(struct mm_struct *mm)
> {
> @@ -53,15 +55,18 @@ static void destroy_pagetable_cache(struct mm_struct *mm)
> if (frag)
> pte_frag_destroy(frag);
>
> +#ifdef CONFIG_PPC_BOOK3S_64
> frag = mm->context.pmd_frag;
> if (frag)
> pmd_frag_destroy(frag);
> +#endif
> }
>
> void arch_exit_mmap(struct mm_struct *mm)
> {
> destroy_pagetable_cache(mm);
>
> +#ifdef CONFIG_PPC_BOOK3S_64
> if (radix_enabled()) {
> /*
> * Radix doesn't have a valid bit in the process table
> @@ -79,6 +84,7 @@ void arch_exit_mmap(struct mm_struct *mm)
> */
> process_tb[mm->context.id].prtb0 = 0;
> }
> +#endif
> }
>
is there a way to avoid all that #ifdef? May be redo the frag code such
that we have few helpers that is platform independent?
> static pte_t *get_pte_from_cache(struct mm_struct *mm)
> diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
> index 7900b613e6e5..81e6b18d1955 100644
> --- a/arch/powerpc/mm/pgtable_32.c
> +++ b/arch/powerpc/mm/pgtable_32.c
> @@ -195,12 +195,16 @@ EXPORT_SYMBOL(iounmap);
> static __init pte_t *early_pte_alloc_kernel(pmd_t *pmdp, unsigned long va)
> {
> if (!pmd_present(*pmdp)) {
> - pte_t *ptep = __va(memblock_alloc(PAGE_SIZE, PAGE_SIZE));
> + pte_t *ptep = __va(memblock_alloc(PTE_FRAG_SIZE, PTE_FRAG_SIZE));
>
> if (!ptep)
> return NULL;
>
> - clear_page(ptep);
> + if (PTE_FRAG_SIZE == PAGE_SIZE)
> + clear_page(ptep);
> + else
> + memset(ptep, 0, PTE_FRAG_SIZE);
> +
> pmd_populate_kernel(&init_mm, pmdp, ptep);
> }
> return pte_offset_kernel(pmdp, va);
>
^ permalink raw reply
* Re: [PATCH] lib/xz: Fix powerpc build with KERNEL_XZ
From: Christophe LEROY @ 2018-09-19 5:52 UTC (permalink / raw)
To: Joel Stanley, Krzysztof Kozlowski
Cc: linuxppc-dev, Oliver O'Halloran, Herbert Xu, linux-kernel
In-Reply-To: <20180918230756.26035-1-joel@jms.id.au>
Le 19/09/2018 à 01:07, Joel Stanley a écrit :
> This partially reverts faa16bc404d72a5 ("lib: Use existing define with
> polynomial").
>
> The cleanup added a dependency on include/linux, which broke the PowerPC
> boot wrapper/decompresser when KERNEL_XZ is enabled:
>
> BOOTCC arch/powerpc/boot/decompress.o
> In file included from arch/powerpc/boot/../../../lib/decompress_unxz.c:233,
> from arch/powerpc/boot/decompress.c:42:
> arch/powerpc/boot/../../../lib/xz/xz_crc32.c:18:10: fatal error:
> linux/crc32poly.h: No such file or directory
> #include <linux/crc32poly.h>
> ^~~~~~~~~~~~~~~~~~~
>
> The powerpc decompressor is a hairy corner of the kernel. Even while building
> a 64-bit kernel it needs to build a 32-bit binary and therefore avoid including
> files from include/linux.
>
> Fixes: faa16bc404d7 ("lib: Use existing define with polynomial")
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> ---
> We need to clean up the powerpc boot decompresser but that work will be
> more involved than we would include in a late -rc. Please consider
> merging this fix for 4.19. Thanks!
>
> lib/xz/xz_crc32.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/lib/xz/xz_crc32.c b/lib/xz/xz_crc32.c
> index 25a5d87e2e4c..34532d14fd4c 100644
> --- a/lib/xz/xz_crc32.c
> +++ b/lib/xz/xz_crc32.c
> @@ -15,7 +15,6 @@
> * but they are bigger and use more memory for the lookup table.
> */
>
> -#include <linux/crc32poly.h>
> #include "xz_private.h"
>
> /*
> @@ -30,7 +29,7 @@ STATIC_RW_DATA uint32_t xz_crc32_table[256];
>
> XZ_EXTERN void xz_crc32_init(void)
> {
> - const uint32_t poly = CRC32_POLY_LE;
> + const uint32_t poly = 0xEDB88320;
Maybe avoid capital letters ?
What about adding something like the following in xz_private.h instead:
#define CRC32_POLY_LE 0xedb88320
Christophe
>
> uint32_t i;
> uint32_t j;
>
^ permalink raw reply
* RE: [PATCH] powerpc/mpc85xx: fix issues in clock node
From: Andy Tang @ 2018-09-19 6:31 UTC (permalink / raw)
To: Scott Wood
Cc: robh+dt@kernel.org, mark.rutland@arm.com,
benh@kernel.crashing.org, devicetree@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org
In-Reply-To: <ee1869ae946229fe01f5269fcebd855a2fc8770d.camel@buserror.net>
SGkgU2NvdHQsDQoNCldoYXQgeW91IHNhaWQgbWFrZXMgc2Vuc2Ugd2VsbC4gSSB3aWxsIHJlc2Vu
ZCB0aGUgcGF0Y2guDQoNClRoYW5rcywNCkFuZHkNCg0KPiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2Ut
LS0tLQ0KPiBGcm9tOiBTY290dCBXb29kIDxvc3NAYnVzZXJyb3IubmV0Pg0KPiBTZW50OiAyMDE4
5bm0OeaciDE55pelIDY6MjQNCj4gVG86IEFuZHkgVGFuZyA8YW5keS50YW5nQG54cC5jb20+DQo+
IENjOiByb2JoK2R0QGtlcm5lbC5vcmc7IG1hcmsucnV0bGFuZEBhcm0uY29tOw0KPiBiZW5oQGtl
cm5lbC5jcmFzaGluZy5vcmc7IGRldmljZXRyZWVAdmdlci5rZXJuZWwub3JnOw0KPiBsaW51eHBw
Yy1kZXZAbGlzdHMub3psYWJzLm9yZw0KPiBTdWJqZWN0OiBSZTogW1BBVENIXSBwb3dlcnBjL21w
Yzg1eHg6IGZpeCBpc3N1ZXMgaW4gY2xvY2sgbm9kZQ0KPiANCj4gT24gVHVlLCAyMDE4LTA5LTEx
IGF0IDEwOjEyICswODAwLCBhbmR5LnRhbmdAbnhwLmNvbSB3cm90ZToNCj4gPiBGcm9tOiBZdWFu
dGlhbiBUYW5nIDxhbmR5LnRhbmdAbnhwLmNvbT4NCj4gPg0KPiA+IFRoZSBjb21wYXRpYmxlIHN0
cmluZyBpcyBub3QgY29ycmVjdCBpbiB0aGUgY2xvY2sgbm9kZS4NCj4gPiBUaGUgY2xvY2tzIHBy
b3BlcnR5IHJlZmVycyB0byB0aGUgd3Jvbmcgbm9kZSB0b28uDQo+ID4gVGhpcyBwYXRjaCBpcyB0
byBmaXggdGhlbS4NCj4gPg0KPiA+IFNpZ25lZC1vZmYtYnk6IFRhbmcgWXVhbnRpYW4gPGFuZHku
dGFuZ0BueHAuY29tPg0KPiA+IC0tLQ0KPiA+ICBhcmNoL3Bvd2VycGMvYm9vdC9kdHMvZnNsL3Qx
MDIzc2ktcG9zdC5kdHNpIHwgICAgOCArKysrLS0tLQ0KPiA+ICAxIGZpbGVzIGNoYW5nZWQsIDQg
aW5zZXJ0aW9ucygrKSwgNCBkZWxldGlvbnMoLSkNCj4gPg0KPiA+IGRpZmYgLS1naXQgYS9hcmNo
L3Bvd2VycGMvYm9vdC9kdHMvZnNsL3QxMDIzc2ktcG9zdC5kdHNpDQo+ID4gYi9hcmNoL3Bvd2Vy
cGMvYm9vdC9kdHMvZnNsL3QxMDIzc2ktcG9zdC5kdHNpDQo+ID4gaW5kZXggNDkwOGFmNS4uNzYz
Y2FmNCAxMDA2NDQNCj4gPiAtLS0gYS9hcmNoL3Bvd2VycGMvYm9vdC9kdHMvZnNsL3QxMDIzc2kt
cG9zdC5kdHNpDQo+ID4gKysrIGIvYXJjaC9wb3dlcnBjL2Jvb3QvZHRzL2ZzbC90MTAyM3NpLXBv
c3QuZHRzaQ0KPiA+IEBAIC0zNDgsNyArMzQ4LDcgQEANCj4gPiAgCQltdXgwOiBtdXgwQDAgew0K
PiA+ICAJCQkjY2xvY2stY2VsbHMgPSA8MD47DQo+ID4gIAkJCXJlZyA9IDwweDAgND47DQo+ID4g
LQkJCWNvbXBhdGlibGUgPSAiZnNsLGNvcmUtbXV4LWNsb2NrIjsNCj4gPiArCQkJY29tcGF0aWJs
ZSA9ICJmc2wscW9yaXEtY29yZS1tdXgtMi4wIjsNCj4gPiAgCQkJY2xvY2tzID0gPCZwbGwwIDA+
LCA8JnBsbDAgMT47DQo+ID4gIAkJCWNsb2NrLW5hbWVzID0gInBsbDBfMCIsICJwbGwwXzEiOw0K
PiA+ICAJCQljbG9jay1vdXRwdXQtbmFtZXMgPSAiY211eDAiOw0KPiA+IEBAIC0zNTYsOSArMzU2
LDkgQEANCj4gPiAgCQltdXgxOiBtdXgxQDIwIHsNCj4gPiAgCQkJI2Nsb2NrLWNlbGxzID0gPDA+
Ow0KPiA+ICAJCQlyZWcgPSA8MHgyMCA0PjsNCj4gPiAtCQkJY29tcGF0aWJsZSA9ICJmc2wsY29y
ZS1tdXgtY2xvY2siOw0KPiA+IC0JCQljbG9ja3MgPSA8JnBsbDAgMD4sIDwmcGxsMCAxPjsNCj4g
PiAtCQkJY2xvY2stbmFtZXMgPSAicGxsMF8wIiwgInBsbDBfMSI7DQo+ID4gKwkJCWNvbXBhdGli
bGUgPSAiZnNsLHFvcmlxLWNvcmUtbXV4LTIuMCI7DQo+ID4gKwkJCWNsb2NrcyA9IDwmcGxsMSAw
PiwgPCZwbGwxIDE+Ow0KPiA+ICsJCQljbG9jay1uYW1lcyA9ICJwbGwxXzAiLCAicGxsMV8xIjsN
Cj4gPiAgCQkJY2xvY2stb3V0cHV0LW5hbWVzID0gImNtdXgxIjsNCj4gPiAgCQl9Ow0KPiA+ICAJ
fTsNCj4gDQo+IFRoZXNlIGFyZSB0aGUgbGVnYWN5IG5vZGVzLiAgV2h5IG5vdCBqdXN0IHJlbW92
ZSB0aGVtIGluc3RlYWQgb2YgZml4aW5nDQo+IHRoZW0/DQo+IE5vdyB0aGF0IHRoZSBjcHVmcmVx
IGRyaXZlciBpcyBmaXhlZCB3ZSBjb3VsZCBnZXQgcmlkIG9mIHRoZSBsZWdhY3kgbm9kZXMNCj4g
Zm9yIGFsbCB0aGUgY2hpcHMuDQo+IA0KPiAtU2NvdHQNCg0K
^ permalink raw reply
* Re: [PATCH] lib/xz: Fix powerpc build with KERNEL_XZ
From: Krzysztof Kozlowski @ 2018-09-19 6:39 UTC (permalink / raw)
To: joel; +Cc: herbert, linux-kernel, mpe, oohall, linuxppc-dev,
Christophe LEROY
In-Reply-To: <20180918230756.26035-1-joel@jms.id.au>
On Wed, 19 Sep 2018 at 01:08, Joel Stanley <joel@jms.id.au> wrote:
>
> This partially reverts faa16bc404d72a5 ("lib: Use existing define with
> polynomial").
>
> The cleanup added a dependency on include/linux, which broke the PowerPC
> boot wrapper/decompresser when KERNEL_XZ is enabled:
>
> BOOTCC arch/powerpc/boot/decompress.o
> In file included from arch/powerpc/boot/../../../lib/decompress_unxz.c:233,
> from arch/powerpc/boot/decompress.c:42:
> arch/powerpc/boot/../../../lib/xz/xz_crc32.c:18:10: fatal error:
> linux/crc32poly.h: No such file or directory
> #include <linux/crc32poly.h>
> ^~~~~~~~~~~~~~~~~~~
>
> The powerpc decompressor is a hairy corner of the kernel. Even while building
> a 64-bit kernel it needs to build a 32-bit binary and therefore avoid including
> files from include/linux.
I fixed the build error here:
https://lkml.org/lkml/2018/8/29/179
If you choose to remove any includes from /linux, then go ahead but
please use original reported-by :)
Best regards,
Krzysztof
>
> Fixes: faa16bc404d7 ("lib: Use existing define with polynomial")
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> ---
> We need to clean up the powerpc boot decompresser but that work will be
> more involved than we would include in a late -rc. Please consider
> merging this fix for 4.19. Thanks!
>
> lib/xz/xz_crc32.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/lib/xz/xz_crc32.c b/lib/xz/xz_crc32.c
> index 25a5d87e2e4c..34532d14fd4c 100644
> --- a/lib/xz/xz_crc32.c
> +++ b/lib/xz/xz_crc32.c
> @@ -15,7 +15,6 @@
> * but they are bigger and use more memory for the lookup table.
> */
>
> -#include <linux/crc32poly.h>
> #include "xz_private.h"
>
> /*
> @@ -30,7 +29,7 @@ STATIC_RW_DATA uint32_t xz_crc32_table[256];
>
> XZ_EXTERN void xz_crc32_init(void)
> {
> - const uint32_t poly = CRC32_POLY_LE;
> + const uint32_t poly = 0xEDB88320;
>
> uint32_t i;
> uint32_t j;
> --
> 2.17.1
>
^ permalink raw reply
* Re: [PATCH] lib/xz: Fix powerpc build with KERNEL_XZ
From: Oliver @ 2018-09-19 6:44 UTC (permalink / raw)
To: Christophe LEROY
Cc: Joel Stanley, Krzysztof Kozlowski, linuxppc-dev, Herbert Xu,
Linux Kernel Mailing List
In-Reply-To: <a3a97ebf-9a40-db6e-8225-7b9ccf9cfb4b@c-s.fr>
On Wed, Sep 19, 2018 at 3:52 PM, Christophe LEROY
<christophe.leroy@c-s.fr> wrote:
>
>
> Le 19/09/2018 =C3=A0 01:07, Joel Stanley a =C3=A9crit :
>>
>> This partially reverts faa16bc404d72a5 ("lib: Use existing define with
>> polynomial").
>>
>> The cleanup added a dependency on include/linux, which broke the PowerPC
>> boot wrapper/decompresser when KERNEL_XZ is enabled:
>>
>> BOOTCC arch/powerpc/boot/decompress.o
>> In file included from
>> arch/powerpc/boot/../../../lib/decompress_unxz.c:233,
>> from arch/powerpc/boot/decompress.c:42:
>> arch/powerpc/boot/../../../lib/xz/xz_crc32.c:18:10: fatal error:
>> linux/crc32poly.h: No such file or directory
>> #include <linux/crc32poly.h>
>> ^~~~~~~~~~~~~~~~~~~
>>
>> The powerpc decompressor is a hairy corner of the kernel. Even while
>> building
>> a 64-bit kernel it needs to build a 32-bit binary and therefore avoid
>> including
>> files from include/linux.
>>
>> Fixes: faa16bc404d7 ("lib: Use existing define with polynomial")
>> Signed-off-by: Joel Stanley <joel@jms.id.au>
>> ---
>> We need to clean up the powerpc boot decompresser but that work will be
>> more involved than we would include in a late -rc. Please consider
>> merging this fix for 4.19. Thanks!
>>
>> lib/xz/xz_crc32.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/lib/xz/xz_crc32.c b/lib/xz/xz_crc32.c
>> index 25a5d87e2e4c..34532d14fd4c 100644
>> --- a/lib/xz/xz_crc32.c
>> +++ b/lib/xz/xz_crc32.c
>> @@ -15,7 +15,6 @@
>> * but they are bigger and use more memory for the lookup table.
>> */
>> -#include <linux/crc32poly.h>
>> #include "xz_private.h"
>> /*
>> @@ -30,7 +29,7 @@ STATIC_RW_DATA uint32_t xz_crc32_table[256];
>> XZ_EXTERN void xz_crc32_init(void)
>> {
>> - const uint32_t poly =3D CRC32_POLY_LE;
>> + const uint32_t poly =3D 0xEDB88320;
>
>
> Maybe avoid capital letters ?
>
> What about adding something like the following in xz_private.h instead:
>
> #define CRC32_POLY_LE 0xedb88320
The problem is that it's pulling in linux/crc32poly.h. To support old
systems with a 32bit Open Firmware we boot wrapper we build the boot
wrapper as a 32bit ELF even for a 64 bit kernel. The headers generated
by Kbuild are only valid for the 64bit kernel so we have to avoid
pulling them into the boot wrapper.
> Christophe
>
>> uint32_t i;
>> uint32_t j;
>>
>
^ permalink raw reply
* Re: [PATCH] lib/xz: Fix powerpc build with KERNEL_XZ
From: Christophe LEROY @ 2018-09-19 6:52 UTC (permalink / raw)
To: Oliver
Cc: Joel Stanley, Krzysztof Kozlowski, linuxppc-dev, Herbert Xu,
Linux Kernel Mailing List
In-Reply-To: <CAOSf1CG3bFHNWS8hQVy-VrpfnwjLWBHSrr-c52AMQbsBRqeyZA@mail.gmail.com>
Le 19/09/2018 à 08:44, Oliver a écrit :
> On Wed, Sep 19, 2018 at 3:52 PM, Christophe LEROY
> <christophe.leroy@c-s.fr> wrote:
>>
>>
>> Le 19/09/2018 à 01:07, Joel Stanley a écrit :
>>>
>>> This partially reverts faa16bc404d72a5 ("lib: Use existing define with
>>> polynomial").
>>>
>>> The cleanup added a dependency on include/linux, which broke the PowerPC
>>> boot wrapper/decompresser when KERNEL_XZ is enabled:
>>>
>>> BOOTCC arch/powerpc/boot/decompress.o
>>> In file included from
>>> arch/powerpc/boot/../../../lib/decompress_unxz.c:233,
>>> from arch/powerpc/boot/decompress.c:42:
>>> arch/powerpc/boot/../../../lib/xz/xz_crc32.c:18:10: fatal error:
>>> linux/crc32poly.h: No such file or directory
>>> #include <linux/crc32poly.h>
>>> ^~~~~~~~~~~~~~~~~~~
>>>
>>> The powerpc decompressor is a hairy corner of the kernel. Even while
>>> building
>>> a 64-bit kernel it needs to build a 32-bit binary and therefore avoid
>>> including
>>> files from include/linux.
>>>
>>> Fixes: faa16bc404d7 ("lib: Use existing define with polynomial")
>>> Signed-off-by: Joel Stanley <joel@jms.id.au>
>>> ---
>>> We need to clean up the powerpc boot decompresser but that work will be
>>> more involved than we would include in a late -rc. Please consider
>>> merging this fix for 4.19. Thanks!
>>>
>>> lib/xz/xz_crc32.c | 3 +--
>>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>>
>>> diff --git a/lib/xz/xz_crc32.c b/lib/xz/xz_crc32.c
>>> index 25a5d87e2e4c..34532d14fd4c 100644
>>> --- a/lib/xz/xz_crc32.c
>>> +++ b/lib/xz/xz_crc32.c
>>> @@ -15,7 +15,6 @@
>>> * but they are bigger and use more memory for the lookup table.
>>> */
>>> -#include <linux/crc32poly.h>
>>> #include "xz_private.h"
>>> /*
>>> @@ -30,7 +29,7 @@ STATIC_RW_DATA uint32_t xz_crc32_table[256];
>>> XZ_EXTERN void xz_crc32_init(void)
>>> {
>>> - const uint32_t poly = CRC32_POLY_LE;
>>> + const uint32_t poly = 0xEDB88320;
>>
>>
>> Maybe avoid capital letters ?
>>
>> What about adding something like the following in xz_private.h instead:
>>
>> #define CRC32_POLY_LE 0xedb88320
>
> The problem is that it's pulling in linux/crc32poly.h. To support old
> systems with a 32bit Open Firmware we boot wrapper we build the boot
> wrapper as a 32bit ELF even for a 64 bit kernel. The headers generated
> by Kbuild are only valid for the 64bit kernel so we have to avoid
> pulling them into the boot wrapper.
Yes I understood, hence my proposal to redefine CRC32_POLY_LE in
xz_private.h instead of including linux/crc32poly.h
It avoids modifying the C code.
Christophe
>
>> Christophe
>>
>>> uint32_t i;
>>> uint32_t j;
>>>
>>
^ permalink raw reply
* Re: [PATCH v1 0/6] mm: online/offline_pages called w.o. mem_hotplug_lock
From: David Hildenbrand @ 2018-09-19 7:35 UTC (permalink / raw)
To: Balbir Singh
Cc: linux-mm, linux-kernel, linux-doc, linuxppc-dev, linux-acpi,
xen-devel, devel, Andrew Morton, Benjamin Herrenschmidt,
Boris Ostrovsky, Dan Williams, Greg Kroah-Hartman, Haiyang Zhang,
Heiko Carstens, John Allen, Jonathan Corbet, Joonsoo Kim,
Juergen Gross, Kate Stewart, K. Y. Srinivasan, Len Brown,
Martin Schwidefsky, Mathieu Malaterre, Michael Ellerman,
Michael Neuling, Michal Hocko, Nathan Fontenot, Oscar Salvador,
Paul Mackerras, Pavel Tatashin, Pavel Tatashin,
Philippe Ombredanne, Rafael J. Wysocki, Rashmica Gupta,
Stephen Hemminger, Thomas Gleixner, Vlastimil Babka,
YASUAKI ISHIMATSU
In-Reply-To: <20180919012207.GD8537@350D>
Am 19.09.18 um 03:22 schrieb Balbir Singh:
> On Tue, Sep 18, 2018 at 01:48:16PM +0200, David Hildenbrand wrote:
>> Reading through the code and studying how mem_hotplug_lock is to be used,
>> I noticed that there are two places where we can end up calling
>> device_online()/device_offline() - online_pages()/offline_pages() without
>> the mem_hotplug_lock. And there are other places where we call
>> device_online()/device_offline() without the device_hotplug_lock.
>>
>> While e.g.
>> echo "online" > /sys/devices/system/memory/memory9/state
>> is fine, e.g.
>> echo 1 > /sys/devices/system/memory/memory9/online
>> Will not take the mem_hotplug_lock. However the device_lock() and
>> device_hotplug_lock.
>>
>> E.g. via memory_probe_store(), we can end up calling
>> add_memory()->online_pages() without the device_hotplug_lock. So we can
>> have concurrent callers in online_pages(). We e.g. touch in online_pages()
>> basically unprotected zone->present_pages then.
>>
>> Looks like there is a longer history to that (see Patch #2 for details),
>> and fixing it to work the way it was intended is not really possible. We
>> would e.g. have to take the mem_hotplug_lock in device/base/core.c, which
>> sounds wrong.
>>
>> Summary: We had a lock inversion on mem_hotplug_lock and device_lock().
>> More details can be found in patch 3 and patch 6.
>>
>> I propose the general rules (documentation added in patch 6):
>>
>> 1. add_memory/add_memory_resource() must only be called with
>> device_hotplug_lock.
>> 2. remove_memory() must only be called with device_hotplug_lock. This is
>> already documented and holds for all callers.
>> 3. device_online()/device_offline() must only be called with
>> device_hotplug_lock. This is already documented and true for now in core
>> code. Other callers (related to memory hotplug) have to be fixed up.
>> 4. mem_hotplug_lock is taken inside of add_memory/remove_memory/
>> online_pages/offline_pages.
>>
>> To me, this looks way cleaner than what we have right now (and easier to
>> verify). And looking at the documentation of remove_memory, using
>> lock_device_hotplug also for add_memory() feels natural.
>>
>
> That seems reasonable, but also implies that device_online() would hold
> back add/remove memory, could you please also document what mode
> read/write the locks need to be held? For example can the device_hotplug_lock
> be held in read mode while add/remove memory via (mem_hotplug_lock) is held
> in write mode?
device_hotplug_lock is an ordinary mutex. So no option there.
Only mem_hotplug_lock is a per CPU RW mutex. And as of now it only
exists to not require get_online_mems()/put_online_mems() to take the
device_hotplug_lock. Which is perfectly valid, because these users only
care about memory (not any other devices) not suddenly vanish. And that
RW lock makes things fast.
Any modifications (online/offline/add/remove) require the
mem_hotplug_lock in write.
I can add some more details to documentation in patch #6.
"... we should always hold the mem_hotplug_lock (via
mem_hotplug_begin/mem_hotplug_done) in write mode to serialize memory
hotplug" ..."
"In addition, mem_hotplug_lock (in contrast to device_hotplug_lock) in
read mode allows for a quite efficient get_online_mems/put_online_mems
implementation, so code accessing memory can protect from that memory
vanishing."
Would that work for you?
Thanks!
>
> Balbir Singh.
>
>
--
Thanks,
David / dhildenb
^ permalink raw reply
* Re: [PATCH v2 4/5] powerpc: Fix duplicate const clang warning in user access code
From: Joel Stanley @ 2018-09-19 7:45 UTC (permalink / raw)
To: Nick Desaulniers; +Cc: linuxppc-dev, Anton Blanchard, Anton Blanchard
In-Reply-To: <CAKwvOd=-22J2=QvCTOAxkWw-WV8C4VY6Yvx91Rif5STmiXMtMg@mail.gmail.com>
On Sat, 15 Sep 2018 at 03:27, Nick Desaulniers <ndesaulniers@google.com> wrote:
>
> On Thu, Sep 13, 2018 at 9:07 PM Joel Stanley <joel@jms.id.au> wrote:
> >
> > From: Anton Blanchard <anton@samba.org>
> >
> > This re-applies b91c1e3e7a6f which was reverted in f2ca80905929
> > d466f6c5cac1 f84ed59a612d (powerpc/sparse: Constify the address pointer
> > ...").
> >
> > We see a large number of duplicate const errors in the user access
> > code when building with llvm/clang:
> >
> > include/linux/pagemap.h:576:8: warning: duplicate 'const' declaration specifier
> > [-Wduplicate-decl-specifier]
> > ret = __get_user(c, uaddr);
> >
> > The problem is we are doing const __typeof__(*(ptr)), which will hit the
> > warning if ptr is marked const.
> >
> > Removing const does not seem to have any effect on GCC code generation.
>
> I wouldn't expect it to for a local variable with such localized
> usage. I myself am quite liberal in applying `const` to everything,
> so I will try to fix this in Clang as well, but this should silence
> the warning for users of older versions of Clang and results in no
> functional change.
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Nick has written a clang patch that suppresses the warning in the same
way as GCC. Assuming it gets merged, as we depend on clang-8 we could
chose to not merge the kernel patch.
https://reviews.llvm.org/D52248
Cheers,
Joel
^ permalink raw reply
* [RFC PATCH 1/4] powerpc/pseries: Use macros for referring to the DTL enable mask
From: Naveen N. Rao @ 2018-09-19 8:08 UTC (permalink / raw)
To: Michael Ellerman, Nathan Fontenot, Michael Bringmann; +Cc: linuxppc-dev
In-Reply-To: <cover.1537343904.git.naveen.n.rao@linux.vnet.ibm.com>
Introduce macros to encode the DTL enable mask fields and use those
instead of hardcoding numbers.
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
arch/powerpc/include/asm/lppaca.h | 11 +++++++++++
arch/powerpc/platforms/pseries/dtl.c | 8 +-------
arch/powerpc/platforms/pseries/lpar.c | 2 +-
arch/powerpc/platforms/pseries/setup.c | 2 +-
4 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/arch/powerpc/include/asm/lppaca.h b/arch/powerpc/include/asm/lppaca.h
index 7c23ce8a5a4c..2c7e31187726 100644
--- a/arch/powerpc/include/asm/lppaca.h
+++ b/arch/powerpc/include/asm/lppaca.h
@@ -154,6 +154,17 @@ struct dtl_entry {
#define DISPATCH_LOG_BYTES 4096 /* bytes per cpu */
#define N_DISPATCH_LOG (DISPATCH_LOG_BYTES / sizeof(struct dtl_entry))
+/*
+ * Dispatch trace log event enable mask:
+ * 0x1: voluntary virtual processor waits
+ * 0x2: time-slice preempts
+ * 0x4: virtual partition memory page faults
+ */
+#define DTL_LOG_CEDE 0x1
+#define DTL_LOG_PREEMPT 0x2
+#define DTL_LOG_FAULT 0x4
+#define DTL_LOG_ALL (DTL_LOG_CEDE | DTL_LOG_PREEMPT | DTL_LOG_FAULT)
+
extern struct kmem_cache *dtl_cache;
/*
diff --git a/arch/powerpc/platforms/pseries/dtl.c b/arch/powerpc/platforms/pseries/dtl.c
index 18014cdeb590..e0421aa6eafa 100644
--- a/arch/powerpc/platforms/pseries/dtl.c
+++ b/arch/powerpc/platforms/pseries/dtl.c
@@ -40,13 +40,7 @@ struct dtl {
};
static DEFINE_PER_CPU(struct dtl, cpu_dtl);
-/*
- * Dispatch trace log event mask:
- * 0x7: 0x1: voluntary virtual processor waits
- * 0x2: time-slice preempts
- * 0x4: virtual partition memory page faults
- */
-static u8 dtl_event_mask = 0x7;
+static u8 dtl_event_mask = DTL_LOG_ALL;
/*
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index d3992ced0782..dd024a192512 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -125,7 +125,7 @@ void vpa_init(int cpu)
pr_err("WARNING: DTL registration of cpu %d (hw %d) "
"failed with %ld\n", smp_processor_id(),
hwcpu, ret);
- lppaca_of(cpu).dtl_enable_mask = 2;
+ lppaca_of(cpu).dtl_enable_mask = DTL_LOG_PREEMPT;
}
}
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index ba1791fd3234..a48cb9757be2 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -293,7 +293,7 @@ static int alloc_dispatch_logs(void)
pr_err("WARNING: DTL registration of cpu %d (hw %d) failed "
"with %d\n", smp_processor_id(),
hard_smp_processor_id(), ret);
- get_paca()->lppaca_ptr->dtl_enable_mask = 2;
+ get_paca()->lppaca_ptr->dtl_enable_mask = DTL_LOG_PREEMPT;
return 0;
}
--
2.18.0
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox