* Re: [PATCH v2 00/23] powerpc: Fix W=1 compile errors
From: Michael Ellerman @ 2021-02-03 11:40 UTC (permalink / raw)
To: linuxppc-dev, Cédric Le Goater; +Cc: Christophe Leroy
In-Reply-To: <20210104143206.695198-1-clg@kaod.org>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3887 bytes --]
On Mon, 4 Jan 2021 15:31:43 +0100, Cédric Le Goater wrote:
> Here is an assorted collection of fixes for W=1.
>
> After this series, only a few errors are left, some missing declarations
> in arch/powerpc/kernel/sys_ppc32.c, panic_smp_self_stop() declaration
> and a few of these which I don't know how to fix :
>
> ./arch/powerpc/xmon/xmon.c: In function ‘xmon_print_symbol’:
> ./arch/powerpc/xmon/xmon.c:3656:14: error: variable ‘name’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
> 3656 | const char *name = NULL;
> | ^~~~
>
> [...]
Applied to powerpc/next.
[01/23] powerpc/mm: Include __find_linux_pte() prototype
https://git.kernel.org/powerpc/c/d25da505c3f567a8667adb0118de1400468172ac
[02/23] powerpc/pseries/ras: Remove unused variable 'status'
https://git.kernel.org/powerpc/c/aa23ea0c5f7f9a46e6aa3be0a4cfdfb80fabca6d
[03/23] powerpc/pseries/eeh: Make pseries_pcibios_bus_add_device() static
https://git.kernel.org/powerpc/c/44159329e0ad160af7cc7e84fa6d97531c8ed78f
[04/23] powerpc/pseries/ras: Make init_ras_hotplug_IRQ() static
https://git.kernel.org/powerpc/c/90db8bf24d133654032a1c7dd46aa5096627b9ff
[05/23] powerpc/pmem: Include pmem prototypes
https://git.kernel.org/powerpc/c/d03f210e6ed8f5d64b00f0f07b03db74aa5b95a1
[06/23] powerpc/setup_64: Make some routines static
https://git.kernel.org/powerpc/c/692e592895266bafb1e0d688e960b4bdd8e165a8
[07/23] powerpc/mce: Include prototypes
https://git.kernel.org/powerpc/c/1cc2fd75934454be024cd7609b6d7890de6e724b
[08/23] powerpc/smp: Include tick_broadcast() prototype
https://git.kernel.org/powerpc/c/cd7aa5d2fae11794a00ea34b10ee58434d718bc3
[09/23] powerpc/smp: Make debugger_ipi_callback() static
https://git.kernel.org/powerpc/c/157c9f409d11fe79f09c69e78bfc7f8fe7410744
[10/23] powerpc/optprobes: Remove unused routine patch_imm32_load_insns()
https://git.kernel.org/powerpc/c/d47d307f1049be545d45cf0f2332495ec9a89cc0
[11/23] powerpc/optprobes: Make patch_imm64_load_insns() static
https://git.kernel.org/powerpc/c/bb21e1b6c5352d62d866e9236ed427f632cd537b
[12/23] powerpc/mm: Declare some prototypes
https://git.kernel.org/powerpc/c/cccaf1a10abf03d91321d29ff333d6d5d4cef542
[13/23] powerpc/mm: Move hpte_insert_repeating() prototype
https://git.kernel.org/powerpc/c/11f9c1d2fb497f69f83d4fab6fb7fc8a6884eded
[14/23] powerpc/mm: Declare preload_new_slb_context() prototype
https://git.kernel.org/powerpc/c/1f55aefea3c1431f662aafa02ef9ac18d8880751
[15/23] powerpc/mm/hugetlb: Make pseries_alloc_bootmem_huge_page() static
https://git.kernel.org/powerpc/c/94b87d72fc852b6995702d74541136a65f88624a
[16/23] powerpc/mm: Declare arch_report_meminfo() prototype.
https://git.kernel.org/powerpc/c/1429ff51480fe5a21a3d17158d259a4b4b04808f
[17/23] powerpc/watchdog: Declare soft_nmi_interrupt() prototype
https://git.kernel.org/powerpc/c/9ae440fb3d7d1c91ada7d6b13e009bd9f4f00e6c
[18/23] KVM: PPC: Make the VMX instruction emulation routines static
https://git.kernel.org/powerpc/c/9236f57a9e51c72ce426ccd2e53e123de7196a0f
[19/23] KVM: PPC: Book3S HV: Include prototypes
https://git.kernel.org/powerpc/c/d834915e8ee28884f1180dc566ba77c8768ec00a
[20/23] KVM: PPC: Book3S HV: Declare some prototypes
https://git.kernel.org/powerpc/c/ce275179b6c98032361271927b7458884e9708b1
[21/23] powerpc/pseries: Make IOV setup routines static
https://git.kernel.org/powerpc/c/42c1f400d1da50dd1cd9f874df72dc827f9fe2d2
[22/23] powerpc/pcidn: Make IOV setup routines static
https://git.kernel.org/powerpc/c/53137a9b51e49e0399ad322e4a39bc5f9bf0a1de
[23/23] powerpc/pseries/eeh: Make pseries_send_allow_unfreeze() static
https://git.kernel.org/powerpc/c/22f1de2e13b066921dedf6a00d2cc414f3cbab05
cheers
^ permalink raw reply
* Re: [PATCH v5 1/2] powerpc/mce: Reduce the size of event arrays
From: Michael Ellerman @ 2021-02-03 11:40 UTC (permalink / raw)
To: linuxppc-dev, Ganesh Goudar, mpe; +Cc: mahesh, npiggin
In-Reply-To: <20210128104143.70668-1-ganeshgr@linux.ibm.com>
On Thu, 28 Jan 2021 16:11:42 +0530, Ganesh Goudar wrote:
> Maximum recursive depth of MCE is 4, Considering the maximum depth
> allowed reduce the size of event to 10 from 100. This saves us ~19kB
> of memory and has no fatal consequences.
Applied to powerpc/next.
[1/2] powerpc/mce: Reduce the size of event arrays
https://git.kernel.org/powerpc/c/17c5cf0fb993e219bda4f53aa9ec90d3cfcf92ab
[2/2] powerpc/mce: Remove per cpu variables from MCE handlers
https://git.kernel.org/powerpc/c/923b3cf00b3ffc896543bac99affc0fa8553e41a
cheers
^ permalink raw reply
* Re: [PATCH] powerpc/time: enable sched clock for irqtime
From: Michael Ellerman @ 2021-02-03 11:40 UTC (permalink / raw)
To: linuxppc-dev, Pingfan Liu; +Cc: Christophe Leroy, Nicholas Piggin
In-Reply-To: <1603349479-26185-1-git-send-email-kernelfans@gmail.com>
On Thu, 22 Oct 2020 14:51:19 +0800, Pingfan Liu wrote:
> When CONFIG_IRQ_TIME_ACCOUNTING and CONFIG_VIRT_CPU_ACCOUNTING_GEN, powerpc
> does not enable "sched_clock_irqtime" and can not utilize irq time
> accounting.
>
> Like x86, powerpc does not use the sched_clock_register() interface. So it
> needs an dedicated call to enable_sched_clock_irqtime() to enable irq time
> accounting.
Applied to powerpc/next.
[1/1] powerpc/time: Enable sched clock for irqtime
https://git.kernel.org/powerpc/c/b709e32ef570b8b91dfbcb63cffac4324c87799f
cheers
^ permalink raw reply
* Re: [PATCH v3] powerpc/perf/hv-24x7: Dont create sysfs event files for dummy events
From: Michael Ellerman @ 2021-02-03 11:40 UTC (permalink / raw)
To: linuxppc-dev, Kajol Jain, mpe; +Cc: suka, atrajeev, maddy
In-Reply-To: <20201228085204.18026-1-kjain@linux.ibm.com>
On Mon, 28 Dec 2020 14:22:04 +0530, Kajol Jain wrote:
> hv_24x7 performance monitoring unit creates list of supported events
> from the event catalog obtained via HCALL. hv_24x7 catalog could also
> contain invalid or dummy events with names like RESERVED*.
> These events does not have any hardware counters backing them.
> So patch adds a check to string compare the event names
> to filter out them.
>
> [...]
Applied to powerpc/next.
[1/1] powerpc/perf/hv-24x7: Dont create sysfs event files for dummy events
https://git.kernel.org/powerpc/c/e5f9d8858612c192a4326f39ed16c91c3a9e0893
cheers
^ permalink raw reply
* Re: [PATCH 0/2] powerpc/82xx: Adjustments for pq2ads_pci_init_irq()
From: Michael Ellerman @ 2021-02-03 11:40 UTC (permalink / raw)
To: linuxppc-dev, Benjamin Herrenschmidt, Kate Stewart,
Thomas Gleixner, Michael Ellerman, Markus Elfring,
Greg Kroah-Hartman, Paul Mackerras, Enrico Weigelt
Cc: kernel-janitors, LKML
In-Reply-To: <6dc7d70e-8a40-46ab-897b-d2eaf9a87d77@web.de>
On Tue, 27 Aug 2019 10:23:29 +0200, Markus Elfring wrote:
> Two update suggestions were taken into account
> from static source code analysis.
>
> Markus Elfring (2):
> Delete an unnecessary of_node_put() call
> Use common error handling code
>
> [...]
Applied to powerpc/next.
[1/2] powerpc/82xx: Delete an unnecessary of_node_put() call in pq2ads_pci_init_irq()
https://git.kernel.org/powerpc/c/60aece416483fdf7e51728a3518438e0458bdabb
[2/2] powerpc/82xx: Use common error handling code in pq2ads_pci_init_irq()
https://git.kernel.org/powerpc/c/c0cff7a17781f8b02b4837a9fc434a7eed322a14
cheers
^ permalink raw reply
* Re: [PATCH 0/2] PowerPC-pSeries: Adjustments for dlpar_store()
From: Michael Ellerman @ 2021-02-03 11:40 UTC (permalink / raw)
To: linuxppc-dev, Benjamin Herrenschmidt, Frank Rowand,
Michael Ellerman, Allison Randal, Markus Elfring,
Oliver O'Halloran, Nathan Lynch, Greg Kroah-Hartman,
Paul Mackerras, Gen Zhang, Nathan Fontenot, Thomas Gleixner
Cc: kernel-janitors, LKML
In-Reply-To: <db28c84d-ac07-6d9a-a371-c97ab72bf763@web.de>
On Tue, 27 Aug 2019 14:40:42 +0200, Markus Elfring wrote:
> Two update suggestions were taken into account
> from static source code analysis.
>
> Markus Elfring (2):
> Delete an unnecessary kfree() call
> Delete an error message for a failed string duplication
>
> [...]
Applied to powerpc/next.
[1/2] powerpc/pseries: Delete an unnecessary kfree() call in dlpar_store()
https://git.kernel.org/powerpc/c/de060ac83e5c1fe5fb8c505a4e99c1fe4f70ff94
[2/2] powerpc/pseries: Delete an error message for a failed string duplication in dlpar_store()
https://git.kernel.org/powerpc/c/6e7a4da754f3087fa1f0839c1128aac233c21442
cheers
^ permalink raw reply
* Re: [PATCH] cxl: Reduce scope for the variable “mm” in cxllib_get_PE_attributes()
From: Michael Ellerman @ 2021-02-03 11:40 UTC (permalink / raw)
To: linuxppc-dev, Andrew Donnellan, Arnd Bergmann, Markus Elfring,
Frederic Barrat, Greg Kroah-Hartman
Cc: kernel-janitors, LKML
In-Reply-To: <5cee2b25-71e0-15aa-fba6-12211b8308aa@web.de>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 460 bytes --]
On Thu, 10 Dec 2020 15:35:38 +0100, Markus Elfring wrote:
> A local variable was used only within an if branch.
> Thus move the definition for the variable “mm” into the corresponding
> code block.
>
> This issue was detected by using the Coccinelle software.
Applied to powerpc/next.
[1/1] cxl: Reduce scope for the variable “mm” in cxllib_get_PE_attributes()
https://git.kernel.org/powerpc/c/245a389c6ded15a7d308dbe988aec8a96e8aa8cf
cheers
^ permalink raw reply
* Re: [PATCH] powerpc/setup: Adjust six seq_printf() calls in show_cpuinfo()
From: Michael Ellerman @ 2021-02-03 11:40 UTC (permalink / raw)
To: linuxppc-dev, Andrew Morton, Benjamin Herrenschmidt,
Mike Rapoport, Aneesh Kumar K.V, Michael Ellerman, Markus Elfring,
Christophe Leroy, Paul Mackerras
Cc: kernel-janitors, LKML
In-Reply-To: <5b62379e-a35f-4f56-f1b5-6350f76007e7@web.de>
On Tue, 2 Jul 2019 14:56:46 +0200, Markus Elfring wrote:
> A bit of information should be put into a sequence.
> Thus improve the execution speed for this data output by better usage
> of corresponding functions.
>
> This issue was detected by using the Coccinelle software.
Applied to powerpc/next.
[1/1] powerpc/setup: Adjust six seq_printf() calls in show_cpuinfo()
https://git.kernel.org/powerpc/c/675b963e2b6007818fe1b0a64b47be40c125246e
cheers
^ permalink raw reply
* Re: [PATCH] powerpc: Fix build error in paravirt.h
From: Michael Ellerman @ 2021-02-03 11:40 UTC (permalink / raw)
To: linuxppc-dev, Michal Suchanek
Cc: Juergen Gross, Srikar Dronamraju, Deep Shah, VMware, Inc.,
linux-kernel, virtualization, Paul Mackerras, Waiman Long
In-Reply-To: <20210120132838.15589-1-msuchanek@suse.de>
On Wed, 20 Jan 2021 14:28:38 +0100, Michal Suchanek wrote:
> ./arch/powerpc/include/asm/paravirt.h:83:44: error: implicit declaration
> of function 'smp_processor_id'; did you mean 'raw_smp_processor_id'?
>
> smp_processor_id is defined in linux/smp.h but it is not included.
>
> The build error happens only when the patch is applied to 5.3 kernel but
> it only works by chance in mainline.
Applied to powerpc/next.
[1/1] powerpc: Fix build error in paravirt.h
https://git.kernel.org/powerpc/c/9899a56f1eca964cd0de21008a9fa1523a571231
cheers
^ permalink raw reply
* Re: [PATCH] powerpc/64s/kuap: Use mmu_has_feature()
From: Michael Ellerman @ 2021-02-03 11:40 UTC (permalink / raw)
To: Michael Ellerman, linuxppc-dev
In-Reply-To: <20201217005306.895685-1-mpe@ellerman.id.au>
On Thu, 17 Dec 2020 11:53:06 +1100, Michael Ellerman wrote:
> In commit 8150a153c013 ("powerpc/64s: Use early_mmu_has_feature() in
> set_kuap()") we switched the KUAP code to use early_mmu_has_feature(),
> to avoid a bug where we called set_kuap() before feature patching had
> been done, leading to recursion and crashes.
>
> That path, which called probe_kernel_read() from printk(), has since
> been removed, see commit 2ac5a3bf7042 ("vsprintf: Do not break early
> boot with probing addresses").
>
> [...]
Applied to powerpc/next.
[1/1] powerpc/64s/kuap: Use mmu_has_feature()
https://git.kernel.org/powerpc/c/7613f5a66becfd0e43a0f34de8518695888f5458
cheers
^ permalink raw reply
* Re: [PATCH v2] powerpc: always enable queued spinlocks for 64s, disable for others
From: Michael Ellerman @ 2021-02-03 11:40 UTC (permalink / raw)
To: linuxppc-dev, Nicholas Piggin
In-Reply-To: <20210118123451.1452206-1-npiggin@gmail.com>
On Mon, 18 Jan 2021 22:34:51 +1000, Nicholas Piggin wrote:
> Queued spinlocks have shown to have good performance and fairness
> properties even on smaller (2 socket) POWER systems. This selects
> them automatically for 64s. For other platforms they are de-selected,
> the standard spinlock is far simpler and smaller code, and single
> chips with a handful of cores is unlikely to show any improvement.
>
> CONFIG_EXPERT still allows this to be changed, e.g., to help debug
> performance or correctness issues.
Applied to powerpc/next.
[1/1] powerpc: Always enable queued spinlocks for 64s, disable for others
https://git.kernel.org/powerpc/c/c9f3401313a5089f100d7d1ef4b75cd7b49b2190
cheers
^ permalink raw reply
* Re: [PATCH 1/2] powerpc/eeh: Rework pci_dev lookup in debugfs attributes
From: Michael Ellerman @ 2021-02-03 11:40 UTC (permalink / raw)
To: linuxppc-dev, Oliver O'Halloran
In-Reply-To: <20201103051512.919333-1-oohall@gmail.com>
On Tue, 3 Nov 2020 16:15:11 +1100, Oliver O'Halloran wrote:
> Pull the string -> pci_dev lookup stuff into a helper function. No functional change.
Applied to powerpc/next.
[1/2] powerpc/eeh: Rework pci_dev lookup in debugfs attributes
https://git.kernel.org/powerpc/c/b5e904b83067bbbd7dc83ea3734c119f8796d79f
[2/2] powerpc/eeh: Add a debugfs interface to check if a driver supports recovery
https://git.kernel.org/powerpc/c/9e857416833d9701a406ecd6f03a695405ada5e6
cheers
^ permalink raw reply
* Re: [PATCH] powerpc/pci: Delete traverse_pci_dn()
From: Michael Ellerman @ 2021-02-03 11:40 UTC (permalink / raw)
To: linuxppc-dev, Oliver O'Halloran
In-Reply-To: <20200902035121.1762475-1-oohall@gmail.com>
On Wed, 2 Sep 2020 13:51:21 +1000, Oliver O'Halloran wrote:
> Nothing uses it.
Applied to powerpc/next.
[1/1] powerpc/pci: Delete traverse_pci_dn()
https://git.kernel.org/powerpc/c/7bd2b120f3fdf8e5c6d9a343517a33c2a5108794
cheers
^ permalink raw reply
* Re: [PATCH 1/3] selftests/powerpc: Hoist helper code out of eeh-basic
From: Michael Ellerman @ 2021-02-03 11:40 UTC (permalink / raw)
To: linuxppc-dev, Oliver O'Halloran
In-Reply-To: <20201103044503.917128-1-oohall@gmail.com>
On Tue, 3 Nov 2020 15:45:01 +1100, Oliver O'Halloran wrote:
> Hoist some of the useful test environment checking and prep code into
> eeh-functions.sh so they can be reused in other tests.
Applied to powerpc/next.
[1/3] selftests/powerpc: Hoist helper code out of eeh-basic
https://git.kernel.org/powerpc/c/db82f7097c265776c22ad866511074836f17665e
[2/3] selftests/powerpc: Use stderr for debug messages in eeh-functions
https://git.kernel.org/powerpc/c/d6749ccba7ff86f99b4672e50db871487ba69f19
[3/3] selftests/powerpc: Add VF recovery tests
https://git.kernel.org/powerpc/c/38132cc0e5a6b22b04fac2e4df25c59435fcd6de
cheers
^ permalink raw reply
* Re: [PATCH] selftests/powerpc: make the test check in eeh-basic.sh posix compliant
From: Michael Ellerman @ 2021-02-03 11:40 UTC (permalink / raw)
To: linuxppc-dev, linux-kernel, linux-kselftest, Po-Hsu Lin
Cc: shuah, oohall, paulus
In-Reply-To: <20201228043459.14281-1-po-hsu.lin@canonical.com>
On Mon, 28 Dec 2020 12:34:59 +0800, Po-Hsu Lin wrote:
> The == operand is a bash extension, thus this will fail on Ubuntu with
>
> As the /bin/sh on Ubuntu is pointed to DASH.
>
> Use -eq to fix this posix compatibility issue.
Applied to powerpc/next.
[1/1] selftests/powerpc: Make the test check in eeh-basic.sh posix compliant
https://git.kernel.org/powerpc/c/3db380570af7052620ace20c29e244938610ca71
cheers
^ permalink raw reply
* Re: [PATCH v2 -next] misc: ocxl: use DEFINE_MUTEX() for mutex lock
From: Michael Ellerman @ 2021-02-03 11:40 UTC (permalink / raw)
To: linuxppc-dev, linux-kernel, Zheng Yongjun; +Cc: fbarrat, gregkh, ajd, arnd
In-Reply-To: <20201224132446.31286-1-zhengyongjun3@huawei.com>
On Thu, 24 Dec 2020 21:24:46 +0800, Zheng Yongjun wrote:
> mutex lock can be initialized automatically with DEFINE_MUTEX()
> rather than explicitly calling mutex_init().
Applied to powerpc/next.
[1/1] ocxl: use DEFINE_MUTEX() for mutex lock
https://git.kernel.org/powerpc/c/52f6b0a90bcf573ba8a33e97544c7b6f292376a4
cheers
^ permalink raw reply
* Re: [PATCH 1/2] powerpc/vdso: fix unnecessary rebuilds of vgettimeofday.o
From: Michael Ellerman @ 2021-02-03 11:46 UTC (permalink / raw)
To: Michael Ellerman, Paul Mackerras, Benjamin Herrenschmidt,
Masahiro Yamada, linuxppc-dev
Cc: Ravi Bangoria, linux-kernel, Nicholas Piggin,
Oliver O'Halloran, Greentime Hu, Michal Suchanek,
Ard Biesheuvel, Daniel Axtens
In-Reply-To: <20201223171142.707053-1-masahiroy@kernel.org>
On Thu, 24 Dec 2020 02:11:41 +0900, Masahiro Yamada wrote:
> vgettimeofday.o is unnecessarily rebuilt. Adding it to 'targets' is not
> enough to fix the issue. Kbuild is correctly rebuilding it because the
> command line is changed.
>
> PowerPC builds each vdso directory twice; first in vdso_prepare to
> generate vdso{32,64}-offsets.h, second as part of the ordinary build
> process to embed vdso{32,64}.so.dbg into the kernel.
>
> [...]
Applied to powerpc/fixes.
[1/2] powerpc/vdso: fix unnecessary rebuilds of vgettimeofday.o
https://git.kernel.org/powerpc/c/bce74491c3008e27dd6e8f79a83b4faa77a08f7e
[2/2] powerpc/vdso64: remove meaningless vgettimeofday.o build rule
https://git.kernel.org/powerpc/c/66f0a9e058fad50e569ad752be72e52701991fd5
cheers
^ permalink raw reply
* Re: [PATCH] powerpc/64s: prevent recursive replay_soft_interrupts causing superfluous interrupt
From: Michael Ellerman @ 2021-02-03 11:46 UTC (permalink / raw)
To: Nicholas Piggin, linuxppc-dev; +Cc: Athira Rajeev
In-Reply-To: <20210123061244.2076145-1-npiggin@gmail.com>
On Sat, 23 Jan 2021 16:12:44 +1000, Nicholas Piggin wrote:
> When an asynchronous interrupt calls irq_exit, it checks for softirqs
> that may have been created, and runs them. Running softirqs enables
> local irqs, which can replay pending interrupts causing recursion in
> replay_soft_interrupts. This abridged trace shows how this can occur:
>
> ! NIP replay_soft_interrupts
> LR interrupt_exit_kernel_prepare
> Call Trace:
> interrupt_exit_kernel_prepare (unreliable)
> interrupt_return
> --- interrupt: ea0 at __rb_reserve_next
> NIP __rb_reserve_next
> LR __rb_reserve_next
> Call Trace:
> ring_buffer_lock_reserve
> trace_function
> function_trace_call
> ftrace_call
> __do_softirq
> irq_exit
> timer_interrupt
> ! replay_soft_interrupts
> interrupt_exit_kernel_prepare
> interrupt_return
> --- interrupt: ea0 at arch_local_irq_restore
>
> [...]
Applied to powerpc/fixes.
[1/1] powerpc/64s: prevent recursive replay_soft_interrupts causing superfluous interrupt
https://git.kernel.org/powerpc/c/4025c784c573cab7e3f84746cc82b8033923ec62
cheers
^ permalink raw reply
* Re: [PATCH v2] powerpc/sstep: Fix array out of bound warning
From: Michael Ellerman @ 2021-02-03 11:46 UTC (permalink / raw)
To: Ravi Bangoria, mpe; +Cc: naveen.n.rao, jniethe5, paulus, linuxppc-dev
In-Reply-To: <20210129071745.111466-1-ravi.bangoria@linux.ibm.com>
On Fri, 29 Jan 2021 12:47:45 +0530, Ravi Bangoria wrote:
> Compiling kernel with -Warray-bounds throws below warning:
>
> In function 'emulate_vsx_store':
> warning: array subscript is above array bounds [-Warray-bounds]
> buf.d[2] = byterev_8(reg->d[1]);
> ~~~~~^~~
> buf.d[3] = byterev_8(reg->d[0]);
> ~~~~~^~~
>
> [...]
Applied to powerpc/fixes.
[1/1] powerpc/sstep: Fix array out of bound warning
https://git.kernel.org/powerpc/c/344717a14cd7272f88346022a77742323346299e
cheers
^ permalink raw reply
* Re: [PATCH] powerpc/64/signal: Fix regression in __kernel_sigtramp_rt64 semantics
From: Michael Ellerman @ 2021-02-03 11:46 UTC (permalink / raw)
To: Raoni Fassina Firmino, linuxppc-dev; +Cc: Nicholas Piggin
In-Reply-To: <20210201200505.iz46ubcizipnkcxe@work-tp>
On Mon, 1 Feb 2021 17:05:05 -0300, Raoni Fassina Firmino wrote:
> Tested on powerpc64 and powerpc64le, with a glibc build and running the
> affected glibc's testcase[2], inspected that glibc's backtrace() now gives
> the correct result and gdb backtrace also keeps working as before.
>
> I believe this should be backported to releases 5.9 and 5.10 as userspace
> is affected in this releases.
>
> [...]
Applied to powerpc/fixes.
[1/1] powerpc/64/signal: Fix regression in __kernel_sigtramp_rt64() semantics
https://git.kernel.org/powerpc/c/24321ac668e452a4942598533d267805f291fdc9
cheers
^ permalink raw reply
* Re: [PATCH v9 6/6] powerpc: Book3S 64-bit outline-only KASAN support
From: Daniel Axtens @ 2021-02-03 11:46 UTC (permalink / raw)
To: Christophe Leroy, linux-kernel, linux-mm, linuxppc-dev, kasan-dev,
christophe.leroy, aneesh.kumar, bsingharora
In-Reply-To: <251530bd-49ab-4d6e-13bc-03f97edafcc4@csgroup.eu>
Hi Christophe,
>> select HAVE_ARCH_HUGE_VMAP if PPC_BOOK3S_64 && PPC_RADIX_MMU
>> select HAVE_ARCH_JUMP_LABEL
>> select HAVE_ARCH_KASAN if PPC32 && PPC_PAGE_SHIFT <= 14
>> - select HAVE_ARCH_KASAN_VMALLOC if PPC32 && PPC_PAGE_SHIFT <= 14
>> + select HAVE_ARCH_KASAN if PPC_BOOK3S_64 && PPC_RADIX_MMU
>
> PPC_RADIX_MMU already depends on PPC_BOOK3S_64 so 'if PPC_RADIX_MMU' would be enough
Done.
>> + select HAVE_ARCH_NO_KASAN_INLINE if PPC_BOOK3S_64 && PPC_RADIX_MMU
>
> This list must respect Alphabetical order.
Fixed.
>
>> + select HAVE_ARCH_KASAN_VMALLOC if HAVE_ARCH_KASAN
>> select HAVE_ARCH_KGDB
>> select HAVE_ARCH_MMAP_RND_BITS
>> select HAVE_ARCH_MMAP_RND_COMPAT_BITS if COMPAT
>> diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug
>> index b88900f4832f..60c1bba72a6f 100644
>> --- a/arch/powerpc/Kconfig.debug
>> +++ b/arch/powerpc/Kconfig.debug
>> @@ -396,5 +396,5 @@ config PPC_FAST_ENDIAN_SWITCH
>>
>> config KASAN_SHADOW_OFFSET
>> hex
>> - depends on KASAN
>> + depends on KASAN && PPC32
>> default 0xe0000000
>
> Instead of the above, why not doing:
>
> default 0xe0000000 if PPC32
> default 0xa80e000000000000 is PPC_BOOK3S_64
Done. I just used PPC64.
>
>> diff --git a/arch/powerpc/include/asm/book3s/64/hash.h b/arch/powerpc/include/asm/book3s/64/hash.h
>> index 73ad038ed10b..105b90594a8a 100644
>> --- a/arch/powerpc/include/asm/book3s/64/hash.h
>> +++ b/arch/powerpc/include/asm/book3s/64/hash.h
>> @@ -18,6 +18,10 @@
>> #include <asm/book3s/64/hash-4k.h>
>> #endif
>>
>> +#define H_PTRS_PER_PTE (1 << H_PTE_INDEX_SIZE)
>> +#define H_PTRS_PER_PMD (1 << H_PMD_INDEX_SIZE)
>> +#define H_PTRS_PER_PUD (1 << H_PUD_INDEX_SIZE)
>> +
>> /* Bits to set in a PMD/PUD/PGD entry valid bit*/
>> #define HASH_PMD_VAL_BITS (0x8000000000000000UL)
>> #define HASH_PUD_VAL_BITS (0x8000000000000000UL)
>> diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h
>> index a39886681629..767e239d75e3 100644
>> --- a/arch/powerpc/include/asm/book3s/64/pgtable.h
>> +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
>> @@ -230,6 +230,13 @@ extern unsigned long __pmd_frag_size_shift;
>> #define PTRS_PER_PUD (1 << PUD_INDEX_SIZE)
>> #define PTRS_PER_PGD (1 << PGD_INDEX_SIZE)
>>
>> +#define MAX_PTRS_PER_PTE ((H_PTRS_PER_PTE > R_PTRS_PER_PTE) ? \
>> + H_PTRS_PER_PTE : R_PTRS_PER_PTE)
>
> Nowadays we allow 100 chars per line. Could this fit on a single line ?
Yes, so long as we drop the tab between the name and the definition and
replace it with a single space.
>> +#define MAX_PTRS_PER_PMD ((H_PTRS_PER_PMD > R_PTRS_PER_PMD) ? \
>> + H_PTRS_PER_PMD : R_PTRS_PER_PMD)
>> +#define MAX_PTRS_PER_PUD ((H_PTRS_PER_PUD > R_PTRS_PER_PUD) ? \
>> + H_PTRS_PER_PUD : R_PTRS_PER_PUD)
>> +
>> /* PMD_SHIFT determines what a second-level page table entry can map */
>> #define PMD_SHIFT (PAGE_SHIFT + PTE_INDEX_SIZE)
>> #define PMD_SIZE (1UL << PMD_SHIFT)
>> +#ifdef CONFIG_PPC32
>> #define KASAN_SHADOW_END (-(-KASAN_SHADOW_START >> KASAN_SHADOW_SCALE_SHIFT))
>> +#endif
>> +
>> +#ifdef CONFIG_PPC_BOOK3S_64
>> +/*
>> + * We define the offset such that the shadow of the linear map lives
>> + * at the end of vmemmap space, that is, we choose offset such that
>> + * shadow(c000_0000_0000_0000) = c00e_0000_0000_0000. This gives:
>> + * c00e000000000000 - c000000000000000 >> 3 = a80e000000000000
>> + */
>> +#define KASAN_SHADOW_OFFSET ASM_CONST(0xa80e000000000000)
>
> Why can't you use CONFIG_KASAN_SHADOW_OFFSET ?
I didn't do this earlier due to some interesting interactions in the
generic configuration. The generic Kconfig/Makefile will turn on stack
instrumentation if CONFIG_KASAN_SHADOW_OFFSET is set. This, however,
creates a bunch of inline code that crashes on ppc64 when it runs
translations off.
I've made changes to the patch that introduces ARCH_DISABLE_KASAN_INLINE
to fix this, and converted to using CONFIG_KASAN_SHADOW_OFFSET.
>> +
>> +/*
>> + * The shadow ends before the highest accessible address
>> + * because we don't need a shadow for the shadow. Instead:
>> + * c00e000000000000 << 3 + a80e000000000000000 = c00fc00000000000
>> + */
>> +#define KASAN_SHADOW_END 0xc00fc00000000000UL
>
> I think we should be able to have a common formula for PPC32 and PPC64.
>
Perhaps, but I can't figure out what it would be. For PPC64,
end = start + (size of kernel space + vmalloc space + ioremap space + vmemmap space) >> 3
For PPC32, AIUI you don't have vmemmap space so I'm not sure how to
calculate it.
>> +
>> +DECLARE_STATIC_KEY_FALSE(powerpc_kasan_enabled_key);
>> +
>> +static inline bool kasan_arch_is_ready_ppc64(void)
>
> I'd make it __always_inline
Done.
>> +{
>> + if (static_branch_likely(&powerpc_kasan_enabled_key))
>> + return true;
>> + return false;
>> +}
>> +
>> +#define kasan_arch_is_ready kasan_arch_is_ready_ppc64
>
> Usually we keep the generic name, you don't need to have an arch specific name.
Done.
>> +#endif
>>
>> #ifdef CONFIG_KASAN
>> void kasan_early_init(void);
>> @@ -47,5 +79,5 @@ void kasan_update_early_region(unsigned long k_start, unsigned long k_end, pte_t
>> int kasan_init_shadow_page_tables(unsigned long k_start, unsigned long k_end);
>> int kasan_init_region(void *start, size_t size);
>>
>> -#endif /* __ASSEMBLY */
>> +#endif /* !__ASSEMBLY__ */
>
> This patch is already big. Is that worth it ?
Fair enough. Dropped.
>> #endif
>> diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
>> index fe2ef598e2ea..cd58202459dd 100644
>> --- a/arch/powerpc/kernel/Makefile
>> +++ b/arch/powerpc/kernel/Makefile
>> @@ -32,6 +32,11 @@ KASAN_SANITIZE_early_32.o := n
>> KASAN_SANITIZE_cputable.o := n
>> KASAN_SANITIZE_prom_init.o := n
>> KASAN_SANITIZE_btext.o := n
>> +KASAN_SANITIZE_paca.o := n
>> +KASAN_SANITIZE_setup_64.o := n
>
> The entire setup_64 ?
> Can you split things out into an early_64.o like was done for ppc32 ?
setup_64.c contains around 40 functions, of which about half are not __init:
cpu_ready_for_interrupts
smp setup/maintenance functions:
early_setup_secondary
panic_smp_self_stop
use_spinloop
smp_release_cpus
(Some of these we couldn't instrument anyway as they use real addresses.)
Functions which AFAICT should be marked __init, as they're static and
only called from __init functions:
init_cache_info
pcpu_cpu_distance
Tiny functions:
memory_block_size_bytes
hw_nmi_get_sample_period
Flush maintenance:
do_nothing (an empty function)
init_fallback_flush
setup_{rfi,entry,uaccess}_flush (3 functions)
{rfi,entry,uaccess}_flush_{get,set,enable} (9 functions)
We don't really get much value from instrumenting any of these, but we
could split out at least the flush maintenance ones if we really wanted
to.
I'd say there isn't enough value in moving them to justify the churn but
I'm happy to move them if people feel differently.
>> +KASAN_SANITIZE_mce.o := n
>> +KASAN_SANITIZE_traps.o := n
>
> Why ? ppc32 doesn't need that.
Some of that code runs with translations off. If we try to access the
shadow region with translations off, things will crash. This is part of
what I gave up in order to be able to have the one kernel binary work
regardless of the quantity of physical memory.
Only traps.c is compiled for ppc32, I'll wrap it so that it's still
instrumented there.
> +KASAN_SANITIZE_mce_power.o := n
>>
>> ifdef CONFIG_KASAN
>> CFLAGS_early_32.o += -DDISABLE_BRANCH_PROFILING
>> +
>> + va = memblock_alloc(k_end - k_start, PAGE_SIZE);
>> + for (k_cur = k_start; k_cur < k_end; k_cur += PAGE_SIZE) {
>> + map_kernel_page(k_cur, __pa(va), PAGE_KERNEL);
>> + va += PAGE_SIZE;
>> + }
>
> What about:
>
> for (k_cur = k_start; k_cur < k_end; k_cur += PAGE_SIZE, va += PAGE_SIZE)
> map_kernel_page(k_cur, __pa(va), PAGE_KERNEL);
>
Done.
>> +}
>> +
>> +void __init kasan_init(void)
>> +{
>> + /*
>> + * We want to do the following things:
>> + * 1) Map real memory into the shadow for all physical memblocks
>> + * This takes us from c000... to c008...
>> + * 2) Leave a hole over the shadow of vmalloc space. KASAN_VMALLOC
>> + * will manage this for us.
>> + * This takes us from c008... to c00a...
>> + * 3) Map the 'early shadow'/zero page over iomap and vmemmap space.
>> + * This takes us up to where we start at c00e...
>> + */
>> +
>> + void *k_start = kasan_mem_to_shadow((void *)RADIX_VMALLOC_END);
>> + void *k_end = kasan_mem_to_shadow((void *)RADIX_VMEMMAP_END);
>> + phys_addr_t start, end;
>> + u64 i;
>> + pte_t zero_pte = pfn_pte(virt_to_pfn(kasan_early_shadow_page), PAGE_KERNEL);
>> +
>> + if (!early_radix_enabled())
>> + panic("KASAN requires radix!");
>> +
>> + for_each_mem_range(i, &start, &end) {
>> + kasan_init_phys_region((void *)start, (void *)end);
>> + }
>
> No need of { } for single line loops. Check the kernel codyign stype
Fixed.
>> +
>> + for (i = 0; i < PTRS_PER_PTE; i++)
>> + __set_pte_at(&init_mm, (unsigned long)kasan_early_shadow_page,
>> + &kasan_early_shadow_pte[i], zero_pte, 0);
>> +
>> + for (i = 0; i < PTRS_PER_PMD; i++)
>> + pmd_populate_kernel(&init_mm, &kasan_early_shadow_pmd[i],
>> + kasan_early_shadow_pte);
>> +
>> + for (i = 0; i < PTRS_PER_PUD; i++)
>> + pud_populate(&init_mm, &kasan_early_shadow_pud[i],
>> + kasan_early_shadow_pmd);
>> +
>> + /* map the early shadow over the iomap and vmemmap space */
>> + kasan_populate_early_shadow(k_start, k_end);
>> +
>> + /* mark early shadow region as RO and wipe it */
>> + zero_pte = pfn_pte(virt_to_pfn(kasan_early_shadow_page), PAGE_KERNEL_RO);
>> + for (i = 0; i < PTRS_PER_PTE; i++)
>> + __set_pte_at(&init_mm, (unsigned long)kasan_early_shadow_page,
>> + &kasan_early_shadow_pte[i], zero_pte, 0);
>> +
>> + /*
>> + * clear_page relies on some cache info that hasn't been set up yet.
>> + * It ends up looping ~forever and blows up other data.
>> + * Use memset instead.
>> + */
>> + memset(kasan_early_shadow_page, 0, PAGE_SIZE);
>> +
>> + static_branch_inc(&powerpc_kasan_enabled_key);
>> +
>> + /* Enable error messages */
>> + init_task.kasan_depth = 0;
>> + pr_info("KASAN init done (64-bit Book3S)\n");
>> +}
>> +
>> +void __init kasan_late_init(void) { }
>> diff --git a/arch/powerpc/mm/ptdump/ptdump.c b/arch/powerpc/mm/ptdump/ptdump.c
>> index aca354fb670b..63672aa656e8 100644
>> --- a/arch/powerpc/mm/ptdump/ptdump.c
>> +++ b/arch/powerpc/mm/ptdump/ptdump.c
>> @@ -20,6 +20,7 @@
>> #include <linux/seq_file.h>
>> #include <asm/fixmap.h>
>> #include <linux/const.h>
>> +#include <linux/kasan.h>
>> #include <asm/page.h>
>> #include <asm/hugetlb.h>
>>
>> @@ -317,6 +318,23 @@ static void walk_pud(struct pg_state *st, p4d_t *p4d, unsigned long start)
>> unsigned long addr;
>> unsigned int i;
>>
>> +#if defined(CONFIG_KASAN) && defined(CONFIG_PPC_BOOK3S_64)
>> + /*
>> + * On radix + KASAN, we want to check for the KASAN "early" shadow
>> + * which covers huge quantities of memory with the same set of
>> + * read-only PTEs. If it is, we want to note the first page (to see
>> + * the status change), and then note the last page. This gives us good
>> + * results without spending ages noting the exact same PTEs over 100s of
>> + * terabytes of memory.
>> + */
>> + if (p4d_page(*p4d) == virt_to_page(lm_alias(kasan_early_shadow_pud))) {
>> + walk_pmd(st, pud, start);
>> + addr = start + (PTRS_PER_PUD - 1) * PUD_SIZE;
>> + walk_pmd(st, pud, addr);
>> + return;
>> + }
>> +#endif
>
> Why do you need that ? When PTEs are all pointing to the same page, it shoud already appear in a
> single line into []
It would eventually be printed as one line, but first you have to
traverse ~7.5 billion PTEs. It's the process of walking that that takes
too long, not the printing.
Thanks for the review, I'll have a new spin out soon.
Kind regards,
Daniel
^ permalink raw reply
* [PATCH v10 0/6] KASAN for powerpc64 radix
From: Daniel Axtens @ 2021-02-03 11:59 UTC (permalink / raw)
To: linux-kernel, linux-mm, linuxppc-dev, kasan-dev, christophe.leroy,
aneesh.kumar, bsingharora
Cc: Daniel Axtens
Building on the work of Christophe, Aneesh and Balbir, I've ported
KASAN to 64-bit Book3S kernels running on the Radix MMU.
v10 rebases on top of next-20210125, fixing things up to work on top
of the latest changes, and fixing some review comments from
Christophe. I have tested host and guest with 64k pages for this spin.
It does not apply to powerpc/next, sorry: there are conflicting kasan
changes staged in next.
There is now only 1 failing KUnit test: kasan_global_oob - gcc puts
the ASAN init code in a section called '.init_array'. Powerpc64 module
loading code goes through and _renames_ any section beginning with
'.init' to begin with '_init' in order to avoid some complexities
around our 24-bit indirect jumps. This means it renames '.init_array'
to '_init_array', and the generic module loading code then fails to
recognise the section as a constructor and thus doesn't run it. This
hack dates back to 2003 and so I'm not going to try to unpick it in
this series. (I suspect this may have previously worked if the code
ended up in .ctors rather than .init_array but I don't keep my old
binaries around so I have no real way of checking.)
(The previously failing stack tests are now skipped due to more
accurate configuration settings.)
Details from v9: This is a significant reworking of the previous
versions. Instead of the previous approach which supported inline
instrumentation, this series provides only outline instrumentation.
To get around the problem of accessing the shadow region inside code we run
with translations off (in 'real mode'), we we restrict checking to when
translations are enabled. This is done via a new hook in the kasan core and
by excluding larger quantites of arch code from instrumentation. The upside
is that we no longer require that you be able to specify the amount of
physically contiguous memory on the system at compile time. Hopefully this
is a better trade-off. More details in patch 6.
kexec works. Both 64k and 4k pages work. Running as a KVM host works, but
nothing in arch/powerpc/kvm is instrumented. It's also potentially a bit
fragile - if any real mode code paths call out to instrumented code, things
will go boom.
Kind regards,
Daniel
^ permalink raw reply
* [PATCH v10 1/6] kasan: allow an architecture to disable inline instrumentation
From: Daniel Axtens @ 2021-02-03 11:59 UTC (permalink / raw)
To: linux-kernel, linux-mm, linuxppc-dev, kasan-dev, christophe.leroy,
aneesh.kumar, bsingharora
Cc: Daniel Axtens
In-Reply-To: <20210203115946.663273-1-dja@axtens.net>
For annoying architectural reasons, it's very difficult to support inline
instrumentation on powerpc64.
Add a Kconfig flag to allow an arch to disable inline. (It's a bit
annoying to be 'backwards', but I'm not aware of any way to have
an arch force a symbol to be 'n', rather than 'y'.)
We also disable stack instrumentation in this case as it does things that
are functionally equivalent to inline instrumentation, namely adding
code that touches the shadow directly without going through a C helper.
Signed-off-by: Daniel Axtens <dja@axtens.net>
---
lib/Kconfig.kasan | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan
index cffc2ebbf185..4f4d3fb8733d 100644
--- a/lib/Kconfig.kasan
+++ b/lib/Kconfig.kasan
@@ -12,6 +12,9 @@ config HAVE_ARCH_KASAN_HW_TAGS
config HAVE_ARCH_KASAN_VMALLOC
bool
+config ARCH_DISABLE_KASAN_INLINE
+ def_bool n
+
config CC_HAS_KASAN_GENERIC
def_bool $(cc-option, -fsanitize=kernel-address)
@@ -130,6 +133,7 @@ config KASAN_OUTLINE
config KASAN_INLINE
bool "Inline instrumentation"
+ depends on !ARCH_DISABLE_KASAN_INLINE
help
Compiler directly inserts code checking shadow memory before
memory accesses. This is faster than outline (in some workloads
@@ -141,6 +145,7 @@ endchoice
config KASAN_STACK
bool "Enable stack instrumentation (unsafe)" if CC_IS_CLANG && !COMPILE_TEST
depends on KASAN_GENERIC || KASAN_SW_TAGS
+ depends on !ARCH_DISABLE_KASAN_INLINE
default y if CC_IS_GCC
help
The LLVM stack address sanitizer has a know problem that
@@ -154,6 +159,9 @@ config KASAN_STACK
but clang users can still enable it for builds without
CONFIG_COMPILE_TEST. On gcc it is assumed to always be safe
to use and enabled by default.
+ If the architecture disables inline instrumentation, this is
+ also disabled as it adds inline-style instrumentation that
+ is run unconditionally.
config KASAN_SW_TAGS_IDENTIFY
bool "Enable memory corruption identification"
--
2.27.0
^ permalink raw reply related
* [PATCH v10 3/6] kasan: define and use MAX_PTRS_PER_* for early shadow tables
From: Daniel Axtens @ 2021-02-03 11:59 UTC (permalink / raw)
To: linux-kernel, linux-mm, linuxppc-dev, kasan-dev, christophe.leroy,
aneesh.kumar, bsingharora
Cc: Daniel Axtens
In-Reply-To: <20210203115946.663273-1-dja@axtens.net>
powerpc has a variable number of PTRS_PER_*, set at runtime based
on the MMU that the kernel is booted under.
This means the PTRS_PER_* are no longer constants, and therefore
breaks the build.
Define default MAX_PTRS_PER_*s in the same style as MAX_PTRS_PER_P4D.
As KASAN is the only user at the moment, just define them in the kasan
header, and have them default to PTRS_PER_* unless overridden in arch
code.
Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Suggested-by: Balbir Singh <bsingharora@gmail.com>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Balbir Singh <bsingharora@gmail.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
---
include/linux/kasan.h | 18 +++++++++++++++---
mm/kasan/init.c | 6 +++---
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/include/linux/kasan.h b/include/linux/kasan.h
index d314c0fa5804..84bea59d01b3 100644
--- a/include/linux/kasan.h
+++ b/include/linux/kasan.h
@@ -43,10 +43,22 @@ static inline bool kasan_arch_is_ready(void) { return true; }
#define PTE_HWTABLE_PTRS 0
#endif
+#ifndef MAX_PTRS_PER_PTE
+#define MAX_PTRS_PER_PTE PTRS_PER_PTE
+#endif
+
+#ifndef MAX_PTRS_PER_PMD
+#define MAX_PTRS_PER_PMD PTRS_PER_PMD
+#endif
+
+#ifndef MAX_PTRS_PER_PUD
+#define MAX_PTRS_PER_PUD PTRS_PER_PUD
+#endif
+
extern unsigned char kasan_early_shadow_page[PAGE_SIZE];
-extern pte_t kasan_early_shadow_pte[PTRS_PER_PTE + PTE_HWTABLE_PTRS];
-extern pmd_t kasan_early_shadow_pmd[PTRS_PER_PMD];
-extern pud_t kasan_early_shadow_pud[PTRS_PER_PUD];
+extern pte_t kasan_early_shadow_pte[MAX_PTRS_PER_PTE + PTE_HWTABLE_PTRS];
+extern pmd_t kasan_early_shadow_pmd[MAX_PTRS_PER_PMD];
+extern pud_t kasan_early_shadow_pud[MAX_PTRS_PER_PUD];
extern p4d_t kasan_early_shadow_p4d[MAX_PTRS_PER_P4D];
int kasan_populate_early_shadow(const void *shadow_start,
diff --git a/mm/kasan/init.c b/mm/kasan/init.c
index c4605ac9837b..b4d822dff1fb 100644
--- a/mm/kasan/init.c
+++ b/mm/kasan/init.c
@@ -41,7 +41,7 @@ static inline bool kasan_p4d_table(pgd_t pgd)
}
#endif
#if CONFIG_PGTABLE_LEVELS > 3
-pud_t kasan_early_shadow_pud[PTRS_PER_PUD] __page_aligned_bss;
+pud_t kasan_early_shadow_pud[MAX_PTRS_PER_PUD] __page_aligned_bss;
static inline bool kasan_pud_table(p4d_t p4d)
{
return p4d_page(p4d) == virt_to_page(lm_alias(kasan_early_shadow_pud));
@@ -53,7 +53,7 @@ static inline bool kasan_pud_table(p4d_t p4d)
}
#endif
#if CONFIG_PGTABLE_LEVELS > 2
-pmd_t kasan_early_shadow_pmd[PTRS_PER_PMD] __page_aligned_bss;
+pmd_t kasan_early_shadow_pmd[MAX_PTRS_PER_PMD] __page_aligned_bss;
static inline bool kasan_pmd_table(pud_t pud)
{
return pud_page(pud) == virt_to_page(lm_alias(kasan_early_shadow_pmd));
@@ -64,7 +64,7 @@ static inline bool kasan_pmd_table(pud_t pud)
return false;
}
#endif
-pte_t kasan_early_shadow_pte[PTRS_PER_PTE + PTE_HWTABLE_PTRS]
+pte_t kasan_early_shadow_pte[MAX_PTRS_PER_PTE + PTE_HWTABLE_PTRS]
__page_aligned_bss;
static inline bool kasan_pte_table(pmd_t pmd)
--
2.27.0
^ permalink raw reply related
* [PATCH v10 2/6] kasan: allow architectures to provide an outline readiness check
From: Daniel Axtens @ 2021-02-03 11:59 UTC (permalink / raw)
To: linux-kernel, linux-mm, linuxppc-dev, kasan-dev, christophe.leroy,
aneesh.kumar, bsingharora
Cc: Aneesh Kumar K . V, Daniel Axtens
In-Reply-To: <20210203115946.663273-1-dja@axtens.net>
Allow architectures to define a kasan_arch_is_ready() hook that bails
out of any function that's about to touch the shadow unless the arch
says that it is ready for the memory to be accessed. This is fairly
uninvasive and should have a negligible performance penalty.
This will only work in outline mode, so an arch must specify
ARCH_DISABLE_KASAN_INLINE if it requires this.
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Daniel Axtens <dja@axtens.net>
--
I discuss the justfication for this later in the series. Also,
both previous RFCs for ppc64 - by 2 different people - have
needed this trick! See:
- https://lore.kernel.org/patchwork/patch/592820/ # ppc64 hash series
- https://patchwork.ozlabs.org/patch/795211/ # ppc radix series
---
include/linux/kasan.h | 4 ++++
mm/kasan/common.c | 4 ++++
mm/kasan/generic.c | 3 +++
mm/kasan/shadow.c | 4 ++++
4 files changed, 15 insertions(+)
diff --git a/include/linux/kasan.h b/include/linux/kasan.h
index bb862d1f0e15..d314c0fa5804 100644
--- a/include/linux/kasan.h
+++ b/include/linux/kasan.h
@@ -23,6 +23,10 @@ struct kunit_kasan_expectation {
#endif
+#ifndef kasan_arch_is_ready
+static inline bool kasan_arch_is_ready(void) { return true; }
+#endif
+
#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
#include <linux/pgtable.h>
diff --git a/mm/kasan/common.c b/mm/kasan/common.c
index a390fae9d64b..871ceefd723d 100644
--- a/mm/kasan/common.c
+++ b/mm/kasan/common.c
@@ -348,6 +348,10 @@ static bool ____kasan_slab_free(struct kmem_cache *cache, void *object,
if (unlikely(cache->flags & SLAB_TYPESAFE_BY_RCU))
return false;
+ /* We can't read the shadow byte if the arch isn't ready */
+ if (!kasan_arch_is_ready())
+ return false;
+
if (!kasan_byte_accessible(tagged_object)) {
kasan_report_invalid_free(tagged_object, ip);
return true;
diff --git a/mm/kasan/generic.c b/mm/kasan/generic.c
index 2e55e0f82f39..718c171584e3 100644
--- a/mm/kasan/generic.c
+++ b/mm/kasan/generic.c
@@ -163,6 +163,9 @@ static __always_inline bool check_region_inline(unsigned long addr,
size_t size, bool write,
unsigned long ret_ip)
{
+ if (!kasan_arch_is_ready())
+ return true;
+
if (unlikely(size == 0))
return true;
diff --git a/mm/kasan/shadow.c b/mm/kasan/shadow.c
index de6b3f074742..0aafc2d5138f 100644
--- a/mm/kasan/shadow.c
+++ b/mm/kasan/shadow.c
@@ -85,6 +85,10 @@ void kasan_poison(const void *address, size_t size, u8 value)
address = kasan_reset_tag(address);
size = round_up(size, KASAN_GRANULE_SIZE);
+ /* Don't touch the shadow memory if arch isn't ready */
+ if (!kasan_arch_is_ready())
+ return;
+
/* Skip KFENCE memory if called explicitly outside of sl*b. */
if (is_kfence_address(address))
return;
--
2.27.0
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox