Re: [PATCH 1/5] ocxl: Rename struct link to ocxl_link
On 27/2/19 6:34 pm, Alastair D'Silva wrote:>>> diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c index e6a607488f8a..16eb8a60d5c7 100644 --- a/drivers/misc/ocxl/file.c +++ b/drivers/misc/ocxl/file.c @@ -152,7 +152,7 @@ static long afu_ioctl_enable_p9_wait(struct ocxl_context *ctx, if (status == ATTACHED) { int rc; - struct link *link = ctx->afu->fn->link; + void *link = ctx->afu->fn->link; This doesn't look like a rename... That corrects the type to what the member (and prototype for ocxl_link_update_pe) declare it as. The struct link there is bogus, it shouldn't even compile (since the intended struct link is defined in a different compilation unit), but instead picks up a different definition of 'struct link' from elsewhere. Given there's only a handful of struct links defined across the entire kernel, I'm going to guess that the definition it's picking up is in fact the ocxl one. I think the better solution here is to move struct ocxl_link into ocxl_internal.h, change ocxl_fn::link to be struct ocxl_link * rather than void *, and update the function signature for ocxl_link_update_pe() as well. -- Andrew Donnellan OzLabs, ADL Canberra andrew.donnel...@au1.ibm.com IBM Australia Limited
RE: [PATCH 1/5] ocxl: Rename struct link to ocxl_link
> -Original Message- > From: Andrew Donnellan > Sent: Wednesday, 27 February 2019 6:16 PM > To: Alastair D'Silva ; alast...@d-silva.org > Cc: Greg Kurz ; Frederic Barrat ; > Arnd Bergmann ; Greg Kroah-Hartman > ; linuxppc-dev@lists.ozlabs.org; linux- > ker...@vger.kernel.org > Subject: Re: [PATCH 1/5] ocxl: Rename struct link to ocxl_link > > On 27/2/19 3:57 pm, Alastair D'Silva wrote: > > From: Alastair D'Silva > > > > The term 'link' is ambiguous (especially when the struct is used for a > > list), so rename it for clarity. > > > > Signed-off-by: Alastair D'Silva > > Reviewed-by: Greg Kurz > > --- > > drivers/misc/ocxl/file.c | 2 +- > > drivers/misc/ocxl/link.c | 36 ++-- > > 2 files changed, 19 insertions(+), 19 deletions(-) > > > > diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c index > > e6a607488f8a..16eb8a60d5c7 100644 > > --- a/drivers/misc/ocxl/file.c > > +++ b/drivers/misc/ocxl/file.c > > @@ -152,7 +152,7 @@ static long afu_ioctl_enable_p9_wait(struct > > ocxl_context *ctx, > > > > if (status == ATTACHED) { > > int rc; > > - struct link *link = ctx->afu->fn->link; > > + void *link = ctx->afu->fn->link; > > This doesn't look like a rename... That corrects the type to what the member (and prototype for ocxl_link_update_pe) declare it as. The struct link there is bogus, it shouldn't even compile (since the intended struct link is defined in a different compilation unit), but instead picks up a different definition of 'struct link' from elsewhere. -- Alastair D'Silva mob: 0423 762 819 skype: alastair_dsilva msn: alast...@d-silva.org blog: http://alastair.d-silva.orgTwitter: @EvilDeece
Re: [PATCH 1/5] ocxl: Rename struct link to ocxl_link
On 27/2/19 3:57 pm, Alastair D'Silva wrote: From: Alastair D'Silva The term 'link' is ambiguous (especially when the struct is used for a list), so rename it for clarity. Signed-off-by: Alastair D'Silva Reviewed-by: Greg Kurz --- drivers/misc/ocxl/file.c | 2 +- drivers/misc/ocxl/link.c | 36 ++-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c index e6a607488f8a..16eb8a60d5c7 100644 --- a/drivers/misc/ocxl/file.c +++ b/drivers/misc/ocxl/file.c @@ -152,7 +152,7 @@ static long afu_ioctl_enable_p9_wait(struct ocxl_context *ctx, if (status == ATTACHED) { int rc; - struct link *link = ctx->afu->fn->link; + void *link = ctx->afu->fn->link; This doesn't look like a rename... rc = ocxl_link_update_pe(link, ctx->pasid, ctx->tidr); if (rc) diff --git a/drivers/misc/ocxl/link.c b/drivers/misc/ocxl/link.c index d50b861d7e57..8d2690a1a9de 100644 --- a/drivers/misc/ocxl/link.c +++ b/drivers/misc/ocxl/link.c @@ -76,7 +76,7 @@ struct spa { * limited number of opencapi slots on a system and lookup is only * done when the device is probed */ -struct link { +struct ocxl_link { struct list_head list; struct kref ref; int domain; @@ -179,7 +179,7 @@ static void xsl_fault_handler_bh(struct work_struct *fault_work) static irqreturn_t xsl_fault_handler(int irq, void *data) { - struct link *link = (struct link *) data; + struct ocxl_link *link = (struct ocxl_link *) data; struct spa *spa = link->spa; u64 dsisr, dar, pe_handle; struct pe_data *pe_data; @@ -256,7 +256,7 @@ static int map_irq_registers(struct pci_dev *dev, struct spa *spa) >reg_tfc, >reg_pe_handle); } -static int setup_xsl_irq(struct pci_dev *dev, struct link *link) +static int setup_xsl_irq(struct pci_dev *dev, struct ocxl_link *link) { struct spa *spa = link->spa; int rc; @@ -311,7 +311,7 @@ static int setup_xsl_irq(struct pci_dev *dev, struct link *link) return rc; } -static void release_xsl_irq(struct link *link) +static void release_xsl_irq(struct ocxl_link *link) { struct spa *spa = link->spa; @@ -323,7 +323,7 @@ static void release_xsl_irq(struct link *link) unmap_irq_registers(spa); } -static int alloc_spa(struct pci_dev *dev, struct link *link) +static int alloc_spa(struct pci_dev *dev, struct ocxl_link *link) { struct spa *spa; @@ -350,7 +350,7 @@ static int alloc_spa(struct pci_dev *dev, struct link *link) return 0; } -static void free_spa(struct link *link) +static void free_spa(struct ocxl_link *link) { struct spa *spa = link->spa; @@ -364,12 +364,12 @@ static void free_spa(struct link *link) } } -static int alloc_link(struct pci_dev *dev, int PE_mask, struct link **out_link) +static int alloc_link(struct pci_dev *dev, int PE_mask, struct ocxl_link **out_link) { - struct link *link; + struct ocxl_link *link; int rc; - link = kzalloc(sizeof(struct link), GFP_KERNEL); + link = kzalloc(sizeof(struct ocxl_link), GFP_KERNEL); if (!link) return -ENOMEM; @@ -405,7 +405,7 @@ static int alloc_link(struct pci_dev *dev, int PE_mask, struct link **out_link) return rc; } -static void free_link(struct link *link) +static void free_link(struct ocxl_link *link) { release_xsl_irq(link); free_spa(link); @@ -415,7 +415,7 @@ static void free_link(struct link *link) int ocxl_link_setup(struct pci_dev *dev, int PE_mask, void **link_handle) { int rc = 0; - struct link *link; + struct ocxl_link *link; mutex_lock(_list_lock); list_for_each_entry(link, _list, list) { @@ -442,7 +442,7 @@ EXPORT_SYMBOL_GPL(ocxl_link_setup); static void release_xsl(struct kref *ref) { - struct link *link = container_of(ref, struct link, ref); + struct ocxl_link *link = container_of(ref, struct ocxl_link, ref); list_del(>list); /* call platform code before releasing data */ @@ -452,7 +452,7 @@ static void release_xsl(struct kref *ref) void ocxl_link_release(struct pci_dev *dev, void *link_handle) { - struct link *link = (struct link *) link_handle; + struct ocxl_link *link = (struct ocxl_link *) link_handle; mutex_lock(_list_lock); kref_put(>ref, release_xsl); @@ -488,7 +488,7 @@ int ocxl_link_add_pe(void *link_handle, int pasid, u32 pidr, u32 tidr, void (*xsl_err_cb)(void *data, u64 addr, u64 dsisr), void *xsl_err_data) { - struct link *link = (struct link *) link_handle; + struct ocxl_link *link = (struct ocxl_link *) link_handle; struct spa *spa = link->spa; struct
Re: [PATCH v8 02/11] powerpc: prepare string/mem functions for KASAN
Christophe Leroy writes: > CONFIG_KASAN implements wrappers for memcpy() memmove() and memset() > Those wrappers are doing the verification then call respectively > __memcpy() __memmove() and __memset(). The arches are therefore > expected to rename their optimised functions that way. > > For files on which KASAN is inhibited, #defines are used to allow > them to directly call optimised versions of the functions without > going through the KASAN wrappers. > > See commit 393f203f5fd5 ("x86_64: kasan: add interceptors for > memset/memmove/memcpy functions") for details. > > Other string / mem functions do not (yet) have kasan wrappers, > we therefore have to fallback to the generic versions when > KASAN is active, otherwise KASAN checks will be skipped. > > Signed-off-by: Christophe Leroy > --- > arch/powerpc/include/asm/kasan.h | 15 +++ > arch/powerpc/include/asm/string.h | 32 +--- > arch/powerpc/kernel/prom_init_check.sh | 10 +- > arch/powerpc/lib/Makefile | 11 --- > arch/powerpc/lib/copy_32.S | 15 +-- > arch/powerpc/lib/mem_64.S | 11 +++ > arch/powerpc/lib/memcpy_64.S | 5 +++-- > 7 files changed, 80 insertions(+), 19 deletions(-) > create mode 100644 arch/powerpc/include/asm/kasan.h > > diff --git a/arch/powerpc/include/asm/kasan.h > b/arch/powerpc/include/asm/kasan.h > new file mode 100644 > index ..c3161b8fc017 > --- /dev/null > +++ b/arch/powerpc/include/asm/kasan.h > @@ -0,0 +1,15 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#ifndef __ASM_KASAN_H > +#define __ASM_KASAN_H > + > +#ifdef CONFIG_KASAN > +#define _GLOBAL_KASAN(fn).weak fn ; _GLOBAL(__##fn) ; _GLOBAL(fn) > +#define _GLOBAL_TOC_KASAN(fn).weak fn ; _GLOBAL_TOC(__##fn) ; > _GLOBAL_TOC(fn) > +#define EXPORT_SYMBOL_KASAN(fn) EXPORT_SYMBOL(__##fn) ; > EXPORT_SYMBOL(fn) [FWIW, and this shouldn't block your patch:] This doesn't seem to work with the 64bit elf abi v1, as we have symbols and dot symbols - our _GLOBAL* doesn't just create a symtab entry. I don't fully understand the inner workings just yet, but Aneesh and Balbir have solutions that use .set instead of creating two entries. What I am also struggling with is why we export the __symbol version. I know the x86 version does this, but I can't figure that out either - why would a module need an uninstrumented copy? Anyway, I am getting some issues such as: WARNING: EXPORT symbol "__memcpy" [vmlinux] version generation failed, symbol will not be versioned. WARNING: EXPORT symbol "__memset" [vmlinux] version generation failed, symbol will not be versioned. WARNING: EXPORT symbol "__memmove" [vmlinux] version generation failed, symbol will not be versioned. I think Balbir and Aneesh avoided this by just not ever exporting the __symbol versions, but perhaps that won't fly for the final version. It looks like we can also avoid this by jumping through some extra hoops and creating new weak symbols - I'll keep working on it and let you know how I go. As I said, I don't think this should necessarily block your patches - it's just notes on ppc64 progress. Regards, Daniel > +#else > +#define _GLOBAL_KASAN(fn)_GLOBAL(fn) > +#define _GLOBAL_TOC_KASAN(fn)_GLOBAL_TOC(fn) > +#define EXPORT_SYMBOL_KASAN(fn) EXPORT_SYMBOL(fn) > +#endif > + > +#endif > diff --git a/arch/powerpc/include/asm/string.h > b/arch/powerpc/include/asm/string.h > index 1647de15a31e..9bf6dffb4090 100644 > --- a/arch/powerpc/include/asm/string.h > +++ b/arch/powerpc/include/asm/string.h > @@ -4,14 +4,17 @@ > > #ifdef __KERNEL__ > > +#ifndef CONFIG_KASAN > #define __HAVE_ARCH_STRNCPY > #define __HAVE_ARCH_STRNCMP > +#define __HAVE_ARCH_MEMCHR > +#define __HAVE_ARCH_MEMCMP > +#define __HAVE_ARCH_MEMSET16 > +#endif > + > #define __HAVE_ARCH_MEMSET > #define __HAVE_ARCH_MEMCPY > #define __HAVE_ARCH_MEMMOVE > -#define __HAVE_ARCH_MEMCMP > -#define __HAVE_ARCH_MEMCHR > -#define __HAVE_ARCH_MEMSET16 > #define __HAVE_ARCH_MEMCPY_FLUSHCACHE > > extern char * strcpy(char *,const char *); > @@ -27,7 +30,27 @@ extern int memcmp(const void *,const void > *,__kernel_size_t); > extern void * memchr(const void *,int,__kernel_size_t); > extern void * memcpy_flushcache(void *,const void *,__kernel_size_t); > > +void *__memset(void *s, int c, __kernel_size_t count); > +void *__memcpy(void *to, const void *from, __kernel_size_t n); > +void *__memmove(void *to, const void *from, __kernel_size_t n); > + > +#if defined(CONFIG_KASAN) && !defined(__SANITIZE_ADDRESS__) > +/* > + * For files that are not instrumented (e.g. mm/slub.c) we > + * should use not instrumented version of mem* functions. > + */ > +#define memcpy(dst, src, len) __memcpy(dst, src, len) > +#define memmove(dst, src, len) __memmove(dst, src, len) > +#define memset(s, c, n) __memset(s, c, n) > + > +#ifndef __NO_FORTIFY > +#define __NO_FORTIFY /* FORTIFY_SOURCE uses
Re: [PATCH] powerpc/fsl: Fix the flush of branch predictor.
Reviewed-by: Diana Craciun Thanks for fixing it! On 2/26/2019 8:18 PM, Christophe Leroy wrote: > The commit identified below adds MC_BTB_FLUSH macro only when > CONFIG_PPC_FSL_BOOK3E is defined. This results in the following error > on some configs (seen several times with kisskb randconfig_defconfig) > > arch/powerpc/kernel/exceptions-64e.S:576: Error: Unrecognized opcode: > `mc_btb_flush' > make[3]: *** [scripts/Makefile.build:367: > arch/powerpc/kernel/exceptions-64e.o] Error 1 > make[2]: *** [scripts/Makefile.build:492: arch/powerpc/kernel] Error 2 > make[1]: *** [Makefile:1043: arch/powerpc] Error 2 > make: *** [Makefile:152: sub-make] Error 2 > > This patch adds a blank definition of MC_BTB_FLUSH for other cases. > > Fixes: 10c5e83afd4a ("powerpc/fsl: Flush the branch predictor at each kernel > entry (64bit)") > Cc: Diana Craciun > Signed-off-by: Christophe Leroy > --- > arch/powerpc/kernel/exceptions-64e.S | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/powerpc/kernel/exceptions-64e.S > b/arch/powerpc/kernel/exceptions-64e.S > index 4549ce8d4637..49381f32b374 100644 > --- a/arch/powerpc/kernel/exceptions-64e.S > +++ b/arch/powerpc/kernel/exceptions-64e.S > @@ -338,6 +338,7 @@ ret_from_mc_except: > #define GEN_BTB_FLUSH > #define CRIT_BTB_FLUSH > #define DBG_BTB_FLUSH > +#define MC_BTB_FLUSH > #define GDBELL_BTB_FLUSH > #endif >
Re: build failure of current mmotm with skiroot_defconfig
Le 26/02/2019 à 23:24, Paul Mackerras a écrit : On Tue, Feb 26, 2019 at 11:59:08AM +0200, Mike Rapoport wrote: On Tue, Feb 26, 2019 at 10:39:54AM +0100, Christophe Leroy wrote: Le 26/02/2019 à 09:12, Mike Rapoport a écrit : Hi, I've encountered the following error when building skyroot_defconfig with current mmotm tree: make CONFIG_OF_ALL_DTBS=y CONFIG_DTC=y CROSS_COMPILE=/opt/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux- ARCH=powerpc vmlinux ... CC arch/powerpc/kernel/dbell.o In file included from arch/powerpc/kernel/dbell.c:20: arch/powerpc/include/asm/kvm_ppc.h: In function 'xics_on_xive': arch/powerpc/include/asm/kvm_ppc.h:625:9: error: implicit declaration of function 'xive_enabled'; did you mean 'eeh_enabled'? [-Werror=implicit-function-declaration] return xive_enabled() && cpu_has_feature(CPU_FTR_HVMODE); ^~~~ eeh_enabled I can neither find the above in arch/powerpc/include/asm/kvm_ppc.h in the powerpc tree, nor a patch removing it. Where does that comes from ? It's from current mmotm, probably some merge conflict... It's not a merge conflict; see http://patchwork.ozlabs.org/patch/1048584/ for the fix. Why not include asm/xive.h all the time, as it defines xive_enabled() for when CONFIG_PPC_XIVE is set and for when it is not set ? Christophe
[PATCH V4] ASoC: fsl_esai: fix channel swap issue when stream starts
There is very low possibility ( < 0.1% ) that channel swap happened in beginning when multi output/input pin is enabled. The issue is that hardware can't send data to correct pin in the beginning with the normal enable flow. This is hardware issue, but there is no errata, the workaround flow is that: Each time playback/recording, firstly clear the xSMA/xSMB, then enable TE/RE, then enable xSMB and xSMA (xSMB must be enabled before xSMA). Which is to use the xSMA as the trigger start register, previously the xCR_TE or xCR_RE is the bit for starting. Fixes commit 43d24e76b698 ("ASoC: fsl_esai: Add ESAI CPU DAI driver") Cc: Reviewed-by: Fabio Estevam Acked-by: Nicolin Chen Signed-off-by: Shengjiu Wang --- sound/soc/fsl/fsl_esai.c | 47 +-- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c index afe67c865330..3623aa9a6f2e 100644 --- a/sound/soc/fsl/fsl_esai.c +++ b/sound/soc/fsl/fsl_esai.c @@ -54,6 +54,8 @@ struct fsl_esai { u32 fifo_depth; u32 slot_width; u32 slots; + u32 tx_mask; + u32 rx_mask; u32 hck_rate[2]; u32 sck_rate[2]; bool hck_dir[2]; @@ -361,21 +363,13 @@ static int fsl_esai_set_dai_tdm_slot(struct snd_soc_dai *dai, u32 tx_mask, regmap_update_bits(esai_priv->regmap, REG_ESAI_TCCR, ESAI_xCCR_xDC_MASK, ESAI_xCCR_xDC(slots)); - regmap_update_bits(esai_priv->regmap, REG_ESAI_TSMA, - ESAI_xSMA_xS_MASK, ESAI_xSMA_xS(tx_mask)); - regmap_update_bits(esai_priv->regmap, REG_ESAI_TSMB, - ESAI_xSMB_xS_MASK, ESAI_xSMB_xS(tx_mask)); - regmap_update_bits(esai_priv->regmap, REG_ESAI_RCCR, ESAI_xCCR_xDC_MASK, ESAI_xCCR_xDC(slots)); - regmap_update_bits(esai_priv->regmap, REG_ESAI_RSMA, - ESAI_xSMA_xS_MASK, ESAI_xSMA_xS(rx_mask)); - regmap_update_bits(esai_priv->regmap, REG_ESAI_RSMB, - ESAI_xSMB_xS_MASK, ESAI_xSMB_xS(rx_mask)); - esai_priv->slot_width = slot_width; esai_priv->slots = slots; + esai_priv->tx_mask = tx_mask; + esai_priv->rx_mask = rx_mask; return 0; } @@ -596,6 +590,7 @@ static int fsl_esai_trigger(struct snd_pcm_substream *substream, int cmd, bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; u8 i, channels = substream->runtime->channels; u32 pins = DIV_ROUND_UP(channels, esai_priv->slots); + u32 mask; switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -608,15 +603,38 @@ static int fsl_esai_trigger(struct snd_pcm_substream *substream, int cmd, for (i = 0; tx && i < channels; i++) regmap_write(esai_priv->regmap, REG_ESAI_ETDR, 0x0); + /* +* When set the TE/RE in the end of enablement flow, there +* will be channel swap issue for multi data line case. +* In order to workaround this issue, we switch the bit +* enablement sequence to below sequence +* 1) clear the xSMB & xSMA: which is done in probe and +* stop state. +* 2) set TE/RE +* 3) set xSMB +* 4) set xSMA: xSMA is the last one in this flow, which +* will trigger esai to start. +*/ regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx), tx ? ESAI_xCR_TE_MASK : ESAI_xCR_RE_MASK, tx ? ESAI_xCR_TE(pins) : ESAI_xCR_RE(pins)); + mask = tx ? esai_priv->tx_mask : esai_priv->rx_mask; + + regmap_update_bits(esai_priv->regmap, REG_ESAI_xSMB(tx), + ESAI_xSMB_xS_MASK, ESAI_xSMB_xS(mask)); + regmap_update_bits(esai_priv->regmap, REG_ESAI_xSMA(tx), + ESAI_xSMA_xS_MASK, ESAI_xSMA_xS(mask)); + break; case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx), tx ? ESAI_xCR_TE_MASK : ESAI_xCR_RE_MASK, 0); + regmap_update_bits(esai_priv->regmap, REG_ESAI_xSMA(tx), + ESAI_xSMA_xS_MASK, 0); + regmap_update_bits(esai_priv->regmap, REG_ESAI_xSMB(tx), + ESAI_xSMB_xS_MASK, 0); /* Disable and reset FIFO */ regmap_update_bits(esai_priv->regmap, REG_ESAI_xFCR(tx), @@ -906,6 +924,15 @@ static int fsl_esai_probe(struct platform_device *pdev) return ret; } + esai_priv->tx_mask = 0x; + esai_priv->rx_mask =
RE: [PATCH V3] ASoC: fsl_esai: fix channel swap issue when stream starts
Ok, will send v4. Best regards Wang shengjiu > > Hi Shengjiu, > > Two more trivial comments inline. > > On Tue, Feb 26, 2019 at 03:12:25AM +, S.j. Wang wrote: > > There is very low possibility ( < 0.1% ) that channel swap happened in > > beginning when multi output/input pin is enabled. The issue is that > > hardware can't send data to correct pin in the beginning with the > > normal enable flow. > > > > This is hardware issue, but there is no errata, the workaround flow is > > that: Each time playback/recording, firstly clear the xSMA/xSMB, then > > enable TE/RE, then enable xSMB and xSMA (xSMB must be enabled > before > > xSMA). Which is to use the xSMA as the trigger start register, > > previously the xCR_TE or xCR_RE is the bit for starting. > > > > Fixes commit 43d24e76b698 ("ASoC: fsl_esai: Add ESAI CPU DAI driver") > > Cc: > > Re> @@ -361,21 +363,13 @@ static int fsl_esai_set_dai_tdm_slot(struct > > Re> snd_soc_dai *dai, u32 tx_mask, > > esai_priv->slot_width = slot_width; > > esai_priv->slots = slots; > > + esai_priv->tx_mask= tx_mask; > > + esai_priv->rx_mask= rx_mask; > > Not necessary to have tabs before "="s. > > > @@ -611,12 +606,23 @@ static int fsl_esai_trigger(struct > snd_pcm_substream *substream, int cmd, > > regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx), > >tx ? ESAI_xCR_TE_MASK : > ESAI_xCR_RE_MASK, > >tx ? ESAI_xCR_TE(pins) : > ESAI_xCR_RE(pins)); > > + mask = tx ? esai_priv->tx_mask : esai_priv->rx_mask; > > + > > Please add a line of brief comments for the reason why we are doing this > here, something similar to the commit log, but should have: > 1) Clear xSMA/B 2) Set TE/RE before xSMA/B 3)Set xSMB before xSMA. > > Apparently having this mask settings in the trigger() does not look very > common, so I believe a line of comments would help a lot. > > You may add my Acked-by in your next version: > > Acked-by: Nicolin Chen > > Thanks > > > + regmap_update_bits(esai_priv->regmap, > REG_ESAI_xSMB(tx), > > + ESAI_xSMB_xS_MASK, > ESAI_xSMB_xS(mask)); > > + regmap_update_bits(esai_priv->regmap, > REG_ESAI_xSMA(tx), > > + ESAI_xSMA_xS_MASK, > ESAI_xSMA_xS(mask)); > > + > > break; > > case SNDRV_PCM_TRIGGER_SUSPEND: > > case SNDRV_PCM_TRIGGER_STOP: > > case SNDRV_PCM_TRIGGER_PAUSE_PUSH: > > regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx), > >tx ? ESAI_xCR_TE_MASK : > ESAI_xCR_RE_MASK, 0); > > + regmap_update_bits(esai_priv->regmap, > REG_ESAI_xSMA(tx), > > + ESAI_xSMA_xS_MASK, 0); > > + regmap_update_bits(esai_priv->regmap, > REG_ESAI_xSMB(tx), > > + ESAI_xSMB_xS_MASK, 0); > >
[PATCH 4/5] ocxl: Remove superfluous 'extern' from headers
From: Alastair D'Silva The 'extern' keyword adds no value here. Signed-off-by: Alastair D'Silva --- drivers/misc/ocxl/ocxl_internal.h | 54 +++ include/misc/ocxl.h | 36 ++--- 2 files changed, 44 insertions(+), 46 deletions(-) diff --git a/drivers/misc/ocxl/ocxl_internal.h b/drivers/misc/ocxl/ocxl_internal.h index a32f2151029f..321b29e77f45 100644 --- a/drivers/misc/ocxl/ocxl_internal.h +++ b/drivers/misc/ocxl/ocxl_internal.h @@ -16,7 +16,6 @@ extern struct pci_driver ocxl_pci_driver; - struct ocxl_fn { struct device dev; int bar_used[3]; @@ -92,41 +91,40 @@ struct ocxl_process_element { __be32 software_state; }; +struct ocxl_afu *ocxl_afu_get(struct ocxl_afu *afu); +void ocxl_afu_put(struct ocxl_afu *afu); -extern struct ocxl_afu *ocxl_afu_get(struct ocxl_afu *afu); -extern void ocxl_afu_put(struct ocxl_afu *afu); - -extern int ocxl_create_cdev(struct ocxl_afu *afu); -extern void ocxl_destroy_cdev(struct ocxl_afu *afu); -extern int ocxl_register_afu(struct ocxl_afu *afu); -extern void ocxl_unregister_afu(struct ocxl_afu *afu); +int ocxl_create_cdev(struct ocxl_afu *afu); +void ocxl_destroy_cdev(struct ocxl_afu *afu); +int ocxl_register_afu(struct ocxl_afu *afu); +void ocxl_unregister_afu(struct ocxl_afu *afu); -extern int ocxl_file_init(void); -extern void ocxl_file_exit(void); +int ocxl_file_init(void); +void ocxl_file_exit(void); -extern int ocxl_pasid_afu_alloc(struct ocxl_fn *fn, u32 size); -extern void ocxl_pasid_afu_free(struct ocxl_fn *fn, u32 start, u32 size); -extern int ocxl_actag_afu_alloc(struct ocxl_fn *fn, u32 size); -extern void ocxl_actag_afu_free(struct ocxl_fn *fn, u32 start, u32 size); +int ocxl_pasid_afu_alloc(struct ocxl_fn *fn, u32 size); +void ocxl_pasid_afu_free(struct ocxl_fn *fn, u32 start, u32 size); +int ocxl_actag_afu_alloc(struct ocxl_fn *fn, u32 size); +void ocxl_actag_afu_free(struct ocxl_fn *fn, u32 start, u32 size); -extern struct ocxl_context *ocxl_context_alloc(void); -extern int ocxl_context_init(struct ocxl_context *ctx, struct ocxl_afu *afu, +struct ocxl_context *ocxl_context_alloc(void); +int ocxl_context_init(struct ocxl_context *ctx, struct ocxl_afu *afu, struct address_space *mapping); -extern int ocxl_context_attach(struct ocxl_context *ctx, u64 amr); -extern int ocxl_context_mmap(struct ocxl_context *ctx, +int ocxl_context_attach(struct ocxl_context *ctx, u64 amr); +int ocxl_context_mmap(struct ocxl_context *ctx, struct vm_area_struct *vma); -extern int ocxl_context_detach(struct ocxl_context *ctx); -extern void ocxl_context_detach_all(struct ocxl_afu *afu); -extern void ocxl_context_free(struct ocxl_context *ctx); +int ocxl_context_detach(struct ocxl_context *ctx); +void ocxl_context_detach_all(struct ocxl_afu *afu); +void ocxl_context_free(struct ocxl_context *ctx); -extern int ocxl_sysfs_add_afu(struct ocxl_afu *afu); -extern void ocxl_sysfs_remove_afu(struct ocxl_afu *afu); +int ocxl_sysfs_add_afu(struct ocxl_afu *afu); +void ocxl_sysfs_remove_afu(struct ocxl_afu *afu); -extern int ocxl_afu_irq_alloc(struct ocxl_context *ctx, u64 *irq_offset); -extern int ocxl_afu_irq_free(struct ocxl_context *ctx, u64 irq_offset); -extern void ocxl_afu_irq_free_all(struct ocxl_context *ctx); -extern int ocxl_afu_irq_set_fd(struct ocxl_context *ctx, u64 irq_offset, +int ocxl_afu_irq_alloc(struct ocxl_context *ctx, u64 *irq_offset); +int ocxl_afu_irq_free(struct ocxl_context *ctx, u64 irq_offset); +void ocxl_afu_irq_free_all(struct ocxl_context *ctx); +int ocxl_afu_irq_set_fd(struct ocxl_context *ctx, u64 irq_offset, int eventfd); -extern u64 ocxl_afu_irq_get_addr(struct ocxl_context *ctx, u64 irq_offset); +u64 ocxl_afu_irq_get_addr(struct ocxl_context *ctx, u64 irq_offset); #endif /* _OCXL_INTERNAL_H_ */ diff --git a/include/misc/ocxl.h b/include/misc/ocxl.h index 9ff6ddc28e22..4544573cc93c 100644 --- a/include/misc/ocxl.h +++ b/include/misc/ocxl.h @@ -53,7 +53,7 @@ struct ocxl_fn_config { * Read the configuration space of a function and fill in a * ocxl_fn_config structure with all the function details */ -extern int ocxl_config_read_function(struct pci_dev *dev, +int ocxl_config_read_function(struct pci_dev *dev, struct ocxl_fn_config *fn); /* @@ -62,14 +62,14 @@ extern int ocxl_config_read_function(struct pci_dev *dev, * AFU indexes can be sparse, so a driver should check all indexes up * to the maximum found in the function description */ -extern int ocxl_config_check_afu_index(struct pci_dev *dev, +int ocxl_config_check_afu_index(struct pci_dev *dev, struct ocxl_fn_config *fn, int afu_idx); /* * Read the configuration space of a function for the AFU specified by * the index 'afu_idx'. Fills in a ocxl_afu_config structure */ -extern int ocxl_config_read_afu(struct pci_dev *dev, +int
[PATCH 0/5] ocxl: OpenCAPI Cleanup
From: Alastair D'Silva Some minor cleanups for the OpenCAPI driver as a prerequisite for an ocxl driver refactoring to allow the driver core to be utilised by external drivers. Alastair D'Silva (5): ocxl: Rename struct link to ocxl_link ocxl: Clean up printf formats ocxl: read_pasid never returns an error, so make it void ocxl: Remove superfluous 'extern' from headers ocxl: Remove some unused exported symbols drivers/misc/ocxl/config.c| 17 ++ drivers/misc/ocxl/context.c | 2 +- drivers/misc/ocxl/file.c | 2 +- drivers/misc/ocxl/link.c | 36 ++--- drivers/misc/ocxl/ocxl_internal.h | 86 +++ drivers/misc/ocxl/trace.h | 10 ++-- include/misc/ocxl.h | 53 ++- 7 files changed, 99 insertions(+), 107 deletions(-) -- 2.20.1
[PATCH 1/5] ocxl: Rename struct link to ocxl_link
From: Alastair D'Silva The term 'link' is ambiguous (especially when the struct is used for a list), so rename it for clarity. Signed-off-by: Alastair D'Silva Reviewed-by: Greg Kurz --- drivers/misc/ocxl/file.c | 2 +- drivers/misc/ocxl/link.c | 36 ++-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c index e6a607488f8a..16eb8a60d5c7 100644 --- a/drivers/misc/ocxl/file.c +++ b/drivers/misc/ocxl/file.c @@ -152,7 +152,7 @@ static long afu_ioctl_enable_p9_wait(struct ocxl_context *ctx, if (status == ATTACHED) { int rc; - struct link *link = ctx->afu->fn->link; + void *link = ctx->afu->fn->link; rc = ocxl_link_update_pe(link, ctx->pasid, ctx->tidr); if (rc) diff --git a/drivers/misc/ocxl/link.c b/drivers/misc/ocxl/link.c index d50b861d7e57..8d2690a1a9de 100644 --- a/drivers/misc/ocxl/link.c +++ b/drivers/misc/ocxl/link.c @@ -76,7 +76,7 @@ struct spa { * limited number of opencapi slots on a system and lookup is only * done when the device is probed */ -struct link { +struct ocxl_link { struct list_head list; struct kref ref; int domain; @@ -179,7 +179,7 @@ static void xsl_fault_handler_bh(struct work_struct *fault_work) static irqreturn_t xsl_fault_handler(int irq, void *data) { - struct link *link = (struct link *) data; + struct ocxl_link *link = (struct ocxl_link *) data; struct spa *spa = link->spa; u64 dsisr, dar, pe_handle; struct pe_data *pe_data; @@ -256,7 +256,7 @@ static int map_irq_registers(struct pci_dev *dev, struct spa *spa) >reg_tfc, >reg_pe_handle); } -static int setup_xsl_irq(struct pci_dev *dev, struct link *link) +static int setup_xsl_irq(struct pci_dev *dev, struct ocxl_link *link) { struct spa *spa = link->spa; int rc; @@ -311,7 +311,7 @@ static int setup_xsl_irq(struct pci_dev *dev, struct link *link) return rc; } -static void release_xsl_irq(struct link *link) +static void release_xsl_irq(struct ocxl_link *link) { struct spa *spa = link->spa; @@ -323,7 +323,7 @@ static void release_xsl_irq(struct link *link) unmap_irq_registers(spa); } -static int alloc_spa(struct pci_dev *dev, struct link *link) +static int alloc_spa(struct pci_dev *dev, struct ocxl_link *link) { struct spa *spa; @@ -350,7 +350,7 @@ static int alloc_spa(struct pci_dev *dev, struct link *link) return 0; } -static void free_spa(struct link *link) +static void free_spa(struct ocxl_link *link) { struct spa *spa = link->spa; @@ -364,12 +364,12 @@ static void free_spa(struct link *link) } } -static int alloc_link(struct pci_dev *dev, int PE_mask, struct link **out_link) +static int alloc_link(struct pci_dev *dev, int PE_mask, struct ocxl_link **out_link) { - struct link *link; + struct ocxl_link *link; int rc; - link = kzalloc(sizeof(struct link), GFP_KERNEL); + link = kzalloc(sizeof(struct ocxl_link), GFP_KERNEL); if (!link) return -ENOMEM; @@ -405,7 +405,7 @@ static int alloc_link(struct pci_dev *dev, int PE_mask, struct link **out_link) return rc; } -static void free_link(struct link *link) +static void free_link(struct ocxl_link *link) { release_xsl_irq(link); free_spa(link); @@ -415,7 +415,7 @@ static void free_link(struct link *link) int ocxl_link_setup(struct pci_dev *dev, int PE_mask, void **link_handle) { int rc = 0; - struct link *link; + struct ocxl_link *link; mutex_lock(_list_lock); list_for_each_entry(link, _list, list) { @@ -442,7 +442,7 @@ EXPORT_SYMBOL_GPL(ocxl_link_setup); static void release_xsl(struct kref *ref) { - struct link *link = container_of(ref, struct link, ref); + struct ocxl_link *link = container_of(ref, struct ocxl_link, ref); list_del(>list); /* call platform code before releasing data */ @@ -452,7 +452,7 @@ static void release_xsl(struct kref *ref) void ocxl_link_release(struct pci_dev *dev, void *link_handle) { - struct link *link = (struct link *) link_handle; + struct ocxl_link *link = (struct ocxl_link *) link_handle; mutex_lock(_list_lock); kref_put(>ref, release_xsl); @@ -488,7 +488,7 @@ int ocxl_link_add_pe(void *link_handle, int pasid, u32 pidr, u32 tidr, void (*xsl_err_cb)(void *data, u64 addr, u64 dsisr), void *xsl_err_data) { - struct link *link = (struct link *) link_handle; + struct ocxl_link *link = (struct ocxl_link *) link_handle; struct spa *spa = link->spa; struct ocxl_process_element *pe; int pe_handle, rc = 0; @@ -558,7 +558,7 @@ EXPORT_SYMBOL_GPL(ocxl_link_add_pe);
[PATCH 3/5] ocxl: read_pasid never returns an error, so make it void
From: Alastair D'Silva No need for a return value in read_pasid as it only returns 0. Signed-off-by: Alastair D'Silva Reviewed-by: Greg Kurz --- drivers/misc/ocxl/config.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/misc/ocxl/config.c b/drivers/misc/ocxl/config.c index 0ee7856b033d..026ac2ac4f9c 100644 --- a/drivers/misc/ocxl/config.c +++ b/drivers/misc/ocxl/config.c @@ -68,7 +68,7 @@ static int find_dvsec_afu_ctrl(struct pci_dev *dev, u8 afu_idx) return 0; } -static int read_pasid(struct pci_dev *dev, struct ocxl_fn_config *fn) +static void read_pasid(struct pci_dev *dev, struct ocxl_fn_config *fn) { u16 val; int pos; @@ -89,7 +89,6 @@ static int read_pasid(struct pci_dev *dev, struct ocxl_fn_config *fn) out: dev_dbg(>dev, "PASID capability:\n"); dev_dbg(>dev, " Max PASID log = %d\n", fn->max_pasid_log); - return 0; } static int read_dvsec_tl(struct pci_dev *dev, struct ocxl_fn_config *fn) @@ -205,11 +204,7 @@ int ocxl_config_read_function(struct pci_dev *dev, struct ocxl_fn_config *fn) { int rc; - rc = read_pasid(dev, fn); - if (rc) { - dev_err(>dev, "Invalid PASID configuration: %d\n", rc); - return -ENODEV; - } + read_pasid(dev, fn); rc = read_dvsec_tl(dev, fn); if (rc) { -- 2.20.1
[PATCH 2/5] ocxl: Clean up printf formats
From: Alastair D'Silva Use %# instead of using a literal '0x' Signed-off-by: Alastair D'Silva --- drivers/misc/ocxl/config.c | 6 +++--- drivers/misc/ocxl/context.c | 2 +- drivers/misc/ocxl/trace.h | 10 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/misc/ocxl/config.c b/drivers/misc/ocxl/config.c index 8f2c5d8bd2ee..0ee7856b033d 100644 --- a/drivers/misc/ocxl/config.c +++ b/drivers/misc/ocxl/config.c @@ -178,9 +178,9 @@ static int read_dvsec_vendor(struct pci_dev *dev) pci_read_config_dword(dev, pos + OCXL_DVSEC_VENDOR_DLX_VERS, ); dev_dbg(>dev, "Vendor specific DVSEC:\n"); - dev_dbg(>dev, " CFG version = 0x%x\n", cfg); - dev_dbg(>dev, " TLX version = 0x%x\n", tlx); - dev_dbg(>dev, " DLX version = 0x%x\n", dlx); + dev_dbg(>dev, " CFG version = %#x\n", cfg); + dev_dbg(>dev, " TLX version = %#x\n", tlx); + dev_dbg(>dev, " DLX version = %#x\n", dlx); return 0; } diff --git a/drivers/misc/ocxl/context.c b/drivers/misc/ocxl/context.c index c10a940e3b38..3498a0199bde 100644 --- a/drivers/misc/ocxl/context.c +++ b/drivers/misc/ocxl/context.c @@ -134,7 +134,7 @@ static vm_fault_t ocxl_mmap_fault(struct vm_fault *vmf) vm_fault_t ret; offset = vmf->pgoff << PAGE_SHIFT; - pr_debug("%s: pasid %d address 0x%lx offset 0x%llx\n", __func__, + pr_debug("%s: pasid %d address %#lx offset %#llx\n", __func__, ctx->pasid, vmf->address, offset); if (offset < ctx->afu->irq_base_offset) diff --git a/drivers/misc/ocxl/trace.h b/drivers/misc/ocxl/trace.h index bcb7ff330c1e..8d2f53812edd 100644 --- a/drivers/misc/ocxl/trace.h +++ b/drivers/misc/ocxl/trace.h @@ -28,7 +28,7 @@ DECLARE_EVENT_CLASS(ocxl_context, __entry->tidr = tidr; ), - TP_printk("linux pid=%d spa=0x%p pasid=0x%x pidr=0x%x tidr=0x%x", + TP_printk("linux pid=%d spa=%p pasid=%#x pidr=%#x tidr=%#x", __entry->pid, __entry->spa, __entry->pasid, @@ -61,7 +61,7 @@ TRACE_EVENT(ocxl_terminate_pasid, __entry->rc = rc; ), - TP_printk("pasid=0x%x rc=%d", + TP_printk("pasid=%#x rc=%d", __entry->pasid, __entry->rc ) @@ -87,7 +87,7 @@ DECLARE_EVENT_CLASS(ocxl_fault_handler, __entry->tfc = tfc; ), - TP_printk("spa=%p pe=0x%llx dsisr=0x%llx dar=0x%llx tfc=0x%llx", + TP_printk("spa=%p pe=%#llx dsisr=%#llx dar=%#llx tfc=%#llx", __entry->spa, __entry->pe, __entry->dsisr, @@ -127,7 +127,7 @@ TRACE_EVENT(ocxl_afu_irq_alloc, __entry->irq_offset = irq_offset; ), - TP_printk("pasid=0x%x irq_id=%d virq=%u hw_irq=%d irq_offset=0x%llx", + TP_printk("pasid=%#x irq_id=%d virq=%u hw_irq=%d irq_offset=0x%llx", __entry->pasid, __entry->irq_id, __entry->virq, @@ -150,7 +150,7 @@ TRACE_EVENT(ocxl_afu_irq_free, __entry->irq_id = irq_id; ), - TP_printk("pasid=0x%x irq_id=%d", + TP_printk("pasid=%#x irq_id=%d", __entry->pasid, __entry->irq_id ) -- 2.20.1
[PATCH 5/5] ocxl: Remove some unused exported symbols
From: Alastair D'Silva Remove some unused exported symbols. Signed-off-by: Alastair D'Silva --- drivers/misc/ocxl/config.c| 2 -- drivers/misc/ocxl/ocxl_internal.h | 26 +- include/misc/ocxl.h | 23 --- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/drivers/misc/ocxl/config.c b/drivers/misc/ocxl/config.c index 026ac2ac4f9c..c90c2e4875bf 100644 --- a/drivers/misc/ocxl/config.c +++ b/drivers/misc/ocxl/config.c @@ -299,7 +299,6 @@ int ocxl_config_check_afu_index(struct pci_dev *dev, } return 1; } -EXPORT_SYMBOL_GPL(ocxl_config_check_afu_index); static int read_afu_name(struct pci_dev *dev, struct ocxl_fn_config *fn, struct ocxl_afu_config *afu) @@ -535,7 +534,6 @@ int ocxl_config_get_pasid_info(struct pci_dev *dev, int *count) { return pnv_ocxl_get_pasid_count(dev, count); } -EXPORT_SYMBOL_GPL(ocxl_config_get_pasid_info); void ocxl_config_set_afu_pasid(struct pci_dev *dev, int pos, int pasid_base, u32 pasid_count_log) diff --git a/drivers/misc/ocxl/ocxl_internal.h b/drivers/misc/ocxl/ocxl_internal.h index 321b29e77f45..cd5a1e3cc950 100644 --- a/drivers/misc/ocxl/ocxl_internal.h +++ b/drivers/misc/ocxl/ocxl_internal.h @@ -107,10 +107,34 @@ void ocxl_pasid_afu_free(struct ocxl_fn *fn, u32 start, u32 size); int ocxl_actag_afu_alloc(struct ocxl_fn *fn, u32 size); void ocxl_actag_afu_free(struct ocxl_fn *fn, u32 start, u32 size); +/* + * Get the max PASID value that can be used by the function + */ +int ocxl_config_get_pasid_info(struct pci_dev *dev, int *count); + +int ocxl_context_attach(struct ocxl_context *ctx, u64 amr); + +/* + * Check if an AFU index is valid for the given function. + * + * AFU indexes can be sparse, so a driver should check all indexes up + * to the maximum found in the function description + */ +int ocxl_config_check_afu_index(struct pci_dev *dev, + struct ocxl_fn_config *fn, int afu_idx); + +/** + * Update values within a Process Element + * + * link_handle: the link handle associated with the process element + * pasid: the PASID for the AFU context + * tid: the new thread id for the process element + */ +int ocxl_link_update_pe(void *link_handle, int pasid, __u16 tid); + struct ocxl_context *ocxl_context_alloc(void); int ocxl_context_init(struct ocxl_context *ctx, struct ocxl_afu *afu, struct address_space *mapping); -int ocxl_context_attach(struct ocxl_context *ctx, u64 amr); int ocxl_context_mmap(struct ocxl_context *ctx, struct vm_area_struct *vma); int ocxl_context_detach(struct ocxl_context *ctx); diff --git a/include/misc/ocxl.h b/include/misc/ocxl.h index 4544573cc93c..9530d3be1b30 100644 --- a/include/misc/ocxl.h +++ b/include/misc/ocxl.h @@ -56,15 +56,6 @@ struct ocxl_fn_config { int ocxl_config_read_function(struct pci_dev *dev, struct ocxl_fn_config *fn); -/* - * Check if an AFU index is valid for the given function. - * - * AFU indexes can be sparse, so a driver should check all indexes up - * to the maximum found in the function description - */ -int ocxl_config_check_afu_index(struct pci_dev *dev, - struct ocxl_fn_config *fn, int afu_idx); - /* * Read the configuration space of a function for the AFU specified by * the index 'afu_idx'. Fills in a ocxl_afu_config structure @@ -74,11 +65,6 @@ int ocxl_config_read_afu(struct pci_dev *dev, struct ocxl_afu_config *afu, u8 afu_idx); -/* - * Get the max PASID value that can be used by the function - */ -int ocxl_config_get_pasid_info(struct pci_dev *dev, int *count); - /* * Tell an AFU, by writing in the configuration space, the PASIDs that * it can use. Range starts at 'pasid_base' and its size is a multiple @@ -188,15 +174,6 @@ int ocxl_link_add_pe(void *link_handle, int pasid, u32 pidr, u32 tidr, void (*xsl_err_cb)(void *data, u64 addr, u64 dsisr), void *xsl_err_data); -/** - * Update values within a Process Element - * - * link_handle: the link handle associated with the process element - * pasid: the PASID for the AFU context - * tid: the new thread id for the process element - */ -int ocxl_link_update_pe(void *link_handle, int pasid, __u16 tid); - /* * Remove a Process Element from the Shared Process Area for a link */ -- 2.20.1
[PATCH 6/8] PCI: iproc: fix a leaked reference by adding missing of_node_put
The call to of_parse_phandle returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage. iproc_msi_init also calls of_node_get to increase refcount (proc_msi_init -> iproc_msi_alloc_domains -> pci_msi_create_irq_domain -> msi_create_irq_domain -> irq_domain_create_linear -> __irq_domain_add), so irq_domain will not be affected when it is released. Detected by coccinelle with the following warnings: ./drivers/pci/controller/pcie-iproc.c:1323:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1299, but without a corresponding object release within this function. ./drivers/pci/controller/pcie-iproc.c:1330:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1299, but without a corresponding object release within this function. Signed-off-by: Wen Yang Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Cc: Ray Jui Cc: Scott Branden Cc: bcm-kernel-feedback-l...@broadcom.com Cc: linux-...@vger.kernel.org Cc: linux-arm-ker...@lists.infradead.org Cc: linux-ker...@vger.kernel.org --- drivers/pci/controller/pcie-iproc.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/pcie-iproc.c b/drivers/pci/controller/pcie-iproc.c index c20fd6b..9998c5c 100644 --- a/drivers/pci/controller/pcie-iproc.c +++ b/drivers/pci/controller/pcie-iproc.c @@ -1320,14 +1320,18 @@ static int iproc_pcie_msi_enable(struct iproc_pcie *pcie) if (pcie->need_msi_steer) { ret = iproc_pcie_msi_steer(pcie, msi_node); if (ret) - return ret; + goto out_put_node; } /* * If another MSI controller is being used, the call below should fail * but that is okay */ - return iproc_msi_init(pcie, msi_node); + ret = iproc_msi_init(pcie, msi_node); + +out_put_node: + of_node_put(msi_node); + return ret; } static void iproc_pcie_msi_disable(struct iproc_pcie *pcie) -- 2.9.5
[PATCH 7/8] PCI: mediatek: fix a leaked reference by adding missing of_node_put
The call to of_get_next_child returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage. irq_domain_add_linear also calls of_node_get to increase refcount, so irq_domain will not be affected when it is released. Detected by coccinelle with the following warnings: ./drivers/pci/controller/pcie-mediatek.c:577:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 567, but without a corresponding object release within this function. ./drivers/pci/controller/pcie-mediatek.c:583:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 567, but without a corresponding object release within this function. ./drivers/pci/controller/pcie-mediatek.c:586:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 567, but without a corresponding object release within this function. Signed-off-by: Wen Yang Cc: Ryder Lee Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Cc: Matthias Brugger Cc: linux-...@vger.kernel.org Cc: linux-media...@lists.infradead.org Cc: linux-ker...@vger.kernel.org Cc: linux-arm-ker...@lists.infradead.org --- drivers/pci/controller/pcie-mediatek.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c index 55e471c..e91716a 100644 --- a/drivers/pci/controller/pcie-mediatek.c +++ b/drivers/pci/controller/pcie-mediatek.c @@ -572,6 +572,7 @@ static int mtk_pcie_init_irq_domain(struct mtk_pcie_port *port, port->irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, _domain_ops, port); + of_node_put(pcie_intc_node); if (!port->irq_domain) { dev_err(dev, "failed to get INTx IRQ domain\n"); return -ENODEV; -- 2.9.5
[PATCH 8/8] PCI: rpadlpar: fix a leaked reference by adding missing of_node_put
The call to of_find_node_by_name returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage. Detected by coccinelle with the following warnings: ./drivers/pci/hotplug/rpadlpar_core.c:55:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 42, but without a corresponding object release within this function Signed-off-by: Wen Yang Cc: Tyrel Datwyler Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman Cc: Bjorn Helgaas Cc: linux-...@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-ker...@vger.kernel.org --- drivers/pci/hotplug/rpadlpar_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c index e2356a9..f3f42ff 100644 --- a/drivers/pci/hotplug/rpadlpar_core.c +++ b/drivers/pci/hotplug/rpadlpar_core.c @@ -52,6 +52,7 @@ static struct device_node *find_vio_slot_node(char *drc_name) break; } + of_node_put(parent); return dn; } -- 2.9.5
[PATCH 2/8] PCI: uniphier: fix a leaked reference by adding missing of_node_put
The call to of_get_child_by_name returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage. irq_domain_add_linear also calls of_node_get to increase refcount, so irq_domain will not be affected when it is released. Detected by coccinelle with the following warnings: ./drivers/pci/controller/dwc/pcie-uniphier.c:283:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 274, but without a corresponding object release within this function. ./drivers/pci/controller/dwc/pcie-uniphier.c:290:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 274, but without a corresponding object release within this function. ./drivers/pci/controller/dwc/pcie-uniphier.c:296:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 274, but without a corresponding object release within this function. Signed-off-by: Wen Yang Cc: Kunihiko Hayashi Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Cc: Masahiro Yamada Cc: linux-...@vger.kernel.org Cc: linux-arm-ker...@lists.infradead.org Cc: linux-ker...@vger.kernel.org --- drivers/pci/controller/dwc/pcie-uniphier.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-uniphier.c b/drivers/pci/controller/dwc/pcie-uniphier.c index d5dc402..3f30ee4 100644 --- a/drivers/pci/controller/dwc/pcie-uniphier.c +++ b/drivers/pci/controller/dwc/pcie-uniphier.c @@ -270,6 +270,7 @@ static int uniphier_pcie_config_legacy_irq(struct pcie_port *pp) struct uniphier_pcie_priv *priv = to_uniphier_pcie(pci); struct device_node *np = pci->dev->of_node; struct device_node *np_intc; + int ret = 0; np_intc = of_get_child_by_name(np, "legacy-interrupt-controller"); if (!np_intc) { @@ -280,20 +281,24 @@ static int uniphier_pcie_config_legacy_irq(struct pcie_port *pp) pp->irq = irq_of_parse_and_map(np_intc, 0); if (!pp->irq) { dev_err(pci->dev, "Failed to get an IRQ entry in legacy-interrupt-controller\n"); - return -EINVAL; + ret = -EINVAL; + goto out_put_node; } priv->legacy_irq_domain = irq_domain_add_linear(np_intc, PCI_NUM_INTX, _intx_domain_ops, pp); if (!priv->legacy_irq_domain) { dev_err(pci->dev, "Failed to get INTx domain\n"); - return -ENODEV; + ret = -ENODEV; + goto out_put_node; } irq_set_chained_handler_and_data(pp->irq, uniphier_pcie_irq_handler, pp); - return 0; +out_put_node: + of_node_put(np_intc); + return ret; } static int uniphier_pcie_host_init(struct pcie_port *pp) -- 2.9.5
[PATCH 4/8] PCI: rockchip: fix a leaked reference by adding missing of_node_put
The call to of_get_child_by_name returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage. irq_domain_add_linear also calls of_node_get to increase refcount, so irq_domain will not be affected when it is released. Detected by coccinelle with the following warnings: ./drivers/pci/controller/pcie-rockchip-host.c:729:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 718, but without a corresponding object release within this function. ./drivers/pci/controller/pcie-rockchip-host.c:732:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 718, but without a corresponding object release within this function. Signed-off-by: Wen Yang Cc: Shawn Lin Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Cc: Heiko Stuebner Cc: linux-...@vger.kernel.org Cc: linux-rockc...@lists.infradead.org Cc: linux-arm-ker...@lists.infradead.org Cc: linux-ker...@vger.kernel.org --- drivers/pci/controller/pcie-rockchip-host.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pci/controller/pcie-rockchip-host.c b/drivers/pci/controller/pcie-rockchip-host.c index 1372d27..8d20f17 100644 --- a/drivers/pci/controller/pcie-rockchip-host.c +++ b/drivers/pci/controller/pcie-rockchip-host.c @@ -724,6 +724,7 @@ static int rockchip_pcie_init_irq_domain(struct rockchip_pcie *rockchip) rockchip->irq_domain = irq_domain_add_linear(intc, PCI_NUM_INTX, _domain_ops, rockchip); + of_node_put(intc); if (!rockchip->irq_domain) { dev_err(dev, "failed to get a INTx IRQ domain\n"); return -EINVAL; -- 2.9.5
[PATCH 5/8] PCI: aardvark: fix a leaked reference by adding missing of_node_put
The call to of_get_next_child returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage. irq_domain_add_linear also calls of_node_get to increase refcount, so irq_domain will not be affected when it is released. Detected by coccinelle with the following warnings: ./drivers/pci/controller/pci-aardvark.c:826:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 798, but without a corresponding object release within this function. Signed-off-by: Wen Yang Cc: Thomas Petazzoni Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Cc: linux-...@vger.kernel.org Cc: linux-arm-ker...@lists.infradead.org Cc: linux-ker...@vger.kernel.org --- drivers/pci/controller/pci-aardvark.c | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 750081c..56ecb16 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -794,6 +794,7 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie) struct device_node *node = dev->of_node; struct device_node *pcie_intc_node; struct irq_chip *irq_chip; + int ret = 0; pcie_intc_node = of_get_next_child(node, NULL); if (!pcie_intc_node) { @@ -806,8 +807,8 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie) irq_chip->name = devm_kasprintf(dev, GFP_KERNEL, "%s-irq", dev_name(dev)); if (!irq_chip->name) { - of_node_put(pcie_intc_node); - return -ENOMEM; + ret = -ENOMEM; + goto out_put_node; } irq_chip->irq_mask = advk_pcie_irq_mask; @@ -819,11 +820,13 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie) _pcie_irq_domain_ops, pcie); if (!pcie->irq_domain) { dev_err(dev, "Failed to get a INTx IRQ domain\n"); - of_node_put(pcie_intc_node); - return -ENOMEM; + ret = -ENOMEM; + goto out_put_node; } - return 0; +out_put_node: + of_node_put(pcie_intc_node); + return ret; } static void advk_pcie_remove_irq_domain(struct advk_pcie *pcie) -- 2.9.5
[PATCH 3/8] PCI: dwc: layerscape: fix a leaked reference by adding missing of_node_put
The call to of_parse_phandle returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage. Detected by coccinelle with the following warnings: ./drivers/pci/controller/dwc/pci-layerscape.c:204:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 198, but without a corresponding object release within this function. Signed-off-by: Wen Yang Cc: Minghuan Lian Cc: Mingkai Hu Cc: Roy Zang Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-...@vger.kernel.org Cc: linux-arm-ker...@lists.infradead.org Cc: linux-ker...@vger.kernel.org --- drivers/pci/controller/dwc/pci-layerscape.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pci/controller/dwc/pci-layerscape.c b/drivers/pci/controller/dwc/pci-layerscape.c index ce45bde2..3a5fa26 100644 --- a/drivers/pci/controller/dwc/pci-layerscape.c +++ b/drivers/pci/controller/dwc/pci-layerscape.c @@ -201,6 +201,7 @@ static int ls_pcie_msi_host_init(struct pcie_port *pp) return -EINVAL; } + of_node_put(msi_node); return 0; } -- 2.9.5
[PATCH 1/8] PCI: dwc: pci-dra7xx: fix a leaked reference by adding missing of_node_put
The call to of_get_next_child returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage. irq_domain_add_linear also calls of_node_get to increase refcount, so irq_domain will not be affected when it is released. Detected by coccinelle with the following warnings: ./drivers/pci/controller/dwc/pci-dra7xx.c:252:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 241, but without a corresponding object release within this function. ./drivers/pci/controller/dwc/pci-dra7xx.c:255:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 241, but without a corresponding object release within this function. Signed-off-by: Wen Yang Cc: Kishon Vijay Abraham I Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Cc: linux-o...@vger.kernel.org Cc: linux-...@vger.kernel.org Cc: linux-ker...@vger.kernel.org --- drivers/pci/controller/dwc/pci-dra7xx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c index ae84a69..627c91d 100644 --- a/drivers/pci/controller/dwc/pci-dra7xx.c +++ b/drivers/pci/controller/dwc/pci-dra7xx.c @@ -247,6 +247,7 @@ static int dra7xx_pcie_init_irq_domain(struct pcie_port *pp) dra7xx->irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, _domain_ops, pp); + of_node_put(pcie_intc_node); if (!dra7xx->irq_domain) { dev_err(dev, "Failed to get a INTx IRQ domain\n"); return -ENODEV; -- 2.9.5
Re: [PATCH 00/18] Add FADump support on PowerNV platform
Hari Bathini's on February 22, 2019 3:35 am: > Firmware-Assisted Dump (FADump) is currently supported only on pseries > platform. This patch series adds support for powernv platform too. > > The first and third patches refactor the FADump code to make use of common > code across multiple platforms. The fifth patch adds basic FADump support > for powernv platform. Patches seven & eight honour reserved-ranges DT node > while reserving/releasing memory used by FADump. The next patch processes > CPU state data provided by firmware to create and append core notes to the > ELF core file. The tenth patch adds support for preserving crash data for > subsequent boots (useful in cases like petitboot). Patch twelve provides > support to export opalcore. This is to make debugging of failures in OPAL > code easier. The subsequent patch ensures vmcore processing is skipped > when only OPAL core is exported by f/w. The next patch provides option to > release the kernel memory used to export opalcore. Patch seventeen adds > backup area (an area populated before crash and used in the capture kernel > to setup vmcore file robustly) support on PowerNV platform. The remaining > patches update Firmware-Assisted Dump documentation appropriately. > > Note that the quantam of increase in robustness due to patch seventeen may > not be worth breaking backward compatibility for older kernel versions. > Would like to hear thoughts from others on it. > > The patch series is tested with the latest firmware plus the below skiboot > changes for MPIPL support: > > https://patchwork.ozlabs.org/project/skiboot/list/?series=78497 > ("MPIPL support") > > --- > > Hari Bathini (18): > powerpc/fadump: move internal fadump code to a new file > powerpc/fadump: Improve fadump documentation > pseries/fadump: move out platform specific support from generic code > powerpc/fadump: use FADump instead of fadump for how it is pronounced > powerpc/fadump: enable fadump support on OPAL based POWER platform > powerpc/fadump: Update documentation about OPAL platform support > powerpc/fadump: consider reserved ranges while reserving memory > powerpc/fadump: consider reserved ranges while releasing memory > powernv/fadump: process architected register state data provided by > firmware > powernv/fadump: add support to preserve crash data on FADUMP disabled > kernel > powerpc/fadump: update documentation about CONFIG_PRESERVE_FA_DUMP > powerpc/powernv: export /proc/opalcore for analysing opal crashes > powernv/fadump: Skip processing /proc/vmcore when only OPAL core exists > powernv/opalcore: provide an option to invalidate /proc/opalcore file > powernv/fadump: consider f/w load area > powernv/fadump: update documentation about option to release opalcore > powernv/fadump: use backup area to map PIR to logical CPUs The need to map firmware identifiers like PIR to Linux numbering comes up in a few places, OPAL msglog, pdbg debugger, etc. I wonder if we could have Linux register its logical CPU numbers with OPAL after it boots. Would that help with your usage? > powerpc/fadump: Update documentation about backup area support > > > Documentation/powerpc/firmware-assisted-dump.txt | 208 ++-- > arch/powerpc/Kconfig | 23 > arch/powerpc/include/asm/fadump.h| 190 --- > arch/powerpc/include/asm/opal-api.h | 58 + > arch/powerpc/include/asm/opal.h |1 > arch/powerpc/kernel/Makefile |6 > arch/powerpc/kernel/fadump.c | 1199 > -- > arch/powerpc/kernel/fadump_internal.c| 297 + > arch/powerpc/kernel/fadump_internal.h| 250 + I don't have much knowledge of fadump code, so I'll nitpick instead :P Why are you calling it fadump_internal, what's internal about it? You have the framework for the ops table etc here, which makes the platform code have to #include "../kernel/fadump_internal.h", and suggests it's not so internal. Seems like it would be fine just to go in include/asm/fadump.h and kernel fadump.c? > arch/powerpc/kernel/prom.c |4 > arch/powerpc/platforms/powernv/Makefile |3 > arch/powerpc/platforms/powernv/opal-core.c | 602 +++ > arch/powerpc/platforms/powernv/opal-fadump.c | 670 > arch/powerpc/platforms/powernv/opal-fadump.h | 116 ++ > arch/powerpc/platforms/powernv/opal-wrappers.S |1 > arch/powerpc/platforms/pseries/Makefile |1 > arch/powerpc/platforms/pseries/pseries_fadump.c | 535 ++ > arch/powerpc/platforms/pseries/pseries_fadump.h | 96 ++ These hopefully could just be called pseries/fadump.[ch]? Or maybe rtas-fadump if you want to be like powernv. Thanks, Nick
Re: [PATCH] powerpc/powernv: Make opal log only readable by root
On 27/2/19 2:02 pm, Jordan Niethe wrote: Currently the opal log is globally readable. It is kernel policy to limit the visibility of physical addresses / kernel pointers to root. Given this and the fact the opal log may contain this information it would be better to limit the readability to root. Signed-off-by: Jordan Niethe Guess I'll have to get used to typing sudo more often. :( Makes sense also given that we do the same thing for exports afaict. Reviewed-by: Andrew Donnellan -- Andrew Donnellan OzLabs, ADL Canberra andrew.donnel...@au1.ibm.com IBM Australia Limited
Re: [PATCH] powerpc/powernv: Make opal log only readable by root
Jordan Niethe writes: > Currently the opal log is globally readable. It is kernel policy to limit > the visibility of physical addresses / kernel pointers to root. > Given this and the fact the opal log may contain this information it would > be better to limit the readability to root. > > Signed-off-by: Jordan Niethe Yeah, this is a really good idea. Reviewed-by: Stewart Smith -- Stewart Smith OPAL Architect, IBM.
Re: [PATCH 00/18] Add FADump support on PowerNV platform
Hi Hari, > Firmware-Assisted Dump (FADump) is currently supported only on pseries > platform. This patch series adds support for powernv platform too. > > The first and third patches refactor the FADump code to make use of common > code across multiple platforms. The fifth patch adds basic FADump support > for powernv platform. Patches seven & eight honour reserved-ranges DT node > while reserving/releasing memory used by FADump. The next patch processes > CPU state data provided by firmware to create and append core notes to the > ELF core file. The tenth patch adds support for preserving crash data for > subsequent boots (useful in cases like petitboot). Patch twelve provides > support to export opalcore. This is to make debugging of failures in OPAL > code easier. The subsequent patch ensures vmcore processing is skipped > when only OPAL core is exported by f/w. The next patch provides option to > release the kernel memory used to export opalcore. Patch seventeen adds > backup area (an area populated before crash and used in the capture kernel > to setup vmcore file robustly) support on PowerNV platform. The remaining > patches update Firmware-Assisted Dump documentation appropriately. > > Note that the quantam of increase in robustness due to patch seventeen may > not be worth breaking backward compatibility for older kernel versions. > Would like to hear thoughts from others on it. > > The patch series is tested with the latest firmware plus the below skiboot > changes for MPIPL support: > > https://patchwork.ozlabs.org/project/skiboot/list/?series=78497 > ("MPIPL support") > If I want to test this, is there some userspace tooling that will extract a fadump from a rebooted system and allow me to examine it as I would with a kdump (e.g. with crash)? I did look at Documentation/powerpc/firmware-assisted-dump.txt but it seems to only cover the kernel layer. Regards, Daniel > --- > > Hari Bathini (18): > powerpc/fadump: move internal fadump code to a new file > powerpc/fadump: Improve fadump documentation > pseries/fadump: move out platform specific support from generic code > powerpc/fadump: use FADump instead of fadump for how it is pronounced > powerpc/fadump: enable fadump support on OPAL based POWER platform > powerpc/fadump: Update documentation about OPAL platform support > powerpc/fadump: consider reserved ranges while reserving memory > powerpc/fadump: consider reserved ranges while releasing memory > powernv/fadump: process architected register state data provided by > firmware > powernv/fadump: add support to preserve crash data on FADUMP disabled > kernel > powerpc/fadump: update documentation about CONFIG_PRESERVE_FA_DUMP > powerpc/powernv: export /proc/opalcore for analysing opal crashes > powernv/fadump: Skip processing /proc/vmcore when only OPAL core exists > powernv/opalcore: provide an option to invalidate /proc/opalcore file > powernv/fadump: consider f/w load area > powernv/fadump: update documentation about option to release opalcore > powernv/fadump: use backup area to map PIR to logical CPUs > powerpc/fadump: Update documentation about backup area support > > > Documentation/powerpc/firmware-assisted-dump.txt | 208 ++-- > arch/powerpc/Kconfig | 23 > arch/powerpc/include/asm/fadump.h| 190 --- > arch/powerpc/include/asm/opal-api.h | 58 + > arch/powerpc/include/asm/opal.h |1 > arch/powerpc/kernel/Makefile |6 > arch/powerpc/kernel/fadump.c | 1199 > -- > arch/powerpc/kernel/fadump_internal.c| 297 + > arch/powerpc/kernel/fadump_internal.h| 250 + > arch/powerpc/kernel/prom.c |4 > arch/powerpc/platforms/powernv/Makefile |3 > arch/powerpc/platforms/powernv/opal-core.c | 602 +++ > arch/powerpc/platforms/powernv/opal-fadump.c | 670 > arch/powerpc/platforms/powernv/opal-fadump.h | 116 ++ > arch/powerpc/platforms/powernv/opal-wrappers.S |1 > arch/powerpc/platforms/pseries/Makefile |1 > arch/powerpc/platforms/pseries/pseries_fadump.c | 535 ++ > arch/powerpc/platforms/pseries/pseries_fadump.h | 96 ++ > 18 files changed, 3252 insertions(+), 1008 deletions(-) > create mode 100644 arch/powerpc/kernel/fadump_internal.c > create mode 100644 arch/powerpc/kernel/fadump_internal.h > create mode 100644 arch/powerpc/platforms/powernv/opal-core.c > create mode 100644 arch/powerpc/platforms/powernv/opal-fadump.c > create mode 100644 arch/powerpc/platforms/powernv/opal-fadump.h > create mode 100644 arch/powerpc/platforms/pseries/pseries_fadump.c > create mode 100644 arch/powerpc/platforms/pseries/pseries_fadump.h > > -- > Signature
Re: [PATCH] powerpc/fsl: Fix the flush of branch predictor.
Christophe Leroy writes: > The commit identified below adds MC_BTB_FLUSH macro only when > CONFIG_PPC_FSL_BOOK3E is defined. This results in the following error > on some configs (seen several times with kisskb randconfig_defconfig) > > arch/powerpc/kernel/exceptions-64e.S:576: Error: Unrecognized opcode: > `mc_btb_flush' > make[3]: *** [scripts/Makefile.build:367: > arch/powerpc/kernel/exceptions-64e.o] Error 1 > make[2]: *** [scripts/Makefile.build:492: arch/powerpc/kernel] Error 2 > make[1]: *** [Makefile:1043: arch/powerpc] Error 2 > make: *** [Makefile:152: sub-make] Error 2 > > This patch adds a blank definition of MC_BTB_FLUSH for other cases. > > Fixes: 10c5e83afd4a ("powerpc/fsl: Flush the branch predictor at each kernel > entry (64bit)") > Cc: Diana Craciun > Signed-off-by: Christophe Leroy > --- > arch/powerpc/kernel/exceptions-64e.S | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/powerpc/kernel/exceptions-64e.S > b/arch/powerpc/kernel/exceptions-64e.S > index 4549ce8d4637..49381f32b374 100644 > --- a/arch/powerpc/kernel/exceptions-64e.S > +++ b/arch/powerpc/kernel/exceptions-64e.S > @@ -338,6 +338,7 @@ ret_from_mc_except: > #define GEN_BTB_FLUSH > #define CRIT_BTB_FLUSH > #define DBG_BTB_FLUSH > +#define MC_BTB_FLUSH > #define GDBELL_BTB_FLUSH This seems correct to me: - MC_BTB_FLUSH gets a definition in the CONFIG_PPC_FSL_BOOK3E case. - other things that are defined in the FSL_BOOK3E case get empty definitions in the #else branch, but MC_BTB_FLUSH doesn't. - this patch just adds that empty definition. - there are no other definitions of MC_BTB_FLUSH that should be used instead. Reviewed-by: Daniel Axtens Regards, Daniel > #endif > > -- > 2.13.3
[PATCH] powerpc/powernv: Make opal log only readable by root
Currently the opal log is globally readable. It is kernel policy to limit the visibility of physical addresses / kernel pointers to root. Given this and the fact the opal log may contain this information it would be better to limit the readability to root. Signed-off-by: Jordan Niethe --- arch/powerpc/platforms/powernv/opal-msglog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/powernv/opal-msglog.c b/arch/powerpc/platforms/powernv/opal-msglog.c index acd3206dfae3..06628c71cef6 100644 --- a/arch/powerpc/platforms/powernv/opal-msglog.c +++ b/arch/powerpc/platforms/powernv/opal-msglog.c @@ -98,7 +98,7 @@ static ssize_t opal_msglog_read(struct file *file, struct kobject *kobj, } static struct bin_attribute opal_msglog_attr = { - .attr = {.name = "msglog", .mode = 0444}, + .attr = {.name = "msglog", .mode = 0400}, .read = opal_msglog_read }; -- 2.20.1
Re: [PATCH] powerpc/powernv: move OPAL call wrapper tracing and interrupt handling to C
Nicholas Piggin writes: > The OPAL call wrapper gets interrupt disabling wrong. It disables > interrupts just by clearing MSR[EE], which has two problems: > > - It doesn't call into the IRQ tracing subsystem, which means tracing > across OPAL calls does not always notice IRQs have been disabled. > > - It doesn't go through the IRQ soft-mask code, which causes a minor > bug. MSR[EE] can not be restored by saving the MSR then clearing > MSR[EE], because a racing interrupt while soft-masked could clear > MSR[EE] between the two steps. This can cause MSR[EE] to be > incorrectly enabled when the OPAL call returns. Fortunately that > should only result in another masked interrupt being taken to > disable MSR[EE] again, but it's a bit sloppy. > > The existing code also saves MSR to PACA, which is not re-entrant if > there is a nested OPAL call from different MSR contexts, which can > happen these days with SRESET interrupts on bare metal. > > To fix these issues, move the tracing and IRQ handling code to C, and > call into asm just for the low level call when everything is ready to > go. Save the MSR on stack rather than PACA. > > Performance cost is kept to a minimum with a few optimisations: > > - The endian switch upon return is combined with the MSR restore, > which avoids an expensive context synchronizing operation for LE > kernels. This makes up for the additional mtmsrd to enable > interrupts with local_irq_enable(). > > - blr is now used to return from the opal_* functions that are called > as C functions, to avoid link stack corruption. This requires a > skiboot fix as well to keep the call stack balanced. > > A NULL call is more costly after this, (410ns->430ns on POWER9), but > OPAL calls are generally not performance critical at this scale. At least with this patch we can start to better measure things, and that's a big plus. Also, When I get to start worrying about <1ms OPAL calls, I think we can revisit optimising this path :) -- Stewart Smith OPAL Architect, IBM.
Re: [PATCH V7 0/4] mm/kvm/vfio/ppc64: Migrate compound pages out of CMA region
[patch 1/4]: OK. I guess. Was this worth consuming our last PF_ flag? [patch 2/4]: unreviewed [patch 3/4]: unreviewed, mpe still unhappy, I expect? [patch 4/4]: unreviewed
Re: [PATCH V5 0/5] NestMMU pte upgrade workaround for mprotect
[patch 1/5]: unreviewed and has unaddressed comments from mpe. [patch 2/5]: ditto [patch 3/5]: ditto [patch 4/5]: seems ready [patch 5/5]: reviewed by mpe, but appears to need more work
Re: [PATCH v2 11/16] KVM: introduce a 'mmap' method for KVM devices
On Tue, Feb 26, 2019 at 01:52:39PM +0100, Paolo Bonzini wrote: > On 25/02/19 11:57, Cédric Le Goater wrote: > > Hello Paolo, > > > > On 2/25/19 4:33 AM, David Gibson wrote: > >> On Fri, Feb 22, 2019 at 12:28:35PM +0100, Cédric Le Goater wrote: > >>> Some KVM devices will want to handle special mappings related to the > >>> underlying HW. For instance, the XIVE interrupt controller of the > >>> POWER9 processor has MMIO pages for thread interrupt management and > >>> for interrupt source control that need to be exposed to the guest when > >>> the OS has the required support. > >>> > >>> Signed-off-by: Cédric Le Goater > >> > >> Ah, when I suggested mmap() on the base device fd, I hadn't realized > >> there wasn't a facility for that yet. > >> > >> Have you discussed this with Paolo? > > > > Not yet. > > > >> We'll need some core KVM buy in to merge this. > > > > Here is an extension of the KVM device to allow special mappings. > > Something we would need for the support of the POWER9 XIVE interrupt > > controller. > > > > There are two MMIOs we need to expose to the guest : > > > > 1. HW MMIO controlling of the interrupt presenter registers (TIMA) > > 2. HW MMIO of the interrupt sources for interrupt management (ESB) > > > > The TIMA could have been exposed with a page offset in the vCPU mapping > > but as it only makes sense when the XIVE interrupt mode is active, we > > chose to use directly the KVM device fd for that. Is that ok ? > > > > An alternate solution is to use a device ioctl to allocate an anon fd > > and do the mapping, but that seems like extra fuss for the same result. > > It's okay, it's a natural extension to dev_ops - but thanks for asking > anyway. :) Ok, cool. Given that, do you want to merge directly - since this looks sound enough, even though the rest of the series needs some polish? Or would you prefer it to come in via Paulus' tree? -- David Gibson| I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson signature.asc Description: PGP signature
Re: [PATCH v2 04/16] KVM: PPC: Book3S HV: XIVE: add a control to initialize a source
On Tue, Feb 26, 2019 at 03:25:15PM +1100, Paul Mackerras wrote: > On Mon, Feb 25, 2019 at 01:10:12PM +1100, David Gibson wrote: > > On Fri, Feb 22, 2019 at 12:28:28PM +0100, Cédric Le Goater wrote: > > > + /* > > > + * If the source doesn't already have an IPI, allocate > > > + * one and get the corresponding data > > > + */ > > > + if (!state->ipi_number) { > > > + state->ipi_number = xive_native_alloc_irq(); > > > + if (state->ipi_number == 0) { > > > + pr_err("Failed to allocate IRQ !\n"); > > > + return -ENXIO; > > > + } > > > + xive_native_populate_irq_data(state->ipi_number, > > > + >ipi_data); > > > + pr_debug("%s allocated hw_irq=0x%x for irq=0x%lx\n", __func__, > > > + state->ipi_number, irq); > > > + } > > > + > > > + arch_spin_lock(>lock); > > > > Why the direct call to arch_spin_lock() rather than just spin_lock()? > > He's sharing data structures with the xics-on-xive code, and that code > has a real-mode variant, and in real mode we don't want to risk > invoking lockdep code. Hence sb->lock is an arch_spinlock_t, and he > has to use arch_spin_lock() on it. Ah, right. -- David Gibson| I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson signature.asc Description: PGP signature
Re: build failure of current mmotm with skiroot_defconfig
On Tue, Feb 26, 2019 at 11:59:08AM +0200, Mike Rapoport wrote: > On Tue, Feb 26, 2019 at 10:39:54AM +0100, Christophe Leroy wrote: > > > > > > Le 26/02/2019 à 09:12, Mike Rapoport a écrit : > > >Hi, > > > > > >I've encountered the following error when building skyroot_defconfig with > > >current mmotm tree: > > > > > >make CONFIG_OF_ALL_DTBS=y CONFIG_DTC=y > > >CROSS_COMPILE=/opt/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux- > > >ARCH=powerpc vmlinux > > > ... > > > CC arch/powerpc/kernel/dbell.o > > >In file included from arch/powerpc/kernel/dbell.c:20: > > >arch/powerpc/include/asm/kvm_ppc.h: In function 'xics_on_xive': > > >arch/powerpc/include/asm/kvm_ppc.h:625:9: error: implicit declaration of > > >function 'xive_enabled'; did you mean 'eeh_enabled'? > > >[-Werror=implicit-function-declaration] > > > return xive_enabled() && cpu_has_feature(CPU_FTR_HVMODE); > > > ^~~~ > > > eeh_enabled > > > > I can neither find the above in arch/powerpc/include/asm/kvm_ppc.h in the > > powerpc tree, nor a patch removing it. > > > > Where does that comes from ? > > It's from current mmotm, probably some merge conflict... It's not a merge conflict; see http://patchwork.ozlabs.org/patch/1048584/ for the fix. Paul.
[PATCH] KVM: PPC: Fix compilation when KVM is not enabled
Compiling with CONFIG_PPC_POWERNV=y and KVM disabled currently gives an error like this: CC arch/powerpc/kernel/dbell.o In file included from arch/powerpc/kernel/dbell.c:20:0: arch/powerpc/include/asm/kvm_ppc.h: In function ‘xics_on_xive’: arch/powerpc/include/asm/kvm_ppc.h:625:9: error: implicit declaration of function ‘xive_enabled’ [-Werror=implicit-function-declaration] return xive_enabled() && cpu_has_feature(CPU_FTR_HVMODE); ^ cc1: all warnings being treated as errors scripts/Makefile.build:276: recipe for target 'arch/powerpc/kernel/dbell.o' failed make[3]: *** [arch/powerpc/kernel/dbell.o] Error 1 Fix this by making the xics_on_xive() definition conditional on the same symbol (CONFIG_KVM_BOOK3S_64_HANDLER) that determines whether we include or not, since that's the header that defines xive_enabled(). Fixes: 03f953329bd8 ("KVM: PPC: Book3S: Allow XICS emulation to work in nested hosts using XIVE") Signed-off-by: Paul Mackerras --- arch/powerpc/include/asm/kvm_ppc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index d283d31..ac22b28 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -619,7 +619,7 @@ static inline int kvmppc_xive_set_irq(struct kvm *kvm, int irq_source_id, u32 ir static inline void kvmppc_xive_push_vcpu(struct kvm_vcpu *vcpu) { } #endif /* CONFIG_KVM_XIVE */ -#ifdef CONFIG_PPC_POWERNV +#if defined(CONFIG_PPC_POWERNV) && defined(CONFIG_KVM_BOOK3S_64_HANDLER) static inline bool xics_on_xive(void) { return xive_enabled() && cpu_has_feature(CPU_FTR_HVMODE); -- 2.7.4
Re: [PATCH v1 4/4] clk: qoriq: Add clockgen support for lx2160a
On Tue, 2019-02-26 at 10:11 +, Vabhav Sharma wrote: > From: Yogesh Gaur > > Add clockgen support for lx2160a. > Added entry for compat 'fsl,lx2160a-clockgen'. > > Signed-off-by: Tang Yuantian > Signed-off-by: Yogesh Gaur > Signed-off-by: Vabhav Sharma > Acked-by: Stephen Boyd > Acked-by: Viresh Kumar > --- > drivers/clk/clk-qoriq.c | 12 > drivers/cpufreq/qoriq-cpufreq.c | 1 + > 2 files changed, 13 insertions(+) Acked-by: Scott Wood -Scott
Re: [PATCH v1 3/4] clk: qoriq: increase array size of cmux_to_group
On Tue, 2019-02-26 at 10:11 +, Vabhav Sharma wrote: > From: Yogesh Gaur > > Increase size of cmux_to_group array, to accomdate entry of > -1 termination. > > Added -1, terminated, entry for 4080_cmux_grpX. > > Signed-off-by: Yogesh Gaur > Signed-off-by: Vabhav Sharma > Acked-by: Stephen Boyd > --- > drivers/clk/clk-qoriq.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) Acked-by: Scott Wood -Scott
PROBLEM: monotonic clock going backwards on ppc64
Hi all, I think I observed a potential problem, is this the correct place to report it? (CC me, not on list) [1.] One line summary: monotonic clock can be made to decrease on ppc64 [2.] Full description: Setting the realtime clock can sometimes make the monotonic clock go back by over a hundred years. Decreasing the realtime clock across the y2k38 threshold is one reliable way to reproduce. Allegedly this can also happen just by running ntpd, I have not managed to reproduce that other than booting with rtc at >2038 and then running ntp. When this happens, anything with timers (e.g. openjdk) breaks rather badly. [3.] Keywords: gettimeofday, ppc64, vdso [4.] Kernel information [4.1.] Kernel version: any (tested on 4.19) [4.2.] Kernel .config file: any [5.] Most recent kernel version which did not have the bug: not a regression [6.] Output of Oops..: not applicable [7.] Example program which triggers the problem --- testcase.c #include #include #include #include long get_time() { struct timespec tp; if (clock_gettime(CLOCK_MONOTONIC, ) != 0) { perror("clock_gettime failed"); exit(1); } long result = tp.tv_sec + tp.tv_nsec / 10; return result; } int main() { printf("monitoring monotonic clock...\n"); long last = get_time(); while(1) { long now = get_time(); if (now < last) { printf("clock went backwards by %ld seconds!\n", last - now); } last = now; sleep(1); } return 0; } --- when running # date -s 2040-1-1 # date -s 2037-1-1 program outputs: clock went backwards by 4294967295 seconds! [8.] Environment: any ppc64, currently reproducing on qemu-system-ppc64le running debian unstable [X.] Other notes, patches, fixes, workarounds: The problem seems to be in vDSO code in arch/powerpc/kernel/vdso64/gettimeofday.S. (possibly because some values used in the calculation are only 32 bit?) Slightly silly workaround: nuke the "cmpwi cr1,r3,CLOCK_MONOTONIC" in __kernel_clock_gettime Now it always goes through the syscall fallback which does not have the same problem. Regards, Jakub Drnec
Re: [PATCH V3] ASoC: fsl_esai: fix channel swap issue when stream starts
Hi Shengjiu, Two more trivial comments inline. On Tue, Feb 26, 2019 at 03:12:25AM +, S.j. Wang wrote: > There is very low possibility ( < 0.1% ) that channel swap happened > in beginning when multi output/input pin is enabled. The issue is > that hardware can't send data to correct pin in the beginning with > the normal enable flow. > > This is hardware issue, but there is no errata, the workaround flow > is that: Each time playback/recording, firstly clear the xSMA/xSMB, > then enable TE/RE, then enable xSMB and xSMA (xSMB must be enabled > before xSMA). Which is to use the xSMA as the trigger start register, > previously the xCR_TE or xCR_RE is the bit for starting. > > Fixes commit 43d24e76b698 ("ASoC: fsl_esai: Add ESAI CPU DAI driver") > Cc: > Re> @@ -361,21 +363,13 @@ static int fsl_esai_set_dai_tdm_slot(struct > snd_soc_dai *dai, u32 tx_mask, > esai_priv->slot_width = slot_width; > esai_priv->slots = slots; > + esai_priv->tx_mask= tx_mask; > + esai_priv->rx_mask= rx_mask; Not necessary to have tabs before "="s. > @@ -611,12 +606,23 @@ static int fsl_esai_trigger(struct snd_pcm_substream > *substream, int cmd, > regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx), > tx ? ESAI_xCR_TE_MASK : ESAI_xCR_RE_MASK, > tx ? ESAI_xCR_TE(pins) : ESAI_xCR_RE(pins)); > + mask = tx ? esai_priv->tx_mask : esai_priv->rx_mask; > + Please add a line of brief comments for the reason why we are doing this here, something similar to the commit log, but should have: 1) Clear xSMA/B 2) Set TE/RE before xSMA/B 3)Set xSMB before xSMA. Apparently having this mask settings in the trigger() does not look very common, so I believe a line of comments would help a lot. You may add my Acked-by in your next version: Acked-by: Nicolin Chen Thanks > + regmap_update_bits(esai_priv->regmap, REG_ESAI_xSMB(tx), > +ESAI_xSMB_xS_MASK, ESAI_xSMB_xS(mask)); > + regmap_update_bits(esai_priv->regmap, REG_ESAI_xSMA(tx), > +ESAI_xSMA_xS_MASK, ESAI_xSMA_xS(mask)); > + > break; > case SNDRV_PCM_TRIGGER_SUSPEND: > case SNDRV_PCM_TRIGGER_STOP: > case SNDRV_PCM_TRIGGER_PAUSE_PUSH: > regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx), > tx ? ESAI_xCR_TE_MASK : ESAI_xCR_RE_MASK, 0); > + regmap_update_bits(esai_priv->regmap, REG_ESAI_xSMA(tx), > +ESAI_xSMA_xS_MASK, 0); > + regmap_update_bits(esai_priv->regmap, REG_ESAI_xSMB(tx), > +ESAI_xSMB_xS_MASK, 0); >
[PATCH] powerpc/fsl: Fix the flush of branch predictor.
The commit identified below adds MC_BTB_FLUSH macro only when CONFIG_PPC_FSL_BOOK3E is defined. This results in the following error on some configs (seen several times with kisskb randconfig_defconfig) arch/powerpc/kernel/exceptions-64e.S:576: Error: Unrecognized opcode: `mc_btb_flush' make[3]: *** [scripts/Makefile.build:367: arch/powerpc/kernel/exceptions-64e.o] Error 1 make[2]: *** [scripts/Makefile.build:492: arch/powerpc/kernel] Error 2 make[1]: *** [Makefile:1043: arch/powerpc] Error 2 make: *** [Makefile:152: sub-make] Error 2 This patch adds a blank definition of MC_BTB_FLUSH for other cases. Fixes: 10c5e83afd4a ("powerpc/fsl: Flush the branch predictor at each kernel entry (64bit)") Cc: Diana Craciun Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/exceptions-64e.S | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S index 4549ce8d4637..49381f32b374 100644 --- a/arch/powerpc/kernel/exceptions-64e.S +++ b/arch/powerpc/kernel/exceptions-64e.S @@ -338,6 +338,7 @@ ret_from_mc_except: #define GEN_BTB_FLUSH #define CRIT_BTB_FLUSH #define DBG_BTB_FLUSH +#define MC_BTB_FLUSH #define GDBELL_BTB_FLUSH #endif -- 2.13.3
Re: [PATCH] soc: fsl: guts: make fsl_guts_get_svr() static
On Fri, Feb 22, 2019 at 2:09 AM Y.b. Lu wrote: > > > > > -Original Message- > > From: Horia Geantă > > Sent: Thursday, February 21, 2019 6:38 PM > > To: Leo Li > > Cc: Y.b. Lu ; linuxppc-dev@lists.ozlabs.org; > > linux-arm-ker...@lists.infradead.org; linux-ker...@vger.kernel.org > > Subject: [PATCH] soc: fsl: guts: make fsl_guts_get_svr() static > > > > The export of fsl_guts_get_svr() is a left-over, it's currently used only > > internally > > and users needing SoC information should use the generic soc_device > > infrastructure. > > > > [Y.b. Lu] Acked-by: Yangbo Lu Applied for next. Thanks. > > > Signed-off-by: Horia Geantă > > --- > > drivers/soc/fsl/guts.c | 3 +-- > > include/linux/fsl/guts.h | 2 -- > > 2 files changed, 1 insertion(+), 4 deletions(-) > > > > diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c index > > 4f9655087bd7..63f6df86f9e5 100644 > > --- a/drivers/soc/fsl/guts.c > > +++ b/drivers/soc/fsl/guts.c > > @@ -115,7 +115,7 @@ static const struct fsl_soc_die_attr > > *fsl_soc_die_match( > > return NULL; > > } > > > > -u32 fsl_guts_get_svr(void) > > +static u32 fsl_guts_get_svr(void) > > { > > u32 svr = 0; > > > > @@ -129,7 +129,6 @@ u32 fsl_guts_get_svr(void) > > > > return svr; > > } > > -EXPORT_SYMBOL(fsl_guts_get_svr); > > > > static int fsl_guts_probe(struct platform_device *pdev) { diff --git > > a/include/linux/fsl/guts.h b/include/linux/fsl/guts.h index > > 941b11811f85..1fc0edd71c52 100644 > > --- a/include/linux/fsl/guts.h > > +++ b/include/linux/fsl/guts.h > > @@ -135,8 +135,6 @@ struct ccsr_guts { > > u32 srds2cr1; /* 0x.0f44 - SerDes2 Control Register 0 */ > > } __attribute__ ((packed)); > > > > -u32 fsl_guts_get_svr(void); > > - > > /* Alternate function signal multiplex control */ #define > > MPC85xx_PMUXCR_QE(x) (0x8000 >> (x)) > > > > -- > > 2.16.2 >
[PATCH v8 10/11] powerpc/32s: move hash code patching out of MMU_init_hw()
For KASAN, hash table handling will be activated early for accessing to KASAN shadow areas. In order to avoid any modification of the hash functions while they are still used with the early hash table, the code patching is moved out of MMU_init_hw() and put close to the big-bang switch to the final hash table. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/head_32.S | 3 +++ arch/powerpc/mm/mmu_decl.h| 1 + arch/powerpc/mm/ppc_mmu_32.c | 36 ++-- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/kernel/head_32.S b/arch/powerpc/kernel/head_32.S index 02229c005853..e644aab2cf5b 100644 --- a/arch/powerpc/kernel/head_32.S +++ b/arch/powerpc/kernel/head_32.S @@ -960,6 +960,9 @@ start_here: bl machine_init bl __save_cpu_setup bl MMU_init +BEGIN_MMU_FTR_SECTION + bl MMU_init_hw_patch +END_MMU_FTR_SECTION_IFSET(MMU_FTR_HPTE_TABLE) /* * Go back to running unmapped so we can load up new values diff --git a/arch/powerpc/mm/mmu_decl.h b/arch/powerpc/mm/mmu_decl.h index 74ff61dabcb1..d726ff776054 100644 --- a/arch/powerpc/mm/mmu_decl.h +++ b/arch/powerpc/mm/mmu_decl.h @@ -130,6 +130,7 @@ extern void wii_memory_fixups(void); */ #ifdef CONFIG_PPC32 extern void MMU_init_hw(void); +void MMU_init_hw_patch(void); unsigned long mmu_mapin_ram(unsigned long base, unsigned long top); #endif diff --git a/arch/powerpc/mm/ppc_mmu_32.c b/arch/powerpc/mm/ppc_mmu_32.c index 2d5b0d50fb31..38c0e28c21e1 100644 --- a/arch/powerpc/mm/ppc_mmu_32.c +++ b/arch/powerpc/mm/ppc_mmu_32.c @@ -39,6 +39,7 @@ struct hash_pte *Hash, *Hash_end; unsigned long Hash_size, Hash_mask; unsigned long _SDR1; +static unsigned int hash_mb, hash_mb2; struct ppc_bat BATS[8][2]; /* 8 pairs of IBAT, DBAT */ @@ -308,7 +309,6 @@ void hash_preload(struct mm_struct *mm, unsigned long ea, */ void __init MMU_init_hw(void) { - unsigned int hmask, mb, mb2; unsigned int n_hpteg, lg_n_hpteg; if (!mmu_has_feature(MMU_FTR_HPTE_TABLE)) @@ -349,20 +349,30 @@ void __init MMU_init_hw(void) (unsigned long long)(total_memory >> 20), Hash_size >> 10, Hash); - /* -* Patch up the instructions in hashtable.S:create_hpte -*/ - if ( ppc_md.progress ) ppc_md.progress("hash:patch", 0x345); Hash_mask = n_hpteg - 1; - hmask = Hash_mask >> (16 - LG_HPTEG_SIZE); - mb2 = mb = 32 - LG_HPTEG_SIZE - lg_n_hpteg; + hash_mb2 = hash_mb = 32 - LG_HPTEG_SIZE - lg_n_hpteg; if (lg_n_hpteg > 16) - mb2 = 16 - LG_HPTEG_SIZE; + hash_mb2 = 16 - LG_HPTEG_SIZE; +} + +void __init MMU_init_hw_patch(void) +{ + unsigned int hmask = Hash_mask >> (16 - LG_HPTEG_SIZE); + if (ppc_md.progress) + ppc_md.progress("hash:patch", 0x345); + if (ppc_md.progress) + ppc_md.progress("hash:done", 0x205); + + /* WARNING: Make sure nothing can trigger a KASAN check past this point */ + + /* +* Patch up the instructions in hashtable.S:create_hpte +*/ modify_instruction_site(__hash_page_A0, 0x, ((unsigned int)Hash - PAGE_OFFSET) >> 16); - modify_instruction_site(__hash_page_A1, 0x7c0, mb << 6); - modify_instruction_site(__hash_page_A2, 0x7c0, mb2 << 6); + modify_instruction_site(__hash_page_A1, 0x7c0, hash_mb << 6); + modify_instruction_site(__hash_page_A2, 0x7c0, hash_mb2 << 6); modify_instruction_site(__hash_page_B, 0x, hmask); modify_instruction_site(__hash_page_C, 0x, hmask); @@ -371,11 +381,9 @@ void __init MMU_init_hw(void) */ modify_instruction_site(__flush_hash_A0, 0x, ((unsigned int)Hash - PAGE_OFFSET) >> 16); - modify_instruction_site(__flush_hash_A1, 0x7c0, mb << 6); - modify_instruction_site(__flush_hash_A2, 0x7c0, mb2 << 6); + modify_instruction_site(__flush_hash_A1, 0x7c0, hash_mb << 6); + modify_instruction_site(__flush_hash_A2, 0x7c0, hash_mb2 << 6); modify_instruction_site(__flush_hash_B, 0x, hmask); - - if ( ppc_md.progress ) ppc_md.progress("hash:done", 0x205); } void setup_initial_memory_limit(phys_addr_t first_memblock_base, -- 2.13.3
[PATCH v8 11/11] powerpc/32s: set up an early static hash table for KASAN.
KASAN requires early activation of hash table, before memblock() functions are available. This patch implements an early hash_table statically defined in __initdata. During early boot, a single page table is used. For hash32, when doing the final init, one page table is allocated for each PGD entry because of the _PAGE_HASHPTE flag which can't be common to several virt pages. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/head_32.S | 40 ++- arch/powerpc/mm/kasan/kasan_init_32.c | 32 arch/powerpc/mm/mmu_decl.h| 1 + 3 files changed, 59 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/kernel/head_32.S b/arch/powerpc/kernel/head_32.S index e644aab2cf5b..65c9e8819da1 100644 --- a/arch/powerpc/kernel/head_32.S +++ b/arch/powerpc/kernel/head_32.S @@ -160,6 +160,10 @@ __after_mmu_off: bl flush_tlbs bl initial_bats + bl load_segment_registers +#ifdef CONFIG_KASAN + bl early_hash_table +#endif #if defined(CONFIG_BOOTX_TEXT) bl setup_disp_bat #endif @@ -205,7 +209,7 @@ __after_mmu_off: */ turn_on_mmu: mfmsr r0 - ori r0,r0,MSR_DR|MSR_IR + ori r0,r0,MSR_DR|MSR_IR|MSR_RI mtspr SPRN_SRR1,r0 lis r0,start_here@h ori r0,r0,start_here@l @@ -881,11 +885,24 @@ _ENTRY(__restore_cpu_setup) blr #endif /* !defined(CONFIG_PPC_BOOK3S_32) */ - /* * Load stuff into the MMU. Intended to be called with * IR=0 and DR=0. */ +#ifdef CONFIG_KASAN +early_hash_table: + sync/* Force all PTE updates to finish */ + isync + tlbia /* Clear all TLB entries */ + sync/* wait for tlbia/tlbie to finish */ + TLBSYNC /* ... on all CPUs */ + /* Load the SDR1 register (hash table base & size) */ + lis r6, early_hash - PAGE_OFFSET@h + ori r6, r6, 3 /* 256kB table */ + mtspr SPRN_SDR1, r6 + blr +#endif + load_up_mmu: sync/* Force all PTE updates to finish */ isync @@ -897,14 +914,6 @@ load_up_mmu: tophys(r6,r6) lwz r6,_SDR1@l(r6) mtspr SPRN_SDR1,r6 - li r0,16 /* load up segment register values */ - mtctr r0 /* for context 0 */ - lis r3,0x2000 /* Ku = 1, VSID = 0 */ - li r4,0 -3: mtsrin r3,r4 - addir3,r3,0x111 /* increment VSID */ - addis r4,r4,0x1000/* address of next segment */ - bdnz3b /* Load the BAT registers with the values set up by MMU_init. MMU_init takes care of whether we're on a 601 or not. */ @@ -926,6 +935,17 @@ BEGIN_MMU_FTR_SECTION END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS) blr +load_segment_registers: + li r0, 16 /* load up segment register values */ + mtctr r0 /* for context 0 */ + lis r3, 0x2000 /* Ku = 1, VSID = 0 */ + li r4, 0 +3: mtsrin r3, r4 + addir3, r3, 0x111 /* increment VSID */ + addis r4, r4, 0x1000 /* address of next segment */ + bdnz3b + blr + /* * This is where the main kernel code starts. */ diff --git a/arch/powerpc/mm/kasan/kasan_init_32.c b/arch/powerpc/mm/kasan/kasan_init_32.c index 42f8534ce3ea..8c25c1e8c2c8 100644 --- a/arch/powerpc/mm/kasan/kasan_init_32.c +++ b/arch/powerpc/mm/kasan/kasan_init_32.c @@ -60,10 +60,13 @@ static int __ref kasan_init_region(void *start, size_t size) unsigned long k_cur; pmd_t *pmd; void *block = NULL; - int ret = kasan_init_shadow_page_tables(k_start, k_end); - if (ret) - return ret; + if (!early_mmu_has_feature(MMU_FTR_HPTE_TABLE)) { + int ret = kasan_init_shadow_page_tables(k_start, k_end); + + if (ret) + return ret; + } if (!slab_is_available()) block = memblock_alloc(k_end - k_start, PAGE_SIZE); @@ -94,6 +97,13 @@ void __init kasan_init(void) int ret; struct memblock_region *reg; + if (early_mmu_has_feature(MMU_FTR_HPTE_TABLE)) { + ret = kasan_init_shadow_page_tables(KASAN_SHADOW_START, KASAN_SHADOW_END); + + if (ret) + panic("kasan: kasan_init_shadow_page_tables() failed"); + } + for_each_memblock(memory, reg) { phys_addr_t base = reg->base; phys_addr_t top = min(base + reg->size, total_lowmem); @@ -132,6 +142,20 @@ void *module_alloc(unsigned long size) } #endif +#ifdef CONFIG_PPC_BOOK3S_32 +u8 __initdata early_hash[256 << 10] __aligned(256 << 10) = {0}; + +static void __init kasan_early_hash_table(void) +{ + modify_instruction_site(__hash_page_A0, 0x, __pa(early_hash) >> 16); +
[PATCH v8 08/11] powerpc: disable KASAN instrumentation on early/critical files.
All files containing functions run before kasan_early_init() is called must have KASAN instrumentation disabled. For those file, branch profiling also have to be disabled otherwise each if () generates a call to ftrace_likely_update(). Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/Makefile | 12 arch/powerpc/lib/Makefile| 8 arch/powerpc/mm/Makefile | 6 ++ arch/powerpc/platforms/powermac/Makefile | 6 ++ arch/powerpc/purgatory/Makefile | 3 +++ arch/powerpc/xmon/Makefile | 1 + 6 files changed, 36 insertions(+) diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index 45e47752b692..0ea6c4aa3a20 100644 --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile @@ -31,6 +31,18 @@ CFLAGS_REMOVE_btext.o = $(CC_FLAGS_FTRACE) CFLAGS_REMOVE_prom.o = $(CC_FLAGS_FTRACE) endif +KASAN_SANITIZE_early_32.o := n +KASAN_SANITIZE_cputable.o := n +KASAN_SANITIZE_prom_init.o := n +KASAN_SANITIZE_btext.o := n + +ifdef CONFIG_KASAN +CFLAGS_early_32.o += -DDISABLE_BRANCH_PROFILING +CFLAGS_cputable.o += -DDISABLE_BRANCH_PROFILING +CFLAGS_prom_init.o += -DDISABLE_BRANCH_PROFILING +CFLAGS_btext.o += -DDISABLE_BRANCH_PROFILING +endif + obj-y := cputable.o ptrace.o syscalls.o \ irq.o align.o signal_32.o pmc.o vdso.o \ process.o systbl.o idle.o \ diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile index 47a4de434c22..c55f9c27bf79 100644 --- a/arch/powerpc/lib/Makefile +++ b/arch/powerpc/lib/Makefile @@ -8,6 +8,14 @@ ccflags-$(CONFIG_PPC64):= $(NO_MINIMAL_TOC) CFLAGS_REMOVE_code-patching.o = $(CC_FLAGS_FTRACE) CFLAGS_REMOVE_feature-fixups.o = $(CC_FLAGS_FTRACE) +KASAN_SANITIZE_code-patching.o := n +KASAN_SANITIZE_feature-fixups.o := n + +ifdef CONFIG_KASAN +CFLAGS_code-patching.o += -DDISABLE_BRANCH_PROFILING +CFLAGS_feature-fixups.o += -DDISABLE_BRANCH_PROFILING +endif + obj-y += alloc.o code-patching.o feature-fixups.o ifndef CONFIG_KASAN diff --git a/arch/powerpc/mm/Makefile b/arch/powerpc/mm/Makefile index d52ec118e09d..240d73dce6bb 100644 --- a/arch/powerpc/mm/Makefile +++ b/arch/powerpc/mm/Makefile @@ -7,6 +7,12 @@ ccflags-$(CONFIG_PPC64):= $(NO_MINIMAL_TOC) CFLAGS_REMOVE_slb.o = $(CC_FLAGS_FTRACE) +KASAN_SANITIZE_ppc_mmu_32.o := n + +ifdef CONFIG_KASAN +CFLAGS_ppc_mmu_32.o+= -DDISABLE_BRANCH_PROFILING +endif + obj-y := fault.o mem.o pgtable.o mmap.o \ init_$(BITS).o pgtable_$(BITS).o \ init-common.o mmu_context.o drmem.o diff --git a/arch/powerpc/platforms/powermac/Makefile b/arch/powerpc/platforms/powermac/Makefile index 923bfb340433..859efbacdf06 100644 --- a/arch/powerpc/platforms/powermac/Makefile +++ b/arch/powerpc/platforms/powermac/Makefile @@ -2,6 +2,12 @@ CFLAGS_bootx_init.o+= -fPIC CFLAGS_bootx_init.o+= $(call cc-option, -fno-stack-protector) +KASAN_SANITIZE_bootx_init.o := n + +ifdef CONFIG_KASAN +CFLAGS_bootx_init.o+= -DDISABLE_BRANCH_PROFILING +endif + ifdef CONFIG_FUNCTION_TRACER # Do not trace early boot code CFLAGS_REMOVE_bootx_init.o = $(CC_FLAGS_FTRACE) diff --git a/arch/powerpc/purgatory/Makefile b/arch/powerpc/purgatory/Makefile index 4314ba5baf43..7c6d8b14f440 100644 --- a/arch/powerpc/purgatory/Makefile +++ b/arch/powerpc/purgatory/Makefile @@ -1,4 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 + +KASAN_SANITIZE := n + targets += trampoline.o purgatory.ro kexec-purgatory.c LDFLAGS_purgatory.ro := -e purgatory_start -r --no-undefined diff --git a/arch/powerpc/xmon/Makefile b/arch/powerpc/xmon/Makefile index 3050f9323254..f142570ad860 100644 --- a/arch/powerpc/xmon/Makefile +++ b/arch/powerpc/xmon/Makefile @@ -7,6 +7,7 @@ subdir-ccflags-y := $(call cc-disable-warning, builtin-requires-header) GCOV_PROFILE := n KCOV_INSTRUMENT := n UBSAN_SANITIZE := n +KASAN_SANITIZE := n # Disable ftrace for the entire directory ORIG_CFLAGS := $(KBUILD_CFLAGS) -- 2.13.3
[PATCH v8 05/11] powerpc/32: use memset() instead of memset_io() to zero BSS
Since commit 400c47d81ca38 ("powerpc32: memset: only use dcbz once cache is enabled"), memset() can be used before activation of the cache, so no need to use memset_io() for zeroing the BSS. Acked-by: Dmitry Vyukov Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/early_32.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/early_32.c b/arch/powerpc/kernel/early_32.c index cf3cdd81dc47..3482118ffe76 100644 --- a/arch/powerpc/kernel/early_32.c +++ b/arch/powerpc/kernel/early_32.c @@ -21,8 +21,8 @@ notrace unsigned long __init early_init(unsigned long dt_ptr) { unsigned long offset = reloc_offset(); - /* First zero the BSS -- use memset_io, some platforms don't have caches on yet */ - memset_io((void __iomem *)PTRRELOC(&__bss_start), 0, __bss_stop - __bss_start); + /* First zero the BSS */ + memset(PTRRELOC(&__bss_start), 0, __bss_stop - __bss_start); /* * Identify the CPU type and fix up code sections -- 2.13.3
[PATCH v8 09/11] powerpc/32: Add KASAN support
This patch adds KASAN support for PPC32. The following patch will add an early activation of hash table for book3s. Until then, a warning will be raised if trying to use KASAN on an hash 6xx. To support KASAN, this patch initialises that MMU mapings for accessing to the KASAN shadow area defined in a previous patch. An early mapping is set as soon as the kernel code has been relocated at its definitive place. Then the definitive mapping is set once paging is initialised. For modules, the shadow area is allocated at module_alloc(). Signed-off-by: Christophe Leroy --- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/kasan.h | 7 ++ arch/powerpc/kernel/head_32.S | 3 + arch/powerpc/kernel/head_40x.S| 3 + arch/powerpc/kernel/head_44x.S| 3 + arch/powerpc/kernel/head_8xx.S| 3 + arch/powerpc/kernel/head_fsl_booke.S | 3 + arch/powerpc/kernel/setup-common.c| 3 + arch/powerpc/mm/Makefile | 1 + arch/powerpc/mm/kasan/Makefile| 5 ++ arch/powerpc/mm/kasan/kasan_init_32.c | 153 ++ 11 files changed, 185 insertions(+) create mode 100644 arch/powerpc/mm/kasan/Makefile create mode 100644 arch/powerpc/mm/kasan/kasan_init_32.c diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 652c25260838..8d6108c83299 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -172,6 +172,7 @@ config PPC select GENERIC_TIME_VSYSCALL select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL + select HAVE_ARCH_KASAN if PPC32 select HAVE_ARCH_KGDB select HAVE_ARCH_MMAP_RND_BITS select HAVE_ARCH_MMAP_RND_COMPAT_BITS if COMPAT diff --git a/arch/powerpc/include/asm/kasan.h b/arch/powerpc/include/asm/kasan.h index 8dc1e3819171..74a4ba9fb8a3 100644 --- a/arch/powerpc/include/asm/kasan.h +++ b/arch/powerpc/include/asm/kasan.h @@ -27,5 +27,12 @@ #define KASAN_SHADOW_SIZE (KASAN_SHADOW_END - KASAN_SHADOW_START) +#ifdef CONFIG_KASAN +void kasan_early_init(void); +void kasan_init(void); +#else +static inline void kasan_init(void) { } +#endif + #endif /* __ASSEMBLY */ #endif diff --git a/arch/powerpc/kernel/head_32.S b/arch/powerpc/kernel/head_32.S index ce6a972f2584..02229c005853 100644 --- a/arch/powerpc/kernel/head_32.S +++ b/arch/powerpc/kernel/head_32.S @@ -952,6 +952,9 @@ start_here: * Do early platform-specific initialization, * and set up the MMU. */ +#ifdef CONFIG_KASAN + bl kasan_early_init +#endif li r3,0 mr r4,r31 bl machine_init diff --git a/arch/powerpc/kernel/head_40x.S b/arch/powerpc/kernel/head_40x.S index a9c934f2319b..efa219d2136e 100644 --- a/arch/powerpc/kernel/head_40x.S +++ b/arch/powerpc/kernel/head_40x.S @@ -848,6 +848,9 @@ start_here: /* * Decide what sort of machine this is and initialize the MMU. */ +#ifdef CONFIG_KASAN + bl kasan_early_init +#endif li r3,0 mr r4,r31 bl machine_init diff --git a/arch/powerpc/kernel/head_44x.S b/arch/powerpc/kernel/head_44x.S index 37117ab11584..34a5df827b38 100644 --- a/arch/powerpc/kernel/head_44x.S +++ b/arch/powerpc/kernel/head_44x.S @@ -203,6 +203,9 @@ _ENTRY(_start); /* * Decide what sort of machine this is and initialize the MMU. */ +#ifdef CONFIG_KASAN + bl kasan_early_init +#endif li r3,0 mr r4,r31 bl machine_init diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S index 03c73b4c6435..d25adb6ef235 100644 --- a/arch/powerpc/kernel/head_8xx.S +++ b/arch/powerpc/kernel/head_8xx.S @@ -853,6 +853,9 @@ start_here: /* * Decide what sort of machine this is and initialize the MMU. */ +#ifdef CONFIG_KASAN + bl kasan_early_init +#endif li r3,0 mr r4,r31 bl machine_init diff --git a/arch/powerpc/kernel/head_fsl_booke.S b/arch/powerpc/kernel/head_fsl_booke.S index 1881127682e9..0fc38eb957b7 100644 --- a/arch/powerpc/kernel/head_fsl_booke.S +++ b/arch/powerpc/kernel/head_fsl_booke.S @@ -275,6 +275,9 @@ set_ivor: /* * Decide what sort of machine this is and initialize the MMU. */ +#ifdef CONFIG_KASAN + bl kasan_early_init +#endif mr r3,r30 mr r4,r31 bl machine_init diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c index e7534f306c8e..3c6c5a43901e 100644 --- a/arch/powerpc/kernel/setup-common.c +++ b/arch/powerpc/kernel/setup-common.c @@ -67,6 +67,7 @@ #include #include #include +#include #include "setup.h" @@ -865,6 +866,8 @@ static void smp_setup_pacas(void) */ void __init setup_arch(char **cmdline_p) { + kasan_init(); + *cmdline_p = boot_command_line; /* Set a half-reasonable default so udelay does something sensible */ diff --git a/arch/powerpc/mm/Makefile
[PATCH v8 06/11] powerpc/32: make KVIRT_TOP dependent on FIXMAP_START
When we add KASAN shadow area, KVIRT_TOP can't be anymore fixed at 0xfe00. This patch uses FIXADDR_START to define KVIRT_TOP. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/book3s/32/pgtable.h | 13 ++--- arch/powerpc/include/asm/nohash/32/pgtable.h | 13 ++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/32/pgtable.h b/arch/powerpc/include/asm/book3s/32/pgtable.h index aa8406b8f7ba..838de59f6754 100644 --- a/arch/powerpc/include/asm/book3s/32/pgtable.h +++ b/arch/powerpc/include/asm/book3s/32/pgtable.h @@ -134,15 +134,24 @@ static inline bool pte_user(pte_t pte) #define PGDIR_MASK (~(PGDIR_SIZE-1)) #define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE) + +#ifndef __ASSEMBLY__ + +int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot); + +#endif /* !__ASSEMBLY__ */ + /* * This is the bottom of the PKMAP area with HIGHMEM or an arbitrary * value (for now) on others, from where we can start layout kernel * virtual space that goes below PKMAP and FIXMAP */ +#include + #ifdef CONFIG_HIGHMEM #define KVIRT_TOP PKMAP_BASE #else -#define KVIRT_TOP (0xfe00UL) /* for now, could be FIXMAP_BASE ? */ +#define KVIRT_TOP FIXADDR_START #endif /* @@ -373,8 +382,6 @@ static inline void __ptep_set_access_flags(struct vm_area_struct *vma, #define __pte_to_swp_entry(pte)((swp_entry_t) { pte_val(pte) >> 3 }) #define __swp_entry_to_pte(x) ((pte_t) { (x).val << 3 }) -int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot); - /* Generic accessors to PTE bits */ static inline int pte_write(pte_t pte) { return !!(pte_val(pte) & _PAGE_RW);} static inline int pte_read(pte_t pte) { return 1; } diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h index bed433358260..0284f8f5305f 100644 --- a/arch/powerpc/include/asm/nohash/32/pgtable.h +++ b/arch/powerpc/include/asm/nohash/32/pgtable.h @@ -64,15 +64,24 @@ extern int icache_44x_need_flush; #define pgd_ERROR(e) \ pr_err("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e)) +#ifndef __ASSEMBLY__ + +int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot); + +#endif /* !__ASSEMBLY__ */ + + /* * This is the bottom of the PKMAP area with HIGHMEM or an arbitrary * value (for now) on others, from where we can start layout kernel * virtual space that goes below PKMAP and FIXMAP */ +#include + #ifdef CONFIG_HIGHMEM #define KVIRT_TOP PKMAP_BASE #else -#define KVIRT_TOP (0xfe00UL) /* for now, could be FIXMAP_BASE ? */ +#define KVIRT_TOP FIXADDR_START #endif /* @@ -379,8 +388,6 @@ static inline int pte_young(pte_t pte) #define __pte_to_swp_entry(pte)((swp_entry_t) { pte_val(pte) >> 3 }) #define __swp_entry_to_pte(x) ((pte_t) { (x).val << 3 }) -int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot); - #endif /* !__ASSEMBLY__ */ #endif /* __ASM_POWERPC_NOHASH_32_PGTABLE_H */ -- 2.13.3
[PATCH v8 07/11] powerpc/32: prepare shadow area for KASAN
This patch prepares a shadow area for KASAN. The shadow area will be at the top of the kernel virtual memory space above the fixmap area and will occupy one eighth of the total kernel virtual memory space. Signed-off-by: Christophe Leroy --- arch/powerpc/Kconfig.debug| 5 + arch/powerpc/include/asm/fixmap.h | 5 + arch/powerpc/include/asm/kasan.h | 16 arch/powerpc/mm/mem.c | 4 arch/powerpc/mm/ptdump/ptdump.c | 8 5 files changed, 38 insertions(+) diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug index 4e00cb0a5464..61febbbdd02b 100644 --- a/arch/powerpc/Kconfig.debug +++ b/arch/powerpc/Kconfig.debug @@ -366,3 +366,8 @@ config PPC_FAST_ENDIAN_SWITCH depends on DEBUG_KERNEL && PPC_BOOK3S_64 help If you're unsure what this is, say N. + +config KASAN_SHADOW_OFFSET + hex + depends on KASAN + default 0xe000 diff --git a/arch/powerpc/include/asm/fixmap.h b/arch/powerpc/include/asm/fixmap.h index b9fbed84ddca..51a1a309c919 100644 --- a/arch/powerpc/include/asm/fixmap.h +++ b/arch/powerpc/include/asm/fixmap.h @@ -22,7 +22,12 @@ #include #endif +#ifdef CONFIG_KASAN +#include +#define FIXADDR_TOPKASAN_SHADOW_START +#else #define FIXADDR_TOP((unsigned long)(-PAGE_SIZE)) +#endif /* * Here we define all the compile-time 'special' virtual diff --git a/arch/powerpc/include/asm/kasan.h b/arch/powerpc/include/asm/kasan.h index c3161b8fc017..8dc1e3819171 100644 --- a/arch/powerpc/include/asm/kasan.h +++ b/arch/powerpc/include/asm/kasan.h @@ -12,4 +12,20 @@ #define EXPORT_SYMBOL_KASAN(fn)EXPORT_SYMBOL(fn) #endif +#ifndef __ASSEMBLY__ + +#include + +#define KASAN_SHADOW_SCALE_SHIFT 3 + +#define KASAN_SHADOW_OFFSETASM_CONST(CONFIG_KASAN_SHADOW_OFFSET) + +#define KASAN_SHADOW_START (KASAN_SHADOW_OFFSET + \ +(PAGE_OFFSET >> KASAN_SHADOW_SCALE_SHIFT)) + +#define KASAN_SHADOW_END 0UL + +#define KASAN_SHADOW_SIZE (KASAN_SHADOW_END - KASAN_SHADOW_START) + +#endif /* __ASSEMBLY */ #endif diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index f6787f90e158..4e7fa4eb2dd3 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -309,6 +309,10 @@ void __init mem_init(void) mem_init_print_info(NULL); #ifdef CONFIG_PPC32 pr_info("Kernel virtual memory layout:\n"); +#ifdef CONFIG_KASAN + pr_info(" * 0x%08lx..0x%08lx : kasan shadow mem\n", + KASAN_SHADOW_START, KASAN_SHADOW_END); +#endif pr_info(" * 0x%08lx..0x%08lx : fixmap\n", FIXADDR_START, FIXADDR_TOP); #ifdef CONFIG_HIGHMEM pr_info(" * 0x%08lx..0x%08lx : highmem PTEs\n", diff --git a/arch/powerpc/mm/ptdump/ptdump.c b/arch/powerpc/mm/ptdump/ptdump.c index 37138428ab55..812ed680024f 100644 --- a/arch/powerpc/mm/ptdump/ptdump.c +++ b/arch/powerpc/mm/ptdump/ptdump.c @@ -101,6 +101,10 @@ static struct addr_marker address_markers[] = { { 0,"Fixmap start" }, { 0,"Fixmap end" }, #endif +#ifdef CONFIG_KASAN + { 0,"kasan shadow mem start" }, + { 0,"kasan shadow mem end" }, +#endif { -1, NULL }, }; @@ -322,6 +326,10 @@ static void populate_markers(void) #endif address_markers[i++].start_address = FIXADDR_START; address_markers[i++].start_address = FIXADDR_TOP; +#ifdef CONFIG_KASAN + address_markers[i++].start_address = KASAN_SHADOW_START; + address_markers[i++].start_address = KASAN_SHADOW_END; +#endif #endif /* CONFIG_PPC64 */ } -- 2.13.3
[PATCH v8 03/11] powerpc/prom_init: don't use string functions from lib/
When KASAN is active, the string functions in lib/ are doing the KASAN checks. This is too early for prom_init. This patch implements dedicated string functions for prom_init, which will be compiled in with KASAN disabled. Size of prom_init before the patch: textdata bss dec hex filename 12060 4886960 195084c34 arch/powerpc/kernel/prom_init.o Size of prom_init after the patch: textdata bss dec hex filename 12460 4886960 199084dc4 arch/powerpc/kernel/prom_init.o This increases the size of prom_init a bit, but as prom_init is in __init section, it is freed after boot anyway. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/prom_init.c| 213 ++--- arch/powerpc/kernel/prom_init_check.sh | 2 +- 2 files changed, 173 insertions(+), 42 deletions(-) diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c index f33ff4163a51..56d5639ab082 100644 --- a/arch/powerpc/kernel/prom_init.c +++ b/arch/powerpc/kernel/prom_init.c @@ -224,6 +224,137 @@ static bool __prombss rtas_has_query_cpu_stopped; #define PHANDLE_VALID(p) ((p) != 0 && (p) != PROM_ERROR) #define IHANDLE_VALID(i) ((i) != 0 && (i) != PROM_ERROR) +/* Copied from lib/string.c and lib/kstrtox.c */ + +static int __init prom_strcmp(const char *cs, const char *ct) +{ + unsigned char c1, c2; + + while (1) { + c1 = *cs++; + c2 = *ct++; + if (c1 != c2) + return c1 < c2 ? -1 : 1; + if (!c1) + break; + } + return 0; +} + +static char __init *prom_strcpy(char *dest, const char *src) +{ + char *tmp = dest; + + while ((*dest++ = *src++) != '\0') + /* nothing */; + return tmp; +} + +static int __init prom_strncmp(const char *cs, const char *ct, size_t count) +{ + unsigned char c1, c2; + + while (count) { + c1 = *cs++; + c2 = *ct++; + if (c1 != c2) + return c1 < c2 ? -1 : 1; + if (!c1) + break; + count--; + } + return 0; +} + +static size_t __init prom_strlen(const char *s) +{ + const char *sc; + + for (sc = s; *sc != '\0'; ++sc) + /* nothing */; + return sc - s; +} + +static int __init prom_memcmp(const void *cs, const void *ct, size_t count) +{ + const unsigned char *su1, *su2; + int res = 0; + + for (su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--) + if ((res = *su1 - *su2) != 0) + break; + return res; +} + +static char __init *prom_strstr(const char *s1, const char *s2) +{ + size_t l1, l2; + + l2 = prom_strlen(s2); + if (!l2) + return (char *)s1; + l1 = prom_strlen(s1); + while (l1 >= l2) { + l1--; + if (!prom_memcmp(s1, s2, l2)) + return (char *)s1; + s1++; + } + return NULL; +} + +#ifdef CONFIG_CMDLINE +static size_t __init prom_strlcpy(char *dest, const char *src, size_t size) +{ + size_t ret = prom_strlen(src); + + if (size) { + size_t len = (ret >= size) ? size - 1 : ret; + memcpy(dest, src, len); + dest[len] = '\0'; + } + return ret; +} +#endif + +#ifdef CONFIG_PPC_PSERIES +static int __init prom_strtobool(const char *s, bool *res) +{ + if (!s) + return -EINVAL; + + switch (s[0]) { + case 'y': + case 'Y': + case '1': + *res = true; + return 0; + case 'n': + case 'N': + case '0': + *res = false; + return 0; + case 'o': + case 'O': + switch (s[1]) { + case 'n': + case 'N': + *res = true; + return 0; + case 'f': + case 'F': + *res = false; + return 0; + default: + break; + } + default: + break; + } + + return -EINVAL; +} +#endif /* This is the one and *ONLY* place where we actually call open * firmware. @@ -555,7 +686,7 @@ static int __init prom_setprop(phandle node, const char *nodename, add_string(, tohex((u32)(unsigned long) value)); add_string(, tohex(valuelen)); add_string(, tohex(ADDR(pname))); - add_string(, tohex(strlen(pname))); + add_string(, tohex(prom_strlen(pname))); add_string(, "property"); *p = 0; return call_prom("interpret", 1, 1, (u32)(unsigned long) cmd); @@ -639,25 +770,25 @@ static void __init early_cmdline_parse(void) l = prom_getprop(prom.chosen, "bootargs", p,
[PATCH v8 01/11] powerpc/32: Move early_init() in a separate file
In preparation of KASAN, move early_init() into a separate file in order to allow deactivation of KASAN for that function. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/Makefile | 2 +- arch/powerpc/kernel/early_32.c | 36 arch/powerpc/kernel/setup_32.c | 28 3 files changed, 37 insertions(+), 29 deletions(-) create mode 100644 arch/powerpc/kernel/early_32.c diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index cddadccf551d..45e47752b692 100644 --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile @@ -93,7 +93,7 @@ extra-y += vmlinux.lds obj-$(CONFIG_RELOCATABLE) += reloc_$(BITS).o -obj-$(CONFIG_PPC32)+= entry_32.o setup_32.o +obj-$(CONFIG_PPC32)+= entry_32.o setup_32.o early_32.o obj-$(CONFIG_PPC64)+= dma-iommu.o iommu.o obj-$(CONFIG_KGDB) += kgdb.o obj-$(CONFIG_BOOTX_TEXT) += btext.o diff --git a/arch/powerpc/kernel/early_32.c b/arch/powerpc/kernel/early_32.c new file mode 100644 index ..cf3cdd81dc47 --- /dev/null +++ b/arch/powerpc/kernel/early_32.c @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * Early init before relocation + */ + +#include +#include +#include +#include +#include + +/* + * We're called here very early in the boot. + * + * Note that the kernel may be running at an address which is different + * from the address that it was linked at, so we must use RELOC/PTRRELOC + * to access static data (including strings). -- paulus + */ +notrace unsigned long __init early_init(unsigned long dt_ptr) +{ + unsigned long offset = reloc_offset(); + + /* First zero the BSS -- use memset_io, some platforms don't have caches on yet */ + memset_io((void __iomem *)PTRRELOC(&__bss_start), 0, __bss_stop - __bss_start); + + /* +* Identify the CPU type and fix up code sections +* that depend on which cpu we have. +*/ + identify_cpu(offset, mfspr(SPRN_PVR)); + + apply_feature_fixups(); + + return KERNELBASE + offset; +} diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index 1f0b7629c1a6..3f0d51b4b2f5 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c @@ -63,34 +63,6 @@ EXPORT_SYMBOL(DMA_MODE_READ); EXPORT_SYMBOL(DMA_MODE_WRITE); /* - * We're called here very early in the boot. - * - * Note that the kernel may be running at an address which is different - * from the address that it was linked at, so we must use RELOC/PTRRELOC - * to access static data (including strings). -- paulus - */ -notrace unsigned long __init early_init(unsigned long dt_ptr) -{ - unsigned long offset = reloc_offset(); - - /* First zero the BSS -- use memset_io, some platforms don't have -* caches on yet */ - memset_io((void __iomem *)PTRRELOC(&__bss_start), 0, - __bss_stop - __bss_start); - - /* -* Identify the CPU type and fix up code sections -* that depend on which cpu we have. -*/ - identify_cpu(offset, mfspr(SPRN_PVR)); - - apply_feature_fixups(); - - return KERNELBASE + offset; -} - - -/* * This is run before start_kernel(), the kernel has been relocated * and we are running with enough of the MMU enabled to have our * proper kernel virtual addresses -- 2.13.3
[PATCH v8 02/11] powerpc: prepare string/mem functions for KASAN
CONFIG_KASAN implements wrappers for memcpy() memmove() and memset() Those wrappers are doing the verification then call respectively __memcpy() __memmove() and __memset(). The arches are therefore expected to rename their optimised functions that way. For files on which KASAN is inhibited, #defines are used to allow them to directly call optimised versions of the functions without going through the KASAN wrappers. See commit 393f203f5fd5 ("x86_64: kasan: add interceptors for memset/memmove/memcpy functions") for details. Other string / mem functions do not (yet) have kasan wrappers, we therefore have to fallback to the generic versions when KASAN is active, otherwise KASAN checks will be skipped. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/kasan.h | 15 +++ arch/powerpc/include/asm/string.h | 32 +--- arch/powerpc/kernel/prom_init_check.sh | 10 +- arch/powerpc/lib/Makefile | 11 --- arch/powerpc/lib/copy_32.S | 15 +-- arch/powerpc/lib/mem_64.S | 11 +++ arch/powerpc/lib/memcpy_64.S | 5 +++-- 7 files changed, 80 insertions(+), 19 deletions(-) create mode 100644 arch/powerpc/include/asm/kasan.h diff --git a/arch/powerpc/include/asm/kasan.h b/arch/powerpc/include/asm/kasan.h new file mode 100644 index ..c3161b8fc017 --- /dev/null +++ b/arch/powerpc/include/asm/kasan.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_KASAN_H +#define __ASM_KASAN_H + +#ifdef CONFIG_KASAN +#define _GLOBAL_KASAN(fn) .weak fn ; _GLOBAL(__##fn) ; _GLOBAL(fn) +#define _GLOBAL_TOC_KASAN(fn) .weak fn ; _GLOBAL_TOC(__##fn) ; _GLOBAL_TOC(fn) +#define EXPORT_SYMBOL_KASAN(fn)EXPORT_SYMBOL(__##fn) ; EXPORT_SYMBOL(fn) +#else +#define _GLOBAL_KASAN(fn) _GLOBAL(fn) +#define _GLOBAL_TOC_KASAN(fn) _GLOBAL_TOC(fn) +#define EXPORT_SYMBOL_KASAN(fn)EXPORT_SYMBOL(fn) +#endif + +#endif diff --git a/arch/powerpc/include/asm/string.h b/arch/powerpc/include/asm/string.h index 1647de15a31e..9bf6dffb4090 100644 --- a/arch/powerpc/include/asm/string.h +++ b/arch/powerpc/include/asm/string.h @@ -4,14 +4,17 @@ #ifdef __KERNEL__ +#ifndef CONFIG_KASAN #define __HAVE_ARCH_STRNCPY #define __HAVE_ARCH_STRNCMP +#define __HAVE_ARCH_MEMCHR +#define __HAVE_ARCH_MEMCMP +#define __HAVE_ARCH_MEMSET16 +#endif + #define __HAVE_ARCH_MEMSET #define __HAVE_ARCH_MEMCPY #define __HAVE_ARCH_MEMMOVE -#define __HAVE_ARCH_MEMCMP -#define __HAVE_ARCH_MEMCHR -#define __HAVE_ARCH_MEMSET16 #define __HAVE_ARCH_MEMCPY_FLUSHCACHE extern char * strcpy(char *,const char *); @@ -27,7 +30,27 @@ extern int memcmp(const void *,const void *,__kernel_size_t); extern void * memchr(const void *,int,__kernel_size_t); extern void * memcpy_flushcache(void *,const void *,__kernel_size_t); +void *__memset(void *s, int c, __kernel_size_t count); +void *__memcpy(void *to, const void *from, __kernel_size_t n); +void *__memmove(void *to, const void *from, __kernel_size_t n); + +#if defined(CONFIG_KASAN) && !defined(__SANITIZE_ADDRESS__) +/* + * For files that are not instrumented (e.g. mm/slub.c) we + * should use not instrumented version of mem* functions. + */ +#define memcpy(dst, src, len) __memcpy(dst, src, len) +#define memmove(dst, src, len) __memmove(dst, src, len) +#define memset(s, c, n) __memset(s, c, n) + +#ifndef __NO_FORTIFY +#define __NO_FORTIFY /* FORTIFY_SOURCE uses __builtin_memcpy, etc. */ +#endif + +#endif + #ifdef CONFIG_PPC64 +#ifndef CONFIG_KASAN #define __HAVE_ARCH_MEMSET32 #define __HAVE_ARCH_MEMSET64 @@ -49,8 +72,11 @@ static inline void *memset64(uint64_t *p, uint64_t v, __kernel_size_t n) { return __memset64(p, v, n * 8); } +#endif #else +#ifndef CONFIG_KASAN #define __HAVE_ARCH_STRLEN +#endif extern void *memset16(uint16_t *, uint16_t, __kernel_size_t); #endif diff --git a/arch/powerpc/kernel/prom_init_check.sh b/arch/powerpc/kernel/prom_init_check.sh index 667df97d2595..181fd10008ef 100644 --- a/arch/powerpc/kernel/prom_init_check.sh +++ b/arch/powerpc/kernel/prom_init_check.sh @@ -16,8 +16,16 @@ # If you really need to reference something from prom_init.o add # it to the list below: +grep "^CONFIG_KASAN=y$" .config >/dev/null +if [ $? -eq 0 ] +then + MEM_FUNCS="__memcpy __memset" +else + MEM_FUNCS="memcpy memset" +fi + WHITELIST="add_reloc_offset __bss_start __bss_stop copy_and_flush -_end enter_prom memcpy memset reloc_offset __secondary_hold +_end enter_prom $MEM_FUNCS reloc_offset __secondary_hold __secondary_hold_acknowledge __secondary_hold_spinloop __start strcmp strcpy strlcpy strlen strncmp strstr kstrtobool logo_linux_clut224 reloc_got2 kernstart_addr memstart_addr linux_banner _stext diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile index 79396e184bca..47a4de434c22 100644 --- a/arch/powerpc/lib/Makefile +++ b/arch/powerpc/lib/Makefile @@ -8,9 +8,14 @@
[PATCH v8 00/11] KASAN for powerpc/32
This series adds KASAN support to powerpc/32 Tested on nohash/32 (8xx) and book3s/32 (mpc832x ie 603). Boot tested on qemu mac99 Changes in v8: - Fixed circular issue between pgtable.h and fixmap.h - Added missing includes in ppc64 string files - Fixed kasan string related macro names for ppc64. - Fixed most checkpatch messages - build tested on kisskb (http://kisskb.ellerman.id.au/kisskb/head/6e65827de2fe71d21682dafd9084ed2cc6e06d4f/) Changes in v7: - split in several smaller patches - prom_init now has its own string functions - full deactivation of powerpc-optimised string functions when KASAN is active - shadow area now at a fixed place on very top of kernel virtual space. - Early static hash table for hash book3s/32. - Full support of both inline and outline instrumentation for both hash and nohash ppc32 - Earlier full activation of kasan. Changes in v6: - Fixed oops on module loading (due to access to RO shadow zero area). - Added support for hash book3s/32, thanks to Daniel's patch to differ KASAN activation. - Reworked handling of optimised string functions (dedicated patch for it) - Reordered some files to ease adding of book3e/64 support. Changes in v5: - Added KASAN_SHADOW_OFFSET in Makefile, otherwise we fallback to KASAN_MINIMAL and some stuff like stack instrumentation is not performed - Moved calls to kasan_early_init() in head.S because stack instrumentation in machine_init was performed before the call to kasan_early_init() - Mapping kasan_early_shadow_page RW in kasan_early_init() and remaping RO later in kasan_init() - Allocating a big memblock() for shadow area, falling back to PAGE_SIZE blocks in case of failure. Changes in v4: - Comments from Andrey (DISABLE_BRANCH_PROFILING, Activation of reports) - Proper initialisation of shadow area in kasan_init() - Panic in case Hash table is required. - Added comments in patch one to explain why *t = *s becomes memcpy(t, s, ...) - Call of kasan_init_tags() Changes in v3: - Removed the printk() in kasan_early_init() to avoid build failure (see https://github.com/linuxppc/issues/issues/218) - Added necessary changes in asm/book3s/32/pgtable.h to get it work on powerpc 603 family - Added a few KASAN_SANITIZE_xxx.o := n to successfully boot on powerpc 603 family Changes in v2: - Rebased. - Using __set_pte_at() to build the early table. - Worked around and got rid of the patch adding asm/page.h in asm/pgtable-types.h ==> might be fixed independently but not needed for this serie. Christophe Leroy (11): powerpc/32: Move early_init() in a separate file powerpc: prepare string/mem functions for KASAN powerpc/prom_init: don't use string functions from lib/ powerpc/mm: don't use direct assignation during early boot. powerpc/32: use memset() instead of memset_io() to zero BSS powerpc/32: make KVIRT_TOP dependent on FIXMAP_START powerpc/32: prepare shadow area for KASAN powerpc: disable KASAN instrumentation on early/critical files. powerpc/32: Add KASAN support powerpc/32s: move hash code patching out of MMU_init_hw() powerpc/32s: set up an early static hash table for KASAN. arch/powerpc/Kconfig | 1 + arch/powerpc/Kconfig.debug | 5 + arch/powerpc/include/asm/book3s/32/pgtable.h | 13 +- arch/powerpc/include/asm/fixmap.h| 5 + arch/powerpc/include/asm/kasan.h | 38 + arch/powerpc/include/asm/nohash/32/pgtable.h | 13 +- arch/powerpc/include/asm/string.h| 32 +++- arch/powerpc/kernel/Makefile | 14 +- arch/powerpc/kernel/cputable.c | 13 +- arch/powerpc/kernel/early_32.c | 36 + arch/powerpc/kernel/head_32.S| 46 -- arch/powerpc/kernel/head_40x.S | 3 + arch/powerpc/kernel/head_44x.S | 3 + arch/powerpc/kernel/head_8xx.S | 3 + arch/powerpc/kernel/head_fsl_booke.S | 3 + arch/powerpc/kernel/prom_init.c | 213 +-- arch/powerpc/kernel/prom_init_check.sh | 12 +- arch/powerpc/kernel/setup-common.c | 3 + arch/powerpc/kernel/setup_32.c | 28 arch/powerpc/lib/Makefile| 19 ++- arch/powerpc/lib/copy_32.S | 15 +- arch/powerpc/lib/mem_64.S| 11 +- arch/powerpc/lib/memcpy_64.S | 5 +- arch/powerpc/mm/Makefile | 7 + arch/powerpc/mm/kasan/Makefile | 5 + arch/powerpc/mm/kasan/kasan_init_32.c| 177 ++ arch/powerpc/mm/mem.c| 4 + arch/powerpc/mm/mmu_decl.h | 2 + arch/powerpc/mm/ppc_mmu_32.c | 36 +++-- arch/powerpc/mm/ptdump/ptdump.c | 8 + arch/powerpc/platforms/powermac/Makefile | 6 + arch/powerpc/purgatory/Makefile | 3 + arch/powerpc/xmon/Makefile | 1 + 33 files
[PATCH v8 04/11] powerpc/mm: don't use direct assignation during early boot.
In kernel/cputable.c, explicitly use memcpy() instead of *y = *x; This will allow GCC to replace it with __memcpy() when KASAN is selected. Acked-by: Dmitry Vyukov Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/cputable.c | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c index 1eab54bc6ee9..cd12f362b61f 100644 --- a/arch/powerpc/kernel/cputable.c +++ b/arch/powerpc/kernel/cputable.c @@ -2147,7 +2147,11 @@ void __init set_cur_cpu_spec(struct cpu_spec *s) struct cpu_spec *t = _cpu_spec; t = PTRRELOC(t); - *t = *s; + /* +* use memcpy() instead of *t = *s so that GCC replaces it +* by __memcpy() when KASAN is active +*/ + memcpy(t, s, sizeof(*t)); *PTRRELOC(_cpu_spec) = _cpu_spec; } @@ -2161,8 +2165,11 @@ static struct cpu_spec * __init setup_cpu_spec(unsigned long offset, t = PTRRELOC(t); old = *t; - /* Copy everything, then do fixups */ - *t = *s; + /* +* Copy everything, then do fixups. Use memcpy() instead of *t = *s +* so that GCC replaces it by __memcpy() when KASAN is active +*/ + memcpy(t, s, sizeof(*t)); /* * If we are overriding a previous value derived from the real -- 2.13.3
Re: [PATCH 0/2] x86, numa: always initialize all possible nodes
On Tue 12-02-19 10:53:41, Michal Hocko wrote: > Hi, > this has been posted as an RFC previously [1]. There didn't seem to be > any objections so I am reposting this for inclusion. I have added a > debugging patch which prints the zonelist setup for each numa node > for an easier debugging of a broken zonelist setup. > > [1] http://lkml.kernel.org/r/20190114082416.30939-1-mho...@kernel.org Friendly ping. I haven't heard any complains so can we route this via tip/x86/mm or should we go via mmotm. -- Michal Hocko SUSE Labs
Re: [PATCH V3 1/10] X86/Hyper-V: Add parameter offset for hyperv_fill_flush_guest_mapping_list()
Hi Stephen: Thanks for your review. On Sat, Feb 23, 2019 at 1:08 AM Stephen Hemminger wrote: > > int hyperv_fill_flush_guest_mapping_list( > struct hv_guest_mapping_flush_list *flush, > - u64 start_gfn, u64 pages) > + int offset, u64 start_gfn, u64 pages) > { > u64 cur = start_gfn; > u64 additional_pages; > - int gpa_n = 0; > + int gpa_n = offset; > > do { > /* > > Do you mean to support negative offsets here? Maybe unsigned would be better? Yes, this makes sense. Will update. Thanks. -- Best regards Tianyu Lan
Re: [PATCH v2 11/16] KVM: introduce a 'mmap' method for KVM devices
On 25/02/19 11:57, Cédric Le Goater wrote: > Hello Paolo, > > On 2/25/19 4:33 AM, David Gibson wrote: >> On Fri, Feb 22, 2019 at 12:28:35PM +0100, Cédric Le Goater wrote: >>> Some KVM devices will want to handle special mappings related to the >>> underlying HW. For instance, the XIVE interrupt controller of the >>> POWER9 processor has MMIO pages for thread interrupt management and >>> for interrupt source control that need to be exposed to the guest when >>> the OS has the required support. >>> >>> Signed-off-by: Cédric Le Goater >> >> Ah, when I suggested mmap() on the base device fd, I hadn't realized >> there wasn't a facility for that yet. >> >> Have you discussed this with Paolo? > > Not yet. > >> We'll need some core KVM buy in to merge this. > > Here is an extension of the KVM device to allow special mappings. > Something we would need for the support of the POWER9 XIVE interrupt > controller. > > There are two MMIOs we need to expose to the guest : > > 1. HW MMIO controlling of the interrupt presenter registers (TIMA) > 2. HW MMIO of the interrupt sources for interrupt management (ESB) > > The TIMA could have been exposed with a page offset in the vCPU mapping > but as it only makes sense when the XIVE interrupt mode is active, we > chose to use directly the KVM device fd for that. Is that ok ? > > An alternate solution is to use a device ioctl to allocate an anon fd > and do the mapping, but that seems like extra fuss for the same result. It's okay, it's a natural extension to dev_ops - but thanks for asking anyway. :) Paolo
Re: Re: Kernel panic when loading the IDE controller driver
On 02/14/2019 06:54 PM, Christophe Leroy wrote: > > > Le 13/02/2019 à 16:27, Christophe Leroy a écrit : >> >> >> Le 13/02/2019 à 13:53, sgosavi1 a écrit : Why using 4.15.13 which is obsolete instead of using one of the Long Term Support versions which are still maintained, like 4.14 or 4.19 ? (see the complete list at https://www.kernel.org/category/releases.html) >>> >>> Well, when I started this task 4.15.13 was probably the latest stable >>> release and hence we decided to port this version. In the older kernel, we >>> have the m8260_setup.c source file for our board where the function >>> "io_block_mapping" was used to configure the non-standard IO port address >>> starting at 0xe000 location. This address was passed as the base address >>> followed by control address and IRQ number to the ide-core.ko module. In the >>> new kernel we do not have an option to send these addresses and IRQ numbers >>> as arguments to the driver. Instead the ide-generic.c source file in the new >>> kernel uses the standard IO port values and IRQ values. I modified the code >>> in the above file to used the addresses and IRQ number we used in the past. >>> Also, added code in the "MMU_init" function call available under >>> arch/PowerPC/init_32.c to setup the IO port address range by adding the >>> "io_block_mapping" call and the required IO port address range. >>> >>> Is there anything else that needs to be added or how can we configure the >>> desired IO address range in the new kernel? >>> >> >> Maybe look around >> https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=9a0e77f28b50128df0c9e26ae489e44e29a7270a >> >> Also look at ide_platform.c. I imagine there must be some way to set it up >> in your device tree. Please don't add new users to subsystem deprecated almost 10 years ago.. >> Maybe Bartlomiej Zolnierkiewicz can help ? >> >> Christophe > > Le 14/02/2019 à 09:17, sgosavi1 a écrit :>> Maybe look around >> >> I have gone through this before and also tried the pata_platform driver but >> no success yet. I haven't found any example that passes the IO ports and IRQ >> information through the device tree to the driver code. Please look at pata_of_platform.c driver from libata subsystem, it should have all required functionality. >> Thanks, >> Sachin. > > > Maybe someone from the IDE SUBSYSTEM would be able to help better ? > > Entire thread at > http://linuxppc.10917.n7.nabble.com/Kernel-panic-when-loading-the-IDE-controller-driver-td150020.html#none > > Christophe Best regards, -- Bartlomiej Zolnierkiewicz Samsung R Institute Poland Samsung Electronics
[PATCH v1 4/4] clk: qoriq: Add clockgen support for lx2160a
From: Yogesh Gaur Add clockgen support for lx2160a. Added entry for compat 'fsl,lx2160a-clockgen'. Signed-off-by: Tang Yuantian Signed-off-by: Yogesh Gaur Signed-off-by: Vabhav Sharma Acked-by: Stephen Boyd Acked-by: Viresh Kumar --- drivers/clk/clk-qoriq.c | 12 drivers/cpufreq/qoriq-cpufreq.c | 1 + 2 files changed, 13 insertions(+) diff --git a/drivers/clk/clk-qoriq.c b/drivers/clk/clk-qoriq.c index e75194a..288e8f0c 100644 --- a/drivers/clk/clk-qoriq.c +++ b/drivers/clk/clk-qoriq.c @@ -570,6 +570,17 @@ static const struct clockgen_chipinfo chipinfo[] = { .flags = CG_VER3 | CG_LITTLE_ENDIAN, }, { + .compat = "fsl,lx2160a-clockgen", + .cmux_groups = { + _cmux_cga12, _cmux_cgb + }, + .cmux_to_group = { + 0, 0, 0, 0, 1, 1, 1, 1, -1 + }, + .pll_mask = 0x37, + .flags = CG_VER3 | CG_LITTLE_ENDIAN, + }, + { .compat = "fsl,p2041-clockgen", .guts_compat = "fsl,qoriq-device-config-1.0", .init_periph = p2041_init_periph, @@ -1426,6 +1437,7 @@ CLK_OF_DECLARE(qoriq_clockgen_ls1043a, "fsl,ls1043a-clockgen", clockgen_init); CLK_OF_DECLARE(qoriq_clockgen_ls1046a, "fsl,ls1046a-clockgen", clockgen_init); CLK_OF_DECLARE(qoriq_clockgen_ls1088a, "fsl,ls1088a-clockgen", clockgen_init); CLK_OF_DECLARE(qoriq_clockgen_ls2080a, "fsl,ls2080a-clockgen", clockgen_init); +CLK_OF_DECLARE(qoriq_clockgen_lx2160a, "fsl,lx2160a-clockgen", clockgen_init); CLK_OF_DECLARE(qoriq_clockgen_p2041, "fsl,p2041-clockgen", clockgen_init); CLK_OF_DECLARE(qoriq_clockgen_p3041, "fsl,p3041-clockgen", clockgen_init); CLK_OF_DECLARE(qoriq_clockgen_p4080, "fsl,p4080-clockgen", clockgen_init); diff --git a/drivers/cpufreq/qoriq-cpufreq.c b/drivers/cpufreq/qoriq-cpufreq.c index 3d773f6..83921b7 100644 --- a/drivers/cpufreq/qoriq-cpufreq.c +++ b/drivers/cpufreq/qoriq-cpufreq.c @@ -295,6 +295,7 @@ static const struct of_device_id node_matches[] __initconst = { { .compatible = "fsl,ls1046a-clockgen", }, { .compatible = "fsl,ls1088a-clockgen", }, { .compatible = "fsl,ls2080a-clockgen", }, + { .compatible = "fsl,lx2160a-clockgen", }, { .compatible = "fsl,p4080-clockgen", }, { .compatible = "fsl,qoriq-clockgen-1.0", }, { .compatible = "fsl,qoriq-clockgen-2.0", }, -- 2.7.4
[PATCH v1 3/4] clk: qoriq: increase array size of cmux_to_group
From: Yogesh Gaur Increase size of cmux_to_group array, to accomdate entry of -1 termination. Added -1, terminated, entry for 4080_cmux_grpX. Signed-off-by: Yogesh Gaur Signed-off-by: Vabhav Sharma Acked-by: Stephen Boyd --- drivers/clk/clk-qoriq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk-qoriq.c b/drivers/clk/clk-qoriq.c index 5baa9e0..e75194a 100644 --- a/drivers/clk/clk-qoriq.c +++ b/drivers/clk/clk-qoriq.c @@ -79,7 +79,7 @@ struct clockgen_chipinfo { const struct clockgen_muxinfo *cmux_groups[2]; const struct clockgen_muxinfo *hwaccel[NUM_HWACCEL]; void (*init_periph)(struct clockgen *cg); - int cmux_to_group[NUM_CMUX]; /* -1 terminates if fewer than NUM_CMUX */ + int cmux_to_group[NUM_CMUX+1]; /* array should be -1 terminated */ u32 pll_mask; /* 1 << n bit set if PLL n is valid */ u32 flags; /* CG_xxx */ }; @@ -601,7 +601,7 @@ static const struct clockgen_chipinfo chipinfo[] = { _cmux_grp1, _cmux_grp2 }, .cmux_to_group = { - 0, 0, 0, 0, 1, 1, 1, 1 + 0, 0, 0, 0, 1, 1, 1, 1, -1 }, .pll_mask = 0x1f, }, -- 2.7.4
[PATCH v1 2/4] soc/fsl/guts: Add definition for LX2160A
Adding compatible string "lx2160a-dcfg" to initialize guts driver for lx2160 and SoC die attribute definition for LX2160A Signed-off-by: Vabhav Sharma Signed-off-by: Yinbo Zhu Acked-by: Li Yang --- drivers/soc/fsl/guts.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c index 302e0c8..bcab1ee 100644 --- a/drivers/soc/fsl/guts.c +++ b/drivers/soc/fsl/guts.c @@ -100,6 +100,11 @@ static const struct fsl_soc_die_attr fsl_soc_die[] = { .svr = 0x8700, .mask = 0xfff7, }, + /* Die: LX2160A, SoC: LX2160A/LX2120A/LX2080A */ + { .die = "LX2160A", + .svr = 0x8736, + .mask = 0xff3f, + }, { }, }; @@ -222,6 +227,7 @@ static const struct of_device_id fsl_guts_of_match[] = { { .compatible = "fsl,ls1088a-dcfg", }, { .compatible = "fsl,ls1012a-dcfg", }, { .compatible = "fsl,ls1046a-dcfg", }, + { .compatible = "fsl,lx2160a-dcfg", }, {} }; MODULE_DEVICE_TABLE(of, fsl_guts_of_match); -- 2.7.4
[PATCH v1 1/4] dt-bindings: arm64: add compatible for LX2160A
Add compatible for LX2160A SoC,QDS and RDB board Add lx2160a compatible for clockgen and dcfg Signed-off-by: Vabhav Sharma Reviewed-by: Rob Herring --- .../bindings/arm/freescale/fsl,layerscape-dcfg.txt | 2 +- Documentation/devicetree/bindings/arm/fsl.txt| 12 Documentation/devicetree/bindings/clock/qoriq-clock.txt | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/arm/freescale/fsl,layerscape-dcfg.txt b/Documentation/devicetree/bindings/arm/freescale/fsl,layerscape-dcfg.txt index b5cb374..dc76046 100644 --- a/Documentation/devicetree/bindings/arm/freescale/fsl,layerscape-dcfg.txt +++ b/Documentation/devicetree/bindings/arm/freescale/fsl,layerscape-dcfg.txt @@ -8,7 +8,7 @@ Required properties: - compatible: Should contain a chip-specific compatible string, Chip-specific strings are of the form "fsl,-dcfg", The following s are known to be supported: - ls1012a, ls1021a, ls1043a, ls1046a, ls2080a. + ls1012a, ls1021a, ls1043a, ls1046a, ls2080a, lx2160a. - reg : should contain base address and length of DCFG memory-mapped registers diff --git a/Documentation/devicetree/bindings/arm/fsl.txt b/Documentation/devicetree/bindings/arm/fsl.txt index 7fbc424..baef162 100644 --- a/Documentation/devicetree/bindings/arm/fsl.txt +++ b/Documentation/devicetree/bindings/arm/fsl.txt @@ -235,3 +235,15 @@ Required root node properties: LS2088A ARMv8 based RDB Board Required root node properties: - compatible = "fsl,ls2088a-rdb", "fsl,ls2088a"; + +LX2160A SoC +Required root node properties: +- compatible = "fsl,lx2160a"; + +LX2160A ARMv8 based QDS Board +Required root node properties: +- compatible = "fsl,lx2160a-qds", "fsl,lx2160a"; + +LX2160A ARMv8 based RDB Board +Required root node properties: +- compatible = "fsl,lx2160a-rdb", "fsl,lx2160a"; diff --git a/Documentation/devicetree/bindings/clock/qoriq-clock.txt b/Documentation/devicetree/bindings/clock/qoriq-clock.txt index c655f28..f322989 100644 --- a/Documentation/devicetree/bindings/clock/qoriq-clock.txt +++ b/Documentation/devicetree/bindings/clock/qoriq-clock.txt @@ -43,6 +43,7 @@ Required properties: * "fsl,ls1046a-clockgen" * "fsl,ls1088a-clockgen" * "fsl,ls2080a-clockgen" + * "fsl,lx2160a-clockgen" Chassis-version clock strings include: * "fsl,qoriq-clockgen-1.0": for chassis 1.0 clocks * "fsl,qoriq-clockgen-2.0": for chassis 2.0 clocks -- 2.7.4
[PATCH v1 0/4] arm64: dts: NXP: add basic dts file for LX2160A SoC
These patches were reviewed and acked but dropped during merge window. Patchwork link was https://lore.kernel.org/patchwork/cover/1004155/ Changes for v1: - Updated lx2160a clockgen in alphabetical order Vabhav Sharma (2): dt-bindings: arm64: add compatible for LX2160A soc/fsl/guts: Add definition for LX2160A Yogesh Gaur (2): clk: qoriq: increase array size of cmux_to_group clk: qoriq: Add clockgen support for lx2160a .../bindings/arm/freescale/fsl,layerscape-dcfg.txt | 2 +- Documentation/devicetree/bindings/arm/fsl.txt| 12 Documentation/devicetree/bindings/clock/qoriq-clock.txt | 1 + drivers/clk/clk-qoriq.c | 16 ++-- drivers/cpufreq/qoriq-cpufreq.c | 1 + drivers/soc/fsl/guts.c | 6 ++ 6 files changed, 35 insertions(+), 3 deletions(-) -- 2.7.4
RE: [PATCH 4/4] clk: qoriq: Add clockgen support for lx2160a
> -Original Message- > From: Scott Wood > Sent: Tuesday, February 26, 2019 3:15 PM > To: Vabhav Sharma ; sudeep.ho...@arm.com; > linux-ker...@vger.kernel.org; devicet...@vger.kernel.org; > robh...@kernel.org; mark.rutl...@arm.com; linuxppc-dev@lists.ozlabs.org; > linux-arm-ker...@lists.infradead.org; mturque...@baylibre.com; > sb...@kernel.org; r...@rjwysocki.net; viresh.ku...@linaro.org; linux- > c...@vger.kernel.org; linux...@vger.kernel.org; linux-kernel- > ow...@vger.kernel.org; catalin.mari...@arm.com; will.dea...@arm.com; > gre...@linuxfoundation.org; a...@arndb.de; > kstew...@linuxfoundation.org; yamada.masah...@socionext.com; Leo Li > ; shawn...@kernel.org > Cc: li...@armlinux.org.uk; adrian.hun...@intel.com; > ulf.hans...@linaro.org; Yogesh Narayan Gaur > ; Andy Tang > Subject: Re: [PATCH 4/4] clk: qoriq: Add clockgen support for lx2160a > > On Tue, 2019-02-26 at 08:34 +, Vabhav Sharma wrote: > > @@ -1435,6 +1446,7 @@ CLK_OF_DECLARE(qoriq_clockgen_t1023, > "fsl,t1023- > > clockgen", clockgen_init); CLK_OF_DECLARE(qoriq_clockgen_t1040, > > "fsl,t1040-clockgen", clockgen_init); > > CLK_OF_DECLARE(qoriq_clockgen_t2080, "fsl,t2080-clockgen", > > clockgen_init); CLK_OF_DECLARE(qoriq_clockgen_t4240, > > "fsl,t4240-clockgen", clockgen_init); > > +CLK_OF_DECLARE(qoriq_clockgen_lx2160a, "fsl,lx2160a-clockgen", > > clockgen_init); > > The chips were previously in alphabetical order... Ok > > -Scott >
Re: build failure of current mmotm with skiroot_defconfig
On Tue, Feb 26, 2019 at 10:39:54AM +0100, Christophe Leroy wrote: > > > Le 26/02/2019 à 09:12, Mike Rapoport a écrit : > >Hi, > > > >I've encountered the following error when building skyroot_defconfig with > >current mmotm tree: > > > >make CONFIG_OF_ALL_DTBS=y CONFIG_DTC=y > >CROSS_COMPILE=/opt/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux- > >ARCH=powerpc vmlinux > > ... > > CC arch/powerpc/kernel/dbell.o > >In file included from arch/powerpc/kernel/dbell.c:20: > >arch/powerpc/include/asm/kvm_ppc.h: In function 'xics_on_xive': > >arch/powerpc/include/asm/kvm_ppc.h:625:9: error: implicit declaration of > >function 'xive_enabled'; did you mean 'eeh_enabled'? > >[-Werror=implicit-function-declaration] > > return xive_enabled() && cpu_has_feature(CPU_FTR_HVMODE); > > ^~~~ > > eeh_enabled > > I can neither find the above in arch/powerpc/include/asm/kvm_ppc.h in the > powerpc tree, nor a patch removing it. > > Where does that comes from ? It's from current mmotm, probably some merge conflict... > Christophe > > >cc1: all warnings being treated as errors > >scripts/Makefile.build:278: recipe for target 'arch/powerpc/kernel/dbell.o' > >failed > >make[3]: *** [arch/powerpc/kernel/dbell.o] Error 1 > >scripts/Makefile.build:493: recipe for target 'arch/powerpc/kernel' failed > >make[2]: *** [arch/powerpc/kernel] Error 2 > >Makefile:1049: recipe for target 'arch/powerpc' failed > >make[1]: *** [arch/powerpc] Error 2 > > > > > -- Sincerely yours, Mike.
Re: [PATCH 4/4] clk: qoriq: Add clockgen support for lx2160a
On Tue, 2019-02-26 at 08:34 +, Vabhav Sharma wrote: > @@ -1435,6 +1446,7 @@ CLK_OF_DECLARE(qoriq_clockgen_t1023, "fsl,t1023- > clockgen", clockgen_init); > CLK_OF_DECLARE(qoriq_clockgen_t1040, "fsl,t1040-clockgen", clockgen_init); > CLK_OF_DECLARE(qoriq_clockgen_t2080, "fsl,t2080-clockgen", clockgen_init); > CLK_OF_DECLARE(qoriq_clockgen_t4240, "fsl,t4240-clockgen", clockgen_init); > +CLK_OF_DECLARE(qoriq_clockgen_lx2160a, "fsl,lx2160a-clockgen", > clockgen_init); The chips were previously in alphabetical order... -Scott
Re: build failure of current mmotm with skiroot_defconfig
Le 26/02/2019 à 09:12, Mike Rapoport a écrit : Hi, I've encountered the following error when building skyroot_defconfig with current mmotm tree: make CONFIG_OF_ALL_DTBS=y CONFIG_DTC=y CROSS_COMPILE=/opt/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux- ARCH=powerpc vmlinux ... CC arch/powerpc/kernel/dbell.o In file included from arch/powerpc/kernel/dbell.c:20: arch/powerpc/include/asm/kvm_ppc.h: In function 'xics_on_xive': arch/powerpc/include/asm/kvm_ppc.h:625:9: error: implicit declaration of function 'xive_enabled'; did you mean 'eeh_enabled'? [-Werror=implicit-function-declaration] return xive_enabled() && cpu_has_feature(CPU_FTR_HVMODE); ^~~~ eeh_enabled I can neither find the above in arch/powerpc/include/asm/kvm_ppc.h in the powerpc tree, nor a patch removing it. Where does that comes from ? Christophe cc1: all warnings being treated as errors scripts/Makefile.build:278: recipe for target 'arch/powerpc/kernel/dbell.o' failed make[3]: *** [arch/powerpc/kernel/dbell.o] Error 1 scripts/Makefile.build:493: recipe for target 'arch/powerpc/kernel' failed make[2]: *** [arch/powerpc/kernel] Error 2 Makefile:1049: recipe for target 'arch/powerpc' failed make[1]: *** [arch/powerpc] Error 2
[PATCH] powerpc/powernv: move OPAL call wrapper tracing and interrupt handling to C
The OPAL call wrapper gets interrupt disabling wrong. It disables interrupts just by clearing MSR[EE], which has two problems: - It doesn't call into the IRQ tracing subsystem, which means tracing across OPAL calls does not always notice IRQs have been disabled. - It doesn't go through the IRQ soft-mask code, which causes a minor bug. MSR[EE] can not be restored by saving the MSR then clearing MSR[EE], because a racing interrupt while soft-masked could clear MSR[EE] between the two steps. This can cause MSR[EE] to be incorrectly enabled when the OPAL call returns. Fortunately that should only result in another masked interrupt being taken to disable MSR[EE] again, but it's a bit sloppy. The existing code also saves MSR to PACA, which is not re-entrant if there is a nested OPAL call from different MSR contexts, which can happen these days with SRESET interrupts on bare metal. To fix these issues, move the tracing and IRQ handling code to C, and call into asm just for the low level call when everything is ready to go. Save the MSR on stack rather than PACA. Performance cost is kept to a minimum with a few optimisations: - The endian switch upon return is combined with the MSR restore, which avoids an expensive context synchronizing operation for LE kernels. This makes up for the additional mtmsrd to enable interrupts with local_irq_enable(). - blr is now used to return from the opal_* functions that are called as C functions, to avoid link stack corruption. This requires a skiboot fix as well to keep the call stack balanced. A NULL call is more costly after this, (410ns->430ns on POWER9), but OPAL calls are generally not performance critical at this scale. Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/asm-prototypes.h | 10 +- arch/powerpc/platforms/powernv/Makefile | 5 +- arch/powerpc/platforms/powernv/opal-call.c| 283 +++ .../powerpc/platforms/powernv/opal-wrappers.S | 343 ++ 4 files changed, 328 insertions(+), 313 deletions(-) create mode 100644 arch/powerpc/platforms/powernv/opal-call.c diff --git a/arch/powerpc/include/asm/asm-prototypes.h b/arch/powerpc/include/asm/asm-prototypes.h index 1d911f68a23b..6c67b4bef854 100644 --- a/arch/powerpc/include/asm/asm-prototypes.h +++ b/arch/powerpc/include/asm/asm-prototypes.h @@ -37,13 +37,11 @@ void kexec_copy_flush(struct kimage *image); extern struct static_key hcall_tracepoint_key; void __trace_hcall_entry(unsigned long opcode, unsigned long *args); void __trace_hcall_exit(long opcode, long retval, unsigned long *retbuf); -/* OPAL tracing */ -#ifdef CONFIG_JUMP_LABEL -extern struct static_key opal_tracepoint_key; -#endif -void __trace_opal_entry(unsigned long opcode, unsigned long *args); -void __trace_opal_exit(long opcode, unsigned long retval); +/* OPAL */ +int64_t __opal_call(int64_t a0, int64_t a1, int64_t a2, int64_t a3, + int64_t a4, int64_t a5, int64_t a6, int64_t a7, + int64_t opcode, uint64_t msr); /* VMX copying */ int enter_vmx_usercopy(void); diff --git a/arch/powerpc/platforms/powernv/Makefile b/arch/powerpc/platforms/powernv/Makefile index b540ce8eec55..da2e99efbd04 100644 --- a/arch/powerpc/platforms/powernv/Makefile +++ b/arch/powerpc/platforms/powernv/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 -obj-y += setup.o opal-wrappers.o opal.o opal-async.o idle.o -obj-y += opal-rtc.o opal-nvram.o opal-lpc.o opal-flash.o +obj-y += setup.o opal-call.o opal-wrappers.o opal.o opal-async.o +obj-y += idle.o opal-rtc.o opal-nvram.o opal-lpc.o opal-flash.o obj-y += rng.o opal-elog.o opal-dump.o opal-sysparam.o opal-sensor.o obj-y += opal-msglog.o opal-hmi.o opal-power.o opal-irqchip.o obj-y += opal-kmsg.o opal-powercap.o opal-psr.o opal-sensor-groups.o @@ -11,7 +11,6 @@ obj-$(CONFIG_CXL_BASE)+= pci-cxl.o obj-$(CONFIG_EEH) += eeh-powernv.o obj-$(CONFIG_PPC_SCOM) += opal-xscom.o obj-$(CONFIG_MEMORY_FAILURE) += opal-memory-errors.o -obj-$(CONFIG_TRACEPOINTS) += opal-tracepoints.o obj-$(CONFIG_OPAL_PRD) += opal-prd.o obj-$(CONFIG_PERF_EVENTS) += opal-imc.o obj-$(CONFIG_PPC_MEMTRACE) += memtrace.o diff --git a/arch/powerpc/platforms/powernv/opal-call.c b/arch/powerpc/platforms/powernv/opal-call.c new file mode 100644 index ..578757d403ab --- /dev/null +++ b/arch/powerpc/platforms/powernv/opal-call.c @@ -0,0 +1,283 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include +#include +#include + +#ifdef CONFIG_TRACEPOINTS +/* + * Since the tracing code might execute OPAL calls we need to guard against + * recursion. + */ +static DEFINE_PER_CPU(unsigned int, opal_trace_depth); + +static void __trace_opal_entry(s64 a0, s64 a1, s64 a2, s64 a3, + s64 a4, s64 a5, s64 a6, s64 a7, +
[PATCH v4 4/4] powerpc/64s: Fix data interrupts vs d-side MCE reentrancy
Handlers for interrupts that set DAR / DSISR, set MSR[RI] before those SPRs are read. If a d-side machine check hits in this window, DAR / DSISR will be clobbered silently, leading to random corruption. Fix this by having handlers save those registers before setting MSR[RI]. Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/exceptions-64s.S | 36 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index 0b8b57597837..0e6f274788dd 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -582,12 +582,25 @@ EXC_REAL_END(data_access, 0x300, 0x80) TRAMP_REAL_BEGIN(tramp_real_data_access) EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_PR, 0x300) + /* +* DAR/DSISR must be read before setting MSR[RI], because +* a d-side MCE will clobber those registers so is not +* recoverable if they are live. +*/ + mfspr r10,SPRN_DAR + mfspr r11,SPRN_DSISR + std r10,PACA_EXGEN+EX_DAR(r13) + stw r11,PACA_EXGEN+EX_DSISR(r13) EXCEPTION_PROLOG_2(data_access_common, EXC_STD) EXC_VIRT_BEGIN(data_access, 0x4300, 0x80) SET_SCRATCH0(r13) /* save r13 */ EXCEPTION_PROLOG_0(PACA_EXGEN) EXCEPTION_PROLOG_1(PACA_EXGEN, NOTEST, 0x300) + mfspr r10,SPRN_DAR + mfspr r11,SPRN_DSISR + std r10,PACA_EXGEN+EX_DAR(r13) + stw r11,PACA_EXGEN+EX_DSISR(r13) EXCEPTION_PROLOG_2_RELON(data_access_common, EXC_STD) EXC_VIRT_END(data_access, 0x4300, 0x80) @@ -598,11 +611,8 @@ EXC_COMMON_BEGIN(data_access_common) * Here r13 points to the paca, r9 contains the saved CR, * SRR0 and SRR1 are saved in r11 and r12, * r9 - r13 are saved in paca->exgen. +* EX_DAR and EX_DSISR have saved DAR/DSISR */ - mfspr r10,SPRN_DAR - std r10,PACA_EXGEN+EX_DAR(r13) - mfspr r10,SPRN_DSISR - stw r10,PACA_EXGEN+EX_DSISR(r13) EXCEPTION_PROLOG_COMMON(0x300, PACA_EXGEN) RECONCILE_IRQ_STATE(r10, r11) ld r12,_MSR(r1) @@ -626,20 +636,22 @@ EXC_REAL_END(data_access_slb, 0x380, 0x80) TRAMP_REAL_BEGIN(tramp_real_data_access_slb) EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST_PR, 0x380) + mfspr r10,SPRN_DAR + std r10,PACA_EXSLB+EX_DAR(r13) EXCEPTION_PROLOG_2(data_access_slb_common, EXC_STD) EXC_VIRT_BEGIN(data_access_slb, 0x4380, 0x80) SET_SCRATCH0(r13) /* save r13 */ EXCEPTION_PROLOG_0(PACA_EXSLB) EXCEPTION_PROLOG_1(PACA_EXSLB, NOTEST, 0x380) + mfspr r10,SPRN_DAR + std r10,PACA_EXSLB+EX_DAR(r13) EXCEPTION_PROLOG_2_RELON(data_access_slb_common, EXC_STD) EXC_VIRT_END(data_access_slb, 0x4380, 0x80) TRAMP_KVM_SKIP(PACA_EXSLB, 0x380) EXC_COMMON_BEGIN(data_access_slb_common) - mfspr r10,SPRN_DAR - std r10,PACA_EXSLB+EX_DAR(r13) EXCEPTION_PROLOG_COMMON(0x380, PACA_EXSLB) ld r4,PACA_EXSLB+EX_DAR(r13) std r4,_DAR(r1) @@ -739,6 +751,10 @@ EXC_REAL_BEGIN(alignment, 0x600, 0x100) SET_SCRATCH0(r13) /* save r13 */ EXCEPTION_PROLOG_0(PACA_EXGEN) EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_PR, 0x600) + mfspr r10,SPRN_DAR + mfspr r11,SPRN_DSISR + std r10,PACA_EXGEN+EX_DAR(r13) + stw r11,PACA_EXGEN+EX_DSISR(r13) EXCEPTION_PROLOG_2(alignment_common, EXC_STD) EXC_REAL_END(alignment, 0x600, 0x100) @@ -746,15 +762,15 @@ EXC_VIRT_BEGIN(alignment, 0x4600, 0x100) SET_SCRATCH0(r13) /* save r13 */ EXCEPTION_PROLOG_0(PACA_EXGEN) EXCEPTION_PROLOG_1(PACA_EXGEN, NOTEST, 0x600) + mfspr r10,SPRN_DAR + mfspr r11,SPRN_DSISR + std r10,PACA_EXGEN+EX_DAR(r13) + stw r11,PACA_EXGEN+EX_DSISR(r13) EXCEPTION_PROLOG_2_RELON(alignment_common, EXC_STD) EXC_VIRT_END(alignment, 0x4600, 0x100) TRAMP_KVM(PACA_EXGEN, 0x600) EXC_COMMON_BEGIN(alignment_common) - mfspr r10,SPRN_DAR - std r10,PACA_EXGEN+EX_DAR(r13) - mfspr r10,SPRN_DSISR - stw r10,PACA_EXGEN+EX_DSISR(r13) EXCEPTION_PROLOG_COMMON(0x600, PACA_EXGEN) ld r3,PACA_EXGEN+EX_DAR(r13) lwz r4,PACA_EXGEN+EX_DSISR(r13) -- 2.18.0
[PATCH v4 3/4] powerpc/64s: Prepare to handle data interrupts vs d-side MCE reentrancy
A subsequent fix for data interrupts (those that set DAR / DSISR) requires some interrupt macros to be open-coded, and also requires the 0x300 interrupt handler to be moved out-of-line. This patch does that without changing behaviour, which makes the later fix a smaller change. Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/exceptions-64s.S | 48 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index d2e9fc968655..0b8b57597837 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -574,8 +574,23 @@ EXC_COMMON_BEGIN(mce_return) RFI_TO_KERNEL b . -EXC_REAL(data_access, 0x300, 0x80) -EXC_VIRT(data_access, 0x4300, 0x80, 0x300) +EXC_REAL_BEGIN(data_access, 0x300, 0x80) +SET_SCRATCH0(r13) /* save r13 */ +EXCEPTION_PROLOG_0(PACA_EXGEN) + b tramp_real_data_access +EXC_REAL_END(data_access, 0x300, 0x80) + +TRAMP_REAL_BEGIN(tramp_real_data_access) +EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_PR, 0x300) +EXCEPTION_PROLOG_2(data_access_common, EXC_STD) + +EXC_VIRT_BEGIN(data_access, 0x4300, 0x80) +SET_SCRATCH0(r13) /* save r13 */ +EXCEPTION_PROLOG_0(PACA_EXGEN) +EXCEPTION_PROLOG_1(PACA_EXGEN, NOTEST, 0x300) +EXCEPTION_PROLOG_2_RELON(data_access_common, EXC_STD) +EXC_VIRT_END(data_access, 0x4300, 0x80) + TRAMP_KVM_SKIP(PACA_EXGEN, 0x300) EXC_COMMON_BEGIN(data_access_common) @@ -604,11 +619,20 @@ ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX) EXC_REAL_BEGIN(data_access_slb, 0x380, 0x80) -EXCEPTION_PROLOG(PACA_EXSLB, data_access_slb_common, EXC_STD, KVMTEST_PR, 0x380); +SET_SCRATCH0(r13) /* save r13 */ +EXCEPTION_PROLOG_0(PACA_EXSLB) + b tramp_real_data_access_slb EXC_REAL_END(data_access_slb, 0x380, 0x80) +TRAMP_REAL_BEGIN(tramp_real_data_access_slb) +EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST_PR, 0x380) +EXCEPTION_PROLOG_2(data_access_slb_common, EXC_STD) + EXC_VIRT_BEGIN(data_access_slb, 0x4380, 0x80) -EXCEPTION_RELON_PROLOG(PACA_EXSLB, data_access_slb_common, EXC_STD, NOTEST, 0x380); +SET_SCRATCH0(r13) /* save r13 */ +EXCEPTION_PROLOG_0(PACA_EXSLB) +EXCEPTION_PROLOG_1(PACA_EXSLB, NOTEST, 0x380) +EXCEPTION_PROLOG_2_RELON(data_access_slb_common, EXC_STD) EXC_VIRT_END(data_access_slb, 0x4380, 0x80) TRAMP_KVM_SKIP(PACA_EXSLB, 0x380) @@ -711,8 +735,20 @@ TRAMP_KVM_HV(PACA_EXGEN, 0x500) EXC_COMMON_ASYNC(hardware_interrupt_common, 0x500, do_IRQ) -EXC_REAL(alignment, 0x600, 0x100) -EXC_VIRT(alignment, 0x4600, 0x100, 0x600) +EXC_REAL_BEGIN(alignment, 0x600, 0x100) +SET_SCRATCH0(r13) /* save r13 */ +EXCEPTION_PROLOG_0(PACA_EXGEN) +EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_PR, 0x600) +EXCEPTION_PROLOG_2(alignment_common, EXC_STD) +EXC_REAL_END(alignment, 0x600, 0x100) + +EXC_VIRT_BEGIN(alignment, 0x4600, 0x100) +SET_SCRATCH0(r13) /* save r13 */ +EXCEPTION_PROLOG_0(PACA_EXGEN) +EXCEPTION_PROLOG_1(PACA_EXGEN, NOTEST, 0x600) +EXCEPTION_PROLOG_2_RELON(alignment_common, EXC_STD) +EXC_VIRT_END(alignment, 0x4600, 0x100) + TRAMP_KVM(PACA_EXGEN, 0x600) EXC_COMMON_BEGIN(alignment_common) mfspr r10,SPRN_DAR -- 2.18.0
[PATCH v4 2/4] powerpc/64s: system reset interrupt preserve HSRRs
Code that uses HSRR registers is not required to clear MSR[RI] by convention, however the system reset NMI itself may use HSRR registers (e.g., to call OPAL) and clobber them. Rather than introduce the requirement to clear RI in order to use HSRRs, have system reset interrupt save and restore HSRRs. Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/traps.c | 25 - 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c index 12b54908c15d..f2191755fdf5 100644 --- a/arch/powerpc/kernel/traps.c +++ b/arch/powerpc/kernel/traps.c @@ -442,14 +442,32 @@ void hv_nmi_check_nonrecoverable(struct pt_regs *regs) void system_reset_exception(struct pt_regs *regs) { + unsigned long hsrr0, hsrr1; + bool nested = in_nmi(); + bool saved_hsrrs = false; + /* * Avoid crashes in case of nested NMI exceptions. Recoverability * is determined by RI and in_nmi */ - bool nested = in_nmi(); if (!nested) nmi_enter(); + /* +* System reset can interrupt code where HSRRs are live and MSR[RI]=1. +* The system reset interrupt itself may clobber HSRRs (e.g., to call +* OPAL), so save them here and restore them before returning. +* +* Machine checks don't need to save HSRRs, as the real mode handler +* is careful to avoid them, and the regular handler is not delivered +* as an NMI. +*/ + if (cpu_has_feature(CPU_FTR_HVMODE)) { + hsrr0 = mfspr(SPRN_HSRR0); + hsrr1 = mfspr(SPRN_HSRR1); + saved_hsrrs = true; + } + hv_nmi_check_nonrecoverable(regs); __this_cpu_inc(irq_stat.sreset_irqs); @@ -499,6 +517,11 @@ void system_reset_exception(struct pt_regs *regs) if (!(regs->msr & MSR_RI)) nmi_panic(regs, "Unrecoverable System Reset"); + if (saved_hsrrs) { + mtspr(SPRN_HSRR0, hsrr0); + mtspr(SPRN_HSRR1, hsrr1); + } + if (!nested) nmi_exit(); -- 2.18.0
[PATCH v4 1/4] powerpc/64s: Fix HV NMI vs HV interrupt recoverability test
HV interrupts that use HSRR registers do not enter with MSR[RI] clear, but their entry code is not recoverable vs NMI, due to shared use of HSPRG1 as a scratch register to save r13. This means that a system reset or machine check that hits in HSRR interrupt entry can cause r13 to be silently corrupted. Fix this by marking NMIs non-recoverable if they land in HV interrupt ranges. Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/asm-prototypes.h | 8 +++ arch/powerpc/include/asm/nmi.h| 2 + arch/powerpc/kernel/exceptions-64s.S | 8 +++ arch/powerpc/kernel/mce.c | 3 ++ arch/powerpc/kernel/traps.c | 66 +++ 5 files changed, 87 insertions(+) diff --git a/arch/powerpc/include/asm/asm-prototypes.h b/arch/powerpc/include/asm/asm-prototypes.h index 1d911f68a23b..0f8326644fa4 100644 --- a/arch/powerpc/include/asm/asm-prototypes.h +++ b/arch/powerpc/include/asm/asm-prototypes.h @@ -51,6 +51,14 @@ int exit_vmx_usercopy(void); int enter_vmx_ops(void); void *exit_vmx_ops(void *dest); +/* Exceptions */ +#ifdef CONFIG_PPC_POWERNV +extern unsigned long real_trampolines_start; +extern unsigned long real_trampolines_end; +extern unsigned long virt_trampolines_start; +extern unsigned long virt_trampolines_end; +#endif + /* Traps */ long machine_check_early(struct pt_regs *regs); long hmi_exception_realmode(struct pt_regs *regs); diff --git a/arch/powerpc/include/asm/nmi.h b/arch/powerpc/include/asm/nmi.h index bd9ba8defd72..84b4cfe73edd 100644 --- a/arch/powerpc/include/asm/nmi.h +++ b/arch/powerpc/include/asm/nmi.h @@ -14,4 +14,6 @@ extern void arch_trigger_cpumask_backtrace(const cpumask_t *mask, #define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace #endif +extern void hv_nmi_check_nonrecoverable(struct pt_regs *regs); + #endif /* _ASM_NMI_H */ diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index 9e253ce27e08..d2e9fc968655 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -68,6 +68,14 @@ OPEN_FIXED_SECTION(real_vectors,0x0100, 0x1900) OPEN_FIXED_SECTION(real_trampolines,0x1900, 0x4000) OPEN_FIXED_SECTION(virt_vectors,0x4000, 0x5900) OPEN_FIXED_SECTION(virt_trampolines,0x5900, 0x7000) + +#ifdef CONFIG_PPC_POWERNV + .globl real_trampolines_start + .globl real_trampolines_end + .globl virt_trampolines_start + .globl virt_trampolines_end +#endif + #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) /* * Data area reserved for FWNMI option. diff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c index bd933a75f0bc..d653b5de4537 100644 --- a/arch/powerpc/kernel/mce.c +++ b/arch/powerpc/kernel/mce.c @@ -31,6 +31,7 @@ #include #include +#include static DEFINE_PER_CPU(int, mce_nest_count); static DEFINE_PER_CPU(struct machine_check_event[MAX_MC_EVT], mce_event); @@ -488,6 +489,8 @@ long machine_check_early(struct pt_regs *regs) { long handled = 0; + hv_nmi_check_nonrecoverable(regs); + /* * See if platform is capable of handling machine check. */ diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c index 64936b60d521..12b54908c15d 100644 --- a/arch/powerpc/kernel/traps.c +++ b/arch/powerpc/kernel/traps.c @@ -376,6 +376,70 @@ void _exception(int signr, struct pt_regs *regs, int code, unsigned long addr) force_sig_fault(signr, code, (void __user *)addr, current); } +/* + * The interrupt architecture has a quirk in that the HV interrupts excluding + * the NMIs (0x100 and 0x200) do not clear MSR[RI] at entry. The first thing + * that an interrupt handler must do is save off a GPR into a scratch register, + * and all interrupts on POWERNV (HV=1) use the HSPRG1 register as scratch. + * Therefore an NMI can clobber an HV interrupt's live HSPRG1 without noticing + * that it is non-reentrant, which leads to random data corruption. + * + * The solution is for NMI interrupts in HV mode to check if they originated + * from these critical HV interrupt regions. If so, then mark them not + * recoverable. + * + * An alternative would be for HV NMIs to use SPRG for scratch to avoid the + * HSPRG1 clobber, however this would cause guest SPRG to be clobbered. Linux + * guests should always have MSR[RI]=0 when its scratch SPRG is in use, so + * that would work. However any other guest OS that may have the SPRG live + * and MSR[RI]=1 could encounter silent corruption. + * + * Builds that do not support KVM could take this second option to increase + * the recoverability of NMIs. + */ +void hv_nmi_check_nonrecoverable(struct pt_regs *regs) +{ +#ifdef CONFIG_PPC_POWERNV + unsigned long kbase = (unsigned long)_stext; + unsigned long nip = regs->nip; + + if (!(regs->msr & MSR_RI)) + return; + if (!(regs->msr & MSR_HV)) + return; + if
[PATCH v4 0/4] Fixes for 3 separate NMI reentrancy bugs
This series fixes several similar but unrelated bugs with NMIs clobbering live registers without noticing it, because MSR[RI] is set. Pretty rare bugs, but serious silent corruption consequences. For the most part these can be observed and tested quite easily with the mambo simulator, except that it does not seem to follow the architecture wrt leaving MSR[RI] unchanged for HV interrupts. Mambo clears MSR[RI], so you have to account for that manually. Since v1: - Fixed several build bugs. Since v2: - Improved changelog and comments. - Fixed the NIA test for virt mode interrupts. Since v3: - Fixed HPT crash due to use of PACA_EXGEN rather than EXSLB in the SLB interrupt handlers. Nicholas Piggin (4): powerpc/64s: Fix HV NMI vs HV interrupt recoverability test powerpc/64s: system reset interrupt preserve HSRRs powerpc/64s: Prepare to handle data interrupts vs d-side MCE reentrancy powerpc/64s: Fix data interrupts vs d-side MCE reentrancy arch/powerpc/include/asm/asm-prototypes.h | 8 ++ arch/powerpc/include/asm/nmi.h| 2 + arch/powerpc/kernel/exceptions-64s.S | 92 +++ arch/powerpc/kernel/mce.c | 3 + arch/powerpc/kernel/traps.c | 91 +- 5 files changed, 179 insertions(+), 17 deletions(-) -- 2.18.0
[PATCH 2/4] soc/fsl/guts: Add definition for LX2160A
Adding compatible string "lx2160a-dcfg" to initialize guts driver for lx2160 and SoC die attribute definition for LX2160A Signed-off-by: Vabhav Sharma Signed-off-by: Yinbo Zhu Acked-by: Li Yang --- drivers/soc/fsl/guts.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c index 302e0c8..bcab1ee 100644 --- a/drivers/soc/fsl/guts.c +++ b/drivers/soc/fsl/guts.c @@ -100,6 +100,11 @@ static const struct fsl_soc_die_attr fsl_soc_die[] = { .svr = 0x8700, .mask = 0xfff7, }, + /* Die: LX2160A, SoC: LX2160A/LX2120A/LX2080A */ + { .die = "LX2160A", + .svr = 0x8736, + .mask = 0xff3f, + }, { }, }; @@ -222,6 +227,7 @@ static const struct of_device_id fsl_guts_of_match[] = { { .compatible = "fsl,ls1088a-dcfg", }, { .compatible = "fsl,ls1012a-dcfg", }, { .compatible = "fsl,ls1046a-dcfg", }, + { .compatible = "fsl,lx2160a-dcfg", }, {} }; MODULE_DEVICE_TABLE(of, fsl_guts_of_match); -- 2.7.4
[PATCH 1/4] dt-bindings: arm64: add compatible for LX2160A
Add compatible for LX2160A SoC,QDS and RDB board Add lx2160a compatible for clockgen and dcfg Signed-off-by: Vabhav Sharma Reviewed-by: Rob Herring --- .../bindings/arm/freescale/fsl,layerscape-dcfg.txt | 2 +- Documentation/devicetree/bindings/arm/fsl.txt| 12 Documentation/devicetree/bindings/clock/qoriq-clock.txt | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/arm/freescale/fsl,layerscape-dcfg.txt b/Documentation/devicetree/bindings/arm/freescale/fsl,layerscape-dcfg.txt index b5cb374..dc76046 100644 --- a/Documentation/devicetree/bindings/arm/freescale/fsl,layerscape-dcfg.txt +++ b/Documentation/devicetree/bindings/arm/freescale/fsl,layerscape-dcfg.txt @@ -8,7 +8,7 @@ Required properties: - compatible: Should contain a chip-specific compatible string, Chip-specific strings are of the form "fsl,-dcfg", The following s are known to be supported: - ls1012a, ls1021a, ls1043a, ls1046a, ls2080a. + ls1012a, ls1021a, ls1043a, ls1046a, ls2080a, lx2160a. - reg : should contain base address and length of DCFG memory-mapped registers diff --git a/Documentation/devicetree/bindings/arm/fsl.txt b/Documentation/devicetree/bindings/arm/fsl.txt index 7fbc424..baef162 100644 --- a/Documentation/devicetree/bindings/arm/fsl.txt +++ b/Documentation/devicetree/bindings/arm/fsl.txt @@ -235,3 +235,15 @@ Required root node properties: LS2088A ARMv8 based RDB Board Required root node properties: - compatible = "fsl,ls2088a-rdb", "fsl,ls2088a"; + +LX2160A SoC +Required root node properties: +- compatible = "fsl,lx2160a"; + +LX2160A ARMv8 based QDS Board +Required root node properties: +- compatible = "fsl,lx2160a-qds", "fsl,lx2160a"; + +LX2160A ARMv8 based RDB Board +Required root node properties: +- compatible = "fsl,lx2160a-rdb", "fsl,lx2160a"; diff --git a/Documentation/devicetree/bindings/clock/qoriq-clock.txt b/Documentation/devicetree/bindings/clock/qoriq-clock.txt index c655f28..f322989 100644 --- a/Documentation/devicetree/bindings/clock/qoriq-clock.txt +++ b/Documentation/devicetree/bindings/clock/qoriq-clock.txt @@ -43,6 +43,7 @@ Required properties: * "fsl,ls1046a-clockgen" * "fsl,ls1088a-clockgen" * "fsl,ls2080a-clockgen" + * "fsl,lx2160a-clockgen" Chassis-version clock strings include: * "fsl,qoriq-clockgen-1.0": for chassis 1.0 clocks * "fsl,qoriq-clockgen-2.0": for chassis 2.0 clocks -- 2.7.4
[PATCH 4/4] clk: qoriq: Add clockgen support for lx2160a
From: Yogesh Gaur Add clockgen support for lx2160a. Added entry for compat 'fsl,lx2160a-clockgen'. Signed-off-by: Tang Yuantian Signed-off-by: Yogesh Gaur Signed-off-by: Vabhav Sharma Acked-by: Stephen Boyd Acked-by: Viresh Kumar --- drivers/clk/clk-qoriq.c | 12 drivers/cpufreq/qoriq-cpufreq.c | 1 + 2 files changed, 13 insertions(+) diff --git a/drivers/clk/clk-qoriq.c b/drivers/clk/clk-qoriq.c index e75194a..cfd14ef 100644 --- a/drivers/clk/clk-qoriq.c +++ b/drivers/clk/clk-qoriq.c @@ -570,6 +570,17 @@ static const struct clockgen_chipinfo chipinfo[] = { .flags = CG_VER3 | CG_LITTLE_ENDIAN, }, { + .compat = "fsl,lx2160a-clockgen", + .cmux_groups = { + _cmux_cga12, _cmux_cgb + }, + .cmux_to_group = { + 0, 0, 0, 0, 1, 1, 1, 1, -1 + }, + .pll_mask = 0x37, + .flags = CG_VER3 | CG_LITTLE_ENDIAN, + }, + { .compat = "fsl,p2041-clockgen", .guts_compat = "fsl,qoriq-device-config-1.0", .init_periph = p2041_init_periph, @@ -1435,6 +1446,7 @@ CLK_OF_DECLARE(qoriq_clockgen_t1023, "fsl,t1023-clockgen", clockgen_init); CLK_OF_DECLARE(qoriq_clockgen_t1040, "fsl,t1040-clockgen", clockgen_init); CLK_OF_DECLARE(qoriq_clockgen_t2080, "fsl,t2080-clockgen", clockgen_init); CLK_OF_DECLARE(qoriq_clockgen_t4240, "fsl,t4240-clockgen", clockgen_init); +CLK_OF_DECLARE(qoriq_clockgen_lx2160a, "fsl,lx2160a-clockgen", clockgen_init); /* Legacy nodes */ CLK_OF_DECLARE(qoriq_sysclk_1, "fsl,qoriq-sysclk-1.0", sysclk_init); diff --git a/drivers/cpufreq/qoriq-cpufreq.c b/drivers/cpufreq/qoriq-cpufreq.c index 3d773f6..83921b7 100644 --- a/drivers/cpufreq/qoriq-cpufreq.c +++ b/drivers/cpufreq/qoriq-cpufreq.c @@ -295,6 +295,7 @@ static const struct of_device_id node_matches[] __initconst = { { .compatible = "fsl,ls1046a-clockgen", }, { .compatible = "fsl,ls1088a-clockgen", }, { .compatible = "fsl,ls2080a-clockgen", }, + { .compatible = "fsl,lx2160a-clockgen", }, { .compatible = "fsl,p4080-clockgen", }, { .compatible = "fsl,qoriq-clockgen-1.0", }, { .compatible = "fsl,qoriq-clockgen-2.0", }, -- 2.7.4
[PATCH 3/4] clk: qoriq: increase array size of cmux_to_group
From: Yogesh Gaur Increase size of cmux_to_group array, to accomdate entry of -1 termination. Added -1, terminated, entry for 4080_cmux_grpX. Signed-off-by: Yogesh Gaur Signed-off-by: Vabhav Sharma Acked-by: Stephen Boyd --- drivers/clk/clk-qoriq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk-qoriq.c b/drivers/clk/clk-qoriq.c index 5baa9e0..e75194a 100644 --- a/drivers/clk/clk-qoriq.c +++ b/drivers/clk/clk-qoriq.c @@ -79,7 +79,7 @@ struct clockgen_chipinfo { const struct clockgen_muxinfo *cmux_groups[2]; const struct clockgen_muxinfo *hwaccel[NUM_HWACCEL]; void (*init_periph)(struct clockgen *cg); - int cmux_to_group[NUM_CMUX]; /* -1 terminates if fewer than NUM_CMUX */ + int cmux_to_group[NUM_CMUX+1]; /* array should be -1 terminated */ u32 pll_mask; /* 1 << n bit set if PLL n is valid */ u32 flags; /* CG_xxx */ }; @@ -601,7 +601,7 @@ static const struct clockgen_chipinfo chipinfo[] = { _cmux_grp1, _cmux_grp2 }, .cmux_to_group = { - 0, 0, 0, 0, 1, 1, 1, 1 + 0, 0, 0, 0, 1, 1, 1, 1, -1 }, .pll_mask = 0x1f, }, -- 2.7.4
[PATCH 0/4] arm64: dts: NXP: add basic dts file for LX2160A SoC
These patches were reviewed and acked but dropped during merge window. Patchwork link was https://lore.kernel.org/patchwork/cover/1004155/ Vabhav Sharma (2): dt-bindings: arm64: add compatible for LX2160A soc/fsl/guts: Add definition for LX2160A Yogesh Gaur (2): clk: qoriq: increase array size of cmux_to_group clk: qoriq: Add clockgen support for lx2160a .../bindings/arm/freescale/fsl,layerscape-dcfg.txt | 2 +- Documentation/devicetree/bindings/arm/fsl.txt| 12 Documentation/devicetree/bindings/clock/qoriq-clock.txt | 1 + drivers/clk/clk-qoriq.c | 16 ++-- drivers/cpufreq/qoriq-cpufreq.c | 1 + drivers/soc/fsl/guts.c | 6 ++ 6 files changed, 35 insertions(+), 3 deletions(-) -- 2.7.4
[PATCH 1/3] ASoC: wcd9335: fix a leaked reference by adding missing of_node_put
The call to of_parse_phandle returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage. Detected by coccinelle with the following warnings: ./sound/soc/codecs/wcd9335.c:5193:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 5183, but without a correspon ding object release within this function. Signed-off-by: Wen Yang Cc: Liam Girdwood Cc: Mark Brown Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: Srinivas Kandagatla Cc: Vinod Koul Cc: Dan Carpenter (commit_signer:1/11=9%,authored:1/11=9%) Cc: alsa-de...@alsa-project.org Cc: linux-ker...@vger.kernel.org --- sound/soc/codecs/wcd9335.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/codecs/wcd9335.c b/sound/soc/codecs/wcd9335.c index 981f88a..a04a7ce 100644 --- a/sound/soc/codecs/wcd9335.c +++ b/sound/soc/codecs/wcd9335.c @@ -5188,6 +5188,7 @@ static int wcd9335_slim_status(struct slim_device *sdev, wcd->slim = sdev; wcd->slim_ifc_dev = of_slim_get_device(sdev->ctrl, ifc_dev_np); + of_node_put(ifc_dev_np); if (!wcd->slim_ifc_dev) { dev_err(dev, "Unable to get SLIM Interface device\n"); return -EINVAL; -- 2.9.5
[PATCH 3/3] ASoC: eukrea-tlv320: fix a leaked reference by adding missing of_node_put
The call to of_parse_phandle returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage. Detected by coccinelle with the following warnings: ./sound/soc/fsl/eukrea-tlv320.c:121:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 102, but without a correspo nding object release within this function. ./sound/soc/fsl/eukrea-tlv320.c:127:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 102, but without a correspo nding object release within this function. Signed-off-by: Wen Yang Cc: Liam Girdwood Cc: Mark Brown Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: alsa-de...@alsa-project.org Cc: linux-ker...@vger.kernel.org --- sound/soc/fsl/eukrea-tlv320.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/fsl/eukrea-tlv320.c b/sound/soc/fsl/eukrea-tlv320.c index 191426a..30a3d68 100644 --- a/sound/soc/fsl/eukrea-tlv320.c +++ b/sound/soc/fsl/eukrea-tlv320.c @@ -118,13 +118,13 @@ static int eukrea_tlv320_probe(struct platform_device *pdev) if (ret) { dev_err(>dev, "fsl,mux-int-port node missing or invalid.\n"); - return ret; + goto err; } ret = of_property_read_u32(np, "fsl,mux-ext-port", _port); if (ret) { dev_err(>dev, "fsl,mux-ext-port node missing or invalid.\n"); - return ret; + goto err; } /* -- 2.9.5
[PATCH 2/3] ASoC: fsl_utils: fix a leaked reference by adding missing of_node_put
The call to of_parse_phandle returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage. Detected by coccinelle with the following warnings: ./sound/soc/fsl/fsl_utils.c:74:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 38, but without a corresponding object release within this function. Signed-off-by: Wen Yang Cc: Timur Tabi Cc: Nicolin Chen Cc: Xiubo Li Cc: Fabio Estevam Cc: Liam Girdwood Cc: Mark Brown Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: alsa-de...@alsa-project.org Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-ker...@vger.kernel.org --- sound/soc/fsl/fsl_utils.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/fsl/fsl_utils.c b/sound/soc/fsl/fsl_utils.c index 9981668..040d06b 100644 --- a/sound/soc/fsl/fsl_utils.c +++ b/sound/soc/fsl/fsl_utils.c @@ -71,6 +71,7 @@ int fsl_asoc_get_dma_channel(struct device_node *ssi_np, iprop = of_get_property(dma_np, "cell-index", NULL); if (!iprop) { of_node_put(dma_np); + of_node_put(dma_channel_np); return -EINVAL; } *dma_id = be32_to_cpup(iprop); -- 2.9.5
Re: linux-next: build failure after merge of the akpm tree
On Tue, Feb 26, 2019 at 06:39:15PM +1100, Stephen Rothwell wrote: > Hi Andrew, > > After merging the akpm tree, today's linux-next build (powerpc > allnoconfig) failed like this: > > /home/sfr/next/next/arch/powerpc/kernel/setup_32.c:176:21: error: > redefinition of 'alloc_stack' > static void *__init alloc_stack(void) > ^~~ > /home/sfr/next/next/arch/powerpc/kernel/setup_32.c:165:21: note: previous > definition of 'alloc_stack' was here > static void *__init alloc_stack(void) > ^~~ > > Caused by patch > > "powerpc: use memblock functions returning virtual address" > > from the akpm tree interacting with commit > > c8e409a33cf8 ("powerpc/irq: use memblock functions returning virtual > address") > > from the powerpc tree. > > Both patches added the alloc_stack() function and git resolved it by > adding both. :-( I have added a patch to remove one of them. Yeah, me too :) https://lore.kernel.org/linux-mm/20190226064032.GA5873@rapoport-lnx/ Stephen, sorry, should have cc'ed you > -- > Cheers, > Stephen Rothwell -- Sincerely yours, Mike.
build failure of current mmotm with skiroot_defconfig
Hi, I've encountered the following error when building skyroot_defconfig with current mmotm tree: make CONFIG_OF_ALL_DTBS=y CONFIG_DTC=y CROSS_COMPILE=/opt/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux- ARCH=powerpc vmlinux ... CC arch/powerpc/kernel/dbell.o In file included from arch/powerpc/kernel/dbell.c:20: arch/powerpc/include/asm/kvm_ppc.h: In function 'xics_on_xive': arch/powerpc/include/asm/kvm_ppc.h:625:9: error: implicit declaration of function 'xive_enabled'; did you mean 'eeh_enabled'? [-Werror=implicit-function-declaration] return xive_enabled() && cpu_has_feature(CPU_FTR_HVMODE); ^~~~ eeh_enabled cc1: all warnings being treated as errors scripts/Makefile.build:278: recipe for target 'arch/powerpc/kernel/dbell.o' failed make[3]: *** [arch/powerpc/kernel/dbell.o] Error 1 scripts/Makefile.build:493: recipe for target 'arch/powerpc/kernel' failed make[2]: *** [arch/powerpc/kernel] Error 2 Makefile:1049: recipe for target 'arch/powerpc' failed make[1]: *** [arch/powerpc] Error 2 -- Sincerely yours, Mike.