From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x226KHr6CDEErlXzGfj12obA2SSrkqrDByq4jvJPHqaF04dScfkZb/V0ADkj37qCRfHHejAhE ARC-Seal: i=1; a=rsa-sha256; t=1517018685; cv=none; d=google.com; s=arc-20160816; b=jxRxVlIVY8wiHGW9FCw7ZiqVwRjQ0Uk1NtY36PUGU0yQ9AeEFCU4uHnzWXEginGyCu oi+bClxYLTujCq8e7E1nmpeIGZ7ARHf5iwDcICxZkrtmpKyiDqtNU/ZGlYxF0S+XXAFz yiVnpngkMJ54dFzGShTeWlctz2hBEybCtu2Pph+6hR+SOi14yQGw9HnhCrWrHoeKqN10 iSNf/CSyEH5Ts0gNRQsBiZGpCD0oEYsEMwTiOEgLLYZcuQLQnNPux4OmHJ87nV2E9G4M /1vZbPFhFIskIR3EcY62IJ/h5mN0ZYV7lAN2RdyxWyJuycqSy1BX2al4EU/s3uEHM1et rIcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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=mnlqmTV6twbrR0BQB6/KL2nAne2ZSCtWgj0VROSmzYZAHvQRiCp8pID2jCr8N5oDPu iNWMOho3v18qZBUFNoVlzKnzuoddK6RFry+I+P70cHRXVatbyZp0542Y2v1kovvB4rcB 5gpCmUfAyI3o6G3gc7VAMcu6Aiagoq9NEtCYkN9X6JH2FOV00OUVl0nHZxhzIvbGvXXg djnZn0GBgihhTXsjQO9/61VM3SNIFs5QBbGIiHakBJHRn/TBZoHC+nvesF5XDgwf5LDb lYWURPVaLsgB2Le/aCrwMGqXxcJE4zYnhzAyGpRGEzaiM0CWh64ThDQuGfW7BOYUAr1W nUhQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of puck.chen@hisilicon.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=puck.chen@hisilicon.com Authentication-Results: mx.google.com; spf=pass (google.com: domain of puck.chen@hisilicon.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=puck.chen@hisilicon.com 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1590678153366118365?= X-GMAIL-MSGID: =?utf-8?q?1590709384570360407?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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; >