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 26A38C77B7C for ; Wed, 10 May 2023 17:26:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236334AbjEJR0v (ORCPT ); Wed, 10 May 2023 13:26:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232796AbjEJR0q (ORCPT ); Wed, 10 May 2023 13:26:46 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F68AE3 for ; Wed, 10 May 2023 10:26:45 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-50bc37e1525so14291323a12.1 for ; Wed, 10 May 2023 10:26:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683739603; x=1686331603; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=HJL+JhQmxU9qA5lMrvGM05IUnqGL3GZgrHCNTgjj3t0=; b=v3awAP8GUD/ZDAJvrp2L+Znr7TDIkUCt5LWmzipwChCwH7m0oNy7iOV/XqpkYIvXC/ BaMLy1q5d30O1WltT+xWOddJUdKCZ77bVEh+iIGcn7clk+Pr7J34ZR9C6HjlOh0M8PQN +KtV3eWjkMhmHGFj3VzXyHLN12k3kTd0Xp27WmEQMgAvOXZx8+M07tdd09LAcdq9S5gw Op6AeU8UYav4jAMxNbO8sejmCm826l+LN+yd8U18+i4+BXzX9kJ4pN6hmGxz+2JMRPVy lnOmcSZWW/LN0u/yOT1Hm6pCFNYc9LVNZeLjV+RSIjZHbsGsFCzBdebHdWJa6cCrS655 E2wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683739603; x=1686331603; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HJL+JhQmxU9qA5lMrvGM05IUnqGL3GZgrHCNTgjj3t0=; b=Xlm0N+cGAdNYW4TGRG0KR++8vxUDehMyxhe4Ff2hGY/BHsD8sQIq4ukl6lwoPW5n3a niFNURI9NLGx2VMhN5nBgUaQNgSo+tTIg/0MbkIKc7Lyu1g6RzoPrbUZS7S03LRlyepd /apTcvQnJbSa68aomHgb6e3GtFphjvPj6AZA5Py91ffIv/WIPHaS00pRn5RNiz3zkFuw cP6Ns+kewe/X93FUBo6ph1k5t+jhN3KRzCw53yb5U9KwTZTbk3ONDXrvkOQSbbG92DGj 8LU1QT1DhwqTGi9ux9QDawwkVnzb5ZChyegpq1LFzjHNyY2VSqZAb7zur2EvWjghmTAY oxKg== X-Gm-Message-State: AC+VfDy5U+XCvLuf8TkBxN1W+QRcD3+LlP4HTCKTj+7PmcTtAxPMWfLg bmv7bZQdbyrIRpCoqaGRhyTNBB++DWdXXVdEP4mjCQ== X-Google-Smtp-Source: ACHHUZ64G94ODQQyPBdm7IGyu9kHzcE0JVQFyt0rwKkromaOxP7k8Aq6aDDkSvekpiO3NFhe4DF5fY89lBIyRxbDjfw= X-Received: by 2002:aa7:cf95:0:b0:50b:c4f0:c200 with SMTP id z21-20020aa7cf95000000b0050bc4f0c200mr15479402edx.41.1683739603390; Wed, 10 May 2023 10:26:43 -0700 (PDT) MIME-Version: 1.0 References: <20221202061347.1070246-1-chao.p.peng@linux.intel.com> <658018f9-581c-7786-795a-85227c712be0@redhat.com> <1ed06a62-05a1-ebe6-7ac4-5b35ba272d13@redhat.com> <9efef45f-e9f4-18d1-0120-f0fc0961761c@redhat.com> <5869f50f-0858-ab0c-9049-4345abcf5641@redhat.com> In-Reply-To: From: Vishal Annapurve Date: Wed, 10 May 2023 10:26:32 -0700 Message-ID: Subject: Re: Rename restrictedmem => guardedmem? (was: Re: [PATCH v10 0/9] KVM: mm: fd-based approach for supporting KVM) To: Sean Christopherson Cc: David Hildenbrand , Chao Peng , Paolo Bonzini , Vitaly Kuznetsov , Jim Mattson , Joerg Roedel , "Maciej S . Szmigiero" , Vlastimil Babka , Yu Zhang , "Kirill A . Shutemov" , dhildenb@redhat.com, Quentin Perret , tabba@google.com, Michael Roth , wei.w.wang@intel.com, Mike Rapoport , Liam Merwick , Isaku Yamahata , Jarkko Sakkinen , Ackerley Tng , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Hugh Dickins , Christian Brauner Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 21, 2023 at 6:33=E2=80=AFPM Sean Christopherson wrote: > > ... > cold. I poked around a bit to see how we could avoid reinventing all of = that > infrastructure for fd-only memory, and the best idea I could come up with= is > basically a rehash of Kirill's very original "KVM protected memory" RFC[3= ], i.e. > allow "mapping" fd-only memory, but ensure that memory is never actually = present > from hardware's perspective. > I am most likely missing a lot of context here and possibly venturing into an infeasible/already shot down direction here. But I would still like to get this discussed here before we move on. I am wondering if it would make sense to implement restricted_mem/guest_mem file to expose both private and shared memory regions, inline with Kirill's original proposal now that the file implementation is controlled by KVM. Thinking from userspace perspective: 1) Userspace creates guest mem files and is able to mmap them but all accesses to these files result into faults as no memory is allowed to be mapped into userspace VMM pagetables. 2) Userspace registers mmaped HVA ranges with KVM with additional KVM_MEM_PRIVATE flag 3) Userspace converts memory attributes and this memory conversion allows userspace to access shared ranges of the file because those are allowed to be faulted in from guest_mem. Shared to private conversion unmaps the file ranges from userspace VMM pagetables. 4) Granularity of userspace pagetable mappings for shared ranges will have to be dictated by KVM guest_mem file implementation. Caveat here is that once private pages are mapped into userspace view. Benefits here: 1) Userspace view remains consistent while still being able to use HVA rang= es 2) It would be possible to use HVA based APIs from userspace to do things like binding. 3) Double allocation wouldn't be a concern since hva ranges and gpa ranges possibly map to the same HPA ranges. > > Code is available here if folks want to take a look before any kind of fo= rmal > posting: > > https://github.com/sean-jc/linux.git x86/kvm_gmem_solo > > [1] https://lore.kernel.org/all/ff5c5b97-acdf-9745-ebe5-c6609dd6322e@goog= le.com > [2] https://lore.kernel.org/all/20230418-anfallen-irdisch-6993a61be10b@br= auner > [3] https://lore.kernel.org/linux-mm/20200522125214.31348-1-kirill.shutem= ov@linux.intel.com