Received: by 10.223.176.5 with SMTP id f5csp82048wra; Fri, 26 Jan 2018 18:05:58 -0800 (PST) X-Google-Smtp-Source: AH8x2255bj9HMX+eQ5eJvO4X/ZYF9wJDiqyXnO9RD2ATjk231OFKLsRwC8w6+S6RLp723qbWetua X-Received: by 2002:a17:902:2cc1:: with SMTP id n59-v6mr15451225plb.153.1517018758301; Fri, 26 Jan 2018 18:05:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517018758; cv=none; d=google.com; s=arc-20160816; b=N1tkYl7bhKG8dGYHFtoa1DnMQBWvWASXL3ObgdGSjBdhXZzzJTQEfxDGp4Rf3UF/t2 7p1N7ozbpZb6AGlw8yqD+PE4FoxSleSGUvV4h4mXYy7OtEQ2K2OuKCwKh1E9QcNbjQph bXW3UcROtz459Kok6upnh7CSBiOjITZCyJrSuOtQ0IRujQgUB18rKbFbrcfKUcc5MQgF ALCxYfCW3AzCHHCUuFfIB4Q+6LnBS2Vj7Ek3DlQdl2WsBIpUsXv90cZDayXsYNXQjKP6 CA7T/V0L67saZpa1/f6KyZLvEge3v735zek0Y5pxoNEStEw7xf99R0J1MD7mnWRD+mMM L9Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=yCrFAh6y+bYb19+G30fx6bBl/zSCiY5z+qP9NTL5j+I=; b=lbrwWDCDooEIsgKLIaJQ2DZe+gGYBKCo0GnNdSYE03VI60xhm/3sOndg1rUcIVibDP Jaf45kXauGNT1Iw+e4SUNWsXUGX79SE5dxdiYE9hKjQ3dQGcKfRKr9gUzq7oI4xF8fwT VISM8u4JejHdW21ew0OQiAP+m0R6tKCgAdvotL5K5nmGzrWIs2Lzoqen5IxcJaZM6CcA g1tUh4b4jD0gngTKPlyXOzFeOcQdOw9iEgcB/mJfZ78p4lag+D3XDSmkcYEi0Vz9xDHG 4kty9zd4IkhKWZyavfhyuDLGpaVsUsih64GZVki55Y1idH0vfc0UvxyIvOo7E+6YEz6D UhBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h1si7228210pfg.412.2018.01.26.18.05.11; Fri, 26 Jan 2018 18:05:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751647AbeA0CEO (ORCPT + 99 others); Fri, 26 Jan 2018 21:04:14 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:48273 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751394AbeA0CEN (ORCPT ); Fri, 26 Jan 2018 21:04:13 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id A830B42D51CEE; Sat, 27 Jan 2018 10:04:09 +0800 (CST) Received: from [127.0.0.1] (10.142.193.64) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.361.1; Sat, 27 Jan 2018 10:04:04 +0800 Subject: Re: [Linaro-mm-sig] [PATCH v3] staging: android: ion: Zero CMA allocated memory To: Liam Mark , Laura Abbott , "Sumit Semwal" References: CC: , Greg KH , , , "Dan Carpenter" , "Xiaqing (A)" , Zhuangluan Su From: Chen Feng Message-ID: <5A6BDE11.9070403@hisilicon.com> Date: Sat, 27 Jan 2018 10:04:01 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.142.193.64] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/1/27 1:48, Liam Mark wrote: > Since commit 204f672255c2 ("staging: android: ion: Use CMA APIs directly") > the CMA API is now used directly and therefore the allocated memory is no > longer automatically zeroed. > > Explicitly zero CMA allocated memory to ensure that no data is exposed to > userspace. > > Fixes: 204f672255c2 ("staging: android: ion: Use CMA APIs directly") > Signed-off-by: Liam Mark > --- > Changes in v2: > - Clean up the commit message. > - Add 'Fixes:' > > Changes in v3: > - Add support for highmem pages > > drivers/staging/android/ion/ion_cma_heap.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c > index 86196ffd2faf..fa3e4b7e0c9f 100644 > --- a/drivers/staging/android/ion/ion_cma_heap.c > +++ b/drivers/staging/android/ion/ion_cma_heap.c > @@ -21,6 +21,7 @@ > #include > #include > #include > +#include > > #include "ion.h" > > @@ -51,6 +52,22 @@ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer, > if (!pages) > return -ENOMEM; > > + if (PageHighMem(pages)) { > + unsigned long nr_clear_pages = nr_pages; > + struct page *page = pages; > + > + while (nr_clear_pages > 0) { > + void *vaddr = kmap_atomic(page); > + > + memset(vaddr, 0, PAGE_SIZE); > + kunmap_atomic(vaddr); Here. This way may cause performance latency at mapping-memset-umap page one bye one. Take a look at ion_heap_pages_zero. Not very critical, arm64 always have linear mapping. > + page++; > + nr_clear_pages--; > + } > + } else { > + memset(page_address(pages), 0, size); > + } > + > table = kmalloc(sizeof(*table), GFP_KERNEL); > if (!table) > goto err; >