* Re: [PATCH V2 4/5] ocxl: Add mmu notifier
From: Christophe Lombard @ 2020-11-24 16:48 UTC (permalink / raw)
To: Jason Gunthorpe, Christoph Hellwig; +Cc: linuxppc-dev, ajd, fbarrat
In-Reply-To: <20201124134525.GB4800@nvidia.com>
[-- Attachment #1: Type: text/plain, Size: 2485 bytes --]
Le 24/11/2020 à 14:45, Jason Gunthorpe a écrit :
> On Tue, Nov 24, 2020 at 09:17:38AM +0000, Christoph Hellwig wrote:
>
>>> @@ -470,6 +487,26 @@ void ocxl_link_release(struct pci_dev *dev, void *link_handle)
>>> }
>>> EXPORT_SYMBOL_GPL(ocxl_link_release);
>>>
>>> +static void invalidate_range(struct mmu_notifier *mn,
>>> + struct mm_struct *mm,
>>> + unsigned long start, unsigned long end)
>>> +{
>>> + struct pe_data *pe_data = container_of(mn, struct pe_data, mmu_notifier);
>>> + struct ocxl_link *link = pe_data->link;
>>> + unsigned long addr, pid, page_size = PAGE_SIZE;
> The page_size variable seems unnecessary
>
>>> +
>>> + pid = mm->context.id;
>>> +
>>> + spin_lock(&link->atsd_lock);
>>> + for (addr = start; addr < end; addr += page_size)
>>> + pnv_ocxl_tlb_invalidate(&link->arva, pid, addr);
>>> + spin_unlock(&link->atsd_lock);
>>> +}
>>> +
>>> +static const struct mmu_notifier_ops ocxl_mmu_notifier_ops = {
>>> + .invalidate_range = invalidate_range,
>>> +};
>>> +
>>> static u64 calculate_cfg_state(bool kernel)
>>> {
>>> u64 state;
>>> @@ -526,6 +563,8 @@ int ocxl_link_add_pe(void *link_handle, int pasid, u32 pidr, u32 tidr,
>>> pe_data->mm = mm;
>>> pe_data->xsl_err_cb = xsl_err_cb;
>>> pe_data->xsl_err_data = xsl_err_data;
>>> + pe_data->link = link;
>>> + pe_data->mmu_notifier.ops = &ocxl_mmu_notifier_ops;
>>>
>>> memset(pe, 0, sizeof(struct ocxl_process_element));
>>> pe->config_state = cpu_to_be64(calculate_cfg_state(pidr == 0));
>>> @@ -542,8 +581,16 @@ int ocxl_link_add_pe(void *link_handle, int pasid, u32 pidr, u32 tidr,
>>> * by the nest MMU. If we have a kernel context, TLBIs are
>>> * already global.
>>> */
>>> - if (mm)
>>> + if (mm) {
>>> mm_context_add_copro(mm);
>>> + if (link->arva) {
>>> + /* Use MMIO registers for the TLB Invalidate
>>> + * operations.
>>> + */
>>> + mmu_notifier_register(&pe_data->mmu_notifier, mm);
> Every other place doing stuff like this is de-duplicating the
> notifier. If you have multiple clients this will do multiple redundant
> invalidations?
We could have multiple clients, although not something that we have often.
We have only one attach per process. But if not, we must still have
invalidation for each.
>
> The notifier get/put API is designed to solve that problem, you'd get
> a single notifier for the mm and then add the impacted arva's to some
> list at the notifier.
Thanks for the information.
>
> Jason
[-- Attachment #2: Type: text/html, Size: 3655 bytes --]
^ permalink raw reply
* Re: [PATCH 0/2] powerpc/pseries: fix MSI/X IRQ affinity on pseries
From: Michael S. Tsirkin @ 2020-11-24 21:08 UTC (permalink / raw)
To: Laurent Vivier
Cc: Marc Zyngier, linux-pci, linux-kernel, linux-block,
Paul Mackerras, Thomas Gleixner, linuxppc-dev, Christoph Hellwig
In-Reply-To: <20201124200308.1110744-1-lvivier@redhat.com>
On Tue, Nov 24, 2020 at 09:03:06PM +0100, Laurent Vivier wrote:
> With virtio, in multiqueue case, each queue IRQ is normally
> bound to a different CPU using the affinity mask.
>
> This works fine on x86_64 but totally ignored on pseries.
>
> This is not obvious at first look because irqbalance is doing
> some balancing to improve that.
>
> It appears that the "managed" flag set in the MSI entry
> is never copied to the system IRQ entry.
>
> This series passes the affinity mask from rtas_setup_msi_irqs()
> to irq_domain_alloc_descs() by adding an affinity parameter to
> irq_create_mapping().
>
> The first patch adds the parameter (no functional change), the
> second patch passes the actual affinity mask to irq_create_mapping()
> in rtas_setup_msi_irqs().
>
> For instance, with 32 CPUs VM and 32 queues virtio-scsi interface:
>
> ... -smp 32 -device virtio-scsi-pci,id=virtio_scsi_pci0,num_queues=32
>
> for IRQ in $(grep virtio2-request /proc/interrupts |cut -d: -f1); do
> for file in /proc/irq/$IRQ/ ; do
> echo -n "IRQ: $(basename $file) CPU: " ; cat $file/smp_affinity_list
> done
> done
>
> Without the patch (and without irqbalanced)
>
> IRQ: 268 CPU: 0-31
> IRQ: 269 CPU: 0-31
> IRQ: 270 CPU: 0-31
> IRQ: 271 CPU: 0-31
> IRQ: 272 CPU: 0-31
> IRQ: 273 CPU: 0-31
> IRQ: 274 CPU: 0-31
> IRQ: 275 CPU: 0-31
> IRQ: 276 CPU: 0-31
> IRQ: 277 CPU: 0-31
> IRQ: 278 CPU: 0-31
> IRQ: 279 CPU: 0-31
> IRQ: 280 CPU: 0-31
> IRQ: 281 CPU: 0-31
> IRQ: 282 CPU: 0-31
> IRQ: 283 CPU: 0-31
> IRQ: 284 CPU: 0-31
> IRQ: 285 CPU: 0-31
> IRQ: 286 CPU: 0-31
> IRQ: 287 CPU: 0-31
> IRQ: 288 CPU: 0-31
> IRQ: 289 CPU: 0-31
> IRQ: 290 CPU: 0-31
> IRQ: 291 CPU: 0-31
> IRQ: 292 CPU: 0-31
> IRQ: 293 CPU: 0-31
> IRQ: 294 CPU: 0-31
> IRQ: 295 CPU: 0-31
> IRQ: 296 CPU: 0-31
> IRQ: 297 CPU: 0-31
> IRQ: 298 CPU: 0-31
> IRQ: 299 CPU: 0-31
>
> With the patch:
>
> IRQ: 265 CPU: 0
> IRQ: 266 CPU: 1
> IRQ: 267 CPU: 2
> IRQ: 268 CPU: 3
> IRQ: 269 CPU: 4
> IRQ: 270 CPU: 5
> IRQ: 271 CPU: 6
> IRQ: 272 CPU: 7
> IRQ: 273 CPU: 8
> IRQ: 274 CPU: 9
> IRQ: 275 CPU: 10
> IRQ: 276 CPU: 11
> IRQ: 277 CPU: 12
> IRQ: 278 CPU: 13
> IRQ: 279 CPU: 14
> IRQ: 280 CPU: 15
> IRQ: 281 CPU: 16
> IRQ: 282 CPU: 17
> IRQ: 283 CPU: 18
> IRQ: 284 CPU: 19
> IRQ: 285 CPU: 20
> IRQ: 286 CPU: 21
> IRQ: 287 CPU: 22
> IRQ: 288 CPU: 23
> IRQ: 289 CPU: 24
> IRQ: 290 CPU: 25
> IRQ: 291 CPU: 26
> IRQ: 292 CPU: 27
> IRQ: 293 CPU: 28
> IRQ: 294 CPU: 29
> IRQ: 295 CPU: 30
> IRQ: 299 CPU: 31
>
> This matches what we have on an x86_64 system.
Makes sense to me. FWIW
Acked-by: Michael S. Tsirkin <mst@redhat.com>
> Laurent Vivier (2):
> genirq: add an affinity parameter to irq_create_mapping()
> powerpc/pseries: pass MSI affinity to irq_create_mapping()
>
> arch/arc/kernel/intc-arcv2.c | 4 ++--
> arch/arc/kernel/mcip.c | 2 +-
> arch/arm/common/sa1111.c | 2 +-
> arch/arm/mach-s3c/irq-s3c24xx.c | 3 ++-
> arch/arm/plat-orion/gpio.c | 2 +-
> arch/mips/ath25/ar2315.c | 4 ++--
> arch/mips/ath25/ar5312.c | 4 ++--
> arch/mips/lantiq/irq.c | 2 +-
> arch/mips/pci/pci-ar2315.c | 3 ++-
> arch/mips/pic32/pic32mzda/time.c | 2 +-
> arch/mips/ralink/irq.c | 2 +-
> arch/powerpc/kernel/pci-common.c | 2 +-
> arch/powerpc/kvm/book3s_xive.c | 2 +-
> arch/powerpc/platforms/44x/ppc476.c | 4 ++--
> arch/powerpc/platforms/cell/interrupt.c | 4 ++--
> arch/powerpc/platforms/cell/iommu.c | 3 ++-
> arch/powerpc/platforms/cell/pmu.c | 2 +-
> arch/powerpc/platforms/cell/spider-pic.c | 2 +-
> arch/powerpc/platforms/cell/spu_manage.c | 6 +++---
> arch/powerpc/platforms/maple/pci.c | 2 +-
> arch/powerpc/platforms/pasemi/dma_lib.c | 5 +++--
> arch/powerpc/platforms/pasemi/msi.c | 2 +-
> arch/powerpc/platforms/pasemi/setup.c | 4 ++--
> arch/powerpc/platforms/powermac/pci.c | 2 +-
> arch/powerpc/platforms/powermac/pic.c | 2 +-
> arch/powerpc/platforms/powermac/smp.c | 2 +-
> arch/powerpc/platforms/powernv/opal-irqchip.c | 5 +++--
> arch/powerpc/platforms/powernv/pci.c | 2 +-
> arch/powerpc/platforms/powernv/vas.c | 2 +-
> arch/powerpc/platforms/ps3/interrupt.c | 2 +-
> arch/powerpc/platforms/pseries/ibmebus.c | 2 +-
> arch/powerpc/platforms/pseries/msi.c | 2 +-
> arch/powerpc/sysdev/fsl_mpic_err.c | 2 +-
> arch/powerpc/sysdev/fsl_msi.c | 2 +-
> arch/powerpc/sysdev/mpic.c | 3 ++-
> arch/powerpc/sysdev/mpic_u3msi.c | 2 +-
> arch/powerpc/sysdev/xics/xics-common.c | 2 +-
> arch/powerpc/sysdev/xive/common.c | 2 +-
> arch/sh/boards/mach-se/7343/irq.c | 2 +-
> arch/sh/boards/mach-se/7722/irq.c | 2 +-
> arch/sh/boards/mach-x3proto/gpio.c | 2 +-
> arch/xtensa/kernel/perf_event.c | 2 +-
> arch/xtensa/kernel/smp.c | 2 +-
> arch/xtensa/kernel/time.c | 2 +-
> drivers/ata/pata_macio.c | 2 +-
> drivers/base/regmap/regmap-irq.c | 2 +-
> drivers/bus/moxtet.c | 2 +-
> drivers/clocksource/ingenic-timer.c | 2 +-
> drivers/clocksource/timer-riscv.c | 2 +-
> drivers/extcon/extcon-max8997.c | 3 ++-
> drivers/gpio/gpio-bcm-kona.c | 2 +-
> drivers/gpio/gpio-brcmstb.c | 2 +-
> drivers/gpio/gpio-davinci.c | 2 +-
> drivers/gpio/gpio-em.c | 3 ++-
> drivers/gpio/gpio-grgpio.c | 2 +-
> drivers/gpio/gpio-mockup.c | 2 +-
> drivers/gpio/gpio-mpc8xxx.c | 2 +-
> drivers/gpio/gpio-mvebu.c | 2 +-
> drivers/gpio/gpio-tb10x.c | 2 +-
> drivers/gpio/gpio-tegra.c | 2 +-
> drivers/gpio/gpio-wm831x.c | 2 +-
> drivers/gpio/gpiolib.c | 2 +-
> drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 3 ++-
> drivers/gpu/ipu-v3/ipu-common.c | 2 +-
> drivers/hid/hid-rmi.c | 2 +-
> drivers/i2c/busses/i2c-cht-wc.c | 2 +-
> drivers/i2c/i2c-core-base.c | 2 +-
> drivers/i2c/muxes/i2c-mux-pca954x.c | 2 +-
> drivers/ide/pmac.c | 2 +-
> drivers/iio/dummy/iio_dummy_evgen.c | 3 ++-
> drivers/input/rmi4/rmi_bus.c | 2 +-
> drivers/irqchip/irq-ath79-misc.c | 3 ++-
> drivers/irqchip/irq-bcm2835.c | 3 ++-
> drivers/irqchip/irq-csky-mpintc.c | 2 +-
> drivers/irqchip/irq-eznps.c | 2 +-
> drivers/irqchip/irq-mips-gic.c | 8 +++++---
> drivers/irqchip/irq-mmp.c | 4 ++--
> drivers/irqchip/irq-versatile-fpga.c | 2 +-
> drivers/irqchip/irq-vic.c | 2 +-
> drivers/macintosh/macio_asic.c | 2 +-
> drivers/memory/omap-gpmc.c | 2 +-
> drivers/mfd/ab8500-core.c | 2 +-
> drivers/mfd/arizona-irq.c | 5 +++--
> drivers/mfd/db8500-prcmu.c | 2 +-
> drivers/mfd/mfd-core.c | 2 +-
> drivers/mfd/stmpe.c | 5 +++--
> drivers/mfd/tc3589x.c | 2 +-
> drivers/mfd/tps6586x.c | 2 +-
> drivers/mfd/wm8994-irq.c | 5 +++--
> drivers/misc/cxl/irq.c | 2 +-
> drivers/misc/ocxl/afu_irq.c | 2 +-
> drivers/misc/ocxl/link.c | 2 +-
> drivers/net/dsa/mv88e6xxx/chip.c | 2 +-
> drivers/net/dsa/mv88e6xxx/global2.c | 2 +-
> drivers/net/dsa/qca/ar9331.c | 2 +-
> drivers/net/dsa/rtl8366rb.c | 3 ++-
> drivers/net/ethernet/ibm/ibmvnic.c | 4 ++--
> drivers/net/usb/lan78xx.c | 2 +-
> drivers/pci/controller/pci-ftpci100.c | 2 +-
> drivers/pci/controller/pci-tegra.c | 2 +-
> drivers/pci/controller/pcie-rcar-host.c | 2 +-
> drivers/pci/controller/pcie-xilinx-cpm.c | 4 ++--
> drivers/pci/controller/pcie-xilinx.c | 2 +-
> drivers/pinctrl/mediatek/mtk-eint.c | 2 +-
> drivers/pinctrl/nomadik/pinctrl-abx500.c | 3 ++-
> drivers/pinctrl/pinctrl-at91-pio4.c | 3 ++-
> drivers/pinctrl/pinctrl-rockchip.c | 2 +-
> drivers/pinctrl/samsung/pinctrl-samsung.c | 2 +-
> drivers/pinctrl/sunxi/pinctrl-sunxi.c | 2 +-
> drivers/power/supply/lp8788-charger.c | 2 +-
> drivers/rtc/rtc-lp8788.c | 2 +-
> drivers/rtc/rtc-max8997.c | 3 ++-
> drivers/rtc/rtc-max8998.c | 3 ++-
> drivers/scsi/cxlflash/ocxl_hw.c | 2 +-
> drivers/ssb/driver_gpio.c | 4 ++--
> drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 2 +-
> drivers/staging/octeon-usb/octeon-hcd.c | 2 +-
> drivers/tty/hvc/hvsi.c | 2 +-
> drivers/tty/serial/pmac_zilog.c | 6 +++---
> drivers/watchdog/octeon-wdt-main.c | 2 +-
> include/linux/irqdomain.h | 3 ++-
> kernel/irq/irqdomain.c | 8 +++++---
> sound/soc/codecs/rt5677.c | 2 +-
> 123 files changed, 171 insertions(+), 146 deletions(-)
>
> --
> 2.28.0
>
^ permalink raw reply
* Re: [PATCH] net/ethernet/freescale: Fix incorrect IS_ERR_VALUE macro usages
From: Li Yang @ 2020-11-24 21:44 UTC (permalink / raw)
To: Wei Li, Zhao Qiang
Cc: Netdev, David S. Miller, Paul Gortmaker, guohanjun,
Jakub Kicinski, linuxppc-dev, Timur Tabi, lkml
In-Reply-To: <20201124062234.678-1-liwei391@huawei.com>
On Tue, Nov 24, 2020 at 12:24 AM Wei Li <liwei391@huawei.com> wrote:
>
> IS_ERR_VALUE macro should be used only with unsigned long type.
> Especially it works incorrectly with unsigned shorter types on
> 64bit machines.
This is truly a problem for the driver to run on 64-bit architectures.
But from an earlier discussion
https://patchwork.kernel.org/project/linux-kbuild/patch/1464384685-347275-1-git-send-email-arnd@arndb.de/,
the preferred solution would be removing the IS_ERR_VALUE() usage or
make the values to be unsigned long.
It looks like we are having a bigger problem with the 64-bit support
for the driver that the offset variables can also be real pointers
which cannot be held with 32-bit data types(when uf_info->bd_mem_part
== MEM_PART_SYSTEM). So actually we have to change these offsets to
unsigned long, otherwise we are having more serious issues on 64-bit
systems. Are you willing to make such changes or you want us to deal
with it?
Regards,
Leo
>
> Fixes: 4c35630ccda5 ("[POWERPC] Change rheap functions to use ulongs instead of pointers")
> Signed-off-by: Wei Li <liwei391@huawei.com>
> ---
> drivers/net/ethernet/freescale/ucc_geth.c | 30 +++++++++++------------
> 1 file changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c
> index 714b501be7d0..8656d9be256a 100644
> --- a/drivers/net/ethernet/freescale/ucc_geth.c
> +++ b/drivers/net/ethernet/freescale/ucc_geth.c
> @@ -286,7 +286,7 @@ static int fill_init_enet_entries(struct ucc_geth_private *ugeth,
> else {
> init_enet_offset =
> qe_muram_alloc(thread_size, thread_alignment);
> - if (IS_ERR_VALUE(init_enet_offset)) {
> + if (IS_ERR_VALUE((unsigned long)(int)init_enet_offset)) {
> if (netif_msg_ifup(ugeth))
> pr_err("Can not allocate DPRAM memory\n");
> qe_put_snum((u8) snum);
> @@ -2223,7 +2223,7 @@ static int ucc_geth_alloc_tx(struct ucc_geth_private *ugeth)
> ugeth->tx_bd_ring_offset[j] =
> qe_muram_alloc(length,
> UCC_GETH_TX_BD_RING_ALIGNMENT);
> - if (!IS_ERR_VALUE(ugeth->tx_bd_ring_offset[j]))
> + if (!IS_ERR_VALUE((unsigned long)(int)ugeth->tx_bd_ring_offset[j]))
> ugeth->p_tx_bd_ring[j] =
> (u8 __iomem *) qe_muram_addr(ugeth->
> tx_bd_ring_offset[j]);
> @@ -2300,7 +2300,7 @@ static int ucc_geth_alloc_rx(struct ucc_geth_private *ugeth)
> ugeth->rx_bd_ring_offset[j] =
> qe_muram_alloc(length,
> UCC_GETH_RX_BD_RING_ALIGNMENT);
> - if (!IS_ERR_VALUE(ugeth->rx_bd_ring_offset[j]))
> + if (!IS_ERR_VALUE((unsigned long)(int)ugeth->rx_bd_ring_offset[j]))
> ugeth->p_rx_bd_ring[j] =
> (u8 __iomem *) qe_muram_addr(ugeth->
> rx_bd_ring_offset[j]);
> @@ -2510,7 +2510,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
> ugeth->tx_glbl_pram_offset =
> qe_muram_alloc(sizeof(struct ucc_geth_tx_global_pram),
> UCC_GETH_TX_GLOBAL_PRAM_ALIGNMENT);
> - if (IS_ERR_VALUE(ugeth->tx_glbl_pram_offset)) {
> + if (IS_ERR_VALUE((unsigned long)(int)ugeth->tx_glbl_pram_offset)) {
> if (netif_msg_ifup(ugeth))
> pr_err("Can not allocate DPRAM memory for p_tx_glbl_pram\n");
> return -ENOMEM;
> @@ -2530,7 +2530,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
> sizeof(struct ucc_geth_thread_data_tx) +
> 32 * (numThreadsTxNumerical == 1),
> UCC_GETH_THREAD_DATA_ALIGNMENT);
> - if (IS_ERR_VALUE(ugeth->thread_dat_tx_offset)) {
> + if (IS_ERR_VALUE((unsigned long)(int)ugeth->thread_dat_tx_offset)) {
> if (netif_msg_ifup(ugeth))
> pr_err("Can not allocate DPRAM memory for p_thread_data_tx\n");
> return -ENOMEM;
> @@ -2557,7 +2557,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
> qe_muram_alloc(ug_info->numQueuesTx *
> sizeof(struct ucc_geth_send_queue_qd),
> UCC_GETH_SEND_QUEUE_QUEUE_DESCRIPTOR_ALIGNMENT);
> - if (IS_ERR_VALUE(ugeth->send_q_mem_reg_offset)) {
> + if (IS_ERR_VALUE((unsigned long)(int)ugeth->send_q_mem_reg_offset)) {
> if (netif_msg_ifup(ugeth))
> pr_err("Can not allocate DPRAM memory for p_send_q_mem_reg\n");
> return -ENOMEM;
> @@ -2597,7 +2597,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
> ugeth->scheduler_offset =
> qe_muram_alloc(sizeof(struct ucc_geth_scheduler),
> UCC_GETH_SCHEDULER_ALIGNMENT);
> - if (IS_ERR_VALUE(ugeth->scheduler_offset)) {
> + if (IS_ERR_VALUE((unsigned long)(int)ugeth->scheduler_offset)) {
> if (netif_msg_ifup(ugeth))
> pr_err("Can not allocate DPRAM memory for p_scheduler\n");
> return -ENOMEM;
> @@ -2644,7 +2644,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
> qe_muram_alloc(sizeof
> (struct ucc_geth_tx_firmware_statistics_pram),
> UCC_GETH_TX_STATISTICS_ALIGNMENT);
> - if (IS_ERR_VALUE(ugeth->tx_fw_statistics_pram_offset)) {
> + if (IS_ERR_VALUE((unsigned long)(int)ugeth->tx_fw_statistics_pram_offset)) {
> if (netif_msg_ifup(ugeth))
> pr_err("Can not allocate DPRAM memory for p_tx_fw_statistics_pram\n");
> return -ENOMEM;
> @@ -2681,7 +2681,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
> ugeth->rx_glbl_pram_offset =
> qe_muram_alloc(sizeof(struct ucc_geth_rx_global_pram),
> UCC_GETH_RX_GLOBAL_PRAM_ALIGNMENT);
> - if (IS_ERR_VALUE(ugeth->rx_glbl_pram_offset)) {
> + if (IS_ERR_VALUE((unsigned long)(int)ugeth->rx_glbl_pram_offset)) {
> if (netif_msg_ifup(ugeth))
> pr_err("Can not allocate DPRAM memory for p_rx_glbl_pram\n");
> return -ENOMEM;
> @@ -2700,7 +2700,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
> qe_muram_alloc(numThreadsRxNumerical *
> sizeof(struct ucc_geth_thread_data_rx),
> UCC_GETH_THREAD_DATA_ALIGNMENT);
> - if (IS_ERR_VALUE(ugeth->thread_dat_rx_offset)) {
> + if (IS_ERR_VALUE((unsigned long)(int)ugeth->thread_dat_rx_offset)) {
> if (netif_msg_ifup(ugeth))
> pr_err("Can not allocate DPRAM memory for p_thread_data_rx\n");
> return -ENOMEM;
> @@ -2721,7 +2721,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
> qe_muram_alloc(sizeof
> (struct ucc_geth_rx_firmware_statistics_pram),
> UCC_GETH_RX_STATISTICS_ALIGNMENT);
> - if (IS_ERR_VALUE(ugeth->rx_fw_statistics_pram_offset)) {
> + if (IS_ERR_VALUE((unsigned long)(int)ugeth->rx_fw_statistics_pram_offset)) {
> if (netif_msg_ifup(ugeth))
> pr_err("Can not allocate DPRAM memory for p_rx_fw_statistics_pram\n");
> return -ENOMEM;
> @@ -2741,7 +2741,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
> qe_muram_alloc(ug_info->numQueuesRx *
> sizeof(struct ucc_geth_rx_interrupt_coalescing_entry)
> + 4, UCC_GETH_RX_INTERRUPT_COALESCING_ALIGNMENT);
> - if (IS_ERR_VALUE(ugeth->rx_irq_coalescing_tbl_offset)) {
> + if (IS_ERR_VALUE((unsigned long)(int)ugeth->rx_irq_coalescing_tbl_offset)) {
> if (netif_msg_ifup(ugeth))
> pr_err("Can not allocate DPRAM memory for p_rx_irq_coalescing_tbl\n");
> return -ENOMEM;
> @@ -2807,7 +2807,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
> (sizeof(struct ucc_geth_rx_bd_queues_entry) +
> sizeof(struct ucc_geth_rx_prefetched_bds)),
> UCC_GETH_RX_BD_QUEUES_ALIGNMENT);
> - if (IS_ERR_VALUE(ugeth->rx_bd_qs_tbl_offset)) {
> + if (IS_ERR_VALUE((unsigned long)(int)ugeth->rx_bd_qs_tbl_offset)) {
> if (netif_msg_ifup(ugeth))
> pr_err("Can not allocate DPRAM memory for p_rx_bd_qs_tbl\n");
> return -ENOMEM;
> @@ -2892,7 +2892,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
> ugeth->exf_glbl_param_offset =
> qe_muram_alloc(sizeof(struct ucc_geth_exf_global_pram),
> UCC_GETH_RX_EXTENDED_FILTERING_GLOBAL_PARAMETERS_ALIGNMENT);
> - if (IS_ERR_VALUE(ugeth->exf_glbl_param_offset)) {
> + if (IS_ERR_VALUE((unsigned long)(int)ugeth->exf_glbl_param_offset)) {
> if (netif_msg_ifup(ugeth))
> pr_err("Can not allocate DPRAM memory for p_exf_glbl_param\n");
> return -ENOMEM;
> @@ -3026,7 +3026,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
>
> /* Allocate InitEnet command parameter structure */
> init_enet_pram_offset = qe_muram_alloc(sizeof(struct ucc_geth_init_pram), 4);
> - if (IS_ERR_VALUE(init_enet_pram_offset)) {
> + if (IS_ERR_VALUE((unsigned long)(int)init_enet_pram_offset)) {
> if (netif_msg_ifup(ugeth))
> pr_err("Can not allocate DPRAM memory for p_init_enet_pram\n");
> return -ENOMEM;
> --
> 2.17.1
>
^ permalink raw reply
* Re: [PATCH] net/ethernet/freescale: Fix incorrect IS_ERR_VALUE macro usages
From: Li Yang @ 2020-11-24 22:13 UTC (permalink / raw)
To: Wei Li, Zhao Qiang
Cc: Netdev, David S. Miller, Paul Gortmaker, guohanjun,
Jakub Kicinski, linuxppc-dev, Timur Tabi, lkml
In-Reply-To: <CADRPPNQDW4w-4so=smxqLnkBpDzF82NPXmpZ-pyVz_aTwVzREw@mail.gmail.com>
On Tue, Nov 24, 2020 at 3:44 PM Li Yang <leoyang.li@nxp.com> wrote:
>
> On Tue, Nov 24, 2020 at 12:24 AM Wei Li <liwei391@huawei.com> wrote:
> >
> > IS_ERR_VALUE macro should be used only with unsigned long type.
> > Especially it works incorrectly with unsigned shorter types on
> > 64bit machines.
>
> This is truly a problem for the driver to run on 64-bit architectures.
> But from an earlier discussion
> https://patchwork.kernel.org/project/linux-kbuild/patch/1464384685-347275-1-git-send-email-arnd@arndb.de/,
> the preferred solution would be removing the IS_ERR_VALUE() usage or
> make the values to be unsigned long.
>
> It looks like we are having a bigger problem with the 64-bit support
> for the driver that the offset variables can also be real pointers
> which cannot be held with 32-bit data types(when uf_info->bd_mem_part
> == MEM_PART_SYSTEM). So actually we have to change these offsets to
> unsigned long, otherwise we are having more serious issues on 64-bit
> systems. Are you willing to make such changes or you want us to deal
> with it?
Well, it looks like this hardware block was never integrated on a
64-bit SoC and will very likely to keep so. So probably we can keep
the driver 32-bit only. It is currently limited to PPC32 in Kconfig,
how did you build it for 64-bit?
>
> Regards,
> Leo
> >
> > Fixes: 4c35630ccda5 ("[POWERPC] Change rheap functions to use ulongs instead of pointers")
> > Signed-off-by: Wei Li <liwei391@huawei.com>
> > ---
> > drivers/net/ethernet/freescale/ucc_geth.c | 30 +++++++++++------------
> > 1 file changed, 15 insertions(+), 15 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c
> > index 714b501be7d0..8656d9be256a 100644
> > --- a/drivers/net/ethernet/freescale/ucc_geth.c
> > +++ b/drivers/net/ethernet/freescale/ucc_geth.c
> > @@ -286,7 +286,7 @@ static int fill_init_enet_entries(struct ucc_geth_private *ugeth,
> > else {
> > init_enet_offset =
> > qe_muram_alloc(thread_size, thread_alignment);
> > - if (IS_ERR_VALUE(init_enet_offset)) {
> > + if (IS_ERR_VALUE((unsigned long)(int)init_enet_offset)) {
> > if (netif_msg_ifup(ugeth))
> > pr_err("Can not allocate DPRAM memory\n");
> > qe_put_snum((u8) snum);
> > @@ -2223,7 +2223,7 @@ static int ucc_geth_alloc_tx(struct ucc_geth_private *ugeth)
> > ugeth->tx_bd_ring_offset[j] =
> > qe_muram_alloc(length,
> > UCC_GETH_TX_BD_RING_ALIGNMENT);
> > - if (!IS_ERR_VALUE(ugeth->tx_bd_ring_offset[j]))
> > + if (!IS_ERR_VALUE((unsigned long)(int)ugeth->tx_bd_ring_offset[j]))
> > ugeth->p_tx_bd_ring[j] =
> > (u8 __iomem *) qe_muram_addr(ugeth->
> > tx_bd_ring_offset[j]);
> > @@ -2300,7 +2300,7 @@ static int ucc_geth_alloc_rx(struct ucc_geth_private *ugeth)
> > ugeth->rx_bd_ring_offset[j] =
> > qe_muram_alloc(length,
> > UCC_GETH_RX_BD_RING_ALIGNMENT);
> > - if (!IS_ERR_VALUE(ugeth->rx_bd_ring_offset[j]))
> > + if (!IS_ERR_VALUE((unsigned long)(int)ugeth->rx_bd_ring_offset[j]))
> > ugeth->p_rx_bd_ring[j] =
> > (u8 __iomem *) qe_muram_addr(ugeth->
> > rx_bd_ring_offset[j]);
> > @@ -2510,7 +2510,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
> > ugeth->tx_glbl_pram_offset =
> > qe_muram_alloc(sizeof(struct ucc_geth_tx_global_pram),
> > UCC_GETH_TX_GLOBAL_PRAM_ALIGNMENT);
> > - if (IS_ERR_VALUE(ugeth->tx_glbl_pram_offset)) {
> > + if (IS_ERR_VALUE((unsigned long)(int)ugeth->tx_glbl_pram_offset)) {
> > if (netif_msg_ifup(ugeth))
> > pr_err("Can not allocate DPRAM memory for p_tx_glbl_pram\n");
> > return -ENOMEM;
> > @@ -2530,7 +2530,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
> > sizeof(struct ucc_geth_thread_data_tx) +
> > 32 * (numThreadsTxNumerical == 1),
> > UCC_GETH_THREAD_DATA_ALIGNMENT);
> > - if (IS_ERR_VALUE(ugeth->thread_dat_tx_offset)) {
> > + if (IS_ERR_VALUE((unsigned long)(int)ugeth->thread_dat_tx_offset)) {
> > if (netif_msg_ifup(ugeth))
> > pr_err("Can not allocate DPRAM memory for p_thread_data_tx\n");
> > return -ENOMEM;
> > @@ -2557,7 +2557,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
> > qe_muram_alloc(ug_info->numQueuesTx *
> > sizeof(struct ucc_geth_send_queue_qd),
> > UCC_GETH_SEND_QUEUE_QUEUE_DESCRIPTOR_ALIGNMENT);
> > - if (IS_ERR_VALUE(ugeth->send_q_mem_reg_offset)) {
> > + if (IS_ERR_VALUE((unsigned long)(int)ugeth->send_q_mem_reg_offset)) {
> > if (netif_msg_ifup(ugeth))
> > pr_err("Can not allocate DPRAM memory for p_send_q_mem_reg\n");
> > return -ENOMEM;
> > @@ -2597,7 +2597,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
> > ugeth->scheduler_offset =
> > qe_muram_alloc(sizeof(struct ucc_geth_scheduler),
> > UCC_GETH_SCHEDULER_ALIGNMENT);
> > - if (IS_ERR_VALUE(ugeth->scheduler_offset)) {
> > + if (IS_ERR_VALUE((unsigned long)(int)ugeth->scheduler_offset)) {
> > if (netif_msg_ifup(ugeth))
> > pr_err("Can not allocate DPRAM memory for p_scheduler\n");
> > return -ENOMEM;
> > @@ -2644,7 +2644,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
> > qe_muram_alloc(sizeof
> > (struct ucc_geth_tx_firmware_statistics_pram),
> > UCC_GETH_TX_STATISTICS_ALIGNMENT);
> > - if (IS_ERR_VALUE(ugeth->tx_fw_statistics_pram_offset)) {
> > + if (IS_ERR_VALUE((unsigned long)(int)ugeth->tx_fw_statistics_pram_offset)) {
> > if (netif_msg_ifup(ugeth))
> > pr_err("Can not allocate DPRAM memory for p_tx_fw_statistics_pram\n");
> > return -ENOMEM;
> > @@ -2681,7 +2681,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
> > ugeth->rx_glbl_pram_offset =
> > qe_muram_alloc(sizeof(struct ucc_geth_rx_global_pram),
> > UCC_GETH_RX_GLOBAL_PRAM_ALIGNMENT);
> > - if (IS_ERR_VALUE(ugeth->rx_glbl_pram_offset)) {
> > + if (IS_ERR_VALUE((unsigned long)(int)ugeth->rx_glbl_pram_offset)) {
> > if (netif_msg_ifup(ugeth))
> > pr_err("Can not allocate DPRAM memory for p_rx_glbl_pram\n");
> > return -ENOMEM;
> > @@ -2700,7 +2700,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
> > qe_muram_alloc(numThreadsRxNumerical *
> > sizeof(struct ucc_geth_thread_data_rx),
> > UCC_GETH_THREAD_DATA_ALIGNMENT);
> > - if (IS_ERR_VALUE(ugeth->thread_dat_rx_offset)) {
> > + if (IS_ERR_VALUE((unsigned long)(int)ugeth->thread_dat_rx_offset)) {
> > if (netif_msg_ifup(ugeth))
> > pr_err("Can not allocate DPRAM memory for p_thread_data_rx\n");
> > return -ENOMEM;
> > @@ -2721,7 +2721,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
> > qe_muram_alloc(sizeof
> > (struct ucc_geth_rx_firmware_statistics_pram),
> > UCC_GETH_RX_STATISTICS_ALIGNMENT);
> > - if (IS_ERR_VALUE(ugeth->rx_fw_statistics_pram_offset)) {
> > + if (IS_ERR_VALUE((unsigned long)(int)ugeth->rx_fw_statistics_pram_offset)) {
> > if (netif_msg_ifup(ugeth))
> > pr_err("Can not allocate DPRAM memory for p_rx_fw_statistics_pram\n");
> > return -ENOMEM;
> > @@ -2741,7 +2741,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
> > qe_muram_alloc(ug_info->numQueuesRx *
> > sizeof(struct ucc_geth_rx_interrupt_coalescing_entry)
> > + 4, UCC_GETH_RX_INTERRUPT_COALESCING_ALIGNMENT);
> > - if (IS_ERR_VALUE(ugeth->rx_irq_coalescing_tbl_offset)) {
> > + if (IS_ERR_VALUE((unsigned long)(int)ugeth->rx_irq_coalescing_tbl_offset)) {
> > if (netif_msg_ifup(ugeth))
> > pr_err("Can not allocate DPRAM memory for p_rx_irq_coalescing_tbl\n");
> > return -ENOMEM;
> > @@ -2807,7 +2807,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
> > (sizeof(struct ucc_geth_rx_bd_queues_entry) +
> > sizeof(struct ucc_geth_rx_prefetched_bds)),
> > UCC_GETH_RX_BD_QUEUES_ALIGNMENT);
> > - if (IS_ERR_VALUE(ugeth->rx_bd_qs_tbl_offset)) {
> > + if (IS_ERR_VALUE((unsigned long)(int)ugeth->rx_bd_qs_tbl_offset)) {
> > if (netif_msg_ifup(ugeth))
> > pr_err("Can not allocate DPRAM memory for p_rx_bd_qs_tbl\n");
> > return -ENOMEM;
> > @@ -2892,7 +2892,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
> > ugeth->exf_glbl_param_offset =
> > qe_muram_alloc(sizeof(struct ucc_geth_exf_global_pram),
> > UCC_GETH_RX_EXTENDED_FILTERING_GLOBAL_PARAMETERS_ALIGNMENT);
> > - if (IS_ERR_VALUE(ugeth->exf_glbl_param_offset)) {
> > + if (IS_ERR_VALUE((unsigned long)(int)ugeth->exf_glbl_param_offset)) {
> > if (netif_msg_ifup(ugeth))
> > pr_err("Can not allocate DPRAM memory for p_exf_glbl_param\n");
> > return -ENOMEM;
> > @@ -3026,7 +3026,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
> >
> > /* Allocate InitEnet command parameter structure */
> > init_enet_pram_offset = qe_muram_alloc(sizeof(struct ucc_geth_init_pram), 4);
> > - if (IS_ERR_VALUE(init_enet_pram_offset)) {
> > + if (IS_ERR_VALUE((unsigned long)(int)init_enet_pram_offset)) {
> > if (netif_msg_ifup(ugeth))
> > pr_err("Can not allocate DPRAM memory for p_init_enet_pram\n");
> > return -ENOMEM;
> > --
> > 2.17.1
> >
^ permalink raw reply
* Re: [PATCH 1/2] genirq: add an affinity parameter to irq_create_mapping()
From: Thomas Gleixner @ 2020-11-24 22:19 UTC (permalink / raw)
To: Laurent Vivier, linux-kernel
Cc: Laurent Vivier, Michael S . Tsirkin, linux-pci, linux-block,
Paul Mackerras, Marc Zyngier, linuxppc-dev, Christoph Hellwig
In-Reply-To: <20201124200308.1110744-2-lvivier@redhat.com>
On Tue, Nov 24 2020 at 21:03, Laurent Vivier wrote:
> This parameter is needed to pass it to irq_domain_alloc_descs().
>
> This seems to have been missed by
> o06ee6d571f0e ("genirq: Add affinity hint to irq allocation")
No, this has not been missed at all. There was and is no reason to do
this.
> This is needed to implement proper support for multiqueue with
> pseries.
And because pseries needs this _all_ callers need to be changed?
> 123 files changed, 171 insertions(+), 146 deletions(-)
Lots of churn for nothing. 99% of the callers will never need that.
What's wrong with simply adding an interface which takes that parameter,
make the existing one an inline wrapper and and leave the rest alone?
Thanks,
tglx
^ permalink raw reply
* Re: [PATCH v2 2/2] kbuild: Disable CONFIG_LD_ORPHAN_WARN for ld.lld 10.0.1
From: Kees Cook @ 2020-11-24 22:22 UTC (permalink / raw)
To: Nick Desaulniers
Cc: Michal Marek, kernelci . org bot, Linux Kbuild mailing list,
Mark Brown, Catalin Marinas, Masahiro Yamada,
maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT), Russell King,
LKML, linuxppc-dev, Arvind Sankar, Ingo Molnar, Borislav Petkov,
clang-built-linux, Nathan Chancellor, Will Deacon,
Thomas Gleixner, Linux ARM
In-Reply-To: <CAKwvOdkPgwL8H4EGF6=-VuxTdmxA8JHhGbLHVYcLJj9MmAvW=g@mail.gmail.com>
On Thu, Nov 19, 2020 at 01:13:27PM -0800, Nick Desaulniers wrote:
> On Thu, Nov 19, 2020 at 12:57 PM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > ld.lld 10.0.1 spews a bunch of various warnings about .rela sections,
> > along with a few others. Newer versions of ld.lld do not have these
> > warnings. As a result, do not add '--orphan-handling=warn' to
> > LDFLAGS_vmlinux if ld.lld's version is not new enough.
> >
> > Link: https://github.com/ClangBuiltLinux/linux/issues/1187
> > Link: https://github.com/ClangBuiltLinux/linux/issues/1193
> > Reported-by: Arvind Sankar <nivedita@alum.mit.edu>
> > Reported-by: kernelci.org bot <bot@kernelci.org>
> > Reported-by: Mark Brown <broonie@kernel.org>
> > Reviewed-by: Kees Cook <keescook@chromium.org>
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
>
> Thanks for the additions in v2.
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
I'm going to carry this for a few days in -next, and if no one screams,
ask Linus to pull it for v5.10-rc6.
Thanks!
--
Kees Cook
^ permalink raw reply
* Re: [PATCH 2/2] powerpc/pseries: pass MSI affinity to irq_create_mapping()
From: Thomas Gleixner @ 2020-11-24 22:35 UTC (permalink / raw)
To: Laurent Vivier, linux-kernel
Cc: Laurent Vivier, Michael S . Tsirkin, linux-pci, linux-block,
Paul Mackerras, Marc Zyngier, linuxppc-dev, Christoph Hellwig
In-Reply-To: <20201124200308.1110744-3-lvivier@redhat.com>
On Tue, Nov 24 2020 at 21:03, Laurent Vivier wrote:
> With virtio multiqueue, normally each queue IRQ is mapped to a CPU.
>
> This problem cannot be shown on x86_64 for two reasons:
There is only _ONE_ reason why this is not a problem on x86. x86 uses
the generic PCI/MSI domain which supports this out of the box.
> - the call path traverses arch_setup_msi_irqs() that is arch specific:
>
> virtscsi_probe()
> virtscsi_init()
> vp_modern_find_vqs()
> vp_find_vqs()
> vp_find_vqs_msix()
> pci_alloc_irq_vectors_affinity()
> __pci_enable_msix_range()
> pci_msi_setup_msi_irqs()
> arch_setup_msi_irqs()
> rtas_setup_msi_irqs()
This is a problem on _all_ variants of PPC MSI providers, not only for
pseries. It's not restricted to virtscsi devices either, that's just the
device which made you discover this.
Thanks,
tglx
^ permalink raw reply
* Re: [PATCH 1/2] genirq: add an affinity parameter to irq_create_mapping()
From: kernel test robot @ 2020-11-24 22:50 UTC (permalink / raw)
To: Laurent Vivier, linux-kernel
Cc: Laurent Vivier, kbuild-all, Michael S . Tsirkin, Marc Zyngier,
linux-block, Paul Mackerras, linux-pci, Thomas Gleixner,
linuxppc-dev, Christoph Hellwig
In-Reply-To: <20201124200308.1110744-2-lvivier@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3000 bytes --]
Hi Laurent,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on gpio/for-next]
[also build test ERROR on linus/master v5.10-rc5 next-20201124]
[cannot apply to powerpc/next tip/irq/core]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Laurent-Vivier/powerpc-pseries-fix-MSI-X-IRQ-affinity-on-pseries/20201125-040537
base: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git for-next
config: parisc-randconfig-r014-20201124 (attached as .config)
compiler: hppa64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/86de9fd2e4f360722119b69bb2269330ae9e1d54
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Laurent-Vivier/powerpc-pseries-fix-MSI-X-IRQ-affinity-on-pseries/20201125-040537
git checkout 86de9fd2e4f360722119b69bb2269330ae9e1d54
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=parisc
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
In file included from drivers/regulator/wm831x-dcdc.c:21:
include/linux/mfd/wm831x/core.h: In function 'wm831x_irq':
>> include/linux/mfd/wm831x/core.h:424:9: error: too few arguments to function 'irq_create_mapping'
424 | return irq_create_mapping(wm831x->irq_domain, irq);
| ^~~~~~~~~~~~~~~~~~
In file included from include/linux/acpi.h:13,
from include/linux/i2c.h:13,
from drivers/regulator/wm831x-dcdc.c:14:
include/linux/irqdomain.h:387:21: note: declared here
387 | extern unsigned int irq_create_mapping(struct irq_domain *host,
| ^~~~~~~~~~~~~~~~~~
In file included from drivers/regulator/wm831x-dcdc.c:21:
include/linux/mfd/wm831x/core.h:425:1: error: control reaches end of non-void function [-Werror=return-type]
425 | }
| ^
cc1: some warnings being treated as errors
vim +/irq_create_mapping +424 include/linux/mfd/wm831x/core.h
7d4d0a3e7343e31 Mark Brown 2009-07-27 421
cd99758ba3bde64 Mark Brown 2012-05-14 422 static inline int wm831x_irq(struct wm831x *wm831x, int irq)
cd99758ba3bde64 Mark Brown 2012-05-14 423 {
cd99758ba3bde64 Mark Brown 2012-05-14 @424 return irq_create_mapping(wm831x->irq_domain, irq);
cd99758ba3bde64 Mark Brown 2012-05-14 425 }
cd99758ba3bde64 Mark Brown 2012-05-14 426
---
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: 29784 bytes --]
^ permalink raw reply
* Re: [PATCH 1/2] genirq: add an affinity parameter to irq_create_mapping()
From: kernel test robot @ 2020-11-25 1:03 UTC (permalink / raw)
To: Laurent Vivier, linux-kernel
Cc: Laurent Vivier, kbuild-all, Michael S . Tsirkin, linux-pci,
linux-block, clang-built-linux, Paul Mackerras, Marc Zyngier,
Thomas Gleixner, linuxppc-dev, Christoph Hellwig
In-Reply-To: <20201124200308.1110744-2-lvivier@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2738 bytes --]
Hi Laurent,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on gpio/for-next]
[also build test ERROR on linus/master v5.10-rc5 next-20201124]
[cannot apply to powerpc/next tip/irq/core]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Laurent-Vivier/powerpc-pseries-fix-MSI-X-IRQ-affinity-on-pseries/20201125-040537
base: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git for-next
config: powerpc64-randconfig-r024-20201124 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project df9ae5992889560a8f3c6760b54d5051b47c7bf5)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install powerpc64 cross compiling tool for clang build
# apt-get install binutils-powerpc64-linux-gnu
# https://github.com/0day-ci/linux/commit/86de9fd2e4f360722119b69bb2269330ae9e1d54
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Laurent-Vivier/powerpc-pseries-fix-MSI-X-IRQ-affinity-on-pseries/20201125-040537
git checkout 86de9fd2e4f360722119b69bb2269330ae9e1d54
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
In file included from drivers/mfd/wm831x-core.c:21:
>> include/linux/mfd/wm831x/core.h:424:51: error: too few arguments to function call, expected 3, have 2
return irq_create_mapping(wm831x->irq_domain, irq);
~~~~~~~~~~~~~~~~~~ ^
include/linux/irqdomain.h:387:21: note: 'irq_create_mapping' declared here
extern unsigned int irq_create_mapping(struct irq_domain *host,
^
1 error generated.
vim +424 include/linux/mfd/wm831x/core.h
7d4d0a3e7343e31 Mark Brown 2009-07-27 421
cd99758ba3bde64 Mark Brown 2012-05-14 422 static inline int wm831x_irq(struct wm831x *wm831x, int irq)
cd99758ba3bde64 Mark Brown 2012-05-14 423 {
cd99758ba3bde64 Mark Brown 2012-05-14 @424 return irq_create_mapping(wm831x->irq_domain, irq);
cd99758ba3bde64 Mark Brown 2012-05-14 425 }
cd99758ba3bde64 Mark Brown 2012-05-14 426
---
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: 31295 bytes --]
^ permalink raw reply
* Re: [PATCH] net/ethernet/freescale: Fix incorrect IS_ERR_VALUE macro usages
From: liwei (GF) @ 2020-11-25 1:57 UTC (permalink / raw)
To: Li Yang, Zhao Qiang
Cc: Netdev, David S. Miller, Paul Gortmaker, guohanjun,
Jakub Kicinski, linuxppc-dev, Timur Tabi, lkml
In-Reply-To: <CADRPPNTpOsp-mrzvR-=c6SqHuNfyx7y9+1p+x0ft4qu-mD_xcA@mail.gmail.com>
Hi Yang,
On 2020/11/25 6:13, Li Yang wrote:
> On Tue, Nov 24, 2020 at 3:44 PM Li Yang <leoyang.li@nxp.com> wrote:
>>
>> On Tue, Nov 24, 2020 at 12:24 AM Wei Li <liwei391@huawei.com> wrote:
>>>
>>> IS_ERR_VALUE macro should be used only with unsigned long type.
>>> Especially it works incorrectly with unsigned shorter types on
>>> 64bit machines.
>>
>> This is truly a problem for the driver to run on 64-bit architectures.
>> But from an earlier discussion
>> https://patchwork.kernel.org/project/linux-kbuild/patch/1464384685-347275-1-git-send-email-arnd@arndb.de/,
>> the preferred solution would be removing the IS_ERR_VALUE() usage or
>> make the values to be unsigned long.
>>
>> It looks like we are having a bigger problem with the 64-bit support
>> for the driver that the offset variables can also be real pointers
>> which cannot be held with 32-bit data types(when uf_info->bd_mem_part
>> == MEM_PART_SYSTEM). So actually we have to change these offsets to
>> unsigned long, otherwise we are having more serious issues on 64-bit
>> systems. Are you willing to make such changes or you want us to deal
>> with it?
>
> Well, it looks like this hardware block was never integrated on a
> 64-bit SoC and will very likely to keep so. So probably we can keep
> the driver 32-bit only. It is currently limited to PPC32 in Kconfig,
> how did you build it for 64-bit?
>
>>
Thank you for providing the earlier discussion archive. In fact, this
issue is detected by our static analysis tool.
From my view, there is no harm to fix these potential misuses. But if you
really have decided to keep the driver 32-bit only, please just ingore this patch.
Thanks,
Wei
>>>
>>> Fixes: 4c35630ccda5 ("[POWERPC] Change rheap functions to use ulongs instead of pointers")
>>> Signed-off-by: Wei Li <liwei391@huawei.com>
>>> ---
>>> drivers/net/ethernet/freescale/ucc_geth.c | 30 +++++++++++------------
>>> 1 file changed, 15 insertions(+), 15 deletions(-)
>>>
>>> diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c
>>> index 714b501be7d0..8656d9be256a 100644
>>> --- a/drivers/net/ethernet/freescale/ucc_geth.c
>>> +++ b/drivers/net/ethernet/freescale/ucc_geth.c
>>> @@ -286,7 +286,7 @@ static int fill_init_enet_entries(struct ucc_geth_private *ugeth,
>>> else {
>>> init_enet_offset =
>>> qe_muram_alloc(thread_size, thread_alignment);
>>> - if (IS_ERR_VALUE(init_enet_offset)) {
>>> + if (IS_ERR_VALUE((unsigned long)(int)init_enet_offset)) {
>>> if (netif_msg_ifup(ugeth))
>>> pr_err("Can not allocate DPRAM memory\n");
>>> qe_put_snum((u8) snum);
>>> @@ -2223,7 +2223,7 @@ static int ucc_geth_alloc_tx(struct ucc_geth_private *ugeth)
>>> ugeth->tx_bd_ring_offset[j] =
>>> qe_muram_alloc(length,
>>> UCC_GETH_TX_BD_RING_ALIGNMENT);
>>> - if (!IS_ERR_VALUE(ugeth->tx_bd_ring_offset[j]))
>>> + if (!IS_ERR_VALUE((unsigned long)(int)ugeth->tx_bd_ring_offset[j]))
>>> ugeth->p_tx_bd_ring[j] =
>>> (u8 __iomem *) qe_muram_addr(ugeth->
>>> tx_bd_ring_offset[j]);
>>> @@ -2300,7 +2300,7 @@ static int ucc_geth_alloc_rx(struct ucc_geth_private *ugeth)
>>> ugeth->rx_bd_ring_offset[j] =
>>> qe_muram_alloc(length,
>>> UCC_GETH_RX_BD_RING_ALIGNMENT);
>>> - if (!IS_ERR_VALUE(ugeth->rx_bd_ring_offset[j]))
>>> + if (!IS_ERR_VALUE((unsigned long)(int)ugeth->rx_bd_ring_offset[j]))
>>> ugeth->p_rx_bd_ring[j] =
>>> (u8 __iomem *) qe_muram_addr(ugeth->
>>> rx_bd_ring_offset[j]);
>>> @@ -2510,7 +2510,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
>>> ugeth->tx_glbl_pram_offset =
>>> qe_muram_alloc(sizeof(struct ucc_geth_tx_global_pram),
>>> UCC_GETH_TX_GLOBAL_PRAM_ALIGNMENT);
>>> - if (IS_ERR_VALUE(ugeth->tx_glbl_pram_offset)) {
>>> + if (IS_ERR_VALUE((unsigned long)(int)ugeth->tx_glbl_pram_offset)) {
>>> if (netif_msg_ifup(ugeth))
>>> pr_err("Can not allocate DPRAM memory for p_tx_glbl_pram\n");
>>> return -ENOMEM;
>>> @@ -2530,7 +2530,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
>>> sizeof(struct ucc_geth_thread_data_tx) +
>>> 32 * (numThreadsTxNumerical == 1),
>>> UCC_GETH_THREAD_DATA_ALIGNMENT);
>>> - if (IS_ERR_VALUE(ugeth->thread_dat_tx_offset)) {
>>> + if (IS_ERR_VALUE((unsigned long)(int)ugeth->thread_dat_tx_offset)) {
>>> if (netif_msg_ifup(ugeth))
>>> pr_err("Can not allocate DPRAM memory for p_thread_data_tx\n");
>>> return -ENOMEM;
>>> @@ -2557,7 +2557,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
>>> qe_muram_alloc(ug_info->numQueuesTx *
>>> sizeof(struct ucc_geth_send_queue_qd),
>>> UCC_GETH_SEND_QUEUE_QUEUE_DESCRIPTOR_ALIGNMENT);
>>> - if (IS_ERR_VALUE(ugeth->send_q_mem_reg_offset)) {
>>> + if (IS_ERR_VALUE((unsigned long)(int)ugeth->send_q_mem_reg_offset)) {
>>> if (netif_msg_ifup(ugeth))
>>> pr_err("Can not allocate DPRAM memory for p_send_q_mem_reg\n");
>>> return -ENOMEM;
>>> @@ -2597,7 +2597,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
>>> ugeth->scheduler_offset =
>>> qe_muram_alloc(sizeof(struct ucc_geth_scheduler),
>>> UCC_GETH_SCHEDULER_ALIGNMENT);
>>> - if (IS_ERR_VALUE(ugeth->scheduler_offset)) {
>>> + if (IS_ERR_VALUE((unsigned long)(int)ugeth->scheduler_offset)) {
>>> if (netif_msg_ifup(ugeth))
>>> pr_err("Can not allocate DPRAM memory for p_scheduler\n");
>>> return -ENOMEM;
>>> @@ -2644,7 +2644,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
>>> qe_muram_alloc(sizeof
>>> (struct ucc_geth_tx_firmware_statistics_pram),
>>> UCC_GETH_TX_STATISTICS_ALIGNMENT);
>>> - if (IS_ERR_VALUE(ugeth->tx_fw_statistics_pram_offset)) {
>>> + if (IS_ERR_VALUE((unsigned long)(int)ugeth->tx_fw_statistics_pram_offset)) {
>>> if (netif_msg_ifup(ugeth))
>>> pr_err("Can not allocate DPRAM memory for p_tx_fw_statistics_pram\n");
>>> return -ENOMEM;
>>> @@ -2681,7 +2681,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
>>> ugeth->rx_glbl_pram_offset =
>>> qe_muram_alloc(sizeof(struct ucc_geth_rx_global_pram),
>>> UCC_GETH_RX_GLOBAL_PRAM_ALIGNMENT);
>>> - if (IS_ERR_VALUE(ugeth->rx_glbl_pram_offset)) {
>>> + if (IS_ERR_VALUE((unsigned long)(int)ugeth->rx_glbl_pram_offset)) {
>>> if (netif_msg_ifup(ugeth))
>>> pr_err("Can not allocate DPRAM memory for p_rx_glbl_pram\n");
>>> return -ENOMEM;
>>> @@ -2700,7 +2700,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
>>> qe_muram_alloc(numThreadsRxNumerical *
>>> sizeof(struct ucc_geth_thread_data_rx),
>>> UCC_GETH_THREAD_DATA_ALIGNMENT);
>>> - if (IS_ERR_VALUE(ugeth->thread_dat_rx_offset)) {
>>> + if (IS_ERR_VALUE((unsigned long)(int)ugeth->thread_dat_rx_offset)) {
>>> if (netif_msg_ifup(ugeth))
>>> pr_err("Can not allocate DPRAM memory for p_thread_data_rx\n");
>>> return -ENOMEM;
>>> @@ -2721,7 +2721,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
>>> qe_muram_alloc(sizeof
>>> (struct ucc_geth_rx_firmware_statistics_pram),
>>> UCC_GETH_RX_STATISTICS_ALIGNMENT);
>>> - if (IS_ERR_VALUE(ugeth->rx_fw_statistics_pram_offset)) {
>>> + if (IS_ERR_VALUE((unsigned long)(int)ugeth->rx_fw_statistics_pram_offset)) {
>>> if (netif_msg_ifup(ugeth))
>>> pr_err("Can not allocate DPRAM memory for p_rx_fw_statistics_pram\n");
>>> return -ENOMEM;
>>> @@ -2741,7 +2741,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
>>> qe_muram_alloc(ug_info->numQueuesRx *
>>> sizeof(struct ucc_geth_rx_interrupt_coalescing_entry)
>>> + 4, UCC_GETH_RX_INTERRUPT_COALESCING_ALIGNMENT);
>>> - if (IS_ERR_VALUE(ugeth->rx_irq_coalescing_tbl_offset)) {
>>> + if (IS_ERR_VALUE((unsigned long)(int)ugeth->rx_irq_coalescing_tbl_offset)) {
>>> if (netif_msg_ifup(ugeth))
>>> pr_err("Can not allocate DPRAM memory for p_rx_irq_coalescing_tbl\n");
>>> return -ENOMEM;
>>> @@ -2807,7 +2807,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
>>> (sizeof(struct ucc_geth_rx_bd_queues_entry) +
>>> sizeof(struct ucc_geth_rx_prefetched_bds)),
>>> UCC_GETH_RX_BD_QUEUES_ALIGNMENT);
>>> - if (IS_ERR_VALUE(ugeth->rx_bd_qs_tbl_offset)) {
>>> + if (IS_ERR_VALUE((unsigned long)(int)ugeth->rx_bd_qs_tbl_offset)) {
>>> if (netif_msg_ifup(ugeth))
>>> pr_err("Can not allocate DPRAM memory for p_rx_bd_qs_tbl\n");
>>> return -ENOMEM;
>>> @@ -2892,7 +2892,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
>>> ugeth->exf_glbl_param_offset =
>>> qe_muram_alloc(sizeof(struct ucc_geth_exf_global_pram),
>>> UCC_GETH_RX_EXTENDED_FILTERING_GLOBAL_PARAMETERS_ALIGNMENT);
>>> - if (IS_ERR_VALUE(ugeth->exf_glbl_param_offset)) {
>>> + if (IS_ERR_VALUE((unsigned long)(int)ugeth->exf_glbl_param_offset)) {
>>> if (netif_msg_ifup(ugeth))
>>> pr_err("Can not allocate DPRAM memory for p_exf_glbl_param\n");
>>> return -ENOMEM;
>>> @@ -3026,7 +3026,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
>>>
>>> /* Allocate InitEnet command parameter structure */
>>> init_enet_pram_offset = qe_muram_alloc(sizeof(struct ucc_geth_init_pram), 4);
>>> - if (IS_ERR_VALUE(init_enet_pram_offset)) {
>>> + if (IS_ERR_VALUE((unsigned long)(int)init_enet_pram_offset)) {
>>> if (netif_msg_ifup(ugeth))
>>> pr_err("Can not allocate DPRAM memory for p_init_enet_pram\n");
>>> return -ENOMEM;
>>> --
>>> 2.17.1
>>>
^ permalink raw reply
* Re: C vdso
From: Michael Ellerman @ 2020-11-25 2:04 UTC (permalink / raw)
To: Christophe Leroy; +Cc: linuxppc-dev@ozlabs.org
In-Reply-To: <49ac0354-d6a5-be2c-c717-965e6a102320@csgroup.eu>
Christophe Leroy <christophe.leroy@csgroup.eu> writes:
> Le 03/11/2020 à 19:13, Christophe Leroy a écrit :
>> Le 23/10/2020 à 15:24, Michael Ellerman a écrit :
>>> Christophe Leroy <christophe.leroy@csgroup.eu> writes:
>>>> Le 24/09/2020 à 15:17, Christophe Leroy a écrit :
>>>>> Le 17/09/2020 à 14:33, Michael Ellerman a écrit :
>>>>>> Christophe Leroy <christophe.leroy@csgroup.eu> writes:
>>>>>>>
>>>>>>> What is the status with the generic C vdso merge ?
>>>>>>> In some mail, you mentionned having difficulties getting it working on
>>>>>>> ppc64, any progress ? What's the problem ? Can I help ?
>>>>>>
>>>>>> Yeah sorry I was hoping to get time to work on it but haven't been able
>>>>>> to.
>>>>>>
>>>>>> It's causing crashes on ppc64 ie. big endian.
>>> ...
>>>>>
>>>>> Can you tell what defconfig you are using ? I have been able to setup a full glibc PPC64 cross
>>>>> compilation chain and been able to test it under QEMU with success, using Nathan's vdsotest tool.
>>>>
>>>> What config are you using ?
>>>
>>> ppc64_defconfig + guest.config
>>>
>>> Or pseries_defconfig.
>>>
>>> I'm using Ubuntu GCC 9.3.0 mostly, but it happens with other toolchains too.
>>>
>>> At a minimum we're seeing relocations in the output, which is a problem:
>>>
>>> $ readelf -r build\~/arch/powerpc/kernel/vdso64/vdso64.so
>>> Relocation section '.rela.dyn' at offset 0x12a8 contains 8 entries:
>>> Offset Info Type Sym. Value Sym. Name + Addend
>>> 000000001368 000000000016 R_PPC64_RELATIVE 7c0
>>> 000000001370 000000000016 R_PPC64_RELATIVE 9300
>>> 000000001380 000000000016 R_PPC64_RELATIVE 970
>>> 000000001388 000000000016 R_PPC64_RELATIVE 9300
>>> 000000001398 000000000016 R_PPC64_RELATIVE a90
>>> 0000000013a0 000000000016 R_PPC64_RELATIVE 9300
>>> 0000000013b0 000000000016 R_PPC64_RELATIVE b20
>>> 0000000013b8 000000000016 R_PPC64_RELATIVE 9300
>>
>> Looks like it's due to the OPD and relation between the function() and .function()
>>
>> By using DOTSYM() in the 'bl' call, that's directly the dot function which is called and the OPD is
>> not used anymore, it can get dropped.
>>
>> Now I get .rela.dyn full of 0, don't know if we should drop it explicitely.
>
> What is the status now with latest version of CVDSO ? I saw you had it in next-test for some time,
> it is not there anymore today.
Still having some trouble with the compat VDSO.
eg:
$ ./vdsotest clock-gettime-monotonic verify
timestamp obtained from kernel predates timestamp
previously obtained from libc/vDSO:
[1346, 821441653] (vDSO)
[570, 769440040] (kernel)
And similar for all clocks except the coarse ones.
Hopefully I can find time to dig into it.
cheers
^ permalink raw reply
* Re: linux-next: build failure in Linus' tree
From: Michael Ellerman @ 2020-11-25 2:47 UTC (permalink / raw)
To: Daniel Axtens, Michael Ellerman, Stephen Rothwell, PowerPC
Cc: Linux Next Mailing List, Linux Kernel Mailing List,
Nicholas Piggin
In-Reply-To: <87h7pfhac3.fsf@dja-thinkpad.axtens.net>
Daniel Axtens <dja@axtens.net> writes:
> Thanks sfr and mpe.
>
>> Applied to powerpc/fixes.
>>
>> [1/1] powerpc/64s: Fix allnoconfig build since uaccess flush
>> https://git.kernel.org/powerpc/c/b6b79dd53082db11070b4368d85dd6699ff0b063
>
> We also needed a similar fix for stable, which has also been applied.
>
> I guess I should build some sort of build process that tests a whole
> range of configs. I did test a few but clearly not enough. Is there a
> known list that I should be using? Something from kisskb?
It's basically unsolvable in general. I guess allnoconfig is a good one
to build, although by default that gets you a 32-bit config.
I'll send a patch to add ppc64le_allnoconfig.
cheers
^ permalink raw reply
* [PATCH] powerpc/configs: Add ppc64le_allnoconfig target
From: Michael Ellerman @ 2020-11-25 3:15 UTC (permalink / raw)
To: linuxppc-dev; +Cc: dja
Add a phony target for ppc64le_allnoconfig, which tests some
combinations of CONFIG symbols that aren't covered by any of our
defconfigs.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/Makefile | 5 +++++
arch/powerpc/configs/ppc64le.config | 2 ++
2 files changed, 7 insertions(+)
create mode 100644 arch/powerpc/configs/ppc64le.config
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index a4d56f0a41d9..26a17798c815 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -376,6 +376,11 @@ PHONY += ppc64le_allmodconfig
$(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/le.config \
-f $(srctree)/Makefile allmodconfig
+PHONY += ppc64le_allnoconfig
+ppc64le_allnoconfig:
+ $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/ppc64le.config \
+ -f $(srctree)/Makefile allnoconfig
+
PHONY += ppc64_book3e_allmodconfig
ppc64_book3e_allmodconfig:
$(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/85xx-64bit.config \
diff --git a/arch/powerpc/configs/ppc64le.config b/arch/powerpc/configs/ppc64le.config
new file mode 100644
index 000000000000..14dca1062c1b
--- /dev/null
+++ b/arch/powerpc/configs/ppc64le.config
@@ -0,0 +1,2 @@
+CONFIG_PPC64=y
+CONFIG_CPU_LITTLE_ENDIAN=y
--
2.25.1
^ permalink raw reply related
* Re: [PATCH 1/3] powerpc: Make NUMA depend on SMP
From: Srikar Dronamraju @ 2020-11-25 4:30 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev, rdunlap
In-Reply-To: <20201124120547.1940635-1-mpe@ellerman.id.au>
* Michael Ellerman <mpe@ellerman.id.au> [2020-11-24 23:05:45]:
> Our Kconfig allows NUMA to be enabled without SMP, but none of
> our defconfigs use that combination. This means it can easily be
> broken inadvertently by code changes, which has happened recently.
>
> Although it's theoretically possible to have a machine with a single
> CPU and multiple memory nodes, I can't think of any real systems where
> that's the case. Even so if such a system exists, it can just run an
> SMP kernel anyway.
>
> So to avoid the need to add extra #ifdefs and/or build breaks, make
> NUMA depend on SMP.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Looks good to me.
Reviewed-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
> ---
> arch/powerpc/Kconfig | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index e9f13fe08492..a22db3db6b96 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -660,7 +660,7 @@ config IRQ_ALL_CPUS
>
> config NUMA
> bool "NUMA support"
> - depends on PPC64
> + depends on PPC64 && SMP
> default y if SMP && PPC_PSERIES
>
> config NODES_SHIFT
> --
> 2.25.1
>
--
Thanks and Regards
Srikar Dronamraju
^ permalink raw reply
* Re: [PATCH 2/3] powerpc: Make NUMA default y for powernv
From: Srikar Dronamraju @ 2020-11-25 4:30 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev, rdunlap
In-Reply-To: <20201124120547.1940635-2-mpe@ellerman.id.au>
* Michael Ellerman <mpe@ellerman.id.au> [2020-11-24 23:05:46]:
> Our NUMA option is default y for pseries, but not powernv. The bulk of
> powernv systems are NUMA, so make NUMA default y for powernv also.
>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Looks good to me.
Reviewed-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
> ---
> arch/powerpc/Kconfig | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index a22db3db6b96..4d688b426353 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -661,7 +661,7 @@ config IRQ_ALL_CPUS
> config NUMA
> bool "NUMA support"
> depends on PPC64 && SMP
> - default y if SMP && PPC_PSERIES
> + default y if PPC_PSERIES || PPC_POWERNV
>
> config NODES_SHIFT
> int
> --
> 2.25.1
>
--
Thanks and Regards
Srikar Dronamraju
^ permalink raw reply
* Re: [PATCH v3 3/3] powerpc/64s: feature: Work around inline asm issues
From: Bill Wendling @ 2020-11-25 5:13 UTC (permalink / raw)
To: Michael Ellerman; +Cc: Nick Desaulniers, linuxppc-dev
In-Reply-To: <87zh37zaf4.fsf@mpe.ellerman.id.au>
On Mon, Nov 23, 2020 at 7:44 PM Michael Ellerman <mpe@ellerman.id.au> wrote:
> Bill Wendling <morbo@google.com> writes:
> > On Mon, Nov 23, 2020 at 12:10 PM Segher Boessenkool
> > <segher@kernel.crashing.org> wrote:
> >> On Mon, Nov 23, 2020 at 12:01:01PM -0800, Bill Wendling wrote:
> >> > On Mon, Nov 23, 2020 at 11:58 AM Segher Boessenkool
> >> > <segher@kernel.crashing.org> wrote:
> >> > > > On Sun, Nov 22, 2020 at 10:36 PM Segher Boessenkool
> >> > > > <segher@kernel.crashing.org> wrote:
> >> > > > > "true" (as a result of a comparison) in as is -1, not 1.
> >> > >
> >> > > On Mon, Nov 23, 2020 at 11:43:11AM -0800, Bill Wendling wrote:
> >> > > > What Segher said. :-) Also, if you reverse the comparison, you'll get
> >> > > > a build error.
> >> > >
> >> > > But that means your patch is the wrong way around?
> >> > >
> >> > > - .ifgt (label##4b- label##3b)-(label##2b- label##1b); \
> >> > > - .error "Feature section else case larger than body"; \
> >> > > - .endif; \
> >> > > + .org . - ((label##4b-label##3b) > (label##2b-label##1b)); \
> >> > >
> >> > > It should be a + in that last line, not a -.
> >> >
> >> > I said so in a follow up email.
> >>
> >> Yeah, and that arrived a second after I pressed "send" :-)
> >>
> > Michael, I apologize for the churn with these patches. I believe the
> > policy is to resend the match as "v4", correct?
> >
> > I ran tests with the change above. It compiled with no error. If I
> > switch the labels around to ".org . + ((label##2b-label##1b) >
> > (label##4b-label##3b))", then it fails as expected.
>
> I wanted to retain the nicer error reporting for gcc builds, so I did it
> like this:
>
> diff --git a/arch/powerpc/include/asm/feature-fixups.h b/arch/powerpc/include/asm/feature-fixups.h
> index b0af97add751..c4ad33074df5 100644
> --- a/arch/powerpc/include/asm/feature-fixups.h
> +++ b/arch/powerpc/include/asm/feature-fixups.h
> @@ -36,6 +36,24 @@ label##2: \
> .align 2; \
> label##3:
>
> +
> +#ifndef CONFIG_CC_IS_CLANG
> +#define CHECK_ALT_SIZE(else_size, body_size) \
> + .ifgt (else_size) - (body_size); \
> + .error "Feature section else case larger than body"; \
> + .endif;
> +#else
> +/*
> + * If we use the ifgt syntax above, clang's assembler complains about the
> + * expression being non-absolute when the code appears in an inline assembly
> + * statement.
> + * As a workaround use an .org directive that has no effect if the else case
> + * instructions are smaller than the body, but fails otherwise.
> + */
> +#define CHECK_ALT_SIZE(else_size, body_size) \
> + .org . + ((else_size) > (body_size));
> +#endif
> +
> #define MAKE_FTR_SECTION_ENTRY(msk, val, label, sect) \
> label##4: \
> .popsection; \
> @@ -48,9 +66,7 @@ label##5: \
> FTR_ENTRY_OFFSET label##2b-label##5b; \
> FTR_ENTRY_OFFSET label##3b-label##5b; \
> FTR_ENTRY_OFFSET label##4b-label##5b; \
> - .ifgt (label##4b- label##3b)-(label##2b- label##1b); \
> - .error "Feature section else case larger than body"; \
> - .endif; \
> + CHECK_ALT_SIZE((label##4b-label##3b), (label##2b-label##1b)); \
> .popsection;
>
>
>
> I've pushed a branch with all your patches applied to:
>
> https://github.com/linuxppc/linux/commits/next-test
>
This works for me. Thanks!
> Are you able to give that a quick test? It builds clean with clang for
> me, but we must be using different versions of clang because my branch
> already builds clean for me even without your patches.
>
You may need to set LLVM_IAS=1 to get the behavior I'm seeing. That
turns on clang's integrated assembler, which I think is disabled by
default.
Note that with clang's integrated assembler, arch/powerpc/boot/util.S
fails to compile. Alan Modra mentioned that he sent you a patch to
"modernize" the file so that clang can compile it.
-bw
^ permalink raw reply
* [PATCH v6 01/22] powerpc: Add new macro to handle NESTED_IFCLR
From: Aneesh Kumar K.V @ 2020-11-25 5:16 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V
In-Reply-To: <20201125051634.509286-1-aneesh.kumar@linux.ibm.com>
This will be used by the following patches
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/include/asm/feature-fixups.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/powerpc/include/asm/feature-fixups.h b/arch/powerpc/include/asm/feature-fixups.h
index fbd406cd6916..5cdba929a8ae 100644
--- a/arch/powerpc/include/asm/feature-fixups.h
+++ b/arch/powerpc/include/asm/feature-fixups.h
@@ -100,6 +100,9 @@ label##5: \
#define END_MMU_FTR_SECTION_NESTED_IFSET(msk, label) \
END_MMU_FTR_SECTION_NESTED((msk), (msk), label)
+#define END_MMU_FTR_SECTION_NESTED_IFCLR(msk, label) \
+ END_MMU_FTR_SECTION_NESTED((msk), 0, label)
+
#define END_MMU_FTR_SECTION_IFSET(msk) END_MMU_FTR_SECTION((msk), (msk))
#define END_MMU_FTR_SECTION_IFCLR(msk) END_MMU_FTR_SECTION((msk), 0)
--
2.28.0
^ permalink raw reply related
* [PATCH v6 02/22] KVM: PPC: BOOK3S: PR: Ignore UAMOR SPR
From: Aneesh Kumar K.V @ 2020-11-25 5:16 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V
In-Reply-To: <20201125051634.509286-1-aneesh.kumar@linux.ibm.com>
With power7 and above we expect the cpu to support keys. The
number of keys are firmware controlled based on device tree.
PR KVM do not expose key details via device tree. Hence when running with PR KVM
we do run with MMU_FTR_KEY support disabled. But we can still
get updates on UAMOR. Hence ignore access to them and for mfstpr return
0 indicating no AMR/IAMR update is no allowed.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/kvm/book3s_emulate.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/powerpc/kvm/book3s_emulate.c b/arch/powerpc/kvm/book3s_emulate.c
index 0effd48c8f4d..b08cc15f31c7 100644
--- a/arch/powerpc/kvm/book3s_emulate.c
+++ b/arch/powerpc/kvm/book3s_emulate.c
@@ -840,6 +840,9 @@ int kvmppc_core_emulate_mtspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val)
case SPRN_MMCR1:
case SPRN_MMCR2:
case SPRN_UMMCR2:
+ case SPRN_UAMOR:
+ case SPRN_IAMR:
+ case SPRN_AMR:
#endif
break;
unprivileged:
@@ -1004,6 +1007,9 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val
case SPRN_MMCR2:
case SPRN_UMMCR2:
case SPRN_TIR:
+ case SPRN_UAMOR:
+ case SPRN_IAMR:
+ case SPRN_AMR:
#endif
*spr_val = 0;
break;
--
2.28.0
^ permalink raw reply related
* [PATCH v6 00/22] Kernel userspace access/execution prevention with hash translation
From: Aneesh Kumar K.V @ 2020-11-25 5:16 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V
This patch series implements KUAP and KUEP with hash translation mode using
memory keys. The kernel now uses memory protection key 3 to control access
to the kernel. Kernel page table entries are now configured with key 3.
Access to locations configured with any other key value is denied when in
kernel mode (MSR_PR=0). This includes userspace which is by default configured
with key 0.
null-syscall benchmark results:
With smap/smep disabled:
Without patch:
845.29 ns 2451.44 cycles
With patch series:
858.38 ns 2489.30 cycles
With smap/smep enabled:
Without patch:
NA
With patch series:
1021.51 ns 2962.44 cycles
Changes from v5:
* Rework the patch based on suggestion from Michael to avoid the
usage of CONFIG_PPC_PKEY on BOOKE platforms.
Changes from v4:
* Repost with other pkey related changes split out as a separate series.
* Improve null-syscall benchmark by optimizing SPRN save and restore.
Changes from v3:
* Fix build error reported by kernel test robot <lkp@intel.com>
Changes from v2:
* Rebase to the latest kernel.
* Fixed a bug with disabling KUEP/KUAP on kernel command line
* Added a patch to make kup key dynamic.
Changes from V1:
* Rebased on latest kernel
Aneesh Kumar K.V (22):
powerpc: Add new macro to handle NESTED_IFCLR
KVM: PPC: BOOK3S: PR: Ignore UAMOR SPR
powerpc/book3s64/kuap/kuep: Make KUAP and KUEP a subfeature of
PPC_MEM_KEYS
powerpc/book3s64/kuap/kuep: Move uamor setup to pkey init
powerpc/book3s64/kuap: Move KUAP related function outside radix
powerpc/book3s64/kuep: Move KUEP related function outside radix
powerpc/book3s64/kuap: Rename MMU_FTR_RADIX_KUAP to MMU_FTR_KUAP
powerpc/book3s64/kuap: Use Key 3 for kernel mapping with hash
translation
powerpc/exec: Set thread.regs early during exec
powerpc/book3s64/pkeys: Store/restore userspace AMR/IAMR correctly on
entry and exit from kernel
powerpc/book3s64/pkeys: Inherit correctly on fork.
powerpc/book3s64/pkeys: Reset userspace AMR correctly on exec
powerpc/ptrace-view: Use pt_regs values instead of thread_struct based
one.
powerpc/book3s64/pkeys: Don't update SPRN_AMR when in kernel mode.
powerpc/book3s64/kuap: Restrict access to userspace based on userspace
AMR
powerpc/book3s64/kuap: Improve error reporting with KUAP
powerpc/book3s64/kuap: Use Key 3 to implement KUAP with hash
translation.
powerpc/book3s64/kuep: Use Key 3 to implement KUEP with hash
translation.
powerpc/book3s64/hash/kuap: Enable kuap on hash
powerpc/book3s64/hash/kuep: Enable KUEP on hash
powerpc/book3s64/hash/kup: Don't hardcode kup key
powerpc/book3s64/pkeys: Optimize FTR_KUAP and FTR_KUEP disabled case
arch/powerpc/include/asm/book3s/32/kup.h | 4 +-
.../powerpc/include/asm/book3s/64/hash-pkey.h | 10 +-
arch/powerpc/include/asm/book3s/64/hash.h | 2 +-
.../powerpc/include/asm/book3s/64/kup-radix.h | 203 --------
arch/powerpc/include/asm/book3s/64/kup.h | 440 ++++++++++++++++++
arch/powerpc/include/asm/book3s/64/mmu-hash.h | 1 +
arch/powerpc/include/asm/book3s/64/mmu.h | 2 +-
arch/powerpc/include/asm/book3s/64/pkeys.h | 3 +
arch/powerpc/include/asm/feature-fixups.h | 3 +
arch/powerpc/include/asm/kup.h | 8 +-
arch/powerpc/include/asm/mmu.h | 14 +-
arch/powerpc/include/asm/mmu_context.h | 2 +-
arch/powerpc/include/asm/nohash/32/kup-8xx.h | 4 +-
arch/powerpc/include/asm/processor.h | 4 -
arch/powerpc/include/asm/ptrace.h | 12 +-
arch/powerpc/include/asm/thread_info.h | 2 -
arch/powerpc/kernel/asm-offsets.c | 5 +
arch/powerpc/kernel/entry_64.S | 6 +-
arch/powerpc/kernel/exceptions-64s.S | 4 +-
arch/powerpc/kernel/process.c | 58 ++-
arch/powerpc/kernel/ptrace/ptrace-view.c | 7 +-
arch/powerpc/kernel/syscall_64.c | 38 +-
arch/powerpc/kernel/traps.c | 6 -
arch/powerpc/kvm/book3s_emulate.c | 6 +
arch/powerpc/mm/book3s64/Makefile | 2 +-
arch/powerpc/mm/book3s64/hash_4k.c | 2 +-
arch/powerpc/mm/book3s64/hash_64k.c | 4 +-
arch/powerpc/mm/book3s64/hash_hugepage.c | 2 +-
arch/powerpc/mm/book3s64/hash_hugetlbpage.c | 2 +-
arch/powerpc/mm/book3s64/hash_pgtable.c | 2 +-
arch/powerpc/mm/book3s64/hash_utils.c | 10 +-
arch/powerpc/mm/book3s64/pkeys.c | 177 ++++---
arch/powerpc/mm/book3s64/radix_pgtable.c | 47 +-
arch/powerpc/mm/fault.c | 2 +-
arch/powerpc/platforms/Kconfig.cputype | 5 +
35 files changed, 715 insertions(+), 384 deletions(-)
delete mode 100644 arch/powerpc/include/asm/book3s/64/kup-radix.h
create mode 100644 arch/powerpc/include/asm/book3s/64/kup.h
--
2.28.0
^ permalink raw reply
* [PATCH v6 03/22] powerpc/book3s64/kuap/kuep: Make KUAP and KUEP a subfeature of PPC_MEM_KEYS
From: Aneesh Kumar K.V @ 2020-11-25 5:16 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V
In-Reply-To: <20201125051634.509286-1-aneesh.kumar@linux.ibm.com>
The next set of patches adds support for kuap with hash translation.
Hence make KUAP a BOOK3S_64 feature. Also make it a subfeature of
PPC_MEM_KEYS. Hash translation is going to use pkeys to support
KUAP/KUEP. Adding this dependency reduces the code complexity and
enables us to move some of the initialization code to pkeys.c
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
.../powerpc/include/asm/book3s/64/kup-radix.h | 4 ++--
arch/powerpc/include/asm/book3s/64/mmu.h | 2 +-
arch/powerpc/include/asm/ptrace.h | 7 +++++-
arch/powerpc/kernel/asm-offsets.c | 3 +++
arch/powerpc/mm/book3s64/Makefile | 2 +-
arch/powerpc/mm/book3s64/pkeys.c | 24 ++++++++++++-------
arch/powerpc/platforms/Kconfig.cputype | 5 ++++
7 files changed, 33 insertions(+), 14 deletions(-)
diff --git a/arch/powerpc/include/asm/book3s/64/kup-radix.h b/arch/powerpc/include/asm/book3s/64/kup-radix.h
index 28716e2f13e3..68eaa2fac3ab 100644
--- a/arch/powerpc/include/asm/book3s/64/kup-radix.h
+++ b/arch/powerpc/include/asm/book3s/64/kup-radix.h
@@ -16,7 +16,7 @@
#ifdef CONFIG_PPC_KUAP
BEGIN_MMU_FTR_SECTION_NESTED(67)
mfspr \gpr1, SPRN_AMR
- ld \gpr2, STACK_REGS_KUAP(r1)
+ ld \gpr2, STACK_REGS_AMR(r1)
cmpd \gpr1, \gpr2
beq 998f
isync
@@ -48,7 +48,7 @@
bne \msr_pr_cr, 99f
.endif
mfspr \gpr1, SPRN_AMR
- std \gpr1, STACK_REGS_KUAP(r1)
+ std \gpr1, STACK_REGS_AMR(r1)
li \gpr2, (AMR_KUAP_BLOCKED >> AMR_KUAP_SHIFT)
sldi \gpr2, \gpr2, AMR_KUAP_SHIFT
cmpd \use_cr, \gpr1, \gpr2
diff --git a/arch/powerpc/include/asm/book3s/64/mmu.h b/arch/powerpc/include/asm/book3s/64/mmu.h
index e0b52940e43c..a2a015066bae 100644
--- a/arch/powerpc/include/asm/book3s/64/mmu.h
+++ b/arch/powerpc/include/asm/book3s/64/mmu.h
@@ -199,7 +199,7 @@ extern int mmu_io_psize;
void mmu_early_init_devtree(void);
void hash__early_init_devtree(void);
void radix__early_init_devtree(void);
-#ifdef CONFIG_PPC_MEM_KEYS
+#ifdef CONFIG_PPC_PKEY
void pkey_early_init_devtree(void);
#else
static inline void pkey_early_init_devtree(void) {}
diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h
index e2c778c176a3..e7f1caa007a4 100644
--- a/arch/powerpc/include/asm/ptrace.h
+++ b/arch/powerpc/include/asm/ptrace.h
@@ -53,9 +53,14 @@ struct pt_regs
#ifdef CONFIG_PPC64
unsigned long ppr;
#endif
+ union {
#ifdef CONFIG_PPC_KUAP
- unsigned long kuap;
+ unsigned long kuap;
#endif
+#ifdef CONFIG_PPC_PKEY
+ unsigned long amr;
+#endif
+ };
};
unsigned long __pad[2]; /* Maintain 16 byte interrupt stack alignment */
};
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index c2722ff36e98..418a0b314a33 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -354,6 +354,9 @@ int main(void)
STACK_PT_REGS_OFFSET(_PPR, ppr);
#endif /* CONFIG_PPC64 */
+#ifdef CONFIG_PPC_PKEY
+ STACK_PT_REGS_OFFSET(STACK_REGS_AMR, amr);
+#endif
#ifdef CONFIG_PPC_KUAP
STACK_PT_REGS_OFFSET(STACK_REGS_KUAP, kuap);
#endif
diff --git a/arch/powerpc/mm/book3s64/Makefile b/arch/powerpc/mm/book3s64/Makefile
index fd393b8be14f..1b56d3af47d4 100644
--- a/arch/powerpc/mm/book3s64/Makefile
+++ b/arch/powerpc/mm/book3s64/Makefile
@@ -17,7 +17,7 @@ endif
obj-$(CONFIG_TRANSPARENT_HUGEPAGE) += hash_hugepage.o
obj-$(CONFIG_PPC_SUBPAGE_PROT) += subpage_prot.o
obj-$(CONFIG_SPAPR_TCE_IOMMU) += iommu_api.o
-obj-$(CONFIG_PPC_MEM_KEYS) += pkeys.o
+obj-$(CONFIG_PPC_PKEY) += pkeys.o
# Instrumenting the SLB fault path can lead to duplicate SLB entries
KCOV_INSTRUMENT_slb.o := n
diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c
index b1d091a97611..7dc71f85683d 100644
--- a/arch/powerpc/mm/book3s64/pkeys.c
+++ b/arch/powerpc/mm/book3s64/pkeys.c
@@ -89,12 +89,14 @@ static int scan_pkey_feature(void)
}
}
+#ifdef CONFIG_PPC_MEM_KEYS
/*
* Adjust the upper limit, based on the number of bits supported by
* arch-neutral code.
*/
pkeys_total = min_t(int, pkeys_total,
((ARCH_VM_PKEY_FLAGS >> VM_PKEY_SHIFT) + 1));
+#endif
return pkeys_total;
}
@@ -102,6 +104,7 @@ void __init pkey_early_init_devtree(void)
{
int pkeys_total, i;
+#ifdef CONFIG_PPC_MEM_KEYS
/*
* We define PKEY_DISABLE_EXECUTE in addition to the arch-neutral
* generic defines for PKEY_DISABLE_ACCESS and PKEY_DISABLE_WRITE.
@@ -117,7 +120,7 @@ void __init pkey_early_init_devtree(void)
BUILD_BUG_ON(__builtin_clzl(ARCH_VM_PKEY_FLAGS >> VM_PKEY_SHIFT) +
__builtin_popcountl(ARCH_VM_PKEY_FLAGS >> VM_PKEY_SHIFT)
!= (sizeof(u64) * BITS_PER_BYTE));
-
+#endif
/*
* Only P7 and above supports SPRN_AMR update with MSR[PR] = 1
*/
@@ -223,14 +226,6 @@ void __init pkey_early_init_devtree(void)
return;
}
-void pkey_mm_init(struct mm_struct *mm)
-{
- if (!mmu_has_feature(MMU_FTR_PKEY))
- return;
- mm_pkey_allocation_map(mm) = initial_allocation_mask;
- mm->context.execute_only_pkey = execute_only_key;
-}
-
static inline u64 read_amr(void)
{
return mfspr(SPRN_AMR);
@@ -257,6 +252,15 @@ static inline void write_iamr(u64 value)
mtspr(SPRN_IAMR, value);
}
+#ifdef CONFIG_PPC_MEM_KEYS
+void pkey_mm_init(struct mm_struct *mm)
+{
+ if (!mmu_has_feature(MMU_FTR_PKEY))
+ return;
+ mm_pkey_allocation_map(mm) = initial_allocation_mask;
+ mm->context.execute_only_pkey = execute_only_key;
+}
+
static inline void init_amr(int pkey, u8 init_bits)
{
u64 new_amr_bits = (((u64)init_bits & 0x3UL) << pkeyshift(pkey));
@@ -445,3 +449,5 @@ void arch_dup_pkeys(struct mm_struct *oldmm, struct mm_struct *mm)
mm_pkey_allocation_map(mm) = mm_pkey_allocation_map(oldmm);
mm->context.execute_only_pkey = oldmm->context.execute_only_pkey;
}
+
+#endif /* CONFIG_PPC_MEM_KEYS */
diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
index c194c4ae8bc7..f255e8f32155 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -395,6 +395,11 @@ config PPC_KUAP_DEBUG
Add extra debugging for Kernel Userspace Access Protection (KUAP)
If you're unsure, say N.
+config PPC_PKEY
+ def_bool y
+ depends on PPC_BOOK3S_64
+ depends on PPC_MEM_KEYS || PPC_KUAP || PPC_KUEP
+
config ARCH_ENABLE_HUGEPAGE_MIGRATION
def_bool y
depends on PPC_BOOK3S_64 && HUGETLB_PAGE && MIGRATION
--
2.28.0
^ permalink raw reply related
* [PATCH v6 04/22] powerpc/book3s64/kuap/kuep: Move uamor setup to pkey init
From: Aneesh Kumar K.V @ 2020-11-25 5:16 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V
In-Reply-To: <20201125051634.509286-1-aneesh.kumar@linux.ibm.com>
This patch consolidates UAMOR update across pkey, kuap and kuep features.
The boot cpu initialize UAMOR via pkey init and both radix/hash do the
secondary cpu UAMOR init in early_init_mmu_secondary.
We don't check for mmu_feature in radix secondary init because UAMOR
is a supported SPRN with all CPUs supporting radix translation.
The old code was not updating UAMOR if we had smap disabled and smep enabled.
This change handles that case.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/mm/book3s64/radix_pgtable.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c
index 3adcf730f478..bfe441af916a 100644
--- a/arch/powerpc/mm/book3s64/radix_pgtable.c
+++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
@@ -620,9 +620,6 @@ void setup_kuap(bool disabled)
cur_cpu_spec->mmu_features |= MMU_FTR_RADIX_KUAP;
}
- /* Make sure userspace can't change the AMR */
- mtspr(SPRN_UAMOR, 0);
-
/*
* Set the default kernel AMR values on all cpus.
*/
@@ -721,6 +718,11 @@ void radix__early_init_mmu_secondary(void)
radix__switch_mmu_context(NULL, &init_mm);
tlbiel_all();
+
+#ifdef CONFIG_PPC_PKEY
+ /* Make sure userspace can't change the AMR */
+ mtspr(SPRN_UAMOR, 0);
+#endif
}
void radix__mmu_cleanup_all(void)
--
2.28.0
^ permalink raw reply related
* [PATCH v6 05/22] powerpc/book3s64/kuap: Move KUAP related function outside radix
From: Aneesh Kumar K.V @ 2020-11-25 5:16 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V
In-Reply-To: <20201125051634.509286-1-aneesh.kumar@linux.ibm.com>
The next set of patches adds support for kuap with hash translation.
In preparation for that rename/move kuap related functions to
non radix names.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
.../asm/book3s/64/{kup-radix.h => kup.h} | 6 ++---
arch/powerpc/include/asm/kup.h | 4 +++-
arch/powerpc/mm/book3s64/pkeys.c | 22 +++++++++++++++++++
arch/powerpc/mm/book3s64/radix_pgtable.c | 19 ----------------
4 files changed, 28 insertions(+), 23 deletions(-)
rename arch/powerpc/include/asm/book3s/64/{kup-radix.h => kup.h} (97%)
diff --git a/arch/powerpc/include/asm/book3s/64/kup-radix.h b/arch/powerpc/include/asm/book3s/64/kup.h
similarity index 97%
rename from arch/powerpc/include/asm/book3s/64/kup-radix.h
rename to arch/powerpc/include/asm/book3s/64/kup.h
index 68eaa2fac3ab..56dbe3666dc8 100644
--- a/arch/powerpc/include/asm/book3s/64/kup-radix.h
+++ b/arch/powerpc/include/asm/book3s/64/kup.h
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _ASM_POWERPC_BOOK3S_64_KUP_RADIX_H
-#define _ASM_POWERPC_BOOK3S_64_KUP_RADIX_H
+#ifndef _ASM_POWERPC_BOOK3S_64_KUP_H
+#define _ASM_POWERPC_BOOK3S_64_KUP_H
#include <linux/const.h>
#include <asm/reg.h>
@@ -200,4 +200,4 @@ static inline void restore_user_access(unsigned long flags)
}
#endif /* __ASSEMBLY__ */
-#endif /* _ASM_POWERPC_BOOK3S_64_KUP_RADIX_H */
+#endif /* _ASM_POWERPC_BOOK3S_64_KUP_H */
diff --git a/arch/powerpc/include/asm/kup.h b/arch/powerpc/include/asm/kup.h
index 0d93331d0fab..a06e50b68d40 100644
--- a/arch/powerpc/include/asm/kup.h
+++ b/arch/powerpc/include/asm/kup.h
@@ -15,11 +15,13 @@
#define KUAP_CURRENT (KUAP_CURRENT_READ | KUAP_CURRENT_WRITE)
#ifdef CONFIG_PPC_BOOK3S_64
-#include <asm/book3s/64/kup-radix.h>
+#include <asm/book3s/64/kup.h>
#endif
+
#ifdef CONFIG_PPC_8xx
#include <asm/nohash/32/kup-8xx.h>
#endif
+
#ifdef CONFIG_PPC_BOOK3S_32
#include <asm/book3s/32/kup.h>
#endif
diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c
index 7dc71f85683d..c75994cf50a7 100644
--- a/arch/powerpc/mm/book3s64/pkeys.c
+++ b/arch/powerpc/mm/book3s64/pkeys.c
@@ -9,9 +9,12 @@
#include <asm/mmu_context.h>
#include <asm/mmu.h>
#include <asm/setup.h>
+#include <asm/smp.h>
+
#include <linux/pkeys.h>
#include <linux/of_fdt.h>
+
int num_pkey; /* Max number of pkeys supported */
/*
* Keys marked in the reservation list cannot be allocated by userspace
@@ -226,6 +229,25 @@ void __init pkey_early_init_devtree(void)
return;
}
+#ifdef CONFIG_PPC_KUAP
+void __init setup_kuap(bool disabled)
+{
+ if (disabled || !early_radix_enabled())
+ return;
+
+ if (smp_processor_id() == boot_cpuid) {
+ pr_info("Activating Kernel Userspace Access Prevention\n");
+ cur_cpu_spec->mmu_features |= MMU_FTR_RADIX_KUAP;
+ }
+
+ /*
+ * Set the default kernel AMR values on all cpus.
+ */
+ mtspr(SPRN_AMR, AMR_KUAP_BLOCKED);
+ isync();
+}
+#endif
+
static inline u64 read_amr(void)
{
return mfspr(SPRN_AMR);
diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c
index bfe441af916a..cd9872894552 100644
--- a/arch/powerpc/mm/book3s64/radix_pgtable.c
+++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
@@ -609,25 +609,6 @@ void setup_kuep(bool disabled)
}
#endif
-#ifdef CONFIG_PPC_KUAP
-void setup_kuap(bool disabled)
-{
- if (disabled || !early_radix_enabled())
- return;
-
- if (smp_processor_id() == boot_cpuid) {
- pr_info("Activating Kernel Userspace Access Prevention\n");
- cur_cpu_spec->mmu_features |= MMU_FTR_RADIX_KUAP;
- }
-
- /*
- * Set the default kernel AMR values on all cpus.
- */
- mtspr(SPRN_AMR, AMR_KUAP_BLOCKED);
- isync();
-}
-#endif
-
void __init radix__early_init_mmu(void)
{
unsigned long lpcr;
--
2.28.0
^ permalink raw reply related
* [PATCH v6 06/22] powerpc/book3s64/kuep: Move KUEP related function outside radix
From: Aneesh Kumar K.V @ 2020-11-25 5:16 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V
In-Reply-To: <20201125051634.509286-1-aneesh.kumar@linux.ibm.com>
The next set of patches adds support for kuep with hash translation.
In preparation for that rename/move kuap related functions to
non radix names.
Also set MMU_FTR_KUEP and add the missing isync().
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/include/asm/book3s/64/kup.h | 1 +
arch/powerpc/mm/book3s64/pkeys.c | 21 +++++++++++++++++++++
arch/powerpc/mm/book3s64/radix_pgtable.c | 20 --------------------
3 files changed, 22 insertions(+), 20 deletions(-)
diff --git a/arch/powerpc/include/asm/book3s/64/kup.h b/arch/powerpc/include/asm/book3s/64/kup.h
index 56dbe3666dc8..39d2e3a0d64d 100644
--- a/arch/powerpc/include/asm/book3s/64/kup.h
+++ b/arch/powerpc/include/asm/book3s/64/kup.h
@@ -7,6 +7,7 @@
#define AMR_KUAP_BLOCK_READ UL(0x4000000000000000)
#define AMR_KUAP_BLOCK_WRITE UL(0x8000000000000000)
+#define AMR_KUEP_BLOCKED (1UL << 62)
#define AMR_KUAP_BLOCKED (AMR_KUAP_BLOCK_READ | AMR_KUAP_BLOCK_WRITE)
#define AMR_KUAP_SHIFT 62
diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c
index c75994cf50a7..82c722fbce52 100644
--- a/arch/powerpc/mm/book3s64/pkeys.c
+++ b/arch/powerpc/mm/book3s64/pkeys.c
@@ -229,6 +229,27 @@ void __init pkey_early_init_devtree(void)
return;
}
+#ifdef CONFIG_PPC_KUEP
+void __init setup_kuep(bool disabled)
+{
+ if (disabled || !early_radix_enabled())
+ return;
+
+ if (smp_processor_id() == boot_cpuid) {
+ pr_info("Activating Kernel Userspace Execution Prevention\n");
+ cur_cpu_spec->mmu_features |= MMU_FTR_KUEP;
+ }
+
+ /*
+ * Radix always uses key0 of the IAMR to determine if an access is
+ * allowed. We set bit 0 (IBM bit 1) of key0, to prevent instruction
+ * fetch.
+ */
+ mtspr(SPRN_IAMR, AMR_KUEP_BLOCKED);
+ isync();
+}
+#endif
+
#ifdef CONFIG_PPC_KUAP
void __init setup_kuap(bool disabled)
{
diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c
index cd9872894552..fd22a5e9f0ff 100644
--- a/arch/powerpc/mm/book3s64/radix_pgtable.c
+++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
@@ -589,26 +589,6 @@ static void radix_init_amor(void)
mtspr(SPRN_AMOR, (3ul << 62));
}
-#ifdef CONFIG_PPC_KUEP
-void setup_kuep(bool disabled)
-{
- if (disabled || !early_radix_enabled())
- return;
-
- if (smp_processor_id() == boot_cpuid) {
- pr_info("Activating Kernel Userspace Execution Prevention\n");
- cur_cpu_spec->mmu_features |= MMU_FTR_KUEP;
- }
-
- /*
- * Radix always uses key0 of the IAMR to determine if an access is
- * allowed. We set bit 0 (IBM bit 1) of key0, to prevent instruction
- * fetch.
- */
- mtspr(SPRN_IAMR, (1ul << 62));
-}
-#endif
-
void __init radix__early_init_mmu(void)
{
unsigned long lpcr;
--
2.28.0
^ permalink raw reply related
* [PATCH v6 07/22] powerpc/book3s64/kuap: Rename MMU_FTR_RADIX_KUAP to MMU_FTR_KUAP
From: Aneesh Kumar K.V @ 2020-11-25 5:16 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V
In-Reply-To: <20201125051634.509286-1-aneesh.kumar@linux.ibm.com>
This is in preparate to adding support for kuap with hash translation.
In preparation for that rename/move kuap related functions to
non radix names. Also move the feature bit closer to MMU_FTR_KUEP.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/include/asm/book3s/64/kup.h | 18 +++++++++---------
arch/powerpc/include/asm/mmu.h | 14 +++++++-------
arch/powerpc/mm/book3s64/pkeys.c | 2 +-
3 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/arch/powerpc/include/asm/book3s/64/kup.h b/arch/powerpc/include/asm/book3s/64/kup.h
index 39d2e3a0d64d..1d38eab83d48 100644
--- a/arch/powerpc/include/asm/book3s/64/kup.h
+++ b/arch/powerpc/include/asm/book3s/64/kup.h
@@ -24,7 +24,7 @@
mtspr SPRN_AMR, \gpr2
/* No isync required, see kuap_restore_amr() */
998:
- END_MMU_FTR_SECTION_NESTED_IFSET(MMU_FTR_RADIX_KUAP, 67)
+ END_MMU_FTR_SECTION_NESTED_IFSET(MMU_FTR_KUAP, 67)
#endif
.endm
@@ -37,7 +37,7 @@
sldi \gpr2, \gpr2, AMR_KUAP_SHIFT
999: tdne \gpr1, \gpr2
EMIT_BUG_ENTRY 999b, __FILE__, __LINE__, (BUGFLAG_WARNING | BUGFLAG_ONCE)
- END_MMU_FTR_SECTION_NESTED_IFSET(MMU_FTR_RADIX_KUAP, 67)
+ END_MMU_FTR_SECTION_NESTED_IFSET(MMU_FTR_KUAP, 67)
#endif
.endm
#endif
@@ -58,7 +58,7 @@
mtspr SPRN_AMR, \gpr2
isync
99:
- END_MMU_FTR_SECTION_NESTED_IFSET(MMU_FTR_RADIX_KUAP, 67)
+ END_MMU_FTR_SECTION_NESTED_IFSET(MMU_FTR_KUAP, 67)
#endif
.endm
@@ -73,7 +73,7 @@ DECLARE_STATIC_KEY_FALSE(uaccess_flush_key);
static inline void kuap_restore_amr(struct pt_regs *regs, unsigned long amr)
{
- if (mmu_has_feature(MMU_FTR_RADIX_KUAP) && unlikely(regs->kuap != amr)) {
+ if (mmu_has_feature(MMU_FTR_KUAP) && unlikely(regs->kuap != amr)) {
isync();
mtspr(SPRN_AMR, regs->kuap);
/*
@@ -86,7 +86,7 @@ static inline void kuap_restore_amr(struct pt_regs *regs, unsigned long amr)
static inline unsigned long kuap_get_and_check_amr(void)
{
- if (mmu_has_feature(MMU_FTR_RADIX_KUAP)) {
+ if (mmu_has_feature(MMU_FTR_KUAP)) {
unsigned long amr = mfspr(SPRN_AMR);
if (IS_ENABLED(CONFIG_PPC_KUAP_DEBUG)) /* kuap_check_amr() */
WARN_ON_ONCE(amr != AMR_KUAP_BLOCKED);
@@ -97,7 +97,7 @@ static inline unsigned long kuap_get_and_check_amr(void)
static inline void kuap_check_amr(void)
{
- if (IS_ENABLED(CONFIG_PPC_KUAP_DEBUG) && mmu_has_feature(MMU_FTR_RADIX_KUAP))
+ if (IS_ENABLED(CONFIG_PPC_KUAP_DEBUG) && mmu_has_feature(MMU_FTR_KUAP))
WARN_ON_ONCE(mfspr(SPRN_AMR) != AMR_KUAP_BLOCKED);
}
@@ -116,7 +116,7 @@ static inline unsigned long get_kuap(void)
* This has no effect in terms of actually blocking things on hash,
* so it doesn't break anything.
*/
- if (!early_mmu_has_feature(MMU_FTR_RADIX_KUAP))
+ if (!early_mmu_has_feature(MMU_FTR_KUAP))
return AMR_KUAP_BLOCKED;
return mfspr(SPRN_AMR);
@@ -124,7 +124,7 @@ static inline unsigned long get_kuap(void)
static inline void set_kuap(unsigned long value)
{
- if (!early_mmu_has_feature(MMU_FTR_RADIX_KUAP))
+ if (!early_mmu_has_feature(MMU_FTR_KUAP))
return;
/*
@@ -139,7 +139,7 @@ static inline void set_kuap(unsigned long value)
static inline bool
bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write)
{
- return WARN(mmu_has_feature(MMU_FTR_RADIX_KUAP) &&
+ return WARN(mmu_has_feature(MMU_FTR_KUAP) &&
(regs->kuap & (is_write ? AMR_KUAP_BLOCK_WRITE : AMR_KUAP_BLOCK_READ)),
"Bug: %s fault blocked by AMR!", is_write ? "Write" : "Read");
}
diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
index 255a1837e9f7..f5c7a17c198a 100644
--- a/arch/powerpc/include/asm/mmu.h
+++ b/arch/powerpc/include/asm/mmu.h
@@ -28,6 +28,11 @@
* Individual features below.
*/
+/*
+ * Supports KUAP (key 0 controlling userspace addresses) on radix
+ */
+#define MMU_FTR_KUAP ASM_CONST(0x00000200)
+
/*
* Support for KUEP feature.
*/
@@ -120,11 +125,6 @@
*/
#define MMU_FTR_1T_SEGMENT ASM_CONST(0x40000000)
-/*
- * Supports KUAP (key 0 controlling userspace addresses) on radix
- */
-#define MMU_FTR_RADIX_KUAP ASM_CONST(0x80000000)
-
/* MMU feature bit sets for various CPUs */
#define MMU_FTRS_DEFAULT_HPTE_ARCH_V2 \
MMU_FTR_HPTE_TABLE | MMU_FTR_PPCAS_ARCH_V2
@@ -187,10 +187,10 @@ enum {
#ifdef CONFIG_PPC_RADIX_MMU
MMU_FTR_TYPE_RADIX |
MMU_FTR_GTSE |
+#endif /* CONFIG_PPC_RADIX_MMU */
#ifdef CONFIG_PPC_KUAP
- MMU_FTR_RADIX_KUAP |
+ MMU_FTR_KUAP |
#endif /* CONFIG_PPC_KUAP */
-#endif /* CONFIG_PPC_RADIX_MMU */
#ifdef CONFIG_PPC_MEM_KEYS
MMU_FTR_PKEY |
#endif
diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c
index 82c722fbce52..bfc27f1f0ab0 100644
--- a/arch/powerpc/mm/book3s64/pkeys.c
+++ b/arch/powerpc/mm/book3s64/pkeys.c
@@ -258,7 +258,7 @@ void __init setup_kuap(bool disabled)
if (smp_processor_id() == boot_cpuid) {
pr_info("Activating Kernel Userspace Access Prevention\n");
- cur_cpu_spec->mmu_features |= MMU_FTR_RADIX_KUAP;
+ cur_cpu_spec->mmu_features |= MMU_FTR_KUAP;
}
/*
--
2.28.0
^ permalink raw reply related
* [PATCH v6 08/22] powerpc/book3s64/kuap: Use Key 3 for kernel mapping with hash translation
From: Aneesh Kumar K.V @ 2020-11-25 5:16 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V, Sandipan Das
In-Reply-To: <20201125051634.509286-1-aneesh.kumar@linux.ibm.com>
This patch updates kernel hash page table entries to use storage key 3
for its mapping. This implies all kernel access will now use key 3 to
control READ/WRITE. The patch also prevents the allocation of key 3 from
userspace and UAMOR value is updated such that userspace cannot modify key 3.
Reviewed-by: Sandipan Das <sandipan@linux.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
.../powerpc/include/asm/book3s/64/hash-pkey.h | 24 ++++++++++++++-----
arch/powerpc/include/asm/book3s/64/hash.h | 2 +-
arch/powerpc/include/asm/book3s/64/mmu-hash.h | 1 +
arch/powerpc/include/asm/mmu_context.h | 2 +-
arch/powerpc/mm/book3s64/hash_4k.c | 2 +-
arch/powerpc/mm/book3s64/hash_64k.c | 4 ++--
arch/powerpc/mm/book3s64/hash_hugepage.c | 2 +-
arch/powerpc/mm/book3s64/hash_hugetlbpage.c | 2 +-
arch/powerpc/mm/book3s64/hash_pgtable.c | 2 +-
arch/powerpc/mm/book3s64/hash_utils.c | 10 ++++----
arch/powerpc/mm/book3s64/pkeys.c | 4 ++++
11 files changed, 37 insertions(+), 18 deletions(-)
diff --git a/arch/powerpc/include/asm/book3s/64/hash-pkey.h b/arch/powerpc/include/asm/book3s/64/hash-pkey.h
index 795010897e5d..9f44e208f036 100644
--- a/arch/powerpc/include/asm/book3s/64/hash-pkey.h
+++ b/arch/powerpc/include/asm/book3s/64/hash-pkey.h
@@ -2,6 +2,9 @@
#ifndef _ASM_POWERPC_BOOK3S_64_HASH_PKEY_H
#define _ASM_POWERPC_BOOK3S_64_HASH_PKEY_H
+/* We use key 3 for KERNEL */
+#define HASH_DEFAULT_KERNEL_KEY (HPTE_R_KEY_BIT0 | HPTE_R_KEY_BIT1)
+
static inline u64 hash__vmflag_to_pte_pkey_bits(u64 vm_flags)
{
return (((vm_flags & VM_PKEY_BIT0) ? H_PTE_PKEY_BIT0 : 0x0UL) |
@@ -11,13 +14,22 @@ static inline u64 hash__vmflag_to_pte_pkey_bits(u64 vm_flags)
((vm_flags & VM_PKEY_BIT4) ? H_PTE_PKEY_BIT4 : 0x0UL));
}
-static inline u64 pte_to_hpte_pkey_bits(u64 pteflags)
+static inline u64 pte_to_hpte_pkey_bits(u64 pteflags, unsigned long flags)
{
- return (((pteflags & H_PTE_PKEY_BIT4) ? HPTE_R_KEY_BIT4 : 0x0UL) |
- ((pteflags & H_PTE_PKEY_BIT3) ? HPTE_R_KEY_BIT3 : 0x0UL) |
- ((pteflags & H_PTE_PKEY_BIT2) ? HPTE_R_KEY_BIT2 : 0x0UL) |
- ((pteflags & H_PTE_PKEY_BIT1) ? HPTE_R_KEY_BIT1 : 0x0UL) |
- ((pteflags & H_PTE_PKEY_BIT0) ? HPTE_R_KEY_BIT0 : 0x0UL));
+ unsigned long pte_pkey;
+
+ pte_pkey = (((pteflags & H_PTE_PKEY_BIT4) ? HPTE_R_KEY_BIT4 : 0x0UL) |
+ ((pteflags & H_PTE_PKEY_BIT3) ? HPTE_R_KEY_BIT3 : 0x0UL) |
+ ((pteflags & H_PTE_PKEY_BIT2) ? HPTE_R_KEY_BIT2 : 0x0UL) |
+ ((pteflags & H_PTE_PKEY_BIT1) ? HPTE_R_KEY_BIT1 : 0x0UL) |
+ ((pteflags & H_PTE_PKEY_BIT0) ? HPTE_R_KEY_BIT0 : 0x0UL));
+
+ if (mmu_has_feature(MMU_FTR_KUAP) || mmu_has_feature(MMU_FTR_KUEP)) {
+ if ((pte_pkey == 0) && (flags & HPTE_USE_KERNEL_KEY))
+ return HASH_DEFAULT_KERNEL_KEY;
+ }
+
+ return pte_pkey;
}
static inline u16 hash__pte_to_pkey_bits(u64 pteflags)
diff --git a/arch/powerpc/include/asm/book3s/64/hash.h b/arch/powerpc/include/asm/book3s/64/hash.h
index 73ad038ed10b..d959b0195ad9 100644
--- a/arch/powerpc/include/asm/book3s/64/hash.h
+++ b/arch/powerpc/include/asm/book3s/64/hash.h
@@ -145,7 +145,7 @@ extern void hash__mark_initmem_nx(void);
extern void hpte_need_flush(struct mm_struct *mm, unsigned long addr,
pte_t *ptep, unsigned long pte, int huge);
-extern unsigned long htab_convert_pte_flags(unsigned long pteflags);
+unsigned long htab_convert_pte_flags(unsigned long pteflags, unsigned long flags);
/* Atomic PTE updates */
static inline unsigned long hash__pte_update(struct mm_struct *mm,
unsigned long addr,
diff --git a/arch/powerpc/include/asm/book3s/64/mmu-hash.h b/arch/powerpc/include/asm/book3s/64/mmu-hash.h
index 683a9c7d1b03..9192cb05a6ab 100644
--- a/arch/powerpc/include/asm/book3s/64/mmu-hash.h
+++ b/arch/powerpc/include/asm/book3s/64/mmu-hash.h
@@ -452,6 +452,7 @@ static inline unsigned long hpt_hash(unsigned long vpn,
#define HPTE_LOCAL_UPDATE 0x1
#define HPTE_NOHPTE_UPDATE 0x2
+#define HPTE_USE_KERNEL_KEY 0x4
extern int __hash_page_4K(unsigned long ea, unsigned long access,
unsigned long vsid, pte_t *ptep, unsigned long trap,
diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h
index e02aa793420b..4b5e1cb49dce 100644
--- a/arch/powerpc/include/asm/mmu_context.h
+++ b/arch/powerpc/include/asm/mmu_context.h
@@ -284,7 +284,7 @@ static inline bool arch_vma_access_permitted(struct vm_area_struct *vma,
#define thread_pkey_regs_init(thread)
#define arch_dup_pkeys(oldmm, mm)
-static inline u64 pte_to_hpte_pkey_bits(u64 pteflags)
+static inline u64 pte_to_hpte_pkey_bits(u64 pteflags, unsigned long flags)
{
return 0x0UL;
}
diff --git a/arch/powerpc/mm/book3s64/hash_4k.c b/arch/powerpc/mm/book3s64/hash_4k.c
index 22e787123cdf..7de1a8a0c62a 100644
--- a/arch/powerpc/mm/book3s64/hash_4k.c
+++ b/arch/powerpc/mm/book3s64/hash_4k.c
@@ -54,7 +54,7 @@ int __hash_page_4K(unsigned long ea, unsigned long access, unsigned long vsid,
* PP bits. _PAGE_USER is already PP bit 0x2, so we only
* need to add in 0x1 if it's a read-only user page
*/
- rflags = htab_convert_pte_flags(new_pte);
+ rflags = htab_convert_pte_flags(new_pte, flags);
rpte = __real_pte(__pte(old_pte), ptep, PTRS_PER_PTE);
if (cpu_has_feature(CPU_FTR_NOEXECUTE) &&
diff --git a/arch/powerpc/mm/book3s64/hash_64k.c b/arch/powerpc/mm/book3s64/hash_64k.c
index 7084ce2951e6..998c6817ed47 100644
--- a/arch/powerpc/mm/book3s64/hash_64k.c
+++ b/arch/powerpc/mm/book3s64/hash_64k.c
@@ -72,7 +72,7 @@ int __hash_page_4K(unsigned long ea, unsigned long access, unsigned long vsid,
* Handle the subpage protection bits
*/
subpg_pte = new_pte & ~subpg_prot;
- rflags = htab_convert_pte_flags(subpg_pte);
+ rflags = htab_convert_pte_flags(subpg_pte, flags);
if (cpu_has_feature(CPU_FTR_NOEXECUTE) &&
!cpu_has_feature(CPU_FTR_COHERENT_ICACHE)) {
@@ -260,7 +260,7 @@ int __hash_page_64K(unsigned long ea, unsigned long access,
new_pte |= _PAGE_DIRTY;
} while (!pte_xchg(ptep, __pte(old_pte), __pte(new_pte)));
- rflags = htab_convert_pte_flags(new_pte);
+ rflags = htab_convert_pte_flags(new_pte, flags);
rpte = __real_pte(__pte(old_pte), ptep, PTRS_PER_PTE);
if (cpu_has_feature(CPU_FTR_NOEXECUTE) &&
diff --git a/arch/powerpc/mm/book3s64/hash_hugepage.c b/arch/powerpc/mm/book3s64/hash_hugepage.c
index 440823797de7..c0fabe6c5a12 100644
--- a/arch/powerpc/mm/book3s64/hash_hugepage.c
+++ b/arch/powerpc/mm/book3s64/hash_hugepage.c
@@ -57,7 +57,7 @@ int __hash_page_thp(unsigned long ea, unsigned long access, unsigned long vsid,
if (!(old_pmd & (H_PAGE_THP_HUGE | _PAGE_DEVMAP)))
return 0;
- rflags = htab_convert_pte_flags(new_pmd);
+ rflags = htab_convert_pte_flags(new_pmd, flags);
#if 0
if (!cpu_has_feature(CPU_FTR_COHERENT_ICACHE)) {
diff --git a/arch/powerpc/mm/book3s64/hash_hugetlbpage.c b/arch/powerpc/mm/book3s64/hash_hugetlbpage.c
index 964467b3a776..b5e9fff8c217 100644
--- a/arch/powerpc/mm/book3s64/hash_hugetlbpage.c
+++ b/arch/powerpc/mm/book3s64/hash_hugetlbpage.c
@@ -70,7 +70,7 @@ int __hash_page_huge(unsigned long ea, unsigned long access, unsigned long vsid,
if (old_pte & (H_PAGE_THP_HUGE | _PAGE_DEVMAP))
return 0;
- rflags = htab_convert_pte_flags(new_pte);
+ rflags = htab_convert_pte_flags(new_pte, flags);
if (unlikely(mmu_psize == MMU_PAGE_16G))
offset = PTRS_PER_PUD;
else
diff --git a/arch/powerpc/mm/book3s64/hash_pgtable.c b/arch/powerpc/mm/book3s64/hash_pgtable.c
index fd9c7f91b092..567e0c6b3978 100644
--- a/arch/powerpc/mm/book3s64/hash_pgtable.c
+++ b/arch/powerpc/mm/book3s64/hash_pgtable.c
@@ -443,7 +443,7 @@ void hash__mark_initmem_nx(void)
start = (unsigned long)__init_begin;
end = (unsigned long)__init_end;
- pp = htab_convert_pte_flags(pgprot_val(PAGE_KERNEL));
+ pp = htab_convert_pte_flags(pgprot_val(PAGE_KERNEL), HPTE_USE_KERNEL_KEY);
WARN_ON(!hash__change_memory_range(start, end, pp));
}
diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s64/hash_utils.c
index 24702c0a92e0..41ab053e17c9 100644
--- a/arch/powerpc/mm/book3s64/hash_utils.c
+++ b/arch/powerpc/mm/book3s64/hash_utils.c
@@ -186,7 +186,7 @@ static struct mmu_psize_def mmu_psize_defaults_gp[] = {
* - We make sure R is always set and never lost
* - C is _PAGE_DIRTY, and *should* always be set for a writeable mapping
*/
-unsigned long htab_convert_pte_flags(unsigned long pteflags)
+unsigned long htab_convert_pte_flags(unsigned long pteflags, unsigned long flags)
{
unsigned long rflags = 0;
@@ -240,7 +240,7 @@ unsigned long htab_convert_pte_flags(unsigned long pteflags)
*/
rflags |= HPTE_R_M;
- rflags |= pte_to_hpte_pkey_bits(pteflags);
+ rflags |= pte_to_hpte_pkey_bits(pteflags, flags);
return rflags;
}
@@ -255,7 +255,7 @@ int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
shift = mmu_psize_defs[psize].shift;
step = 1 << shift;
- prot = htab_convert_pte_flags(prot);
+ prot = htab_convert_pte_flags(prot, HPTE_USE_KERNEL_KEY);
DBG("htab_bolt_mapping(%lx..%lx -> %lx (%lx,%d,%d)\n",
vstart, vend, pstart, prot, psize, ssize);
@@ -1317,12 +1317,14 @@ int hash_page_mm(struct mm_struct *mm, unsigned long ea,
vsid = get_kernel_vsid(ea, mmu_kernel_ssize);
psize = mmu_vmalloc_psize;
ssize = mmu_kernel_ssize;
+ flags |= HPTE_USE_KERNEL_KEY;
break;
case IO_REGION_ID:
vsid = get_kernel_vsid(ea, mmu_kernel_ssize);
psize = mmu_io_psize;
ssize = mmu_kernel_ssize;
+ flags |= HPTE_USE_KERNEL_KEY;
break;
default:
/*
@@ -1901,7 +1903,7 @@ static void kernel_map_linear_page(unsigned long vaddr, unsigned long lmi)
unsigned long hash;
unsigned long vsid = get_kernel_vsid(vaddr, mmu_kernel_ssize);
unsigned long vpn = hpt_vpn(vaddr, vsid, mmu_kernel_ssize);
- unsigned long mode = htab_convert_pte_flags(pgprot_val(PAGE_KERNEL));
+ unsigned long mode = htab_convert_pte_flags(pgprot_val(PAGE_KERNEL), HPTE_USE_KERNEL_KEY);
long ret;
hash = hpt_hash(vpn, PAGE_SHIFT, mmu_kernel_ssize);
diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c
index bfc27f1f0ab0..640f090b9f9d 100644
--- a/arch/powerpc/mm/book3s64/pkeys.c
+++ b/arch/powerpc/mm/book3s64/pkeys.c
@@ -205,6 +205,10 @@ void __init pkey_early_init_devtree(void)
reserved_allocation_mask |= (0x1 << 1);
default_uamor &= ~(0x3ul << pkeyshift(1));
+ /* handle key 3 which is used by kernel for KAUP */
+ reserved_allocation_mask |= (0x1 << 3);
+ default_uamor &= ~(0x3ul << pkeyshift(3));
+
/*
* Prevent the usage of OS reserved keys. Update UAMOR
* for those keys. Also mark the rest of the bits in the
--
2.28.0
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox