Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp203764pxk; Tue, 1 Sep 2020 21:34:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwx9CFy/ift04tVLgwamRoGL7POz7j8L2ULCc/gbLS01R1HqSYcRVKA8qrWgF9RWVD30dCO X-Received: by 2002:a17:906:b090:: with SMTP id x16mr2367096ejy.46.1599021284314; Tue, 01 Sep 2020 21:34:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599021284; cv=none; d=google.com; s=arc-20160816; b=Z/ysRgqbhj2zKvKWkktl3H7m7hR9jW2KcgXvM4N+XZsWemom6o6eP/vxOavJGHlFuj LQqgzbFGAvPw0LSEIshY15lbT44fJ9Qy/ilU70soY3qEWrni1L3UiCBUv3BqnHg0xLUk MWfy/zo77gECnZPnC9dGCy4IpfA7k4qpTITTF/8JWEQPtz7EmMEaQTezScGPNqoRzzpp sXXusOQ28YjYYimMRihhIq/fD+VcJmBaSgWsLjd8FhyFeAlXBwlopMXMfD2SuT/TEVoH DKunb8kL5uvkMtprVmOa+r1rrUWg7TJQ8T+iCu9tyEqWMfYjI4WGDqs0VJU61MVAb3Vv FeZw== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WueL5bbnAhStAjp91dYVMqaOCtsmfsblMRkQBxibmcs=; b=pOUY36Rb+bw/LUpEbIcBi6XtiV6eQRaIM3EhQ5Njrd6rsq88oZZFtDpny6ADAdB+XJ /AOJQv2L9tuplnWG4ECHbK47SAV3/xoKz5WEAoaWY4KzcFOfHvAYh0rwRal1m6fvPGRT nO/tOm+IonjdkBTP77ih4Z/Af4X05e1KLxK5vDB3yx4t4gzBiDWd19BpyjstBVGQWRSJ zr5hj+SIhAl+a1f70sZglMw8bx21pTXTUpsi7OXelmtBvORZpB3LoREtxuQwM2h0zIlk HCv/OXQ5LIhRcAUFl1684SMyTitcpo1y3CtOv2hRe/OwH4/paBZdftMUIViPdvIcPLKf 5v9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=YoUagbRp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oo24si1894792ejb.651.2020.09.01.21.34.19; Tue, 01 Sep 2020 21:34:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=YoUagbRp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726479AbgIBEaY (ORCPT + 99 others); Wed, 2 Sep 2020 00:30:24 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:12864 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726021AbgIBEaV (ORCPT ); Wed, 2 Sep 2020 00:30:21 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 08240iGX133779; Wed, 2 Sep 2020 00:30:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=WueL5bbnAhStAjp91dYVMqaOCtsmfsblMRkQBxibmcs=; b=YoUagbRpGI6C36m5v68OKwd+I4QEd8eiHkpFTlDwVLDyrHyYwuN6MoqZebeHAkl/sJ53 VlVNsYwXcmPBV08UpMxe3d9d83V2OfS8st37tZXQ8+n/r5vL/JqTitqljzn3oVTCszCh KsL74MWM0iDJeOyJhROl6AT65D1j+hcl+If5f+zRRcu7KpRQKppc5AjVTHaCefd1tzrT njHqkvt3YXbc8r4mVkLgW+d67qOaMiN4uJ+xCXxB9sq3c0Ov31u+8FFHG9Rws5NfCJfL CofUa1OJ+MSYyhMZEHMQMvoW/yni8LKQ8O+/gzY7jy9Mrvhgo+aH1W8jbp5z4NVbQBUW bg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 33a160mbtk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Sep 2020 00:30:00 -0400 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 08240iZF133734; Wed, 2 Sep 2020 00:30:00 -0400 Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0b-001b2d01.pphosted.com with ESMTP id 33a160mbt1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Sep 2020 00:30:00 -0400 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0824QfA5011524; Wed, 2 Sep 2020 04:29:58 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma04fra.de.ibm.com with ESMTP id 339ap7rwy1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Sep 2020 04:29:58 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0824SNwL16515494 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 2 Sep 2020 04:28:23 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B8212A405B; Wed, 2 Sep 2020 04:29:54 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1DF68A4054; Wed, 2 Sep 2020 04:29:52 +0000 (GMT) Received: from bangoria.ibmuc.com (unknown [9.199.37.120]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 2 Sep 2020 04:29:51 +0000 (GMT) From: Ravi Bangoria To: mpe@ellerman.id.au, christophe.leroy@c-s.fr Cc: ravi.bangoria@linux.ibm.com, mikey@neuling.org, paulus@samba.org, naveen.n.rao@linux.vnet.ibm.com, pedromfc@linux.ibm.com, rogealve@linux.ibm.com, jniethe5@gmail.com, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 1/8] powerpc/watchpoint: Fix quarword instruction handling on p10 predecessors Date: Wed, 2 Sep 2020 09:59:38 +0530 Message-Id: <20200902042945.129369-2-ravi.bangoria@linux.ibm.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200902042945.129369-1-ravi.bangoria@linux.ibm.com> References: <20200902042945.129369-1-ravi.bangoria@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-09-02_02:2020-09-01,2020-09-02 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 spamscore=0 malwarescore=0 mlxscore=0 clxscore=1015 mlxlogscore=999 lowpriorityscore=0 suspectscore=0 priorityscore=1501 adultscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009020031 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On p10 predecessors, watchpoint with quarword access is compared at quardword length. If the watch range is doubleword or less than that in a first half of quarword aligned 16 bytes, and if there is any unaligned quadword access which will access only the 2nd half, the handler should consider it as extraneous and emulate/single-step it before continuing. Reported-by: Pedro Miraglia Franco de Carvalho Fixes: 74c6881019b7 ("powerpc/watchpoint: Prepare handler to handle more than one watchpoint") Signed-off-by: Ravi Bangoria --- arch/powerpc/include/asm/hw_breakpoint.h | 1 + arch/powerpc/kernel/hw_breakpoint.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/hw_breakpoint.h b/arch/powerpc/include/asm/hw_breakpoint.h index db206a7f38e2..9b68eafebf43 100644 --- a/arch/powerpc/include/asm/hw_breakpoint.h +++ b/arch/powerpc/include/asm/hw_breakpoint.h @@ -42,6 +42,7 @@ struct arch_hw_breakpoint { #else #define HW_BREAKPOINT_SIZE 0x8 #endif +#define HW_BREAKPOINT_SIZE_QUADWORD 0x10 #define DABR_MAX_LEN 8 #define DAWR_MAX_LEN 512 diff --git a/arch/powerpc/kernel/hw_breakpoint.c b/arch/powerpc/kernel/hw_breakpoint.c index 1f4a1efa0074..9f7df1c37233 100644 --- a/arch/powerpc/kernel/hw_breakpoint.c +++ b/arch/powerpc/kernel/hw_breakpoint.c @@ -520,9 +520,17 @@ static bool ea_hw_range_overlaps(unsigned long ea, int size, struct arch_hw_breakpoint *info) { unsigned long hw_start_addr, hw_end_addr; + unsigned long align_size = HW_BREAKPOINT_SIZE; - hw_start_addr = ALIGN_DOWN(info->address, HW_BREAKPOINT_SIZE); - hw_end_addr = ALIGN(info->address + info->len, HW_BREAKPOINT_SIZE); + /* + * On p10 predecessors, quadword is handle differently then + * other instructions. + */ + if (!cpu_has_feature(CPU_FTR_ARCH_31) && size == 16) + align_size = HW_BREAKPOINT_SIZE_QUADWORD; + + hw_start_addr = ALIGN_DOWN(info->address, align_size); + hw_end_addr = ALIGN(info->address + info->len, align_size); return ((ea < hw_end_addr) && (ea + size > hw_start_addr)); } -- 2.26.2