[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 5/5] target/riscv: Split the Hypervisor execute load helpe
From: |
Richard Henderson |
Subject: |
Re: [PATCH v2 5/5] target/riscv: Split the Hypervisor execute load helpers |
Date: |
Wed, 28 Oct 2020 08:22:29 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
On 10/28/20 7:42 AM, Alistair Francis wrote:
> +target_ulong helper_hyp_hlvx_hu(CPURISCVState *env, target_ulong address)
> {
> if (env->priv == PRV_M ||
> (env->priv == PRV_S && !riscv_cpu_virt_enabled(env)) ||
> (env->priv == PRV_U && !riscv_cpu_virt_enabled(env) &&
> get_field(env->hstatus, HSTATUS_HU))) {
> + int mmu_idx = cpu_mmu_index(env, true) |
> TB_FLAGS_PRIV_HYP_ACCESS_MASK;
> +
> + return cpu_lduw_mmuidx_ra(env, address, mmu_idx, GETPC());
> + }
> +
> + if (riscv_cpu_virt_enabled(env)) {
> + riscv_raise_exception(env, RISCV_EXCP_VIRT_INSTRUCTION_FAULT,
> GETPC());
> + } else {
> + riscv_raise_exception(env, RISCV_EXCP_ILLEGAL_INST, GETPC());
> + }
> + return 0;
> +}
> +
> +target_ulong helper_hyp_hlvx_wu(CPURISCVState *env, target_ulong address)
> +{
> + if (env->priv == PRV_M ||
> + (env->priv == PRV_S && !riscv_cpu_virt_enabled(env)) ||
> + (env->priv == PRV_U && !riscv_cpu_virt_enabled(env) &&
> + get_field(env->hstatus, HSTATUS_HU))) {
> + int mmu_idx = cpu_mmu_index(env, true) |
> TB_FLAGS_PRIV_HYP_ACCESS_MASK;
>
> + return cpu_ldl_mmuidx_ra(env, address, mmu_idx, GETPC());
> }
Do not replicate the PRV tests.
My first suggestion is to compute this into TBFLAGS and test it at translate
time, so that these functions just become the one cpu_ld* call.
But failing that, at least split out the test + exception into a common helper
function.
r~
- Re: [PATCH v2 1/5] target/riscv: Add a virtualised MMU Mode, (continued)
[PATCH v2 2/5] target/riscv: Set the virtualised MMU mode when doing hyp accesses, Alistair Francis, 2020/10/28
[PATCH v2 3/5] target/riscv: Remove the HS_TWO_STAGE flag, Alistair Francis, 2020/10/28
[PATCH v2 4/5] target/riscv: Remove the hyp load and store functions, Alistair Francis, 2020/10/28
[PATCH v2 5/5] target/riscv: Split the Hypervisor execute load helpers, Alistair Francis, 2020/10/28
- Re: [PATCH v2 5/5] target/riscv: Split the Hypervisor execute load helpers,
Richard Henderson <=