* [PATCH 2/4] powerpc/5200: dts: fix pci ranges warnings
From: Anatolij Gustschin @ 2021-10-13 22:05 UTC (permalink / raw)
To: linuxppc-dev
Cc: devicetree, Stephen Rothwell, linux-kernel, Rob Herring,
Paul Mackerras
In-Reply-To: <20211013220532.24759-1-agust@denx.de>
Fix ranges property warnings:
pci@f0000d00:ranges: 'oneOf' conditional failed, one must be fixed:
Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
arch/powerpc/boot/dts/a4m072.dts | 6 +++---
arch/powerpc/boot/dts/charon.dts | 6 +++---
arch/powerpc/boot/dts/digsy_mtc.dts | 6 +++---
arch/powerpc/boot/dts/lite5200.dts | 6 +++---
arch/powerpc/boot/dts/lite5200b.dts | 6 +++---
arch/powerpc/boot/dts/media5200.dts | 6 +++---
arch/powerpc/boot/dts/mucmc52.dts | 6 +++---
arch/powerpc/boot/dts/pcm030.dts | 6 +++---
arch/powerpc/boot/dts/pcm032.dts | 6 +++---
arch/powerpc/boot/dts/tqm5200.dts | 6 +++---
10 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/arch/powerpc/boot/dts/a4m072.dts b/arch/powerpc/boot/dts/a4m072.dts
index a9cef5726422..d4270a2ec6c7 100644
--- a/arch/powerpc/boot/dts/a4m072.dts
+++ b/arch/powerpc/boot/dts/a4m072.dts
@@ -140,8 +140,8 @@
clock-frequency = <0>; /* From boot loader */
interrupts = <2 8 0 2 9 0 2 10 0>;
bus-range = <0 0>;
- ranges = <0x42000000 0 0x80000000 0x80000000 0 0x10000000
- 0x02000000 0 0x90000000 0x90000000 0 0x10000000
- 0x01000000 0 0x00000000 0xa0000000 0 0x01000000>;
+ ranges = <0x42000000 0 0x80000000 0x80000000 0 0x10000000>,
+ <0x02000000 0 0x90000000 0x90000000 0 0x10000000>,
+ <0x01000000 0 0x00000000 0xa0000000 0 0x01000000>;
};
};
diff --git a/arch/powerpc/boot/dts/charon.dts b/arch/powerpc/boot/dts/charon.dts
index 408b486b13df..6f9fe88a5f36 100644
--- a/arch/powerpc/boot/dts/charon.dts
+++ b/arch/powerpc/boot/dts/charon.dts
@@ -225,8 +225,8 @@
clock-frequency = <0>; // From boot loader
interrupts = <2 8 0 2 9 0 2 10 0>;
bus-range = <0 0>;
- ranges = <0x42000000 0 0x80000000 0x80000000 0 0x10000000
- 0x02000000 0 0x90000000 0x90000000 0 0x10000000
- 0x01000000 0 0x00000000 0xa0000000 0 0x01000000>;
+ ranges = <0x42000000 0 0x80000000 0x80000000 0 0x10000000>,
+ <0x02000000 0 0x90000000 0x90000000 0 0x10000000>,
+ <0x01000000 0 0x00000000 0xa0000000 0 0x01000000>;
};
};
diff --git a/arch/powerpc/boot/dts/digsy_mtc.dts b/arch/powerpc/boot/dts/digsy_mtc.dts
index 0e5e9d3acf79..010156649bfe 100644
--- a/arch/powerpc/boot/dts/digsy_mtc.dts
+++ b/arch/powerpc/boot/dts/digsy_mtc.dts
@@ -98,9 +98,9 @@
clock-frequency = <0>; // From boot loader
interrupts = <2 8 0 2 9 0 2 10 0>;
bus-range = <0 0>;
- ranges = <0x42000000 0 0x80000000 0x80000000 0 0x10000000
- 0x02000000 0 0x90000000 0x90000000 0 0x10000000
- 0x01000000 0 0x00000000 0xa0000000 0 0x01000000>;
+ ranges = <0x42000000 0 0x80000000 0x80000000 0 0x10000000>,
+ <0x02000000 0 0x90000000 0x90000000 0 0x10000000>,
+ <0x01000000 0 0x00000000 0xa0000000 0 0x01000000>;
};
localbus {
diff --git a/arch/powerpc/boot/dts/lite5200.dts b/arch/powerpc/boot/dts/lite5200.dts
index cb2782dd6132..84a12e7915e9 100644
--- a/arch/powerpc/boot/dts/lite5200.dts
+++ b/arch/powerpc/boot/dts/lite5200.dts
@@ -283,9 +283,9 @@
clock-frequency = <0>; // From boot loader
interrupts = <2 8 0 2 9 0 2 10 0>;
bus-range = <0 0>;
- ranges = <0x42000000 0 0x80000000 0x80000000 0 0x20000000
- 0x02000000 0 0xa0000000 0xa0000000 0 0x10000000
- 0x01000000 0 0x00000000 0xb0000000 0 0x01000000>;
+ ranges = <0x42000000 0 0x80000000 0x80000000 0 0x20000000>,
+ <0x02000000 0 0xa0000000 0xa0000000 0 0x10000000>,
+ <0x01000000 0 0x00000000 0xb0000000 0 0x01000000>;
};
localbus {
diff --git a/arch/powerpc/boot/dts/lite5200b.dts b/arch/powerpc/boot/dts/lite5200b.dts
index 2b86c81f9048..c361c59a9681 100644
--- a/arch/powerpc/boot/dts/lite5200b.dts
+++ b/arch/powerpc/boot/dts/lite5200b.dts
@@ -116,9 +116,9 @@
clock-frequency = <0>; // From boot loader
interrupts = <2 8 0 2 9 0 2 10 0>;
bus-range = <0 0>;
- ranges = <0x42000000 0 0x80000000 0x80000000 0 0x20000000
- 0x02000000 0 0xa0000000 0xa0000000 0 0x10000000
- 0x01000000 0 0x00000000 0xb0000000 0 0x01000000>;
+ ranges = <0x42000000 0 0x80000000 0x80000000 0 0x20000000>,
+ <0x02000000 0 0xa0000000 0xa0000000 0 0x10000000>,
+ <0x01000000 0 0x00000000 0xb0000000 0 0x01000000>;
};
localbus {
diff --git a/arch/powerpc/boot/dts/media5200.dts b/arch/powerpc/boot/dts/media5200.dts
index 61cae9dcddef..f7d7538eb69d 100644
--- a/arch/powerpc/boot/dts/media5200.dts
+++ b/arch/powerpc/boot/dts/media5200.dts
@@ -96,9 +96,9 @@
0xe000 0 0 1 &media5200_fpga 0 5 // CoralIP
>;
- ranges = <0x42000000 0 0x80000000 0x80000000 0 0x20000000
- 0x02000000 0 0xa0000000 0xa0000000 0 0x10000000
- 0x01000000 0 0x00000000 0xb0000000 0 0x01000000>;
+ ranges = <0x42000000 0 0x80000000 0x80000000 0 0x20000000>,
+ <0x02000000 0 0xa0000000 0xa0000000 0 0x10000000>,
+ <0x01000000 0 0x00000000 0xb0000000 0 0x01000000>;
interrupt-parent = <&mpc5200_pic>;
};
diff --git a/arch/powerpc/boot/dts/mucmc52.dts b/arch/powerpc/boot/dts/mucmc52.dts
index c6c66306308d..e88a7bd4034d 100644
--- a/arch/powerpc/boot/dts/mucmc52.dts
+++ b/arch/powerpc/boot/dts/mucmc52.dts
@@ -106,9 +106,9 @@
0x8000 0 0 3 &mpc5200_pic 0 2 3
0x8000 0 0 4 &mpc5200_pic 0 1 3
>;
- ranges = <0x42000000 0 0x60000000 0x60000000 0 0x10000000
- 0x02000000 0 0x90000000 0x90000000 0 0x10000000
- 0x01000000 0 0x00000000 0xa0000000 0 0x01000000>;
+ ranges = <0x42000000 0 0x60000000 0x60000000 0 0x10000000>,
+ <0x02000000 0 0x90000000 0x90000000 0 0x10000000>,
+ <0x01000000 0 0x00000000 0xa0000000 0 0x01000000>;
};
localbus {
diff --git a/arch/powerpc/boot/dts/pcm030.dts b/arch/powerpc/boot/dts/pcm030.dts
index b1bc731f7afd..5cee474dcc4c 100644
--- a/arch/powerpc/boot/dts/pcm030.dts
+++ b/arch/powerpc/boot/dts/pcm030.dts
@@ -90,9 +90,9 @@
0xc800 0 0 2 &mpc5200_pic 1 2 3
0xc800 0 0 3 &mpc5200_pic 1 3 3
0xc800 0 0 4 &mpc5200_pic 0 0 3>;
- ranges = <0x42000000 0 0x80000000 0x80000000 0 0x20000000
- 0x02000000 0 0xa0000000 0xa0000000 0 0x10000000
- 0x01000000 0 0x00000000 0xb0000000 0 0x01000000>;
+ ranges = <0x42000000 0 0x80000000 0x80000000 0 0x20000000>,
+ <0x02000000 0 0xa0000000 0xa0000000 0 0x10000000>,
+ <0x01000000 0 0x00000000 0xb0000000 0 0x01000000>;
};
localbus {
diff --git a/arch/powerpc/boot/dts/pcm032.dts b/arch/powerpc/boot/dts/pcm032.dts
index 780e13d99e7b..b6fdf861c7d6 100644
--- a/arch/powerpc/boot/dts/pcm032.dts
+++ b/arch/powerpc/boot/dts/pcm032.dts
@@ -87,9 +87,9 @@
0xc800 0 0 2 &mpc5200_pic 1 2 3
0xc800 0 0 3 &mpc5200_pic 1 3 3
0xc800 0 0 4 &mpc5200_pic 0 0 3>;
- ranges = <0x42000000 0 0x80000000 0x80000000 0 0x20000000
- 0x02000000 0 0xa0000000 0xa0000000 0 0x10000000
- 0x01000000 0 0x00000000 0xb0000000 0 0x01000000>;
+ ranges = <0x42000000 0 0x80000000 0x80000000 0 0x20000000>,
+ <0x02000000 0 0xa0000000 0xa0000000 0 0x10000000>,
+ <0x01000000 0 0x00000000 0xb0000000 0 0x01000000>;
};
localbus {
diff --git a/arch/powerpc/boot/dts/tqm5200.dts b/arch/powerpc/boot/dts/tqm5200.dts
index 9ed0bc78967e..40b139d92a19 100644
--- a/arch/powerpc/boot/dts/tqm5200.dts
+++ b/arch/powerpc/boot/dts/tqm5200.dts
@@ -200,8 +200,8 @@
clock-frequency = <0>; // From boot loader
interrupts = <2 8 0 2 9 0 2 10 0>;
bus-range = <0 0>;
- ranges = <0x42000000 0 0x80000000 0x80000000 0 0x10000000
- 0x02000000 0 0x90000000 0x90000000 0 0x10000000
- 0x01000000 0 0x00000000 0xa0000000 0 0x01000000>;
+ ranges = <0x42000000 0 0x80000000 0x80000000 0 0x10000000>,
+ <0x02000000 0 0x90000000 0x90000000 0 0x10000000>,
+ <0x01000000 0 0x00000000 0xa0000000 0 0x01000000>;
};
};
--
2.17.1
^ permalink raw reply related
* [PATCH v2] powerpc/s64: Clarify that radix lacks DEBUG_PAGEALLOC
From: Joel Stanley @ 2021-10-13 21:34 UTC (permalink / raw)
To: Jordan Niethe, Christophe Leroy; +Cc: linuxppc-dev
The page_alloc.c code will call into __kernel_map_pages when
DEBUG_PAGEALLOC is configured and enabled.
As the implementation assumes hash, this should crash spectacularly if
not for a bit of luck in __kernel_map_pages. In this function
linear_map_hash_count is always zero, the for loop exits without doing
any damage.
There are no other platforms that determine if they support
debug_pagealloc at runtime. Instead of adding code to mm/page_alloc.c to
do that, this change turns the map/unmap into a noop when in radix
mode and prints a warning once.
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
v2: Put __kernel_map_pages in pgtable.h
arch/powerpc/include/asm/book3s/64/hash.h | 2 ++
arch/powerpc/include/asm/book3s/64/pgtable.h | 11 +++++++++++
arch/powerpc/include/asm/book3s/64/radix.h | 3 +++
arch/powerpc/mm/book3s64/hash_utils.c | 2 +-
arch/powerpc/mm/book3s64/radix_pgtable.c | 7 +++++++
5 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/include/asm/book3s/64/hash.h b/arch/powerpc/include/asm/book3s/64/hash.h
index d959b0195ad9..674fe0e890dc 100644
--- a/arch/powerpc/include/asm/book3s/64/hash.h
+++ b/arch/powerpc/include/asm/book3s/64/hash.h
@@ -255,6 +255,8 @@ int hash__create_section_mapping(unsigned long start, unsigned long end,
int nid, pgprot_t prot);
int hash__remove_section_mapping(unsigned long start, unsigned long end);
+void hash__kernel_map_pages(struct page *page, int numpages, int enable);
+
#endif /* !__ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_BOOK3S_64_HASH_H */
diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h
index 5d34a8646f08..265661ded238 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -1101,6 +1101,17 @@ static inline void vmemmap_remove_mapping(unsigned long start,
}
#endif
+#ifdef CONFIG_DEBUG_PAGEALLOC
+static inline void __kernel_map_pages(struct page *page, int numpages, int enable)
+{
+ if (radix_enabled()) {
+ radix__kernel_map_pages(page, numpages, enable);
+ return;
+ }
+ hash__kernel_map_pages(page, numpages, enable);
+}
+#endif
+
static inline pte_t pmd_pte(pmd_t pmd)
{
return __pte_raw(pmd_raw(pmd));
diff --git a/arch/powerpc/include/asm/book3s/64/radix.h b/arch/powerpc/include/asm/book3s/64/radix.h
index 59cab558e2f0..d090d9612348 100644
--- a/arch/powerpc/include/asm/book3s/64/radix.h
+++ b/arch/powerpc/include/asm/book3s/64/radix.h
@@ -316,5 +316,8 @@ int radix__create_section_mapping(unsigned long start, unsigned long end,
int nid, pgprot_t prot);
int radix__remove_section_mapping(unsigned long start, unsigned long end);
#endif /* CONFIG_MEMORY_HOTPLUG */
+
+void radix__kernel_map_pages(struct page *page, int numpages, int enable);
+
#endif /* __ASSEMBLY__ */
#endif
diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s64/hash_utils.c
index c145776d3ae5..cfd45245d009 100644
--- a/arch/powerpc/mm/book3s64/hash_utils.c
+++ b/arch/powerpc/mm/book3s64/hash_utils.c
@@ -1988,7 +1988,7 @@ static void kernel_unmap_linear_page(unsigned long vaddr, unsigned long lmi)
mmu_kernel_ssize, 0);
}
-void __kernel_map_pages(struct page *page, int numpages, int enable)
+void hash__kernel_map_pages(struct page *page, int numpages, int enable)
{
unsigned long flags, vaddr, lmi;
int i;
diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c
index ae20add7954a..83b33418ad28 100644
--- a/arch/powerpc/mm/book3s64/radix_pgtable.c
+++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
@@ -920,6 +920,13 @@ void __meminit radix__vmemmap_remove_mapping(unsigned long start, unsigned long
#endif
#endif
+#ifdef CONFIG_DEBUG_PAGEALLOC
+void radix__kernel_map_pages(struct page *page, int numpages, int enable)
+{
+ pr_warn_once("DEBUG_PAGEALLOC not supported in radix mode\n");
+}
+#endif
+
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
unsigned long radix__pmd_hugepage_update(struct mm_struct *mm, unsigned long addr,
--
2.33.0
^ permalink raw reply related
* Re: [PATCH v3 02/52] powerpc/64s: guard optional TIDR SPR with CPU ftr test
From: Fabiano Rosas @ 2021-10-13 16:51 UTC (permalink / raw)
To: Michael Ellerman, Nicholas Piggin, kvm-ppc, linuxppc-dev; +Cc: Nicholas Piggin
In-Reply-To: <87k0ijm1ty.fsf@mpe.ellerman.id.au>
Michael Ellerman <mpe@ellerman.id.au> writes:
> Fabiano Rosas <farosas@linux.ibm.com> writes:
>> Nicholas Piggin <npiggin@gmail.com> writes:
>>
>>> The TIDR SPR only exists on POWER9. Avoid accessing it when the
>>> feature bit for it is not set.
>>
>> Not related to this patch, but how does this work with compat mode? A P9
>> compat mode guest would get an invalid instruction when trying to access
>> this SPR?
>
> Good question.
>
> I assume you're talking about P9 compat mode on P10.
>
> In general compat mode only applies to userspace, because it's
> implemented by setting the PCR which only (mostly?) applies to PR=1.
>
> I don't think there's any special casing in the ISA for the TIDR, so I
> think it just falls into the unimplemented SPR case for mt/fspr.
>
> That's documented in Book III section 5.4.4, in particular on page 1171
> it says:
>
> Execution of this instruction specifying an SPR number
> that is undefined for the implementation causes one of
> the following.
> • if spr[0]=0:
> - if MSR[PR]=1: Hypervisor Emulation Assistance interrupt
> - if MSR[PR]=0: Hypervisor Emulation Assistance interrupt for SPR
> 0,4,5, and 6, and no operation (i.e., the instruction is treated
> as a no-op) when LPCR[EVIRT]=0 and Hypervisor Emulation Assistance
> interrupt when LPCR[EVIRT]=1 for all other SPRs
I knew this must have been somewhere in there but had no idea how to
find it. Thanks.
> Linux doesn't set EVIRT, and I assume neither does phyp, so it behaves
> like a nop.
>
> We actually use that behaviour in xmon to detect that an SPR is not
> implemented, by noticing that the mfspr has no effect on the target
> register, see dump_one_spr().
>
> We should really write some docs on compat mode in the linuxppc wiki
> and/or Documentation ;)
Hmm I was not aware we had a wiki. I'll see if I can contribute
something. I need to go learn all this stuff first, though =D.
>
> cheers
^ permalink raw reply
* [PATCH] powerpc: Mark .opd section read-only
From: Christophe Leroy @ 2021-10-13 14:43 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linuxppc-dev, linux-kernel
.opd section contains function descriptors used to locate
functions in the kernel. If someone is able to modify a
function descriptor he will be able to run arbitrary
kernel function instead of another.
To avoid that, move .opd section inside read-only memory.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/powerpc/kernel/vmlinux.lds.S | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index 40bdefe9caa7..18e42c74abdd 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -143,6 +143,12 @@ SECTIONS
SOFT_MASK_TABLE(8)
RESTART_TABLE(8)
+ .opd : AT(ADDR(.opd) - LOAD_OFFSET) {
+ __start_opd = .;
+ KEEP(*(.opd))
+ __end_opd = .;
+ }
+
. = ALIGN(8);
__stf_entry_barrier_fixup : AT(ADDR(__stf_entry_barrier_fixup) - LOAD_OFFSET) {
__start___stf_entry_barrier_fixup = .;
@@ -339,12 +345,6 @@ SECTIONS
*(.branch_lt)
}
- .opd : AT(ADDR(.opd) - LOAD_OFFSET) {
- __start_opd = .;
- KEEP(*(.opd))
- __end_opd = .;
- }
-
. = ALIGN(256);
.got : AT(ADDR(.got) - LOAD_OFFSET) {
__toc_start = .;
--
2.31.1
^ permalink raw reply related
* [RFC PATCH v3 10/13] ASoC: fsl: asrc_dma: protect for_each_dpcm_be() loops
From: Pierre-Louis Bossart @ 2021-10-13 14:30 UTC (permalink / raw)
To: alsa-devel
Cc: Shengjiu Wang, open list:FREESCALE SOC SOUND DRIVERS,
Kuninori Morimoto, Xiubo Li, tiwai, Fabio Estevam, Sameer Pujar,
Takashi Iwai, Pierre-Louis Bossart, Liam Girdwood, Nicolin Chen,
vkoul, broonie, Gyeongtaek Lee, Jaroslav Kysela, Peter Ujfalusi,
open list
In-Reply-To: <20211013143050.244444-1-pierre-louis.bossart@linux.intel.com>
Follow the locking model used within soc-pcm.c
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
sound/soc/fsl/fsl_asrc_dma.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c
index cd9b36ec0ecb..b67097503836 100644
--- a/sound/soc/fsl/fsl_asrc_dma.c
+++ b/sound/soc/fsl/fsl_asrc_dma.c
@@ -151,6 +151,7 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,
int ret, width;
/* Fetch the Back-End dma_data from DPCM */
+ snd_soc_dpcm_fe_lock_irq(rtd, stream);
for_each_dpcm_be(rtd, stream, dpcm) {
struct snd_soc_pcm_runtime *be = dpcm->be;
struct snd_pcm_substream *substream_be;
@@ -164,6 +165,7 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,
dev_be = dai->dev;
break;
}
+ snd_soc_dpcm_fe_unlock_irq(rtd, stream);
if (!dma_params_be) {
dev_err(dev, "failed to get the substream of Back-End\n");
--
2.25.1
^ permalink raw reply related
* Re: [RESEND PATCH v2 1/2] ftrace: disable preemption between ftrace_test_recursion_trylock/unlock()
From: Steven Rostedt @ 2021-10-13 14:24 UTC (permalink / raw)
To: 王贇
Cc: Peter Zijlstra (Intel), Paul Walmsley, James E.J. Bottomley,
Guo Ren, Jisheng Zhang, H. Peter Anvin, live-patching,
linux-riscv, Miroslav Benes, Paul Mackerras, Joe Lawrence,
Helge Deller, x86, linux-csky, Ingo Molnar, Petr Mladek,
Albert Ou, Jiri Kosina, Nicholas Piggin, Borislav Petkov,
Josh Poimboeuf, Thomas Gleixner, linux-parisc, linux-kernel,
Palmer Dabbelt, Masami Hiramatsu, Colin Ian King, linuxppc-dev
In-Reply-To: <861d81d6-e202-09f3-f0be-6c77205f9d34@linux.alibaba.com>
On Wed, 13 Oct 2021 16:34:53 +0800
王贇 <yun.wang@linux.alibaba.com> wrote:
> On 2021/10/13 下午4:25, Miroslav Benes wrote:
> >>> Side note... the comment will eventually conflict with peterz's
> >>> https://lore.kernel.org/all/20210929152429.125997206@infradead.org/.
> >>
> >> Steven, would you like to share your opinion on this patch?
> >>
> >> If klp_synchronize_transition() will be removed anyway, the comments
> >> will be meaningless and we can just drop it :-P
> >
> > The comment will still be needed in some form. We will handle it depending
> > on what gets merged first. peterz's patches are not ready yet.
>
> Ok, then I'll move it before trylock() inside klp_ftrace_handler() anyway.
+1
-- Steve
^ permalink raw reply
* Re: [PATCH v1 09/10] lkdtm: Fix lkdtm_EXEC_RODATA()
From: Christophe Leroy @ 2021-10-13 12:45 UTC (permalink / raw)
To: Kees Cook
Cc: linux-arch, linux-ia64, linux-parisc, Arnd Bergmann,
Greg Kroah-Hartman, Helge Deller, linux-kernel,
James E.J. Bottomley, linux-mm, Paul Mackerras, Andrew Morton,
linuxppc-dev
In-Reply-To: <134b968f-f65f-cd74-3db1-fff60e5ebeb8@csgroup.eu>
Le 13/10/2021 à 09:48, Christophe Leroy a écrit :
>
>
> Le 13/10/2021 à 09:39, Christophe Leroy a écrit :
>>
>>
>> Le 13/10/2021 à 09:23, Kees Cook a écrit :
>>> On Mon, Oct 11, 2021 at 05:25:36PM +0200, Christophe Leroy wrote:
>>>> Behind a location, lkdtm_EXEC_RODATA() executes a real function,
>>>> not a copy of do_nothing().
>>>>
>>>> So do it directly instead of using execute_location().
>>>>
>>>> And fix displayed addresses by dereferencing the function descriptors.
>>>>
>>>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>>>> ---
>>>> drivers/misc/lkdtm/perms.c | 9 ++++++++-
>>>> 1 file changed, 8 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/misc/lkdtm/perms.c b/drivers/misc/lkdtm/perms.c
>>>> index 442d60ed25ef..da16564e1ecd 100644
>>>> --- a/drivers/misc/lkdtm/perms.c
>>>> +++ b/drivers/misc/lkdtm/perms.c
>>>> @@ -153,7 +153,14 @@ void lkdtm_EXEC_VMALLOC(void)
>>>>
>>>> void lkdtm_EXEC_RODATA(void)
>>>> {
>>>> - execute_location(lkdtm_rodata_do_nothing, CODE_AS_IS);
>>>> + pr_info("attempting ok execution at %px\n",
>>>> + dereference_symbol_descriptor(do_nothing));
>>>> + do_nothing();
>>>> +
>>>> + pr_info("attempting bad execution at %px\n",
>>>> + dereference_symbol_descriptor(lkdtm_rodata_do_nothing));
>>>> + lkdtm_rodata_do_nothing();
>>>> + pr_err("FAIL: func returned\n");
>>>> }
>>>
>>> (In re-reading this more carefully, I see now why kallsyms.h is used
>>> earlier: _function_ vs _symbol_ descriptor.)
>>>
>>> In the next patch:
>>>
>>> static noinline void execute_location(void *dst, bool write)
>>> {
>>> ...
>>> func = setup_function_descriptor(&fdesc, dst);
>>> if (IS_ERR(func))
>>> return;
>>>
>>> pr_info("attempting bad execution at %px\n", dst);
>>> func();
>>> pr_err("FAIL: func returned\n");
>>> }
>>>
>>> What are the conditions for which dereference_symbol_descriptor works
>>> but dereference _function_descriptor doesn't?
>>>
>>
>> When LKDTM is built as a module I guess ?
>>
>
> To be more precise, dereference_symbol_descriptor() calls either
> dereference_kernel_function_descriptor() or
> dereference_module_function_descriptor()
>
> Both functions call dereference_function_descriptor() after checking
> that we want to dereference something that is in the OPD section.
>
> If we call dereference_function_descriptor() directly instead of
> dereference_symbol_descriptor() we skip the range verification and may
> dereference something that is not a function descriptor.
>
> Should we do that ?
>
Indeed we are using it only for well known functions so using
dereference_function_descriptor() is good enough. I'll use that in v2.
^ permalink raw reply
* Re: [PATCH v1 10/10] lkdtm: Fix execute_[user]_location()
From: Christophe Leroy @ 2021-10-13 12:00 UTC (permalink / raw)
To: Kees Cook
Cc: linux-arch, linux-ia64, linux-parisc, Arnd Bergmann,
Greg Kroah-Hartman, Helge Deller, linux-kernel,
James E.J. Bottomley, linux-mm, Paul Mackerras, Andrew Morton,
linuxppc-dev
In-Reply-To: <202110130012.4608FFD38E@keescook>
Le 13/10/2021 à 09:16, Kees Cook a écrit :
> On Mon, Oct 11, 2021 at 05:25:37PM +0200, Christophe Leroy wrote:
>> execute_location() and execute_user_location() intent
>> to copy do_nothing() text and execute it at a new location.
>> However, at the time being it doesn't copy do_nothing() function
>> but do_nothing() function descriptor which still points to the
>> original text. So at the end it still executes do_nothing() at
>> its original location allthough using a copied function descriptor.
>>
>> So, fix that by really copying do_nothing() text and build a new
>> function descriptor by copying do_nothing() function descriptor and
>> updating the target address with the new location.
>>
>> Also fix the displayed addresses by dereferencing do_nothing()
>> function descriptor.
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>> ---
>> drivers/misc/lkdtm/perms.c | 45 +++++++++++++++++++++++++++++++-------
>> 1 file changed, 37 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/misc/lkdtm/perms.c b/drivers/misc/lkdtm/perms.c
>> index da16564e1ecd..1d03cd44c21d 100644
>> --- a/drivers/misc/lkdtm/perms.c
>> +++ b/drivers/misc/lkdtm/perms.c
>> @@ -44,19 +44,42 @@ static noinline void do_overwritten(void)
>> return;
>> }
>>
>> +static void *setup_function_descriptor(funct_descr_t *fdesc, void *dst)
>> +{
>> + int err;
>> +
>> + if (!__is_defined(HAVE_DEREFERENCE_FUNCTION_DESCRIPTOR))
>> + return dst;
>> +
>> + err = copy_from_kernel_nofault(fdesc, do_nothing, sizeof(*fdesc));
>> + if (err < 0)
>> + return ERR_PTR(err);
>> +
>> + fdesc->addr = (unsigned long)dst;
>> + barrier();
>> +
>> + return fdesc;
>> +}
>> +
>> static noinline void execute_location(void *dst, bool write)
>> {
>> - void (*func)(void) = dst;
>> + void (*func)(void);
>> + funct_descr_t fdesc;
>> + void *do_nothing_text = dereference_symbol_descriptor(do_nothing);
>>
>> - pr_info("attempting ok execution at %px\n", do_nothing);
>> + pr_info("attempting ok execution at %px\n", do_nothing_text);
>> do_nothing();
>>
>> if (write == CODE_WRITE) {
>> - memcpy(dst, do_nothing, EXEC_SIZE);
>> + memcpy(dst, do_nothing_text, EXEC_SIZE);
>> flush_icache_range((unsigned long)dst,
>> (unsigned long)dst + EXEC_SIZE);
>> }
>> - pr_info("attempting bad execution at %px\n", func);
>> + func = setup_function_descriptor(&fdesc, dst);
>> + if (IS_ERR(func))
>> + return;
>
> I think this error case should complain with some details. :) Maybe:
>
> pr_err("FAIL: could not build function descriptor for %px\n", dst);
Ok, I was going to add that in v2, but after one more thought I realise
that there's no need to use copy_from_kernel_nofault() here, we are
copying a static object into our stack, so a memcpy() will be good enough.
>
>> +
>> + pr_info("attempting bad execution at %px\n", dst);
>
> And then leave this pr_info() as it was, before the
> setup_function_descriptor() call.
>
>> func();
>> pr_err("FAIL: func returned\n");
>> }
>> @@ -66,16 +89,22 @@ static void execute_user_location(void *dst)
>> int copied;
>>
>> /* Intentionally crossing kernel/user memory boundary. */
>> - void (*func)(void) = dst;
>> + void (*func)(void);
>> + funct_descr_t fdesc;
>> + void *do_nothing_text = dereference_symbol_descriptor(do_nothing);
>>
>> - pr_info("attempting ok execution at %px\n", do_nothing);
>> + pr_info("attempting ok execution at %px\n", do_nothing_text);
>> do_nothing();
>>
>> - copied = access_process_vm(current, (unsigned long)dst, do_nothing,
>> + copied = access_process_vm(current, (unsigned long)dst, do_nothing_text,
>> EXEC_SIZE, FOLL_WRITE);
>> if (copied < EXEC_SIZE)
>> return;
>> - pr_info("attempting bad execution at %px\n", func);
>> + func = setup_function_descriptor(&fdesc, dst);
>> + if (IS_ERR(func))
>> + return;
>> +
>> + pr_info("attempting bad execution at %px\n", dst);
>
> Same here.
>
>> func();
>> pr_err("FAIL: func returned\n");
>> }
>> --
>> 2.31.1
>>
>
^ permalink raw reply
* Re: [PATCH v1 06/10] asm-generic: Refactor dereference_[kernel]_function_descriptor()
From: Arnd Bergmann @ 2021-10-13 11:34 UTC (permalink / raw)
To: Christophe Leroy
Cc: linux-arch, linux-ia64, Kees Cook, Arnd Bergmann,
Greg Kroah-Hartman, Helge Deller, Linux Kernel Mailing List,
James E.J. Bottomley, Linux-MM, Paul Mackerras, Parisc List,
Andrew Morton, linuxppc-dev
In-Reply-To: <c2904a2e-c112-f2bc-04a0-52b08b46c1ce@csgroup.eu>
On Wed, Oct 13, 2021 at 1:20 PM Christophe Leroy
<christophe.leroy@csgroup.eu> wrote:
> Le 13/10/2021 à 09:02, Kees Cook a écrit :
> > On Mon, Oct 11, 2021 at 05:25:33PM +0200, Christophe Leroy wrote:
> >> dereference_function_descriptor() and
> >> dereference_kernel_function_descriptor() are identical on the
> >> three architectures implementing them.
> >>
> >> Make it common.
> >>
> >> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> >> ---
> >> arch/ia64/include/asm/sections.h | 19 -------------------
> >> arch/parisc/include/asm/sections.h | 9 ---------
> >> arch/parisc/kernel/process.c | 21 ---------------------
> >> arch/powerpc/include/asm/sections.h | 23 -----------------------
> >> include/asm-generic/sections.h | 18 ++++++++++++++++++
> >> 5 files changed, 18 insertions(+), 72 deletions(-)
> >
> > A diffstat to love. :)
> >
> > Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
> Unless somebody minds, I will make them out of line as
> suggested by Helge in he's comment to patch 4.
>
> Allthough there is no spectacular size reduction, the functions
> are not worth being inlined as they are not used in critical pathes.
Sounds good to me.
Arnd
^ permalink raw reply
* Re: [PATCH v1 06/10] asm-generic: Refactor dereference_[kernel]_function_descriptor()
From: Christophe Leroy @ 2021-10-13 11:20 UTC (permalink / raw)
To: Kees Cook, Helge Deller
Cc: linux-arch, linux-ia64, linux-parisc, Arnd Bergmann,
Greg Kroah-Hartman, linux-kernel, James E.J. Bottomley, linux-mm,
Paul Mackerras, Andrew Morton, linuxppc-dev
In-Reply-To: <202110130002.A7C0A86@keescook>
Le 13/10/2021 à 09:02, Kees Cook a écrit :
> On Mon, Oct 11, 2021 at 05:25:33PM +0200, Christophe Leroy wrote:
>> dereference_function_descriptor() and
>> dereference_kernel_function_descriptor() are identical on the
>> three architectures implementing them.
>>
>> Make it common.
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>> ---
>> arch/ia64/include/asm/sections.h | 19 -------------------
>> arch/parisc/include/asm/sections.h | 9 ---------
>> arch/parisc/kernel/process.c | 21 ---------------------
>> arch/powerpc/include/asm/sections.h | 23 -----------------------
>> include/asm-generic/sections.h | 18 ++++++++++++++++++
>> 5 files changed, 18 insertions(+), 72 deletions(-)
>
> A diffstat to love. :)
>
> Reviewed-by: Kees Cook <keescook@chromium.org>
Unless somebody minds, I will make them out of line as
suggested by Helge in he's comment to patch 4.
Allthough there is no spectacular size reduction, the functions
are not worth being inlined as they are not used in critical pathes.
^ permalink raw reply
* Re: [PATCH v5 0/4] Add perf interface to expose nvdimm
From: kajoljain @ 2021-10-13 10:15 UTC (permalink / raw)
To: mpe, linuxppc-dev, nvdimm, linux-kernel, peterz, dan.j.williams,
ira.weiny, vishal.l.verma
Cc: santosh, maddy, rnsastry, aneesh.kumar, atrajeev, vaibhav, tglx
In-Reply-To: <20210928124200.146331-1-kjain@linux.ibm.com>
Hi Dan,
Any comments on this patch-set?
Thanks,
Kajol Jain
On 9/28/21 6:11 PM, Kajol Jain wrote:
> Patchset adds performance stats reporting support for nvdimm.
> Added interface includes support for pmu register/unregister
> functions. A structure is added called nvdimm_pmu to be used for
> adding arch/platform specific data such as cpumask, nvdimm device
> pointer and pmu event functions like event_init/add/read/del.
> User could use the standard perf tool to access perf events
> exposed via pmu.
>
> Interface also defines supported event list, config fields for the
> event attributes and their corresponding bit values which are exported
> via sysfs. Patch 3 exposes IBM pseries platform nmem* device
> performance stats using this interface.
>
> Result from power9 pseries lpar with 2 nvdimm device:
>
> Ex: List all event by perf list
>
> command:# perf list nmem
>
> nmem0/cache_rh_cnt/ [Kernel PMU event]
> nmem0/cache_wh_cnt/ [Kernel PMU event]
> nmem0/cri_res_util/ [Kernel PMU event]
> nmem0/ctl_res_cnt/ [Kernel PMU event]
> nmem0/ctl_res_tm/ [Kernel PMU event]
> nmem0/fast_w_cnt/ [Kernel PMU event]
> nmem0/host_l_cnt/ [Kernel PMU event]
> nmem0/host_l_dur/ [Kernel PMU event]
> nmem0/host_s_cnt/ [Kernel PMU event]
> nmem0/host_s_dur/ [Kernel PMU event]
> nmem0/med_r_cnt/ [Kernel PMU event]
> nmem0/med_r_dur/ [Kernel PMU event]
> nmem0/med_w_cnt/ [Kernel PMU event]
> nmem0/med_w_dur/ [Kernel PMU event]
> nmem0/mem_life/ [Kernel PMU event]
> nmem0/poweron_secs/ [Kernel PMU event]
> ...
> nmem1/mem_life/ [Kernel PMU event]
> nmem1/poweron_secs/ [Kernel PMU event]
>
> Patch1:
> Introduces the nvdimm_pmu structure
> Patch2:
> Adds common interface to add arch/platform specific data
> includes nvdimm device pointer, pmu data along with
> pmu event functions. It also defines supported event list
> and adds attribute groups for format, events and cpumask.
> It also adds code for cpu hotplug support.
> Patch3:
> Add code in arch/powerpc/platform/pseries/papr_scm.c to expose
> nmem* pmu. It fills in the nvdimm_pmu structure with pmu name,
> capabilities, cpumask and event functions and then registers
> the pmu by adding callbacks to register_nvdimm_pmu.
> Patch4:
> Sysfs documentation patch
>
> Changelog
> ---
> v4 -> v5:
> - Remove multiple variables defined in nvdimm_pmu structure include
> name and pmu functions(event_int/add/del/read) as they are just
> used to copy them again in pmu variable. Now we are directly doing
> this step in arch specific code as suggested by Dan Williams.
>
> - Remove attribute group field from nvdimm pmu structure and
> defined these attribute groups in common interface which
> includes format, event list along with cpumask as suggested by
> Dan Williams.
> Since we added static defination for attrbute groups needed in
> common interface, removes corresponding code from papr.
>
> - Add nvdimm pmu event list with event codes in the common interface.
>
> - Remove Acked-by/Reviewed-by/Tested-by tags as code is refactored
> to handle review comments from Dan.
>
> - Make nvdimm_pmu_free_hotplug_memory function static as reported
> by kernel test robot, also add corresponding Reported-by tag.
>
> - Link to the patchset v4: https://lkml.org/lkml/2021/9/3/45
>
> v3 -> v4
> - Rebase code on top of current papr_scm code without any logical
> changes.
>
> - Added Acked-by tag from Peter Zijlstra and Reviewed by tag
> from Madhavan Srinivasan.
>
> - Link to the patchset v3: https://lkml.org/lkml/2021/6/17/605
>
> v2 -> v3
> - Added Tested-by tag.
>
> - Fix nvdimm mailing list in the ABI Documentation.
>
> - Link to the patchset v2: https://lkml.org/lkml/2021/6/14/25
>
> v1 -> v2
> - Fix hotplug code by adding pmu migration call
> incase current designated cpu got offline. As
> pointed by Peter Zijlstra.
>
> - Removed the retun -1 part from cpu hotplug offline
> function.
>
> - Link to the patchset v1: https://lkml.org/lkml/2021/6/8/500
>
> Kajol Jain (4):
> drivers/nvdimm: Add nvdimm pmu structure
> drivers/nvdimm: Add perf interface to expose nvdimm performance stats
> powerpc/papr_scm: Add perf interface support
> docs: ABI: sysfs-bus-nvdimm: Document sysfs event format entries for
> nvdimm pmu
>
> Documentation/ABI/testing/sysfs-bus-nvdimm | 35 +++
> arch/powerpc/include/asm/device.h | 5 +
> arch/powerpc/platforms/pseries/papr_scm.c | 225 ++++++++++++++
> drivers/nvdimm/Makefile | 1 +
> drivers/nvdimm/nd_perf.c | 328 +++++++++++++++++++++
> include/linux/nd.h | 41 +++
> 6 files changed, 635 insertions(+)
> create mode 100644 drivers/nvdimm/nd_perf.c
>
^ permalink raw reply
* Re: [PATCH v6 00/11] PCI: Drop duplicated tracking of a pci_dev's bound driver
From: Andy Shevchenko @ 2021-10-13 9:26 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Giovanni Cabiddu, Mark Rutland, Sathya Prakash,
Alexander Shishkin, Alexander Duyck,
maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT), qat-linux,
oss-drivers, Oliver O'Halloran, H. Peter Anvin, Jiri Olsa,
Thomas Gleixner, Marco Chiappero, Stefano Stabellini, Herbert Xu,
linux-scsi, Rafał Miłecki, Jesse Brandeburg,
Peter Zijlstra, Ingo Molnar, linux-pci,
open list:TI WILINK WIRELES..., Jakub Kicinski, Yisen Zhuang,
Suganath Prabu Subramani, Fiona Trahe, Andrew Donnellan,
Arnd Bergmann, Konrad Rzeszutek Wilk, Ido Schimmel,
Uwe Kleine-König, Simon Horman,
open list:LINUX FOR POWERPC PA SEMI PWRFICIENT,
Arnaldo Carvalho de Melo, Jack Xu, Borislav Petkov,
Michael Buesch, Jiri Pirko, Bjorn Helgaas, Namhyung Kim,
Boris Ostrovsky, Andy Shevchenko, Juergen Gross, Salil Mehta,
Sreekanth Reddy, xen-devel, Vadym Kochan, MPT-FusionLinux.pdl,
Greg Kroah-Hartman, USB, Wojciech Ziemba,
Linux Kernel Mailing List, Mathias Nyman, Zhou Wang, linux-crypto,
Sascha Hauer, netdev, Frederic Barrat, Paul Mackerras,
Tomaszx Kowalik, Taras Chornyi, David S. Miller, linux-perf-users
In-Reply-To: <20211012233212.GA1806189@bhelgaas>
On Wed, Oct 13, 2021 at 2:33 AM Bjorn Helgaas <helgaas@kernel.org> wrote:
> On Mon, Oct 04, 2021 at 02:59:24PM +0200, Uwe Kleine-König wrote:
> I split some of the bigger patches apart so they only touched one
> driver or subsystem at a time. I also updated to_pci_driver() so it
> returns NULL when given NULL, which makes some of the validations
> quite a bit simpler, especially in the PM code in pci-driver.c.
It's a bit unusual. Other to_*_dev() are not NULL-aware IIRC.
Below are some comments as well.
...
> static bool match_id(struct pci_dev *pdev, unsigned short vendor, unsigned short device)
> {
> + struct pci_driver *drv = to_pci_driver(pdev->dev.driver);
> const struct pci_device_id *id;
>
> if (pdev->vendor == vendor && pdev->device == device)
> return true;
> + for (id = drv ? drv->id_table : NULL; id && id->vendor; id++)
> + if (id->vendor == vendor && id->device == device)
> + break;
return true;
> return id && id->vendor;
return false;
> }
...
> + afu_result = err_handler->error_detected(afu_dev,
> + state);
One line?
...
> device_lock(&vf_dev->dev);
> - if (vf_dev->dev.driver) {
> + if (to_pci_driver(vf_dev->dev.driver)) {
Hmm...
...
> + if (!pci_dev->state_saved && pci_dev->current_state != PCI_D0
> + && pci_dev->current_state != PCI_UNKNOWN) {
Can we keep && on the previous line?
> + pci_WARN_ONCE(pci_dev, pci_dev->current_state != prev,
> + "PCI PM: Device state not saved by %pS\n",
> + drv->suspend);
> }
...
> + return drv && drv->resume ?
> + drv->resume(pci_dev) : pci_pm_reenable_device(pci_dev);
One line?
...
> + struct pci_driver *drv = to_pci_driver(dev->dev.driver);
> const struct pci_error_handlers *err_handler =
> - dev->dev.driver ? to_pci_driver(dev->dev.driver)->err_handler : NULL;
> + drv ? drv->err_handler : NULL;
Isn't dev->driver == to_pci_driver(dev->dev.driver)?
...
> + struct pci_driver *drv = to_pci_driver(dev->dev.driver);
> const struct pci_error_handlers *err_handler =
> - dev->dev.driver ? to_pci_driver(dev->dev.driver)->err_handler : NULL;
> + drv ? drv->err_handler : NULL;
Ditto.
...
> device_lock(&dev->dev);
> + pdrv = to_pci_driver(dev->dev.driver);
> if (!pci_dev_set_io_state(dev, state) ||
> - !dev->dev.driver ||
> - !(pdrv = to_pci_driver(dev->dev.driver))->err_handler ||
> + !pdrv ||
> + !pdrv->err_handler ||
One line now?
> !pdrv->err_handler->error_detected) {
Or this and the previous line?
...
> + pdrv = to_pci_driver(dev->dev.driver);
> + if (!pdrv ||
> + !pdrv->err_handler ||
> !pdrv->err_handler->mmio_enabled)
> goto out;
Ditto.
...
> + pdrv = to_pci_driver(dev->dev.driver);
> + if (!pdrv ||
> + !pdrv->err_handler ||
> !pdrv->err_handler->slot_reset)
> goto out;
Ditto.
...
> if (!pci_dev_set_io_state(dev, pci_channel_io_normal) ||
> - !dev->dev.driver ||
> - !(pdrv = to_pci_driver(dev->dev.driver))->err_handler ||
> + !pdrv ||
> + !pdrv->err_handler ||
> !pdrv->err_handler->resume)
> goto out;
Ditto.
> - result = PCI_ERS_RESULT_NONE;
>
> pcidev = pci_get_domain_bus_and_slot(domain, bus, devfn);
> if (!pcidev || !pcidev->dev.driver) {
> dev_err(&pdev->xdev->dev, "device or AER driver is NULL\n");
> pci_dev_put(pcidev);
> - return result;
> + return PCI_ERS_RESULT_NONE;
> }
> pdrv = to_pci_driver(pcidev->dev.driver);
What about splitting the conditional to two with clear error message
in each and use pci_err() in the second one?
...
> default:
> dev_err(&pdev->xdev->dev,
> - "bad request in aer recovery "
> - "operation!\n");
> + "bad request in AER recovery operation!\n");
Stray change? Or is it in a separate patch in your tree?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* Re: [PATCH v6 00/11] PCI: Drop duplicated tracking of a pci_dev's bound driver
From: Uwe Kleine-König @ 2021-10-13 8:51 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Giovanni Cabiddu, Mark Rutland, x86, Alexander Shishkin,
linux-pci, Alexander Duyck, Jesse Brandeburg, Sathya Prakash,
oss-drivers, netdev, Oliver O'Halloran, H. Peter Anvin,
Jiri Olsa, Boris Ostrovsky, Paul Mackerras, Marco Chiappero,
Stefano Stabellini, Herbert Xu, linux-scsi, Ido Schimmel,
Rafał Miłecki, qat-linux, Peter Zijlstra, Ingo Molnar,
Jakub Kicinski, Yisen Zhuang, Frederic Barrat, Fiona Trahe,
Andrew Donnellan, Arnd Bergmann, Konrad Rzeszutek Wilk,
Suganath Prabu Subramani, Arnaldo Carvalho de Melo, Jack Xu,
Borislav Petkov, Michael Buesch, Jiri Pirko, Bjorn Helgaas,
Namhyung Kim, Thomas Gleixner, Andy Shevchenko, Juergen Gross,
Salil Mehta, Sreekanth Reddy, xen-devel, Vadym Kochan,
MPT-FusionLinux.pdl, linux-usb, linux-wireless, linux-kernel,
David S. Miller, Mathias Nyman, Zhou Wang, linux-crypto, kernel,
Greg Kroah-Hartman, Simon Horman, Wojciech Ziemba,
Tomaszx Kowalik, linuxppc-dev, Taras Chornyi, linux-perf-users
In-Reply-To: <20211012233212.GA1806189@bhelgaas>
[-- Attachment #1: Type: text/plain, Size: 2395 bytes --]
On Tue, Oct 12, 2021 at 06:32:12PM -0500, Bjorn Helgaas wrote:
> On Mon, Oct 04, 2021 at 02:59:24PM +0200, Uwe Kleine-König wrote:
> > Hello,
> >
> > this is v6 of the quest to drop the "driver" member from struct pci_dev
> > which tracks the same data (apart from a constant offset) as dev.driver.
>
> I like this a lot and applied it to pci/driver for v5.16, thanks!
>
> I split some of the bigger patches apart so they only touched one
> driver or subsystem at a time. I also updated to_pci_driver() so it
> returns NULL when given NULL, which makes some of the validations
> quite a bit simpler, especially in the PM code in pci-driver.c.
OK.
> Full interdiff from this v6 series:
>
> diff --git a/arch/x86/kernel/probe_roms.c b/arch/x86/kernel/probe_roms.c
> index deaaef6efe34..36e84d904260 100644
> --- a/arch/x86/kernel/probe_roms.c
> +++ b/arch/x86/kernel/probe_roms.c
> @@ -80,17 +80,15 @@ static struct resource video_rom_resource = {
> */
> static bool match_id(struct pci_dev *pdev, unsigned short vendor, unsigned short device)
> {
> + struct pci_driver *drv = to_pci_driver(pdev->dev.driver);
> const struct pci_device_id *id;
>
> if (pdev->vendor == vendor && pdev->device == device)
> return true;
>
> - if (pdev->dev.driver) {
> - struct pci_driver *drv = to_pci_driver(pdev->dev.driver);
> - for (id = drv->id_table; id && id->vendor; id++)
> - if (id->vendor == vendor && id->device == device)
> - break;
> - }
> + for (id = drv ? drv->id_table : NULL; id && id->vendor; id++)
> + if (id->vendor == vendor && id->device == device)
> + break;
>
> return id && id->vendor;
> }
> diff --git a/drivers/misc/cxl/guest.c b/drivers/misc/cxl/guest.c
> index d997c9c3ebb5..7eb3706cf42d 100644
> --- a/drivers/misc/cxl/guest.c
> +++ b/drivers/misc/cxl/guest.c
> @@ -20,38 +20,38 @@ static void pci_error_handlers(struct cxl_afu *afu,
> pci_channel_state_t state)
> {
> struct pci_dev *afu_dev;
> + struct pci_driver *afu_drv;
> + struct pci_error_handlers *err_handler;
These two could be moved into the for loop (where afu_drv was with my
patch already). This is also possible in a few other drivers.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply
* Re: [PATCH 2/2] kbuild: use more subdir- for visiting subdirectories while cleaning
From: Geert Uytterhoeven @ 2021-10-13 6:59 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Mark Rutland, Randy Dunlap, linux-ia64@vger.kernel.org,
open list:DOCUMENTATION, Viresh Kumar,
open list:BROADCOM NVRAM DRIVER, James E.J. Bottomley,
Max Filippov, Rich Felker, Guo Ren, linux-csky, H. Peter Anvin,
sparclinux, linux-riscv, Vincent Chen, Will Deacon,
Thomas Gleixner, Paul Mackerras, Jonas Bonn, Rob Herring,
Vasily Gorbik, Yoshinori Sato, Krzysztof Kozlowski, Marc Zyngier,
Helge Deller, Linux-sh list, Russell King, Ley Foon Tan,
Christian Borntraeger, alpha, Ingo Molnar, Parisc List,
Sami Tolvanen, Catalin Marinas, Matt Turner, arcml,
moderated list:H8/300 ARCHITECTURE,
open list:TENSILICA XTENSA PORT (xtensa), Albert Ou,
Robert Richter, Kees Cook, Arnd Bergmann, linux-kbuild,
Heiko Carstens, Uwe Kleine-König, Stefan Kristiansson,
Nathan Chancellor, linux-m68k, Thomas Bogendoerfer,
Ivan Kokshaysky, Greentime Hu, Paul Walmsley, Stafford Horne,
Linux ARM, Richard Henderson, William Cohen, Chris Zankel,
Michal Simek, Michal Marek, Julien Thierry, Nick Hu, linux-s390,
Jonathan Corbet, Nick Desaulniers, Linux Kernel Mailing List,
Openrisc, Palmer Dabbelt, Borislav Petkov, Vineet Gupta,
linuxppc-dev, David S. Miller, x86
In-Reply-To: <20211013063622.548590-2-masahiroy@kernel.org>
On Wed, Oct 13, 2021 at 8:43 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> Documentation/kbuild/makefiles.rst suggests to use "archclean" for
> cleaning arch/$(SRCARCH)/boot/.
>
> Since commit d92cc4d51643 ("kbuild: require all architectures to have
> arch/$(SRCARCH)/Kbuild"), we can use the "subdir- += boot" trick for
> all architectures. This can take advantage of the parallel option (-j)
> for "make clean".
>
> I also cleaned up the comments. The "archdep" target does not exist.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> arch/m68k/Makefile | 4 +---
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply
* [PATCH 2/2] kbuild: use more subdir- for visiting subdirectories while cleaning
From: Masahiro Yamada @ 2021-10-13 6:36 UTC (permalink / raw)
To: linux-kbuild
Cc: Mark Rutland, Randy Dunlap, linux-ia64, linux-doc, Viresh Kumar,
linux-mips, James E.J. Bottomley, Max Filippov, Rich Felker,
Guo Ren, linux-csky, H. Peter Anvin, sparclinux, linux-riscv,
Vincent Chen, Will Deacon, Thomas Gleixner, Paul Mackerras,
Jonas Bonn, Rob Herring, Vasily Gorbik, Yoshinori Sato,
Jonathan Corbet, Marc Zyngier, Masahiro Yamada, linux-sh,
Russell King, Ley Foon Tan, Christian Borntraeger, linux-alpha,
Ingo Molnar, Geert Uytterhoeven, linux-parisc, Sami Tolvanen,
Catalin Marinas, Matt Turner, linux-snps-arc, uclinux-h8-devel,
linux-xtensa, Albert Ou, Robert Richter, Kees Cook, Arnd Bergmann,
linux-s390, Heiko Carstens, Uwe Kleine-König,
Stefan Kristiansson, Nathan Chancellor, linux-m68k,
Thomas Bogendoerfer, Ivan Kokshaysky, Greentime Hu, Paul Walmsley,
Stafford Horne, linux-arm-kernel, Richard Henderson,
William Cohen, Chris Zankel, Michal Simek, Michal Marek,
Julien Thierry, Nick Hu, Krzysztof Kozlowski, Nick Desaulniers,
linux-kernel, David S. Miller, openrisc, Palmer Dabbelt,
Borislav Petkov, Vineet Gupta, linuxppc-dev, Helge Deller, x86
In-Reply-To: <20211013063622.548590-1-masahiroy@kernel.org>
Documentation/kbuild/makefiles.rst suggests to use "archclean" for
cleaning arch/$(SRCARCH)/boot/.
Since commit d92cc4d51643 ("kbuild: require all architectures to have
arch/$(SRCARCH)/Kbuild"), we can use the "subdir- += boot" trick for
all architectures. This can take advantage of the parallel option (-j)
for "make clean".
I also cleaned up the comments. The "archdep" target does not exist.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
Documentation/kbuild/makefiles.rst | 17 ++---------------
arch/alpha/Kbuild | 3 +++
arch/alpha/Makefile | 3 ---
arch/arc/Kbuild | 3 +++
arch/arc/Makefile | 3 ---
arch/arm/Kbuild | 3 +++
arch/arm/Makefile | 4 ----
arch/arm64/Kbuild | 3 +++
arch/arm64/Makefile | 7 -------
arch/arm64/kernel/Makefile | 3 +++
arch/csky/Kbuild | 3 +++
arch/csky/Makefile | 3 ---
arch/h8300/Kbuild | 3 +++
arch/h8300/Makefile | 3 ---
arch/ia64/Makefile | 2 --
arch/m68k/Makefile | 4 +---
arch/microblaze/Kbuild | 3 +++
arch/microblaze/Makefile | 3 ---
arch/mips/Kbuild | 3 +++
arch/mips/Makefile | 8 +-------
arch/mips/boot/Makefile | 3 +++
arch/nds32/Kbuild | 3 +++
arch/nds32/Makefile | 3 ---
arch/nios2/Kbuild | 3 +++
arch/nios2/Makefile | 6 +-----
arch/openrisc/Kbuild | 3 +++
arch/openrisc/Makefile | 7 +------
arch/parisc/Kbuild | 3 +++
arch/parisc/Makefile | 7 +------
arch/powerpc/Kbuild | 3 +++
arch/powerpc/Makefile | 7 +------
arch/riscv/Kbuild | 3 +++
arch/riscv/Makefile | 7 +------
arch/s390/Kbuild | 3 +++
arch/s390/Makefile | 8 +-------
arch/sh/Kbuild | 3 +++
arch/sh/Makefile | 3 ---
arch/sparc/Kbuild | 3 +++
arch/sparc/Makefile | 3 ---
arch/x86/Kbuild | 3 +++
arch/x86/Makefile | 2 --
arch/xtensa/Makefile | 4 +---
42 files changed, 71 insertions(+), 103 deletions(-)
diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/makefiles.rst
index db3af0b45baf..b008b90b92c9 100644
--- a/Documentation/kbuild/makefiles.rst
+++ b/Documentation/kbuild/makefiles.rst
@@ -1050,22 +1050,9 @@ is not sufficient this sometimes needs to be explicit.
The above assignment instructs kbuild to descend down in the
directory compressed/ when "make clean" is executed.
-To support the clean infrastructure in the Makefiles that build the
-final bootimage there is an optional target named archclean:
-
- Example::
-
- #arch/x86/Makefile
- archclean:
- $(Q)$(MAKE) $(clean)=arch/x86/boot
-
-When "make clean" is executed, make will descend down in arch/x86/boot,
-and clean as usual. The Makefile located in arch/x86/boot/ may use
-the subdir- trick to descend further down.
-
Note 1: arch/$(SRCARCH)/Makefile cannot use "subdir-", because that file is
-included in the top level makefile, and the kbuild infrastructure
-is not operational at that point.
+included in the top level makefile. Instead, arch/$(SRCARCH)/Kbuild can use
+"subdir-".
Note 2: All directories listed in core-y, libs-y, drivers-y and net-y will
be visited during "make clean".
diff --git a/arch/alpha/Kbuild b/arch/alpha/Kbuild
index c2302017403a..345d79df24bb 100644
--- a/arch/alpha/Kbuild
+++ b/arch/alpha/Kbuild
@@ -1,3 +1,6 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-y += kernel/ mm/
obj-$(CONFIG_MATHEMU) += math-emu/
+
+# for cleaning
+subdir- += boot
diff --git a/arch/alpha/Makefile b/arch/alpha/Makefile
index 52529ee42dac..881cb913e23a 100644
--- a/arch/alpha/Makefile
+++ b/arch/alpha/Makefile
@@ -55,9 +55,6 @@ $(boot)/vmlinux.gz: vmlinux
bootimage bootpfile bootpzfile: vmlinux
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
-archclean:
- $(Q)$(MAKE) $(clean)=$(boot)
-
archheaders:
$(Q)$(MAKE) $(build)=arch/alpha/kernel/syscalls all
diff --git a/arch/arc/Kbuild b/arch/arc/Kbuild
index 699d8cae9b1f..b94102fff68b 100644
--- a/arch/arc/Kbuild
+++ b/arch/arc/Kbuild
@@ -1,3 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
obj-y += kernel/
obj-y += mm/
+
+# for cleaning
+subdir- += boot
diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index 08995f6c6441..efc54f3e35e0 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -112,6 +112,3 @@ uImage: $(uimage-default-y)
@$(kecho) ' Image $(boot)/uImage is ready'
CLEAN_FILES += $(boot)/uImage
-
-archclean:
- $(Q)$(MAKE) $(clean)=$(boot)
diff --git a/arch/arm/Kbuild b/arch/arm/Kbuild
index 5208f7061524..b506622e7e23 100644
--- a/arch/arm/Kbuild
+++ b/arch/arm/Kbuild
@@ -9,3 +9,6 @@ obj-y += kernel/ mm/ common/
obj-y += probes/
obj-y += net/
obj-y += crypto/
+
+# for cleaning
+subdir- += boot
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 847c31e7c368..07ea71f8665c 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -317,10 +317,6 @@ ifeq ($(CONFIG_VDSO),y)
$(Q)$(MAKE) $(build)=arch/arm/vdso $@
endif
-# We use MRPROPER_FILES and CLEAN_FILES now
-archclean:
- $(Q)$(MAKE) $(clean)=$(boot)
-
# My testing targets (bypasses dependencies)
bp:; $(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $(boot)/bootpImage
diff --git a/arch/arm64/Kbuild b/arch/arm64/Kbuild
index ea7ab4ca81f9..5bfbf7d79c99 100644
--- a/arch/arm64/Kbuild
+++ b/arch/arm64/Kbuild
@@ -4,3 +4,6 @@ obj-$(CONFIG_KVM) += kvm/
obj-$(CONFIG_XEN) += xen/
obj-$(subst m,y,$(CONFIG_HYPERV)) += hyperv/
obj-$(CONFIG_CRYPTO) += crypto/
+
+# for cleaning
+subdir- += boot
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index c744b1e7b356..e8cfc5868aa8 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -182,13 +182,6 @@ ifeq ($(CONFIG_ARM64_USE_LSE_ATOMICS),y)
endif
endif
-
-# We use MRPROPER_FILES and CLEAN_FILES now
-archclean:
- $(Q)$(MAKE) $(clean)=$(boot)
- $(Q)$(MAKE) $(clean)=arch/arm64/kernel/vdso
- $(Q)$(MAKE) $(clean)=arch/arm64/kernel/vdso32
-
ifeq ($(KBUILD_EXTMOD),)
# We need to generate vdso-offsets.h before compiling certain files in kernel/.
# In order to do that, we should use the archprepare target, but we can't since
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index 3f1490bfb938..88b3e2a21408 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -81,3 +81,6 @@ extra-y += $(head-y) vmlinux.lds
ifeq ($(CONFIG_DEBUG_EFI),y)
AFLAGS_head.o += -DVMLINUX_PATH="\"$(realpath $(objtree)/vmlinux)\""
endif
+
+# for cleaning
+subdir- += vdso vdso32
diff --git a/arch/csky/Kbuild b/arch/csky/Kbuild
index a4e40e534e6a..4e39f7abdeb6 100644
--- a/arch/csky/Kbuild
+++ b/arch/csky/Kbuild
@@ -1 +1,4 @@
# SPDX-License-Identifier: GPL-2.0-only
+
+# for cleaning
+subdir- += boot
diff --git a/arch/csky/Makefile b/arch/csky/Makefile
index 37f593a4bf53..866805077636 100644
--- a/arch/csky/Makefile
+++ b/arch/csky/Makefile
@@ -76,9 +76,6 @@ all: zImage
zImage Image uImage: vmlinux
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
-archclean:
- $(Q)$(MAKE) $(clean)=$(boot)
-
define archhelp
echo '* zImage - Compressed kernel image (arch/$(ARCH)/boot/zImage)'
echo ' Image - Uncompressed kernel image (arch/$(ARCH)/boot/Image)'
diff --git a/arch/h8300/Kbuild b/arch/h8300/Kbuild
index b2583e7efbd1..e4703f3534cc 100644
--- a/arch/h8300/Kbuild
+++ b/arch/h8300/Kbuild
@@ -1,2 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-y += kernel/ mm/ boot/dts/
+
+# for cleaning
+subdir- += boot
diff --git a/arch/h8300/Makefile b/arch/h8300/Makefile
index eb4cb8f6830c..807f41e60ee4 100644
--- a/arch/h8300/Makefile
+++ b/arch/h8300/Makefile
@@ -34,9 +34,6 @@ libs-y += arch/$(ARCH)/lib/
boot := arch/h8300/boot
-archclean:
- $(Q)$(MAKE) $(clean)=$(boot)
-
vmlinux.srec vmlinux.bin zImage uImage.bin: vmlinux
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile
index 7e548c654a29..3b3ac3e1f272 100644
--- a/arch/ia64/Makefile
+++ b/arch/ia64/Makefile
@@ -67,8 +67,6 @@ vmlinux.bin: vmlinux FORCE
unwcheck: vmlinux
-$(Q)READELF=$(READELF) $(PYTHON3) $(srctree)/arch/ia64/scripts/unwcheck.py $<
-archclean:
-
archheaders:
$(Q)$(MAKE) $(build)=arch/ia64/kernel/syscalls all
diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
index dd0c0ec67f67..740fc97b9c0f 100644
--- a/arch/m68k/Makefile
+++ b/arch/m68k/Makefile
@@ -2,9 +2,7 @@
# m68k/Makefile
#
# This file is included by the global makefile so that you can add your own
-# architecture-specific flags and dependencies. Remember to do have actions
-# for "archclean" and "archdep" for cleaning up and making dependencies for
-# this architecture
+# architecture-specific flags and dependencies.
#
# This file is subject to the terms and conditions of the GNU General Public
# License. See the file "COPYING" in the main directory of this archive
diff --git a/arch/microblaze/Kbuild b/arch/microblaze/Kbuild
index a1c597889319..077a0b8e9615 100644
--- a/arch/microblaze/Kbuild
+++ b/arch/microblaze/Kbuild
@@ -3,3 +3,6 @@ obj-y += kernel/
obj-y += mm/
obj-$(CONFIG_PCI) += pci/
obj-y += boot/dts/
+
+# for cleaning
+subdir- += boot
diff --git a/arch/microblaze/Makefile b/arch/microblaze/Makefile
index 982cd8b876bf..a25e76d89e86 100644
--- a/arch/microblaze/Makefile
+++ b/arch/microblaze/Makefile
@@ -60,9 +60,6 @@ export DTB
all: linux.bin
-archclean:
- $(Q)$(MAKE) $(clean)=$(boot)
-
archheaders:
$(Q)$(MAKE) $(build)=arch/microblaze/kernel/syscalls all
diff --git a/arch/mips/Kbuild b/arch/mips/Kbuild
index d5d6ef9bb986..9e8071f0e58f 100644
--- a/arch/mips/Kbuild
+++ b/arch/mips/Kbuild
@@ -25,3 +25,6 @@ obj-y += vdso/
ifdef CONFIG_KVM
obj-y += kvm/
endif
+
+# for cleaning
+subdir- += boot
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index ea3cd080a1c7..e036fc025ccc 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -8,8 +8,7 @@
# Copyright (C) 2002, 2003, 2004 Maciej W. Rozycki
#
# This file is included by the global makefile so that you can add your own
-# architecture-specific flags and dependencies. Remember to do have actions
-# for "archclean" cleaning up for this architecture.
+# architecture-specific flags and dependencies.
#
archscripts: scripts_basic
@@ -426,11 +425,6 @@ endif
$(Q)install -D -m 644 .config $(INSTALL_PATH)/config-$(KERNELRELEASE)
$(Q)install -D -m 644 System.map $(INSTALL_PATH)/System.map-$(KERNELRELEASE)
-archclean:
- $(Q)$(MAKE) $(clean)=arch/mips/boot
- $(Q)$(MAKE) $(clean)=arch/mips/boot/compressed
- $(Q)$(MAKE) $(clean)=arch/mips/boot/tools
-
archheaders:
$(Q)$(MAKE) $(build)=arch/mips/kernel/syscalls all
diff --git a/arch/mips/boot/Makefile b/arch/mips/boot/Makefile
index a3da2c5d63c2..196c44fa72d9 100644
--- a/arch/mips/boot/Makefile
+++ b/arch/mips/boot/Makefile
@@ -171,3 +171,6 @@ $(obj)/vmlinux.itb: $(obj)/vmlinux.its $(obj)/vmlinux.bin FORCE
$(obj)/vmlinux.%.itb: $(obj)/vmlinux.%.its $(obj)/vmlinux.bin.% FORCE
$(call if_changed,itb-image,$<)
+
+# for cleaning
+subdir- += compressed tools
diff --git a/arch/nds32/Kbuild b/arch/nds32/Kbuild
index a4e40e534e6a..4e39f7abdeb6 100644
--- a/arch/nds32/Kbuild
+++ b/arch/nds32/Kbuild
@@ -1 +1,4 @@
# SPDX-License-Identifier: GPL-2.0-only
+
+# for cleaning
+subdir- += boot
diff --git a/arch/nds32/Makefile b/arch/nds32/Makefile
index ee26e4df2fd0..b33d5d81b6ae 100644
--- a/arch/nds32/Makefile
+++ b/arch/nds32/Makefile
@@ -58,9 +58,6 @@ prepare: vdso_prepare
vdso_prepare: prepare0
$(Q)$(MAKE) $(build)=arch/nds32/kernel/vdso include/generated/vdso-offsets.h
-archclean:
- $(Q)$(MAKE) $(clean)=$(boot)
-
define archhelp
echo ' Image - kernel image (arch/$(ARCH)/boot/Image)'
endef
diff --git a/arch/nios2/Kbuild b/arch/nios2/Kbuild
index a4e40e534e6a..4e39f7abdeb6 100644
--- a/arch/nios2/Kbuild
+++ b/arch/nios2/Kbuild
@@ -1 +1,4 @@
# SPDX-License-Identifier: GPL-2.0-only
+
+# for cleaning
+subdir- += boot
diff --git a/arch/nios2/Makefile b/arch/nios2/Makefile
index 72e8ff065cf7..02d678559066 100644
--- a/arch/nios2/Makefile
+++ b/arch/nios2/Makefile
@@ -8,8 +8,7 @@
# Written by Fredrik Markstrom
#
# This file is included by the global makefile so that you can add your own
-# architecture-specific flags and dependencies. Remember to do have actions
-# for "archclean" cleaning up for this architecture.
+# architecture-specific flags and dependencies.
#
# Nios2 port by Wind River Systems Inc trough:
# fredrik.markstrom@gmail.com and ivarholmqvist@gmail.com
@@ -53,9 +52,6 @@ core-y += $(nios2-boot)/dts/
all: vmImage
-archclean:
- $(Q)$(MAKE) $(clean)=$(nios2-boot)
-
$(BOOT_TARGETS): vmlinux
$(Q)$(MAKE) $(build)=$(nios2-boot) $(nios2-boot)/$@
diff --git a/arch/openrisc/Kbuild b/arch/openrisc/Kbuild
index 4234b4c03e72..b0b0f2b03f87 100644
--- a/arch/openrisc/Kbuild
+++ b/arch/openrisc/Kbuild
@@ -1,3 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
obj-y += lib/ kernel/ mm/
obj-y += boot/dts/
+
+# for cleaning
+subdir- += boot
diff --git a/arch/openrisc/Makefile b/arch/openrisc/Makefile
index c52de526e518..760b734fb822 100644
--- a/arch/openrisc/Makefile
+++ b/arch/openrisc/Makefile
@@ -1,9 +1,7 @@
# BK Id: %F% %I% %G% %U% %#%
#
# This file is included by the global makefile so that you can add your own
-# architecture-specific flags and dependencies. Remember to do have actions
-# for "archclean" and "archdep" for cleaning up and making dependencies for
-# this architecture
+# architecture-specific flags and dependencies.
#
# This file is subject to the terms and conditions of the GNU General Public
# License. See the file "COPYING" in the main directory of this archive
@@ -48,6 +46,3 @@ PHONY += vmlinux.bin
vmlinux.bin: vmlinux
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
-
-archclean:
- $(Q)$(MAKE) $(clean)=$(boot)
diff --git a/arch/parisc/Kbuild b/arch/parisc/Kbuild
index 3c068b700a81..a6d3b280ba0c 100644
--- a/arch/parisc/Kbuild
+++ b/arch/parisc/Kbuild
@@ -1,2 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-y += mm/ kernel/ math-emu/
+
+# for cleaning
+subdir- += boot
diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile
index fcde3ffa0221..8db4af4879d0 100644
--- a/arch/parisc/Makefile
+++ b/arch/parisc/Makefile
@@ -2,9 +2,7 @@
# parisc/Makefile
#
# This file is included by the global makefile so that you can add your own
-# architecture-specific flags and dependencies. Remember to do have actions
-# for "archclean" and "archdep" for cleaning up and making dependencies for
-# this architecture
+# architecture-specific flags and dependencies.
#
# This file is subject to the terms and conditions of the GNU General Public
# License. See the file "COPYING" in the main directory of this archive
@@ -181,8 +179,5 @@ define archhelp
@echo ' zinstall - Install compressed vmlinuz kernel'
endef
-archclean:
- $(Q)$(MAKE) $(clean)=$(boot)
-
archheaders:
$(Q)$(MAKE) $(build)=arch/parisc/kernel/syscalls all
diff --git a/arch/powerpc/Kbuild b/arch/powerpc/Kbuild
index 5e2f9eaa3ee7..22cd0d55a892 100644
--- a/arch/powerpc/Kbuild
+++ b/arch/powerpc/Kbuild
@@ -16,3 +16,6 @@ obj-$(CONFIG_KVM) += kvm/
obj-$(CONFIG_PERF_EVENTS) += perf/
obj-$(CONFIG_KEXEC_CORE) += kexec/
obj-$(CONFIG_KEXEC_FILE) += purgatory/
+
+# for cleaning
+subdir- += boot
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index aa6808e70647..b61d8be3c226 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -1,7 +1,5 @@
# This file is included by the global makefile so that you can add your own
-# architecture-specific flags and dependencies. Remember to do have actions
-# for "archclean" and "archdep" for cleaning up and making dependencies for
-# this architecture.
+# architecture-specific flags and dependencies.
#
# This file is subject to the terms and conditions of the GNU General Public
# License. See the file "COPYING" in the main directory of this archive
@@ -411,9 +409,6 @@ install:
sh -x $(srctree)/$(boot)/install.sh "$(KERNELRELEASE)" vmlinux \
System.map "$(INSTALL_PATH)"
-archclean:
- $(Q)$(MAKE) $(clean)=$(boot)
-
ifeq ($(KBUILD_EXTMOD),)
# We need to generate vdso-offsets.h before compiling certain files in kernel/.
# In order to do that, we should use the archprepare target, but we can't since
diff --git a/arch/riscv/Kbuild b/arch/riscv/Kbuild
index 4614c01ba5b3..fb3397223d52 100644
--- a/arch/riscv/Kbuild
+++ b/arch/riscv/Kbuild
@@ -2,3 +2,6 @@
obj-y += kernel/ mm/ net/
obj-$(CONFIG_BUILTIN_DTB) += boot/dts/
+
+# for cleaning
+subdir- += boot
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 0eb4568fbd29..753e13f3a9d2 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -1,7 +1,5 @@
# This file is included by the global makefile so that you can add your own
-# architecture-specific flags and dependencies. Remember to do have actions
-# for "archclean" and "archdep" for cleaning up and making dependencies for
-# this architecture
+# architecture-specific flags and dependencies.
#
# This file is subject to the terms and conditions of the GNU General Public
# License. See the file "COPYING" in the main directory of this archive
@@ -137,6 +135,3 @@ zinstall: install-image = Image.gz
install zinstall:
$(CONFIG_SHELL) $(srctree)/$(boot)/install.sh $(KERNELRELEASE) \
$(boot)/$(install-image) System.map "$(INSTALL_PATH)"
-
-archclean:
- $(Q)$(MAKE) $(clean)=$(boot)
diff --git a/arch/s390/Kbuild b/arch/s390/Kbuild
index 8b98c501142d..76e362277179 100644
--- a/arch/s390/Kbuild
+++ b/arch/s390/Kbuild
@@ -8,3 +8,6 @@ obj-$(CONFIG_APPLDATA_BASE) += appldata/
obj-y += net/
obj-$(CONFIG_PCI) += pci/
obj-$(CONFIG_ARCH_HAS_KEXEC_PURGATORY) += purgatory/
+
+# for cleaning
+subdir- += boot tools
diff --git a/arch/s390/Makefile b/arch/s390/Makefile
index 450b351dfa8e..69c45f600273 100644
--- a/arch/s390/Makefile
+++ b/arch/s390/Makefile
@@ -3,9 +3,7 @@
# s390/Makefile
#
# This file is included by the global makefile so that you can add your own
-# architecture-specific flags and dependencies. Remember to do have actions
-# for "archclean" and "archdep" for cleaning up and making dependencies for
-# this architecture
+# architecture-specific flags and dependencies.
#
# Copyright (C) 1994 by Linus Torvalds
#
@@ -147,10 +145,6 @@ zfcpdump:
vdso_install:
$(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
-archclean:
- $(Q)$(MAKE) $(clean)=$(boot)
- $(Q)$(MAKE) $(clean)=$(tools)
-
archheaders:
$(Q)$(MAKE) $(build)=$(syscalls) uapi
diff --git a/arch/sh/Kbuild b/arch/sh/Kbuild
index 48c2a091a072..be171880977e 100644
--- a/arch/sh/Kbuild
+++ b/arch/sh/Kbuild
@@ -2,3 +2,6 @@
obj-y += kernel/ mm/ boards/
obj-$(CONFIG_SH_FPU_EMU) += math-emu/
obj-$(CONFIG_USE_BUILTIN_DTB) += boot/dts/
+
+# for cleaning
+subdir- += boot
diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index 781463900621..b39412bf91fb 100644
--- a/arch/sh/Makefile
+++ b/arch/sh/Makefile
@@ -198,9 +198,6 @@ compressed: zImage
archprepare:
$(Q)$(MAKE) $(build)=arch/sh/tools include/generated/machtypes.h
-archclean:
- $(Q)$(MAKE) $(clean)=$(boot)
-
archheaders:
$(Q)$(MAKE) $(build)=arch/sh/kernel/syscalls all
diff --git a/arch/sparc/Kbuild b/arch/sparc/Kbuild
index c9e574906a9b..71cb3d934bf6 100644
--- a/arch/sparc/Kbuild
+++ b/arch/sparc/Kbuild
@@ -9,3 +9,6 @@ obj-y += math-emu/
obj-y += net/
obj-y += crypto/
obj-$(CONFIG_SPARC64) += vdso/
+
+# for cleaning
+subdir- += boot
diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile
index 24fb5a99f439..c7008bbebc4c 100644
--- a/arch/sparc/Makefile
+++ b/arch/sparc/Makefile
@@ -75,9 +75,6 @@ install:
sh $(srctree)/$(boot)/install.sh $(KERNELRELEASE) $(KBUILD_IMAGE) \
System.map "$(INSTALL_PATH)"
-archclean:
- $(Q)$(MAKE) $(clean)=$(boot)
-
archheaders:
$(Q)$(MAKE) $(build)=arch/sparc/kernel/syscalls all
diff --git a/arch/x86/Kbuild b/arch/x86/Kbuild
index 30dec019756b..f384cb1a4f7a 100644
--- a/arch/x86/Kbuild
+++ b/arch/x86/Kbuild
@@ -25,3 +25,6 @@ obj-y += platform/
obj-y += net/
obj-$(CONFIG_KEXEC_FILE) += purgatory/
+
+# for cleaning
+subdir- += boot tools
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 7488cfbbd2f6..67d7c265e0ce 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -283,8 +283,6 @@ endif
archclean:
$(Q)rm -rf $(objtree)/arch/i386
$(Q)rm -rf $(objtree)/arch/x86_64
- $(Q)$(MAKE) $(clean)=$(boot)
- $(Q)$(MAKE) $(clean)=arch/x86/tools
define archhelp
echo '* bzImage - Compressed kernel image (arch/x86/boot/bzImage)'
diff --git a/arch/xtensa/Makefile b/arch/xtensa/Makefile
index 284fd1f592a8..ee2769519eaf 100644
--- a/arch/xtensa/Makefile
+++ b/arch/xtensa/Makefile
@@ -7,9 +7,7 @@
# Copyright (C) 2014 Cadence Design Systems Inc.
#
# This file is included by the global makefile so that you can add your own
-# architecture-specific flags and dependencies. Remember to do have actions
-# for "archclean" and "archdep" for cleaning up and making dependencies for
-# this architecture
+# architecture-specific flags and dependencies.
# Core configuration.
# (Use VAR=<xtensa_config> to use another default compiler.)
--
2.30.2
^ permalink raw reply related
* Re: [PATCH 2/2] kbuild: use more subdir- for visiting subdirectories while cleaning
From: Kees Cook @ 2021-10-13 6:45 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Mark Rutland, Randy Dunlap, linux-ia64, linux-doc, Viresh Kumar,
linux-mips, James E.J. Bottomley, Max Filippov, Rich Felker,
Guo Ren, linux-csky, H. Peter Anvin, sparclinux, linux-riscv,
Vincent Chen, Will Deacon, Thomas Gleixner, Paul Mackerras,
Jonas Bonn, Rob Herring, Vasily Gorbik, Yoshinori Sato,
Krzysztof Kozlowski, Marc Zyngier, Helge Deller, linux-sh,
Russell King, Ley Foon Tan, Christian Borntraeger, linux-alpha,
Ingo Molnar, Geert Uytterhoeven, linux-parisc, Sami Tolvanen,
Catalin Marinas, Matt Turner, linux-snps-arc, uclinux-h8-devel,
linux-xtensa, Albert Ou, Robert Richter, Arnd Bergmann,
linux-kbuild, Heiko Carstens, Uwe Kleine-König,
Stefan Kristiansson, Nathan Chancellor, linux-m68k,
Thomas Bogendoerfer, Ivan Kokshaysky, Greentime Hu, Paul Walmsley,
Stafford Horne, linux-arm-kernel, Richard Henderson,
William Cohen, Chris Zankel, Michal Simek, Michal Marek,
Julien Thierry, Nick Hu, linux-s390, Jonathan Corbet,
Nick Desaulniers, linux-kernel, openrisc, Palmer Dabbelt,
Borislav Petkov, Vineet Gupta, linuxppc-dev, David S. Miller, x86
In-Reply-To: <20211013063622.548590-2-masahiroy@kernel.org>
On Wed, Oct 13, 2021 at 03:36:22PM +0900, Masahiro Yamada wrote:
> Documentation/kbuild/makefiles.rst suggests to use "archclean" for
> cleaning arch/$(SRCARCH)/boot/.
>
> Since commit d92cc4d51643 ("kbuild: require all architectures to have
> arch/$(SRCARCH)/Kbuild"), we can use the "subdir- += boot" trick for
> all architectures. This can take advantage of the parallel option (-j)
> for "make clean".
>
> I also cleaned up the comments. The "archdep" target does not exist.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
I like the clean-up!
Reviewed-by: Kees Cook <keescook@chromium.org>
--
Kees Cook
^ permalink raw reply
* Re: [PATCH v2] KVM: PPC: Defer vtime accounting 'til after IRQ handling
From: Laurent Vivier @ 2021-10-13 9:30 UTC (permalink / raw)
To: Michael Ellerman, kvm-ppc
Cc: Greg Kurz, Nicholas Piggin, linux-kernel, stable, linuxppc-dev
In-Reply-To: <875yu17rxk.fsf@mpe.ellerman.id.au>
On 13/10/2021 01:18, Michael Ellerman wrote:
> Laurent Vivier <lvivier@redhat.com> writes:
>> Commit 112665286d08 moved guest_exit() in the interrupt protected
>> area to avoid wrong context warning (or worse), but the tick counter
>> cannot be updated and the guest time is accounted to the system time.
>>
>> To fix the problem port to POWER the x86 fix
>> 160457140187 ("Defer vtime accounting 'til after IRQ handling"):
>>
>> "Defer the call to account guest time until after servicing any IRQ(s)
>> that happened in the guest or immediately after VM-Exit. Tick-based
>> accounting of vCPU time relies on PF_VCPU being set when the tick IRQ
>> handler runs, and IRQs are blocked throughout the main sequence of
>> vcpu_enter_guest(), including the call into vendor code to actually
>> enter and exit the guest."
>>
>> Fixes: 112665286d08 ("KVM: PPC: Book3S HV: Context tracking exit guest context before enabling irqs")
>> Cc: npiggin@gmail.com
>> Cc: <stable@vger.kernel.org> # 5.12
>> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
>> ---
>>
>> Notes:
>> v2: remove reference to commit 61bd0f66ff92
>> cc stable 5.12
>> add the same comment in the code as for x86
>>
>> arch/powerpc/kvm/book3s_hv.c | 24 ++++++++++++++++++++----
>> 1 file changed, 20 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
>> index 2acb1c96cfaf..a694d1a8f6ce 100644
>> --- a/arch/powerpc/kvm/book3s_hv.c
>> +++ b/arch/powerpc/kvm/book3s_hv.c
> ...
>> @@ -4506,13 +4514,21 @@ int kvmhv_run_single_vcpu(struct kvm_vcpu *vcpu, u64 time_limit,
>>
>> srcu_read_unlock(&kvm->srcu, srcu_idx);
>>
>> + context_tracking_guest_exit();
>> +
>> set_irq_happened(trap);
>>
>> kvmppc_set_host_core(pcpu);
>>
>> - guest_exit_irqoff();
>> -
>> local_irq_enable();
>> + /*
>> + * Wait until after servicing IRQs to account guest time so that any
>> + * ticks that occurred while running the guest are properly accounted
>> + * to the guest. Waiting until IRQs are enabled degrades the accuracy
>> + * of accounting via context tracking, but the loss of accuracy is
>> + * acceptable for all known use cases.
>> + */
>> + vtime_account_guest_exit();
>
> This pops a warning for me, running guest(s) on Power8:
>
> [ 270.745303][T16661] ------------[ cut here ]------------
> [ 270.745374][T16661] WARNING: CPU: 72 PID: 16661 at arch/powerpc/kernel/time.c:311 vtime_account_kernel+0xe0/0xf0
Thank you, I missed that...
My patch is wrong, I have to add vtime_account_guest_exit() before the local_irq_enable().
arch/powerpc/kernel/time.c
305 static unsigned long vtime_delta(struct cpu_accounting_data *acct,
306 unsigned long *stime_scaled,
307 unsigned long *steal_time)
308 {
309 unsigned long now, stime;
310
311 WARN_ON_ONCE(!irqs_disabled());
...
But I don't understand how ticks can be accounted now if irqs are still disabled.
Not sure it is as simple as expected...
Thanks,
Laurent
^ permalink raw reply
* [PATCH v3 2/2] ftrace: do CPU checking after preemption disabled
From: 王贇 @ 2021-10-13 8:52 UTC (permalink / raw)
To: Guo Ren, Steven Rostedt, Ingo Molnar, James E.J. Bottomley,
Helge Deller, Michael Ellerman, Benjamin Herrenschmidt,
Paul Mackerras, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Thomas Gleixner, Borislav Petkov, x86, H. Peter Anvin,
Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Petr Mladek,
Joe Lawrence, Colin Ian King, Masami Hiramatsu,
Peter Zijlstra (Intel), Nicholas Piggin, Jisheng Zhang,
linux-csky, linux-kernel, linux-parisc, linuxppc-dev, linux-riscv,
live-patching
In-Reply-To: <609b565a-ed6e-a1da-f025-166691b5d994@linux.alibaba.com>
With CONFIG_DEBUG_PREEMPT we observed reports like:
BUG: using smp_processor_id() in preemptible
caller is perf_ftrace_function_call+0x6f/0x2e0
CPU: 1 PID: 680 Comm: a.out Not tainted
Call Trace:
<TASK>
dump_stack_lvl+0x8d/0xcf
check_preemption_disabled+0x104/0x110
? optimize_nops.isra.7+0x230/0x230
? text_poke_bp_batch+0x9f/0x310
perf_ftrace_function_call+0x6f/0x2e0
...
__text_poke+0x5/0x620
text_poke_bp_batch+0x9f/0x310
This telling us the CPU could be changed after task is preempted, and
the checking on CPU before preemption will be invalid.
Since now ftrace_test_recursion_trylock() will help to disable the
preemption, this patch just do the checking after trylock() to address
the issue.
CC: Steven Rostedt <rostedt@goodmis.org>
Reported-by: Abaci <abaci@linux.alibaba.com>
Signed-off-by: Michael Wang <yun.wang@linux.alibaba.com>
---
kernel/trace/trace_event_perf.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
index 6aed10e..fba8cb7 100644
--- a/kernel/trace/trace_event_perf.c
+++ b/kernel/trace/trace_event_perf.c
@@ -441,13 +441,13 @@ void perf_trace_buf_update(void *record, u16 type)
if (!rcu_is_watching())
return;
- if ((unsigned long)ops->private != smp_processor_id())
- return;
-
bit = ftrace_test_recursion_trylock(ip, parent_ip);
if (bit < 0)
return;
+ if ((unsigned long)ops->private != smp_processor_id())
+ goto out;
+
event = container_of(ops, struct perf_event, ftrace_ops);
/*
--
1.8.3.1
^ permalink raw reply related
* [PATCH v3 1/2] ftrace: disable preemption between ftrace_test_recursion_trylock/unlock()
From: 王贇 @ 2021-10-13 8:51 UTC (permalink / raw)
To: Guo Ren, Steven Rostedt, Ingo Molnar, James E.J. Bottomley,
Helge Deller, Michael Ellerman, Benjamin Herrenschmidt,
Paul Mackerras, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Thomas Gleixner, Borislav Petkov, x86, H. Peter Anvin,
Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Petr Mladek,
Joe Lawrence, Colin Ian King, Masami Hiramatsu,
Peter Zijlstra (Intel), Nicholas Piggin, Jisheng Zhang,
linux-csky, linux-kernel, linux-parisc, linuxppc-dev, linux-riscv,
live-patching
In-Reply-To: <609b565a-ed6e-a1da-f025-166691b5d994@linux.alibaba.com>
As the documentation explained, ftrace_test_recursion_trylock()
and ftrace_test_recursion_unlock() were supposed to disable and
enable preemption properly, however currently this work is done
outside of the function, which could be missing by mistake.
This path will make sure the preemption was disabled when trylock()
succeed, and the unlock() will enable the preemption if previously
enabled.
CC: Steven Rostedt <rostedt@goodmis.org>
CC: Miroslav Benes <mbenes@suse.cz>
Reported-by: Abaci <abaci@linux.alibaba.com>
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Michael Wang <yun.wang@linux.alibaba.com>
---
arch/csky/kernel/probes/ftrace.c | 2 --
arch/parisc/kernel/ftrace.c | 2 --
arch/powerpc/kernel/kprobes-ftrace.c | 2 --
arch/riscv/kernel/probes/ftrace.c | 2 --
arch/x86/kernel/kprobes/ftrace.c | 2 --
include/linux/trace_recursion.h | 17 ++++++++++++++++-
kernel/livepatch/patch.c | 13 +++++++------
kernel/trace/trace_functions.c | 5 -----
8 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/arch/csky/kernel/probes/ftrace.c b/arch/csky/kernel/probes/ftrace.c
index b388228..834cffc 100644
--- a/arch/csky/kernel/probes/ftrace.c
+++ b/arch/csky/kernel/probes/ftrace.c
@@ -17,7 +17,6 @@ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
return;
regs = ftrace_get_regs(fregs);
- preempt_disable_notrace();
p = get_kprobe((kprobe_opcode_t *)ip);
if (!p) {
p = get_kprobe((kprobe_opcode_t *)(ip - MCOUNT_INSN_SIZE));
@@ -57,7 +56,6 @@ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
__this_cpu_write(current_kprobe, NULL);
}
out:
- preempt_enable_notrace();
ftrace_test_recursion_unlock(bit);
}
NOKPROBE_SYMBOL(kprobe_ftrace_handler);
diff --git a/arch/parisc/kernel/ftrace.c b/arch/parisc/kernel/ftrace.c
index 0a1e75a..3543496 100644
--- a/arch/parisc/kernel/ftrace.c
+++ b/arch/parisc/kernel/ftrace.c
@@ -216,7 +216,6 @@ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
return;
regs = ftrace_get_regs(fregs);
- preempt_disable_notrace();
p = get_kprobe((kprobe_opcode_t *)ip);
if (unlikely(!p) || kprobe_disabled(p))
goto out;
@@ -245,7 +244,6 @@ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
}
__this_cpu_write(current_kprobe, NULL);
out:
- preempt_enable_notrace();
ftrace_test_recursion_unlock(bit);
}
NOKPROBE_SYMBOL(kprobe_ftrace_handler);
diff --git a/arch/powerpc/kernel/kprobes-ftrace.c b/arch/powerpc/kernel/kprobes-ftrace.c
index 7154d58..072ebe7 100644
--- a/arch/powerpc/kernel/kprobes-ftrace.c
+++ b/arch/powerpc/kernel/kprobes-ftrace.c
@@ -26,7 +26,6 @@ void kprobe_ftrace_handler(unsigned long nip, unsigned long parent_nip,
return;
regs = ftrace_get_regs(fregs);
- preempt_disable_notrace();
p = get_kprobe((kprobe_opcode_t *)nip);
if (unlikely(!p) || kprobe_disabled(p))
goto out;
@@ -61,7 +60,6 @@ void kprobe_ftrace_handler(unsigned long nip, unsigned long parent_nip,
__this_cpu_write(current_kprobe, NULL);
}
out:
- preempt_enable_notrace();
ftrace_test_recursion_unlock(bit);
}
NOKPROBE_SYMBOL(kprobe_ftrace_handler);
diff --git a/arch/riscv/kernel/probes/ftrace.c b/arch/riscv/kernel/probes/ftrace.c
index aab85a8..7142ec4 100644
--- a/arch/riscv/kernel/probes/ftrace.c
+++ b/arch/riscv/kernel/probes/ftrace.c
@@ -15,7 +15,6 @@ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
if (bit < 0)
return;
- preempt_disable_notrace();
p = get_kprobe((kprobe_opcode_t *)ip);
if (unlikely(!p) || kprobe_disabled(p))
goto out;
@@ -52,7 +51,6 @@ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
__this_cpu_write(current_kprobe, NULL);
}
out:
- preempt_enable_notrace();
ftrace_test_recursion_unlock(bit);
}
NOKPROBE_SYMBOL(kprobe_ftrace_handler);
diff --git a/arch/x86/kernel/kprobes/ftrace.c b/arch/x86/kernel/kprobes/ftrace.c
index 596de2f..dd2ec14 100644
--- a/arch/x86/kernel/kprobes/ftrace.c
+++ b/arch/x86/kernel/kprobes/ftrace.c
@@ -25,7 +25,6 @@ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
if (bit < 0)
return;
- preempt_disable_notrace();
p = get_kprobe((kprobe_opcode_t *)ip);
if (unlikely(!p) || kprobe_disabled(p))
goto out;
@@ -59,7 +58,6 @@ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
__this_cpu_write(current_kprobe, NULL);
}
out:
- preempt_enable_notrace();
ftrace_test_recursion_unlock(bit);
}
NOKPROBE_SYMBOL(kprobe_ftrace_handler);
diff --git a/include/linux/trace_recursion.h b/include/linux/trace_recursion.h
index a9f9c57..58e474c 100644
--- a/include/linux/trace_recursion.h
+++ b/include/linux/trace_recursion.h
@@ -214,7 +214,18 @@ static __always_inline void trace_clear_recursion(int bit)
static __always_inline int ftrace_test_recursion_trylock(unsigned long ip,
unsigned long parent_ip)
{
- return trace_test_and_set_recursion(ip, parent_ip, TRACE_FTRACE_START, TRACE_FTRACE_MAX);
+ int bit;
+
+ bit = trace_test_and_set_recursion(ip, parent_ip, TRACE_FTRACE_START, TRACE_FTRACE_MAX);
+ /*
+ * The zero bit indicate we are nested
+ * in another trylock(), which means the
+ * preemption already disabled.
+ */
+ if (bit > 0)
+ preempt_disable_notrace();
+
+ return bit;
}
/**
@@ -222,9 +233,13 @@ static __always_inline int ftrace_test_recursion_trylock(unsigned long ip,
* @bit: The return of a successful ftrace_test_recursion_trylock()
*
* This is used at the end of a ftrace callback.
+ *
+ * Preemption will be enabled (if it was previously enabled).
*/
static __always_inline void ftrace_test_recursion_unlock(int bit)
{
+ if (bit)
+ preempt_enable_notrace();
trace_clear_recursion(bit);
}
diff --git a/kernel/livepatch/patch.c b/kernel/livepatch/patch.c
index e8029ae..b8d75fb 100644
--- a/kernel/livepatch/patch.c
+++ b/kernel/livepatch/patch.c
@@ -49,14 +49,16 @@ static void notrace klp_ftrace_handler(unsigned long ip,
ops = container_of(fops, struct klp_ops, fops);
+ /*
+ *
+ * The ftrace_test_recursion_trylock() will disable preemption,
+ * which is required for the variant of synchronize_rcu() that is
+ * used to allow patching functions where RCU is not watching.
+ * See klp_synchronize_transition() for more details.
+ */
bit = ftrace_test_recursion_trylock(ip, parent_ip);
if (WARN_ON_ONCE(bit < 0))
return;
- /*
- * A variant of synchronize_rcu() is used to allow patching functions
- * where RCU is not watching, see klp_synchronize_transition().
- */
- preempt_disable_notrace();
func = list_first_or_null_rcu(&ops->func_stack, struct klp_func,
stack_node);
@@ -120,7 +122,6 @@ static void notrace klp_ftrace_handler(unsigned long ip,
klp_arch_set_pc(fregs, (unsigned long)func->new_func);
unlock:
- preempt_enable_notrace();
ftrace_test_recursion_unlock(bit);
}
diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c
index 1f0e63f..9f1bfbe 100644
--- a/kernel/trace/trace_functions.c
+++ b/kernel/trace/trace_functions.c
@@ -186,7 +186,6 @@ static void function_trace_start(struct trace_array *tr)
return;
trace_ctx = tracing_gen_ctx();
- preempt_disable_notrace();
cpu = smp_processor_id();
data = per_cpu_ptr(tr->array_buffer.data, cpu);
@@ -194,7 +193,6 @@ static void function_trace_start(struct trace_array *tr)
trace_function(tr, ip, parent_ip, trace_ctx);
ftrace_test_recursion_unlock(bit);
- preempt_enable_notrace();
}
#ifdef CONFIG_UNWINDER_ORC
@@ -298,8 +296,6 @@ static inline void process_repeats(struct trace_array *tr,
if (bit < 0)
return;
- preempt_disable_notrace();
-
cpu = smp_processor_id();
data = per_cpu_ptr(tr->array_buffer.data, cpu);
if (atomic_read(&data->disabled))
@@ -324,7 +320,6 @@ static inline void process_repeats(struct trace_array *tr,
out:
ftrace_test_recursion_unlock(bit);
- preempt_enable_notrace();
}
static void
--
1.8.3.1
^ permalink raw reply related
* [PATCH v3 0/2] fix & prevent the missing preemption disabling
From: 王贇 @ 2021-10-13 8:51 UTC (permalink / raw)
To: Guo Ren, Steven Rostedt, Ingo Molnar, James E.J. Bottomley,
Helge Deller, Michael Ellerman, Benjamin Herrenschmidt,
Paul Mackerras, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Thomas Gleixner, Borislav Petkov, x86, H. Peter Anvin,
Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Petr Mladek,
Joe Lawrence, Colin Ian King, Masami Hiramatsu,
Peter Zijlstra (Intel), Nicholas Piggin, Jisheng Zhang,
linux-csky, linux-kernel, linux-parisc, linuxppc-dev, linux-riscv,
live-patching
The testing show that perf_ftrace_function_call() are using smp_processor_id()
with preemption enabled, all the checking on CPU could be wrong after preemption.
As Peter point out, the section between ftrace_test_recursion_trylock/unlock()
pair require the preemption to be disabled as 'Documentation/trace/ftrace-uses.rst'
explained, but currently the work is done outside of the helpers.
Patch 1/2 will make sure preemption disabled after trylock() succeed,
patch 2/2 will do smp_processor_id() checking after trylock to address the
issue.
v1: https://lore.kernel.org/all/8c7de46d-9869-aa5e-2bb9-5dbc2eda395e@linux.alibaba.com/
v2: https://lore.kernel.org/all/b1d7fe43-ce84-0ed7-32f7-ea1d12d0b716@linux.alibaba.com/
Michael Wang (2):
ftrace: disable preemption between ftrace_test_recursion_trylock/unlock()
ftrace: do CPU checking after preemption disabled
arch/csky/kernel/probes/ftrace.c | 2 --
arch/parisc/kernel/ftrace.c | 2 --
arch/powerpc/kernel/kprobes-ftrace.c | 2 --
arch/riscv/kernel/probes/ftrace.c | 2 --
arch/x86/kernel/kprobes/ftrace.c | 2 --
include/linux/trace_recursion.h | 17 ++++++++++++++++-
kernel/livepatch/patch.c | 13 +++++++------
kernel/trace/trace_event_perf.c | 6 +++---
kernel/trace/trace_functions.c | 5 -----
9 files changed, 26 insertions(+), 25 deletions(-)
--
1.8.3.1
^ permalink raw reply
* Re: [RESEND PATCH v2 1/2] ftrace: disable preemption between ftrace_test_recursion_trylock/unlock()
From: 王贇 @ 2021-10-13 8:34 UTC (permalink / raw)
To: Miroslav Benes
Cc: Peter Zijlstra (Intel), Paul Walmsley, James E.J. Bottomley,
Guo Ren, Jisheng Zhang, H. Peter Anvin, live-patching,
linux-riscv, Paul Mackerras, Joe Lawrence, Helge Deller, x86,
linux-csky, Ingo Molnar, Petr Mladek, Albert Ou, Jiri Kosina,
Steven Rostedt, Borislav Petkov, Nicholas Piggin, Josh Poimboeuf,
Thomas Gleixner, linux-parisc, linux-kernel, Palmer Dabbelt,
Masami Hiramatsu, Colin Ian King, linuxppc-dev
In-Reply-To: <alpine.LSU.2.21.2110131022590.5647@pobox.suse.cz>
On 2021/10/13 下午4:25, Miroslav Benes wrote:
>>> Side note... the comment will eventually conflict with peterz's
>>> https://lore.kernel.org/all/20210929152429.125997206@infradead.org/.
>>
>> Steven, would you like to share your opinion on this patch?
>>
>> If klp_synchronize_transition() will be removed anyway, the comments
>> will be meaningless and we can just drop it :-P
>
> The comment will still be needed in some form. We will handle it depending
> on what gets merged first. peterz's patches are not ready yet.
Ok, then I'll move it before trylock() inside klp_ftrace_handler() anyway.
Regards,
Michael Wang
>
> Miroslav
>
^ permalink raw reply
* Re: [RESEND PATCH v2 1/2] ftrace: disable preemption between ftrace_test_recursion_trylock/unlock()
From: Miroslav Benes @ 2021-10-13 8:25 UTC (permalink / raw)
To: 王贇
Cc: Peter Zijlstra (Intel), Paul Walmsley, James E.J. Bottomley,
Guo Ren, Jisheng Zhang, H. Peter Anvin, live-patching,
linux-riscv, Paul Mackerras, Joe Lawrence, Helge Deller, x86,
linux-csky, Ingo Molnar, Petr Mladek, Albert Ou, Jiri Kosina,
Steven Rostedt, Borislav Petkov, Nicholas Piggin, Josh Poimboeuf,
Thomas Gleixner, linux-parisc, linux-kernel, Palmer Dabbelt,
Masami Hiramatsu, Colin Ian King, linuxppc-dev
In-Reply-To: <d5fbd49a-55c5-a9f5-6600-707c8d749312@linux.alibaba.com>
> > Side note... the comment will eventually conflict with peterz's
> > https://lore.kernel.org/all/20210929152429.125997206@infradead.org/.
>
> Steven, would you like to share your opinion on this patch?
>
> If klp_synchronize_transition() will be removed anyway, the comments
> will be meaningless and we can just drop it :-P
The comment will still be needed in some form. We will handle it depending
on what gets merged first. peterz's patches are not ready yet.
Miroslav
^ permalink raw reply
* Re: [PATCH] powerpc: don't select KFENCE on platform PPC_FSL_BOOK3E
From: Christophe Leroy @ 2021-10-13 8:16 UTC (permalink / raw)
To: Michael Ellerman, Liu Shixin, Marco Elver, Benjamin Herrenschmidt,
Paul Mackerras
Cc: linuxppc-dev, linux-kernel
In-Reply-To: <8735p57nsb.fsf@mpe.ellerman.id.au>
Le 13/10/2021 à 02:48, Michael Ellerman a écrit :
> Christophe Leroy <christophe.leroy@csgroup.eu> writes:
>> Le 12/10/2021 à 08:24, Michael Ellerman a écrit :
>>> Liu Shixin <liushixin2@huawei.com> writes:
>>>> kindly ping.
>>>
>>> I was under the impression you were trying to debug why it wasn't
>>> working with Christophe.
>>
>> The investigation was a bit dormant to be honest since Liu confirmed
>> that neither KFENCE not DEBUG_PAGEALLOC works.
>
> No worries. Sorry it fell to you to do the investigation.
No problem.
>
>> I now looked at the effort to make it work, and it is not trivial.
>> At the time being, all linear space is mapped with pinned TLBs and
>> everything is setup for space 0, with space 1 being used temporarily
>> when doing heavy changes to space 0.
>>
>> We can't use standard pages for linear space on space 0 because we need
>> memory mapped at all time for exceptions (on booke exception run with
>> MMU on in space 0).
>>
>> In order to use standard pages, we'd need to reorganise the kernel to
>> have it run mostly in space 1 (for data at least) where we would map
>> almost everything with standard pages, and keep pinned TLB to map linear
>> space on space 0 for TLB miss exceptions. Then we'd do more or less like
>> book3s/32 and switch back into space 1 into other exceptions prolog.
>>
>> That could be good to do it as we could maybe have more code in common
>> with non booke 32 bits, but it is not a trivial job.
>>
>> So I suggest that for now, we just make KFENCE and DEBUG_PAGEALLOC
>> unselectable for booke/32 (e500 and 44x).
>
> Yep seems reasonable.
>
We also have a problem with STRICT_KERNEL_RWX as it is based on the same
principles until someone implements it by blocks like book3s/32 and 8xx.
So it should also be unselectable on e500 and 44x for now.
Christophe
^ permalink raw reply
* Re: [RESEND PATCH v2 1/2] ftrace: disable preemption between ftrace_test_recursion_trylock/unlock()
From: 王贇 @ 2021-10-13 8:11 UTC (permalink / raw)
To: Miroslav Benes
Cc: Peter Zijlstra (Intel), Paul Walmsley, James E.J. Bottomley,
Guo Ren, Jisheng Zhang, H. Peter Anvin, live-patching,
linux-riscv, Paul Mackerras, Joe Lawrence, Helge Deller, x86,
linux-csky, Ingo Molnar, Petr Mladek, Albert Ou, Jiri Kosina,
Steven Rostedt, Borislav Petkov, Nicholas Piggin, Josh Poimboeuf,
Thomas Gleixner, linux-parisc, linux-kernel, Palmer Dabbelt,
Masami Hiramatsu, Colin Ian King, linuxppc-dev
In-Reply-To: <alpine.LSU.2.21.2110130948120.5647@pobox.suse.cz>
On 2021/10/13 下午3:55, Miroslav Benes wrote:
>> diff --git a/include/linux/trace_recursion.h b/include/linux/trace_recursion.h
>> index a9f9c57..101e1fb 100644
>> --- a/include/linux/trace_recursion.h
>> +++ b/include/linux/trace_recursion.h
>> @@ -208,13 +208,29 @@ static __always_inline void trace_clear_recursion(int bit)
>> * Use this for ftrace callbacks. This will detect if the function
>> * tracing recursed in the same context (normal vs interrupt),
>> *
>> + * The ftrace_test_recursion_trylock() will disable preemption,
>> + * which is required for the variant of synchronize_rcu() that is
>> + * used to allow patching functions where RCU is not watching.
>> + * See klp_synchronize_transition() for more details.
>> + *
>
> I think that you misunderstood. Steven proposed to put the comment before
> ftrace_test_recursion_trylock() call site in klp_ftrace_handler().
Oh, I see... thanks for pointing out :-)
>
>> * Returns: -1 if a recursion happened.
[snip]
>> }
>
> Side note... the comment will eventually conflict with peterz's
> https://lore.kernel.org/all/20210929152429.125997206@infradead.org/.
Steven, would you like to share your opinion on this patch?
If klp_synchronize_transition() will be removed anyway, the comments
will be meaningless and we can just drop it :-P
Regards,
Michael Wang
>
> Miroslav
>
^ permalink raw reply
* Re: [PATCH v2 00/11] Add Apple M1 support to PASemi i2c driver
From: Christian Zigotzky @ 2021-10-13 8:06 UTC (permalink / raw)
To: Wolfram Sang, Sven Peter, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Olof Johansson,
Arnd Bergmann, Hector Martin, Mohamed Mediouni, Stan Skowronek,
Mark Kettenis, Alyssa Rosenzweig, linux-arm-kernel, linuxppc-dev,
linux-i2c, linux-kernel, R.T.Dickinson, Matthew Leaman,
Darren Stevens
In-Reply-To: <8a8afc73-3756-a305-ce5f-70b4bce6999f@xenosoft.de>
On 09 October 2021 at 03:57 pm, Christian Zigotzky wrote:
> On 09 October 2021 at 12:10 pm, Wolfram Sang wrote:
>>> I still don't have access to any old PASemi hardware but the
changes from
>>> v1 are pretty small and I expect them to still work. Would still be
nice
>>> if someone with access to such hardware could give this a quick test.
>> Looks good to me. I will wait a few more days so that people can report
>> their tests. But it will be in the next merge window.
>>
> Series v2:
>
> Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de> [1]
>
> - Christian
>
> [1]
https://forum.hyperion-entertainment.com/viewtopic.php?p=54213#p54213
Series v2:
Tested-by: Damien Stewart (Hypex) [1]
- Christian
[1] https://forum.hyperion-entertainment.com/viewtopic.php?p=54217#p54217
^ 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