[clang] [RISCV] Implement shadow stack on shadow stack mode with Zicfiss. (PR #68075)

Craig Topper via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 17 13:34:48 PDT 2023


================
@@ -106,9 +111,14 @@ static void emitSCSEpilogue(MachineFunction &MF, MachineBasicBlock &MBB,
           CSI, [&](CalleeSavedInfo &CSR) { return CSR.getReg() == RAReg; }))
     return;
 
+  const RISCVInstrInfo *TII = STI.getInstrInfo();
+  if (STI.hasFeature(RISCV::FeatureStdExtZicfiss)) {
----------------
topperc wrote:

As @samitolvanen wrote earlier the SSPUSH and SSPOPCHK instruction fall back to NOPs based on configuration.

> If the kernel doesn't support Zicfiss, it presumably also hasn't enabled the extension for U-mode. Therefore, my understanding is that the application loader can simply skip shadow stack setup for the program, including the prctl (which would fail with -EINVAL), and since the Zicfiss (Zimop) instructions are no-ops when the extension is disabled, the program would run normally, just without shadow stacks. Does this sound correct?

https://github.com/llvm/llvm-project/pull/68075


More information about the cfe-commits mailing list