[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH for-7.1 v6 26/51] target/nios2: Prevent writes to read-only o
|
From: |
Peter Maydell |
|
Subject: |
Re: [PATCH for-7.1 v6 26/51] target/nios2: Prevent writes to read-only or reserved control fields |
|
Date: |
Thu, 17 Mar 2022 15:49:45 +0000 |
On Thu, 17 Mar 2022 at 05:53, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Create an array of masks which detail the writable and readonly
> bits for each control register. Apply them when writing to
> control registers, including the write to status during eret.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> @@ -34,6 +34,15 @@ void helper_raise_exception(CPUNios2State *env, uint32_t
> index)
> #ifndef CONFIG_USER_ONLY
> void helper_eret(CPUNios2State *env, uint32_t new_status, uint32_t new_pc)
> {
> + Nios2CPU *cpu = env_archcpu(env);
> +
> + /*
> + * Both estatus and bstatus have no constraints on write;
> + * do not allow reserved fields in status to be set.
> + */
> + new_status &= (cpu->cr_state[CR_STATUS].writable |
> + cpu->cr_state[CR_STATUS].readonly);
> +
> env->ctrl[CR_STATUS] = new_status;
Isn't this allowing the guest to write to readonly bits ?
> env->pc = new_pc;
> cpu_loop_exit(env_cpu(env));
-- PMM
- Re: [PATCH for-7.1 v6 25/51] target/nios2: Clean up handling of tlbmisc in do_exception, (continued)
- [PATCH for-7.1 v6 29/51] target/nios2: Remove CPU_INTERRUPT_NMI, Richard Henderson, 2022/03/17
- [PATCH for-7.1 v6 24/51] target/nios2: Cleanup set of CR_EXCEPTION for do_interrupt, Richard Henderson, 2022/03/17
- [PATCH for-7.1 v6 27/51] target/nios2: Implement cpuid, Richard Henderson, 2022/03/17
- [PATCH for-7.1 v6 31/51] target/nios2: Use tcg_constant_tl, Richard Henderson, 2022/03/17
- [PATCH for-7.1 v6 32/51] target/nios2: Introduce dest_gpr, Richard Henderson, 2022/03/17
- [PATCH for-7.1 v6 37/51] target/nios2: Use gen_goto_tb for DISAS_TOO_MANY, Richard Henderson, 2022/03/17
- [PATCH for-7.1 v6 26/51] target/nios2: Prevent writes to read-only or reserved control fields, Richard Henderson, 2022/03/17
- Re: [PATCH for-7.1 v6 26/51] target/nios2: Prevent writes to read-only or reserved control fields,
Peter Maydell <=
- [PATCH for-7.1 v6 33/51] target/nios2: Drop CR_STATUS_EH from tb->flags, Richard Henderson, 2022/03/17
- [PATCH for-7.1 v6 28/51] target/nios2: Implement CR_STATUS.RSIE, Richard Henderson, 2022/03/17
- [PATCH for-7.1 v6 30/51] target/nios2: Support division error exception, Richard Henderson, 2022/03/17
- [PATCH for-7.1 v6 34/51] target/nios2: Enable unaligned traps for system mode, Richard Henderson, 2022/03/17
- [PATCH for-7.1 v6 35/51] target/nios2: Create gen_jumpr, Richard Henderson, 2022/03/17
- [PATCH for-7.1 v6 36/51] target/nios2: Hoist set of is_jmp into gen_goto_tb, Richard Henderson, 2022/03/17