From patchwork Mon Jan 14 19:06:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Gardon X-Patchwork-Id: 10763311 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 24F8917FB for ; Mon, 14 Jan 2019 19:07:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14D4128F1C for ; Mon, 14 Jan 2019 19:07:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 051512930D; Mon, 14 Jan 2019 19:07:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5D9C28C9C for ; Mon, 14 Jan 2019 19:07:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726745AbfANTHD (ORCPT ); Mon, 14 Jan 2019 14:07:03 -0500 Received: from mail-ot1-f74.google.com ([209.85.210.74]:52183 "EHLO mail-ot1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726646AbfANTHD (ORCPT ); Mon, 14 Jan 2019 14:07:03 -0500 Received: by mail-ot1-f74.google.com with SMTP id c33so35310otb.18 for ; Mon, 14 Jan 2019 11:07:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=KB3bYhyX7Nm//HNYJcnub2tFcSTElIyL4jnFaTE5cJM=; b=sSqtd9L5VRD3z+OQDyIvVHi7dO/bp+NSZPPf0pJVnsHORcIJYInW0LN0GOYw8t5KS2 xGKGXp75XvNz7oxXOIAXish94yMC2lpk9IeuZoWZLrD57yWUV/NNa63IgZPoDA3AygrD V/T+OvJCfbJRhyTsg4a6N7/SymNRrQCxYCQOf+QMqvbRfDdRFpqBu5S5FBsOgYihO3xf +uS2NSMd4aQakJHweSK4RUE0H3zKDsXjwF2klWZUXIqxYEBBZNRQ3JDw0QDlraU4vik2 rAqmnDvyusqJETMGUw+rl4FOFCzv0k7XE55MDpteLr5nv4UvBjwUZxj1csf2LBodV7rO Y/yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=KB3bYhyX7Nm//HNYJcnub2tFcSTElIyL4jnFaTE5cJM=; b=Q2i6mXVZCbhcTV/TjTqNqLJKcStwY2c+JIcBs2HY2JOy9ViIBXsAnaSXgFbotOkgRH /ot8K29qs1tJXFQzluI6Gz0LfZoSrWi7Nzy5bfa1Chphg/bTi8N18M2UF8WqfdnDkw24 LPv4pp+N1pZ/BnY6Cv7gXH500mtZNrLE2DnA06kWQUtm8rGwTcnSBBWeS0JaArvTROty SouThC4q9GbcLHmSBSDbN7Dt4AgNCnihgtG2tRIg9mi1LdNX/Xpc0PeB21Xs6otbk8p9 2e3GGvb/y9wJnYECs12LlaHWH4wFuW6XukH5R10tYmGB/IJH4Dh9tse5ptUw9EP0SiHW L5Jg== X-Gm-Message-State: AJcUukcg/yoPuCOyKltxp5ouAUhXuwaTa8C3Lmd2JQllEd3ABn+ksWbn oJNHTfAK1b3GgVaB4FUo8sEUE9FoKdpV X-Google-Smtp-Source: ALg8bN5AbHPU5odVhZ6f7k/NmVHuVS7LjpX68mzt9x0wjC+d0kD0CadD1U8ghOhykKs4Fz/V2HmXGK+ezmcQ X-Received: by 2002:aca:32c3:: with SMTP id y186mr9308752oiy.49.1547492822492; Mon, 14 Jan 2019 11:07:02 -0800 (PST) Date: Mon, 14 Jan 2019 11:06:53 -0800 Message-Id: <20190114190653.203837-1-bgardon@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.20.1.97.g81188d93c3-goog Subject: [PATCH] kvm: selftests: Fix region overlap check in kvm_util From: Ben Gardon To: kvm@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: Paolo Bonzini , Andrew Jones , " =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= " , Ben Gardon , Jim Mattson Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fix a call to userspace_mem_region_find to conform to its spec of taking an inclusive, inclusive range. It was previously being called with an inclusive, exclusive range. Also remove a redundant region bounds check in vm_userspace_mem_region_add. Region overlap checking is already performed by the call to userspace_mem_region_find. Tested: Compiled tools/testing/selftests/kvm with -static Ran all resulting test binaries on an Intel Haswell test machine All tests passed Signed-off-by: Ben Gardon Reviewed-by: Jim Mattson --- tools/testing/selftests/kvm/lib/kvm_util.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index 23022e9d32eb81..461e1a50779762 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -571,7 +571,7 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm, * already exist. */ region = (struct userspace_mem_region *) userspace_mem_region_find( - vm, guest_paddr, guest_paddr + npages * vm->page_size); + vm, guest_paddr, (guest_paddr + npages * vm->page_size) + 1); if (region != NULL) TEST_ASSERT(false, "overlapping userspace_mem_region already " "exists\n" @@ -587,11 +587,6 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm, region = region->next) { if (region->region.slot == slot) break; - if ((guest_paddr <= (region->region.guest_phys_addr - + region->region.memory_size)) - && ((guest_paddr + npages * vm->page_size) - >= region->region.guest_phys_addr)) - break; } if (region != NULL) TEST_ASSERT(false, "A mem region with the requested slot "