Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp302236ybb; Tue, 31 Mar 2020 23:50:48 -0700 (PDT) X-Google-Smtp-Source: APiQypJrk7yo3NOFPqoulJBYpSQ6sNc1GhwviEqzq+m1ySP04YdNVwfSqFcKi+2HZDKa15yF+Im7 X-Received: by 2002:a54:4197:: with SMTP id 23mr1843518oiy.87.1585723848353; Tue, 31 Mar 2020 23:50:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585723848; cv=none; d=google.com; s=arc-20160816; b=RpxDXLAcLTlPUwO3veDjwYo9BXJTFu9qL/opq+O05ijvHX9O881QHqtKSbLXH3SA0v 7YYl1fKgBTQvKEkEAaDkRl2xkMfHPv7Y/ap6LnMJfSl/aV6rxcfOphI0SNish2PIZoEt mQCd/ag2jVWf0nROM/L+oBIYdQxpSVtaEolpw5a3E1Vf/WJPeozTsO7hpy06A3/xGFxG qSHTQTH4w1tBfsIPDKVVoWItvL06eKsHjddqgoYmPN9BEED4CQIe70+GgfeMgvCHpEnG S1k6EmDJwHqzsNP4tLmR+bkelDwDizDyHF8An19AYZ/rDIfHcmUrumzqxwfWrYhCP0lr HH1Q== 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=/v/yFC5Me+oB029ChIvZOH8gGHQt7UZV4uLwljZmJUo=; b=yEa3YeXwK1hejklMvbUiqswGRLFvDzBANMCasO845q5PaBNyaMtlbLbfH3Ivp43VPS g3vOUixKQq5vtwRdt2d0M/UwA/iHVXN8hoG+kXeO/jdYlmpL0lIB9suKG3OdeASWN8Hc USscCyRwgawnVqt9DIFcEjuq3OZuBZVTesBJg2nklG4mJ3c+QhLwal519rB5z0nXtF41 6K1ltb3HvUiOSdGQjMoROe9CWs/vSo4j903E9VrXVGqHFVCr49mtBeFdhi/tFh04uvHY 9iHMeyn1KzGATEL9Cnla9R676+7sj8HuMWJlO3XqID63s6lQHtsi6djr6Bqd8xQ6K1HH el9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=uDJQlg1Y; 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 z6si449856otm.218.2020.03.31.23.50.35; Tue, 31 Mar 2020 23:50:48 -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=uDJQlg1Y; 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 S1731885AbgDAGuI (ORCPT + 99 others); Wed, 1 Apr 2020 02:50:08 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:29668 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731741AbgDAGuH (ORCPT ); Wed, 1 Apr 2020 02:50:07 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48scJX6ylSz9tyZJ; Wed, 1 Apr 2020 08:50:04 +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=uDJQlg1Y; 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 rp9wn7S42rj0; Wed, 1 Apr 2020 08:50:04 +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 48scJX5ksnz9tyYt; Wed, 1 Apr 2020 08:50:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1585723804; bh=/v/yFC5Me+oB029ChIvZOH8gGHQt7UZV4uLwljZmJUo=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=uDJQlg1YWF7fudqZaNEW0MQCyx90f8sHgEQit+ZOzHZziOpdB2TsC9GVJWQDF+5bV 7TCsvLELllCQxpE0W7Up3xJDdymf1seXxNtaDrVDTr/29ZuStzu/n7plj50z2U44DR huqR6cocjHjZtuQKrioAxyMsih7fdse9I6DdPJCw= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 870568B7B3; Wed, 1 Apr 2020 08:50:05 +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 wCkTTMMTen22; Wed, 1 Apr 2020 08:50:05 +0200 (CEST) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A894D8B778; Wed, 1 Apr 2020 08:50:02 +0200 (CEST) Subject: Re: [PATCH v2 13/16] powerpc/watchpoint: Prepare handler to handle more than one watcnhpoint To: Ravi Bangoria , mpe@ellerman.id.au, mikey@neuling.org Cc: apopple@linux.ibm.com, paulus@samba.org, npiggin@gmail.com, naveen.n.rao@linux.vnet.ibm.com, peterz@infradead.org, jolsa@kernel.org, oleg@redhat.com, fweisbec@gmail.com, mingo@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <20200401061309.92442-1-ravi.bangoria@linux.ibm.com> <20200401061309.92442-14-ravi.bangoria@linux.ibm.com> From: Christophe Leroy Message-ID: <6b89991b-481a-8cbd-b5b7-559e5e16cf92@c-s.fr> Date: Wed, 1 Apr 2020 08:50:01 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200401061309.92442-14-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 01/04/2020 à 08:13, Ravi Bangoria a écrit : > Currently we assume that we have only one watchpoint supported by hw. > Get rid of that assumption and use dynamic loop instead. This should > make supporting more watchpoints very easy. > > With more than one watchpoint, exception handler need to know which > DAWR caused the exception, and hw currently does not provide it. So > we need sw logic for the same. To figure out which DAWR caused the > exception, check all different combinations of user specified range, > dawr address range, actual access range and dawrx constrains. For ex, > if user specified range and actual access range overlaps but dawrx is > configured for readonly watchpoint and the instruction is store, this > DAWR must not have caused exception. > > Signed-off-by: Ravi Bangoria > --- > arch/powerpc/include/asm/processor.h | 2 +- > arch/powerpc/include/asm/sstep.h | 2 + > arch/powerpc/kernel/hw_breakpoint.c | 396 +++++++++++++++++++++------ > arch/powerpc/kernel/process.c | 3 - > 4 files changed, 313 insertions(+), 90 deletions(-) > [...] > -static bool > -dar_range_overlaps(unsigned long dar, int size, struct arch_hw_breakpoint *info) > +static bool dar_user_range_overlaps(unsigned long dar, int size, > + struct arch_hw_breakpoint *info) > { > return ((dar <= info->address + info->len - 1) && > (dar + size - 1 >= info->address)); > } Here and several other places, I think it would be more clear if you could avoid the - 1 : return ((dar < info->address + info->len) && (dar + size > info->address)); > > +static bool dar_in_hw_range(unsigned long dar, struct arch_hw_breakpoint *info) > +{ > + unsigned long hw_start_addr, hw_end_addr; > + > + hw_start_addr = ALIGN_DOWN(info->address, HW_BREAKPOINT_SIZE); > + hw_end_addr = ALIGN(info->address + info->len, HW_BREAKPOINT_SIZE) - 1; > + > + return ((hw_start_addr <= dar) && (hw_end_addr >= dar)); > +} hw_end_addr = ALIGN(info->address + info->len, HW_BREAKPOINT_SIZE); return ((hw_start_addr <= dar) && (hw_end_addr > dar)); Christophe > + > +static bool dar_hw_range_overlaps(unsigned long dar, int size, > + struct arch_hw_breakpoint *info) > +{ > + unsigned long hw_start_addr, hw_end_addr; > + > + hw_start_addr = ALIGN_DOWN(info->address, HW_BREAKPOINT_SIZE); > + hw_end_addr = ALIGN(info->address + info->len, HW_BREAKPOINT_SIZE) - 1; > + > + return ((dar <= hw_end_addr) && (dar + size - 1 >= hw_start_addr)); > +} Same Christophe