Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2684772rwb; Mon, 7 Nov 2022 16:47:16 -0800 (PST) X-Google-Smtp-Source: AMsMyM4MSTZVTQzZ3xxXNvdIcE6XtMZGGMSjHmfUaLtcMx3P5iO6YyMyQrUeyVWnglEwbpemDlMy X-Received: by 2002:a17:907:7632:b0:7a1:d4f0:e7c5 with SMTP id jy18-20020a170907763200b007a1d4f0e7c5mr50787197ejc.160.1667868436156; Mon, 07 Nov 2022 16:47:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667868436; cv=none; d=google.com; s=arc-20160816; b=MC5eq1dxh+OmySrO4DxWL/c8137TDUi9LDYJlkJEuf7UXUzjaO6UnKVE3EcoJQikms nsJcomoquOLMwOAvc2RXzKR+h/ahmEEKe+cJXNigpYq0wXTaISNTJaBm52pnhDhhEqxu K0fHKdn/BKBvyOoz6rdQ8YUlOFuu1nmXCQ5YkybFdiGxEUyTqhywTEwYFZxVd1PzVjxh 3sS7aOk7wxZDqUXAQGgcW9HTHmaF67LLKgcOIcpZIif3xzVH5h+gBgVFiYJRzgPDCqHY BS2E9w8PL7fS9bQePMFSF4Kx59v1uSTkzlRGYiAA5/22D++6mhUz/ZrBAf3gk69e53b7 gq4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=f4mzRLoeQ48oTB+HkMbcCJtw/jiM85vqqZbEZxBfoPw=; b=Cs+ZIf72nqdrbEw66jqp9jqPHw37KBYNRUpDST9+QM96geY9ECzmMvzG3FuGRHBG+O AlNjsRfqJ/Ms68T+xkQZXhPkRWfZk1G8Q9igEIwAfNJp2/aBmcMMSysz/reOfnnBwFoK fpg2dKtNm+K0F1O4wRLRLcSiYFEiBFsSOV4f/oS/fwrH8IaUXdYbj33CU53L6IKHuPMF buq3zIGdrXyeRFl0lVO96keO5OWHUoO2UyPgrpVfGP639RL7e4J4S+ADIwJuaHbJKme1 +notCFEzGo3ctpn8UeuiCAfX9Dhj7yVZai+3rKi74c2fDE/K1UD8Nc+Hv3I/jgkjgXcx BL+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=jNkxWtUC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w17-20020a056402269100b00461f2b974d2si11397434edd.339.2022.11.07.16.46.53; Mon, 07 Nov 2022 16:47:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=jNkxWtUC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232494AbiKHAlu (ORCPT + 91 others); Mon, 7 Nov 2022 19:41:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232366AbiKHAlp (ORCPT ); Mon, 7 Nov 2022 19:41:45 -0500 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B44CF14032; Mon, 7 Nov 2022 16:41:44 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id b1-20020a17090a7ac100b00213fde52d49so11950333pjl.3; Mon, 07 Nov 2022 16:41:44 -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=f4mzRLoeQ48oTB+HkMbcCJtw/jiM85vqqZbEZxBfoPw=; b=jNkxWtUCmfG2zrTTxPn7pXbOfg8WgaPlJ/TmU5ho83sUA7wRBlAIcBc7kM55RSxQfz O9KfA73Mo41SgYIU/6ztTbPkU74vvXbXhLfeG7if5q08aJsers9rlUH+IcWmJCieuLMB gbuRsARLxBA75WAmVf89DtRjcvxlhjWPeHEm1phJr7YMFgREvRfd7mjbZlBzS7taId+K Z7st3hqeZybjF8yrj+ldtMVMB0xM9NnHcs5o8YhIkyHPPFq825EvPYOoBldCw5yPpP7F HggWHyUW5wTNWT3I1EIWRCFsjLeBu0Rg8w3vv3t1/ntNPIXw9J4HHOSpeRyqwRkQq+gR i+bw== 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=f4mzRLoeQ48oTB+HkMbcCJtw/jiM85vqqZbEZxBfoPw=; b=sP4V7a/omZxYz53t9JaV9isPTYy1KtKt8rXR1bLFGdVYgAKlU8LcZfIWW67/e+aI61 uht6oZ8ZLRi5jVSIXy6WgbjkcQ7IH9NW14gdpfTRqZOOmR5XFFC9fI5hgvxsUOVGkdDr sYCFgvbesP1n3DgZxeQPdiBS5526BVKdMOEoS/k9pciGcD/k43UNFYJFvLWQEXCsqJDh s6+D1FxvzGb22qJHVrC1JiVYBQqRa1P5zYI3OinS7zQZkQ4ZtqzZtUhk7yM0BLKzNKux MP7kFbyDe7TJ/sdkR/sdgltYFVvRWEXddO5Hl6Z+bKg+vo1P1AKJvRy0rLBJFmuNAlzY JC4A== X-Gm-Message-State: ACrzQf1XE+JTh/mC+sDCtngfNYo2hwX7NgT1cXkSe3fzSFew9AaW2NKq Ge7Ylh5/8O1oi9hlz8AA7fs= X-Received: by 2002:a17:903:1109:b0:179:d220:1f55 with SMTP id n9-20020a170903110900b00179d2201f55mr36061753plh.42.1667868104037; Mon, 07 Nov 2022 16:41:44 -0800 (PST) Received: from localhost ([192.55.54.55]) by smtp.gmail.com with ESMTPSA id s4-20020a170902ea0400b001837463f654sm5535395plg.251.2022.11.07.16.41.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 16:41:43 -0800 (PST) Date: Mon, 7 Nov 2022 16:41:41 -0800 From: Isaku Yamahata To: Vishal Annapurve 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 , 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 , 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, Muchun Song , wei.w.wang@intel.com, isaku.yamahata@gmail.com Subject: Re: [PATCH v9 0/8] KVM: mm: fd-based approach for supporting KVM Message-ID: <20221108004141.GF1063309@ls.amr.corp.intel.com> References: <20221025151344.3784230-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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 03, 2022 at 05:43:52PM +0530, Vishal Annapurve wrote: > On Tue, Oct 25, 2022 at 8:48 PM 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-08: KVM change, target for KVM tree > > > > Given KVM is the only current user for the mm part, I have chatted with > > Paolo and he is OK to merge the mm change through KVM tree, but > > reviewed-by/acked-by is still expected from the mm people. > > > > The patches have been verified in Intel TDX environment, but Vishal has > > done an excellent work on the selftests[4] which are dedicated for this > > series, making it possible to test this series without innovative > > hardware and fancy steps of building a VM environment. See Test section > > below for more info. > > > > > > Introduction > > ============ > > KVM userspace being able to crash the host is horrible. Under current > > KVM architecture, all guest memory is inherently accessible from KVM > > userspace and is exposed to the mentioned crash issue. The goal of this > > series is to provide a solution to align mm and KVM, on a userspace > > inaccessible approach of exposing guest memory. > > > > Normally, KVM populates secondary page table (e.g. EPT) by using a host > > virtual address (hva) from core mm page table (e.g. x86 userspace page > > table). This requires guest memory being mmaped into KVM userspace, but > > this is also the source where the mentioned crash issue can happen. In > > theory, apart from those 'shared' memory for device emulation etc, guest > > memory doesn't have to be mmaped into KVM userspace. > > > > This series introduces fd-based guest memory which will not be mmaped > > into KVM userspace. KVM populates secondary page table by using a > > With no mappings in place for userspace VMM, IIUC, looks like the host > kernel will not be able to find the culprit userspace process in case > of Machine check error on guest private memory. As implemented in > hwpoison_user_mappings, host kernel tries to look at the processes > which have mapped the pfns with hardware error. > > Is there a modification needed in mce handling logic of the host > kernel to immediately send a signal to the vcpu thread accessing > faulting pfn backing guest private memory? mce_register_decode_chain() can be used. MCE physical address(p->mce_addr) includes host key id in addition to real physical address. By searching used hkid by KVM, we can determine if the page is assigned to guest TD or not. If yes, send SIGBUS. kvm_machine_check() can be enhanced for KVM specific use. This is before memory_failure() is called, though. any other ideas? -- Isaku Yamahata