On 4/15/22 02:40, Xiaojuan Yang wrote:
+uint64_t helper_rdtime_d(CPULoongArchState *env) +{ + LoongArchCPU *cpu = LOONGARCH_CPU(env_cpu(env)); + + if ((env->CSR_MISC >> 7) & 0x1) { + do_raise_exception(env, EXCCODE_IPE, GETPC());
This isn't correct -- you need to extract bit 4 + plv. It would be better to add CSR_MISC fields to cpu-csr.h rather than hard-code a constant. If you treat them as the 4-bit fields that they are,
FIELD(CSR_MISC, VA32, 0, 4) FIELD(CSR_MISC, DRDTL, 4, 4) etc then here, plv = FIELD_EX64(env->CSR_CRMD, CSR_CRMD, PLV); if (extract64(env->CSR_MISC, R_CSR_MISC_DRDTL_SHIFT + plv, 1)) r~