Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp5954762iog; Thu, 23 Jun 2022 08:28:07 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t3TYcxJV6ITdu3xOJ+DQEWZURjRXHRdhdTvwiFrrJ2brKx7e+MrVBzcwIpJgfYHiUuWNfp X-Received: by 2002:a50:ef12:0:b0:435:81f3:a93a with SMTP id m18-20020a50ef12000000b0043581f3a93amr11549270eds.80.1655998086823; Thu, 23 Jun 2022 08:28:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655998086; cv=none; d=google.com; s=arc-20160816; b=zuEID11kFtTOcdtH57PcYeZsnZe0/YUa9hhdOqiWtYQzSAF7vsYsPSJOeASV0akH1j UZ/CXJMGQdhgWK2KFRh0naqzPxm0SNlkhTfmcwSEAf/G8SxfecbHGz6SfVWaoZuG6PXt giMmtDlxveLYnniNprO4nfw1pee1qf6KN+h+Osnm6qjUC3Y2cAVI/FRLjtUNgqQu3Vps b4aYm7anuPKaY56mKkJAvTZiWedgsCt3HH7O7MtTIk/7OkStln2D3esnsZ6JRcUq3J1t xCQmVOh/KmAyT4rL/ZATfgShnjusimCqVy7T9t36+57/+FvBCMt83us9dPx1SH6T8FX3 dZ4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+qSsChT75v3dvhRAkXYqSV2TfsP5NCarupm2V9Kqui0=; b=TzMctuGXNqpvMShZ7gXQqFnaVyJvrUF3ESBo33qb8XZ7TWI20AKRxMx/Kq0p5DIO8R PU6cpecLlHa3zuZi9VNSOSp89GlFN3EmEJnJAwRoJAfglZqsDfog8DLgu7FYeTO81gK0 YmZeArUAC8d5KAry8KsW9hrFeSe4jMuobn+clb3UAeqQtpTXOxi/pNko/sC1ICGou2sP pmqPupTJ7djDDirq9nXbVSdS3yGacO1KVaPW99Q3kAdMvt1jKkxf7jAFDF6YMyaCAmHh XlYPvXMcCWzZyi+X2/0MSibq3wn4300rUyxdJrGWNJr3uyCRwafv4oBhS+vxUyjSuHki UJag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Yz5N2ry9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ss28-20020a170907c01c00b006f5116d3cdcsi14974606ejc.22.2022.06.23.08.27.41; Thu, 23 Jun 2022 08:28:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Yz5N2ry9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232013AbiFWOty (ORCPT + 99 others); Thu, 23 Jun 2022 10:49:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231995AbiFWOtw (ORCPT ); Thu, 23 Jun 2022 10:49:52 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EFB146679 for ; Thu, 23 Jun 2022 07:49:51 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id a15so12134190pfv.13 for ; Thu, 23 Jun 2022 07:49:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=+qSsChT75v3dvhRAkXYqSV2TfsP5NCarupm2V9Kqui0=; b=Yz5N2ry9uNEF1gaCrCZKOslUu3DOdurMNWT1q6KWoCmT2NDA4a+LtMpMgwsnVfK7zZ RsRoEVr//JBe44DK1MPKhvSYbDQEx/uQDDfuM1g7Fd/GXkj2UvofhpAgxVqE6XuVFjei RcT6g1GMZMEu+84zRGCPZTX491w5ladQzU+KEdRiqOwVWr85a5ka7cpCuMBsW+SyES8p owJ5Gu1oonI/fBRiqhh7dfwfdguVM1ck5qAZBPl7Q3xcxrjQB0vZjt0qFDZWR34kQOjl fcxmI1ChSM01swtv8XSTLbvCTm1tyxxteXF6A4GjAvQYNaZesY9YQzaluqk8xoHdg5+g JdJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=+qSsChT75v3dvhRAkXYqSV2TfsP5NCarupm2V9Kqui0=; b=hGD620tgK9sEDrTNvMIFuECf6QWGbVt/HVBPgAoZicTuMav9CSgvdHRMXT2lZ9UtlZ 5jQ14ryhfIAPr0Zr/s+BUkqU4YMEjgXFWlobsKOTMsI8FjSuMjdyZYWk6dbJYO6oSiZS 273uXjJAZ0PFQa/YbkE8YzNE3jWNE6Qanv4UKThtKIGfrowWfGDXxTPpXiyG1AZ5CjTe iALv11kxUUkipAs3+2Ug/+KccSF93IcAOLViYZWJgsyuY01nP5bPxnLbNasScWzMxWLQ yXd4lgOKA3LjyuXkG8PdinXwRo2yaf771qEa9KQHmrSTp8Sbc4EfecsJDgQgY0L1n9ld Rlnw== X-Gm-Message-State: AJIora/N0yaJ+8D1QvV8fme33p03ULkK27q2tcaZVycDl+6ACRl5heeo OVhqn/onc+fRNEA8av45lkc7Bw== X-Received: by 2002:a05:6a00:9a2:b0:505:974f:9fd6 with SMTP id u34-20020a056a0009a200b00505974f9fd6mr40733440pfg.12.1655995790918; Thu, 23 Jun 2022 07:49:50 -0700 (PDT) Received: from google.com (123.65.230.35.bc.googleusercontent.com. [35.230.65.123]) by smtp.gmail.com with ESMTPSA id i22-20020a17090ad35600b001ec8d191db4sm2003335pjx.17.2022.06.23.07.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jun 2022 07:49:50 -0700 (PDT) Date: Thu, 23 Jun 2022 14:49:47 +0000 From: Sean Christopherson To: Peter Xu Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini , Andrew Morton , David Hildenbrand , "Dr . David Alan Gilbert" , Andrea Arcangeli , Linux MM Mailing List Subject: Re: [PATCH 2/4] kvm: Merge "atomic" and "write" in __gfn_to_pfn_memslot() Message-ID: References: <20220622213656.81546-1-peterx@redhat.com> <20220622213656.81546-3-peterx@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220622213656.81546-3-peterx@redhat.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 22, 2022, Peter Xu wrote: > Merge two boolean parameters into a bitmask flag called kvm_gtp_flag_t for > __gfn_to_pfn_memslot(). This cleans the parameter lists, and also prepare > for new boolean to be added to __gfn_to_pfn_memslot(). ... > @@ -3999,8 +4000,8 @@ static int kvm_faultin_pfn(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault) > } > > async = false; > - fault->pfn = __gfn_to_pfn_memslot(slot, fault->gfn, false, &async, > - fault->write, &fault->map_writable, > + fault->pfn = __gfn_to_pfn_memslot(slot, fault->gfn, flags, > + &async, &fault->map_writable, > &fault->hva); > if (!async) > return RET_PF_CONTINUE; /* *pfn has correct page already */ > @@ -4016,9 +4017,8 @@ static int kvm_faultin_pfn(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault) > } > } > > - fault->pfn = __gfn_to_pfn_memslot(slot, fault->gfn, false, NULL, > - fault->write, &fault->map_writable, > - &fault->hva); > + fault->pfn = __gfn_to_pfn_memslot(slot, fault->gfn, flags, NULL, > + &fault->map_writable, &fault->hva); > return RET_PF_CONTINUE; > } > > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > index c20f2d55840c..b646b6fcaec6 100644 > --- a/include/linux/kvm_host.h > +++ b/include/linux/kvm_host.h > @@ -1146,8 +1146,15 @@ kvm_pfn_t gfn_to_pfn_prot(struct kvm *kvm, gfn_t gfn, bool write_fault, > bool *writable); > kvm_pfn_t gfn_to_pfn_memslot(const struct kvm_memory_slot *slot, gfn_t gfn); > kvm_pfn_t gfn_to_pfn_memslot_atomic(const struct kvm_memory_slot *slot, gfn_t gfn); > + > +/* gfn_to_pfn (gtp) flags */ > +typedef unsigned int __bitwise kvm_gtp_flag_t; > + > +#define KVM_GTP_WRITE ((__force kvm_gtp_flag_t) BIT(0)) > +#define KVM_GTP_ATOMIC ((__force kvm_gtp_flag_t) BIT(1)) > + > kvm_pfn_t __gfn_to_pfn_memslot(const struct kvm_memory_slot *slot, gfn_t gfn, > - bool atomic, bool *async, bool write_fault, > + kvm_gtp_flag_t gtp_flags, bool *async, > bool *writable, hva_t *hva); I completely agree the list of booleans is a mess, but I don't love the result of adding @flags. I wonder if we can do something similar to x86's struct kvm_page_fault and add an internal struct to pass params. And then add e.g. gfn_to_pfn_interruptible() to wrap that logic. I suspect we could also clean up the @async behavior at the same time, as its interaction with FOLL_NOWAIT is confusing.