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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C870ECAAD8 for ; Fri, 16 Sep 2022 09:14:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B5598D0002; Fri, 16 Sep 2022 05:14:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 23EAC8D0001; Fri, 16 Sep 2022 05:14:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E00B8D0002; Fri, 16 Sep 2022 05:14:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id F3D4E8D0001 for ; Fri, 16 Sep 2022 05:14:34 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C9E4D407AF for ; Fri, 16 Sep 2022 09:14:34 +0000 (UTC) X-FDA: 79917388068.02.90AF203 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by imf15.hostedemail.com (Postfix) with ESMTP id 7D458A00A7 for ; Fri, 16 Sep 2022 09:14:34 +0000 (UTC) Received: by mail-pg1-f180.google.com with SMTP id q63so19784997pga.9 for ; Fri, 16 Sep 2022 02:14:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=9HbJp1JFOjaCOMdfyVv+S5Btdn1/AdqiEXlLTZXJGsw=; b=FhXk6bHLd2b2R99Ls/aHceAb/stM1+/U366ItM+cIq6+4cGyeSSS3oIj0C0fleVnRb 1Oy5YydiCifwONXQ7wSQiUYRXoH7Mx1foLkqZPWh8dP8iXIDDqQ5t6pLwxs6+plCZvlg Nn+HEf/pJUaZbke7TTPzTTPkGpt085qGFfZNtCQRSNX3ALv7oZte2z1tpOrDZga6rULp UhUnt0L+EsaXnKH93vJFxK9Cqsv5+shWxVZ8+qcd1oF52gRR3xHbwA1NrpOFdZedwuRe un8jpB+sJR4QedlqDa4uSBkp9rex0MViA2EldTkEAnstjD1ZJKcVVfl3WtUvxl6d6Cxc Ghxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=9HbJp1JFOjaCOMdfyVv+S5Btdn1/AdqiEXlLTZXJGsw=; b=4hvrNQ5ahAIWOiWBDgKovWDNkHEbaQYhRCymEuo7vvXuzGASNdMQkw8lHPDyCcKn5u BWn3CK7Iq8oDxB1y+PeVjV2rZ5qzDrbdlt/T+CxCPh/6ugUrgcVhxdo80r+L/UqSHUzn sF/h9YByXjBmnbkyG9AmRp60sm0eOWVivfHkxK2TCMbPLI4a6NBlWgwXrElG8FUTJ6sz kS0QCKlWrTXTxDCUTlcuW/7trUean/fTuIUs6OuS5tdXoLUyx46Qe/G14DVjET8K4qq9 DTL8Op9QE4pL60wPgq9Oru2zYBj32kPeF7xuI9ZtrCl1NCQIvJolJsCNp0ENoBoyObTM VLRg== X-Gm-Message-State: ACrzQf0s8YzoSlYL7cXDThQAbmfK8IQOksh4noIhiZFbhmYuCrR9guYD CY1fysC6Erz532Ewr/ITo6M= X-Google-Smtp-Source: AMsMyM5/dJZc/QkfgAbO54iWH2nmTge0XbEgPmG5RCUUzNqq/hIVySC1GzK1Hf1d9uWZroqXUsDRFw== X-Received: by 2002:a65:6e82:0:b0:41a:9b73:f0e6 with SMTP id bm2-20020a656e82000000b0041a9b73f0e6mr3808278pgb.371.1663319673424; Fri, 16 Sep 2022 02:14:33 -0700 (PDT) Received: from debian.me (subs32-116-206-28-32.three.co.id. [116.206.28.32]) by smtp.gmail.com with ESMTPSA id c81-20020a621c54000000b0052d4cb47339sm13931057pfc.151.2022.09.16.02.14.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 02:14:32 -0700 (PDT) Received: by debian.me (Postfix, from userid 1000) id 719B010322A; Fri, 16 Sep 2022 16:14:29 +0700 (WIB) Date: Fri, 16 Sep 2022 16:14:29 +0700 From: Bagas Sanjaya To: Chao Peng Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, qemu-devel@nongnu.org, Paolo Bonzini , Jonathan Corbet , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H . Peter Anvin" , Hugh Dickins , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Shuah Khan , Mike Rapoport , Steven Price , "Maciej S . Szmigiero" , Vlastimil Babka , Vishal Annapurve , Yu Zhang , "Kirill A . Shutemov" , luto@kernel.org, jun.nakajima@intel.com, dave.hansen@intel.com, ak@linux.intel.com, david@redhat.com, aarcange@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, Quentin Perret , Michael Roth , mhocko@suse.com, Muchun Song , wei.w.wang@intel.com Subject: Re: [PATCH v8 2/8] KVM: Extend the memslot to support fd-based private memory Message-ID: References: <20220915142913.2213336-1-chao.p.peng@linux.intel.com> <20220915142913.2213336-3-chao.p.peng@linux.intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="r2iCa8Nng+AYARyi" Content-Disposition: inline In-Reply-To: <20220915142913.2213336-3-chao.p.peng@linux.intel.com> ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=FhXk6bHL; spf=pass (imf15.hostedemail.com: domain of bagasdotme@gmail.com designates 209.85.215.180 as permitted sender) smtp.mailfrom=bagasdotme@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663319674; a=rsa-sha256; cv=none; b=rc0tvyG0YGpvKPuf/inZawzgBTdZDWZXMyUzenQZXa54tT4vuS6Q7s+Xe28DVj38mtolY6 fxyKu3Dg3TyGiHyJtVIXoK4HX9u9xPHjRkvUAumYyQowyraB83q2yv3mBVJAy4km9Ar/09 +eZdlkaONfv8lxuoyFOZVQd6bUS5t/s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663319674; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9HbJp1JFOjaCOMdfyVv+S5Btdn1/AdqiEXlLTZXJGsw=; b=LpAG3lh16LWdx1M8b86LorF/prCQHf6fRGKHcgRfL1ehVjRw4luLrnz9VAYWD8FIapIsEH 4jYz0tCwXqQqtFB+PiWWzXlr9YJQmWwzsTDCZpEaWorIyiG2SqAqhTOSj014UTSiECmo7A fUQ2xskDqYXN0/sH6cnjTrb2SgiXGt8= X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 7D458A00A7 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=FhXk6bHL; spf=pass (imf15.hostedemail.com: domain of bagasdotme@gmail.com designates 209.85.215.180 as permitted sender) smtp.mailfrom=bagasdotme@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: p6ughhieotttwmzx38kf8i9xysf76mqr X-HE-Tag: 1663319674-529359 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: --r2iCa8Nng+AYARyi Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Sep 15, 2022 at 10:29:07PM +0800, Chao Peng wrote: > diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.= rst > index abd7c32126ce..c1fac1e9f820 100644 > --- a/Documentation/virt/kvm/api.rst > +++ b/Documentation/virt/kvm/api.rst > @@ -1319,7 +1319,7 @@ yet and must be cleared on entry. > :Capability: KVM_CAP_USER_MEMORY > :Architectures: all > :Type: vm ioctl > -:Parameters: struct kvm_userspace_memory_region (in) > +:Parameters: struct kvm_userspace_memory_region(_ext) (in) > :Returns: 0 on success, -1 on error > =20 > :: > @@ -1332,9 +1332,18 @@ yet and must be cleared on entry. > __u64 userspace_addr; /* start of the userspace allocated memory */ > }; > =20 > + struct kvm_userspace_memory_region_ext { > + struct kvm_userspace_memory_region region; > + __u64 private_offset; > + __u32 private_fd; > + __u32 pad1; > + __u64 pad2[14]; > + }; > + > /* for kvm_memory_region::flags */ > #define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0) > #define KVM_MEM_READONLY (1UL << 1) > + #define KVM_MEM_PRIVATE (1UL << 2) > =20 > This ioctl allows the user to create, modify or delete a guest physical > memory slot. Bits 0-15 of "slot" specify the slot id and this value > @@ -1365,12 +1374,27 @@ It is recommended that the lower 21 bits of guest= _phys_addr and userspace_addr > be identical. This allows large pages in the guest to be backed by large > pages in the host. > =20 > -The flags field supports two flags: KVM_MEM_LOG_DIRTY_PAGES and > -KVM_MEM_READONLY. The former can be set to instruct KVM to keep track of > -writes to memory within the slot. See KVM_GET_DIRTY_LOG ioctl to know h= ow to > -use it. The latter can be set, if KVM_CAP_READONLY_MEM capability allow= s it, > -to make a new slot read-only. In this case, writes to this memory will = be > -posted to userspace as KVM_EXIT_MMIO exits. > +kvm_userspace_memory_region_ext includes all the kvm_userspace_memory_re= gion > +fields. It also includes additional fields for some specific features. S= ee > +below description of flags field for more information. It's recommended = to use > +kvm_userspace_memory_region_ext in new userspace code. Better say "kvm_userspace_memory_region_ext includes all fields of kvm_userspace_memory_region struct, while also adds additional fields ..." > + > +The flags field supports below flags: s/below/following/ > + > +- KVM_MEM_LOG_DIRTY_PAGES can be set to instruct KVM to keep track of wr= ites to > + memory within the slot. See KVM_GET_DIRTY_LOG ioctl to know how to us= e it. > + Better say "... For more details, see KVM_GET_DIRTY_LOG." > +- KVM_MEM_READONLY can be set, if KVM_CAP_READONLY_MEM capability allows= it, to > + make a new slot read-only. In this case, writes to this memory will b= e posted > + to userspace as KVM_EXIT_MMIO exits. > + Better say "if KVM_CAP_READONLY_MEM allows, KVM_MEM_READONLY makes a new slot read-only ..." > +- KVM_MEM_PRIVATE can be set to indicate a new slot has private memory b= acked by > + a file descirptor(fd) and the content of the private memory is invisib= le to > + userspace. In this case, userspace should use private_fd/private_offse= t in > + kvm_userspace_memory_region_ext to instruct KVM to provide private mem= ory to > + guest. Userspace should guarantee not to map the same pfn indicated by > + private_fd/private_offset to different gfns with multiple memslots. Fa= iled to > + do this may result undefined behavior. > =20 For the lists above, s/can be set/ Thanks.=20 --=20 An old man doll... just what I always wanted! - Clara --r2iCa8Nng+AYARyi Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQSSYQ6Cy7oyFNCHrUH2uYlJVVFOowUCYyQ+bwAKCRD2uYlJVVFO o23ZAQDRE9CoC5C+vDIubVjEpXEJsigvh2LH13HdQDeX1z+k1AD/X1CQT1z1G/wL BTUE4CCJxYH87fBebOmUE0OMZL/c8go= =sF4e -----END PGP SIGNATURE----- --r2iCa8Nng+AYARyi--