diff mbox

sparc: fix leon3 casa instruction when MMU is disabled

Message ID 1519984765-15748-1-git-send-email-konrad@adacore.com (mailing list archive)
State New, archived
Headers show

Commit Message

Frederic Konrad March 2, 2018, 9:59 a.m. UTC
From: KONRAD Frederic <frederic.konrad@adacore.com>

Since the commit af7a06bac7d3abb2da48ef3277d2a415772d2ae8:
`casa [..](10), .., ..` (and probably others alternate space instructions)
triggers a data access exception when the MMU is disabled.

When we enter get_asi(...) dc->mem_idx is set to MMU_PHYS_IDX when the MMU
is disabled. Just keep mem_idx unchanged in this case so we passthrough the
MMU when it is disabled.

Signed-off-by: KONRAD Frederic <frederic.konrad@adacore.com>
---

Notes:
    Changes RFC -> V1:
     * emit the instruction with MMU_PHYS_IDX instead of checking that the MMU
       is enabled in get_physical_address(..)

 target/sparc/translate.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Richard Henderson March 2, 2018, 7:04 p.m. UTC | #1
On 03/02/2018 01:59 AM, KONRAD Frederic wrote:
> From: KONRAD Frederic <frederic.konrad@adacore.com>
> 
> Since the commit af7a06bac7d3abb2da48ef3277d2a415772d2ae8:
> `casa [..](10), .., ..` (and probably others alternate space instructions)
> triggers a data access exception when the MMU is disabled.
> 
> When we enter get_asi(...) dc->mem_idx is set to MMU_PHYS_IDX when the MMU
> is disabled. Just keep mem_idx unchanged in this case so we passthrough the
> MMU when it is disabled.
> 
> Signed-off-by: KONRAD Frederic <frederic.konrad@adacore.com>
> ---
> 
> Notes:
>     Changes RFC -> V1:
>      * emit the instruction with MMU_PHYS_IDX instead of checking that the MMU
>        is enabled in get_physical_address(..)
> 
>  target/sparc/translate.c | 5 +++++
>  1 file changed, 5 insertions(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
KONRAD Frederic March 5, 2018, 9:14 a.m. UTC | #2
On 03/02/2018 08:04 PM, Richard Henderson wrote:
> On 03/02/2018 01:59 AM, KONRAD Frederic wrote:
>> From: KONRAD Frederic <frederic.konrad@adacore.com>
>>
>> Since the commit af7a06bac7d3abb2da48ef3277d2a415772d2ae8:
>> `casa [..](10), .., ..` (and probably others alternate space instructions)
>> triggers a data access exception when the MMU is disabled.
>>
>> When we enter get_asi(...) dc->mem_idx is set to MMU_PHYS_IDX when the MMU
>> is disabled. Just keep mem_idx unchanged in this case so we passthrough the
>> MMU when it is disabled.
>>
>> Signed-off-by: KONRAD Frederic <frederic.konrad@adacore.com>
>> ---
>>
>> Notes:
>>      Changes RFC -> V1:
>>       * emit the instruction with MMU_PHYS_IDX instead of checking that the MMU
>>         is enabled in get_physical_address(..)
>>
>>   target/sparc/translate.c | 5 +++++
>>   1 file changed, 5 insertions(+)
> 
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> 
> r~
> 

Thanks for the review Richard.

BTW I think it makes sense to have it in stable release..
So CC'ing qemu-stable.

Regards,
Fred
Mark Cave-Ayland March 5, 2018, 9:56 p.m. UTC | #3
On 02/03/18 19:04, Richard Henderson wrote:
> On 03/02/2018 01:59 AM, KONRAD Frederic wrote:
>> From: KONRAD Frederic <frederic.konrad@adacore.com>
>>
>> Since the commit af7a06bac7d3abb2da48ef3277d2a415772d2ae8:
>> `casa [..](10), .., ..` (and probably others alternate space instructions)
>> triggers a data access exception when the MMU is disabled.
>>
>> When we enter get_asi(...) dc->mem_idx is set to MMU_PHYS_IDX when the MMU
>> is disabled. Just keep mem_idx unchanged in this case so we passthrough the
>> MMU when it is disabled.
>>
>> Signed-off-by: KONRAD Frederic <frederic.konrad@adacore.com>
>> ---
>>
>> Notes:
>>      Changes RFC -> V1:
>>       * emit the instruction with MMU_PHYS_IDX instead of checking that the MMU
>>         is enabled in get_physical_address(..)
>>
>>   target/sparc/translate.c | 5 +++++
>>   1 file changed, 5 insertions(+)
> 
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

Thanks for reviewing the patch Richard. Do you want me to take this one 
via my qemu-sparc branch?


ATB,

Mark.
Richard Henderson March 6, 2018, 9:03 a.m. UTC | #4
On 03/05/2018 09:56 PM, Mark Cave-Ayland wrote:
> Thanks for reviewing the patch Richard. Do you want me to take this one via my
> qemu-sparc branch?

Yes, please.

r~
Mark Cave-Ayland March 7, 2018, 6:49 p.m. UTC | #5
On 02/03/18 09:59, KONRAD Frederic wrote:

> From: KONRAD Frederic <frederic.konrad@adacore.com>
> 
> Since the commit af7a06bac7d3abb2da48ef3277d2a415772d2ae8:
> `casa [..](10), .., ..` (and probably others alternate space instructions)
> triggers a data access exception when the MMU is disabled.
> 
> When we enter get_asi(...) dc->mem_idx is set to MMU_PHYS_IDX when the MMU
> is disabled. Just keep mem_idx unchanged in this case so we passthrough the
> MMU when it is disabled.
> 
> Signed-off-by: KONRAD Frederic <frederic.konrad@adacore.com>
> ---
> 
> Notes:
>      Changes RFC -> V1:
>       * emit the instruction with MMU_PHYS_IDX instead of checking that the MMU
>         is enabled in get_physical_address(..)
> 
>   target/sparc/translate.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/target/sparc/translate.c b/target/sparc/translate.c
> index 71e0853..5aa367a 100644
> --- a/target/sparc/translate.c
> +++ b/target/sparc/translate.c
> @@ -2093,6 +2093,11 @@ static DisasASI get_asi(DisasContext *dc, int insn, TCGMemOp memop)
>               type = GET_ASI_BFILL;
>               break;
>           }
> +
> +        /* MMU_PHYS_IDX is used when the MMU is disabled to passthrough the
> +         * permissions check in get_physical_address(..).
> +         */
> +        mem_idx = (dc->mem_idx == MMU_PHYS_IDX) ? MMU_PHYS_IDX : mem_idx;
>       } else {
>           gen_exception(dc, TT_PRIV_INSN);
>           type = GET_ASI_EXCP;
> 

Thanks Frederic, I've applied this to my qemu-sparc branch.


ATB,

Mark.
diff mbox

Patch

diff --git a/target/sparc/translate.c b/target/sparc/translate.c
index 71e0853..5aa367a 100644
--- a/target/sparc/translate.c
+++ b/target/sparc/translate.c
@@ -2093,6 +2093,11 @@  static DisasASI get_asi(DisasContext *dc, int insn, TCGMemOp memop)
             type = GET_ASI_BFILL;
             break;
         }
+
+        /* MMU_PHYS_IDX is used when the MMU is disabled to passthrough the
+         * permissions check in get_physical_address(..).
+         */
+        mem_idx = (dc->mem_idx == MMU_PHYS_IDX) ? MMU_PHYS_IDX : mem_idx;
     } else {
         gen_exception(dc, TT_PRIV_INSN);
         type = GET_ASI_EXCP;