* Re: [PATCH 4/8] binfmt_elf: open code copy_siginfo_to_user to kernelspace buffer
From: Michael Ellerman @ 2020-04-15 3:01 UTC (permalink / raw)
To: Christoph Hellwig, Andrew Morton, Alexander Viro
Cc: Arnd Bergmann, linux-kernel, Jeremy Kerr, linux-fsdevel,
linuxppc-dev, Eric W . Biederman
In-Reply-To: <20200414070142.288696-5-hch@lst.de>
Christoph Hellwig <hch@lst.de> writes:
> Instead of messing with the address limit just open code the trivial
> memcpy + memset logic for the native version, and a call to
> to_compat_siginfo for the compat version.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> fs/binfmt_elf.c | 9 +++++----
> fs/compat_binfmt_elf.c | 6 +++++-
> 2 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
> index 13f25e241ac4..607c5a5f855e 100644
> --- a/fs/binfmt_elf.c
> +++ b/fs/binfmt_elf.c
> @@ -1553,15 +1553,16 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
> fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
> }
>
> +#ifndef fill_siginfo_note
> static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
> const kernel_siginfo_t *siginfo)
> {
> - mm_segment_t old_fs = get_fs();
> - set_fs(KERNEL_DS);
> - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
> - set_fs(old_fs);
> + memcpy(csigdata, siginfo, sizeof(struct kernel_siginfo));
> + memset((char *)csigdata + sizeof(struct kernel_siginfo), 0,
> + SI_EXPANSION_SIZE);
> fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
> }
> +#endif
>
> #define MAX_FILE_NOTE_SIZE (4*1024*1024)
> /*
> diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
> index aaad4ca1217e..ab84e095618b 100644
> --- a/fs/compat_binfmt_elf.c
> +++ b/fs/compat_binfmt_elf.c
> @@ -39,7 +39,11 @@
> */
> #define user_long_t compat_long_t
> #define user_siginfo_t compat_siginfo_t
> -#define copy_siginfo_to_user copy_siginfo_to_user32
> +#define fill_siginfo_note(note, csigdata, siginfo) \
> +do { \
> + to_compat_siginfo(csigdata, siginfo, compat_siginfo_flags()); \
> + fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata); \
> +} while (0)
This doesn't build on ppc (cell_defconfig):
../fs/binfmt_elf.c: In function 'fill_note_info':
../fs/compat_binfmt_elf.c:44:39: error: implicit declaration of function 'compat_siginfo_flags'; did you mean 'to_compat_siginfo'? [-Werror=implicit-function-d
eclaration]
to_compat_siginfo(csigdata, siginfo, compat_siginfo_flags()); \
^~~~~~~~~~~~~~~~~~~~
../fs/binfmt_elf.c:1846:2: note: in expansion of macro 'fill_siginfo_note'
fill_siginfo_note(&info->signote, &info->csigdata, siginfo);
^~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[2]: *** [../scripts/Makefile.build:266: fs/compat_binfmt_elf.o] Error 1
I guess the empty version from kernel/signal.c needs to move into a
header somewhere.
cheers
^ permalink raw reply
* [PATCH kernel] powerpc/dma: Call indirect dma_ops when persistent memory present
From: Alexey Kardashevskiy @ 2020-04-15 2:58 UTC (permalink / raw)
To: linuxppc-dev
Cc: Brian J King, Alexey Kardashevskiy, Sam Bobroff,
Aneesh Kumar K . V, Wen Xiong, Christoph Hellwig, David Gibson
Unlike normal memory ("memory" compatible type in the FDT),
the persistent memory ("ibm,pmemory" in the FDT) can be mapped anywhere
in the guest physical space and it can be used for DMA.
In order to maintain 1:1 mapping via the huge DMA window, we need to
know the maximum physical address at the time of the window setup.
So far we've been looking at "memory" nodes but "ibm,pmemory" does not
have fixed addresses and the persistent memory may be mapped afterwards.
When the maximum window size is not big enough to fit persistent memory,
this clears the dma_ops_bypass flag to tell the generic code that indirect
dma_ops call is needed. This lets the platform code check the DMA
boundaries and call direct DMA API if DMA-ing to/from generic RAM
or call IOMMU API otherwise.
This adds dma_max to device::archdata to tell the direct DMA mapping
limit. At the moment only pseries sets the limit so powernv is
unaffected by this change.
As persistent memory is backed with page structs, this uses
MAX_PHYSMEM_BITS as the upper limit (rather than simple 64bit).
This should not change the existing behaviour when no persistent memory.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
This is based on
https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=170152
---
arch/powerpc/include/asm/device.h | 2 +
arch/powerpc/kernel/dma-iommu.c | 68 +++++++++++++++++++++++++-
arch/powerpc/platforms/pseries/iommu.c | 23 ++++++++-
3 files changed, 89 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/include/asm/device.h b/arch/powerpc/include/asm/device.h
index 452402215e12..380e92684a16 100644
--- a/arch/powerpc/include/asm/device.h
+++ b/arch/powerpc/include/asm/device.h
@@ -18,6 +18,8 @@ struct iommu_table;
* drivers/macintosh/macio_asic.c
*/
struct dev_archdata {
+ /* Maximum DMA address for 1:1 mapping (when enabled) */
+ dma_addr_t dma_max;
/*
* These two used to be a union. However, with the hybrid ops we need
* both so here we store both a DMA offset for direct mappings and
diff --git a/arch/powerpc/kernel/dma-iommu.c b/arch/powerpc/kernel/dma-iommu.c
index 569fecd7b5b2..8c67bfffdef6 100644
--- a/arch/powerpc/kernel/dma-iommu.c
+++ b/arch/powerpc/kernel/dma-iommu.c
@@ -10,6 +10,16 @@
#include <linux/pci.h>
#include <asm/iommu.h>
+static inline bool can_map_direct(struct device *dev, phys_addr_t addr)
+{
+ return dev->archdata.dma_max >= phys_to_dma(dev, addr);
+}
+
+static inline bool dma_handle_direct(struct device *dev, dma_addr_t dma_handle)
+{
+ return dma_handle >= dev->archdata.dma_offset;
+}
+
/*
* Generic iommu implementation
*/
@@ -44,6 +54,12 @@ static dma_addr_t dma_iommu_map_page(struct device *dev, struct page *page,
enum dma_data_direction direction,
unsigned long attrs)
{
+ if (dev->archdata.dma_max &&
+ can_map_direct(dev, (phys_addr_t) page_to_phys(page) +
+ offset + size))
+ return dma_direct_map_page(dev, page, offset, size, direction,
+ attrs);
+
return iommu_map_page(dev, get_iommu_table_base(dev), page, offset,
size, dma_get_mask(dev), direction, attrs);
}
@@ -53,6 +69,12 @@ static void dma_iommu_unmap_page(struct device *dev, dma_addr_t dma_handle,
size_t size, enum dma_data_direction direction,
unsigned long attrs)
{
+ if (dev->archdata.dma_max &&
+ dma_handle_direct(dev, dma_handle + size)) {
+ dma_direct_unmap_page(dev, dma_handle, size, direction, attrs);
+ return;
+ }
+
iommu_unmap_page(get_iommu_table_base(dev), dma_handle, size, direction,
attrs);
}
@@ -62,6 +84,22 @@ static int dma_iommu_map_sg(struct device *dev, struct scatterlist *sglist,
int nelems, enum dma_data_direction direction,
unsigned long attrs)
{
+ if (dev->archdata.dma_max) {
+ struct scatterlist *s;
+ bool direct = true;
+ int i;
+
+ for_each_sg(sglist, s, nelems, i) {
+ direct = can_map_direct(dev,
+ sg_phys(s) + s->offset + s->length);
+ if (!direct)
+ break;
+ }
+ if (direct)
+ return dma_direct_map_sg(dev, sglist, nelems, direction,
+ attrs);
+ }
+
return ppc_iommu_map_sg(dev, get_iommu_table_base(dev), sglist, nelems,
dma_get_mask(dev), direction, attrs);
}
@@ -70,6 +108,24 @@ static void dma_iommu_unmap_sg(struct device *dev, struct scatterlist *sglist,
int nelems, enum dma_data_direction direction,
unsigned long attrs)
{
+ if (dev->archdata.dma_max) {
+ struct scatterlist *s;
+ bool direct = true;
+ int i;
+
+ for_each_sg(sglist, s, nelems, i) {
+ direct = dma_handle_direct(dev,
+ s->dma_address + s->length);
+ if (!direct)
+ break;
+ }
+ if (direct) {
+ dma_direct_unmap_sg(dev, sglist, nelems, direction,
+ attrs);
+ return;
+ }
+ }
+
ppc_iommu_unmap_sg(get_iommu_table_base(dev), sglist, nelems,
direction, attrs);
}
@@ -90,8 +146,16 @@ int dma_iommu_dma_supported(struct device *dev, u64 mask)
struct iommu_table *tbl = get_iommu_table_base(dev);
if (dev_is_pci(dev) && dma_iommu_bypass_supported(dev, mask)) {
- dev->dma_ops_bypass = true;
- dev_dbg(dev, "iommu: 64-bit OK, using fixed ops\n");
+ /*
+ * dma_iommu_bypass_supported() sets dma_max when there is
+ * 1:1 mapping but it is somehow limited.
+ * ibm,pmemory is one example.
+ */
+ dev->dma_ops_bypass = dev->archdata.dma_max == 0;
+ if (!dev->dma_ops_bypass)
+ dev_warn(dev, "iommu: 64-bit OK but using default ops\n");
+ else
+ dev_dbg(dev, "iommu: 64-bit OK, using fixed ops\n");
return 1;
}
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index 6d47b4a3ce39..227055a4fbe2 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -994,7 +994,7 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
struct ddw_query_response query;
struct ddw_create_response create;
int page_shift;
- u64 dma_addr, max_addr;
+ u64 dma_addr, max_addr = 0, dma_max_sz = 0;
struct device_node *dn;
u32 ddw_avail[3];
struct direct_window *window;
@@ -1066,7 +1066,23 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
}
/* verify the window * number of ptes will map the partition */
/* check largest block * page size > max memory hotplug addr */
- max_addr = ddw_memory_hotplug_max();
+ /*
+ * The "ibm,pmemory" can appear anywhere in the address space.
+ * Assuming it is still backed by page structs, try MAX_PHYSMEM_BITS
+ * for the upper limit and fallback to max RAM otherwise but this
+ * disables device::dma_ops_bypass.
+ */
+ if (of_find_node_by_type(NULL, "ibm,pmemory")) {
+ max_addr = 1ULL << (MAX_PHYSMEM_BITS - page_shift);
+ if (query.largest_available_block < max_addr) {
+ dev_info(&dev->dev, "Skipping ibm,pmemory");
+ max_addr = ddw_memory_hotplug_max();
+ dma_max_sz = max_addr;
+ }
+ } else {
+ max_addr = ddw_memory_hotplug_max();
+ }
+
if (query.largest_available_block < (max_addr >> page_shift)) {
dev_dbg(&dev->dev, "can't map partition max 0x%llx with %u "
"%llu-sized pages\n", max_addr, query.largest_available_block,
@@ -1151,6 +1167,9 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
out_unlock:
mutex_unlock(&direct_window_init_mutex);
+ if (!dev->dev.archdata.dma_max && dma_addr && dma_max_sz)
+ dev->dev.archdata.dma_max = dma_addr + dma_max_sz;
+
return dma_addr;
}
--
2.17.1
^ permalink raw reply related
* Re: [PATCH v6 6/7] ASoC: dt-bindings: fsl_easrc: Add document for EASRC
From: Shengjiu Wang @ 2020-04-15 2:55 UTC (permalink / raw)
To: Rob Herring
Cc: Mark Rutland,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
Linux-ALSA, Timur Tabi, Xiubo Li, Fabio Estevam, Shengjiu Wang,
Takashi Iwai, Liam Girdwood, Nicolin Chen, Mark Brown,
linuxppc-dev, linux-kernel
In-Reply-To: <20200414154643.GA29098@bogus>
Hi Rob
On Tue, Apr 14, 2020 at 11:49 PM Rob Herring <robh@kernel.org> wrote:
>
> On Wed, Apr 01, 2020 at 04:45:39PM +0800, Shengjiu Wang wrote:
> > EASRC (Enhanced Asynchronous Sample Rate Converter) is a new
> > IP module found on i.MX8MN.
> >
> > Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
> > ---
> > .../devicetree/bindings/sound/fsl,easrc.yaml | 101 ++++++++++++++++++
> > 1 file changed, 101 insertions(+)
> > create mode 100644 Documentation/devicetree/bindings/sound/fsl,easrc.yaml
> >
> > diff --git a/Documentation/devicetree/bindings/sound/fsl,easrc.yaml b/Documentation/devicetree/bindings/sound/fsl,easrc.yaml
> > new file mode 100644
> > index 000000000000..14ea60084420
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/sound/fsl,easrc.yaml
> > @@ -0,0 +1,101 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/sound/fsl,easrc.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: NXP Asynchronous Sample Rate Converter (ASRC) Controller
> > +
> > +maintainers:
> > + - Shengjiu Wang <shengjiu.wang@nxp.com>
> > +
> > +properties:
> > + $nodename:
> > + pattern: "^easrc@.*"
> > +
> > + compatible:
> > + const: fsl,imx8mn-easrc
> > +
> > + reg:
> > + maxItems: 1
> > +
> > + interrupts:
> > + maxItems: 1
> > +
> > + clocks:
> > + items:
> > + - description: Peripheral clock
> > +
> > + clock-names:
> > + items:
> > + - const: mem
> > +
> > + dmas:
> > + maxItems: 8
> > +
> > + dma-names:
> > + items:
> > + - const: ctx0_rx
> > + - const: ctx0_tx
> > + - const: ctx1_rx
> > + - const: ctx1_tx
> > + - const: ctx2_rx
> > + - const: ctx2_tx
> > + - const: ctx3_rx
> > + - const: ctx3_tx
> > +
> > + firmware-name:
> > + allOf:
> > + - $ref: /schemas/types.yaml#/definitions/string
> > + - const: imx/easrc/easrc-imx8mn.bin
> > + description: The coefficient table for the filters
> > +
> > + fsl,asrc-rate:
>
> fsl,asrc-rate-hz
Can we keep "fsl,asrc-rate", because I want this property
align with the one in fsl,asrc.txt. These two asrc modules
can share same property name.
best regards
wang shengjiu
^ permalink raw reply
* [PATCH V2] vhost: do not enable VHOST_MENU by default
From: Jason Wang @ 2020-04-15 2:43 UTC (permalink / raw)
To: jasowang, mst
Cc: linux-s390, tsbogend, gor, kvm, linux-kernel, heiko.carstens,
linux-mips, virtualization, borntraeger, geert, netdev, paulus,
linuxppc-dev
We try to keep the defconfig untouched after decoupling CONFIG_VHOST
out of CONFIG_VIRTUALIZATION in commit 20c384f1ea1a
("vhost: refine vhost and vringh kconfig") by enabling VHOST_MENU by
default. Then the defconfigs can keep enabling CONFIG_VHOST_NET
without the caring of CONFIG_VHOST.
But this will leave a "CONFIG_VHOST_MENU=y" in all defconfigs and even
for the ones that doesn't want vhost. So it actually shifts the
burdens to the maintainers of all other to add "CONFIG_VHOST_MENU is
not set". So this patch tries to enable CONFIG_VHOST explicitly in
defconfigs that enables CONFIG_VHOST_NET and CONFIG_VHOST_VSOCK.
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> (s390)
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
Change since V1:
- depends on EVENTFD for VHOST
---
arch/mips/configs/malta_kvm_defconfig | 1 +
arch/powerpc/configs/powernv_defconfig | 1 +
arch/powerpc/configs/ppc64_defconfig | 1 +
arch/powerpc/configs/pseries_defconfig | 1 +
arch/s390/configs/debug_defconfig | 1 +
arch/s390/configs/defconfig | 1 +
drivers/vhost/Kconfig | 26 +++++++++-----------------
7 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/arch/mips/configs/malta_kvm_defconfig b/arch/mips/configs/malta_kvm_defconfig
index 8ef612552a19..06f0c7a0ca87 100644
--- a/arch/mips/configs/malta_kvm_defconfig
+++ b/arch/mips/configs/malta_kvm_defconfig
@@ -18,6 +18,7 @@ CONFIG_PCI=y
CONFIG_VIRTUALIZATION=y
CONFIG_KVM=m
CONFIG_KVM_MIPS_DEBUG_COP0_COUNTERS=y
+CONFIG_VHOST=m
CONFIG_VHOST_NET=m
CONFIG_MODULES=y
CONFIG_MODULE_UNLOAD=y
diff --git a/arch/powerpc/configs/powernv_defconfig b/arch/powerpc/configs/powernv_defconfig
index 71749377d164..404245b4594d 100644
--- a/arch/powerpc/configs/powernv_defconfig
+++ b/arch/powerpc/configs/powernv_defconfig
@@ -346,5 +346,6 @@ CONFIG_CRYPTO_DEV_VMX=y
CONFIG_VIRTUALIZATION=y
CONFIG_KVM_BOOK3S_64=m
CONFIG_KVM_BOOK3S_64_HV=m
+CONFIG_VHOST=m
CONFIG_VHOST_NET=m
CONFIG_PRINTK_TIME=y
diff --git a/arch/powerpc/configs/ppc64_defconfig b/arch/powerpc/configs/ppc64_defconfig
index 7e68cb222c7b..4599fc7be285 100644
--- a/arch/powerpc/configs/ppc64_defconfig
+++ b/arch/powerpc/configs/ppc64_defconfig
@@ -61,6 +61,7 @@ CONFIG_ELECTRA_CF=y
CONFIG_VIRTUALIZATION=y
CONFIG_KVM_BOOK3S_64=m
CONFIG_KVM_BOOK3S_64_HV=m
+CONFIG_VHOST=m
CONFIG_VHOST_NET=m
CONFIG_OPROFILE=m
CONFIG_KPROBES=y
diff --git a/arch/powerpc/configs/pseries_defconfig b/arch/powerpc/configs/pseries_defconfig
index 6b68109e248f..4cad3901b5de 100644
--- a/arch/powerpc/configs/pseries_defconfig
+++ b/arch/powerpc/configs/pseries_defconfig
@@ -321,5 +321,6 @@ CONFIG_CRYPTO_DEV_VMX=y
CONFIG_VIRTUALIZATION=y
CONFIG_KVM_BOOK3S_64=m
CONFIG_KVM_BOOK3S_64_HV=m
+CONFIG_VHOST=m
CONFIG_VHOST_NET=m
CONFIG_PRINTK_TIME=y
diff --git a/arch/s390/configs/debug_defconfig b/arch/s390/configs/debug_defconfig
index 0c86ba19fa2b..6ec6e69630d1 100644
--- a/arch/s390/configs/debug_defconfig
+++ b/arch/s390/configs/debug_defconfig
@@ -57,6 +57,7 @@ CONFIG_PROTECTED_VIRTUALIZATION_GUEST=y
CONFIG_CMM=m
CONFIG_APPLDATA_BASE=y
CONFIG_KVM=m
+CONFIG_VHOST=m
CONFIG_VHOST_NET=m
CONFIG_VHOST_VSOCK=m
CONFIG_OPROFILE=m
diff --git a/arch/s390/configs/defconfig b/arch/s390/configs/defconfig
index 6b27d861a9a3..d1b3bf83d687 100644
--- a/arch/s390/configs/defconfig
+++ b/arch/s390/configs/defconfig
@@ -57,6 +57,7 @@ CONFIG_PROTECTED_VIRTUALIZATION_GUEST=y
CONFIG_CMM=m
CONFIG_APPLDATA_BASE=y
CONFIG_KVM=m
+CONFIG_VHOST=m
CONFIG_VHOST_NET=m
CONFIG_VHOST_VSOCK=m
CONFIG_OPROFILE=m
diff --git a/drivers/vhost/Kconfig b/drivers/vhost/Kconfig
index e79cbbdfea45..29f171a53d8a 100644
--- a/drivers/vhost/Kconfig
+++ b/drivers/vhost/Kconfig
@@ -12,23 +12,19 @@ config VHOST_RING
This option is selected by any driver which needs to access
the host side of a virtio ring.
-config VHOST
- tristate
+menuconfig VHOST
+ tristate "Vhost Devices"
+ depends on EVENTFD
select VHOST_IOTLB
help
- This option is selected by any driver which needs to access
- the core of vhost.
+ Enable option to support host kernel or hardware accelerator
+ for virtio device.
-menuconfig VHOST_MENU
- bool "VHOST drivers"
- default y
-
-if VHOST_MENU
+if VHOST
config VHOST_NET
tristate "Host kernel accelerator for virtio net"
- depends on NET && EVENTFD && (TUN || !TUN) && (TAP || !TAP)
- select VHOST
+ depends on NET && (TUN || !TUN) && (TAP || !TAP)
---help---
This kernel module can be loaded in host kernel to accelerate
guest networking with virtio_net. Not to be confused with virtio_net
@@ -39,8 +35,7 @@ config VHOST_NET
config VHOST_SCSI
tristate "VHOST_SCSI TCM fabric driver"
- depends on TARGET_CORE && EVENTFD
- select VHOST
+ depends on TARGET_CORE
default n
---help---
Say M here to enable the vhost_scsi TCM fabric module
@@ -48,8 +43,7 @@ config VHOST_SCSI
config VHOST_VSOCK
tristate "vhost virtio-vsock driver"
- depends on VSOCKETS && EVENTFD
- select VHOST
+ depends on VSOCKETS
select VIRTIO_VSOCKETS_COMMON
default n
---help---
@@ -62,8 +56,6 @@ config VHOST_VSOCK
config VHOST_VDPA
tristate "Vhost driver for vDPA-based backend"
- depends on EVENTFD
- select VHOST
depends on VDPA
help
This kernel module can be loaded in host kernel to accelerate
--
2.20.1
^ permalink raw reply related
* Re: [PATCH] vhost: do not enable VHOST_MENU by default
From: Jason Wang @ 2020-04-15 2:40 UTC (permalink / raw)
To: kbuild test robot, mst, linux-mips, linux-kernel, linuxppc-dev,
linux-s390, kvm, virtualization, netdev, geert,
Thomas Bogendoerfer, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, Heiko Carstens, Vasily Gorbik,
Christian Borntraeger
Cc: kbuild-all
In-Reply-To: <202004150530.wxnpDMSc%lkp@intel.com>
On 2020/4/15 上午5:15, kbuild test robot wrote:
> Hi Jason,
>
> I love your patch! Yet something to improve:
>
> [auto build test ERROR on vhost/linux-next]
> [also build test ERROR on next-20200414]
> [cannot apply to powerpc/next s390/features v5.7-rc1]
> [if your patch is applied to the wrong git tree, please drop us a note to help
> improve the system. BTW, we also suggest to use '--base' option to specify the
> base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
>
> url: https://github.com/0day-ci/linux/commits/Jason-Wang/vhost-do-not-enable-VHOST_MENU-by-default/20200414-110807
> base: https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next
> config: ia64-randconfig-a001-20200415 (attached as .config)
> compiler: ia64-linux-gcc (GCC) 9.3.0
> reproduce:
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> GCC_VERSION=9.3.0 make.cross ARCH=ia64
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kbuild test robot <lkp@intel.com>
>
> All error/warnings (new ones prefixed by >>):
>
> drivers/vhost/vhost.c: In function 'vhost_vring_ioctl':
>>> drivers/vhost/vhost.c:1577:33: error: implicit declaration of function 'eventfd_fget'; did you mean 'eventfd_signal'? [-Werror=implicit-function-declaration]
> 1577 | eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
> | ^~~~~~~~~~~~
> | eventfd_signal
>>> drivers/vhost/vhost.c:1577:31: warning: pointer/integer type mismatch in conditional expression
Forget to make VHOST depend on EVENTFD.
Will send v2.
Thanks
> 1577 | eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
> | ^
> cc1: some warnings being treated as errors
>
> vim +1577 drivers/vhost/vhost.c
>
> feebcaeac79ad8 Jason Wang 2019-05-24 1493
> feebcaeac79ad8 Jason Wang 2019-05-24 1494 static long vhost_vring_set_num_addr(struct vhost_dev *d,
> feebcaeac79ad8 Jason Wang 2019-05-24 1495 struct vhost_virtqueue *vq,
> feebcaeac79ad8 Jason Wang 2019-05-24 1496 unsigned int ioctl,
> feebcaeac79ad8 Jason Wang 2019-05-24 1497 void __user *argp)
> feebcaeac79ad8 Jason Wang 2019-05-24 1498 {
> feebcaeac79ad8 Jason Wang 2019-05-24 1499 long r;
> feebcaeac79ad8 Jason Wang 2019-05-24 1500
> feebcaeac79ad8 Jason Wang 2019-05-24 1501 mutex_lock(&vq->mutex);
> feebcaeac79ad8 Jason Wang 2019-05-24 1502
> feebcaeac79ad8 Jason Wang 2019-05-24 1503 switch (ioctl) {
> feebcaeac79ad8 Jason Wang 2019-05-24 1504 case VHOST_SET_VRING_NUM:
> feebcaeac79ad8 Jason Wang 2019-05-24 1505 r = vhost_vring_set_num(d, vq, argp);
> feebcaeac79ad8 Jason Wang 2019-05-24 1506 break;
> feebcaeac79ad8 Jason Wang 2019-05-24 1507 case VHOST_SET_VRING_ADDR:
> feebcaeac79ad8 Jason Wang 2019-05-24 1508 r = vhost_vring_set_addr(d, vq, argp);
> feebcaeac79ad8 Jason Wang 2019-05-24 1509 break;
> feebcaeac79ad8 Jason Wang 2019-05-24 1510 default:
> feebcaeac79ad8 Jason Wang 2019-05-24 1511 BUG();
> feebcaeac79ad8 Jason Wang 2019-05-24 1512 }
> feebcaeac79ad8 Jason Wang 2019-05-24 1513
> feebcaeac79ad8 Jason Wang 2019-05-24 1514 mutex_unlock(&vq->mutex);
> feebcaeac79ad8 Jason Wang 2019-05-24 1515
> feebcaeac79ad8 Jason Wang 2019-05-24 1516 return r;
> feebcaeac79ad8 Jason Wang 2019-05-24 1517 }
> 26b36604523f4a Sonny Rao 2018-03-14 1518 long vhost_vring_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp)
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1519 {
> cecb46f194460d Al Viro 2012-08-27 1520 struct file *eventfp, *filep = NULL;
> cecb46f194460d Al Viro 2012-08-27 1521 bool pollstart = false, pollstop = false;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1522 struct eventfd_ctx *ctx = NULL;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1523 u32 __user *idxp = argp;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1524 struct vhost_virtqueue *vq;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1525 struct vhost_vring_state s;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1526 struct vhost_vring_file f;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1527 u32 idx;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1528 long r;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1529
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1530 r = get_user(idx, idxp);
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1531 if (r < 0)
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1532 return r;
> 0f3d9a17469d71 Krishna Kumar 2010-05-25 1533 if (idx >= d->nvqs)
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1534 return -ENOBUFS;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1535
> ff002269a4ee9c Jason Wang 2018-10-30 1536 idx = array_index_nospec(idx, d->nvqs);
> 3ab2e420ec1caf Asias He 2013-04-27 1537 vq = d->vqs[idx];
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1538
> feebcaeac79ad8 Jason Wang 2019-05-24 1539 if (ioctl == VHOST_SET_VRING_NUM ||
> feebcaeac79ad8 Jason Wang 2019-05-24 1540 ioctl == VHOST_SET_VRING_ADDR) {
> feebcaeac79ad8 Jason Wang 2019-05-24 1541 return vhost_vring_set_num_addr(d, vq, ioctl, argp);
> feebcaeac79ad8 Jason Wang 2019-05-24 1542 }
> feebcaeac79ad8 Jason Wang 2019-05-24 1543
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1544 mutex_lock(&vq->mutex);
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1545
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1546 switch (ioctl) {
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1547 case VHOST_SET_VRING_BASE:
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1548 /* Moving base with an active backend?
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1549 * You don't want to do that. */
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1550 if (vq->private_data) {
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1551 r = -EBUSY;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1552 break;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1553 }
> 7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1554 if (copy_from_user(&s, argp, sizeof s)) {
> 7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1555 r = -EFAULT;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1556 break;
> 7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1557 }
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1558 if (s.num > 0xffff) {
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1559 r = -EINVAL;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1560 break;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1561 }
> 8d65843c44269c Jason Wang 2017-07-27 1562 vq->last_avail_idx = s.num;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1563 /* Forget the cached index value. */
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1564 vq->avail_idx = vq->last_avail_idx;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1565 break;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1566 case VHOST_GET_VRING_BASE:
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1567 s.index = idx;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1568 s.num = vq->last_avail_idx;
> 7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1569 if (copy_to_user(argp, &s, sizeof s))
> 7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1570 r = -EFAULT;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1571 break;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1572 case VHOST_SET_VRING_KICK:
> 7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1573 if (copy_from_user(&f, argp, sizeof f)) {
> 7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1574 r = -EFAULT;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1575 break;
> 7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1576 }
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 @1577 eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
> 535297a6ae4c3b Michael S. Tsirkin 2010-03-17 1578 if (IS_ERR(eventfp)) {
> 535297a6ae4c3b Michael S. Tsirkin 2010-03-17 1579 r = PTR_ERR(eventfp);
> 535297a6ae4c3b Michael S. Tsirkin 2010-03-17 1580 break;
> 535297a6ae4c3b Michael S. Tsirkin 2010-03-17 1581 }
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1582 if (eventfp != vq->kick) {
> cecb46f194460d Al Viro 2012-08-27 1583 pollstop = (filep = vq->kick) != NULL;
> cecb46f194460d Al Viro 2012-08-27 1584 pollstart = (vq->kick = eventfp) != NULL;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1585 } else
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1586 filep = eventfp;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1587 break;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1588 case VHOST_SET_VRING_CALL:
> 7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1589 if (copy_from_user(&f, argp, sizeof f)) {
> 7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1590 r = -EFAULT;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1591 break;
> 7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1592 }
> e050c7d93f4adb Eric Biggers 2018-01-06 1593 ctx = f.fd == -1 ? NULL : eventfd_ctx_fdget(f.fd);
> e050c7d93f4adb Eric Biggers 2018-01-06 1594 if (IS_ERR(ctx)) {
> e050c7d93f4adb Eric Biggers 2018-01-06 1595 r = PTR_ERR(ctx);
> 535297a6ae4c3b Michael S. Tsirkin 2010-03-17 1596 break;
> 535297a6ae4c3b Michael S. Tsirkin 2010-03-17 1597 }
> e050c7d93f4adb Eric Biggers 2018-01-06 1598 swap(ctx, vq->call_ctx);
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1599 break;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1600 case VHOST_SET_VRING_ERR:
> 7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1601 if (copy_from_user(&f, argp, sizeof f)) {
> 7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1602 r = -EFAULT;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1603 break;
> 7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1604 }
> 09f332a589232f Eric Biggers 2018-01-06 1605 ctx = f.fd == -1 ? NULL : eventfd_ctx_fdget(f.fd);
> 09f332a589232f Eric Biggers 2018-01-06 1606 if (IS_ERR(ctx)) {
> 09f332a589232f Eric Biggers 2018-01-06 1607 r = PTR_ERR(ctx);
> 535297a6ae4c3b Michael S. Tsirkin 2010-03-17 1608 break;
> 535297a6ae4c3b Michael S. Tsirkin 2010-03-17 1609 }
> 09f332a589232f Eric Biggers 2018-01-06 1610 swap(ctx, vq->error_ctx);
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1611 break;
> 2751c9882b9472 Greg Kurz 2015-04-24 1612 case VHOST_SET_VRING_ENDIAN:
> 2751c9882b9472 Greg Kurz 2015-04-24 1613 r = vhost_set_vring_endian(vq, argp);
> 2751c9882b9472 Greg Kurz 2015-04-24 1614 break;
> 2751c9882b9472 Greg Kurz 2015-04-24 1615 case VHOST_GET_VRING_ENDIAN:
> 2751c9882b9472 Greg Kurz 2015-04-24 1616 r = vhost_get_vring_endian(vq, idx, argp);
> 2751c9882b9472 Greg Kurz 2015-04-24 1617 break;
> 03088137246065 Jason Wang 2016-03-04 1618 case VHOST_SET_VRING_BUSYLOOP_TIMEOUT:
> 03088137246065 Jason Wang 2016-03-04 1619 if (copy_from_user(&s, argp, sizeof(s))) {
> 03088137246065 Jason Wang 2016-03-04 1620 r = -EFAULT;
> 03088137246065 Jason Wang 2016-03-04 1621 break;
> 03088137246065 Jason Wang 2016-03-04 1622 }
> 03088137246065 Jason Wang 2016-03-04 1623 vq->busyloop_timeout = s.num;
> 03088137246065 Jason Wang 2016-03-04 1624 break;
> 03088137246065 Jason Wang 2016-03-04 1625 case VHOST_GET_VRING_BUSYLOOP_TIMEOUT:
> 03088137246065 Jason Wang 2016-03-04 1626 s.index = idx;
> 03088137246065 Jason Wang 2016-03-04 1627 s.num = vq->busyloop_timeout;
> 03088137246065 Jason Wang 2016-03-04 1628 if (copy_to_user(argp, &s, sizeof(s)))
> 03088137246065 Jason Wang 2016-03-04 1629 r = -EFAULT;
> 03088137246065 Jason Wang 2016-03-04 1630 break;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1631 default:
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1632 r = -ENOIOCTLCMD;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1633 }
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1634
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1635 if (pollstop && vq->handle_kick)
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1636 vhost_poll_stop(&vq->poll);
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1637
> e050c7d93f4adb Eric Biggers 2018-01-06 1638 if (!IS_ERR_OR_NULL(ctx))
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1639 eventfd_ctx_put(ctx);
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1640 if (filep)
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1641 fput(filep);
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1642
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1643 if (pollstart && vq->handle_kick)
> 2b8b328b61c799 Jason Wang 2013-01-28 1644 r = vhost_poll_start(&vq->poll, vq->kick);
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1645
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1646 mutex_unlock(&vq->mutex);
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1647
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1648 if (pollstop && vq->handle_kick)
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1649 vhost_poll_flush(&vq->poll);
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1650 return r;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1651 }
> 6ac1afbf6132df Asias He 2013-05-06 1652 EXPORT_SYMBOL_GPL(vhost_vring_ioctl);
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1653
>
> :::::: The code at line 1577 was first introduced by commit
> :::::: 3a4d5c94e959359ece6d6b55045c3f046677f55c vhost_net: a kernel-level virtio server
>
> :::::: TO: Michael S. Tsirkin <mst@redhat.com>
> :::::: CC: David S. Miller <davem@davemloft.net>
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply
* Re: [PATCH 1/3] kexec: Prevent removal of memory in use by a loaded kexec image
From: Baoquan He @ 2020-04-15 2:35 UTC (permalink / raw)
To: David Hildenbrand
Cc: piliu, Anshuman Khandual, Catalin Marinas, Bhupesh Sharma,
linuxppc-dev, kexec, Russell King - ARM Linux admin, linux-mm,
James Morse, Eric W. Biederman, Andrew Morton, Will Deacon,
linux-arm-kernel
In-Reply-To: <0085f460-b0c7-b25f-36a7-fa3bafaab6fe@redhat.com>
On 04/14/20 at 04:49pm, David Hildenbrand wrote:
> >>>>> The root cause is kexec-ed kernel is targeted at hotpluggable memory
> >>>>> region. Just avoiding the movable area can fix it. In kexec_file_load(),
> >>>>> just checking or picking those unmovable region to put kernel/initrd in
> >>>>> function locate_mem_hole_callback() can fix it. The page or pageblock's
> >>>>> zone is movable or not, it's easy to know. This fix doesn't need to
> >>>>> bother other component.
> >>>>
> >>>> I don't fully agree. E.g., just because memory is onlined to ZONE_NORMAL
> >>>> does not imply that it cannot get offlined and removed e.g., this is
> >>>> heavily used on ppc64, with 16MB sections.
> >>>
> >>> Really? I just know there are two kinds of mem hoplug in ppc, but don't
> >>> know the details. So in this case, is there any flag or a way to know
> >>> those memory block are hotpluggable? I am curious how those kernel data
> >>> is avoided to be put in this area. Or ppc just freely uses it for kernel
> >>> data or user space data, then try to migrate when hot remove?
> >>
> >> See
> >> arch/powerpc/platforms/pseries/hotplug-memory.c:dlpar_memory_remove_by_count()
> >>
> >> Under DLAPR, it can remove memory in LMB granularity, which is usually
> >> 16MB (== single section on ppc64). DLPAR will directly online all
> >> hotplugged memory (LMBs) from the kernel using device_online(), which
> >> will go to ZONE_NORMAL.
> >>
> >> When trying to remove memory, it simply scans for offlineable 16MB
> >> memory blocks (==section == LMB), offlines and removes them. No need for
> >> the movable zone and all the involved issues.
> >
> > Yes, this is a different one, thanks for pointing it out. It sounds like
> > balloon driver in virt platform, doesn't it?
>
> With DLPAR there is a hypervisor involved (which manages the actual HW
> DIMMs), so yes.
>
> >
> > Avoiding to put kexec kernel into movable zone can't solve this DLPAR
> > case as you said.
> >
> >>
> >> Now, the interesting question is, can we have LMBs added during boot
> >> (not via add_memory()), that will later be removed via remove_memory().
> >> IIRC, we had BUGs related to that, so I think yes. If a section contains
> >> no unmovable allocations (after boot), it can get removed.
> >
> > I do want to ask this question. If we can add LMB into system RAM, then
> > reload kexec can solve it.
> >
> > Another better way is adding a common function to filter out the
> > movable zone when search position for kexec kernel, use a arch specific
> > funciton to filter out DLPAR memory blocks for ppc only. Over there,
> > we can simply use for_each_drmem_lmb() to do that.
>
> I was thinking about something similar. Maybe something like a notifier
> that can be used to test if selected memory can be used for kexec
Not sure if I get the notifier idea clearly. If you mean
1) Add a common function to pick memory in unmovable zone;
2) Let DLPAR, balloon register with notifier;
3) In the common function, ask notified part to check if the picked
unmovable memory is available for locating kexec kernel;
Sounds doable to me, and not complicated.
> images. It would apply to
>
> - arm64 and filter out all hotadded memory (IIRC, only boot memory can
> be used).
Do you mean hot added memory after boot can't be recognized and added
into system RAM on arm64?
> - powerpc to filter out all LMBs that can be removed (assuming not all
> memory corresponds to LMBs that can be removed, otherwise we're in
> trouble ... :) )
> - virtio-mem to filter out all memory it added.
> - hyper-v to filter out partially backed memory blocks (esp. the last
> memory block it added and only partially backed it by memory).
>
> This would make it work for kexec_file_load(), however, I do wonder how
> we would want to approach that from userspace kexec-tools when handling
> it from kexec_load().
Let's make kexec_file_load work firstly. Since this work is only first
step to make kexec-ed kernel not break memory hotplug. After kexec
rebooting, the KASLR may locate kernel into hotpluggable area too.
^ permalink raw reply
* Re: [PATCH 1/4] dma-mapping: move the remaining DMA API calls out of line
From: Alexey Kardashevskiy @ 2020-04-15 2:26 UTC (permalink / raw)
To: Christoph Hellwig, iommu
Cc: Greg Kroah-Hartman, Joerg Roedel, Robin Murphy, linux-kernel,
linuxppc-dev, Lu Baolu
In-Reply-To: <20200414122506.438134-2-hch@lst.de>
On 14/04/2020 22:25, Christoph Hellwig wrote:
> For a long time the DMA API has been implemented inline in dma-mapping.h,
> but the function bodies can be quite large. Move them all out of line.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> include/linux/dma-direct.h | 58 +++++++++
> include/linux/dma-mapping.h | 247 ++++--------------------------------
> kernel/dma/direct.c | 9 --
> kernel/dma/mapping.c | 164 ++++++++++++++++++++++++
> 4 files changed, 244 insertions(+), 234 deletions(-)
>
> diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h
> index 24b8684aa21d..da689ad5fffd 100644
> --- a/include/linux/dma-direct.h
> +++ b/include/linux/dma-direct.h
> @@ -85,4 +85,62 @@ int dma_direct_mmap(struct device *dev, struct vm_area_struct *vma,
> void *cpu_addr, dma_addr_t dma_addr, size_t size,
> unsigned long attrs);
> int dma_direct_supported(struct device *dev, u64 mask);
> +dma_addr_t dma_direct_map_page(struct device *dev, struct page *page,
> + unsigned long offset, size_t size, enum dma_data_direction dir,
> + unsigned long attrs);
> +int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, int nents,
> + enum dma_data_direction dir, unsigned long attrs);
> +dma_addr_t dma_direct_map_resource(struct device *dev, phys_addr_t paddr,
> + size_t size, enum dma_data_direction dir, unsigned long attrs);
> +
> +#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
> + defined(CONFIG_SWIOTLB)
> +void dma_direct_sync_single_for_device(struct device *dev,
> + dma_addr_t addr, size_t size, enum dma_data_direction dir);
> +void dma_direct_sync_sg_for_device(struct device *dev,
> + struct scatterlist *sgl, int nents, enum dma_data_direction dir);
> +#else
> +static inline void dma_direct_sync_single_for_device(struct device *dev,
> + dma_addr_t addr, size_t size, enum dma_data_direction dir)
> +{
> +}
> +static inline void dma_direct_sync_sg_for_device(struct device *dev,
> + struct scatterlist *sgl, int nents, enum dma_data_direction dir)
> +{
> +}
> +#endif
> +
> +#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
> + defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL) || \
> + defined(CONFIG_SWIOTLB)
> +void dma_direct_unmap_page(struct device *dev, dma_addr_t addr,
> + size_t size, enum dma_data_direction dir, unsigned long attrs);
> +void dma_direct_unmap_sg(struct device *dev, struct scatterlist *sgl,
> + int nents, enum dma_data_direction dir, unsigned long attrs);
> +void dma_direct_sync_single_for_cpu(struct device *dev,
> + dma_addr_t addr, size_t size, enum dma_data_direction dir);
> +void dma_direct_sync_sg_for_cpu(struct device *dev,
> + struct scatterlist *sgl, int nents, enum dma_data_direction dir);
> +#else
> +static inline void dma_direct_unmap_page(struct device *dev, dma_addr_t addr,
> + size_t size, enum dma_data_direction dir, unsigned long attrs)
> +{
> +}
> +static inline void dma_direct_unmap_sg(struct device *dev,
> + struct scatterlist *sgl, int nents, enum dma_data_direction dir,
> + unsigned long attrs)
> +{
> +}
> +static inline void dma_direct_sync_single_for_cpu(struct device *dev,
> + dma_addr_t addr, size_t size, enum dma_data_direction dir)
> +{
> +}
> +static inline void dma_direct_sync_sg_for_cpu(struct device *dev,
> + struct scatterlist *sgl, int nents, enum dma_data_direction dir)
> +{
> +}
> +#endif
> +
> +size_t dma_direct_max_mapping_size(struct device *dev);
> +
> #endif /* _LINUX_DMA_DIRECT_H */
> diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> index 330ad58fbf4d..793ad775cd54 100644
> --- a/include/linux/dma-mapping.h
> +++ b/include/linux/dma-mapping.h
> @@ -188,73 +188,6 @@ static inline int dma_mmap_from_global_coherent(struct vm_area_struct *vma,
> }
> #endif /* CONFIG_DMA_DECLARE_COHERENT */
>
> -static inline bool dma_is_direct(const struct dma_map_ops *ops)
> -{
> - return likely(!ops);
> -}
> -
> -/*
> - * All the dma_direct_* declarations are here just for the indirect call bypass,
> - * and must not be used directly drivers!
> - */
> -dma_addr_t dma_direct_map_page(struct device *dev, struct page *page,
> - unsigned long offset, size_t size, enum dma_data_direction dir,
> - unsigned long attrs);
> -int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, int nents,
> - enum dma_data_direction dir, unsigned long attrs);
> -dma_addr_t dma_direct_map_resource(struct device *dev, phys_addr_t paddr,
> - size_t size, enum dma_data_direction dir, unsigned long attrs);
> -
> -#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
> - defined(CONFIG_SWIOTLB)
> -void dma_direct_sync_single_for_device(struct device *dev,
> - dma_addr_t addr, size_t size, enum dma_data_direction dir);
> -void dma_direct_sync_sg_for_device(struct device *dev,
> - struct scatterlist *sgl, int nents, enum dma_data_direction dir);
> -#else
> -static inline void dma_direct_sync_single_for_device(struct device *dev,
> - dma_addr_t addr, size_t size, enum dma_data_direction dir)
> -{
> -}
> -static inline void dma_direct_sync_sg_for_device(struct device *dev,
> - struct scatterlist *sgl, int nents, enum dma_data_direction dir)
> -{
> -}
> -#endif
> -
> -#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
> - defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL) || \
> - defined(CONFIG_SWIOTLB)
> -void dma_direct_unmap_page(struct device *dev, dma_addr_t addr,
> - size_t size, enum dma_data_direction dir, unsigned long attrs);
> -void dma_direct_unmap_sg(struct device *dev, struct scatterlist *sgl,
> - int nents, enum dma_data_direction dir, unsigned long attrs);
> -void dma_direct_sync_single_for_cpu(struct device *dev,
> - dma_addr_t addr, size_t size, enum dma_data_direction dir);
> -void dma_direct_sync_sg_for_cpu(struct device *dev,
> - struct scatterlist *sgl, int nents, enum dma_data_direction dir);
> -#else
> -static inline void dma_direct_unmap_page(struct device *dev, dma_addr_t addr,
> - size_t size, enum dma_data_direction dir, unsigned long attrs)
> -{
> -}
> -static inline void dma_direct_unmap_sg(struct device *dev,
> - struct scatterlist *sgl, int nents, enum dma_data_direction dir,
> - unsigned long attrs)
> -{
> -}
> -static inline void dma_direct_sync_single_for_cpu(struct device *dev,
> - dma_addr_t addr, size_t size, enum dma_data_direction dir)
> -{
> -}
> -static inline void dma_direct_sync_sg_for_cpu(struct device *dev,
> - struct scatterlist *sgl, int nents, enum dma_data_direction dir)
> -{
> -}
> -#endif
> -
> -size_t dma_direct_max_mapping_size(struct device *dev);
> -
> #ifdef CONFIG_HAS_DMA
> #include <asm/dma-mapping.h>
>
> @@ -271,164 +204,6 @@ static inline void set_dma_ops(struct device *dev,
> dev->dma_ops = dma_ops;
> }
>
> -static inline dma_addr_t dma_map_page_attrs(struct device *dev,
> - struct page *page, size_t offset, size_t size,
> - enum dma_data_direction dir, unsigned long attrs)
> -{
> - const struct dma_map_ops *ops = get_dma_ops(dev);
> - dma_addr_t addr;
> -
> - BUG_ON(!valid_dma_direction(dir));
> - if (dma_is_direct(ops))
> - addr = dma_direct_map_page(dev, page, offset, size, dir, attrs);
> - else
> - addr = ops->map_page(dev, page, offset, size, dir, attrs);
> - debug_dma_map_page(dev, page, offset, size, dir, addr);
> -
> - return addr;
> -}
> -
> -static inline void dma_unmap_page_attrs(struct device *dev, dma_addr_t addr,
> - size_t size, enum dma_data_direction dir, unsigned long attrs)
> -{
> - const struct dma_map_ops *ops = get_dma_ops(dev);
> -
> - BUG_ON(!valid_dma_direction(dir));
> - if (dma_is_direct(ops))
> - dma_direct_unmap_page(dev, addr, size, dir, attrs);
> - else if (ops->unmap_page)
> - ops->unmap_page(dev, addr, size, dir, attrs);
> - debug_dma_unmap_page(dev, addr, size, dir);
> -}
> -
> -/*
> - * dma_maps_sg_attrs returns 0 on error and > 0 on success.
> - * It should never return a value < 0.
> - */
> -static inline int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg,
> - int nents, enum dma_data_direction dir,
> - unsigned long attrs)
> -{
> - const struct dma_map_ops *ops = get_dma_ops(dev);
> - int ents;
> -
> - BUG_ON(!valid_dma_direction(dir));
> - if (dma_is_direct(ops))
> - ents = dma_direct_map_sg(dev, sg, nents, dir, attrs);
> - else
> - ents = ops->map_sg(dev, sg, nents, dir, attrs);
> - BUG_ON(ents < 0);
> - debug_dma_map_sg(dev, sg, nents, ents, dir);
> -
> - return ents;
> -}
> -
> -static inline void dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sg,
> - int nents, enum dma_data_direction dir,
> - unsigned long attrs)
> -{
> - const struct dma_map_ops *ops = get_dma_ops(dev);
> -
> - BUG_ON(!valid_dma_direction(dir));
> - debug_dma_unmap_sg(dev, sg, nents, dir);
> - if (dma_is_direct(ops))
> - dma_direct_unmap_sg(dev, sg, nents, dir, attrs);
> - else if (ops->unmap_sg)
> - ops->unmap_sg(dev, sg, nents, dir, attrs);
> -}
> -
> -static inline dma_addr_t dma_map_resource(struct device *dev,
> - phys_addr_t phys_addr,
> - size_t size,
> - enum dma_data_direction dir,
> - unsigned long attrs)
> -{
> - const struct dma_map_ops *ops = get_dma_ops(dev);
> - dma_addr_t addr = DMA_MAPPING_ERROR;
> -
> - BUG_ON(!valid_dma_direction(dir));
> -
> - /* Don't allow RAM to be mapped */
> - if (WARN_ON_ONCE(pfn_valid(PHYS_PFN(phys_addr))))
> - return DMA_MAPPING_ERROR;
> -
> - if (dma_is_direct(ops))
> - addr = dma_direct_map_resource(dev, phys_addr, size, dir, attrs);
> - else if (ops->map_resource)
> - addr = ops->map_resource(dev, phys_addr, size, dir, attrs);
> -
> - debug_dma_map_resource(dev, phys_addr, size, dir, addr);
> - return addr;
> -}
> -
> -static inline void dma_unmap_resource(struct device *dev, dma_addr_t addr,
> - size_t size, enum dma_data_direction dir,
> - unsigned long attrs)
> -{
> - const struct dma_map_ops *ops = get_dma_ops(dev);
> -
> - BUG_ON(!valid_dma_direction(dir));
> - if (!dma_is_direct(ops) && ops->unmap_resource)
> - ops->unmap_resource(dev, addr, size, dir, attrs);
> - debug_dma_unmap_resource(dev, addr, size, dir);
> -}
> -
> -static inline void dma_sync_single_for_cpu(struct device *dev, dma_addr_t addr,
> - size_t size,
> - enum dma_data_direction dir)
> -{
> - const struct dma_map_ops *ops = get_dma_ops(dev);
> -
> - BUG_ON(!valid_dma_direction(dir));
> - if (dma_is_direct(ops))
> - dma_direct_sync_single_for_cpu(dev, addr, size, dir);
> - else if (ops->sync_single_for_cpu)
> - ops->sync_single_for_cpu(dev, addr, size, dir);
> - debug_dma_sync_single_for_cpu(dev, addr, size, dir);
> -}
> -
> -static inline void dma_sync_single_for_device(struct device *dev,
> - dma_addr_t addr, size_t size,
> - enum dma_data_direction dir)
> -{
> - const struct dma_map_ops *ops = get_dma_ops(dev);
> -
> - BUG_ON(!valid_dma_direction(dir));
> - if (dma_is_direct(ops))
> - dma_direct_sync_single_for_device(dev, addr, size, dir);
> - else if (ops->sync_single_for_device)
> - ops->sync_single_for_device(dev, addr, size, dir);
> - debug_dma_sync_single_for_device(dev, addr, size, dir);
> -}
> -
> -static inline void
> -dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
> - int nelems, enum dma_data_direction dir)
> -{
> - const struct dma_map_ops *ops = get_dma_ops(dev);
> -
> - BUG_ON(!valid_dma_direction(dir));
> - if (dma_is_direct(ops))
> - dma_direct_sync_sg_for_cpu(dev, sg, nelems, dir);
> - else if (ops->sync_sg_for_cpu)
> - ops->sync_sg_for_cpu(dev, sg, nelems, dir);
> - debug_dma_sync_sg_for_cpu(dev, sg, nelems, dir);
> -}
> -
> -static inline void
> -dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
> - int nelems, enum dma_data_direction dir)
> -{
> - const struct dma_map_ops *ops = get_dma_ops(dev);
> -
> - BUG_ON(!valid_dma_direction(dir));
> - if (dma_is_direct(ops))
> - dma_direct_sync_sg_for_device(dev, sg, nelems, dir);
> - else if (ops->sync_sg_for_device)
> - ops->sync_sg_for_device(dev, sg, nelems, dir);
> - debug_dma_sync_sg_for_device(dev, sg, nelems, dir);
> -
> -}
>
> static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
> {
> @@ -439,6 +214,28 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
> return 0;
> }
>
> +dma_addr_t dma_map_page_attrs(struct device *dev, struct page *page,
> + size_t offset, size_t size, enum dma_data_direction dir,
> + unsigned long attrs);
> +void dma_unmap_page_attrs(struct device *dev, dma_addr_t addr, size_t size,
> + enum dma_data_direction dir, unsigned long attrs);
> +int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg, int nents,
> + enum dma_data_direction dir, unsigned long attrs);
> +void dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sg,
> + int nents, enum dma_data_direction dir,
> + unsigned long attrs);
> +dma_addr_t dma_map_resource(struct device *dev, phys_addr_t phys_addr,
> + size_t size, enum dma_data_direction dir, unsigned long attrs);
> +void dma_unmap_resource(struct device *dev, dma_addr_t addr, size_t size,
> + enum dma_data_direction dir, unsigned long attrs);
> +void dma_sync_single_for_cpu(struct device *dev, dma_addr_t addr, size_t size,
> + enum dma_data_direction dir);
> +void dma_sync_single_for_device(struct device *dev, dma_addr_t addr,
> + size_t size, enum dma_data_direction dir);
> +void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
> + int nelems, enum dma_data_direction dir);
> +void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
> + int nelems, enum dma_data_direction dir);
> void *dma_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle,
> gfp_t flag, unsigned long attrs);
> void dma_free_attrs(struct device *dev, size_t size, void *cpu_addr,
> diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
> index 8f4bbdaf965e..f1a9099a4b5b 100644
> --- a/kernel/dma/direct.c
> +++ b/kernel/dma/direct.c
> @@ -260,7 +260,6 @@ void dma_direct_sync_single_for_device(struct device *dev,
> if (!dev_is_dma_coherent(dev))
> arch_sync_dma_for_device(paddr, size, dir);
> }
> -EXPORT_SYMBOL(dma_direct_sync_single_for_device);
May be this is correct and allowed (no idea) but removing exported
symbols at least deserves a mention in the commit log, does not it?
The rest of the series is fine and works. Thanks,
--
Alexey
^ permalink raw reply
* [PATCH 1/2] ocxl: Remove unnecessary externs
From: Alastair D'Silva @ 2020-04-15 1:23 UTC (permalink / raw)
To: alastair
Cc: Andrew Donnellan, Arnd Bergmann, Greg Kroah-Hartman, linux-kernel,
Paul Mackerras, Frederic Barrat, linuxppc-dev
In-Reply-To: <20200415012343.919255-1-alastair@d-silva.org>
Function declarations don't need externs, remove the existing ones
so they are consistent with newer code
Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
Acked-by: Andrew Donnellan <ajd@linux.ibm.com>
Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>
---
arch/powerpc/include/asm/pnv-ocxl.h | 40 ++++++++++++++---------------
include/misc/ocxl.h | 6 ++---
2 files changed, 22 insertions(+), 24 deletions(-)
diff --git a/arch/powerpc/include/asm/pnv-ocxl.h b/arch/powerpc/include/asm/pnv-ocxl.h
index 7de82647e761..ee79d2cd9fb6 100644
--- a/arch/powerpc/include/asm/pnv-ocxl.h
+++ b/arch/powerpc/include/asm/pnv-ocxl.h
@@ -9,28 +9,26 @@
#define PNV_OCXL_TL_BITS_PER_RATE 4
#define PNV_OCXL_TL_RATE_BUF_SIZE ((PNV_OCXL_TL_MAX_TEMPLATE+1) * PNV_OCXL_TL_BITS_PER_RATE / 8)
-extern int pnv_ocxl_get_actag(struct pci_dev *dev, u16 *base, u16 *enabled,
- u16 *supported);
-extern int pnv_ocxl_get_pasid_count(struct pci_dev *dev, int *count);
+int pnv_ocxl_get_actag(struct pci_dev *dev, u16 *base, u16 *enabled, u16 *supported);
+int pnv_ocxl_get_pasid_count(struct pci_dev *dev, int *count);
-extern int pnv_ocxl_get_tl_cap(struct pci_dev *dev, long *cap,
+int pnv_ocxl_get_tl_cap(struct pci_dev *dev, long *cap,
char *rate_buf, int rate_buf_size);
-extern int pnv_ocxl_set_tl_conf(struct pci_dev *dev, long cap,
- uint64_t rate_buf_phys, int rate_buf_size);
-
-extern int pnv_ocxl_get_xsl_irq(struct pci_dev *dev, int *hwirq);
-extern void pnv_ocxl_unmap_xsl_regs(void __iomem *dsisr, void __iomem *dar,
- void __iomem *tfc, void __iomem *pe_handle);
-extern int pnv_ocxl_map_xsl_regs(struct pci_dev *dev, void __iomem **dsisr,
- void __iomem **dar, void __iomem **tfc,
- void __iomem **pe_handle);
-
-extern int pnv_ocxl_spa_setup(struct pci_dev *dev, void *spa_mem, int PE_mask,
- void **platform_data);
-extern void pnv_ocxl_spa_release(void *platform_data);
-extern int pnv_ocxl_spa_remove_pe_from_cache(void *platform_data, int pe_handle);
-
-extern int pnv_ocxl_alloc_xive_irq(u32 *irq, u64 *trigger_addr);
-extern void pnv_ocxl_free_xive_irq(u32 irq);
+int pnv_ocxl_set_tl_conf(struct pci_dev *dev, long cap,
+ uint64_t rate_buf_phys, int rate_buf_size);
+
+int pnv_ocxl_get_xsl_irq(struct pci_dev *dev, int *hwirq);
+void pnv_ocxl_unmap_xsl_regs(void __iomem *dsisr, void __iomem *dar,
+ void __iomem *tfc, void __iomem *pe_handle);
+int pnv_ocxl_map_xsl_regs(struct pci_dev *dev, void __iomem **dsisr,
+ void __iomem **dar, void __iomem **tfc,
+ void __iomem **pe_handle);
+
+int pnv_ocxl_spa_setup(struct pci_dev *dev, void *spa_mem, int PE_mask, void **platform_data);
+void pnv_ocxl_spa_release(void *platform_data);
+int pnv_ocxl_spa_remove_pe_from_cache(void *platform_data, int pe_handle);
+
+int pnv_ocxl_alloc_xive_irq(u32 *irq, u64 *trigger_addr);
+void pnv_ocxl_free_xive_irq(u32 irq);
#endif /* _ASM_PNV_OCXL_H */
diff --git a/include/misc/ocxl.h b/include/misc/ocxl.h
index 06dd5839e438..0a762e387418 100644
--- a/include/misc/ocxl.h
+++ b/include/misc/ocxl.h
@@ -173,7 +173,7 @@ int ocxl_context_detach(struct ocxl_context *ctx);
*
* Returns 0 on success, negative on failure
*/
-extern int ocxl_afu_irq_alloc(struct ocxl_context *ctx, int *irq_id);
+int ocxl_afu_irq_alloc(struct ocxl_context *ctx, int *irq_id);
/**
* Frees an IRQ associated with an AFU context
@@ -182,7 +182,7 @@ extern int ocxl_afu_irq_alloc(struct ocxl_context *ctx, int *irq_id);
*
* Returns 0 on success, negative on failure
*/
-extern int ocxl_afu_irq_free(struct ocxl_context *ctx, int irq_id);
+int ocxl_afu_irq_free(struct ocxl_context *ctx, int irq_id);
/**
* Gets the address of the trigger page for an IRQ
@@ -193,7 +193,7 @@ extern int ocxl_afu_irq_free(struct ocxl_context *ctx, int irq_id);
*
* returns the trigger page address, or 0 if the IRQ is not valid
*/
-extern u64 ocxl_afu_irq_get_addr(struct ocxl_context *ctx, int irq_id);
+u64 ocxl_afu_irq_get_addr(struct ocxl_context *ctx, int irq_id);
/**
* Provide a callback to be called when an IRQ is triggered
--
2.25.1
^ permalink raw reply related
* [PATCH 2/2] ocxl: Address kernel doc errors & warnings
From: Alastair D'Silva @ 2020-04-15 1:23 UTC (permalink / raw)
To: alastair
Cc: Andrew Donnellan, Arnd Bergmann, Greg Kroah-Hartman, linux-kernel,
Paul Mackerras, Frederic Barrat, linuxppc-dev
In-Reply-To: <20200415012343.919255-1-alastair@d-silva.org>
This patch addresses warnings and errors from the kernel doc scripts for
the OpenCAPI driver.
It also makes minor tweaks to make the docs more consistent.
Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
Acked-by: Andrew Donnellan <ajd@linux.ibm.com>
---
drivers/misc/ocxl/config.c | 24 ++++----
drivers/misc/ocxl/ocxl_internal.h | 9 +--
include/misc/ocxl.h | 96 ++++++++++++-------------------
3 files changed, 55 insertions(+), 74 deletions(-)
diff --git a/drivers/misc/ocxl/config.c b/drivers/misc/ocxl/config.c
index c8e19bfb5ef9..a62e3d7db2bf 100644
--- a/drivers/misc/ocxl/config.c
+++ b/drivers/misc/ocxl/config.c
@@ -273,16 +273,16 @@ static int read_afu_info(struct pci_dev *dev, struct ocxl_fn_config *fn,
}
/**
- * Read the template version from the AFU
- * dev: the device for the AFU
- * fn: the AFU offsets
- * len: outputs the template length
- * version: outputs the major<<8,minor version
+ * read_template_version() - Read the template version from the AFU
+ * @dev: the device for the AFU
+ * @fn: the AFU offsets
+ * @len: outputs the template length
+ * @version: outputs the major<<8,minor version
*
* Returns 0 on success, negative on failure
*/
static int read_template_version(struct pci_dev *dev, struct ocxl_fn_config *fn,
- u16 *len, u16 *version)
+ u16 *len, u16 *version)
{
u32 val32;
u8 major, minor;
@@ -476,16 +476,16 @@ static int validate_afu(struct pci_dev *dev, struct ocxl_afu_config *afu)
}
/**
- * Populate AFU metadata regarding LPC memory
- * dev: the device for the AFU
- * fn: the AFU offsets
- * afu: the AFU struct to populate the LPC metadata into
+ * read_afu_lpc_memory_info() - Populate AFU metadata regarding LPC memory
+ * @dev: the device for the AFU
+ * @fn: the AFU offsets
+ * @afu: the AFU struct to populate the LPC metadata into
*
* Returns 0 on success, negative on failure
*/
static int read_afu_lpc_memory_info(struct pci_dev *dev,
- struct ocxl_fn_config *fn,
- struct ocxl_afu_config *afu)
+ struct ocxl_fn_config *fn,
+ struct ocxl_afu_config *afu)
{
int rc;
u32 val32;
diff --git a/drivers/misc/ocxl/ocxl_internal.h b/drivers/misc/ocxl/ocxl_internal.h
index 345bf843a38e..198e4e4bc51d 100644
--- a/drivers/misc/ocxl/ocxl_internal.h
+++ b/drivers/misc/ocxl/ocxl_internal.h
@@ -122,11 +122,12 @@ int ocxl_config_check_afu_index(struct pci_dev *dev,
struct ocxl_fn_config *fn, int afu_idx);
/**
- * Update values within a Process Element
+ * ocxl_link_update_pe() - 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
*
- * 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
+ * Returns 0 on success
*/
int ocxl_link_update_pe(void *link_handle, int pasid, __u16 tid);
diff --git a/include/misc/ocxl.h b/include/misc/ocxl.h
index 0a762e387418..357ef1aadbc0 100644
--- a/include/misc/ocxl.h
+++ b/include/misc/ocxl.h
@@ -62,8 +62,7 @@ struct ocxl_context;
// Device detection & initialisation
/**
- * Open an OpenCAPI function on an OpenCAPI device
- *
+ * ocxl_function_open() - Open an OpenCAPI function on an OpenCAPI device
* @dev: The PCI device that contains the function
*
* Returns an opaque pointer to the function, or an error pointer (check with IS_ERR)
@@ -71,8 +70,7 @@ struct ocxl_context;
struct ocxl_fn *ocxl_function_open(struct pci_dev *dev);
/**
- * Get the list of AFUs associated with a PCI function device
- *
+ * ocxl_function_afu_list() - Get the list of AFUs associated with a PCI function device
* Returns a list of struct ocxl_afu *
*
* @fn: The OpenCAPI function containing the AFUs
@@ -80,8 +78,7 @@ struct ocxl_fn *ocxl_function_open(struct pci_dev *dev);
struct list_head *ocxl_function_afu_list(struct ocxl_fn *fn);
/**
- * Fetch an AFU instance from an OpenCAPI function
- *
+ * ocxl_function_fetch_afu() - Fetch an AFU instance from an OpenCAPI function
* @fn: The OpenCAPI function to get the AFU from
* @afu_idx: The index of the AFU to get
*
@@ -92,23 +89,20 @@ struct list_head *ocxl_function_afu_list(struct ocxl_fn *fn);
struct ocxl_afu *ocxl_function_fetch_afu(struct ocxl_fn *fn, u8 afu_idx);
/**
- * Take a reference to an AFU
- *
+ * ocxl_afu_get() - Take a reference to an AFU
* @afu: The AFU to increment the reference count on
*/
void ocxl_afu_get(struct ocxl_afu *afu);
/**
- * Release a reference to an AFU
- *
+ * ocxl_afu_put() - Release a reference to an AFU
* @afu: The AFU to decrement the reference count on
*/
void ocxl_afu_put(struct ocxl_afu *afu);
/**
- * Get the configuration information for an OpenCAPI function
- *
+ * ocxl_function_config() - Get the configuration information for an OpenCAPI function
* @fn: The OpenCAPI function to get the config for
*
* Returns the function config, or NULL on error
@@ -116,8 +110,7 @@ void ocxl_afu_put(struct ocxl_afu *afu);
const struct ocxl_fn_config *ocxl_function_config(struct ocxl_fn *fn);
/**
- * Close an OpenCAPI function
- *
+ * ocxl_function_close() - Close an OpenCAPI function
* This will free any AFUs previously retrieved from the function, and
* detach and associated contexts. The contexts must by freed by the caller.
*
@@ -129,8 +122,7 @@ void ocxl_function_close(struct ocxl_fn *fn);
// Context allocation
/**
- * Allocate an OpenCAPI context
- *
+ * ocxl_context_alloc() - Allocate an OpenCAPI context
* @context: The OpenCAPI context to allocate, must be freed with ocxl_context_free
* @afu: The AFU the context belongs to
* @mapping: The mapping to unmap when the context is closed (may be NULL)
@@ -139,14 +131,13 @@ int ocxl_context_alloc(struct ocxl_context **context, struct ocxl_afu *afu,
struct address_space *mapping);
/**
- * Free an OpenCAPI context
- *
+ * ocxl_context_free() - Free an OpenCAPI context
* @ctx: The OpenCAPI context to free
*/
void ocxl_context_free(struct ocxl_context *ctx);
/**
- * Grant access to an MM to an OpenCAPI context
+ * ocxl_context_attach() - Grant access to an MM to an OpenCAPI context
* @ctx: The OpenCAPI context to attach
* @amr: The value of the AMR register to restrict access
* @mm: The mm to attach to the context
@@ -157,7 +148,7 @@ int ocxl_context_attach(struct ocxl_context *ctx, u64 amr,
struct mm_struct *mm);
/**
- * Detach an MM from an OpenCAPI context
+ * ocxl_context_detach() - Detach an MM from an OpenCAPI context
* @ctx: The OpenCAPI context to attach
*
* Returns 0 on success, negative on failure
@@ -167,7 +158,7 @@ int ocxl_context_detach(struct ocxl_context *ctx);
// AFU IRQs
/**
- * Allocate an IRQ associated with an AFU context
+ * ocxl_afu_irq_alloc() - Allocate an IRQ associated with an AFU context
* @ctx: the AFU context
* @irq_id: out, the IRQ ID
*
@@ -176,7 +167,7 @@ int ocxl_context_detach(struct ocxl_context *ctx);
int ocxl_afu_irq_alloc(struct ocxl_context *ctx, int *irq_id);
/**
- * Frees an IRQ associated with an AFU context
+ * ocxl_afu_irq_free() - Frees an IRQ associated with an AFU context
* @ctx: the AFU context
* @irq_id: the IRQ ID
*
@@ -185,7 +176,7 @@ int ocxl_afu_irq_alloc(struct ocxl_context *ctx, int *irq_id);
int ocxl_afu_irq_free(struct ocxl_context *ctx, int irq_id);
/**
- * Gets the address of the trigger page for an IRQ
+ * ocxl_afu_irq_get_addr() - Gets the address of the trigger page for an IRQ
* This can then be provided to an AFU which will write to that
* page to trigger the IRQ.
* @ctx: The AFU context that the IRQ is associated with
@@ -196,7 +187,7 @@ int ocxl_afu_irq_free(struct ocxl_context *ctx, int irq_id);
u64 ocxl_afu_irq_get_addr(struct ocxl_context *ctx, int irq_id);
/**
- * Provide a callback to be called when an IRQ is triggered
+ * ocxl_irq_set_handler() - Provide a callback to be called when an IRQ is triggered
* @ctx: The AFU context that the IRQ is associated with
* @irq_id: The IRQ ID
* @handler: the callback to be called when the IRQ is triggered
@@ -213,8 +204,7 @@ int ocxl_irq_set_handler(struct ocxl_context *ctx, int irq_id,
// AFU Metadata
/**
- * Get a pointer to the config for an AFU
- *
+ * ocxl_afu_config() - Get a pointer to the config for an AFU
* @afu: a pointer to the AFU to get the config for
*
* Returns a pointer to the AFU config
@@ -222,27 +212,24 @@ int ocxl_irq_set_handler(struct ocxl_context *ctx, int irq_id,
struct ocxl_afu_config *ocxl_afu_config(struct ocxl_afu *afu);
/**
- * Assign opaque hardware specific information to an OpenCAPI AFU.
- *
- * @dev: The PCI device associated with the OpenCAPI device
+ * ocxl_afu_set_private() - Assign opaque hardware specific information to an OpenCAPI AFU.
+ * @afu: The OpenCAPI AFU
* @private: the opaque hardware specific information to assign to the driver
*/
void ocxl_afu_set_private(struct ocxl_afu *afu, void *private);
/**
- * Fetch the hardware specific information associated with an external OpenCAPI
- * AFU. This may be consumed by an external OpenCAPI driver.
- *
- * @afu: The AFU
+ * ocxl_afu_get_private() - Fetch the hardware specific information associated with
+ * an external OpenCAPI AFU. This may be consumed by an external OpenCAPI driver.
+ * @afu: The OpenCAPI AFU
*
* Returns the opaque pointer associated with the device, or NULL if not set
*/
-void *ocxl_afu_get_private(struct ocxl_afu *dev);
+void *ocxl_afu_get_private(struct ocxl_afu *afu);
// Global MMIO
/**
- * Read a 32 bit value from global MMIO
- *
+ * ocxl_global_mmio_read32() - Read a 32 bit value from global MMIO
* @afu: The AFU
* @offset: The Offset from the start of MMIO
* @endian: the endianness that the MMIO data is in
@@ -251,11 +238,10 @@ void *ocxl_afu_get_private(struct ocxl_afu *dev);
* Returns 0 for success, negative on error
*/
int ocxl_global_mmio_read32(struct ocxl_afu *afu, size_t offset,
- enum ocxl_endian endian, u32 *val);
+ enum ocxl_endian endian, u32 *val);
/**
- * Read a 64 bit value from global MMIO
- *
+ * ocxl_global_mmio_read64() - Read a 64 bit value from global MMIO
* @afu: The AFU
* @offset: The Offset from the start of MMIO
* @endian: the endianness that the MMIO data is in
@@ -264,11 +250,10 @@ int ocxl_global_mmio_read32(struct ocxl_afu *afu, size_t offset,
* Returns 0 for success, negative on error
*/
int ocxl_global_mmio_read64(struct ocxl_afu *afu, size_t offset,
- enum ocxl_endian endian, u64 *val);
+ enum ocxl_endian endian, u64 *val);
/**
- * Write a 32 bit value to global MMIO
- *
+ * ocxl_global_mmio_write32() - Write a 32 bit value to global MMIO
* @afu: The AFU
* @offset: The Offset from the start of MMIO
* @endian: the endianness that the MMIO data is in
@@ -277,11 +262,10 @@ int ocxl_global_mmio_read64(struct ocxl_afu *afu, size_t offset,
* Returns 0 for success, negative on error
*/
int ocxl_global_mmio_write32(struct ocxl_afu *afu, size_t offset,
- enum ocxl_endian endian, u32 val);
+ enum ocxl_endian endian, u32 val);
/**
- * Write a 64 bit value to global MMIO
- *
+ * ocxl_global_mmio_write64() - Write a 64 bit value to global MMIO
* @afu: The AFU
* @offset: The Offset from the start of MMIO
* @endian: the endianness that the MMIO data is in
@@ -290,11 +274,10 @@ int ocxl_global_mmio_write32(struct ocxl_afu *afu, size_t offset,
* Returns 0 for success, negative on error
*/
int ocxl_global_mmio_write64(struct ocxl_afu *afu, size_t offset,
- enum ocxl_endian endian, u64 val);
+ enum ocxl_endian endian, u64 val);
/**
- * Set bits in a 32 bit global MMIO register
- *
+ * ocxl_global_mmio_set32() - Set bits in a 32 bit global MMIO register
* @afu: The AFU
* @offset: The Offset from the start of MMIO
* @endian: the endianness that the MMIO data is in
@@ -303,11 +286,10 @@ int ocxl_global_mmio_write64(struct ocxl_afu *afu, size_t offset,
* Returns 0 for success, negative on error
*/
int ocxl_global_mmio_set32(struct ocxl_afu *afu, size_t offset,
- enum ocxl_endian endian, u32 mask);
+ enum ocxl_endian endian, u32 mask);
/**
- * Set bits in a 64 bit global MMIO register
- *
+ * ocxl_global_mmio_set64() - Set bits in a 64 bit global MMIO register
* @afu: The AFU
* @offset: The Offset from the start of MMIO
* @endian: the endianness that the MMIO data is in
@@ -316,11 +298,10 @@ int ocxl_global_mmio_set32(struct ocxl_afu *afu, size_t offset,
* Returns 0 for success, negative on error
*/
int ocxl_global_mmio_set64(struct ocxl_afu *afu, size_t offset,
- enum ocxl_endian endian, u64 mask);
+ enum ocxl_endian endian, u64 mask);
/**
- * Set bits in a 32 bit global MMIO register
- *
+ * ocxl_global_mmio_clear32() - Set bits in a 32 bit global MMIO register
* @afu: The AFU
* @offset: The Offset from the start of MMIO
* @endian: the endianness that the MMIO data is in
@@ -329,11 +310,10 @@ int ocxl_global_mmio_set64(struct ocxl_afu *afu, size_t offset,
* Returns 0 for success, negative on error
*/
int ocxl_global_mmio_clear32(struct ocxl_afu *afu, size_t offset,
- enum ocxl_endian endian, u32 mask);
+ enum ocxl_endian endian, u32 mask);
/**
- * Set bits in a 64 bit global MMIO register
- *
+ * ocxl_global_mmio_clear64() - Set bits in a 64 bit global MMIO register
* @afu: The AFU
* @offset: The Offset from the start of MMIO
* @endian: the endianness that the MMIO data is in
@@ -342,7 +322,7 @@ int ocxl_global_mmio_clear32(struct ocxl_afu *afu, size_t offset,
* Returns 0 for success, negative on error
*/
int ocxl_global_mmio_clear64(struct ocxl_afu *afu, size_t offset,
- enum ocxl_endian endian, u64 mask);
+ enum ocxl_endian endian, u64 mask);
// Functions left here are for compatibility with the cxlflash driver
--
2.25.1
^ permalink raw reply related
* [PATCH 0/2] powerpc: OpenCAPI Cleanup
From: Alastair D'Silva @ 2020-04-15 1:23 UTC (permalink / raw)
To: alastair
Cc: Andrew Donnellan, Arnd Bergmann, Greg Kroah-Hartman, linux-kernel,
Paul Mackerras, Frederic Barrat, linuxppc-dev
These patches address checkpatch & kernel doc warnings
in the OpenCAPI infrastructure.
Alastair D'Silva (2):
ocxl: Remove unnecessary externs
ocxl: Address kernel doc errors & warnings
arch/powerpc/include/asm/pnv-ocxl.h | 40 ++++++-----
drivers/misc/ocxl/config.c | 24 +++----
drivers/misc/ocxl/ocxl_internal.h | 9 +--
include/misc/ocxl.h | 102 +++++++++++-----------------
4 files changed, 77 insertions(+), 98 deletions(-)
--
2.25.1
^ permalink raw reply
* Re: [PATCH v2 25/33] docs: powerpc: cxl.rst: mark two section titles as such
From: Andrew Donnellan @ 2020-04-15 0:16 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Linux Doc Mailing List
Cc: Jonathan Corbet, linux-kernel, Paul Mackerras, Frederic Barrat,
linuxppc-dev
In-Reply-To: <190d67397cd63e419de8d85b92e8018d48e8c345.1586881715.git.mchehab+huawei@kernel.org>
On 15/4/20 2:48 am, Mauro Carvalho Chehab wrote:
> The User API chapter contains two sub-chapters. Mark them as
> such.
>
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Acked-by: Andrew Donnellan <ajd@linux.ibm.com>
--
Andrew Donnellan OzLabs, ADL Canberra
ajd@linux.ibm.com IBM Australia Limited
^ permalink raw reply
* Re: [PATCH] target/ppc: Fix mtmsr(d) L=1 variant that loses interrupts
From: Nathan Chancellor @ 2020-04-14 23:35 UTC (permalink / raw)
To: Nicholas Piggin
Cc: qemu-stable, qemu-devel, Cédric Le Goater, qemu-ppc,
linuxppc-dev, David Gibson
In-Reply-To: <20200414111131.465560-1-npiggin@gmail.com>
On Tue, Apr 14, 2020 at 09:11:31PM +1000, Nicholas Piggin wrote:
> If mtmsr L=1 sets MSR[EE] while there is a maskable exception pending,
> it does not cause an interrupt. This causes the test case to hang:
>
> https://lists.gnu.org/archive/html/qemu-ppc/2019-10/msg00826.html
>
> More recently, Linux reduced the occurance of operations (e.g., rfi)
> which stop translation and allow pending interrupts to be processed.
> This started causing hangs in Linux boot in long-running kernel tests,
> running with '-d int' shows the decrementer stops firing despite DEC
> wrapping and MSR[EE]=1.
>
> https://lists.ozlabs.org/pipermail/linuxppc-dev/2020-April/208301.html
>
> The cause is the broken mtmsr L=1 behaviour, which is contrary to the
> architecture. From Power ISA v3.0B, p.977, Move To Machine State Register,
> Programming Note states:
>
> If MSR[EE]=0 and an External, Decrementer, or Performance Monitor
> exception is pending, executing an mtmsrd instruction that sets
> MSR[EE] to 1 will cause the interrupt to occur before the next
> instruction is executed, if no higher priority exception exists
>
> Fix this by handling L=1 exactly the same way as L=0, modulo the MSR
> bits altered.
>
> The confusion arises from L=0 being "context synchronizing" whereas L=1
> is "execution synchronizing", which is a weaker semantic. However this
> is not a relaxation of the requirement that these exceptions cause
> interrupts when MSR[EE]=1 (e.g., when mtmsr executes to completion as
> TCG is doing here), rather it specifies how a pipelined processor can
> have multiple instructions in flight where one may influence how another
> behaves.
>
> Cc: qemu-stable@nongnu.org
> Reported-by: Anton Blanchard <anton@ozlabs.org>
> Reported-by: Nathan Chancellor <natechancellor@gmail.com>
> Tested-by: Nathan Chancellor <natechancellor@gmail.com>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> Thanks very much to Nathan for reporting and testing it, I added his
> Tested-by tag despite a more polished patch, as the the basics are
> still the same (and still fixes his test case here).
I did re-run the test with the updated version of your patch and it
passed still so that tag can still stand without any controversy :)
Thank you for the fix again!
Nathan
> This bug possibly goes back to early v2.04 / mtmsrd L=1 support around
> 2007, and the code has been changed several times since then so may
> require some backporting.
>
> 32-bit / mtmsr untested at the moment, I don't have an environment
> handy.
>
> target/ppc/translate.c | 46 +++++++++++++++++++++++++-----------------
> 1 file changed, 27 insertions(+), 19 deletions(-)
>
> diff --git a/target/ppc/translate.c b/target/ppc/translate.c
> index b207fb5386..9959259dba 100644
> --- a/target/ppc/translate.c
> +++ b/target/ppc/translate.c
> @@ -4361,30 +4361,34 @@ static void gen_mtmsrd(DisasContext *ctx)
> CHK_SV;
>
> #if !defined(CONFIG_USER_ONLY)
> + if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
> + gen_io_start();
> + }
> if (ctx->opcode & 0x00010000) {
> - /* Special form that does not need any synchronisation */
> + /* L=1 form only updates EE and RI */
> TCGv t0 = tcg_temp_new();
> + TCGv t1 = tcg_temp_new();
> tcg_gen_andi_tl(t0, cpu_gpr[rS(ctx->opcode)],
> (1 << MSR_RI) | (1 << MSR_EE));
> - tcg_gen_andi_tl(cpu_msr, cpu_msr,
> + tcg_gen_andi_tl(t1, cpu_msr,
> ~(target_ulong)((1 << MSR_RI) | (1 << MSR_EE)));
> - tcg_gen_or_tl(cpu_msr, cpu_msr, t0);
> + tcg_gen_or_tl(t1, t1, t0);
> +
> + gen_helper_store_msr(cpu_env, t1);
> tcg_temp_free(t0);
> + tcg_temp_free(t1);
> +
> } else {
> /*
> * XXX: we need to update nip before the store if we enter
> * power saving mode, we will exit the loop directly from
> * ppc_store_msr
> */
> - if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
> - gen_io_start();
> - }
> gen_update_nip(ctx, ctx->base.pc_next);
> gen_helper_store_msr(cpu_env, cpu_gpr[rS(ctx->opcode)]);
> - /* Must stop the translation as machine state (may have) changed */
> - /* Note that mtmsr is not always defined as context-synchronizing */
> - gen_stop_exception(ctx);
> }
> + /* Must stop the translation as machine state (may have) changed */
> + gen_stop_exception(ctx);
> #endif /* !defined(CONFIG_USER_ONLY) */
> }
> #endif /* defined(TARGET_PPC64) */
> @@ -4394,15 +4398,23 @@ static void gen_mtmsr(DisasContext *ctx)
> CHK_SV;
>
> #if !defined(CONFIG_USER_ONLY)
> - if (ctx->opcode & 0x00010000) {
> - /* Special form that does not need any synchronisation */
> + if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
> + gen_io_start();
> + }
> + if (ctx->opcode & 0x00010000) {
> + /* L=1 form only updates EE and RI */
> TCGv t0 = tcg_temp_new();
> + TCGv t1 = tcg_temp_new();
> tcg_gen_andi_tl(t0, cpu_gpr[rS(ctx->opcode)],
> (1 << MSR_RI) | (1 << MSR_EE));
> - tcg_gen_andi_tl(cpu_msr, cpu_msr,
> + tcg_gen_andi_tl(t1, cpu_msr,
> ~(target_ulong)((1 << MSR_RI) | (1 << MSR_EE)));
> - tcg_gen_or_tl(cpu_msr, cpu_msr, t0);
> + tcg_gen_or_tl(t1, t1, t0);
> +
> + gen_helper_store_msr(cpu_env, t1);
> tcg_temp_free(t0);
> + tcg_temp_free(t1);
> +
> } else {
> TCGv msr = tcg_temp_new();
>
> @@ -4411,9 +4423,6 @@ static void gen_mtmsr(DisasContext *ctx)
> * power saving mode, we will exit the loop directly from
> * ppc_store_msr
> */
> - if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
> - gen_io_start();
> - }
> gen_update_nip(ctx, ctx->base.pc_next);
> #if defined(TARGET_PPC64)
> tcg_gen_deposit_tl(msr, cpu_msr, cpu_gpr[rS(ctx->opcode)], 0, 32);
> @@ -4422,10 +4431,9 @@ static void gen_mtmsr(DisasContext *ctx)
> #endif
> gen_helper_store_msr(cpu_env, msr);
> tcg_temp_free(msr);
> - /* Must stop the translation as machine state (may have) changed */
> - /* Note that mtmsr is not always defined as context-synchronizing */
> - gen_stop_exception(ctx);
> }
> + /* Must stop the translation as machine state (may have) changed */
> + gen_stop_exception(ctx);
> #endif
> }
>
> --
> 2.23.0
>
^ permalink raw reply
* [PATCH] powerpc/powernv/pci: Add an explaination for PNV_IODA_PE_BUS_ALL
From: Oliver O'Halloran @ 2020-04-14 23:35 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Oliver O'Halloran
It's pretty obsecure and confused me for a long time so I figured it's
worth documenting properly.
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
arch/powerpc/platforms/powernv/pci.h | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/arch/powerpc/platforms/powernv/pci.h b/arch/powerpc/platforms/powernv/pci.h
index a8cde70..51c254f2 100644
--- a/arch/powerpc/platforms/powernv/pci.h
+++ b/arch/powerpc/platforms/powernv/pci.h
@@ -33,6 +33,24 @@ enum pnv_phb_model {
#define PNV_IODA_PE_SLAVE (1 << 4) /* Slave PE in compound case */
#define PNV_IODA_PE_VF (1 << 5) /* PE for one VF */
+/*
+ * A brief note on PNV_IODA_PE_BUS_ALL
+ *
+ * This is needed because of the behaviour of PCIe-to-PCI bridges. The PHB uses
+ * the Requester ID field of the PCIe request header to determine the device
+ * (and PE) that initiated a DMA. In legacy PCI individual memory read/write
+ * requests aren't tagged with the RID. To work around this the PCIe-to-PCI
+ * bridge will use (secondary_bus_no << 8) | 0x00 as the RID on the PCIe side.
+ *
+ * PCIe-to-X bridges have a similar issue even though PCI-X requests also have
+ * a RID in the transaction header. The PCIe-to-X bridge is permitted to "take
+ * ownership" of a transaction by a PCI-X device when forwarding it to the PCIe
+ * side of the bridge.
+ *
+ * To work around these problems we use the BUS_ALL flag since every subordinate
+ * bus of the bridge should go into the same PE.
+ */
+
/* Indicates operations are frozen for a PE: MMIO in PESTA & DMA in PESTB. */
#define PNV_IODA_STOPPED_STATE 0x8000000000000000
--
2.9.5
^ permalink raw reply related
* Re: [PATCH 3/8] fs: wrap simple_pin_fs/simple_release_fs arguments in a struct
From: Greg Kroah-Hartman @ 2020-04-14 13:03 UTC (permalink / raw)
To: Emanuele Giuseppe Esposito
Cc: Song Liu, linux-usb, bpf, Rafael J. Wysocki, David Airlie,
Heiko Carstens, Alexei Starovoitov, dri-devel, J. Bruce Fields,
Joseph Qi, Hugh Dickins, Paul Mackerras, John Johansen, netdev,
ocfs2-devel, Christoph Hellwig, Andrew Donnellan, Matthew Garrett,
linux-efi, Arnd Bergmann, Daniel Borkmann, Christian Borntraeger,
linux-rdma, Mark Fasheh, Anton Vorontsov, John Fastabend,
James Morris, Ard Biesheuvel, Jason Gunthorpe, Doug Ledford,
oprofile-list, Yonghong Song, Ian Kent, Andrii Nakryiko,
Alexey Dobriyan, Serge E. Hallyn, Robert Richter,
Thomas Zimmermann, Vasily Gorbik, Tony Luck, Kees Cook,
James E.J. Bottomley, autofs, Maarten Lankhorst, Mike Marciniszyn,
Maxime Ripard, linux-fsdevel, Manoj N. Kumar, Uma Krishnan,
Jakub Kicinski, KP Singh, Trond Myklebust, Matthew R. Ochs,
David S. Miller, Felipe Balbi, linux-nfs, Iurii Zaikin,
linux-scsi, Martin K. Petersen, linux-mm, linux-s390,
Dennis Dalessandro, Miklos Szeredi, linux-security-module,
linux-kernel, Anna Schumaker, Luis Chamberlain, Chuck Lever,
Jeremy Kerr, Daniel Vetter, Colin Cross, Frederic Barrat,
Paolo Bonzini, Andrew Morton, Mike Kravetz, linuxppc-dev,
Martin KaFai Lau, Joel Becker, Alexander Viro
In-Reply-To: <20200414124304.4470-4-eesposit@redhat.com>
On Tue, Apr 14, 2020 at 02:42:57PM +0200, Emanuele Giuseppe Esposito wrote:
> @@ -676,9 +674,9 @@ static void __debugfs_file_removed(struct dentry *dentry)
>
> static void remove_one(struct dentry *victim)
> {
> - if (d_is_reg(victim))
> + if (d_is_reg(victim))
> __debugfs_file_removed(victim);
> - simple_release_fs(&debugfs_mount, &debugfs_mount_count);
> + simple_release_fs(&debugfs);
> }
>
> /**
Always run checkpatch.pl on your patches so you do not get grumpy
maintainers telling you to run checkpatch.pl on your patches...
^ permalink raw reply
* Re: [PATCH 4/8] fs: introduce simple_new_inode
From: Greg Kroah-Hartman @ 2020-04-14 13:01 UTC (permalink / raw)
To: Emanuele Giuseppe Esposito
Cc: Song Liu, linux-usb, bpf, Rafael J. Wysocki, David Airlie,
Heiko Carstens, Alexei Starovoitov, dri-devel, J. Bruce Fields,
Joseph Qi, Hugh Dickins, Paul Mackerras, John Johansen, netdev,
ocfs2-devel, Christoph Hellwig, Andrew Donnellan, Matthew Garrett,
linux-efi, Arnd Bergmann, Daniel Borkmann, Christian Borntraeger,
linux-rdma, Mark Fasheh, Anton Vorontsov, John Fastabend,
James Morris, Ard Biesheuvel, Jason Gunthorpe, Doug Ledford,
oprofile-list, Yonghong Song, Ian Kent, Andrii Nakryiko,
Alexey Dobriyan, Serge E. Hallyn, Robert Richter,
Thomas Zimmermann, Vasily Gorbik, Tony Luck, Kees Cook,
James E.J. Bottomley, autofs, Maarten Lankhorst, Mike Marciniszyn,
Maxime Ripard, linux-fsdevel, Manoj N. Kumar, Uma Krishnan,
Jakub Kicinski, KP Singh, Trond Myklebust, Matthew R. Ochs,
David S. Miller, Felipe Balbi, linux-nfs, Iurii Zaikin,
linux-scsi, Martin K. Petersen, linux-mm, linux-s390,
Dennis Dalessandro, Miklos Szeredi, linux-security-module,
linux-kernel, Anna Schumaker, Luis Chamberlain, Chuck Lever,
Jeremy Kerr, Daniel Vetter, Colin Cross, Frederic Barrat,
Paolo Bonzini, Andrew Morton, Mike Kravetz, linuxppc-dev,
Martin KaFai Lau, Joel Becker, Alexander Viro
In-Reply-To: <20200414124304.4470-5-eesposit@redhat.com>
On Tue, Apr 14, 2020 at 02:42:58PM +0200, Emanuele Giuseppe Esposito wrote:
> It is a common special case for new_inode to initialize the
> time to the current time and the inode to get_next_ino().
> Introduce a core function that does it and use it throughout
> Linux.
Shouldn't this just be called new_inode_current_time()?
How is anyone going to remember what simple_new_inode() does to the
inode structure?
> --- a/fs/libfs.c
> +++ b/fs/libfs.c
> @@ -595,6 +595,18 @@ int simple_write_end(struct file *file, struct address_space *mapping,
> }
> EXPORT_SYMBOL(simple_write_end);
>
> +struct inode *simple_new_inode(struct super_block *sb)
> +{
> + struct inode *inode = new_inode(sb);
> + if (inode) {
> + inode->i_ino = get_next_ino();
> + inode->i_atime = inode->i_mtime =
> + inode->i_ctime = current_time(inode);
> + }
> + return inode;
> +}
> +EXPORT_SYMBOL(simple_new_inode);
No kernel doc explaining that get_next_ino() is called already?
Please document new global functions like this so we have a chance to
know how to use them.
Also, it is almost always easier to introduce a common function, get it
merged, and _THEN_ send out cleanup functions to all of the different
subsystems to convert over to it. Yes, it takes longer, but it makes it
possible to do this in a way that can be reviewed properly, unlike this
patch series :(
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH 6/8] simplefs: add file creation functions
From: Greg Kroah-Hartman @ 2020-04-14 12:56 UTC (permalink / raw)
To: Emanuele Giuseppe Esposito
Cc: Song Liu, linux-usb, bpf, Rafael J. Wysocki, David Airlie,
Heiko Carstens, Alexei Starovoitov, dri-devel, J. Bruce Fields,
Joseph Qi, Hugh Dickins, Paul Mackerras, John Johansen, netdev,
ocfs2-devel, Christoph Hellwig, Andrew Donnellan, Matthew Garrett,
linux-efi, Arnd Bergmann, Daniel Borkmann, Christian Borntraeger,
linux-rdma, Mark Fasheh, Anton Vorontsov, John Fastabend,
James Morris, Ard Biesheuvel, Jason Gunthorpe, Doug Ledford,
oprofile-list, Yonghong Song, Ian Kent, Andrii Nakryiko,
Alexey Dobriyan, Serge E. Hallyn, Robert Richter,
Thomas Zimmermann, Vasily Gorbik, Tony Luck, Kees Cook,
James E.J. Bottomley, autofs, Maarten Lankhorst, Mike Marciniszyn,
Maxime Ripard, linux-fsdevel, Manoj N. Kumar, Uma Krishnan,
Jakub Kicinski, KP Singh, Trond Myklebust, Matthew R. Ochs,
David S. Miller, Felipe Balbi, linux-nfs, Iurii Zaikin,
linux-scsi, Martin K. Petersen, linux-mm, linux-s390,
Dennis Dalessandro, Miklos Szeredi, linux-security-module,
linux-kernel, Anna Schumaker, Luis Chamberlain, Chuck Lever,
Jeremy Kerr, Daniel Vetter, Colin Cross, Frederic Barrat,
Paolo Bonzini, Andrew Morton, Mike Kravetz, linuxppc-dev,
Martin KaFai Lau, Joel Becker, Alexander Viro
In-Reply-To: <20200414124304.4470-7-eesposit@redhat.com>
On Tue, Apr 14, 2020 at 02:43:00PM +0200, Emanuele Giuseppe Esposito wrote:
> A bunch of code is duplicated between debugfs and tracefs, unify it to the
> simplefs library.
>
> The code is very similar, except that dentry and inode creation are unified
> into a single function (unlike start_creating in debugfs and tracefs, which
> only takes care of dentries). This adds an output parameter to the creation
> functions, but pushes all error recovery into fs/simplefs.c.
>
> Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
> ---
> fs/simplefs.c | 150 +++++++++++++++++++++++++++++++++++++++
> include/linux/simplefs.h | 19 +++++
> 2 files changed, 169 insertions(+)
What's wrong with libfs, isn't that supposed to be for these types of
"common" filesystem interactions?
Why create a whole "new" fs for this?
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH 5/8] simplefs: add alloc_anon_inode wrapper
From: Greg Kroah-Hartman @ 2020-04-14 12:55 UTC (permalink / raw)
To: Emanuele Giuseppe Esposito
Cc: Song Liu, linux-usb, bpf, Rafael J. Wysocki, David Airlie,
Heiko Carstens, Alexei Starovoitov, dri-devel, J. Bruce Fields,
Joseph Qi, Hugh Dickins, Paul Mackerras, John Johansen, netdev,
ocfs2-devel, Christoph Hellwig, Andrew Donnellan, Matthew Garrett,
linux-efi, Arnd Bergmann, Daniel Borkmann, Christian Borntraeger,
linux-rdma, Mark Fasheh, Anton Vorontsov, John Fastabend,
James Morris, Ard Biesheuvel, Jason Gunthorpe, Doug Ledford,
oprofile-list, Yonghong Song, Ian Kent, Andrii Nakryiko,
Alexey Dobriyan, Serge E. Hallyn, Robert Richter,
Thomas Zimmermann, Vasily Gorbik, Tony Luck, Kees Cook,
James E.J. Bottomley, autofs, Maarten Lankhorst, Mike Marciniszyn,
Maxime Ripard, linux-fsdevel, Manoj N. Kumar, Uma Krishnan,
Jakub Kicinski, KP Singh, Trond Myklebust, Matthew R. Ochs,
David S. Miller, Felipe Balbi, linux-nfs, Iurii Zaikin,
linux-scsi, Martin K. Petersen, linux-mm, linux-s390,
Dennis Dalessandro, Miklos Szeredi, linux-security-module,
linux-kernel, Anna Schumaker, Luis Chamberlain, Chuck Lever,
Jeremy Kerr, Daniel Vetter, Colin Cross, Frederic Barrat,
Paolo Bonzini, Andrew Morton, Mike Kravetz, linuxppc-dev,
Martin KaFai Lau, Joel Becker, Alexander Viro
In-Reply-To: <20200414124304.4470-6-eesposit@redhat.com>
On Tue, Apr 14, 2020 at 02:42:59PM +0200, Emanuele Giuseppe Esposito wrote:
> Start adding file creation wrappers, the simplest returns an anonymous
> inode.
This changelog text does not make much sense on its own. Please say why
you are doing something, not just what you are doing.
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH 2/8] fs: extract simple_pin/release_fs to separate files
From: Greg Kroah-Hartman @ 2020-04-14 12:54 UTC (permalink / raw)
To: Emanuele Giuseppe Esposito
Cc: Song Liu, linux-usb, bpf, Rafael J. Wysocki, David Airlie,
Heiko Carstens, Alexei Starovoitov, dri-devel, J. Bruce Fields,
Joseph Qi, Hugh Dickins, Paul Mackerras, John Johansen, netdev,
ocfs2-devel, Christoph Hellwig, Andrew Donnellan, Matthew Garrett,
linux-efi, Arnd Bergmann, Daniel Borkmann, Christian Borntraeger,
linux-rdma, Mark Fasheh, Anton Vorontsov, John Fastabend,
James Morris, Ard Biesheuvel, Jason Gunthorpe, Doug Ledford,
oprofile-list, Yonghong Song, Ian Kent, Andrii Nakryiko,
Alexey Dobriyan, Serge E. Hallyn, Robert Richter,
Thomas Zimmermann, Vasily Gorbik, Tony Luck, Kees Cook,
James E.J. Bottomley, autofs, Maarten Lankhorst, Mike Marciniszyn,
Maxime Ripard, linux-fsdevel, Manoj N. Kumar, Uma Krishnan,
Jakub Kicinski, KP Singh, Trond Myklebust, Matthew R. Ochs,
David S. Miller, Felipe Balbi, linux-nfs, Iurii Zaikin,
linux-scsi, Martin K. Petersen, linux-mm, linux-s390,
Dennis Dalessandro, Miklos Szeredi, linux-security-module,
linux-kernel, Anna Schumaker, Luis Chamberlain, Chuck Lever,
Jeremy Kerr, Daniel Vetter, Colin Cross, Frederic Barrat,
Paolo Bonzini, Andrew Morton, Mike Kravetz, linuxppc-dev,
Martin KaFai Lau, Joel Becker, Alexander Viro
In-Reply-To: <20200414124304.4470-3-eesposit@redhat.com>
On Tue, Apr 14, 2020 at 02:42:56PM +0200, Emanuele Giuseppe Esposito wrote:
> We will augment this family of functions with inode management. To avoid
> littering include/linux/fs.h and fs/libfs.c, move them to a separate header,
> with a Kconfig symbol to enable them.
>
> Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
You have a lot of people on cc:, this is going to be hard for everyone
to review...
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index d1398cef3b18..fc38a6f0fc11 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -288,12 +288,16 @@ config STRIP_ASM_SYMS
>
> config READABLE_ASM
> bool "Generate readable assembler code"
> - depends on DEBUG_KERNEL
> - help
> - Disable some compiler optimizations that tend to generate human unreadable
> - assembler output. This may make the kernel slightly slower, but it helps
> - to keep kernel developers who have to stare a lot at assembler listings
> - sane.
> + depends on DEBUG_KERNEL
> + help
> + Disable some compiler optimizations that tend to generate human unreadable
> + assembler output. This may make the kernel slightly slower, but it helps
> + to keep kernel developers who have to stare a lot at assembler listings
> + sane.
> +
Why did you loose the indentation here and add trailing whitespace?
> +config DEBUG_FS
> + bool "Debug Filesystem"
> + select SIMPLEFS
>
We already have a DEBUG_FS config option in this file, why another one?
And what happened to the help text?
I think you need to rework your patch series to do smaller things on
each step, which would make it reviewable much easier, and prevent
mistakes like this one.
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH] vhost: do not enable VHOST_MENU by default
From: kbuild test robot @ 2020-04-14 21:15 UTC (permalink / raw)
To: Jason Wang, mst, linux-mips, linux-kernel, linuxppc-dev,
linux-s390, kvm, virtualization, netdev, geert,
Thomas Bogendoerfer, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, Heiko Carstens, Vasily Gorbik,
Christian Borntraeger
Cc: linux-s390, Thomas Bogendoerfer, kbuild-all, kvm, netdev,
linux-mips, linux-kernel, geert, virtualization, linuxppc-dev
In-Reply-To: <20200414024438.19103-1-jasowang@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 13933 bytes --]
Hi Jason,
I love your patch! Yet something to improve:
[auto build test ERROR on vhost/linux-next]
[also build test ERROR on next-20200414]
[cannot apply to powerpc/next s390/features v5.7-rc1]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Jason-Wang/vhost-do-not-enable-VHOST_MENU-by-default/20200414-110807
base: https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next
config: ia64-randconfig-a001-20200415 (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=9.3.0 make.cross ARCH=ia64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>
All error/warnings (new ones prefixed by >>):
drivers/vhost/vhost.c: In function 'vhost_vring_ioctl':
>> drivers/vhost/vhost.c:1577:33: error: implicit declaration of function 'eventfd_fget'; did you mean 'eventfd_signal'? [-Werror=implicit-function-declaration]
1577 | eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
| ^~~~~~~~~~~~
| eventfd_signal
>> drivers/vhost/vhost.c:1577:31: warning: pointer/integer type mismatch in conditional expression
1577 | eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
| ^
cc1: some warnings being treated as errors
vim +1577 drivers/vhost/vhost.c
feebcaeac79ad8 Jason Wang 2019-05-24 1493
feebcaeac79ad8 Jason Wang 2019-05-24 1494 static long vhost_vring_set_num_addr(struct vhost_dev *d,
feebcaeac79ad8 Jason Wang 2019-05-24 1495 struct vhost_virtqueue *vq,
feebcaeac79ad8 Jason Wang 2019-05-24 1496 unsigned int ioctl,
feebcaeac79ad8 Jason Wang 2019-05-24 1497 void __user *argp)
feebcaeac79ad8 Jason Wang 2019-05-24 1498 {
feebcaeac79ad8 Jason Wang 2019-05-24 1499 long r;
feebcaeac79ad8 Jason Wang 2019-05-24 1500
feebcaeac79ad8 Jason Wang 2019-05-24 1501 mutex_lock(&vq->mutex);
feebcaeac79ad8 Jason Wang 2019-05-24 1502
feebcaeac79ad8 Jason Wang 2019-05-24 1503 switch (ioctl) {
feebcaeac79ad8 Jason Wang 2019-05-24 1504 case VHOST_SET_VRING_NUM:
feebcaeac79ad8 Jason Wang 2019-05-24 1505 r = vhost_vring_set_num(d, vq, argp);
feebcaeac79ad8 Jason Wang 2019-05-24 1506 break;
feebcaeac79ad8 Jason Wang 2019-05-24 1507 case VHOST_SET_VRING_ADDR:
feebcaeac79ad8 Jason Wang 2019-05-24 1508 r = vhost_vring_set_addr(d, vq, argp);
feebcaeac79ad8 Jason Wang 2019-05-24 1509 break;
feebcaeac79ad8 Jason Wang 2019-05-24 1510 default:
feebcaeac79ad8 Jason Wang 2019-05-24 1511 BUG();
feebcaeac79ad8 Jason Wang 2019-05-24 1512 }
feebcaeac79ad8 Jason Wang 2019-05-24 1513
feebcaeac79ad8 Jason Wang 2019-05-24 1514 mutex_unlock(&vq->mutex);
feebcaeac79ad8 Jason Wang 2019-05-24 1515
feebcaeac79ad8 Jason Wang 2019-05-24 1516 return r;
feebcaeac79ad8 Jason Wang 2019-05-24 1517 }
26b36604523f4a Sonny Rao 2018-03-14 1518 long vhost_vring_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp)
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1519 {
cecb46f194460d Al Viro 2012-08-27 1520 struct file *eventfp, *filep = NULL;
cecb46f194460d Al Viro 2012-08-27 1521 bool pollstart = false, pollstop = false;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1522 struct eventfd_ctx *ctx = NULL;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1523 u32 __user *idxp = argp;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1524 struct vhost_virtqueue *vq;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1525 struct vhost_vring_state s;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1526 struct vhost_vring_file f;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1527 u32 idx;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1528 long r;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1529
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1530 r = get_user(idx, idxp);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1531 if (r < 0)
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1532 return r;
0f3d9a17469d71 Krishna Kumar 2010-05-25 1533 if (idx >= d->nvqs)
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1534 return -ENOBUFS;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1535
ff002269a4ee9c Jason Wang 2018-10-30 1536 idx = array_index_nospec(idx, d->nvqs);
3ab2e420ec1caf Asias He 2013-04-27 1537 vq = d->vqs[idx];
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1538
feebcaeac79ad8 Jason Wang 2019-05-24 1539 if (ioctl == VHOST_SET_VRING_NUM ||
feebcaeac79ad8 Jason Wang 2019-05-24 1540 ioctl == VHOST_SET_VRING_ADDR) {
feebcaeac79ad8 Jason Wang 2019-05-24 1541 return vhost_vring_set_num_addr(d, vq, ioctl, argp);
feebcaeac79ad8 Jason Wang 2019-05-24 1542 }
feebcaeac79ad8 Jason Wang 2019-05-24 1543
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1544 mutex_lock(&vq->mutex);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1545
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1546 switch (ioctl) {
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1547 case VHOST_SET_VRING_BASE:
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1548 /* Moving base with an active backend?
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1549 * You don't want to do that. */
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1550 if (vq->private_data) {
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1551 r = -EBUSY;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1552 break;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1553 }
7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1554 if (copy_from_user(&s, argp, sizeof s)) {
7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1555 r = -EFAULT;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1556 break;
7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1557 }
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1558 if (s.num > 0xffff) {
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1559 r = -EINVAL;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1560 break;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1561 }
8d65843c44269c Jason Wang 2017-07-27 1562 vq->last_avail_idx = s.num;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1563 /* Forget the cached index value. */
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1564 vq->avail_idx = vq->last_avail_idx;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1565 break;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1566 case VHOST_GET_VRING_BASE:
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1567 s.index = idx;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1568 s.num = vq->last_avail_idx;
7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1569 if (copy_to_user(argp, &s, sizeof s))
7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1570 r = -EFAULT;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1571 break;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1572 case VHOST_SET_VRING_KICK:
7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1573 if (copy_from_user(&f, argp, sizeof f)) {
7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1574 r = -EFAULT;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1575 break;
7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1576 }
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 @1577 eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
535297a6ae4c3b Michael S. Tsirkin 2010-03-17 1578 if (IS_ERR(eventfp)) {
535297a6ae4c3b Michael S. Tsirkin 2010-03-17 1579 r = PTR_ERR(eventfp);
535297a6ae4c3b Michael S. Tsirkin 2010-03-17 1580 break;
535297a6ae4c3b Michael S. Tsirkin 2010-03-17 1581 }
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1582 if (eventfp != vq->kick) {
cecb46f194460d Al Viro 2012-08-27 1583 pollstop = (filep = vq->kick) != NULL;
cecb46f194460d Al Viro 2012-08-27 1584 pollstart = (vq->kick = eventfp) != NULL;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1585 } else
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1586 filep = eventfp;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1587 break;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1588 case VHOST_SET_VRING_CALL:
7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1589 if (copy_from_user(&f, argp, sizeof f)) {
7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1590 r = -EFAULT;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1591 break;
7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1592 }
e050c7d93f4adb Eric Biggers 2018-01-06 1593 ctx = f.fd == -1 ? NULL : eventfd_ctx_fdget(f.fd);
e050c7d93f4adb Eric Biggers 2018-01-06 1594 if (IS_ERR(ctx)) {
e050c7d93f4adb Eric Biggers 2018-01-06 1595 r = PTR_ERR(ctx);
535297a6ae4c3b Michael S. Tsirkin 2010-03-17 1596 break;
535297a6ae4c3b Michael S. Tsirkin 2010-03-17 1597 }
e050c7d93f4adb Eric Biggers 2018-01-06 1598 swap(ctx, vq->call_ctx);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1599 break;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1600 case VHOST_SET_VRING_ERR:
7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1601 if (copy_from_user(&f, argp, sizeof f)) {
7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1602 r = -EFAULT;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1603 break;
7ad9c9d2704854 Takuya Yoshikawa 2010-05-27 1604 }
09f332a589232f Eric Biggers 2018-01-06 1605 ctx = f.fd == -1 ? NULL : eventfd_ctx_fdget(f.fd);
09f332a589232f Eric Biggers 2018-01-06 1606 if (IS_ERR(ctx)) {
09f332a589232f Eric Biggers 2018-01-06 1607 r = PTR_ERR(ctx);
535297a6ae4c3b Michael S. Tsirkin 2010-03-17 1608 break;
535297a6ae4c3b Michael S. Tsirkin 2010-03-17 1609 }
09f332a589232f Eric Biggers 2018-01-06 1610 swap(ctx, vq->error_ctx);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1611 break;
2751c9882b9472 Greg Kurz 2015-04-24 1612 case VHOST_SET_VRING_ENDIAN:
2751c9882b9472 Greg Kurz 2015-04-24 1613 r = vhost_set_vring_endian(vq, argp);
2751c9882b9472 Greg Kurz 2015-04-24 1614 break;
2751c9882b9472 Greg Kurz 2015-04-24 1615 case VHOST_GET_VRING_ENDIAN:
2751c9882b9472 Greg Kurz 2015-04-24 1616 r = vhost_get_vring_endian(vq, idx, argp);
2751c9882b9472 Greg Kurz 2015-04-24 1617 break;
03088137246065 Jason Wang 2016-03-04 1618 case VHOST_SET_VRING_BUSYLOOP_TIMEOUT:
03088137246065 Jason Wang 2016-03-04 1619 if (copy_from_user(&s, argp, sizeof(s))) {
03088137246065 Jason Wang 2016-03-04 1620 r = -EFAULT;
03088137246065 Jason Wang 2016-03-04 1621 break;
03088137246065 Jason Wang 2016-03-04 1622 }
03088137246065 Jason Wang 2016-03-04 1623 vq->busyloop_timeout = s.num;
03088137246065 Jason Wang 2016-03-04 1624 break;
03088137246065 Jason Wang 2016-03-04 1625 case VHOST_GET_VRING_BUSYLOOP_TIMEOUT:
03088137246065 Jason Wang 2016-03-04 1626 s.index = idx;
03088137246065 Jason Wang 2016-03-04 1627 s.num = vq->busyloop_timeout;
03088137246065 Jason Wang 2016-03-04 1628 if (copy_to_user(argp, &s, sizeof(s)))
03088137246065 Jason Wang 2016-03-04 1629 r = -EFAULT;
03088137246065 Jason Wang 2016-03-04 1630 break;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1631 default:
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1632 r = -ENOIOCTLCMD;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1633 }
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1634
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1635 if (pollstop && vq->handle_kick)
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1636 vhost_poll_stop(&vq->poll);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1637
e050c7d93f4adb Eric Biggers 2018-01-06 1638 if (!IS_ERR_OR_NULL(ctx))
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1639 eventfd_ctx_put(ctx);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1640 if (filep)
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1641 fput(filep);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1642
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1643 if (pollstart && vq->handle_kick)
2b8b328b61c799 Jason Wang 2013-01-28 1644 r = vhost_poll_start(&vq->poll, vq->kick);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1645
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1646 mutex_unlock(&vq->mutex);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1647
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1648 if (pollstop && vq->handle_kick)
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1649 vhost_poll_flush(&vq->poll);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1650 return r;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1651 }
6ac1afbf6132df Asias He 2013-05-06 1652 EXPORT_SYMBOL_GPL(vhost_vring_ioctl);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 1653
:::::: The code at line 1577 was first introduced by commit
:::::: 3a4d5c94e959359ece6d6b55045c3f046677f55c vhost_net: a kernel-level virtio server
:::::: TO: Michael S. Tsirkin <mst@redhat.com>
:::::: CC: David S. Miller <davem@davemloft.net>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 27202 bytes --]
^ permalink raw reply
* Re: [PATCH v2 2/2] crypto: Remove unnecessary memzero_explicit()
From: Joe Perches @ 2020-04-14 19:44 UTC (permalink / raw)
To: Waiman Long, Michal Suchánek
Cc: linux-btrfs, Jarkko Sakkinen, virtualization, David Howells,
linux-mm, linux-sctp, keyrings, kasan-dev, samba-technical,
linux-stm32, devel, linux-s390, linux-scsi, x86, James Morris,
Matthew Wilcox, cocci, linux-wpan, intel-wired-lan,
David Rientjes, Serge E. Hallyn, linux-pm, ecryptfs, linux-nfs,
linux-fscrypt, linux-mediatek, linux-amlogic, linux-integrity,
linux-arm-kernel, linux-cifs, Linus Torvalds, linux-wireless,
linux-kernel, linux-bluetooth, linux-security-module,
target-devel, tipc-discussion, linux-crypto, netdev,
Andrew Morton, linuxppc-dev, wireguard, linux-ppp
In-Reply-To: <578fe9b6-1ccd-2698-60aa-96c3f2dd2c31@redhat.com>
On Tue, 2020-04-14 at 15:37 -0400, Waiman Long wrote:
> OK, I can change it to clear the key length when the allocation failed
> which isn't likely.
Perhaps:
kfree_sensitive(op->key);
op->key = NULL;
op->keylen = 0;
but I don't know that it impacts any possible state.
^ permalink raw reply
* Re: [PATCH v2 2/2] crypto: Remove unnecessary memzero_explicit()
From: Waiman Long @ 2020-04-14 19:37 UTC (permalink / raw)
To: Michal Suchánek
Cc: linux-btrfs, Jarkko Sakkinen, virtualization, David Howells,
linux-mm, linux-sctp, keyrings, kasan-dev, samba-technical,
linux-stm32, devel, linux-s390, linux-scsi, x86, James Morris,
Matthew Wilcox, cocci, linux-wpan, intel-wired-lan,
David Rientjes, Serge E. Hallyn, linux-pm, ecryptfs, linux-nfs,
linux-fscrypt, linux-mediatek, linux-amlogic, linux-integrity,
linux-arm-kernel, linux-cifs, Linus Torvalds, linux-wireless,
linux-kernel, linux-bluetooth, linux-security-module,
target-devel, tipc-discussion, linux-crypto, netdev, Joe Perches,
Andrew Morton, linuxppc-dev, wireguard, linux-ppp
In-Reply-To: <20200414191601.GZ25468@kitsune.suse.cz>
On 4/14/20 3:16 PM, Michal Suchánek wrote:
> On Tue, Apr 14, 2020 at 12:24:36PM -0400, Waiman Long wrote:
>> On 4/14/20 2:08 AM, Christophe Leroy wrote:
>>>
>>> Le 14/04/2020 à 00:28, Waiman Long a écrit :
>>>> Since kfree_sensitive() will do an implicit memzero_explicit(), there
>>>> is no need to call memzero_explicit() before it. Eliminate those
>>>> memzero_explicit() and simplify the call sites. For better correctness,
>>>> the setting of keylen is also moved down after the key pointer check.
>>>>
>>>> Signed-off-by: Waiman Long <longman@redhat.com>
>>>> ---
>>>> .../allwinner/sun8i-ce/sun8i-ce-cipher.c | 19 +++++-------------
>>>> .../allwinner/sun8i-ss/sun8i-ss-cipher.c | 20 +++++--------------
>>>> drivers/crypto/amlogic/amlogic-gxl-cipher.c | 12 +++--------
>>>> drivers/crypto/inside-secure/safexcel_hash.c | 3 +--
>>>> 4 files changed, 14 insertions(+), 40 deletions(-)
>>>>
>>>> diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c
>>>> b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c
>>>> index aa4e8fdc2b32..8358fac98719 100644
>>>> --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c
>>>> +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c
>>>> @@ -366,10 +366,7 @@ void sun8i_ce_cipher_exit(struct crypto_tfm *tfm)
>>>> {
>>>> struct sun8i_cipher_tfm_ctx *op = crypto_tfm_ctx(tfm);
>>>> - if (op->key) {
>>>> - memzero_explicit(op->key, op->keylen);
>>>> - kfree(op->key);
>>>> - }
>>>> + kfree_sensitive(op->key);
>>>> crypto_free_sync_skcipher(op->fallback_tfm);
>>>> pm_runtime_put_sync_suspend(op->ce->dev);
>>>> }
>>>> @@ -391,14 +388,11 @@ int sun8i_ce_aes_setkey(struct crypto_skcipher
>>>> *tfm, const u8 *key,
>>>> dev_dbg(ce->dev, "ERROR: Invalid keylen %u\n", keylen);
>>>> return -EINVAL;
>>>> }
>>>> - if (op->key) {
>>>> - memzero_explicit(op->key, op->keylen);
>>>> - kfree(op->key);
>>>> - }
>>>> - op->keylen = keylen;
>>>> + kfree_sensitive(op->key);
>>>> op->key = kmemdup(key, keylen, GFP_KERNEL | GFP_DMA);
>>>> if (!op->key)
>>>> return -ENOMEM;
>>>> + op->keylen = keylen;
>>> Does it matter at all to ensure op->keylen is not set when of->key is
>>> NULL ? I'm not sure.
>>>
>>> But if it does, then op->keylen should be set to 0 when freeing op->key.
>> My thinking is that if memory allocation fails, we just don't touch
>> anything and return an error code. I will not explicitly set keylen to 0
>> in this case unless it is specified in the API documentation.
> You already freed the key by now so not touching anything is not
> possible. The key is set to NULL on allocation failure so setting keylen
> to 0 should be redundant. However, setting keylen to 0 is consisent with
> not having a key, and it avoids the possibility of leaking the length
> later should that ever cause any problem.
OK, I can change it to clear the key length when the allocation failed
which isn't likely.
Cheers,
Longman
^ permalink raw reply
* Re: [PATCH v2 2/2] crypto: Remove unnecessary memzero_explicit()
From: Michal Suchánek @ 2020-04-14 19:16 UTC (permalink / raw)
To: Waiman Long
Cc: linux-btrfs, Jarkko Sakkinen, virtualization, David Howells,
linux-mm, linux-sctp, keyrings, kasan-dev, samba-technical,
linux-stm32, devel, linux-s390, linux-scsi, x86, James Morris,
Matthew Wilcox, cocci, linux-wpan, intel-wired-lan,
David Rientjes, Serge E. Hallyn, linux-pm, ecryptfs, linux-nfs,
linux-fscrypt, linux-mediatek, linux-amlogic, linux-integrity,
linux-arm-kernel, linux-cifs, Linus Torvalds, linux-wireless,
linux-kernel, linux-bluetooth, linux-security-module,
target-devel, tipc-discussion, linux-crypto, netdev, Joe Perches,
Andrew Morton, linuxppc-dev, wireguard, linux-ppp
In-Reply-To: <e194a51f-a5e5-a557-c008-b08cac558572@redhat.com>
On Tue, Apr 14, 2020 at 12:24:36PM -0400, Waiman Long wrote:
> On 4/14/20 2:08 AM, Christophe Leroy wrote:
> >
> >
> > Le 14/04/2020 à 00:28, Waiman Long a écrit :
> >> Since kfree_sensitive() will do an implicit memzero_explicit(), there
> >> is no need to call memzero_explicit() before it. Eliminate those
> >> memzero_explicit() and simplify the call sites. For better correctness,
> >> the setting of keylen is also moved down after the key pointer check.
> >>
> >> Signed-off-by: Waiman Long <longman@redhat.com>
> >> ---
> >> .../allwinner/sun8i-ce/sun8i-ce-cipher.c | 19 +++++-------------
> >> .../allwinner/sun8i-ss/sun8i-ss-cipher.c | 20 +++++--------------
> >> drivers/crypto/amlogic/amlogic-gxl-cipher.c | 12 +++--------
> >> drivers/crypto/inside-secure/safexcel_hash.c | 3 +--
> >> 4 files changed, 14 insertions(+), 40 deletions(-)
> >>
> >> diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c
> >> b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c
> >> index aa4e8fdc2b32..8358fac98719 100644
> >> --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c
> >> +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c
> >> @@ -366,10 +366,7 @@ void sun8i_ce_cipher_exit(struct crypto_tfm *tfm)
> >> {
> >> struct sun8i_cipher_tfm_ctx *op = crypto_tfm_ctx(tfm);
> >> - if (op->key) {
> >> - memzero_explicit(op->key, op->keylen);
> >> - kfree(op->key);
> >> - }
> >> + kfree_sensitive(op->key);
> >> crypto_free_sync_skcipher(op->fallback_tfm);
> >> pm_runtime_put_sync_suspend(op->ce->dev);
> >> }
> >> @@ -391,14 +388,11 @@ int sun8i_ce_aes_setkey(struct crypto_skcipher
> >> *tfm, const u8 *key,
> >> dev_dbg(ce->dev, "ERROR: Invalid keylen %u\n", keylen);
> >> return -EINVAL;
> >> }
> >> - if (op->key) {
> >> - memzero_explicit(op->key, op->keylen);
> >> - kfree(op->key);
> >> - }
> >> - op->keylen = keylen;
> >> + kfree_sensitive(op->key);
> >> op->key = kmemdup(key, keylen, GFP_KERNEL | GFP_DMA);
> >> if (!op->key)
> >> return -ENOMEM;
> >> + op->keylen = keylen;
> >
> > Does it matter at all to ensure op->keylen is not set when of->key is
> > NULL ? I'm not sure.
> >
> > But if it does, then op->keylen should be set to 0 when freeing op->key.
>
> My thinking is that if memory allocation fails, we just don't touch
> anything and return an error code. I will not explicitly set keylen to 0
> in this case unless it is specified in the API documentation.
You already freed the key by now so not touching anything is not
possible. The key is set to NULL on allocation failure so setting keylen
to 0 should be redundant. However, setting keylen to 0 is consisent with
not having a key, and it avoids the possibility of leaking the length
later should that ever cause any problem.
Thanks
Michal
^ permalink raw reply
* [PATCH v2] Fix: buffer overflow during hvc_alloc().
From: andrew @ 2020-04-14 19:15 UTC (permalink / raw)
To: virtualization; +Cc: gregkh, linuxppc-dev, linux-kernel, jslaby
From: Andrew Melnychenko <andrew@daynix.com>
If there is a lot(more then 16) of virtio-console devices
or virtio_console module is reloaded
- buffers 'vtermnos' and 'cons_ops' are overflowed.
In older kernels it overruns spinlock which leads to kernel freezing:
https://bugzilla.redhat.com/show_bug.cgi?id=1786239
To reproduce the issue, you can try simple script that
loads/unloads module. Something like this:
while [ 1 ]
do
modprobe virtio_console
sleep 2
modprobe -r virtio_console
sleep 2
done
Description of problem:
Guest get 'Call Trace' when loading module "virtio_console"
and unloading it frequently - clearly reproduced on kernel-4.18.0:
[ 81.498208] ------------[ cut here ]------------
[ 81.499263] pvqspinlock: lock 0xffffffff92080020 has corrupted value 0xc0774ca0!
[ 81.501000] WARNING: CPU: 0 PID: 785 at kernel/locking/qspinlock_paravirt.h:500 __pv_queued_spin_unlock_slowpath+0xc0/0xd0
[ 81.503173] Modules linked in: virtio_console fuse xt_CHECKSUM ipt_MASQUERADE xt_conntrack ipt_REJECT nft_counter nf_nat_tftp nft_objref nf_conntrack_tftp tun bridge stp llc nft_fib_inet nft_fib_ipv4 nft_fib_ipv6 nft_fib nft_reject_inet nf_reject_ipv4 nf_reject_ipv6 nft_reject nft_ct nf_tables_set nft_chain_nat_ipv6 nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 nft_chain_route_ipv6 nft_chain_nat_ipv4 nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack nft_chain_route_ipv4 ip6_tables nft_compat ip_set nf_tables nfnetlink sunrpc bochs_drm drm_vram_helper ttm drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops drm i2c_piix4 pcspkr crct10dif_pclmul crc32_pclmul joydev ghash_clmulni_intel ip_tables xfs libcrc32c sd_mod sg ata_generic ata_piix virtio_net libata crc32c_intel net_failover failover serio_raw virtio_scsi dm_mirror dm_region_hash dm_log dm_mod [last unloaded: virtio_console]
[ 81.517019] CPU: 0 PID: 785 Comm: kworker/0:2 Kdump: loaded Not tainted 4.18.0-167.el8.x86_64 #1
[ 81.518639] Hardware name: Red Hat KVM, BIOS 1.12.0-5.scrmod+el8.2.0+5159+d8aa4d83 04/01/2014
[ 81.520205] Workqueue: events control_work_handler [virtio_console]
[ 81.521354] RIP: 0010:__pv_queued_spin_unlock_slowpath+0xc0/0xd0
[ 81.522450] Code: 07 00 48 63 7a 10 e8 bf 64 f5 ff 66 90 c3 8b 05 e6 cf d6 01 85 c0 74 01 c3 8b 17 48 89 fe 48 c7 c7 38 4b 29 91 e8 3a 6c fa ff <0f> 0b c3 0f 0b 90 90 90 90 90 90 90 90 90 90 90 0f 1f 44 00 00 48
[ 81.525830] RSP: 0018:ffffb51a01ffbd70 EFLAGS: 00010282
[ 81.526798] RAX: 0000000000000000 RBX: 0000000000000010 RCX: 0000000000000000
[ 81.528110] RDX: ffff9e66f1826480 RSI: ffff9e66f1816a08 RDI: ffff9e66f1816a08
[ 81.529437] RBP: ffffffff9153ff10 R08: 000000000000026c R09: 0000000000000053
[ 81.530732] R10: 0000000000000000 R11: ffffb51a01ffbc18 R12: ffff9e66cd682200
[ 81.532133] R13: ffffffff9153ff10 R14: ffff9e6685569500 R15: ffff9e66cd682000
[ 81.533442] FS: 0000000000000000(0000) GS:ffff9e66f1800000(0000) knlGS:0000000000000000
[ 81.534914] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 81.535971] CR2: 00005624c55b14d0 CR3: 00000003a023c000 CR4: 00000000003406f0
[ 81.537283] Call Trace:
[ 81.537763] __raw_callee_save___pv_queued_spin_unlock_slowpath+0x11/0x20
[ 81.539011] .slowpath+0x9/0xe
[ 81.539585] hvc_alloc+0x25e/0x300
[ 81.540237] init_port_console+0x28/0x100 [virtio_console]
[ 81.541251] handle_control_message.constprop.27+0x1c4/0x310 [virtio_console]
[ 81.542546] control_work_handler+0x70/0x10c [virtio_console]
[ 81.543601] process_one_work+0x1a7/0x3b0
[ 81.544356] worker_thread+0x30/0x390
[ 81.545025] ? create_worker+0x1a0/0x1a0
[ 81.545749] kthread+0x112/0x130
[ 81.546358] ? kthread_flush_work_fn+0x10/0x10
[ 81.547183] ret_from_fork+0x22/0x40
[ 81.547842] ---[ end trace aa97649bd16c8655 ]---
[ 83.546539] general protection fault: 0000 [#1] SMP NOPTI
[ 83.547422] CPU: 5 PID: 3225 Comm: modprobe Kdump: loaded Tainted: G W --------- - - 4.18.0-167.el8.x86_64 #1
[ 83.549191] Hardware name: Red Hat KVM, BIOS 1.12.0-5.scrmod+el8.2.0+5159+d8aa4d83 04/01/2014
[ 83.550544] RIP: 0010:__pv_queued_spin_lock_slowpath+0x19a/0x2a0
[ 83.551504] Code: c4 c1 ea 12 41 be 01 00 00 00 4c 8d 6d 14 41 83 e4 03 8d 42 ff 49 c1 e4 05 48 98 49 81 c4 40 a5 02 00 4c 03 24 c5 60 48 34 91 <49> 89 2c 24 b8 00 80 00 00 eb 15 84 c0 75 0a 41 0f b6 54 24 14 84
[ 83.554449] RSP: 0018:ffffb51a0323fdb0 EFLAGS: 00010202
[ 83.555290] RAX: 000000000000301c RBX: ffffffff92080020 RCX: 0000000000000001
[ 83.556426] RDX: 000000000000301d RSI: 0000000000000000 RDI: 0000000000000000
[ 83.557556] RBP: ffff9e66f196a540 R08: 000000000000028a R09: ffff9e66d2757788
[ 83.558688] R10: 0000000000000000 R11: 0000000000000000 R12: 646e61725f770b07
[ 83.559821] R13: ffff9e66f196a554 R14: 0000000000000001 R15: 0000000000180000
[ 83.560958] FS: 00007fd5032e8740(0000) GS:ffff9e66f1940000(0000) knlGS:0000000000000000
[ 83.562233] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 83.563149] CR2: 00007fd5022b0da0 CR3: 000000038c334000 CR4: 00000000003406e0
Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
---
drivers/tty/hvc/hvc_console.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index 27284a2dcd2b..436cc51c92c3 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -302,10 +302,6 @@ int hvc_instantiate(uint32_t vtermno, int index, const struct hv_ops *ops)
vtermnos[index] = vtermno;
cons_ops[index] = ops;
- /* reserve all indices up to and including this index */
- if (last_hvc < index)
- last_hvc = index;
-
/* check if we need to re-register the kernel console */
hvc_check_console(index);
@@ -960,13 +956,22 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data,
cons_ops[i] == hp->ops)
break;
- /* no matching slot, just use a counter */
- if (i >= MAX_NR_HVC_CONSOLES)
- i = ++last_hvc;
+ if (i >= MAX_NR_HVC_CONSOLES) {
+
+ /* find 'empty' slot for console */
+ for (i = 0; i < MAX_NR_HVC_CONSOLES && vtermnos[i] != -1; i++) {
+ }
+
+ /* no matching slot, just use a counter */
+ if (i == MAX_NR_HVC_CONSOLES)
+ i = ++last_hvc + MAX_NR_HVC_CONSOLES;
+ }
hp->index = i;
- cons_ops[i] = ops;
- vtermnos[i] = vtermno;
+ if (i < MAX_NR_HVC_CONSOLES) {
+ cons_ops[i] = ops;
+ vtermnos[i] = vtermno;
+ }
list_add_tail(&(hp->next), &hvc_structs);
mutex_unlock(&hvc_structs_mutex);
--
2.24.1
^ permalink raw reply related
* Re: [PATCH 1/2] mm, treewide: Rename kzfree() to kfree_sensitive()
From: Waiman Long @ 2020-04-14 18:26 UTC (permalink / raw)
To: dsterba, Andrew Morton, David Howells, Jarkko Sakkinen,
James Morris, Serge E. Hallyn, Linus Torvalds, Joe Perches,
Matthew Wilcox, David Rientjes, linux-mm, keyrings, linux-kernel,
x86, linux-crypto, linux-s390, linux-pm, linux-stm32,
linux-arm-kernel, linux-amlogic, linux-mediatek, linuxppc-dev,
virtualization, netdev, intel-wired-lan, linux-ppp, wireguard,
linux-wireless, devel, linux-scsi, target-devel, linux-btrfs,
linux-cifs, samba-technical, linux-fscrypt, ecryptfs, kasan-dev,
linux-bluetooth, linux-wpan, linux-sctp, linux-nfs,
tipc-discussion, cocci, linux-security-module, linux-integrity
In-Reply-To: <20200414124854.GQ5920@twin.jikos.cz>
On 4/14/20 8:48 AM, David Sterba wrote:
> On Mon, Apr 13, 2020 at 05:15:49PM -0400, Waiman Long wrote:
>> fs/btrfs/ioctl.c | 2 +-
>
>> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
>> index 40b729dce91c..eab3f8510426 100644
>> --- a/fs/btrfs/ioctl.c
>> +++ b/fs/btrfs/ioctl.c
>> @@ -2691,7 +2691,7 @@ static int btrfs_ioctl_get_subvol_info(struct file *file, void __user *argp)
>> btrfs_put_root(root);
>> out_free:
>> btrfs_free_path(path);
>> - kzfree(subvol_info);
>> + kfree_sensitive(subvol_info);
> This is not in a sensitive context so please switch it to plain kfree.
> With that you have my acked-by. Thanks.
>
Thanks for letting me know about. I think I will send it out as a
separate patch.
Cheers,
Longman
^ permalink raw reply
* Re: -Wincompatible-pointer-types in arch/powerpc/platforms/embedded6xx/mvme5100.c
From: Scott Wood @ 2020-04-14 17:04 UTC (permalink / raw)
To: Michael Ellerman, Nathan Chancellor, linuxppc-dev,
clang-built-linux
In-Reply-To: <87eesqjzc6.fsf@mpe.ellerman.id.au>
On Tue, 2020-04-14 at 17:33 +1000, Michael Ellerman wrote:
> I'm not sure TBH. This is all ancient history as far as I can tell, none
> of it's been touched for ~7 years.
>
> Your config has:
>
> CONFIG_EMBEDDED6xx=y
> CONFIG_PPC_BOOK3S_32=y
> CONFIG_PPC_BOOK3S_6xx=y
> CONFIG_PPC_MPC52xx=y
> CONFIG_PPC_86xx=y
>
>
> Which I'm not sure really makes sense at all, ie. it's trying to build a
> kernel for multiple platforms at once (EMBEDDED6xx, MPC52xx, 86xx), but
> the Kconfig doesn't exclude that so I guess we have to live with it for
> now.
I thought supporting multiple platforms in a kernel was something we tried to
support when practical?
> So I'm going to guess it should have also excluded embedded6xx, and this
> seems to fix it:
>
> diff --git a/arch/powerpc/platforms/Kconfig.cputype
> b/arch/powerpc/platforms/Kconfig.cputype
> index 0c3c1902135c..134fc383daf7 100644
> --- a/arch/powerpc/platforms/Kconfig.cputype
> +++ b/arch/powerpc/platforms/Kconfig.cputype
> @@ -278,7 +278,7 @@ config PTE_64BIT
>
> config PHYS_64BIT
> bool 'Large physical address support' if E500 || PPC_86xx
> - depends on (44x || E500 || PPC_86xx) && !PPC_83xx && !PPC_82xx
> + depends on (44x || E500 || PPC_86xx) && !PPC_83xx && !PPC_82xx &&
> !EMBEDDED6xx
> select PHYS_ADDR_T_64BIT
> ---help---
> This option enables kernel support for larger than 32-bit physical
>
>
> So unless anyone can tell me otherwise I'm inclined to commit that ^
This could silently break someone's config who's depending on PHYS_64BIT (e.g.
an 86xx kernel that happens to include an embedded6xx target as well, even if
just by accident). It'd be better to have the MVME500 depend on
!CONFIG_PHYS_ADDR_T_64BIT as Nathan suggested (if there's nobody around to
test a fix to the actual bug), which shouldn't break anyone since it already
didn't build.
-Scott
^ 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