Received: by 10.192.165.148 with SMTP id m20csp5401035imm; Wed, 9 May 2018 04:35:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqPsz60zZCUNDo6SwcB2guUqo+KPUiQE7YRp6gcVW+6wybaGXC2hGzjD0MZ5geAbn895Erx X-Received: by 2002:a63:6197:: with SMTP id v145-v6mr36402740pgb.35.1525865718149; Wed, 09 May 2018 04:35:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525865718; cv=none; d=google.com; s=arc-20160816; b=wHzxidQySsFjMFmTLzwrgWYA56WGa7IZLxfWN6TyoYrijqZwiIRqda/Q8TWF8VjTEa QUVEUCC5lEtKCsgl0Bw9Br8W9pbGJo746DFEAcp+gVzR2z86UqoROjxYA1ZiS1qLLqhL i2izl4IXxGoYAPkF6njPxulq8eRZHRzHsYYwbGtmqkT3kOlYJkYdF26Q3tPH4NMvooiG JL5C1FmdZKlMn9CQfxUo/GM06svg7tIOmf/o/RcQA59juO0t2K+2OEkl57SVS9cqW9xe 2niPYT+irWsdmahwxpyeYhf0JHrwpeIugxUdVdhf4pWXFYtNV9De/j67fjUI3BjdXstV x41g== 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=8m8pcU+2KCl5jK8sCeu3/8c/4A8JQ7BeoMXGVpRl+tI=; b=w9hGIyJ4cWb2Vc00I+wpk382LyzYe8k3t/ZMaFYd6bQHoxbk73aeK54rZd4ABBiXfi PGPpZnRBPFTXXa+s59n1MsYZiCfu0jwzni7UEe7lEdS5rCiz3c8ph/leHCxCshvkBdbL x9wtFmzc8a/xbxrC1rGurL8hLzawM4Izjv5V75ZTTgDNsVeJ0gIJXmhN4dZ6BY9WGkFL bt90BwyVZg9uEMo7i9yh07jZkww9F+1ZXy67apFv89RXMhDrbtyiEY9EoKI0w/fT/0ym GJ1kIT95Dm82EIRPjcc+kcYN4JeCG+HcHRzIccxbZ6kibk4/rv8T0V3EaS8a7Cw5wCVE JZkQ== 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 q9-v6si20697222pgp.226.2018.05.09.04.35.03; Wed, 09 May 2018 04:35:18 -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 S934323AbeEILd2 (ORCPT + 99 others); Wed, 9 May 2018 07:33:28 -0400 Received: from foss.arm.com ([217.140.101.70]:42530 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934107AbeEILdD (ORCPT ); Wed, 9 May 2018 07:33:03 -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 5150A1435; Wed, 9 May 2018 04:33:03 -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 17ADA3F318; Wed, 9 May 2018 04:32:59 -0700 (PDT) Date: Wed, 9 May 2018 12:32:57 +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: <20180509113257.hl6frl424trdt2em@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, > > 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? From digging, I now see that this is a problem when modify_user_hw_breakpoint() is called on an existing breakpoint. It would be nice to mention that in the commit message. > 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? IIUC, this *would* work, but it is a little opaque. Perhaps we could explicitly pass the temporary arch_hw_breakpoint in, and have the core code struct-assign it after checking for errors? Thanks, Mark.