public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: Qing Zhao <qing.zhao@oracle.com>
Cc: Jakub Jelinek <jakub@redhat.com>,
	 gcc-patches Paul A Clarke via <gcc-patches@gcc.gnu.org>,
	 kees Cook <keescook@chromium.org>
Subject: Re: Back porting to GCC11/GCC12: Re: [patch][gcc13][i386][pr101891]Adjust -fzero-call-used-regs to always use XOR
Date: Tue, 24 May 2022 06:19:09 +0000 (UTC)	[thread overview]
Message-ID: <nycvar.YFH.7.77.849.2205240619030.4278@jbgna.fhfr.qr> (raw)
In-Reply-To: <A5D10623-9E04-42E4-9528-9A99C578F2C5@oracle.com>

On Mon, 23 May 2022, Qing Zhao wrote:

> Hi,
> 
> I have added the patch to GCC11 and GCC12 in my local area and bootstrapped and regress tested on both x86 and aarch64, no any issues.
> 
> Can I committed them to both GCC11 and GCC12 branches?

Yes.

Thanks,
Richard.

> Thanks.
> 
> 
> 
> 
> > On May 10, 2022, at 8:38 AM, Qing Zhao via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> >
> >
> >
> >> On May 10, 2022, at 1:12 AM, Richard Biener <rguenther@suse.de> wrote:
> >>
> >> On Mon, 9 May 2022, Uros Bizjak wrote:
> >>
> >>> On Mon, May 9, 2022 at 5:44 PM Qing Zhao <qing.zhao@oracle.com> wrote:
> >>>>
> >>>> Another question:
> >>>>
> >>>> I think that this patch might need to be back ported to Gcc12 and GCC11.
> >>>>
> >>>> What?s your opinion on this?
> >>>
> >>> It is not a regression, so following general rules, the patch should
> >>> not be backported. OTOH, the patch creates functionally equivalent
> >>> code, better in some security aspects. The functionality is also
> >>> hidden behind some non-default flag, so I think if release managers
> >>> (CC'd) are OK with the backport, I'd give it a technical approval.
> >>>
> >>>> If so, when can I backport it?
> >>>
> >>> Let's keep it in the mainline for a week or two, before backporting it
> >>> to non-EoL branches.
> >>
> >> OK from my POV after a week or two on trunk.
> >
> > Sure, I will do the back porting after two weeks.
> >
> > thanks.
> >
> > Qing
> >>
> >> Richard.
> >>
> >>> Uros.
> >>>
> >>>>
> >>>> thanks.
> >>>>
> >>>> Qing
> >>>>
> >>>>> On May 7, 2022, at 4:06 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> >>>>>
> >>>>> On Fri, May 6, 2022 at 6:42 PM Qing Zhao <qing.zhao@oracle.com> wrote:
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>> On May 6, 2022, at 10:58 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> >>>>>>>
> >>>>>>> On Fri, May 6, 2022 at 4:29 PM Qing Zhao <qing.zhao@oracle.com> wrote:
> >>>>>>>>
> >>>>>>>> Hi,
> >>>>>>>>
> >>>>>>>> As Kee?s requested in this PR: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101891
> >>>>>>>>
> >>>>>>>> =====
> >>>>>>>>
> >>>>>>>> Currently -fzero-call-used-regs will use a pattern of:
> >>>>>>>>
> >>>>>>>> XOR regA,regA
> >>>>>>>> MOV regA,regB
> >>>>>>>> MOV regA,regC
> >>>>>>>> ...
> >>>>>>>> RET
> >>>>>>>>
> >>>>>>>> However, this introduces both a register ordering dependency (e.g. the CPU cannot clear regB without clearing regA first), and while greatly reduces available ROP gadgets, it does technically leave a set of "MOV" ROP gadgets at the end of functions (e.g. "MOV regA,regC; RET").
> >>>>>>>>
> >>>>>>>> Please switch to always using XOR:
> >>>>>>>>
> >>>>>>>> XOR regA,regA
> >>>>>>>> XOR regB,regB
> >>>>>>>> XOR regC,regC
> >>>>>>>> ...
> >>>>>>>> RET
> >>>>>>>>
> >>>>>>>> =======
> >>>>>>>>
> >>>>>>>> This patch switch all MOV to XOR on i386.
> >>>>>>>>
> >>>>>>>> Bootstrapped and regresstion tested on x86_64-linux-gnu.
> >>>>>>>>
> >>>>>>>> Okay for gcc13?
> >>>>>>>>
> >>>>>>>> Thanks.
> >>>>>>>>
> >>>>>>>> Qing
> >>>>>>>>
> >>>>>>>> ==========================================
> >>>>>>>
> >>>>>>>> gcc/ChangeLog:
> >>>>>>>>
> >>>>>>>> * config/i386/i386.cc (zero_all_mm_registers): Use SET to zero instead
> >>>>>>>> of MOV for zeroing scratch registers.
> >>>>>>>> (ix86_zero_call_used_regs): Likewise.
> >>>>>>>>
> >>>>>>>> gcc/testsuite/ChangeLog:
> >>>>>>>>
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-1.c: Add -fno-stack-protector
> >>>>>>>> -fno-PIC.
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-10.c: Adjust mov to xor.
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-13.c: Add -msse.
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-14.c: Adjust mov to xor.
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-15.c: Add -fno-stack-protector
> >>>>>>>> -fno-PIC.
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-16.c: Likewise.
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-17.c: Likewise.
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-18.c: Add -fno-stack-protector
> >>>>>>>> -fno-PIC, adjust mov to xor.
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-19.c: Add -fno-stack-protector
> >>>>>>>> -fno-PIC.
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-2.c: Adjust mov to xor.
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-20.c: Add -msse.
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-21.c: Add -fno-stack-protector
> >>>>>>>> -fno-PIC, Adjust mov to xor.
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-22.c: Adjust mov to xor.
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-23.c: Likewise.
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-26.c: Likewise.
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-27.c: Likewise.
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-28.c: Likewise.
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-3.c: Add -fno-stack-protector.
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-31.c: Adjust mov to xor.
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-4.c: Add -fno-stack-protector
> >>>>>>>> -fno-PIC.
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-5.c: Adjust mov to xor.
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-6.c: Add -fno-stack-protector.
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-7.c: Likewise.
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-8.c: Adjust mov to xor.
> >>>>>>>> * gcc.target/i386/zero-scratch-regs-9.c: Add -fno-stack-protector.
> >>>>>>>
> >>>>>>> Please use something like the attached (functionally equivalent) patch
> >>>>>>> for the last hunk of your patch.
> >>>>>>
> >>>>>> Sure, I will update the code.
> >>>>>>>
> >>>>>>> Also, if possible, please use V2SImode as a generic MMX mode instead
> >>>>>>> of V4HImode.
> >>>>>> What?s the major purpose of this change?
> >>>>>
> >>>>> Although the generated code is the same, V2SI is used as a "generic"
> >>>>> MMX move insn in the same way V2DI is used to describe generic SSE
> >>>>> move instruction.
> >>>>>
> >>>>> Uros.
> >>>>
> >>>
> >>
> >> --
> >> Richard Biener <rguenther@suse.de>
> >> SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
> >> Germany; GF: Felix Imend
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman;
HRB 36809 (AG Nuernberg)

  reply	other threads:[~2022-05-24  6:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-06 14:29 Qing Zhao
2022-05-06 15:58 ` Uros Bizjak
2022-05-06 16:42   ` Qing Zhao
2022-05-07  9:06     ` Uros Bizjak
2022-05-09 15:42       ` Qing Zhao
2022-05-09 15:44       ` Qing Zhao
2022-05-09 18:25         ` Uros Bizjak
2022-05-10  6:12           ` Richard Biener
2022-05-10 13:38             ` Qing Zhao
2022-05-23 15:16               ` Back porting to GCC11/GCC12: " Qing Zhao
2022-05-24  6:19                 ` Richard Biener [this message]
2022-05-24 15:57                   ` Qing Zhao

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=nycvar.YFH.7.77.849.2205240619030.4278@jbgna.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=keescook@chromium.org \
    --cc=qing.zhao@oracle.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 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 read-only IMAP folder(s) and NNTP newsgroup(s).