From patchwork Fri Sep 27 00:16:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13813783 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 865B663A9 for ; Fri, 27 Sep 2024 00:16:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727396201; cv=none; b=cLsof6bJj9DvTPmwbY3Lw4MzMgroZOJtbbg5PoXvHDc1FuDa3967AwU85LinK7OaxWs2493p50XreVSii5eKZfkqHAMrkbhcO/B0pbRMI1wiz2800uof7KQRZXe6qmCDw6NYzZ+q1vNhprYmzouUt8t/gN6ZNUrpwFRcdnO7/SA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727396201; c=relaxed/simple; bh=KHhB1JvodiEZlYG0K/aIr41oOeymhmWOlg3SNBHxxp4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=OuCyFJriAetaIClyEvRePUyiyPh05wrASYuV/l1JoKbzY5jG590ILiiJRPmRNbMttTnNo0dkwvgGfHVdOpMmV9fmr5skRX7dyKdyCiCTHTQDrK+Rhw7S3TrcgBXHGOeQC6yT5r/AQ7g7Q3NNAKKB4XkCjG321ftInU5rF9elXLg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ho0FAqYC; arc=none smtp.client-ip=209.85.214.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ho0FAqYC" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2070e327014so13149055ad.1 for ; Thu, 26 Sep 2024 17:16:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727396200; x=1728001000; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=qCS+Ka3w15waaZmhKt3WbYhaBaIYN1wdPlmBW/+h3qE=; b=ho0FAqYCRu5llEQ1wYBU1WkdA0anXl/Btv0JjNzpR2yaY04S37qBr0K5yGG0a6PrH5 knUOLqTT3V9OiBV62eYlN6okYiEaJEqtYy3rskCSf2qg2zjxCNaOWfBMzh1+7LXdHWaY XM9nlGHjs8w5QgE17pwCLrWP5Qrxl5+sxgqLM/ujoHL4krTwyMp9rkhQVq1ex/Hja/H/ MGYFk7R/PdkOO9O2DdGxUkmn2wdaSqpQjSWJ5CggsByiLDr9nGe1F3lALWZAMT8llGa9 8a4hr9ypLktnDaojeTBIlBY8Dcr2e1Vcq3PzUOcLsdn6KkZngoeAWjvxQ+aKPmxnuNKU VLbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727396200; x=1728001000; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qCS+Ka3w15waaZmhKt3WbYhaBaIYN1wdPlmBW/+h3qE=; b=vLqj3gk6JVsmLrV0YWIIc9k50EIuwYDM1ZSDDygvlA89U5VTh1/LPq7wU1sg6YubjL gdD/nboKLYxR1ThB9A9sMgu33/1i7vsmcxddPiVIOVVXv/0hdfcZMOhUOKXaEa833MR5 BNIXeGsRRFjRBXpljgUICvT5FLPWDsGQwpWADsEHQhz9oj4eYuawBuUfY6PIPc0I6n8S XDQa3jjdzwBsINTHTK9HrpN1GuMhLkXQoOjRf1BpJlT+QM7foNsM1e/2mjlOv9ppnR+h i6T697f61araA8ryPMLs1ey6QkOxaDHqKT2ZlYPUqARYVQL7Qpf39hPgNuIBNl2Qs7jl nYEA== X-Gm-Message-State: AOJu0YwdnUqRl9xmiGr/n8nSnv941McwM1BQzSZsu25Tc3323qWwsflF J8d4LR7wXoONwE+6N4vPI+u0yjSnZQD+9dWxRyNX110Sxc3yq31rG4VzibttCYOPweWZnt6Rw7+ MGw== X-Google-Smtp-Source: AGHT+IHGZHd87jRSKB1vMMfqB2NkUEzbiC7nAZzkcFWnI6OrmacXeP3BVJ5c97nGJzj2dRpAEXFGoCIYE78= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:e891:b0:205:6e76:e1b1 with SMTP id d9443c01a7336-20b37b73820mr247965ad.4.1727396199576; Thu, 26 Sep 2024 17:16:39 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 26 Sep 2024 17:16:32 -0700 In-Reply-To: <20240927001635.501418-1-seanjc@google.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240927001635.501418-1-seanjc@google.com> X-Mailer: git-send-email 2.46.1.824.gd892dcdcdd-goog Message-ID: <20240927001635.501418-2-seanjc@google.com> Subject: [PATCH 1/4] Revert "KVM: selftests: Test memslot move in memslot_perf_test with quirk disabled" From: Sean Christopherson To: Paolo Bonzini , Sean Christopherson Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Kai Huang , Rick Edgecombe , Yan Zhao Revert memslot_perf_test's testcase for KVM_X86_QUIRK_SLOT_ZAP_ALL, as the quirk is being removed, i.e. the KVM side of things is being reverted. This reverts commit 61de4c34b51c5b9c7ef8229eb246346254638446. Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/memslot_perf_test.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/tools/testing/selftests/kvm/memslot_perf_test.c b/tools/testing/selftests/kvm/memslot_perf_test.c index 893366982f77..579a64f97333 100644 --- a/tools/testing/selftests/kvm/memslot_perf_test.c +++ b/tools/testing/selftests/kvm/memslot_perf_test.c @@ -113,7 +113,6 @@ static_assert(ATOMIC_BOOL_LOCK_FREE == 2, "atomic bool is not lockless"); static sem_t vcpu_ready; static bool map_unmap_verify; -static bool disable_slot_zap_quirk; static bool verbose; #define pr_info_v(...) \ @@ -579,9 +578,6 @@ static bool test_memslot_move_prepare(struct vm_data *data, uint32_t guest_page_size = data->vm->page_size; uint64_t movesrcgpa, movetestgpa; - if (disable_slot_zap_quirk) - vm_enable_cap(data->vm, KVM_CAP_DISABLE_QUIRKS2, KVM_X86_QUIRK_SLOT_ZAP_ALL); - movesrcgpa = vm_slot2gpa(data, data->nslots - 1); if (isactive) { @@ -900,7 +896,6 @@ static void help(char *name, struct test_args *targs) pr_info(" -h: print this help screen.\n"); pr_info(" -v: enable verbose mode (not for benchmarking).\n"); pr_info(" -d: enable extra debug checks.\n"); - pr_info(" -q: Disable memslot zap quirk during memslot move.\n"); pr_info(" -s: specify memslot count cap (-1 means no cap; currently: %i)\n", targs->nslots); pr_info(" -f: specify the first test to run (currently: %i; max %zu)\n", @@ -959,7 +954,7 @@ static bool parse_args(int argc, char *argv[], uint32_t max_mem_slots; int opt; - while ((opt = getopt(argc, argv, "hvdqs:f:e:l:r:")) != -1) { + while ((opt = getopt(argc, argv, "hvds:f:e:l:r:")) != -1) { switch (opt) { case 'h': default: @@ -971,11 +966,6 @@ static bool parse_args(int argc, char *argv[], case 'd': map_unmap_verify = true; break; - case 'q': - disable_slot_zap_quirk = true; - TEST_REQUIRE(kvm_check_cap(KVM_CAP_DISABLE_QUIRKS2) & - KVM_X86_QUIRK_SLOT_ZAP_ALL); - break; case 's': targs->nslots = atoi_paranoid(optarg); if (targs->nslots <= 1 && targs->nslots != -1) { From patchwork Fri Sep 27 00:16:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13813784 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F5951B5AA for ; Fri, 27 Sep 2024 00:16:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727396205; cv=none; b=PG1RxsXsC4NaFXCezGJ2NKU8a53Px0YzymzT9e8ca1NOahs0u9ovApdAd+1ghFekrStzB0OKQDrKP4gsg1LKfQrhEk2Oc6KVPyo7aZJQ8cNHZkhtvTzJb9h8NuSmLfGkZ7neMYUxFWgXr2WxwgDzxmY8k6XhL6iPjtZZFCI9LIE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727396205; c=relaxed/simple; bh=qPB840LKVU6ZflRf4RW/o9F2/cJChriS9wj2fwnqz/o=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=BZFUul7NyJjt5pIb/FcuDlUmk4dn9YcRqMzxcweR/UtVKJQW9EXcxVBSUX3hHzzWmKsZpno90Y+S9ddaUcZpGTKaqfyubNAyl0kKlQ9BXhnU2VDl/Ek/KclSG2YLhtMSAQ1PWNsLNVVSPqjMA5848GdxgtIS+HVnjXEw+0xSaj4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=NC7jcXPL; arc=none smtp.client-ip=209.85.214.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="NC7jcXPL" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-206b912491eso25693945ad.0 for ; Thu, 26 Sep 2024 17:16:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727396202; x=1728001002; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=LnipXkdMp/tlON0pah63FvB2MDul+F9hL2RAHqV8Mqc=; b=NC7jcXPLf7b4SblfqLKX+beZUKFvbWkFWWfTAU/PKAoWG7eyRQG4slbU6YytIeuMeB ySP47Y+UAIN3hn/cSZLwHbEB5pnaDwj5jkviBRe3pSyUnhVwHCpQkGteINz9omPy+vY7 31qlNy5r3nNJl0K3P1yyNUtGmZ7zvxqIvodLNLHD8Ycv74escpf5gk8lPsHxu7JR/mZP 8Sdea/KIYJ4Zz4LtT2wbKLf8eDeCeVJ/bUooWhSqLYgs0bIBxCREcL1dcUFcraEeVDed 5wERlESEX0OWMTdc7MdX75ByTQb0Oem8+BWPsrcHCY9EC9HDlYjTqnKrmUD2Bv7z9/mi qebQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727396202; x=1728001002; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LnipXkdMp/tlON0pah63FvB2MDul+F9hL2RAHqV8Mqc=; b=LpKyNEFMtGvztUU408Uk5Ewx8dGjoi6+1uI97lVVmMB3G6C3OseCBcdWjInUSbSPUa 7zciQduhkvltCMg8oYMDvEBJCP9kL5w3NF987ju0tCA15f5mqZKTrQtQQ5fknZ3XjEv9 wDLeHVlFz7I2utmWlM0yfw+aAo3V9seIHdq0DCJq4/sYCskwMpXV3cDzqdE1P0KxsXhm VEgrEdDvCyUyOeuPf89jgNYhSgIYHpjCuKhyJHtieBbD+3PWrtzhwKVssKz8VBRzeZIU BAhI0cWJeucKO9+Yc6k/h3tg9fGiujItEfhYO6wvyhx7ZJ24Qwln1uO5xym/l0xFN0dw AbjQ== X-Gm-Message-State: AOJu0YxaIADUouZcJpxdYC8Afc0HxPl0+5DUWCeKF1F1qDDARleq1VRz vhkrGTsJi2hynER0oISTHshfC8shT5s/POdVX39sdqCy8qZ5ZyrvMpHTDTX6TiCxvemGTH8/wBe K8A== X-Google-Smtp-Source: AGHT+IGBgI29zkiAKYn/9+spEvVm1fKGkUxDR5oSOVdglhJX+CIn7SSutJlwoDocu8LwMv7t2j2eZRuCCYQ= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:903:33cf:b0:205:3bc6:bf1 with SMTP id d9443c01a7336-20b19cad0f2mr59905ad.4.1727396201564; Thu, 26 Sep 2024 17:16:41 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 26 Sep 2024 17:16:33 -0700 In-Reply-To: <20240927001635.501418-1-seanjc@google.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240927001635.501418-1-seanjc@google.com> X-Mailer: git-send-email 2.46.1.824.gd892dcdcdd-goog Message-ID: <20240927001635.501418-3-seanjc@google.com> Subject: [PATCH 2/4] Revert "KVM: selftests: Allow slot modification stress test with quirk disabled" From: Sean Christopherson To: Paolo Bonzini , Sean Christopherson Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Kai Huang , Rick Edgecombe , Yan Zhao Revert memslot_modification_stress_test's KVM_X86_QUIRK_SLOT_ZAP_ALL testcase, as the quirk is being removed, i.e. the KVM side of things is being reverted. This reverts commit 218f6415004a881d116e254eeb837358aced55ab. Signed-off-by: Sean Christopherson --- .../kvm/memslot_modification_stress_test.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/tools/testing/selftests/kvm/memslot_modification_stress_test.c b/tools/testing/selftests/kvm/memslot_modification_stress_test.c index e3343f0df9e1..49f162573126 100644 --- a/tools/testing/selftests/kvm/memslot_modification_stress_test.c +++ b/tools/testing/selftests/kvm/memslot_modification_stress_test.c @@ -79,7 +79,6 @@ struct test_params { useconds_t delay; uint64_t nr_iterations; bool partition_vcpu_memory_access; - bool disable_slot_zap_quirk; }; static void run_test(enum vm_guest_mode mode, void *arg) @@ -90,13 +89,6 @@ static void run_test(enum vm_guest_mode mode, void *arg) vm = memstress_create_vm(mode, nr_vcpus, guest_percpu_mem_size, 1, VM_MEM_SRC_ANONYMOUS, p->partition_vcpu_memory_access); -#ifdef __x86_64__ - if (p->disable_slot_zap_quirk) - vm_enable_cap(vm, KVM_CAP_DISABLE_QUIRKS2, KVM_X86_QUIRK_SLOT_ZAP_ALL); - - pr_info("Memslot zap quirk %s\n", p->disable_slot_zap_quirk ? - "disabled" : "enabled"); -#endif pr_info("Finished creating vCPUs\n"); @@ -115,12 +107,11 @@ static void run_test(enum vm_guest_mode mode, void *arg) static void help(char *name) { puts(""); - printf("usage: %s [-h] [-m mode] [-d delay_usec] [-q]\n" + printf("usage: %s [-h] [-m mode] [-d delay_usec]\n" " [-b memory] [-v vcpus] [-o] [-i iterations]\n", name); guest_modes_help(); printf(" -d: add a delay between each iteration of adding and\n" " deleting a memslot in usec.\n"); - printf(" -q: Disable memslot zap quirk.\n"); printf(" -b: specify the size of the memory region which should be\n" " accessed by each vCPU. e.g. 10M or 3G.\n" " Default: 1G\n"); @@ -146,7 +137,7 @@ int main(int argc, char *argv[]) guest_modes_append_default(); - while ((opt = getopt(argc, argv, "hm:d:qb:v:oi:")) != -1) { + while ((opt = getopt(argc, argv, "hm:d:b:v:oi:")) != -1) { switch (opt) { case 'm': guest_modes_cmdline(optarg); @@ -169,12 +160,6 @@ int main(int argc, char *argv[]) case 'i': p.nr_iterations = atoi_positive("Number of iterations", optarg); break; - case 'q': - p.disable_slot_zap_quirk = true; - - TEST_REQUIRE(kvm_check_cap(KVM_CAP_DISABLE_QUIRKS2) & - KVM_X86_QUIRK_SLOT_ZAP_ALL); - break; case 'h': default: help(argv[0]); From patchwork Fri Sep 27 00:16:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13813785 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7448F3A1A8 for ; Fri, 27 Sep 2024 00:16:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727396205; cv=none; b=V6c7eIZTDNQqRdw2MwiJr4cjQNHXUm7H/aYSUUA+AvyUnHeCSDLvqwdDzZd3c+dlY9Vcx/nE43Zb7bs6B1OKZQKS2mNKRcEbGVj1WPiJ/9FS69UlCQx1qtZEcWkfQs6UqC7fV+++UWEiNYZ406eWLQ6UvHcEO1EDdgS8qYsyHCw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727396205; c=relaxed/simple; bh=eHthjJeKXXZNP/HJ44d3fT3ZNvSma+yqLbDWTWe268s=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=jjwA8Pp3ieiwcE0n6MZ67yauhBcY0p+cXSxWreX117D4HDBl6mEB0E6wJmc+j389Bnjb/DB1cq2Ev0Uo/FNbTYAZ+a+JTmJGF1LNqsrQjDerOw3asJoKRlTIF0JyZ84TbMRcQhnoG1pT2jmx2sI2CbakCyK39LO1hEAq1K1oGhQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=kskN3XVT; arc=none smtp.client-ip=209.85.216.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kskN3XVT" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2e08fca19b9so1530346a91.2 for ; Thu, 26 Sep 2024 17:16:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727396204; x=1728001004; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=XLS/E/81Wzw3Za+L/Cr3978PALSFMwYPmSR0QYXFI1I=; b=kskN3XVTwZ5YI42rttRAtI71zyHwxzXFkml2vBwUHNtQR+0ZuOVofM3zjAFaMY0W6G a83zY2+SHA6gck1cwyahKVp1Hs2j4IjR8bgi7+UVlxs2AvVDVx/QSsHDFsw1H5PWzz5z xD0oDEffIgQXWfIiLfaJNsUivFbMt/IBnIJped+mudvyMuC2Tdfn+t6IuJa0qohorNZC ntWuo0qV6UUtJnruknDG0M7905juljbwfrGFyzQkxLiaaRliIX8rIdiTLm5wLojTXWEc 4nRE2Wdtng4Fu49Z6lwZoU/fx4uuKxtPqsqv6MkF8N6OxwUXFEACX3JeK5/tMbLGpypK YqRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727396204; x=1728001004; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XLS/E/81Wzw3Za+L/Cr3978PALSFMwYPmSR0QYXFI1I=; b=ZPsIVbSR3up7b+ihN1LIzKO/w7Yxzi6CKrDKIDhOeUCm26yaf/Bd9ttkaS/ORHCV+Z e1K0+57O0sCyrA4D1Py6bqnSbPdiG4YOsO7cqXuFZEeufKmdD7AnbpjyFw1hKrwx6Q9B jgs7MY/QWWePj81I9CfoACm5UG3p28e4tURbgkWrD/FpXmDBe6t36cyvzaU7MC91EaqR isLdMF5SG5kJeObvZg0m4NlMkWRmElzUqYDlZA5LhjqDt6/INSZytMgUr5HP6kVG58IE Lt69d6Mf5R1BG9OYwmqk4jigtJ5+XErNUfboIBkDW5bpba58SouunIvKHQPwzpYZwYpA Q0OA== X-Gm-Message-State: AOJu0Yzb5DMeAZn2q7g3tL0SElVa1IxzHYVGudzoYx+izFEsPhgvpWvy G0pZ7mWqv8Bg/NApzG4N2SdsvqWWadN064AJDh+pBG4laI9gKz+CUrt/pCNoZnv/M51MXQSMQqS 8Bw== X-Google-Smtp-Source: AGHT+IFe3o5RCNOX4D2Pw1PUnAH3Si2msLGWgXE9du5TEjEDFpFJ9cNI9ayHRXGA2vwPaFgiysbMMEpCIEE= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:90b:f07:b0:2c9:7616:dec5 with SMTP id 98e67ed59e1d1-2e0b8663061mr1914a91.2.1727396203647; Thu, 26 Sep 2024 17:16:43 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 26 Sep 2024 17:16:34 -0700 In-Reply-To: <20240927001635.501418-1-seanjc@google.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240927001635.501418-1-seanjc@google.com> X-Mailer: git-send-email 2.46.1.824.gd892dcdcdd-goog Message-ID: <20240927001635.501418-4-seanjc@google.com> Subject: [PATCH 3/4] Revert "KVM: selftests: Test slot move/delete with slot zap quirk enabled/disabled" From: Sean Christopherson To: Paolo Bonzini , Sean Christopherson Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Kai Huang , Rick Edgecombe , Yan Zhao Revert set_memory_region_test's KVM_X86_QUIRK_SLOT_ZAP_ALL testcase, as the quirk is being removed, i.e. the KVM side of things is being reverted. This reverts commit b4ed2c67d275b85b2ab07d54f88bebd5998d61d8. Signed-off-by: Sean Christopherson --- .../selftests/kvm/set_memory_region_test.c | 29 +++++-------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/tools/testing/selftests/kvm/set_memory_region_test.c b/tools/testing/selftests/kvm/set_memory_region_test.c index a8267628e9ed..bb8002084f52 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(bool disable_slot_zap_quirk) +static void test_move_memory_region(void) { pthread_t vcpu_thread; struct kvm_vcpu *vcpu; @@ -184,9 +184,6 @@ static void test_move_memory_region(bool disable_slot_zap_quirk) 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); /* @@ -269,7 +266,7 @@ static void guest_code_delete_memory_region(void) GUEST_ASSERT(0); } -static void test_delete_memory_region(bool disable_slot_zap_quirk) +static void test_delete_memory_region(void) { pthread_t vcpu_thread; struct kvm_vcpu *vcpu; @@ -279,9 +276,6 @@ static void test_delete_memory_region(bool disable_slot_zap_quirk) 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(); @@ -559,10 +553,7 @@ 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. @@ -588,17 +579,13 @@ int main(int argc, char *argv[]) else loops = 10; - 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 MOVE of in-use region, %d loops\n", loops); + for (i = 0; i < loops; i++) + test_move_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); - } + pr_info("Testing DELETE of in-use region, %d loops\n", loops); + for (i = 0; i < loops; i++) + test_delete_memory_region(); #endif return 0; From patchwork Fri Sep 27 00:16:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13813786 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9DCCA4C98 for ; Fri, 27 Sep 2024 00:16:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727396208; cv=none; b=DKuP1C1RIjtAFdr4kUHuaqe0Qo+1jc0Ao8XfGaW8hQD+GToVj/cabzVh+PFS5inwm4f6oef4gU12SdJBtbPUTC1WMvXhWyKKSAt9WIB7u4JKaPmSHHOjI4Tb70fCDfotckgwsPvM33/4nvsWf5K2bceUGgFXekJomuQAjISc0K8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727396208; c=relaxed/simple; bh=XUxMxGbo8IVDbos6wBsnolJD2X9/FpSrjZX7NpyOkvU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=J1t2Jk/CvTlqegG1ET0DUR55hAfSBTo0RjUBWe99wqSJBCRVb2PTfdyzwjaK/MY6bOc3iivYVJRqTc/iihf9bbjVFr08EXxCTjJtjz2796V7TnELAUAUCq/i9XEtwHxxjzcziWUZZ91FYvaWX8ggKICzhwBNajvoyxF6Oulplac= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=cCXiUjIa; arc=none smtp.client-ip=209.85.216.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cCXiUjIa" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2e070439426so2248089a91.1 for ; Thu, 26 Sep 2024 17:16:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727396206; x=1728001006; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=BT2ULlw760pN7swvLVwkns3C2/rih9SJJkz53vDfr04=; b=cCXiUjIaPzIDAlBu7asmH/5sECoMHafYECfaApR7/InQiDwObMtshG90HruQriZBTG IH9fKbhJAEeQ/QXMzrokzOaKP3Rcn2P0TEIX1IjYtGJPloZFYCu9WagMhpJIj5pvO5OH L9lTsQa/afM+xecxEFOyEWShahI/CSdufbzMTmI1CVfHXvVqD7ctdg7xDnGwyXOu3R5Q o2kSowIwK6pil5c09w6b7O5vlJtQx2o1a1S4gPc8qJP82doK7wwI418nyG0v5TO8I8xb A8+1RNke0HSS8BW0NLsA1Qh2DRgDR7iifPbukV7jIOJ79OSXVnXKSiLWD9DElMQTDRIL RAfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727396206; x=1728001006; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BT2ULlw760pN7swvLVwkns3C2/rih9SJJkz53vDfr04=; b=aLR3kgQ+74/0Ae12PBY9Q3IPYGK/cTordGihjskm7/MH6MgkvQssH5HbslAA/sNBBz Uq9XTsx1gEVdkoTzkRO3yMCCGQDt8eQTBFXfNEYXyDuxOYcTJlXz7h8QgKrvoLJmLSt2 0kemAtr2iXfJ5jxXhdzT/bPDVBUaxly8wNtVD8GlWKthnS+osFO6sFD3tRLU31tLUMY1 3eoH9/pu3fv3RD99wuaTBM07GmmI1N6d6mWbzZWbS+nWqVEHGlmT8HnLXvslPHdKWt8C 9Sdb+HHWsYptHtF+iRsLlvHZjWlfNiC/fVQk0+tM8j9gjmFWwOyIh3fA/vVEmCTVUydr tLkQ== X-Gm-Message-State: AOJu0Yxc9YM18PuvTvgqP/iJ4pFwKXfTpgn1FpEwqS1vBwOyaL9ZR+72 4XqdTzp7esX5E+6CLr/6UbXv1iNFJ3iJDykvjYQe7OlglghIuRX3tyU82nY5N15cS4DWXuDqPjC Efg== X-Google-Smtp-Source: AGHT+IGwasQylCvu4I8BVuSCdmfP6ZlSeL8v6Z33k4yxeX8y33WMwNDys5uVYIJwxQ2AD7a3aefe7ozkktc= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:903:2289:b0:20b:26e2:5507 with SMTP id d9443c01a7336-20b37c3063dmr231745ad.11.1727396205787; Thu, 26 Sep 2024 17:16:45 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 26 Sep 2024 17:16:35 -0700 In-Reply-To: <20240927001635.501418-1-seanjc@google.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240927001635.501418-1-seanjc@google.com> X-Mailer: git-send-email 2.46.1.824.gd892dcdcdd-goog Message-ID: <20240927001635.501418-5-seanjc@google.com> Subject: [PATCH 4/4] Revert "KVM: x86/mmu: Introduce a quirk to control memslot zap behavior" From: Sean Christopherson To: Paolo Bonzini , Sean Christopherson Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Kai Huang , Rick Edgecombe , Yan Zhao Remove KVM_X86_QUIRK_SLOT_ZAP_ALL, as the code is broken for shadow MMUs, and the underlying premise is dodgy. As was tried in commit 4e103134b862 ("KVM: x86/mmu: Zap only the relevant pages when removing a memslot"), all shadow pages, i.e. non-leaf SPTEs, need to be zapped. All of the accounting for a shadow page is tied to the memslot, i.e. the shadow page holds a reference to the memslot, for all intents and purposes. Deleting the memslot without removing all relevant shadow pages, as is done when KVM_X86_QUIRK_SLOT_ZAP_ALL is disabled, results in NULL pointer derefs when tearing down the VM. BUG: kernel NULL pointer dereference, address: 00000000000000b0 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 6085f43067 P4D 608c080067 PUD 608c081067 PMD 0 Oops: Oops: 0000 [#1] SMP NOPTI CPU: 79 UID: 0 PID: 187063 Comm: set_memory_regi Tainted: G W 6.11.0-smp--24867312d167-cpl #395 Tainted: [W]=WARN Hardware name: Google Astoria/astoria, BIOS 0.20240617.0-0 06/17/2024 RIP: 0010:__kvm_mmu_prepare_zap_page+0x3a9/0x7b0 [kvm] Code: <48> 8b 8e b0 00 00 00 48 8b 96 e0 00 00 00 48 c1 e9 09 48 29 c8 8b RSP: 0018:ff314a25b19f7c28 EFLAGS: 00010212 Call Trace: kvm_arch_flush_shadow_all+0x7a/0xf0 [kvm] kvm_mmu_notifier_release+0x6c/0xb0 [kvm] mmu_notifier_unregister+0x85/0x140 kvm_put_kvm+0x263/0x410 [kvm] kvm_vm_release+0x21/0x30 [kvm] __fput+0x8d/0x2c0 __se_sys_close+0x71/0xc0 do_syscall_64+0x83/0x160 entry_SYSCALL_64_after_hwframe+0x76/0x7e Rather than trying to get things functional for shadow MMUs (which includes nested TDP), scrap the quirk idea, at least for now. In addition to the function bug, it's not clear that unconditionally doing a targeted zap for all non-default VM types is actually desirable. E.g. it's entirely possible that SEV-ES and SNP VMs would exhibit worse performance than KVM's current "zap all" behavior, or that it's better to do a targeted zap only in specific situations, etc. This reverts commit aa8d1f48d353b0469bff357183ee9df137d15ef0. Cc: Kai Huang Cc: Rick Edgecombe Cc: Yan Zhao Signed-off-by: Sean Christopherson --- Documentation/virt/kvm/api.rst | 8 -------- arch/x86/include/asm/kvm_host.h | 3 +-- arch/x86/include/uapi/asm/kvm.h | 1 - arch/x86/kvm/mmu/mmu.c | 34 +-------------------------------- 4 files changed, 2 insertions(+), 44 deletions(-) diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst index e32471977d0a..a4b7dc4a9dda 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -8097,14 +8097,6 @@ KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS By default, KVM emulates MONITOR/MWAIT (if guest CPUID on writes to MISC_ENABLE if KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT is disabled. - -KVM_X86_QUIRK_SLOT_ZAP_ALL By default, KVM invalidates all SPTEs in - fast way for memslot deletion when VM type - is KVM_X86_DEFAULT_VM. - When this quirk is disabled or when VM type - is other than KVM_X86_DEFAULT_VM, KVM zaps - only leaf SPTEs that are within the range of - the memslot being deleted. =================================== ============================================ 7.32 KVM_CAP_MAX_VCPU_ID diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 6d9f763a7bb9..4738f6f5a794 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -2358,8 +2358,7 @@ int memslot_rmap_alloc(struct kvm_memory_slot *slot, unsigned long npages); KVM_X86_QUIRK_OUT_7E_INC_RIP | \ KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT | \ KVM_X86_QUIRK_FIX_HYPERCALL_INSN | \ - KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS | \ - KVM_X86_QUIRK_SLOT_ZAP_ALL) + KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS) /* * KVM previously used a u32 field in kvm_run to indicate the hypercall was diff --git a/arch/x86/include/uapi/asm/kvm.h b/arch/x86/include/uapi/asm/kvm.h index a8debbf2f702..bf57a824f722 100644 --- a/arch/x86/include/uapi/asm/kvm.h +++ b/arch/x86/include/uapi/asm/kvm.h @@ -439,7 +439,6 @@ struct kvm_sync_regs { #define KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT (1 << 4) #define KVM_X86_QUIRK_FIX_HYPERCALL_INSN (1 << 5) #define KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS (1 << 6) -#define KVM_X86_QUIRK_SLOT_ZAP_ALL (1 << 7) #define KVM_STATE_NESTED_FORMAT_VMX 0 #define KVM_STATE_NESTED_FORMAT_SVM 1 diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index e081f785fb23..0d94354bb2f8 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -7049,42 +7049,10 @@ void kvm_arch_flush_shadow_all(struct kvm *kvm) kvm_mmu_zap_all(kvm); } -/* - * Zapping leaf SPTEs with memslot range when a memslot is moved/deleted. - * - * Zapping non-leaf SPTEs, a.k.a. not-last SPTEs, isn't required, worst - * case scenario we'll have unused shadow pages lying around until they - * are recycled due to age or when the VM is destroyed. - */ -static void kvm_mmu_zap_memslot_leafs(struct kvm *kvm, struct kvm_memory_slot *slot) -{ - struct kvm_gfn_range range = { - .slot = slot, - .start = slot->base_gfn, - .end = slot->base_gfn + slot->npages, - .may_block = true, - }; - - write_lock(&kvm->mmu_lock); - if (kvm_unmap_gfn_range(kvm, &range)) - kvm_flush_remote_tlbs_memslot(kvm, slot); - - write_unlock(&kvm->mmu_lock); -} - -static inline bool kvm_memslot_flush_zap_all(struct kvm *kvm) -{ - return kvm->arch.vm_type == KVM_X86_DEFAULT_VM && - kvm_check_has_quirk(kvm, KVM_X86_QUIRK_SLOT_ZAP_ALL); -} - void kvm_arch_flush_shadow_memslot(struct kvm *kvm, struct kvm_memory_slot *slot) { - if (kvm_memslot_flush_zap_all(kvm)) - kvm_mmu_zap_all_fast(kvm); - else - kvm_mmu_zap_memslot_leafs(kvm, slot); + kvm_mmu_zap_all_fast(kvm); } void kvm_mmu_invalidate_mmio_sptes(struct kvm *kvm, u64 gen)