Commit c8135d9af670d091359cb8b03f594c7591f199ec

Authored by bellard
1 parent 9e62fd7f

fixed subtle bug: in some cases PG_DIRTY was not set correctly


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@547 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 12 additions and 7 deletions
target-i386/helper2.c
@@ -348,15 +348,20 @@ int cpu_x86_handle_mmu_fault(CPUX86State *env, uint32_t addr, @@ -348,15 +348,20 @@ int cpu_x86_handle_mmu_fault(CPUX86State *env, uint32_t addr,
348 page_size = 4096; 348 page_size = 4096;
349 virt_addr = addr & ~0xfff; 349 virt_addr = addr & ~0xfff;
350 } 350 }
  351 +
351 /* the page can be put in the TLB */ 352 /* the page can be put in the TLB */
352 prot = PROT_READ; 353 prot = PROT_READ;
353 - if (is_user) {  
354 - if (pte & PG_RW_MASK)  
355 - prot |= PROT_WRITE;  
356 - } else {  
357 - if (!(env->cr[0] & CR0_WP_MASK) || !(pte & PG_USER_MASK) ||  
358 - (pte & PG_RW_MASK))  
359 - prot |= PROT_WRITE; 354 + if (pte & PG_DIRTY_MASK) {
  355 + /* only set write access if already dirty... otherwise wait
  356 + for dirty access */
  357 + if (is_user) {
  358 + if (pte & PG_RW_MASK)
  359 + prot |= PROT_WRITE;
  360 + } else {
  361 + if (!(env->cr[0] & CR0_WP_MASK) || !(pte & PG_USER_MASK) ||
  362 + (pte & PG_RW_MASK))
  363 + prot |= PROT_WRITE;
  364 + }
360 } 365 }
361 366
362 do_mapping: 367 do_mapping: