Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3407464ybi; Mon, 17 Jun 2019 23:51:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZEiIOlyjAMNXmXrNpgZVfPNi8mfwdBiBEcmoKAYKUhkzZG201Y9oxC7el0i4KAkb6j79x X-Received: by 2002:a63:f50d:: with SMTP id w13mr1247520pgh.411.1560840711509; Mon, 17 Jun 2019 23:51:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560840711; cv=none; d=google.com; s=arc-20160816; b=Y9Oc85P9CZMZtkV4/rnFUYMKWu4nRX17TVDZH91BilzypS8qRCHQporxvd0U1LSgxM IEfpP7P2UjXd80tU4esNOePOxuhx82TcHWZRN83+PEgl5wB1kyUwfDL6Z6EGV5hQ5ZfL SOUeL+ijaaGM+HS6KxMqOJ2zsdXsARij5AdhnJnqLWLmPB53vCSoFQPmm7BkIzypJl+F 0c/jmQ3NhIYKWtjLUFOqbxTGFK0mr69cvZc/ViwDAz38Fd0HZhHBSuuPwT4uRPkc0nL7 1JlEZuPHd1ppCGgdtIgA1OhDrjWQdySUd7MP7oklRiJI06DBhkQa0cwFi+2jf7gbcU5U TKuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=FCB7CdEBbBFcFNkuD3v6ni+zfUzz8NqMtrHA12Q714w=; b=x+9vkXZrddTWAoxsxpbdC/vyX6d5eg2aJv+/9aKRgTi8CRScwNFBMyRLFnNbwC6qSZ 9IOmdiPWADZS4NqUS1MLhWJY2q8Ha3BSVmS5fiERcNROrZwoKi3hh5FxuT5dpDWcUviq o0Pfd/O9dzg+yjZz9irYzQ51/CN4YqAN6/7QvLtXCRTOd/bgqqNtT4VqudedzvEkf5Xh nX18LGMLxeaqaz5gGySeKOpGIi+GgYAbPei18vaRaW0ZjD0eWXPj9ky9S5vhYci0jC/I a4NRh1UVl3LrHOVNbZ+Dja8YPc/P8XH4KhHRK2yrC8cFivK9rAVkHMKj7ObmljTDMhup sdHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=TKNZzGvX; 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 l5si13073478pfl.270.2019.06.17.23.51.36; Mon, 17 Jun 2019 23:51:51 -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; dkim=pass header.i=@c-s.fr header.s=mail header.b=TKNZzGvX; 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 S1728807AbfFRGuz (ORCPT + 99 others); Tue, 18 Jun 2019 02:50:55 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:10503 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725900AbfFRGuo (ORCPT ); Tue, 18 Jun 2019 02:50:44 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 45SdK14Rfwz9vBJt; Tue, 18 Jun 2019 08:21:57 +0200 (CEST) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=TKNZzGvX; dkim-adsp=pass; dkim-atps=neutral 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 KSmGm5VL72on; Tue, 18 Jun 2019 08:21:57 +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 45SdK13G6fz9vBJp; Tue, 18 Jun 2019 08:21:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1560838917; bh=FCB7CdEBbBFcFNkuD3v6ni+zfUzz8NqMtrHA12Q714w=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=TKNZzGvXPy40kaL9LaUOHSsIwHMuZxENX96THuEAeEJRimn1kuU1dGmvPR3FDaC2W 7Jt9nzVF8LwISZuxamxBPn4InCA1/e/hEO+sHFsgDydB+M6A285DccUC2R40a5SeyN e9Ibc5LkeplbAUMVNVKaZfFvrL0Gl9nkNuo8TnHo= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 6DA238B86C; Tue, 18 Jun 2019 08:21:57 +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 qbpbh5PAMYh3; Tue, 18 Jun 2019 08:21:57 +0200 (CEST) Received: from PO15451 (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 78A5A8B78B; Tue, 18 Jun 2019 08:21:56 +0200 (CEST) Subject: Re: [PATCH 2/5] Powerpc/hw-breakpoint: Refactor hw_breakpoint_arch_parse() To: Ravi Bangoria , mpe@ellerman.id.au Cc: benh@kernel.crashing.org, paulus@samba.org, mikey@neuling.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, npiggin@gmail.com, naveen.n.rao@linux.vnet.ibm.com References: <20190618042732.5582-1-ravi.bangoria@linux.ibm.com> <20190618042732.5582-3-ravi.bangoria@linux.ibm.com> From: Christophe Leroy Message-ID: <66e70f57-befa-f241-9476-8e06519bac90@c-s.fr> Date: Tue, 18 Jun 2019 08:21:56 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.1 MIME-Version: 1.0 In-Reply-To: <20190618042732.5582-3-ravi.bangoria@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 18/06/2019 à 06:27, Ravi Bangoria a écrit : > Move feature availability check at the start of the function. > Rearrange comment to it's associated code. Use hw->address and > hw->len in the 512 bytes boundary check(to write if statement > in a single line). Add spacing between code blocks. Are those cosmetic changes in the boundary check worth it since they disappear in the final patch ? Christophe > > Signed-off-by: Ravi Bangoria > --- > arch/powerpc/kernel/hw_breakpoint.c | 34 +++++++++++++++-------------- > 1 file changed, 18 insertions(+), 16 deletions(-) > > diff --git a/arch/powerpc/kernel/hw_breakpoint.c b/arch/powerpc/kernel/hw_breakpoint.c > index 1908e4fcc132..36bcf705df65 100644 > --- a/arch/powerpc/kernel/hw_breakpoint.c > +++ b/arch/powerpc/kernel/hw_breakpoint.c > @@ -133,10 +133,13 @@ int hw_breakpoint_arch_parse(struct perf_event *bp, > const struct perf_event_attr *attr, > struct arch_hw_breakpoint *hw) > { > - int ret = -EINVAL, length_max; > + int length_max; > + > + if (!ppc_breakpoint_available()) > + return -ENODEV; > > if (!bp) > - return ret; > + return -EINVAL; > > hw->type = HW_BRK_TYPE_TRANSLATE; > if (attr->bp_type & HW_BREAKPOINT_R) > @@ -145,34 +148,33 @@ int hw_breakpoint_arch_parse(struct perf_event *bp, > hw->type |= HW_BRK_TYPE_WRITE; > if (hw->type == HW_BRK_TYPE_TRANSLATE) > /* must set alteast read or write */ > - return ret; > + return -EINVAL; > + > if (!attr->exclude_user) > hw->type |= HW_BRK_TYPE_USER; > if (!attr->exclude_kernel) > hw->type |= HW_BRK_TYPE_KERNEL; > if (!attr->exclude_hv) > hw->type |= HW_BRK_TYPE_HYP; > + > hw->address = attr->bp_addr; > hw->len = attr->bp_len; > > - /* > - * Since breakpoint length can be a maximum of HW_BREAKPOINT_LEN(8) > - * and breakpoint addresses are aligned to nearest double-word > - * HW_BREAKPOINT_ALIGN by rounding off to the lower address, the > - * 'symbolsize' should satisfy the check below. > - */ > - if (!ppc_breakpoint_available()) > - return -ENODEV; > length_max = 8; /* DABR */ > if (dawr_enabled()) { > length_max = 512 ; /* 64 doublewords */ > - /* DAWR region can't cross 512 boundary */ > - if ((attr->bp_addr >> 9) != > - ((attr->bp_addr + attr->bp_len - 1) >> 9)) > + /* DAWR region can't cross 512 bytes boundary */ > + if ((hw->address >> 9) != ((hw->address + hw->len - 1) >> 9)) > return -EINVAL; > } > - if (hw->len > > - (length_max - (hw->address & HW_BREAKPOINT_ALIGN))) > + > + /* > + * Since breakpoint length can be a maximum of length_max and > + * breakpoint addresses are aligned to nearest double-word > + * HW_BREAKPOINT_ALIGN by rounding off to the lower address, > + * the 'symbolsize' should satisfy the check below. > + */ > + if (hw->len > (length_max - (hw->address & HW_BREAKPOINT_ALIGN))) > return -EINVAL; > return 0; > } >