mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Joshua Hudson' <joshudson@gmail.com>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: RE: System Call trashing registers
Date: Mon, 28 Aug 2023 17:06:10 +0000	[thread overview]
Message-ID: <c3b9a46e2cf44ff1a08efadde68248b2@AcuMS.aculab.com> (raw)
In-Reply-To: <CA+jjjYQWeqDY3EFQWmVzV2pXyhfRaHm6s-XWYSXfe1CxvkeuEQ@mail.gmail.com>

From: Joshua Hudson
> Sent: 24 August 2023 17:15
> 
> 1) A lot of my old 32-bit programs don't work on x64 linux anymore
> because int 80h now trashes ecx and edx. This hasn't been a serious
> problem for me.

Aren't both ecx and edx caller saved?
So if the code is using asm syscall wrappers provided the asm
wrappers don't expect the registers be saved (which is unlikely)
then it is safe for the kernel to trash them.

OTOH I have seen code compiled with inlined syscall code
(but not recently). In that case it will matter.

It gets more interesting with all the xmm/ymm/zmm registers.
They are also all caller saved, so if the compiler always
sees a real function call wrapping a system call then the kernel
need not save them and can return with them all set to zero.

I don't believe that is done, but it is likely to be a measurable
performance gain for most programs.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  parent reply	other threads:[~2023-08-28 17:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-24 16:15 Joshua Hudson
2023-08-28 15:06 ` Pavel Machek
2023-08-28 16:41   ` Joshua Hudson
2023-08-28 17:06 ` David Laight [this message]
2023-08-28 17:11   ` Joshua Hudson
2023-09-01 16:24 ` Ammar Faizi
2023-09-01 17:03   ` Thomas Gleixner
2023-09-01 17:38   ` Joshua Hudson
2023-09-01 18:49     ` Thomas Gleixner

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=c3b9a46e2cf44ff1a08efadde68248b2@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=joshudson@gmail.com \
    --cc=linux-kernel@vger.kernel.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

Powered by JetHome