Re: [PATCH 11/13] powerpc: Implement architecture specific KMSAN interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Le 14/12/2023 à 06:55, Nicholas Miehlbradt a écrit :
> arch_kmsan_get_meta_or_null finds the metadata addresses for addresses
> in the ioremap region which is mapped separately on powerpc.
> 
> kmsan_vir_addr_valid is the same as virt_addr_valid except excludes the
> check that addr is less than high_memory since this function can be
> called on addresses higher than this.
> 
> Signed-off-by: Nicholas Miehlbradt <nicholas@xxxxxxxxxxxxx>
> ---
>   arch/powerpc/include/asm/kmsan.h | 44 ++++++++++++++++++++++++++++++++
>   1 file changed, 44 insertions(+)
>   create mode 100644 arch/powerpc/include/asm/kmsan.h
> 
> diff --git a/arch/powerpc/include/asm/kmsan.h b/arch/powerpc/include/asm/kmsan.h
> new file mode 100644
> index 000000000000..bc84f6ff2ee9
> --- /dev/null
> +++ b/arch/powerpc/include/asm/kmsan.h
> @@ -0,0 +1,44 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * powerpc KMSAN support.
> + *
> + */
> +
> +#ifndef _ASM_POWERPC_KMSAN_H
> +#define _ASM_POWERPC_KMSAN_H
> +
> +#ifndef __ASSEMBLY__
> +#ifndef MODULE
> +
> +#include <linux/mmzone.h>
> +#include <asm/page.h>
> +#include <asm/book3s/64/pgtable.h>
> +
> +/*
> + * Functions below are declared in the header to make sure they are inlined.
> + * They all are called from kmsan_get_metadata() for every memory access in
> + * the kernel, so speed is important here.
> + */
> +
> +/*
> + * No powerpc specific metadata locations
> + */
> +static inline void *arch_kmsan_get_meta_or_null(void *addr, bool is_origin)
> +{
> +	unsigned long addr64 = (unsigned long)addr, off;

Missing blank line.

> +	if (KERN_IO_START <= addr64 && addr64 < KERN_IO_END) {

off is only used in that block so it should be declared here, can be 
done as a single line (followed by a blank line too):

	unsigned long off = addr64 - KERN_IO_START;

> +		off = addr64 - KERN_IO_START;
> +		return (void *)off + (is_origin ? KERN_IO_ORIGIN_START : KERN_IO_SHADOW_START);
> +	} else {
> +		return 0;
> +	}
> +}
> +
> +static inline bool kmsan_virt_addr_valid(void *addr)
> +{
> +	return (unsigned long)addr >= PAGE_OFFSET && pfn_valid(virt_to_pfn(addr));
> +}
> +
> +#endif /* !MODULE */
> +#endif /* !__ASSEMBLY__ */
> +#endif /* _ASM_POWERPC_KMSAN_H */




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux