From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FAF1C433E0 for ; Sun, 3 Jan 2021 17:55:12 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B36C120782 for ; Sun, 3 Jan 2021 17:55:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B36C120782 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94) (envelope-from ) id 1kw7ag-0004KF-A8; Sun, 03 Jan 2021 12:54:54 -0500 Received: from mail-yb1-xb33.google.com ([2607:f8b0:4864:20::b33]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1kw7ae-0004Jo-OE for kernelnewbies@kernelnewbies.org; Sun, 03 Jan 2021 12:54:52 -0500 Received: by mail-yb1-xb33.google.com with SMTP id k78so23909486ybf.12 for ; Sun, 03 Jan 2021 09:54:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0La80ZJn4rZ1thrkh84H5Y4YS9D4x+DYuVIPngBzPe0=; b=IDxD3Nz0oNUjlc6as/+uvY9mHS3AfyWCGIDduk53sXEUt8t5WKufRSYBlf4RM02BkC sIH/GMj2QU3nnmrREuT20c1F8jzBaY+/cPvZCA1WqvSmvRPcrO/WfvDrR+vWijk/+kuq 1mEDdI2hE7KyiN4kqT2DmnXA/39Eyna5vL24qW3V/WIjt3AipoMrfQY8Fy9OFl/d58Bx E2WQoEVHaXJyEC9ERxGI+oz2a5zl9bTP9wb6e1XLhzbsgJeInsqXXQWINEQmfaa3BKGX 8XmYRsoLg9X46cMQH24pRp0EOJF1R5QaOIInbmtkY6pmdl1lm2da4GvDc3c2cgkUWPUx VUhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0La80ZJn4rZ1thrkh84H5Y4YS9D4x+DYuVIPngBzPe0=; b=VC3/ZRYp1QuN6pnCVv5jpHk7011793iW6/gBIoW9vUEKo7Tyv6D72iBYSksQzD8EG/ GDzc/VmDjycjylWLohtuSwsUf1XsvfV0S5pn6MnwhuMtB7gwCxooIKxS9qQjl2bv9zMp lv56SL0wklbiB5sDKKOO5EnW3vXC99gtk23R16KkiuPA/zYgqyQI5mFNUBcP0ocCKmqj fDCFhzQY43xwVGYhdUOyjyPxGHcTtR1/Hfqi87Mz/7Gy7S6l1PCV1MmSgDBUtnmVkUra W8nXzWeGx2uGzxlUkLGlDzhgGxBLCcdSqnI90WxqoWUl+cpmF3en/TNVUPo5N1kwKDW6 nNew== X-Gm-Message-State: AOAM533fNcrCRdOXG9Hj0giygyT+6Mlr3RZ4BwAIAXTayfnzOd/sB3on H9IoPWmfbAqUz80Rt5v6S/tDL9lcRt68HuQ7onK4Snoc X-Google-Smtp-Source: ABdhPJy5Z7V0MEcJwI76Xf7sQv5+Ykob82px908oqnX1+8/k30Geak9wq++T3rEOHcM9k+qi/1Ksj3HHNBjoGNhxpHo= X-Received: by 2002:a25:75d6:: with SMTP id q205mr103918814ybc.383.1609696490576; Sun, 03 Jan 2021 09:54:50 -0800 (PST) MIME-Version: 1.0 References: <5C603B48-1AA6-4692-B484-564E08D63E7E@kernel.wtf> In-Reply-To: <5C603B48-1AA6-4692-B484-564E08D63E7E@kernel.wtf> From: Sadanand Warrier Date: Sun, 3 Jan 2021 12:54:39 -0500 Message-ID: Subject: Re: get_user_pages and pinning To: Cengiz Can Cc: kernelnewbies@kernelnewbies.org X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org Cengiz > I don't have an answer to your question because your sentences are too long and I couldn't understand the thing you are asking. A clearer picture below. 1) There is a user program that allocates memory using malloc. It does not initialize the memory. 2) It uses an ioctl to pass a pointer to different areas of this allocated memory to a driver controlling a device. 3) The device is supposed to fill the buffer that this pointer points to with requested data. 4) The driver pins the pages that the pointer points to in memory using get_user_pages. 5) The driver gets the physical (bus) address of this buffer using kernel apis such as dma_map_sg and queues up the DMA. 6) Inspecting the bus address returned by kernel apis shows that the same address is returned for different locations in the buffer. 7) So the DMA fails (rather the device sends the data but it is over writing the same location) 8) It looks like the memory isn't actually allocated by malloc. Not a surprise. 9) It will ideally allocate memory when a write to the memory location occurs. 10) But the write is happening not from user space but by DMA from a device. So the question is what should happen if the memory isn't actually allocated. Should get_user_pages check? It doesn't seem to be doing so. Can it? S _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies