All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Finn Thain <fthain@linux-m68k.org>
To: Michael Schmitz <schmitzmic@gmail.com>
Cc: geert@linux-m68k.org, linux-m68k@lists.linux-m68k.org
Subject: Re: [PATCH RFC v2 1/2] m68k: Handle __generic_copy_to_user faults more carefully
Date: Thu, 25 Apr 2024 16:32:35 +1000 (AEST)	[thread overview]
Message-ID: <36a70661-3bfc-46f1-f211-fa87f883371a@linux-m68k.org> (raw)
In-Reply-To: <5d1a552e-f66d-dbbb-5630-42d22870dd15@gmail.com>


On Thu, 25 Apr 2024, Michael Schmitz wrote:

> >
> > I've just tested this on a Motorola 68040 and I got an oops in 
> > __generic_copy_to_user(). It appears that we need more entries in the 
> > exception table. (I also tested in QEMU and it did not oops.)
> 
> I'm a bit puzzled about the location of the fault.
> 
> The values of faddr and a0 from the exception frame indicate that the 
> transfer leading up to the fault was a longword transfer. Both ssw and 
> wbs2 suggest the same. Yet we don't take the fault on the longword 
> moves, but apparently on the word moves right after.
> 
> That can't be right either - d1 is 1 so the word moves would have been 
> skipped. It appears that we only take the movesl fault the next time any 
> bus cycle is initiated on 040 (the moveb at 0x46454c).
> 

Seems so.

> That's different from how the 030 faulted in the same situation. I 
> expect we'll have to add exception table entries on the movew and moveb 
> instructions, too. I'll do that next.
> 
> > This oops indicates that we are going to need the final NOP that was 
> > in the first version of your patch. My test program seems inadequate 
> > to show that it is safe to omit that NOP -- we would need a test which 
> > doesn't jump over the MOVES.B.
> 
> We'd need a test using any number of longword moves expected to succeed, 
> followed by a byte move which is expected to fault. The current test 
> would attempt to do a byte move, but faults during the longword moves.
> 
> This requires running the test program in a directory whose absolute 
> path is a multiple of four characters long, and setting the start 
> address for the getcwd test accordingly, so the newline at the end of 
> the string is the single byte left to copy. Does that make sense?
> 

Yes (I take it you meant NUL instead of LF). But my concern was that the 
test program passes a pointer like 0xc0029000 - 1. That means the final 
byte will land on a word that already faulted. I'll need to add a new test 
that passes a pointer like 0xc0029000 - 5.

> Incidentally - what is the path this tests is run in? Any path longer 
> than five characters (including the newline) would have to had looped 
> back to the first movel, and faulted there?
> 

It was /tmp.

> As you said before - we'd need to know a lot more about 
> microarchitectural details here.
> 

It's hard to be certain. We just have to experiment until we find 
something that works on the CPUs we can test.

  reply	other threads:[~2024-04-25  6:32 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-22  2:29 [PATCH RFC v2 0/2] m68k uaccess fault handling fixes Michael Schmitz
2024-04-22  2:29 ` [PATCH RFC v2 1/2] m68k: Handle __generic_copy_to_user faults more carefully Michael Schmitz
2024-04-25  4:16   ` Finn Thain
2024-04-25  5:32     ` Michael Schmitz
2024-04-25  6:32       ` Finn Thain [this message]
2024-04-25  7:52         ` Michael Schmitz
2024-04-25  5:45     ` Michael Schmitz
2024-04-25  6:47       ` Finn Thain
2024-04-25  7:43         ` Michael Schmitz
2024-04-25  8:20     ` Michael Schmitz
2024-04-25 19:15     ` Michael Schmitz
2024-04-26  1:00       ` Finn Thain
2024-04-26  1:22         ` Michael Schmitz
2024-04-26  7:10           ` Michael Schmitz
2024-04-26  7:57             ` Finn Thain
2024-04-26  8:31               ` Michael Schmitz
2024-04-26  7:58             ` Finn Thain
2024-04-27  1:44               ` Finn Thain
2024-04-27  4:41                 ` Michael Schmitz
2024-04-22  2:29 ` [PATCH RFC v2 2/2] m68k: improve __constant_copy_to_user_asm() fault handling Michael Schmitz

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=36a70661-3bfc-46f1-f211-fa87f883371a@linux-m68k.org \
    --to=fthain@linux-m68k.org \
    --cc=geert@linux-m68k.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=schmitzmic@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.