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 6BF57C4332F for ; Wed, 19 Oct 2022 13:41:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232993AbiJSNls (ORCPT ); Wed, 19 Oct 2022 09:41:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231907AbiJSNlX (ORCPT ); Wed, 19 Oct 2022 09:41:23 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABFE6155DA9; Wed, 19 Oct 2022 06:29:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666186147; x=1697722147; h=date:from:to:cc:subject:message-id:reply-to:references: mime-version:in-reply-to; bh=maPvHabENdJbu0SifYloWSh+XeE9JeazxOD/pHHB/rU=; b=ePpJqt9a4rYoKf3f12FBETQeEqSJKEclKShJ3msgjKvjAPf7WfCLI1pf v/r7NAhjqY+sXAHXt5vodSFw96vWkPNKLGRhe0pahKlQlXpL++/LXbVpr kNF5fTwmx4O6rTERYAPEXWBuIeLmNoYU6Tlpzm1LBIOP0KgEb9AtLbeRg lXM3vlo4Mpb1lJJLLQrQOUqcZ58JEi7L+HUI+yhK30BgKRuvvCNoUeqa6 5FLxBsKLf7t2mkQ0630JT7P1FhtIjFThhPj7EVrXK7QHE0WXRcnU+wSfV ZPYEcaJ0VotbFFJVd34yECs4DH8tU9SCPoxaizR7DvaQXGAc9rZe7bvqv Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10505"; a="293803646" X-IronPort-AV: E=Sophos;i="5.95,196,1661842800"; d="scan'208";a="293803646" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2022 06:27:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10505"; a="624134706" X-IronPort-AV: E=Sophos;i="5.95,196,1661842800"; d="scan'208";a="624134706" Received: from chaop.bj.intel.com (HELO localhost) ([10.240.193.75]) by orsmga007.jf.intel.com with ESMTP; 19 Oct 2022 06:27:39 -0700 Date: Wed, 19 Oct 2022 21:23:08 +0800 From: Chao Peng To: Sean Christopherson Cc: Fuad Tabba , 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 , 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 5/8] KVM: Register/unregister the guest private memory regions Message-ID: <20221019132308.GA3496045@chaop.bj.intel.com> Reply-To: Chao Peng References: <20220915142913.2213336-1-chao.p.peng@linux.intel.com> <20220915142913.2213336-6-chao.p.peng@linux.intel.com> <20221012023516.GA3218049@chaop.bj.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 17, 2022 at 10:17:45PM +0000, Sean Christopherson wrote: > On Mon, Oct 17, 2022, Fuad Tabba wrote: > > Hi, > > > > > > > +#ifdef CONFIG_HAVE_KVM_PRIVATE_MEM > > > > > +#define KVM_MEM_ATTR_SHARED 0x0001 > > > > > +static int kvm_vm_ioctl_set_mem_attr(struct kvm *kvm, gpa_t gpa, gpa_t size, > > > > > + bool is_private) > > > > > +{ > > > > > > > > I wonder if this ioctl should be implemented as an arch-specific > > > > ioctl. In this patch it performs some actions that pKVM might not need > > > > or might want to do differently. > > > > > > I think it's doable. We can provide the mem_attr_array kind thing in > > > common code and let arch code decide to use it or not. Currently > > > mem_attr_array is defined in the struct kvm, if those bytes are > > > unnecessary for pKVM it can even be moved to arch definition, but that > > > also loses the potential code sharing for confidential usages in other > > > non-architectures, e.g. if ARM also supports such usage. Or it can be > > > provided through a different CONFIG_ instead of > > > CONFIG_HAVE_KVM_PRIVATE_MEM. > > > > This sounds good. Thank you. > > I like the idea of a separate Kconfig, e.g. CONFIG_KVM_GENERIC_PRIVATE_MEM or > something. I highly doubt there will be any non-x86 users for multiple years, > if ever, but it would allow testing the private memory stuff on ARM (and any other > non-x86 arch) without needing full pKVM support and with only minor KVM > modifications, e.g. the x86 support[*] to test UPM without TDX is shaping up to be > trivial. CONFIG_KVM_GENERIC_PRIVATE_MEM looks good to me. Thanks, Chao > > [*] https://lore.kernel.org/all/Y0mu1FKugNQG5T8K@google.com