linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Uros Bizjak <ubizjak@gmail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Borislav Petkov <bp@suse.de>, x86-ml <x86@kernel.org>,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: [GIT PULL] x86/asm updates for v5.10
Date: Tue, 13 Oct 2020 10:00:45 +0200	[thread overview]
Message-ID: <CAFULd4axRbk4rT_+xuwjWv2J0+TP-qKjNK+QaivOGFdJ3aL+vg@mail.gmail.com> (raw)
In-Reply-To: <CAHk-=whnq+JmKsRwCbUnpZm4ZJLgaiX-KSFMkp7OeeE-RXwRGg@mail.gmail.com>

On Mon, Oct 12, 2020 at 10:57 PM Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> On Mon, Oct 12, 2020 at 1:22 PM Uros Bizjak <ubizjak@gmail.com> wrote:
> >
> > No, this fact is not documented, although there are close to zero
> > chances it will ever change. High registers are independent from their
> > 8bit lowparts, but they still clobber corresponding 16bit, 32bit and
> > 64bit representations. I guess this limitation is so severe that the
> > compiler writers will be more than happy to document that %ah and %al
> > can't be independent.
>
> Ok, if we can get that agreed upon (and the clang people too), then I
> have no concerns about the patch.

The GCC's development documentation says:

--cut here--
         When storing to a normal 'subreg' that is smaller than a
         block, the other bits of the referenced block are usually left
         in an undefined state.  This laxity makes it easier to
         generate efficient code for such instructions.  To represent
         an instruction that preserves all the bits outside of those in
         the 'subreg', use 'strict_low_part' or 'zero_extract' around
         the 'subreg'.
--cut here--

REG is divided into individually-addressable blocks in which each block has:

              REGMODE_NATURAL_SIZE (M2)

bytes.  Usually the value is 'UNITS_PER_WORD'; that is, most targets
usually treat each word of a register as being independently
addressable.

The 'block' is 32bits for i386 or 64bits for x86_64. When asm is
writing to %al, this effectively means that other bits of a register
are left in an undefined state. Please note that 'strict_low_part' and
'zero_extract' are internal representations, not available in asm
statements.

> Just so that we don't have any nasty surprises in the future where
> some clever compiler change ends up breaking this (very rare)
> exception case.

IMO the above documents that write to a partial register clobbers the
entire register.

Uros.

  reply	other threads:[~2020-10-13  8:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-12 11:05 [GIT PULL] x86/asm updates for v5.10 Borislav Petkov
2020-10-12 18:11 ` Linus Torvalds
     [not found]   ` <CAFULd4Z1_UKN6haGbNJMi0_tGddPZcawRDfoYnLdn-Qe6UR3-Q@mail.gmail.com>
2020-10-12 18:55     ` Borislav Petkov
2020-10-12 20:29       ` Arvind Sankar
2020-10-12 18:56     ` Linus Torvalds
2020-10-12 18:59       ` Borislav Petkov
2020-10-12 19:03       ` Linus Torvalds
     [not found]         ` <CAFULd4bHpJQau5kw8J93B2Xu1J_tYhShG6eWP88vRvhwxRZmdQ@mail.gmail.com>
2020-10-12 19:33           ` Linus Torvalds
     [not found]             ` <CAFULd4YQ5dNPU5mFuT9GHNH8-UVdcHLz7NYnvPi=kmhaUk1mcw@mail.gmail.com>
2020-10-12 20:57               ` Linus Torvalds
2020-10-13  8:00                 ` Uros Bizjak [this message]
2020-10-12 20:27   ` Arvind Sankar
2020-10-13  9:41 ` [GIT PULL -v2] " Borislav Petkov
2020-10-13 20:39   ` Linus Torvalds
2020-10-13 20:47     ` Borislav Petkov
2020-10-13 20:44 ` [GIT PULL] " pr-tracker-bot

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=CAFULd4axRbk4rT_+xuwjWv2J0+TP-qKjNK+QaivOGFdJ3aL+vg@mail.gmail.com \
    --to=ubizjak@gmail.com \
    --cc=bp@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@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;
as well as URLs for NNTP newsgroup(s).