From: Hollis Blanchard Date: Wed, 29 Apr 2009 17:37:15 +0000 Subject: Re: [Qemu-devel] [PATCH 4/7] kvm: Add sanity checks to slot Message-Id: <1241026635.24990.53.camel@slate.austin.ibm.com> List-Id: References: <20090411172025.32383.77687.stgit@mchn012c.ww002.siemens.net> <20090411172026.32383.7492.stgit@mchn012c.ww002.siemens.net> <0A1FE637C2C7E148B9573BB60CC630E5210713@zch01exm26.fsl.freescale.net> <49F82E09.3070702@siemens.com> <1241025000.24990.51.camel@slate.austin.ibm.com> <49F88ECC.8080005@siemens.com> In-Reply-To: <49F88ECC.8080005@siemens.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Jan Kiszka Cc: Liu Yu-B13201 , qemu-devel@nongnu.org, kvm-ppc@vger.kernel.org On Wed, 2009-04-29 at 19:30 +0200, Jan Kiszka wrote: > Hollis Blanchard wrote: > > On Wed, 2009-04-29 at 12:38 +0200, Jan Kiszka wrote: > >> Liu Yu-B13201 wrote: > >>>> -----Original Message----- > >>>> From: qemu-devel-bounces+yu.liu=freescale.com@nongnu.org > >>>> [mailto:qemu-devel-bounces+yu.liu=freescale.com@nongnu.org] > >>>> On Behalf Of Jan Kiszka > >>>> Sent: Sunday, April 12, 2009 1:20 AM > >>>> To: qemu-devel@nongnu.org > >>>> Subject: [Qemu-devel] [PATCH 4/7] kvm: Add sanity checks to > >>>> slot management > >>>> > >>>> Fail loudly if we run out of memory slot. > >>>> > >>>> Make sure that dirty log start/stop works with consistent > >>>> memory regions > >>>> by reporting invalid parameters. This reveals several > >>>> inconsistencies in > >>>> the vga code, patch to fix them follows later in this series. > >>>> > >>>> And, for simplicity reasons, also catch and report unaligned memory > >>>> regions passed to kvm_set_phys_mem (KVM works on page basis). > >>>> > >>> Commit d3f8d37fe2d0c24ec8bac9c94d5b0e2dc09c0d2a hurts kvm/powerpc > >>> The alignment check in kvm_set_phys_mem prevents pci controller and mpic initializing mmio regions. > >> What is the alignment of those regions then? None? And do regions of > >> different types overlap even on the same page? Maybe the check reveals > >> some deeper conflict /wrt KVM. Can you point me to the involved code files? > > > > These PCI controllers make separate calls to > > cpu_register_physical_memory() for separate callbacks. Reading > > ppce500_pci_init(), for example: > > 0xe0008000 -> CFGADDR (4 bytes) > > 0xe0008004 -> CFGDATA (4 bytes) > > 0xe0008c00 -> other registers > > > > The loop in cpu_register_physical_memory_offset() handles "subpage" > > registration. However, kvm_set_phys_mem() is called outside that loop, > > so it gets the non-page-aligned addresses. > > > > Half-blind shot: > > diff --git a/kvm-all.c b/kvm-all.c > index 32cd636..c2c760e 100644 > --- a/kvm-all.c > +++ b/kvm-all.c > @@ -583,6 +583,9 @@ void kvm_set_phys_mem(target_phys_addr_t start_addr, > int err; > > if (start_addr & ~TARGET_PAGE_MASK) { > + if (flags >= IO_MEM_UNASSIGNED) { > + return; > + } > fprintf(stderr, "Only page-aligned memory slots supported\n"); > abort(); > } > > If it works, it likely needs a cleaner approach to handle all cases. I don't understand the point. kvm_set_phys_mem() already works without this new abort() check. -- Hollis Blanchard IBM Linux Technology Center