* [PATCH] target/i386: Fix test for paging enabled
@ 2022-11-02 9:12 Richard Henderson
2022-11-02 12:57 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Richard Henderson @ 2022-11-02 9:12 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, eduardo, Andreas Gustafsson
If CR0.PG is unset, pg_mode will be zero, but that is not the
only condition for which pg_mode will be zero. Restore the
correct test for paging enabled.
Fixes: 98281984a37 ("target/i386: Add MMU_PHYS_IDX and MMU_NESTED_IDX")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1269
Reported-by: Andreas Gustafsson <gson@gson.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/i386/tcg/sysemu/excp_helper.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/target/i386/tcg/sysemu/excp_helper.c b/target/i386/tcg/sysemu/excp_helper.c
index d51b5d7431..405a5d414a 100644
--- a/target/i386/tcg/sysemu/excp_helper.c
+++ b/target/i386/tcg/sysemu/excp_helper.c
@@ -553,12 +553,12 @@ static bool get_physical_address(CPUX86State *env, vaddr addr,
break;
default:
- in.cr3 = env->cr[3];
- in.mmu_idx = mmu_idx;
- in.ptw_idx = use_stage2 ? MMU_NESTED_IDX : MMU_PHYS_IDX;
- in.pg_mode = get_pg_mode(env);
+ if (likely(env->cr[0] & CR0_PG_MASK)) {
+ in.cr3 = env->cr[3];
+ in.mmu_idx = mmu_idx;
+ in.ptw_idx = use_stage2 ? MMU_NESTED_IDX : MMU_PHYS_IDX;
+ in.pg_mode = get_pg_mode(env);
- if (likely(in.pg_mode)) {
if (in.pg_mode & PG_MODE_LMA) {
/* test virtual address sign extension */
int shift = in.pg_mode & PG_MODE_LA57 ? 56 : 47;
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] target/i386: Fix test for paging enabled
2022-11-02 9:12 [PATCH] target/i386: Fix test for paging enabled Richard Henderson
@ 2022-11-02 12:57 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2022-11-02 12:57 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: eduardo, Andreas Gustafsson
On 11/2/22 10:12, Richard Henderson wrote:
> If CR0.PG is unset, pg_mode will be zero, but that is not the
> only condition for which pg_mode will be zero. Restore the
> correct test for paging enabled.
>
> Fixes: 98281984a37 ("target/i386: Add MMU_PHYS_IDX and MMU_NESTED_IDX")
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1269
> Reported-by: Andreas Gustafsson <gson@gson.org>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> target/i386/tcg/sysemu/excp_helper.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/target/i386/tcg/sysemu/excp_helper.c b/target/i386/tcg/sysemu/excp_helper.c
> index d51b5d7431..405a5d414a 100644
> --- a/target/i386/tcg/sysemu/excp_helper.c
> +++ b/target/i386/tcg/sysemu/excp_helper.c
> @@ -553,12 +553,12 @@ static bool get_physical_address(CPUX86State *env, vaddr addr,
> break;
>
> default:
> - in.cr3 = env->cr[3];
> - in.mmu_idx = mmu_idx;
> - in.ptw_idx = use_stage2 ? MMU_NESTED_IDX : MMU_PHYS_IDX;
> - in.pg_mode = get_pg_mode(env);
> + if (likely(env->cr[0] & CR0_PG_MASK)) {
> + in.cr3 = env->cr[3];
> + in.mmu_idx = mmu_idx;
> + in.ptw_idx = use_stage2 ? MMU_NESTED_IDX : MMU_PHYS_IDX;
> + in.pg_mode = get_pg_mode(env);
>
> - if (likely(in.pg_mode)) {
> if (in.pg_mode & PG_MODE_LMA) {
> /* test virtual address sign extension */
> int shift = in.pg_mode & PG_MODE_LA57 ? 56 : 47;
Queued, thanks.
Paolo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-02 13:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-02 9:12 [PATCH] target/i386: Fix test for paging enabled Richard Henderson
2022-11-02 12:57 ` Paolo Bonzini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.