This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Stack protector ppc/ppc64 support

On Sun, Jun 26, 2005 at 06:48:41PM -0400, David Edelsohn wrote:
> 	Is there a reason that stack_protect_set<mode> and
> stack_protect_test<mode> cannot use mode macros?

They can be implemented that way, and in fact I had them written
that way in the beginning.  The reason why I'm not using them
in the patch is that the <mode> pattern would then need to use
if (TARGET_64BIT) return "..."; else return "..." in the body
anyway (because they need different instructions), and as <mode>
using patterns are expanded in this case twice, we would end up
with e.g. TARGET_32BIT pattern that would then again test in
the emit body if (TARGET_64BIT) and contain twice as much code
as needed.  But if you think it would increase readability, I
can surely do that.

> 	Also, can the patterns use splitters, both for better scheduling
> and to avoid forcing comparison result in cr0?

The whole point of the pattern (well, except for the special
__stack_chk_guard sequences on Linux I'm adding in a later patch)
is that it is not split, the fallback patterns in stack_protect_prologue
and stack_protect_epilogue do what the split sequences do.
We want to keep the sensitive data (stack canary) in registers
for shortest possible time and ensure that it is not kept
in the register after the necessary load/store (or load/load/compare),
so that exploits can't find the value somewhere on the stack and just
use it.  If the pattern is split, then we no longer control accross
which instructions the lifespan of the sensitive data in register
is, reload can spill it to the stack etc.

As for not forcing cr0 comparison, I guess that's doable:

(define_insn "stack_protect_testdi"
  [(set (match_operand:CCEQ 0 "cc_reg_operand" "=x,?y")
        (unspec:CCEQ [(match_operand:DI 1 "memory_operand" "m,m")
                      (match_operand:DI 2 "memory_operand" "m,m")]
   (clobber (match_scratch:DI 3 "=r"))
   (set (match_scratch:DI 4 "=&r") (const_int 0))]
   ld%U1%X1 %3,%1\;ld%U2%X2 %4,%2\;xor. %3,%3,%4\;{lil|li} %4,0
   ld%U1%X1 %3,%1\;ld%U2%X2 %4,%2\;cmpld %0,%3,%4\;{lil|li} %3,0\;{lil|li} %4,0
  [(set_attr "length" "16,20")])


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]