From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A458C43334 for ; Thu, 23 Jun 2022 14:49:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232005AbiFWOtz (ORCPT ); Thu, 23 Jun 2022 10:49:55 -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-Google-Smtp-Source: AGRyM1u61EzUEh+JRGUbY08AnREjTd6Ub3VvJ0Hteh1fCeq4G/TENL2UDjYm4NKsqKEpJH2VZPMPPg== 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> 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.