LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v5 2/3] KVM: PPC: Book3S HV: Add support for H_RPT_INVALIDATE
From: David Gibson @ 2021-03-02  1:45 UTC (permalink / raw)
  To: Bharata B Rao; +Cc: farosas, aneesh.kumar, npiggin, kvm-ppc, linuxppc-dev
In-Reply-To: <20210224082510.3962423-3-bharata@linux.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 20757 bytes --]

On Wed, Feb 24, 2021 at 01:55:09PM +0530, Bharata B Rao wrote:
> Implement H_RPT_INVALIDATE hcall and add KVM capability
> KVM_CAP_PPC_RPT_INVALIDATE to indicate the support for the same.
> 
> This hcall does two types of TLB invalidations:
> 
> 1. Process-scoped invalidations for guests with LPCR[GTSE]=0.
>    This is currently not used in KVM as GTSE is not usually
>    disabled in KVM.
> 2. Partition-scoped invalidations that an L1 hypervisor does on
>    behalf of an L2 guest. This replaces the uses of the existing
>    hcall H_TLB_INVALIDATE.
> 
> In order to handle process scoped invalidations of L2, we
> intercept the nested exit handling code in L0 only to handle
> H_TLB_INVALIDATE hcall.
> 
> Process scoped tlbie invalidations from L1 and nested guests
> need RS register for TLBIE instruction to contain both PID and
> LPID.  This patch introduces primitives that execute tlbie
> instruction with both PID and LPID set in prepartion for
> H_RPT_INVALIDATE hcall.
> 
> Signed-off-by: Bharata B Rao <bharata@linux.ibm.com>
> ---
>  Documentation/virt/kvm/api.rst                |  18 +++
>  .../include/asm/book3s/64/tlbflush-radix.h    |   4 +
>  arch/powerpc/include/asm/kvm_book3s.h         |   3 +
>  arch/powerpc/include/asm/mmu_context.h        |  11 ++
>  arch/powerpc/kvm/book3s_hv.c                  |  90 +++++++++++
>  arch/powerpc/kvm/book3s_hv_nested.c           |  77 +++++++++
>  arch/powerpc/kvm/powerpc.c                    |   3 +
>  arch/powerpc/mm/book3s64/radix_tlb.c          | 147 +++++++++++++++++-
>  include/uapi/linux/kvm.h                      |   1 +
>  9 files changed, 350 insertions(+), 4 deletions(-)
> 
> diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
> index 45fd862ac128..38ce3f21b21f 100644
> --- a/Documentation/virt/kvm/api.rst
> +++ b/Documentation/virt/kvm/api.rst
> @@ -6225,6 +6225,24 @@ KVM_RUN_BUS_LOCK flag is used to distinguish between them.
>  This capability can be used to check / enable 2nd DAWR feature provided
>  by POWER10 processor.
>  
> +7.23 KVM_CAP_PPC_RPT_INVALIDATE
> +------------------------------
> +
> +:Capability: KVM_CAP_PPC_RPT_INVALIDATE
> +:Architectures: ppc
> +:Type: vm
> +
> +This capability indicates that the kernel is capable of handling
> +H_RPT_INVALIDATE hcall.
> +
> +In order to enable the use of H_RPT_INVALIDATE in the guest,
> +user space might have to advertise it for the guest. For example,
> +IBM pSeries (sPAPR) guest starts using it if "hcall-rpt-invalidate" is
> +present in the "ibm,hypertas-functions" device-tree property.
> +
> +This capability is enabled for hypervisors on platforms like POWER9
> +that support radix MMU.

Does this mean that KVM will handle the hypercall, even if not
explicitly enabled by userspace (qemu)?  That's generally not what we
want, since we need to allow qemu to set up backwards compatible
guests.

