Received: by 2002:ab2:6f44:0:b0:1fd:c486:4f03 with SMTP id l4csp190355lqq; Wed, 12 Jun 2024 23:11:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXgkWr9ginunQk1ZhVFy4gEUC2s7RUScWAnx1j+O06tbbGGymmb/AckyqHhDdbMdYVgGNQKuOADUkhTO67ErODBdiY6kq1ceaejs3yjdg== X-Google-Smtp-Source: AGHT+IEmJsKBkaE/f5oWKLQoyKWZTthJO9rRndKZ4ZW1zksbhxeVNeH766SLAm5UZaYMtBmNj0+K X-Received: by 2002:a50:f68b:0:b0:57c:a7dc:b0e4 with SMTP id 4fb4d7f45d1cf-57ca975695dmr3092527a12.3.1718259103370; Wed, 12 Jun 2024 23:11:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718259103; cv=pass; d=google.com; s=arc-20160816; b=cJB0p3NzPWfNH2eYPkeUlEOam+sYuW3rse6yEnKJ2D4vgCcNTlewiXJSJGo42panEi RwIRL9efMLoAN1qnai9PI7yxsvgcCfB1W1QKPme3rBXJCz4yPTbZFFJ+24UeouYOJ7gq p67/iBPJVgVg+wKDZe7cPo3grYAsaNdda40WOa8Dx9zP0g8aT1NZm+mvKGEcKyiNv4PM moVaud9+YI3axxEOJ6h1ZGJWWv7WNUCi1pspKQtrNAiGfGd7e7MU7TjvQmP3zA6LO6+k PJ68djc3bqGbKiE0V8OjpBJnVVwlKPwE1xDaNpKEW4XOijP2CYincoPhKhANWoy3gE6+ vQog== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=6c0D6QIhXBHEekdrH4SSr1/eFqv1jljijGYg6hByyUk=; fh=qe2Vx5guuNLtyYtIS3RAxoQguUQlq7P9FbuA0pPj9Wc=; b=iqubdjKtSCwoZG0SlgUDz33JjOfR6LvDPVPwzKrSK633wNFop9exnFYzgEEMMvBLYc Uw+WfC2Q36LyLU6KTad2C7BUSPTvIlpst0M/C8Jzkxt2mg/PgElLwcKZeyPaiYUqDAg9 WZM7PMPe7QZV5b3T1KxDwZ2uvKXuKcA/LCRaqCPEFBIfa7cUA0YVdxIYtGU2sZE0qIbe v+o+7KMhqExMH3vt7qj8bn8IlmphUSjY5FF+lIBsekmWvCM8ihy+CfVUc3OmpyEKow1W w+EO7sotjn6AoY4varwdyU1me1RbscQF+3F5yIEuxjXQ4mZSU17uuah/lEzSTCLstSKU Pzig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TLAMOb0d; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-212598-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212598-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57cb72e2279si378271a12.157.2024.06.12.23.11.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 23:11:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-212598-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TLAMOb0d; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-212598-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212598-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1BDDE1F22E7E for ; Thu, 13 Jun 2024 06:11:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D9717136E27; Thu, 13 Jun 2024 06:11:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="TLAMOb0d" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4624E1369A0; Thu, 13 Jun 2024 06:11:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718259089; cv=none; b=lwTvBECMxGsCGk5pZPo7U46gXtt2CS+YwUfUVnF3W9FMVWcbo5PU8ovnQQJ48NRdQxjQk+T5T1o1ZcK1XVam2E4R+XYnHxHdv/uAwiVxVqDPTHCq5voP6iFG0HR3Yzn9wLkOEYtu3xMB0fZO7f+FR3d0yEUXNlHutOreSXqQ6uE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718259089; c=relaxed/simple; bh=xELkib58GVsHFnJOyikK4lxSSfPcXfJatrw+PYgf+/A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a5CFq3vttZcKoEBxIlfGvQms78EbOZmgwwK0s6AZf42g5zU6yf8OKxPySpqEbqsJldDzcfkCVLB+bfyGc2tC4HfZguV0W5WRUpPGEjBKfY9rNt0unkeVEq7vJDIbFKSqjWVMLezhaCa/CguTSB01G2k4MIKz7kidtrT/Ji74Z6Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=TLAMOb0d; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718259088; x=1749795088; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xELkib58GVsHFnJOyikK4lxSSfPcXfJatrw+PYgf+/A=; b=TLAMOb0d5LZPcHq/6sCKmMVyx1dh3zxh9bwYT7QsItMfR0MUSO/hy8F+ yyU8wDfZ5kyzTBbkfXHAsQDQn0HDaJ9VyrMBftjhhYGZC/ccCjAeG/JN3 aZUIWjGGOk/YchcffqW/wCbzIH7bjTv/9gXhl7nPHPigHj60kumEUIE+l Rq1wxUiAvUbPVNpSq0B07bBj5doTEk77E4VIrfXxMErthN5UKdGNdWlst JuMhmH7Ygg6nOtCZgdA61YeB+W/uyfytErozOv0vBUvnD56NPJcSry2YD mAhoVzOwPLsEf8Qx6kud+nnTRBIqViimMJ1FyiwIoQ1J6sAlVWd/BRDyR g==; X-CSE-ConnectionGUID: P/vIYiOGTiqjQWIrhblyPw== X-CSE-MsgGUID: gLnke7yRRo26umhDdbWvQQ== X-IronPort-AV: E=McAfee;i="6700,10204,11101"; a="14894744" X-IronPort-AV: E=Sophos;i="6.08,234,1712646000"; d="scan'208";a="14894744" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2024 23:11:26 -0700 X-CSE-ConnectionGUID: prGISX2bT62Qm9w6RNU/0g== X-CSE-MsgGUID: vfjsAz2WTkyzrbiPqUcNqA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,234,1712646000"; d="scan'208";a="44417196" Received: from yzhao56-desk.sh.intel.com ([10.239.159.62]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2024 23:11:23 -0700 From: Yan Zhao To: pbonzini@redhat.com, seanjc@google.com Cc: rick.p.edgecombe@intel.com, kai.huang@intel.com, isaku.yamahata@intel.com, dmatlack@google.com, sagis@google.com, erdemaktas@google.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Yan Zhao Subject: [PATCH 2/5] KVM: selftests: Test slot move/delete with slot zap quirk enabled/disabled Date: Thu, 13 Jun 2024 14:10:24 +0800 Message-ID: <20240613061024.11831-1-yan.y.zhao@intel.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240613060708.11761-1-yan.y.zhao@intel.com> References: <20240613060708.11761-1-yan.y.zhao@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Update set_memory_region_test to make sure memslot move and deletion function correctly both when slot zap quirk KVM_X86_QUIRK_SLOT_ZAP_ALL is enabled and disabled. Signed-off-by: Yan Zhao --- .../selftests/kvm/set_memory_region_test.c | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/kvm/set_memory_region_test.c b/tools/testing/selftests/kvm/set_memory_region_test.c index bb8002084f52..a8267628e9ed 100644 --- a/tools/testing/selftests/kvm/set_memory_region_test.c +++ b/tools/testing/selftests/kvm/set_memory_region_test.c @@ -175,7 +175,7 @@ static void guest_code_move_memory_region(void) GUEST_DONE(); } -static void test_move_memory_region(void) +static void test_move_memory_region(bool disable_slot_zap_quirk) { pthread_t vcpu_thread; struct kvm_vcpu *vcpu; @@ -184,6 +184,9 @@ static void test_move_memory_region(void) vm = spawn_vm(&vcpu, &vcpu_thread, guest_code_move_memory_region); + if (disable_slot_zap_quirk) + vm_enable_cap(vm, KVM_CAP_DISABLE_QUIRKS2, KVM_X86_QUIRK_SLOT_ZAP_ALL); + hva = addr_gpa2hva(vm, MEM_REGION_GPA); /* @@ -266,7 +269,7 @@ static void guest_code_delete_memory_region(void) GUEST_ASSERT(0); } -static void test_delete_memory_region(void) +static void test_delete_memory_region(bool disable_slot_zap_quirk) { pthread_t vcpu_thread; struct kvm_vcpu *vcpu; @@ -276,6 +279,9 @@ static void test_delete_memory_region(void) vm = spawn_vm(&vcpu, &vcpu_thread, guest_code_delete_memory_region); + if (disable_slot_zap_quirk) + vm_enable_cap(vm, KVM_CAP_DISABLE_QUIRKS2, KVM_X86_QUIRK_SLOT_ZAP_ALL); + /* Delete the memory region, the guest should not die. */ vm_mem_region_delete(vm, MEM_REGION_SLOT); wait_for_vcpu(); @@ -553,7 +559,10 @@ int main(int argc, char *argv[]) { #ifdef __x86_64__ int i, loops; + int j, disable_slot_zap_quirk = 0; + if (kvm_check_cap(KVM_CAP_DISABLE_QUIRKS2) & KVM_X86_QUIRK_SLOT_ZAP_ALL) + disable_slot_zap_quirk = 1; /* * FIXME: the zero-memslot test fails on aarch64 and s390x because * KVM_RUN fails with ENOEXEC or EFAULT. @@ -579,13 +588,17 @@ int main(int argc, char *argv[]) else loops = 10; - pr_info("Testing MOVE of in-use region, %d loops\n", loops); - for (i = 0; i < loops; i++) - test_move_memory_region(); + for (j = 0; j <= disable_slot_zap_quirk; j++) { + pr_info("Testing MOVE of in-use region, %d loops, slot zap quirk %s\n", + loops, j ? "disabled" : "enabled"); + for (i = 0; i < loops; i++) + test_move_memory_region(!!j); - pr_info("Testing DELETE of in-use region, %d loops\n", loops); - for (i = 0; i < loops; i++) - test_delete_memory_region(); + pr_info("Testing DELETE of in-use region, %d loops, slot zap quirk %s\n", + loops, j ? "disabled" : "enabled"); + for (i = 0; i < loops; i++) + test_delete_memory_region(!!j); + } #endif return 0; -- 2.43.2