From: Mark Burton <[email protected]>

Dirty-page logging handles a RAM write fault by marking the page dirty,
restoring write permission, and retrying the guest instruction.

The handler also retried when the resolved RAM region had no dirty-log
client.  This path neither restores permission nor advances the PC, so
the instruction can repeatedly exit to QEMU.

Retry only after marking the page dirty and restoring write permission.
Otherwise, use the existing emulation path to complete the access and
advance the guest PC.

Cc: [email protected]
Fixes: 58bc47fd1c ("target/arm/hvf: Implement dirty page tracking")
Signed-off-by: Mark Burton <[email protected]>
[PMD: Reworded description]
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
---
 target/arm/hvf/hvf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index b00a7e1a845..b6a2dba71bb 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -2427,10 +2427,10 @@ static int hvf_handle_exception(CPUState *cpu, 
hv_vcpu_exit_exception_t *excp)
                 if (memory_region_get_dirty_log_mask(mr)) {
                     memory_region_set_dirty(mr, xlat, page_size);
                     hvf_unprotect_dirty_range(ipa_page, page_size);
-                }
 
-                /* Retry with page writes enabled. */
-                break;
+                    /* Retry with page writes enabled. */
+                    break;
+                }
             }
         }
 
-- 
2.55.0


Reply via email to