On Fri, 2011-12-16 at 16:36 +0800, Zang Hongyong wrote: > 于 2011/12/16,星期五 15:23, Sasha Levin 写道: > > On Fri, 2011-12-16 at 15:02 +0800, Zang Hongyong wrote: > >> 于 2011/12/16,星期五 13:50, Sasha Levin 写道: > >>> On Fri, 2011-12-16 at 09:01 +0800, zanghongyong@xxxxxxxxxx wrote: > >>>> If a guest's ram_size exceeds KVM_32BIT_GAP_START, the corresponding kvm tool's > >>>> virtual address size should be (ram_size + KVM_32BIT_GAP_SIZE), rather than ram_size. > >>> You're right. > >>> > >>> There are more places than just the madvise() code which make the same > >>> error you've spotted (for example, the memslot allocation code), so > >>> instead of trying to fix all of them I'd suggest to just update ram_size > >>> in kvm__arch_init() before allocating everything - that should fix all > >>> of them at once. > >>> > >> Yes. There are other scenarios with the same error. > >> However ram_size sometimes means real guest ram size, and sometimes > >> means virtual address > >> size of kvm tool's user space. Shall we define a new variable? > > Let's keep it simple. If the user requests more than RAM than > > KVM_32BIT_GAP_START just increase it by KVM_32BIT_GAP_SIZE, this way > > mapped size == guest size always (we can madvise(MADV_DONTNEED) the gap > > in the mmapped ram). > > > > Since a user which requests more than KVM_32BIT_GAP_START will have to > > be on 64bit host anyway, there shouldn't be any issue with that. > > > Do you mean increase *kvm->ram_size* by KVM_32BIT_GAP_SIZE? > but sometimes kvm->ram_size stands for guest physical ram size (for > example in kvm__init_ram() code). Yup, kvm->ram_size. If the user requested more than KVM_32BIT_GAP_START, we pretty much have to create the gap, so instead of playing around with different interpretations of ram_size, lets add the gap size - this will let us have just one ram_size. mmap()ing extra space for the gap is free, and that was the plan in the first place (we just got the math wrong :) ). Do you see an issue with increasing kvm->ram_size? -- Sasha. -- 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