> +
>  8. Other capabilities.
>  ======================
>  
> diff --git a/arch/powerpc/include/asm/book3s/64/tlbflush-radix.h b/arch/powerpc/include/asm/book3s/64/tlbflush-radix.h
> index 8b33601cdb9d..a46fd37ad552 100644
> --- a/arch/powerpc/include/asm/book3s/64/tlbflush-radix.h
> +++ b/arch/powerpc/include/asm/book3s/64/tlbflush-radix.h
> @@ -4,6 +4,10 @@
>  
>  #include <asm/hvcall.h>
>  
> +#define RIC_FLUSH_TLB 0
> +#define RIC_FLUSH_PWC 1
> +#define RIC_FLUSH_ALL 2
> +
>  struct vm_area_struct;
>  struct mm_struct;
>  struct mmu_gather;
> diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h
> index 2f5f919f6cd3..a1515f94400e 100644
> --- a/arch/powerpc/include/asm/kvm_book3s.h
> +++ b/arch/powerpc/include/asm/kvm_book3s.h
> @@ -305,6 +305,9 @@ void kvmhv_set_ptbl_entry(unsigned int lpid, u64 dw0, u64 dw1);
>  void kvmhv_release_all_nested(struct kvm *kvm);
>  long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu);
>  long kvmhv_do_nested_tlbie(struct kvm_vcpu *vcpu);
> +long kvmhv_h_rpti_nested(struct kvm_vcpu *vcpu, unsigned long lpid,
> +			 unsigned long type, unsigned long pg_sizes,
> +			 unsigned long start, unsigned long end);
>  int kvmhv_run_single_vcpu(struct kvm_vcpu *vcpu,
>  			  u64 time_limit, unsigned long lpcr);
>  void kvmhv_save_hv_regs(struct kvm_vcpu *vcpu, struct hv_guest_state *hr);
> diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h
> index 652ce85f9410..820caf4e01b7 100644
> --- a/arch/powerpc/include/asm/mmu_context.h
> +++ b/arch/powerpc/include/asm/mmu_context.h
> @@ -124,8 +124,19 @@ static inline bool need_extra_context(struct mm_struct *mm, unsigned long ea)
>  
>  #if defined(CONFIG_KVM_BOOK3S_HV_POSSIBLE) && defined(CONFIG_PPC_RADIX_MMU)
>  extern void radix_kvm_prefetch_workaround(struct mm_struct *mm);
> +void do_h_rpt_invalidate(unsigned long pid, unsigned long lpid,
> +			 unsigned long type, unsigned long page_size,
> +			 unsigned long psize, unsigned long start,
> +			 unsigned long end);
>  #else
>  static inline void radix_kvm_prefetch_workaround(struct mm_struct *mm) { }
> +static inline void do_h_rpt_invalidate(unsigned long pid,
> +				       unsigned long lpid,
> +				       unsigned long type,
> +				       unsigned long page_size,
> +				       unsigned long psize,
> +				       unsigned long start,
> +				       unsigned long end) { }
>  #endif
>  
>  extern void switch_cop(struct mm_struct *next);
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index 13bad6bf4c95..d83f006fc19d 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -921,6 +921,69 @@ static int kvmppc_get_yield_count(struct kvm_vcpu *vcpu)
>  	return yield_count;
>  }
>  
> +static void do_h_rpt_invalidate_prs(unsigned long pid, unsigned long lpid,
> +				    unsigned long type, unsigned long pg_sizes,
> +				    unsigned long start, unsigned long end)
> +{
> +	unsigned long psize;
> +	struct mmu_psize_def *def;
> +
> +	for (psize = 0; psize < MMU_PAGE_COUNT; psize++) {
> +		def = &mmu_psize_defs[psize];
> +		if (pg_sizes & def->h_rpt_pgsize)
> +			do_h_rpt_invalidate(pid, lpid, type,
> +					    (1UL << def->shift), psize,
> +					    start, end);
> +	}
> +}
> +
> +static void kvmppc_nested_rpt_invalidate(struct kvm_vcpu *vcpu)
> +{
> +	do_h_rpt_invalidate_prs(kvmppc_get_gpr(vcpu, 4),
> +				vcpu->arch.nested->shadow_lpid,
> +				kvmppc_get_gpr(vcpu, 5),
> +				kvmppc_get_gpr(vcpu, 6),
> +				kvmppc_get_gpr(vcpu, 7),
> +				kvmppc_get_gpr(vcpu, 8));
> +	kvmppc_set_gpr(vcpu, 3, H_SUCCESS);
> +}
> +
> +static long kvmppc_h_rpt_invalidate(struct kvm_vcpu *vcpu,
> +				    unsigned long pid, unsigned long target,
> +				    unsigned long type, unsigned long pg_sizes,
> +				    unsigned long start, unsigned long end)
> +{
> +	if (!kvm_is_radix(vcpu->kvm))
> +		return H_UNSUPPORTED;
> +
> +	/*
> +	 * For nested guests, this hcall is handled in
> +	 * L0. See kvmppc_handle_nested_exit() for details.
> +	 */
> +	if (kvmhv_on_pseries())
> +		return H_UNSUPPORTED;
> +
> +	if (end < start)
> +		return H_P5;
> +
> +	if (type & H_RPTI_TYPE_NESTED) {
> +		if (!nesting_enabled(vcpu->kvm))
> +			return H_FUNCTION;
> +
> +		/* Support only cores as target */
> +		if (target != H_RPTI_TARGET_CMMU)
> +			return H_P2;
> +

IIUC, we'll hit this code path if an L1 calls this on behalf of an L2,
whereas we'll hit the nested exit code path going straight to
kvmhv_h_rpti_nested() if an L2 calls it on behalf of an L3.  Is that
right?

> +		return kvmhv_h_rpti_nested(vcpu, pid,
> +					   (type & ~H_RPTI_TYPE_NESTED),
> +					    pg_sizes, start, end);
> +	}
> +
> +	do_h_rpt_invalidate_prs(pid, vcpu->kvm->arch.lpid, type, pg_sizes,
> +				start, end);
> +	return H_SUCCESS;
> +}
> +
>  int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu)
>  {
>  	unsigned long req = kvmppc_get_gpr(vcpu, 3);
> @@ -1129,6 +1192,14 @@ int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu)
>  		 */
>  		ret = kvmppc_h_svm_init_abort(vcpu->kvm);
>  		break;
> +	case H_RPT_INVALIDATE:
> +		ret = kvmppc_h_rpt_invalidate(vcpu, kvmppc_get_gpr(vcpu, 4),
> +					      kvmppc_get_gpr(vcpu, 5),
> +					      kvmppc_get_gpr(vcpu, 6),
> +					      kvmppc_get_gpr(vcpu, 7),
> +					      kvmppc_get_gpr(vcpu, 8),
> +					      kvmppc_get_gpr(vcpu, 9));
> +		break;
>  
>  	default:
>  		return RESUME_HOST;
> @@ -1175,6 +1246,7 @@ static int kvmppc_hcall_impl_hv(unsigned long cmd)
>  	case H_XIRR_X:
>  #endif
>  	case H_PAGE_INIT:
> +	case H_RPT_INVALIDATE:
>  		return 1;
>  	}
>  
> @@ -1590,6 +1662,24 @@ static int kvmppc_handle_nested_exit(struct kvm_vcpu *vcpu)
>  		if (!xics_on_xive())
>  			kvmppc_xics_rm_complete(vcpu, 0);
>  		break;
> +	case BOOK3S_INTERRUPT_SYSCALL:
> +	{
> +		unsigned long req = kvmppc_get_gpr(vcpu, 3);
> +
> +		/*
> +		 * The H_RPT_INVALIDATE hcalls issued by nested
> +		 * guests for process scoped invalidations when
> +		 * GTSE=0, are handled here in L0.
> +		 */

What if the L2 is not calling this for the GTSE=0 case, but on behalf
of an L3?

> +		if (req == H_RPT_INVALIDATE) {
> +			kvmppc_nested_rpt_invalidate(vcpu);
> +			r = RESUME_GUEST;
> +			break;
> +		}
> +
> +		r = RESUME_HOST;
> +		break;
> +	}
>  	default:
>  		r = RESUME_HOST;
>  		break;
> diff --git a/arch/powerpc/kvm/book3s_hv_nested.c b/arch/powerpc/kvm/book3s_hv_nested.c
> index 0cd0e7aad588..ca43b2d38dce 100644
> --- a/arch/powerpc/kvm/book3s_hv_nested.c
> +++ b/arch/powerpc/kvm/book3s_hv_nested.c
> @@ -1191,6 +1191,83 @@ long kvmhv_do_nested_tlbie(struct kvm_vcpu *vcpu)
>  	return H_SUCCESS;
>  }
>  
> +static long do_tlb_invalidate_nested_tlb(struct kvm_vcpu *vcpu,
> +					 unsigned long lpid,
> +					 unsigned long page_size,
> +					 unsigned long ap,
> +					 unsigned long start,
> +					 unsigned long end)
> +{
> +	unsigned long addr = start;
> +	int ret;
> +
> +	do {
> +		ret = kvmhv_emulate_tlbie_tlb_addr(vcpu, lpid, ap,
> +						   get_epn(addr));
> +		if (ret)
> +			return ret;
> +		addr += page_size;
> +	} while (addr < end);
> +
> +	return ret;
> +}
> +
> +static long do_tlb_invalidate_nested_all(struct kvm_vcpu *vcpu,
> +					 unsigned long lpid)
> +{
> +	struct kvm *kvm = vcpu->kvm;
> +	struct kvm_nested_guest *gp;
> +
> +	gp = kvmhv_get_nested(kvm, lpid, false);
> +	if (gp) {
> +		kvmhv_emulate_tlbie_lpid(vcpu, gp, RIC_FLUSH_ALL);
> +		kvmhv_put_nested(gp);
> +	}
> +	return H_SUCCESS;
> +}
> +
> +long kvmhv_h_rpti_nested(struct kvm_vcpu *vcpu, unsigned long lpid,
> +			 unsigned long type, unsigned long pg_sizes,
> +			 unsigned long start, unsigned long end)
> +{
> +	struct kvm_nested_guest *gp;
> +	long ret;
> +	unsigned long psize, ap;
> +
> +	/*
> +	 * If L2 lpid isn't valid, we need to return H_PARAMETER.
> +	 *
> +	 * However, nested KVM issues a L2 lpid flush call when creating
> +	 * partition table entries for L2. This happens even before the
> +	 * corresponding shadow lpid is created in HV which happens in
> +	 * H_ENTER_NESTED call. Since we can't differentiate this case from
> +	 * the invalid case, we ignore such flush requests and return success.
> +	 */

What if this is being called on behalf of an L3 or deeper?  Do we need
something to do a translation from L3 to L2 addresses?

> +	gp = kvmhv_find_nested(vcpu->kvm, lpid);
> +	if (!gp)
> +		return H_SUCCESS;
> +
> +	if ((type & H_RPTI_TYPE_NESTED_ALL) == H_RPTI_TYPE_NESTED_ALL)
> +		return do_tlb_invalidate_nested_all(vcpu, lpid);
> +
> +	if ((type & H_RPTI_TYPE_TLB) == H_RPTI_TYPE_TLB) {
> +		struct mmu_psize_def *def;
> +
> +		for (psize = 0; psize < MMU_PAGE_COUNT; psize++) {
> +			def = &mmu_psize_defs[psize];
> +			if (!(pg_sizes & def->h_rpt_pgsize))
> +				continue;
> +
> +			ret = do_tlb_invalidate_nested_tlb(vcpu, lpid,
> +							   (1UL << def->shift),
> +							   ap, start, end);
> +			if (ret)
> +				return H_P4;
> +		}
> +	}
> +	return H_SUCCESS;
> +}
> +
>  /* Used to convert a nested guest real address to a L1 guest real address */
>  static int kvmhv_translate_addr_nested(struct kvm_vcpu *vcpu,
>  				       struct kvm_nested_guest *gp,
> diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
> index a2a68a958fa0..be33b5321a76 100644
> --- a/arch/powerpc/kvm/powerpc.c
> +++ b/arch/powerpc/kvm/powerpc.c
> @@ -682,6 +682,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
>  		r = !!(hv_enabled && kvmppc_hv_ops->enable_dawr1 &&
>  		       !kvmppc_hv_ops->enable_dawr1(NULL));
>  		break;
> +	case KVM_CAP_PPC_RPT_INVALIDATE:
> +		r = 1;
> +		break;
>  #endif
>  	default:
>  		r = 0;
> diff --git a/arch/powerpc/mm/book3s64/radix_tlb.c b/arch/powerpc/mm/book3s64/radix_tlb.c
> index 409e61210789..440d84fffa8c 100644
> --- a/arch/powerpc/mm/book3s64/radix_tlb.c
> +++ b/arch/powerpc/mm/book3s64/radix_tlb.c
> @@ -20,10 +20,6 @@
>  
>  #include "internal.h"
>  
> -#define RIC_FLUSH_TLB 0
> -#define RIC_FLUSH_PWC 1
> -#define RIC_FLUSH_ALL 2
> -
>  /*
>   * tlbiel instruction for radix, set invalidation
>   * i.e., r=1 and is=01 or is=10 or is=11
> @@ -130,6 +126,21 @@ static __always_inline void __tlbie_pid(unsigned long pid, unsigned long ric)
>  	trace_tlbie(0, 0, rb, rs, ric, prs, r);
>  }
>  
> +static __always_inline void __tlbie_pid_lpid(unsigned long pid,
> +					     unsigned long lpid,
> +					     unsigned long ric)
> +{
> +	unsigned long rb, rs, prs, r;
> +
> +	rb = PPC_BIT(53); /* IS = 1 */
> +	rs = (pid << PPC_BITLSHIFT(31)) | (lpid & ~(PPC_BITMASK(0, 31)));
> +	prs = 1; /* process scoped */
> +	r = 1;   /* radix format */
> +
> +	asm volatile(PPC_TLBIE_5(%0, %4, %3, %2, %1)
> +		     : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory");
> +	trace_tlbie(0, 0, rb, rs, ric, prs, r);
> +}
>  static __always_inline void __tlbie_lpid(unsigned long lpid, unsigned long ric)
>  {
>  	unsigned long rb,rs,prs,r;
> @@ -190,6 +201,23 @@ static __always_inline void __tlbie_va(unsigned long va, unsigned long pid,
>  	trace_tlbie(0, 0, rb, rs, ric, prs, r);
>  }
>  
> +static __always_inline void __tlbie_va_lpid(unsigned long va, unsigned long pid,
> +					    unsigned long lpid,
> +					    unsigned long ap, unsigned long ric)
> +{
> +	unsigned long rb, rs, prs, r;
> +
> +	rb = va & ~(PPC_BITMASK(52, 63));
> +	rb |= ap << PPC_BITLSHIFT(58);
> +	rs = (pid << PPC_BITLSHIFT(31)) | (lpid & ~(PPC_BITMASK(0, 31)));
> +	prs = 1; /* process scoped */
> +	r = 1;   /* radix format */
> +
> +	asm volatile(PPC_TLBIE_5(%0, %4, %3, %2, %1)
> +		     : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory");
> +	trace_tlbie(0, 0, rb, rs, ric, prs, r);
> +}
> +
>  static __always_inline void __tlbie_lpid_va(unsigned long va, unsigned long lpid,
>  					    unsigned long ap, unsigned long ric)
>  {
> @@ -235,6 +263,22 @@ static inline void fixup_tlbie_va_range(unsigned long va, unsigned long pid,
>  	}
>  }
>  
> +static inline void fixup_tlbie_va_range_lpid(unsigned long va,
> +					     unsigned long pid,
> +					     unsigned long lpid,
> +					     unsigned long ap)
> +{
> +	if (cpu_has_feature(CPU_FTR_P9_TLBIE_ERAT_BUG)) {
> +		asm volatile("ptesync" : : : "memory");
> +		__tlbie_pid_lpid(0, lpid, RIC_FLUSH_TLB);
> +	}
> +
> +	if (cpu_has_feature(CPU_FTR_P9_TLBIE_STQ_BUG)) {
> +		asm volatile("ptesync" : : : "memory");
> +		__tlbie_va_lpid(va, pid, lpid, ap, RIC_FLUSH_TLB);
> +	}
> +}
> +
>  static inline void fixup_tlbie_pid(unsigned long pid)
>  {
>  	/*
> @@ -254,6 +298,25 @@ static inline void fixup_tlbie_pid(unsigned long pid)
>  	}
>  }
>  
> +static inline void fixup_tlbie_pid_lpid(unsigned long pid, unsigned long lpid)
> +{
> +	/*
> +	 * We can use any address for the invalidation, pick one which is
> +	 * probably unused as an optimisation.
> +	 */
> +	unsigned long va = ((1UL << 52) - 1);
> +
> +	if (cpu_has_feature(CPU_FTR_P9_TLBIE_ERAT_BUG)) {
> +		asm volatile("ptesync" : : : "memory");
> +		__tlbie_pid_lpid(0, lpid, RIC_FLUSH_TLB);
> +	}
> +
> +	if (cpu_has_feature(CPU_FTR_P9_TLBIE_STQ_BUG)) {
> +		asm volatile("ptesync" : : : "memory");
> +		__tlbie_va_lpid(va, pid, lpid, mmu_get_ap(MMU_PAGE_64K),
> +				RIC_FLUSH_TLB);
> +	}
> +}
>  
>  static inline void fixup_tlbie_lpid_va(unsigned long va, unsigned long lpid,
>  				       unsigned long ap)
> @@ -344,6 +407,31 @@ static inline void _tlbie_pid(unsigned long pid, unsigned long ric)
>  	asm volatile("eieio; tlbsync; ptesync": : :"memory");
>  }
>  
> +static inline void _tlbie_pid_lpid(unsigned long pid, unsigned long lpid,
> +				   unsigned long ric)
> +{
> +	asm volatile("ptesync" : : : "memory");
> +
> +	/*
> +	 * Workaround the fact that the "ric" argument to __tlbie_pid
> +	 * must be a compile-time contraint to match the "i" constraint
> +	 * in the asm statement.
> +	 */
> +	switch (ric) {
> +	case RIC_FLUSH_TLB:
> +		__tlbie_pid_lpid(pid, lpid, RIC_FLUSH_TLB);
> +		fixup_tlbie_pid_lpid(pid, lpid);
> +		break;
> +	case RIC_FLUSH_PWC:
> +		__tlbie_pid_lpid(pid, lpid, RIC_FLUSH_PWC);
> +		break;
> +	case RIC_FLUSH_ALL:
> +	default:
> +		__tlbie_pid_lpid(pid, lpid, RIC_FLUSH_ALL);
> +		fixup_tlbie_pid_lpid(pid, lpid);
> +	}
> +	asm volatile("eieio; tlbsync; ptesync" : : : "memory");
> +}
>  struct tlbiel_pid {
>  	unsigned long pid;
>  	unsigned long ric;
> @@ -469,6 +557,20 @@ static inline void __tlbie_va_range(unsigned long start, unsigned long end,
>  	fixup_tlbie_va_range(addr - page_size, pid, ap);
>  }
>  
> +static inline void __tlbie_va_range_lpid(unsigned long start, unsigned long end,
> +					 unsigned long pid, unsigned long lpid,
> +					 unsigned long page_size,
> +					 unsigned long psize)
> +{
> +	unsigned long addr;
> +	unsigned long ap = mmu_get_ap(psize);
> +
> +	for (addr = start; addr < end; addr += page_size)
> +		__tlbie_va_lpid(addr, pid, lpid, ap, RIC_FLUSH_TLB);
> +
> +	fixup_tlbie_va_range_lpid(addr - page_size, pid, lpid, ap);
> +}
> +
>  static __always_inline void _tlbie_va(unsigned long va, unsigned long pid,
>  				      unsigned long psize, unsigned long ric)
>  {
> @@ -549,6 +651,18 @@ static inline void _tlbie_va_range(unsigned long start, unsigned long end,
>  	asm volatile("eieio; tlbsync; ptesync": : :"memory");
>  }
>  
> +static inline void _tlbie_va_range_lpid(unsigned long start, unsigned long end,
> +					unsigned long pid, unsigned long lpid,
> +					unsigned long page_size,
> +					unsigned long psize, bool also_pwc)
> +{
> +	asm volatile("ptesync" : : : "memory");
> +	if (also_pwc)
> +		__tlbie_pid_lpid(pid, lpid, RIC_FLUSH_PWC);
> +	__tlbie_va_range_lpid(start, end, pid, lpid, page_size, psize);
> +	asm volatile("eieio; tlbsync; ptesync" : : : "memory");
> +}
> +
>  static inline void _tlbiel_va_range_multicast(struct mm_struct *mm,
>  				unsigned long start, unsigned long end,
>  				unsigned long pid, unsigned long page_size,
> @@ -1381,4 +1495,29 @@ extern void radix_kvm_prefetch_workaround(struct mm_struct *mm)
>  	}
>  }
>  EXPORT_SYMBOL_GPL(radix_kvm_prefetch_workaround);
> +
> +/*
> + * Process-scoped invalidations for a given LPID.
> + */
> +void do_h_rpt_invalidate(unsigned long pid, unsigned long lpid,
> +			 unsigned long type, unsigned long page_size,
> +			 unsigned long psize, unsigned long start,
> +			 unsigned long end)
> +{
> +	if ((type & H_RPTI_TYPE_ALL) == H_RPTI_TYPE_ALL) {
> +		_tlbie_pid_lpid(pid, lpid, RIC_FLUSH_ALL);
> +		return;
> +	}
> +
> +	if (type & H_RPTI_TYPE_PWC)
> +		_tlbie_pid_lpid(pid, lpid, RIC_FLUSH_PWC);
> +
> +	if (!start && end == -1) /* PID */
> +		_tlbie_pid_lpid(pid, lpid, RIC_FLUSH_TLB);
> +	else /* EA */
> +		_tlbie_va_range_lpid(start, end, pid, lpid, page_size,
> +				     psize, false);
> +}
> +EXPORT_SYMBOL_GPL(do_h_rpt_invalidate);
> +
>  #endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */
> diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
> index 8b281f722e5b..f8c84a62e8f3 100644
> --- a/include/uapi/linux/kvm.h
> +++ b/include/uapi/linux/kvm.h
> @@ -1078,6 +1078,7 @@ struct kvm_ppc_resize_hpt {
>  #define KVM_CAP_DIRTY_LOG_RING 192
>  #define KVM_CAP_X86_BUS_LOCK_EXIT 193
>  #define KVM_CAP_PPC_DAWR1 194
> +#define KVM_CAP_PPC_RPT_INVALIDATE 195
>  
>  #ifdef KVM_CAP_IRQ_ROUTING
>  

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply

* Re: [PATCH v5 1/3] powerpc/book3s64/radix: Add H_RPT_INVALIDATE pgsize encodings to mmu_psize_def
From: David Gibson @ 2021-03-02  1:28 UTC (permalink / raw)
  To: Bharata B Rao; +Cc: farosas, aneesh.kumar, npiggin, kvm-ppc, linuxppc-dev
In-Reply-To: <20210224082510.3962423-2-bharata@linux.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 2627 bytes --]

On Wed, Feb 24, 2021 at 01:55:08PM +0530, Bharata B Rao wrote:
> Add a field to mmu_psize_def to store the page size encodings
> of H_RPT_INVALIDATE hcall. Initialize this while scanning the radix
> AP encodings. This will be used when invalidating with required
> page size encoding in the hcall.
> 
> Signed-off-by: Bharata B Rao <bharata@linux.ibm.com>
> ---
>  arch/powerpc/include/asm/book3s/64/mmu.h | 1 +
>  arch/powerpc/mm/book3s64/radix_pgtable.c | 5 +++++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/arch/powerpc/include/asm/book3s/64/mmu.h b/arch/powerpc/include/asm/book3s/64/mmu.h
> index eace8c3f7b0a..c02f42d1031e 100644
> --- a/arch/powerpc/include/asm/book3s/64/mmu.h
> +++ b/arch/powerpc/include/asm/book3s/64/mmu.h
> @@ -19,6 +19,7 @@ struct mmu_psize_def {
>  	int		penc[MMU_PAGE_COUNT];	/* HPTE encoding */
>  	unsigned int	tlbiel;	/* tlbiel supported for that page size */
>  	unsigned long	avpnm;	/* bits to mask out in AVPN in the HPTE */
> +	unsigned long   h_rpt_pgsize; /* H_RPT_INVALIDATE page size encoding */
>  	union {
>  		unsigned long	sllp;	/* SLB L||LP (exact mask to use in slbmte) */
>  		unsigned long ap;	/* Ap encoding used by PowerISA 3.0 */
> diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c
> index 98f0b243c1ab..1b749899016b 100644
> --- a/arch/powerpc/mm/book3s64/radix_pgtable.c
> +++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
> @@ -486,6 +486,7 @@ static int __init radix_dt_scan_page_sizes(unsigned long node,
>  		def = &mmu_psize_defs[idx];
>  		def->shift = shift;
>  		def->ap  = ap;
> +		def->h_rpt_pgsize = psize_to_rpti_pgsize(idx);
>  	}
>  
>  	/* needed ? */
> @@ -560,9 +561,13 @@ void __init radix__early_init_devtree(void)
>  		 */
>  		mmu_psize_defs[MMU_PAGE_4K].shift = 12;
>  		mmu_psize_defs[MMU_PAGE_4K].ap = 0x0;
> +		mmu_psize_defs[MMU_PAGE_4K].h_rpt_pgsize =
> +			psize_to_rpti_pgsize(MMU_PAGE_4K);

Hm.  TBH, I was thinking of this as replacing psize_to_rpti_pgsize() -
that is, you directly put the correct codes in there, then just have
psize_to_rpti_pgsize() look them up in the table.

I guess that could be a followup change, though.

>  
>  		mmu_psize_defs[MMU_PAGE_64K].shift = 16;
>  		mmu_psize_defs[MMU_PAGE_64K].ap = 0x5;
> +		mmu_psize_defs[MMU_PAGE_64K].h_rpt_pgsize =
> +			psize_to_rpti_pgsize(MMU_PAGE_64K);
>  	}
>  
>  	/*

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply

* Re: [PATCH v2 1/3] powerpc: sstep: Fix load and update emulation
From: Segher Boessenkool @ 2021-03-02  2:37 UTC (permalink / raw)
  To: Naveen N. Rao
  Cc: ravi.bangoria, ananth, jniethe5, paulus, Sandipan Das,
	linuxppc-dev, dja
In-Reply-To: <20210204082753.GI210@DESKTOP-TDPLP67.localdomain>

Hi!

I didn't see this until now, almost a month later, sorry about that :-)

On Thu, Feb 04, 2021 at 01:57:53PM +0530, Naveen N. Rao wrote:
> On 2021/02/03 03:17PM, Segher Boessenkool wrote:
> > Power8 does:
> > 
> >   Load with Update Instructions (RA = 0)
> >     EA is placed into R0.
> >   Load with Update Instructions (RA = RT)
> >     EA is placed into RT. The storage operand addressed by EA is
> >     accessed, but the data returned by the load is discarded.
> 
> I'm actually not seeing that. This is what I am testing with:
> 	li      8,0xaaa
> 	mr      6,1
> 	std     8,64(6)
> 	#ldu    6,64(6)
> 	.long	0xe8c60041
> 
> And, r6 always ends up with 0xaea. It changes with the value I put into 
> r6 though.

That is exactly the behaviour specified for p8.  0aaa+0040=0aea.

> Granted, this is all up in the air, but it does look like there is more 
> going on and the value isn't the EA or the value at the address.

That *is* the EA.  The EA is the address the insn does the access at.


Segher

^ permalink raw reply

* Re: [PATCH v3 2/2] powerpc: Remove remaining parts of oprofile
From: Viresh Kumar @ 2021-03-02  3:48 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: Desnes A. Nunes do Rosario, Madhavan Srinivasan, linux-kernel,
	Paul Mackerras, Rashmica Gupta, linuxppc-dev
In-Reply-To: <0085280627ee44927fc3f07590a8b4909cf8e56d.1614600516.git.christophe.leroy@csgroup.eu>

On 01-03-21, 12:09, Christophe Leroy wrote:
> Commit 9850b6c69356 ("arch: powerpc: Remove oprofile") removed
> oprofile.
> 
> Remove all remaining parts of it.
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
>  arch/powerpc/include/asm/cputable.h       |  3 --
>  arch/powerpc/kernel/cputable.c            | 66 +----------------------
>  arch/powerpc/kernel/dt_cpu_ftrs.c         |  4 --
>  arch/powerpc/platforms/cell/spufs/spufs.h |  2 +-
>  4 files changed, 3 insertions(+), 72 deletions(-)

Great, I wasn't sure how the handle the cpu type stuff and so left it
for the right people to handle. :)

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply

* Re: [PATCH] mm: Generalize HUGETLB_PAGE_SIZE_VARIABLE
From: Anshuman Khandual @ 2021-03-02  4:01 UTC (permalink / raw)
  To: kernel test robot, linux-mm
  Cc: kbuild-all, Paul Mackerras, linux-ia64, Andrew Morton,
	linuxppc-dev, Christoph Hellwig
In-Reply-To: <202103011736.uYkOLJKy-lkp@intel.com>



On 3/1/21 3:22 PM, kernel test robot wrote:
> Hi Anshuman,
> 
> Thank you for the patch! Yet something to improve:
> 
> [auto build test ERROR on powerpc/next]
> [also build test ERROR on linus/master v5.12-rc1 next-20210301]
> [cannot apply to hnaz-linux-mm/master]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch]
> 
> url:    https://github.com/0day-ci/linux/commits/Anshuman-Khandual/mm-Generalize-HUGETLB_PAGE_SIZE_VARIABLE/20210301-135205
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
> config: ia64-randconfig-r003-20210301 (attached as .config)
> compiler: ia64-linux-gcc (GCC) 9.3.0
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # https://github.com/0day-ci/linux/commit/fe78e3508e5221ac13aa288136e2a6506211be68
>         git remote add linux-review https://github.com/0day-ci/linux
>         git fetch --no-tags linux-review Anshuman-Khandual/mm-Generalize-HUGETLB_PAGE_SIZE_VARIABLE/20210301-135205
>         git checkout fe78e3508e5221ac13aa288136e2a6506211be68
>         # save the attached .config to linux build tree
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64 
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All errors (new ones prefixed by >>):
> 
>    In file included from arch/ia64/include/asm/pgtable.h:154,
>                     from include/linux/pgtable.h:6,
>                     from include/linux/mm.h:33,
>                     from mm/page_alloc.c:19:
>    arch/ia64/include/asm/mmu_context.h: In function 'reload_context':
>    arch/ia64/include/asm/mmu_context.h:127:41: warning: variable 'old_rr4' set but not used [-Wunused-but-set-variable]
>      127 |  unsigned long rr0, rr1, rr2, rr3, rr4, old_rr4;
>          |                                         ^~~~~~~
>    In file included from include/linux/kconfig.h:7,
>                     from <command-line>:
>    mm/page_alloc.c: At top level:
>>> ./include/generated/autoconf.h:269:36: error: expected identifier or '(' before numeric constant
>      269 | #define CONFIG_FORCE_MAX_ZONEORDER 11
>          |                                    ^~
>    include/linux/mmzone.h:29:19: note: in expansion of macro 'CONFIG_FORCE_MAX_ZONEORDER'
>       29 | #define MAX_ORDER CONFIG_FORCE_MAX_ZONEORDER
>          |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
>    include/linux/pageblock-flags.h:48:27: note: in expansion of macro 'MAX_ORDER'
>       48 | #define pageblock_order  (MAX_ORDER-1)
>          |                           ^~~~~~~~~
>    mm/page_alloc.c:250:14: note: in expansion of macro 'pageblock_order'
>      250 | unsigned int pageblock_order __read_mostly;
>          |              ^~~~~~~~~~~~~~~
>    mm/page_alloc.c:2618:5: warning: no previous prototype for 'find_suitable_fallback' [-Wmissing-prototypes]
>     2618 | int find_suitable_fallback(struct free_area *area, unsigned int order,
>          |     ^~~~~~~~~~~~~~~~~~~~~~
>    mm/page_alloc.c:3596:15: warning: no previous prototype for 'should_fail_alloc_page' [-Wmissing-prototypes]
>     3596 | noinline bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
>          |               ^~~~~~~~~~~~~~~~~~~~~~
>    mm/page_alloc.c:6257:23: warning: no previous prototype for 'memmap_init' [-Wmissing-prototypes]
>     6257 | void __meminit __weak memmap_init(unsigned long size, int nid,
>          |                       ^~~~~~~~~~~
>    mm/page_alloc.c: In function 'set_pageblock_order':
>>> mm/page_alloc.c:6798:6: error: 'HPAGE_SHIFT' undeclared (first use in this function); did you mean 'PAGE_SHIFT'?
>     6798 |  if (HPAGE_SHIFT > PAGE_SHIFT)
>          |      ^~~~~~~~~~~
>          |      PAGE_SHIFT
>    mm/page_alloc.c:6798:6: note: each undeclared identifier is reported only once for each function it appears in
>>> mm/page_alloc.c:6799:11: error: 'HUGETLB_PAGE_ORDER' undeclared (first use in this function)
>     6799 |   order = HUGETLB_PAGE_ORDER;
>          |           ^~~~~~~~~~~~~~~~~~
>>> mm/page_alloc.c:6808:18: error: lvalue required as left operand of assignment
>     6808 |  pageblock_order = order;
>          |                  ^
> 
> Kconfig warnings: (for reference only)
>    WARNING: unmet direct dependencies detected for HUGETLB_PAGE_SIZE_VARIABLE
>    Depends on HUGETLB_PAGE
>    Selected by
>    - IA64

This shows that HUGETLB_PAGE_SIZE_VARIABLE could be selected without HUGETLB_PAGE
being enabled, which was not intended. The dependency on HUGETLB_PAGE need to be
explicit for HUGETLB_PAGE_SIZE_VARIABLE.

^ permalink raw reply

* Re: [PATCH v5 2/3] KVM: PPC: Book3S HV: Add support for H_RPT_INVALIDATE
From: Bharata B Rao @ 2021-03-02  4:14 UTC (permalink / raw)
  To: Fabiano Rosas; +Cc: aneesh.kumar, npiggin, kvm-ppc, linuxppc-dev, david
In-Reply-To: <87blc9xxth.fsf@linux.ibm.com>

On Wed, Feb 24, 2021 at 12:58:02PM -0300, Fabiano Rosas wrote:
> > @@ -1590,6 +1662,24 @@ static int kvmppc_handle_nested_exit(struct kvm_vcpu *vcpu)
> >  		if (!xics_on_xive())
> >  			kvmppc_xics_rm_complete(vcpu, 0);
> >  		break;
> > +	case BOOK3S_INTERRUPT_SYSCALL:
> > +	{
> > +		unsigned long req = kvmppc_get_gpr(vcpu, 3);
> > +
> > +		/*
> > +		 * The H_RPT_INVALIDATE hcalls issued by nested
> > +		 * guests for process scoped invalidations when
> > +		 * GTSE=0, are handled here in L0.
> > +		 */
> > +		if (req == H_RPT_INVALIDATE) {
> > +			kvmppc_nested_rpt_invalidate(vcpu);
> > +			r = RESUME_GUEST;
> > +			break;
> > +		}
> 
> I'm inclined to say this is a bit too early. We're handling the hcall
> before kvmhv_run_single_vcpu has fully finished and we'll skip some
> code that has been running in all guest exits:
> 
> 	if (trap) {
> 		if (!nested)
> 			r = kvmppc_handle_exit_hv(vcpu, current);
> 		else
> 			r = kvmppc_handle_nested_exit(vcpu);  <--- we're here
> 	}
> 	vcpu->arch.ret = r;
> 
>         (...)
> 
> 	vcpu->arch.ceded = 0;
> 
> 	vc->vcore_state = VCORE_INACTIVE;
> 	trace_kvmppc_run_core(vc, 1);
> 
>  done:
> 	kvmppc_remove_runnable(vc, vcpu);
> 	trace_kvmppc_run_vcpu_exit(vcpu);
> 
> 	return vcpu->arch.ret;
> 
> Especially the kvmppc_remove_runnable function because it sets the
> vcpu state:
> 
>     	vcpu->arch.state = KVMPPC_VCPU_BUSY_IN_HOST;
> 
> which should be the case if we're handling a hypercall.
> 
> I suggest we do similarly to the L1 exit code and defer the hcall
> handling until after kvmppc_run_single_vcpu has exited, still inside the
> is_kvmppc_resume_guest(r) loop.
> 
> So we'd set:
> case BOOK3S_INTERRUPT_SYSCALL:
> 	vcpu->run->exit_reason = KVM_EXIT_PAPR_HCALL;
> 	r = RESUME_HOST;
>         break;
> 
> and perhaps introduce a new kvmppc_pseries_do_nested_hcall that's called
> after kvmppc_run_single_vcpu.

Yes, looks like we should, but I wasn't sure if an exit similar to L1
exit for hcall handling is needed here too, hence took this approach.

Paul, could you please clarify?

Regards,
Bharata.

^ permalink raw reply

* Re: [PATCH v5 1/3] powerpc/book3s64/radix: Add H_RPT_INVALIDATE pgsize encodings to mmu_psize_def
From: Bharata B Rao @ 2021-03-02  4:21 UTC (permalink / raw)
  To: David Gibson; +Cc: farosas, aneesh.kumar, npiggin, kvm-ppc, linuxppc-dev
In-Reply-To: <YD2UwhaweIpImZDv@yekko.fritz.box>

On Tue, Mar 02, 2021 at 12:28:34PM +1100, David Gibson wrote:
> On Wed, Feb 24, 2021 at 01:55:08PM +0530, Bharata B Rao wrote:
> > Add a field to mmu_psize_def to store the page size encodings
> > of H_RPT_INVALIDATE hcall. Initialize this while scanning the radix
> > AP encodings. This will be used when invalidating with required
> > page size encoding in the hcall.
> > 
> > Signed-off-by: Bharata B Rao <bharata@linux.ibm.com>
> > ---
> >  arch/powerpc/include/asm/book3s/64/mmu.h | 1 +
> >  arch/powerpc/mm/book3s64/radix_pgtable.c | 5 +++++
> >  2 files changed, 6 insertions(+)
> > 
> > diff --git a/arch/powerpc/include/asm/book3s/64/mmu.h b/arch/powerpc/include/asm/book3s/64/mmu.h
> > index eace8c3f7b0a..c02f42d1031e 100644
> > --- a/arch/powerpc/include/asm/book3s/64/mmu.h
> > +++ b/arch/powerpc/include/asm/book3s/64/mmu.h
> > @@ -19,6 +19,7 @@ struct mmu_psize_def {
> >  	int		penc[MMU_PAGE_COUNT];	/* HPTE encoding */
> >  	unsigned int	tlbiel;	/* tlbiel supported for that page size */
> >  	unsigned long	avpnm;	/* bits to mask out in AVPN in the HPTE */
> > +	unsigned long   h_rpt_pgsize; /* H_RPT_INVALIDATE page size encoding */
> >  	union {
> >  		unsigned long	sllp;	/* SLB L||LP (exact mask to use in slbmte) */
> >  		unsigned long ap;	/* Ap encoding used by PowerISA 3.0 */
> > diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c
> > index 98f0b243c1ab..1b749899016b 100644
> > --- a/arch/powerpc/mm/book3s64/radix_pgtable.c
> > +++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
> > @@ -486,6 +486,7 @@ static int __init radix_dt_scan_page_sizes(unsigned long node,
> >  		def = &mmu_psize_defs[idx];
> >  		def->shift = shift;
> >  		def->ap  = ap;
> > +		def->h_rpt_pgsize = psize_to_rpti_pgsize(idx);
> >  	}
> >  
> >  	/* needed ? */
> > @@ -560,9 +561,13 @@ void __init radix__early_init_devtree(void)
> >  		 */
> >  		mmu_psize_defs[MMU_PAGE_4K].shift = 12;
> >  		mmu_psize_defs[MMU_PAGE_4K].ap = 0x0;
> > +		mmu_psize_defs[MMU_PAGE_4K].h_rpt_pgsize =
> > +			psize_to_rpti_pgsize(MMU_PAGE_4K);
> 
> Hm.  TBH, I was thinking of this as replacing psize_to_rpti_pgsize() -
> that is, you directly put the correct codes in there, then just have
> psize_to_rpti_pgsize() look them up in the table.
> 
> I guess that could be a followup change, though.
> 
> >  
> >  		mmu_psize_defs[MMU_PAGE_64K].shift = 16;
> >  		mmu_psize_defs[MMU_PAGE_64K].ap = 0x5;
> > +		mmu_psize_defs[MMU_PAGE_64K].h_rpt_pgsize =
> > +			psize_to_rpti_pgsize(MMU_PAGE_64K);

Hmm if you see I got rid of rpti_pgsize_to_psize() by having the
defines directly in mmu_psize_def[].

There are two cases in the above code (radix__early_init_devtree)

1. If radix pagesize encodings are present in the DT, we walk
the page sizes in the loop and populate the enconding for
H_RPT_INVALIDATE. I am not sure if we can use the direct codes
in this case.

2. If DT doesn't have the radix pagesize encodings, 4K and 64K
sizes are assumed as fallback sizes where we can use direct
encodings.

Regards,
Bharata.

^ permalink raw reply

* Re: [PATCH v5 2/3] KVM: PPC: Book3S HV: Add support for H_RPT_INVALIDATE
From: Bharata B Rao @ 2021-03-02  4:58 UTC (permalink / raw)
  To: David Gibson; +Cc: farosas, aneesh.kumar, npiggin, kvm-ppc, linuxppc-dev
In-Reply-To: <YD2YrkY0cg+uO+wz@yekko.fritz.box>

On Tue, Mar 02, 2021 at 12:45:18PM +1100, David Gibson wrote:
> > diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
> > index 45fd862ac128..38ce3f21b21f 100644
> > --- a/Documentation/virt/kvm/api.rst
> > +++ b/Documentation/virt/kvm/api.rst
> > @@ -6225,6 +6225,24 @@ KVM_RUN_BUS_LOCK flag is used to distinguish between them.
> >  This capability can be used to check / enable 2nd DAWR feature provided
> >  by POWER10 processor.
> >  
> > +7.23 KVM_CAP_PPC_RPT_INVALIDATE
> > +------------------------------
> > +
> > +:Capability: KVM_CAP_PPC_RPT_INVALIDATE
> > +:Architectures: ppc
> > +:Type: vm
> > +
> > +This capability indicates that the kernel is capable of handling
> > +H_RPT_INVALIDATE hcall.
> > +
> > +In order to enable the use of H_RPT_INVALIDATE in the guest,
> > +user space might have to advertise it for the guest. For example,
> > +IBM pSeries (sPAPR) guest starts using it if "hcall-rpt-invalidate" is
> > +present in the "ibm,hypertas-functions" device-tree property.
> > +
> > +This capability is enabled for hypervisors on platforms like POWER9
> > +that support radix MMU.
> 
> Does this mean that KVM will handle the hypercall, even if not
> explicitly enabled by userspace (qemu)?  That's generally not what we
> want, since we need to allow qemu to set up backwards compatible
> guests.

This capability only indicates that hypervisor supports the hcall.

QEMU will check for this and conditionally enable the hcall
(via KVM_CAP_PPC_ENABLE_HCALL ioctl). Enabling the hcall is
conditional to cap-rpt-invalidate sPAPR machine capability being
enabled by the user. Will post a followup QEMU patch shortly.

Older QEMU patch can be found here:
https://lists.gnu.org/archive/html/qemu-devel/2021-01/msg00627.html

> 
> > +
> >  8. Other capabilities.
> >  ======================
> >  
> > diff --git a/arch/powerpc/include/asm/book3s/64/tlbflush-radix.h b/arch/powerpc/include/asm/book3s/64/tlbflush-radix.h
> > index 8b33601cdb9d..a46fd37ad552 100644
> > --- a/arch/powerpc/include/asm/book3s/64/tlbflush-radix.h
> > +++ b/arch/powerpc/include/asm/book3s/64/tlbflush-radix.h
> > @@ -4,6 +4,10 @@
> >  
> >  #include <asm/hvcall.h>
> >  
> > +#define RIC_FLUSH_TLB 0
> > +#define RIC_FLUSH_PWC 1
> > +#define RIC_FLUSH_ALL 2
> > +
> >  struct vm_area_struct;
> >  struct mm_struct;
> >  struct mmu_gather;
> > diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h
> > index 2f5f919f6cd3..a1515f94400e 100644
> > --- a/arch/powerpc/include/asm/kvm_book3s.h
> > +++ b/arch/powerpc/include/asm/kvm_book3s.h
> > @@ -305,6 +305,9 @@ void kvmhv_set_ptbl_entry(unsigned int lpid, u64 dw0, u64 dw1);
> >  void kvmhv_release_all_nested(struct kvm *kvm);
> >  long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu);
> >  long kvmhv_do_nested_tlbie(struct kvm_vcpu *vcpu);
> > +long kvmhv_h_rpti_nested(struct kvm_vcpu *vcpu, unsigned long lpid,
> > +			 unsigned long type, unsigned long pg_sizes,
> > +			 unsigned long start, unsigned long end);
> >  int kvmhv_run_single_vcpu(struct kvm_vcpu *vcpu,
> >  			  u64 time_limit, unsigned long lpcr);
> >  void kvmhv_save_hv_regs(struct kvm_vcpu *vcpu, struct hv_guest_state *hr);
> > diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h
> > index 652ce85f9410..820caf4e01b7 100644
> > --- a/arch/powerpc/include/asm/mmu_context.h
> > +++ b/arch/powerpc/include/asm/mmu_context.h
> > @@ -124,8 +124,19 @@ static inline bool need_extra_context(struct mm_struct *mm, unsigned long ea)
> >  
> >  #if defined(CONFIG_KVM_BOOK3S_HV_POSSIBLE) && defined(CONFIG_PPC_RADIX_MMU)
> >  extern void radix_kvm_prefetch_workaround(struct mm_struct *mm);
> > +void do_h_rpt_invalidate(unsigned long pid, unsigned long lpid,
> > +			 unsigned long type, unsigned long page_size,
> > +			 unsigned long psize, unsigned long start,
> > +			 unsigned long end);
> >  #else
> >  static inline void radix_kvm_prefetch_workaround(struct mm_struct *mm) { }
> > +static inline void do_h_rpt_invalidate(unsigned long pid,
> > +				       unsigned long lpid,
> > +				       unsigned long type,
> > +				       unsigned long page_size,
> > +				       unsigned long psize,
> > +				       unsigned long start,
> > +				       unsigned long end) { }
> >  #endif
> >  
> >  extern void switch_cop(struct mm_struct *next);
> > diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> > index 13bad6bf4c95..d83f006fc19d 100644
> > --- a/arch/powerpc/kvm/book3s_hv.c
> > +++ b/arch/powerpc/kvm/book3s_hv.c
> > @@ -921,6 +921,69 @@ static int kvmppc_get_yield_count(struct kvm_vcpu *vcpu)
> >  	return yield_count;
> >  }
> >  
> > +static void do_h_rpt_invalidate_prs(unsigned long pid, unsigned long lpid,
> > +				    unsigned long type, unsigned long pg_sizes,
> > +				    unsigned long start, unsigned long end)
> > +{
> > +	unsigned long psize;
> > +	struct mmu_psize_def *def;
> > +
> > +	for (psize = 0; psize < MMU_PAGE_COUNT; psize++) {
> > +		def = &mmu_psize_defs[psize];
> > +		if (pg_sizes & def->h_rpt_pgsize)
> > +			do_h_rpt_invalidate(pid, lpid, type,
> > +					    (1UL << def->shift), psize,
> > +					    start, end);
> > +	}
> > +}
> > +
> > +static void kvmppc_nested_rpt_invalidate(struct kvm_vcpu *vcpu)
> > +{
> > +	do_h_rpt_invalidate_prs(kvmppc_get_gpr(vcpu, 4),
> > +				vcpu->arch.nested->shadow_lpid,
> > +				kvmppc_get_gpr(vcpu, 5),
> > +				kvmppc_get_gpr(vcpu, 6),
> > +				kvmppc_get_gpr(vcpu, 7),
> > +				kvmppc_get_gpr(vcpu, 8));
> > +	kvmppc_set_gpr(vcpu, 3, H_SUCCESS);
> > +}
> > +
> > +static long kvmppc_h_rpt_invalidate(struct kvm_vcpu *vcpu,
> > +				    unsigned long pid, unsigned long target,
> > +				    unsigned long type, unsigned long pg_sizes,
> > +				    unsigned long start, unsigned long end)
> > +{
> > +	if (!kvm_is_radix(vcpu->kvm))
> > +		return H_UNSUPPORTED;
> > +
> > +	/*
> > +	 * For nested guests, this hcall is handled in
> > +	 * L0. See kvmppc_handle_nested_exit() for details.
> > +	 */
> > +	if (kvmhv_on_pseries())
> > +		return H_UNSUPPORTED;
> > +
> > +	if (end < start)
> > +		return H_P5;
> > +
> > +	if (type & H_RPTI_TYPE_NESTED) {
> > +		if (!nesting_enabled(vcpu->kvm))
> > +			return H_FUNCTION;
> > +
> > +		/* Support only cores as target */
> > +		if (target != H_RPTI_TARGET_CMMU)
> > +			return H_P2;
> > +
> 
> IIUC, we'll hit this code path if an L1 calls this on behalf of an L2,

Correct.

> whereas we'll hit the nested exit code path going straight to
> kvmhv_h_rpti_nested() if an L2 calls it on behalf of an L3.  Is that
> right?

We will hit the nested exit code path when L2 calls it on behalf
of L3. Looks like I am not handling this case (hcall issued by
L2 on behalf of L3 for handling partition scoped translations)
in the nested exit path.

> 
> > +		return kvmhv_h_rpti_nested(vcpu, pid,
> > +					   (type & ~H_RPTI_TYPE_NESTED),
> > +					    pg_sizes, start, end);
> > +	}
> > +
> > +	do_h_rpt_invalidate_prs(pid, vcpu->kvm->arch.lpid, type, pg_sizes,
> > +				start, end);
> > +	return H_SUCCESS;
> > +}
> > +
> >  int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu)
> >  {
> >  	unsigned long req = kvmppc_get_gpr(vcpu, 3);
> > @@ -1129,6 +1192,14 @@ int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu)
> >  		 */
> >  		ret = kvmppc_h_svm_init_abort(vcpu->kvm);
> >  		break;
> > +	case H_RPT_INVALIDATE:
> > +		ret = kvmppc_h_rpt_invalidate(vcpu, kvmppc_get_gpr(vcpu, 4),
> > +					      kvmppc_get_gpr(vcpu, 5),
> > +					      kvmppc_get_gpr(vcpu, 6),
> > +					      kvmppc_get_gpr(vcpu, 7),
> > +					      kvmppc_get_gpr(vcpu, 8),
> > +					      kvmppc_get_gpr(vcpu, 9));
> > +		break;
> >  
> >  	default:
> >  		return RESUME_HOST;
> > @@ -1175,6 +1246,7 @@ static int kvmppc_hcall_impl_hv(unsigned long cmd)
> >  	case H_XIRR_X:
> >  #endif
> >  	case H_PAGE_INIT:
> > +	case H_RPT_INVALIDATE:
> >  		return 1;
> >  	}
> >  
> > @@ -1590,6 +1662,24 @@ static int kvmppc_handle_nested_exit(struct kvm_vcpu *vcpu)
> >  		if (!xics_on_xive())
> >  			kvmppc_xics_rm_complete(vcpu, 0);
> >  		break;
> > +	case BOOK3S_INTERRUPT_SYSCALL:
> > +	{
> > +		unsigned long req = kvmppc_get_gpr(vcpu, 3);
> > +
> > +		/*
> > +		 * The H_RPT_INVALIDATE hcalls issued by nested
> > +		 * guests for process scoped invalidations when
> > +		 * GTSE=0, are handled here in L0.
> > +		 */
> 
> What if the L2 is not calling this for the GTSE=0 case, but on behalf
> of an L3?

That case would be for flushing partition scoped translations. I am
realizing that I am not handling that case, but it should be handled
here in the nested hcall exit path.

Currently I am handling only the hcall requests for process scoped
translations from nested guests here.

> 
> > +		if (req == H_RPT_INVALIDATE) {
> > +			kvmppc_nested_rpt_invalidate(vcpu);
> > +			r = RESUME_GUEST;
> > +			break;
> > +		}
> > +
> > +		r = RESUME_HOST;
> > +		break;
> > +	}
> >  	default:
> >  		r = RESUME_HOST;
> >  		break;
> > diff --git a/arch/powerpc/kvm/book3s_hv_nested.c b/arch/powerpc/kvm/book3s_hv_nested.c
> > index 0cd0e7aad588..ca43b2d38dce 100644
> > --- a/arch/powerpc/kvm/book3s_hv_nested.c
> > +++ b/arch/powerpc/kvm/book3s_hv_nested.c
> > @@ -1191,6 +1191,83 @@ long kvmhv_do_nested_tlbie(struct kvm_vcpu *vcpu)
> >  	return H_SUCCESS;
> >  }
> >  
> > +static long do_tlb_invalidate_nested_tlb(struct kvm_vcpu *vcpu,
> > +					 unsigned long lpid,
> > +					 unsigned long page_size,
> > +					 unsigned long ap,
> > +					 unsigned long start,
> > +					 unsigned long end)
> > +{
> > +	unsigned long addr = start;
> > +	int ret;
> > +
> > +	do {
> > +		ret = kvmhv_emulate_tlbie_tlb_addr(vcpu, lpid, ap,
> > +						   get_epn(addr));
> > +		if (ret)
> > +			return ret;
> > +		addr += page_size;
> > +	} while (addr < end);
> > +
> > +	return ret;
> > +}
> > +
> > +static long do_tlb_invalidate_nested_all(struct kvm_vcpu *vcpu,
> > +					 unsigned long lpid)
> > +{
> > +	struct kvm *kvm = vcpu->kvm;
> > +	struct kvm_nested_guest *gp;
> > +
> > +	gp = kvmhv_get_nested(kvm, lpid, false);
> > +	if (gp) {
> > +		kvmhv_emulate_tlbie_lpid(vcpu, gp, RIC_FLUSH_ALL);
> > +		kvmhv_put_nested(gp);
> > +	}
> > +	return H_SUCCESS;
> > +}
> > +
> > +long kvmhv_h_rpti_nested(struct kvm_vcpu *vcpu, unsigned long lpid,
> > +			 unsigned long type, unsigned long pg_sizes,
> > +			 unsigned long start, unsigned long end)
> > +{
> > +	struct kvm_nested_guest *gp;
> > +	long ret;
> > +	unsigned long psize, ap;
> > +
> > +	/*
> > +	 * If L2 lpid isn't valid, we need to return H_PARAMETER.
> > +	 *
> > +	 * However, nested KVM issues a L2 lpid flush call when creating
> > +	 * partition table entries for L2. This happens even before the
> > +	 * corresponding shadow lpid is created in HV which happens in
> > +	 * H_ENTER_NESTED call. Since we can't differentiate this case from
> > +	 * the invalid case, we ignore such flush requests and return success.
> > +	 */
> 
> What if this is being called on behalf of an L3 or deeper?  Do we need
> something to do a translation from L3 to L2 addresses?

I am not sure, I will have to check if gp->shadow_lpid points to
correct nested LPID in all the cases.

> 
> > +	gp = kvmhv_find_nested(vcpu->kvm, lpid);
> > +	if (!gp)
> > +		return H_SUCCESS;

Regards,
Bharata.

^ permalink raw reply

* [PATCH V2] mm: Generalize HUGETLB_PAGE_SIZE_VARIABLE
From: Anshuman Khandual @ 2021-03-02  5:13 UTC (permalink / raw)
  To: linux-mm
  Cc: linux-ia64, Anshuman Khandual, linux-kernel, Paul Mackerras,
	Andrew Morton, linuxppc-dev, Christoph Hellwig

HUGETLB_PAGE_SIZE_VARIABLE need not be defined for each individual
platform subscribing it. Instead just make it generic.

Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: linux-ia64@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
This change was originally suggested in an earilier discussion. This
applies on v5.12-rc1 and has been build tested on all applicable
platforms i.e ia64 and powerpc.

https://patchwork.kernel.org/project/linux-mm/patch/1613024531-19040-3-git-send-email-anshuman.khandual@arm.com/

Changes in V2:

- Added a description for HUGETLB_PAGE_SIZE_VARIABLE
- Added HUGETLB_PAGE dependency while selecting HUGETLB_PAGE_SIZE_VARIABLE

Changes in V1:

https://patchwork.kernel.org/project/linux-mm/patch/1614577853-7452-1-git-send-email-anshuman.khandual@arm.com/

 arch/ia64/Kconfig    | 6 +-----
 arch/powerpc/Kconfig | 6 +-----
 mm/Kconfig           | 9 +++++++++
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 2ad7a8d29fcc..dccf5bfebf48 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -32,6 +32,7 @@ config IA64
 	select TTY
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_VIRT_CPU_ACCOUNTING
+	select HUGETLB_PAGE_SIZE_VARIABLE if HUGETLB_PAGE
 	select VIRT_TO_BUS
 	select GENERIC_IRQ_PROBE
 	select GENERIC_PENDING_IRQ if SMP
@@ -82,11 +83,6 @@ config STACKTRACE_SUPPORT
 config GENERIC_LOCKBREAK
 	def_bool n
 
-config HUGETLB_PAGE_SIZE_VARIABLE
-	bool
-	depends on HUGETLB_PAGE
-	default y
-
 config GENERIC_CALIBRATE_DELAY
 	bool
 	default y
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 3778ad17f56a..3fdec3e53256 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -232,6 +232,7 @@ config PPC
 	select HAVE_HARDLOCKUP_DETECTOR_PERF	if PERF_EVENTS && HAVE_PERF_EVENTS_NMI && !HAVE_HARDLOCKUP_DETECTOR_ARCH
 	select HAVE_PERF_REGS
 	select HAVE_PERF_USER_STACK_DUMP
+	select HUGETLB_PAGE_SIZE_VARIABLE	if PPC_BOOK3S_64 && HUGETLB_PAGE
 	select MMU_GATHER_RCU_TABLE_FREE
 	select MMU_GATHER_PAGE_SIZE
 	select HAVE_REGS_AND_STACK_ACCESS_API
@@ -416,11 +417,6 @@ config HIGHMEM
 
 source "kernel/Kconfig.hz"
 
-config HUGETLB_PAGE_SIZE_VARIABLE
-	bool
-	depends on HUGETLB_PAGE && PPC_BOOK3S_64
-	default y
-
 config MATH_EMULATION
 	bool "Math emulation"
 	depends on 4xx || PPC_8xx || PPC_MPC832x || BOOKE
diff --git a/mm/Kconfig b/mm/Kconfig
index 24c045b24b95..64f1e0503e4f 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -274,6 +274,15 @@ config ARCH_ENABLE_HUGEPAGE_MIGRATION
 config ARCH_ENABLE_THP_MIGRATION
 	bool
 
+config HUGETLB_PAGE_SIZE_VARIABLE
+	bool "Allows dynamic pageblock_order"
+	def_bool n
+	depends on HUGETLB_PAGE
+	help
+	  Allows the pageblock_order value to be dynamic instead of just standard
+	  HUGETLB_PAGE_ORDER when there are multiple HugeTLB page sizes available
+	  on a platform.
+
 config CONTIG_ALLOC
 	def_bool (MEMORY_ISOLATION && COMPACTION) || CMA
 
-- 
2.20.1


^ permalink raw reply related

* Re: [PATCH V2] mm: Generalize HUGETLB_PAGE_SIZE_VARIABLE
From: Christophe Leroy @ 2021-03-02  5:43 UTC (permalink / raw)
  To: Anshuman Khandual, linux-mm
  Cc: linux-ia64, linux-kernel, Paul Mackerras, Andrew Morton,
	linuxppc-dev, Christoph Hellwig
In-Reply-To: <1614661987-23881-1-git-send-email-anshuman.khandual@arm.com>



Le 02/03/2021 à 06:13, Anshuman Khandual a écrit :
> HUGETLB_PAGE_SIZE_VARIABLE need not be defined for each individual
> platform subscribing it. Instead just make it generic.
> 
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: linux-ia64@vger.kernel.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-mm@kvack.org
> Cc: linux-kernel@vger.kernel.org
> Suggested-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
> This change was originally suggested in an earilier discussion. This
> applies on v5.12-rc1 and has been build tested on all applicable
> platforms i.e ia64 and powerpc.
> 
> https://patchwork.kernel.org/project/linux-mm/patch/1613024531-19040-3-git-send-email-anshuman.khandual@arm.com/
> 
> Changes in V2:
> 
> - Added a description for HUGETLB_PAGE_SIZE_VARIABLE

You are doing more than adding a description: you are making it user selectable. Is that what you want ?

> - Added HUGETLB_PAGE dependency while selecting HUGETLB_PAGE_SIZE_VARIABLE
> 
> Changes in V1:
> 
> https://patchwork.kernel.org/project/linux-mm/patch/1614577853-7452-1-git-send-email-anshuman.khandual@arm.com/
> 
>   arch/ia64/Kconfig    | 6 +-----
>   arch/powerpc/Kconfig | 6 +-----
>   mm/Kconfig           | 9 +++++++++
>   3 files changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
> index 2ad7a8d29fcc..dccf5bfebf48 100644
> --- a/arch/ia64/Kconfig
> +++ b/arch/ia64/Kconfig
> @@ -32,6 +32,7 @@ config IA64
>   	select TTY
>   	select HAVE_ARCH_TRACEHOOK
>   	select HAVE_VIRT_CPU_ACCOUNTING
> +	select HUGETLB_PAGE_SIZE_VARIABLE if HUGETLB_PAGE
>   	select VIRT_TO_BUS
>   	select GENERIC_IRQ_PROBE
>   	select GENERIC_PENDING_IRQ if SMP
> @@ -82,11 +83,6 @@ config STACKTRACE_SUPPORT
>   config GENERIC_LOCKBREAK
>   	def_bool n
>   
> -config HUGETLB_PAGE_SIZE_VARIABLE
> -	bool
> -	depends on HUGETLB_PAGE
> -	default y
> -
>   config GENERIC_CALIBRATE_DELAY
>   	bool
>   	default y
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 3778ad17f56a..3fdec3e53256 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -232,6 +232,7 @@ config PPC
>   	select HAVE_HARDLOCKUP_DETECTOR_PERF	if PERF_EVENTS && HAVE_PERF_EVENTS_NMI && !HAVE_HARDLOCKUP_DETECTOR_ARCH
>   	select HAVE_PERF_REGS
>   	select HAVE_PERF_USER_STACK_DUMP
> +	select HUGETLB_PAGE_SIZE_VARIABLE	if PPC_BOOK3S_64 && HUGETLB_PAGE
>   	select MMU_GATHER_RCU_TABLE_FREE
>   	select MMU_GATHER_PAGE_SIZE
>   	select HAVE_REGS_AND_STACK_ACCESS_API
> @@ -416,11 +417,6 @@ config HIGHMEM
>   
>   source "kernel/Kconfig.hz"
>   
> -config HUGETLB_PAGE_SIZE_VARIABLE
> -	bool
> -	depends on HUGETLB_PAGE && PPC_BOOK3S_64
> -	default y
> -
>   config MATH_EMULATION
>   	bool "Math emulation"
>   	depends on 4xx || PPC_8xx || PPC_MPC832x || BOOKE
> diff --git a/mm/Kconfig b/mm/Kconfig
> index 24c045b24b95..64f1e0503e4f 100644
> --- a/mm/Kconfig
> +++ b/mm/Kconfig
> @@ -274,6 +274,15 @@ config ARCH_ENABLE_HUGEPAGE_MIGRATION
>   config ARCH_ENABLE_THP_MIGRATION
>   	bool
>   
> +config HUGETLB_PAGE_SIZE_VARIABLE
> +	bool "Allows dynamic pageblock_order"
> +	def_bool n
> +	depends on HUGETLB_PAGE
> +	help
> +	  Allows the pageblock_order value to be dynamic instead of just standard
> +	  HUGETLB_PAGE_ORDER when there are multiple HugeTLB page sizes available
> +	  on a platform.
> +
>   config CONTIG_ALLOC
>   	def_bool (MEMORY_ISOLATION && COMPACTION) || CMA
>   
> 

^ permalink raw reply

* Re: [PATCH V2] mm: Generalize HUGETLB_PAGE_SIZE_VARIABLE
From: Anshuman Khandual @ 2021-03-02  6:37 UTC (permalink / raw)
  To: Christophe Leroy, linux-mm
  Cc: linux-ia64, linux-kernel, Paul Mackerras, Andrew Morton,
	linuxppc-dev, Christoph Hellwig
In-Reply-To: <a3772544-1e84-1969-b71c-ea2a3d013471@csgroup.eu>



On 3/2/21 11:13 AM, Christophe Leroy wrote:
> 
> 
> Le 02/03/2021 à 06:13, Anshuman Khandual a écrit :
>> HUGETLB_PAGE_SIZE_VARIABLE need not be defined for each individual
>> platform subscribing it. Instead just make it generic.
>>
>> Cc: Michael Ellerman <mpe@ellerman.id.au>
>> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>> Cc: Paul Mackerras <paulus@samba.org>
>> Cc: Andrew Morton <akpm@linux-foundation.org>
>> Cc: Christoph Hellwig <hch@lst.de>
>> Cc: linux-ia64@vger.kernel.org
>> Cc: linuxppc-dev@lists.ozlabs.org
>> Cc: linux-mm@kvack.org
>> Cc: linux-kernel@vger.kernel.org
>> Suggested-by: Christoph Hellwig <hch@lst.de>
>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>> ---
>> This change was originally suggested in an earilier discussion. This
>> applies on v5.12-rc1 and has been build tested on all applicable
>> platforms i.e ia64 and powerpc.
>>
>> https://patchwork.kernel.org/project/linux-mm/patch/1613024531-19040-3-git-send-email-anshuman.khandual@arm.com/
>>
>> Changes in V2:
>>
>> - Added a description for HUGETLB_PAGE_SIZE_VARIABLE
> 
> You are doing more than adding a description: you are making it user selectable. Is that what you want ?

No, this was unintended. Will drop that description.

^ permalink raw reply

* [PATCH] sound: pps: fix spelling typo of values
From: dingsenjie @ 2021-03-02  3:40 UTC (permalink / raw)
  To: geoff, perex, tiwai; +Cc: dingsenjie, linuxppc-dev, linux-kernel

From: dingsenjie <dingsenjie@yulong.com>

vaules -> values

Signed-off-by: dingsenjie <dingsenjie@yulong.com>
---
 sound/ppc/snd_ps3_reg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/ppc/snd_ps3_reg.h b/sound/ppc/snd_ps3_reg.h
index 566a318..e2212b7 100644
--- a/sound/ppc/snd_ps3_reg.h
+++ b/sound/ppc/snd_ps3_reg.h
@@ -308,7 +308,7 @@
 each interrupt in this register.
 Writing 1b to a field containing 1b clears field and de-asserts interrupt.
 Writing 0b to a field has no effect.
-Field vaules are the following:
+Field values are the following:
 0 - Interrupt hasn't occurred.
 1 - Interrupt has occurred.
 
-- 
1.9.1



^ permalink raw reply related

* [PATCH 40/44] tty: hvc, drop unneeded forward declarations
From: Jiri Slaby @ 2021-03-02  6:22 UTC (permalink / raw)
  To: gregkh; +Cc: linuxppc-dev, Jiri Slaby, linux-kernel, linux-serial
In-Reply-To: <20210302062214.29627-1-jslaby@suse.cz>

Forward declarations make the code larger and rewrites harder. Harder as
they are often omitted from global changes. Remove forward declarations
which are not really needed, i.e. the definition of the function is
before its first use.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: linuxppc-dev@lists.ozlabs.org
---
 drivers/tty/hvc/hvcs.c | 25 -------------------------
 1 file changed, 25 deletions(-)

diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
index c90848919644..0b89d878a108 100644
--- a/drivers/tty/hvc/hvcs.c
+++ b/drivers/tty/hvc/hvcs.c
@@ -290,36 +290,11 @@ static LIST_HEAD(hvcs_structs);
 static DEFINE_SPINLOCK(hvcs_structs_lock);
 static DEFINE_MUTEX(hvcs_init_mutex);
 
-static void hvcs_unthrottle(struct tty_struct *tty);
-static void hvcs_throttle(struct tty_struct *tty);
-static irqreturn_t hvcs_handle_interrupt(int irq, void *dev_instance);
-
-static int hvcs_write(struct tty_struct *tty,
-		const unsigned char *buf, int count);
-static int hvcs_write_room(struct tty_struct *tty);
-static int hvcs_chars_in_buffer(struct tty_struct *tty);
-
-static int hvcs_has_pi(struct hvcs_struct *hvcsd);
-static void hvcs_set_pi(struct hvcs_partner_info *pi,
-		struct hvcs_struct *hvcsd);
 static int hvcs_get_pi(struct hvcs_struct *hvcsd);
 static int hvcs_rescan_devices_list(void);
 
-static int hvcs_partner_connect(struct hvcs_struct *hvcsd);
 static void hvcs_partner_free(struct hvcs_struct *hvcsd);
 
-static int hvcs_enable_device(struct hvcs_struct *hvcsd,
-		uint32_t unit_address, unsigned int irq, struct vio_dev *dev);
-
-static int hvcs_open(struct tty_struct *tty, struct file *filp);
-static void hvcs_close(struct tty_struct *tty, struct file *filp);
-static void hvcs_hangup(struct tty_struct * tty);
-
-static int hvcs_probe(struct vio_dev *dev,
-		const struct vio_device_id *id);
-static int hvcs_remove(struct vio_dev *dev);
-static int __init hvcs_module_init(void);
-static void __exit hvcs_module_exit(void);
 static int hvcs_initialize(void);
 
 #define HVCS_SCHED_READ	0x00000001
-- 
2.30.1


^ permalink raw reply related

* Re: [PATCH V2] mm: Generalize HUGETLB_PAGE_SIZE_VARIABLE
From: Christophe Leroy @ 2021-03-02  7:09 UTC (permalink / raw)
  To: Anshuman Khandual, linux-mm
  Cc: linux-ia64, linux-kernel, Paul Mackerras, Andrew Morton,
	linuxppc-dev, Christoph Hellwig
In-Reply-To: <c33fe839-82c6-d0cd-32d6-b386d143ac51@arm.com>



Le 02/03/2021 à 07:37, Anshuman Khandual a écrit :
> 
> 
> On 3/2/21 11:13 AM, Christophe Leroy wrote:
>>
>>
>> Le 02/03/2021 à 06:13, Anshuman Khandual a écrit :
>>> HUGETLB_PAGE_SIZE_VARIABLE need not be defined for each individual
>>> platform subscribing it. Instead just make it generic.
>>>
>>> Cc: Michael Ellerman <mpe@ellerman.id.au>
>>> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>>> Cc: Paul Mackerras <paulus@samba.org>
>>> Cc: Andrew Morton <akpm@linux-foundation.org>
>>> Cc: Christoph Hellwig <hch@lst.de>
>>> Cc: linux-ia64@vger.kernel.org
>>> Cc: linuxppc-dev@lists.ozlabs.org
>>> Cc: linux-mm@kvack.org
>>> Cc: linux-kernel@vger.kernel.org
>>> Suggested-by: Christoph Hellwig <hch@lst.de>
>>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>>> ---
>>> This change was originally suggested in an earilier discussion. This
>>> applies on v5.12-rc1 and has been build tested on all applicable
>>> platforms i.e ia64 and powerpc.
>>>
>>> https://patchwork.kernel.org/project/linux-mm/patch/1613024531-19040-3-git-send-email-anshuman.khandual@arm.com/
>>>
>>> Changes in V2:
>>>
>>> - Added a description for HUGETLB_PAGE_SIZE_VARIABLE
>>
>> You are doing more than adding a description: you are making it user selectable. Is that what you want ?
> 
> No, this was unintended. Will drop that description.
> 

The description in the help section is OK.

It is only the text after the "bool" that makes it selectable.

	bool "Allows dynamic pageblock_order"


^ permalink raw reply

* [PATCH] powerpc: iommu: fix build when neither PCI or IBMVIO is set
From: Randy Dunlap @ 2021-03-02  8:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: Randy Dunlap, linuxppc-dev, kernel test robot, Anton Blanchard

When neither CONFIG_PCI nor CONFIG_IBMVIO is enabled:

../arch/powerpc/kernel/iommu.c:178:30: error: 'fail_iommu_bus_notifier' defined but not used [-Werror=unused-variable]
  178 | static struct notifier_block fail_iommu_bus_notifier = {

If only that struct is bounded by 2 #if defined() phrases (PCI && IBMVIO):

../arch/powerpc/kernel/iommu.c:162:12: error: 'fail_iommu_bus_notify' defined but not used [-Werror=unused-function]
  162 | static int fail_iommu_bus_notify(struct notifier_block *nb,

If that function is also guarded by 2 #if defined() phrases:

In file included from ../include/linux/dma-mapping.h:7,
                 from ../arch/powerpc/kernel/iommu.c:19:
../include/linux/device.h:131:26: error: 'dev_attr_fail_iommu' defined but not used [-Werror=unused-variable]
  131 |  struct device_attribute dev_attr_##_name = __ATTR_RW(_name)
../arch/powerpc/kernel/iommu.c:160:8: note: in expansion of macro 'DEVICE_ATTR_RW'
  160 | static DEVICE_ATTR_RW(fail_iommu);

and the snowball continues to grow.
Next I got this one:

../arch/powerpc/kernel/iommu.c: In function 'iommu_range_alloc':
../arch/powerpc/kernel/iommu.c:234:6: error: implicit declaration of function 'should_fail_iommu'; did you mean 'should_failslab'? [-Werror=implicit-function-declaration]
  234 |  if (should_fail_iommu(dev))

and

../arch/powerpc/kernel/iommu.c: In function 'should_fail_iommu':
../arch/powerpc/kernel/iommu.c:122:50: error: 'fail_iommu' undeclared (first use in this function)
  122 |  return dev->archdata.fail_iommu && should_fail(&fail_iommu, 1);

So combine CONFIG_FAIL_IOMMU && (CONFIG_PCI || CONFIG_IBMVIO)
to decide on building some of this code/data.

This came from a .config file from the kernel test robot, but it was
not for this particular build problem.

Fixes: d6b9a81b2a45 ("powerpc: IOMMU fault injection")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Anton Blanchard <anton@samba.org>
---
Found/seen in v5.12-rc1.

 arch/powerpc/kernel/iommu.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

--- lnx-512-rc1.orig/arch/powerpc/kernel/iommu.c
+++ lnx-512-rc1/arch/powerpc/kernel/iommu.c
@@ -115,7 +115,13 @@ static int __init setup_iommu_pool_hash(
 }
 subsys_initcall(setup_iommu_pool_hash);
 
-#ifdef CONFIG_FAIL_IOMMU
+#if defined(CONFIG_FAIL_IOMMU) && \
+   (defined(CONFIG_PCI) || defined(CONFIG_IBMVIO))
+
+static bool should_fail_iommu(struct device *dev)
+{
+	return dev->archdata.fail_iommu && should_fail(&fail_iommu, 1);
+}
 
 static DECLARE_FAULT_ATTR(fail_iommu);
 
@@ -125,11 +131,6 @@ static int __init setup_fail_iommu(char
 }
 __setup("fail_iommu=", setup_fail_iommu);
 
-static bool should_fail_iommu(struct device *dev)
-{
-	return dev->archdata.fail_iommu && should_fail(&fail_iommu, 1);
-}
-
 static int __init fail_iommu_debugfs(void)
 {
 	struct dentry *dir = fault_create_debugfs_attr("fail_iommu",

^ permalink raw reply

* Re: linux-next: build failure after merge of the powerpc-fixes tree
From: Uwe Kleine-König @ 2021-03-02  8:30 UTC (permalink / raw)
  To: Michael Ellerman, Stephen Rothwell, PowerPC
  Cc: Linux Next Mailing List, Linux Kernel Mailing List
In-Reply-To: <87pn0is3wg.fsf@mpe.ellerman.id.au>


[-- Attachment #1.1: Type: text/plain, Size: 1134 bytes --]

Hello,

On 3/2/21 3:09 AM, Michael Ellerman wrote:
> Stephen Rothwell <sfr@canb.auug.org.au> writes:
>> Hi all,
>>
>> After merging the powerpc-fixes tree, today's linux-next build (powerpc
>> allyesconfig) failed like this:
>>
>> drivers/net/ethernet/ibm/ibmvnic.c:5399:13: error: conflicting types for 'ibmvnic_remove'
>>   5399 | static void ibmvnic_remove(struct vio_dev *dev)
>>        |             ^~~~~~~~~~~~~~
>> drivers/net/ethernet/ibm/ibmvnic.c:81:12: note: previous declaration of 'ibmvnic_remove' was here
>>     81 | static int ibmvnic_remove(struct vio_dev *);
>>        |            ^~~~~~~~~~~~~~
>>
>> Caused by commit
>>
>>    1bdd1e6f9320 ("vio: make remove callback return void")
> 
> Gah, is IBMVNIC in any of our defconfigs?! ... no it's not.

Would you accept a patch to add the driver to one of the defconfigs as 
an excuse for the build breakage I created? Which would be appropriate? 
ppc64_defconfig?

>> I have applied the following patch for today:
> 
> Thanks, I'll squash it in.

Also thanks for catching to Stephen and to Michael for the fixup.

Best regards
Uwe


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply

* [RFC PATCH v1] powerpc: Enable KFENCE for PPC32
From: Christophe Leroy @ 2021-03-02  8:37 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Alexander Potapenko, Marco Elver, Dmitry Vyukov
  Cc: linuxppc-dev, linux-kernel, kasan-dev

Add architecture specific implementation details for KFENCE and enable
KFENCE for the ppc32 architecture. In particular, this implements the
required interface in <asm/kfence.h>.

KFENCE requires that attributes for pages from its memory pool can
individually be set. Therefore, force the Read/Write linear map to be
mapped at page granularity.

Unit tests succeed on all tests but one:

	[   15.053324]     # test_invalid_access: EXPECTATION FAILED at mm/kfence/kfence_test.c:636
	[   15.053324]     Expected report_matches(&expect) to be true, but is false
	[   15.068359]     not ok 21 - test_invalid_access

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/Kconfig              | 13 +++++++------
 arch/powerpc/include/asm/kfence.h | 32 +++++++++++++++++++++++++++++++
 arch/powerpc/mm/book3s32/mmu.c    |  2 +-
 arch/powerpc/mm/fault.c           |  7 ++++++-
 arch/powerpc/mm/init_32.c         |  3 +++
 arch/powerpc/mm/nohash/8xx.c      |  5 +++--
 6 files changed, 52 insertions(+), 10 deletions(-)
 create mode 100644 arch/powerpc/include/asm/kfence.h

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 386ae12d8523..d46db0bfb998 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -185,6 +185,7 @@ config PPC
 	select HAVE_ARCH_KASAN			if PPC32 && PPC_PAGE_SHIFT <= 14
 	select HAVE_ARCH_KASAN_VMALLOC		if PPC32 && PPC_PAGE_SHIFT <= 14
 	select HAVE_ARCH_KGDB
+	select HAVE_ARCH_KFENCE			if PPC32
 	select HAVE_ARCH_MMAP_RND_BITS
 	select HAVE_ARCH_MMAP_RND_COMPAT_BITS	if COMPAT
 	select HAVE_ARCH_NVRAM_OPS
@@ -786,7 +787,7 @@ config THREAD_SHIFT
 config DATA_SHIFT_BOOL
 	bool "Set custom data alignment"
 	depends on ADVANCED_OPTIONS
-	depends on STRICT_KERNEL_RWX || DEBUG_PAGEALLOC
+	depends on STRICT_KERNEL_RWX || DEBUG_PAGEALLOC || KFENCE
 	depends on PPC_BOOK3S_32 || (PPC_8xx && !PIN_TLB_DATA && !STRICT_KERNEL_RWX)
 	help
 	  This option allows you to set the kernel data alignment. When
@@ -798,13 +799,13 @@ config DATA_SHIFT_BOOL
 config DATA_SHIFT
 	int "Data shift" if DATA_SHIFT_BOOL
 	default 24 if STRICT_KERNEL_RWX && PPC64
-	range 17 28 if (STRICT_KERNEL_RWX || DEBUG_PAGEALLOC) && PPC_BOOK3S_32
-	range 19 23 if (STRICT_KERNEL_RWX || DEBUG_PAGEALLOC) && PPC_8xx
+	range 17 28 if (STRICT_KERNEL_RWX || DEBUG_PAGEALLOC || KFENCE) && PPC_BOOK3S_32
+	range 19 23 if (STRICT_KERNEL_RWX || DEBUG_PAGEALLOC || KFENCE) && PPC_8xx
 	default 22 if STRICT_KERNEL_RWX && PPC_BOOK3S_32
-	default 18 if DEBUG_PAGEALLOC && PPC_BOOK3S_32
+	default 18 if (DEBUG_PAGEALLOC || KFENCE) && PPC_BOOK3S_32
 	default 23 if STRICT_KERNEL_RWX && PPC_8xx
-	default 23 if DEBUG_PAGEALLOC && PPC_8xx && PIN_TLB_DATA
-	default 19 if DEBUG_PAGEALLOC && PPC_8xx
+	default 23 if (DEBUG_PAGEALLOC || KFENCE) && PPC_8xx && PIN_TLB_DATA
+	default 19 if (DEBUG_PAGEALLOC || KFENCE) && PPC_8xx
 	default PPC_PAGE_SHIFT
 	help
 	  On Book3S 32 (603+), DBATs are used to map kernel text and rodata RO.
diff --git a/arch/powerpc/include/asm/kfence.h b/arch/powerpc/include/asm/kfence.h
new file mode 100644
index 000000000000..c229ee6a48f0
--- /dev/null
+++ b/arch/powerpc/include/asm/kfence.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * powerpc KFENCE support.
+ *
+ * Copyright (C) 2020 CS GROUP France
+ */
+
+#ifndef __ASM_POWERPC_KFENCE_H
+#define __ASM_POWERPC_KFENCE_H
+
+#include <asm/pgtable.h>
+
+static inline bool arch_kfence_init_pool(void)
+{
+	return true;
+}
+
+static inline bool kfence_protect_page(unsigned long addr, bool protect)
+{
+	pte_t *kpte = virt_to_kpte(addr);
+
+	if (protect) {
+		pte_update(&init_mm, addr, kpte, _PAGE_PRESENT, 0, 0);
+		flush_tlb_kernel_range(addr, addr + PAGE_SIZE);
+	} else {
+		pte_update(&init_mm, addr, kpte, 0, _PAGE_PRESENT, 0);
+	}
+
+	return true;
+}
+
+#endif /* __ASM_POWERPC_KFENCE_H */
diff --git a/arch/powerpc/mm/book3s32/mmu.c b/arch/powerpc/mm/book3s32/mmu.c
index d7eb266a3f7a..4548aec95561 100644
--- a/arch/powerpc/mm/book3s32/mmu.c
+++ b/arch/powerpc/mm/book3s32/mmu.c
@@ -162,7 +162,7 @@ unsigned long __init mmu_mapin_ram(unsigned long base, unsigned long top)
 	unsigned long border = (unsigned long)__init_begin - PAGE_OFFSET;
 
 
-	if (debug_pagealloc_enabled() || __map_without_bats) {
+	if (debug_pagealloc_enabled() || __map_without_bats || IS_ENABLED(CONFIG_KFENCE)) {
 		pr_debug_once("Read-Write memory mapped without BATs\n");
 		if (base >= border)
 			return base;
diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
index bb368257b55c..bea13682c909 100644
--- a/arch/powerpc/mm/fault.c
+++ b/arch/powerpc/mm/fault.c
@@ -32,6 +32,7 @@
 #include <linux/context_tracking.h>
 #include <linux/hugetlb.h>
 #include <linux/uaccess.h>
+#include <linux/kfence.h>
 
 #include <asm/firmware.h>
 #include <asm/interrupt.h>
@@ -418,8 +419,12 @@ static int ___do_page_fault(struct pt_regs *regs, unsigned long address,
 	 * take a page fault to a kernel address or a page fault to a user
 	 * address outside of dedicated places
 	 */
-	if (unlikely(!is_user && bad_kernel_fault(regs, error_code, address, is_write)))
+	if (unlikely(!is_user && bad_kernel_fault(regs, error_code, address, is_write))) {
+		if (kfence_handle_page_fault(address, is_write, regs))
+			return 0;
+
 		return SIGSEGV;
+	}
 
 	/*
 	 * If we're in an interrupt, have no user context or are running
diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c
index 02c7db4087cb..3d690be48e84 100644
--- a/arch/powerpc/mm/init_32.c
+++ b/arch/powerpc/mm/init_32.c
@@ -97,6 +97,9 @@ static void __init MMU_setup(void)
 	if (IS_ENABLED(CONFIG_PPC_8xx))
 		return;
 
+	if (IS_ENABLED(CONFIG_KFENCE))
+		__map_without_ltlbs = 1;
+
 	if (debug_pagealloc_enabled())
 		__map_without_ltlbs = 1;
 
diff --git a/arch/powerpc/mm/nohash/8xx.c b/arch/powerpc/mm/nohash/8xx.c
index 19a3eec1d8c5..17051377aed7 100644
--- a/arch/powerpc/mm/nohash/8xx.c
+++ b/arch/powerpc/mm/nohash/8xx.c
@@ -149,7 +149,8 @@ unsigned long __init mmu_mapin_ram(unsigned long base, unsigned long top)
 {
 	unsigned long etext8 = ALIGN(__pa(_etext), SZ_8M);
 	unsigned long sinittext = __pa(_sinittext);
-	bool strict_boundary = strict_kernel_rwx_enabled() || debug_pagealloc_enabled();
+	bool strict_boundary = strict_kernel_rwx_enabled() || debug_pagealloc_enabled() ||
+			       IS_ENABLED(CONFIG_KFENCE);
 	unsigned long boundary = strict_boundary ? sinittext : etext8;
 	unsigned long einittext8 = ALIGN(__pa(_einittext), SZ_8M);
 
@@ -161,7 +162,7 @@ unsigned long __init mmu_mapin_ram(unsigned long base, unsigned long top)
 		return 0;
 
 	mmu_mapin_ram_chunk(0, boundary, PAGE_KERNEL_TEXT, true);
-	if (debug_pagealloc_enabled()) {
+	if (debug_pagealloc_enabled() || IS_ENABLED(CONFIG_KFENCE)) {
 		top = boundary;
 	} else {
 		mmu_mapin_ram_chunk(boundary, einittext8, PAGE_KERNEL_TEXT, true);
-- 
2.25.0


^ permalink raw reply related

* [PATCH v1 2/2] powerpc: Use %y addressing on bitops
From: Christophe Leroy @ 2021-03-02  8:48 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linuxppc-dev, linux-kernel
In-Reply-To: <1fc81f07cabebb875b963e295408cc3dd38c8d85.1614674882.git.christophe.leroy@csgroup.eu>

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/include/asm/bitops.h | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/include/asm/bitops.h b/arch/powerpc/include/asm/bitops.h
index 11847b6a244e..264626b13ea8 100644
--- a/arch/powerpc/include/asm/bitops.h
+++ b/arch/powerpc/include/asm/bitops.h
@@ -70,12 +70,12 @@ static inline void fn(unsigned long mask,	\
 	unsigned long *p = (unsigned long *)_p;	\
 	__asm__ __volatile__ (			\
 	prefix					\
-"1:"	PPC_LLARX "%0,0,%3,0\n"			\
+"1:"	PPC_LLARX "%0,%y3,0\n"			\
 	stringify_in_c(op) "%0,%0,%2\n"		\
-	PPC_STLCX "%0,0,%3\n"			\
+	PPC_STLCX "%0,%y3\n"			\
 	"bne- 1b\n"				\
 	: "=&r" (old), "+m" (*p)		\
-	: "r" (mask), "r" (p)			\
+	: "r" (mask), "Z" (*p)			\
 	: "cc", "memory");			\
 }
 
@@ -115,13 +115,13 @@ static inline unsigned long fn(			\
 	unsigned long *p = (unsigned long *)_p;		\
 	__asm__ __volatile__ (				\
 	prefix						\
-"1:"	PPC_LLARX "%0,0,%3,%4\n"			\
+"1:"	PPC_LLARX "%0,%y3,%4\n"				\
 	stringify_in_c(op) "%1,%0,%2\n"			\
-	PPC_STLCX "%1,0,%3\n"				\
+	PPC_STLCX "%1,%y3\n"				\
 	"bne- 1b\n"					\
 	postfix						\
 	: "=&r" (old), "=&r" (t)			\
-	: "r" (mask), "r" (p), "i" (IS_ENABLED(CONFIG_PPC64) ? eh : 0)	\
+	: "r" (mask), "Z" (*p), "i" (IS_ENABLED(CONFIG_PPC64) ? eh : 0)	\
 	: "cc", "memory");				\
 	return (old & mask);				\
 }
@@ -170,12 +170,12 @@ clear_bit_unlock_return_word(int nr, volatile unsigned long *addr)
 
 	__asm__ __volatile__ (
 	PPC_RELEASE_BARRIER
-"1:"	PPC_LLARX "%0,0,%3,0\n"
+"1:"	PPC_LLARX "%0,%y3,0\n"
 	"andc %1,%0,%2\n"
-	PPC_STLCX "%1,0,%3\n"
+	PPC_STLCX "%1,%y3\n"
 	"bne- 1b\n"
 	: "=&r" (old), "=&r" (t)
-	: "r" (mask), "r" (p)
+	: "r" (mask), "Z" (*p)
 	: "cc", "memory");
 
 	return old;
-- 
2.25.0


^ permalink raw reply related

* [PATCH v1 1/2] powerpc: Use lwarx/ldarx directly instead of PPC_LWARX/LDARX macros
From: Christophe Leroy @ 2021-03-02  8:48 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linuxppc-dev, linux-kernel

Force the eh flag at 0 on PPC32.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/include/asm/asm-compat.h      | 4 ++--
 arch/powerpc/include/asm/atomic.h          | 4 ++--
 arch/powerpc/include/asm/bitops.h          | 8 ++++----
 arch/powerpc/include/asm/ppc-opcode.h      | 2 --
 arch/powerpc/include/asm/simple_spinlock.h | 6 +++---
 5 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/arch/powerpc/include/asm/asm-compat.h b/arch/powerpc/include/asm/asm-compat.h
index 19b70c5b5f18..2b736d9fbb1b 100644
--- a/arch/powerpc/include/asm/asm-compat.h
+++ b/arch/powerpc/include/asm/asm-compat.h
@@ -17,7 +17,7 @@
 #define PPC_LONG	stringify_in_c(.8byte)
 #define PPC_LONG_ALIGN	stringify_in_c(.balign 8)
 #define PPC_TLNEI	stringify_in_c(tdnei)
-#define PPC_LLARX(t, a, b, eh)	PPC_LDARX(t, a, b, eh)
+#define PPC_LLARX	stringify_in_c(ldarx)
 #define PPC_STLCX	stringify_in_c(stdcx.)
 #define PPC_CNTLZL	stringify_in_c(cntlzd)
 #define PPC_MTOCRF(FXM, RS) MTOCRF((FXM), RS)
@@ -50,7 +50,7 @@
 #define PPC_LONG	stringify_in_c(.long)
 #define PPC_LONG_ALIGN	stringify_in_c(.balign 4)
 #define PPC_TLNEI	stringify_in_c(twnei)
-#define PPC_LLARX(t, a, b, eh)	PPC_LWARX(t, a, b, eh)
+#define PPC_LLARX	stringify_in_c(lwarx)
 #define PPC_STLCX	stringify_in_c(stwcx.)
 #define PPC_CNTLZL	stringify_in_c(cntlzw)
 #define PPC_MTOCRF	stringify_in_c(mtcrf)
diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
index 61c6e8b200e8..ba177d0be278 100644
--- a/arch/powerpc/include/asm/atomic.h
+++ b/arch/powerpc/include/asm/atomic.h
@@ -204,7 +204,7 @@ atomic_try_cmpxchg_lock(atomic_t *v, int *old, int new)
 	int r, o = *old;
 
 	__asm__ __volatile__ (
-"1:\t"	PPC_LWARX(%0,0,%2,1) "	# atomic_try_cmpxchg_acquire	\n"
+"1:	lwarx	%0,0,%2,%5	# atomic_try_cmpxchg_acquire		\n"
 "	cmpw	0,%0,%3							\n"
 "	bne-	2f							\n"
 "	stwcx.	%4,0,%2							\n"
@@ -212,7 +212,7 @@ atomic_try_cmpxchg_lock(atomic_t *v, int *old, int new)
 "\t"	PPC_ACQUIRE_BARRIER "						\n"
 "2:									\n"
 	: "=&r" (r), "+m" (v->counter)
-	: "r" (&v->counter), "r" (o), "r" (new)
+	: "r" (&v->counter), "r" (o), "r" (new), "i" (IS_ENABLED(CONFIG_PPC64) ? 1 : 0)
 	: "cr0", "memory");
 
 	if (unlikely(r != o))
diff --git a/arch/powerpc/include/asm/bitops.h b/arch/powerpc/include/asm/bitops.h
index 299ab33505a6..11847b6a244e 100644
--- a/arch/powerpc/include/asm/bitops.h
+++ b/arch/powerpc/include/asm/bitops.h
@@ -70,7 +70,7 @@ static inline void fn(unsigned long mask,	\
 	unsigned long *p = (unsigned long *)_p;	\
 	__asm__ __volatile__ (			\
 	prefix					\
-"1:"	PPC_LLARX(%0,0,%3,0) "\n"		\
+"1:"	PPC_LLARX "%0,0,%3,0\n"			\
 	stringify_in_c(op) "%0,%0,%2\n"		\
 	PPC_STLCX "%0,0,%3\n"			\
 	"bne- 1b\n"				\
@@ -115,13 +115,13 @@ static inline unsigned long fn(			\
 	unsigned long *p = (unsigned long *)_p;		\
 	__asm__ __volatile__ (				\
 	prefix						\
-"1:"	PPC_LLARX(%0,0,%3,eh) "\n"			\
+"1:"	PPC_LLARX "%0,0,%3,%4\n"			\
 	stringify_in_c(op) "%1,%0,%2\n"			\
 	PPC_STLCX "%1,0,%3\n"				\
 	"bne- 1b\n"					\
 	postfix						\
 	: "=&r" (old), "=&r" (t)			\
-	: "r" (mask), "r" (p)				\
+	: "r" (mask), "r" (p), "i" (IS_ENABLED(CONFIG_PPC64) ? eh : 0)	\
 	: "cc", "memory");				\
 	return (old & mask);				\
 }
@@ -170,7 +170,7 @@ clear_bit_unlock_return_word(int nr, volatile unsigned long *addr)
 
 	__asm__ __volatile__ (
 	PPC_RELEASE_BARRIER
-"1:"	PPC_LLARX(%0,0,%3,0) "\n"
+"1:"	PPC_LLARX "%0,0,%3,0\n"
 	"andc %1,%0,%2\n"
 	PPC_STLCX "%1,0,%3\n"
 	"bne- 1b\n"
diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
index ed161ef2b3ca..9550af2301b1 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -531,8 +531,6 @@
 #define	PPC_DIVDE(t, a, b)	stringify_in_c(.long PPC_RAW_DIVDE(t, a, b))
 #define	PPC_DIVDEU(t, a, b)	stringify_in_c(.long PPC_RAW_DIVDEU(t, a, b))
 #define PPC_LQARX(t, a, b, eh)	stringify_in_c(.long PPC_RAW_LQARX(t, a, b, eh))
-#define PPC_LDARX(t, a, b, eh)	stringify_in_c(.long PPC_RAW_LDARX(t, a, b, eh))
-#define PPC_LWARX(t, a, b, eh)	stringify_in_c(.long PPC_RAW_LWARX(t, a, b, eh))
 #define PPC_STQCX(t, a, b)	stringify_in_c(.long PPC_RAW_STQCX(t, a, b))
 #define PPC_MADDHD(t, a, b, c)	stringify_in_c(.long PPC_RAW_MADDHD(t, a, b, c))
 #define PPC_MADDHDU(t, a, b, c)	stringify_in_c(.long PPC_RAW_MADDHDU(t, a, b, c))
diff --git a/arch/powerpc/include/asm/simple_spinlock.h b/arch/powerpc/include/asm/simple_spinlock.h
index 5b862de29dff..1b1ded4a21f3 100644
--- a/arch/powerpc/include/asm/simple_spinlock.h
+++ b/arch/powerpc/include/asm/simple_spinlock.h
@@ -52,7 +52,7 @@ static inline unsigned long __arch_spin_trylock(arch_spinlock_t *lock)
 
 	token = LOCK_TOKEN;
 	__asm__ __volatile__(
-"1:	" PPC_LWARX(%0,0,%2,1) "\n\
+"1:	lwarx		%0,0,%2,1\n\
 	cmpwi		0,%0,0\n\
 	bne-		2f\n\
 	stwcx.		%1,0,%2\n\
@@ -180,7 +180,7 @@ static inline long __arch_read_trylock(arch_rwlock_t *rw)
 	long tmp;
 
 	__asm__ __volatile__(
-"1:	" PPC_LWARX(%0,0,%1,1) "\n"
+"1:	lwarx		%0,0,%1,1\n"
 	__DO_SIGN_EXTEND
 "	addic.		%0,%0,1\n\
 	ble-		2f\n"
@@ -204,7 +204,7 @@ static inline long __arch_write_trylock(arch_rwlock_t *rw)
 
 	token = WRLOCK_TOKEN;
 	__asm__ __volatile__(
-"1:	" PPC_LWARX(%0,0,%2,1) "\n\
+"1:	lwarx		%0,0,%2,1\n\
 	cmpwi		0,%0,0\n\
 	bne-		2f\n"
 "	stwcx.		%1,0,%2\n\
-- 
2.25.0


^ permalink raw reply related

* Re: [RFC PATCH v1] powerpc: Enable KFENCE for PPC32
From: Marco Elver @ 2021-03-02  8:58 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: LKML, kasan-dev, Alexander Potapenko, Paul Mackerras,
	linuxppc-dev, Dmitry Vyukov
In-Reply-To: <51c397a23631d8bb2e2a6515c63440d88bf74afd.1614674144.git.christophe.leroy@csgroup.eu>

On Tue, 2 Mar 2021 at 09:37, Christophe Leroy
<christophe.leroy@csgroup.eu> wrote:
> Add architecture specific implementation details for KFENCE and enable
> KFENCE for the ppc32 architecture. In particular, this implements the
> required interface in <asm/kfence.h>.

Nice!

> KFENCE requires that attributes for pages from its memory pool can
> individually be set. Therefore, force the Read/Write linear map to be
> mapped at page granularity.
>
> Unit tests succeed on all tests but one:
>
>         [   15.053324]     # test_invalid_access: EXPECTATION FAILED at mm/kfence/kfence_test.c:636
>         [   15.053324]     Expected report_matches(&expect) to be true, but is false
>         [   15.068359]     not ok 21 - test_invalid_access

This is strange, given all the other tests passed. Do you mind sharing
the full test log?

Thanks,
-- Marco

^ permalink raw reply

* Re: [RFC PATCH v1] powerpc: Enable KFENCE for PPC32
From: Christophe Leroy @ 2021-03-02  9:05 UTC (permalink / raw)
  To: Marco Elver
  Cc: LKML, kasan-dev, Alexander Potapenko, Paul Mackerras,
	linuxppc-dev, Dmitry Vyukov
In-Reply-To: <CANpmjNPOJfL_qsSZYRbwMUrxnXxtF5L3k9hursZZ7k9H1jLEuA@mail.gmail.com>



Le 02/03/2021 à 09:58, Marco Elver a écrit :
> On Tue, 2 Mar 2021 at 09:37, Christophe Leroy
> <christophe.leroy@csgroup.eu> wrote:
>> Add architecture specific implementation details for KFENCE and enable
>> KFENCE for the ppc32 architecture. In particular, this implements the
>> required interface in <asm/kfence.h>.
> 
> Nice!
> 
>> KFENCE requires that attributes for pages from its memory pool can
>> individually be set. Therefore, force the Read/Write linear map to be
>> mapped at page granularity.
>>
>> Unit tests succeed on all tests but one:
>>
>>          [   15.053324]     # test_invalid_access: EXPECTATION FAILED at mm/kfence/kfence_test.c:636
>>          [   15.053324]     Expected report_matches(&expect) to be true, but is false
>>          [   15.068359]     not ok 21 - test_invalid_access
> 
> This is strange, given all the other tests passed. Do you mind sharing
> the full test log?
> 

[    0.000000] Linux version 5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty 
(root@localhost.localdomain) (powerpc64-linux-gcc (GCC) 10.1.0, GNU ld (GNU Binutils) 2.34) #4674 
PREEMPT Tue Mar 2 08:18:49 UTC 2021
[    0.000000] Using CMPCPRO machine description
[    0.000000] Found legacy serial port 0 for /soc8321@b0000000/serial@4500
[    0.000000]   mem=b0004500, taddr=b0004500, irq=0, clk=133333334, speed=0
[    0.000000] Found legacy serial port 1 for /soc8321@b0000000/serial@4600
[    0.000000]   mem=b0004600, taddr=b0004600, irq=0, clk=133333334, speed=0
[    0.000000] ioremap() called early from find_legacy_serial_ports+0x3e4/0x4d8. Use early_ioremap() 
instead
[    0.000000] printk: bootconsole [udbg0] enabled
[    0.000000] -----------------------------------------------------
[    0.000000] phys_mem_size     = 0x20000000
[    0.000000] dcache_bsize      = 0x20
[    0.000000] icache_bsize      = 0x20
[    0.000000] cpu_features      = 0x0000000001000140
[    0.000000]   possible        = 0x00000000277ce140
[    0.000000]   always          = 0x0000000001000000
[    0.000000] cpu_user_features = 0x84000000 0x00000000
[    0.000000] mmu_features      = 0x00210000
[    0.000000] Hash_size         = 0x0
[    0.000000] -----------------------------------------------------
[    0.000000] Top of RAM: 0x20000000, Total RAM: 0x20000000
[    0.000000] Memory hole size: 0MB
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x000000001fffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x000000001fffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x000000001fffffff]
[    0.000000] On node 0 totalpages: 131072
[    0.000000]   Normal zone: 1024 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 131072 pages, LIFO batch:31
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 130048
[    0.000000] Kernel command line: ip=192.168.0.3:192.168.0.1::255.0.0.0:vgoippro:eth0:off 
console=ttyS0,115200
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 503516K/524288K available (7532K kernel code, 2236K rwdata, 1328K rodata, 
1500K init, 931K bss, 20772K reserved, 0K cma-reserved)
[    0.000000] Kernel virtual memory layout:
[    0.000000]   * 0xff7ff000..0xfffff000  : fixmap
[    0.000000]   * 0xff7fd000..0xff7ff000  : early ioremap
[    0.000000]   * 0xe1000000..0xff7fd000  : vmalloc & ioremap
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] rcu: Preemptible hierarchical RCU implementation.
[    0.000000] rcu: 	RCU event tracing is enabled.
[    0.000000] 	Trampoline variant of Tasks RCU enabled.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[    0.000000] NR_IRQS: 512, nr_irqs: 512, preallocated irqs: 16
[    0.000000] IPIC (128 IRQ sources) at (ptrval)
[    0.000000] kfence: initialized - using 2097152 bytes for 255 objects at 0x(ptrval)-0x(ptrval)
...
[    4.472455]     # Subtest: kfence
[    4.472490]     1..25
[    4.476069]     # test_out_of_bounds_read: test_alloc: size=32, gfp=cc0, policy=left, cache=0
[    4.946420] ==================================================================
[    4.953667] BUG: KFENCE: out-of-bounds read in test_out_of_bounds_read+0x90/0x228
[    4.953667]
[    4.962657] Out-of-bounds read at 0x(ptrval) (1B left of kfence-#23):
[    4.969109]  test_out_of_bounds_read+0x90/0x228
[    4.973663]  kunit_try_run_case+0x5c/0xd0
[    4.977712]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    4.983128]  kthread+0x15c/0x174
[    4.986387]  ret_from_kernel_thread+0x14/0x1c
[    4.990774]
[    4.992274] kfence-#23 [0x(ptrval)-0x(ptrval), size=32, cache=kmalloc-32] allocated by task 91:
[    5.000997]  test_alloc+0x10c/0x384
[    5.004508]  test_out_of_bounds_read+0x90/0x228
[    5.009057]  kunit_try_run_case+0x5c/0xd0
[    5.013093]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    5.018505]  kthread+0x15c/0x174
[    5.021758]  ret_from_kernel_thread+0x14/0x1c
[    5.026139]
[    5.027641] CPU: 0 PID: 91 Comm: kunit_try_catch Not tainted 
5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
[    5.037729] ==================================================================
[    5.045220]     # test_out_of_bounds_read: test_alloc: size=32, gfp=cc0, policy=right, cache=0
[    5.146454] ==================================================================
[    5.153698] BUG: KFENCE: out-of-bounds read in test_out_of_bounds_read+0x14c/0x228
[    5.153698]
[    5.162770] Out-of-bounds read at 0x(ptrval) (32B right of kfence-#24):
[    5.169395]  test_out_of_bounds_read+0x14c/0x228
[    5.174037]  kunit_try_run_case+0x5c/0xd0
[    5.178085]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    5.183501]  kthread+0x15c/0x174
[    5.186758]  ret_from_kernel_thread+0x14/0x1c
[    5.191145]
[    5.192645] kfence-#24 [0x(ptrval)-0x(ptrval), size=32, cache=kmalloc-32] allocated by task 91:
[    5.201366]  test_alloc+0x10c/0x384
[    5.204878]  test_out_of_bounds_read+0x14c/0x228
[    5.209514]  kunit_try_run_case+0x5c/0xd0
[    5.213552]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    5.218965]  kthread+0x15c/0x174
[    5.222219]  ret_from_kernel_thread+0x14/0x1c
[    5.226600]
[    5.228103] CPU: 0 PID: 91 Comm: kunit_try_catch Tainted: G    B 
5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
[    5.239575] ==================================================================
[    5.247126]     ok 1 - test_out_of_bounds_read
[    5.247534]     # test_out_of_bounds_read-memcache: setup_test_cache: size=32, ctor=0x0
[    5.260310]     # test_out_of_bounds_read-memcache: test_alloc: size=32, gfp=cc0, policy=left, 
cache=1
[    5.356422] ==================================================================
[    5.363670] BUG: KFENCE: out-of-bounds read in test_out_of_bounds_read+0x90/0x228
[    5.363670]
[    5.372661] Out-of-bounds read at 0x(ptrval) (1B left of kfence-#25):
[    5.379115]  test_out_of_bounds_read+0x90/0x228
[    5.383671]  kunit_try_run_case+0x5c/0xd0
[    5.387720]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    5.393138]  kthread+0x15c/0x174
[    5.396398]  ret_from_kernel_thread+0x14/0x1c
[    5.400786]
[    5.402287] kfence-#25 [0x(ptrval)-0x(ptrval), size=32, cache=test] allocated by task 92:
[    5.410490]  test_alloc+0xfc/0x384
[    5.413918]  test_out_of_bounds_read+0x90/0x228
[    5.418470]  kunit_try_run_case+0x5c/0xd0
[    5.422511]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    5.427926]  kthread+0x15c/0x174
[    5.431180]  ret_from_kernel_thread+0x14/0x1c
[    5.435563]
[    5.437067] CPU: 0 PID: 92 Comm: kunit_try_catch Tainted: G    B 
5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
[    5.448539] ==================================================================
[    5.456076]     # test_out_of_bounds_read-memcache: test_alloc: size=32, gfp=cc0, policy=right, 
cache=1
[    5.556454] ==================================================================
[    5.563701] BUG: KFENCE: out-of-bounds read in test_out_of_bounds_read+0x14c/0x228
[    5.563701]
[    5.572774] Out-of-bounds read at 0x(ptrval) (32B right of kfence-#26):
[    5.579400]  test_out_of_bounds_read+0x14c/0x228
[    5.584042]  kunit_try_run_case+0x5c/0xd0
[    5.588091]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    5.593509]  kthread+0x15c/0x174
[    5.596768]  ret_from_kernel_thread+0x14/0x1c
[    5.601155]
[    5.602656] kfence-#26 [0x(ptrval)-0x(ptrval), size=32, cache=test] allocated by task 92:
[    5.610861]  test_alloc+0xfc/0x384
[    5.614288]  test_out_of_bounds_read+0x14c/0x228
[    5.618927]  kunit_try_run_case+0x5c/0xd0
[    5.622966]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    5.628382]  kthread+0x15c/0x174
[    5.631637]  ret_from_kernel_thread+0x14/0x1c
[    5.636019]
[    5.637522] CPU: 0 PID: 92 Comm: kunit_try_catch Tainted: G    B 
5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
[    5.648993] ==================================================================
[    5.656810]     ok 2 - test_out_of_bounds_read-memcache
[    5.657178]     # test_out_of_bounds_write: test_alloc: size=32, gfp=cc0, policy=left, cache=0
[    5.766441] ==================================================================
[    5.773686] BUG: KFENCE: out-of-bounds write in test_out_of_bounds_write+0x78/0x164
[    5.773686]
[    5.782848] Out-of-bounds write at 0x(ptrval) (1B left of kfence-#27):
[    5.789387]  test_out_of_bounds_write+0x78/0x164
[    5.794029]  kunit_try_run_case+0x5c/0xd0
[    5.798078]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    5.803494]  kthread+0x15c/0x174
[    5.806753]  ret_from_kernel_thread+0x14/0x1c
[    5.811138]
[    5.812638] kfence-#27 [0x(ptrval)-0x(ptrval), size=32, cache=kmalloc-32] allocated by task 93:
[    5.821357]  test_alloc+0x10c/0x384
[    5.824868]  test_out_of_bounds_write+0x78/0x164
[    5.829503]  kunit_try_run_case+0x5c/0xd0
[    5.833538]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    5.838949]  kthread+0x15c/0x174
[    5.842202]  ret_from_kernel_thread+0x14/0x1c
[    5.846580]
[    5.848083] CPU: 0 PID: 93 Comm: kunit_try_catch Tainted: G    B 
5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
[    5.859554] ==================================================================
[    5.867115]     ok 3 - test_out_of_bounds_write
[    5.867476]     # test_out_of_bounds_write-memcache: setup_test_cache: size=32, ctor=0x0
[    5.880408]     # test_out_of_bounds_write-memcache: test_alloc: size=32, gfp=cc0, policy=left, 
cache=1
[    5.976421] ==================================================================
[    5.983669] BUG: KFENCE: out-of-bounds write in test_out_of_bounds_write+0x78/0x164
[    5.983669]
[    5.992834] Out-of-bounds write at 0x(ptrval) (1B left of kfence-#28):
[    5.999374]  test_out_of_bounds_write+0x78/0x164
[    6.004016]  kunit_try_run_case+0x5c/0xd0
[    6.008065]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    6.013481]  kthread+0x15c/0x174
[    6.016741]  ret_from_kernel_thread+0x14/0x1c
[    6.021128]
[    6.022631] kfence-#28 [0x(ptrval)-0x(ptrval), size=32, cache=test] allocated by task 94:
[    6.030835]  test_alloc+0xfc/0x384
[    6.034263]  test_out_of_bounds_write+0x78/0x164
[    6.038903]  kunit_try_run_case+0x5c/0xd0
[    6.042944]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    6.048359]  kthread+0x15c/0x174
[    6.051615]  ret_from_kernel_thread+0x14/0x1c
[    6.055998]
[    6.057501] CPU: 0 PID: 94 Comm: kunit_try_catch Tainted: G    B 
5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
[    6.068973] ==================================================================
[    6.076743]     ok 4 - test_out_of_bounds_write-memcache
[    6.077110]     # test_use_after_free_read: test_alloc: size=32, gfp=cc0, policy=any, cache=0
[    6.186527] ==================================================================
[    6.193773] BUG: KFENCE: use-after-free read in test_use_after_free_read+0xa0/0x158
[    6.193773]
[    6.202934] Use-after-free read at 0x(ptrval) (in kfence-#29):
[    6.208777]  test_use_after_free_read+0xa0/0x158
[    6.213417]  kunit_try_run_case+0x5c/0xd0
[    6.217466]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    6.222882]  kthread+0x15c/0x174
[    6.226140]  ret_from_kernel_thread+0x14/0x1c
[    6.230526]
[    6.232026] kfence-#29 [0x(ptrval)-0x(ptrval), size=32, cache=kmalloc-32] allocated by task 95:
[    6.240746]  test_alloc+0x10c/0x384
[    6.244257]  test_use_after_free_read+0x7c/0x158
[    6.248892]  kunit_try_run_case+0x5c/0xd0
[    6.252927]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    6.258337]  kthread+0x15c/0x174
[    6.261590]  ret_from_kernel_thread+0x14/0x1c
[    6.265969]
[    6.265969] freed by task 95:
[    6.270467]  test_use_after_free_read+0xa0/0x158
[    6.275108]  kunit_try_run_case+0x5c/0xd0
[    6.279141]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    6.284551]  kthread+0x15c/0x174
[    6.287802]  ret_from_kernel_thread+0x14/0x1c
[    6.292180]
[    6.293682] CPU: 0 PID: 95 Comm: kunit_try_catch Tainted: G    B 
5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
[    6.305153] ==================================================================
[    6.312658]     ok 5 - test_use_after_free_read
[    6.313020]     # test_use_after_free_read-memcache: setup_test_cache: size=32, ctor=0x0
[    6.325976]     # test_use_after_free_read-memcache: test_alloc: size=32, gfp=cc0, policy=any, 
cache=1
[    6.416496] ==================================================================
[    6.423743] BUG: KFENCE: use-after-free read in test_use_after_free_read+0x98/0x158
[    6.423743]
[    6.432908] Use-after-free read at 0x(ptrval) (in kfence-#30):
[    6.438752]  test_use_after_free_read+0x98/0x158
[    6.443395]  kunit_try_run_case+0x5c/0xd0
[    6.447445]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    6.452863]  kthread+0x15c/0x174
[    6.456124]  ret_from_kernel_thread+0x14/0x1c
[    6.460511]
[    6.462014] kfence-#30 [0x(ptrval)-0x(ptrval), size=32, cache=test] allocated by task 96:
[    6.470219]  test_alloc+0xfc/0x384
[    6.473646]  test_use_after_free_read+0x7c/0x158
[    6.478286]  kunit_try_run_case+0x5c/0xd0
[    6.482327]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    6.487742]  kthread+0x15c/0x174
[    6.490998]  ret_from_kernel_thread+0x14/0x1c
[    6.495381]
[    6.495381] freed by task 96:
[    6.499849]  test_use_after_free_read+0x98/0x158
[    6.504490]  kunit_try_run_case+0x5c/0xd0
[    6.508530]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    6.513945]  kthread+0x15c/0x174
[    6.517201]  ret_from_kernel_thread+0x14/0x1c
[    6.521583]
[    6.523086] CPU: 0 PID: 96 Comm: kunit_try_catch Tainted: G    B 
5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
[    6.534558] ==================================================================
[    6.542222]     ok 6 - test_use_after_free_read-memcache
[    6.542587]     # test_double_free: test_alloc: size=32, gfp=cc0, policy=any, cache=0
[    6.646612] ==================================================================
[    6.653855] BUG: KFENCE: invalid free in test_double_free+0xc0/0x170
[    6.653855]
[    6.661704] Invalid free of 0x(ptrval) (in kfence-#31):
[    6.666940]  test_double_free+0xc0/0x170
[    6.670889]  kunit_try_run_case+0x5c/0xd0
[    6.674928]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    6.680341]  kthread+0x15c/0x174
[    6.683596]  ret_from_kernel_thread+0x14/0x1c
[    6.687977]
[    6.689478] kfence-#31 [0x(ptrval)-0x(ptrval), size=32, cache=kmalloc-32] allocated by task 97:
[    6.698196]  test_alloc+0x10c/0x384
[    6.701706]  test_double_free+0x7c/0x170
[    6.705649]  kunit_try_run_case+0x5c/0xd0
[    6.709685]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    6.715096]  kthread+0x15c/0x174
[    6.718347]  ret_from_kernel_thread+0x14/0x1c
[    6.722725]
[    6.722725] freed by task 97:
[    6.727222]  test_double_free+0xa0/0x170
[    6.731169]  kunit_try_run_case+0x5c/0xd0
[    6.735203]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    6.740615]  kthread+0x15c/0x174
[    6.743865]  ret_from_kernel_thread+0x14/0x1c
[    6.748243]
[    6.749746] CPU: 0 PID: 97 Comm: kunit_try_catch Tainted: G    B 
5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
[    6.761217] ==================================================================
[    6.768683]     ok 7 - test_double_free
[    6.769043]     # test_double_free-memcache: setup_test_cache: size=32, ctor=0x0
[    6.780589]     # test_double_free-memcache: test_alloc: size=32, gfp=cc0, policy=any, cache=1
[    6.876516] ==================================================================
[    6.883761] BUG: KFENCE: invalid free in test_double_free+0xb4/0x170
[    6.883761]
[    6.891612] Invalid free of 0x(ptrval) (in kfence-#32):
[    6.896854]  test_double_free+0xb4/0x170
[    6.900807]  kunit_try_run_case+0x5c/0xd0
[    6.904857]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    6.910277]  kthread+0x15c/0x174
[    6.913540]  ret_from_kernel_thread+0x14/0x1c
[    6.917930]
[    6.919432] kfence-#32 [0x(ptrval)-0x(ptrval), size=32, cache=test] allocated by task 98:
[    6.927637]  test_alloc+0xfc/0x384
[    6.931067]  test_double_free+0x7c/0x170
[    6.935015]  kunit_try_run_case+0x5c/0xd0
[    6.939057]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    6.944473]  kthread+0x15c/0x174
[    6.947728]  ret_from_kernel_thread+0x14/0x1c
[    6.952113]
[    6.952113] freed by task 98:
[    6.956579]  test_double_free+0x98/0x170
[    6.960528]  kunit_try_run_case+0x5c/0xd0
[    6.964570]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    6.969985]  kthread+0x15c/0x174
[    6.973242]  ret_from_kernel_thread+0x14/0x1c
[    6.977626]
[    6.979130] CPU: 0 PID: 98 Comm: kunit_try_catch Tainted: G    B 
5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
[    6.990602] ==================================================================
[    6.998260]     ok 8 - test_double_free-memcache
[    6.998626]     # test_invalid_addr_free: test_alloc: size=32, gfp=cc0, policy=any, cache=0
[    7.106546] ==================================================================
[    7.113790] BUG: KFENCE: invalid free in test_invalid_addr_free+0xa4/0x178
[    7.113790]
[    7.122159] Invalid free of 0x(ptrval) (in kfence-#33):
[    7.127397]  test_invalid_addr_free+0xa4/0x178
[    7.131867]  kunit_try_run_case+0x5c/0xd0
[    7.135907]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    7.141323]  kthread+0x15c/0x174
[    7.144576]  ret_from_kernel_thread+0x14/0x1c
[    7.148959]
[    7.150460] kfence-#33 [0x(ptrval)-0x(ptrval), size=32, cache=kmalloc-32] allocated by task 99:
[    7.159179]  test_alloc+0x10c/0x384
[    7.162692]  test_invalid_addr_free+0x78/0x178
[    7.167157]  kunit_try_run_case+0x5c/0xd0
[    7.171195]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    7.176608]  kthread+0x15c/0x174
[    7.179862]  ret_from_kernel_thread+0x14/0x1c
[    7.184245]
[    7.185748] CPU: 0 PID: 99 Comm: kunit_try_catch Tainted: G    B 
5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
[    7.197220] ==================================================================
[    7.204816]     ok 9 - test_invalid_addr_free
[    7.205177]     # test_invalid_addr_free-memcache: setup_test_cache: size=32, ctor=0x0
[    7.217849]     # test_invalid_addr_free-memcache: test_alloc: size=32, gfp=cc0, policy=any, cache=1
[    7.306455] ==================================================================
[    7.313701] BUG: KFENCE: invalid free in test_invalid_addr_free+0x98/0x178
[    7.313701]
[    7.322070] Invalid free of 0x(ptrval) (in kfence-#34):
[    7.327310]  test_invalid_addr_free+0x98/0x178
[    7.331781]  kunit_try_run_case+0x5c/0xd0
[    7.335832]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    7.341252]  kthread+0x15c/0x174
[    7.344514]  ret_from_kernel_thread+0x14/0x1c
[    7.348903]
[    7.350405] kfence-#34 [0x(ptrval)-0x(ptrval), size=32, cache=test] allocated by task 100:
[    7.358695]  test_alloc+0xfc/0x384
[    7.362125]  test_invalid_addr_free+0x78/0x178
[    7.366591]  kunit_try_run_case+0x5c/0xd0
[    7.370631]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    7.376047]  kthread+0x15c/0x174
[    7.379303]  ret_from_kernel_thread+0x14/0x1c
[    7.383687]
[    7.385191] CPU: 0 PID: 100 Comm: kunit_try_catch Tainted: G    B 
5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
[    7.396751] ==================================================================
[    7.404531]     ok 10 - test_invalid_addr_free-memcache
[    7.404897]     # test_corruption: test_alloc: size=32, gfp=cc0, policy=left, cache=0
[    7.506510] ==================================================================
[    7.513754] BUG: KFENCE: memory corruption in test_corruption+0xac/0x20c
[    7.513754]
[    7.521951] Corrupted memory at 0x(ptrval) [ ! . . . . . . . . . . . . . . . ] (in kfence-#35):
[    7.530760]  test_corruption+0xac/0x20c
[    7.534624]  kunit_try_run_case+0x5c/0xd0
[    7.538664]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    7.544080]  kthread+0x15c/0x174
[    7.547335]  ret_from_kernel_thread+0x14/0x1c
[    7.551719]
[    7.553219] kfence-#35 [0x(ptrval)-0x(ptrval), size=32, cache=kmalloc-32] allocated by task 101:
[    7.562027]  test_alloc+0x10c/0x384
[    7.565540]  test_corruption+0x7c/0x20c
[    7.569399]  kunit_try_run_case+0x5c/0xd0
[    7.573437]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    7.578850]  kthread+0x15c/0x174
[    7.582104]  ret_from_kernel_thread+0x14/0x1c
[    7.586485]
[    7.587988] CPU: 0 PID: 101 Comm: kunit_try_catch Tainted: G    B 
5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
[    7.599545] ==================================================================
[    7.606994]     # test_corruption: test_alloc: size=32, gfp=cc0, policy=right, cache=0
[    7.976603] ==================================================================
[    7.983846] BUG: KFENCE: memory corruption in test_corruption+0x168/0x20c
[    7.983846]
[    7.992128] Corrupted memory at 0x(ptrval) [ ! ] (in kfence-#38):
[    7.998258]  test_corruption+0x168/0x20c
[    8.002208]  kunit_try_run_case+0x5c/0xd0
[    8.006247]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    8.011661]  kthread+0x15c/0x174
[    8.014915]  ret_from_kernel_thread+0x14/0x1c
[    8.019297]
[    8.020797] kfence-#38 [0x(ptrval)-0x(ptrval), size=32, cache=kmalloc-32] allocated by task 101:
[    8.029603]  test_alloc+0x10c/0x384
[    8.033114]  test_corruption+0x138/0x20c
[    8.037057]  kunit_try_run_case+0x5c/0xd0
[    8.041092]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    8.046503]  kthread+0x15c/0x174
[    8.049752]  ret_from_kernel_thread+0x14/0x1c
[    8.054131]
[    8.055633] CPU: 0 PID: 101 Comm: kunit_try_catch Tainted: G    B 
5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
[    8.067190] ==================================================================
[    8.074671]     ok 11 - test_corruption
[    8.075043]     # test_corruption-memcache: setup_test_cache: size=32, ctor=0x0
[    8.086586]     # test_corruption-memcache: test_alloc: size=32, gfp=cc0, policy=left, cache=1
[    8.436449] ==================================================================
[    8.443694] BUG: KFENCE: memory corruption in test_corruption+0xa4/0x20c
[    8.443694]
[    8.451888] Corrupted memory at 0x(ptrval) [ ! . . . . . . . . . . . . . . . ] (in kfence-#41):
[    8.460709]  test_corruption+0xa4/0x20c
[    8.464573]  kunit_try_run_case+0x5c/0xd0
[    8.468622]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    8.474039]  kthread+0x15c/0x174
[    8.477298]  ret_from_kernel_thread+0x14/0x1c
[    8.481685]
[    8.483187] kfence-#41 [0x(ptrval)-0x(ptrval), size=32, cache=test] allocated by task 102:
[    8.491476]  test_alloc+0xfc/0x384
[    8.494904]  test_corruption+0x7c/0x20c
[    8.498763]  kunit_try_run_case+0x5c/0xd0
[    8.502801]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    8.508215]  kthread+0x15c/0x174
[    8.511468]  ret_from_kernel_thread+0x14/0x1c
[    8.515849]
[    8.517352] CPU: 0 PID: 102 Comm: kunit_try_catch Tainted: G    B 
5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
[    8.528910] ==================================================================
[    8.536421]     # test_corruption-memcache: test_alloc: size=32, gfp=cc0, policy=right, cache=1
[    8.646543] ==================================================================
[    8.653786] BUG: KFENCE: memory corruption in test_corruption+0x160/0x20c
[    8.653786]
[    8.662066] Corrupted memory at 0x(ptrval) [ ! ] (in kfence-#42):
[    8.668201]  test_corruption+0x160/0x20c
[    8.672151]  kunit_try_run_case+0x5c/0xd0
[    8.676199]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    8.681615]  kthread+0x15c/0x174
[    8.684872]  ret_from_kernel_thread+0x14/0x1c
[    8.689259]
[    8.690760] kfence-#42 [0x(ptrval)-0x(ptrval), size=32, cache=test] allocated by task 102:
[    8.699050]  test_alloc+0xfc/0x384
[    8.702477]  test_corruption+0x138/0x20c
[    8.706422]  kunit_try_run_case+0x5c/0xd0
[    8.710461]  kunit_generic_run_threadfn_adapter+0x24/0x30
[    8.715875]  kthread+0x15c/0x174
[    8.719130]  ret_from_kernel_thread+0x14/0x1c
[    8.723511]
[    8.725014] CPU: 0 PID: 102 Comm: kunit_try_catch Tainted: G    B 
5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
[    8.736572] ==================================================================
[    8.744274]     ok 12 - test_corruption-memcache
[    8.744642]     # test_free_bulk: test_alloc: size=108, gfp=cc0, policy=right, cache=0
[    8.846447]     # test_free_bulk: test_alloc: size=108, gfp=cc0, policy=none, cache=0
[    8.854317]     # test_free_bulk: test_alloc: size=108, gfp=cc0, policy=left, cache=0
[    8.976407]     # test_free_bulk: test_alloc: size=108, gfp=cc0, policy=none, cache=0
[    8.984275]     # test_free_bulk: test_alloc: size=108, gfp=cc0, policy=none, cache=0
[    8.992322]     # test_free_bulk: test_alloc: size=279, gfp=cc0, policy=right, cache=0
[    9.496452]     # test_free_bulk: test_alloc: size=279, gfp=cc0, policy=none, cache=0
[    9.504323]     # test_free_bulk: test_alloc: size=279, gfp=cc0, policy=left, cache=0
[    9.626404]     # test_free_bulk: test_alloc: size=279, gfp=cc0, policy=none, cache=0
[    9.634272]     # test_free_bulk: test_alloc: size=279, gfp=cc0, policy=none, cache=0
[    9.642331]     # test_free_bulk: test_alloc: size=168, gfp=cc0, policy=right, cache=0
[    9.886438]     # test_free_bulk: test_alloc: size=168, gfp=cc0, policy=none, cache=0
[    9.894309]     # test_free_bulk: test_alloc: size=168, gfp=cc0, policy=left, cache=0
[   10.146407]     # test_free_bulk: test_alloc: size=168, gfp=cc0, policy=none, cache=0
[   10.154277]     # test_free_bulk: test_alloc: size=168, gfp=cc0, policy=none, cache=0
[   10.162329]     # test_free_bulk: test_alloc: size=95, gfp=cc0, policy=right, cache=0
[   10.406442]     # test_free_bulk: test_alloc: size=95, gfp=cc0, policy=none, cache=0
[   10.414225]     # test_free_bulk: test_alloc: size=95, gfp=cc0, policy=left, cache=0
[   10.796405]     # test_free_bulk: test_alloc: size=95, gfp=cc0, policy=none, cache=0
[   10.804189]     # test_free_bulk: test_alloc: size=95, gfp=cc0, policy=none, cache=0
[   10.812156]     # test_free_bulk: test_alloc: size=214, gfp=cc0, policy=right, cache=0
[   11.056442]     # test_free_bulk: test_alloc: size=214, gfp=cc0, policy=none, cache=0
[   11.064312]     # test_free_bulk: test_alloc: size=214, gfp=cc0, policy=left, cache=0
[   11.186407]     # test_free_bulk: test_alloc: size=214, gfp=cc0, policy=none, cache=0
[   11.194276]     # test_free_bulk: test_alloc: size=214, gfp=cc0, policy=none, cache=0
[   11.202357]     ok 13 - test_free_bulk
[   11.202730]     # test_free_bulk-memcache: setup_test_cache: size=264, ctor=0x0
[   11.214213]     # test_free_bulk-memcache: test_alloc: size=264, gfp=cc0, policy=right, cache=1
[   11.316443]     # test_free_bulk-memcache: test_alloc: size=264, gfp=cc0, policy=none, cache=1
[   11.325092]     # test_free_bulk-memcache: test_alloc: size=264, gfp=cc0, policy=left, cache=1
[   11.706404]     # test_free_bulk-memcache: test_alloc: size=264, gfp=cc0, policy=none, cache=1
[   11.715052]     # test_free_bulk-memcache: test_alloc: size=264, gfp=cc0, policy=none, cache=1
[   11.724042]     # test_free_bulk-memcache: setup_test_cache: size=58, ctor=ctor_set_x
[   11.732296]     # test_free_bulk-memcache: test_alloc: size=58, gfp=cc0, policy=right, cache=1
[   12.486442]     # test_free_bulk-memcache: test_alloc: size=58, gfp=cc0, policy=none, cache=1
[   12.495083]     # test_free_bulk-memcache: test_alloc: size=58, gfp=cc0, policy=left, cache=1
[   12.616406]     # test_free_bulk-memcache: test_alloc: size=58, gfp=cc0, policy=none, cache=1
[   12.624967]     # test_free_bulk-memcache: test_alloc: size=58, gfp=cc0, policy=none, cache=1
[   12.633885]     # test_free_bulk-memcache: setup_test_cache: size=260, ctor=0x0
[   12.641609]     # test_free_bulk-memcache: test_alloc: size=260, gfp=cc0, policy=right, cache=1
[   12.746443]     # test_free_bulk-memcache: test_alloc: size=260, gfp=cc0, policy=none, cache=1
[   12.755091]     # test_free_bulk-memcache: test_alloc: size=260, gfp=cc0, policy=left, cache=1
[   13.136401]     # test_free_bulk-memcache: test_alloc: size=260, gfp=cc0, policy=none, cache=1
[   13.145052]     # test_free_bulk-memcache: test_alloc: size=260, gfp=cc0, policy=none, cache=1
[   13.154042]     # test_free_bulk-memcache: setup_test_cache: size=155, ctor=ctor_set_x
[   13.162383]     # test_free_bulk-memcache: test_alloc: size=155, gfp=cc0, policy=right, cache=1
[   13.526458]     # test_free_bulk-memcache: test_alloc: size=155, gfp=cc0, policy=none, cache=1
[   13.535107]     # test_free_bulk-memcache: test_alloc: size=155, gfp=cc0, policy=left, cache=1
[   13.786404]     # test_free_bulk-memcache: test_alloc: size=155, gfp=cc0, policy=none, cache=1
[   13.795051]     # test_free_bulk-memcache: test_alloc: size=155, gfp=cc0, policy=none, cache=1
[   13.804047]     # test_free_bulk-memcache: setup_test_cache: size=173, ctor=0x0
[   13.811768]     # test_free_bulk-memcache: test_alloc: size=173, gfp=cc0, policy=right, cache=1
[   13.916446]     # test_free_bulk-memcache: test_alloc: size=173, gfp=cc0, policy=none, cache=1
[   13.925094]     # test_free_bulk-memcache: test_alloc: size=173, gfp=cc0, policy=left, cache=1
[   14.046408]     # test_free_bulk-memcache: test_alloc: size=173, gfp=cc0, policy=none, cache=1
[   14.055057]     # test_free_bulk-memcache: test_alloc: size=173, gfp=cc0, policy=none, cache=1
[   14.064085]     ok 14 - test_free_bulk-memcache
[   14.064468]     ok 15 - test_init_on_free
[   14.069584]     ok 16 - test_init_on_free-memcache
[   14.073956]     # test_kmalloc_aligned_oob_read: test_alloc: size=73, gfp=cc0, policy=right, cache=0
[   14.176456] ==================================================================
[   14.183702] BUG: KFENCE: out-of-bounds read in test_kmalloc_aligned_oob_read+0x60/0x200
[   14.183702]
[   14.193213] Out-of-bounds read at 0x(ptrval) (81B right of kfence-#84):
[   14.199839]  test_kmalloc_aligned_oob_read+0x60/0x200
[   14.204914]  kunit_try_run_case+0x5c/0xd0
[   14.208964]  kunit_generic_run_threadfn_adapter+0x24/0x30
[   14.214380]  kthread+0x15c/0x174
[   14.217640]  ret_from_kernel_thread+0x14/0x1c
[   14.222026]
[   14.223527] kfence-#84 [0x(ptrval)-0x(ptrval), size=73, cache=kmalloc-96] allocated by task 107:
[   14.232335]  test_alloc+0x10c/0x384
[   14.235847]  test_kmalloc_aligned_oob_read+0x60/0x200
[   14.240916]  kunit_try_run_case+0x5c/0xd0
[   14.244953]  kunit_generic_run_threadfn_adapter+0x24/0x30
[   14.250365]  kthread+0x15c/0x174
[   14.253617]  ret_from_kernel_thread+0x14/0x1c
[   14.257998]
[   14.259501] CPU: 0 PID: 107 Comm: kunit_try_catch Tainted: G    B 
5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
[   14.271058] ==================================================================
[   14.278626]     ok 17 - test_kmalloc_aligned_oob_read
[   14.278987]     # test_kmalloc_aligned_oob_write: test_alloc: size=73, gfp=cc0, policy=right, cache=0
[   14.646606] ==================================================================
[   14.653849] BUG: KFENCE: memory corruption in test_kmalloc_aligned_oob_write+0x104/0x1b0
[   14.653849]
[   14.663430] Corrupted memory at 0x(ptrval) [ ! . . . . . . ] (in kfence-#87):
[   14.670630]  test_kmalloc_aligned_oob_write+0x104/0x1b0
[   14.675880]  kunit_try_run_case+0x5c/0xd0
[   14.679921]  kunit_generic_run_threadfn_adapter+0x24/0x30
[   14.685337]  kthread+0x15c/0x174
[   14.688592]  ret_from_kernel_thread+0x14/0x1c
[   14.692975]
[   14.694477] kfence-#87 [0x(ptrval)-0x(ptrval), size=73, cache=kmalloc-96] allocated by task 108:
[   14.703285]  test_alloc+0x10c/0x384
[   14.706800]  test_kmalloc_aligned_oob_write+0x58/0x1b0
[   14.711959]  kunit_try_run_case+0x5c/0xd0
[   14.715997]  kunit_generic_run_threadfn_adapter+0x24/0x30
[   14.721411]  kthread+0x15c/0x174
[   14.724666]  ret_from_kernel_thread+0x14/0x1c
[   14.729047]
[   14.730551] CPU: 0 PID: 108 Comm: kunit_try_catch Tainted: G    B 
5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
[   14.742108] ==================================================================
[   14.749627]     ok 18 - test_kmalloc_aligned_oob_write
[   14.749989]     # test_shrink_memcache: setup_test_cache: size=32, ctor=0x0
[   14.762405]     # test_shrink_memcache: test_alloc: size=32, gfp=cc0, policy=any, cache=1
[   14.856686]     ok 19 - test_shrink_memcache
[   14.857052]     # test_memcache_ctor: setup_test_cache: size=32, ctor=ctor_set_x
[   14.869060]     # test_memcache_ctor: test_alloc: size=32, gfp=cc0, policy=any, cache=1
[   14.986723]     ok 20 - test_memcache_ctor
[   14.987102] ==================================================================
[   14.998426] BUG: KFENCE: invalid read in finish_task_switch.isra.0+0x54/0x23c
[   14.998426]
[   15.007061] Invalid read at 0x(ptrval):
[   15.010906]  finish_task_switch.isra.0+0x54/0x23c
[   15.015633]  kunit_try_run_case+0x5c/0xd0
[   15.019682]  kunit_generic_run_threadfn_adapter+0x24/0x30
[   15.025099]  kthread+0x15c/0x174
[   15.028359]  ret_from_kernel_thread+0x14/0x1c
[   15.032747]
[   15.034251] CPU: 0 PID: 111 Comm: kunit_try_catch Tainted: G    B 
5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
[   15.045811] ==================================================================
[   15.053324]     # test_invalid_access: EXPECTATION FAILED at mm/kfence/kfence_test.c:636
[   15.053324]     Expected report_matches(&expect) to be true, but is false
[   15.068359]     not ok 21 - test_invalid_access
[   15.068722]     # test_gfpzero: test_alloc: size=4096, gfp=cc0, policy=any, cache=0
[   15.156430]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   15.286387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   15.416379]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   15.546385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   15.676382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   15.806388]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   15.936382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   16.066420]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   16.196384]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   16.326379]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   16.456381]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   16.586400]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   16.716382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   16.846389]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   16.976382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   17.106388]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   17.236380]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   17.366395]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   17.496385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   17.626383]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   17.756398]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   17.886386]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   18.016387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   18.146383]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   18.276385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   18.406388]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   18.536389]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   18.666387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   18.796386]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   18.926381]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   19.056383]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   19.186384]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   19.316388]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   19.446382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   19.576387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   19.706386]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   19.836379]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   19.966387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   20.096387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   20.226387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   20.356381]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   20.486386]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   20.616380]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   20.746387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   20.876379]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   21.006383]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   21.136389]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   21.266385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   21.396385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   21.526382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   21.656387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   21.786385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   21.916385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   22.046381]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   22.176381]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   22.306401]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   22.436383]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   22.566381]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   22.696411]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   22.826388]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   22.956383]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   23.086387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   23.216405]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   23.346379]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   23.476381]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   23.606387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   23.736385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   23.866383]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   23.996386]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   24.126390]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   24.256386]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   24.386382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   24.516388]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   24.646385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   24.776381]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   24.906385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   25.036379]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   25.166381]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   25.296391]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   25.426385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   25.556380]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   25.686385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   25.816387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   25.946382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   26.076379]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   26.206384]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   26.336389]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   26.466383]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   26.596385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   26.726379]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   26.856389]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   26.986384]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   27.116383]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   27.246381]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   27.376387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   27.506395]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   27.636381]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   27.766386]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   27.896381]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   28.026387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   28.156386]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   28.286393]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   28.416388]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   28.546385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   28.676380]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   28.806384]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   28.936387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   29.066390]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   29.196384]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   29.326416]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   29.456388]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   29.586383]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   29.716385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   29.846402]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   29.976396]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   30.106385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   30.236379]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   30.366395]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   30.496386]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   30.626387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   30.756380]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   30.886386]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   31.016381]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   31.146383]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   31.276388]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   31.406386]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   31.536383]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   31.666388]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   31.796384]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   31.926384]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   32.056391]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   32.186382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   32.316385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   32.446391]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   32.576385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   32.706381]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   32.836388]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   32.966388]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   33.096378]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   33.226386]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   33.356383]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   33.486389]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   33.616386]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   33.746383]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   33.876385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   34.006383]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   34.136389]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   34.266384]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   34.396385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   34.526382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   34.656385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   34.786383]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   34.916383]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   35.046390]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   35.176387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   35.306386]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   35.436385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   35.566382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   35.696386]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   35.826383]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   35.956415]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   36.086386]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   36.216382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   36.346378]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   36.476404]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   36.606382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   36.736386]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   36.866381]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   36.996388]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   37.126390]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   37.256395]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   37.386388]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   37.516386]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   37.646382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   37.776385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   37.906385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   38.036389]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   38.166382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   38.296389]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   38.426387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   38.556388]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   38.686388]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   38.816386]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   38.946381]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   39.076382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   39.206387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   39.336386]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   39.466382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   39.596392]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   39.726382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   39.856390]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   39.986389]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   40.116382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   40.246382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   40.376381]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   40.506387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   40.636388]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   40.766387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   40.896381]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   41.026390]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   41.156384]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   41.286380]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   41.416384]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   41.546383]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   41.676388]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   41.806386]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   41.936381]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   42.066390]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   42.196389]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   42.326386]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   42.456390]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   42.586414]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   42.716380]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   42.846386]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   42.976381]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   43.106404]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   43.236385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   43.366387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   43.496382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   43.626385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   43.756378]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   43.886387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   44.016390]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   44.146385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   44.276389]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   44.406382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   44.536384]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   44.666391]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   44.796382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   44.926387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   45.056381]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   45.186384]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   45.316389]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   45.446382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   45.576385]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   45.706382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   45.836387]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   45.966383]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   46.096383]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   46.226382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   46.356382]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   46.486384]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   46.616391]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   46.746386]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   46.876381]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   47.006399]     # test_gfpzero: test_alloc: size=4096, gfp=dc0, policy=any, cache=0
[   47.136923]     ok 22 - test_gfpzero
[   47.137299]     # test_memcache_typesafe_by_rcu: setup_test_cache: size=32, ctor=0x0
[   47.148950]     # test_memcache_typesafe_by_rcu: test_alloc: size=32, gfp=cc0, policy=any, cache=1
[   47.296422] ==================================================================
[   47.303670] BUG: KFENCE: use-after-free read in test_memcache_typesafe_by_rcu+0x210/0x34c
[   47.303670]
[   47.313354] Use-after-free read at 0x(ptrval) (in kfence-#91):
[   47.319199]  test_memcache_typesafe_by_rcu+0x210/0x34c
[   47.324363]  kunit_try_run_case+0x5c/0xd0
[   47.328412]  kunit_generic_run_threadfn_adapter+0x24/0x30
[   47.333830]  kthread+0x15c/0x174
[   47.337090]  ret_from_kernel_thread+0x14/0x1c
[   47.341476]
[   47.342979] kfence-#91 [0x(ptrval)-0x(ptrval), size=32, cache=test] allocated by task 113:
[   47.351269]  test_alloc+0xfc/0x384
[   47.354696]  test_memcache_typesafe_by_rcu+0x100/0x34c
[   47.359855]  kunit_try_run_case+0x5c/0xd0
[   47.363896]  kunit_generic_run_threadfn_adapter+0x24/0x30
[   47.369311]  kthread+0x15c/0x174
[   47.372568]  ret_from_kernel_thread+0x14/0x1c
[   47.376951]
[   47.376951] freed by task 0:
[   47.381401]  rcu_core+0x1c8/0x900
[   47.384741]  __do_softirq+0x13c/0x374
[   47.388431]  irq_exit+0x9c/0xf8
[   47.391599]  ret_from_except+0x0/0x14
[   47.395289]  default_idle_call+0x5c/0x10c
[   47.399326]  do_idle+0x8c/0x118
[   47.402495]  cpu_startup_entry+0x14/0x1c
[   47.406441]  start_kernel+0x4e4/0x530
[   47.410123]  0x37d0
[   47.412239]
[   47.413742] CPU: 0 PID: 113 Comm: kunit_try_catch Tainted: G    B 
5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
[   47.425300] ==================================================================
[   47.432931]     ok 23 - test_memcache_typesafe_by_rcu
[   47.433487]     # test_krealloc: test_alloc: size=32, gfp=cc0, policy=any, cache=0
[   47.556587] ==================================================================
[   47.563835] BUG: KFENCE: use-after-free read in test_krealloc+0x3dc/0x578
[   47.563835]
[   47.572130] Use-after-free read at 0x(ptrval) (in kfence-#93):
[   47.577973]  test_krealloc+0x3dc/0x578
[   47.581751]  kunit_try_run_case+0x5c/0xd0
[   47.585800]  kunit_generic_run_threadfn_adapter+0x24/0x30
[   47.591218]  kthread+0x15c/0x174
[   47.594476]  ret_from_kernel_thread+0x14/0x1c
[   47.598863]
[   47.600364] kfence-#93 [0x(ptrval)-0x(ptrval), size=32, cache=kmalloc-32] allocated by task 114:
[   47.609170]  test_alloc+0x10c/0x384
[   47.612684]  test_krealloc+0x4c/0x578
[   47.616369]  kunit_try_run_case+0x5c/0xd0
[   47.620411]  kunit_generic_run_threadfn_adapter+0x24/0x30
[   47.625825]  kthread+0x15c/0x174
[   47.629078]  ret_from_kernel_thread+0x14/0x1c
[   47.633460]
[   47.633460] freed by task 114:
[   47.638066]  krealloc+0xc4/0x124
[   47.641327]  test_krealloc+0x170/0x578
[   47.645103]  kunit_try_run_case+0x5c/0xd0
[   47.649140]  kunit_generic_run_threadfn_adapter+0x24/0x30
[   47.654554]  kthread+0x15c/0x174
[   47.657808]  ret_from_kernel_thread+0x14/0x1c
[   47.662188]
[   47.663691] CPU: 0 PID: 114 Comm: kunit_try_catch Tainted: G    B 
5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
[   47.675248] ==================================================================
[   47.682686]     ok 24 - test_krealloc
[   47.683045]     # test_memcache_alloc_bulk: setup_test_cache: size=32, ctor=0x0
[   47.786755]     ok 25 - test_memcache_alloc_bulk
[   47.786799] not ok 1 - kfence


^ permalink raw reply

* Re: [PATCH] sound: pps: fix spelling typo of values
From: Takashi Iwai @ 2021-03-02  9:26 UTC (permalink / raw)
  To: dingsenjie; +Cc: geoff, linux-kernel, tiwai, dingsenjie, perex, linuxppc-dev
In-Reply-To: <20210302034053.34524-1-dingsenjie@163.com>

On Tue, 02 Mar 2021 04:40:53 +0100,
dingsenjie@163.com wrote:
> 
> From: dingsenjie <dingsenjie@yulong.com>
> 
> vaules -> values
> 
> Signed-off-by: dingsenjie <dingsenjie@yulong.com>

Thanks, applied.


Takashi

^ permalink raw reply

* Re: [RFC PATCH v1] powerpc: Enable KFENCE for PPC32
From: Christophe Leroy @ 2021-03-02  9:27 UTC (permalink / raw)
  To: Alexander Potapenko
  Cc: Marco Elver, LKML, kasan-dev, Paul Mackerras, linuxppc-dev,
	Dmitry Vyukov
In-Reply-To: <CAG_fn=WFffkVzqC9b6pyNuweFhFswZfa8RRio2nL9-Wq10nBbw@mail.gmail.com>



Le 02/03/2021 à 10:21, Alexander Potapenko a écrit :
>> [   14.998426] BUG: KFENCE: invalid read in finish_task_switch.isra.0+0x54/0x23c
>> [   14.998426]
>> [   15.007061] Invalid read at 0x(ptrval):
>> [   15.010906]  finish_task_switch.isra.0+0x54/0x23c
>> [   15.015633]  kunit_try_run_case+0x5c/0xd0
>> [   15.019682]  kunit_generic_run_threadfn_adapter+0x24/0x30
>> [   15.025099]  kthread+0x15c/0x174
>> [   15.028359]  ret_from_kernel_thread+0x14/0x1c
>> [   15.032747]
>> [   15.034251] CPU: 0 PID: 111 Comm: kunit_try_catch Tainted: G    B
>> 5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
>> [   15.045811] ==================================================================
>> [   15.053324]     # test_invalid_access: EXPECTATION FAILED at mm/kfence/kfence_test.c:636
>> [   15.053324]     Expected report_matches(&expect) to be true, but is false
>> [   15.068359]     not ok 21 - test_invalid_access
> 
> The test expects the function name to be test_invalid_access, i. e.
> the first line should be "BUG: KFENCE: invalid read in
> test_invalid_access".
> The error reporting function unwinds the stack, skips a couple of
> "uninteresting" frames
> (https://elixir.bootlin.com/linux/v5.12-rc1/source/mm/kfence/report.c#L43)
> and uses the first "interesting" one frame to print the report header
> (https://elixir.bootlin.com/linux/v5.12-rc1/source/mm/kfence/report.c#L226).
> 
> It's strange that test_invalid_access is missing altogether from the
> stack trace - is that expected?
> Can you try printing the whole stacktrace without skipping any frames
> to see if that function is there?
> 

Booting with 'no_hash_pointers" I get the following. Does it helps ?

[   16.837198] ==================================================================
[   16.848521] BUG: KFENCE: invalid read in finish_task_switch.isra.0+0x54/0x23c
[   16.848521]
[   16.857158] Invalid read at 0xdf98800a:
[   16.861004]  finish_task_switch.isra.0+0x54/0x23c
[   16.865731]  kunit_try_run_case+0x5c/0xd0
[   16.869780]  kunit_generic_run_threadfn_adapter+0x24/0x30
[   16.875199]  kthread+0x15c/0x174
[   16.878460]  ret_from_kernel_thread+0x14/0x1c
[   16.882847]
[   16.884351] CPU: 0 PID: 111 Comm: kunit_try_catch Tainted: G    B 
5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
[   16.895908] NIP:  c016eb8c LR: c02f50dc CTR: c016eb38
[   16.900963] REGS: e2449d90 TRAP: 0301   Tainted: G    B 
(5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty)
[   16.911386] MSR:  00009032 <EE,ME,IR,DR,RI>  CR: 22000004  XER: 00000000
[   16.918153] DAR: df98800a DSISR: 20000000
[   16.918153] GPR00: c02f50dc e2449e50 c1140d00 e100dd24 c084b13c 00000008 c084b32b c016eb38
[   16.918153] GPR08: c0850000 df988000 c0d10000 e2449eb0 22000288
[   16.936695] NIP [c016eb8c] test_invalid_access+0x54/0x108
[   16.942125] LR [c02f50dc] kunit_try_run_case+0x5c/0xd0
[   16.947292] Call Trace:
[   16.949746] [e2449e50] [c005a5ec] finish_task_switch.isra.0+0x54/0x23c (unreliable)
[   16.957443] [e2449eb0] [c02f50dc] kunit_try_run_case+0x5c/0xd0
[   16.963319] [e2449ed0] [c02f63ec] kunit_generic_run_threadfn_adapter+0x24/0x30
[   16.970574] [e2449ef0] [c004e710] kthread+0x15c/0x174
[   16.975670] [e2449f30] [c001317c] ret_from_kernel_thread+0x14/0x1c
[   16.981896] Instruction dump:
[   16.984879] 8129d608 38e7eb38 81020280 911f004c 39000000 995f0024 907f0028 90ff001c
[   16.992710] 3949000a 915f0020 3d40c0d1 3d00c085 <8929000a> 3908adb0 812a4b98 3d40c02f
[   17.000711] ==================================================================
[   17.008223]     # test_invalid_access: EXPECTATION FAILED at mm/kfence/kfence_test.c:636
[   17.008223]     Expected report_matches(&expect) to be true, but is false
[   17.023243]     not ok 21 - test_invalid_access

^ permalink raw reply

* Re: [RFC PATCH v1] powerpc: Enable KFENCE for PPC32
From: Alexander Potapenko @ 2021-03-02  9:21 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: Marco Elver, LKML, kasan-dev, Paul Mackerras, linuxppc-dev,
	Dmitry Vyukov
In-Reply-To: <b9dc8d35-a3b0-261a-b1a4-5f4d33406095@csgroup.eu>

> [   14.998426] BUG: KFENCE: invalid read in finish_task_switch.isra.0+0x54/0x23c
> [   14.998426]
> [   15.007061] Invalid read at 0x(ptrval):
> [   15.010906]  finish_task_switch.isra.0+0x54/0x23c
> [   15.015633]  kunit_try_run_case+0x5c/0xd0
> [   15.019682]  kunit_generic_run_threadfn_adapter+0x24/0x30
> [   15.025099]  kthread+0x15c/0x174
> [   15.028359]  ret_from_kernel_thread+0x14/0x1c
> [   15.032747]
> [   15.034251] CPU: 0 PID: 111 Comm: kunit_try_catch Tainted: G    B
> 5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
> [   15.045811] ==================================================================
> [   15.053324]     # test_invalid_access: EXPECTATION FAILED at mm/kfence/kfence_test.c:636
> [   15.053324]     Expected report_matches(&expect) to be true, but is false
> [   15.068359]     not ok 21 - test_invalid_access

The test expects the function name to be test_invalid_access, i. e.
the first line should be "BUG: KFENCE: invalid read in
test_invalid_access".
The error reporting function unwinds the stack, skips a couple of
"uninteresting" frames
(https://elixir.bootlin.com/linux/v5.12-rc1/source/mm/kfence/report.c#L43)
and uses the first "interesting" one frame to print the report header
(https://elixir.bootlin.com/linux/v5.12-rc1/source/mm/kfence/report.c#L226).

It's strange that test_invalid_access is missing altogether from the
stack trace - is that expected?
Can you try printing the whole stacktrace without skipping any frames
to see if that function is there?

^ permalink raw reply

* Re: [RFC PATCH v1] powerpc: Enable KFENCE for PPC32
From: Marco Elver @ 2021-03-02  9:53 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: LKML, kasan-dev, Alexander Potapenko, Paul Mackerras,
	linuxppc-dev, Dmitry Vyukov
In-Reply-To: <f806de26-daf9-9317-fdaa-a0f7a32d8fe0@csgroup.eu>

On Tue, 2 Mar 2021 at 10:27, Christophe Leroy
<christophe.leroy@csgroup.eu> wrote:
> Le 02/03/2021 à 10:21, Alexander Potapenko a écrit :
> >> [   14.998426] BUG: KFENCE: invalid read in finish_task_switch.isra.0+0x54/0x23c
> >> [   14.998426]
> >> [   15.007061] Invalid read at 0x(ptrval):
> >> [   15.010906]  finish_task_switch.isra.0+0x54/0x23c
> >> [   15.015633]  kunit_try_run_case+0x5c/0xd0
> >> [   15.019682]  kunit_generic_run_threadfn_adapter+0x24/0x30
> >> [   15.025099]  kthread+0x15c/0x174
> >> [   15.028359]  ret_from_kernel_thread+0x14/0x1c
> >> [   15.032747]
> >> [   15.034251] CPU: 0 PID: 111 Comm: kunit_try_catch Tainted: G    B
> >> 5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
> >> [   15.045811] ==================================================================
> >> [   15.053324]     # test_invalid_access: EXPECTATION FAILED at mm/kfence/kfence_test.c:636
> >> [   15.053324]     Expected report_matches(&expect) to be true, but is false
> >> [   15.068359]     not ok 21 - test_invalid_access
> >
> > The test expects the function name to be test_invalid_access, i. e.
> > the first line should be "BUG: KFENCE: invalid read in
> > test_invalid_access".
> > The error reporting function unwinds the stack, skips a couple of
> > "uninteresting" frames
> > (https://elixir.bootlin.com/linux/v5.12-rc1/source/mm/kfence/report.c#L43)
> > and uses the first "interesting" one frame to print the report header
> > (https://elixir.bootlin.com/linux/v5.12-rc1/source/mm/kfence/report.c#L226).
> >
> > It's strange that test_invalid_access is missing altogether from the
> > stack trace - is that expected?
> > Can you try printing the whole stacktrace without skipping any frames
> > to see if that function is there?
> >
>
> Booting with 'no_hash_pointers" I get the following. Does it helps ?
>
> [   16.837198] ==================================================================
> [   16.848521] BUG: KFENCE: invalid read in finish_task_switch.isra.0+0x54/0x23c
> [   16.848521]
> [   16.857158] Invalid read at 0xdf98800a:
> [   16.861004]  finish_task_switch.isra.0+0x54/0x23c
> [   16.865731]  kunit_try_run_case+0x5c/0xd0
> [   16.869780]  kunit_generic_run_threadfn_adapter+0x24/0x30
> [   16.875199]  kthread+0x15c/0x174
> [   16.878460]  ret_from_kernel_thread+0x14/0x1c
> [   16.882847]
> [   16.884351] CPU: 0 PID: 111 Comm: kunit_try_catch Tainted: G    B
> 5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty #4674
> [   16.895908] NIP:  c016eb8c LR: c02f50dc CTR: c016eb38
> [   16.900963] REGS: e2449d90 TRAP: 0301   Tainted: G    B
> (5.12.0-rc1-s3k-dev-01534-g4f14ae75edf0-dirty)
> [   16.911386] MSR:  00009032 <EE,ME,IR,DR,RI>  CR: 22000004  XER: 00000000
> [   16.918153] DAR: df98800a DSISR: 20000000
> [   16.918153] GPR00: c02f50dc e2449e50 c1140d00 e100dd24 c084b13c 00000008 c084b32b c016eb38
> [   16.918153] GPR08: c0850000 df988000 c0d10000 e2449eb0 22000288
> [   16.936695] NIP [c016eb8c] test_invalid_access+0x54/0x108
> [   16.942125] LR [c02f50dc] kunit_try_run_case+0x5c/0xd0
> [   16.947292] Call Trace:
> [   16.949746] [e2449e50] [c005a5ec] finish_task_switch.isra.0+0x54/0x23c (unreliable)

The "(unreliable)" might be a clue that it's related to ppc32 stack
unwinding. Any ppc expert know what this is about?

> [   16.957443] [e2449eb0] [c02f50dc] kunit_try_run_case+0x5c/0xd0
> [   16.963319] [e2449ed0] [c02f63ec] kunit_generic_run_threadfn_adapter+0x24/0x30
> [   16.970574] [e2449ef0] [c004e710] kthread+0x15c/0x174
> [   16.975670] [e2449f30] [c001317c] ret_from_kernel_thread+0x14/0x1c
> [   16.981896] Instruction dump:
> [   16.984879] 8129d608 38e7eb38 81020280 911f004c 39000000 995f0024 907f0028 90ff001c
> [   16.992710] 3949000a 915f0020 3d40c0d1 3d00c085 <8929000a> 3908adb0 812a4b98 3d40c02f
> [   17.000711] ==================================================================
> [   17.008223]     # test_invalid_access: EXPECTATION FAILED at mm/kfence/kfence_test.c:636
> [   17.008223]     Expected report_matches(&expect) to be true, but is false
> [   17.023243]     not ok 21 - test_invalid_access

On a fault in test_invalid_access, KFENCE prints the stack trace based
on the information in pt_regs. So we do not think there's anything we
can do to improve stack printing pe-se.

What's confusing is that it's only this test, and none of the others.
Given that, it might be code-gen related, which results in some subtle
issue with stack unwinding. There are a few things to try, if you feel
like it:

-- Change the unwinder, if it's possible for ppc32.

-- Add code to test_invalid_access(), to get the compiler to emit
different code. E.g. add a bunch (unnecessary) function calls, or add
barriers, etc.

-- Play with compiler options. We already pass
-fno-optimize-sibling-calls for kfence_test.o to avoid tail-call
optimizations that'd hide stack trace entries. But perhaps there's
something ppc-specific we missed?

Well, the good thing is that KFENCE detects the bad access just fine.
Since, according to the test, everything works from KFENCE's side, I'd
be happy to give my Ack:

  Acked-by: Marco Elver <elver@google.com>

Thanks,
-- Marco

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox