kvm-all: PAGE_SIZE should be real host page size
PATCH 1/1 kvm-all: PAGE_SIZE should be real host page size
Just noticed this while grepping TARGET_PAGE_SIZE for an unrelated reason. I didn't use qemu_real_host_page_size as kvm_set_phys_mem() does, because we'd need to make sure page_size_init() has run first.
--- kvm-all.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
kvm-all.c +4 -2
@@ -45,8 +45,10 @@#include <sys/eventfd.h> #endif -/* KVM uses PAGE_SIZE in its definition of COALESCED_MMIO_MAX */ -#define PAGE_SIZE TARGET_PAGE_SIZE +/* KVM uses PAGE_SIZE in its definition of KVM_COALESCED_MMIO_MAX. We +* need to use the real host PAGE_SIZE, as that's what KVM will use. +*/ +#define PAGE_SIZE getpagesize()//#define DEBUG_KVM
Signature · 1 line
2.4.3
Paolo Bonzini
maintainerQuoted 17 lines · Andrew Jones
Just noticed this while grepping
TARGET_PAGE_SIZEfor an unrelated reason. I didn't useqemu_real_host_page_sizeaskvm_set_phys_mem()does, because we'd need to make surepage_size_init()has run first.Signed-off-by Andrew Jones <[email protected]>--- kvm-all.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)kvm-all.c +0
-0@@ -45,8 +45,10 @@#include <sys/eventfd.h> #endif
kvm-all.c line 54
Quoted 10 lines
kvm-all.c +4
-2-/* KVM uses PAGE_SIZE in its definition of COALESCED_MMIO_MAX */ -#define PAGE_SIZE TARGET_PAGE_SIZE +/* KVM uses PAGE_SIZE in its definition of KVM_COALESCED_MMIO_MAX. We +* need to use the real host PAGE_SIZE, as that's what KVM will use. +*/ +#define PAGE_SIZE getpagesize()//#define DEBUG_KVM
Is this a bugfix or just a cleanup? If the former, on which targets?
Paolo
Quoted 27 lines · Paolo Bonzini
Quoted 24 lines · Andrew Jones
Just noticed this while grepping
TARGET_PAGE_SIZEfor an unrelated reason. I didn't useqemu_real_host_page_sizeaskvm_set_phys_mem()does, because we'd need to make surepage_size_init()has run first.Signed-off-by Andrew Jones <[email protected]>--- kvm-all.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)kvm-all.c +4
-2@@ -45,8 +45,10 @@#include <sys/eventfd.h> #endif -/* KVM uses PAGE_SIZE in its definition of COALESCED_MMIO_MAX */ -#define PAGE_SIZE TARGET_PAGE_SIZE +/* KVM uses PAGE_SIZE in its definition of KVM_COALESCED_MMIO_MAX. We +* need to use the real host PAGE_SIZE, as that's what KVM will use. +*/ +#define PAGE_SIZE getpagesize()
Quoted 5 lines
kvm-all.c line 54
Quoted 3 lines
kvm-all.c +0
-0//#define DEBUG_KVM Is this a bugfix or just a cleanup? If the former, on which targets?
It's a bugfix for any targets that have a TARGET_PAGE_SIZE != real-host-page-size. For example ARM has TARGET_PAGE_SIZE set to 1024, even when the host is using 4k or 64k pages. However, I didn't find this due to a bug, because on ARM I'm not using emulated devices that make use of the coalesced-mmio feature at this time.
Thanks,
drew
Quoted 6 lines
Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Paolo Bonzini
maintainerQuoted 34 lines · Andrew Jones
Quoted 27 lines · Paolo Bonzini
Quoted 24 lines · Andrew Jones
Just noticed this while grepping
TARGET_PAGE_SIZEfor an unrelated reason. I didn't useqemu_real_host_page_sizeaskvm_set_phys_mem()does, because we'd need to make surepage_size_init()has run first.Signed-off-by Andrew Jones <[email protected]>--- kvm-all.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)kvm-all.c +4
-2@@ -45,8 +45,10 @@#include <sys/eventfd.h> #endif -/* KVM uses PAGE_SIZE in its definition of COALESCED_MMIO_MAX */ -#define PAGE_SIZE TARGET_PAGE_SIZE +/* KVM uses PAGE_SIZE in its definition of KVM_COALESCED_MMIO_MAX. We +* need to use the real host PAGE_SIZE, as that's what KVM will use. +*/ +#define PAGE_SIZE getpagesize()Quoted 5 lines
kvm-all.c line 54
Quoted 3 lines
kvm-all.c +0
-0//#define DEBUG_KVM Is this a bugfix or just a cleanup? If the former, on which targets?
Quoted 15 lines
It's a bugfix for any targets that have a
TARGET_PAGE_SIZE!= real-host-page-size. For example ARM hasTARGET_PAGE_SIZEset to 1024, even when the host is using 4k or 64k pages. However, I didn't find this due to a bug, because on ARM I'm not using emulated devices that make use of the coalesced-mmio feature at this time.Thanks,
drewQuoted 6 lines
Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Ok, applied (2.6 only unless I gather more urgent patches).
Paolo
Quoted 14 lines · Andrew Jones
Just noticed this while grepping
TARGET_PAGE_SIZEfor an unrelated reason. I didn't useqemu_real_host_page_sizeaskvm_set_phys_mem()does, because we'd need to make surepage_size_init()has run first.Signed-off-by Andrew Jones <[email protected]>--- kvm-all.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)kvm-all.c +0
-0
kvm-all.c line 51
Quoted 9 lines
kvm-all.c +4
-2@@ -45,8 +45,10 @@#include <sys/eventfd.h> #endif -/* KVM uses PAGE_SIZE in its definition of COALESCED_MMIO_MAX */ -#define PAGE_SIZE TARGET_PAGE_SIZE +/* KVM uses PAGE_SIZE in its definition of KVM_COALESCED_MMIO_MAX. We +* need to use the real host PAGE_SIZE, as that's what KVM will use. +*/ +#define PAGE_SIZE getpagesize()
Rather than defining PAGE_SIZE here (a confusing macro given we have several page sizes to deal with), why not just use getpagesize() in the one and only location where we currently use this macro?
Also, you're guaranteed that page_size_init() has been run, because we call that from kvm_init(), and you can't call kvm_vcpu_init() before kvm_init().
thanks
-- PMM
Quoted 18 lines · Peter Maydell
Quoted 17 lines · Andrew Jones
Just noticed this while grepping
TARGET_PAGE_SIZEfor an unrelated reason. I didn't useqemu_real_host_page_sizeaskvm_set_phys_mem()does, because we'd need to make surepage_size_init()has run first.Signed-off-by Andrew Jones <[email protected]>--- kvm-all.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)kvm-all.c +0
-0@@ -45,8 +45,10 @@#include <sys/eventfd.h> #endif
Quoted 11 lines
kvm-all.c line 51
Quoted 6 lines
kvm-all.c +4
-2-/* KVM uses PAGE_SIZE in its definition of COALESCED_MMIO_MAX */ -#define PAGE_SIZE TARGET_PAGE_SIZE +/* KVM uses PAGE_SIZE in its definition of KVM_COALESCED_MMIO_MAX. We +* need to use the real host PAGE_SIZE, as that's what KVM will use. +*/ +#define PAGE_SIZE getpagesize()Rather than defining
PAGE_SIZEhere (a confusing macro given we have several page sizes to deal with), why not just usegetpagesize()in the one and only location where we currently use this macro?
The macro is used by kernel headers that we import and include in kvm-all.c. It's ugly, I agree, but that's how the this cookie crumbled.
Quoted 4 lines
Also, you're guaranteed that
page_size_init()has been run, because we call that fromkvm_init(), and you can't callkvm_vcpu_init()beforekvm_init().
True, but having that dependency seemed error prone to me. If we we some day changed when/if page_size_init is called then there could be an issue, or if somebody did something like
kvm_init()
{
my_page_size = PAGE_SIZE;
...
page_size_init();
...
use(my_page_size)
}
things would break.
Thanks,
drew
Quoted 14 lines · Andrew Jones
Quoted 12 lines · Peter Maydell
kvm-all.c line 51
Quoted 6 lines · Andrew Jones
kvm-all.c +4
-2-/* KVM uses PAGE_SIZE in its definition of COALESCED_MMIO_MAX */ -#define PAGE_SIZE TARGET_PAGE_SIZE +/* KVM uses PAGE_SIZE in its definition of KVM_COALESCED_MMIO_MAX. We +* need to use the real host PAGE_SIZE, as that's what KVM will use. +*/ +#define PAGE_SIZE getpagesize()Rather than defining
PAGE_SIZEhere (a confusing macro given we have several page sizes to deal with), why not just usegetpagesize()in the one and only location where we currently use this macro?
Quoted 2 lines
The macro is used by kernel headers that we import and include in
kvm-all.c. It's ugly, I agree, but that's how the this cookie crumbled.
Oh, I see. That's pretty horrible.
thanks
-- PMM