提交 331b4de9 编写于 作者: A Andrew Jones 提交者: Paolo Bonzini

KVM: selftests: s390x: Provide additional num-guest-pages adjustment

s390 requires 1M aligned guest sizes. Embedding the rounding in
vm_adjust_num_guest_pages() allows us to remove it from a few
other places.
Signed-off-by: NAndrew Jones <drjones@redhat.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 ab56f8e6
...@@ -378,10 +378,6 @@ static void run_test(enum vm_guest_mode mode, bool use_uffd, ...@@ -378,10 +378,6 @@ static void run_test(enum vm_guest_mode mode, bool use_uffd,
guest_num_pages = (vcpus * vcpu_memory_bytes) / guest_page_size; guest_num_pages = (vcpus * vcpu_memory_bytes) / guest_page_size;
guest_num_pages = vm_adjust_num_guest_pages(mode, guest_num_pages); guest_num_pages = vm_adjust_num_guest_pages(mode, guest_num_pages);
#ifdef __s390x__
/* Round up to multiple of 1M (segment size) */
guest_num_pages = (guest_num_pages + 0xff) & ~0xffUL;
#endif
/* /*
* If there should be more memory in the guest test region than there * If there should be more memory in the guest test region than there
* can be pages in the guest, it will definitely cause problems. * can be pages in the guest, it will definitely cause problems.
......
...@@ -296,10 +296,7 @@ static void run_test(enum vm_guest_mode mode, unsigned long iterations, ...@@ -296,10 +296,7 @@ static void run_test(enum vm_guest_mode mode, unsigned long iterations,
guest_num_pages = (1ul << (DIRTY_MEM_BITS - guest_num_pages = (1ul << (DIRTY_MEM_BITS -
vm_get_page_shift(vm))) + 3; vm_get_page_shift(vm))) + 3;
guest_num_pages = vm_adjust_num_guest_pages(mode, guest_num_pages); guest_num_pages = vm_adjust_num_guest_pages(mode, guest_num_pages);
#ifdef __s390x__
/* Round up to multiple of 1M (segment size) */
guest_num_pages = (guest_num_pages + 0xff) & ~0xffUL;
#endif
host_page_size = getpagesize(); host_page_size = getpagesize();
host_num_pages = vm_num_host_pages(mode, guest_num_pages); host_num_pages = vm_num_host_pages(mode, guest_num_pages);
......
...@@ -164,7 +164,13 @@ unsigned int vm_num_guest_pages(enum vm_guest_mode mode, unsigned int num_host_p ...@@ -164,7 +164,13 @@ unsigned int vm_num_guest_pages(enum vm_guest_mode mode, unsigned int num_host_p
static inline unsigned int static inline unsigned int
vm_adjust_num_guest_pages(enum vm_guest_mode mode, unsigned int num_guest_pages) vm_adjust_num_guest_pages(enum vm_guest_mode mode, unsigned int num_guest_pages)
{ {
return vm_num_guest_pages(mode, vm_num_host_pages(mode, num_guest_pages)); unsigned int n;
n = vm_num_guest_pages(mode, vm_num_host_pages(mode, num_guest_pages));
#ifdef __s390x__
/* s390 requires 1M aligned guest sizes */
n = (n + 255) & ~255;
#endif
return n;
} }
struct kvm_userspace_memory_region * struct kvm_userspace_memory_region *
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册