Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1635309rwd; Thu, 15 Jun 2023 13:22:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5HM7gVA6UVDfxvS3+WL02LoJU4Tbxl/W852pQjzANn2YG28kTAxiXDYh5ajbPrbr7HMB+r X-Received: by 2002:a17:90a:6d8f:b0:25b:acaf:2e3d with SMTP id a15-20020a17090a6d8f00b0025bacaf2e3dmr4883184pjk.30.1686860541639; Thu, 15 Jun 2023 13:22:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686860541; cv=none; d=google.com; s=arc-20160816; b=H3H1WM1hWmBeKHKzPRUbDcjDZWyZvyz32vQLF519uN2yEC1rdKw6aG4NMMp9/B9K/h 6S7+05Hs5QUEk8ANAv7gwgspjFaevvBdkXkYkoRC+60qS5TYrWyUaZAj8HN7VYfLJKeq AykcaInteEWHd/erfWFLqK+aXr7zCu3ccxa4wGD1ObmIAZn/uBcIjrWSqf/M9+/eBu48 0eEF180limY1Vh7TmSInPKgkaNwLZFT5oc4MFwESJG+4jr1G6rjjeeDL9JtFMKEjp/t4 3xRvI9TB4s/jGBYA+rd8oGSbr4EMJiGcjnH9J0NtGUKEuIKUmLZuXafIn0+y0Q2tP1nu 8K9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yssQi01BwRrxhqMAeMwASBQBlCvfx5BVEwrzkNeMIq0=; b=aRLPerSATu47sFojmj7wD0CfVH1T+KLbp7RnX+3HifRprOQjusGkbf9OSNit1/Hju5 haquiQ2jdl1zsBzoPRg/0FtiFQXcPCxLM3K5qfU/+Ktxm/r3hOiFDO4PIM9QHvqcY3iN souyDrwp5Wf78MYJ18bcE5GSEmUXPStGdpDtOeT6jolFjuizy7ehSMxNUZMdlsUQGKwU JliPFY1mH5r+r5qq4remlgyRpF5g8UnkitO45RfogRAWf8yHW82xFcgAMZ6ytRsmdlo+ WYMDhmfTqLrjT2XNHQvmwzM1/tiB4OjySfFdIcHHBDnB357etMGvWr87lIjLiNT3QblJ OBLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CvgVwPD3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mi12-20020a17090b4b4c00b002563251c8e7si80348pjb.128.2023.06.15.13.22.09; Thu, 15 Jun 2023 13:22:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CvgVwPD3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236206AbjFOUMr (ORCPT + 99 others); Thu, 15 Jun 2023 16:12:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229767AbjFOUMi (ORCPT ); Thu, 15 Jun 2023 16:12:38 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD3F912E; Thu, 15 Jun 2023 13:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686859957; x=1718395957; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eOHhXhX/zKooxVF8rvqXJbJxqJhicIuTcsuvo4fz+k0=; b=CvgVwPD3hw6PuX3pdZyIrNjVhf3vKlseoa+4U2MuPO38mUk7Kf62Jhh+ eQOVEy7/J1mws2Bw/eiJD3ekccOuwUgjRHoFjdR0h+6aqSczXi4dZ77vw n2GzEWa17MUFsR5W8Cjt3IrgRD8QLrVvgn38wJ9RAvFxIycZ/m16a5iA3 6jXy+zYCcdVVy57id576beZPkkb9N9c0XBPZgZqtdO9qxo++Amt3i+C7A P1GnubKsCAkEaRwqBAW5/DgpyPrALGka+KVHboCypm7rWNKbkBeQWnLFj mvCBXGZkhvSV8MFgePwnwe1ENAqsxe+O32RgsBweSKbiC95dDLS6Gro2j A==; X-IronPort-AV: E=McAfee;i="6600,9927,10742"; a="387611436" X-IronPort-AV: E=Sophos;i="6.00,245,1681196400"; d="scan'208";a="387611436" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2023 13:12:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10742"; a="712576646" X-IronPort-AV: E=Sophos;i="6.00,245,1681196400"; d="scan'208";a="712576646" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2023 13:12:35 -0700 From: isaku.yamahata@intel.com To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , David Matlack , Kai Huang , Zhi Wang , chen.bo@intel.com, linux-coco@lists.linux.dev, Chao Peng , Ackerley Tng , Vishal Annapurve , Michael Roth Subject: [RFC PATCH 1/6] KVM: selftests: Fix test_add_overlapping_private_memory_regions() Date: Thu, 15 Jun 2023 13:12:14 -0700 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Isaku Yamahata The last test in test_add_overlapping_private_memory_regions() doesn't use overlapping regions resulting in the failure. When the region is overlaps with the existing ones, the error code is EEXIST instead of EINVAL. Pass the overlapping region, and check if the errno is EEXIST. Fixes: bdb645960cb5 ("KVM: selftests: Expand set_memory_region_test to validate guest_memfd()") Signed-off-by: Isaku Yamahata --- .../selftests/kvm/set_memory_region_test.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/kvm/set_memory_region_test.c b/tools/testing/selftests/kvm/set_memory_region_test.c index f46841843300..ea7da324c4d6 100644 --- a/tools/testing/selftests/kvm/set_memory_region_test.c +++ b/tools/testing/selftests/kvm/set_memory_region_test.c @@ -432,6 +432,7 @@ static void test_add_overlapping_private_memory_regions(void) { struct kvm_vm *vm; int memfd; + int r; pr_info("Testing ADD of overlapping KVM_MEM_PRIVATE memory regions\n"); @@ -453,8 +454,19 @@ static void test_add_overlapping_private_memory_regions(void) vm_set_user_memory_region2(vm, MEM_REGION_SLOT, KVM_MEM_PRIVATE, MEM_REGION_GPA, 0, NULL, -1, 0); - test_invalid_guest_memfd(vm, memfd, MEM_REGION_SIZE, - "Overlapping guest_memfd() bindings should fail"); + r = __vm_set_user_memory_region2(vm, MEM_REGION_SLOT, KVM_MEM_PRIVATE, + MEM_REGION_GPA * 2 - MEM_REGION_SIZE, + MEM_REGION_SIZE * 2, + 0, memfd, 0); + TEST_ASSERT(r == -1 && errno == EEXIST, "%s", + "Overlapping guest_memfd() bindings should fail"); + + r = __vm_set_user_memory_region2(vm, MEM_REGION_SLOT, KVM_MEM_PRIVATE, + MEM_REGION_GPA * 2 + MEM_REGION_SIZE, + MEM_REGION_SIZE * 2, + 0, memfd, 0); + TEST_ASSERT(r == -1 && errno == EEXIST, "%s", + "Overlapping guest_memfd() bindings should fail"); close(memfd); kvm_vm_free(vm); -- 2.25.1