* [PATCH v8 22.5/30] powerpc/optprobes: Add register argument to patch_imm64_load_insns()
From: Michael Ellerman @ 2020-05-16 11:54 UTC (permalink / raw)
To: linuxppc-dev; +Cc: christophe.leroy, jniethe5
In-Reply-To: <20200506034050.24806-24-jniethe5@gmail.com>
From: Jordan Niethe <jniethe5@gmail.com>
Currently patch_imm32_load_insns() is used to load an instruction to
r4 to be emulated by emulate_step(). For prefixed instructions we
would like to be able to load a 64bit immediate to r4. To prepare for
this make patch_imm64_load_insns() take an argument that decides which
register to load an immediate to - rather than hardcoding r3.
Signed-off-by: Jordan Niethe <jniethe5@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/kernel/optprobes.c | 34 ++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
v8: Split out of patch 23.
diff --git a/arch/powerpc/kernel/optprobes.c b/arch/powerpc/kernel/optprobes.c
index 52c1ab3f85aa..8eea8dbb93fa 100644
--- a/arch/powerpc/kernel/optprobes.c
+++ b/arch/powerpc/kernel/optprobes.c
@@ -162,38 +162,38 @@ void patch_imm32_load_insns(unsigned int val, kprobe_opcode_t *addr)
/*
* Generate instructions to load provided immediate 64-bit value
- * to register 'r3' and patch these instructions at 'addr'.
+ * to register 'reg' and patch these instructions at 'addr'.
*/
-void patch_imm64_load_insns(unsigned long val, kprobe_opcode_t *addr)
+void patch_imm64_load_insns(unsigned long val, int reg, kprobe_opcode_t *addr)
{
- /* lis r3,(op)@highest */
+ /* lis reg,(op)@highest */
patch_instruction((struct ppc_inst *)addr,
- ppc_inst(PPC_INST_ADDIS | ___PPC_RT(3) |
+ ppc_inst(PPC_INST_ADDIS | ___PPC_RT(reg) |
((val >> 48) & 0xffff)));
addr++;
- /* ori r3,r3,(op)@higher */
+ /* ori reg,reg,(op)@higher */
patch_instruction((struct ppc_inst *)addr,
- ppc_inst(PPC_INST_ORI | ___PPC_RA(3) |
- ___PPC_RS(3) | ((val >> 32) & 0xffff)));
+ ppc_inst(PPC_INST_ORI | ___PPC_RA(reg) |
+ ___PPC_RS(reg) | ((val >> 32) & 0xffff)));
addr++;
- /* rldicr r3,r3,32,31 */
+ /* rldicr reg,reg,32,31 */
patch_instruction((struct ppc_inst *)addr,
- ppc_inst(PPC_INST_RLDICR | ___PPC_RA(3) |
- ___PPC_RS(3) | __PPC_SH64(32) | __PPC_ME64(31)));
+ ppc_inst(PPC_INST_RLDICR | ___PPC_RA(reg) |
+ ___PPC_RS(reg) | __PPC_SH64(32) | __PPC_ME64(31)));
addr++;
- /* oris r3,r3,(op)@h */
+ /* oris reg,reg,(op)@h */
patch_instruction((struct ppc_inst *)addr,
- ppc_inst(PPC_INST_ORIS | ___PPC_RA(3) |
- ___PPC_RS(3) | ((val >> 16) & 0xffff)));
+ ppc_inst(PPC_INST_ORIS | ___PPC_RA(reg) |
+ ___PPC_RS(reg) | ((val >> 16) & 0xffff)));
addr++;
- /* ori r3,r3,(op)@l */
+ /* ori reg,reg,(op)@l */
patch_instruction((struct ppc_inst *)addr,
- ppc_inst(PPC_INST_ORI | ___PPC_RA(3) |
- ___PPC_RS(3) | (val & 0xffff)));
+ ppc_inst(PPC_INST_ORI | ___PPC_RA(reg) |
+ ___PPC_RS(reg) | (val & 0xffff)));
}
int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, struct kprobe *p)
@@ -249,7 +249,7 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, struct kprobe *p)
* Fixup the template with instructions to:
* 1. load the address of the actual probepoint
*/
- patch_imm64_load_insns((unsigned long)op, buff + TMPL_OP_IDX);
+ patch_imm64_load_insns((unsigned long)op, 3, buff + TMPL_OP_IDX);
/*
* 2. branch to optimized_callback() and emulate_step()
--
2.25.1
^ permalink raw reply related
* [GIT PULL] Please pull powerpc/linux.git powerpc-5.7-4 tag
From: Michael Ellerman @ 2020-05-16 12:11 UTC (permalink / raw)
To: Linus Torvalds
Cc: christophe.leroy, nayna, linux-kernel, npiggin, linuxppc-dev
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Hi Linus,
Please pull some more powerpc fixes for 5.7.
This is actually three weeks worth of fixes, I was going to send most of them
last week but my build box had a hiccup so I didn't. ie. we haven't just found
all these just before rc6.
cheers
The following changes since commit 5990cdee689c6885b27c6d969a3d58b09002b0bc:
lib/mpi: Fix building for powerpc with clang (2020-04-24 13:14:59 +1000)
are available in the git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git tags/powerpc-5.7-4
for you to fetch changes up to 249c9b0cd193d983c3a0b00f3fd3b92333bfeebe:
powerpc/40x: Make more space for system call exception (2020-05-12 21:22:11 +1000)
- ------------------------------------------------------------------
powerpc fixes for 5.7 #4
A fix for unrecoverable SLB faults in the interrupt exit path, introduced by the
recent rewrite of interrupt exit in C.
Four fixes for our KUAP (Kernel Userspace Access Prevention) support on 64-bit.
These are all fairly minor with the exception of the change to evaluate the
get/put_user() arguments before we enable user access, which reduces the amount
of code we run with user access enabled.
A fix for our secure boot IMA rules, if enforcement of module signatures is
enabled at runtime rather than build time.
A fix to our 32-bit VDSO clock_getres() which wasn't falling back to the syscall
for unknown clocks.
A build fix for CONFIG_PPC_KUAP_DEBUG on 32-bit BookS, and another for 40x.
Thanks to:
Christophe Leroy, Hugh Dickins, Nicholas Piggin, Aurelien Jarno, Mimi Zohar,
Nayna Jain.
- ------------------------------------------------------------------
Christophe Leroy (3):
powerpc/32s: Fix build failure with CONFIG_PPC_KUAP_DEBUG
powerpc/vdso32: Fallback on getres syscall when clock is unknown
powerpc/40x: Make more space for system call exception
Michael Ellerman (2):
Merge KUAP fix from topic/uaccess-ppc into fixes
powerpc/64s: Fix unrecoverable SLB crashes due to preemption check
Nayna Jain (1):
powerpc/ima: Fix secure boot rules in ima arch policy
Nicholas Piggin (4):
powerpc/uaccess: Evaluate macro arguments once, before user access is allowed
powerpc/64/kuap: Move kuap checks out of MSR[RI]=0 regions of exit code
powerpc/64s/kuap: Restore AMR in system reset exception
powerpc/64s/kuap: Restore AMR in fast_interrupt_return
arch/powerpc/include/asm/book3s/32/kup.h | 2 +-
arch/powerpc/include/asm/hw_irq.h | 20 +++++++-
arch/powerpc/include/asm/uaccess.h | 49 ++++++++++++++------
arch/powerpc/kernel/entry_64.S | 4 +-
arch/powerpc/kernel/exceptions-64s.S | 1 +
arch/powerpc/kernel/head_40x.S | 3 +-
arch/powerpc/kernel/ima_arch.c | 6 +--
arch/powerpc/kernel/syscall_64.c | 20 ++++----
arch/powerpc/kernel/vdso32/gettimeofday.S | 6 +--
9 files changed, 78 insertions(+), 33 deletions(-)
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEEJFGtCPCthwEv2Y/bUevqPMjhpYAFAl6/2FcACgkQUevqPMjh
pYAKFQ/9EnGGclynmL6LtPGZwUx85SjGDlWSLTL3edJFQZ4x66QkSBT2R6HF9PYA
HMNC8ei5gTUBOSM9SBtapbYPfVrPO0PtjLzCIKASXpr/vmh7wPN9Fs0kcofKcRoi
p0fnxabTxFMRjOljAsywhbNBMzT5YFN91E0Ab20x/TKsh4PbXm1NfOvHy5R1J/Hw
EcomxGwp6yLEGGMl6hshEmPI49C2+BchO5rUxEYziGQmnfoG3QtPMLg3f9Spe764
MdkPd9lLgP/jLSBdIIG/qGg8OT3O3tN6l/cXZE6nHri7qHAe/1UubXQ4R5zzCmut
4hKwmDIugRdaX0MX55NKq1DRAvw6txK596Gfcas4ooO+4CXYD+0kmIcMTQsQyWxg
SY5ZpHyrU6GTvvcvAR7NVKZVDrw/xrnlpxE5L2lqRE41BUWj1dRmU3NCRpny/otp
WuXqi9rKeFJrPIO2ziBbj3a/205BbkYmVz+kDhemWQ7nh137ryUlaXGTbUfqgE3z
sTNyw84Sc1NTbd5QfFABJDDIMT3kotyDgWeLiMuTw0u6FPcaixpYCSO/DcoxxrZr
2Q6G/4QEgm6lT1tDZ0Te3dStT6PKCg6YjiC7mefMeo3OnnWJGIE3iVJJTwtDDv3a
kuzhIMynKpNZ/26kAmydpEYjFHxmyX0nwzb8704aL6WxgGhVyTw=
=LCRY
-----END PGP SIGNATURE-----
^ permalink raw reply
* Re: [PATCH v5 2/2] powerpc/rtas: Implement reentrant rtas call
From: kbuild test robot @ 2020-05-16 12:15 UTC (permalink / raw)
To: Leonardo Bras, Michael Ellerman, Benjamin Herrenschmidt,
Paul Mackerras, Nicholas Piggin, Thomas Gleixner, Allison Randal,
Greg Kroah-Hartman, Thiago Jung Bauermann, Anshuman Khandual,
Daniel Axtens, Nathan Lynch, Gautham R. Shenoy, Nadav Amit
Cc: linuxppc-dev, kbuild-all, linux-kernel
In-Reply-To: <20200516052137.175881-3-leobras.c@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3330 bytes --]
Hi Leonardo,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on powerpc/next]
[also build test ERROR on v5.7-rc5 next-20200515]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Leonardo-Bras/Implement-reentrant-rtas-call/20200516-132358
base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc64-randconfig-r006-20200515 (attached as .config)
compiler: powerpc-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day GCC_VERSION=9.3.0 make.cross ARCH=powerpc64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>
All errors (new ones prefixed by >>, old ones prefixed by <<):
arch/powerpc/kernel/rtas.c: In function 'rtas_call_reentrant':
>> arch/powerpc/kernel/rtas.c:519:9: error: 'local_paca' undeclared (first use in this function); did you mean 'local_inc'?
519 | args = local_paca->reentrant_args;
| ^~~~~~~~~~
| local_inc
arch/powerpc/kernel/rtas.c:519:9: note: each undeclared identifier is reported only once for each function it appears in
vim +519 arch/powerpc/kernel/rtas.c
486
487 /**
488 * rtas_call_reentrant() - Used for reentrant rtas calls
489 * @token: Token for desired reentrant RTAS call
490 * @nargs: Number of Input Parameters
491 * @nret: Number of Output Parameters
492 * @outputs: Array of outputs
493 * @...: Inputs for desired RTAS call
494 *
495 * According to LoPAR documentation, only "ibm,int-on", "ibm,int-off",
496 * "ibm,get-xive" and "ibm,set-xive" are currently reentrant.
497 * Reentrant calls need their own rtas_args buffer, so not using rtas.args, but
498 * PACA one instead.
499 *
500 * Return: -1 on error,
501 * First output value of RTAS call if (nret > 0),
502 * 0 otherwise,
503 */
504
505 int rtas_call_reentrant(int token, int nargs, int nret, int *outputs, ...)
506 {
507 va_list list;
508 struct rtas_args *args;
509 unsigned long flags;
510 int i, ret = 0;
511
512 if (!rtas.entry || token == RTAS_UNKNOWN_SERVICE)
513 return -1;
514
515 local_irq_save(flags);
516 preempt_disable();
517
518 /* We use the per-cpu (PACA) rtas args buffer */
> 519 args = local_paca->reentrant_args;
520
521 va_start(list, outputs);
522 va_rtas_call_unlocked(args, token, nargs, nret, list);
523 va_end(list);
524
525 if (nret > 1 && outputs)
526 for (i = 0; i < nret - 1; ++i)
527 outputs[i] = be32_to_cpu(args->rets[i + 1]);
528
529 if (nret > 0)
530 ret = be32_to_cpu(args->rets[0]);
531
532 local_irq_restore(flags);
533 preempt_enable();
534
535 return ret;
536 }
537
---
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: 35659 bytes --]
^ permalink raw reply
* Re: [PATCH v2 7/9] powerpc/ps3: Add check for otheros image size
From: Geoff Levand @ 2020-05-16 16:03 UTC (permalink / raw)
To: Michael Ellerman
Cc: linuxppc-dev, Geert Uytterhoeven, Markus Elfring,
Emmanuel Nicolet
In-Reply-To: <87y2pu9cqd.fsf@mpe.ellerman.id.au>
Hi Michael,
On 5/14/20 7:02 PM, Michael Ellerman wrote:
> Geoff Levand <geoff@infradead.org> writes:
...
>> + # The ps3's flash loader has a size limit of 16 MiB for the uncompressed
>> + # image. If a compressed image that exceeded this limit is written to
>> + # flash the loader will decompress that image until the 16 MiB limit is
>> + # reached, then enter the system reset vector of the partially decompressed
>> + # image. No warning is issued.
>> + rm -f "$odir"/{otheros,otheros-too-big}.bld
>> + size=$(${CROSS}nm --no-sort --radix=d "$ofile" | egrep ' _end$' | cut -d' ' -f1)
>> + bld="otheros.bld"
>> + if [ $size -gt $((0x1000000)) ]; then
>> + bld="otheros-too-big.bld"
>> + echo " INFO: Uncompressed kernel is too large to program into PS3 flash memory;" \
>
> This now appears on all my ppc64_defconfig builds, which I don't really
> like.
No, neither do I. I didn't think of that case.
> That does highlight the fact that ppc64_defconfig including
> CONFIG_PPC_PS3 is not really helpful for people actually wanting to run
> the kernel on a PS3.
No, this is just for the bootloader image (.bld) that can be
programed into flash memory. This is what is used to create,
for example, a petitboot bootloader image.
Normal usage is for the bootloader in flash to load a vmlinux
image from disk or network, in which case running a ppc64_defconfig
image would be fine.
> So I wonder if we should drop CONFIG_PPC_PS3 from ppc64_defconfig, in
> which case I'd be happy to keep the INFO message because it should only
> appear on ps3 specific builds.
I'd like to keep CONFIG_PPC_PS3 set in ppc64_defconfig. I feel it
useful to get some build testing of the PS3 platform code.
> The other option would be to drop the message, or only print it when
> we're doing a verbose build.
Building a boatloader image to program into flash memory is
something only very advanced users would be doing. I don't
think they would need this message. They would see the file
name and understand the situation. I'll post a v3 patch that
removes the message.
-Geoff
^ permalink raw reply
* [PATCH v3 7/9] powerpc/ps3: Add check for otheros image size
From: Geoff Levand @ 2020-05-16 16:20 UTC (permalink / raw)
To: Michael Ellerman
Cc: linuxppc-dev, Geert Uytterhoeven, Markus Elfring,
Emmanuel Nicolet
In-Reply-To: <4e8defeb49d62dd9d435e5ea3ddc5668e56fa496.1589049250.git.geoff@infradead.org>
The ps3's otheros flash loader has a size limit of 16 MiB for the
uncompressed image. If that limit will be reached output the
flash image file as 'otheros-too-big.bld'.
Signed-off-by: Geoff Levand <geoff@infradead.org>
---
v2: Change from decimal to hex values. Output an INFO message to screen.
v3: Remove the INFO message.
arch/powerpc/boot/wrapper | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index 35ace40d9fc2..d0b5f202c49c 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -571,7 +571,18 @@ ps3)
count=$overlay_size bs=1
odir="$(dirname "$ofile.bin")"
- rm -f "$odir/otheros.bld"
- gzip -n --force -9 --stdout "$ofile.bin" > "$odir/otheros.bld"
+
+ # The ps3's flash loader has a size limit of 16 MiB for the uncompressed
+ # image. If a compressed image that exceeded this limit is written to
+ # flash the loader will decompress that image until the 16 MiB limit is
+ # reached, then enter the system reset vector of the partially decompressed
+ # image. No warning is issued.
+ rm -f "$odir"/{otheros,otheros-too-big}.bld
+ size=$(${CROSS}nm --no-sort --radix=d "$ofile" | egrep ' _end$' | cut -d' ' -f1)
+ bld="otheros.bld"
+ if [ $size -gt $((0x1000000)) ]; then
+ bld="otheros-too-big.bld"
+ fi
+ gzip -n --force -9 --stdout "$ofile.bin" > "$odir/$bld"
;;
esac
--
2.20.1
^ permalink raw reply related
* Re: [PATCH v4 03/14] arm64: add support for folded p4d page tables
From: Mike Rapoport @ 2020-05-16 17:20 UTC (permalink / raw)
To: Andrew Morton
Cc: Rich Felker, linux-ia64, Geert Uytterhoeven, linux-sh, linux-mm,
Paul Mackerras, linux-hexagon, Will Deacon, kvmarm, Jonas Bonn,
linux-arch, Brian Cain, Marc Zyngier, Russell King, Ley Foon Tan,
Mike Rapoport, Catalin Marinas, Julien Thierry, uclinux-h8-devel,
Fenghua Yu, Arnd Bergmann, Suzuki K Poulose, kvm-ppc,
Stefan Kristiansson, openrisc, Stafford Horne, Guan Xuetao,
linux-arm-kernel, Christophe Leroy, Tony Luck, Yoshinori Sato,
linux-kernel, James Morse, nios2-dev, linuxppc-dev
In-Reply-To: <20200515114012.49f45aa01efb7d8b918bc0f5@linux-foundation.org>
On Fri, May 15, 2020 at 11:40:12AM -0700, Andrew Morton wrote:
> On Tue, 14 Apr 2020 18:34:44 +0300 Mike Rapoport <rppt@kernel.org> wrote:
>
> > Implement primitives necessary for the 4th level folding, add walks of p4d
> > level where appropriate, replace 5level-fixup.h with pgtable-nop4d.h and
> > remove __ARCH_USE_5LEVEL_HACK.
>
> This needed some rework due to arm changes in linux-next. Please check
> my handiwork and test it once I've merged this into linux-next?
Looks ok to me. It passed defconfig and a couple of randconfig builds
and qemu-system-aarch64 boots find with this.
> Rejects were
>
> --- arch/arm64/include/asm/pgtable.h~arm64-add-support-for-folded-p4d-page-tables
> +++ arch/arm64/include/asm/pgtable.h
> @@ -596,49 +604,50 @@ static inline phys_addr_t pud_page_paddr
>
> #define pud_ERROR(pud) __pud_error(__FILE__, __LINE__, pud_val(pud))
>
> -#define pgd_none(pgd) (!pgd_val(pgd))
> -#define pgd_bad(pgd) (!(pgd_val(pgd) & 2))
> -#define pgd_present(pgd) (pgd_val(pgd))
> +#define p4d_none(p4d) (!p4d_val(p4d))
> +#define p4d_bad(p4d) (!(p4d_val(p4d) & 2))
> +#define p4d_present(p4d) (p4d_val(p4d))
>
> -static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
> +static inline void set_p4d(p4d_t *p4dp, p4d_t p4d)
> {
> - if (in_swapper_pgdir(pgdp)) {
> - set_swapper_pgd(pgdp, pgd);
> + if (in_swapper_pgdir(p4dp)) {
> + set_swapper_pgd((pgd_t *)p4dp, __pgd(p4d_val(p4d)));
> return;
> }
>
> - WRITE_ONCE(*pgdp, pgd);
> + WRITE_ONCE(*p4dp, p4d);
> dsb(ishst);
> isb();
> }
>
> -static inline void pgd_clear(pgd_t *pgdp)
> +static inline void p4d_clear(p4d_t *p4dp)
> {
> - set_pgd(pgdp, __pgd(0));
> + set_p4d(p4dp, __p4d(0));
> }
>
> -static inline phys_addr_t pgd_page_paddr(pgd_t pgd)
> +static inline phys_addr_t p4d_page_paddr(p4d_t p4d)
> {
> - return __pgd_to_phys(pgd);
> + return __p4d_to_phys(p4d);
> }
>
> /* Find an entry in the frst-level page table. */
> #define pud_index(addr) (((addr) >> PUD_SHIFT) & (PTRS_PER_PUD - 1))
>
> -#define pud_offset_phys(dir, addr) (pgd_page_paddr(READ_ONCE(*(dir))) + pud_index(addr) * sizeof(pud_t))
> +#define pud_offset_phys(dir, addr) (p4d_page_paddr(READ_ONCE(*(dir))) + pud_index(addr) * sizeof(pud_t))
> #define pud_offset(dir, addr) ((pud_t *)__va(pud_offset_phys((dir), (addr))))
>
> #define pud_set_fixmap(addr) ((pud_t *)set_fixmap_offset(FIX_PUD, addr))
> -#define pud_set_fixmap_offset(pgd, addr) pud_set_fixmap(pud_offset_phys(pgd, addr))
> +#define pud_set_fixmap_offset(p4d, addr) pud_set_fixmap(pud_offset_phys(p4d, addr))
> #define pud_clear_fixmap() clear_fixmap(FIX_PUD)
>
> -#define pgd_page(pgd) pfn_to_page(__phys_to_pfn(__pgd_to_phys(pgd)))
> +#define p4d_page(p4d) pfn_to_page(__phys_to_pfn(__p4d_to_phys(p4d)))
>
> /* use ONLY for statically allocated translation tables */
> #define pud_offset_kimg(dir,addr) ((pud_t *)__phys_to_kimg(pud_offset_phys((dir), (addr))))
>
> #else
>
> +#define p4d_page_paddr(p4d) ({ BUILD_BUG(); 0;})
> #define pgd_page_paddr(pgd) ({ BUILD_BUG(); 0;})
>
> /* Match pud_offset folding in <asm/generic/pgtable-nopud.h> */
>
>
>
> and
>
> --- arch/arm64/kvm/mmu.c~arm64-add-support-for-folded-p4d-page-tables
> +++ arch/arm64/kvm/mmu.c
> @@ -469,7 +517,7 @@ static void stage2_flush_memslot(struct
> do {
> next = stage2_pgd_addr_end(kvm, addr, end);
> if (!stage2_pgd_none(kvm, *pgd))
> - stage2_flush_puds(kvm, pgd, addr, next);
> + stage2_flush_p4ds(kvm, pgd, addr, next);
> } while (pgd++, addr = next, addr != end);
> }
>
>
>
> Result:
>
> From: Mike Rapoport <rppt@linux.ibm.com>
> Subject: arm64: add support for folded p4d page tables
>
> Implement primitives necessary for the 4th level folding, add walks of p4d
> level where appropriate, replace 5level-fixup.h with pgtable-nop4d.h and
> remove __ARCH_USE_5LEVEL_HACK.
>
> Link: http://lkml.kernel.org/r/20200414153455.21744-4-rppt@kernel.org
> Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Brian Cain <bcain@codeaurora.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Christophe Leroy <christophe.leroy@c-s.fr>
> Cc: Fenghua Yu <fenghua.yu@intel.com>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Guan Xuetao <gxt@pku.edu.cn>
> Cc: James Morse <james.morse@arm.com>
> Cc: Jonas Bonn <jonas@southpole.se>
> Cc: Julien Thierry <julien.thierry.kdev@gmail.com>
> Cc: Ley Foon Tan <ley.foon.tan@intel.com>
> Cc: Marc Zyngier <maz@kernel.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Rich Felker <dalias@libc.org>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: Stafford Horne <shorne@gmail.com>
> Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
> Cc: Tony Luck <tony.luck@intel.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
>
> arch/arm64/include/asm/kvm_mmu.h | 10 -
> arch/arm64/include/asm/pgalloc.h | 10 -
> arch/arm64/include/asm/pgtable-types.h | 5
> arch/arm64/include/asm/pgtable.h | 37 ++-
> arch/arm64/include/asm/stage2_pgtable.h | 48 +++--
> arch/arm64/kernel/hibernate.c | 44 +++-
> arch/arm64/kvm/mmu.c | 209 ++++++++++++++++++----
> arch/arm64/mm/fault.c | 9
> arch/arm64/mm/hugetlbpage.c | 15 +
> arch/arm64/mm/kasan_init.c | 26 ++
> arch/arm64/mm/mmu.c | 52 +++--
> arch/arm64/mm/pageattr.c | 7
> 12 files changed, 368 insertions(+), 104 deletions(-)
>
> --- a/arch/arm64/include/asm/kvm_mmu.h~arm64-add-support-for-folded-p4d-page-tables
> +++ a/arch/arm64/include/asm/kvm_mmu.h
> @@ -172,8 +172,8 @@ void kvm_clear_hyp_idmap(void);
> __pmd(__phys_to_pmd_val(__pa(ptep)) | PMD_TYPE_TABLE)
> #define kvm_mk_pud(pmdp) \
> __pud(__phys_to_pud_val(__pa(pmdp)) | PMD_TYPE_TABLE)
> -#define kvm_mk_pgd(pudp) \
> - __pgd(__phys_to_pgd_val(__pa(pudp)) | PUD_TYPE_TABLE)
> +#define kvm_mk_p4d(pmdp) \
> + __p4d(__phys_to_p4d_val(__pa(pmdp)) | PUD_TYPE_TABLE)
>
> #define kvm_set_pud(pudp, pud) set_pud(pudp, pud)
>
> @@ -299,6 +299,12 @@ static inline bool kvm_s2pud_young(pud_t
> #define hyp_pud_table_empty(pudp) kvm_page_empty(pudp)
> #endif
>
> +#ifdef __PAGETABLE_P4D_FOLDED
> +#define hyp_p4d_table_empty(p4dp) (0)
> +#else
> +#define hyp_p4d_table_empty(p4dp) kvm_page_empty(p4dp)
> +#endif
> +
> struct kvm;
>
> #define kvm_flush_dcache_to_poc(a,l) __flush_dcache_area((a), (l))
> --- a/arch/arm64/include/asm/pgalloc.h~arm64-add-support-for-folded-p4d-page-tables
> +++ a/arch/arm64/include/asm/pgalloc.h
> @@ -73,17 +73,17 @@ static inline void pud_free(struct mm_st
> free_page((unsigned long)pudp);
> }
>
> -static inline void __pgd_populate(pgd_t *pgdp, phys_addr_t pudp, pgdval_t prot)
> +static inline void __p4d_populate(p4d_t *p4dp, phys_addr_t pudp, p4dval_t prot)
> {
> - set_pgd(pgdp, __pgd(__phys_to_pgd_val(pudp) | prot));
> + set_p4d(p4dp, __p4d(__phys_to_p4d_val(pudp) | prot));
> }
>
> -static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgdp, pud_t *pudp)
> +static inline void p4d_populate(struct mm_struct *mm, p4d_t *p4dp, pud_t *pudp)
> {
> - __pgd_populate(pgdp, __pa(pudp), PUD_TYPE_TABLE);
> + __p4d_populate(p4dp, __pa(pudp), PUD_TYPE_TABLE);
> }
> #else
> -static inline void __pgd_populate(pgd_t *pgdp, phys_addr_t pudp, pgdval_t prot)
> +static inline void __p4d_populate(p4d_t *p4dp, phys_addr_t pudp, p4dval_t prot)
> {
> BUILD_BUG();
> }
> --- a/arch/arm64/include/asm/pgtable.h~arm64-add-support-for-folded-p4d-page-tables
> +++ a/arch/arm64/include/asm/pgtable.h
> @@ -298,6 +298,11 @@ static inline pte_t pgd_pte(pgd_t pgd)
> return __pte(pgd_val(pgd));
> }
>
> +static inline pte_t p4d_pte(p4d_t p4d)
> +{
> + return __pte(p4d_val(p4d));
> +}
> +
> static inline pte_t pud_pte(pud_t pud)
> {
> return __pte(pud_val(pud));
> @@ -401,6 +406,9 @@ static inline pmd_t pmd_mkdevmap(pmd_t p
>
> #define set_pmd_at(mm, addr, pmdp, pmd) set_pte_at(mm, addr, (pte_t *)pmdp, pmd_pte(pmd))
>
> +#define __p4d_to_phys(p4d) __pte_to_phys(p4d_pte(p4d))
> +#define __phys_to_p4d_val(phys) __phys_to_pte_val(phys)
> +
> #define __pgd_to_phys(pgd) __pte_to_phys(pgd_pte(pgd))
> #define __phys_to_pgd_val(phys) __phys_to_pte_val(phys)
>
> @@ -592,49 +600,50 @@ static inline phys_addr_t pud_page_paddr
>
> #define pud_ERROR(pud) __pud_error(__FILE__, __LINE__, pud_val(pud))
>
> -#define pgd_none(pgd) (!pgd_val(pgd))
> -#define pgd_bad(pgd) (!(pgd_val(pgd) & 2))
> -#define pgd_present(pgd) (pgd_val(pgd))
> +#define p4d_none(p4d) (!p4d_val(p4d))
> +#define p4d_bad(p4d) (!(p4d_val(p4d) & 2))
> +#define p4d_present(p4d) (p4d_val(p4d))
>
> -static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
> +static inline void set_p4d(p4d_t *p4dp, p4d_t p4d)
> {
> - if (in_swapper_pgdir(pgdp)) {
> - set_swapper_pgd(pgdp, pgd);
> + if (in_swapper_pgdir(p4dp)) {
> + set_swapper_pgd((pgd_t *)p4dp, __pgd(p4d_val(p4d)));
> return;
> }
>
> - WRITE_ONCE(*pgdp, pgd);
> + WRITE_ONCE(*p4dp, p4d);
> dsb(ishst);
> isb();
> }
>
> -static inline void pgd_clear(pgd_t *pgdp)
> +static inline void p4d_clear(p4d_t *p4dp)
> {
> - set_pgd(pgdp, __pgd(0));
> + set_p4d(p4dp, __p4d(0));
> }
>
> -static inline phys_addr_t pgd_page_paddr(pgd_t pgd)
> +static inline phys_addr_t p4d_page_paddr(p4d_t p4d)
> {
> - return __pgd_to_phys(pgd);
> + return __p4d_to_phys(p4d);
> }
>
> /* Find an entry in the frst-level page table. */
> #define pud_index(addr) (((addr) >> PUD_SHIFT) & (PTRS_PER_PUD - 1))
>
> -#define pud_offset_phys(dir, addr) (pgd_page_paddr(READ_ONCE(*(dir))) + pud_index(addr) * sizeof(pud_t))
> +#define pud_offset_phys(dir, addr) (p4d_page_paddr(READ_ONCE(*(dir))) + pud_index(addr) * sizeof(pud_t))
> #define pud_offset(dir, addr) ((pud_t *)__va(pud_offset_phys((dir), (addr))))
>
> #define pud_set_fixmap(addr) ((pud_t *)set_fixmap_offset(FIX_PUD, addr))
> -#define pud_set_fixmap_offset(pgd, addr) pud_set_fixmap(pud_offset_phys(pgd, addr))
> +#define pud_set_fixmap_offset(p4d, addr) pud_set_fixmap(pud_offset_phys(p4d, addr))
> #define pud_clear_fixmap() clear_fixmap(FIX_PUD)
>
> -#define pgd_page(pgd) phys_to_page(__pgd_to_phys(pgd))
> +#define p4d_page(p4d) pfn_to_page(__phys_to_pfn(__p4d_to_phys(p4d)))
>
> /* use ONLY for statically allocated translation tables */
> #define pud_offset_kimg(dir,addr) ((pud_t *)__phys_to_kimg(pud_offset_phys((dir), (addr))))
>
> #else
>
> +#define p4d_page_paddr(p4d) ({ BUILD_BUG(); 0;})
> #define pgd_page_paddr(pgd) ({ BUILD_BUG(); 0;})
>
> /* Match pud_offset folding in <asm/generic/pgtable-nopud.h> */
> --- a/arch/arm64/include/asm/pgtable-types.h~arm64-add-support-for-folded-p4d-page-tables
> +++ a/arch/arm64/include/asm/pgtable-types.h
> @@ -14,6 +14,7 @@
> typedef u64 pteval_t;
> typedef u64 pmdval_t;
> typedef u64 pudval_t;
> +typedef u64 p4dval_t;
> typedef u64 pgdval_t;
>
> /*
> @@ -44,13 +45,11 @@ typedef struct { pteval_t pgprot; } pgpr
> #define __pgprot(x) ((pgprot_t) { (x) } )
>
> #if CONFIG_PGTABLE_LEVELS == 2
> -#define __ARCH_USE_5LEVEL_HACK
> #include <asm-generic/pgtable-nopmd.h>
> #elif CONFIG_PGTABLE_LEVELS == 3
> -#define __ARCH_USE_5LEVEL_HACK
> #include <asm-generic/pgtable-nopud.h>
> #elif CONFIG_PGTABLE_LEVELS == 4
> -#include <asm-generic/5level-fixup.h>
> +#include <asm-generic/pgtable-nop4d.h>
> #endif
>
> #endif /* __ASM_PGTABLE_TYPES_H */
> --- a/arch/arm64/include/asm/stage2_pgtable.h~arm64-add-support-for-folded-p4d-page-tables
> +++ a/arch/arm64/include/asm/stage2_pgtable.h
> @@ -68,41 +68,67 @@ static inline bool kvm_stage2_has_pud(st
> #define S2_PUD_SIZE (1UL << S2_PUD_SHIFT)
> #define S2_PUD_MASK (~(S2_PUD_SIZE - 1))
>
> -static inline bool stage2_pgd_none(struct kvm *kvm, pgd_t pgd)
> +#define stage2_pgd_none(kvm, pgd) pgd_none(pgd)
> +#define stage2_pgd_clear(kvm, pgd) pgd_clear(pgd)
> +#define stage2_pgd_present(kvm, pgd) pgd_present(pgd)
> +#define stage2_pgd_populate(kvm, pgd, p4d) pgd_populate(NULL, pgd, p4d)
> +
> +static inline p4d_t *stage2_p4d_offset(struct kvm *kvm,
> + pgd_t *pgd, unsigned long address)
> +{
> + return p4d_offset(pgd, address);
> +}
> +
> +static inline void stage2_p4d_free(struct kvm *kvm, p4d_t *p4d)
> +{
> +}
> +
> +static inline bool stage2_p4d_table_empty(struct kvm *kvm, p4d_t *p4dp)
> +{
> + return false;
> +}
> +
> +static inline phys_addr_t stage2_p4d_addr_end(struct kvm *kvm,
> + phys_addr_t addr, phys_addr_t end)
> +{
> + return end;
> +}
> +
> +static inline bool stage2_p4d_none(struct kvm *kvm, p4d_t p4d)
> {
> if (kvm_stage2_has_pud(kvm))
> - return pgd_none(pgd);
> + return p4d_none(p4d);
> else
> return 0;
> }
>
> -static inline void stage2_pgd_clear(struct kvm *kvm, pgd_t *pgdp)
> +static inline void stage2_p4d_clear(struct kvm *kvm, p4d_t *p4dp)
> {
> if (kvm_stage2_has_pud(kvm))
> - pgd_clear(pgdp);
> + p4d_clear(p4dp);
> }
>
> -static inline bool stage2_pgd_present(struct kvm *kvm, pgd_t pgd)
> +static inline bool stage2_p4d_present(struct kvm *kvm, p4d_t p4d)
> {
> if (kvm_stage2_has_pud(kvm))
> - return pgd_present(pgd);
> + return p4d_present(p4d);
> else
> return 1;
> }
>
> -static inline void stage2_pgd_populate(struct kvm *kvm, pgd_t *pgd, pud_t *pud)
> +static inline void stage2_p4d_populate(struct kvm *kvm, p4d_t *p4d, pud_t *pud)
> {
> if (kvm_stage2_has_pud(kvm))
> - pgd_populate(NULL, pgd, pud);
> + p4d_populate(NULL, p4d, pud);
> }
>
> static inline pud_t *stage2_pud_offset(struct kvm *kvm,
> - pgd_t *pgd, unsigned long address)
> + p4d_t *p4d, unsigned long address)
> {
> if (kvm_stage2_has_pud(kvm))
> - return pud_offset(pgd, address);
> + return pud_offset(p4d, address);
> else
> - return (pud_t *)pgd;
> + return (pud_t *)p4d;
> }
>
> static inline void stage2_pud_free(struct kvm *kvm, pud_t *pud)
> --- a/arch/arm64/kernel/hibernate.c~arm64-add-support-for-folded-p4d-page-tables
> +++ a/arch/arm64/kernel/hibernate.c
> @@ -184,6 +184,7 @@ static int trans_pgd_map_page(pgd_t *tra
> pgprot_t pgprot)
> {
> pgd_t *pgdp;
> + p4d_t *p4dp;
> pud_t *pudp;
> pmd_t *pmdp;
> pte_t *ptep;
> @@ -196,7 +197,15 @@ static int trans_pgd_map_page(pgd_t *tra
> pgd_populate(&init_mm, pgdp, pudp);
> }
>
> - pudp = pud_offset(pgdp, dst_addr);
> + p4dp = p4d_offset(pgdp, dst_addr);
> + if (p4d_none(READ_ONCE(*p4dp))) {
> + pudp = (void *)get_safe_page(GFP_ATOMIC);
> + if (!pudp)
> + return -ENOMEM;
> + p4d_populate(&init_mm, p4dp, pudp);
> + }
> +
> + pudp = pud_offset(p4dp, dst_addr);
> if (pud_none(READ_ONCE(*pudp))) {
> pmdp = (void *)get_safe_page(GFP_ATOMIC);
> if (!pmdp)
> @@ -419,7 +428,7 @@ static int copy_pmd(pud_t *dst_pudp, pud
> return 0;
> }
>
> -static int copy_pud(pgd_t *dst_pgdp, pgd_t *src_pgdp, unsigned long start,
> +static int copy_pud(p4d_t *dst_p4dp, p4d_t *src_p4dp, unsigned long start,
> unsigned long end)
> {
> pud_t *dst_pudp;
> @@ -427,15 +436,15 @@ static int copy_pud(pgd_t *dst_pgdp, pgd
> unsigned long next;
> unsigned long addr = start;
>
> - if (pgd_none(READ_ONCE(*dst_pgdp))) {
> + if (p4d_none(READ_ONCE(*dst_p4dp))) {
> dst_pudp = (pud_t *)get_safe_page(GFP_ATOMIC);
> if (!dst_pudp)
> return -ENOMEM;
> - pgd_populate(&init_mm, dst_pgdp, dst_pudp);
> + p4d_populate(&init_mm, dst_p4dp, dst_pudp);
> }
> - dst_pudp = pud_offset(dst_pgdp, start);
> + dst_pudp = pud_offset(dst_p4dp, start);
>
> - src_pudp = pud_offset(src_pgdp, start);
> + src_pudp = pud_offset(src_p4dp, start);
> do {
> pud_t pud = READ_ONCE(*src_pudp);
>
> @@ -454,6 +463,27 @@ static int copy_pud(pgd_t *dst_pgdp, pgd
> return 0;
> }
>
> +static int copy_p4d(pgd_t *dst_pgdp, pgd_t *src_pgdp, unsigned long start,
> + unsigned long end)
> +{
> + p4d_t *dst_p4dp;
> + p4d_t *src_p4dp;
> + unsigned long next;
> + unsigned long addr = start;
> +
> + dst_p4dp = p4d_offset(dst_pgdp, start);
> + src_p4dp = p4d_offset(src_pgdp, start);
> + do {
> + next = p4d_addr_end(addr, end);
> + if (p4d_none(READ_ONCE(*src_p4dp)))
> + continue;
> + if (copy_pud(dst_p4dp, src_p4dp, addr, next))
> + return -ENOMEM;
> + } while (dst_p4dp++, src_p4dp++, addr = next, addr != end);
> +
> + return 0;
> +}
> +
> static int copy_page_tables(pgd_t *dst_pgdp, unsigned long start,
> unsigned long end)
> {
> @@ -466,7 +496,7 @@ static int copy_page_tables(pgd_t *dst_p
> next = pgd_addr_end(addr, end);
> if (pgd_none(READ_ONCE(*src_pgdp)))
> continue;
> - if (copy_pud(dst_pgdp, src_pgdp, addr, next))
> + if (copy_p4d(dst_pgdp, src_pgdp, addr, next))
> return -ENOMEM;
> } while (dst_pgdp++, src_pgdp++, addr = next, addr != end);
>
> --- a/arch/arm64/kvm/mmu.c~arm64-add-support-for-folded-p4d-page-tables
> +++ a/arch/arm64/kvm/mmu.c
> @@ -158,13 +158,22 @@ static void *mmu_memory_cache_alloc(stru
>
> static void clear_stage2_pgd_entry(struct kvm *kvm, pgd_t *pgd, phys_addr_t addr)
> {
> - pud_t *pud_table __maybe_unused = stage2_pud_offset(kvm, pgd, 0UL);
> + p4d_t *p4d_table __maybe_unused = stage2_p4d_offset(kvm, pgd, 0UL);
> stage2_pgd_clear(kvm, pgd);
> kvm_tlb_flush_vmid_ipa(kvm, addr);
> - stage2_pud_free(kvm, pud_table);
> + stage2_p4d_free(kvm, p4d_table);
> put_page(virt_to_page(pgd));
> }
>
> +static void clear_stage2_p4d_entry(struct kvm *kvm, p4d_t *p4d, phys_addr_t addr)
> +{
> + pud_t *pud_table __maybe_unused = stage2_pud_offset(kvm, p4d, 0);
> + stage2_p4d_clear(kvm, p4d);
> + kvm_tlb_flush_vmid_ipa(kvm, addr);
> + stage2_pud_free(kvm, pud_table);
> + put_page(virt_to_page(p4d));
> +}
> +
> static void clear_stage2_pud_entry(struct kvm *kvm, pud_t *pud, phys_addr_t addr)
> {
> pmd_t *pmd_table __maybe_unused = stage2_pmd_offset(kvm, pud, 0);
> @@ -208,12 +217,20 @@ static inline void kvm_pud_populate(pud_
> dsb(ishst);
> }
>
> -static inline void kvm_pgd_populate(pgd_t *pgdp, pud_t *pudp)
> +static inline void kvm_p4d_populate(p4d_t *p4dp, pud_t *pudp)
> {
> - WRITE_ONCE(*pgdp, kvm_mk_pgd(pudp));
> + WRITE_ONCE(*p4dp, kvm_mk_p4d(pudp));
> dsb(ishst);
> }
>
> +static inline void kvm_pgd_populate(pgd_t *pgdp, p4d_t *p4dp)
> +{
> +#ifndef __PAGETABLE_P4D_FOLDED
> + WRITE_ONCE(*pgdp, kvm_mk_pgd(p4dp));
> + dsb(ishst);
> +#endif
> +}
> +
> /*
> * Unmapping vs dcache management:
> *
> @@ -293,13 +310,13 @@ static void unmap_stage2_pmds(struct kvm
> clear_stage2_pud_entry(kvm, pud, start_addr);
> }
>
> -static void unmap_stage2_puds(struct kvm *kvm, pgd_t *pgd,
> +static void unmap_stage2_puds(struct kvm *kvm, p4d_t *p4d,
> phys_addr_t addr, phys_addr_t end)
> {
> phys_addr_t next, start_addr = addr;
> pud_t *pud, *start_pud;
>
> - start_pud = pud = stage2_pud_offset(kvm, pgd, addr);
> + start_pud = pud = stage2_pud_offset(kvm, p4d, addr);
> do {
> next = stage2_pud_addr_end(kvm, addr, end);
> if (!stage2_pud_none(kvm, *pud)) {
> @@ -317,6 +334,23 @@ static void unmap_stage2_puds(struct kvm
> } while (pud++, addr = next, addr != end);
>
> if (stage2_pud_table_empty(kvm, start_pud))
> + clear_stage2_p4d_entry(kvm, p4d, start_addr);
> +}
> +
> +static void unmap_stage2_p4ds(struct kvm *kvm, pgd_t *pgd,
> + phys_addr_t addr, phys_addr_t end)
> +{
> + phys_addr_t next, start_addr = addr;
> + p4d_t *p4d, *start_p4d;
> +
> + start_p4d = p4d = stage2_p4d_offset(kvm, pgd, addr);
> + do {
> + next = stage2_p4d_addr_end(kvm, addr, end);
> + if (!stage2_p4d_none(kvm, *p4d))
> + unmap_stage2_puds(kvm, p4d, addr, next);
> + } while (p4d++, addr = next, addr != end);
> +
> + if (stage2_p4d_table_empty(kvm, start_p4d))
> clear_stage2_pgd_entry(kvm, pgd, start_addr);
> }
>
> @@ -351,7 +385,7 @@ static void unmap_stage2_range(struct kv
> break;
> next = stage2_pgd_addr_end(kvm, addr, end);
> if (!stage2_pgd_none(kvm, *pgd))
> - unmap_stage2_puds(kvm, pgd, addr, next);
> + unmap_stage2_p4ds(kvm, pgd, addr, next);
> /*
> * If the range is too large, release the kvm->mmu_lock
> * to prevent starvation and lockup detector warnings.
> @@ -391,13 +425,13 @@ static void stage2_flush_pmds(struct kvm
> } while (pmd++, addr = next, addr != end);
> }
>
> -static void stage2_flush_puds(struct kvm *kvm, pgd_t *pgd,
> +static void stage2_flush_puds(struct kvm *kvm, p4d_t *p4d,
> phys_addr_t addr, phys_addr_t end)
> {
> pud_t *pud;
> phys_addr_t next;
>
> - pud = stage2_pud_offset(kvm, pgd, addr);
> + pud = stage2_pud_offset(kvm, p4d, addr);
> do {
> next = stage2_pud_addr_end(kvm, addr, end);
> if (!stage2_pud_none(kvm, *pud)) {
> @@ -409,6 +443,20 @@ static void stage2_flush_puds(struct kvm
> } while (pud++, addr = next, addr != end);
> }
>
> +static void stage2_flush_p4ds(struct kvm *kvm, pgd_t *pgd,
> + phys_addr_t addr, phys_addr_t end)
> +{
> + p4d_t *p4d;
> + phys_addr_t next;
> +
> + p4d = stage2_p4d_offset(kvm, pgd, addr);
> + do {
> + next = stage2_p4d_addr_end(kvm, addr, end);
> + if (!stage2_p4d_none(kvm, *p4d))
> + stage2_flush_puds(kvm, p4d, addr, next);
> + } while (p4d++, addr = next, addr != end);
> +}
> +
> static void stage2_flush_memslot(struct kvm *kvm,
> struct kvm_memory_slot *memslot)
> {
> @@ -421,7 +469,7 @@ static void stage2_flush_memslot(struct
> do {
> next = stage2_pgd_addr_end(kvm, addr, end);
> if (!stage2_pgd_none(kvm, *pgd))
> - stage2_flush_puds(kvm, pgd, addr, next);
> + stage2_flush_p4ds(kvm, pgd, addr, next);
>
> if (next != end)
> cond_resched_lock(&kvm->mmu_lock);
> @@ -454,12 +502,21 @@ static void stage2_flush_vm(struct kvm *
>
> static void clear_hyp_pgd_entry(pgd_t *pgd)
> {
> - pud_t *pud_table __maybe_unused = pud_offset(pgd, 0UL);
> + p4d_t *p4d_table __maybe_unused = p4d_offset(pgd, 0UL);
> pgd_clear(pgd);
> - pud_free(NULL, pud_table);
> + p4d_free(NULL, p4d_table);
> put_page(virt_to_page(pgd));
> }
>
> +static void clear_hyp_p4d_entry(p4d_t *p4d)
> +{
> + pud_t *pud_table __maybe_unused = pud_offset(p4d, 0);
> + VM_BUG_ON(p4d_huge(*p4d));
> + p4d_clear(p4d);
> + pud_free(NULL, pud_table);
> + put_page(virt_to_page(p4d));
> +}
> +
> static void clear_hyp_pud_entry(pud_t *pud)
> {
> pmd_t *pmd_table __maybe_unused = pmd_offset(pud, 0);
> @@ -511,12 +568,12 @@ static void unmap_hyp_pmds(pud_t *pud, p
> clear_hyp_pud_entry(pud);
> }
>
> -static void unmap_hyp_puds(pgd_t *pgd, phys_addr_t addr, phys_addr_t end)
> +static void unmap_hyp_puds(p4d_t *p4d, phys_addr_t addr, phys_addr_t end)
> {
> phys_addr_t next;
> pud_t *pud, *start_pud;
>
> - start_pud = pud = pud_offset(pgd, addr);
> + start_pud = pud = pud_offset(p4d, addr);
> do {
> next = pud_addr_end(addr, end);
> /* Hyp doesn't use huge puds */
> @@ -525,6 +582,23 @@ static void unmap_hyp_puds(pgd_t *pgd, p
> } while (pud++, addr = next, addr != end);
>
> if (hyp_pud_table_empty(start_pud))
> + clear_hyp_p4d_entry(p4d);
> +}
> +
> +static void unmap_hyp_p4ds(pgd_t *pgd, phys_addr_t addr, phys_addr_t end)
> +{
> + phys_addr_t next;
> + p4d_t *p4d, *start_p4d;
> +
> + start_p4d = p4d = p4d_offset(pgd, addr);
> + do {
> + next = p4d_addr_end(addr, end);
> + /* Hyp doesn't use huge p4ds */
> + if (!p4d_none(*p4d))
> + unmap_hyp_puds(p4d, addr, next);
> + } while (p4d++, addr = next, addr != end);
> +
> + if (hyp_p4d_table_empty(start_p4d))
> clear_hyp_pgd_entry(pgd);
> }
>
> @@ -548,7 +622,7 @@ static void __unmap_hyp_range(pgd_t *pgd
> do {
> next = pgd_addr_end(addr, end);
> if (!pgd_none(*pgd))
> - unmap_hyp_puds(pgd, addr, next);
> + unmap_hyp_p4ds(pgd, addr, next);
> } while (pgd++, addr = next, addr != end);
> }
>
> @@ -658,7 +732,7 @@ static int create_hyp_pmd_mappings(pud_t
> return 0;
> }
>
> -static int create_hyp_pud_mappings(pgd_t *pgd, unsigned long start,
> +static int create_hyp_pud_mappings(p4d_t *p4d, unsigned long start,
> unsigned long end, unsigned long pfn,
> pgprot_t prot)
> {
> @@ -669,7 +743,7 @@ static int create_hyp_pud_mappings(pgd_t
>
> addr = start;
> do {
> - pud = pud_offset(pgd, addr);
> + pud = pud_offset(p4d, addr);
>
> if (pud_none_or_clear_bad(pud)) {
> pmd = pmd_alloc_one(NULL, addr);
> @@ -691,12 +765,45 @@ static int create_hyp_pud_mappings(pgd_t
> return 0;
> }
>
> +static int create_hyp_p4d_mappings(pgd_t *pgd, unsigned long start,
> + unsigned long end, unsigned long pfn,
> + pgprot_t prot)
> +{
> + p4d_t *p4d;
> + pud_t *pud;
> + unsigned long addr, next;
> + int ret;
> +
> + addr = start;
> + do {
> + p4d = p4d_offset(pgd, addr);
> +
> + if (p4d_none(*p4d)) {
> + pud = pud_alloc_one(NULL, addr);
> + if (!pud) {
> + kvm_err("Cannot allocate Hyp pud\n");
> + return -ENOMEM;
> + }
> + kvm_p4d_populate(p4d, pud);
> + get_page(virt_to_page(p4d));
> + }
> +
> + next = p4d_addr_end(addr, end);
> + ret = create_hyp_pud_mappings(p4d, addr, next, pfn, prot);
> + if (ret)
> + return ret;
> + pfn += (next - addr) >> PAGE_SHIFT;
> + } while (addr = next, addr != end);
> +
> + return 0;
> +}
> +
> static int __create_hyp_mappings(pgd_t *pgdp, unsigned long ptrs_per_pgd,
> unsigned long start, unsigned long end,
> unsigned long pfn, pgprot_t prot)
> {
> pgd_t *pgd;
> - pud_t *pud;
> + p4d_t *p4d;
> unsigned long addr, next;
> int err = 0;
>
> @@ -707,18 +814,18 @@ static int __create_hyp_mappings(pgd_t *
> pgd = pgdp + kvm_pgd_index(addr, ptrs_per_pgd);
>
> if (pgd_none(*pgd)) {
> - pud = pud_alloc_one(NULL, addr);
> - if (!pud) {
> - kvm_err("Cannot allocate Hyp pud\n");
> + p4d = p4d_alloc_one(NULL, addr);
> + if (!p4d) {
> + kvm_err("Cannot allocate Hyp p4d\n");
> err = -ENOMEM;
> goto out;
> }
> - kvm_pgd_populate(pgd, pud);
> + kvm_pgd_populate(pgd, p4d);
> get_page(virt_to_page(pgd));
> }
>
> next = pgd_addr_end(addr, end);
> - err = create_hyp_pud_mappings(pgd, addr, next, pfn, prot);
> + err = create_hyp_p4d_mappings(pgd, addr, next, pfn, prot);
> if (err)
> goto out;
> pfn += (next - addr) >> PAGE_SHIFT;
> @@ -1015,22 +1122,40 @@ void kvm_free_stage2_pgd(struct kvm *kvm
> free_pages_exact(pgd, stage2_pgd_size(kvm));
> }
>
> -static pud_t *stage2_get_pud(struct kvm *kvm, struct kvm_mmu_memory_cache *cache,
> +static p4d_t *stage2_get_p4d(struct kvm *kvm, struct kvm_mmu_memory_cache *cache,
> phys_addr_t addr)
> {
> pgd_t *pgd;
> - pud_t *pud;
> + p4d_t *p4d;
>
> pgd = kvm->arch.pgd + stage2_pgd_index(kvm, addr);
> if (stage2_pgd_none(kvm, *pgd)) {
> if (!cache)
> return NULL;
> - pud = mmu_memory_cache_alloc(cache);
> - stage2_pgd_populate(kvm, pgd, pud);
> + p4d = mmu_memory_cache_alloc(cache);
> + stage2_pgd_populate(kvm, pgd, p4d);
> get_page(virt_to_page(pgd));
> }
>
> - return stage2_pud_offset(kvm, pgd, addr);
> + return stage2_p4d_offset(kvm, pgd, addr);
> +}
> +
> +static pud_t *stage2_get_pud(struct kvm *kvm, struct kvm_mmu_memory_cache *cache,
> + phys_addr_t addr)
> +{
> + p4d_t *p4d;
> + pud_t *pud;
> +
> + p4d = stage2_get_p4d(kvm, cache, addr);
> + if (stage2_p4d_none(kvm, *p4d)) {
> + if (!cache)
> + return NULL;
> + pud = mmu_memory_cache_alloc(cache);
> + stage2_p4d_populate(kvm, p4d, pud);
> + get_page(virt_to_page(p4d));
> + }
> +
> + return stage2_pud_offset(kvm, p4d, addr);
> }
>
> static pmd_t *stage2_get_pmd(struct kvm *kvm, struct kvm_mmu_memory_cache *cache,
> @@ -1423,18 +1548,18 @@ static void stage2_wp_pmds(struct kvm *k
> }
>
> /**
> - * stage2_wp_puds - write protect PGD range
> + * stage2_wp_puds - write protect P4D range
> * @pgd: pointer to pgd entry
> * @addr: range start address
> * @end: range end address
> */
> -static void stage2_wp_puds(struct kvm *kvm, pgd_t *pgd,
> +static void stage2_wp_puds(struct kvm *kvm, p4d_t *p4d,
> phys_addr_t addr, phys_addr_t end)
> {
> pud_t *pud;
> phys_addr_t next;
>
> - pud = stage2_pud_offset(kvm, pgd, addr);
> + pud = stage2_pud_offset(kvm, p4d, addr);
> do {
> next = stage2_pud_addr_end(kvm, addr, end);
> if (!stage2_pud_none(kvm, *pud)) {
> @@ -1449,6 +1574,26 @@ static void stage2_wp_puds(struct kvm *
> }
>
> /**
> + * stage2_wp_p4ds - write protect PGD range
> + * @pgd: pointer to pgd entry
> + * @addr: range start address
> + * @end: range end address
> + */
> +static void stage2_wp_p4ds(struct kvm *kvm, pgd_t *pgd,
> + phys_addr_t addr, phys_addr_t end)
> +{
> + p4d_t *p4d;
> + phys_addr_t next;
> +
> + p4d = stage2_p4d_offset(kvm, pgd, addr);
> + do {
> + next = stage2_p4d_addr_end(kvm, addr, end);
> + if (!stage2_p4d_none(kvm, *p4d))
> + stage2_wp_puds(kvm, p4d, addr, next);
> + } while (p4d++, addr = next, addr != end);
> +}
> +
> +/**
> * stage2_wp_range() - write protect stage2 memory region range
> * @kvm: The KVM pointer
> * @addr: Start address of range
> @@ -1475,7 +1620,7 @@ static void stage2_wp_range(struct kvm *
> break;
> next = stage2_pgd_addr_end(kvm, addr, end);
> if (stage2_pgd_present(kvm, *pgd))
> - stage2_wp_puds(kvm, pgd, addr, next);
> + stage2_wp_p4ds(kvm, pgd, addr, next);
> } while (pgd++, addr = next, addr != end);
> }
>
> --- a/arch/arm64/mm/fault.c~arm64-add-support-for-folded-p4d-page-tables
> +++ a/arch/arm64/mm/fault.c
> @@ -145,6 +145,7 @@ static void show_pte(unsigned long addr)
> pr_alert("[%016lx] pgd=%016llx", addr, pgd_val(pgd));
>
> do {
> + p4d_t *p4dp, p4d;
> pud_t *pudp, pud;
> pmd_t *pmdp, pmd;
> pte_t *ptep, pte;
> @@ -152,7 +153,13 @@ static void show_pte(unsigned long addr)
> if (pgd_none(pgd) || pgd_bad(pgd))
> break;
>
> - pudp = pud_offset(pgdp, addr);
> + p4dp = p4d_offset(pgdp, addr);
> + p4d = READ_ONCE(*p4dp);
> + pr_cont(", p4d=%016llx", p4d_val(p4d));
> + if (p4d_none(p4d) || p4d_bad(p4d))
> + break;
> +
> + pudp = pud_offset(p4dp, addr);
> pud = READ_ONCE(*pudp);
> pr_cont(", pud=%016llx", pud_val(pud));
> if (pud_none(pud) || pud_bad(pud))
> --- a/arch/arm64/mm/hugetlbpage.c~arm64-add-support-for-folded-p4d-page-tables
> +++ a/arch/arm64/mm/hugetlbpage.c
> @@ -67,11 +67,13 @@ static int find_num_contig(struct mm_str
> pte_t *ptep, size_t *pgsize)
> {
> pgd_t *pgdp = pgd_offset(mm, addr);
> + p4d_t *p4dp;
> pud_t *pudp;
> pmd_t *pmdp;
>
> *pgsize = PAGE_SIZE;
> - pudp = pud_offset(pgdp, addr);
> + p4dp = p4d_offset(pgdp, addr);
> + pudp = pud_offset(p4dp, addr);
> pmdp = pmd_offset(pudp, addr);
> if ((pte_t *)pmdp == ptep) {
> *pgsize = PMD_SIZE;
> @@ -217,12 +219,14 @@ pte_t *huge_pte_alloc(struct mm_struct *
> unsigned long addr, unsigned long sz)
> {
> pgd_t *pgdp;
> + p4d_t *p4dp;
> pud_t *pudp;
> pmd_t *pmdp;
> pte_t *ptep = NULL;
>
> pgdp = pgd_offset(mm, addr);
> - pudp = pud_alloc(mm, pgdp, addr);
> + p4dp = p4d_offset(pgdp, addr);
> + pudp = pud_alloc(mm, p4dp, addr);
> if (!pudp)
> return NULL;
>
> @@ -261,6 +265,7 @@ pte_t *huge_pte_offset(struct mm_struct
> unsigned long addr, unsigned long sz)
> {
> pgd_t *pgdp;
> + p4d_t *p4dp;
> pud_t *pudp, pud;
> pmd_t *pmdp, pmd;
>
> @@ -268,7 +273,11 @@ pte_t *huge_pte_offset(struct mm_struct
> if (!pgd_present(READ_ONCE(*pgdp)))
> return NULL;
>
> - pudp = pud_offset(pgdp, addr);
> + p4dp = p4d_offset(pgdp, addr);
> + if (!p4d_present(READ_ONCE(*p4dp)))
> + return NULL;
> +
> + pudp = pud_offset(p4dp, addr);
> pud = READ_ONCE(*pudp);
> if (sz != PUD_SIZE && pud_none(pud))
> return NULL;
> --- a/arch/arm64/mm/kasan_init.c~arm64-add-support-for-folded-p4d-page-tables
> +++ a/arch/arm64/mm/kasan_init.c
> @@ -84,17 +84,17 @@ static pmd_t *__init kasan_pmd_offset(pu
> return early ? pmd_offset_kimg(pudp, addr) : pmd_offset(pudp, addr);
> }
>
> -static pud_t *__init kasan_pud_offset(pgd_t *pgdp, unsigned long addr, int node,
> +static pud_t *__init kasan_pud_offset(p4d_t *p4dp, unsigned long addr, int node,
> bool early)
> {
> - if (pgd_none(READ_ONCE(*pgdp))) {
> + if (p4d_none(READ_ONCE(*p4dp))) {
> phys_addr_t pud_phys = early ?
> __pa_symbol(kasan_early_shadow_pud)
> : kasan_alloc_zeroed_page(node);
> - __pgd_populate(pgdp, pud_phys, PMD_TYPE_TABLE);
> + __p4d_populate(p4dp, pud_phys, PMD_TYPE_TABLE);
> }
>
> - return early ? pud_offset_kimg(pgdp, addr) : pud_offset(pgdp, addr);
> + return early ? pud_offset_kimg(p4dp, addr) : pud_offset(p4dp, addr);
> }
>
> static void __init kasan_pte_populate(pmd_t *pmdp, unsigned long addr,
> @@ -126,11 +126,11 @@ static void __init kasan_pmd_populate(pu
> } while (pmdp++, addr = next, addr != end && pmd_none(READ_ONCE(*pmdp)));
> }
>
> -static void __init kasan_pud_populate(pgd_t *pgdp, unsigned long addr,
> +static void __init kasan_pud_populate(p4d_t *p4dp, unsigned long addr,
> unsigned long end, int node, bool early)
> {
> unsigned long next;
> - pud_t *pudp = kasan_pud_offset(pgdp, addr, node, early);
> + pud_t *pudp = kasan_pud_offset(p4dp, addr, node, early);
>
> do {
> next = pud_addr_end(addr, end);
> @@ -138,6 +138,18 @@ static void __init kasan_pud_populate(pg
> } while (pudp++, addr = next, addr != end && pud_none(READ_ONCE(*pudp)));
> }
>
> +static void __init kasan_p4d_populate(pgd_t *pgdp, unsigned long addr,
> + unsigned long end, int node, bool early)
> +{
> + unsigned long next;
> + p4d_t *p4dp = p4d_offset(pgdp, addr);
> +
> + do {
> + next = p4d_addr_end(addr, end);
> + kasan_pud_populate(p4dp, addr, next, node, early);
> + } while (p4dp++, addr = next, addr != end);
> +}
> +
> static void __init kasan_pgd_populate(unsigned long addr, unsigned long end,
> int node, bool early)
> {
> @@ -147,7 +159,7 @@ static void __init kasan_pgd_populate(un
> pgdp = pgd_offset_k(addr);
> do {
> next = pgd_addr_end(addr, end);
> - kasan_pud_populate(pgdp, addr, next, node, early);
> + kasan_p4d_populate(pgdp, addr, next, node, early);
> } while (pgdp++, addr = next, addr != end);
> }
>
> --- a/arch/arm64/mm/mmu.c~arm64-add-support-for-folded-p4d-page-tables
> +++ a/arch/arm64/mm/mmu.c
> @@ -290,18 +290,19 @@ static void alloc_init_pud(pgd_t *pgdp,
> {
> unsigned long next;
> pud_t *pudp;
> - pgd_t pgd = READ_ONCE(*pgdp);
> + p4d_t *p4dp = p4d_offset(pgdp, addr);
> + p4d_t p4d = READ_ONCE(*p4dp);
>
> - if (pgd_none(pgd)) {
> + if (p4d_none(p4d)) {
> phys_addr_t pud_phys;
> BUG_ON(!pgtable_alloc);
> pud_phys = pgtable_alloc(PUD_SHIFT);
> - __pgd_populate(pgdp, pud_phys, PUD_TYPE_TABLE);
> - pgd = READ_ONCE(*pgdp);
> + __p4d_populate(p4dp, pud_phys, PUD_TYPE_TABLE);
> + p4d = READ_ONCE(*p4dp);
> }
> - BUG_ON(pgd_bad(pgd));
> + BUG_ON(p4d_bad(p4d));
>
> - pudp = pud_set_fixmap_offset(pgdp, addr);
> + pudp = pud_set_fixmap_offset(p4dp, addr);
> do {
> pud_t old_pud = READ_ONCE(*pudp);
>
> @@ -672,6 +673,7 @@ static void __init map_kernel(pgd_t *pgd
> READ_ONCE(*pgd_offset_k(FIXADDR_START)));
> } else if (CONFIG_PGTABLE_LEVELS > 3) {
> pgd_t *bm_pgdp;
> + p4d_t *bm_p4dp;
> pud_t *bm_pudp;
> /*
> * The fixmap shares its top level pgd entry with the kernel
> @@ -681,7 +683,8 @@ static void __init map_kernel(pgd_t *pgd
> */
> BUG_ON(!IS_ENABLED(CONFIG_ARM64_16K_PAGES));
> bm_pgdp = pgd_offset_raw(pgdp, FIXADDR_START);
> - bm_pudp = pud_set_fixmap_offset(bm_pgdp, FIXADDR_START);
> + bm_p4dp = p4d_offset(bm_pgdp, FIXADDR_START);
> + bm_pudp = pud_set_fixmap_offset(bm_p4dp, FIXADDR_START);
> pud_populate(&init_mm, bm_pudp, lm_alias(bm_pmd));
> pud_clear_fixmap();
> } else {
> @@ -715,6 +718,7 @@ void __init paging_init(void)
> int kern_addr_valid(unsigned long addr)
> {
> pgd_t *pgdp;
> + p4d_t *p4dp;
> pud_t *pudp, pud;
> pmd_t *pmdp, pmd;
> pte_t *ptep, pte;
> @@ -726,7 +730,11 @@ int kern_addr_valid(unsigned long addr)
> if (pgd_none(READ_ONCE(*pgdp)))
> return 0;
>
> - pudp = pud_offset(pgdp, addr);
> + p4dp = p4d_offset(pgdp, addr);
> + if (p4d_none(READ_ONCE(*p4dp)))
> + return 0;
> +
> + pudp = pud_offset(p4dp, addr);
> pud = READ_ONCE(*pudp);
> if (pud_none(pud))
> return 0;
> @@ -1069,6 +1077,7 @@ int __meminit vmemmap_populate(unsigned
> unsigned long addr = start;
> unsigned long next;
> pgd_t *pgdp;
> + p4d_t *p4dp;
> pud_t *pudp;
> pmd_t *pmdp;
>
> @@ -1079,7 +1088,11 @@ int __meminit vmemmap_populate(unsigned
> if (!pgdp)
> return -ENOMEM;
>
> - pudp = vmemmap_pud_populate(pgdp, addr, node);
> + p4dp = vmemmap_p4d_populate(pgdp, addr, node);
> + if (!p4dp)
> + return -ENOMEM;
> +
> + pudp = vmemmap_pud_populate(p4dp, addr, node);
> if (!pudp)
> return -ENOMEM;
>
> @@ -1114,11 +1127,12 @@ void vmemmap_free(unsigned long start, u
> static inline pud_t * fixmap_pud(unsigned long addr)
> {
> pgd_t *pgdp = pgd_offset_k(addr);
> - pgd_t pgd = READ_ONCE(*pgdp);
> + p4d_t *p4dp = p4d_offset(pgdp, addr);
> + p4d_t p4d = READ_ONCE(*p4dp);
>
> - BUG_ON(pgd_none(pgd) || pgd_bad(pgd));
> + BUG_ON(p4d_none(p4d) || p4d_bad(p4d));
>
> - return pud_offset_kimg(pgdp, addr);
> + return pud_offset_kimg(p4dp, addr);
> }
>
> static inline pmd_t * fixmap_pmd(unsigned long addr)
> @@ -1144,25 +1158,27 @@ static inline pte_t * fixmap_pte(unsigne
> */
> void __init early_fixmap_init(void)
> {
> - pgd_t *pgdp, pgd;
> + pgd_t *pgdp;
> + p4d_t *p4dp, p4d;
> pud_t *pudp;
> pmd_t *pmdp;
> unsigned long addr = FIXADDR_START;
>
> pgdp = pgd_offset_k(addr);
> - pgd = READ_ONCE(*pgdp);
> + p4dp = p4d_offset(pgdp, addr);
> + p4d = READ_ONCE(*p4dp);
> if (CONFIG_PGTABLE_LEVELS > 3 &&
> - !(pgd_none(pgd) || pgd_page_paddr(pgd) == __pa_symbol(bm_pud))) {
> + !(p4d_none(p4d) || p4d_page_paddr(p4d) == __pa_symbol(bm_pud))) {
> /*
> * We only end up here if the kernel mapping and the fixmap
> * share the top level pgd entry, which should only happen on
> * 16k/4 levels configurations.
> */
> BUG_ON(!IS_ENABLED(CONFIG_ARM64_16K_PAGES));
> - pudp = pud_offset_kimg(pgdp, addr);
> + pudp = pud_offset_kimg(p4dp, addr);
> } else {
> - if (pgd_none(pgd))
> - __pgd_populate(pgdp, __pa_symbol(bm_pud), PUD_TYPE_TABLE);
> + if (p4d_none(p4d))
> + __p4d_populate(p4dp, __pa_symbol(bm_pud), PUD_TYPE_TABLE);
> pudp = fixmap_pud(addr);
> }
> if (pud_none(READ_ONCE(*pudp)))
> --- a/arch/arm64/mm/pageattr.c~arm64-add-support-for-folded-p4d-page-tables
> +++ a/arch/arm64/mm/pageattr.c
> @@ -198,6 +198,7 @@ void __kernel_map_pages(struct page *pag
> bool kernel_page_present(struct page *page)
> {
> pgd_t *pgdp;
> + p4d_t *p4dp;
> pud_t *pudp, pud;
> pmd_t *pmdp, pmd;
> pte_t *ptep;
> @@ -210,7 +211,11 @@ bool kernel_page_present(struct page *pa
> if (pgd_none(READ_ONCE(*pgdp)))
> return false;
>
> - pudp = pud_offset(pgdp, addr);
> + p4dp = p4d_offset(pgdp, addr);
> + if (p4d_none(READ_ONCE(*p4dp)))
> + return false;
> +
> + pudp = pud_offset(p4dp, addr);
> pud = READ_ONCE(*pudp);
> if (pud_none(pud))
> return false;
> _
>
--
Sincerely yours,
Mike.
^ permalink raw reply
* Re: [PATCH v8 12/30] powerpc: Use a function for reading instructions
From: Christophe Leroy @ 2020-05-16 18:39 UTC (permalink / raw)
To: Jordan Niethe, linuxppc-dev
Cc: christophe.leroy, alistair, npiggin, bala24, naveen.n.rao, dja
In-Reply-To: <20200506034050.24806-13-jniethe5@gmail.com>
Le 06/05/2020 à 05:40, Jordan Niethe a écrit :
> Prefixed instructions will mean there are instructions of different
> length. As a result dereferencing a pointer to an instruction will not
> necessarily give the desired result. Introduce a function for reading
> instructions from memory into the instruction data type.
Shouldn't this function be used in mmu_patch_addis() in mm/nohash/8xx.c ?
Christophe
>
> Reviewed-by: Alistair Popple <alistair@popple.id.au>
> Signed-off-by: Jordan Niethe <jniethe5@gmail.com>
> ---
> v4: New to series
> v5: - Rename read_inst() -> probe_kernel_read_inst()
> - No longer modify uprobe probe type in this patch
> v6: - feature-fixups.c: do_final_fixups(): Use here
> - arch_prepare_kprobe(): patch_instruction(): no longer part of this
> patch
> - Move probe_kernel_read_inst() out of this patch
> - Use in uprobes
> v8: style
> ---
> arch/powerpc/include/asm/inst.h | 5 +++++
> arch/powerpc/kernel/kprobes.c | 6 +++---
> arch/powerpc/kernel/mce_power.c | 2 +-
> arch/powerpc/kernel/optprobes.c | 4 ++--
> arch/powerpc/kernel/trace/ftrace.c | 4 ++--
> arch/powerpc/kernel/uprobes.c | 2 +-
> arch/powerpc/lib/code-patching.c | 26 ++++++++++++++------------
> arch/powerpc/lib/feature-fixups.c | 4 ++--
> arch/powerpc/xmon/xmon.c | 6 +++---
> 9 files changed, 33 insertions(+), 26 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/inst.h b/arch/powerpc/include/asm/inst.h
> index 19d8bb7a1c2b..552e953bf04f 100644
> --- a/arch/powerpc/include/asm/inst.h
> +++ b/arch/powerpc/include/asm/inst.h
> @@ -27,6 +27,11 @@ static inline struct ppc_inst ppc_inst_swab(struct ppc_inst x)
> return ppc_inst(swab32(ppc_inst_val(x)));
> }
>
> +static inline struct ppc_inst ppc_inst_read(const struct ppc_inst *ptr)
> +{
> + return *ptr;
> +}
> +
> static inline bool ppc_inst_equal(struct ppc_inst x, struct ppc_inst y)
> {
> return ppc_inst_val(x) == ppc_inst_val(y);
> diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
> index a08ae5803622..f64312dca84f 100644
> --- a/arch/powerpc/kernel/kprobes.c
> +++ b/arch/powerpc/kernel/kprobes.c
> @@ -106,7 +106,7 @@ kprobe_opcode_t *kprobe_lookup_name(const char *name, unsigned int offset)
> int arch_prepare_kprobe(struct kprobe *p)
> {
> int ret = 0;
> - struct ppc_inst insn = *(struct ppc_inst *)p->addr;
> + struct ppc_inst insn = ppc_inst_read((struct ppc_inst *)p->addr);
>
> if ((unsigned long)p->addr & 0x03) {
> printk("Attempt to register kprobe at an unaligned address\n");
> @@ -127,7 +127,7 @@ int arch_prepare_kprobe(struct kprobe *p)
> if (!ret) {
> memcpy(p->ainsn.insn, p->addr,
> MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
> - p->opcode = *p->addr;
> + p->opcode = ppc_inst_val(insn);
> flush_icache_range((unsigned long)p->ainsn.insn,
> (unsigned long)p->ainsn.insn + sizeof(kprobe_opcode_t));
> }
> @@ -217,7 +217,7 @@ NOKPROBE_SYMBOL(arch_prepare_kretprobe);
> static int try_to_emulate(struct kprobe *p, struct pt_regs *regs)
> {
> int ret;
> - struct ppc_inst insn = *(struct ppc_inst *)p->ainsn.insn;
> + struct ppc_inst insn = ppc_inst_read((struct ppc_inst *)p->ainsn.insn);
>
> /* regs->nip is also adjusted if emulate_step returns 1 */
> ret = emulate_step(regs, insn);
> diff --git a/arch/powerpc/kernel/mce_power.c b/arch/powerpc/kernel/mce_power.c
> index cd23218c60bb..45c51ba0071b 100644
> --- a/arch/powerpc/kernel/mce_power.c
> +++ b/arch/powerpc/kernel/mce_power.c
> @@ -374,7 +374,7 @@ static int mce_find_instr_ea_and_phys(struct pt_regs *regs, uint64_t *addr,
> pfn = addr_to_pfn(regs, regs->nip);
> if (pfn != ULONG_MAX) {
> instr_addr = (pfn << PAGE_SHIFT) + (regs->nip & ~PAGE_MASK);
> - instr = *(struct ppc_inst *)(instr_addr);
> + instr = ppc_inst_read((struct ppc_inst *)instr_addr);
> if (!analyse_instr(&op, &tmp, instr)) {
> pfn = addr_to_pfn(regs, op.ea);
> *addr = op.ea;
> diff --git a/arch/powerpc/kernel/optprobes.c b/arch/powerpc/kernel/optprobes.c
> index 5a71fef71c22..52c1ab3f85aa 100644
> --- a/arch/powerpc/kernel/optprobes.c
> +++ b/arch/powerpc/kernel/optprobes.c
> @@ -100,9 +100,9 @@ static unsigned long can_optimize(struct kprobe *p)
> * Ensure that the instruction is not a conditional branch,
> * and that can be emulated.
> */
> - if (!is_conditional_branch(*(struct ppc_inst *)p->ainsn.insn) &&
> + if (!is_conditional_branch(ppc_inst_read((struct ppc_inst *)p->ainsn.insn)) &&
> analyse_instr(&op, ®s,
> - *(struct ppc_inst *)p->ainsn.insn) == 1) {
> + ppc_inst_read((struct ppc_inst *)p->ainsn.insn)) == 1) {
> emulate_update_regs(®s, &op);
> nip = regs.nip;
> }
> diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c
> index 3117ed675735..acd5b889815f 100644
> --- a/arch/powerpc/kernel/trace/ftrace.c
> +++ b/arch/powerpc/kernel/trace/ftrace.c
> @@ -848,7 +848,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
> struct ppc_inst old, new;
> int ret;
>
> - old = *(struct ppc_inst *)&ftrace_call;
> + old = ppc_inst_read((struct ppc_inst *)&ftrace_call);
> new = ftrace_call_replace(ip, (unsigned long)func, 1);
> ret = ftrace_modify_code(ip, old, new);
>
> @@ -856,7 +856,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
> /* Also update the regs callback function */
> if (!ret) {
> ip = (unsigned long)(&ftrace_regs_call);
> - old = *(struct ppc_inst *)&ftrace_regs_call;
> + old = ppc_inst_read((struct ppc_inst *)&ftrace_regs_call);
> new = ftrace_call_replace(ip, (unsigned long)func, 1);
> ret = ftrace_modify_code(ip, old, new);
> }
> diff --git a/arch/powerpc/kernel/uprobes.c b/arch/powerpc/kernel/uprobes.c
> index 31c870287f2b..6893d40a48c5 100644
> --- a/arch/powerpc/kernel/uprobes.c
> +++ b/arch/powerpc/kernel/uprobes.c
> @@ -174,7 +174,7 @@ bool arch_uprobe_skip_sstep(struct arch_uprobe *auprobe, struct pt_regs *regs)
> * emulate_step() returns 1 if the insn was successfully emulated.
> * For all other cases, we need to single-step in hardware.
> */
> - ret = emulate_step(regs, auprobe->insn);
> + ret = emulate_step(regs, ppc_inst_read(&auprobe->insn));
> if (ret > 0)
> return true;
>
> diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c
> index 1dff9d9d6645..435fc8e9f45d 100644
> --- a/arch/powerpc/lib/code-patching.c
> +++ b/arch/powerpc/lib/code-patching.c
> @@ -348,9 +348,9 @@ static unsigned long branch_bform_target(const struct ppc_inst *instr)
>
> unsigned long branch_target(const struct ppc_inst *instr)
> {
> - if (instr_is_branch_iform(*instr))
> + if (instr_is_branch_iform(ppc_inst_read(instr)))
> return branch_iform_target(instr);
> - else if (instr_is_branch_bform(*instr))
> + else if (instr_is_branch_bform(ppc_inst_read(instr)))
> return branch_bform_target(instr);
>
> return 0;
> @@ -358,7 +358,8 @@ unsigned long branch_target(const struct ppc_inst *instr)
>
> int instr_is_branch_to_addr(const struct ppc_inst *instr, unsigned long addr)
> {
> - if (instr_is_branch_iform(*instr) || instr_is_branch_bform(*instr))
> + if (instr_is_branch_iform(ppc_inst_read(instr)) ||
> + instr_is_branch_bform(ppc_inst_read(instr)))
> return branch_target(instr) == addr;
>
> return 0;
> @@ -368,13 +369,14 @@ int translate_branch(struct ppc_inst *instr, const struct ppc_inst *dest,
> const struct ppc_inst *src)
> {
> unsigned long target;
> -
> target = branch_target(src);
>
> - if (instr_is_branch_iform(*src))
> - return create_branch(instr, dest, target, ppc_inst_val(*src));
> - else if (instr_is_branch_bform(*src))
> - return create_cond_branch(instr, dest, target, ppc_inst_val(*src));
> + if (instr_is_branch_iform(ppc_inst_read(src)))
> + return create_branch(instr, dest, target,
> + ppc_inst_val(ppc_inst_read(src)));
> + else if (instr_is_branch_bform(ppc_inst_read(src)))
> + return create_cond_branch(instr, dest, target,
> + ppc_inst_val(ppc_inst_read(src)));
>
> return 1;
> }
> @@ -598,7 +600,7 @@ static void __init test_translate_branch(void)
> patch_instruction(q, instr);
> check(instr_is_branch_to_addr(p, addr));
> check(instr_is_branch_to_addr(q, addr));
> - check(ppc_inst_equal(*q, ppc_inst(0x4a000000)));
> + check(ppc_inst_equal(ppc_inst_read(q), ppc_inst(0x4a000000)));
>
> /* Maximum positive case, move x to x - 32 MB + 4 */
> p = buf + 0x2000000;
> @@ -609,7 +611,7 @@ static void __init test_translate_branch(void)
> patch_instruction(q, instr);
> check(instr_is_branch_to_addr(p, addr));
> check(instr_is_branch_to_addr(q, addr));
> - check(ppc_inst_equal(*q, ppc_inst(0x49fffffc)));
> + check(ppc_inst_equal(ppc_inst_read(q), ppc_inst(0x49fffffc)));
>
> /* Jump to x + 16 MB moved to x + 20 MB */
> p = buf;
> @@ -655,7 +657,7 @@ static void __init test_translate_branch(void)
> patch_instruction(q, instr);
> check(instr_is_branch_to_addr(p, addr));
> check(instr_is_branch_to_addr(q, addr));
> - check(ppc_inst_equal(*q, ppc_inst(0x43ff8000)));
> + check(ppc_inst_equal(ppc_inst_read(q), ppc_inst(0x43ff8000)));
>
> /* Maximum positive case, move x to x - 32 KB + 4 */
> p = buf + 0x8000;
> @@ -667,7 +669,7 @@ static void __init test_translate_branch(void)
> patch_instruction(q, instr);
> check(instr_is_branch_to_addr(p, addr));
> check(instr_is_branch_to_addr(q, addr));
> - check(ppc_inst_equal(*q, ppc_inst(0x43ff7ffc)));
> + check(ppc_inst_equal(ppc_inst_read(q), ppc_inst(0x43ff7ffc)));
>
> /* Jump to x + 12 KB moved to x + 20 KB */
> p = buf;
> diff --git a/arch/powerpc/lib/feature-fixups.c b/arch/powerpc/lib/feature-fixups.c
> index fb6e8e8abf4e..c0d3ed4efb7e 100644
> --- a/arch/powerpc/lib/feature-fixups.c
> +++ b/arch/powerpc/lib/feature-fixups.c
> @@ -48,7 +48,7 @@ static int patch_alt_instruction(struct ppc_inst *src, struct ppc_inst *dest,
> int err;
> struct ppc_inst instr;
>
> - instr = *src;
> + instr = ppc_inst_read(src);
>
> if (instr_is_relative_branch(*src)) {
> struct ppc_inst *target = (struct ppc_inst *)branch_target(src);
> @@ -403,7 +403,7 @@ static void do_final_fixups(void)
> length = (__end_interrupts - _stext) / sizeof(struct ppc_inst);
>
> while (length--) {
> - raw_patch_instruction(dest, *src);
> + raw_patch_instruction(dest, ppc_inst_read(src));
> src++;
> dest++;
> }
> diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
> index e0132d6d24d0..68e0b05d9226 100644
> --- a/arch/powerpc/xmon/xmon.c
> +++ b/arch/powerpc/xmon/xmon.c
> @@ -702,13 +702,13 @@ static int xmon_core(struct pt_regs *regs, int fromipi)
> if ((regs->msr & (MSR_IR|MSR_PR|MSR_64BIT)) == (MSR_IR|MSR_64BIT)) {
> bp = at_breakpoint(regs->nip);
> if (bp != NULL) {
> - int stepped = emulate_step(regs, bp->instr[0]);
> + int stepped = emulate_step(regs, ppc_inst_read(bp->instr));
> if (stepped == 0) {
> regs->nip = (unsigned long) &bp->instr[0];
> atomic_inc(&bp->ref_count);
> } else if (stepped < 0) {
> printf("Couldn't single-step %s instruction\n",
> - (IS_RFID(bp->instr[0])? "rfid": "mtmsrd"));
> + IS_RFID(ppc_inst_read(bp->instr))? "rfid": "mtmsrd");
> }
> }
> }
> @@ -949,7 +949,7 @@ static void remove_bpts(void)
> if (mread(bp->address, &instr, 4) == 4
> && ppc_inst_equal(instr, ppc_inst(bpinstr))
> && patch_instruction(
> - (struct ppc_inst *)bp->address, bp->instr[0]) != 0)
> + (struct ppc_inst *)bp->address, ppc_inst_read(bp->instr)) != 0)
> printf("Couldn't remove breakpoint at %lx\n",
> bp->address);
> }
>
^ permalink raw reply
* Re: [PATCH V3 07/15] arch/kunmap_atomic: Consolidate duplicate code
From: Guenter Roeck @ 2020-05-16 22:33 UTC (permalink / raw)
To: ira.weiny
Cc: Peter Zijlstra, Dave Hansen, dri-devel, linux-mips,
James E.J. Bottomley, Max Filippov, Paul Mackerras,
H. Peter Anvin, sparclinux, Dan Williams, Helge Deller, x86,
linux-csky, Christoph Hellwig, Ingo Molnar, linux-snps-arc,
linux-xtensa, Borislav Petkov, Al Viro, Andy Lutomirski,
Thomas Gleixner, linux-arm-kernel, Chris Zankel,
Thomas Bogendoerfer, linux-parisc, linux-kernel, Christian Koenig,
Andrew Morton, linuxppc-dev, David S. Miller
In-Reply-To: <20200507150004.1423069-8-ira.weiny@intel.com>
On Thu, May 07, 2020 at 07:59:55AM -0700, ira.weiny@intel.com wrote:
> From: Ira Weiny <ira.weiny@intel.com>
>
> Every single architecture (including !CONFIG_HIGHMEM) calls...
>
> pagefault_enable();
> preempt_enable();
>
> ... before returning from __kunmap_atomic(). Lift this code into the
> kunmap_atomic() macro.
>
> While we are at it rename __kunmap_atomic() to kunmap_atomic_high() to
> be consistent.
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Ira Weiny <ira.weiny@intel.com>
This patch results in:
Starting init: /bin/sh exists but couldn't execute it (error -14)
when trying to boot microblazeel:petalogix-ml605 in qemu.
Bisect log attached.
Guenter
---
# bad: [bdecf38f228bcca73b31ada98b5b7ba1215eb9c9] Add linux-next specific files for 20200515
# good: [2ef96a5bb12be62ef75b5828c0aab838ebb29cb8] Linux 5.7-rc5
git bisect start 'HEAD' 'v5.7-rc5'
# good: [3674d7aa7a8e61d993886c2fb7c896c5ef85e988] Merge remote-tracking branch 'crypto/master'
git bisect good 3674d7aa7a8e61d993886c2fb7c896c5ef85e988
# good: [87f6f21783522e6d62127cf33ae5e95f50874beb] Merge remote-tracking branch 'spi/for-next'
git bisect good 87f6f21783522e6d62127cf33ae5e95f50874beb
# good: [5c428e8277d5d97c85126387d4e00aa5adde4400] Merge remote-tracking branch 'staging/staging-next'
git bisect good 5c428e8277d5d97c85126387d4e00aa5adde4400
# good: [f68de67ed934e7bdef4799fd7777c86f33f14982] Merge remote-tracking branch 'hyperv/hyperv-next'
git bisect good f68de67ed934e7bdef4799fd7777c86f33f14982
# bad: [54acd2dc52b069da59639eea0d0c92726f32fb01] mm/memblock: fix a typo in comment "implict"->"implicit"
git bisect bad 54acd2dc52b069da59639eea0d0c92726f32fb01
# good: [784a17aa58a529b84f7cc50f351ed4acf3bd11f3] mm: remove the pgprot argument to __vmalloc
git bisect good 784a17aa58a529b84f7cc50f351ed4acf3bd11f3
# good: [6cd8137ff37e9a37aee2d2a8889c8beb8eab192f] khugepaged: replace the usage of system(3) in the test
git bisect good 6cd8137ff37e9a37aee2d2a8889c8beb8eab192f
# bad: [6987da379826ed01b8a1cf046b67cc8cc10117cc] sparc: remove unnecessary includes
git bisect bad 6987da379826ed01b8a1cf046b67cc8cc10117cc
# good: [bc17b545388f64c09e83e367898e28f60277c584] mm/hugetlb: define a generic fallback for is_hugepage_only_range()
git bisect good bc17b545388f64c09e83e367898e28f60277c584
# bad: [9b5aa5b43f957f03a1f4a9aff5f7924e2ebbc011] arch-kmap_atomic-consolidate-duplicate-code-checkpatch-fixes
git bisect bad 9b5aa5b43f957f03a1f4a9aff5f7924e2ebbc011
# good: [0941a38ff0790c1004270f952067a5918a4ba32d] arch/kmap: remove redundant arch specific kmaps
git bisect good 0941a38ff0790c1004270f952067a5918a4ba32d
# good: [56e635a64c2cbfa815c851af10e0f811e809977b] arch-kunmap-remove-duplicate-kunmap-implementations-fix
git bisect good 56e635a64c2cbfa815c851af10e0f811e809977b
# bad: [60f96b2233c790d4f1c49317643051f1670bcb29] arch/kmap_atomic: consolidate duplicate code
git bisect bad 60f96b2233c790d4f1c49317643051f1670bcb29
# good: [7b3708dc3bf72a647243064fe7ddf9a76248ddfd] {x86,powerpc,microblaze}/kmap: move preempt disable
git bisect good 7b3708dc3bf72a647243064fe7ddf9a76248ddfd
# first bad commit: [60f96b2233c790d4f1c49317643051f1670bcb29] arch/kmap_atomic: consolidate duplicate code
^ permalink raw reply
* [powerpc:merge] BUILD SUCCESS 5b55902a1d35b73daec747b11b903959b8e7aa70
From: kbuild test robot @ 2020-05-17 0:06 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: 5b55902a1d35b73daec747b11b903959b8e7aa70 Automatic merge of 'master', 'next' and 'fixes' (2020-05-16 21:36)
elapsed time: 553m
configs tested: 117
configs skipped: 3
The following configs have been built successfully.
More configs may be tested in the coming days.
arm64 allyesconfig
arm64 defconfig
arm64 allmodconfig
arm64 allnoconfig
arm defconfig
arm allyesconfig
arm allmodconfig
arm allnoconfig
mips allyesconfig
m68k allyesconfig
s390 zfcpdump_defconfig
powerpc mpc866_ads_defconfig
powerpc adder875_defconfig
sh microdev_defconfig
arm shannon_defconfig
sh kfr2r09-romimage_defconfig
powerpc pq2fads_defconfig
mips bmips_stb_defconfig
csky alldefconfig
mips malta_kvm_guest_defconfig
arm imx_v4_v5_defconfig
arm moxart_defconfig
c6x dsk6455_defconfig
mips gpr_defconfig
sh sh2007_defconfig
arm vt8500_v6_v7_defconfig
powerpc g5_defconfig
powerpc cell_defconfig
arm multi_v7_defconfig
i386 allnoconfig
i386 defconfig
i386 debian-10.3
i386 allyesconfig
ia64 allmodconfig
ia64 defconfig
ia64 allnoconfig
ia64 allyesconfig
m68k allmodconfig
m68k allnoconfig
m68k sun3_defconfig
m68k defconfig
nds32 defconfig
nds32 allnoconfig
csky allyesconfig
csky defconfig
alpha defconfig
alpha allyesconfig
xtensa allyesconfig
h8300 allyesconfig
h8300 allmodconfig
xtensa defconfig
nios2 defconfig
nios2 allyesconfig
openrisc defconfig
c6x allyesconfig
c6x allnoconfig
openrisc allyesconfig
arc defconfig
arc allyesconfig
sh allmodconfig
sh allnoconfig
microblaze allnoconfig
mips allnoconfig
mips allmodconfig
parisc allnoconfig
parisc defconfig
parisc allyesconfig
parisc allmodconfig
powerpc defconfig
powerpc allyesconfig
powerpc rhel-kconfig
powerpc allmodconfig
powerpc allnoconfig
i386 randconfig-a006-20200515
i386 randconfig-a005-20200515
i386 randconfig-a003-20200515
i386 randconfig-a001-20200515
i386 randconfig-a004-20200515
i386 randconfig-a002-20200515
i386 randconfig-a012-20200515
i386 randconfig-a016-20200515
i386 randconfig-a014-20200515
i386 randconfig-a011-20200515
i386 randconfig-a013-20200515
i386 randconfig-a015-20200515
x86_64 randconfig-a005-20200515
x86_64 randconfig-a003-20200515
x86_64 randconfig-a006-20200515
x86_64 randconfig-a004-20200515
x86_64 randconfig-a001-20200515
x86_64 randconfig-a002-20200515
riscv allyesconfig
riscv allnoconfig
riscv defconfig
riscv allmodconfig
s390 allyesconfig
s390 allnoconfig
s390 allmodconfig
s390 defconfig
x86_64 defconfig
sparc allyesconfig
sparc defconfig
sparc64 defconfig
sparc64 allnoconfig
sparc64 allyesconfig
sparc64 allmodconfig
um allmodconfig
um allnoconfig
um allyesconfig
um defconfig
x86_64 rhel
x86_64 rhel-7.6
x86_64 rhel-7.6-kselftests
x86_64 rhel-7.2-clear
x86_64 lkp
x86_64 fedora-25
x86_64 kexec
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply
* [powerpc:next-test] BUILD SUCCESS 7b92ee1db93df64553a36f23fec86298d37ee10a
From: kbuild test robot @ 2020-05-17 2:27 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next-test
branch HEAD: 7b92ee1db93df64553a36f23fec86298d37ee10a powerpc/watchpoint/xmon: Support 2nd DAWR
i386-tinyconfig vmlinux size:
+-------+------------------------------------+-----------------------------------------------------------------------+
| DELTA | SYMBOL | COMMIT |
+-------+------------------------------------+-----------------------------------------------------------------------+
| +118 | TOTAL | ae83d0b416db..7b92ee1db93d (ALL COMMITS) |
| +114 | TEXT | ae83d0b416db..7b92ee1db93d (ALL COMMITS) |
| +1355 | balance_dirty_pages() | ae83d0b416db..7b92ee1db93d (ALL COMMITS) |
| +615 | __setup_rt_frame() | ae83d0b416db..7b92ee1db93d (ALL COMMITS) |
| +136 | arch/x86/events/zhaoxin/built-in.* | ae83d0b416db..7b92ee1db93d (ALL COMMITS) |
| +136 | arch/x86/events/zhaoxin/built-in.* | 722c1963aba5 selftests/powerpc: Add README for GZIP engine tests |
| -136 | arch/x86/events/zhaoxin/built-in.* | 45591da76588 powerpc/vas: Include linux/types.h in uapi/asm/vas-api.h |
| +113 | klist_release() | ae83d0b416db..7b92ee1db93d (ALL COMMITS) |
| +93 | change_clocksource() | ae83d0b416db..7b92ee1db93d (ALL COMMITS) |
| +86 | release_bdi() | ae83d0b416db..7b92ee1db93d (ALL COMMITS) |
| +84 | kobject_release() | ae83d0b416db..7b92ee1db93d (ALL COMMITS) |
| -68 | bdi_put() | ae83d0b416db..7b92ee1db93d (ALL COMMITS) |
| -77 | kobject_put() | ae83d0b416db..7b92ee1db93d (ALL COMMITS) |
| -79 | timekeeping_notify() | ae83d0b416db..7b92ee1db93d (ALL COMMITS) |
| -99 | klist_dec_and_del() | ae83d0b416db..7b92ee1db93d (ALL COMMITS) |
| -555 | do_signal() | ae83d0b416db..7b92ee1db93d (ALL COMMITS) |
| -1383 | balance_dirty_pages_ratelimited() | ae83d0b416db..7b92ee1db93d (ALL COMMITS) |
+-------+------------------------------------+-----------------------------------------------------------------------+
elapsed time: 695m
configs tested: 67
configs skipped: 77
The following configs have been built successfully.
More configs may be tested in the coming days.
sparc allyesconfig
mips allyesconfig
m68k allyesconfig
arm em_x270_defconfig
powerpc pq2fads_defconfig
mips cu1000-neo_defconfig
powerpc ppc40x_defconfig
sh shx3_defconfig
m68k hp300_defconfig
ia64 allmodconfig
powerpc powernv_defconfig
arm aspeed_g5_defconfig
sh titan_defconfig
microblaze mmu_defconfig
arm jornada720_defconfig
arm spear3xx_defconfig
i386 allnoconfig
xtensa allyesconfig
h8300 allyesconfig
h8300 allmodconfig
xtensa defconfig
nios2 defconfig
nios2 allyesconfig
openrisc defconfig
c6x allyesconfig
c6x allnoconfig
openrisc allyesconfig
powerpc defconfig
powerpc allyesconfig
powerpc rhel-kconfig
powerpc allmodconfig
powerpc allnoconfig
i386 randconfig-a006-20200517
i386 randconfig-a005-20200517
i386 randconfig-a003-20200517
i386 randconfig-a001-20200517
i386 randconfig-a004-20200517
i386 randconfig-a002-20200517
x86_64 randconfig-a005-20200517
x86_64 randconfig-a003-20200517
x86_64 randconfig-a006-20200517
x86_64 randconfig-a004-20200517
x86_64 randconfig-a001-20200517
x86_64 randconfig-a002-20200517
i386 randconfig-a012-20200517
i386 randconfig-a016-20200517
i386 randconfig-a014-20200517
i386 randconfig-a011-20200517
i386 randconfig-a013-20200517
i386 randconfig-a015-20200517
i386 randconfig-a012-20200515
i386 randconfig-a016-20200515
i386 randconfig-a014-20200515
i386 randconfig-a013-20200515
x86_64 defconfig
i386 allyesconfig
um allmodconfig
um allnoconfig
um allyesconfig
um defconfig
x86_64 rhel
x86_64 rhel-7.6
x86_64 rhel-7.6-kselftests
x86_64 rhel-7.2-clear
x86_64 lkp
x86_64 fedora-25
x86_64 kexec
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply
* Re: [GIT PULL] Please pull powerpc/linux.git powerpc-5.7-4 tag
From: pr-tracker-bot @ 2020-05-17 4:45 UTC (permalink / raw)
To: Michael Ellerman
Cc: christophe.leroy, Linus Torvalds, nayna, linux-kernel, npiggin,
linuxppc-dev
In-Reply-To: <87pnb49j0c.fsf@mpe.ellerman.id.au>
The pull request you sent on Sat, 16 May 2020 22:11:47 +1000:
> https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git tags/powerpc-5.7-4
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/befc42e5dd4977b63dd3b0c0db05e21d56f13c2e
Thank you!
--
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker
^ permalink raw reply
* Re: [PATCH v8 08/30] powerpc: Use a function for getting the instruction op code
From: Jordan Niethe @ 2020-05-17 7:41 UTC (permalink / raw)
To: Michael Ellerman
Cc: Christophe Leroy, Alistair Popple, Nicholas Piggin, Balamuruhan S,
naveen.n.rao, linuxppc-dev, Daniel Axtens
In-Reply-To: <87v9kw9lx3.fsf@mpe.ellerman.id.au>
On Sat, May 16, 2020 at 9:08 PM Michael Ellerman <mpe@ellerman.id.au> wrote:
>
> Jordan Niethe <jniethe5@gmail.com> writes:
> > mpe, as suggested by Christophe could you please add this.
>
> I did that and ...
>
> > diff --git a/arch/powerpc/include/asm/inst.h b/arch/powerpc/include/asm/inst.h
> > --- a/arch/powerpc/include/asm/inst.h
> > +++ b/arch/powerpc/include/asm/inst.h
> > @@ -2,6 +2,8 @@
> > #ifndef _ASM_INST_H
> > #define _ASM_INST_H
> >
> > +#include <asm/disassemble.h>
>
> .. this eventually breaks the build in some driver, because get_ra() is
> redefined.
>
> So I've backed out this change for now.
Thanks, that is fine with me.
>
> If we want to use the macros in disassemble.h we'll need to namespace
> them better, eg. make them ppc_get_ra() and so on.
>
> cheers
>
> > /*
> > * Instruction data type for POWER
> > */
> > @@ -15,7 +17,7 @@ static inline u32 ppc_inst_val(u32 x)
> >
> > static inline int ppc_inst_primary_opcode(u32 x)
> > {
> > - return ppc_inst_val(x) >> 26;
> > + return get_op(ppc_inst_val(x));
> > }
> >
> > #endif /* _ASM_INST_H */
> > --
> > 2.17.1
^ permalink raw reply
* Re: [PATCH] powerpc/64s: Fix early_init_mmu section mismatch
From: Christian Zigotzky @ 2020-05-17 10:12 UTC (permalink / raw)
To: Nicholas Piggin, linuxppc-dev
In-Reply-To: <20200429070247.1678172-1-npiggin@gmail.com>
Hi All,
This patch wasn't included in the PowerPC fixes 5.7-4. Please add it.
Thanks,
Christian
On 29 April 2020 at 09:02 am, Nicholas Piggin wrote:
> Christian reports:
>
> MODPOST vmlinux.o
> WARNING: modpost: vmlinux.o(.text.unlikely+0x1a0): Section mismatch in
> reference from the function .early_init_mmu() to the function
> .init.text:.radix__early_init_mmu()
> The function .early_init_mmu() references
> the function __init .radix__early_init_mmu().
> This is often because .early_init_mmu lacks a __init
> annotation or the annotation of .radix__early_init_mmu is wrong.
>
> WARNING: modpost: vmlinux.o(.text.unlikely+0x1ac): Section mismatch in
> reference from the function .early_init_mmu() to the function
> .init.text:.hash__early_init_mmu()
> The function .early_init_mmu() references
> the function __init .hash__early_init_mmu().
> This is often because .early_init_mmu lacks a __init
> annotation or the annotation of .hash__early_init_mmu is wrong.
>
> The compiler is uninlining early_init_mmu and not putting it in an init
> section because there is no annotation. Add it.
>
> Reported-by: Christian Zigotzky <chzigotzky@xenosoft.de>
> Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> arch/powerpc/include/asm/book3s/64/mmu.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/include/asm/book3s/64/mmu.h b/arch/powerpc/include/asm/book3s/64/mmu.h
> index bb3deb76c951..3ffe5f967483 100644
> --- a/arch/powerpc/include/asm/book3s/64/mmu.h
> +++ b/arch/powerpc/include/asm/book3s/64/mmu.h
> @@ -208,7 +208,7 @@ void hash__early_init_devtree(void);
> void radix__early_init_devtree(void);
> extern void hash__early_init_mmu(void);
> extern void radix__early_init_mmu(void);
> -static inline void early_init_mmu(void)
> +static inline void __init early_init_mmu(void)
> {
> if (radix_enabled())
> return radix__early_init_mmu();
^ permalink raw reply
* Re: [PATCH v8 12/30] powerpc: Use a function for reading instructions
From: Jordan Niethe @ 2020-05-17 10:44 UTC (permalink / raw)
To: Christophe Leroy
Cc: Christophe Leroy, Alistair Popple, Nicholas Piggin, Balamuruhan S,
naveen.n.rao, linuxppc-dev, Daniel Axtens
In-Reply-To: <a7005edf-cdda-4aec-b7b0-fd9f45776147@csgroup.eu>
On Sun, May 17, 2020 at 4:39 AM Christophe Leroy
<christophe.leroy@csgroup.eu> wrote:
>
>
>
> Le 06/05/2020 à 05:40, Jordan Niethe a écrit :
> > Prefixed instructions will mean there are instructions of different
> > length. As a result dereferencing a pointer to an instruction will not
> > necessarily give the desired result. Introduce a function for reading
> > instructions from memory into the instruction data type.
>
>
> Shouldn't this function be used in mmu_patch_addis() in mm/nohash/8xx.c ?
>
> Christophe
Yes, that would be a good idea. mpe here is a fix, along with one I'll
post for [PATCH v8 11/30] powerpc: Use a datatype for instructions.
diff --git a/arch/powerpc/mm/nohash/8xx.c b/arch/powerpc/mm/nohash/8xx.c
--- a/arch/powerpc/mm/nohash/8xx.c
+++ b/arch/powerpc/mm/nohash/8xx.c
@@ -98,7 +98,7 @@ static void mmu_patch_cmp_limit(s32 *site, unsigned
long mapped)
static void mmu_patch_addis(s32 *site, long simm)
{
- struct ppc_inst instr = *(struct ppc_inst *)patch_site_addr(site);
+ struct ppc_inst instr = ppc_inst_read((struct ppc_inst
*)patch_site_addr(site));
unsigned int val = ppc_inst_val(instr);
val &= 0xffff0000;
--
>
> >
> > Reviewed-by: Alistair Popple <alistair@popple.id.au>
> > Signed-off-by: Jordan Niethe <jniethe5@gmail.com>
> > ---
> > v4: New to series
> > v5: - Rename read_inst() -> probe_kernel_read_inst()
> > - No longer modify uprobe probe type in this patch
> > v6: - feature-fixups.c: do_final_fixups(): Use here
> > - arch_prepare_kprobe(): patch_instruction(): no longer part of this
> > patch
> > - Move probe_kernel_read_inst() out of this patch
> > - Use in uprobes
> > v8: style
> > ---
> > arch/powerpc/include/asm/inst.h | 5 +++++
> > arch/powerpc/kernel/kprobes.c | 6 +++---
> > arch/powerpc/kernel/mce_power.c | 2 +-
> > arch/powerpc/kernel/optprobes.c | 4 ++--
> > arch/powerpc/kernel/trace/ftrace.c | 4 ++--
> > arch/powerpc/kernel/uprobes.c | 2 +-
> > arch/powerpc/lib/code-patching.c | 26 ++++++++++++++------------
> > arch/powerpc/lib/feature-fixups.c | 4 ++--
> > arch/powerpc/xmon/xmon.c | 6 +++---
> > 9 files changed, 33 insertions(+), 26 deletions(-)
> >
> > diff --git a/arch/powerpc/include/asm/inst.h b/arch/powerpc/include/asm/inst.h
> > index 19d8bb7a1c2b..552e953bf04f 100644
> > --- a/arch/powerpc/include/asm/inst.h
> > +++ b/arch/powerpc/include/asm/inst.h
> > @@ -27,6 +27,11 @@ static inline struct ppc_inst ppc_inst_swab(struct ppc_inst x)
> > return ppc_inst(swab32(ppc_inst_val(x)));
> > }
> >
> > +static inline struct ppc_inst ppc_inst_read(const struct ppc_inst *ptr)
> > +{
> > + return *ptr;
> > +}
> > +
> > static inline bool ppc_inst_equal(struct ppc_inst x, struct ppc_inst y)
> > {
> > return ppc_inst_val(x) == ppc_inst_val(y);
> > diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
> > index a08ae5803622..f64312dca84f 100644
> > --- a/arch/powerpc/kernel/kprobes.c
> > +++ b/arch/powerpc/kernel/kprobes.c
> > @@ -106,7 +106,7 @@ kprobe_opcode_t *kprobe_lookup_name(const char *name, unsigned int offset)
> > int arch_prepare_kprobe(struct kprobe *p)
> > {
> > int ret = 0;
> > - struct ppc_inst insn = *(struct ppc_inst *)p->addr;
> > + struct ppc_inst insn = ppc_inst_read((struct ppc_inst *)p->addr);
> >
> > if ((unsigned long)p->addr & 0x03) {
> > printk("Attempt to register kprobe at an unaligned address\n");
> > @@ -127,7 +127,7 @@ int arch_prepare_kprobe(struct kprobe *p)
> > if (!ret) {
> > memcpy(p->ainsn.insn, p->addr,
> > MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
> > - p->opcode = *p->addr;
> > + p->opcode = ppc_inst_val(insn);
> > flush_icache_range((unsigned long)p->ainsn.insn,
> > (unsigned long)p->ainsn.insn + sizeof(kprobe_opcode_t));
> > }
> > @@ -217,7 +217,7 @@ NOKPROBE_SYMBOL(arch_prepare_kretprobe);
> > static int try_to_emulate(struct kprobe *p, struct pt_regs *regs)
> > {
> > int ret;
> > - struct ppc_inst insn = *(struct ppc_inst *)p->ainsn.insn;
> > + struct ppc_inst insn = ppc_inst_read((struct ppc_inst *)p->ainsn.insn);
> >
> > /* regs->nip is also adjusted if emulate_step returns 1 */
> > ret = emulate_step(regs, insn);
> > diff --git a/arch/powerpc/kernel/mce_power.c b/arch/powerpc/kernel/mce_power.c
> > index cd23218c60bb..45c51ba0071b 100644
> > --- a/arch/powerpc/kernel/mce_power.c
> > +++ b/arch/powerpc/kernel/mce_power.c
> > @@ -374,7 +374,7 @@ static int mce_find_instr_ea_and_phys(struct pt_regs *regs, uint64_t *addr,
> > pfn = addr_to_pfn(regs, regs->nip);
> > if (pfn != ULONG_MAX) {
> > instr_addr = (pfn << PAGE_SHIFT) + (regs->nip & ~PAGE_MASK);
> > - instr = *(struct ppc_inst *)(instr_addr);
> > + instr = ppc_inst_read((struct ppc_inst *)instr_addr);
> > if (!analyse_instr(&op, &tmp, instr)) {
> > pfn = addr_to_pfn(regs, op.ea);
> > *addr = op.ea;
> > diff --git a/arch/powerpc/kernel/optprobes.c b/arch/powerpc/kernel/optprobes.c
> > index 5a71fef71c22..52c1ab3f85aa 100644
> > --- a/arch/powerpc/kernel/optprobes.c
> > +++ b/arch/powerpc/kernel/optprobes.c
> > @@ -100,9 +100,9 @@ static unsigned long can_optimize(struct kprobe *p)
> > * Ensure that the instruction is not a conditional branch,
> > * and that can be emulated.
> > */
> > - if (!is_conditional_branch(*(struct ppc_inst *)p->ainsn.insn) &&
> > + if (!is_conditional_branch(ppc_inst_read((struct ppc_inst *)p->ainsn.insn)) &&
> > analyse_instr(&op, ®s,
> > - *(struct ppc_inst *)p->ainsn.insn) == 1) {
> > + ppc_inst_read((struct ppc_inst *)p->ainsn.insn)) == 1) {
> > emulate_update_regs(®s, &op);
> > nip = regs.nip;
> > }
> > diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c
> > index 3117ed675735..acd5b889815f 100644
> > --- a/arch/powerpc/kernel/trace/ftrace.c
> > +++ b/arch/powerpc/kernel/trace/ftrace.c
> > @@ -848,7 +848,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
> > struct ppc_inst old, new;
> > int ret;
> >
> > - old = *(struct ppc_inst *)&ftrace_call;
> > + old = ppc_inst_read((struct ppc_inst *)&ftrace_call);
> > new = ftrace_call_replace(ip, (unsigned long)func, 1);
> > ret = ftrace_modify_code(ip, old, new);
> >
> > @@ -856,7 +856,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
> > /* Also update the regs callback function */
> > if (!ret) {
> > ip = (unsigned long)(&ftrace_regs_call);
> > - old = *(struct ppc_inst *)&ftrace_regs_call;
> > + old = ppc_inst_read((struct ppc_inst *)&ftrace_regs_call);
> > new = ftrace_call_replace(ip, (unsigned long)func, 1);
> > ret = ftrace_modify_code(ip, old, new);
> > }
> > diff --git a/arch/powerpc/kernel/uprobes.c b/arch/powerpc/kernel/uprobes.c
> > index 31c870287f2b..6893d40a48c5 100644
> > --- a/arch/powerpc/kernel/uprobes.c
> > +++ b/arch/powerpc/kernel/uprobes.c
> > @@ -174,7 +174,7 @@ bool arch_uprobe_skip_sstep(struct arch_uprobe *auprobe, struct pt_regs *regs)
> > * emulate_step() returns 1 if the insn was successfully emulated.
> > * For all other cases, we need to single-step in hardware.
> > */
> > - ret = emulate_step(regs, auprobe->insn);
> > + ret = emulate_step(regs, ppc_inst_read(&auprobe->insn));
> > if (ret > 0)
> > return true;
> >
> > diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c
> > index 1dff9d9d6645..435fc8e9f45d 100644
> > --- a/arch/powerpc/lib/code-patching.c
> > +++ b/arch/powerpc/lib/code-patching.c
> > @@ -348,9 +348,9 @@ static unsigned long branch_bform_target(const struct ppc_inst *instr)
> >
> > unsigned long branch_target(const struct ppc_inst *instr)
> > {
> > - if (instr_is_branch_iform(*instr))
> > + if (instr_is_branch_iform(ppc_inst_read(instr)))
> > return branch_iform_target(instr);
> > - else if (instr_is_branch_bform(*instr))
> > + else if (instr_is_branch_bform(ppc_inst_read(instr)))
> > return branch_bform_target(instr);
> >
> > return 0;
> > @@ -358,7 +358,8 @@ unsigned long branch_target(const struct ppc_inst *instr)
> >
> > int instr_is_branch_to_addr(const struct ppc_inst *instr, unsigned long addr)
> > {
> > - if (instr_is_branch_iform(*instr) || instr_is_branch_bform(*instr))
> > + if (instr_is_branch_iform(ppc_inst_read(instr)) ||
> > + instr_is_branch_bform(ppc_inst_read(instr)))
> > return branch_target(instr) == addr;
> >
> > return 0;
> > @@ -368,13 +369,14 @@ int translate_branch(struct ppc_inst *instr, const struct ppc_inst *dest,
> > const struct ppc_inst *src)
> > {
> > unsigned long target;
> > -
> > target = branch_target(src);
> >
> > - if (instr_is_branch_iform(*src))
> > - return create_branch(instr, dest, target, ppc_inst_val(*src));
> > - else if (instr_is_branch_bform(*src))
> > - return create_cond_branch(instr, dest, target, ppc_inst_val(*src));
> > + if (instr_is_branch_iform(ppc_inst_read(src)))
> > + return create_branch(instr, dest, target,
> > + ppc_inst_val(ppc_inst_read(src)));
> > + else if (instr_is_branch_bform(ppc_inst_read(src)))
> > + return create_cond_branch(instr, dest, target,
> > + ppc_inst_val(ppc_inst_read(src)));
> >
> > return 1;
> > }
> > @@ -598,7 +600,7 @@ static void __init test_translate_branch(void)
> > patch_instruction(q, instr);
> > check(instr_is_branch_to_addr(p, addr));
> > check(instr_is_branch_to_addr(q, addr));
> > - check(ppc_inst_equal(*q, ppc_inst(0x4a000000)));
> > + check(ppc_inst_equal(ppc_inst_read(q), ppc_inst(0x4a000000)));
> >
> > /* Maximum positive case, move x to x - 32 MB + 4 */
> > p = buf + 0x2000000;
> > @@ -609,7 +611,7 @@ static void __init test_translate_branch(void)
> > patch_instruction(q, instr);
> > check(instr_is_branch_to_addr(p, addr));
> > check(instr_is_branch_to_addr(q, addr));
> > - check(ppc_inst_equal(*q, ppc_inst(0x49fffffc)));
> > + check(ppc_inst_equal(ppc_inst_read(q), ppc_inst(0x49fffffc)));
> >
> > /* Jump to x + 16 MB moved to x + 20 MB */
> > p = buf;
> > @@ -655,7 +657,7 @@ static void __init test_translate_branch(void)
> > patch_instruction(q, instr);
> > check(instr_is_branch_to_addr(p, addr));
> > check(instr_is_branch_to_addr(q, addr));
> > - check(ppc_inst_equal(*q, ppc_inst(0x43ff8000)));
> > + check(ppc_inst_equal(ppc_inst_read(q), ppc_inst(0x43ff8000)));
> >
> > /* Maximum positive case, move x to x - 32 KB + 4 */
> > p = buf + 0x8000;
> > @@ -667,7 +669,7 @@ static void __init test_translate_branch(void)
> > patch_instruction(q, instr);
> > check(instr_is_branch_to_addr(p, addr));
> > check(instr_is_branch_to_addr(q, addr));
> > - check(ppc_inst_equal(*q, ppc_inst(0x43ff7ffc)));
> > + check(ppc_inst_equal(ppc_inst_read(q), ppc_inst(0x43ff7ffc)));
> >
> > /* Jump to x + 12 KB moved to x + 20 KB */
> > p = buf;
> > diff --git a/arch/powerpc/lib/feature-fixups.c b/arch/powerpc/lib/feature-fixups.c
> > index fb6e8e8abf4e..c0d3ed4efb7e 100644
> > --- a/arch/powerpc/lib/feature-fixups.c
> > +++ b/arch/powerpc/lib/feature-fixups.c
> > @@ -48,7 +48,7 @@ static int patch_alt_instruction(struct ppc_inst *src, struct ppc_inst *dest,
> > int err;
> > struct ppc_inst instr;
> >
> > - instr = *src;
> > + instr = ppc_inst_read(src);
> >
> > if (instr_is_relative_branch(*src)) {
> > struct ppc_inst *target = (struct ppc_inst *)branch_target(src);
> > @@ -403,7 +403,7 @@ static void do_final_fixups(void)
> > length = (__end_interrupts - _stext) / sizeof(struct ppc_inst);
> >
> > while (length--) {
> > - raw_patch_instruction(dest, *src);
> > + raw_patch_instruction(dest, ppc_inst_read(src));
> > src++;
> > dest++;
> > }
> > diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
> > index e0132d6d24d0..68e0b05d9226 100644
> > --- a/arch/powerpc/xmon/xmon.c
> > +++ b/arch/powerpc/xmon/xmon.c
> > @@ -702,13 +702,13 @@ static int xmon_core(struct pt_regs *regs, int fromipi)
> > if ((regs->msr & (MSR_IR|MSR_PR|MSR_64BIT)) == (MSR_IR|MSR_64BIT)) {
> > bp = at_breakpoint(regs->nip);
> > if (bp != NULL) {
> > - int stepped = emulate_step(regs, bp->instr[0]);
> > + int stepped = emulate_step(regs, ppc_inst_read(bp->instr));
> > if (stepped == 0) {
> > regs->nip = (unsigned long) &bp->instr[0];
> > atomic_inc(&bp->ref_count);
> > } else if (stepped < 0) {
> > printf("Couldn't single-step %s instruction\n",
> > - (IS_RFID(bp->instr[0])? "rfid": "mtmsrd"));
> > + IS_RFID(ppc_inst_read(bp->instr))? "rfid": "mtmsrd");
> > }
> > }
> > }
> > @@ -949,7 +949,7 @@ static void remove_bpts(void)
> > if (mread(bp->address, &instr, 4) == 4
> > && ppc_inst_equal(instr, ppc_inst(bpinstr))
> > && patch_instruction(
> > - (struct ppc_inst *)bp->address, bp->instr[0]) != 0)
> > + (struct ppc_inst *)bp->address, ppc_inst_read(bp->instr)) != 0)
> > printf("Couldn't remove breakpoint at %lx\n",
> > bp->address);
> > }
> >
^ permalink raw reply
* Re: [PATCH v8 11/30] powerpc: Use a datatype for instructions
From: Jordan Niethe @ 2020-05-17 10:48 UTC (permalink / raw)
To: linuxppc-dev
Cc: Christophe Leroy, Alistair Popple, Nicholas Piggin, Balamuruhan S,
naveen.n.rao, Daniel Axtens
In-Reply-To: <20200506034050.24806-12-jniethe5@gmail.com>
mpe, this is to go with the fixup I posted for mmu_patch_addis() in
[PATCH v8 12/30] powerpc: Use a function for reading instructions.
Thanks to Christophe pointing it out.
diff --git a/arch/powerpc/mm/nohash/8xx.c b/arch/powerpc/mm/nohash/8xx.c
--- a/arch/powerpc/mm/nohash/8xx.c
+++ b/arch/powerpc/mm/nohash/8xx.c
@@ -98,11 +98,12 @@ static void mmu_patch_cmp_limit(s32 *site,
unsigned long mapped)
static void mmu_patch_addis(s32 *site, long simm)
{
- unsigned int instr = *(unsigned int *)patch_site_addr(site);
+ struct ppc_inst instr = *(struct ppc_inst *)patch_site_addr(site);
+ unsigned int val = ppc_inst_val(instr);
- instr &= 0xffff0000;
- instr |= ((unsigned long)simm) >> 16;
- patch_instruction_site(site, ppc_inst(instr));
+ val &= 0xffff0000;
+ val |= ((unsigned long)simm) >> 16;
+ patch_instruction_site(site, ppc_inst(val));
}
static void mmu_mapin_ram_chunk(unsigned long offset, unsigned long
top, pgprot_t prot)
--
^ permalink raw reply
* Re: [PATCH V3 10/15] arch/kmap: Define kmap_atomic_prot() for all arch's
From: Guenter Roeck @ 2020-05-17 17:37 UTC (permalink / raw)
To: ira.weiny
Cc: Peter Zijlstra, Dave Hansen, dri-devel, linux-mips,
James E.J. Bottomley, Max Filippov, Paul Mackerras,
H. Peter Anvin, sparclinux, Dan Williams, Helge Deller, x86,
linux-csky, Christoph Hellwig, Ingo Molnar, linux-snps-arc,
linux-xtensa, Borislav Petkov, Al Viro, Andy Lutomirski,
Thomas Gleixner, linux-arm-kernel, Chris Zankel,
Thomas Bogendoerfer, linux-parisc, linux-kernel, Christian Koenig,
Andrew Morton, linuxppc-dev, David S. Miller
In-Reply-To: <20200507150004.1423069-11-ira.weiny@intel.com>
Hi,
On Thu, May 07, 2020 at 07:59:58AM -0700, ira.weiny@intel.com wrote:
> From: Ira Weiny <ira.weiny@intel.com>
>
> To support kmap_atomic_prot(), all architectures need to support
> protections passed to their kmap_atomic_high() function. Pass
> protections into kmap_atomic_high() and change the name to
> kmap_atomic_high_prot() to match.
>
> Then define kmap_atomic_prot() as a core function which calls
> kmap_atomic_high_prot() when needed.
>
> Finally, redefine kmap_atomic() as a wrapper of kmap_atomic_prot() with
> the default kmap_prot exported by the architectures.
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Ira Weiny <ira.weiny@intel.com>
This patch causes a variety of crashes whem booting powerpc images in qemu.
There are lots of warnings such as:
WARNING: CPU: 0 PID: 0 at lib/locking-selftest.c:743 irqsafe1_hard_spin_12+0x50/0xb0
Modules linked in:
CPU: 0 PID: 0 Comm: swapper Tainted: G W 5.7.0-rc5-next-20200515 #1
NIP: c0660c7c LR: c0660c44 CTR: c0660c2c
REGS: c1223e68 TRAP: 0700 Tainted: G W (5.7.0-rc5-next-20200515)
MSR: 00021000 <CE,ME> CR: 28000224 XER: 20000000
GPR00: c0669c78 c1223f20 c113d560 c0660c44 00000000 00000001 c1223ea8 00000001
GPR08: 00000000 00000001 0000fffc ffffffff 88000222 00000000 00000000 00000000
GPR16: 00000000 00000000 00000000 00000000 c0000000 00000000 00000000 c1125084
GPR24: c1125084 c1230000 c1879538 fffffffc 00000001 00000000 c1011afc c1230000
NIP [c0660c7c] irqsafe1_hard_spin_12+0x50/0xb0
LR [c0660c44] irqsafe1_hard_spin_12+0x18/0xb0
Call Trace:
[c1223f20] [c1880000] megasas_mgmt_info+0xee4/0x1008 (unreliable)
[c1223f40] [c0669c78] dotest+0x38/0x550
[c1223f70] [c066aa4c] locking_selftest+0x8bc/0x1d54
[c1223fa0] [c10e0bc8] start_kernel+0x3ec/0x510
[c1223ff0] [c00003a0] set_ivor+0x118/0x154
Instruction dump:
81420000 38e80001 3d4a0001 2c080000 91420000 90e20488 40820008 91020470
81290000 5529031e 7d290034 5529d97e <0f090000> 3fe0c11c 3bff3964 3bff00ac
irq event stamp: 588
hardirqs last enabled at (587): [<c00b9fe4>] vprintk_emit+0x1b4/0x33c
hardirqs last disabled at (588): [<c0660c44>] irqsafe1_hard_spin_12+0x18/0xb0
softirqs last enabled at (0): [<00000000>] 0x0
softirqs last disabled at (0): [<00000000>] 0x0
---[ end trace b18fe9e172f99d03 ]---
This is followed by:
BUG: sleeping function called from invalid context at lib/mpi/mpi-pow.c:245
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 14, name: cryptomgr_test
INFO: lockdep is turned off.
CPU: 0 PID: 14 Comm: cryptomgr_test Tainted: G W 5.7.0-rc5-next-20200515 #1
Call Trace:
[ce221b58] [c008755c] ___might_sleep+0x280/0x2a8 (unreliable)
[ce221b78] [c06bc524] mpi_powm+0x634/0xc50
[ce221c38] [c05eafdc] rsa_dec+0x88/0x134
[ce221c78] [c05f3b40] test_akcipher_one+0x678/0x804
[ce221dc8] [c05f3d7c] alg_test_akcipher+0xb0/0x130
[ce221df8] [c05ee674] alg_test.part.0+0xb4/0x458
[ce221ed8] [c05ed2b0] cryptomgr_test+0x30/0x50
[ce221ef8] [c007cd74] kthread+0x134/0x170
[ce221f38] [c001433c] ret_from_kernel_thread+0x14/0x1c
Kernel panic - not syncing: Aiee, killing interrupt handler!
CPU: 0 PID: 14 Comm: cryptomgr_test Tainted: G W 5.7.0-rc5-next-20200515 #1
Call Trace:
[ce221e08] [c00530fc] panic+0x148/0x34c (unreliable)
[ce221e68] [c0056460] do_exit+0xac0/0xb40
[ce221eb8] [c00f5be8] find_kallsyms_symbol_value+0x0/0x128
[ce221ed8] [c05ed2d0] crypto_alg_put+0x0/0x70
[ce221ef8] [c007cd74] kthread+0x134/0x170
[ce221f38] [c001433c] ret_from_kernel_thread+0x14/0x1c
Bisect log is attached. The patch can not easily be reverted since
it results in compile errors.
Note that similar failures are seen with sparc32 images. Those bisect
to a different patch, but reverting that patch doesn't fix the problem.
The failure pattern (warnings followed by a crash in cryptomgr_test)
is the same.
Guenter
---
# bad: [bdecf38f228bcca73b31ada98b5b7ba1215eb9c9] Add linux-next specific files for 20200515
# good: [2ef96a5bb12be62ef75b5828c0aab838ebb29cb8] Linux 5.7-rc5
git bisect start 'HEAD' 'v5.7-rc5'
# good: [3674d7aa7a8e61d993886c2fb7c896c5ef85e988] Merge remote-tracking branch 'crypto/master'
git bisect good 3674d7aa7a8e61d993886c2fb7c896c5ef85e988
# good: [87f6f21783522e6d62127cf33ae5e95f50874beb] Merge remote-tracking branch 'spi/for-next'
git bisect good 87f6f21783522e6d62127cf33ae5e95f50874beb
# good: [5c428e8277d5d97c85126387d4e00aa5adde4400] Merge remote-tracking branch 'staging/staging-next'
git bisect good 5c428e8277d5d97c85126387d4e00aa5adde4400
# good: [f68de67ed934e7bdef4799fd7777c86f33f14982] Merge remote-tracking branch 'hyperv/hyperv-next'
git bisect good f68de67ed934e7bdef4799fd7777c86f33f14982
# bad: [54acd2dc52b069da59639eea0d0c92726f32fb01] mm/memblock: fix a typo in comment "implict"->"implicit"
git bisect bad 54acd2dc52b069da59639eea0d0c92726f32fb01
# good: [784a17aa58a529b84f7cc50f351ed4acf3bd11f3] mm: remove the pgprot argument to __vmalloc
git bisect good 784a17aa58a529b84f7cc50f351ed4acf3bd11f3
# good: [6cd8137ff37e9a37aee2d2a8889c8beb8eab192f] khugepaged: replace the usage of system(3) in the test
git bisect good 6cd8137ff37e9a37aee2d2a8889c8beb8eab192f
# bad: [6987da379826ed01b8a1cf046b67cc8cc10117cc] sparc: remove unnecessary includes
git bisect bad 6987da379826ed01b8a1cf046b67cc8cc10117cc
# good: [bc17b545388f64c09e83e367898e28f60277c584] mm/hugetlb: define a generic fallback for is_hugepage_only_range()
git bisect good bc17b545388f64c09e83e367898e28f60277c584
# good: [9b5aa5b43f957f03a1f4a9aff5f7924e2ebbc011] arch-kmap_atomic-consolidate-duplicate-code-checkpatch-fixes
git bisect good 9b5aa5b43f957f03a1f4a9aff5f7924e2ebbc011
# bad: [89194ba5ee31567eeee9c81101b334c8e3248198] arch/kmap: define kmap_atomic_prot() for all arch's
git bisect bad 89194ba5ee31567eeee9c81101b334c8e3248198
# good: [022785d2bea99f8bc2a37b7b6c525eea26f6ac59] arch-kunmap_atomic-consolidate-duplicate-code-checkpatch-fixes
git bisect good 022785d2bea99f8bc2a37b7b6c525eea26f6ac59
# good: [a13c2f39e3f0519ddee57d26cc66ec70e3546106] arch/kmap: don't hard code kmap_prot values
git bisect good a13c2f39e3f0519ddee57d26cc66ec70e3546106
# first bad commit: [89194ba5ee31567eeee9c81101b334c8e3248198] arch/kmap: define kmap_atomic_prot() for all arch's
^ permalink raw reply
* [PATCH v2 2/2] powerpc/configs: replace deprecated riva/nvidia with nouveau
From: Emil Velikov @ 2020-05-17 22:05 UTC (permalink / raw)
To: dri-devel
Cc: linux-fbdev, Antonino Daplas, Bartlomiej Zolnierkiewicz,
emil.l.velikov, Paul Mackerras, linuxppc-dev
In-Reply-To: <20200517220524.4036334-1-emil.l.velikov@gmail.com>
As mentioned in earlier commit, the riva and nvidia fbdev drivers have
seen no love over the years, are short on features and overall below par
Users are encouraged to switch to the nouveau drm driver instead.
v2: Split configs to separate patch, enable nouveau (Bartlomiej)
Cc: Antonino Daplas <adaplas@gmail.com>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: linux-fbdev@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> (v1)
---
Hi all unless, there are objections I would prefer to merge this via
the drm tree.
Thanks
Emil
---
arch/powerpc/configs/g5_defconfig | 10 ++++++++--
arch/powerpc/configs/pasemi_defconfig | 9 +++++++--
arch/powerpc/configs/pmac32_defconfig | 9 +++++++--
arch/powerpc/configs/ppc6xx_defconfig | 10 +++++++---
4 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/arch/powerpc/configs/g5_defconfig b/arch/powerpc/configs/g5_defconfig
index a68c7f3af10e..213472f373b3 100644
--- a/arch/powerpc/configs/g5_defconfig
+++ b/arch/powerpc/configs/g5_defconfig
@@ -124,12 +124,18 @@ CONFIG_RAW_DRIVER=y
CONFIG_I2C_CHARDEV=y
CONFIG_AGP=m
CONFIG_AGP_UNINORTH=m
+CONFIG_DRM=y
+CONFIG_DRM_NOUVEAU=m
+# CONFIG_NOUVEAU_LEGACY_CTX_SUPPORT is not set
+CONFIG_NOUVEAU_DEBUG=5
+CONFIG_NOUVEAU_DEBUG_DEFAULT=3
+# CONFIG_NOUVEAU_DEBUG_MMU is not set
+CONFIG_DRM_NOUVEAU_BACKLIGHT=y
+# CONFIG_DRM_NOUVEAU_SVM is not set
CONFIG_FB=y
CONFIG_FIRMWARE_EDID=y
CONFIG_FB_TILEBLITTING=y
CONFIG_FB_OF=y
-CONFIG_FB_NVIDIA=y
-CONFIG_FB_NVIDIA_I2C=y
CONFIG_FB_RADEON=y
# CONFIG_VGA_CONSOLE is not set
CONFIG_FRAMEBUFFER_CONSOLE=y
diff --git a/arch/powerpc/configs/pasemi_defconfig b/arch/powerpc/configs/pasemi_defconfig
index 08b7f4cef243..ccb3ab5e01da 100644
--- a/arch/powerpc/configs/pasemi_defconfig
+++ b/arch/powerpc/configs/pasemi_defconfig
@@ -102,11 +102,16 @@ CONFIG_SENSORS_LM85=y
CONFIG_SENSORS_LM90=y
CONFIG_DRM=y
CONFIG_DRM_RADEON=y
+CONFIG_DRM_NOUVEAU=m
+# CONFIG_NOUVEAU_LEGACY_CTX_SUPPORT is not set
+CONFIG_NOUVEAU_DEBUG=5
+CONFIG_NOUVEAU_DEBUG_DEFAULT=3
+# CONFIG_NOUVEAU_DEBUG_MMU is not set
+CONFIG_DRM_NOUVEAU_BACKLIGHT=y
+# CONFIG_DRM_NOUVEAU_SVM is not set
CONFIG_FIRMWARE_EDID=y
CONFIG_FB_TILEBLITTING=y
CONFIG_FB_VGA16=y
-CONFIG_FB_NVIDIA=y
-CONFIG_FB_NVIDIA_I2C=y
CONFIG_FB_RADEON=y
# CONFIG_LCD_CLASS_DEVICE is not set
CONFIG_VGACON_SOFT_SCROLLBACK=y
diff --git a/arch/powerpc/configs/pmac32_defconfig b/arch/powerpc/configs/pmac32_defconfig
index 05e325ca3fbd..f858627385c8 100644
--- a/arch/powerpc/configs/pmac32_defconfig
+++ b/arch/powerpc/configs/pmac32_defconfig
@@ -199,6 +199,13 @@ CONFIG_DRM=m
CONFIG_DRM_RADEON=m
CONFIG_DRM_LEGACY=y
CONFIG_DRM_R128=m
+CONFIG_DRM_NOUVEAU=m
+# CONFIG_NOUVEAU_LEGACY_CTX_SUPPORT is not set
+CONFIG_NOUVEAU_DEBUG=5
+CONFIG_NOUVEAU_DEBUG_DEFAULT=3
+# CONFIG_NOUVEAU_DEBUG_MMU is not set
+CONFIG_DRM_NOUVEAU_BACKLIGHT=y
+# CONFIG_DRM_NOUVEAU_SVM is not set
CONFIG_FB=y
CONFIG_FB_OF=y
CONFIG_FB_CONTROL=y
@@ -206,8 +213,6 @@ CONFIG_FB_PLATINUM=y
CONFIG_FB_VALKYRIE=y
CONFIG_FB_CT65550=y
CONFIG_FB_IMSTT=y
-CONFIG_FB_NVIDIA=y
-CONFIG_FB_NVIDIA_I2C=y
CONFIG_FB_MATROX=y
CONFIG_FB_MATROX_MILLENIUM=y
CONFIG_FB_MATROX_MYSTIQUE=y
diff --git a/arch/powerpc/configs/ppc6xx_defconfig b/arch/powerpc/configs/ppc6xx_defconfig
index feb5d47d8d1e..48421f5007ed 100644
--- a/arch/powerpc/configs/ppc6xx_defconfig
+++ b/arch/powerpc/configs/ppc6xx_defconfig
@@ -738,15 +738,19 @@ CONFIG_DRM_MGA=m
CONFIG_DRM_SIS=m
CONFIG_DRM_VIA=m
CONFIG_DRM_SAVAGE=m
+CONFIG_DRM_NOUVEAU=m
+# CONFIG_NOUVEAU_LEGACY_CTX_SUPPORT is not set
+CONFIG_NOUVEAU_DEBUG=5
+CONFIG_NOUVEAU_DEBUG_DEFAULT=3
+# CONFIG_NOUVEAU_DEBUG_MMU is not set
+CONFIG_DRM_NOUVEAU_BACKLIGHT=y
+# CONFIG_DRM_NOUVEAU_SVM is not set
CONFIG_FB=y
CONFIG_FB_CIRRUS=m
CONFIG_FB_OF=y
CONFIG_FB_PLATINUM=y
CONFIG_FB_VALKYRIE=y
CONFIG_FB_CT65550=y
-CONFIG_FB_NVIDIA=y
-CONFIG_FB_NVIDIA_I2C=y
-CONFIG_FB_RIVA=m
CONFIG_FB_MATROX=y
CONFIG_FB_MATROX_MILLENIUM=y
CONFIG_FB_MATROX_MYSTIQUE=y
--
2.25.1
^ permalink raw reply related
* Re: [PATCH v5 2/2] powerpc/rtas: Implement reentrant rtas call
From: Nicholas Piggin @ 2020-05-17 22:52 UTC (permalink / raw)
To: Allison Randal, Thiago Jung Bauermann, Benjamin Herrenschmidt,
Daniel Axtens, Gautham R. Shenoy, Greg Kroah-Hartman,
Anshuman Khandual, Leonardo Bras, Michael Ellerman, Nadav Amit,
Nathan Lynch, Paul Mackerras, Thomas Gleixner
Cc: linuxppc-dev, linux-kernel
In-Reply-To: <1589614523.yfijifo1n6.astroid@bobo.none>
Excerpts from Nicholas Piggin's message of May 16, 2020 5:36 pm:
> Excerpts from Leonardo Bras's message of May 16, 2020 3:21 pm:
>> @@ -202,6 +220,7 @@ void __init __nostackprotector initialise_paca(struct paca_struct *new_paca, int
>> /* For now -- if we have threads this will be adjusted later */
>> new_paca->tcd_ptr = &new_paca->tcd;
>> #endif
>> + new_paca->reentrant_args = NULL;
>> }
>>
>> /* Put the paca pointer into r13 and SPRG_PACA */
>> @@ -274,6 +293,7 @@ void __init allocate_paca(int cpu)
>> #ifdef CONFIG_PPC_BOOK3S_64
>> paca->slb_shadow_ptr = new_slb_shadow(cpu, limit);
>> #endif
>> + paca->reentrant_args = new_rtas_args(cpu, limit);
>
> Good, I think tihs should work as you want now. Can you allocate it like
> lppacas? Put it under PSERIES (and in the paca) and check for !HV?
Oh and while there, could you prefix the name with rtas_?
Thanks,
Nick
^ permalink raw reply
* Re: [PATCH v2 2/2] powerpc/configs: replace deprecated riva/nvidia with nouveau
From: Benjamin Herrenschmidt @ 2020-05-18 0:44 UTC (permalink / raw)
To: Emil Velikov, dri-devel
Cc: linux-fbdev, Antonino Daplas, Bartlomiej Zolnierkiewicz,
Paul Mackerras, linuxppc-dev
In-Reply-To: <20200517220524.4036334-2-emil.l.velikov@gmail.com>
On Sun, 2020-05-17 at 23:05 +0100, Emil Velikov wrote:
> As mentioned in earlier commit, the riva and nvidia fbdev drivers
> have
> seen no love over the years, are short on features and overall below
> par
>
> Users are encouraged to switch to the nouveau drm driver instead.
>
> v2: Split configs to separate patch, enable nouveau (Bartlomiej)
Back when I still had these things to play with (years ago) nouveau
didn't work properly on these ancient machines.
Cheers,
Ben.
> Cc: Antonino Daplas <adaplas@gmail.com>
> Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> Cc: linux-fbdev@vger.kernel.org
> Cc: dri-devel@lists.freedesktop.org
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: linuxppc-dev@lists.ozlabs.org
> Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> (v1)
> ---
> Hi all unless, there are objections I would prefer to merge this via
> the drm tree.
>
> Thanks
> Emil
> ---
> arch/powerpc/configs/g5_defconfig | 10 ++++++++--
> arch/powerpc/configs/pasemi_defconfig | 9 +++++++--
> arch/powerpc/configs/pmac32_defconfig | 9 +++++++--
> arch/powerpc/configs/ppc6xx_defconfig | 10 +++++++---
> 4 files changed, 29 insertions(+), 9 deletions(-)
>
> diff --git a/arch/powerpc/configs/g5_defconfig
> b/arch/powerpc/configs/g5_defconfig
> index a68c7f3af10e..213472f373b3 100644
> --- a/arch/powerpc/configs/g5_defconfig
> +++ b/arch/powerpc/configs/g5_defconfig
> @@ -124,12 +124,18 @@ CONFIG_RAW_DRIVER=y
> CONFIG_I2C_CHARDEV=y
> CONFIG_AGP=m
> CONFIG_AGP_UNINORTH=m
> +CONFIG_DRM=y
> +CONFIG_DRM_NOUVEAU=m
> +# CONFIG_NOUVEAU_LEGACY_CTX_SUPPORT is not set
> +CONFIG_NOUVEAU_DEBUG=5
> +CONFIG_NOUVEAU_DEBUG_DEFAULT=3
> +# CONFIG_NOUVEAU_DEBUG_MMU is not set
> +CONFIG_DRM_NOUVEAU_BACKLIGHT=y
> +# CONFIG_DRM_NOUVEAU_SVM is not set
> CONFIG_FB=y
> CONFIG_FIRMWARE_EDID=y
> CONFIG_FB_TILEBLITTING=y
> CONFIG_FB_OF=y
> -CONFIG_FB_NVIDIA=y
> -CONFIG_FB_NVIDIA_I2C=y
> CONFIG_FB_RADEON=y
> # CONFIG_VGA_CONSOLE is not set
> CONFIG_FRAMEBUFFER_CONSOLE=y
> diff --git a/arch/powerpc/configs/pasemi_defconfig
> b/arch/powerpc/configs/pasemi_defconfig
> index 08b7f4cef243..ccb3ab5e01da 100644
> --- a/arch/powerpc/configs/pasemi_defconfig
> +++ b/arch/powerpc/configs/pasemi_defconfig
> @@ -102,11 +102,16 @@ CONFIG_SENSORS_LM85=y
> CONFIG_SENSORS_LM90=y
> CONFIG_DRM=y
> CONFIG_DRM_RADEON=y
> +CONFIG_DRM_NOUVEAU=m
> +# CONFIG_NOUVEAU_LEGACY_CTX_SUPPORT is not set
> +CONFIG_NOUVEAU_DEBUG=5
> +CONFIG_NOUVEAU_DEBUG_DEFAULT=3
> +# CONFIG_NOUVEAU_DEBUG_MMU is not set
> +CONFIG_DRM_NOUVEAU_BACKLIGHT=y
> +# CONFIG_DRM_NOUVEAU_SVM is not set
> CONFIG_FIRMWARE_EDID=y
> CONFIG_FB_TILEBLITTING=y
> CONFIG_FB_VGA16=y
> -CONFIG_FB_NVIDIA=y
> -CONFIG_FB_NVIDIA_I2C=y
> CONFIG_FB_RADEON=y
> # CONFIG_LCD_CLASS_DEVICE is not set
> CONFIG_VGACON_SOFT_SCROLLBACK=y
> diff --git a/arch/powerpc/configs/pmac32_defconfig
> b/arch/powerpc/configs/pmac32_defconfig
> index 05e325ca3fbd..f858627385c8 100644
> --- a/arch/powerpc/configs/pmac32_defconfig
> +++ b/arch/powerpc/configs/pmac32_defconfig
> @@ -199,6 +199,13 @@ CONFIG_DRM=m
> CONFIG_DRM_RADEON=m
> CONFIG_DRM_LEGACY=y
> CONFIG_DRM_R128=m
> +CONFIG_DRM_NOUVEAU=m
> +# CONFIG_NOUVEAU_LEGACY_CTX_SUPPORT is not set
> +CONFIG_NOUVEAU_DEBUG=5
> +CONFIG_NOUVEAU_DEBUG_DEFAULT=3
> +# CONFIG_NOUVEAU_DEBUG_MMU is not set
> +CONFIG_DRM_NOUVEAU_BACKLIGHT=y
> +# CONFIG_DRM_NOUVEAU_SVM is not set
> CONFIG_FB=y
> CONFIG_FB_OF=y
> CONFIG_FB_CONTROL=y
> @@ -206,8 +213,6 @@ CONFIG_FB_PLATINUM=y
> CONFIG_FB_VALKYRIE=y
> CONFIG_FB_CT65550=y
> CONFIG_FB_IMSTT=y
> -CONFIG_FB_NVIDIA=y
> -CONFIG_FB_NVIDIA_I2C=y
> CONFIG_FB_MATROX=y
> CONFIG_FB_MATROX_MILLENIUM=y
> CONFIG_FB_MATROX_MYSTIQUE=y
> diff --git a/arch/powerpc/configs/ppc6xx_defconfig
> b/arch/powerpc/configs/ppc6xx_defconfig
> index feb5d47d8d1e..48421f5007ed 100644
> --- a/arch/powerpc/configs/ppc6xx_defconfig
> +++ b/arch/powerpc/configs/ppc6xx_defconfig
> @@ -738,15 +738,19 @@ CONFIG_DRM_MGA=m
> CONFIG_DRM_SIS=m
> CONFIG_DRM_VIA=m
> CONFIG_DRM_SAVAGE=m
> +CONFIG_DRM_NOUVEAU=m
> +# CONFIG_NOUVEAU_LEGACY_CTX_SUPPORT is not set
> +CONFIG_NOUVEAU_DEBUG=5
> +CONFIG_NOUVEAU_DEBUG_DEFAULT=3
> +# CONFIG_NOUVEAU_DEBUG_MMU is not set
> +CONFIG_DRM_NOUVEAU_BACKLIGHT=y
> +# CONFIG_DRM_NOUVEAU_SVM is not set
> CONFIG_FB=y
> CONFIG_FB_CIRRUS=m
> CONFIG_FB_OF=y
> CONFIG_FB_PLATINUM=y
> CONFIG_FB_VALKYRIE=y
> CONFIG_FB_CT65550=y
> -CONFIG_FB_NVIDIA=y
> -CONFIG_FB_NVIDIA_I2C=y
> -CONFIG_FB_RIVA=m
> CONFIG_FB_MATROX=y
> CONFIG_FB_MATROX_MILLENIUM=y
> CONFIG_FB_MATROX_MYSTIQUE=y
^ permalink raw reply
* Re: [PATCH] powerpc/64s: Fix early_init_mmu section mismatch
From: Michael Ellerman @ 2020-05-18 2:40 UTC (permalink / raw)
To: Christian Zigotzky, Nicholas Piggin, linuxppc-dev
In-Reply-To: <0f2e656a-fcc4-588c-707d-f05bd8d889df@xenosoft.de>
Christian Zigotzky <chzigotzky@xenosoft.de> writes:
> Hi All,
>
> This patch wasn't included in the PowerPC fixes 5.7-4. Please add it.
It's not an important bug. I'll take the patch for v5.8
cheers
> On 29 April 2020 at 09:02 am, Nicholas Piggin wrote:
>> Christian reports:
>>
>> MODPOST vmlinux.o
>> WARNING: modpost: vmlinux.o(.text.unlikely+0x1a0): Section mismatch in
>> reference from the function .early_init_mmu() to the function
>> .init.text:.radix__early_init_mmu()
>> The function .early_init_mmu() references
>> the function __init .radix__early_init_mmu().
>> This is often because .early_init_mmu lacks a __init
>> annotation or the annotation of .radix__early_init_mmu is wrong.
>>
>> WARNING: modpost: vmlinux.o(.text.unlikely+0x1ac): Section mismatch in
>> reference from the function .early_init_mmu() to the function
>> .init.text:.hash__early_init_mmu()
>> The function .early_init_mmu() references
>> the function __init .hash__early_init_mmu().
>> This is often because .early_init_mmu lacks a __init
>> annotation or the annotation of .hash__early_init_mmu is wrong.
>>
>> The compiler is uninlining early_init_mmu and not putting it in an init
>> section because there is no annotation. Add it.
>>
>> Reported-by: Christian Zigotzky <chzigotzky@xenosoft.de>
>> Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
>> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>> ---
>> arch/powerpc/include/asm/book3s/64/mmu.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/powerpc/include/asm/book3s/64/mmu.h b/arch/powerpc/include/asm/book3s/64/mmu.h
>> index bb3deb76c951..3ffe5f967483 100644
>> --- a/arch/powerpc/include/asm/book3s/64/mmu.h
>> +++ b/arch/powerpc/include/asm/book3s/64/mmu.h
>> @@ -208,7 +208,7 @@ void hash__early_init_devtree(void);
>> void radix__early_init_devtree(void);
>> extern void hash__early_init_mmu(void);
>> extern void radix__early_init_mmu(void);
>> -static inline void early_init_mmu(void)
>> +static inline void __init early_init_mmu(void)
>> {
>> if (radix_enabled())
>> return radix__early_init_mmu();
^ permalink raw reply
* Re: [PATCH V3 07/15] arch/kunmap_atomic: Consolidate duplicate code
From: Ira Weiny @ 2020-05-18 3:49 UTC (permalink / raw)
To: Guenter Roeck
Cc: Peter Zijlstra, Dave Hansen, dri-devel, linux-mips,
James E.J. Bottomley, Max Filippov, Paul Mackerras,
H. Peter Anvin, sparclinux, Dan Williams, Helge Deller, x86,
linux-csky, Christoph Hellwig, Ingo Molnar, linux-snps-arc,
linux-xtensa, Borislav Petkov, Al Viro, Andy Lutomirski,
Thomas Gleixner, linux-arm-kernel, Chris Zankel,
Thomas Bogendoerfer, linux-parisc, linux-kernel, Christian Koenig,
Andrew Morton, linuxppc-dev, David S. Miller
In-Reply-To: <20200516223306.GA161252@roeck-us.net>
On Sat, May 16, 2020 at 03:33:06PM -0700, Guenter Roeck wrote:
> On Thu, May 07, 2020 at 07:59:55AM -0700, ira.weiny@intel.com wrote:
> > From: Ira Weiny <ira.weiny@intel.com>
> >
> > Every single architecture (including !CONFIG_HIGHMEM) calls...
> >
> > pagefault_enable();
> > preempt_enable();
> >
> > ... before returning from __kunmap_atomic(). Lift this code into the
> > kunmap_atomic() macro.
> >
> > While we are at it rename __kunmap_atomic() to kunmap_atomic_high() to
> > be consistent.
> >
> > Reviewed-by: Christoph Hellwig <hch@lst.de>
> > Signed-off-by: Ira Weiny <ira.weiny@intel.com>
>
> This patch results in:
>
> Starting init: /bin/sh exists but couldn't execute it (error -14)
>
> when trying to boot microblazeel:petalogix-ml605 in qemu.
Thanks for the report. I'm not readily seeing the issue.
Do you have a kernel config? Specifically is CONFIG_HIGHMEM set?
>
> Bisect log attached.
>
> Guenter
>
> ---
> # bad: [bdecf38f228bcca73b31ada98b5b7ba1215eb9c9] Add linux-next specific files for 20200515
> # good: [2ef96a5bb12be62ef75b5828c0aab838ebb29cb8] Linux 5.7-rc5
> git bisect start 'HEAD' 'v5.7-rc5'
> # good: [3674d7aa7a8e61d993886c2fb7c896c5ef85e988] Merge remote-tracking branch 'crypto/master'
> git bisect good 3674d7aa7a8e61d993886c2fb7c896c5ef85e988
> # good: [87f6f21783522e6d62127cf33ae5e95f50874beb] Merge remote-tracking branch 'spi/for-next'
> git bisect good 87f6f21783522e6d62127cf33ae5e95f50874beb
> # good: [5c428e8277d5d97c85126387d4e00aa5adde4400] Merge remote-tracking branch 'staging/staging-next'
> git bisect good 5c428e8277d5d97c85126387d4e00aa5adde4400
> # good: [f68de67ed934e7bdef4799fd7777c86f33f14982] Merge remote-tracking branch 'hyperv/hyperv-next'
> git bisect good f68de67ed934e7bdef4799fd7777c86f33f14982
> # bad: [54acd2dc52b069da59639eea0d0c92726f32fb01] mm/memblock: fix a typo in comment "implict"->"implicit"
> git bisect bad 54acd2dc52b069da59639eea0d0c92726f32fb01
> # good: [784a17aa58a529b84f7cc50f351ed4acf3bd11f3] mm: remove the pgprot argument to __vmalloc
> git bisect good 784a17aa58a529b84f7cc50f351ed4acf3bd11f3
> # good: [6cd8137ff37e9a37aee2d2a8889c8beb8eab192f] khugepaged: replace the usage of system(3) in the test
> git bisect good 6cd8137ff37e9a37aee2d2a8889c8beb8eab192f
> # bad: [6987da379826ed01b8a1cf046b67cc8cc10117cc] sparc: remove unnecessary includes
> git bisect bad 6987da379826ed01b8a1cf046b67cc8cc10117cc
> # good: [bc17b545388f64c09e83e367898e28f60277c584] mm/hugetlb: define a generic fallback for is_hugepage_only_range()
> git bisect good bc17b545388f64c09e83e367898e28f60277c584
> # bad: [9b5aa5b43f957f03a1f4a9aff5f7924e2ebbc011] arch-kmap_atomic-consolidate-duplicate-code-checkpatch-fixes
> git bisect bad 9b5aa5b43f957f03a1f4a9aff5f7924e2ebbc011
> # good: [0941a38ff0790c1004270f952067a5918a4ba32d] arch/kmap: remove redundant arch specific kmaps
> git bisect good 0941a38ff0790c1004270f952067a5918a4ba32d
> # good: [56e635a64c2cbfa815c851af10e0f811e809977b] arch-kunmap-remove-duplicate-kunmap-implementations-fix
> git bisect good 56e635a64c2cbfa815c851af10e0f811e809977b
> # bad: [60f96b2233c790d4f1c49317643051f1670bcb29] arch/kmap_atomic: consolidate duplicate code
> git bisect bad 60f96b2233c790d4f1c49317643051f1670bcb29
> # good: [7b3708dc3bf72a647243064fe7ddf9a76248ddfd] {x86,powerpc,microblaze}/kmap: move preempt disable
> git bisect good 7b3708dc3bf72a647243064fe7ddf9a76248ddfd
> # first bad commit: [60f96b2233c790d4f1c49317643051f1670bcb29] arch/kmap_atomic: consolidate duplicate code
I'm confused by this. This points to an earlier commit being bad?
commit 60f96b2233c790d4f1c49317643051f1670bcb29
Author: Ira Weiny <ira.weiny@intel.com>
Date: Thu May 14 13:39:54 2020 +1000
arch/kmap_atomic: consolidate duplicate code
Every arch has the same code to ensure atomic operations and a check for
!HIGHMEM page.
Remove the duplicate code by defining a core kmap_atomic() which only
calls the arch specific kmap_atomic_high() when the page is high memory.
Link: http://lkml.kernel.org/r/20200507150004.1423069-7-ira.weiny@intel.com
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Christian König <christian.koenig@amd.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Helge Deller <deller@gmx.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Any idea which one it is?
Ira
^ permalink raw reply
* Re: [PATCH V3 07/15] arch/kunmap_atomic: Consolidate duplicate code
From: Guenter Roeck @ 2020-05-18 4:29 UTC (permalink / raw)
To: Ira Weiny
Cc: Peter Zijlstra, Dave Hansen, dri-devel, linux-mips,
James E.J. Bottomley, Max Filippov, Paul Mackerras,
H. Peter Anvin, sparclinux, Dan Williams, Helge Deller, x86,
linux-csky, Christoph Hellwig, Ingo Molnar, linux-snps-arc,
linux-xtensa, Borislav Petkov, Al Viro, Andy Lutomirski,
Thomas Gleixner, linux-arm-kernel, Chris Zankel,
Thomas Bogendoerfer, linux-parisc, linux-kernel, Christian Koenig,
Andrew Morton, linuxppc-dev, David S. Miller
In-Reply-To: <20200518034938.GA3023182@iweiny-DESK2.sc.intel.com>
On Sun, May 17, 2020 at 08:49:39PM -0700, Ira Weiny wrote:
> On Sat, May 16, 2020 at 03:33:06PM -0700, Guenter Roeck wrote:
> > On Thu, May 07, 2020 at 07:59:55AM -0700, ira.weiny@intel.com wrote:
> > > From: Ira Weiny <ira.weiny@intel.com>
> > >
> > > Every single architecture (including !CONFIG_HIGHMEM) calls...
> > >
> > > pagefault_enable();
> > > preempt_enable();
> > >
> > > ... before returning from __kunmap_atomic(). Lift this code into the
> > > kunmap_atomic() macro.
> > >
> > > While we are at it rename __kunmap_atomic() to kunmap_atomic_high() to
> > > be consistent.
> > >
> > > Reviewed-by: Christoph Hellwig <hch@lst.de>
> > > Signed-off-by: Ira Weiny <ira.weiny@intel.com>
> >
> > This patch results in:
> >
> > Starting init: /bin/sh exists but couldn't execute it (error -14)
> >
> > when trying to boot microblazeel:petalogix-ml605 in qemu.
>
> Thanks for the report. I'm not readily seeing the issue.
>
> Do you have a kernel config? Specifically is CONFIG_HIGHMEM set?
>
See below. Yes, CONFIG_HIGHMEM is set.
The scripts used to build and boot the image are at:
https://github.com/groeck/linux-build-test/tree/master/rootfs/microblazeel
Hope this helps,
Guenter
---
CONFIG_SYSVIPC=y
CONFIG_POSIX_MQUEUE=y
CONFIG_AUDIT=y
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
CONFIG_SYSFS_DEPRECATED=y
CONFIG_SYSFS_DEPRECATED_V2=y
CONFIG_BLK_DEV_INITRD=y
# CONFIG_BASE_FULL is not set
CONFIG_KALLSYMS_ALL=y
CONFIG_EMBEDDED=y
CONFIG_SLAB=y
CONFIG_KERNEL_BASE_ADDR=0x50000000
CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR=1
CONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTR=1
CONFIG_XILINX_MICROBLAZE0_USE_BARREL=1
CONFIG_XILINX_MICROBLAZE0_USE_DIV=1
CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL=2
CONFIG_XILINX_MICROBLAZE0_USE_FPU=2
CONFIG_XILINX_MICROBLAZE0_HW_VER="10.0.a"
CONFIG_HZ_100=y
CONFIG_MMU=y
CONFIG_HIGHMEM=y
CONFIG_PCI_XILINX=y
CONFIG_MODULES=y
CONFIG_MODULE_UNLOAD=y
# CONFIG_BLK_DEV_BSG is not set
CONFIG_PARTITION_ADVANCED=y
# CONFIG_EFI_PARTITION is not set
CONFIG_NET=y
CONFIG_PACKET=y
CONFIG_UNIX=y
CONFIG_INET=y
# CONFIG_IPV6 is not set
CONFIG_BRIDGE=m
CONFIG_PCI=y
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
CONFIG_MTD=y
CONFIG_MTD_CFI=y
CONFIG_MTD_CFI_INTELEXT=y
CONFIG_MTD_CFI_AMDSTD=y
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_SIZE=8192
CONFIG_NETDEVICES=y
CONFIG_XILINX_EMACLITE=y
CONFIG_XILINX_LL_TEMAC=y
# CONFIG_INPUT is not set
# CONFIG_SERIO is not set
# CONFIG_VT is not set
CONFIG_SERIAL_8250=y
CONFIG_SERIAL_8250_CONSOLE=y
CONFIG_SERIAL_OF_PLATFORM=y
CONFIG_SERIAL_UARTLITE=y
CONFIG_SERIAL_UARTLITE_CONSOLE=y
# CONFIG_HW_RANDOM is not set
CONFIG_XILINX_HWICAP=y
CONFIG_I2C=y
CONFIG_I2C_XILINX=y
CONFIG_SPI=y
CONFIG_SPI_XILINX=y
CONFIG_GPIOLIB=y
CONFIG_GPIO_SYSFS=y
CONFIG_GPIO_XILINX=y
# CONFIG_HWMON is not set
CONFIG_WATCHDOG=y
CONFIG_XILINX_WATCHDOG=y
CONFIG_FB=y
CONFIG_FB_XILINX=y
# CONFIG_USB_SUPPORT is not set
CONFIG_UIO=y
CONFIG_UIO_PDRV_GENIRQ=y
CONFIG_UIO_DMEM_GENIRQ=y
CONFIG_EXT2_FS=y
# CONFIG_DNOTIFY is not set
CONFIG_CRAMFS=y
CONFIG_ROMFS_FS=y
CONFIG_NFS_FS=y
CONFIG_CIFS=y
CONFIG_CIFS_STATS2=y
CONFIG_ENCRYPTED_KEYS=y
CONFIG_DEBUG_INFO=y
CONFIG_KGDB=y
CONFIG_KGDB_TESTS=y
CONFIG_KGDB_KDB=y
CONFIG_DEBUG_SLAB=y
CONFIG_DETECT_HUNG_TASK=y
CONFIG_DEBUG_SPINLOCK=y
^ permalink raw reply
* Re: [PATCH v8 2/5] powerpc/hv-24x7: Add rtas call in hv-24x7 driver to get processor details
From: kajoljain @ 2020-05-18 5:32 UTC (permalink / raw)
To: Nathan Lynch
Cc: ravi.bangoria, maddy, anju, peterz, gregkh, suka,
alexander.shishkin, mingo, mpetlan, yao.jin, ak, mamatha4, acme,
jmario, namhyung, linuxppc-dev, jolsa, kan.liang
In-Reply-To: <87blmu2nac.fsf@linux.ibm.com>
On 5/12/20 2:37 AM, Nathan Lynch wrote:
> Hi,
>
> Kajol Jain <kjain@linux.ibm.com> writes:
>> diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
>> index 48e8f4b17b91..8cf242aad98f 100644
>> --- a/arch/powerpc/perf/hv-24x7.c
>> +++ b/arch/powerpc/perf/hv-24x7.c
>> @@ -20,6 +20,7 @@
>> #include <asm/io.h>
>> #include <linux/byteorder/generic.h>
>>
>> +#include <asm/rtas.h>
>> #include "hv-24x7.h"
>> #include "hv-24x7-catalog.h"
>> #include "hv-common.h"
>> @@ -57,6 +58,75 @@ static bool is_physical_domain(unsigned domain)
>> }
>> }
>>
>> +/*
>> + * The Processor Module Information system parameter allows transferring
>> + * of certain processor module information from the platform to the OS.
>> + * Refer PAPR+ document to get parameter token value as '43'.
>> + */
>> +
>> +#define PROCESSOR_MODULE_INFO 43
>> +#define PROCESSOR_MAX_LENGTH (8 * 1024)
>> +
>> +DEFINE_SPINLOCK(rtas_local_data_buf_lock);
>> +EXPORT_SYMBOL(rtas_local_data_buf_lock);
>
> This should be static and not exported, correct?
>
>> +
>> +static u32 phys_sockets; /* Physical sockets */
>> +static u32 phys_chipspersocket; /* Physical chips per socket*/
>> +static u32 phys_coresperchip; /* Physical cores per chip */
>> +
>> +/*
>> + * Function read_sys_info_pseries() make a rtas_call which require
>> + * data buffer of size 8K. As standard 'rtas_data_buf' is of size
>> + * 4K, we are adding new local buffer 'rtas_local_data_buf'.
>
> Sorry if this has been covered before but I don't understand why it
> would require a larger buffer; by my reading this call will return *ten
> bytes* of output. Also, current versions of PAPR+ limit the output
> length to 4002 bytes. I feel like I'm missing something.
>
Hi Nathan,
Thanks for reviewing the patch. Actually when I was testing this patch in
both power8 and power9 machine, I got some issue in power9 because of buffer size.
And I checked the buffer size used in util_linux which is 8192. So, I increase the
buffer size.I will again test it as I did couple of changes after that with 4002 size.
>
>> + */
>> +static __be16 rtas_local_data_buf[PROCESSOR_MAX_LENGTH] __cacheline_aligned;
>> +
>> +/*
>> + * read_sys_info_pseries()
>> + * Retrieve the number of sockets and chips per socket and cores per
>> + * chip details through the get-system-parameter rtas call.
>> + */
>> +void read_sys_info_pseries(void)
>> +{
>> + int call_status, len, ntypes;
>> +
>> + /*
>> + * Making system parameter: chips and sockets and cores per chip
>> + * default to 1.
>> + */
>> + phys_sockets = 1;
>> + phys_chipspersocket = 1;
>> + phys_coresperchip = 1;
>> + memset(rtas_local_data_buf, 0, PROCESSOR_MAX_LENGTH * sizeof(__be16));
>
> Modifying global state outside of any critical section...? How do
> you prevent readers from seeing inconsistent results?
Yes right, Will update.
>
>
>> + spin_lock(&rtas_local_data_buf_lock);
>> +
>> + call_status = rtas_call(rtas_token("ibm,get-system-parameter"), 3, 1,
>> + NULL,
>> + PROCESSOR_MODULE_INFO,
>> + __pa(rtas_local_data_buf),
>> + PROCESSOR_MAX_LENGTH);
>> +
>> + spin_unlock(&rtas_local_data_buf_lock);
>
> Using this lock this way fails to provide any protection to the data
> buffer or the phys_* variables.
>
>
>> +
>> + if (call_status != 0) {
>> + pr_info("Error calling get-system-parameter (0x%x)\n",
>> + call_status);
>
> To be robust, this should handle busy (-2) and extended delay (990x)
> statuses. And if it's going to log errors it should use pr_err() and use
> decimal, not hex, to report the RTAS call status, since that's how
> they're specified in PAPR+.
Thanks for pointing it, Will update.
Thanks,
Kajol Jain
^ permalink raw reply
* Re: [PATCH v2 7/9] powerpc/ps3: Add check for otheros image size
From: Michael Ellerman @ 2020-05-18 6:31 UTC (permalink / raw)
To: Geoff Levand
Cc: linuxppc-dev, Geert Uytterhoeven, Markus Elfring,
Emmanuel Nicolet
In-Reply-To: <65353693-f082-42eb-aa89-ab11ea5f623b@infradead.org>
Geoff Levand <geoff@infradead.org> writes:
> Hi Michael,
>
> On 5/14/20 7:02 PM, Michael Ellerman wrote:
>> Geoff Levand <geoff@infradead.org> writes:
> ...
>>> + # The ps3's flash loader has a size limit of 16 MiB for the uncompressed
>>> + # image. If a compressed image that exceeded this limit is written to
>>> + # flash the loader will decompress that image until the 16 MiB limit is
>>> + # reached, then enter the system reset vector of the partially decompressed
>>> + # image. No warning is issued.
>>> + rm -f "$odir"/{otheros,otheros-too-big}.bld
>>> + size=$(${CROSS}nm --no-sort --radix=d "$ofile" | egrep ' _end$' | cut -d' ' -f1)
>>> + bld="otheros.bld"
>>> + if [ $size -gt $((0x1000000)) ]; then
>>> + bld="otheros-too-big.bld"
>>> + echo " INFO: Uncompressed kernel is too large to program into PS3 flash memory;" \
>>
>> This now appears on all my ppc64_defconfig builds, which I don't really
>> like.
>
> No, neither do I. I didn't think of that case.
>
>> That does highlight the fact that ppc64_defconfig including
>> CONFIG_PPC_PS3 is not really helpful for people actually wanting to run
>> the kernel on a PS3.
>
> No, this is just for the bootloader image (.bld) that can be
> programed into flash memory. This is what is used to create,
> for example, a petitboot bootloader image.
>
> Normal usage is for the bootloader in flash to load a vmlinux
> image from disk or network, in which case running a ppc64_defconfig
> image would be fine.
Ah yep, that rings a bell.
>> So I wonder if we should drop CONFIG_PPC_PS3 from ppc64_defconfig, in
>> which case I'd be happy to keep the INFO message because it should only
>> appear on ps3 specific builds.
>
> I'd like to keep CONFIG_PPC_PS3 set in ppc64_defconfig. I feel it
> useful to get some build testing of the PS3 platform code.
>
>> The other option would be to drop the message, or only print it when
>> we're doing a verbose build.
>
> Building a boatloader image to program into flash memory is
> something only very advanced users would be doing. I don't
> think they would need this message. They would see the file
> name and understand the situation. I'll post a v3 patch that
> removes the message.
Great, thanks.
cheers
^ permalink raw reply
* Re: [PATCH] powerpc/book3s64/radix/tlb: Determine hugepage flush correctly
From: Michael Ellerman @ 2020-05-18 6:34 UTC (permalink / raw)
To: Nicholas Piggin, Aneesh Kumar K.V, linuxppc-dev; +Cc: Bharata B Rao
In-Reply-To: <1589344088.xrvol2hteg.astroid@bobo.none>
Nicholas Piggin <npiggin@gmail.com> writes:
> Excerpts from Aneesh Kumar K.V's message of May 13, 2020 1:06 pm:
>> With a 64K page size flush with start and end value as below
>> (start, end) = (721f680d0000, 721f680e0000) results in
>> (hstart, hend) = (721f68200000, 721f68000000)
>>
>> Avoid doing a __tlbie_va_range with the wrong hstart and hend value in this
>> case.
>>
>> __tlbie_va_range will skip the actual tlbie operation for start > end.
>> But we still end up doing the tlbie fixup.
>
> Hm, good catch.
>
>> Reported-by: Bharata B Rao <bharata@linux.ibm.com>
>> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
>> ---
>> arch/powerpc/mm/book3s64/radix_tlb.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/powerpc/mm/book3s64/radix_tlb.c b/arch/powerpc/mm/book3s64/radix_tlb.c
>> index 758ade2c2b6e..d592f9e1c037 100644
>> --- a/arch/powerpc/mm/book3s64/radix_tlb.c
>> +++ b/arch/powerpc/mm/book3s64/radix_tlb.c
>> @@ -884,10 +884,10 @@ static inline void __radix__flush_tlb_range(struct mm_struct *mm,
>> if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) {
>> hstart = (start + PMD_SIZE - 1) & PMD_MASK;
>> hend = end & PMD_MASK;
>> - if (hstart == hend)
>> - hflush = false;
>> - else
>> + if (hstart < hend)
>> hflush = true;
>> + else
>> + hflush = false;
>
> We can probably get rid of the else part since it is already false.
Yeah I can do that when applying.
cheers
^ 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