Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2368992rdb; Tue, 10 Oct 2023 01:36:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmJG3fC6+HIXbq2766GsxmGy4YKho0dMGjiWt8qeYt29KWkkavdpKwK0e8BiWxIu60R5la X-Received: by 2002:a05:6e02:1bcc:b0:349:3756:b1ce with SMTP id x12-20020a056e021bcc00b003493756b1cemr21845104ilv.2.1696927003434; Tue, 10 Oct 2023 01:36:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696927003; cv=none; d=google.com; s=arc-20160816; b=gfxRe9Tw/iA5kVQn4+yoiKuQ/WDxbNZ+rV19Nbh/kxq/zIUdDxVjeUUK6/z3O9oKnd Eu4bw+Dp4ZuW7P1dXCvJUgJLL2+Awe3daYqcL3oFIDujAMJCavMIuwBtW9eDbgnoCtyR jeDktWC8y83sMYB7kRIjcZ0lOpy5iRrBjDNuBU6q/NsfdDc0v9hB2x9ql6f3RZpRycve fXzfRQh5Fgae2zhjxIRG6AuTmEGgoGgsLtDuVgaYwTnnD1GcZbtoqBhEz7HvmCCdi0Fs njP4naI/FfotVb4l13R9pHtpbQLwvWYYyw/p9FeQwJiy/n3GrIMXHk7mRb35jSWQPq6C QEGg== 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=I7uDRRJSUFSnl7UORVLsgmSjwsCNEekTjKqUDWNdjDc=; fh=qpQuS5DB8/tFQfmdgX1i3QvppRzkrzhfKx2/rzpwOaE=; b=vN9c/cQ+RaT8GTN7RUbspzlCKUqGKwpDiBQbgZgyi9a1ywJa5ccRcZW9xQRGS32aUF KmVzXl9O4Uu9fDIYIBIvYl7A0gggNQPjt6Yka+9poq6cSoqI+b0jgzq34Xf/guA/75Q1 4EMUCUaCr8zG0CzjShbXo6mfReSQRCwWLXh0ST/OCpjU35xwYDpLPJLyJmLWt3xVQcz6 mk2myxQur3eC8hDyspwlXP1kuVPYW/LuBrK5c+OpsuQEEiWoab5G3bJFPlLjGlWeeZF6 Km+iKW+0GKh+1TGhO6/tWytk9tAQJAAfDUT3bqUKTplzCgJidCexMjoGh4yQ945WE/0i RbaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UIFpXu14; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id v135-20020a63618d000000b0059c02a0f7e3si879796pgb.343.2023.10.10.01.36.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 01:36:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UIFpXu14; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 25B1680220D6; Tue, 10 Oct 2023 01:36:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443044AbjJJIg3 (ORCPT + 99 others); Tue, 10 Oct 2023 04:36:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442928AbjJJIfl (ORCPT ); Tue, 10 Oct 2023 04:35:41 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B189EB4; Tue, 10 Oct 2023 01:35:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696926939; x=1728462939; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=o5MD2FPMw4tHBthOkn4CAG942xWE4Di7Fgiy08pHbDg=; b=UIFpXu14YFLCr6Q2IJYfye6b2fpkjRbP3hH67zkmd4V0qy99cwH33bh/ J96S00sLPbeEn8WKym2vCKE6Jy01bFK0TkaHPhSslHMU47qIO/ka3ieWQ ug6KDXT2EzY6iCxq3Ouv2El3F4AnjLKtMxlUIFeFF9qG5yQ8Y/HSm8YY6 uwLDjOhG4X310sQlO/NZDzrWWtOdaC6rk8h7Rlg3DDfdu99OAJmOf+dl/ EaoJWqRuIn1zHARkEwZSlgs4Jsks56Z3ncycGV1Kp3UzN81SelplKHdg1 EjEfvu73K0HlQBY/TXGiMy1fEwIK7e00Mo/HJrIaj/dxoXj1zn35rgf5o Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10858"; a="363689848" X-IronPort-AV: E=Sophos;i="6.03,212,1694761200"; d="scan'208";a="363689848" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2023 01:35:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10858"; a="1084687210" X-IronPort-AV: E=Sophos;i="6.03,212,1694761200"; d="scan'208";a="1084687210" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2023 01:35:36 -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, Michael Roth , Paolo Bonzini , Sean Christopherson , linux-coco@lists.linux.dev, Chao Peng Subject: [PATCH 11/12] KVM: selftests: lib: Add src memory type for hwpoison test Date: Tue, 10 Oct 2023 01:35:19 -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=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 10 Oct 2023 01:36:39 -0700 (PDT) X-Spam-Level: ** From: Isaku Yamahata For hwpoison test to recover hwpoisoned memory, use madvise(MADV_FREE) that requires private mapping. Add a new src memory type for it. Signed-off-by: Isaku Yamahata --- tools/testing/selftests/kvm/include/test_util.h | 2 ++ tools/testing/selftests/kvm/lib/kvm_util.c | 7 +++++-- tools/testing/selftests/kvm/lib/test_util.c | 8 ++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/kvm/include/test_util.h b/tools/testing/selftests/kvm/include/test_util.h index 7e614adc6cf4..c97af4ff0699 100644 --- a/tools/testing/selftests/kvm/include/test_util.h +++ b/tools/testing/selftests/kvm/include/test_util.h @@ -111,6 +111,8 @@ enum vm_mem_backing_src_type { VM_MEM_SRC_ANONYMOUS_HUGETLB_16GB, VM_MEM_SRC_SHMEM, VM_MEM_SRC_SHARED_HUGETLB, + VM_MEM_SRC_ANONYMOUS_MEMFD, + VM_MEM_SRC_ANONYMOUS_MEMFD_HUGETLB, NUM_SRC_TYPES, }; diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index 310c3a760cb8..95ffb3b97dcf 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -1007,9 +1007,12 @@ void __vm_userspace_mem_region_add(struct kvm_vm *vm, region->mmap_size += alignment; region->fd = -1; - if (backing_src_is_shared(src_type)) + if (backing_src_is_shared(src_type) || + src_type == VM_MEM_SRC_ANONYMOUS_MEMFD || + src_type == VM_MEM_SRC_ANONYMOUS_MEMFD_HUGETLB) region->fd = kvm_memfd_alloc(region->mmap_size, - src_type == VM_MEM_SRC_SHARED_HUGETLB); + src_type == VM_MEM_SRC_SHARED_HUGETLB || + src_type == VM_MEM_SRC_ANONYMOUS_MEMFD_HUGETLB); region->mmap_start = mmap(NULL, region->mmap_size, PROT_READ | PROT_WRITE, diff --git a/tools/testing/selftests/kvm/lib/test_util.c b/tools/testing/selftests/kvm/lib/test_util.c index 5d7f28b02d73..a09bba5c074e 100644 --- a/tools/testing/selftests/kvm/lib/test_util.c +++ b/tools/testing/selftests/kvm/lib/test_util.c @@ -281,6 +281,14 @@ const struct vm_mem_backing_src_alias *vm_mem_backing_src_alias(uint32_t i) */ .flag = MAP_SHARED, }, + [VM_MEM_SRC_ANONYMOUS_MEMFD] = { + .name = "anonymous_memfd", + .flag = ANON_FLAGS, + }, + [VM_MEM_SRC_ANONYMOUS_MEMFD_HUGETLB] = { + .name = "anonymous_memfd_hugetlb", + .flag = ANON_HUGE_FLAGS, + }, }; _Static_assert(ARRAY_SIZE(aliases) == NUM_SRC_TYPES, "Missing new backing src types?"); -- 2.25.1