Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1760644imm; Thu, 9 Aug 2018 01:16:36 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxOKLyIcJYEhuSqRfGr53Bv4geTSar3/6JrDVwBSaXvt5JBtr5A3Xh3E49aq+txp3LPPJka X-Received: by 2002:a62:d085:: with SMTP id p127-v6mr1290399pfg.119.1533802596075; Thu, 09 Aug 2018 01:16:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533802596; cv=none; d=google.com; s=arc-20160816; b=VGJ32l5IGnsx4ibYNh1l5lAzZDwpF06zG8YWHMmcUCkdVQBsKgEmWziN8dvwdl+Z17 QBLpqrZpYOuWFxHGKz5CmOa52HhWVXRSEWu1e3ixbhrCsozCBW3U1T//yc5+SxVZmDkk sWf1UoFrM+3CryplLhohMpz9zj/D9lyY7xRvOerkMyjj67/QzyTreM0jK2XJ7priIg9Y /8VecAMtz737kF2VrV24hEocYO5IjCyvZk7oahfvrQ4ZJinsiZ71QGr0hI/CeYJnidlQ PPZ6ZhMZNVlB2p5YZCvFWOwGO6RP3LbRz4d/8Biw1EODcQinkILT0mFqapg7fpXlIVcl 8XCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:message-id :arc-authentication-results; bh=2wckx8ULv0a/eMUizK5g79Tkq2u/yobK7wj8QtmkhoU=; b=XRTyM7hOovgdbjsyT6bl2I6gPefTFfWWM3qLMGoc2DF8R2DPj3D4chLyNYrKiiwVtC znNvV5K6V25BQf5XQGpHrrLUpT/cJwslwJkAfuqGE8Ur4CK/JEdY/0gwjKrkzmZsSXGH RsyshEUWvOTHlbC856kVsrH51Xcm14IOmhmWa04g1UMo3hFBQDr3cPAdpY6fnPFtO64O UJsAJ9viipoPuJEqk1pKYqfmYtRXJWyFPzzbGy7ZUvVcNAHNH79PdZGzekb6mfejw3KS 2Q3MKIldyWaYAq7NZY2OEa5weqo0cgkHFeEelqiNfwdUVUWaRPCIoSZjKkKTRPT4WImR 5Ukw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a20-v6si6524276pgb.600.2018.08.09.01.16.21; Thu, 09 Aug 2018 01:16:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729846AbeHIKiZ (ORCPT + 99 others); Thu, 9 Aug 2018 06:38:25 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:19299 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727237AbeHIKiZ (ORCPT ); Thu, 9 Aug 2018 06:38:25 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 41mLdW3sN8z9tvQ0; Thu, 9 Aug 2018 10:14:39 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id L1huK3siM7tn; Thu, 9 Aug 2018 10:14:39 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 41mLdW3Ngvz9tvPt; Thu, 9 Aug 2018 10:14:39 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id DE6C38B83F; Thu, 9 Aug 2018 10:14:41 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id xq53Pdpv6AgF; Thu, 9 Aug 2018 10:14:41 +0200 (CEST) Received: from pc16082vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.231.4]) by messagerie.si.c-s.fr (Postfix) with ESMTP id AE1AD8B74B; Thu, 9 Aug 2018 10:14:41 +0200 (CEST) Received: by pc16082vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 89B1071229; Thu, 9 Aug 2018 08:14:41 +0000 (UTC) Message-Id: From: Christophe Leroy Subject: [PATCH] powerpc/lib: Use patch_site to patch copy_32 functions once cache is enabled To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Thu, 9 Aug 2018 08:14:41 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The symbol memcpy_nocache_branch defined in order to allow patching of memset function once cache is enabled leads to confusing reports by perf tool. Using the new patch_site functionality solves this issue. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/asm-prototypes.h | 1 + arch/powerpc/kernel/setup_32.c | 7 +++---- arch/powerpc/lib/copy_32.S | 9 ++++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/include/asm/asm-prototypes.h b/arch/powerpc/include/asm/asm-prototypes.h index 70fdc5b9b9fb..1f4691ce4126 100644 --- a/arch/powerpc/include/asm/asm-prototypes.h +++ b/arch/powerpc/include/asm/asm-prototypes.h @@ -146,6 +146,7 @@ void _kvmppc_save_tm_pr(struct kvm_vcpu *vcpu, u64 guest_msr); /* Patch sites */ extern s32 patch__call_flush_count_cache; extern s32 patch__flush_count_cache_return; +extern s32 patch__memset_nocache, patch__memcpy_nocache; extern long flush_count_cache; diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index 0e3743343280..ba969278bf4d 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c @@ -97,11 +97,10 @@ notrace unsigned long __init early_init(unsigned long dt_ptr) * We do the initial parsing of the flat device-tree and prepares * for the MMU to be fully initialized. */ -extern unsigned int memset_nocache_branch; /* Insn to be replaced by NOP */ - notrace void __init machine_init(u64 dt_ptr) { - unsigned int *addr = &memset_nocache_branch; + unsigned int *addr = (unsigned int *)((unsigned long)&patch__memset_nocache + + patch__memset_nocache); unsigned long insn; /* Configure static keys first, now that we're relocated. */ @@ -110,7 +109,7 @@ notrace void __init machine_init(u64 dt_ptr) /* Enable early debugging if any specified (see udbg.h) */ udbg_early_init(); - patch_instruction((unsigned int *)&memcpy, PPC_INST_NOP); + patch_instruction_site(&patch__memcpy_nocache, PPC_INST_NOP); insn = create_cond_branch(addr, branch_target(addr), 0x820000); patch_instruction(addr, insn); /* replace b by bne cr0 */ diff --git a/arch/powerpc/lib/copy_32.S b/arch/powerpc/lib/copy_32.S index da425bb6b369..ba66846fe973 100644 --- a/arch/powerpc/lib/copy_32.S +++ b/arch/powerpc/lib/copy_32.S @@ -13,6 +13,7 @@ #include #include #include +#include #define COPY_16_BYTES \ lwz r7,4(r4); \ @@ -107,8 +108,8 @@ _GLOBAL(memset) * Skip optimised bloc until cache is enabled. Will be replaced * by 'bne' during boot to use normal procedure if r4 is not zero */ -_GLOBAL(memset_nocache_branch) - b 2f +5: b 2f + patch_site 5b, patch__memset_nocache clrlwi r7,r6,32-LG_CACHELINE_BYTES add r8,r7,r5 @@ -168,7 +169,9 @@ _GLOBAL(memmove) /* fall through */ _GLOBAL(memcpy) - b generic_memcpy +1: b generic_memcpy + patch_site 1b, patch__memcpy_nocache + add r7,r3,r5 /* test if the src & dst overlap */ add r8,r4,r5 cmplw 0,r4,r7 -- 2.13.3