Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5382582rwb; Mon, 14 Nov 2022 04:01:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf6LMebmXt9KdPdpMkjjk1fxOXRcjfbnFtQ0fKpM0GLrN8v4vMQiE7rFUOC1TzVcytanfL9B X-Received: by 2002:a17:902:a508:b0:17f:6845:9be0 with SMTP id s8-20020a170902a50800b0017f68459be0mr13309878plq.158.1668427293407; Mon, 14 Nov 2022 04:01:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668427293; cv=none; d=google.com; s=arc-20160816; b=UHUD5t50gz230wCfEqkIWDGivAvtYnA1GyMDRBmlFJdtjIXINGeDjWXytBrk+cF9DE +xOaaykhG8nX7BmdJC6kxL1RLhB+Kfi7FtDDeYAI01pDf1id+Yd5harohHU2dNtzG8Sz k4PdP9ZItM3qKcUeRxFemxIin6AuUm5TpsxlHZe8stKa/f1mQMDeMABcKb2/PybX+i6x NklTg3kNdqcJ4AkNSE5j+8CZMmqGNB4V7z4RHMPIS1xMM67u7gYpqq6lAPdZWoNWonBa XuS0T9WkEYsBVFwwL5FcUdaGWfOfL+BQFkeUGfQVNvzJyufu/gJernB8XGa5hVjik4De h5pg== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=vBETPaJHyzocIStNZA3XfRFN7+BKiuVhfugdBUV5gm8=; b=wpeXMWTmtt3xDNtCXxaRKRAvphJOcvnp8T3nZ0z73f1wtGWqK7+98AGo6p5lr2DarW o58Gvw/o9BT30Hbrg4DOHssJ80T+ur8kz41Sev72X1lYu27zI+uOm4p0UQYwk5HsRpLj /AfJV2CT6k0v0Nzg+8XWq96tIVEy8lMtrt+xj+dg2xXYRaUhiWuJ/wtV/dwizfU0xzb+ etxX+Yo8wyE26HhOu2cdIAFUd5xgMh/j/86+rQkVecVre4M5QhbAlLTZzpdLRbwgcKLG Tu6TujPzymLQLR2TIQIzqPsLFd69k+ziWv+RLUPFkYBJrjVeA93BzsSXRPxFmYNEB9td HlGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L+KDN2Q5; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h9-20020a056a00170900b00571fad2adaasi4821759pfc.224.2022.11.14.04.01.06; Mon, 14 Nov 2022 04:01:33 -0800 (PST) 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=@linaro.org header.s=google header.b=L+KDN2Q5; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236031AbiKNLaO (ORCPT + 88 others); Mon, 14 Nov 2022 06:30:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236500AbiKNL35 (ORCPT ); Mon, 14 Nov 2022 06:29:57 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E601266B for ; Mon, 14 Nov 2022 03:29:41 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id 130so10690119pfu.8 for ; Mon, 14 Nov 2022 03:29:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=vBETPaJHyzocIStNZA3XfRFN7+BKiuVhfugdBUV5gm8=; b=L+KDN2Q5Uk4aDBsQTOW5tWjZBjXJJ2wTXTQIgtV+4APaRoJIkxZtPcYpnub4DahZTx DhR0T+lzvEdxppO4bB/YLHSCAwlxRQWExF15i1If/zqfvxHfqRAilpBkYdFy24ILAhIU KEeWnhJdkpgnNYoVx3n+DC5tqB3ojoecuauugUny/PhjdjtnNE5O+8sG/NPbpFDkrH4b taXYkIBuPOMc9SYvuiOclrsfut0NkKCoZ7r0+rR0+nIgK5E+nkhhTKaJGF735r8zc6rD cdzcl4JvhzPcPj+sj9i8CW+JNiLHklRxt0Of3TJv1nFI5HXQDjrIgAbL7nkx5hjPhQHN SZiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vBETPaJHyzocIStNZA3XfRFN7+BKiuVhfugdBUV5gm8=; b=Gc1XqIeZl+vkWH60CKsFm5GXOcKUapr5sOMJfBRhBM3kpf+Fka2j1Rv+RCW/q7Rd+g S81oKW/U3USps/f/1e11Z8Y64iF5N/Fka0SIsCkrcwoScsipqTogbOmyd4TAebz+H2Im r4k0wS0CqD79iDUdOfLeTiVOjLmuEz7z1dD57+ISgXes6ks5YbtNkr+x7Bij9RnxS/Tg 106hTLepSBayZ4ean8u7h3Sc/mh5WukKB2Iy6eea+6e4mDAlH+Gc1n0SjTQeoVlZ9o9l XvaCeZVgWwvI3zsP1d8OHi33YK06ecuTzov2lErMayPMPytn8LIZd+vXG0T1SkIA3DId ON2w== X-Gm-Message-State: ANoB5pmdueCEPvtVyisf28wHrQYxGbCOqUC+KlRGfQT8GFR2uHcoH9th eE1IlbjSEmOH6tQjQnG9YtG9kDGLT+Pb X-Received: by 2002:a63:54a:0:b0:46f:fc9c:eb5 with SMTP id 71-20020a63054a000000b0046ffc9c0eb5mr11097737pgf.521.1668425381040; Mon, 14 Nov 2022 03:29:41 -0800 (PST) Received: from thinkpad ([117.248.0.54]) by smtp.gmail.com with ESMTPSA id gk9-20020a17090b118900b00205db4ff6dfsm6245427pjb.46.2022.11.14.03.29.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 03:29:40 -0800 (PST) Date: Mon, 14 Nov 2022 16:59:35 +0530 From: Manivannan Sadhasivam To: catalin.marinas@arm.com, will@kernel.org Cc: robin.murphy@arm.com, amit.pundir@linaro.org, andersson@kernel.org, quic_sibis@quicinc.com, sumit.semwal@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Revert "arm64: dma: Drop cache invalidation from arch_dma_prep_coherent()" Message-ID: <20221114112935.GN3869@thinkpad> References: <20221114110329.68413-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20221114110329.68413-1-manivannan.sadhasivam@linaro.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 On Mon, Nov 14, 2022 at 04:33:29PM +0530, Manivannan Sadhasivam wrote: > This reverts commit c44094eee32f32f175aadc0efcac449d99b1bbf7. > > As reported by Amit [1], dropping cache invalidation from > arch_dma_prep_coherent() triggers a crash on the Qualcomm SM8250 platform s/SM8250/SDM845/g Sorry for the confusion. Thanks, Mani > (most probably on other Qcom platforms too). The reason is, Qcom > qcom_q6v5_mss driver copies the firmware metadata and shares it with modem > for validation. The modem has a secure block (XPU) that will trigger a > whole system crash if the shared memory is accessed by the CPU while modem > is poking at it. > > To avoid this issue, the qcom_q6v5_mss driver allocates a chunk of memory > with no kernel mapping, vmap's it, copies the firmware metadata and > unvmap's it. Finally the address is then shared with modem for metadata > validation [2]. > > Now because of the removal of cache invalidation from > arch_dma_prep_coherent(), there will be cache lines associated with this > memory even after sharing with modem. So when the CPU accesses it, the XPU > violation gets triggered. > > So let's revert this commit to get remoteproc's working (thereby avoiding > full system crash) on Qcom platforms. > > [1] https://lore.kernel.org/linux-arm-kernel/CAMi1Hd1VBCFhf7+EXWHQWcGy4k=tcyLa7RGiFdprtRnegSG0Mw@mail.gmail.com/ > [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/remoteproc/qcom_q6v5_mss.c#n933 > > Signed-off-by: Manivannan Sadhasivam > --- > > Will, Catalin: Please share if you have any other suggestions to handle the > resource sharing in the remoteproc driver that could avoid this revert. > > arch/arm64/mm/dma-mapping.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c > index 3cb101e8cb29..7d7e9a046305 100644 > --- a/arch/arm64/mm/dma-mapping.c > +++ b/arch/arm64/mm/dma-mapping.c > @@ -36,7 +36,7 @@ void arch_dma_prep_coherent(struct page *page, size_t size) > { > unsigned long start = (unsigned long)page_address(page); > > - dcache_clean_poc(start, start + size); > + dcache_clean_inval_poc(start, start + size); > } > > #ifdef CONFIG_IOMMU_DMA > -- > 2.25.1 > -- மணிவண்ணன் சதாசிவம்