Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3518668rwa; Tue, 23 Aug 2022 06:09:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR4n7ww7w5S/o+niy6UCxtu7419navPvUOUrx6PLLPMcVB5iDw69KN494cs/Qf/g1TxgXDPa X-Received: by 2002:a17:902:db12:b0:172:9e51:64 with SMTP id m18-20020a170902db1200b001729e510064mr24125543plx.140.1661260152261; Tue, 23 Aug 2022 06:09:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661260152; cv=none; d=google.com; s=arc-20160816; b=moqasfRbUNCphU4EGIRZTZ26p89DcdikkgKSunaaDLfUCK74PU4hVLy9S1ElSYGVN2 nzCU11VaEmr2AjFF1jUKi0Sg3WFQATFgJMoUKJSw11oqvPysZdSdAdcGVq1rulNpqNb/ Bq9TD+jiQunoPe3rkNh0k37Un84BZXCSFmFoAVtadsegj4y/REGEH2Aj7Av78O8Rhxfq TLL79X2iizmCBg7y5wze+j381MxowbyxxgFy8n/tQDTxUSYwUPJAthTF3qVho68iAPRh nGgEh6QrZhaGstSKXLj5T3lS4MGh5FPN+sBvk8QufsWzDmTPItn0CieEOivOsat2ExL1 3f4g== 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=ncp5hhhdKEsvJC6wNmA/S3O/8vg09DyBOcgPDG9ZFsU=; b=HQKGfamWMoAsd6ZMgdXofv2PPzItN4jIqFsAEOM8Av/PX7j2kRlYLNhWQVv4mFdG4l 5BTXnS0zSnKJxLUl3nSPljgPHmjHrfz1GlT1vb3xhDx5urNBe+LKQ0OVqfX2jQDFb4JD VmDnwqgGuhIJy2BBaJOYL6PuG9fGtFjug3gUDdoGmCw+yqSAMl2jcwGq7qh8JD4i7NzZ 73mLwi66qWb9hD4KnrRprmMeQwXfhdAgn7X941AIEMP9Sm870e4duNdEDplO45a6fJVD aQo5ZkLMMS2U0VONlcYwFv8CQ+yZCFz9fSko0UaRxRat5WAjGvHzb0zYvq3bf/FzazXX rpEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EJceEUwK; 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 oc3-20020a17090b1c0300b001fb1a260c60si8646663pjb.170.2022.08.23.06.09.01; Tue, 23 Aug 2022 06:09:12 -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=EJceEUwK; 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 S1348704AbiHWLaa (ORCPT + 99 others); Tue, 23 Aug 2022 07:30:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356311AbiHWLZx (ORCPT ); Tue, 23 Aug 2022 07:25:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2E35B2846; Tue, 23 Aug 2022 02:24:07 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 4D0CB612B5; Tue, 23 Aug 2022 09:24:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51C9BC433C1; Tue, 23 Aug 2022 09:24:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661246646; bh=bEUsYd6wc+ozBQ9Hz5f85QXJZqk+pUMxGOXwNgpWbN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EJceEUwK3BPLgEQz9aZYDE7fwYK1WpgC6zjPQ7hjBtDMAKMEdm51kpn7FgrKDo8Yi VgFcHzjCHrHpA1f6KQq516HY3HfdI4S9HuQu0CGN6ltVOlw+JnxV7jQXg90jMqD5LK mCnpKOyjOlpBHG1oqdWvXWKmgA/lDInGduTRhwvU= 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.4 176/389] intel_th: msu: Fix vmalloced buffers Date: Tue, 23 Aug 2022 10:24:14 +0200 Message-Id: <20220823080122.990782804@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080115.331990024@linuxfoundation.org> References: <20220823080115.331990024@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 3cd2489d398c..640b0aae7eb4 100644 --- a/drivers/hwtracing/intel_th/msu.c +++ b/drivers/hwtracing/intel_th/msu.c @@ -1050,6 +1050,16 @@ msc_buffer_set_uc(struct msc_window *win, unsigned int nr_segs) {} static inline void msc_buffer_set_wb(struct msc_window *win) {} #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 @@ -1122,7 +1132,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, @@ -1384,7 +1394,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