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 6CE82C77B70 for ; Mon, 17 Apr 2023 14:45:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D65B56B0074; Mon, 17 Apr 2023 10:45:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D175D8E0002; Mon, 17 Apr 2023 10:45:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB6358E0001; Mon, 17 Apr 2023 10:45:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A970D6B0074 for ; Mon, 17 Apr 2023 10:45:35 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 42E25A054F for ; Mon, 17 Apr 2023 14:45:35 +0000 (UTC) X-FDA: 80691156630.21.63A345D Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by imf03.hostedemail.com (Postfix) with ESMTP id 4E84220007 for ; Mon, 17 Apr 2023 14:45:32 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=YHBQvZn5; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf03.hostedemail.com: domain of chao.p.peng@linux.intel.com has no SPF policy when checking 134.134.136.126) smtp.mailfrom=chao.p.peng@linux.intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681742732; h=from:from:sender:reply-to: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=StPOk8Pz+DcXxlpmGbL/4xWshuzUU6o7TwNofjuMvZo=; b=kqa+SN1xv+9oWmJ8049Nxar9kQthzBIkAwbygMSOJuGZSf4RVp1jIlVQCxSHfEKkAsygG/ THIu2HUDkrm8n/OGUxHrhA9dkZoaKqlmDWMTppYbQWBLr+kO3BNbnCIBAEf9pFyYGNyuyQ dVDcLEgU7toSNzkZPaBBr5nk3jwcCqc= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=YHBQvZn5; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf03.hostedemail.com: domain of chao.p.peng@linux.intel.com has no SPF policy when checking 134.134.136.126) smtp.mailfrom=chao.p.peng@linux.intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681742732; a=rsa-sha256; cv=none; b=c4t3uXJNd/Tlrdo/2oJhOqMgR2khYLaTF1W+HuWHsf8DVbGuVNihph8SIwh30sspij6yLx jp2kKgYsqHCb6djR5LNNvqmq2Q2dj7xz1anWSvPggpUr5WpoaZ+eB2OBFjOQkAztZP9Wp+ QYG9FzNkOyeABFMP4DQTLGflKaO7EvQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681742732; x=1713278732; h=date:from:to:cc:subject:message-id:reply-to:references: mime-version:in-reply-to; bh=Ujpr3tfLBQ0cnHPJjNO9yDhomrzTInArxSoyy0XPMmc=; b=YHBQvZn5BepUBXiWzgr2PEn3ioys8o4TOSgmDI0RPx8Oe7SBAetNkGGI F5uIGHNl44eJA+ZyRjHU223oxs69+wyWW2Y0uGwyilC+BQLhtiqRuMSd+ WwvqjGZPkNUoZbeSkHVmPqVrPtpRcurl93OplabAj4XO1VwWe5jh2H0yw GGygIQVqePbP72yok+ENvODearzmskLU9UdlwO8VXCFJwZPpSgRgs052j XEKU7ypJpC224vPQEekSjCUwYouxnLW6oIT+h0BeYTqBw9oq/Yve4fLO5 VsIPUjSjxYVKADx/f+bEIyFGjHvfZZ2JxovQvL0PoPEVc4WKkKm5yoYay g==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="329079977" X-IronPort-AV: E=Sophos;i="5.99,204,1677571200"; d="scan'208";a="329079977" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Apr 2023 07:45:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="780101935" X-IronPort-AV: E=Sophos;i="5.99,204,1677571200"; d="scan'208";a="780101935" Received: from chaop.bj.intel.com (HELO localhost) ([10.240.192.105]) by FMSMGA003.fm.intel.com with ESMTP; 17 Apr 2023 07:45:16 -0700 Date: Mon, 17 Apr 2023 22:37:47 +0800 From: Chao Peng To: Sean Christopherson Cc: Isaku Yamahata , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-arch@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 , Arnd Bergmann , Naoya Horiguchi , Miaohe Lin , 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 , tabba@google.com, Michael Roth , mhocko@suse.com, wei.w.wang@intel.com Subject: Re: [PATCH v10 0/9] KVM: mm: fd-based approach for supporting KVM Message-ID: <20230417143747.GA3639898@chaop.bj.intel.com> Reply-To: Chao Peng References: <20221202061347.1070246-1-chao.p.peng@linux.intel.com> <20230119111308.GC2976263@ls.amr.corp.intel.com> <20230119223704.GD2976263@ls.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 4E84220007 X-Stat-Signature: zwqg5w59xqspqbdu5sbcnpdo9sumubbo X-HE-Tag: 1681742732-835778 X-HE-Meta: U2FsdGVkX1/ppVNLSNHLWUdZLEQJ2LG02BzWLOlooV+hvwj4MKhrHtNSLewMxA6jSh4TL20nvG16jHH8u5ekn/sY2kFziHhE8fYdbo9lnUdGJhbV8yK2QZ9KDxSfkNNO315hql28Bv7leDhs5Rkp4f3xv3iBySiwXqaC4FtZmOGVENtQFfPE0dxpLZ7VuNEycnnEGLz0JmMLMmgqEudT5BUgz/fDJEhAt3SMdi610Gogz+bQQqC6QO5J5dEM23O0J2fGRladbMp36ZkQCaHT0Ez3a+eysR2z86ENcZ0IjrA8ZihVqT2eJEQRFjkFkTc3CG1UMHiaqaN2LeEawTmzLzO91lq6B11KgbPLvv8TwZo93Xlj8BqXiv0A5XAWfnYV2GHIi5731cSrQwPKsIWlyZRaFwVuCsXQo4dBrM+yQhULFCWm5vn9mvk89eDSgSy8sRYEBcD5Jm9wTrhec/E2HCR+vQHgwjb3EMb+Or3zZutie720aSOHgC9FaLom0vZu5bGmcf4jsD/oa9Pc6REha18hVIWjzDI17WK651VVUDy3JxrYIpSWQxjKZp+Jg/vP1VL2jyGgCM39swL+a7uK3xB15B0LJ5NiJo6Qdm3vQ6hoJsRqFTVCfRJdupN/Spb8T3nDyxx2FhvkLgbGoCCNoNGWTEJamSTwbGLDvi2Xxn5/yGTJmKYj+FWV+lwok1FiigPtW4GZfLo3MoGJqXwDMrFAurc5VPFh9qDkXrxefFrGQ9QvMT+leQ+QHHVtM3/asfHqJHUYBYzMlRAzHjVRj9LUYCfdaawmuR8EOn+UcJOs7JxHXVy1Ky3iAXFR/X7Y5Jub/LFln0l8NVM0IRo2ZYUDkxuhtt9IVNvc0mcVS8expimW94HHah3yIWPlYEsBaZf5+fMH4H7iN+u3JrOC3CzCjYYyWun4SrfDmRyoERaTNHVxCk8m9i1taju2NqjbHkDolEzr9niBxj2wQgt CQOlpQzN fQWTsBlFQzJ8R/GUNJlF5phfg51QBhLq/egb9iVQr7gyMoSaTKdLJEmTq9JjJVYea7D4ZKVlWV4hNKzWdTR8R5672Cw1/SNhIvbPaEeQtkW+x4yNsLYfn03RRa6KReKfGr+3LPfqWtoB4qjakeKoEu635KAPtBC7wYLQJm+hXd16jX60gzUXZioO15Xugwe58Pnp5jVGySj31jLkbKbLTb8wHoUjC9MAuV8+3rjOMjNC2/PRNWYa7X3fHm/h2UQaq4pKSen0ITpT66zIEkjQ6bRKTZj5lezFSMip1Q+dNrEcmjnAqsAMXXyzOOqcD6uvd6EhCYGs0LzRyqvv7uijWxSPXJkmkU8TMz6JnB/oT97UZk65A2vZT+E5V4qqkGDcNzUUusT4tB2W5Nox54OkUFngMHP2vo8OHujagPebxwCYAAquXXl/RaW/26g== 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: On Tue, Jan 24, 2023 at 01:27:50AM +0000, Sean Christopherson wrote: > On Thu, Jan 19, 2023, Isaku Yamahata wrote: > > On Thu, Jan 19, 2023 at 03:25:08PM +0000, > > Sean Christopherson wrote: > > > > > On Thu, Jan 19, 2023, Isaku Yamahata wrote: > > > > On Sat, Jan 14, 2023 at 12:37:59AM +0000, > > > > Sean Christopherson wrote: > > > > > > > > > On Fri, Dec 02, 2022, Chao Peng wrote: > > > > > > This patch series implements KVM guest private memory for confidential > > > > > > computing scenarios like Intel TDX[1]. If a TDX host accesses > > > > > > TDX-protected guest memory, machine check can happen which can further > > > > > > crash the running host system, this is terrible for multi-tenant > > > > > > configurations. The host accesses include those from KVM userspace like > > > > > > QEMU. This series addresses KVM userspace induced crash by introducing > > > > > > new mm and KVM interfaces so KVM userspace can still manage guest memory > > > > > > via a fd-based approach, but it can never access the guest memory > > > > > > content. > > > > > > > > > > > > The patch series touches both core mm and KVM code. I appreciate > > > > > > Andrew/Hugh and Paolo/Sean can review and pick these patches. Any other > > > > > > reviews are always welcome. > > > > > > - 01: mm change, target for mm tree > > > > > > - 02-09: KVM change, target for KVM tree > > > > > > > > > > A version with all of my feedback, plus reworked versions of Vishal's selftest, > > > > > is available here: > > > > > > > > > > git@github.com:sean-jc/linux.git x86/upm_base_support > > > > > > > > > > It compiles and passes the selftest, but it's otherwise barely tested. There are > > > > > a few todos (2 I think?) and many of the commits need changelogs, i.e. it's still > > > > > a WIP. > > > > > > > > > > As for next steps, can you (handwaving all of the TDX folks) take a look at what > > > > > I pushed and see if there's anything horrifically broken, and that it still works > > > > > for TDX? > > > > > > > > > > Fuad (and pKVM folks) same ask for you with respect to pKVM. Absolutely no rush > > > > > (and I mean that). > > > > > > > > > > On my side, the two things on my mind are (a) tests and (b) downstream dependencies > > > > > (SEV and TDX). For tests, I want to build a lists of tests that are required for > > > > > merging so that the criteria for merging are clear, and so that if the list is large > > > > > (haven't thought much yet), the work of writing and running tests can be distributed. > > > > > > > > > > Regarding downstream dependencies, before this lands, I want to pull in all the > > > > > TDX and SNP series and see how everything fits together. Specifically, I want to > > > > > make sure that we don't end up with a uAPI that necessitates ugly code, and that we > > > > > don't miss an opportunity to make things simpler. The patches in the SNP series to > > > > > add "legacy" SEV support for UPM in particular made me slightly rethink some minor > > > > > details. Nothing remotely major, but something that needs attention since it'll > > > > > be uAPI. > > > > > > > > Although I'm still debuging with TDX KVM, I needed the following. > > > > kvm_faultin_pfn() is called without mmu_lock held. the race to change > > > > private/shared is handled by mmu_seq. Maybe dedicated function only for > > > > kvm_faultin_pfn(). > > > > > > Gah, you're not on the other thread where this was discussed[*]. Simply deleting > > > the lockdep assertion is safe, for guest types that rely on the attributes to > > > define shared vs. private, KVM rechecks the attributes under the protection of > > > mmu_seq. > > > > > > I'll get a fixed version pushed out today. > > > > > > [*] https://lore.kernel.org/all/Y8gpl+LwSuSgBFks@google.com > > > > Now I have tdx kvm working. I've uploaded at the followings. > > It's rebased to v6.2-rc3. > > git@github.com:yamahata/linux.git tdx/upm > > git@github.com:yamahata/qemu.git tdx/upm > > And I finally got a working, building version updated and pushed out (again to): > > git@github.com:sean-jc/linux.git x86/upm_base_support > > Took longer than expected to get the memslot restrictions sussed out. I'm done > working on the code for now, my plan is to come back to it+TDX+SNP in 2-3 weeks > to resolves any remaining todos (that no one else tackles) and to do the whole > "merge the world" excersise. Hi Sean, In case you started working on the code again, I have a branch [1] originally planned as v11 candidate which I believe I addressed all the discussions we had for v10 except the very latest one [2] and integrated all the newly added selftests from Ackerley and myself. The branch was based on your original upm_base_support and then rebased to your kvm-x86/mmu head. Feel free to take anything you think useful( most of them are trivial things but also some fixes for bugs). [1] https://github.com/chao-p/linux/commits/privmem-v11.6 [2] https://lore.kernel.org/all/20230413160405.h6ov2yl6l3i7mvsj@box.shutemov.name/ Chao > > > kvm_mmu_do_page_fault() needs the following change. > > kvm_mem_is_private() queries mem_attr_array. kvm_faultin_pfn() also uses > > kvm_mem_is_private(). So the shared-private check in kvm_faultin_pfn() doesn't > > make sense. This change would belong to TDX KVM patches, though. > > Yeah, SNP needs similar treatment. Sorting that out is high up on the todo list.