From nobody Thu Nov 28 22:31:52 2024 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (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 8803A6AAD for ; Fri, 27 Sep 2024 00:16:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727396201; cv=none; b=s82TWsq+Z3arOXH7KMiv8J+5BZXQv6ycruKs58Faws14eilvqh9FlLQ4K5hY2pOETM0Oh/W6QJAvbWGGtQnje7NFcY3lW9Cqr75Eo3T0ybNPHt9zoLNYcOg1TaDATVbbO6HNV6U8JUpJLzEJT3XJ2NRDM1HQpFO4nukIjc2eM24= 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.202 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-f202.google.com with SMTP id d9443c01a7336-2070e327014so13149065ad.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=T3U1WpV0i7zFhnTC/5klCngKzFF6kwOgeIqlcHAjVwF8M56HOW6qq/Jhp4pqZ3Isr4 e6YL46lc5Tl1tY4ZAO6tBc7+kW6LklnsKQnSk5hNgeC4vLPhhsXLvy7wXu82yUVs4gC6 kOadguXwcknjporyEKdf8MKmXHLs7cB0zFfIgcL1EXVlR9Xdu2L05gV+5Z7cT96kCfT2 jh1S6+QinPT8qoexl00VDvUbu9cXKQrdAoZs4VVni37H4mIeHzAdw5dqFLq0B596cZLm 0Kh4VVy/wOmlEhFTawGw2c7nVCmp7/J/qxt5JRgxNBp85u1Br6WeO7gx6GwAYBzQxOGf Bf+A== X-Forwarded-Encrypted: i=1; AJvYcCVJw5ehYLKHj7CTjJ/mc55TPcFZmk6f/QekmK/JCNUG4S5gXMupvuw4dIzZzK5TNdYfRwbXT8jmGr96Xfw=@vger.kernel.org X-Gm-Message-State: AOJu0YwsfMFZrH/Sw89S2Z5NSZfgInkfTEsD4c/iBWb7Ohn/v1AnVumI 6ylxrJ1rAvLdGNKD+D4k9ovg6OvnG57ym6ep6KIJFQ4uExdzx5i6Di8/acxlPuJFlugLuzdG4br hZA== 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: linux-kernel@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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/testin= g/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 =3D=3D 2, "atomic b= ool is not lockless"); static sem_t vcpu_ready; =20 static bool map_unmap_verify; -static bool disable_slot_zap_quirk; =20 static bool verbose; #define pr_info_v(...) \ @@ -579,9 +578,6 @@ static bool test_memslot_move_prepare(struct vm_data *d= ata, uint32_t guest_page_size =3D data->vm->page_size; uint64_t movesrcgpa, movetestgpa; =20 - if (disable_slot_zap_quirk) - vm_enable_cap(data->vm, KVM_CAP_DISABLE_QUIRKS2, KVM_X86_QUIRK_SLOT_ZAP_= ALL); - movesrcgpa =3D vm_slot2gpa(data, data->nslots - 1); =20 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; =20 - while ((opt =3D getopt(argc, argv, "hvdqs:f:e:l:r:")) !=3D -1) { + while ((opt =3D getopt(argc, argv, "hvds:f:e:l:r:")) !=3D -1) { switch (opt) { case 'h': default: @@ -971,11 +966,6 @@ static bool parse_args(int argc, char *argv[], case 'd': map_unmap_verify =3D true; break; - case 'q': - disable_slot_zap_quirk =3D true; - TEST_REQUIRE(kvm_check_cap(KVM_CAP_DISABLE_QUIRKS2) & - KVM_X86_QUIRK_SLOT_ZAP_ALL); - break; case 's': targs->nslots =3D atoi_paranoid(optarg); if (targs->nslots <=3D 1 && targs->nslots !=3D -1) { --=20 2.46.1.824.gd892dcdcdd-goog From nobody Thu Nov 28 22:31:52 2024 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (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 8A4DE101F7 for ; Fri, 27 Sep 2024 00:16:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727396204; cv=none; b=VKO0y7T4X3lu4mV63RwJf+NDHLHNeZJWxZhM2TrbJDTwNSdJ7Z+WTNOOz0ymPHBUc+HmqNPlDxP4TFFP8g8fD6qtZQ7scbsqsYLXo5h2hICiTjcsf98fpY5Z6CXe5y1xpEbXlXfkzWDtWbLXQ0zaIuH14YSOGf2/kd5Uj01UTyY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727396204; 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=uljOuEMg5Y//lqvNqiDKRGIWJfTC8GOvBSpIO3/vaUMZQ/XcgQOrlIZohJPyJxKLgI6xRghBParhQycsTmVXeX7Z9sw7dFceSxdQ/as6I0LNqhdphmIb+dBfuOvPX8GofKnOzpIpe3pY4Fflp8HRBZJ3fU1CaCiggnyCV9/F9+Q= 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.202 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-f202.google.com with SMTP id d9443c01a7336-206b912491eso25693935ad.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=ZxBnZcA0GTeN2BxO67e0pn1FzMFc+bW1ho+GSo5f3XCaRea+YJoxKApUPX0zjvlZlj FkDoNEiLX6IFO8Bd0937hl8MRT5BS1d/WEZ41KBheP7QI6C9qsdJceIjfW1XgqXYklGm K9pfCw7sxUWX8pSMywQZQZ4La6ZqrZQigA79BHg7nBUP9uRf7+kFK40WvCSx3Pu+kpJz eAZINSx0HDiEIpfwFnSObj0WWUoYfJE7CdzWx6NiQowEoeo0xgt0RQJJq/VTqk4fqtjM 7y+BVn3E4+nqPGzsrr5YpWL8cauWzfLxqs2v0JH9jCfnQRC0DUTWhOnhSUfddlXH7HfE MwPg== X-Forwarded-Encrypted: i=1; AJvYcCVnJnc637jPJnQmMsdm60SUv01FVrwRMGX1RGd/mWnflZls61guXnMwcpPveQXY63wChRp23OftkhDcb5k=@vger.kernel.org X-Gm-Message-State: AOJu0Yz94HWdKiTtaYiGSGiDZT1aZkRHw9yy26ntCRPPpA3pVdKW8iFx Cinf7P1UdqNyOC1lx1lE39qyPBdjv0CSxJiG77C6mrxLqB8gUJSPKra0nNrvgLC6C2v1dPJdVyB DaA== 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: linux-kernel@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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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; }; =20 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 =3D 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 =20 pr_info("Finished creating vCPUs\n"); =20 @@ -115,12 +107,11 @@ static void run_test(enum vm_guest_mode mode, void *a= rg) 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[]) =20 guest_modes_append_default(); =20 - while ((opt =3D getopt(argc, argv, "hm:d:qb:v:oi:")) !=3D -1) { + while ((opt =3D getopt(argc, argv, "hm:d:b:v:oi:")) !=3D -1) { switch (opt) { case 'm': guest_modes_cmdline(optarg); @@ -169,12 +160,6 @@ int main(int argc, char *argv[]) case 'i': p.nr_iterations =3D atoi_positive("Number of iterations", optarg); break; - case 'q': - p.disable_slot_zap_quirk =3D true; - - TEST_REQUIRE(kvm_check_cap(KVM_CAP_DISABLE_QUIRKS2) & - KVM_X86_QUIRK_SLOT_ZAP_ALL); - break; case 'h': default: help(argv[0]); --=20 2.46.1.824.gd892dcdcdd-goog From nobody Thu Nov 28 22:31:52 2024 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 744C942A93 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-2e07e7be456so1537891a91.1 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=KfOEwn+GqFn9RIkCWNpsOuaKyBMjE9NQ1vFM9PR6JJ6pKlp6leCiVJaEP/rewbmEf4 26bL+urjOYcGRuXBloWuFDXWQ73+I0zeJH/Pzgvq3Lywn1zTWIuWzdyuvYBh20WoM9m0 3vHV1Wt3UtRKzJGHpyMhhd2HgPOGbdGG8xU4b2NFpu9kQ6IFJVGilBLUr8sJlA5V0cOm kdEh1tQt0TUI3YBlFgoEH12uLI/UD3Yc1OWmOuRoJoNdFOdWmnRGfnq6jPIR3Ui9bD++ IN/eJ3jh9W8dc1JcBXgyQ9mQhrTyhhav/DfABQ1EzX9oMR8RxIcPfGLzm+wDXEdIF59m yi4Q== X-Forwarded-Encrypted: i=1; AJvYcCXcAvNHIeRNt/pxKCNVvG78sFUdc9taEb6IfY1Km0Gukjv7gfygz9z38wQqchhlP+4LjwXbG4jNSwjgPsI=@vger.kernel.org X-Gm-Message-State: AOJu0Yw6M7PaVVwQxxBM8miwkYwVd0ZRlBaAtMfTSiQzJEX02OQYxYun iW+ZiZvGQe9or8dEmIjPIj8kWQlnktd49bZRUjI8ofDlQNOND9Bgo3y2RMxXm4QW5xmqHctsSOY 4qw== 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: linux-kernel@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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/t= esting/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(); } =20 -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_z= ap_quirk) =20 vm =3D spawn_vm(&vcpu, &vcpu_thread, guest_code_move_memory_region); =20 - if (disable_slot_zap_quirk) - vm_enable_cap(vm, KVM_CAP_DISABLE_QUIRKS2, KVM_X86_QUIRK_SLOT_ZAP_ALL); - hva =3D addr_gpa2hva(vm, MEM_REGION_GPA); =20 /* @@ -269,7 +266,7 @@ static void guest_code_delete_memory_region(void) GUEST_ASSERT(0); } =20 -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) =20 vm =3D spawn_vm(&vcpu, &vcpu_thread, guest_code_delete_memory_region); =20 - 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 =3D 0; =20 - if (kvm_check_cap(KVM_CAP_DISABLE_QUIRKS2) & KVM_X86_QUIRK_SLOT_ZAP_ALL) - disable_slot_zap_quirk =3D 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 =3D 10; =20 - for (j =3D 0; j <=3D 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 =3D 0; i < loops; i++) - test_move_memory_region(!!j); + pr_info("Testing MOVE of in-use region, %d loops\n", loops); + for (i =3D 0; i < loops; i++) + test_move_memory_region(); =20 - pr_info("Testing DELETE of in-use region, %d loops, slot zap quirk %s\n", - loops, j ? "disabled" : "enabled"); - for (i =3D 0; i < loops; i++) - test_delete_memory_region(!!j); - } + pr_info("Testing DELETE of in-use region, %d loops\n", loops); + for (i =3D 0; i < loops; i++) + test_delete_memory_region(); #endif =20 return 0; --=20 2.46.1.824.gd892dcdcdd-goog From nobody Thu Nov 28 22:31:52 2024 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (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 8BDB98248D for ; Fri, 27 Sep 2024 00:16:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727396208; cv=none; b=sGldPCqyUNqmg9IgzfzG3XAACrEeRYpWVcq4bwGa/P/kHMISDX4fwBQ18gy49VPGLy5+J/bfOLTH3UIdSk5A9JRxwy5strAY+6CS1tuGhpqZ5ZenuV3u+W8ZKf+4T22dmrnnZCHGhNdAsted8w3SChIl0i66Vo2kta5uqyL5mHw= 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.73 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-f73.google.com with SMTP id 98e67ed59e1d1-2db446a3d28so2238353a91.2 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=JgLj+45rIWWSIqgT1YTmp3oGckWMDg33aNQzfxe8VOOTCSD8m4D376SjgJkjQnkg2M Zp65TgmusFDJCQWEoo31lRZXcp+Z+YkN5d3gwB0CViIfExNOw4C9+v/I6yZjPKSYqCwk DDlPnvm1nBVaO8RQ3vIoyDoqZfKb/lOhuYEIDjE7SVdkMM+wXrcpuG+hMDTB7ecA4fZ7 e2oPctCFK3BkbAOMUrg87EnqOrL8NjmHNEd/T+tu0e3MUNqe4oAr3xeJiK3AFb3rdLA1 2xRW7GkjrBprj33KkAQswDxSDnpZ9vWP6ST79f3xv5Is87OnsCK0aNy+HTS7NTOnCjmm dtiQ== X-Forwarded-Encrypted: i=1; AJvYcCXR4hCFNPFGMSFlP7MepWMmsYNnuHnwTJo2baR504Fti7EqLICehaLQV4r1C9g5/MgMmNySUqTAeBVvPnA=@vger.kernel.org X-Gm-Message-State: AOJu0YyQhdOHV+OnE+Ey1aHmZ6hAdmxryIc60EFQd3eiWLtLp1j9ONF/ ebLhrfsyMCcP4pwHBuQAYK3sDKlUXEToQl3OLGzU7kRyhP6uYOACR+XG0FG895RXNzwDqn+yrZP z2A== 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: linux-kernel@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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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]=3DWARN 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 ra= nge of - the memslot being deleted. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D =20 7.32 KVM_CAP_MAX_VCPU_ID diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_hos= t.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) =20 /* * 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/kv= m.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) =20 #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); } =20 -/* - * 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_s= lot *slot) -{ - struct kvm_gfn_range range =3D { - .slot =3D slot, - .start =3D slot->base_gfn, - .end =3D slot->base_gfn + slot->npages, - .may_block =3D 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 =3D=3D 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); } =20 void kvm_mmu_invalidate_mmio_sptes(struct kvm *kvm, u64 gen) --=20 2.46.1.824.gd892dcdcdd-goog