On Mon, Jun 18, 2012 at 9:12 AM, Avi Kivity <avi@xxxxxxxxxx> wrote: > On 06/15/2012 10:07 PM, Christoffer Dall wrote: >> Adds support in the identity mapping feature that allows KVM to setup >> identity mapping for the Hyp mode with the AP[1] bit set as required by >> the specification and also supports freeing created sub pmd's after >> finished use. >> >> These two functions: >> - hyp_idmap_add(pgd, addr, end); >> - hyp_idmap_del(pgd, addr, end); >> are essentially calls to the same function as the non-hyp versions but >> with a different argument value. KVM calls these functions to setup >> and teardown the identity mapping used to initialize the hypervisor. >> >> Note, the hyp-version of the _del function actually frees the pmd's >> pointed to by the pgd as opposed to the non-hyp version which just >> clears them. > > > I asked previously what happens if two data structures share a page, and > one of them is removed. Is that handled now? How? > I think you asked previously for the general hyp-mode mappings, not the identity mappings. For the general hyp-mode mappings we simply don't unmap the data structures, potentially leaking a few pages for the page tables themselves. This is only for initialization, so there are not really any data structures mapped, only one/two pages to initialize the hypervisor mode. > Why not just identity map all memory? You can use large pages so it's > fast and doesn't consume a lot of page table memory. That's an option, but it still seems like an awful waste since it's only used once (unless you unload and re-load the module) and there's really no problem with data structures here. The truth is that this is going to go away, and the code will be put in a section that's idmapped from kernel start. There's a patch under way from Marc taking care of this which I assmue we'll merge for v9. -Christoffer -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html