public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: "Dr. David Alan Gilbert" <dave@treblig.org>
Cc: iommu@lists.linux.dev, mchehab@kernel.org, hch@lst.de,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: Regression: v4l/bttv vbi vs iommu
Date: Thu, 2 Feb 2023 11:09:26 +0100	[thread overview]
Message-ID: <20230202100926.GA14931@lst.de> (raw)
In-Reply-To: <Y9qSwkLxeMpffZK/@gallifrey>

On Wed, Feb 01, 2023 at 04:26:42PM +0000, Dr. David Alan Gilbert wrote:
> f5ff79fddf0efecca538046b5cc20fb3ded2ec4f is the first bad commit
> commit f5ff79fddf0efecca538046b5cc20fb3ded2ec4f
> Author: Christoph Hellwig <hch@lst.de>
> Date:   Sat Feb 26 16:40:21 2022 +0100
> 
>     dma-mapping: remove CONFIG_DMA_REMAP

Which just enabled some code on common x86 configs that was already
used on many other platforms.  In other words:  the code already
was buggy, but got away with it on x86 so far as no one tested on
e.g. arm or arm64.

The bug is in videobuf_dma_init_kernel:

	for (i = 0; i < nr_pages; i++) {
		void *addr;

		addr = dma_alloc_coherent(dma->dev, PAGE_SIZE,
					  &(dma->dma_addr[i]), GFP_KERNEL);
		if (addr == NULL)
			goto out_free_pages;

		dma->vaddr_pages[i] = virt_to_page(addr);
	}
	dma->vaddr = vmap(dma->vaddr_pages, nr_pages, VM_MAP | VM_IOREMAP,
			  PAGE_KERNEL);

The address by dma_alloc_coherent is just a kernel virtual address,
and virt_to_page must not be used on it as it could be vmalloc (as in
this case) or various other really odd forms of memory.


  parent reply	other threads:[~2023-02-02 10:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-01 16:26 Regression: v4l/bttv vbi vs iommu Dr. David Alan Gilbert
2023-02-01 20:48 ` Hans Verkuil
2023-02-02  3:04   ` Dr. David Alan Gilbert
2023-02-03  6:35   ` Christoph Hellwig
2023-02-03  8:05     ` Hans Verkuil
2023-08-13 13:14       ` Dr. David Alan Gilbert
2023-08-13 13:44         ` Hans Verkuil
2023-11-11 19:57           ` Dr. David Alan Gilbert
2023-11-13 14:38             ` Hans Verkuil
2023-11-14  0:31               ` Dr. David Alan Gilbert
2023-02-02 10:09 ` Christoph Hellwig [this message]
2023-02-02 17:09   ` Dr. David Alan Gilbert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230202100926.GA14931@lst.de \
    --to=hch@lst.de \
    --cc=dave@treblig.org \
    --cc=iommu@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox