/[qemu]/qemu/exec.c
ViewVC logotype

Diff of /qemu/exec.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by bellard, Wed May 14 21:51:13 2003 UTC revision 1.4 by bellard, Fri May 16 16:07:10 2003 UTC
# Line 394  TranslationBlock *tb_alloc(unsigned long Line 394  TranslationBlock *tb_alloc(unsigned long
394     page. Return TRUE if the fault was succesfully handled. */     page. Return TRUE if the fault was succesfully handled. */
395  int page_unprotect(unsigned long address)  int page_unprotect(unsigned long address)
396  {  {
397      unsigned int page_index, prot;      unsigned int page_index, prot, pindex;
398      PageDesc *p;      PageDesc *p, *p1;
399      unsigned long host_start, host_end, addr;      unsigned long host_start, host_end, addr;
400    
401      page_index = address >> TARGET_PAGE_BITS;      host_start = address & host_page_mask;
402      p = page_find(page_index);      page_index = host_start >> TARGET_PAGE_BITS;
403      if (!p)      p1 = page_find(page_index);
404        if (!p1)
405          return 0;          return 0;
406      if ((p->flags & (PAGE_WRITE_ORG | PAGE_WRITE)) == PAGE_WRITE_ORG) {      host_end = host_start + host_page_size;
407          /* if the page was really writable, then we change its      p = p1;
408             protection back to writable */      prot = 0;
409          host_start = address & host_page_mask;      for(addr = host_start;addr < host_end; addr += TARGET_PAGE_SIZE) {
410          host_end = host_start + host_page_size;          prot |= p->flags;
411          prot = 0;          p++;
412          for(addr = host_start; addr < host_end; addr += TARGET_PAGE_SIZE)      }
413              prot |= page_get_flags(addr);      /* if the page was really writable, then we change its
414           protection back to writable */
415        if (prot & PAGE_WRITE_ORG) {
416          mprotect((void *)host_start, host_page_size,          mprotect((void *)host_start, host_page_size,
417                   (prot & PAGE_BITS) | PAGE_WRITE);                   (prot & PAGE_BITS) | PAGE_WRITE);
418          p->flags |= PAGE_WRITE;          pindex = (address - host_start) >> TARGET_PAGE_BITS;
419            p1[pindex].flags |= PAGE_WRITE;
420          /* and since the content will be modified, we must invalidate          /* and since the content will be modified, we must invalidate
421             the corresponding translated code. */             the corresponding translated code. */
422          tb_invalidate_page(address);          tb_invalidate_page(address);

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26