From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: Calling to kvm_mmu_load Date: Wed, 30 Oct 2013 12:44:03 +0100 Message-ID: <5270F103.1030603@redhat.com> References: <52676AF4.4080906@redhat.com> <5269BEAC.90809@redhat.com> <526FB05E.1070204@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: kvm , Jan Kiszka To: Arthur Chunqi Li Return-path: Received: from mx1.redhat.com ([209.132.183.28]:24147 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751787Ab3J3LoK (ORCPT ); Wed, 30 Oct 2013 07:44:10 -0400 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: Il 30/10/2013 12:39, Arthur Chunqi Li ha scritto: >> > >> > kvm_memory_slot just maps a host userspace address range to a guest >> > physical address range. Cooperation with Linux memory management is >> > done with the Linux MMU notifiers. MMU notifiers let KVM know that a >> > page has been swapped out, and KVM reacts by invalidating the shadow >> > page tables for the corresponding guest physical address. > So for each VM, qemu need to register its memory region and KVM stores > this region of GPA to HVA mapping in kvm_memory_slot, and at the first > page fault KVM uses EPT to map GPA to HPA. Am I right? Yes. > In this way, how is ballooning mechanism implemented in KVM memory > management module? Ballooning is done entirely in userspace with a madvise(MADV_DONTNEED) call on the HVA. The userspace has its own GPA->HVA mapping that is separate from the memslots (e.g. memory_region_find + memory_region_get_ram_ptr in QEMU). Paolo