* [PATCH] kmemleak: powerpc: skip scanning holes in the .bss section
From: Catalin Marinas @ 2019-03-21 17:19 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, kvm-ppc, linux-mm, Qian Cai, linuxppc-dev
The commit 2d4f567103ff ("KVM: PPC: Introduce kvm_tmp framework") adds
kvm_tmp[] into the .bss section and then free the rest of unused spaces
back to the page allocator.
kernel_init
kvm_guest_init
kvm_free_tmp
free_reserved_area
free_unref_page
free_unref_page_prepare
With DEBUG_PAGEALLOC=y, it will unmap those pages from kernel. As the
result, kmemleak scan will trigger a panic when it scans the .bss
section with unmapped pages.
This patch creates dedicated kmemleak objects for the .data, .bss and
potentially .data..ro_after_init sections to allow partial freeing via
the kmemleak_free_part() in the powerpc kvm_free_tmp() function.
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
Reported-by: Qian Cai <cai@lca.pw>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
---
Posting as a proper patch following the inlined one here:
http://lkml.kernel.org/r/20190320181656.GB38229@arrakis.emea.arm.com
Changes from the above:
- Added comment to the powerpc kmemleak_free_part() call
- Only register the .data..ro_after_init in kmemleak if not contained
within the .data sections (which seems to be the case for lots of
architectures)
I preserved part of Qian's original commit message but changed the
author since I rewrote the patch.
arch/powerpc/kernel/kvm.c | 7 +++++++
mm/kmemleak.c | 16 +++++++++++-----
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/kernel/kvm.c b/arch/powerpc/kernel/kvm.c
index 683b5b3805bd..cd381e2291df 100644
--- a/arch/powerpc/kernel/kvm.c
+++ b/arch/powerpc/kernel/kvm.c
@@ -22,6 +22,7 @@
#include <linux/kvm_host.h>
#include <linux/init.h>
#include <linux/export.h>
+#include <linux/kmemleak.h>
#include <linux/kvm_para.h>
#include <linux/slab.h>
#include <linux/of.h>
@@ -712,6 +713,12 @@ static void kvm_use_magic_page(void)
static __init void kvm_free_tmp(void)
{
+ /*
+ * Inform kmemleak about the hole in the .bss section since the
+ * corresponding pages will be unmapped with DEBUG_PAGEALLOC=y.
+ */
+ kmemleak_free_part(&kvm_tmp[kvm_tmp_index],
+ ARRAY_SIZE(kvm_tmp) - kvm_tmp_index);
free_reserved_area(&kvm_tmp[kvm_tmp_index],
&kvm_tmp[ARRAY_SIZE(kvm_tmp)], -1, NULL);
}
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 707fa5579f66..6c318f5ac234 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -1529,11 +1529,6 @@ static void kmemleak_scan(void)
}
rcu_read_unlock();
- /* data/bss scanning */
- scan_large_block(_sdata, _edata);
- scan_large_block(__bss_start, __bss_stop);
- scan_large_block(__start_ro_after_init, __end_ro_after_init);
-
#ifdef CONFIG_SMP
/* per-cpu sections scanning */
for_each_possible_cpu(i)
@@ -2071,6 +2066,17 @@ void __init kmemleak_init(void)
}
local_irq_restore(flags);
+ /* register the data/bss sections */
+ create_object((unsigned long)_sdata, _edata - _sdata,
+ KMEMLEAK_GREY, GFP_ATOMIC);
+ create_object((unsigned long)__bss_start, __bss_stop - __bss_start,
+ KMEMLEAK_GREY, GFP_ATOMIC);
+ /* only register .data..ro_after_init if not within .data */
+ if (__start_ro_after_init < _sdata || __end_ro_after_init > _edata)
+ create_object((unsigned long)__start_ro_after_init,
+ __end_ro_after_init - __start_ro_after_init,
+ KMEMLEAK_GREY, GFP_ATOMIC);
+
/*
* This is the point where tracking allocations is safe. Automatic
* scanning is started during the late initcall. Add the early logged
^ permalink raw reply related
* Re: [RESEND PATCH 0/7] Add FOLL_LONGTERM to GUP fast and use it
From: Ira Weiny @ 2019-03-21 8:40 UTC (permalink / raw)
To: Andrew Morton
Cc: Michal Hocko, linux-sh, Peter Zijlstra, James Hogan,
Heiko Carstens, linux-mips, linux-mm, Rich Felker, Paul Mackerras,
sparclinux, Dan Williams, linux-s390, Yoshinori Sato, linux-rdma,
Jason Gunthorpe, Ingo Molnar, John Hubbard, Borislav Petkov,
Thomas Gleixner, netdev, linux-kernel, Ralf Baechle,
Martin Schwidefsky, linuxppc-dev, David S. Miller,
Kirill A. Shutemov
In-Reply-To: <20190319151930.bab575d62fb1a33094160fe3@linux-foundation.org>
On Tue, Mar 19, 2019 at 03:19:30PM -0700, Andrew Morton wrote:
> On Sun, 17 Mar 2019 11:34:31 -0700 ira.weiny@intel.com wrote:
>
> > Resending after rebasing to the latest mm tree.
> >
> > HFI1, qib, and mthca, use get_user_pages_fast() due to it performance
> > advantages. These pages can be held for a significant time. But
> > get_user_pages_fast() does not protect against mapping FS DAX pages.
> >
> > Introduce FOLL_LONGTERM and use this flag in get_user_pages_fast() which
> > retains the performance while also adding the FS DAX checks. XDP has also
> > shown interest in using this functionality.[1]
> >
> > In addition we change get_user_pages() to use the new FOLL_LONGTERM flag and
> > remove the specialized get_user_pages_longterm call.
>
> It would be helpful to include your response to Christoph's question
> (http://lkml.kernel.org/r/20190220180255.GA12020@iweiny-DESK2.sc.intel.com)
> in the changelog. Because if one person was wondering about this,
> others will likely do so.
>
> We have no record of acks or reviewed-by's. At least one was missed
> (http://lkml.kernel.org/r/CAOg9mSTTcD-9bCSDfC0WRYqfVrNB4TwOzL0c4+6QXi-N_Y43Vw@mail.gmail.com),
> but that is very very partial.
That is my bad. Sorry to Mike. And I have added him.
>
> This patchset is fairly DAX-centered, but Dan wasn't cc'ed!
Agreed, I'm new to changing things which affect this many sub-systems and I
struggled with who should be CC'ed (get_maintainer.pl returned a very large
list :-(.
I fear I may have cc'ed too many people, and the wrong people apparently, so
that may be affecting the review...
So again my apologies. I don't know if Dan is going to get a chance to put a
reviewed-by on them this week but I thought I would send this note to let you
know I'm not ignoring your feedback. Just waiting a bit before resending to
hopefully get some more acks/reviewed bys.
Thanks,
Ira
>
> So ho hum. I'll scoop them up and shall make the above changes to the
> [1/n] changelog, but we still have some work to do.
>
^ permalink raw reply
* Re: [PATCH 1/4] add generic builtin command line
From: Daniel Walker @ 2019-03-21 15:13 UTC (permalink / raw)
To: Andrew Morton
Cc: Maksym Kokhan, linux-kernel, Rob Herring, Paul Mackerras,
xe-linux-external, Daniel Walker, linuxppc-dev
In-Reply-To: <20190320201433.6c5c4782f4432d280c0e8361@linux-foundation.org>
On Wed, Mar 20, 2019 at 08:14:33PM -0700, Andrew Morton wrote:
> On Wed, 20 Mar 2019 16:23:28 -0700 Daniel Walker <danielwa@cisco.com> wrote:
>
> > On Wed, Mar 20, 2019 at 03:53:19PM -0700, Andrew Morton wrote:
> > > On Tue, 19 Mar 2019 16:24:45 -0700 Daniel Walker <danielwa@cisco.com> wrote:
> > >
> > > > This code allows architectures to use a generic builtin command line.
> > >
> > > I wasn't cc'ed on [2/4]. No mailing lists were cc'ed on [0/4] but it
> > > didn't say anything useful anyway ;)
> > >
> > > I'll queue them up for testing and shall await feedback from the
> > > powerpc developers.
> > >
> >
> > You weren't CC'd , but it was To: you,
> >
> > 35 From: Daniel Walker <danielwa@cisco.com>
> > 36 To: Andrew Morton <akpm@linux-foundation.org>,
> > 37 Christophe Leroy <christophe.leroy@c-s.fr>,
> > 38 Michael Ellerman <mpe@ellerman.id.au>,
> > 39 Rob Herring <robh+dt@kernel.org>, xe-linux-external@cisco.com,
> > 40 linuxppc-dev@lists.ozlabs.org, Frank Rowand <frowand.list@gmail.com>
> > 41 Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
> > 42 Subject: [PATCH 2/4] drivers: of: generic command line support
>
> hm.
>
> > Thanks for picking it up.
>
> The patches (or some version of them) are already in linux-next,
> which messes me up. I'll disable them for now.
Those are from my tree, but I remove them when you picked up the series. The
next linux-next should not have them.
Daniel
^ permalink raw reply
* [PATCH -next] crypto: vmx - Make p8_init and p8_exit static
From: Yue Haibing @ 2019-03-21 15:11 UTC (permalink / raw)
To: leitao, nayna, pfsmorigo, benh, paulus, mpe, herbert, davem
Cc: YueHaibing, linuxppc-dev, linux-kernel, linux-crypto
From: YueHaibing <yuehaibing@huawei.com>
Fix sparse warnings:
drivers/crypto/vmx/vmx.c:44:12: warning:
symbol 'p8_init' was not declared. Should it be static?
drivers/crypto/vmx/vmx.c:70:13: warning:
symbol 'p8_exit' was not declared. Should it be static?
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
drivers/crypto/vmx/vmx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/crypto/vmx/vmx.c b/drivers/crypto/vmx/vmx.c
index 31a98dc..a9f5198 100644
--- a/drivers/crypto/vmx/vmx.c
+++ b/drivers/crypto/vmx/vmx.c
@@ -41,7 +41,7 @@ static struct crypto_alg *algs[] = {
NULL,
};
-int __init p8_init(void)
+static int __init p8_init(void)
{
int ret = 0;
struct crypto_alg **alg_it;
@@ -67,7 +67,7 @@ int __init p8_init(void)
return ret;
}
-void __exit p8_exit(void)
+static void __exit p8_exit(void)
{
struct crypto_alg **alg_it;
--
2.7.0
^ permalink raw reply related
* Applied "ASoC: fsl_asrc: add constraint for the asrc of older version" to the asoc tree
From: Mark Brown @ 2019-03-21 15:07 UTC (permalink / raw)
To: S.j. Wang
Cc: alsa-devel, timur@kernel.org, Xiubo.Lee@gmail.com,
linuxppc-dev@lists.ozlabs.org, Shengjiu Wang,
nicoleotsuka@gmail.com, broonie@kernel.org, festevam@gmail.com
In-Reply-To: <3fc3a2cbe15b67537be9e97beff0d97f619a063f.1551505839.git.shengjiu.wang@nxp.com>
The patch
ASoC: fsl_asrc: add constraint for the asrc of older version
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
From 53f67a78663811968f426d480bc55887d787bd94 Mon Sep 17 00:00:00 2001
From: "S.j. Wang" <shengjiu.wang@nxp.com>
Date: Sat, 2 Mar 2019 05:52:19 +0000
Subject: [PATCH] ASoC: fsl_asrc: add constraint for the asrc of older version
There is a constraint for the channel number setting on the
asrc of older version (e.g. imx35), the channel number should
be even, odd number isn't valid.
So add this constraint when the asrc of older version is used.
Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
sound/soc/fsl/fsl_asrc.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c
index 528e8b108422..0b937924d2e4 100644
--- a/sound/soc/fsl/fsl_asrc.c
+++ b/sound/soc/fsl/fsl_asrc.c
@@ -445,6 +445,19 @@ struct dma_chan *fsl_asrc_get_dma_channel(struct fsl_asrc_pair *pair, bool dir)
}
EXPORT_SYMBOL_GPL(fsl_asrc_get_dma_channel);
+static int fsl_asrc_dai_startup(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *dai)
+{
+ struct fsl_asrc *asrc_priv = snd_soc_dai_get_drvdata(dai);
+
+ /* Odd channel number is not valid for older ASRC (channel_bits==3) */
+ if (asrc_priv->channel_bits == 3)
+ snd_pcm_hw_constraint_step(substream->runtime, 0,
+ SNDRV_PCM_HW_PARAM_CHANNELS, 2);
+
+ return 0;
+}
+
static int fsl_asrc_dai_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
@@ -539,6 +552,7 @@ static int fsl_asrc_dai_trigger(struct snd_pcm_substream *substream, int cmd,
}
static const struct snd_soc_dai_ops fsl_asrc_dai_ops = {
+ .startup = fsl_asrc_dai_startup,
.hw_params = fsl_asrc_dai_hw_params,
.hw_free = fsl_asrc_dai_hw_free,
.trigger = fsl_asrc_dai_trigger,
--
2.20.1
^ permalink raw reply related
* Applied "ASoC: fsl_esai: fix channel swap issue when stream starts" to the asoc tree
From: Mark Brown @ 2019-03-21 15:07 UTC (permalink / raw)
To: S.j. Wang
Cc: alsa-devel, timur@kernel.org, Xiubo.Lee@gmail.com,
linuxppc-dev@lists.ozlabs.org, Shengjiu Wang, stable,
nicoleotsuka@gmail.com, broonie@kernel.org, festevam@gmail.com
In-Reply-To: <f05c95e5371336a8e3b0c395dc4cef70922f0caa.1551248985.git.shengjiu.wang@nxp.com>
The patch
ASoC: fsl_esai: fix channel swap issue when stream starts
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
From 0ff4e8c61b794a4bf6c854ab071a1abaaa80f358 Mon Sep 17 00:00:00 2001
From: "S.j. Wang" <shengjiu.wang@nxp.com>
Date: Wed, 27 Feb 2019 06:31:12 +0000
Subject: [PATCH] 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: <stable@vger.kernel.org>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
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 = 0xFFFFFFFF;
+ esai_priv->rx_mask = 0xFFFFFFFF;
+
+ /* Clear the TSMA, TSMB, RSMA, RSMB */
+ regmap_write(esai_priv->regmap, REG_ESAI_TSMA, 0);
+ regmap_write(esai_priv->regmap, REG_ESAI_TSMB, 0);
+ regmap_write(esai_priv->regmap, REG_ESAI_RSMA, 0);
+ regmap_write(esai_priv->regmap, REG_ESAI_RSMB, 0);
+
ret = devm_snd_soc_register_component(&pdev->dev, &fsl_esai_component,
&fsl_esai_dai, 1);
if (ret) {
--
2.20.1
^ permalink raw reply related
* Re: [RFC PATCH 1/1] KVM: PPC: Report single stepping capability
From: Fabiano Rosas @ 2019-03-21 14:35 UTC (permalink / raw)
To: Alexey Kardashevskiy, kvm-ppc; +Cc: kvm, rkrcmar, pbonzini, linuxppc-dev, david
In-Reply-To: <c15b17c8-6ef5-00b4-c762-8b1627ca5f18@ozlabs.ru>
Alexey Kardashevskiy <aik@ozlabs.ru> writes:
> In the cover letter (which is not really required for a single patch)
> you say the capability will be present for BookE and PR KVM (which
> Book3s) but here it is BookE only, is that intentional?
A few lines below (falling through) we have:
/* We support this only for PR */
r = !hv_enabled;
> Also, you need to update Documentation/virtual/kvm/api.txt for the new
> capability. After reading which I started wondering could not we just
> use existing KVM_CAP_GUEST_DEBUG_HW_BPS?
We _could_, but I think that would conflate two different
concepts. Single stepping does not necessarily makes use of hardware
breakpoints (e.g. Trace Interrupt on Book3s PR).
I also think we should use KVM_CAP_GUEST_DEBUG_HW_BPS in the future to
let QEMU know about: i) the lack of hardware breakpoints in Book3s and
ii) BookE's hardware breakpoints (Instruction Address Compare) that are
currently not being reported via HW_BPS.
^ permalink raw reply
* [PATCH v5 04/19] powerpc: mm: Add p?d_large() definitions
From: Steven Price @ 2019-03-21 14:19 UTC (permalink / raw)
To: linux-mm
Cc: Mark Rutland, Peter Zijlstra, Dave Hansen, Will Deacon,
Paul Mackerras, H. Peter Anvin, Liang, Kan, x86, Steven Price,
Ingo Molnar, Catalin Marinas, Arnd Bergmann, kvm-ppc,
Jérôme Glisse, Borislav Petkov, Andy Lutomirski,
Thomas Gleixner, linux-arm-kernel, Ard Biesheuvel, linux-kernel,
James Morse, linuxppc-dev
In-Reply-To: <20190321141953.31960-1-steven.price@arm.com>
walk_page_range() is going to be allowed to walk page tables other than
those of user space. For this it needs to know when it has reached a
'leaf' entry in the page tables. This information is provided by the
p?d_large() functions/macros.
For powerpc pmd_large() was already implemented, so hoist it out of the
CONFIG_TRANSPARENT_HUGEPAGE condition and implement the other levels.
Also since we now have a pmd_large always implemented we can drop the
pmd_is_leaf() function.
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: Michael Ellerman <mpe@ellerman.id.au>
CC: linuxppc-dev@lists.ozlabs.org
CC: kvm-ppc@vger.kernel.org
Signed-off-by: Steven Price <steven.price@arm.com>
---
arch/powerpc/include/asm/book3s/64/pgtable.h | 30 ++++++++++++++------
arch/powerpc/kvm/book3s_64_mmu_radix.c | 12 ++------
2 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h
index 581f91be9dd4..f6d1ac8b832e 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -897,6 +897,12 @@ static inline int pud_present(pud_t pud)
return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PRESENT));
}
+#define pud_large pud_large
+static inline int pud_large(pud_t pud)
+{
+ return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE));
+}
+
extern struct page *pud_page(pud_t pud);
extern struct page *pmd_page(pmd_t pmd);
static inline pte_t pud_pte(pud_t pud)
@@ -940,6 +946,12 @@ static inline int pgd_present(pgd_t pgd)
return !!(pgd_raw(pgd) & cpu_to_be64(_PAGE_PRESENT));
}
+#define pgd_large pgd_large
+static inline int pgd_large(pgd_t pgd)
+{
+ return !!(pgd_raw(pgd) & cpu_to_be64(_PAGE_PTE));
+}
+
static inline pte_t pgd_pte(pgd_t pgd)
{
return __pte_raw(pgd_raw(pgd));
@@ -1093,6 +1105,15 @@ static inline bool pmd_access_permitted(pmd_t pmd, bool write)
return pte_access_permitted(pmd_pte(pmd), write);
}
+#define pmd_large pmd_large
+/*
+ * returns true for pmd migration entries, THP, devmap, hugetlb
+ */
+static inline int pmd_large(pmd_t pmd)
+{
+ return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE));
+}
+
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
extern pmd_t pfn_pmd(unsigned long pfn, pgprot_t pgprot);
extern pmd_t mk_pmd(struct page *page, pgprot_t pgprot);
@@ -1119,15 +1140,6 @@ pmd_hugepage_update(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp,
return hash__pmd_hugepage_update(mm, addr, pmdp, clr, set);
}
-/*
- * returns true for pmd migration entries, THP, devmap, hugetlb
- * But compile time dependent on THP config
- */
-static inline int pmd_large(pmd_t pmd)
-{
- return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE));
-}
-
static inline pmd_t pmd_mknotpresent(pmd_t pmd)
{
return __pmd(pmd_val(pmd) & ~_PAGE_PRESENT);
diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c
index f55ef071883f..1b57b4e3f819 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_radix.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c
@@ -363,12 +363,6 @@ static void kvmppc_pte_free(pte_t *ptep)
kmem_cache_free(kvm_pte_cache, ptep);
}
-/* Like pmd_huge() and pmd_large(), but works regardless of config options */
-static inline int pmd_is_leaf(pmd_t pmd)
-{
- return !!(pmd_val(pmd) & _PAGE_PTE);
-}
-
static pmd_t *kvmppc_pmd_alloc(void)
{
return kmem_cache_alloc(kvm_pmd_cache, GFP_KERNEL);
@@ -460,7 +454,7 @@ static void kvmppc_unmap_free_pmd(struct kvm *kvm, pmd_t *pmd, bool full,
for (im = 0; im < PTRS_PER_PMD; ++im, ++p) {
if (!pmd_present(*p))
continue;
- if (pmd_is_leaf(*p)) {
+ if (pmd_large(*p)) {
if (full) {
pmd_clear(p);
} else {
@@ -593,7 +587,7 @@ int kvmppc_create_pte(struct kvm *kvm, pgd_t *pgtable, pte_t pte,
else if (level <= 1)
new_pmd = kvmppc_pmd_alloc();
- if (level == 0 && !(pmd && pmd_present(*pmd) && !pmd_is_leaf(*pmd)))
+ if (level == 0 && !(pmd && pmd_present(*pmd) && !pmd_large(*pmd)))
new_ptep = kvmppc_pte_alloc();
/* Check if we might have been invalidated; let the guest retry if so */
@@ -662,7 +656,7 @@ int kvmppc_create_pte(struct kvm *kvm, pgd_t *pgtable, pte_t pte,
new_pmd = NULL;
}
pmd = pmd_offset(pud, gpa);
- if (pmd_is_leaf(*pmd)) {
+ if (pmd_large(*pmd)) {
unsigned long lgpa = gpa & PMD_MASK;
/* Check if we raced and someone else has set the same thing */
--
2.20.1
^ permalink raw reply related
* Re: [alsa-devel] [PATCH V4] ASoC: fsl_esai: fix channel swap issue when stream starts
From: Mark Brown @ 2019-03-21 14:13 UTC (permalink / raw)
To: S.j. Wang
Cc: alsa-devel@alsa-project.org, timur@kernel.org,
Xiubo.Lee@gmail.com, festevam@gmail.com, nicoleotsuka@gmail.com,
linuxppc-dev@lists.ozlabs.org
In-Reply-To: <VI1PR0402MB3392C426C2F5D65322A04253E3400@VI1PR0402MB3392.eurprd04.prod.outlook.com>
[-- Attachment #1: Type: text/plain, Size: 901 bytes --]
On Tue, Mar 19, 2019 at 02:08:20AM +0000, S.j. Wang wrote:
> Hi Mark
>
> Can this patch be accepted? Or need I do any update?
Please don't send content free pings and please allow a reasonable time
for review. People get busy, go on holiday, attend conferences and so
on so unless there is some reason for urgency (like critical bug fixes)
please allow at least a couple of weeks for review. If there have been
review comments then people may be waiting for those to be addressed.
Sending content free pings adds to the mail volume (if they are seen at
all) which is often the problem and since they can't be reviewed
directly if something has gone wrong you'll have to resend the patches
anyway, so sending again is generally a better approach though there are
some other maintainers who like them - if in doubt look at how patches
for the subsystem are normally handled.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply
* [RFC PATCH 7/8] vfs: Convert spufs to fs_context
From: David Howells @ 2019-03-21 11:48 UTC (permalink / raw)
To: viro
Cc: Arnd Bergmann, linux-kernel, dhowells, Jeremy Kerr, linux-fsdevel,
linuxppc-dev
In-Reply-To: <155316885201.29437.3428987891437242750.stgit@warthog.procyon.org.uk>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Jeremy Kerr <jk@ozlabs.org>
cc: Arnd Bergmann <arnd@arndb.de>
cc: linuxppc-dev@lists.ozlabs.org
---
arch/powerpc/platforms/cell/spufs/inode.c | 207 ++++++++++++++++-------------
1 file changed, 116 insertions(+), 91 deletions(-)
diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index db329d4bf1c3..f951a7fe4e3c 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -23,6 +23,8 @@
#include <linux/file.h>
#include <linux/fs.h>
+#include <linux/fs_context.h>
+#include <linux/fs_parser.h>
#include <linux/fsnotify.h>
#include <linux/backing-dev.h>
#include <linux/init.h>
@@ -33,7 +35,6 @@
#include <linux/pagemap.h>
#include <linux/poll.h>
#include <linux/slab.h>
-#include <linux/parser.h>
#include <asm/prom.h>
#include <asm/spu.h>
@@ -43,7 +44,7 @@
#include "spufs.h"
struct spufs_sb_info {
- int debug;
+ bool debug;
};
static struct kmem_cache *spufs_inode_cache;
@@ -593,16 +594,27 @@ long spufs_create(struct path *path, struct dentry *dentry,
}
/* File system initialization */
+struct spufs_fs_context {
+ kuid_t uid;
+ kgid_t gid;
+ umode_t mode;
+};
+
enum {
- Opt_uid, Opt_gid, Opt_mode, Opt_debug, Opt_err,
+ Opt_uid, Opt_gid, Opt_mode, Opt_debug,
+};
+
+static const struct fs_parameter_spec spufs_param_specs[] = {
+ fsparam_u32 ("gid", Opt_gid),
+ fsparam_u32oct ("mode", Opt_mode),
+ fsparam_u32 ("uid", Opt_uid),
+ fsparam_flag ("debug", Opt_debug),
+ {}
};
-static const match_table_t spufs_tokens = {
- { Opt_uid, "uid=%d" },
- { Opt_gid, "gid=%d" },
- { Opt_mode, "mode=%o" },
- { Opt_debug, "debug" },
- { Opt_err, NULL },
+static const struct fs_parameter_description spufs_fs_parameters = {
+ .name = "spufs",
+ .specs = spufs_param_specs,
};
static int spufs_show_options(struct seq_file *m, struct dentry *root)
@@ -623,47 +635,41 @@ static int spufs_show_options(struct seq_file *m, struct dentry *root)
return 0;
}
-static int
-spufs_parse_options(struct super_block *sb, char *options, struct inode *root)
-{
- char *p;
- substring_t args[MAX_OPT_ARGS];
-
- while ((p = strsep(&options, ",")) != NULL) {
- int token, option;
-
- if (!*p)
- continue;
-
- token = match_token(p, spufs_tokens, args);
- switch (token) {
- case Opt_uid:
- if (match_int(&args[0], &option))
- return 0;
- root->i_uid = make_kuid(current_user_ns(), option);
- if (!uid_valid(root->i_uid))
- return 0;
- break;
- case Opt_gid:
- if (match_int(&args[0], &option))
- return 0;
- root->i_gid = make_kgid(current_user_ns(), option);
- if (!gid_valid(root->i_gid))
- return 0;
- break;
- case Opt_mode:
- if (match_octal(&args[0], &option))
- return 0;
- root->i_mode = option | S_IFDIR;
- break;
- case Opt_debug:
- spufs_get_sb_info(sb)->debug = 1;
- break;
- default:
- return 0;
- }
+static int spufs_parse_param(struct fs_context *fc, struct fs_parameter *param)
+{
+ struct spufs_fs_context *ctx = fc->fs_private;
+ struct spufs_sb_info *sbi = fc->s_fs_info;
+ struct fs_parse_result result;
+ kuid_t uid;
+ kgid_t gid;
+ int opt;
+
+ opt = fs_parse(fc, &spufs_fs_parameters, param, &result);
+ if (opt < 0)
+ return opt;
+
+ switch (opt) {
+ case Opt_uid:
+ uid = make_kuid(current_user_ns(), result.uint_32);
+ if (!uid_valid(uid))
+ return invalf(fc, "Unknown uid");
+ ctx->uid = uid;
+ break;
+ case Opt_gid:
+ gid = make_kgid(current_user_ns(), result.uint_32);
+ if (!gid_valid(gid))
+ return invalf(fc, "Unknown gid");
+ ctx->gid = gid;
+ break;
+ case Opt_mode:
+ ctx->mode = result.uint_32 & S_IALLUGO;
+ break;
+ case Opt_debug:
+ sbi->debug = true;
+ break;
}
- return 1;
+
+ return 0;
}
static void spufs_exit_isolated_loader(void)
@@ -697,79 +703,98 @@ spufs_init_isolated_loader(void)
printk(KERN_INFO "spufs: SPU isolation mode enabled\n");
}
-static int
-spufs_create_root(struct super_block *sb, void *data)
+static int spufs_create_root(struct super_block *sb, struct fs_context *fc)
{
+ struct spufs_fs_context *ctx = fc->fs_private;
struct inode *inode;
- int ret;
- ret = -ENODEV;
if (!spu_management_ops)
- goto out;
+ return -ENODEV;
- ret = -ENOMEM;
- inode = spufs_new_inode(sb, S_IFDIR | 0775);
+ inode = spufs_new_inode(sb, S_IFDIR | ctx->mode);
if (!inode)
- goto out;
+ return -ENOMEM;
+ inode->i_uid = ctx->uid;
+ inode->i_gid = ctx->gid;
inode->i_op = &simple_dir_inode_operations;
inode->i_fop = &simple_dir_operations;
SPUFS_I(inode)->i_ctx = NULL;
inc_nlink(inode);
- ret = -EINVAL;
- if (!spufs_parse_options(sb, data, inode))
- goto out_iput;
-
- ret = -ENOMEM;
sb->s_root = d_make_root(inode);
if (!sb->s_root)
- goto out;
-
+ return -ENOMEM;
return 0;
-out_iput:
- iput(inode);
-out:
- return ret;
}
-static int
-spufs_fill_super(struct super_block *sb, void *data, int silent)
-{
- struct spufs_sb_info *info;
- static const struct super_operations s_ops = {
- .alloc_inode = spufs_alloc_inode,
- .destroy_inode = spufs_destroy_inode,
- .statfs = simple_statfs,
- .evict_inode = spufs_evict_inode,
- .show_options = spufs_show_options,
- };
-
- info = kzalloc(sizeof(*info), GFP_KERNEL);
- if (!info)
- return -ENOMEM;
+static const struct super_operations spufs_ops = {
+ .alloc_inode = spufs_alloc_inode,
+ .destroy_inode = spufs_destroy_inode,
+ .statfs = simple_statfs,
+ .evict_inode = spufs_evict_inode,
+ .show_options = spufs_show_options,
+};
+static int spufs_fill_super(struct super_block *sb, struct fs_context *fc)
+{
sb->s_maxbytes = MAX_LFS_FILESIZE;
sb->s_blocksize = PAGE_SIZE;
sb->s_blocksize_bits = PAGE_SHIFT;
sb->s_magic = SPUFS_MAGIC;
- sb->s_op = &s_ops;
- sb->s_fs_info = info;
+ sb->s_op = &spufs_ops;
- return spufs_create_root(sb, data);
+ return spufs_create_root(sb, fc);
+}
+
+static int spufs_get_tree(struct fs_context *fc)
+{
+ return vfs_get_super(fc, vfs_get_single_super, spufs_fill_super);
}
-static struct dentry *
-spufs_mount(struct file_system_type *fstype, int flags,
- const char *name, void *data)
+static void spufs_free_fc(struct fs_context *fc)
{
- return mount_single(fstype, flags, data, spufs_fill_super);
+ kfree(fc->s_fs_info);
+}
+
+static const struct fs_context_operations spufs_context_ops = {
+ .free = spufs_free_fc,
+ .parse_param = spufs_parse_param,
+ .get_tree = spufs_get_tree,
+};
+
+static int spufs_init_fs_context(struct fs_context *fc)
+{
+ struct spufs_fs_context *ctx;
+ struct spufs_sb_info *sbi;
+
+ ctx = kzalloc(sizeof(struct spufs_fs_context), GFP_KERNEL);
+ if (!ctx)
+ goto nomem;
+
+ sbi = kzalloc(sizeof(struct spufs_sb_info), GFP_KERNEL);
+ if (!sbi)
+ goto nomem_ctx;
+
+ ctx->uid = current_uid();
+ ctx->gid = current_gid();
+ ctx->mode = 0755;
+
+ fc->s_fs_info = sbi;
+ fc->ops = &spufs_context_ops;
+ return 0;
+
+nomem_ctx:
+ kfree(ctx);
+nomem:
+ return -ENOMEM;
}
static struct file_system_type spufs_type = {
.owner = THIS_MODULE,
.name = "spufs",
- .mount = spufs_mount,
+ .init_fs_context = spufs_init_fs_context,
+ .parameters = &spufs_fs_parameters,
.kill_sb = kill_litter_super,
};
MODULE_ALIAS_FS("spufs");
^ permalink raw reply related
* [RFC PATCH 0/8] Convert mount_single-using filesystems to fs_context
From: David Howells @ 2019-03-21 11:47 UTC (permalink / raw)
To: viro
Cc: linux-s390, Tony Luck, Kees Cook, Arnd Bergmann,
Rafael J. Wysocki, Greg Kroah-Hartman, Anton Vorontsov,
Heiko Carstens, linux-kernel, Steven Rostedt, dhowells,
linux-fsdevel, Jeremy Kerr, Colin Cross, Martin Schwidefsky,
linuxppc-dev
Hi Al,
Here's a set of patches that converts the mount_single()-using filesystems
to use the new fs_context struct. There may be prerequisite commits in the
branch detailed below.
(1) Add a new keying to vfs_get_super() that indicates that
->reconfigure() should be called instead of (*fill_super)() if the
superblock already exists.
(2) Convert debugfs.
(3) Convert tracefs.
(4) Convert pstore.
(5) Fix a bug in hypfs.
(6) Convert hypfs.
(7) Convert spufs.
(8) Kill off mount_single().
These can be found in the following branch:
http://git.kernel.org/cgit/linux/kernel/git/dhowells/linux-fs.git/log/?h=mount-api-viro
Thanks,
David
---
David Howells (8):
vfs: Add a single-or-reconfig keying to vfs_get_super()
vfs: Convert debugfs to fs_context
vfs: Convert tracefs to fs_context
vfs: Convert pstore to fs_context
hypfs: Fix error number left in struct pointer member
vfs: Convert hypfs to fs_context
vfs: Convert spufs to fs_context
vfs: Kill off mount_single()
Documentation/filesystems/vfs.txt | 4 -
arch/powerpc/platforms/cell/spufs/inode.c | 207 ++++++++++++++++-------------
arch/s390/hypfs/inode.c | 137 +++++++++++--------
fs/debugfs/inode.c | 186 ++++++++++++--------------
fs/pstore/inode.c | 110 ++++++++++-----
fs/super.c | 73 ++--------
fs/tracefs/inode.c | 180 ++++++++++++-------------
include/linux/fs.h | 3
include/linux/fs_context.h | 1
9 files changed, 446 insertions(+), 455 deletions(-)
^ permalink raw reply
* Re: [PATCH v1 00/27] Reduce ifdef mess in hugetlbpage.c and slice.c
From: Christophe Leroy @ 2019-03-21 10:44 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
aneesh.kumar
Cc: linuxppc-dev, linux-kernel
In-Reply-To: <cover.1553076180.git.christophe.leroy@c-s.fr>
This series went through a successfull build test on kisskb:
http://kisskb.ellerman.id.au/kisskb/branch/chleroy/head/f9dc3b2203af4356e9eac2d901126a0dfc5b51f6/
Christophe
Le 20/03/2019 à 11:06, Christophe Leroy a écrit :
> The main purpose of this series is to reduce the amount of #ifdefs in
> hugetlbpage.c and slice.c
>
> At the same time, it does some cleanup by reducing the number of BUG_ON()
> and dropping unused functions.
>
> It also removes 64k pages related code in nohash/64 as 64k pages are
> can only by selected on book3s/64
>
> Christophe Leroy (27):
> powerpc/mm: Don't BUG() in hugepd_page()
> powerpc/mm: don't BUG in add_huge_page_size()
> powerpc/mm: don't BUG() in slice_mask_for_size()
> powerpc/book3e: drop mmu_get_tsize()
> powerpc/mm: drop slice_set_user_psize()
> powerpc/64: only book3s/64 supports CONFIG_PPC_64K_PAGES
> powerpc/book3e: hugetlbpage is only for CONFIG_PPC_FSL_BOOK3E
> powerpc/mm: move __find_linux_pte() out of hugetlbpage.c
> powerpc/mm: make hugetlbpage.c depend on CONFIG_HUGETLB_PAGE
> powerpc/mm: make gup_hugepte() static
> powerpc/mm: split asm/hugetlb.h into dedicated subarch files
> powerpc/mm: add a helper to populate hugepd
> powerpc/mm: define get_slice_psize() all the time
> powerpc/mm: no slice for nohash/64
> powerpc/mm: cleanup ifdef mess in add_huge_page_size()
> powerpc/mm: move hugetlb_disabled into asm/hugetlb.h
> powerpc/mm: cleanup HPAGE_SHIFT setup
> powerpc/mm: cleanup remaining ifdef mess in hugetlbpage.c
> powerpc/mm: drop slice DEBUG
> powerpc/mm: remove unnecessary #ifdef CONFIG_PPC64
> powerpc/mm: hand a context_t over to slice_mask_for_size() instead of
> mm_struct
> powerpc/mm: move slice_mask_for_size() into mmu.h
> powerpc/mm: remove a couple of #ifdef CONFIG_PPC_64K_PAGES in
> mm/slice.c
> powerpc: define subarch SLB_ADDR_LIMIT_DEFAULT
> powerpc/mm: flatten function __find_linux_pte()
> powerpc/mm: flatten function __find_linux_pte() step 2
> powerpc/mm: flatten function __find_linux_pte() step 3
>
> arch/powerpc/Kconfig | 3 +-
> arch/powerpc/include/asm/book3s/64/hugetlb.h | 73 +++++++
> arch/powerpc/include/asm/book3s/64/mmu.h | 22 +-
> arch/powerpc/include/asm/book3s/64/slice.h | 7 +-
> arch/powerpc/include/asm/hugetlb.h | 87 +-------
> arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h | 45 +++++
> arch/powerpc/include/asm/nohash/32/mmu-8xx.h | 18 ++
> arch/powerpc/include/asm/nohash/32/slice.h | 2 +
> arch/powerpc/include/asm/nohash/64/pgalloc.h | 3 -
> arch/powerpc/include/asm/nohash/64/pgtable.h | 4 -
> arch/powerpc/include/asm/nohash/64/slice.h | 12 --
> arch/powerpc/include/asm/nohash/hugetlb-book3e.h | 45 +++++
> arch/powerpc/include/asm/nohash/pte-book3e.h | 5 -
> arch/powerpc/include/asm/page.h | 12 +-
> arch/powerpc/include/asm/pgtable-be-types.h | 7 +-
> arch/powerpc/include/asm/pgtable-types.h | 7 +-
> arch/powerpc/include/asm/pgtable.h | 3 -
> arch/powerpc/include/asm/slice.h | 8 +-
> arch/powerpc/include/asm/task_size_64.h | 2 +-
> arch/powerpc/kernel/fadump.c | 1 +
> arch/powerpc/kernel/setup-common.c | 8 +-
> arch/powerpc/mm/Makefile | 4 +-
> arch/powerpc/mm/hash_utils_64.c | 1 +
> arch/powerpc/mm/hugetlbpage-book3e.c | 52 ++---
> arch/powerpc/mm/hugetlbpage-hash64.c | 16 ++
> arch/powerpc/mm/hugetlbpage.c | 245 ++++-------------------
> arch/powerpc/mm/pgtable.c | 114 +++++++++++
> arch/powerpc/mm/slice.c | 132 ++----------
> arch/powerpc/mm/tlb_low_64e.S | 31 ---
> arch/powerpc/mm/tlb_nohash.c | 13 --
> arch/powerpc/platforms/Kconfig.cputype | 4 +
> 31 files changed, 438 insertions(+), 548 deletions(-)
> create mode 100644 arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h
> delete mode 100644 arch/powerpc/include/asm/nohash/64/slice.h
> create mode 100644 arch/powerpc/include/asm/nohash/hugetlb-book3e.h
>
^ permalink raw reply
* Re: [PATCH v1 11/27] powerpc/mm: split asm/hugetlb.h into dedicated subarch files
From: Christophe Leroy @ 2019-03-21 10:42 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
aneesh.kumar, Russell Currey
Cc: linuxppc-dev, linux-kernel
In-Reply-To: <0049d5686df8fe29cc7a6f45461fe2550d8a4685.1553076180.git.christophe.leroy@c-s.fr>
snowpatch fails applying this.
I usually base my patches on branch merge. Shouldn't snowpatch use merge
branch as well instead of next branch ?
Christophe
Le 20/03/2019 à 11:06, Christophe Leroy a écrit :
> Three subarches support hugepages:
> - fsl book3e
> - book3s/64
> - 8xx
>
> This patch splits asm/hugetlb.h to reduce the #ifdef mess.
>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
> arch/powerpc/include/asm/book3s/64/hugetlb.h | 41 +++++++++++
> arch/powerpc/include/asm/hugetlb.h | 89 ++----------------------
> arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h | 32 +++++++++
> arch/powerpc/include/asm/nohash/hugetlb-book3e.h | 31 +++++++++
> 4 files changed, 108 insertions(+), 85 deletions(-)
> create mode 100644 arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h
> create mode 100644 arch/powerpc/include/asm/nohash/hugetlb-book3e.h
>
> diff --git a/arch/powerpc/include/asm/book3s/64/hugetlb.h b/arch/powerpc/include/asm/book3s/64/hugetlb.h
> index ec2a55a553c7..2f9cf2bc601c 100644
> --- a/arch/powerpc/include/asm/book3s/64/hugetlb.h
> +++ b/arch/powerpc/include/asm/book3s/64/hugetlb.h
> @@ -62,4 +62,45 @@ extern pte_t huge_ptep_modify_prot_start(struct vm_area_struct *vma,
> extern void huge_ptep_modify_prot_commit(struct vm_area_struct *vma,
> unsigned long addr, pte_t *ptep,
> pte_t old_pte, pte_t new_pte);
> +/*
> + * This should work for other subarchs too. But right now we use the
> + * new format only for 64bit book3s
> + */
> +static inline pte_t *hugepd_page(hugepd_t hpd)
> +{
> + if (WARN_ON(!hugepd_ok(hpd)))
> + return NULL;
> + /*
> + * We have only four bits to encode, MMU page size
> + */
> + BUILD_BUG_ON((MMU_PAGE_COUNT - 1) > 0xf);
> + return __va(hpd_val(hpd) & HUGEPD_ADDR_MASK);
> +}
> +
> +static inline unsigned int hugepd_mmu_psize(hugepd_t hpd)
> +{
> + return (hpd_val(hpd) & HUGEPD_SHIFT_MASK) >> 2;
> +}
> +
> +static inline unsigned int hugepd_shift(hugepd_t hpd)
> +{
> + return mmu_psize_to_shift(hugepd_mmu_psize(hpd));
> +}
> +static inline void flush_hugetlb_page(struct vm_area_struct *vma,
> + unsigned long vmaddr)
> +{
> + if (radix_enabled())
> + return radix__flush_hugetlb_page(vma, vmaddr);
> +}
> +
> +static inline pte_t *hugepte_offset(hugepd_t hpd, unsigned long addr,
> + unsigned int pdshift)
> +{
> + unsigned long idx = (addr & ((1UL << pdshift) - 1)) >> hugepd_shift(hpd);
> +
> + return hugepd_page(hpd) + idx;
> +}
> +
> +void flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
> +
> #endif
> diff --git a/arch/powerpc/include/asm/hugetlb.h b/arch/powerpc/include/asm/hugetlb.h
> index 48c29686c78e..fd5c0873a57d 100644
> --- a/arch/powerpc/include/asm/hugetlb.h
> +++ b/arch/powerpc/include/asm/hugetlb.h
> @@ -6,85 +6,13 @@
> #include <asm/page.h>
>
> #ifdef CONFIG_PPC_BOOK3S_64
> -
> #include <asm/book3s/64/hugetlb.h>
> -/*
> - * This should work for other subarchs too. But right now we use the
> - * new format only for 64bit book3s
> - */
> -static inline pte_t *hugepd_page(hugepd_t hpd)
> -{
> - if (WARN_ON(!hugepd_ok(hpd)))
> - return NULL;
> - /*
> - * We have only four bits to encode, MMU page size
> - */
> - BUILD_BUG_ON((MMU_PAGE_COUNT - 1) > 0xf);
> - return __va(hpd_val(hpd) & HUGEPD_ADDR_MASK);
> -}
> -
> -static inline unsigned int hugepd_mmu_psize(hugepd_t hpd)
> -{
> - return (hpd_val(hpd) & HUGEPD_SHIFT_MASK) >> 2;
> -}
> -
> -static inline unsigned int hugepd_shift(hugepd_t hpd)
> -{
> - return mmu_psize_to_shift(hugepd_mmu_psize(hpd));
> -}
> -static inline void flush_hugetlb_page(struct vm_area_struct *vma,
> - unsigned long vmaddr)
> -{
> - if (radix_enabled())
> - return radix__flush_hugetlb_page(vma, vmaddr);
> -}
> -
> -#else
> -
> -static inline pte_t *hugepd_page(hugepd_t hpd)
> -{
> - if (WARN_ON(!hugepd_ok(hpd)))
> - return NULL;
> -#ifdef CONFIG_PPC_8xx
> - return (pte_t *)__va(hpd_val(hpd) & ~HUGEPD_SHIFT_MASK);
> -#else
> - return (pte_t *)((hpd_val(hpd) &
> - ~HUGEPD_SHIFT_MASK) | PD_HUGE);
> -#endif
> -}
> -
> -static inline unsigned int hugepd_shift(hugepd_t hpd)
> -{
> -#ifdef CONFIG_PPC_8xx
> - return ((hpd_val(hpd) & _PMD_PAGE_MASK) >> 1) + 17;
> -#else
> - return hpd_val(hpd) & HUGEPD_SHIFT_MASK;
> -#endif
> -}
> -
> +#elif defined(CONFIG_PPC_FSL_BOOK3E)
> +#include <asm/nohash/hugetlb-book3e.h>
> +#elif defined(CONFIG_PPC_8xx)
> +#include <asm/nohash/32/hugetlb-8xx.h>
> #endif /* CONFIG_PPC_BOOK3S_64 */
>
> -
> -static inline pte_t *hugepte_offset(hugepd_t hpd, unsigned long addr,
> - unsigned pdshift)
> -{
> - /*
> - * On FSL BookE, we have multiple higher-level table entries that
> - * point to the same hugepte. Just use the first one since they're all
> - * identical. So for that case, idx=0.
> - */
> - unsigned long idx = 0;
> -
> - pte_t *dir = hugepd_page(hpd);
> -#ifdef CONFIG_PPC_8xx
> - idx = (addr & ((1UL << pdshift) - 1)) >> PAGE_SHIFT;
> -#elif !defined(CONFIG_PPC_FSL_BOOK3E)
> - idx = (addr & ((1UL << pdshift) - 1)) >> hugepd_shift(hpd);
> -#endif
> -
> - return dir + idx;
> -}
> -
> void flush_dcache_icache_hugepage(struct page *page);
>
> int slice_is_hugepage_only_range(struct mm_struct *mm, unsigned long addr,
> @@ -101,15 +29,6 @@ static inline int is_hugepage_only_range(struct mm_struct *mm,
>
> void book3e_hugetlb_preload(struct vm_area_struct *vma, unsigned long ea,
> pte_t pte);
> -#ifdef CONFIG_PPC_8xx
> -static inline void flush_hugetlb_page(struct vm_area_struct *vma,
> - unsigned long vmaddr)
> -{
> - flush_tlb_page(vma, vmaddr);
> -}
> -#else
> -void flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
> -#endif
>
> #define __HAVE_ARCH_HUGETLB_FREE_PGD_RANGE
> void hugetlb_free_pgd_range(struct mmu_gather *tlb, unsigned long addr,
> diff --git a/arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h b/arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h
> new file mode 100644
> index 000000000000..209e6a219835
> --- /dev/null
> +++ b/arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h
> @@ -0,0 +1,32 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _ASM_POWERPC_NOHASH_32_HUGETLB_8XX_H
> +#define _ASM_POWERPC_NOHASH_32_HUGETLB_8XX_H
> +
> +static inline pte_t *hugepd_page(hugepd_t hpd)
> +{
> + if (WARN_ON(!hugepd_ok(hpd)))
> + return NULL;
> +
> + return (pte_t *)__va(hpd_val(hpd) & ~HUGEPD_SHIFT_MASK);
> +}
> +
> +static inline unsigned int hugepd_shift(hugepd_t hpd)
> +{
> + return ((hpd_val(hpd) & _PMD_PAGE_MASK) >> 1) + 17;
> +}
> +
> +static inline pte_t *hugepte_offset(hugepd_t hpd, unsigned long addr,
> + unsigned int pdshift)
> +{
> + unsigned long idx = (addr & ((1UL << pdshift) - 1)) >> PAGE_SHIFT;
> +
> + return hugepd_page(hpd) + idx;
> +}
> +
> +static inline void flush_hugetlb_page(struct vm_area_struct *vma,
> + unsigned long vmaddr)
> +{
> + flush_tlb_page(vma, vmaddr);
> +}
> +
> +#endif /* _ASM_POWERPC_NOHASH_32_HUGETLB_8XX_H */
> diff --git a/arch/powerpc/include/asm/nohash/hugetlb-book3e.h b/arch/powerpc/include/asm/nohash/hugetlb-book3e.h
> new file mode 100644
> index 000000000000..e94f1cd048ee
> --- /dev/null
> +++ b/arch/powerpc/include/asm/nohash/hugetlb-book3e.h
> @@ -0,0 +1,31 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _ASM_POWERPC_NOHASH_HUGETLB_BOOK3E_H
> +#define _ASM_POWERPC_NOHASH_HUGETLB_BOOK3E_H
> +
> +static inline pte_t *hugepd_page(hugepd_t hpd)
> +{
> + if (WARN_ON(!hugepd_ok(hpd)))
> + return NULL;
> +
> + return (pte_t *)((hpd_val(hpd) & ~HUGEPD_SHIFT_MASK) | PD_HUGE);
> +}
> +
> +static inline unsigned int hugepd_shift(hugepd_t hpd)
> +{
> + return hpd_val(hpd) & HUGEPD_SHIFT_MASK;
> +}
> +
> +static inline pte_t *hugepte_offset(hugepd_t hpd, unsigned long addr,
> + unsigned int pdshift)
> +{
> + /*
> + * On FSL BookE, we have multiple higher-level table entries that
> + * point to the same hugepte. Just use the first one since they're all
> + * identical. So for that case, idx=0.
> + */
> + return hugepd_page(hpd);
> +}
> +
> +void flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
> +
> +#endif /* _ASM_POWERPC_NOHASH_HUGETLB_BOOK3E_H */
>
^ permalink raw reply
* Re: [PATCH v5 05/10] powerpc: Add a framework for Kernel Userspace Access Protection
From: Christophe Leroy @ 2019-03-21 10:21 UTC (permalink / raw)
To: Michael Ellerman, linuxppc-dev; +Cc: npiggin
In-Reply-To: <7fad467c-1e63-02c8-636e-7f8ab456f76c@c-s.fr>
Le 20/03/2019 à 14:04, Christophe Leroy a écrit :
>
>
> Le 20/03/2019 à 13:57, Michael Ellerman a écrit :
>> Christophe Leroy <christophe.leroy@c-s.fr> writes:
>>> Le 08/03/2019 à 02:16, Michael Ellerman a écrit :
>>>> From: Christophe Leroy <christophe.leroy@c-s.fr>
>>>>
>>>> This patch implements a framework for Kernel Userspace Access
>>>> Protection.
>>>>
>>>> Then subarches will have the possibility to provide their own
>>>> implementation by providing setup_kuap() and
>>>> allow/prevent_user_access().
>>>>
>>>> Some platforms will need to know the area accessed and whether it is
>>>> accessed from read, write or both. Therefore source, destination and
>>>> size and handed over to the two functions.
>>>>
>>>> mpe: Rename to allow/prevent rather than unlock/lock, and add
>>>> read/write wrappers. Drop the 32-bit code for now until we have an
>>>> implementation for it. Add kuap to pt_regs for 64-bit as well as
>>>> 32-bit. Don't split strings, use pr_crit_ratelimited().
>>>>
>>>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>>>> Signed-off-by: Russell Currey <ruscur@russell.cc>
>>>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
>>>> ---
>>>> v5: Futex ops need read/write so use allow_user_acccess() there.
>>>> Use #ifdef CONFIG_PPC64 in kup.h to fix build errors.
>>>> Allow subarch to override allow_read/write_from/to_user().
>>>
>>> Those little helpers that will just call allow_user_access() when
>>> distinct read/write handling is not performed looks overkill to me.
>>>
>>> Can't the subarch do it by itself based on the nullity of from/to ?
>>>
>>> static inline void allow_user_access(void __user *to, const void __user
>>> *from,
>>> unsigned long size)
>>> {
>>> if (to & from)
>>> set_kuap(0);
>>> else if (to)
>>> set_kuap(AMR_KUAP_BLOCK_READ);
>>> else if (from)
>>> set_kuap(AMR_KUAP_BLOCK_WRITE);
>>> }
>>
>> You could implement it that way, but it reads better at the call sites
>> if we have:
>>
>> allow_write_to_user(uaddr, sizeof(*uaddr));
>> vs:
>> allow_user_access(uaddr, NULL, sizeof(*uaddr));
>>
>> So I'm inclined to keep them. It should all end up inlined and generate
>> the same code at the end of the day.
>>
>
> I was not suggesting to completly remove allow_write_to_user(), I fully
> agree that it reads better at the call sites.
>
> I was just thinking that allow_write_to_user() could remain generic and
> call the subarch specific allow_user_access() instead of making multiple
> subarch's allow_write_to_user()
Otherwise, could we do something like the following, so that subarches
may implement it or not ?
#ifndef allow_read_from_user
static inline void allow_read_from_user(const void __user *from,
unsigned long size)
{
allow_user_access(NULL, from, size);
}
#endif
#ifndef allow_write_from_user
static inline void allow_write_to_user(void __user *to, unsigned long size)
{
allow_user_access(to, NULL, size);
}
#endif
Christophe
>
> But both solution are OK for me at the end.
>
> Christophe
^ permalink raw reply
* Re: [PATCH] powerpc/highmem: change BUG_ON() to WARN_ON()
From: Christophe Leroy @ 2019-03-21 10:14 UTC (permalink / raw)
To: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras
Cc: linuxppc-dev, linux-kernel
In-Reply-To: <87sgvg1qxk.fsf@concordia.ellerman.id.au>
Le 21/03/2019 à 11:07, Michael Ellerman a écrit :
> Christophe Leroy <christophe.leroy@c-s.fr> writes:
>
>> Le 21/03/2019 à 06:29, Michael Ellerman a écrit :
>>> Christophe Leroy <christophe.leroy@c-s.fr> writes:
>>>> In arch/powerpc/mm/highmem.c, BUG_ON() is called only when
>>>> CONFIG_DEBUG_HIGHMEM is selected, this means the BUG_ON() is
>>>> not vital and can be replaced by a a WARN_ON
>>>>
>>>> At the sametime, use IS_ENABLED() instead of #ifdef to clean a bit.
>>>>
>>>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>>>> ---
>>>> arch/powerpc/mm/highmem.c | 12 ++++--------
>>>> 1 file changed, 4 insertions(+), 8 deletions(-)
>>>>
>>>> diff --git a/arch/powerpc/mm/highmem.c b/arch/powerpc/mm/highmem.c
>>>> index 82a0e37557a5..b68c9f20fbdf 100644
>>>> --- a/arch/powerpc/mm/highmem.c
>>>> +++ b/arch/powerpc/mm/highmem.c
>>>> @@ -56,7 +54,7 @@ EXPORT_SYMBOL(kmap_atomic_prot);
>>>> void __kunmap_atomic(void *kvaddr)
>>>> {
>>>> unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
>>>> - int type __maybe_unused;
>>>> + int type;
>>>
>>> Why don't we move type into the block below.
>>
>> Yes you're right, when Mathieu introduced the __maybe_unused, I was
>> wrongly thinging that kmap_atomic_idx() was doing something important
>> that had to be done also when DEBUG was not selected, but indeed it does
>> nothing else than returning the type.
>>
>> I'll send a new patch.
>
> I can just fix it up when applying.
>
Ok, thanks
Christophe
^ permalink raw reply
* Re: [PATCH] powerpc/highmem: change BUG_ON() to WARN_ON()
From: Michael Ellerman @ 2019-03-21 10:07 UTC (permalink / raw)
To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras
Cc: linuxppc-dev, linux-kernel
In-Reply-To: <9048ba12-a014-3ebe-c414-26f87401c758@c-s.fr>
Christophe Leroy <christophe.leroy@c-s.fr> writes:
> Le 21/03/2019 à 06:29, Michael Ellerman a écrit :
>> Christophe Leroy <christophe.leroy@c-s.fr> writes:
>>> In arch/powerpc/mm/highmem.c, BUG_ON() is called only when
>>> CONFIG_DEBUG_HIGHMEM is selected, this means the BUG_ON() is
>>> not vital and can be replaced by a a WARN_ON
>>>
>>> At the sametime, use IS_ENABLED() instead of #ifdef to clean a bit.
>>>
>>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>>> ---
>>> arch/powerpc/mm/highmem.c | 12 ++++--------
>>> 1 file changed, 4 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/arch/powerpc/mm/highmem.c b/arch/powerpc/mm/highmem.c
>>> index 82a0e37557a5..b68c9f20fbdf 100644
>>> --- a/arch/powerpc/mm/highmem.c
>>> +++ b/arch/powerpc/mm/highmem.c
>>> @@ -56,7 +54,7 @@ EXPORT_SYMBOL(kmap_atomic_prot);
>>> void __kunmap_atomic(void *kvaddr)
>>> {
>>> unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
>>> - int type __maybe_unused;
>>> + int type;
>>
>> Why don't we move type into the block below.
>
> Yes you're right, when Mathieu introduced the __maybe_unused, I was
> wrongly thinging that kmap_atomic_idx() was doing something important
> that had to be done also when DEBUG was not selected, but indeed it does
> nothing else than returning the type.
>
> I'll send a new patch.
I can just fix it up when applying.
cheers
^ permalink raw reply
* Re: [PATCH] powerpc/security: Fix spectre_v2 reporting
From: Diana Madalina Craciun @ 2019-03-21 9:59 UTC (permalink / raw)
To: Michael Ellerman, linuxppc-dev@ozlabs.org
Cc: mikey@neuling.org, msuchanek@suse.de,
andrew.donnellan@au1.ibm.com, dja@axtens.net
In-Reply-To: <20190321042433.20454-1-mpe@ellerman.id.au>
Reviewed-by: Diana Craciun <diana.craciun@nxp.com>
On 3/21/2019 6:24 AM, Michael Ellerman wrote:
> When I updated the spectre_v2 reporting to handle software count cache
> flush I got the logic wrong when there's no software count cache
> enabled at all.
>
> The result is that on systems with the software count cache flush
> disabled we print:
>
> Mitigation: Indirect branch cache disabled, Software count cache flush
>
> Which correctly indicates that the count cache is disabled, but
> incorrectly says the software count cache flush is enabled.
>
> The root of the problem is that we are trying to handle all
> combinations of options. But we know now that we only expect to see
> the software count cache flush enabled if the other options are false.
>
> So split the two cases, which simplifies the logic and fixes the bug.
> We were also missing a space before "(hardware accelerated)".
>
> The result is we see one of:
>
> Mitigation: Indirect branch serialisation (kernel only)
> Mitigation: Indirect branch cache disabled
> Mitigation: Software count cache flush
> Mitigation: Software count cache flush (hardware accelerated)
>
> Fixes: ee13cb249fab ("powerpc/64s: Add support for software count cache flush")
> Cc: stable@vger.kernel.org # v4.19+
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
> arch/powerpc/kernel/security.c | 23 ++++++++---------------
> 1 file changed, 8 insertions(+), 15 deletions(-)
>
> diff --git a/arch/powerpc/kernel/security.c b/arch/powerpc/kernel/security.c
> index 9b8631533e02..b33bafb8fcea 100644
> --- a/arch/powerpc/kernel/security.c
> +++ b/arch/powerpc/kernel/security.c
> @@ -190,29 +190,22 @@ ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr, c
> bcs = security_ftr_enabled(SEC_FTR_BCCTRL_SERIALISED);
> ccd = security_ftr_enabled(SEC_FTR_COUNT_CACHE_DISABLED);
>
> - if (bcs || ccd || count_cache_flush_type != COUNT_CACHE_FLUSH_NONE) {
> - bool comma = false;
> + if (bcs || ccd) {
> seq_buf_printf(&s, "Mitigation: ");
>
> - if (bcs) {
> + if (bcs)
> seq_buf_printf(&s, "Indirect branch serialisation (kernel only)");
> - comma = true;
> - }
>
> - if (ccd) {
> - if (comma)
> - seq_buf_printf(&s, ", ");
> - seq_buf_printf(&s, "Indirect branch cache disabled");
> - comma = true;
> - }
> -
> - if (comma)
> + if (bcs && ccd)
> seq_buf_printf(&s, ", ");
>
> - seq_buf_printf(&s, "Software count cache flush");
> + if (ccd)
> + seq_buf_printf(&s, "Indirect branch cache disabled");
> + } else if (count_cache_flush_type != COUNT_CACHE_FLUSH_NONE) {
> + seq_buf_printf(&s, "Mitigation: Software count cache flush");
>
> if (count_cache_flush_type == COUNT_CACHE_FLUSH_HW)
> - seq_buf_printf(&s, "(hardware accelerated)");
> + seq_buf_printf(&s, " (hardware accelerated)");
> } else if (btb_flush_enabled) {
> seq_buf_printf(&s, "Mitigation: Branch predictor state flush");
> } else {
^ permalink raw reply
* Re: [PATCH v4 06/17] KVM: PPC: Book3S HV: XIVE: add controls for the EQ configuration
From: Cédric Le Goater @ 2019-03-21 8:48 UTC (permalink / raw)
To: David Gibson; +Cc: linuxppc-dev, Paul Mackerras, kvm, kvm-ppc
In-Reply-To: <20190320230956.GA2501@umbus.fritz.box>
On 3/21/19 12:09 AM, David Gibson wrote:
> On Wed, Mar 20, 2019 at 09:37:40AM +0100, Cédric Le Goater wrote:
>> These controls will be used by the H_INT_SET_QUEUE_CONFIG and
>> H_INT_GET_QUEUE_CONFIG hcalls from QEMU to configure the underlying
>> Event Queue in the XIVE IC. They will also be used to restore the
>> configuration of the XIVE EQs and to capture the internal run-time
>> state of the EQs. Both 'get' and 'set' rely on an OPAL call to access
>> the EQ toggle bit and EQ index which are updated by the XIVE IC when
>> event notifications are enqueued in the EQ.
>>
>> The value of the guest physical address of the event queue is saved in
>> the XIVE internal xive_q structure for later use. That is when
>> migration needs to mark the EQ pages dirty to capture a consistent
>> memory state of the VM.
>>
>> To be noted that H_INT_SET_QUEUE_CONFIG does not require the extra
>> OPAL call setting the EQ toggle bit and EQ index to configure the EQ,
>> but restoring the EQ state will.
>>
>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>> ---
>>
>> Changes since v3 :
>>
>> - fix the test ont the initial setting of the EQ toggle bit : 0 -> 1
>> - renamed qsize to qshift
>> - renamed qpage to qaddr
>> - checked host page size
>> - limited flags to KVM_XIVE_EQ_ALWAYS_NOTIFY to fit sPAPR specs
>>
>> Changes since v2 :
>>
>> - fixed comments on the KVM device attribute definitions
>> - fixed check on supported EQ size to restrict to 64K pages
>> - checked kvm_eq.flags that need to be zero
>> - removed the OPAL call when EQ qtoggle bit and index are zero.
>>
>> arch/powerpc/include/asm/xive.h | 2 +
>> arch/powerpc/include/uapi/asm/kvm.h | 19 ++
>> arch/powerpc/kvm/book3s_xive.h | 2 +
>> arch/powerpc/kvm/book3s_xive.c | 15 +-
>> arch/powerpc/kvm/book3s_xive_native.c | 242 +++++++++++++++++++++
>> Documentation/virtual/kvm/devices/xive.txt | 34 +++
>> 6 files changed, 308 insertions(+), 6 deletions(-)
>>
>> diff --git a/arch/powerpc/include/asm/xive.h b/arch/powerpc/include/asm/xive.h
>> index b579a943407b..c4e88abd3b67 100644
>> --- a/arch/powerpc/include/asm/xive.h
>> +++ b/arch/powerpc/include/asm/xive.h
>> @@ -73,6 +73,8 @@ struct xive_q {
>> u32 esc_irq;
>> atomic_t count;
>> atomic_t pending_count;
>> + u64 guest_qaddr;
>> + u32 guest_qshift;
>> };
>>
>> /* Global enable flags for the XIVE support */
>> diff --git a/arch/powerpc/include/uapi/asm/kvm.h b/arch/powerpc/include/uapi/asm/kvm.h
>> index e8161e21629b..85005400fd86 100644
>> --- a/arch/powerpc/include/uapi/asm/kvm.h
>> +++ b/arch/powerpc/include/uapi/asm/kvm.h
>> @@ -681,6 +681,7 @@ struct kvm_ppc_cpu_char {
>> #define KVM_DEV_XIVE_GRP_CTRL 1
>> #define KVM_DEV_XIVE_GRP_SOURCE 2 /* 64-bit source identifier */
>> #define KVM_DEV_XIVE_GRP_SOURCE_CONFIG 3 /* 64-bit source identifier */
>> +#define KVM_DEV_XIVE_GRP_EQ_CONFIG 4 /* 64-bit EQ identifier */
>>
>> /* Layout of 64-bit XIVE source attribute values */
>> #define KVM_XIVE_LEVEL_SENSITIVE (1ULL << 0)
>> @@ -696,4 +697,22 @@ struct kvm_ppc_cpu_char {
>> #define KVM_XIVE_SOURCE_EISN_SHIFT 33
>> #define KVM_XIVE_SOURCE_EISN_MASK 0xfffffffe00000000ULL
>>
>> +/* Layout of 64-bit EQ identifier */
>> +#define KVM_XIVE_EQ_PRIORITY_SHIFT 0
>> +#define KVM_XIVE_EQ_PRIORITY_MASK 0x7
>> +#define KVM_XIVE_EQ_SERVER_SHIFT 3
>> +#define KVM_XIVE_EQ_SERVER_MASK 0xfffffff8ULL
>> +
>> +/* Layout of EQ configuration values (64 bytes) */
>> +struct kvm_ppc_xive_eq {
>> + __u32 flags;
>> + __u32 qshift;
>> + __u64 qaddr;
>> + __u32 qtoggle;
>> + __u32 qindex;
>> + __u8 pad[40];
>> +};
>> +
>> +#define KVM_XIVE_EQ_ALWAYS_NOTIFY 0x00000001
>> +
>> #endif /* __LINUX_KVM_POWERPC_H */
>> diff --git a/arch/powerpc/kvm/book3s_xive.h b/arch/powerpc/kvm/book3s_xive.h
>> index ae26fe653d98..622f594d93e1 100644
>> --- a/arch/powerpc/kvm/book3s_xive.h
>> +++ b/arch/powerpc/kvm/book3s_xive.h
>> @@ -272,6 +272,8 @@ struct kvmppc_xive_src_block *kvmppc_xive_create_src_block(
>> struct kvmppc_xive *xive, int irq);
>> void kvmppc_xive_free_sources(struct kvmppc_xive_src_block *sb);
>> int kvmppc_xive_select_target(struct kvm *kvm, u32 *server, u8 prio);
>> +int kvmppc_xive_attach_escalation(struct kvm_vcpu *vcpu, u8 prio,
>> + bool single_escalation);
>>
>> #endif /* CONFIG_KVM_XICS */
>> #endif /* _KVM_PPC_BOOK3S_XICS_H */
>> diff --git a/arch/powerpc/kvm/book3s_xive.c b/arch/powerpc/kvm/book3s_xive.c
>> index e09f3addffe5..c1b7aa7dbc28 100644
>> --- a/arch/powerpc/kvm/book3s_xive.c
>> +++ b/arch/powerpc/kvm/book3s_xive.c
>> @@ -166,7 +166,8 @@ static irqreturn_t xive_esc_irq(int irq, void *data)
>> return IRQ_HANDLED;
>> }
>>
>> -static int xive_attach_escalation(struct kvm_vcpu *vcpu, u8 prio)
>> +int kvmppc_xive_attach_escalation(struct kvm_vcpu *vcpu, u8 prio,
>> + bool single_escalation)
>> {
>> struct kvmppc_xive_vcpu *xc = vcpu->arch.xive_vcpu;
>> struct xive_q *q = &xc->queues[prio];
>> @@ -185,7 +186,7 @@ static int xive_attach_escalation(struct kvm_vcpu *vcpu, u8 prio)
>> return -EIO;
>> }
>>
>> - if (xc->xive->single_escalation)
>> + if (single_escalation)
>> name = kasprintf(GFP_KERNEL, "kvm-%d-%d",
>> vcpu->kvm->arch.lpid, xc->server_num);
>> else
>> @@ -217,7 +218,7 @@ static int xive_attach_escalation(struct kvm_vcpu *vcpu, u8 prio)
>> * interrupt, thus leaving it effectively masked after
>> * it fires once.
>> */
>> - if (xc->xive->single_escalation) {
>> + if (single_escalation) {
>> struct irq_data *d = irq_get_irq_data(xc->esc_virq[prio]);
>> struct xive_irq_data *xd = irq_data_get_irq_handler_data(d);
>>
>> @@ -291,7 +292,8 @@ static int xive_check_provisioning(struct kvm *kvm, u8 prio)
>> continue;
>> rc = xive_provision_queue(vcpu, prio);
>> if (rc == 0 && !xive->single_escalation)
>> - xive_attach_escalation(vcpu, prio);
>> + kvmppc_xive_attach_escalation(vcpu, prio,
>> + xive->single_escalation);
>> if (rc)
>> return rc;
>> }
>> @@ -1214,7 +1216,8 @@ int kvmppc_xive_connect_vcpu(struct kvm_device *dev,
>> if (xive->qmap & (1 << i)) {
>> r = xive_provision_queue(vcpu, i);
>> if (r == 0 && !xive->single_escalation)
>> - xive_attach_escalation(vcpu, i);
>> + kvmppc_xive_attach_escalation(
>> + vcpu, i, xive->single_escalation);
>> if (r)
>> goto bail;
>> } else {
>> @@ -1229,7 +1232,7 @@ int kvmppc_xive_connect_vcpu(struct kvm_device *dev,
>> }
>>
>> /* If not done above, attach priority 0 escalation */
>> - r = xive_attach_escalation(vcpu, 0);
>> + r = kvmppc_xive_attach_escalation(vcpu, 0, xive->single_escalation);
>> if (r)
>> goto bail;
>>
>> diff --git a/arch/powerpc/kvm/book3s_xive_native.c b/arch/powerpc/kvm/book3s_xive_native.c
>> index 492825a35958..2c335454da72 100644
>> --- a/arch/powerpc/kvm/book3s_xive_native.c
>> +++ b/arch/powerpc/kvm/book3s_xive_native.c
>> @@ -335,6 +335,236 @@ static int kvmppc_xive_native_set_source_config(struct kvmppc_xive *xive,
>> priority, masked, eisn);
>> }
>>
>> +static int xive_native_validate_queue_size(u32 qshift)
>> +{
>> + /*
>> + * We only support 64K pages for the moment. This is also
>> + * advertised in the DT property "ibm,xive-eq-sizes"
>> + */
>> + switch (qshift) {
>> + case 0: /* EQ reset */
>> + case 16:
>> + return 0;
>> + case 12:
>> + case 21:
>> + case 24:
>> + default:
>> + return -EINVAL;
>
> Now that you're doing a proper test against the guest page size, it
> would be very easy to allow this to support things other than a 64kiB
> queue. That can be a followup change, though.
Supporting larger page sizes could be interesting for AIX or Linux. Talking
of which, we should start with QEMU.
>
>> + }
>> +}
>> +
>> +static int kvmppc_xive_native_set_queue_config(struct kvmppc_xive *xive,
>> + long eq_idx, u64 addr)
>> +{
>> + struct kvm *kvm = xive->kvm;
>> + struct kvm_vcpu *vcpu;
>> + struct kvmppc_xive_vcpu *xc;
>> + void __user *ubufp = (void __user *) addr;
>> + u32 server;
>> + u8 priority;
>> + struct kvm_ppc_xive_eq kvm_eq;
>> + int rc;
>> + __be32 *qaddr = 0;
>> + struct page *page;
>> + struct xive_q *q;
>> + gfn_t gfn;
>> + unsigned long page_size;
>> +
>> + /*
>> + * Demangle priority/server tuple from the EQ identifier
>> + */
>> + priority = (eq_idx & KVM_XIVE_EQ_PRIORITY_MASK) >>
>> + KVM_XIVE_EQ_PRIORITY_SHIFT;
>> + server = (eq_idx & KVM_XIVE_EQ_SERVER_MASK) >>
>> + KVM_XIVE_EQ_SERVER_SHIFT;
>> +
>> + if (copy_from_user(&kvm_eq, ubufp, sizeof(kvm_eq)))
>> + return -EFAULT;
>> +
>> + vcpu = kvmppc_xive_find_server(kvm, server);
>> + if (!vcpu) {
>> + pr_err("Can't find server %d\n", server);
>> + return -ENOENT;
>> + }
>> + xc = vcpu->arch.xive_vcpu;
>> +
>> + if (priority != xive_prio_from_guest(priority)) {
>> + pr_err("Trying to restore invalid queue %d for VCPU %d\n",
>> + priority, server);
>> + return -EINVAL;
>> + }
>> + q = &xc->queues[priority];
>> +
>> + pr_devel("%s VCPU %d priority %d fl:%x shift:%d addr:%llx g:%d idx:%d\n",
>> + __func__, server, priority, kvm_eq.flags,
>> + kvm_eq.qshift, kvm_eq.qaddr, kvm_eq.qtoggle, kvm_eq.qindex);
>> +
>> + /*
>> + * sPAPR specifies a "Unconditional Notify (n) flag" for the
>> + * H_INT_SET_QUEUE_CONFIG hcall which forces notification
>> + * without using the coalescing mechanisms provided by the
>> + * XIVE END ESBs.
>> + */
>> + if (kvm_eq.flags & ~KVM_XIVE_EQ_ALWAYS_NOTIFY) {
>> + pr_err("invalid flags %d\n", kvm_eq.flags);
>> + return -EINVAL;
>> + }
>
> So this test prevents setting any (as yet undefined) flags other than
> EQ_ALWAYS_NOTIFY, which is good. However, AFAICT you never actually
> branch based on whether the EQ_ALWAYS_NOTIFY flag is set - you just
> assume that it is.
Yes because it is enforced by xive_native_configure_queue().
> You should either actually pass this flag through
> to the OPAL call, or have another test here which rejects the ioctl()
> if the flag is *not* set.
Indeed. Linux/PowerNV and KVM require this flag to be set, I should error
out if this is not the case. It is safer.
>> +
>> + rc = xive_native_validate_queue_size(kvm_eq.qshift);
>> + if (rc) {
>> + pr_err("invalid queue size %d\n", kvm_eq.qshift);
>> + return rc;
>> + }
>> +
>> + /* reset queue and disable queueing */
>> + if (!kvm_eq.qshift) {
>> + q->guest_qaddr = 0;
>> + q->guest_qshift = 0;
>> +
>> + rc = xive_native_configure_queue(xc->vp_id, q, priority,
>> + NULL, 0, true);
>> + if (rc) {
>> + pr_err("Failed to reset queue %d for VCPU %d: %d\n",
>> + priority, xc->server_num, rc);
>> + return rc;
>> + }
>> +
>> + if (q->qpage) {
>> + put_page(virt_to_page(q->qpage));
>> + q->qpage = NULL;
>> + }
>> +
>> + return 0;
>> + }
>> +
>> + gfn = gpa_to_gfn(kvm_eq.qaddr);
>> + page = gfn_to_page(kvm, gfn);
>> + if (is_error_page(page)) {
>> + pr_warn("Couldn't get guest page for %llx!\n", kvm_eq.qaddr);
>> + return -EINVAL;
>> + }
>> +
>> + page_size = kvm_host_page_size(kvm, gfn);
>> + if (1ull << kvm_eq.qshift > page_size) {
>> + pr_warn("Incompatible host page size %lx!\n", page_size);
>> + return -EINVAL;
>> + }
>
> Sorry.. I should have thought of this earlier. If qaddr isn't aligned
> to a (page_size) boundary, this test isn't sufficient - you need to
> make sure the whole thing fits within the host page, even if it's
> offset.
>
> Alternatively, you could check that qaddr is naturally aligned for the
> requested qshift. Possibly that's necessary for the hardware anyway.
Indeed again, it should be "naturally aligned". I will add an extra test
for this. QEMU will need it also btw.
Thanks,
C.
>> +
>> + qaddr = page_to_virt(page) + (kvm_eq.qaddr & ~PAGE_MASK);
>> +
>> + /*
>> + * Backup the queue page guest address to the mark EQ page
>> + * dirty for migration.
>> + */
>> + q->guest_qaddr = kvm_eq.qaddr;
>> + q->guest_qshift = kvm_eq.qshift;
>> +
>> + /*
>> + * Unconditional Notification is forced by default at the
>> + * OPAL level because the use of END ESBs is not supported by
>> + * Linux.
>> + */
>> + rc = xive_native_configure_queue(xc->vp_id, q, priority,
>> + (__be32 *) qaddr, kvm_eq.qshift, true);
>> + if (rc) {
>> + pr_err("Failed to configure queue %d for VCPU %d: %d\n",
>> + priority, xc->server_num, rc);
>> + put_page(page);
>> + return rc;
>> + }
>> +
>> + /*
>> + * Only restore the queue state when needed. When doing the
>> + * H_INT_SET_SOURCE_CONFIG hcall, it should not.
>> + */
>> + if (kvm_eq.qtoggle != 1 || kvm_eq.qindex != 0) {
>> + rc = xive_native_set_queue_state(xc->vp_id, priority,
>> + kvm_eq.qtoggle,
>> + kvm_eq.qindex);
>> + if (rc)
>> + goto error;
>> + }
>> +
>> + rc = kvmppc_xive_attach_escalation(vcpu, priority,
>> + xive->single_escalation);
>> +error:
>> + if (rc)
>> + kvmppc_xive_native_cleanup_queue(vcpu, priority);
>> + return rc;
>> +}
>> +
>> +static int kvmppc_xive_native_get_queue_config(struct kvmppc_xive *xive,
>> + long eq_idx, u64 addr)
>> +{
>> + struct kvm *kvm = xive->kvm;
>> + struct kvm_vcpu *vcpu;
>> + struct kvmppc_xive_vcpu *xc;
>> + struct xive_q *q;
>> + void __user *ubufp = (u64 __user *) addr;
>> + u32 server;
>> + u8 priority;
>> + struct kvm_ppc_xive_eq kvm_eq;
>> + u64 qaddr;
>> + u64 qshift;
>> + u64 qeoi_page;
>> + u32 escalate_irq;
>> + u64 qflags;
>> + int rc;
>> +
>> + /*
>> + * Demangle priority/server tuple from the EQ identifier
>> + */
>> + priority = (eq_idx & KVM_XIVE_EQ_PRIORITY_MASK) >>
>> + KVM_XIVE_EQ_PRIORITY_SHIFT;
>> + server = (eq_idx & KVM_XIVE_EQ_SERVER_MASK) >>
>> + KVM_XIVE_EQ_SERVER_SHIFT;
>> +
>> + vcpu = kvmppc_xive_find_server(kvm, server);
>> + if (!vcpu) {
>> + pr_err("Can't find server %d\n", server);
>> + return -ENOENT;
>> + }
>> + xc = vcpu->arch.xive_vcpu;
>> +
>> + if (priority != xive_prio_from_guest(priority)) {
>> + pr_err("invalid priority for queue %d for VCPU %d\n",
>> + priority, server);
>> + return -EINVAL;
>> + }
>> + q = &xc->queues[priority];
>> +
>> + memset(&kvm_eq, 0, sizeof(kvm_eq));
>> +
>> + if (!q->qpage)
>> + return 0;
>> +
>> + rc = xive_native_get_queue_info(xc->vp_id, priority, &qaddr, &qshift,
>> + &qeoi_page, &escalate_irq, &qflags);
>> + if (rc)
>> + return rc;
>> +
>> + kvm_eq.flags = 0;
>> + if (qflags & OPAL_XIVE_EQ_ALWAYS_NOTIFY)
>> + kvm_eq.flags |= KVM_XIVE_EQ_ALWAYS_NOTIFY;
>> +
>> + kvm_eq.qshift = q->guest_qshift;
>> + kvm_eq.qaddr = q->guest_qaddr;
>> +
>> + rc = xive_native_get_queue_state(xc->vp_id, priority, &kvm_eq.qtoggle,
>> + &kvm_eq.qindex);
>> + if (rc)
>> + return rc;
>> +
>> + pr_devel("%s VCPU %d priority %d fl:%x shift:%d addr:%llx g:%d idx:%d\n",
>> + __func__, server, priority, kvm_eq.flags,
>> + kvm_eq.qshift, kvm_eq.qaddr, kvm_eq.qtoggle, kvm_eq.qindex);
>> +
>> + if (copy_to_user(ubufp, &kvm_eq, sizeof(kvm_eq)))
>> + return -EFAULT;
>> +
>> + return 0;
>> +}
>> +
>> static int kvmppc_xive_native_set_attr(struct kvm_device *dev,
>> struct kvm_device_attr *attr)
>> {
>> @@ -349,6 +579,9 @@ static int kvmppc_xive_native_set_attr(struct kvm_device *dev,
>> case KVM_DEV_XIVE_GRP_SOURCE_CONFIG:
>> return kvmppc_xive_native_set_source_config(xive, attr->attr,
>> attr->addr);
>> + case KVM_DEV_XIVE_GRP_EQ_CONFIG:
>> + return kvmppc_xive_native_set_queue_config(xive, attr->attr,
>> + attr->addr);
>> }
>> return -ENXIO;
>> }
>> @@ -356,6 +589,13 @@ static int kvmppc_xive_native_set_attr(struct kvm_device *dev,
>> static int kvmppc_xive_native_get_attr(struct kvm_device *dev,
>> struct kvm_device_attr *attr)
>> {
>> + struct kvmppc_xive *xive = dev->private;
>> +
>> + switch (attr->group) {
>> + case KVM_DEV_XIVE_GRP_EQ_CONFIG:
>> + return kvmppc_xive_native_get_queue_config(xive, attr->attr,
>> + attr->addr);
>> + }
>> return -ENXIO;
>> }
>>
>> @@ -371,6 +611,8 @@ static int kvmppc_xive_native_has_attr(struct kvm_device *dev,
>> attr->attr < KVMPPC_XIVE_NR_IRQS)
>> return 0;
>> break;
>> + case KVM_DEV_XIVE_GRP_EQ_CONFIG:
>> + return 0;
>> }
>> return -ENXIO;
>> }
>> diff --git a/Documentation/virtual/kvm/devices/xive.txt b/Documentation/virtual/kvm/devices/xive.txt
>> index 33c64b2cdbe8..8bb5e6e6923a 100644
>> --- a/Documentation/virtual/kvm/devices/xive.txt
>> +++ b/Documentation/virtual/kvm/devices/xive.txt
>> @@ -53,3 +53,37 @@ the legacy interrupt mode, referred as XICS (POWER7/8).
>> -ENXIO: CPU event queues not configured or configuration of the
>> underlying HW interrupt failed
>> -EBUSY: No CPU available to serve interrupt
>> +
>> + 4. KVM_DEV_XIVE_GRP_EQ_CONFIG (read-write)
>> + Configures an event queue of a CPU
>> + Attributes:
>> + EQ descriptor identifier (64-bit)
>> + The EQ descriptor identifier is a tuple (server, priority) :
>> + bits: | 63 .... 32 | 31 .. 3 | 2 .. 0
>> + values: | unused | server | priority
>> + The kvm_device_attr.addr points to :
>> + struct kvm_ppc_xive_eq {
>> + __u32 flags;
>> + __u32 qshift;
>> + __u64 qaddr;
>> + __u32 qtoggle;
>> + __u32 qindex;
>> + __u8 pad[40];
>> + };
>> + - flags: queue flags
>> + KVM_XIVE_EQ_ALWAYS_NOTIFY
>> + forces notification without using the coalescing mechanism
>> + provided by the XIVE END ESBs.
>> + - qshift: queue size (power of 2)
>> + - qaddr: real address of queue
>> + - qtoggle: current queue toggle bit
>> + - qindex: current queue index
>> + - pad: reserved for future use
>> + Errors:
>> + -ENOENT: Invalid CPU number
>> + -EINVAL: Invalid priority
>> + -EINVAL: Invalid flags
>> + -EINVAL: Invalid queue size
>> + -EINVAL: Invalid queue address
>> + -EFAULT: Invalid user pointer for attr->addr.
>> + -EIO: Configuration of the underlying HW failed
>
^ permalink raw reply
* Re: [PATCH] compiler: allow all arches to enable CONFIG_OPTIMIZE_INLINING
From: Heiko Carstens @ 2019-03-21 8:01 UTC (permalink / raw)
To: Masahiro Yamada
Cc: linux-arch, linux-s390, Dave Hansen, Arnd Bergmann, x86,
linux-mips, linux-kernel, Paul Burton, Ingo Molnar, linux-mtd,
Andrew Morton, linuxppc-dev, linux-arm-kernel
In-Reply-To: <1553062828-27798-1-git-send-email-yamada.masahiro@socionext.com>
On Wed, Mar 20, 2019 at 03:20:27PM +0900, Masahiro Yamada wrote:
> Commit 60a3cdd06394 ("x86: add optimized inlining") introduced
> CONFIG_OPTIMIZE_INLINING, but it has been available only for x86.
>
> The idea is obviously arch-agnostic although we need some code fixups.
> This commit moves the config entry from arch/x86/Kconfig.debug to
> lib/Kconfig.debug so that all architectures (except MIPS for now) can
> benefit from it.
>
> At this moment, I added "depends on !MIPS" because fixing 0day bot reports
> for MIPS was complex to me.
>
> I tested this patch on my arm/arm64 boards.
>
> This can make a huge difference in kernel image size especially when
> CONFIG_OPTIMIZE_FOR_SIZE is enabled.
>
> For example, I got 3.5% smaller arm64 kernel image for v5.1-rc1.
>
> dec file
> 18983424 arch/arm64/boot/Image.before
> 18321920 arch/arm64/boot/Image.after
Well, this will change, since now people (have to) start adding
__always_inline annotations on all architectures, most likely until
all have about the same amount of annotations like x86. This will
reduce the benefit.
Not sure if it's really a win that we get the inline vs
__always_inline discussion now on all architectures.
^ permalink raw reply
* Re: [PATCH] powerpc/security: Fix spectre_v2 reporting
From: Michael Neuling @ 2019-03-21 6:29 UTC (permalink / raw)
To: Michael Ellerman, linuxppc-dev
Cc: diana.craciun, msuchanek, andrew.donnellan, dja
In-Reply-To: <20190321042433.20454-1-mpe@ellerman.id.au>
On Thu, 2019-03-21 at 15:24 +1100, Michael Ellerman wrote:
> When I updated the spectre_v2 reporting to handle software count cache
> flush I got the logic wrong when there's no software count cache
> enabled at all.
>
> The result is that on systems with the software count cache flush
> disabled we print:
>
> Mitigation: Indirect branch cache disabled, Software count cache flush
>
> Which correctly indicates that the count cache is disabled, but
> incorrectly says the software count cache flush is enabled.
>
> The root of the problem is that we are trying to handle all
> combinations of options. But we know now that we only expect to see
> the software count cache flush enabled if the other options are false.
>
> So split the two cases, which simplifies the logic and fixes the bug.
> We were also missing a space before "(hardware accelerated)".
>
> The result is we see one of:
>
> Mitigation: Indirect branch serialisation (kernel only)
> Mitigation: Indirect branch cache disabled
> Mitigation: Software count cache flush
> Mitigation: Software count cache flush (hardware accelerated)
>
> Fixes: ee13cb249fab ("powerpc/64s: Add support for software count cache flush")
> Cc: stable@vger.kernel.org # v4.19+
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
LGTM
Reviewed-by: Michael Neuling <mikey@neuling.org>
> ---
> arch/powerpc/kernel/security.c | 23 ++++++++---------------
> 1 file changed, 8 insertions(+), 15 deletions(-)
>
> diff --git a/arch/powerpc/kernel/security.c b/arch/powerpc/kernel/security.c
> index 9b8631533e02..b33bafb8fcea 100644
> --- a/arch/powerpc/kernel/security.c
> +++ b/arch/powerpc/kernel/security.c
> @@ -190,29 +190,22 @@ ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr, c
> bcs = security_ftr_enabled(SEC_FTR_BCCTRL_SERIALISED);
> ccd = security_ftr_enabled(SEC_FTR_COUNT_CACHE_DISABLED);
>
> - if (bcs || ccd || count_cache_flush_type != COUNT_CACHE_FLUSH_NONE) {
> - bool comma = false;
> + if (bcs || ccd) {
> seq_buf_printf(&s, "Mitigation: ");
>
> - if (bcs) {
> + if (bcs)
> seq_buf_printf(&s, "Indirect branch serialisation (kernel only)");
> - comma = true;
> - }
>
> - if (ccd) {
> - if (comma)
> - seq_buf_printf(&s, ", ");
> - seq_buf_printf(&s, "Indirect branch cache disabled");
> - comma = true;
> - }
> -
> - if (comma)
> + if (bcs && ccd)
> seq_buf_printf(&s, ", ");
>
> - seq_buf_printf(&s, "Software count cache flush");
> + if (ccd)
> + seq_buf_printf(&s, "Indirect branch cache disabled");
> + } else if (count_cache_flush_type != COUNT_CACHE_FLUSH_NONE) {
> + seq_buf_printf(&s, "Mitigation: Software count cache flush");
>
> if (count_cache_flush_type == COUNT_CACHE_FLUSH_HW)
> - seq_buf_printf(&s, "(hardware accelerated)");
> + seq_buf_printf(&s, " (hardware accelerated)");
> } else if (btb_flush_enabled) {
> seq_buf_printf(&s, "Mitigation: Branch predictor state flush");
> } else {
^ permalink raw reply
* Re: [RFC PATCH 1/1] KVM: PPC: Report single stepping capability
From: Alexey Kardashevskiy @ 2019-03-21 4:44 UTC (permalink / raw)
To: Fabiano Rosas, kvm-ppc; +Cc: kvm, rkrcmar, pbonzini, linuxppc-dev, david
In-Reply-To: <20190320183951.29537-2-farosas@linux.ibm.com>
On 21/03/2019 05:39, Fabiano Rosas wrote:
> When calling the KVM_SET_GUEST_DEBUG ioctl, userspace might request
> the next instruction to be single stepped via the
> KVM_GUESTDBG_SINGLESTEP control bit of the kvm_guest_debug structure.
>
> We currently don't have support for guest single stepping implemented
> in Book3S HV.
>
> This patch adds the KVM_CAP_PPC_GUEST_DEBUG_SSTEP capability in order
> to inform userspace about the state of single stepping support.
>
> Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
> ---
> arch/powerpc/kvm/powerpc.c | 5 +++++
> include/uapi/linux/kvm.h | 1 +
> 2 files changed, 6 insertions(+)
>
> diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
> index 8885377ec3e0..5ba990b0ec74 100644
> --- a/arch/powerpc/kvm/powerpc.c
> +++ b/arch/powerpc/kvm/powerpc.c
> @@ -538,6 +538,11 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
> case KVM_CAP_IMMEDIATE_EXIT:
> r = 1;
> break;
> + case KVM_CAP_PPC_GUEST_DEBUG_SSTEP:
> +#ifdef CONFIG_BOOKE
In the cover letter (which is not really required for a single patch)
you say the capability will be present for BookE and PR KVM (which
Book3s) but here it is BookE only, is that intentional?
Also, you need to update Documentation/virtual/kvm/api.txt for the new
capability. After reading which I started wondering could not we just
use existing KVM_CAP_GUEST_DEBUG_HW_BPS?
> + r = 1;
> + break;
> +#endif
> case KVM_CAP_PPC_PAIRED_SINGLES:
> case KVM_CAP_PPC_OSI:
> case KVM_CAP_PPC_GET_PVINFO:
> diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
> index 6d4ea4b6c922..33e8a4db867e 100644
> --- a/include/uapi/linux/kvm.h
> +++ b/include/uapi/linux/kvm.h
> @@ -988,6 +988,7 @@ struct kvm_ppc_resize_hpt {
> #define KVM_CAP_ARM_VM_IPA_SIZE 165
> #define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT 166
> #define KVM_CAP_HYPERV_CPUID 167
> +#define KVM_CAP_PPC_GUEST_DEBUG_SSTEP 168
>
> #ifdef KVM_CAP_IRQ_ROUTING
>
>
--
Alexey
^ permalink raw reply
* Re: [PATCH] powerpc/highmem: change BUG_ON() to WARN_ON()
From: Christophe Leroy @ 2019-03-21 6:00 UTC (permalink / raw)
To: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras
Cc: linuxppc-dev, linux-kernel
In-Reply-To: <87va0c23s8.fsf@concordia.ellerman.id.au>
Le 21/03/2019 à 06:29, Michael Ellerman a écrit :
> Christophe Leroy <christophe.leroy@c-s.fr> writes:
>> In arch/powerpc/mm/highmem.c, BUG_ON() is called only when
>> CONFIG_DEBUG_HIGHMEM is selected, this means the BUG_ON() is
>> not vital and can be replaced by a a WARN_ON
>>
>> At the sametime, use IS_ENABLED() instead of #ifdef to clean a bit.
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>> ---
>> arch/powerpc/mm/highmem.c | 12 ++++--------
>> 1 file changed, 4 insertions(+), 8 deletions(-)
>>
>> diff --git a/arch/powerpc/mm/highmem.c b/arch/powerpc/mm/highmem.c
>> index 82a0e37557a5..b68c9f20fbdf 100644
>> --- a/arch/powerpc/mm/highmem.c
>> +++ b/arch/powerpc/mm/highmem.c
>> @@ -56,7 +54,7 @@ EXPORT_SYMBOL(kmap_atomic_prot);
>> void __kunmap_atomic(void *kvaddr)
>> {
>> unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
>> - int type __maybe_unused;
>> + int type;
>
> Why don't we move type into the block below.
Yes you're right, when Mathieu introduced the __maybe_unused, I was
wrongly thinging that kmap_atomic_idx() was doing something important
that had to be done also when DEBUG was not selected, but indeed it does
nothing else than returning the type.
I'll send a new patch.
Christophe
>
> eg:
>
>> @@ -66,12 +64,11 @@ void __kunmap_atomic(void *kvaddr)
>>
> - type = kmap_atomic_idx();
>>
>> -#ifdef CONFIG_DEBUG_HIGHMEM
>> - {
>> + if (IS_ENABLED(CONFIG_DEBUG_HIGHMEM)) {
> int type = kmap_atomic_idx();
>> unsigned int idx;
>>
>> idx = type + KM_TYPE_NR * smp_processor_id();
>> - BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx));
>> + WARN_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx));
>
>
> cheers
>
^ permalink raw reply
* Re: [PATCH] powerpc/highmem: change BUG_ON() to WARN_ON()
From: Michael Ellerman @ 2019-03-21 5:29 UTC (permalink / raw)
To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras
Cc: linuxppc-dev, linux-kernel
In-Reply-To: <0365f99ce2b9273e269a241394957cba924f995e.1551951985.git.christophe.leroy@c-s.fr>
Christophe Leroy <christophe.leroy@c-s.fr> writes:
> In arch/powerpc/mm/highmem.c, BUG_ON() is called only when
> CONFIG_DEBUG_HIGHMEM is selected, this means the BUG_ON() is
> not vital and can be replaced by a a WARN_ON
>
> At the sametime, use IS_ENABLED() instead of #ifdef to clean a bit.
>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
> arch/powerpc/mm/highmem.c | 12 ++++--------
> 1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/arch/powerpc/mm/highmem.c b/arch/powerpc/mm/highmem.c
> index 82a0e37557a5..b68c9f20fbdf 100644
> --- a/arch/powerpc/mm/highmem.c
> +++ b/arch/powerpc/mm/highmem.c
> @@ -56,7 +54,7 @@ EXPORT_SYMBOL(kmap_atomic_prot);
> void __kunmap_atomic(void *kvaddr)
> {
> unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
> - int type __maybe_unused;
> + int type;
Why don't we move type into the block below.
eg:
> @@ -66,12 +64,11 @@ void __kunmap_atomic(void *kvaddr)
>
- type = kmap_atomic_idx();
>
> -#ifdef CONFIG_DEBUG_HIGHMEM
> - {
> + if (IS_ENABLED(CONFIG_DEBUG_HIGHMEM)) {
int type = kmap_atomic_idx();
> unsigned int idx;
>
> idx = type + KM_TYPE_NR * smp_processor_id();
> - BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx));
> + WARN_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx));
cheers
^ permalink raw reply
* Re: [PATCH v2] kmemleak: skip scanning holes in the .bss section
From: Michael Ellerman @ 2019-03-21 5:15 UTC (permalink / raw)
To: Catalin Marinas
Cc: linux-kernel, kvm-ppc, linux-mm, Qian Cai, akpm, linuxppc-dev
In-Reply-To: <20190320181656.GB38229@arrakis.emea.arm.com>
Catalin Marinas <catalin.marinas@arm.com> writes:
> On Thu, Mar 21, 2019 at 12:15:46AM +1100, Michael Ellerman wrote:
>> Catalin Marinas <catalin.marinas@arm.com> writes:
>> > On Wed, Mar 13, 2019 at 10:57:17AM -0400, Qian Cai wrote:
>> >> @@ -1531,7 +1547,14 @@ static void kmemleak_scan(void)
>> >>
>> >> /* data/bss scanning */
>> >> scan_large_block(_sdata, _edata);
>> >> - scan_large_block(__bss_start, __bss_stop);
>> >> +
>> >> + if (bss_hole_start) {
>> >> + scan_large_block(__bss_start, bss_hole_start);
>> >> + scan_large_block(bss_hole_stop, __bss_stop);
>> >> + } else {
>> >> + scan_large_block(__bss_start, __bss_stop);
>> >> + }
>> >> +
>> >> scan_large_block(__start_ro_after_init, __end_ro_after_init);
>> >
>> > I'm not a fan of this approach but I couldn't come up with anything
>> > better. I was hoping we could check for PageReserved() in scan_block()
>> > but on arm64 it ends up not scanning the .bss at all.
>> >
>> > Until another user appears, I'm ok with this patch.
>> >
>> > Acked-by: Catalin Marinas <catalin.marinas@arm.com>
>>
>> I actually would like to rework this kvm_tmp thing to not be in bss at
>> all. It's a bit of a hack and is incompatible with strict RWX.
>>
>> If we size it a bit more conservatively we can hopefully just reserve
>> some space in the text section for it.
>>
>> I'm not going to have time to work on that immediately though, so if
>> people want this fixed now then this patch could go in as a temporary
>> solution.
>
> I think I have a simpler idea. Kmemleak allows punching holes in
> allocated objects, so just turn the data/bss sections into dedicated
> kmemleak objects. This happens when kmemleak is initialised, before the
> initcalls are invoked. The kvm_free_tmp() would just free the
> corresponding part of the bss.
>
> Patch below, only tested briefly on arm64. Qian, could you give it a try
> on powerpc? Thanks.
>
> --------8<------------------------------
> diff --git a/arch/powerpc/kernel/kvm.c b/arch/powerpc/kernel/kvm.c
> index 683b5b3805bd..c4b8cb3c298d 100644
> --- a/arch/powerpc/kernel/kvm.c
> +++ b/arch/powerpc/kernel/kvm.c
> @@ -712,6 +712,8 @@ static void kvm_use_magic_page(void)
>
> static __init void kvm_free_tmp(void)
> {
> + kmemleak_free_part(&kvm_tmp[kvm_tmp_index],
> + ARRAY_SIZE(kvm_tmp) - kvm_tmp_index);
> free_reserved_area(&kvm_tmp[kvm_tmp_index],
> &kvm_tmp[ARRAY_SIZE(kvm_tmp)], -1, NULL);
> }
Fine by me as long as it works (sounds like it does).
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
cheers
^ permalink raw reply
* Re: [PATCH 1/2] ibmvscsi: Protect ibmvscsi_head from concurrent modificaiton
From: Martin K. Petersen @ 2019-03-21 0:13 UTC (permalink / raw)
To: Tyrel Datwyler
Cc: martin.petersen, linux-scsi, stable, james.bottomley, brking,
linuxppc-dev
In-Reply-To: <20190320184151.31321-1-tyreld@linux.vnet.ibm.com>
Tyrel,
> For each ibmvscsi host created during a probe or destroyed during a
> remove we either add or remove that host to/from the global
> ibmvscsi_head list. This runs the risk of concurrent modification.
>
> This patch adds a simple spinlock around the list modification calls
> to prevent concurrent updates as is done similarly in the ibmvfc
> driver and ipr driver.
Applied to 5.1/scsi-fixes.
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox