Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp628196imm; Tue, 15 May 2018 06:54:55 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpFuH1ugpeO6kq8mzGBr0Pt++hQ2ANxlKtSS5QEh6pV29JhtXRmo6LmU401iXFrLQrhQGL7 X-Received: by 2002:a62:d6da:: with SMTP id a87-v6mr15322798pfl.200.1526392495278; Tue, 15 May 2018 06:54:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526392495; cv=none; d=google.com; s=arc-20160816; b=iRhIKeJHKsDChFrx8102NP08pn67VVkT6/gFABlMQ+iFpUvVUOBnkkG4GmCKmiO7TX S94d5EeLmG1RNGxoc51H7apZXDvNj2rGtygYfz5g+umabhLeGfMSL7N1EFW88NjsmlwI KY2pAxA7UYvEATVyYbxU6mnkKUUX3SvJGBLC4eWtqueEUAj7dGQUvWw8OsD1WW64XuTG rY4QsoEAX5k2g+3I2CbbUF52p86lThTvFvpEjou9DWFR74apQH6dEwRhdxUIm5K8k7vl oAXJIDNl3MFWby2D9t8UHvddfQ46HOf3YY8aDEQD0eld2Khk0cUZ9jwXjPFl7oWN5R7v zE6g== 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:dkim-signature:arc-authentication-results; bh=JD18e4iWqKJV91WGAIM1YDvhMlMxmR/elvoI7EwHJUE=; b=GIVRiUH9DV3WLo0n/ThSjdlIcaVOfN5tTpC96EWpls+yXNhiHpW74TTnUGDC2Nqb6Y WnutXyHwk6l9EIfQ+N3IDx5pG+YE/Epz2GcwL3XoXaW0smN98GcZcT4raRJY7WvhzyzW XFEk1zkZ7JSRnTCqUtqGwl38pUOCSh4gK2qwYqYGhpduQVq71372G4dficb0B11ZaI0X LcvomeBlMRAFq3MU11ImDLcaBU493QXCIOJgVWxIV+3+F9+zFQ/FT7TFdF0PZqlPVFTW NJM74isQlHHzrRF/mYq26MewibNbNBBRgnr+DP8VawYsqYfmiyrvrM9PJjyKOXBTBr1z Jbiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kwcoZfd/; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6-v6si93253pgr.72.2018.05.15.06.54.39; Tue, 15 May 2018 06:54:55 -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=@kernel.org header.s=default header.b=kwcoZfd/; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753483AbeEONfj (ORCPT + 99 others); Tue, 15 May 2018 09:35:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:58290 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753000AbeEONfi (ORCPT ); Tue, 15 May 2018 09:35:38 -0400 Received: from localhost (LFbn-NCY-1-193-82.w83-194.abo.wanadoo.fr [83.194.41.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 02E1421723; Tue, 15 May 2018 13:35:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526391337; bh=fx4bzJNDfXEtW9Iv5oLQbckKl9rM3Obfi+9TslEY09Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kwcoZfd/VKvNp9yTa0AdIdnXNkvZPU4G1A33ydjPlbBA1Smrq4yYsIrrb1nR63H8H wSsJ1kA9ayFdr5xp42xiLt3PYmbfmJs7Z10h/kv6FISHnVf/BCQO+F9PlT2gZMA2wO cLvHNYpLe8RKIh/I9MEphsYe1YQy1eQyQpEmQl+0= Date: Tue, 15 May 2018 15:35:33 +0200 From: Frederic Weisbecker To: Mark Rutland 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: <20180515133532.GA24389@lerouge> 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> <20180509113257.hl6frl424trdt2em@lakrids.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180509113257.hl6frl424trdt2em@lakrids.cambridge.arm.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 09, 2018 at 12:32:57PM +0100, Mark Rutland wrote: > 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. Right, I'll improve the changelog. > > > 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? Exactly, that looks like a good idea, I'm trying that. Thanks.