(big) real mode emulation - emulator_write_std
PATCH 1/1 (big) real mode emulation - emulator_write_std
Hi Avi,
I have been collected quiet a few patches in my tree now. They are all
in dirty(style, debug) state. Now I started cleaning some of the code in my tree, and cutting patches again. I plan to send you steady stream of patches now. so you can expect lots of patches coming from me in coming days now.
About the status of the big real mode; In my private tree I have evolved the segment registers support for the emulator to next level now. I think I can also cut that patch also and send it to you. now it is much more complete than earlier. As of today the SuSe Linux 10.1 is proceeding in the big-real mode into the int 10 call. that is with the help emulation of about 20 new instructions, and also the infrastructure support for those instructions. Probably I should keep a count of instructions emulated in the big real mode to gauge my progress.
I am cutting my tree into simple patches, so it will be easy for you to understand and apply/comment.
Thanks & Regards,
Nitin
Open Source Technology Center, Intel Corporation.
-------------------------------------------------------------------------
The mind is like a parachute; it works much better when it's open.
commit a757404387d3580f1a9dca86b2caf142103c6bdf
Author: Nitin A Kamble <[email protected]> Date: Fri Aug 10 17:30:16 2007 -0700
Implement the function emulator_write_std()
drivers/kvm/kvm_main.c +29 -2
@@ -962,8 +962,35 @@ static int emulator_write_std(unsigned long addr,unsigned int bytes, struct kvm_vcpu *vcpu) { - pr_unimpl(vcpu, "emulator_write_std: addr %lx n %d\n", addr, bytes); -return X86EMUL_UNHANDLEABLE ; + void *data = (void *) val; + +while (bytes) { +gpa_t gpa; +unsigned offset = addr & (PAGE_SIZE -1 ); +unsigned tocopy =min (bytes, (unsigned )PAGE_SIZE - offset); +unsigned long pfn; +struct page *page; +void *page_virt; + + gpa = vcpu->mmu.gva_to_gpa (vcpu, addr); +if (gpa ==UNMAPPED_GVA ) +return X86EMUL_PROPAGATE_FAULT ; + pfn = gpa >>PAGE_SHIFT ; + page =gfn_to_page (vcpu->kvm, pfn); +if (!page) +return X86EMUL_UNHANDLEABLE ; + page_virt =kmap_atomic (page,KM_USER0 ); + +memcpy (page_virt + offset, data, tocopy); + +kunmap_atomic (page_virt,KM_USER0 ); + + bytes -= tocopy; + data += tocopy; + addr += tocopy; + } + +return X86EMUL_CONTINUE ; } static struct kvm_io_device *vcpu_find_mmio_dev(struct kvm_vcpu *vcpu,
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel
A message that is not in the archive (sent off-list or not yet received): 1186783440.6097.16.camel-mpPvwfgnXtFHIUuj5cj4Omt3HXsI98Cx0E9HWUfgJXw@public.gmane.org
Quoted 52 lines · Nitin A Kamble
Hi Avi,
I have been collected quiet a few patches in my tree now. They are
all indirty(style, debug)state. Now I started cleaning some of the code in my tree, and cutting patches again. I plan to send you steady stream of patches now. so you can expect lots of patches coming from me in coming days now.About the status of the big real mode; In my private tree I have evolved the segment registers support for the emulator to next level now. I think I can also cut that patch also and send it to you. now it is much more complete than earlier. As of today the SuSe Linux 10.1 is proceeding in the big-real mode into the int 10 call. that is with the help emulation of about 20 new instructions, and also the infrastructure support for those instructions. Probably I should keep a count of instructions emulated in the big real mode to gauge my progress.
I am cutting my tree into simple patches, so it will be easy for you to understand and apply/comment.
drivers/kvm/kvm_main.c +21
-2@@ -962,8 +962,35 @@ static int emulator_write_std(unsigned long addr,unsigned int bytes, struct kvm_vcpu *vcpu) { - pr_unimpl(vcpu, "emulator_write_std: addr %lx n %d\n", addr, bytes); -return X86EMUL_UNHANDLEABLE ; + void *data = (void *) val; + +while (bytes) { +gpa_t gpa; +unsigned offset = addr & (PAGE_SIZE -1 ); +unsigned tocopy =min (bytes, (unsigned )PAGE_SIZE - offset); +unsigned long pfn; +struct page *page; +void *page_virt; + + gpa = vcpu->mmu.gva_to_gpa (vcpu, addr); +if (gpa ==UNMAPPED_GVA ) +return X86EMUL_PROPAGATE_FAULT ; + pfn = gpa >>PAGE_SHIFT ; + page =gfn_to_page (vcpu->kvm, pfn); +if (!page) +return X86EMUL_UNHANDLEABLE ; + page_virt =kmap_atomic (page,KM_USER0 ); + +memcpy (page_virt + offset, data, tocopy); +
drivers/kvm/kvm_main.c static int emulator_write_std(unsigned long addr, · line 995
Quoted 10 lines
drivers/kvm/kvm_main.c +8
-0+kunmap_atomic (page_virt,KM_USER0 ); + + bytes -= tocopy; + data += tocopy; + addr += tocopy; + } + +return X86EMUL_CONTINUE ; }
This doesn't do the right thing if the write is targeted at a page table. Just use emulator_write_emulated.
Signature · 8 lines
error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
A message that is not in the archive (sent off-list or not yet received): 46C01A54.4010606-atKUWr5tajBWk0Htik3J/[email protected]
Hi Avi,
I see. I tried using the function emulator_write_emulated() instead.
And I don't see any change because of that yet.
Thanks & Regards,
Nitin
Linux Open Source Technology Center, Intel Corporation
------------------------------------------------------------------------
--------
The Mind is like a parachute; it works much better when it's open.
-----Original Message-----
From: Avi Kivity [mailto:avi-atKUWr5tajBWk0Htik3J/[email protected]]
Sent: Monday, August 13, 2007 1:46 AM
To: Kamble, Nitin A
Cc: kvm-devel; Nakajima, Jun; Yu, Wilfred
Subject: Re: [Patch] (big) real mode emulation - emulator_write_std
Quoted 30 lines · Nitin A Kamble
Hi Avi,
I have been collected quiet a few patches in my tree now. They are
all indirty(style, debug)state. Now I started cleaning some of the code in my tree, and cutting patches again. I plan to send you steady stream of patches now. so you can expect lots of patches coming from me in coming days now.About the status of the big real mode; In my private tree I have evolved the segment registers support for the emulator to next level now. I think I can also cut that patch also and send it to you. now it
is much more complete than earlier. As of today the SuSe Linux 10.1 is
proceeding in the big-real mode into the int 10 call. that is with the
help emulation of about 20 new instructions, and also the infrastructure support for those instructions. Probably I should keep
a count of instructions emulated in the big real mode to gauge my progress.
I am cutting my tree into simple patches, so it will be easy for you to understand and apply/comment.
drivers/kvm/kvm_main.c +0
-0
drivers/kvm/kvm_main.c static int emulator_write_std(unsigned long addr, · line 965
Quoted 4 lines
drivers/kvm/kvm_main.c +0
-1@@ -962,8 +962,35 @@ static int emulator_write_std(unsigned long addr,unsigned int bytes, struct kvm_vcpu *vcpu) { - pr_unimpl(vcpu, "emulator_write_std: addr %lx n %d\n", addr,
bytes);
drivers/kvm/kvm_main.c static int emulator_write_std(unsigned long addr,
Quoted 7 lines
drivers/kvm/kvm_main.c +6
-1-return X86EMUL_UNHANDLEABLE ; +void *data = (void *) val; + +while (bytes) { +gpa_t gpa; +unsigned offset = addr & (PAGE_SIZE -1 ); + unsigned tocopy = min(bytes, (unsigned)PAGE_SIZE -
offset);
Quoted 15 lines
drivers/kvm/kvm_main.c +15
-0+unsigned long pfn; +struct page *page; +void *page_virt; + + gpa = vcpu->mmu.gva_to_gpa (vcpu, addr); +if (gpa ==UNMAPPED_GVA ) +return X86EMUL_PROPAGATE_FAULT ; + pfn = gpa >>PAGE_SHIFT ; + page =gfn_to_page (vcpu->kvm, pfn); +if (!page) +return X86EMUL_UNHANDLEABLE ; + page_virt =kmap_atomic (page,KM_USER0 ); + +memcpy (page_virt + offset, data, tocopy); +
drivers/kvm/kvm_main.c static int emulator_write_std(unsigned long addr, · line 995
Quoted 10 lines
drivers/kvm/kvm_main.c +8
-0+kunmap_atomic (page_virt,KM_USER0 ); + + bytes -= tocopy; + data += tocopy; + addr += tocopy; + } + +return X86EMUL_CONTINUE ; }
This doesn't do the right thing if the write is targeted at a page table. Just use emulator_write_emulated.
Signature · 7 lines
error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/