Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp10627lql; Fri, 12 Apr 2024 01:48:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV1qwMPvjo3iTjRpoqGtIChdsLDHLCJ6KaDuUEpLO025LAkifJCMtUbm5hb6oINsfD2dLoIS/BmoZilPjMyBV5S4lPGK714mKdXz7QO+w== X-Google-Smtp-Source: AGHT+IH2rS2gWsJ/5l3jeRUBP+K+vzP7/W+OLTqmVwWixFOz8nBBoUS3/D8cNCT5j0u93jQRf7jw X-Received: by 2002:a17:90a:6546:b0:2a4:b04b:d204 with SMTP id f6-20020a17090a654600b002a4b04bd204mr2977352pjs.7.1712911714783; Fri, 12 Apr 2024 01:48:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712911714; cv=pass; d=google.com; s=arc-20160816; b=sl6GkV13SWEAPCNCHKGI6bwFwoBhe96v3alI+/ueyoYSjh/37CW8fo6uN4TWMSlOOh 5uEubZD8k+nuus8Q0x20keXKxhlbb3h+oqOjmXxU5xTSfCqJSOZ9YRc1SN1SBdxMvcPi MjVznjQtRL/5mnsO3/7c3bHB5OvVK8bEVqOPR3FZoWbzu845aSkzaMLu4VtVMHRepVDQ BIP+FXmqROmDZe/7K8kelhrQ0jo2257KtM/3qLStZFrbjryr1X5sm7DVwGWxWZ0PBbjC eIhqR6YHvVCgZnKj4PN/hMbVxfmDDZOzDq6Q7GUK1qPKWMNGOEVjGdPL42K9aoaxRZ8f 91uA== 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=sW3I3Ot/QByY1RX0kCvMiTyTHOSNnrhu94rlgUb8+Sk=; fh=m+8oYQsnscGrLdt+J5hQBC59O1K0aWeL6/b9B5QIO6Y=; b=C3hjOLOv9zldW2ZCURIAcsESBJQ/Tyl5vNAxcSy4zHD8bKMD4C+hyoKGWv4rFdyU4h Po6kCjZoePKSn0+A8VOYZbw+P4wafVjluTZHZscEZB6y6P64tUHyiNJEn6d5ZL1pD6yN X8Vz0Q0dUVDgvaBwX5eJg7Cb+cs9lIgN6jewrTlXFKJWV7VXQfYkOWByi3GBkZ7wEt39 ZbQZ21EvNNXdHJmIO1Uxh+0npcIGVv8TiQZs+QEwQ3MFVB+YbRHxH6DU9+NXHzzPq9Ku 7hZhbJlkKVMQBPa6cMFYRy6OQvijFgvcSFcHSkPk+vmTshMXH9u6fVMo17HjYWbIIhHe b2EA==; 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-142269-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142269-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h36-20020a635324000000b005e49edf6458si2716442pgb.753.2024.04.12.01.48.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 01:48:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142269-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::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-142269-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142269-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7F3AE284E3D for ; Fri, 12 Apr 2024 08:47:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C081C5B5D6; Fri, 12 Apr 2024 08:43:22 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EA11651C42; Fri, 12 Apr 2024 08:43:20 +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=1712911402; cv=none; b=JcGzKF/ZJ02lmwDeZopjD+fuA851vQszzAnqMAo5ljZnFeFW82DCBXsKUcXxjkXeuwPeYMJgBGM42DJ6k6HdN95OTy5MtQXseKNozJGnpsnK2yth4R6jaxhWEfKzJG3tJ0wrVIU0OnpyWcOSoe0HM3YOrIPWZP5P/w/5ln66pzQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712911402; c=relaxed/simple; bh=hQXE1YS9iGYqnK+SmVQuOi4h0v+V1FfkvsGBmVUyMd4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BOjANGUgj3jDLIuPisCYTBR62tGnhc83gc9mJYJAwNyHq1hj7ZBWjrdABCO9Im+4hcycGzdHxFVez9f4v3nf9uYviUNgc86I54Z0f3grVR6cfI6Yqe9Wjg069y8NgXTFSDzpKiGtYDLCbQNKA4y+bLcj34NYYBOAXfbLu5NJsEU= 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 91D86113E; Fri, 12 Apr 2024 01:43:49 -0700 (PDT) Received: from e112269-lin.cambridge.arm.com (e112269-lin.cambridge.arm.com [10.1.194.51]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1B9403F6C4; Fri, 12 Apr 2024 01:43: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 v2 01/43] KVM: Prepare for handling only shared mappings in mmu_notifier events Date: Fri, 12 Apr 2024 09:42:27 +0100 Message-Id: <20240412084309.1733783-2-steven.price@arm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240412084309.1733783-1-steven.price@arm.com> References: <20240412084056.1733704-1-steven.price@arm.com> <20240412084309.1733783-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 48f31dcd318a..c7581360fd88 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -268,6 +268,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 fb49c2a60200..3486ceef6f4e 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -633,6 +633,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