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 EBAA9C004D4 for ; Thu, 19 Jan 2023 22:37:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 475696B0075; Thu, 19 Jan 2023 17:37:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 424ED6B0078; Thu, 19 Jan 2023 17:37:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2ED556B007D; Thu, 19 Jan 2023 17:37:10 -0500 (EST) 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 1F2F66B0075 for ; Thu, 19 Jan 2023 17:37:10 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E3BBEC027C for ; Thu, 19 Jan 2023 22:37:09 +0000 (UTC) X-FDA: 80373010578.29.02C1BE5 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by imf29.hostedemail.com (Postfix) with ESMTP id E4911120002 for ; Thu, 19 Jan 2023 22:37:07 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=NSYj639M; spf=pass (imf29.hostedemail.com: domain of isaku.yamahata@gmail.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=isaku.yamahata@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674167828; 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=c3/xglDrs4GgAM40Pjq1vzK1v2T7qf4JcCCRFWl6k4g=; b=m6N2QEiObNmHCd+tapMZ57HaANxxNm7oQSMNZA6FGSjTPJwKfDB9u1ENHgOo3hZD2ymmdL n1iNTFL+Zv286ln9H1EkGiKsssJS1ZtK62DgbkIYzo2reLBQyYOJhKiW3SM97OsDvRvI9x 2AHPFVZBnuqluee1uWVPXDmeo1V3i4U= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=NSYj639M; spf=pass (imf29.hostedemail.com: domain of isaku.yamahata@gmail.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=isaku.yamahata@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674167828; a=rsa-sha256; cv=none; b=Z4xDzceU0XiAtm3jBYOjj6VlNnR0+76d7bEvMenIvse8iCY3icJNXtKJIfNKCYKKrAu7+n 5KK6dcLVMzHE3dHDcCCd9uf5u3JhysVnKOCzZ369q8KcMt39k5MzHDjlLEByJZYbE5BdgH bL5OF7EbRLkRQnl88XFfkL2A5CPNH1M= Received: by mail-pf1-f171.google.com with SMTP id x4so2665301pfj.1 for ; Thu, 19 Jan 2023 14:37:07 -0800 (PST) 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:message-id:reply-to; bh=c3/xglDrs4GgAM40Pjq1vzK1v2T7qf4JcCCRFWl6k4g=; b=NSYj639Mp9v5ap+wI0hCjvD0/JJIjDFxjIAk8s0W6QQZeGagLHTMYL5/dvvI2DPi4B +aGueObJ+RXaUVDn4NiXYFIhEcPYWxInkxzarthRsu1sZZ256/vMx7XvGmJtSYSWRLwB vl6fpplWJgAyhnKrjElYHYhD8OeiwcbmHLjIG5BiksGBX7KJzcLCywEenDObbw+Mxjwr pmu+l0l6CF6xX7jvLuX0TRIXSYOrvw5purr8S55V7TS8hL4NzHy8DcBRiXHfgymzDvFg PvZjALLBOjVmU5MNA64b0nuXlR2yYuFwQaHv+ETJElDhkdksrjTql7nEvp7HQxv7QCn3 HOLw== 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 :message-id:reply-to; bh=c3/xglDrs4GgAM40Pjq1vzK1v2T7qf4JcCCRFWl6k4g=; b=enFrQp1BMs4vr84xTNwX45S4ivOt9cBWaD3JzCkY9LOvckYpkyQwzFm3H+v4dCyxK+ Vfby/lZ6zUCReTN5KVTco6Jms/CJ/neGqNvz/IceUynxfsw6R0Pg3StGXsUXhxO2odiW 1e0Adm/n6deWnkUY+qBFtyRS02HbPn7BSrI5kfCEs4OrSeJyWKY8JB+PEPNF3PNYquop 7AnVPeX89XaYWW9lqagXcSPXX8wiNUdEuMa9lt/xSxlQv83jbe4t5bnrwupz4NguUZg6 HzDXUXzSzMicx7QV+mJGSJQAiQnCtTbD35WnnLxUpRn3j5iDYFAHT1OumalOsG7kM6KE IjkQ== X-Gm-Message-State: AFqh2kozWD/L6xzLiB/5u8LtLsnNgVkmB+TeKDyW/IcJQkqxeLi5N55e cCE7flscFLmHVDIMgBq/I1g= X-Google-Smtp-Source: AMrXdXtheeUgW/ehdT20D8crA3E+xLX19dRj8kq2j9cAtxWEF6/jTGrekTIsjKUTNo8D+nlbVHnJHA== X-Received: by 2002:a62:ab0b:0:b0:58b:46c9:a6b1 with SMTP id p11-20020a62ab0b000000b0058b46c9a6b1mr13080521pff.33.1674167826597; Thu, 19 Jan 2023 14:37:06 -0800 (PST) Received: from localhost ([192.55.54.55]) by smtp.gmail.com with ESMTPSA id c202-20020a621cd3000000b0058dc1d54db1sm6563910pfc.206.2023.01.19.14.37.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 14:37:05 -0800 (PST) Date: Thu, 19 Jan 2023 14:37:04 -0800 From: Isaku Yamahata To: Sean Christopherson Cc: Isaku Yamahata , Chao Peng , 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: <20230119223704.GD2976263@ls.amr.corp.intel.com> References: <20221202061347.1070246-1-chao.p.peng@linux.intel.com> <20230119111308.GC2976263@ls.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: E4911120002 X-Stat-Signature: 8f1s5w7nnhyqhkhwjeirmx3z81pj5qx9 X-Rspam-User: X-HE-Tag: 1674167827-923857 X-HE-Meta: U2FsdGVkX18T7Eqimn6hnSOkRSLvhuOL38mxvSy3Y64qWpwkZ33nNuFbu2mWyKCNQSR0ReXT7n4nisnb9GLQ+kQc+iq0U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ZN0+PS5Mykzhn9Mh+b4DeS9W3JQX+rvK8qHX7Zz/hgblCsRPwll1JKmb3eeRZvGa1jpteb7Ar6lB+/djmk2Ahx9QHPKRNbodqbNjMwgf3uT3X6jBsmx209U2lpE5uSDYVYFlx74HIIy4rVAW+OcmplX8j3UxLvQvD1ih6N0GGPC+IldFvMtYEL/BOeQMDeEtRAwBMs8xn4VEyMO1upxxtuwhzxIiLQsaQV5ekdRRR6puyFsqiXErBPSGjlqmGHEI0huJ80eK97vS8NFVkI1PYiEuJoQ/k0m2fly4ttX+5b/cWTCYSw23EYrRQY6ksEDPuM36NENbbOjyw5T1Zt6mcZIJDLPG++zDsh74tvzhr9fA4r0Fg0HaETTiMDIkVR8ojvkJ1pqup0R7TKRV6xBYlfLmXOg3ZGMxQCWMCQtizq5to46QcmfPai1vDoukueSJ26l9VYGAej/LV2nobkW+CWed5A= 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 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 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. diff --git a/arch/x86/kvm/mmu/mmu_internal.h b/arch/x86/kvm/mmu/mmu_internal.h index 72b0da8e27e0..f45ac438bbf4 100644 --- a/arch/x86/kvm/mmu/mmu_internal.h +++ b/arch/x86/kvm/mmu/mmu_internal.h @@ -430,7 +430,7 @@ static inline int kvm_mmu_do_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, .max_level = vcpu->kvm->arch.tdp_max_page_level, .req_level = PG_LEVEL_4K, .goal_level = PG_LEVEL_4K, - .is_private = kvm_mem_is_private(vcpu->kvm, cr2_or_gpa >> PAGE_SHIFT), + .is_private = kvm_is_private_gpa(vcpu->kvm, cr2_or_gpa), }; int r; -- Isaku Yamahata