linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	 Mike Rapoport <rppt@kernel.org>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
	 Ira Weiny <ira.weiny@intel.com>,
	Matthew Wilcox <willy@infradead.org>,
	 Randy Dunlap <rdunlap@infradead.org>
Subject: Re: [PATCH] Documentation/page_tables: Add info about MMU/TLB and Page Faults
Date: Mon, 7 Aug 2023 11:40:30 +0200	[thread overview]
Message-ID: <CACRpkdYcAWDZV0GkdP6gEJv971wjYQ-8WweHkreTJ-w7sfKKQg@mail.gmail.com> (raw)
In-Reply-To: <20230728120054.12306-1-fmdefrancesco@gmail.com>

Hi Fabio,

I'm back from vacation! Overall this documentation looks good and
in line with the reset in this section.

On Fri, Jul 28, 2023 at 2:01 PM Fabio M. De Francesco
<fmdefrancesco@gmail.com> wrote:

> +One cause of page faults is due to bugs (or maliciously crafted addresses) and
> +happens when a process tries to access a range of memory that it doesn't have
> +permission to. This could be because the memory is reserved for the kernel or
> +for another process, or because the process is trying to write to a read-only
> +section of memory. When this happens, the kernel sends a Segmentation Fault
> +(SIGSEGV) signal to the process, which usually causes the process to terminate.

This "segmentation fault" (SIGSEGV reads "signal segmentation violation)
is actually a bit hard to understand for people not familiar
with the 1970ies hardware. The Wikipedia tries to explain it but gets a bit
long and confusing.
https://en.wikipedia.org/wiki/Segmentation_fault

The computers where the first Unix was developed (PDP machines) simply
named its MMU the "memory segmentation unit" so "segmentation fault"
is just a 1970ies way of saying "MMU access violation", which stuck inside
Unix and thus inside Linux. Here is the explanation:
https://wfjm.github.io/blogs/w11/2022-08-18-on-segments-and-pages.html

The binary loader would generously use the plentyful virtual memory
"segments" to split each executable into three segments when loading the binary,
still reflected in ELF binaries to this day:
https://en.wikipedia.org/wiki/Code_segment
https://en.wikipedia.org/wiki/Data_segment
https://en.wikipedia.org/wiki/.bss

Then the page table got special permissions set to each segment for read/write
etc. Other programs and the kernel memory are also in inaccessible segments,
so accessing any of the own segments in the wrong way, or another programs
segment, or an unmapped segment (virtual memory) would all result in the
SIGSEGV opaque message "segmentation fault"

I don't know how to reflect this in a good way in the documentation
though, maybe
copy/paste/edit some of my text or I can try to write something as an additional
patch if you prefer.

Yours,
Linus Walleij


  parent reply	other threads:[~2023-08-07  9:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-28 11:53 Fabio M. De Francesco
2023-08-03 17:08 ` Fabio M. De Francesco
2023-08-07  9:40 ` Linus Walleij [this message]
2023-08-09 13:27   ` Fabio M. De Francesco
2023-08-07 10:50 ` Mike Rapoport
2023-08-09 13:00   ` Fabio M. De Francesco

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=CACRpkdYcAWDZV0GkdP6gEJv971wjYQ-8WweHkreTJ-w7sfKKQg@mail.gmail.com \
    --to=linus.walleij@linaro.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=fmdefrancesco@gmail.com \
    --cc=ira.weiny@intel.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rdunlap@infradead.org \
    --cc=rppt@kernel.org \
    --cc=willy@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