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 11477C433EF for ; Wed, 20 Jul 2022 15:12:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241180AbiGTPMT (ORCPT ); Wed, 20 Jul 2022 11:12:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233491AbiGTPML (ORCPT ); Wed, 20 Jul 2022 11:12:11 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79B313CBE5; Wed, 20 Jul 2022 08:12:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658329930; x=1689865930; h=date:from:to:cc:subject:message-id:reply-to:references: mime-version:in-reply-to; bh=q2IlxigBdcwC0dpWUgLpaaCiXj48I0dLaoXRVby3NyA=; b=JVxnA3G31BtwwX7d89ETBKonHVpwhK4I3u2fu7mJk3+lv/F5g+6hMlFI voWmJsThLQ0l5RXtt395CJTthSmFEEBdGsi+WIKvdLBQfX8nbhiXqN9Qe ET1r2bf3pmInDiYPuxddPimaNum33EKgsAH+lFUhKFj3iAXDvMg9CnqO+ vbUg1tHuoJbGuxV4ITFJdZzrxtaPSfg7HgpRxUdFv3Yh0+abmruxgGjue 629HVUuhoV9SJBPPqHd0Vy74LA1qlNKknRstmM/j/gYARF8cHUiVfdqC0 jJC+5Ld3nRSuBOISqtHImJKQsZj3ZHxQBETUIhW6jF55X2aBIpteJWyji g==; X-IronPort-AV: E=McAfee;i="6400,9594,10414"; a="285567970" X-IronPort-AV: E=Sophos;i="5.92,286,1650956400"; d="scan'208";a="285567970" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2022 08:12:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,286,1650956400"; d="scan'208";a="595275695" Received: from chaop.bj.intel.com (HELO localhost) ([10.240.193.75]) by orsmga007.jf.intel.com with ESMTP; 20 Jul 2022 08:11:56 -0700 Date: Wed, 20 Jul 2022 23:07:06 +0800 From: Chao Peng To: "Gupta, Pankaj" 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, linux-kselftest@vger.kernel.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 Subject: Re: [PATCH v7 11/14] KVM: Register/unregister the guest private memory regions Message-ID: <20220720150706.GB124133@chaop.bj.intel.com> Reply-To: Chao Peng References: <20220706082016.2603916-1-chao.p.peng@linux.intel.com> <20220706082016.2603916-12-chao.p.peng@linux.intel.com> <20220719140843.GA84779@chaop.bj.intel.com> <36e671d2-6b95-8e4f-c2ac-fee4b2670c6e@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <36e671d2-6b95-8e4f-c2ac-fee4b2670c6e@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 19, 2022 at 04:23:52PM +0200, Gupta, Pankaj wrote: > > > > > +bool __weak kvm_arch_private_mem_supported(struct kvm *kvm) > > > > +{ > > > > + return false; > > > > +} > > > > > > Does this function has to be overriden by SEV and TDX to support the private > > > regions? > > > > Yes it should be overridden by architectures which want to support it. > > o.k > > > > > > > > > + > > > > static int check_memory_region_flags(const struct kvm_user_mem_region *mem) > > > > { > > > > u32 valid_flags = KVM_MEM_LOG_DIRTY_PAGES; > > > > @@ -4689,6 +4729,22 @@ static long kvm_vm_ioctl(struct file *filp, > > > > r = kvm_vm_ioctl_set_memory_region(kvm, &mem); > > > > break; > > > > } > > > > +#ifdef CONFIG_HAVE_KVM_PRIVATE_MEM > > > > + case KVM_MEMORY_ENCRYPT_REG_REGION: > > > > + case KVM_MEMORY_ENCRYPT_UNREG_REGION: { > > > > + struct kvm_enc_region region; > > > > + > > > > + if (!kvm_arch_private_mem_supported(kvm)) > > > > + goto arch_vm_ioctl; > > > > + > > > > + r = -EFAULT; > > > > + if (copy_from_user(®ion, argp, sizeof(region))) > > > > + goto out; > > > > + > > > > + r = kvm_vm_ioctl_set_encrypted_region(kvm, ioctl, ®ion); > > > > > > this is to store private region metadata not only the encrypted region? > > > > Correct. > > Sorry for not being clear, was suggesting name change of this function from: > "kvm_vm_ioctl_set_encrypted_region" to "kvm_vm_ioctl_set_private_region" Though I don't have strong reason to change it, I'm fine with this and this name matches the above kvm_arch_private_mem_supported perfectly. Thanks, Chao > > > > > > > > > Also, seems same ioctl can be used to put other regions (e.g firmware, later > > > maybe DAX backend etc) into private memory? > > > > Possibly. Depends on what exactly the semantics is. If just want to set > > those regions as private current code already support that. > > Agree. Sure! > > > Thanks, > Pankaj