Received: by 10.192.165.148 with SMTP id m20csp4169404imm; Tue, 8 May 2018 04:15:16 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqg3SeFI961+XrFAIAxaG0BTWlXBEHEDdONcAMw/eQj+rf/PGalZYf9DM6qMRy3TmihLeiL X-Received: by 10.98.72.29 with SMTP id v29mr33942529pfa.57.1525778116758; Tue, 08 May 2018 04:15:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525778116; cv=none; d=google.com; s=arc-20160816; b=v1h43HHIIlxmb10d5ZAcl6236bakvKvGu2yWm7/nvjcNgjTVGMCYMIhOYEV4iBsjIM t7xl+XJsy3eIdy5wj7EUmqexXqLGk2qD4DC6FCaROZIpYvZxHNUvndI/dESKf+7KYsbo 1Fg28J/HLiKA7uqq2EdfpU4ExhT4OzyvWnlaOv+FDQ1QdI6VKKQMYJA2/Qq1jIKEHLRI 4hEfu0iC+CL8dnRbKRlU/g9U/Hum+wnZWIhWslIVWWnjtYXNcUdO0hw21EqtSFkcl+9O AKQIt5xQ54PntUfMQN9afJ2g73JzCWMhDaOdGYRFv13AR1eN1nPsOkEwyebxu39ythZk pftQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=7HLTtkPT+H6BGc1Kdku89PNiBw+GiMmpP1yHgGNoJiA=; b=JaEunbyHu/cJLntcS52EMfC5NkBqXBRkJo3K+b336HJ+3AGjPBwMpl3GXJETpZWIK1 OXIKo8NoUrHPOPkL00MM2KqqW3ROF181UykswoV4tzCZxBGM+b2AtH5OLLI7rawsVtiJ Y48ISA0B4y+vm+rGP6I55uqOoCgUn8EX11S5sKcrKnj6GiKal/fTy3NDMYw9QprHKPnM rVGuI3Eci3mKrMfY3b39G5tnu1zzQoJxsv0LqRohYGW3AWY9KLbV3ja2KUIHtQCMh6nT FwapX6Qvz0sWV+VIEscDO5aCZFMVcMdDLZ6+6EtPmExjHNaY9ueFx/Zj+VbLgEvw0EGV PAcA== 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 d7-v6si14917273pgq.305.2018.05.08.04.15.02; Tue, 08 May 2018 04:15:16 -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 S1753473AbeEHLOi (ORCPT + 99 others); Tue, 8 May 2018 07:14:38 -0400 Received: from foss.arm.com ([217.140.101.70]:56524 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752347AbeEHLOh (ORCPT ); Tue, 8 May 2018 07:14:37 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F24CD1529; Tue, 8 May 2018 04:14:36 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BB62A3F318; Tue, 8 May 2018 04:14:33 -0700 (PDT) Date: Tue, 8 May 2018 12:14:31 +0100 From: Mark Rutland To: Frederic Weisbecker Cc: LKML , Jiri Olsa , Namhyung Kim , Peter Zijlstra , Linus Torvalds , Yoshinori Sato , Benjamin Herrenschmidt , Catalin Marinas , Chris Zankel , Paul Mackerras , Thomas Gleixner , Will Deacon , Michael Ellerman , Rich Felker , Ingo Molnar , Alexander Shishkin , Andy Lutomirski , Arnaldo Carvalho de Melo , Max Filippov Subject: Re: [PATCH 4/9] arm: Split breakpoint validation into "check" and "commit" Message-ID: <20180508111431.ue2zy2v2l3ob6t4h@lakrids.cambridge.arm.com> References: <1525634395-23380-1-git-send-email-frederic@kernel.org> <1525634395-23380-5-git-send-email-frederic@kernel.org> <20180508111323.mmjo4ky4txzi4gx4@lakrids.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180508111323.mmjo4ky4txzi4gx4@lakrids.cambridge.arm.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 08, 2018 at 12:13:23PM +0100, Mark Rutland wrote: > Hi Frederick, Argh, sorry for the typo -- I realise that K should not be there. Mark. > On Sun, May 06, 2018 at 09:19:50PM +0200, Frederic Weisbecker wrote: > > The breakpoint code mixes up attribute check and commit into a single > > code entity. Therefore the validation may return an error due to > > incorrect atributes while still leaving halfway modified architecture > > breakpoint struct. > > > > Prepare fox fixing this misdesign and separate both logics. > > Could you elaborate on what the problem is? I would have expected that > when arch_build_bp_info() returns an error code, we wouldn't > subsequently use the arch_hw_breakpoint information. Where does that > happen? > > I understand that there was a problem on x86 -- I'm just having > difficulty figuring it out. > > I also see that the check and commit hooks have to duplicate a > reasonable amount of logic, e.g. the switch on bp->attr.type. Can we > instead refactor the existing arch_build_bp_info() hooks to use a > temporary arch_hw_breakpoint, and then struct assign it after all the > error cases, e.g. > > static int arch_build_bp_info(struct perf_event *bp) > { > struct arch_hw_breakpoint hbp; > > if (some_condition(bp)) > hbp->field = 0xf00; > > switch (bp->attr.type) { > case FOO: > return -EINVAL; > case BAR: > hbp->other_field = 7; > break; > }; > > if (failure_case(foo)) > return err; > > *counter_arch_bp(bp) = hbp; > } > > ... or is that also problematic? > > Thanks, > Mark.