Subject: linux-next: manual merge of the kvm-arm tree with the kvm tree

From: Stephen Rothwell <[email-masked]>
Date: Thu, 1 Dec 2022 12:09:39 +1100

Hi all,

Today's linux-next merge of the kvm-arm tree got a conflict in:

  tools/testing/selftests/kvm/memslot_perf_test.c

between commits:

  018ea2d71a43 ("KVM: selftests: Add atoi_paranoid() to catch errors missed by atoi()")
  dc88244bf548 ("KVM: selftests: Automatically do init_ucall() for non-barebones VMs")
  197ebb713ad0 ("KVM: selftests: move common startup logic to kvm_util.c")

from the kvm tree and commits:

  34396437b11f ("KVM: selftests: memslot_perf_test: Probe memory slots for once")
  8675c6f22698 ("KVM: selftests: memslot_perf_test: Support variable guest page size")
  a69170c65acd ("KVM: selftests: memslot_perf_test: Report optimal memory slots")

from the kvm-arm tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc tools/testing/selftests/kvm/memslot_perf_test.c
index 36b20abfb948,2ad40f7c9c08..000000000000
--- a/tools/testing/selftests/kvm/memslot_perf_test.c
+++ b/tools/testing/selftests/kvm/memslot_perf_test.c
@@@ -252,23 -284,22 +284,21 @@@ static bool prepare_vm(struct vm_data *
  	struct timespec tstart;
  	struct sync_area *sync;
  
- 	max_mem_slots = kvm_check_cap(KVM_CAP_NR_MEMSLOTS);
- 	TEST_ASSERT(max_mem_slots > 1,
- 		    "KVM_CAP_NR_MEMSLOTS should be greater than 1");
- 	TEST_ASSERT(nslots > 1 || nslots == -1,
- 		    "Slot count cap should be greater than 1");
- 	if (nslots != -1)
- 		max_mem_slots = min(max_mem_slots, (uint32_t)nslots);
- 	pr_info_v("Allowed number of memory slots: %"PRIu32"\n", max_mem_slots);
+ 	host_page_size = getpagesize();
+ 	guest_page_size = vm_guest_mode_params[VM_MODE_DEFAULT].page_size;
+ 	mempages = mem_size / guest_page_size;
  
- 	TEST_ASSERT(mempages > 1,
- 		    "Can't test without any memory");
+ 	data->vm = __vm_create_with_one_vcpu(&data->vcpu, mempages, guest_code);
 -	ucall_init(data->vm, NULL);
+ 	TEST_ASSERT(data->vm->page_size == guest_page_size, "Invalid VM page size");
  
  	data->npages = mempages;
- 	data->nslots = max_mem_slots - 1;
- 	data->pages_per_slot = mempages / data->nslots;
- 	if (!data->pages_per_slot) {
- 		*maxslots = mempages + 1;
+ 	TEST_ASSERT(data->npages > 1, "Can't test without any memory");
+ 	data->nslots = nslots;
+ 	data->pages_per_slot = data->npages / data->nslots;
+ 	rempages = data->npages % data->nslots;
+ 	if (!check_slot_pages(host_page_size, guest_page_size,
+ 			      data->pages_per_slot, rempages)) {
+ 		*maxslots = get_max_slots(data, host_page_size);
  		return false;
  	}
  
@@@ -884,9 -966,9 +965,9 @@@ static bool parse_args(int argc, char *
  			map_unmap_verify = true;
  			break;
  		case 's':
 -			targs->nslots = atoi(optarg);
 +			targs->nslots = atoi_paranoid(optarg);
- 			if (targs->nslots <= 0 && targs->nslots != -1) {
- 				pr_info("Slot count cap has to be positive or -1 for no cap\n");
+ 			if (targs->nslots <= 1 && targs->nslots != -1) {
+ 				pr_info("Slot count cap must be larger than 1 or -1 for no cap\n");
  				return false;
  			}
  			break;
@@@ -994,6 -1103,12 +1090,9 @@@ int main(int argc, char *argv[]
  	struct test_result rbestslottime;
  	int tctr;
  
 -	/* Tell stdout not to buffer its content */
 -	setbuf(stdout, NULL);
 -
+ 	if (!check_memory_sizes())
+ 		return -1;
+ 
  	if (!parse_args(argc, argv, &targs))
  		return -1;