public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: slash.tmp@free.fr (Mason)
To: linux-arm-kernel@lists.infradead.org
Subject: User-space code aborts on some (but not all) misaligned accesses
Date: Thu, 25 May 2017 00:15:31 +0200	[thread overview]
Message-ID: <a09c99d4-10a0-dcf1-a4fe-9e284ac5275d@free.fr> (raw)
In-Reply-To: <CAKv+Gu83Q1bKa7PhXrSqf3jWj-SDWGcEYW1KdXuBAKbckN4Bvw@mail.gmail.com>

[ Dropping gcc-help at this point ]

On 24/05/2017 19:27, Ard Biesheuvel wrote:

> It is really quite simple
> 1. add the memory to the /memory DT node
> 2. add it as a no-map region to the /reserved-memory DT node
> 
> This should result in pgprot_writecombine() attributes on your O_SYNC
> /dev/mem mapping, which should make the problem go away.

I think I see what you are referring to:

http://elixir.free-electrons.com/linux/latest/source/drivers/char/mem.c#L357

http://elixir.free-electrons.com/linux/latest/source/arch/arm/mm/mmu.c#L701

#ifdef CONFIG_ARM_DMA_MEM_BUFFERABLE
pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
			      unsigned long size, pgprot_t vma_prot)
{
	if (!pfn_valid(pfn))
		return pgprot_noncached(vma_prot);
	else if (file->f_flags & O_SYNC)
		return pgprot_writecombine(vma_prot);
	return vma_prot;
}
EXPORT_SYMBOL(phys_mem_access_prot);
#endif

Telling Linux about the RAM makes pfn_valid() return true,
and using O_SYNC means calling pgprot_writecombine.

Thanks for the pointers.

For my own reference:
https://www.kernel.org/doc/Documentation/unaligned-memory-access.txt
https://www.kernel.org/doc/Documentation/arm/mem_alignment

Regards.

      parent reply	other threads:[~2017-05-24 22:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-24 15:26 User-space code aborts on some (but not all) misaligned accesses Mason
2017-05-24 15:45 ` Robin Murphy
2017-05-24 16:56   ` Mason
2017-05-24 17:25     ` Robin Murphy
2017-05-24 21:19       ` Mason
2017-05-24 17:27     ` Ard Biesheuvel
2017-05-24 17:36       ` Robin Murphy
2017-05-24 17:40         ` Ard Biesheuvel
2017-05-24 22:15       ` Mason [this message]

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=a09c99d4-10a0-dcf1-a4fe-9e284ac5275d@free.fr \
    --to=slash.tmp@free.fr \
    --cc=linux-arm-kernel@lists.infradead.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