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 6FEB9C004D4 for ; Thu, 19 Jan 2023 11:13:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D378F6B0072; Thu, 19 Jan 2023 06:13:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CC1036B0073; Thu, 19 Jan 2023 06:13:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B13236B0074; Thu, 19 Jan 2023 06:13:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 9B3046B0072 for ; Thu, 19 Jan 2023 06:13:13 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 6CD3C1A02A2 for ; Thu, 19 Jan 2023 11:13:13 +0000 (UTC) X-FDA: 80371287066.17.EF9D93E Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by imf26.hostedemail.com (Postfix) with ESMTP id C43E6140003 for ; Thu, 19 Jan 2023 11:13:11 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=f7L1TD8+; spf=pass (imf26.hostedemail.com: domain of isaku.yamahata@gmail.com designates 209.85.214.172 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=1674126791; 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=WobviXpwWUZxD+2oQmL88+wYfR6mU0tdRKmjmFL+nas=; b=AyE8cbfLvUEkhlNQ15dw1ijKOfL8+7rSXnf+F1DwUjwZQxUgJv260tlbCfQ1AGE0sxUpms ddT0nmuDYku7jdI1tZGBwK73NrYlL+7C6QJ0a0uWdFYWakRw2yE/fZMfNZ7kv+cj1tcyPa +3EnjXWx3rUk2nw8pbQA2A5avclMdwA= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=f7L1TD8+; spf=pass (imf26.hostedemail.com: domain of isaku.yamahata@gmail.com designates 209.85.214.172 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=1674126791; a=rsa-sha256; cv=none; b=WDd3jk9CPfpxbUe9hMtnEaCGk71GZIdqGxBGyBgu0cu1AjJAzvGAfyqLxotF1i20bLlZr7 QFZPuSiAucpk2F6m63z+i5is2GiN6bRrJGnbrn7kOEjZJLxUXT/OBlgmiiuL8z9i6vBbXr eMqr9YeW68jd24hdc8lMZmneGTDke0M= Received: by mail-pl1-f172.google.com with SMTP id d3so1982956plr.10 for ; Thu, 19 Jan 2023 03:13:11 -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=WobviXpwWUZxD+2oQmL88+wYfR6mU0tdRKmjmFL+nas=; b=f7L1TD8+BmvD+A9pFAjMprM7B0spRnkeduPMQvbgLHvYJpiHQnNW4NU1/YfORCUZQb xaAorOgKYQmiKRAwik+pNTZYr9eT0raty08UEzrXavMtcLBX61EQYx+vZD2j0NdavbRC gf42Gt0VLrwev9tri3s4QJ8s/wW15sCEWExzZjJxOc6DlYr2SBEqQnmG10REIoIr2x7u xRy4XvEACzmTSzYCJ1ebtTfjCFCkLZHZY79OZCLCLg34Z7JITOr+iw6UlLUVH9Yq9b2o CUC0rAHKgZYzWzRKZZhXOG8dkikcSAUrekSJE3ShE6L2WgvT5bMYEZSjZYPJ7WvpIEyk UzDA== 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=WobviXpwWUZxD+2oQmL88+wYfR6mU0tdRKmjmFL+nas=; b=6I7rlHrrg1gWcaCwoj1CWuTZ+CeL7+Eo8bVeUP0r86F3FoA5G4gPqdwdJktau2j+xw fmHkk99jyho+F1OOeXjtjnOQOGSE8JzJDhaq5WhqSIn3BSZRWeVKQ9bksaZh5ljPw6IT a+8aKsaExFB/JCrXXrbpg9e4s8xQdn2qHmnnlDQByxWGqHcLHHscAdKj7M7FLQ9Qn1JU HFUpsN7MQRldgbxcVZYwywZho4cjdxTdruGNgtPXq8Mpeqoi5tjSK8BQdoWnI6ZQebbz b37Dy/P9Y2BnecGAhSxOWZgh04972eowE/iBYmgiKOU/em1Y4eEt7lJy3R83HQdWNufx Z/Cg== X-Gm-Message-State: AFqh2kqeBmJYMtaSqKfBCZPzYn7ZZ218VGUQYcVm84GV/oJ52d9TEL3E tMUDhz6uqc1p2/fCI3pcZNk= X-Google-Smtp-Source: AMrXdXuFUYPr4gl2HBth8ATukfpSeD4X8dOtFLmJYA5beRkuYlrBNgWB27UfhgflYvUdjqzwEfWuFQ== X-Received: by 2002:a17:903:248f:b0:189:6ab3:9e64 with SMTP id p15-20020a170903248f00b001896ab39e64mr10324160plw.34.1674126790421; Thu, 19 Jan 2023 03:13:10 -0800 (PST) Received: from localhost ([192.55.54.55]) by smtp.gmail.com with ESMTPSA id k7-20020a170902ce0700b001885d15e3c1sm24860035plg.26.2023.01.19.03.13.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 03:13:09 -0800 (PST) Date: Thu, 19 Jan 2023 03:13:08 -0800 From: Isaku Yamahata To: Sean Christopherson Cc: 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, isaku.yamahata@gmail.com Subject: Re: [PATCH v10 0/9] KVM: mm: fd-based approach for supporting KVM Message-ID: <20230119111308.GC2976263@ls.amr.corp.intel.com> References: <20221202061347.1070246-1-chao.p.peng@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: i6r4sto5yywbt87mdtfhurxf54ydkghm X-Rspamd-Queue-Id: C43E6140003 X-HE-Tag: 1674126791-908131 X-HE-Meta: U2FsdGVkX18REOUZXrGZNj9QtXB+jPYUtmkpjgwenQYmsIRP2Cqv7dzzsBAoxuw3/qI0xUGauLr6pWEHbxrdIE/M2H+WYToWTyXY+FrICiMtls5LP38+gQH+LNUr+GV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-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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(). diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 02be5e1cba1e..38699ca75ab8 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -2322,7 +2322,7 @@ static inline void kvm_account_pgtable_pages(void *virt, int nr) #ifdef CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES static inline unsigned long kvm_get_memory_attributes(struct kvm *kvm, gfn_t gfn) { - lockdep_assert_held(&kvm->mmu_lock); + // lockdep_assert_held(&kvm->mmu_lock); return xa_to_value(xa_load(&kvm->mem_attr_array, gfn)); } -- Isaku Yamahata