Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1613560pxb; Thu, 4 Nov 2021 05:36:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnasTzCY7NIo3Cc0aLebJNEfu+Jvgzf9kNPU+L3J18p7ElkGLann/qVJTfYqIanH9LdqN9 X-Received: by 2002:a50:9eaa:: with SMTP id a39mr70088528edf.1.1636029377040; Thu, 04 Nov 2021 05:36:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636029377; cv=none; d=google.com; s=arc-20160816; b=Dwi3U6U294lfcF2Yov24I7Wr3lWLZ+KevAwZQbExDeGIcMOZWjRHQ9AMAebEBnWYY7 jP47CY6o5Asz30xx/ZIkd1h6mkyjds26aCF5Ocp3c9/BtC1FCyCIxgJ1LFnygCMD6DNK +rlXeN6e1nLoV8It/PmbokyhCLsZ5mlz7sfT/iMq+ez6aYIVwdds9zX8hoshB6/+bui6 8t6bnfZr+VfsEy/Dm4CdhJwfrsbaRjfITeOJMXw2JtNlGY9JqXZvdzd6Mq6E+KAKGcvN RHIk0uBVswRsc3+dWwjfhp4xXDuldyGCkuivqZtidZ6czTctI0Mu/c2PcdytaaBHXCT/ DPbg== 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 :references:in-reply-to:date:cc:to:from:subject:message-id; bh=fatYzGBhPLwVsaIPHEqc7hbmcO2mbIXWPsE1HvVFASI=; b=Krf7WdF0/KF9ig4hKBnO1jXshCYYKPEWBURSfd0mkkOodUtmmMHPdxuHVFFcjoteU2 mlVrA7P10o2Ko1+ASDbAP9zTJxafALfCe8KymBfBjx4YgkrZJyUG8qpOwBoh+Sjkwv8v GLduYYRZrsuDZ7dkBG+1JDJhsUJyQbmQ9WzHR75gCEEXOkaQhkTP4Guf90E1MsjrNirG BgfR8DT0bpQjaK4ZdyjWpt6yZWPCDE2nMa9OllffkpSt2Gg+7e64rZdH23Q7+I+MTgtQ FbffcQtpROhHMRnZLCfdmyTbuH3dDAO3MhrkJtgC3R2Aj9ftCievlpe9wWrK9P44ojS7 Xj4A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q9si1309335edd.89.2021.11.04.05.35.52; Thu, 04 Nov 2021 05:36:17 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231152AbhKDMdm (ORCPT + 99 others); Thu, 4 Nov 2021 08:33:42 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:49214 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S229809AbhKDMdl (ORCPT ); Thu, 4 Nov 2021 08:33:41 -0400 X-UUID: c651f2c855144886b83e0c995d128bea-20211104 X-UUID: c651f2c855144886b83e0c995d128bea-20211104 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1029824007; Thu, 04 Nov 2021 20:31:01 +0800 Received: from mtkmbs10n1.mediatek.inc (172.21.101.34) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Thu, 4 Nov 2021 20:31:00 +0800 Received: from mtksdccf07 (172.21.84.99) by mtkmbs10n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Thu, 4 Nov 2021 20:31:00 +0800 Message-ID: Subject: Re: [PATCH v2] dma-direct: improve DMA_ATTR_NO_KERNEL_MAPPING From: Walter Wu To: Ard Biesheuvel , Christoph Hellwig CC: Marek Szyprowski , Robin Murphy , Matthias Brugger , "Andrew Morton" , Linux IOMMU , Linux Kernel Mailing List , Linux ARM , wsd_upstream , Date: Thu, 4 Nov 2021 20:31:00 +0800 In-Reply-To: References: <20211104023221.16391-1-walter-zh.wu@mediatek.com> <20211104085336.GA24260@lst.de> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2021-11-04 at 09:57 +0100, Ard Biesheuvel wrote: > On Thu, 4 Nov 2021 at 09:53, Christoph Hellwig wrote: > > > > On Thu, Nov 04, 2021 at 10:32:21AM +0800, Walter Wu wrote: > > > diff --git a/include/linux/set_memory.h > > > b/include/linux/set_memory.h > > > index f36be5166c19..6c7d1683339c 100644 > > > --- a/include/linux/set_memory.h > > > +++ b/include/linux/set_memory.h > > > @@ -7,11 +7,16 @@ > > > > > > #ifdef CONFIG_ARCH_HAS_SET_MEMORY > > > #include > > > + > > > +#ifndef CONFIG_RODATA_FULL_DEFAULT_ENABLED > > > > This is an arm64-specific symbol, and one that only controls a > > default. I don't think it is suitable to key off stubs in common > > code. > > > > > +static inline int set_memory_valid(unsigned long addr, int > > > numpages, int enable) { return 0; } > > > > Pleae avoid overly long lines. > > > > > + if (IS_ENABLED(CONFIG_RODATA_FULL_DEFAULT_ENABLED)) > > > { > > > + kaddr = (unsigned > > > long)phys_to_virt(dma_to_phys(dev, *dma_handle)); > > > > This can just use page_address. > > > > > + /* page remove kernel mapping for arm64 */ > > > + set_memory_valid(kaddr, size >> PAGE_SHIFT, > > > 0); > > > + } > > > > But more importantly: set_memory_valid only exists on arm64, this > > will break compile everywhere else. And this API is complete crap. > > Passing kernel virtual addresses as unsigned long just sucks, and > > passing an integer argument for valid/non-valid also is a horrible > > API. > > > > ... and as I pointed out before, you can still pass rodata=off on > arm64, and get the old behavior, in which case bad things will happen > if you try to use an API that expects to operate on page mappings > with > a 1 GB block mapping. > Thanks for your suggestion. > And you still haven't explained what the actual problem is: is this > about CPU speculation corrupting non-cache coherent inbound DMA? No corrupiton, only cpu read it, we hope to fix the behavior. Thanks. Walter