Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp367662lqp; Mon, 10 Jun 2024 06:42:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUSF8S70cNy+vuz9Ynhv3q/J+xb7xQXAFvqLGXur6kEHQmzjDnOWQNoBvQwEvpUaaEV4pMobaqR86J21Irj8+AP4c0NmgcF0gD0oR51DA== X-Google-Smtp-Source: AGHT+IGIWdc7ofe3MgiIq4iUuIInBj+CSs6q8rWAOwb9NgHufc3K4nXOyhmEECuduyrWtOeEAkMA X-Received: by 2002:a05:620a:4105:b0:795:56de:38f with SMTP id af79cd13be357-79556de133amr704908785a.1.1718026969109; Mon, 10 Jun 2024 06:42:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718026969; cv=pass; d=google.com; s=arc-20160816; b=kNSCOfjaW60QdUj+hkmgaY3MShDxcensAHp3LCX3wwU98fpGwYoG38e0lUmhftqL9D uucTrz5YWrEA2GASZnFb+9HAJsFy70UiPhLofQFKtFkr9BppSxp+LcTdh0wVGQKAHh3+ lZs0TSfqQRtLcfPR9U/Df3XkudGoDtaVyRDR9hPRTr3XSFkeUd3pQI2VMPlG1T2XHcoA 01ZIzyGPBEhwtMxkBLW8yNojWWUc4x2+j6Y719VJAvcplPgbVmuuQ8v6mmkGbGE3F8Qu q9ilSpBpyzbxFFd5M8+Yc8oS0XUgmzTg3uqVeAAzTwG4Z1IeVgp2XAAb0+uOcsTBGRv3 43Pw== 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; bh=Swm2UFu6GFlD2L82PWoz3oTJQBHnGP5AMXD+p6YbzVw=; fh=m+8oYQsnscGrLdt+J5hQBC59O1K0aWeL6/b9B5QIO6Y=; b=qUTFi+IhR9Odmcs4sIkUDYkxRSzthPALsApzhfErY/fhB1fSi7Dh+Db3ojnWkEgZwq m/JTsn/ZNfWG9UjuQU3YyqLYgxc2ZORgbTRuz7FQjB/phRR6OxtXAUaIHmNtM8cd0imS jZAwCtIoXHYbuj3wWeqO18ONv6gbT8X7Y4zdaGrKJBBHJGvrcvMyX6WGXdb6e32c192q iNXA+t9IPPlKDDgXCFa5So/Jfx5qPkTxkBnVsluTJ4vrXuiYea4QEG9kTSEQJiAZyCQQ +Y2Wrh0qrDUwM79tt/P60GwIoa9gc/lCrg4kaL+eBaAzGbJMktK7dshbkY8u+ItN8x9q 0nFQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-208248-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208248-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-7954c4c8932si708291085a.68.2024.06.10.06.42.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 06:42:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208248-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-208248-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208248-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id CEBCD1C21A80 for ; Mon, 10 Jun 2024 13:42:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6EF9912FB27; Mon, 10 Jun 2024 13:42:24 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 59E6184E04; Mon, 10 Jun 2024 13:42:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718026944; cv=none; b=d3+SQ+PvDeXCwSbkw+w+MLoTBpDR4Z7XUGVtaFBaoj597aPN8pkpfe3M3oAT00kx1rrQCsRzAGWU0FJHUaSrve/D0rUtn9+9A36BQYoZIqpI4eIbuwINh5FuQH4c8y/UtTjhGbqGxIBfD7Hn5MR8glLHrCWT8/6HMpFvw8LHTKw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718026944; c=relaxed/simple; bh=SZqlvKa++YGsE9E9uqbdhq9d2K/3nSBBjlc+3fFf3Po=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZpKoRG49QHjN60XtcIUWFVae6rYivAmNDK8e3QWXfkUQijbob3TKdOraD0a8vZ3qIf3XspsE8d9HDL/X83kIFAoRZHKPfZfbPqWGePvBV0Ay9pr7gDnaMTjfzv8qAm+gQw308Q7ViczXEkJvKO99zTeJZJ4oUoyefPyE+4I3XrE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6818F12FC; Mon, 10 Jun 2024 06:42:46 -0700 (PDT) Received: from e122027.cambridge.arm.com (e122027.cambridge.arm.com [10.1.35.41]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 49DE43F58B; Mon, 10 Jun 2024 06:42:18 -0700 (PDT) From: Steven Price To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: Sean Christopherson , Catalin Marinas , Marc Zyngier , Will Deacon , James Morse , Oliver Upton , Suzuki K Poulose , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Joey Gouly , Alexandru Elisei , Christoffer Dall , Fuad Tabba , linux-coco@lists.linux.dev, Ganapatrao Kulkarni , Steven Price Subject: [PATCH v3 01/43] KVM: Prepare for handling only shared mappings in mmu_notifier events Date: Mon, 10 Jun 2024 14:41:20 +0100 Message-Id: <20240610134202.54893-2-steven.price@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610134202.54893-1-steven.price@arm.com> References: <20240610134202.54893-1-steven.price@arm.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 From: Sean Christopherson Add flags to "struct kvm_gfn_range" to let notifier events target only shared and only private mappings, and write up the existing mmu_notifier events to be shared-only (private memory is never associated with a userspace virtual address, i.e. can't be reached via mmu_notifiers). Add two flags so that KVM can handle the three possibilities (shared, private, and shared+private) without needing something like a tri-state enum. Link: https://lore.kernel.org/all/ZJX0hk+KpQP0KUyB@google.com Signed-off-by: Sean Christopherson Signed-off-by: Steven Price --- include/linux/kvm_host.h | 2 ++ virt/kvm/kvm_main.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 692c01e41a18..c5394c948db5 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -265,6 +265,8 @@ struct kvm_gfn_range { gfn_t start; gfn_t end; union kvm_mmu_notifier_arg arg; + bool only_private; + bool only_shared; bool may_block; }; bool kvm_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range); diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 14841acb8b95..ff486d7d29b4 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -634,6 +634,13 @@ static __always_inline kvm_mn_ret_t __kvm_handle_hva_range(struct kvm *kvm, * the second or later invocation of the handler). */ gfn_range.arg = range->arg; + + /* + * HVA-based notifications aren't relevant to private + * mappings as they don't have a userspace mapping. + */ + gfn_range.only_private = false; + gfn_range.only_shared = true; gfn_range.may_block = range->may_block; /* -- 2.34.1