* Re: [PATCH v4 1/2] module: add elf_check_module_arch for module specific elf arch checks
From: Segher Boessenkool @ 2021-06-15 12:50 UTC (permalink / raw)
To: Jessica Yu
Cc: Michal Suchánek, linuxppc-dev, linux-kernel, Nicholas Piggin
In-Reply-To: <YMiaZOqhHck9iy0n@p200300cbcf109700df096d564fe976c3.dip0.t-ipconnect.de>
On Tue, Jun 15, 2021 at 02:17:40PM +0200, Jessica Yu wrote:
> +int __weak elf_check_module_arch(Elf_Ehdr *hdr)
> +{
> + return 1;
> +}
But is this a good idea? It isn't useful to be able to attempt to load
a module not compiled for your architecture, and it increases the attack
surface tremendously. These checks are one of the few things that can
*not* be weak symbols, imo.
Segher
^ permalink raw reply
* Re: [PATCH 0/5] cpufreq: cppc: Fix suspend/resume specific races with FIE code
From: Qian Cai @ 2021-06-15 12:17 UTC (permalink / raw)
To: Viresh Kumar
Cc: linuxppc-dev, Vincent Guittot, linux-doc, Jonathan Corbet,
Dirk Brandewie, linux-pm, Srinivas Pandruvada, Rafael Wysocki,
linux-kernel, Paul Mackerras, Ionela Voinescu, Len Brown
In-Reply-To: <20210615075056.dfkbiftuoihtrfpo@vireshk-i7>
On 6/15/2021 3:50 AM, Viresh Kumar wrote:
> Hi Qian,
>
> First of all thanks for testing this, I need more of your help to test
> this out :)
>
> FWIW, I did test this on my Hikey board today, with some hacks, and
> tried multiple insmod/rmmod operations for the driver, and I wasn't
> able to reproduce the issue you reported. I did enable the list-debug
> config option.
The setup here is an arm64 server with 32 CPUs.
>
> On 14-06-21, 09:48, Qian Cai wrote:
>> Unfortunately, this series looks like needing more works.
>>
>> [ 487.773586][ T0] CPU17: Booted secondary processor 0x0000000801 [0x503f0002]
>> [ 487.976495][ T670] list_del corruption. next->prev should be ffff009b66e9ec70, but was ffff009b66dfec70
>> [ 487.987037][ T670] ------------[ cut here ]------------
>> [ 487.992351][ T670] kernel BUG at lib/list_debug.c:54!
>> [ 487.997810][ T670] Internal error: Oops - BUG: 0 [#1] SMP
>> [ 488.003295][ T670] Modules linked in: cpufreq_userspace xfs loop cppc_cpufreq processor efivarfs ip_tables x_tables ext4 mbcache jbd2 dm_mod igb i2c_algo_bit nvme mlx5_core i2c_core nvme_core firmware_class
>> [ 488.021759][ T670] CPU: 1 PID: 670 Comm: cppc_fie Not tainted 5.13.0-rc5-next-20210611+ #46
>> [ 488.030190][ T670] Hardware name: MiTAC RAPTOR EV-883832-X3-0001/RAPTOR, BIOS 1.6 06/28/2020
>> [ 488.038705][ T670] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO BTYPE=--)
>> [ 488.045398][ T670] pc : __list_del_entry_valid+0x154/0x158
>> [ 488.050969][ T670] lr : __list_del_entry_valid+0x154/0x158
>> [ 488.056534][ T670] sp : ffff8000229afd70
>> [ 488.060534][ T670] x29: ffff8000229afd70 x28: ffff0008c8f4f340 x27: dfff800000000000
>> [ 488.068361][ T670] x26: ffff009b66e9ec70 x25: ffff800011c8b4d0 x24: ffff0008d4bfe488
>> [ 488.076188][ T670] x23: ffff0008c8f4f340 x22: ffff0008c8f4f340 x21: ffff009b6789ec70
>> [ 488.084015][ T670] x20: ffff0008d4bfe4c8 x19: ffff009b66e9ec70 x18: ffff0008c8f4fd70
>> [ 488.091842][ T670] x17: 20747562202c3037 x16: 6365396536366239 x15: 0000000000000028
>> [ 488.099669][ T670] x14: 0000000000000000 x13: 0000000000000001 x12: ffff60136cdd3447
>> [ 488.107495][ T670] x11: 1fffe0136cdd3446 x10: ffff60136cdd3446 x9 : ffff8000103ee444
>> [ 488.115322][ T670] x8 : ffff009b66e9a237 x7 : 0000000000000001 x6 : ffff009b66e9a230
>> [ 488.123149][ T670] x5 : 00009fec9322cbba x4 : ffff60136cdd3447 x3 : 1fffe001191e9e69
>> [ 488.130975][ T670] x2 : 0000000000000000 x1 : 0000000000000000 x0 : 0000000000000054
>> [ 488.138803][ T670] Call trace:
>> [ 488.141935][ T670] __list_del_entry_valid+0x154/0x158
>> [ 488.147153][ T670] kthread_worker_fn+0x15c/0xda0
>
> This is a strange place to get the issue from. And this is a new
> issue.
Well, it was still the same exercises with CPU online/offline.
>
>> [ 488.151939][ T670] kthread+0x3ac/0x460
>> [ 488.155854][ T670] ret_from_fork+0x10/0x18
>> [ 488.160120][ T670] Code: 911e8000 aa1303e1 910a0000 941b595b (d4210000)
>> [ 488.166901][ T670] ---[ end trace e637e2d38b2cc087 ]---
>> [ 488.172206][ T670] Kernel panic - not syncing: Oops - BUG: Fatal exception
>> [ 488.179182][ T670] SMP: stopping secondary CPUs
>> [ 489.209347][ T670] SMP: failed to stop secondary CPUs 0-1,10-11,16-17,31
>> [ 489.216128][ T][ T670] Memoryn ]---
>
> Can you give details on what exactly did you try to do, to get this ?
> Normal boot or something more ?
Basically, it has the cpufreq driver as CPPC and the governor as schedutil. Running a few workloads to get CPU scaling up and down. Later, try to offline all CPUs until the last one and then online all CPUs.
>
> I have made some changes to the way calls were happening, may get this
> thing sorted. Can you please try this branch ?
>
> https://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm.git/log/?h=cpufreq/cppc
>
> I can see one place where race can happen, i.e. between
> topology_clear_scale_freq_source() and topology_scale_freq_tick(). It
> is possible that sfd->set_freq_scale() may get called for a previously
> set handler as there is no protection there.
>
> I will see how to fix that. But I am not sure if the issue reported
> above comes from there.
>
> Anyway, please give my branch a try, lets see.
I am hesitate to try this at the moment because this all feel like shooting in the dark. Ideally, you will be able to get access to one of those arm64 servers (Huawei, Ampere, TX2, FJ etc) eventually and really try the same exercises yourself with those debugging options like list debugging and KASAN on. That way you could fix things way efficiently. I could share you the .config once you are there. Last but not least, once you get better narrow down of the issues, I'd hope to see someone else familiar with the code there to get review of those patches first (feel free to Cc me once you are ready to post) before I'll rerun the whole things again. That way we don't waste time on each other backing and forth chasing the shadow.
^ permalink raw reply
* Re: [PATCH v19 05/13] of: Add a common kexec FDT setup function
From: Geert Uytterhoeven @ 2021-06-15 12:17 UTC (permalink / raw)
To: Lakshmi Ramasubramanian, Rob Herring
Cc: Mark Rutland, tao.li, Mimi Zohar, Paul Mackerras,
Vincenzo Frascino, Frank Rowand, Sasha Levin, Stephen Rothwell,
Masahiro Yamada, James Morris, AKASHI Takahiro, Linux ARM,
Catalin Marinas, Serge E. Hallyn,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
Pavel Tatashin, Will Deacon, prsriva, Hsin-Yi Wang,
Allison Randal, Christophe Leroy, Matthias Brugger, balajib,
dmitry.kasatkin, Linux Kernel Mailing List, James Morse, Greg KH,
Joe Perches, linux-integrity, linuxppc-dev, Thiago Jung Bauermann
In-Reply-To: <20210221174930.27324-6-nramas@linux.microsoft.com>
Hi Lakshmi and Rob,
On Sun, Feb 21, 2021 at 6:52 PM Lakshmi Ramasubramanian
<nramas@linux.microsoft.com> wrote:
> From: Rob Herring <robh@kernel.org>
>
> Both arm64 and powerpc do essentially the same FDT /chosen setup for
> kexec. The differences are either omissions that arm64 should have
> or additional properties that will be ignored. The setup code can be
> combined and shared by both powerpc and arm64.
>
> The differences relative to the arm64 version:
> - If /chosen doesn't exist, it will be created (should never happen).
> - Any old dtb and initrd reserved memory will be released.
> - The new initrd and elfcorehdr are marked reserved.
> - "linux,booted-from-kexec" is set.
>
> The differences relative to the powerpc version:
> - "kaslr-seed" and "rng-seed" may be set.
> - "linux,elfcorehdr" is set.
> - Any existing "linux,usable-memory-range" is removed.
>
> Combine the code for setting up the /chosen node in the FDT and updating
> the memory reservation for kexec, for powerpc and arm64, in
> of_kexec_alloc_and_setup_fdt() and move it to "drivers/of/kexec.c".
>
> Signed-off-by: Rob Herring <robh@kernel.org>
> Signed-off-by: Lakshmi Ramasubramanian <nramas@linux.microsoft.com>
> --- /dev/null
> +++ b/drivers/of/kexec.c
> +/*
> + * of_kexec_alloc_and_setup_fdt - Alloc and setup a new Flattened Device Tree
> + *
> + * @image: kexec image being loaded.
> + * @initrd_load_addr: Address where the next initrd will be loaded.
> + * @initrd_len: Size of the next initrd, or 0 if there will be none.
> + * @cmdline: Command line for the next kernel, or NULL if there will
> + * be none.
> + * @extra_fdt_size: Additional size for the new FDT buffer.
> + *
> + * Return: fdt on success, or NULL errno on error.
> + */
> +void *of_kexec_alloc_and_setup_fdt(const struct kimage *image,
> + unsigned long initrd_load_addr,
> + unsigned long initrd_len,
> + const char *cmdline, size_t extra_fdt_size)
> +{
> + /* Did we boot using an initrd? */
> + prop = fdt_getprop(fdt, chosen_node, "linux,initrd-start", NULL);
> + if (prop) {
> + u64 tmp_start, tmp_end, tmp_size;
> +
> + tmp_start = fdt64_to_cpu(*((const fdt64_t *) prop));
> +
> + prop = fdt_getprop(fdt, chosen_node, "linux,initrd-end", NULL);
> + if (!prop) {
> + ret = -EINVAL;
> + goto out;
> + }
> +
> + tmp_end = fdt64_to_cpu(*((const fdt64_t *) prop));
Some kernel code assumes "linux,initrd-{start,end}" are 64-bit,
other code assumes 32-bit.
linux/Documentation/arm/uefi.rst says 64-bit,
dt-schema/schemas/chosen.yaml says 32-bit.
> +
> + /*
> + * kexec reserves exact initrd size, while firmware may
> + * reserve a multiple of PAGE_SIZE, so check for both.
> + */
> + tmp_size = tmp_end - tmp_start;
> + ret = fdt_find_and_del_mem_rsv(fdt, tmp_start, tmp_size);
> + if (ret == -ENOENT)
> + ret = fdt_find_and_del_mem_rsv(fdt, tmp_start,
> + round_up(tmp_size, PAGE_SIZE));
> + if (ret == -EINVAL)
> + goto out;
> + }
> +
> + /* add initrd-* */
> + if (initrd_load_addr) {
> + ret = fdt_setprop_u64(fdt, chosen_node, FDT_PROP_INITRD_START,
> + initrd_load_addr);
> + if (ret)
> + goto out;
> +
> + ret = fdt_setprop_u64(fdt, chosen_node, FDT_PROP_INITRD_END,
> + initrd_load_addr + initrd_len);
> + if (ret)
> + goto out;
> +
> + ret = fdt_add_mem_rsv(fdt, initrd_load_addr, initrd_len);
> + if (ret)
> + goto out;
> +
> + } else {
> + ret = fdt_delprop(fdt, chosen_node, FDT_PROP_INITRD_START);
> + if (ret && (ret != -FDT_ERR_NOTFOUND))
> + goto out;
> +
> + ret = fdt_delprop(fdt, chosen_node, FDT_PROP_INITRD_END);
> + if (ret && (ret != -FDT_ERR_NOTFOUND))
> + goto out;
> + }
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply
* Re: [PATCH v4 1/2] module: add elf_check_module_arch for module specific elf arch checks
From: Jessica Yu @ 2021-06-15 12:17 UTC (permalink / raw)
To: Nicholas Piggin; +Cc: Michal Suchánek, linuxppc-dev, linux-kernel
In-Reply-To: <1623722110.amu32mwaqs.astroid@bobo.none>
+++ Nicholas Piggin [15/06/21 12:05 +1000]:
>Excerpts from Jessica Yu's message of June 14, 2021 10:06 pm:
>> +++ Nicholas Piggin [11/06/21 19:39 +1000]:
>>>The elf_check_arch() function is used to test usermode binaries, but
>>>kernel modules may have more specific requirements. powerpc would like
>>>to test for ABI version compatibility.
>>>
>>>Add an arch-overridable function elf_check_module_arch() that defaults
>>>to elf_check_arch() and use it in elf_validity_check().
>>>
>>>Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
>>>[np: split patch, added changelog]
>>>Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>>>---
>>> include/linux/moduleloader.h | 5 +++++
>>> kernel/module.c | 2 +-
>>> 2 files changed, 6 insertions(+), 1 deletion(-)
>>>
>>>diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
>>>index 9e09d11ffe5b..fdc042a84562 100644
>>>--- a/include/linux/moduleloader.h
>>>+++ b/include/linux/moduleloader.h
>>>@@ -13,6 +13,11 @@
>>> * must be implemented by each architecture.
>>> */
>>>
>>>+// Allow arch to optionally do additional checking of module ELF header
>>>+#ifndef elf_check_module_arch
>>>+#define elf_check_module_arch elf_check_arch
>>>+#endif
>>
>> Hi Nicholas,
>>
>> Why not make elf_check_module_arch() consistent with the other
>> arch-specific functions? Please see module_frob_arch_sections(),
>> module_{init,exit}_section(), etc in moduleloader.h. That is, they are
>> all __weak functions that are overridable by arches. We can maybe make
>> elf_check_module_arch() a weak symbol, available for arches to
>> override if they want to perform additional elf checks. Then we don't
>> have to have this one-off #define.
>
>
>Like this? I like it. Good idea.
Yeah! Also, maybe we can alternatively make elf_check_module_arch() a
separate check entirely so that the powerpc implementation doesn't
have to include that extra elf_check_arch() call. Something like this maybe?
diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
index 9e09d11ffe5b..2f9ebd593b4f 100644
--- a/include/linux/moduleloader.h
+++ b/include/linux/moduleloader.h
@@ -39,6 +39,9 @@ bool module_init_section(const char *name);
*/
bool module_exit_section(const char *name);
+/* Arch may override to do additional checking of ELF header architecture */
+int elf_check_module_arch(Elf_Ehdr *hdr);
+
/*
* Apply the given relocation to the (simplified) ELF. Return -error
* or 0.
diff --git a/kernel/module.c b/kernel/module.c
index fdd6047728df..9963a979ed54 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2923,6 +2923,11 @@ static int validate_section_offset(struct load_info *info, Elf_Shdr *shdr)
return 0;
}
+int __weak elf_check_module_arch(Elf_Ehdr *hdr)
+{
+ return 1;
+}
+
/*
* Sanity checks against invalid binaries, wrong arch, weird elf version.
*
@@ -2941,6 +2946,7 @@ static int elf_validity_check(struct load_info *info)
if (memcmp(info->hdr->e_ident, ELFMAG, SELFMAG) != 0
|| info->hdr->e_type != ET_REL
|| !elf_check_arch(info->hdr)
+ || !elf_check_module_arch(info->hdr)
|| info->hdr->e_shentsize != sizeof(Elf_Shdr))
return -ENOEXEC;
^ permalink raw reply related
* Re: [PATCH v2 1/2] mm: rename pud_page_vaddr to pud_pgtable and make it return pmd_t *
From: Geert Uytterhoeven @ 2021-06-15 11:41 UTC (permalink / raw)
To: Aneesh Kumar K.V
Cc: Linux-Arch, linux-ia64@vger.kernel.org, Parisc List,
Linux-sh list, linuxppc-dev, linux-um, Linux Kernel Mailing List,
open list:BROADCOM NVRAM DRIVER, Linux MM, linux-m68k, alpha,
sparclinux, Andrew Morton, Linus Torvalds, linux-riscv, Linux ARM
In-Reply-To: <20210615110859.320299-1-aneesh.kumar@linux.ibm.com>
On Tue, Jun 15, 2021 at 1:32 PM Aneesh Kumar K.V
<aneesh.kumar@linux.ibm.com> wrote:
> No functional change in this patch.
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> arch/m68k/include/asm/motorola_pgtable.h | 2 +-
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply
* [powerpc:merge] BUILD SUCCESS 419dfbc3e05d80c5f6d6856534cd0a21c22c22de
From: kernel test robot @ 2021-06-15 11:37 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git merge
branch HEAD: 419dfbc3e05d80c5f6d6856534cd0a21c22c22de Automatic merge of 'master' into merge (2021-06-07 11:03)
elapsed time: 12103m
configs tested: 181
configs skipped: 2
The following configs have been built successfully.
More configs may be tested in the coming days.
gcc tested configs:
arm defconfig
arm64 allyesconfig
arm64 defconfig
arm allyesconfig
arm allmodconfig
arm cm_x300_defconfig
sh alldefconfig
powerpc ebony_defconfig
sh edosk7760_defconfig
sparc sparc32_defconfig
mips lemote2f_defconfig
powerpc motionpro_defconfig
arm moxart_defconfig
sh sh03_defconfig
powerpc pseries_defconfig
m68k mvme147_defconfig
um alldefconfig
powerpc amigaone_defconfig
powerpc fsp2_defconfig
powerpc ppc64e_defconfig
powerpc katmai_defconfig
m68k hp300_defconfig
ia64 defconfig
powerpc tqm8560_defconfig
mips vocore2_defconfig
mips cobalt_defconfig
mips bcm63xx_defconfig
powerpc mpc866_ads_defconfig
sh polaris_defconfig
mips maltasmvp_eva_defconfig
sh dreamcast_defconfig
powerpc powernv_defconfig
powerpc mpc832x_mds_defconfig
arm s3c2410_defconfig
arm nhk8815_defconfig
powerpc chrp32_defconfig
nios2 10m50_defconfig
arm omap1_defconfig
csky defconfig
sh magicpanelr2_defconfig
sh sh7724_generic_defconfig
powerpc tqm8555_defconfig
mips bmips_be_defconfig
arm realview_defconfig
m68k mac_defconfig
x86_64 allnoconfig
powerpc tqm8548_defconfig
powerpc tqm8540_defconfig
arm sunxi_defconfig
sh kfr2r09-romimage_defconfig
arm s3c6400_defconfig
sh sdk7780_defconfig
mips jazz_defconfig
powerpc mpc85xx_cds_defconfig
mips bigsur_defconfig
powerpc taishan_defconfig
arm ixp4xx_defconfig
mips nlm_xlp_defconfig
arm64 alldefconfig
mips maltaup_defconfig
m68k m5275evb_defconfig
powerpc kmeter1_defconfig
powerpc lite5200b_defconfig
um defconfig
powerpc mpc8315_rdb_defconfig
sh se7721_defconfig
mips malta_kvm_defconfig
arm pcm027_defconfig
powerpc ppc40x_defconfig
arm simpad_defconfig
sh rsk7201_defconfig
powerpc mpc8272_ads_defconfig
powerpc walnut_defconfig
m68k mvme16x_defconfig
arm mv78xx0_defconfig
arm dove_defconfig
mips maltasmvp_defconfig
xtensa defconfig
arm multi_v7_defconfig
ia64 allmodconfig
ia64 allyesconfig
m68k allmodconfig
m68k defconfig
m68k allyesconfig
nds32 defconfig
nios2 allyesconfig
alpha defconfig
alpha allyesconfig
xtensa allyesconfig
h8300 allyesconfig
arc defconfig
sh allmodconfig
parisc defconfig
s390 allyesconfig
s390 allmodconfig
parisc allyesconfig
s390 defconfig
i386 allyesconfig
sparc allyesconfig
sparc defconfig
i386 defconfig
nios2 defconfig
arc allyesconfig
nds32 allnoconfig
mips allyesconfig
mips allmodconfig
powerpc allyesconfig
powerpc allmodconfig
powerpc allnoconfig
i386 randconfig-a002-20210613
i386 randconfig-a006-20210613
i386 randconfig-a001-20210613
i386 randconfig-a004-20210613
i386 randconfig-a005-20210613
i386 randconfig-a003-20210613
i386 randconfig-a003-20210606
i386 randconfig-a006-20210606
i386 randconfig-a004-20210606
i386 randconfig-a001-20210606
i386 randconfig-a005-20210606
i386 randconfig-a002-20210606
i386 randconfig-a003-20210607
i386 randconfig-a006-20210607
i386 randconfig-a004-20210607
i386 randconfig-a001-20210607
i386 randconfig-a002-20210607
i386 randconfig-a005-20210607
x86_64 randconfig-a015-20210607
x86_64 randconfig-a011-20210607
x86_64 randconfig-a014-20210607
x86_64 randconfig-a012-20210607
x86_64 randconfig-a016-20210607
x86_64 randconfig-a013-20210607
i386 randconfig-a015-20210613
i386 randconfig-a013-20210613
i386 randconfig-a016-20210613
i386 randconfig-a014-20210613
i386 randconfig-a012-20210613
i386 randconfig-a011-20210613
i386 randconfig-a015-20210607
i386 randconfig-a013-20210607
i386 randconfig-a011-20210607
i386 randconfig-a016-20210607
i386 randconfig-a014-20210607
i386 randconfig-a012-20210607
riscv nommu_k210_defconfig
riscv allyesconfig
riscv nommu_virt_defconfig
riscv allnoconfig
riscv defconfig
riscv rv32_defconfig
riscv allmodconfig
um x86_64_defconfig
um i386_defconfig
um kunit_defconfig
x86_64 allyesconfig
x86_64 rhel-8.3-kselftests
x86_64 defconfig
x86_64 rhel-8.3
x86_64 rhel-8.3-kbuiltin
x86_64 kexec
clang tested configs:
x86_64 randconfig-b001-20210607
x86_64 randconfig-b001-20210614
x86_64 randconfig-a001-20210614
x86_64 randconfig-a004-20210614
x86_64 randconfig-a002-20210614
x86_64 randconfig-a003-20210614
x86_64 randconfig-a006-20210614
x86_64 randconfig-a005-20210614
x86_64 randconfig-a002-20210607
x86_64 randconfig-a004-20210607
x86_64 randconfig-a003-20210607
x86_64 randconfig-a006-20210607
x86_64 randconfig-a005-20210607
x86_64 randconfig-a001-20210607
x86_64 randconfig-a015-20210613
x86_64 randconfig-a011-20210613
x86_64 randconfig-a014-20210613
x86_64 randconfig-a012-20210613
x86_64 randconfig-a013-20210613
x86_64 randconfig-a016-20210613
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply
* [PATCH v2 1/2] mm: rename pud_page_vaddr to pud_pgtable and make it return pmd_t *
From: Aneesh Kumar K.V @ 2021-06-15 11:08 UTC (permalink / raw)
To: linux-mm
Cc: linux-arch, linux-ia64, linux-parisc, linux-sh, Aneesh Kumar K.V,
linuxppc-dev, linux-um, linux-kernel, linux-mips, linux-m68k,
linux-alpha, sparclinux, akpm, Linus Torvalds, linux-riscv,
linux-arm-kernel
No functional change in this patch.
Cc: linux-alpha@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-ia64@vger.kernel.org
Cc: linux-m68k@lists.linux-m68k.org
Cc: linux-mips@vger.kernel.org
Cc: linux-parisc@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-riscv@lists.infradead.org
Cc: linux-sh@vger.kernel.org
Cc: sparclinux@vger.kernel.org
Cc: linux-um@lists.infradead.org
Cc: linux-arch@vger.kernel.org
Link: https://lore.kernel.org/linuxppc-dev/CAHk-=wi+J+iodze9FtjM3Zi4j4OeS+qqbKxME9QN4roxPEXH9Q@mail.gmail.com/
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/alpha/include/asm/pgtable.h | 8 +++++---
arch/arm/include/asm/pgtable-3level.h | 2 +-
arch/arm64/include/asm/pgtable.h | 4 ++--
arch/ia64/include/asm/pgtable.h | 2 +-
arch/m68k/include/asm/motorola_pgtable.h | 2 +-
arch/mips/include/asm/pgtable-64.h | 4 ++--
arch/parisc/include/asm/pgtable.h | 4 ++--
arch/powerpc/include/asm/book3s/64/pgtable.h | 6 +++++-
arch/powerpc/include/asm/nohash/64/pgtable.h | 6 +++++-
arch/powerpc/mm/book3s64/radix_pgtable.c | 4 ++--
arch/powerpc/mm/pgtable_64.c | 2 +-
arch/riscv/include/asm/pgtable-64.h | 4 ++--
arch/sh/include/asm/pgtable-3level.h | 4 ++--
arch/sparc/include/asm/pgtable_32.h | 4 ++--
arch/sparc/include/asm/pgtable_64.h | 6 +++---
arch/um/include/asm/pgtable-3level.h | 2 +-
arch/x86/include/asm/pgtable.h | 4 ++--
arch/x86/mm/pat/set_memory.c | 4 ++--
arch/x86/mm/pgtable.c | 2 +-
include/asm-generic/pgtable-nopmd.h | 2 +-
include/asm-generic/pgtable-nopud.h | 2 +-
include/linux/pgtable.h | 2 +-
22 files changed, 45 insertions(+), 35 deletions(-)
diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
index 8d856c62e22a..be02e4e403d1 100644
--- a/arch/alpha/include/asm/pgtable.h
+++ b/arch/alpha/include/asm/pgtable.h
@@ -239,8 +239,10 @@ pmd_page_vaddr(pmd_t pmd)
#define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> 32))
#define pud_page(pud) (pfn_to_page(pud_val(pud) >> 32))
-extern inline unsigned long pud_page_vaddr(pud_t pgd)
-{ return PAGE_OFFSET + ((pud_val(pgd) & _PFN_MASK) >> (32-PAGE_SHIFT)); }
+static inline pmd_t *pud_pgtable(pud_t pgd)
+{
+ return (pmd_t *)(PAGE_OFFSET + ((pud_val(pgd) & _PFN_MASK) >> (32-PAGE_SHIFT)));
+}
extern inline int pte_none(pte_t pte) { return !pte_val(pte); }
extern inline int pte_present(pte_t pte) { return pte_val(pte) & _PAGE_VALID; }
@@ -290,7 +292,7 @@ extern inline pte_t pte_mkyoung(pte_t pte) { pte_val(pte) |= __ACCESS_BITS; retu
/* Find an entry in the second-level page table.. */
extern inline pmd_t * pmd_offset(pud_t * dir, unsigned long address)
{
- pmd_t *ret = (pmd_t *) pud_page_vaddr(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PAGE - 1));
+ pmd_t *ret = pud_pgtable(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PAGE - 1));
smp_rmb(); /* see above */
return ret;
}
diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
index d4edab51a77c..eabe72ff7381 100644
--- a/arch/arm/include/asm/pgtable-3level.h
+++ b/arch/arm/include/asm/pgtable-3level.h
@@ -130,7 +130,7 @@
flush_pmd_entry(pudp); \
} while (0)
-static inline pmd_t *pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
{
return __va(pud_val(pud) & PHYS_MASK & (s32)PAGE_MASK);
}
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 0b10204e72fc..53a415b329b0 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -636,9 +636,9 @@ static inline phys_addr_t pud_page_paddr(pud_t pud)
return __pud_to_phys(pud);
}
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
{
- return (unsigned long)__va(pud_page_paddr(pud));
+ return (pmd_t *)__va(pud_page_paddr(pud));
}
/* Find an entry in the second-level page table. */
diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
index d765fd948fae..b2ddfbe70365 100644
--- a/arch/ia64/include/asm/pgtable.h
+++ b/arch/ia64/include/asm/pgtable.h
@@ -274,7 +274,7 @@ ia64_phys_addr_valid (unsigned long addr)
#define pud_bad(pud) (!ia64_phys_addr_valid(pud_val(pud)))
#define pud_present(pud) (pud_val(pud) != 0UL)
#define pud_clear(pudp) (pud_val(*(pudp)) = 0UL)
-#define pud_page_vaddr(pud) ((unsigned long) __va(pud_val(pud) & _PFN_MASK))
+#define pud_pgtable(pud) ((pmd_t *) __va(pud_val(pud) & _PFN_MASK))
#define pud_page(pud) virt_to_page((pud_val(pud) + PAGE_OFFSET))
#if CONFIG_PGTABLE_LEVELS == 4
diff --git a/arch/m68k/include/asm/motorola_pgtable.h b/arch/m68k/include/asm/motorola_pgtable.h
index 8076467eff4b..956c80874f98 100644
--- a/arch/m68k/include/asm/motorola_pgtable.h
+++ b/arch/m68k/include/asm/motorola_pgtable.h
@@ -129,7 +129,7 @@ static inline void pud_set(pud_t *pudp, pmd_t *pmdp)
#define __pte_page(pte) ((unsigned long)__va(pte_val(pte) & PAGE_MASK))
#define pmd_page_vaddr(pmd) ((unsigned long)__va(pmd_val(pmd) & _TABLE_MASK))
-#define pud_page_vaddr(pud) ((unsigned long)__va(pud_val(pud) & _TABLE_MASK))
+#define pud_pgtable(pud) ((pmd_t *)__va(pud_val(pud) & _TABLE_MASK))
#define pte_none(pte) (!pte_val(pte))
diff --git a/arch/mips/include/asm/pgtable-64.h b/arch/mips/include/asm/pgtable-64.h
index 1e7d6ce9d8d6..ab305453e90f 100644
--- a/arch/mips/include/asm/pgtable-64.h
+++ b/arch/mips/include/asm/pgtable-64.h
@@ -314,9 +314,9 @@ static inline void pud_clear(pud_t *pudp)
#endif
#ifndef __PAGETABLE_PMD_FOLDED
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
{
- return pud_val(pud);
+ return (pmd_t *)pud_val(pud);
}
#define pud_phys(pud) virt_to_phys((void *)pud_val(pud))
#define pud_page(pud) (pfn_to_page(pud_phys(pud) >> PAGE_SHIFT))
diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
index 39017210dbf0..7218345a447f 100644
--- a/arch/parisc/include/asm/pgtable.h
+++ b/arch/parisc/include/asm/pgtable.h
@@ -324,8 +324,8 @@ static inline void pmd_clear(pmd_t *pmd) {
#if CONFIG_PGTABLE_LEVELS == 3
-#define pud_page_vaddr(pud) ((unsigned long) __va(pud_address(pud)))
-#define pud_page(pud) virt_to_page((void *)pud_page_vaddr(pud))
+#define pud_pgtable(pud) ((pmd_t *) __va(pud_address(pud)))
+#define pud_page(pud) virt_to_page((void *)pud_pgtable(pud))
/* For 64 bit we have three level tables */
diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h
index a666d561b44d..40bafe1e80c9 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -1048,9 +1048,13 @@ extern struct page *p4d_page(p4d_t p4d);
/* Pointers in the page table tree are physical addresses */
#define __pgtable_ptr_val(ptr) __pa(ptr)
-#define pud_page_vaddr(pud) __va(pud_val(pud) & ~PUD_MASKED_BITS)
#define p4d_page_vaddr(p4d) __va(p4d_val(p4d) & ~P4D_MASKED_BITS)
+static inline pmd_t *pud_pgtable(pud_t pud)
+{
+ return (pmd_t *)__va(pud_val(pud) & ~PUD_MASKED_BITS);
+}
+
#define pte_ERROR(e) \
pr_err("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))
#define pmd_ERROR(e) \
diff --git a/arch/powerpc/include/asm/nohash/64/pgtable.h b/arch/powerpc/include/asm/nohash/64/pgtable.h
index 57cd3892bfe0..4158c90c572a 100644
--- a/arch/powerpc/include/asm/nohash/64/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/64/pgtable.h
@@ -164,7 +164,11 @@ static inline void pud_clear(pud_t *pudp)
#define pud_bad(pud) (!is_kernel_addr(pud_val(pud)) \
|| (pud_val(pud) & PUD_BAD_BITS))
#define pud_present(pud) (pud_val(pud) != 0)
-#define pud_page_vaddr(pud) (pud_val(pud) & ~PUD_MASKED_BITS)
+
+static inline pmd_t *pud_pgtable(pud_t pud)
+{
+ return (pmd_t *)(pud_val(pud) & ~PUD_MASKED_BITS);
+}
extern struct page *pud_page(pud_t pud);
diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c
index 5fef8db3b463..b663d8f9f05c 100644
--- a/arch/powerpc/mm/book3s64/radix_pgtable.c
+++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
@@ -825,7 +825,7 @@ static void __meminit remove_pud_table(pud_t *pud_start, unsigned long addr,
continue;
}
- pmd_base = (pmd_t *)pud_page_vaddr(*pud);
+ pmd_base = pud_pgtable(*pud);
remove_pmd_table(pmd_base, addr, next);
free_pmd_table(pmd_base, pud);
}
@@ -1110,7 +1110,7 @@ int pud_free_pmd_page(pud_t *pud, unsigned long addr)
pmd_t *pmd;
int i;
- pmd = (pmd_t *)pud_page_vaddr(*pud);
+ pmd = pud_pgtable(*pud);
pud_clear(pud);
flush_tlb_kernel_range(addr, addr + PUD_SIZE);
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index cc6e2f94517f..4ba311808bdb 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -115,7 +115,7 @@ struct page *pud_page(pud_t pud)
VM_WARN_ON(!pud_huge(pud));
return pte_page(pud_pte(pud));
}
- return virt_to_page(pud_page_vaddr(pud));
+ return virt_to_page(pud_pgtable(pud));
}
/*
diff --git a/arch/riscv/include/asm/pgtable-64.h b/arch/riscv/include/asm/pgtable-64.h
index f3b0da64c6c8..0e863f3f7187 100644
--- a/arch/riscv/include/asm/pgtable-64.h
+++ b/arch/riscv/include/asm/pgtable-64.h
@@ -60,9 +60,9 @@ static inline void pud_clear(pud_t *pudp)
set_pud(pudp, __pud(0));
}
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
{
- return (unsigned long)pfn_to_virt(pud_val(pud) >> _PAGE_PFN_SHIFT);
+ return (pmd_t *)pfn_to_virt(pud_val(pud) >> _PAGE_PFN_SHIFT);
}
static inline struct page *pud_page(pud_t pud)
diff --git a/arch/sh/include/asm/pgtable-3level.h b/arch/sh/include/asm/pgtable-3level.h
index 82d74472dfcd..56bf35c2f29c 100644
--- a/arch/sh/include/asm/pgtable-3level.h
+++ b/arch/sh/include/asm/pgtable-3level.h
@@ -32,9 +32,9 @@ typedef struct { unsigned long long pmd; } pmd_t;
#define pmd_val(x) ((x).pmd)
#define __pmd(x) ((pmd_t) { (x) } )
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
{
- return pud_val(pud);
+ return (pmd_t *)pud_val(pud);
}
/* only used by the stubbed out hugetlb gup code, should never be called */
diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
index a5cf79c149fe..affd70ab02c8 100644
--- a/arch/sparc/include/asm/pgtable_32.h
+++ b/arch/sparc/include/asm/pgtable_32.h
@@ -152,13 +152,13 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)
return (unsigned long)__nocache_va(v << 4);
}
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
{
if (srmmu_device_memory(pud_val(pud))) {
return ~0;
} else {
unsigned long v = pud_val(pud) & SRMMU_PTD_PMASK;
- return (unsigned long)__nocache_va(v << 4);
+ return (pmd_t *)__nocache_va(v << 4);
}
}
diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h
index 550d3904de65..534ec872fa2c 100644
--- a/arch/sparc/include/asm/pgtable_64.h
+++ b/arch/sparc/include/asm/pgtable_64.h
@@ -845,18 +845,18 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)
return ((unsigned long) __va(pfn << PAGE_SHIFT));
}
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
{
pte_t pte = __pte(pud_val(pud));
unsigned long pfn;
pfn = pte_pfn(pte);
- return ((unsigned long) __va(pfn << PAGE_SHIFT));
+ return ((pmd_t *) __va(pfn << PAGE_SHIFT));
}
#define pmd_page(pmd) virt_to_page((void *)pmd_page_vaddr(pmd))
-#define pud_page(pud) virt_to_page((void *)pud_page_vaddr(pud))
+#define pud_page(pud) virt_to_page((void *)pud_pgtable(pud))
#define pmd_clear(pmdp) (pmd_val(*(pmdp)) = 0UL)
#define pud_present(pud) (pud_val(pud) != 0U)
#define pud_clear(pudp) (pud_val(*(pudp)) = 0UL)
diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
index 7e6a4180db9d..091bff319ccd 100644
--- a/arch/um/include/asm/pgtable-3level.h
+++ b/arch/um/include/asm/pgtable-3level.h
@@ -84,7 +84,7 @@ static inline void pud_clear (pud_t *pud)
}
#define pud_page(pud) phys_to_page(pud_val(pud) & PAGE_MASK)
-#define pud_page_vaddr(pud) ((unsigned long) __va(pud_val(pud) & PAGE_MASK))
+#define pud_pgtable(pud) ((pmd_t *) __va(pud_val(pud) & PAGE_MASK))
static inline unsigned long pte_pfn(pte_t pte)
{
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index b1099f2d9800..35a34ca6f2e9 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -865,9 +865,9 @@ static inline int pud_present(pud_t pud)
return pud_flags(pud) & _PAGE_PRESENT;
}
-static inline unsigned long pud_page_vaddr(pud_t pud)
+static inline pmd_t *pud_pgtable(pud_t pud)
{
- return (unsigned long)__va(pud_val(pud) & pud_pfn_mask(pud));
+ return (pmd_t *)__va(pud_val(pud) & pud_pfn_mask(pud));
}
/*
diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
index 156cd235659f..ad8a5c586a35 100644
--- a/arch/x86/mm/pat/set_memory.c
+++ b/arch/x86/mm/pat/set_memory.c
@@ -1134,7 +1134,7 @@ static void __unmap_pmd_range(pud_t *pud, pmd_t *pmd,
unsigned long start, unsigned long end)
{
if (unmap_pte_range(pmd, start, end))
- if (try_to_free_pmd_page((pmd_t *)pud_page_vaddr(*pud)))
+ if (try_to_free_pmd_page(pud_pgtable(*pud)))
pud_clear(pud);
}
@@ -1178,7 +1178,7 @@ static void unmap_pmd_range(pud_t *pud, unsigned long start, unsigned long end)
* Try again to free the PMD page if haven't succeeded above.
*/
if (!pud_none(*pud))
- if (try_to_free_pmd_page((pmd_t *)pud_page_vaddr(*pud)))
+ if (try_to_free_pmd_page(pud_pgtable(*pud)))
pud_clear(pud);
}
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index d27cf69e811d..3481b35cb4ec 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -797,7 +797,7 @@ int pud_free_pmd_page(pud_t *pud, unsigned long addr)
pte_t *pte;
int i;
- pmd = (pmd_t *)pud_page_vaddr(*pud);
+ pmd = pud_pgtable(*pud);
pmd_sv = (pmd_t *)__get_free_page(GFP_KERNEL);
if (!pmd_sv)
return 0;
diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
index 3e13acd019ae..10789cf51d16 100644
--- a/include/asm-generic/pgtable-nopmd.h
+++ b/include/asm-generic/pgtable-nopmd.h
@@ -51,7 +51,7 @@ static inline pmd_t * pmd_offset(pud_t * pud, unsigned long address)
#define __pmd(x) ((pmd_t) { __pud(x) } )
#define pud_page(pud) (pmd_page((pmd_t){ pud }))
-#define pud_page_vaddr(pud) (pmd_page_vaddr((pmd_t){ pud }))
+#define pud_pgtable(pud) ((pmd_t *)(pmd_page_vaddr((pmd_t){ pud })))
/*
* allocating and freeing a pmd is trivial: the 1-entry pmd is
diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
index a9d751fbda9e..7cbd15f70bf5 100644
--- a/include/asm-generic/pgtable-nopud.h
+++ b/include/asm-generic/pgtable-nopud.h
@@ -49,7 +49,7 @@ static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
#define __pud(x) ((pud_t) { __p4d(x) })
#define p4d_page(p4d) (pud_page((pud_t){ p4d }))
-#define p4d_page_vaddr(p4d) (pud_page_vaddr((pud_t){ p4d }))
+#define p4d_page_vaddr(p4d) (pud_pgtable((pud_t){ p4d }))
/*
* allocating and freeing a pud is trivial: the 1-entry pud is
diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
index a43047b1030d..311984f87cf9 100644
--- a/include/linux/pgtable.h
+++ b/include/linux/pgtable.h
@@ -88,7 +88,7 @@ static inline pte_t *pte_offset_kernel(pmd_t *pmd, unsigned long address)
#ifndef pmd_offset
static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
{
- return (pmd_t *)pud_page_vaddr(*pud) + pmd_index(address);
+ return pud_pgtable(*pud) + pmd_index(address);
}
#define pmd_offset pmd_offset
#endif
--
2.31.1
^ permalink raw reply related
* [PATCH v2 2/2] mm: rename p4d_page_vaddr to p4d_pgtable and make it return pud_t *
From: Aneesh Kumar K.V @ 2021-06-15 11:08 UTC (permalink / raw)
To: linux-mm
Cc: linux-arch, linux-ia64, linux-parisc, linux-sh, Aneesh Kumar K.V,
linuxppc-dev, linux-um, linux-kernel, linux-mips, linux-m68k,
linux-alpha, sparclinux, akpm, Linus Torvalds, linux-riscv,
linux-arm-kernel
In-Reply-To: <20210615110859.320299-1-aneesh.kumar@linux.ibm.com>
No functional change in this patch.
Cc: linux-alpha@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-ia64@vger.kernel.org
Cc: linux-m68k@lists.linux-m68k.org
Cc: linux-mips@vger.kernel.org
Cc: linux-parisc@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-riscv@lists.infradead.org
Cc: linux-sh@vger.kernel.org
Cc: sparclinux@vger.kernel.org
Cc: linux-um@lists.infradead.org
Cc: linux-arch@vger.kernel.org
Link: https://lore.kernel.org/linuxppc-dev/CAHk-=wi+J+iodze9FtjM3Zi4j4OeS+qqbKxME9QN4roxPEXH9Q@mail.gmail.com/
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/arm64/include/asm/pgtable.h | 4 ++--
arch/ia64/include/asm/pgtable.h | 2 +-
arch/mips/include/asm/pgtable-64.h | 4 ++--
arch/powerpc/include/asm/book3s/64/pgtable.h | 5 ++++-
arch/powerpc/include/asm/nohash/64/pgtable-4k.h | 6 +++++-
arch/powerpc/mm/book3s64/radix_pgtable.c | 2 +-
arch/powerpc/mm/pgtable_64.c | 2 +-
arch/sparc/include/asm/pgtable_64.h | 4 ++--
arch/x86/include/asm/pgtable.h | 4 ++--
arch/x86/mm/init_64.c | 4 ++--
include/asm-generic/pgtable-nop4d.h | 2 +-
include/asm-generic/pgtable-nopud.h | 2 +-
include/linux/pgtable.h | 2 +-
13 files changed, 25 insertions(+), 18 deletions(-)
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 53a415b329b0..fde06639fff8 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -697,9 +697,9 @@ static inline phys_addr_t p4d_page_paddr(p4d_t p4d)
return __p4d_to_phys(p4d);
}
-static inline unsigned long p4d_page_vaddr(p4d_t p4d)
+static inline pud_t *p4d_pgtable(p4d_t p4d)
{
- return (unsigned long)__va(p4d_page_paddr(p4d));
+ return (pud_t *)__va(p4d_page_paddr(p4d));
}
/* Find an entry in the frst-level page table. */
diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
index b2ddfbe70365..a2d5098b299a 100644
--- a/arch/ia64/include/asm/pgtable.h
+++ b/arch/ia64/include/asm/pgtable.h
@@ -282,7 +282,7 @@ ia64_phys_addr_valid (unsigned long addr)
#define p4d_bad(p4d) (!ia64_phys_addr_valid(p4d_val(p4d)))
#define p4d_present(p4d) (p4d_val(p4d) != 0UL)
#define p4d_clear(p4dp) (p4d_val(*(p4dp)) = 0UL)
-#define p4d_page_vaddr(p4d) ((unsigned long) __va(p4d_val(p4d) & _PFN_MASK))
+#define p4d_pgtable(p4d) ((pud_t *) __va(p4d_val(p4d) & _PFN_MASK))
#define p4d_page(p4d) virt_to_page((p4d_val(p4d) + PAGE_OFFSET))
#endif
diff --git a/arch/mips/include/asm/pgtable-64.h b/arch/mips/include/asm/pgtable-64.h
index ab305453e90f..b865edff2670 100644
--- a/arch/mips/include/asm/pgtable-64.h
+++ b/arch/mips/include/asm/pgtable-64.h
@@ -210,9 +210,9 @@ static inline void p4d_clear(p4d_t *p4dp)
p4d_val(*p4dp) = (unsigned long)invalid_pud_table;
}
-static inline unsigned long p4d_page_vaddr(p4d_t p4d)
+static inline pud_t *p4d_pgtable(p4d_t p4d)
{
- return p4d_val(p4d);
+ return (pud_t *)p4d_val(p4d);
}
#define p4d_phys(p4d) virt_to_phys((void *)p4d_val(p4d))
diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h
index 40bafe1e80c9..cbedc7c8959d 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -1048,7 +1048,10 @@ extern struct page *p4d_page(p4d_t p4d);
/* Pointers in the page table tree are physical addresses */
#define __pgtable_ptr_val(ptr) __pa(ptr)
-#define p4d_page_vaddr(p4d) __va(p4d_val(p4d) & ~P4D_MASKED_BITS)
+static inline pud_t *p4d_pgtable(p4d_t p4d)
+{
+ return (pud_t *)__va(p4d_val(p4d) & ~P4D_MASKED_BITS);
+}
static inline pmd_t *pud_pgtable(pud_t pud)
{
diff --git a/arch/powerpc/include/asm/nohash/64/pgtable-4k.h b/arch/powerpc/include/asm/nohash/64/pgtable-4k.h
index fe2f4c9acd9e..10f5cf444d72 100644
--- a/arch/powerpc/include/asm/nohash/64/pgtable-4k.h
+++ b/arch/powerpc/include/asm/nohash/64/pgtable-4k.h
@@ -56,10 +56,14 @@
#define p4d_none(p4d) (!p4d_val(p4d))
#define p4d_bad(p4d) (p4d_val(p4d) == 0)
#define p4d_present(p4d) (p4d_val(p4d) != 0)
-#define p4d_page_vaddr(p4d) (p4d_val(p4d) & ~P4D_MASKED_BITS)
#ifndef __ASSEMBLY__
+static inline pud_t *p4d_pgtable(p4d_t p4d)
+{
+ return (pud_t *) (p4d_val(p4d) & ~P4D_MASKED_BITS);
+}
+
static inline void p4d_clear(p4d_t *p4dp)
{
*p4dp = __p4d(0);
diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c
index b663d8f9f05c..1ba6d9291c10 100644
--- a/arch/powerpc/mm/book3s64/radix_pgtable.c
+++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
@@ -859,7 +859,7 @@ static void __meminit remove_pagetable(unsigned long start, unsigned long end)
continue;
}
- pud_base = (pud_t *)p4d_page_vaddr(*p4d);
+ pud_base = p4d_pgtable(*p4d);
remove_pud_table(pud_base, addr, next);
free_pud_table(pud_base, p4d);
}
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index 4ba311808bdb..78c8cf01db5f 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -105,7 +105,7 @@ struct page *p4d_page(p4d_t p4d)
VM_WARN_ON(!p4d_huge(p4d));
return pte_page(p4d_pte(p4d));
}
- return virt_to_page(p4d_page_vaddr(p4d));
+ return virt_to_page(p4d_pgtable(p4d));
}
#endif
diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h
index 534ec872fa2c..c0f56da1c205 100644
--- a/arch/sparc/include/asm/pgtable_64.h
+++ b/arch/sparc/include/asm/pgtable_64.h
@@ -860,8 +860,8 @@ static inline pmd_t *pud_pgtable(pud_t pud)
#define pmd_clear(pmdp) (pmd_val(*(pmdp)) = 0UL)
#define pud_present(pud) (pud_val(pud) != 0U)
#define pud_clear(pudp) (pud_val(*(pudp)) = 0UL)
-#define p4d_page_vaddr(p4d) \
- ((unsigned long) __va(p4d_val(p4d)))
+#define p4d_pgtable(p4d) \
+ ((pud_t *) __va(p4d_val(p4d)))
#define p4d_present(p4d) (p4d_val(p4d) != 0U)
#define p4d_clear(p4dp) (p4d_val(*(p4dp)) = 0UL)
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 35a34ca6f2e9..b6c97b8f59ec 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -906,9 +906,9 @@ static inline int p4d_present(p4d_t p4d)
return p4d_flags(p4d) & _PAGE_PRESENT;
}
-static inline unsigned long p4d_page_vaddr(p4d_t p4d)
+static inline pud_t *p4d_pgtable(p4d_t p4d)
{
- return (unsigned long)__va(p4d_val(p4d) & p4d_pfn_mask(p4d));
+ return (pud_t *)__va(p4d_val(p4d) & p4d_pfn_mask(p4d));
}
/*
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index e527d829e1ed..ffb3da2cb038 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -193,8 +193,8 @@ static void sync_global_pgds_l4(unsigned long start, unsigned long end)
spin_lock(pgt_lock);
if (!p4d_none(*p4d_ref) && !p4d_none(*p4d))
- BUG_ON(p4d_page_vaddr(*p4d)
- != p4d_page_vaddr(*p4d_ref));
+ BUG_ON(p4d_pgtable(*p4d)
+ != p4d_pgtable(*p4d_ref));
if (p4d_none(*p4d))
set_p4d(p4d, *p4d_ref);
diff --git a/include/asm-generic/pgtable-nop4d.h b/include/asm-generic/pgtable-nop4d.h
index ce2cbb3c380f..982de5102fc1 100644
--- a/include/asm-generic/pgtable-nop4d.h
+++ b/include/asm-generic/pgtable-nop4d.h
@@ -42,7 +42,7 @@ static inline p4d_t *p4d_offset(pgd_t *pgd, unsigned long address)
#define __p4d(x) ((p4d_t) { __pgd(x) })
#define pgd_page(pgd) (p4d_page((p4d_t){ pgd }))
-#define pgd_page_vaddr(pgd) (p4d_page_vaddr((p4d_t){ pgd }))
+#define pgd_page_vaddr(pgd) (p4d_pgtable((p4d_t){ pgd }))
/*
* allocating and freeing a p4d is trivial: the 1-entry p4d is
diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
index 7cbd15f70bf5..eb70c6d7ceff 100644
--- a/include/asm-generic/pgtable-nopud.h
+++ b/include/asm-generic/pgtable-nopud.h
@@ -49,7 +49,7 @@ static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
#define __pud(x) ((pud_t) { __p4d(x) })
#define p4d_page(p4d) (pud_page((pud_t){ p4d }))
-#define p4d_page_vaddr(p4d) (pud_pgtable((pud_t){ p4d }))
+#define p4d_pgtable(p4d) ((pud_t *)(pud_pgtable((pud_t){ p4d })))
/*
* allocating and freeing a pud is trivial: the 1-entry pud is
diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
index 311984f87cf9..d355290bf70e 100644
--- a/include/linux/pgtable.h
+++ b/include/linux/pgtable.h
@@ -96,7 +96,7 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
#ifndef pud_offset
static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
{
- return (pud_t *)p4d_page_vaddr(*p4d) + pud_index(address);
+ return p4d_pgtable(*p4d) + pud_index(address);
}
#define pud_offset pud_offset
#endif
--
2.31.1
^ permalink raw reply related
* Re: [PATCH] powerpc: Fix initrd corruption with relative jump labels
From: Greg Kurz @ 2021-06-15 10:51 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev, r.bolshakov, a.kovaleva, dja
In-Reply-To: <20210614175740.6721fe0a@bahia.lan>
On Mon, 14 Jun 2021 17:57:40 +0200
Greg Kurz <groug@kaod.org> wrote:
> On Mon, 14 Jun 2021 23:14:40 +1000
> Michael Ellerman <mpe@ellerman.id.au> wrote:
>
> > Commit b0b3b2c78ec0 ("powerpc: Switch to relative jump labels") switched
> > us to using relative jump labels. That involves changing the code,
> > target and key members in struct jump_entry to be relative to the
> > address of the jump_entry, rather than absolute addresses.
> >
> > We have two static inlines that create a struct jump_entry,
> > arch_static_branch() and arch_static_branch_jump(), as well as an asm
> > macro ARCH_STATIC_BRANCH, which is used by the pseries-only hypervisor
> > tracing code.
> >
> > Unfortunately we missed updating the key to be a relative reference in
> > ARCH_STATIC_BRANCH.
> >
> > That causes a pseries kernel to have a handful of jump_entry structs
> > with bad key values. Instead of being a relative reference they instead
> > hold the full address of the key.
> >
> > However the code doesn't expect that, it still adds the key value to the
> > address of the jump_entry (see jump_entry_key()) expecting to get a
> > pointer to a key somewhere in kernel data.
> >
> > The table of jump_entry structs sits in rodata, which comes after the
> > kernel text. In a typical build this will be somewhere around 15MB. The
> > address of the key will be somewhere in data, typically around 20MB.
> > Adding the two values together gets us a pointer somewhere around 45MB.
> >
> > We then call static_key_set_entries() with that bad pointer and modify
> > some members of the struct static_key we think we are pointing at.
> >
> > A pseries kernel is typically ~30MB in size, so writing to ~45MB won't
> > corrupt the kernel itself. However if we're booting with an initrd,
> > depending on the size and exact location of the initrd, we can corrupt
> > the initrd. Depending on how exactly we corrupt the initrd it can either
> > cause the system to not boot, or just corrupt one of the files in the
> > initrd.
> >
> > The fix is simply to make the key value relative to the jump_entry
> > struct in the ARCH_STATIC_BRANCH macro.
> >
> > Fixes: b0b3b2c78ec0 ("powerpc: Switch to relative jump labels")
> > Reported-by: Anastasia Kovaleva <a.kovaleva@yadro.com>
> > Reported-by: Roman Bolshakov <r.bolshakov@yadro.com>
> > Reported-by: Greg Kurz <groug@kaod.org>
> > Reported-by: Daniel Axtens <dja@axtens.net>
> > Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> > ---
>
> Great thanks for debugging this issue ! I'll try it out tomorrow morning.
>
This fixes the issue. Great thanks again :)
Tested-by: Greg Kurz <groug@kaod.org>
> Cheers,
>
> --
> Greg
>
> > arch/powerpc/include/asm/jump_label.h | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/powerpc/include/asm/jump_label.h b/arch/powerpc/include/asm/jump_label.h
> > index 2d5c6bec2b4f..93ce3ec25387 100644
> > --- a/arch/powerpc/include/asm/jump_label.h
> > +++ b/arch/powerpc/include/asm/jump_label.h
> > @@ -50,7 +50,7 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key, bool
> > 1098: nop; \
> > .pushsection __jump_table, "aw"; \
> > .long 1098b - ., LABEL - .; \
> > - FTR_ENTRY_LONG KEY; \
> > + FTR_ENTRY_LONG KEY - .; \
> > .popsection
> > #endif
> >
>
^ permalink raw reply
* Re: [PATCH v12 0/6] KASAN core changes for ppc64 radix KASAN
From: Marco Elver @ 2021-06-15 10:31 UTC (permalink / raw)
To: Daniel Axtens
Cc: aneesh.kumar, LKML, Linux Memory Management List, kasan-dev,
linuxppc-dev, Andrey Konovalov
In-Reply-To: <20210615014705.2234866-1-dja@axtens.net>
[+Cc Andrey]
On Tue, 15 Jun 2021 at 03:47, Daniel Axtens <dja@axtens.net> wrote:
>
> Building on the work of Christophe, Aneesh and Balbir, I've ported
> KASAN to 64-bit Book3S kernels running on the Radix MMU.
>
> I've been trying this for a while, but we keep having collisions
> between the kasan code in the mm tree and the code I want to put in to
> the ppc tree. So my aim here is for patches 1 through 4 or 1 through 5
> to go in via the mm tree.
I think this is reasonable. I'd suggest just sending non-ppc patches
separately (i.e. split the series explicitly) to KASAN maintainers,
and ensure to Cc Andrew, too. Just point at this series to illustrate
how it'll be used.
I think the patches are fine, but I'm not entirely sure about the
current placements of kasan_arch_is_ready(), so hopefully Andrey can
also have a look.
> I will then propose the powerpc changes for
> a later cycle. (I have attached them to this series as an RFC, and
> there are still outstanding review comments I need to attend to.)
>
> v12 applies to next-20210611. There should be no noticable changes to
> other platforms.
>
> Kind regards,
> Daniel
>
> Daniel Axtens (6):
> kasan: allow an architecture to disable inline instrumentation
> kasan: allow architectures to provide an outline readiness check
> kasan: define and use MAX_PTRS_PER_* for early shadow tables
^^ Up to here could be a separate series to go through -mm.
> kasan: Document support on 32-bit powerpc
^^ The Documentation changes are minimal and not just confined to
kasan.rst it seems. In fact your "powerpc: Book3S .." patch changes
Documentation more. So you could just take "kasan: Document support on
32-bit powerpc" through ppc tree as well.
> powerpc/mm/kasan: rename kasan_init_32.c to init_32.c
> [RFC] powerpc: Book3S 64-bit outline-only KASAN support
^ permalink raw reply
* Re: [PATCH v12 2/6] kasan: allow architectures to provide an outline readiness check
From: Marco Elver @ 2021-06-15 10:08 UTC (permalink / raw)
To: Daniel Axtens
Cc: aneesh.kumar, LKML, Linux Memory Management List, kasan-dev,
linuxppc-dev, Aneesh Kumar K . V
In-Reply-To: <20210615014705.2234866-3-dja@axtens.net>
On Tue, 15 Jun 2021 at 03:47, Daniel Axtens <dja@axtens.net> wrote:
>
> Allow architectures to define a kasan_arch_is_ready() hook that bails
> out of any function that's about to touch the shadow unless the arch
> says that it is ready for the memory to be accessed. This is fairly
> uninvasive and should have a negligible performance penalty.
>
> This will only work in outline mode, so an arch must specify
> ARCH_DISABLE_KASAN_INLINE if it requires this.
>
> Cc: Balbir Singh <bsingharora@gmail.com>
> Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> Signed-off-by: Daniel Axtens <dja@axtens.net>
>
> --
>
> I discuss the justfication for this later in the series. Also,
> both previous RFCs for ppc64 - by 2 different people - have
> needed this trick! See:
> - https://lore.kernel.org/patchwork/patch/592820/ # ppc64 hash series
> - https://patchwork.ozlabs.org/patch/795211/ # ppc radix series
> ---
> mm/kasan/common.c | 4 ++++
> mm/kasan/generic.c | 3 +++
> mm/kasan/kasan.h | 4 ++++
> mm/kasan/shadow.c | 4 ++++
> 4 files changed, 15 insertions(+)
>
> diff --git a/mm/kasan/common.c b/mm/kasan/common.c
> index 10177cc26d06..0ad615f3801d 100644
> --- a/mm/kasan/common.c
> +++ b/mm/kasan/common.c
> @@ -331,6 +331,10 @@ static inline bool ____kasan_slab_free(struct kmem_cache *cache, void *object,
> u8 tag;
> void *tagged_object;
>
> + /* Bail if the arch isn't ready */
> + if (!kasan_arch_is_ready())
> + return false;
> +
> tag = get_tag(object);
> tagged_object = object;
> object = kasan_reset_tag(object);
> diff --git a/mm/kasan/generic.c b/mm/kasan/generic.c
> index 53cbf28859b5..c3f5ba7a294a 100644
> --- a/mm/kasan/generic.c
> +++ b/mm/kasan/generic.c
> @@ -163,6 +163,9 @@ static __always_inline bool check_region_inline(unsigned long addr,
> size_t size, bool write,
> unsigned long ret_ip)
> {
> + if (!kasan_arch_is_ready())
> + return true;
> +
> if (unlikely(size == 0))
> return true;
>
> diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h
> index 8f450bc28045..19323a3d5975 100644
> --- a/mm/kasan/kasan.h
> +++ b/mm/kasan/kasan.h
> @@ -449,6 +449,10 @@ static inline void kasan_poison_last_granule(const void *address, size_t size) {
>
> #endif /* CONFIG_KASAN_GENERIC */
>
> +#ifndef kasan_arch_is_ready
> +static inline bool kasan_arch_is_ready(void) { return true; }
> +#endif
> +
> /*
> * Exported functions for interfaces called from assembly or from generated
> * code. Declarations here to avoid warning about missing declarations.
> diff --git a/mm/kasan/shadow.c b/mm/kasan/shadow.c
> index 082ee5b6d9a1..74134b657d7d 100644
> --- a/mm/kasan/shadow.c
> +++ b/mm/kasan/shadow.c
> @@ -73,6 +73,10 @@ void kasan_poison(const void *addr, size_t size, u8 value, bool init)
> {
> void *shadow_start, *shadow_end;
>
> + /* Don't touch the shadow memory if arch isn't ready */
> + if (!kasan_arch_is_ready())
> + return;
> +
What about kasan_poison_last_granule()? kasan_unpoison() currently
seems to potentially trip on that.
^ permalink raw reply
* Re: [PATCH 0/5] cpufreq: cppc: Fix suspend/resume specific races with FIE code
From: Viresh Kumar @ 2021-06-15 9:38 UTC (permalink / raw)
To: Qian Cai
Cc: linuxppc-dev, Vincent Guittot, linux-doc, Jonathan Corbet,
Dirk Brandewie, linux-pm, Srinivas Pandruvada, Rafael Wysocki,
linux-kernel, Paul Mackerras, Ionela Voinescu, Len Brown
In-Reply-To: <20210615075056.dfkbiftuoihtrfpo@vireshk-i7>
On 15-06-21, 13:20, Viresh Kumar wrote:
> I can see one place where race can happen, i.e. between
> topology_clear_scale_freq_source() and topology_scale_freq_tick(). It
> is possible that sfd->set_freq_scale() may get called for a previously
> set handler as there is no protection there.
>
> I will see how to fix that. But I am not sure if the issue reported
> above comes from there.
I have tried to fix this race and pushed the relevant patch to my
branch. Please pick the latest branch and hopefully everything will
just work.
--
viresh
^ permalink raw reply
* [powerpc:fixes] BUILD SUCCESS e41d6c3f4f9b4804e53ca87aba8ee11ada606c77
From: kernel test robot @ 2021-06-15 9:16 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git fixes
branch HEAD: e41d6c3f4f9b4804e53ca87aba8ee11ada606c77 powerpc/signal64: Copy siginfo before changing regs->nip
elapsed time: 1173m
configs tested: 120
configs skipped: 2
The following configs have been built successfully.
More configs may be tested in the coming days.
gcc tested configs:
arm defconfig
arm64 allyesconfig
arm64 defconfig
arm allyesconfig
arm allmodconfig
arc allyesconfig
sh kfr2r09_defconfig
powerpc mpc85xx_cds_defconfig
arm spear3xx_defconfig
powerpc klondike_defconfig
csky alldefconfig
powerpc mpc837x_mds_defconfig
arm spear13xx_defconfig
arm pxa910_defconfig
powerpc mpc8315_rdb_defconfig
powerpc chrp32_defconfig
nios2 10m50_defconfig
arm omap1_defconfig
csky defconfig
sh magicpanelr2_defconfig
x86_64 alldefconfig
powerpc ppc64_defconfig
mips bcm47xx_defconfig
sh se7619_defconfig
powerpc ppa8548_defconfig
mips bigsur_defconfig
sh sh03_defconfig
powerpc taishan_defconfig
arm ixp4xx_defconfig
mips nlm_xlp_defconfig
powerpc mpc8272_ads_defconfig
powerpc walnut_defconfig
m68k mvme16x_defconfig
arm mv78xx0_defconfig
arm dove_defconfig
mips maltasmvp_defconfig
x86_64 allnoconfig
ia64 allmodconfig
ia64 defconfig
ia64 allyesconfig
m68k allmodconfig
m68k defconfig
m68k allyesconfig
nios2 defconfig
nds32 allnoconfig
nds32 defconfig
nios2 allyesconfig
alpha defconfig
alpha allyesconfig
xtensa allyesconfig
h8300 allyesconfig
arc defconfig
sh allmodconfig
parisc defconfig
s390 allyesconfig
s390 allmodconfig
parisc allyesconfig
s390 defconfig
i386 allyesconfig
sparc allyesconfig
sparc defconfig
i386 defconfig
mips allyesconfig
mips allmodconfig
powerpc allyesconfig
powerpc allmodconfig
powerpc allnoconfig
i386 randconfig-a002-20210613
i386 randconfig-a006-20210613
i386 randconfig-a001-20210613
i386 randconfig-a004-20210613
i386 randconfig-a005-20210613
i386 randconfig-a003-20210613
i386 randconfig-a002-20210614
i386 randconfig-a006-20210614
i386 randconfig-a004-20210614
i386 randconfig-a001-20210614
i386 randconfig-a005-20210614
i386 randconfig-a003-20210614
i386 randconfig-a015-20210613
i386 randconfig-a013-20210613
i386 randconfig-a016-20210613
i386 randconfig-a014-20210613
i386 randconfig-a012-20210613
i386 randconfig-a011-20210613
i386 randconfig-a015-20210614
i386 randconfig-a013-20210614
i386 randconfig-a016-20210614
i386 randconfig-a012-20210614
i386 randconfig-a014-20210614
i386 randconfig-a011-20210614
riscv nommu_k210_defconfig
riscv allyesconfig
riscv nommu_virt_defconfig
riscv allnoconfig
riscv defconfig
riscv rv32_defconfig
riscv allmodconfig
um x86_64_defconfig
um i386_defconfig
um kunit_defconfig
x86_64 allyesconfig
x86_64 rhel-8.3-kselftests
x86_64 defconfig
x86_64 rhel-8.3
x86_64 rhel-8.3-kbuiltin
x86_64 kexec
clang tested configs:
x86_64 randconfig-b001-20210614
x86_64 randconfig-a001-20210614
x86_64 randconfig-a004-20210614
x86_64 randconfig-a002-20210614
x86_64 randconfig-a003-20210614
x86_64 randconfig-a006-20210614
x86_64 randconfig-a005-20210614
x86_64 randconfig-a015-20210613
x86_64 randconfig-a011-20210613
x86_64 randconfig-a014-20210613
x86_64 randconfig-a012-20210613
x86_64 randconfig-a013-20210613
x86_64 randconfig-a016-20210613
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply
* [powerpc:fixes-test] BUILD SUCCESS b41bd709a9a2e2d0ce55eef23656770d6fa16221
From: kernel test robot @ 2021-06-15 9:16 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git fixes-test
branch HEAD: b41bd709a9a2e2d0ce55eef23656770d6fa16221 powerpc: Fix initrd corruption with relative jump labels
elapsed time: 1173m
configs tested: 120
configs skipped: 2
The following configs have been built successfully.
More configs may be tested in the coming days.
gcc tested configs:
arm defconfig
arm64 allyesconfig
arm64 defconfig
arm allyesconfig
arm allmodconfig
arc allyesconfig
sh kfr2r09_defconfig
powerpc mpc85xx_cds_defconfig
arm spear3xx_defconfig
powerpc klondike_defconfig
csky alldefconfig
powerpc mpc837x_mds_defconfig
arm spear13xx_defconfig
arm pxa910_defconfig
powerpc mpc8315_rdb_defconfig
powerpc chrp32_defconfig
nios2 10m50_defconfig
arm omap1_defconfig
csky defconfig
sh magicpanelr2_defconfig
x86_64 alldefconfig
powerpc ppc64_defconfig
mips bcm47xx_defconfig
sh se7619_defconfig
powerpc ppa8548_defconfig
mips bigsur_defconfig
sh sh03_defconfig
powerpc taishan_defconfig
arm ixp4xx_defconfig
mips nlm_xlp_defconfig
powerpc mpc8272_ads_defconfig
powerpc walnut_defconfig
m68k mvme16x_defconfig
arm mv78xx0_defconfig
arm dove_defconfig
mips maltasmvp_defconfig
x86_64 allnoconfig
ia64 allmodconfig
ia64 defconfig
ia64 allyesconfig
m68k allmodconfig
m68k defconfig
m68k allyesconfig
nios2 defconfig
nds32 allnoconfig
nds32 defconfig
nios2 allyesconfig
alpha defconfig
alpha allyesconfig
xtensa allyesconfig
h8300 allyesconfig
arc defconfig
sh allmodconfig
parisc defconfig
s390 allyesconfig
s390 allmodconfig
parisc allyesconfig
s390 defconfig
i386 allyesconfig
sparc allyesconfig
sparc defconfig
i386 defconfig
mips allyesconfig
mips allmodconfig
powerpc allyesconfig
powerpc allmodconfig
powerpc allnoconfig
i386 randconfig-a002-20210613
i386 randconfig-a006-20210613
i386 randconfig-a001-20210613
i386 randconfig-a004-20210613
i386 randconfig-a005-20210613
i386 randconfig-a003-20210613
i386 randconfig-a002-20210614
i386 randconfig-a006-20210614
i386 randconfig-a004-20210614
i386 randconfig-a001-20210614
i386 randconfig-a005-20210614
i386 randconfig-a003-20210614
i386 randconfig-a015-20210613
i386 randconfig-a013-20210613
i386 randconfig-a016-20210613
i386 randconfig-a014-20210613
i386 randconfig-a012-20210613
i386 randconfig-a011-20210613
i386 randconfig-a015-20210614
i386 randconfig-a013-20210614
i386 randconfig-a016-20210614
i386 randconfig-a012-20210614
i386 randconfig-a014-20210614
i386 randconfig-a011-20210614
riscv nommu_k210_defconfig
riscv allyesconfig
riscv nommu_virt_defconfig
riscv allnoconfig
riscv defconfig
riscv rv32_defconfig
riscv allmodconfig
um x86_64_defconfig
um i386_defconfig
um kunit_defconfig
x86_64 allyesconfig
x86_64 rhel-8.3-kselftests
x86_64 defconfig
x86_64 rhel-8.3
x86_64 rhel-8.3-kbuiltin
x86_64 kexec
clang tested configs:
x86_64 randconfig-b001-20210614
x86_64 randconfig-a001-20210614
x86_64 randconfig-a004-20210614
x86_64 randconfig-a002-20210614
x86_64 randconfig-a003-20210614
x86_64 randconfig-a006-20210614
x86_64 randconfig-a005-20210614
x86_64 randconfig-a015-20210613
x86_64 randconfig-a011-20210613
x86_64 randconfig-a014-20210613
x86_64 randconfig-a012-20210613
x86_64 randconfig-a013-20210613
x86_64 randconfig-a016-20210613
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply
* Re: [PATCH v5 13/17] powerpc/pseries/vas: Setup IRQ and fault handling
From: Haren Myneni @ 2021-06-15 9:01 UTC (permalink / raw)
To: Nicholas Piggin, herbert, linux-crypto, linuxppc-dev, mpe
In-Reply-To: <1623639403.054wgu233i.astroid@bobo.none>
On Mon, 2021-06-14 at 13:07 +1000, Nicholas Piggin wrote:
> Excerpts from Haren Myneni's message of June 13, 2021 9:02 pm:
> > NX generates an interrupt when sees a fault on the user space
> > buffer and the hypervisor forwards that interrupt to OS. Then
> > the kernel handles the interrupt by issuing H_GET_NX_FAULT hcall
> > to retrieve the fault CRB information.
> >
> > This patch also adds changes to setup and free IRQ per each
> > window and also handles the fault by updating the CSB.
> >
> > Signed-off-by: Haren Myneni <haren@linux.ibm.com>
> > ---
> > arch/powerpc/platforms/pseries/vas.c | 108
> > +++++++++++++++++++++++++++
> > 1 file changed, 108 insertions(+)
> >
> > diff --git a/arch/powerpc/platforms/pseries/vas.c
> > b/arch/powerpc/platforms/pseries/vas.c
> > index fe375f7a7029..55185bdd3776 100644
> > --- a/arch/powerpc/platforms/pseries/vas.c
> > +++ b/arch/powerpc/platforms/pseries/vas.c
> > @@ -11,6 +11,7 @@
> > #include <linux/types.h>
> > #include <linux/delay.h>
> > #include <linux/slab.h>
> > +#include <linux/interrupt.h>
> > #include <asm/machdep.h>
> > #include <asm/hvcall.h>
> > #include <asm/plpar_wrappers.h>
> > @@ -190,6 +191,58 @@ int h_query_vas_capabilities(const u64 hcall,
> > u8 query_type, u64 result)
> > }
> > EXPORT_SYMBOL_GPL(h_query_vas_capabilities);
> >
> > +/*
> > + * hcall to get fault CRB from pHyp.
> > + */
> > +static int h_get_nx_fault(u32 winid, u64 buffer)
> > +{
> > + long rc;
> > +
> > + rc = plpar_hcall_norets(H_GET_NX_FAULT, winid, buffer);
> > +
> > + switch (rc) {
> > + case H_SUCCESS:
> > + return 0;
> > + case H_PARAMETER:
> > + pr_err("HCALL(%x): Invalid window ID %u\n",
> > H_GET_NX_FAULT,
> > + winid);
> > + return -EINVAL;
> > + case H_PRIVILEGE:
> > + pr_err("HCALL(%x): Window(%u): Invalid fault buffer
> > 0x%llx\n",
> > + H_GET_NX_FAULT, winid, buffer);
> > + return -EACCES;
> > + default:
> > + pr_err("HCALL(%x): Failed with error %ld for
> > window(%u)\n",
> > + H_GET_NX_FAULT, rc, winid);
> > + return -EIO;
>
> 3 error messages have 3 different formats for window ID.
>
> I agree with Michael you could just have one error message that
> reports
> the return value. Also "H_GET_NX_FAULT: " would be nicer than
> "HCALL(380): "
yes, Added just one printk for all error codes except for errors which
depend on arguments to HCALL (Ex: WinID).
Sure, I will add just one error message and print all arguments passed
to HCALL.
pr_err("H_GET_NX_FAULT: window(%u), fault buffer(0x%llx) Failed with
error %ld\n", rc, winid, buffer);
>
> Check how some other hcall failures are reported, "hcall failed:
> H_CALL_NAME" seems to have a few takers.
>
> > + }
> > +}
> > +
> > +/*
> > + * Handle the fault interrupt.
> > + * When the fault interrupt is received for each window, query
> > pHyp to get
> > + * the fault CRB on the specific fault. Then process the CRB by
> > updating
> > + * CSB or send signal if the user space CSB is invalid.
> > + * Note: pHyp forwards an interrupt for each fault request. So one
> > fault
> > + * CRB to process for each H_GET_NX_FAULT HCALL.
> > + */
> > +irqreturn_t pseries_vas_fault_thread_fn(int irq, void *data)
> > +{
> > + struct pseries_vas_window *txwin = data;
> > + struct coprocessor_request_block crb;
> > + struct vas_user_win_ref *tsk_ref;
> > + int rc;
> > +
> > + rc = h_get_nx_fault(txwin->vas_win.winid,
> > (u64)virt_to_phys(&crb));
> > + if (!rc) {
> > + tsk_ref = &txwin->vas_win.task_ref;
> > + vas_dump_crb(&crb);
> > + vas_update_csb(&crb, tsk_ref);
> > + }
> > +
> > + return IRQ_HANDLED;
> > +}
> > +
> > /*
> > * Allocate window and setup IRQ mapping.
> > */
> > @@ -201,10 +254,51 @@ static int allocate_setup_window(struct
> > pseries_vas_window *txwin,
> > rc = h_allocate_vas_window(txwin, domain, wintype,
> > DEF_WIN_CREDS);
> > if (rc)
> > return rc;
> > + /*
> > + * On powerVM, pHyp setup and forwards the fault interrupt per
>
> The hypervisor forwards the fault interrupt per-window...
>
> > + * window. So the IRQ setup and fault handling will be done for
> > + * each open window separately.
> > + */
> > + txwin->fault_virq = irq_create_mapping(NULL, txwin->fault_irq);
> > + if (!txwin->fault_virq) {
> > + pr_err("Failed irq mapping %d\n", txwin->fault_irq);
> > + rc = -EINVAL;
> > + goto out_win;
> > + }
> > +
> > + txwin->name = kasprintf(GFP_KERNEL, "vas-win-%d",
> > + txwin->vas_win.winid);
> > + if (!txwin->name) {
> > + rc = -ENOMEM;
> > + goto out_irq;
> > + }
> > +
> > + rc = request_threaded_irq(txwin->fault_virq, NULL,
> > + pseries_vas_fault_thread_fn,
> > IRQF_ONESHOT,
> > + txwin->name, txwin);
> > + if (rc) {
> > + pr_err("VAS-Window[%d]: Request IRQ(%u) failed with
> > %d\n",
> > + txwin->vas_win.winid, txwin->fault_virq, rc);
> > + goto out_free;
> > + }
> >
> > txwin->vas_win.wcreds_max = DEF_WIN_CREDS;
> >
> > return 0;
> > +out_free:
> > + kfree(txwin->name);
> > +out_irq:
> > + irq_dispose_mapping(txwin->fault_virq);
> > +out_win:
> > + h_deallocate_vas_window(txwin->vas_win.winid);
> > + return rc;
> > +}
> > +
> > +static inline void free_irq_setup(struct pseries_vas_window
> > *txwin)
> > +{
> > + free_irq(txwin->fault_virq, txwin);
> > + irq_dispose_mapping(txwin->fault_virq);
> > + kfree(txwin->name);
>
> Nit, but this freeing is in a different order than the error handling
> in
> the function does. I'd just keep it the same unless there is a reason
> to
> be different, in which case it could use a comment.
shouldn't matter, I can change it to:
static inline void free_irq_setup(struct pseries_vas_window *txwin)
{
free_irq(txwin->fault_virq, txwin);
kfree(txwin->name);
irq_dispose_mapping(txwin->fault_virq);
}
Thanks
Haren
>
> So long as the irq can't somehow fire and try to use txwin->name,
> you
> might be okay.
>
> Otherwise I _think_ it's okay, but I don't know the irq APIs well.
>
> Thanks,
> Nick
>
> > }
> >
> > static struct vas_window *vas_allocate_window(struct
> > vas_tx_win_open_attr *uattr,
> > @@ -320,6 +414,11 @@ static struct vas_window
> > *vas_allocate_window(struct vas_tx_win_open_attr *uattr
> > return &txwin->vas_win;
> >
> > out_free:
> > + /*
> > + * Window is not operational. Free IRQ before closing
> > + * window so that do not have to hold mutex.
> > + */
>
> Why don't you have to hold the mutex in that case?
>
> > + free_irq_setup(txwin);
> > h_deallocate_vas_window(txwin->vas_win.winid);
> > out:
> > atomic_dec(&ct_caps->used_lpar_creds);
> > @@ -339,7 +438,16 @@ static int deallocate_free_window(struct
> > pseries_vas_window *win)
> > {
> > int rc = 0;
> >
> > + /*
> > + * Free IRQ after executing H_DEALLOCATE_VAS_WINDOW HCALL
> > + * to close the window. pHyp waits for all requests including
> > + * faults are processed before closing the window - Means all
> > + * credits are returned. In the case of fault request, credit
> > + * is returned after OS issues H_GET_NX_FAULT HCALL.
> > + */
> > rc = h_deallocate_vas_window(win->vas_win.winid);
> > + if (!rc)
> > + free_irq_setup(win);
> >
> > return rc;
> > }
> > --
> > 2.18.2
> >
> >
> >
^ permalink raw reply
* Re: [PATCH v2 2/4] powerpc/interrupt: Refactor prep_irq_for_user_exit()
From: Christophe Leroy @ 2021-06-15 8:37 UTC (permalink / raw)
To: Nicholas Piggin, Benjamin Herrenschmidt, Michael Ellerman,
Paul Mackerras
Cc: linuxppc-dev, linux-kernel
In-Reply-To: <1623378421.ayihg84s3a.astroid@bobo.none>
Le 11/06/2021 à 04:30, Nicholas Piggin a écrit :
> Excerpts from Christophe Leroy's message of June 5, 2021 12:56 am:
>> prep_irq_for_user_exit() is a superset of
>> prep_irq_for_kernel_enabled_exit().
>>
>> Refactor it.
>
> I like the refactoring, but now prep_irq_for_user_exit() is calling
> prep_irq_for_kernel_enabled_exit(), which seems like the wrong naming.
>
> You could re-name prep_irq_for_kernel_enabled_exit() to
> prep_irq_for_enabled_exit() maybe? Or it could be
> __prep_irq_for_enabled_exit() then prep_irq_for_kernel_enabled_exit()
> and prep_irq_for_user_exit() would both call it.
I renamed it prep_irq_for_enabled_exit().
And I realised that after patch 4, prep_irq_for_enabled_exit() has become a trivial function used
only once.
So I swapped patches 1/2 with patches 3/4 and added a 5th one to squash prep_irq_for_enabled_exit()
into its caller.
You didn't have any comment on patch 4 (that is now patch 2) ?
Thanks for the review
Christophe
^ permalink raw reply
* [PATCH v3 5/5] powerpc/interrupt: Remove prep_irq_for_user_exit()
From: Christophe Leroy @ 2021-06-15 8:33 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, npiggin
Cc: linuxppc-dev, linux-kernel
In-Reply-To: <8071cd2e2f2bdc0711e6ac435dff4a09ff21fee2.1623745949.git.christophe.leroy@csgroup.eu>
prep_irq_for_user_exit() has only one caller, squash it
inside that caller.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/powerpc/kernel/interrupt.c | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/arch/powerpc/kernel/interrupt.c b/arch/powerpc/kernel/interrupt.c
index 05831d99bf26..de335da7ab52 100644
--- a/arch/powerpc/kernel/interrupt.c
+++ b/arch/powerpc/kernel/interrupt.c
@@ -75,18 +75,6 @@ static notrace __always_inline bool prep_irq_for_enabled_exit(bool restartable)
return true;
}
-static notrace __always_inline bool prep_irq_for_user_exit(void)
-{
- bool ret;
-
- user_enter_irqoff();
- ret = prep_irq_for_enabled_exit(true);
- if (!ret)
- user_exit_irqoff();
-
- return ret;
-}
-
/* Has to run notrace because it is entered not completely "reconciled" */
notrace long system_call_exception(long r3, long r4, long r5,
long r6, long r7, long r8,
@@ -276,7 +264,9 @@ interrupt_exit_user_prepare_main(struct pt_regs *regs, unsigned long ret)
}
}
- if (!prep_irq_for_user_exit()) {
+ user_enter_irqoff();
+ if (!prep_irq_for_enabled_exit(true)) {
+ user_exit_irqoff();
local_irq_enable();
local_irq_disable();
goto again;
--
2.25.0
^ permalink raw reply related
* [PATCH v3 4/5] powerpc/interrupt: Refactor prep_irq_for_{user/kernel_enabled}_exit()
From: Christophe Leroy @ 2021-06-15 8:33 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, npiggin
Cc: linuxppc-dev, linux-kernel
In-Reply-To: <8071cd2e2f2bdc0711e6ac435dff4a09ff21fee2.1623745949.git.christophe.leroy@csgroup.eu>
prep_irq_for_user_exit() is a superset of
prep_irq_for_kernel_enabled_exit().
Rename prep_irq_for_kernel_enabled_exit() as prep_irq_for_enabled_exit()
and have prep_irq_for_user_exit() use it.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/kernel/interrupt.c | 29 +++++++----------------------
1 file changed, 7 insertions(+), 22 deletions(-)
diff --git a/arch/powerpc/kernel/interrupt.c b/arch/powerpc/kernel/interrupt.c
index 9780c26f19cf..05831d99bf26 100644
--- a/arch/powerpc/kernel/interrupt.c
+++ b/arch/powerpc/kernel/interrupt.c
@@ -50,7 +50,7 @@ static inline bool exit_must_hard_disable(void)
* restartable is true then EE/RI can be left on because interrupts are handled
* with a restart sequence.
*/
-static notrace __always_inline bool prep_irq_for_kernel_enabled_exit(bool restartable)
+static notrace __always_inline bool prep_irq_for_enabled_exit(bool restartable)
{
/* This must be done with RI=1 because tracing may touch vmaps */
trace_hardirqs_on();
@@ -77,29 +77,14 @@ static notrace __always_inline bool prep_irq_for_kernel_enabled_exit(bool restar
static notrace __always_inline bool prep_irq_for_user_exit(void)
{
- user_enter_irqoff();
- /* This must be done with RI=1 because tracing may touch vmaps */
- trace_hardirqs_on();
-
-#ifdef CONFIG_PPC32
- __hard_EE_RI_disable();
-#else
- if (exit_must_hard_disable())
- __hard_EE_RI_disable();
+ bool ret;
- /* This pattern matches prep_irq_for_idle */
- if (unlikely(lazy_irq_pending_nocheck())) {
- if (exit_must_hard_disable()) {
- local_paca->irq_happened |= PACA_IRQ_HARD_DIS;
- __hard_RI_enable();
- }
- trace_hardirqs_off();
+ user_enter_irqoff();
+ ret = prep_irq_for_enabled_exit(true);
+ if (!ret)
user_exit_irqoff();
- return false;
- }
-#endif
- return true;
+ return ret;
}
/* Has to run notrace because it is entered not completely "reconciled" */
@@ -465,7 +450,7 @@ notrace unsigned long interrupt_exit_kernel_prepare(struct pt_regs *regs)
* Stack store exit can't be restarted because the interrupt
* stack frame might have been clobbered.
*/
- if (!prep_irq_for_kernel_enabled_exit(unlikely(stack_store))) {
+ if (!prep_irq_for_enabled_exit(unlikely(stack_store))) {
/*
* Replay pending soft-masked interrupts now. Don't
* just local_irq_enabe(); local_irq_disable(); because
--
2.25.0
^ permalink raw reply related
* [PATCH v3 3/5] powerpc/interrupt: Interchange prep_irq_for_{kernel_enabled/user}_exit()
From: Christophe Leroy @ 2021-06-15 8:33 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, npiggin
Cc: linuxppc-dev, linux-kernel
In-Reply-To: <8071cd2e2f2bdc0711e6ac435dff4a09ff21fee2.1623745949.git.christophe.leroy@csgroup.eu>
prep_irq_for_user_exit() is a superset of
prep_irq_for_kernel_enabled_exit(). In order to allow refactoring in
following patch, interchange the two. This will allow
prep_irq_for_user_exit() to call a renamed version of
prep_irq_for_kernel_enabled_exit().
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/kernel/interrupt.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/arch/powerpc/kernel/interrupt.c b/arch/powerpc/kernel/interrupt.c
index b9558372adc0..9780c26f19cf 100644
--- a/arch/powerpc/kernel/interrupt.c
+++ b/arch/powerpc/kernel/interrupt.c
@@ -46,27 +46,28 @@ static inline bool exit_must_hard_disable(void)
* This should be called with local irqs disabled, but if they were previously
* enabled when the interrupt handler returns (indicating a process-context /
* synchronous interrupt) then irqs_enabled should be true.
+ *
+ * restartable is true then EE/RI can be left on because interrupts are handled
+ * with a restart sequence.
*/
-static notrace __always_inline bool prep_irq_for_user_exit(void)
+static notrace __always_inline bool prep_irq_for_kernel_enabled_exit(bool restartable)
{
- user_enter_irqoff();
/* This must be done with RI=1 because tracing may touch vmaps */
trace_hardirqs_on();
#ifdef CONFIG_PPC32
__hard_EE_RI_disable();
#else
- if (exit_must_hard_disable())
+ if (exit_must_hard_disable() || !restartable)
__hard_EE_RI_disable();
/* This pattern matches prep_irq_for_idle */
if (unlikely(lazy_irq_pending_nocheck())) {
- if (exit_must_hard_disable()) {
+ if (exit_must_hard_disable() || !restartable) {
local_paca->irq_happened |= PACA_IRQ_HARD_DIS;
__hard_RI_enable();
}
trace_hardirqs_off();
- user_exit_irqoff();
return false;
}
@@ -74,28 +75,26 @@ static notrace __always_inline bool prep_irq_for_user_exit(void)
return true;
}
-/*
- * restartable is true then EE/RI can be left on because interrupts are handled
- * with a restart sequence.
- */
-static notrace __always_inline bool prep_irq_for_kernel_enabled_exit(bool restartable)
+static notrace __always_inline bool prep_irq_for_user_exit(void)
{
+ user_enter_irqoff();
/* This must be done with RI=1 because tracing may touch vmaps */
trace_hardirqs_on();
#ifdef CONFIG_PPC32
__hard_EE_RI_disable();
#else
- if (exit_must_hard_disable() || !restartable)
+ if (exit_must_hard_disable())
__hard_EE_RI_disable();
/* This pattern matches prep_irq_for_idle */
if (unlikely(lazy_irq_pending_nocheck())) {
- if (exit_must_hard_disable() || !restartable) {
+ if (exit_must_hard_disable()) {
local_paca->irq_happened |= PACA_IRQ_HARD_DIS;
__hard_RI_enable();
}
trace_hardirqs_off();
+ user_exit_irqoff();
return false;
}
--
2.25.0
^ permalink raw reply related
* [PATCH v3 2/5] powerpc/interrupt: Refactor interrupt_exit_user_prepare()
From: Christophe Leroy @ 2021-06-15 8:33 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, npiggin
Cc: linuxppc-dev, linux-kernel
In-Reply-To: <8071cd2e2f2bdc0711e6ac435dff4a09ff21fee2.1623745949.git.christophe.leroy@csgroup.eu>
interrupt_exit_user_prepare() is a superset of
interrupt_exit_user_prepare_main().
Refactor to avoid code duplication.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/powerpc/kernel/interrupt.c | 57 ++-------------------------------
1 file changed, 3 insertions(+), 54 deletions(-)
diff --git a/arch/powerpc/kernel/interrupt.c b/arch/powerpc/kernel/interrupt.c
index ba2d602d2da6..b9558372adc0 100644
--- a/arch/powerpc/kernel/interrupt.c
+++ b/arch/powerpc/kernel/interrupt.c
@@ -400,9 +400,7 @@ notrace unsigned long syscall_exit_restart(unsigned long r3, struct pt_regs *reg
notrace unsigned long interrupt_exit_user_prepare(struct pt_regs *regs)
{
- unsigned long ti_flags;
- unsigned long flags;
- unsigned long ret = 0;
+ unsigned long ret;
if (!IS_ENABLED(CONFIG_BOOKE) && !IS_ENABLED(CONFIG_40x))
BUG_ON(!(regs->msr & MSR_RI));
@@ -416,63 +414,14 @@ notrace unsigned long interrupt_exit_user_prepare(struct pt_regs *regs)
*/
kuap_assert_locked();
- local_irq_save(flags);
-
-again:
- ti_flags = READ_ONCE(current_thread_info()->flags);
- while (unlikely(ti_flags & (_TIF_USER_WORK_MASK & ~_TIF_RESTORE_TM))) {
- local_irq_enable(); /* returning to user: may enable */
- if (ti_flags & _TIF_NEED_RESCHED) {
- schedule();
- } else {
- if (ti_flags & _TIF_SIGPENDING)
- ret |= _TIF_RESTOREALL;
- do_notify_resume(regs, ti_flags);
- }
- local_irq_disable();
- ti_flags = READ_ONCE(current_thread_info()->flags);
- }
-
- if (IS_ENABLED(CONFIG_PPC_BOOK3S_64) && IS_ENABLED(CONFIG_PPC_FPU)) {
- if (IS_ENABLED(CONFIG_PPC_TRANSACTIONAL_MEM) &&
- unlikely((ti_flags & _TIF_RESTORE_TM))) {
- restore_tm_state(regs);
- } else {
- unsigned long mathflags = MSR_FP;
-
- if (cpu_has_feature(CPU_FTR_VSX))
- mathflags |= MSR_VEC | MSR_VSX;
- else if (cpu_has_feature(CPU_FTR_ALTIVEC))
- mathflags |= MSR_VEC;
-
- /* See above restore_math comment */
- if ((regs->msr & mathflags) != mathflags)
- restore_math(regs);
- }
- }
-
- if (!prep_irq_for_user_exit()) {
- local_irq_enable();
- local_irq_disable();
- goto again;
- }
-
- booke_load_dbcr0();
-
-#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
- local_paca->tm_scratch = regs->msr;
-#endif
+ local_irq_disable();
- account_cpu_user_exit();
+ ret = interrupt_exit_user_prepare_main(regs, 0);
#ifdef CONFIG_PPC64
regs->exit_result = ret;
#endif
- /* Restore user access locks last */
- kuap_user_restore(regs);
- kuep_unlock();
-
return ret;
}
--
2.25.0
^ permalink raw reply related
* [PATCH v3 1/5] powerpc/interrupt: Rename and lightly change syscall_exit_prepare_main()
From: Christophe Leroy @ 2021-06-15 8:33 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, npiggin
Cc: linuxppc-dev, linux-kernel
Rename syscall_exit_prepare_main() into interrupt_exit_prepare_main()
Make it static as it is not used anywhere else.
Pass it the 'ret' so that it can 'or' it directly instead of
oring twice, once inside the function and once outside.
And remove 'r3' parameter which is not used.
Also fix a typo where CONFIG_PPC_BOOK3S should be CONFIG_PPC_BOOK3S_64.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
---
This series applies on top of Nic's series speeding up interrupt return on 64s
arch/powerpc/kernel/interrupt.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/kernel/interrupt.c b/arch/powerpc/kernel/interrupt.c
index 74c995a42399..ba2d602d2da6 100644
--- a/arch/powerpc/kernel/interrupt.c
+++ b/arch/powerpc/kernel/interrupt.c
@@ -243,11 +243,10 @@ static notrace void booke_load_dbcr0(void)
#endif
}
-notrace unsigned long syscall_exit_prepare_main(unsigned long r3,
- struct pt_regs *regs)
+static notrace unsigned long
+interrupt_exit_user_prepare_main(struct pt_regs *regs, unsigned long ret)
{
unsigned long ti_flags;
- unsigned long ret = 0;
again:
ti_flags = READ_ONCE(current_thread_info()->flags);
@@ -269,7 +268,7 @@ notrace unsigned long syscall_exit_prepare_main(unsigned long r3,
ti_flags = READ_ONCE(current_thread_info()->flags);
}
- if (IS_ENABLED(CONFIG_PPC_BOOK3S) && IS_ENABLED(CONFIG_PPC_FPU)) {
+ if (IS_ENABLED(CONFIG_PPC_BOOK3S_64) && IS_ENABLED(CONFIG_PPC_FPU)) {
if (IS_ENABLED(CONFIG_PPC_TRANSACTIONAL_MEM) &&
unlikely((ti_flags & _TIF_RESTORE_TM))) {
restore_tm_state(regs);
@@ -365,7 +364,7 @@ notrace unsigned long syscall_exit_prepare(unsigned long r3,
}
local_irq_disable();
- ret |= syscall_exit_prepare_main(r3, regs);
+ ret = interrupt_exit_user_prepare_main(regs, ret);
#ifdef CONFIG_PPC64
regs->exit_result = ret;
@@ -393,7 +392,7 @@ notrace unsigned long syscall_exit_restart(unsigned long r3, struct pt_regs *reg
BUG_ON(!user_mode(regs));
- regs->exit_result |= syscall_exit_prepare_main(r3, regs);
+ regs->exit_result = interrupt_exit_user_prepare_main(regs, regs->exit_result);
return regs->exit_result;
}
--
2.25.0
^ permalink raw reply related
* Re: [RFC PATCH 4/8] powerpc/pseries: Consolidate DLPAR NUMA distance update
From: Aneesh Kumar K.V @ 2021-06-15 8:26 UTC (permalink / raw)
To: David Gibson; +Cc: Nathan Lynch, Daniel Henrique Barboza, linuxppc-dev
In-Reply-To: <YMga6CtDlIB0wLbp@yekko>
On 6/15/21 8:43 AM, David Gibson wrote:
> On Mon, Jun 14, 2021 at 10:09:59PM +0530, Aneesh Kumar K.V wrote:
>> The associativity details of the newly added resourced are collected from
>> the hypervisor via "ibm,configure-connector" rtas call. Update the numa
>> distance details of the newly added numa node after the above call. In
>> later patch we will remove updating NUMA distance when we are looking
>> for node id from associativity array.
>>
>> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
>> ---
>> arch/powerpc/mm/numa.c | 41 +++++++++++++++++++
>> arch/powerpc/platforms/pseries/hotplug-cpu.c | 2 +
>> .../platforms/pseries/hotplug-memory.c | 2 +
>> arch/powerpc/platforms/pseries/pseries.h | 1 +
>> 4 files changed, 46 insertions(+)
>>
>> diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
>> index 192067991f8a..fec47981c1ef 100644
>> --- a/arch/powerpc/mm/numa.c
>> +++ b/arch/powerpc/mm/numa.c
>> @@ -287,6 +287,47 @@ int of_node_to_nid(struct device_node *device)
>> }
>> EXPORT_SYMBOL(of_node_to_nid);
>>
>> +static void __initialize_form1_numa_distance(const __be32 *associativity)
>> +{
>> + int i, nid;
>> +
>> + if (of_read_number(associativity, 1) >= primary_domain_index) {
>> + nid = of_read_number(&associativity[primary_domain_index], 1);
>> +
>> + for (i = 0; i < max_domain_index; i++) {
>> + const __be32 *entry;
>> +
>> + entry = &associativity[be32_to_cpu(distance_ref_points[i])];
>> + distance_lookup_table[nid][i] = of_read_number(entry, 1);
>> + }
>> + }
>> +}
>
> This logic is almost identicaly to initialize_distance_lookup_table()
> - it would be good if they could be consolidated, so it's clear that
> coldplugged and hotplugged nodes are parsing the NUMA information in
> the same way.
initialize_distance_lookup_table() gets removed in the next patch.
-aneesh
^ permalink raw reply
* Re: [RFC PATCH 2/8] powerpc/pseries: rename distance_ref_points_depth to max_domain_index
From: Aneesh Kumar K.V @ 2021-06-15 8:22 UTC (permalink / raw)
To: David Gibson; +Cc: Nathan Lynch, Daniel Henrique Barboza, linuxppc-dev
In-Reply-To: <YMgYCwpQ+rzkZ8tx@yekko>
On 6/15/21 8:31 AM, David Gibson wrote:
> On Mon, Jun 14, 2021 at 10:09:57PM +0530, Aneesh Kumar K.V wrote:
>> No functional change in this patch
>
> As with 1/8 an explanation of what this actually means and therefore
> why this is a better name would be very helpful.
>
>>
>>
how about max_associativity_domain_index? The documentation added in
patch 7 explains the details. Let me know if we need to add more in
this patch.
-aneesh
^ permalink raw reply
* Re: [RFC PATCH 1/8] powerpc/pseries: rename min_common_depth to primary_domain_index
From: Aneesh Kumar K.V @ 2021-06-15 8:21 UTC (permalink / raw)
To: David Gibson; +Cc: Nathan Lynch, Daniel Henrique Barboza, linuxppc-dev
In-Reply-To: <YMgX1L3j/5JcaLhR@yekko>
On 6/15/21 8:30 AM, David Gibson wrote:
> On Mon, Jun 14, 2021 at 10:09:56PM +0530, Aneesh Kumar K.V wrote:
>> No functional change in this patch.
>
> I think this needs a rationale as to why 'primary_domain_index' is a
> better name than 'min_common_depth'. The meaning isn't obvious to me
> from either name.
>
>
The documentation added in patch 7 explains the name to some extent. Is
that sufficient?
-aneesh
^ permalink raw reply
* Re: [PATCH -next] powerpc/spider-pci: Remove set but not used variable 'val'
From: Arnd Bergmann @ 2021-06-15 8:18 UTC (permalink / raw)
To: Baokun Li
Cc: YueHaibing, Linux Kernel Mailing List, yangjihong1, Wei Yongjun,
Paul Mackerras, linuxppc-dev, Yu Kuai
In-Reply-To: <20210601085319.140461-1-libaokun1@huawei.com>
On Tue, Jun 1, 2021 at 10:53 AM Baokun Li <libaokun1@huawei.com> wrote:
>
> Fixes gcc '-Wunused-but-set-variable' warning:
>
> arch/powerpc/platforms/cell/spider-pci.c: In function 'spiderpci_io_flush':
> arch/powerpc/platforms/cell/spider-pci.c:28:6: warning:
> variable ‘val’ set but not used [-Wunused-but-set-variable]
>
> It never used since introduction.
>
> Signed-off-by: Baokun Li <libaokun1@huawei.com>
LGTM
Acked-by: Arnd Bergmann <arnd@arndb.de>
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox