Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp19867811rwd; Wed, 28 Jun 2023 15:52:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6i/2ppwUoNHr3Ybkdr2IbenEJREvTSC+k3j+Qf75G9bGNsvaHlFSpoh/FKdfKg9IhjfqZc X-Received: by 2002:a05:6808:285:b0:3a1:b638:9c2c with SMTP id z5-20020a056808028500b003a1b6389c2cmr16957688oic.55.1687992758869; Wed, 28 Jun 2023 15:52:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687992758; cv=none; d=google.com; s=arc-20160816; b=rrl6bUJFEXvbWtJG0oUGZIFbbxdGXGde/XD7BYgrB2sH9goHPDP0ni7oV8F9Bh9vV8 Sgvp9Pvc+dQNKP7ti3jCYNexXoD2jUCpWqZiFYrk1/OOePNMmQM9MTN1jBvNO7PCFxch 2qKBpj/GS/Cbu4hHLsBWGBLqSZT3jpQKm0Gm7xVllTlj5h2Kbf/W72rqXE0hnjo3bOhL kK03a+1HVjs/ydOBTRdoapTdFaHgfXlgw97fGzcsvaJwc4BqKVeIpHVvRgXr3H06LoEG KYQGd6Ismk8cyKUCCxSY7XCx6jkRbq3CUs+elmREFK7/cpPHFgoLhbGXNo45SkUuChWD s+YA== 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=viu5g/AI6+M/IwJL+76Jmg7qHnSLxZelkaWgnn1uGys=; fh=CPpRkOwF9GTwy0wtS3lMI/VOqqhYg/hdxkBimukKAqo=; b=0aWN/V70EAcLJEeSOOlsW8CvP7/fq1zk4h/QDgBYx5WQlf2N2JahzE5Qx1/EBhbNCp qOfmqAGvWLjTLI/+Nq0tMbUqiMmh6GAJxPPu9mWcJxq+AbNldiPIoskjjdr6xUnS7D1O 3abvR353tG4wZux5S30jk8CG3A4TWSDYgRrUr3ZumaYDG3BOXMJ7MYlk0WjCHteeETWh kJZ00e5LbwllpYOzB9X6EwBd2ENfOPXOdJYh1BMQIdJ+29ibdmZZxnSrbDoN+Aii3kR1 1sYtInKSyWrAf/l2fC46VRHqrHpUpkTKbRSAG57t7RetDEmEY0aGNOmbcY/sa7pCbTka tzjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="iWpH/MEH"; 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 a15-20020a17090ad80f00b00262fd1f7d1bsi5751167pjv.69.2023.06.28.15.52.24; Wed, 28 Jun 2023 15:52:38 -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="iWpH/MEH"; 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 S231910AbjF1Wn7 (ORCPT + 99 others); Wed, 28 Jun 2023 18:43:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231441AbjF1WnW (ORCPT ); Wed, 28 Jun 2023 18:43:22 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 273491FDC; Wed, 28 Jun 2023 15:43:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687992202; x=1719528202; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1Sq/+JnMtm+xsGNEP3FqZg9J60yyeR0JKdJ3AsGMaUY=; b=iWpH/MEHn+fwxEBu/2m43EkK7wksKJAzUuiCWtT0YcyWsVGKg331EEgR A3/m5Vy8TbCRZj8fVvRCYf4dbo3tuxpqCrADifbBu0p4i5zXjxfZrvVQU VWzB0u8+5xCy+gEA65/nazuynGFCw6/lRaKofvot2sWITIR3UX52VdwnH VMJlUsdrf4d9f/bfU0BHLPtrzK/n9iDd+xEVLWzAkxxsSbS2aCEFKQKeD JHEHbnTRySWp3nET8/VpEVh/e5igs2+bwzbRxtxvMR50WyZc/xarj1/Au Xu1bR8fxrD6TTLrubRhbMkpJdDpY6u2l54HIedmM9ZyTsi06i8TJj+/ZE g==; X-IronPort-AV: E=McAfee;i="6600,9927,10755"; a="392699120" X-IronPort-AV: E=Sophos;i="6.01,166,1684825200"; d="scan'208";a="392699120" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2023 15:43:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10755"; a="830299980" X-IronPort-AV: E=Sophos;i="6.01,166,1684825200"; d="scan'208";a="830299980" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2023 15:43:20 -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 , Yuan Yao Subject: [RFC PATCH v3 01/11] KVM: selftests: Fix test_add_overlapping_private_memory_regions() Date: Wed, 28 Jun 2023 15:43:00 -0700 Message-Id: <4557c452b8ed5a44a22b566db00045991b92fbc6.1687991811.git.isaku.yamahata@intel.com> 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,URIBL_BLOCKED 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 v2 -> v3: - no change 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