Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp11648292rwd; Thu, 22 Jun 2023 16:51:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5sMRAjQWU9HohMcoy6AoIO1TRooO90qX9CbuM3yvm2QQNx1xioUVsbcPw2hrgP1nu6SRaG X-Received: by 2002:a05:6a00:847:b0:66a:614c:5701 with SMTP id q7-20020a056a00084700b0066a614c5701mr3037575pfk.22.1687477883408; Thu, 22 Jun 2023 16:51:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687477883; cv=none; d=google.com; s=arc-20160816; b=N/ZCnidSKfIKnuxtn4mW4oaeuJJzlSC6efzGrccbntsX962pPUJ7kqgswz//u/3rat pbm8oYKXzCzMri3jkd8NDCQMXuuIhK2V2hVZRxotc03qxu4bzpA8O9+qyYyTuI0gN/4W KefINg/S6smietmabV169zKUAF/URLv/On3z2NMLmK8lfONTr6qM0kl10L+xHZ8FSbha L9ZYGV+xFgjMhs0aHpsDUZ+sPSs7sCya4LeLhYBWhJ4gdrBflRe3pU1mTi+nZETgWbrS CG84AAu9i0HJluHi4LQmy3vfeashZIwEXy987n3G1uC0eAVMwhoei3hW/cb9qLFJWz0l f94w== 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=S5W3nWiPSgR6n1zaLnlFFqx+kXwdXD94Vwkr+r0kiyw=; b=ZlKHHa/gYeYGsNX0aFdQDG4j7TBCclc1UM+N0h38ZwP+jvABxwpJU6DRz4vpte8Ne5 w8g0CjUxDShG2Dv9TKI9Q7k+ob7D+aI+ER1sROFF7o+qVy0Yv9+DUo/rM6f1ill7hjoo ZTqAmMHXpX5VtuEvvu5rU7CWN+zVXztpHWdeouxNFRk6SIHjmq5OomSBt3ROfBt7XpGQ IC3M4O/KFdi3EHVKcpUSEK1dmh+SZ/52OmSVj1bpvgcf5FE/kViilharZv1WidnzDigD X8l8RRwD69jgpthc6vOgsPtBrKKC7VOrbV5cMtthJbgS8iT/q3AyQ113RgLVAYHdrpn7 nyTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Vhq4I2BV; 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 y63-20020a638a42000000b0052c8d4d0d1esi557378pgd.364.2023.06.22.16.51.11; Thu, 22 Jun 2023 16:51:23 -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=Vhq4I2BV; 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 S231615AbjFVXR2 (ORCPT + 99 others); Thu, 22 Jun 2023 19:17:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231608AbjFVXRX (ORCPT ); Thu, 22 Jun 2023 19:17:23 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D8C51BCC; Thu, 22 Jun 2023 16:17:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687475832; x=1719011832; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ermiXTEXQyF8E2ENU1Af3tf1v3KAorTSmp9Pi7fGpOs=; b=Vhq4I2BV6FYdew35LoEKDmIw8SZc8U8sbR6zTu2ihKFjd5C/dcF/Ukft dyesFvSu9Mpo/Zk7s/BBKQ6JQokvNnoAf312meSXwoN8EQS+kPCi+TDfh O25uvbr7aGut4NE5/N9etWkWcwqCOImqLD1O5VuWEXC7BSpOouJBVBHA6 bP3YMYlccY32NLtTBLLlQEAoIGp37chsbIfRhvQ/Erwr8dG8A6METia86 KRQdkRUMN4m9ROw9zQMW/GxcYdTDzkFj7IerrIqGGruI3oF02qbksckTS yP1AsELHEOURudq0jeFyoTUp78sd9VFduc7Q7TvV5IZUwzY/rWADmL5j6 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10749"; a="358129716" X-IronPort-AV: E=Sophos;i="6.01,150,1684825200"; d="scan'208";a="358129716" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2023 16:17:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10749"; a="718285973" X-IronPort-AV: E=Sophos;i="6.01,150,1684825200"; d="scan'208";a="718285973" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2023 16:17:10 -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 v2 1/6] KVM: selftests: Fix test_add_overlapping_private_memory_regions() Date: Thu, 22 Jun 2023 16:16:25 -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, 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 --- Changes v1 -> v2: - no change --- .../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