#include "qemu/qemu-print.h"
#include "qemu/ctype.h"
#include "qemu/log.h"
+#include "qemu/guest-random.h"
#include "cpu.h"
#include "cpu_vendorid.h"
#include "target/riscv/csr.h"
}
#endif
+/* Used by csr.c and the KVM driver */
+target_ulong riscv_new_csr_seed(target_ulong new_value,
+ target_ulong write_mask)
+{
+ uint16_t random_v;
+ Error *random_e = NULL;
+ int random_r;
+ target_ulong rval;
+
+ random_r = qemu_guest_getrandom(&random_v, 2, &random_e);
+ if (unlikely(random_r < 0)) {
+ /*
+ * Failed, for unknown reasons in the crypto subsystem.
+ * The best we can do is log the reason and return a
+ * failure indication to the guest. There is no reason
+ * we know to expect the failure to be transitory, so
+ * indicate DEAD to avoid having the guest spin on WAIT.
+ */
+ qemu_log_mask(LOG_UNIMP, "%s: Crypto failure: %s",
+ __func__, error_get_pretty(random_e));
+ error_free(random_e);
+ rval = SEED_OPST_DEAD;
+ } else {
+ rval = random_v | SEED_OPST_ES16;
+ }
+
+ return rval;
+}
+
static ObjectClass *riscv_cpu_class_by_name(const char *cpu_model)
{
ObjectClass *oc;
bool riscv_cpu_accelerator_compatible(RISCVCPU *cpu);
void riscv_cpu_register_gdb_regs_for_features(CPUState *cs);
-
+target_ulong riscv_new_csr_seed(target_ulong new_value,
+ target_ulong write_mask);
const char *satp_mode_str(uint8_t satp_mode, bool is_32_bit);
const char *priv_spec_to_str(int priv_version);
#include "exec/target_long.h"
#include "cpu_bits.h"
-target_ulong riscv_new_csr_seed(target_ulong new_value,
- target_ulong write_mask);
-
RISCVException riscv_csrr(CPURISCVState *env, int csrno,
target_ulong *ret_value);
#include "system/kvm.h"
#include "system/kvm_int.h"
#include "cpu.h"
-#include "target/riscv/csr.h"
#include "trace.h"
#include "accel/accel-cpu-target.h"
#include "hw/pci/pci.h"
#include "exec/icount.h"
#include "accel/tcg/cpu-loop.h"
#include "accel/tcg/getpc.h"
-#include "qemu/guest-random.h"
#include "qapi/error.h"
#include "tcg/insn-start-words.h"
#include "internals.h"
#endif
/* Crypto Extension */
-target_ulong riscv_new_csr_seed(target_ulong new_value,
- target_ulong write_mask)
-{
- uint16_t random_v;
- Error *random_e = NULL;
- int random_r;
- target_ulong rval;
-
- random_r = qemu_guest_getrandom(&random_v, 2, &random_e);
- if (unlikely(random_r < 0)) {
- /*
- * Failed, for unknown reasons in the crypto subsystem.
- * The best we can do is log the reason and return a
- * failure indication to the guest. There is no reason
- * we know to expect the failure to be transitory, so
- * indicate DEAD to avoid having the guest spin on WAIT.
- */
- qemu_log_mask(LOG_UNIMP, "%s: Crypto failure: %s",
- __func__, error_get_pretty(random_e));
- error_free(random_e);
- rval = SEED_OPST_DEAD;
- } else {
- rval = random_v | SEED_OPST_ES16;
- }
-
- return rval;
-}
-
static RISCVException rmw_seed(CPURISCVState *env, int csrno,
target_ulong *ret_value,
target_ulong new_value,