Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 31 Aug 2020 08:36:48 -0400
From: Rich Felker <>
To: Alexander Monakov <>
Cc:, Theodore Dubois <>
Subject: Re: i386 __set_thread_area will crash if the syscall fails

On Mon, Aug 31, 2020 at 09:55:37AM +0300, Alexander Monakov wrote:
> On Sun, 30 Aug 2020, Rich Felker wrote:
> > > Tangentially, I'm not sure why this file has so many hardcoded magic
> > > numbers and no comments to explain what they are.
> > 
> > Really it shouldn't even be external asm anymore. I'm trying to move
> > as much external asm as possible to inline asm written in C, and this
> > could be written entirely with __syscall() after #define
> > SYSCALL_NO_TLS (recently added) and all the structures setup
> > explicitly in C. I'll take a stab at doing that after fixing the bug.
> I also would like an answer to a question about utter lack of comments
> that your response did not directly address. This is an issue in
> specialized asm implementations of math functions too, for instance.

It's just historically how it was done. In general I don't like
comments that are just translation of the programming language to
human language, which tends to be the case with asm comments, as
opposed to ones that explain purpose, contract, subtle reasons
something is done in a particular way that might not be obvious, etc.
But I do think there's room for the latter kind of comments in files
like this. For instance the saved entry number logic, that modify_ldt
is used as fallback for kernels that aren't actually supported,
how conversion of entry number to a segment register value works, etc.

The same applies to math, and I agree it's frustrating reading that
code with no comments. At the same time, a lot of the frustration is
just the density and weird flow, not the actual math logic, so I think
there's a lot more value in converting them to minimal inline asm
where the flow is in C than in adding comments. Once someone has taken
time to understand the asm enough to comment it, that's at least 90%
of the way to actually doing the conversion.


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.