In some cases the sbi_trap_info argument passed to sbi_trap_redirect is
created from scratch by filling its fields. Since we previously added a
gva field to struct sbi_trap_info, initialize gva in these cases also.
Suggested-by: Andrew Jones <ajones@ventanamicro.com>
Signed-off-by: Vivian Wang <dramforever@live.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
trap.tval = insn;
trap.tval2 = 0;
trap.tinst = 0;
+ trap.gva = 0;
return sbi_trap_redirect(regs, &trap);
}
uptrap.tval = addr;
uptrap.tval2 = tval2;
uptrap.tinst = tinst;
+ uptrap.gva = 0;
return sbi_trap_redirect(regs, &uptrap);
}
uptrap.tval = addr;
uptrap.tval2 = tval2;
uptrap.tinst = tinst;
+ uptrap.gva = 0;
return sbi_trap_redirect(regs, &uptrap);
}
trap.tval = mtval;
trap.tval2 = mtval2;
trap.tinst = mtinst;
+
+ /*
+ * If the hypervisor extension is not implemented,
+ * mstatus[h].GVA is a WPRI field, which is guaranteed to read
+ * as zero. In addition, in this case we don't read mstatush and
+ * instead pretend it is zero, which handles privileged spec
+ * version < 1.12.
+ */
+#if __riscv_xlen == 32
+ trap.gva = (regs->mstatusH & MSTATUSH_GVA) ? 1 : 0;
+#else
+ trap.gva = (regs->mstatus & MSTATUS_GVA) ? 1 : 0;
+#endif
+
rc = sbi_trap_redirect(regs, &trap);
break;
};