Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3013170rwb; Mon, 15 Aug 2022 16:08:52 -0700 (PDT) X-Google-Smtp-Source: AA6agR6kL20h5k1xa00oJKhNrC44c9GXJG9a5lHDp6OCh6Phx8tOv4j+RRCh8Ndm/n9yH0kNop28 X-Received: by 2002:a05:6402:34c3:b0:43d:d8d7:a328 with SMTP id w3-20020a05640234c300b0043dd8d7a328mr16566764edc.297.1660604932738; Mon, 15 Aug 2022 16:08:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660604932; cv=none; d=google.com; s=arc-20160816; b=hA2hg4MTJDzM4FUOxM1iydTxUjT2NyxYbg+tflGe52e5zk5b8UJgh/w4DKA1Oa97bR 2k1LDitCozQNgAjRhZ9ccdNt1QXOFJ4vIi9HKbdM9Teyo1pBoX6dKscHAhJ3yoBoaVHo ashWp6fWlyUjsq4PXnqn5K40GsYfpL7NDaLTektFPW95UxoH5BQQWJCgrNLDoCJu9kgQ AzMBD3SU8x3m2OrzZms3cmdaOpbqUw/npyf5EcWiiFualTcg490Dd/iWVeoaTGlz//ru rvPgwVIX1neoLtDTSw7x0CWt6ZZAzWBnRZnmaSBkBvpax6sAr24QhBBOARauADhEMcyz w8JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cX+PnMryQpQpPZKAwuvoyaI/GDndbLnJTOYacQtyWYo=; b=VXY9zx8Cna05h37ki96JZEJkCfzys0Tv3sgb1GOYHHvSG2SklXwrYHTsDjcajmCY+1 5IlD9I/8uruZT3kRbfPnKnpLDB2CcyBgZ81vOaRdtpoO2BtFH3AFqQ22sv48MGafS8bz YKtGXmFdNQtdFb/qVTNi6tt1oI4whbKDYU8AorhYn/es4pA6IMDzkt1a5pX9NNl5jWmr mlxwbnhavqX4pkT+dGg+AH99N37TrVFsW8wxhgkkaUajAVnj9HZAfWId9njYNPB07ZoK Q25oM309rpxYD6w2uIttxNpasDvCgD7K18dqG/yMJMyH395G9TmnrBnMUrvFtshnF2Sf kdcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Gk9Ip5g9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kd5-20020a17090798c500b00730ce22906asi8498410ejc.876.2022.08.15.16.08.27; Mon, 15 Aug 2022 16:08:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Gk9Ip5g9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233937AbiHOWFd (ORCPT + 99 others); Mon, 15 Aug 2022 18:05:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343666AbiHOWAA (ORCPT ); Mon, 15 Aug 2022 18:00:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E18E6E21; Mon, 15 Aug 2022 12:35:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A90A6B80EA8; Mon, 15 Aug 2022 19:35:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 039E9C433C1; Mon, 15 Aug 2022 19:35:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592112; bh=pHZiJJno5N6PtNhBHdAXqpWTived2x+RtACMOKKshSQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gk9Ip5g9saG/Of8/EGps7iD1cprgYnnzeslMETL453vCukMMaUdLyMqVxPyoGNr0Y rehl5iHgYQCNogQPGDajflpTF13hBqvMICO/zIrs4ruYvHpPVAByPkmPGgaqwUuuFW UE2Fl8EPB6OOYkNLkSc/5kDyVV+Z7VAKEJ4KYiAI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andy Shevchenko , Alexander Shishkin , Sasha Levin Subject: [PATCH 5.18 0736/1095] intel_th: msu: Fix vmalloced buffers Date: Mon, 15 Aug 2022 20:02:15 +0200 Message-Id: <20220815180459.827651847@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Shishkin [ Upstream commit ac12ad3ccf6d386e64a9d6a890595a2509d24edd ] After commit f5ff79fddf0e ("dma-mapping: remove CONFIG_DMA_REMAP") there's a chance of DMA buffer getting allocated via vmalloc(), which messes up the mmapping code: > RIP: msc_mmap_fault [intel_th_msu] > Call Trace: > > __do_fault > do_fault ... Fix this by accounting for vmalloc possibility. Fixes: ba39bd830605 ("intel_th: msu: Switch over to scatterlist") Reviewed-by: Andy Shevchenko Signed-off-by: Alexander Shishkin Link: https://lore.kernel.org/r/20220705082637.59979-4-alexander.shishkin@linux.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/hwtracing/intel_th/msu.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c index 70a07b4e9967..6c8215a47a60 100644 --- a/drivers/hwtracing/intel_th/msu.c +++ b/drivers/hwtracing/intel_th/msu.c @@ -1067,6 +1067,16 @@ msc_buffer_set_uc(struct msc *msc) {} static inline void msc_buffer_set_wb(struct msc *msc) {} #endif /* CONFIG_X86 */ +static struct page *msc_sg_page(struct scatterlist *sg) +{ + void *addr = sg_virt(sg); + + if (is_vmalloc_addr(addr)) + return vmalloc_to_page(addr); + + return sg_page(sg); +} + /** * msc_buffer_win_alloc() - alloc a window for a multiblock mode * @msc: MSC device @@ -1137,7 +1147,7 @@ static void __msc_buffer_win_free(struct msc *msc, struct msc_window *win) int i; for_each_sg(win->sgt->sgl, sg, win->nr_segs, i) { - struct page *page = sg_page(sg); + struct page *page = msc_sg_page(sg); page->mapping = NULL; dma_free_coherent(msc_dev(win->msc)->parent->parent, PAGE_SIZE, @@ -1401,7 +1411,7 @@ static struct page *msc_buffer_get_page(struct msc *msc, unsigned long pgoff) pgoff -= win->pgoff; for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) { - struct page *page = sg_page(sg); + struct page *page = msc_sg_page(sg); size_t pgsz = PFN_DOWN(sg->length); if (pgoff < pgsz) -- 2.35.1