mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Clément Léger" <cleger@rivosinc.com>
To: David Laight <David.Laight@ACULAB.COM>,
	Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-trace-kernel@vger.kernel.org" 
	<linux-trace-kernel@vger.kernel.org>
Cc: Beau Belgrave <beaub@linux.microsoft.com>
Subject: Re: [PATCH] tracing/user_events: align uaddr on unsigned long alignment
Date: Mon, 18 Sep 2023 10:37:29 +0200	[thread overview]
Message-ID: <086307ce-2d0d-4cf7-98c8-66a00ddec2aa@rivosinc.com> (raw)
In-Reply-To: <94183afa1fca44d18459da3d12a155d3@AcuMS.aculab.com>



On 17/09/2023 23:09, David Laight wrote:
> From: Clément Léger
>> Sent: 14 September 2023 14:11
>>
>> enabler->uaddr can be aligned on 32 or 64 bits. If aligned on 32 bits,
>> this will result in a misaligned access on 64 bits architectures since
>> set_bit()/clear_bit() are expecting an unsigned long (aligned) pointer.
>> On architecture that do not support misaligned access, this will crash
>> the kernel. Align uaddr on unsigned long size to avoid such behavior.
>> This bug was found while running kselftests on RISC-V.
> 
> You don't want to do it on x86-64 either.
> A locked accesses that crosses a cache line boundary is horrid.
> So horrid that recent cpu's can be made to fault.

Hi David,

Thanks for the additional information.

> 
> I'd also doubt that other cpu that can do misaligned transfers
> can even do locked ones.
> 
> For x86 (and LE) the long[] bitmap can be treated as char[]
> avoiding all the problems.
> 
> Perhaps there ought to be bit a bit-array based on char[]
> (not long[]) that would be endianness independent and
> use byte-sized atomics.

That would work for a few architectures but I don't think all of them
have byte "grain" atomics. So I guess Masami solution (long aligned
set/clear_bit()) remains the best out there.

Clément

> (IIRC that is still an issue on sparc32...)
> 
> 	David
> 
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)

      reply	other threads:[~2023-09-18  8:38 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-14 13:11 Clément Léger
2023-09-14 16:42 ` Beau Belgrave
2023-09-14 17:42   ` Clément Léger
2023-09-14 17:17 ` Steven Rostedt
2023-09-14 17:29   ` Steven Rostedt
2023-09-14 17:32     ` Clément Léger
2023-09-19 12:59     ` Clément Léger
2023-09-22 19:22       ` Beau Belgrave
2023-09-25  7:53         ` Clément Léger
2023-09-25 16:04           ` Beau Belgrave
2023-09-25 18:04             ` Clément Léger
2023-09-25 18:22               ` Clément Léger
2023-09-22 20:00       ` Beau Belgrave
2023-09-25  8:10         ` Clément Léger
2023-09-15  2:54 ` Masami Hiramatsu
2023-09-17 14:10   ` Clément Léger
2023-09-17 21:09 ` David Laight
2023-09-18  8:37   ` Clément Léger [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=086307ce-2d0d-4cf7-98c8-66a00ddec2aa@rivosinc.com \
    --to=cleger@rivosinc.com \
    --cc=David.Laight@ACULAB.COM \
    --cc=beaub@linux.microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.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

all inboxes | Powered by JetHome®