Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1046646pxu; Mon, 23 Nov 2020 10:13:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJzjh92E2L2sBzBaEV09W0deuKtAN2H/dH0h4ztseW+px7az3IuC8sKpAWXiJ6GjdB6PaUsJ X-Received: by 2002:a17:906:7d1:: with SMTP id m17mr823678ejc.98.1606155230951; Mon, 23 Nov 2020 10:13:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606155230; cv=none; d=google.com; s=arc-20160816; b=jUxJ1f+Rwr0ScqUx4ukzpF6pElCTKygdUduenmSHb2DczAPQY/TIE3tvfv7MrXJriD eSVGfCylk2SxUx/K7PI5nEZxFZWctUozNS2pOiOYGL+Fv3kfGjWc173sJpctR/hK9up/ +sr5YgGCKpuYfEflWFTeouRn+56JZ9WQ2jVlkISLgNo0xc8L8SX4FqyrQGLQcnLxvEKO Z7+a6tKzIVVA4EXxxouR8t2UpJKXcD523JxA8n3lUBzO6gFYweXVs1o6TNblGXhiZSMQ QVvyCNy+b1DXuM3PbvmsLsn8CxprjGycn+w74atIthUJ93cW0DJ39iC/2asMp6SGpkSS tPvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=tRbLdzf7nLLz965yR1ha5WkHs6UoOY/QLZBKsNoJJPw=; b=BTQ8MSjhLqTkc6vY5VhWQdvkmy6bN29V+YXvO2C7mOri0yMeIzzFgZlKdhTuXV49nc FdszgZy/LvYdntZtfCy+jgm4DEV/gdEr9DIA12HShVMO6UaEkvgqJe2Dr3gub1R/DrJ1 pfvRFIy03oHJAVTe+8ohtPiA9hYF1BPpXYW0213aKAmQKYgDnK9t4sdCnEM0eJ49IJzL /jsu4YKt/wagnJrv63MFwbL+gxObxHyraIABzW3Xm5W8Uwsbrl+/IU9FSwRb4fmyLFxp I2FAaklZkRWWDxHElEZITvWa6eDxG22qjplr3RNPuxXSBtf4pPUp7eemq/YN2Gm+MBXp sV9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dBR+tZy0; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g3si7102318edj.521.2020.11.23.10.13.27; Mon, 23 Nov 2020 10:13:50 -0800 (PST) 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=@linaro.org header.s=google header.b=dBR+tZy0; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729424AbgKWSKe (ORCPT + 99 others); Mon, 23 Nov 2020 13:10:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726771AbgKWSKd (ORCPT ); Mon, 23 Nov 2020 13:10:33 -0500 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA86BC061A4E for ; Mon, 23 Nov 2020 10:10:33 -0800 (PST) Received: by mail-pf1-x444.google.com with SMTP id v12so15624684pfm.13 for ; Mon, 23 Nov 2020 10:10:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=tRbLdzf7nLLz965yR1ha5WkHs6UoOY/QLZBKsNoJJPw=; b=dBR+tZy0iwKF0n70gHF7fsfCdf7eCjAXKFECem0f7+fzYnRqlcFKu2nna8sZxB5fqO HQmgb5dGJ1nYydgHUNJ+S60UjWo0s71gwQnUHGcVX3k7+EkDeHVXZxYAW0nun2eplQHZ SdU2ZBORtFe5tLv9EqdiEXNxhTLA1a8beMbo70cKjaGCgc+LEFyiwfPLNd6rQwKJCk50 lEaXAsOZYTaBJR8gnETNpLRrpRFoIKvTsdn4Dt4R8z13KzJWKK6c4ZW6HOP3zq0Td/rT 25sYuiDGRLJQC3CVHe5xXbCHebr19ml5FCvbwoZduMmu5UYzfIcrcpAv3wAGos7FbcEe OpRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tRbLdzf7nLLz965yR1ha5WkHs6UoOY/QLZBKsNoJJPw=; b=TUqXPPtb8kFZT590G2R+2mr/GK1ZG389w3ngP5doKDTm3Y0DDF5VG+JPa3f+i2zYBh Rev1NSGpeJLH0Jng2/q4SANoS5QxHRV8d4RcuHGtV5tN73RgZ/Za3ryVrjiy16W1nG3K iZ9ejr66+iKlLrg1PUMjePfXTINCE5RdpKZYmKE64I+/NrNbAlNihlD5ohPl6aoE2N+m O3nSpmpmLhxdwEB01+3VIGUz+GrSaRuf61de8oHBrhU7710RCmmGncRXFzcW/XteyXGW Bv6GZmyv0FhoqQcjkm69TnqEDmbb3o4RGsh1iUjDFmTKquaR0DDRPJYJliqhh7awaNkB yYog== X-Gm-Message-State: AOAM530C3RL0ekaZ+IXp8Ns1Y03yZDu4IsiNXMlGFfZQR6o5LKuHq77K frrmpVSC9afnA432gNts/kIuKQ== X-Received: by 2002:a62:1686:0:b029:197:5d15:2733 with SMTP id 128-20020a6216860000b02901975d152733mr582322pfw.81.1606155033298; Mon, 23 Nov 2020 10:10:33 -0800 (PST) Received: from xps15 (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id b17sm12688815pfi.61.2020.11.23.10.10.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 10:10:32 -0800 (PST) Date: Mon, 23 Nov 2020 11:10:30 -0700 From: Mathieu Poirier To: Suzuki K Poulose Cc: Sai Prakash Ranjan , Mike Leach , coresight@lists.linaro.org, Stephen Boyd , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Mao Jinlong , stable@vger.kernel.org Subject: Re: [PATCH] coresight: tmc-etr: Check if page is valid before dma_map_page() Message-ID: <20201123181030.GC104873@xps15> References: <20201123102133.18979-1-saiprakash.ranjan@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 23, 2020 at 10:46:56AM +0000, Suzuki K Poulose wrote: > On 11/23/20 10:21 AM, Sai Prakash Ranjan wrote: > > From: Mao Jinlong > > > > alloc_pages_node() return should be checked before calling > > dma_map_page() to make sure that valid page is mapped or > > else it can lead to aborts as below: > > > > Unable to handle kernel paging request at virtual address ffffffc008000000 > > Mem abort info: > > ... > > pc : __dma_inv_area+0x40/0x58 > > lr : dma_direct_map_page+0xd8/0x1c8 > > > > Call trace: > > __dma_inv_area > > tmc_pages_alloc > > tmc_alloc_data_pages > > tmc_alloc_sg_table > > tmc_init_etr_sg_table > > tmc_alloc_etr_buf > > tmc_enable_etr_sink_sysfs > > tmc_enable_etr_sink > > coresight_enable_path > > coresight_enable > > enable_source_store > > dev_attr_store > > sysfs_kf_write > > > > Fixes: 99443ea19e8b ("coresight: Add generic TMC sg table framework") > > Cc: stable@vger.kernel.org > > Signed-off-by: Mao Jinlong > > Signed-off-by: Sai Prakash Ranjan > > Reviewed-by: Suzuki K Poulose > Applied - thanks Mathieu > > --- > > drivers/hwtracing/coresight/coresight-tmc-etr.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c > > index 525f0ecc129c..a31a4d7ae25e 100644 > > --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c > > +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c > > @@ -217,6 +217,8 @@ static int tmc_pages_alloc(struct tmc_pages *tmc_pages, > > } else { > > page = alloc_pages_node(node, > > GFP_KERNEL | __GFP_ZERO, 0); > > + if (!page) > > + goto err; > > } > > paddr = dma_map_page(real_dev, page, 0, PAGE_SIZE, dir); > > if (dma_mapping_error(real_dev, paddr)) > > > > base-commit: c04e5d7bbf6f92a346d6b36770705e7f034df42d > > >