Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1215274lqd; Thu, 25 Apr 2024 08:58:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUEt/jehjdLsWEyJtb+11vC54jfILmdr0kvajB5Zt0/1aV43aGoSXBdSUmLqvWg5qf9YQ7Zyy3jmtIz9cJHfoh0Ba4eHjWTWXrO2G7cEg== X-Google-Smtp-Source: AGHT+IFQQigX+HJvVC8oa0sdDJGO0hB4f29Cbxmd4qLjpfpYlfOfwudnHLEe6Qwwj/MaiQF/+Rfm X-Received: by 2002:a05:620a:4898:b0:790:9666:c714 with SMTP id ea24-20020a05620a489800b007909666c714mr4905144qkb.39.1714060709747; Thu, 25 Apr 2024 08:58:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714060709; cv=pass; d=google.com; s=arc-20160816; b=KRVNCRtS78jdSpa8Kg/+iBiPkJ4p7c9MGzGbX6doHfutom66Wxw6G9WuJ/L5srIQW4 Oey8POweQAhzCpl9vMWeZjs2Oa9GpZsgTY/bADSvqZCYwOBWILCTchhWkTe2URLK3Z+t cVoHpruTvSqzfMx8uLYR2xC3lBInBxv3D+QhalDaA0VyK+EYq8JP9xVZ2kpvq7al4Src vGNdCozRWL3F87g9NoUF0NGZGd1Omo/orUphBCbrFExKX0rQW7W2yF+1mxW9issTKZOb l4EXM2xFnkVsJYmMNs3aMOB1FrCUdNEPK4U+bGQPb6oOWKpzp3eGybA3+v8HaWg28UC3 A2OA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=mjI8T5QBAqSWldf/drLeKuI2PKoB0IBjebce+UB59D0=; fh=1zuh1NdwQhNVSaVN7P6J3RMv9uyKRlJ12U9ctQ2uLCs=; b=VmpDtMda+n9r8TshR2FaqAKp9Ium/65G4AcDDd5iMs+sybvSDmJlFHCUzQyvtWFB2R oeEpFQNvK055rs51Fqa3lciKEX/ZLz4qmY8rMmWDyk+vnpsA8adMmKhb7I3tpydX7YUB CuHsP/dYI/wop0qLnMmgex006mcbnqVPgSlH32zCzkS4HfpztvxXQngDI4pQrJ0bQsrz S/WWW7Njgyy2Gvn4RjbJHFcU6GXv4+VT8m8z3Yp/FE6T9OGq0Aqt9oevnA81sFSrBZ1I LGOXhzbs5j7tZiXwowyUDiJ5iG9QYxbSyFLEtH0wOJ5VNemFbxOsJYPG0D3Jaw3TZq1s MEDg==; 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-158852-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158852-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. [147.75.199.223]) by mx.google.com with ESMTPS id w28-20020a05620a095c00b0078ede265017si17475702qkw.656.2024.04.25.08.58.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 08:58:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158852-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-158852-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158852-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 7715B1C20A57 for ; Thu, 25 Apr 2024 15:58:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 87FA814C5B8; Thu, 25 Apr 2024 15:58:19 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 98D0D149E05; Thu, 25 Apr 2024 15:58:17 +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=1714060699; cv=none; b=DIH/nzbh+6rKR85ZEXNI095l90hDW1aYxPlJNwAygP88Kjq1YKUPK1hpfVnUXG8/ydm1oZGmOXk4lkikkQfIsZloL5FRAEDHx5ddNKS7k0Jl2plvHKN2wcWQ1MHg3qqLkIVDuWsSlGcFNqHAnyMZVY6eNeB4AHokT8trk9ez8Ag= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714060699; c=relaxed/simple; bh=f2EiSgp8zlHR9yB6BJrFYtDILE/zqRT/fk/hI9IqEgc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=mlt2CSi12NtJ7vncCl89tTY+s1Je8dSjO0Y5HApQoYK7X9n3S52f+Ek0GkhgIvmb8ROSEIiUq66kbNVohh59FvGFNxzulx8EgZLuV90VXSQd+kzIYClEiln7yKQVV/h4Klz49PEcsqi4G+yxV6HM5FUrJuXC/6HSKXRwAH9cODo= 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 399DA1007; Thu, 25 Apr 2024 08:58:45 -0700 (PDT) Received: from [10.57.56.40] (unknown [10.57.56.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 166443F73F; Thu, 25 Apr 2024 08:58:13 -0700 (PDT) Message-ID: <4195a811-7084-42fe-ad10-27d898fb3196@arm.com> Date: Thu, 25 Apr 2024 16:58:13 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 01/43] KVM: Prepare for handling only shared mappings in mmu_notifier events To: Fuad Tabba Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, 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 , linux-coco@lists.linux.dev, Ganapatrao Kulkarni References: <20240412084056.1733704-1-steven.price@arm.com> <20240412084309.1733783-1-steven.price@arm.com> <20240412084309.1733783-2-steven.price@arm.com> From: Steven Price Content-Language: en-GB In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 25/04/2024 10:48, Fuad Tabba wrote: > Hi, > > On Fri, Apr 12, 2024 at 9:43 AM Steven Price wrote: >> >> 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; > > I'd discussed this with Sean when he posted this earlier. Having two > booleans to encode three valid states could be confusing. In response, > Sean suggested using an enum instead: > https://lore.kernel.org/all/ZUO1Giju0GkUdF0o@google.com/ That would work fine too! Unless I've missed it Sean hasn't posted an updated patch. My assumption is that this will get merged (in whatever form) before the rest of the series as part of that other series. It shouldn't be too hard to adapt. Thanks, Steve > Cheers, > /fuad > >> >> /* > > >> -- >> 2.34.1 >> >