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 X-Spam-Level: X-Spam-Status: No, score=-2.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F3FDC07E96 for ; Thu, 15 Jul 2021 05:49:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E949F6128C for ; Thu, 15 Jul 2021 05:49:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239173AbhGOFwa (ORCPT ); Thu, 15 Jul 2021 01:52:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239135AbhGOFwa (ORCPT ); Thu, 15 Jul 2021 01:52:30 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83883C06175F for ; Wed, 14 Jul 2021 22:49:37 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id 141so7024403ljj.2 for ; Wed, 14 Jul 2021 22:49:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=A/PvA1DB0W5wp+a8Jesrkmf512SBcdKf2TLwujd0mHs=; b=EQxYapb1uUstI3d8aTGl3fY9z0le160jeIBGmL2nJsbgqr8ux2VlwMfhBbvyrU8pQo bNR8hbUCicTntkRekvIJrfI1oiY8jMQY6LG2RqZZ8rH4Qk+K1mfaRAubuliuOGn32wYq 2ULQBmdyU0Zc8yZGWfUCbNYWnEUB1DckK5blR+j56gTolJ6G15pHDB3xLyijxHdOSvIJ teEKXgBkGGVXZiuFZKv90lxPVqjmPUSJf52lERWJOC5tqrLXA7MNI6VM+rFKlxR5PKOA 1/PvL9UtKxnKFn96ge3mQdQ136cbmM6nqN26LgtTtrvmyw056OBZ+Hsy9h3uVUYLcwHB J7pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=A/PvA1DB0W5wp+a8Jesrkmf512SBcdKf2TLwujd0mHs=; b=gkqG+4TidqB5NTVS6pwUsF1s80b7exk72lVtC2r7TunLUM48Xt68F6mb5QXOQxXuxK DqLMEc/IeYuvVxKTd0Ipnu60QSzPjlRyk06tYFYQYS1vWVkJFpfes9SOPQEero/cucsn GrIV8ZGxZvh5RV+5vZWQh77pl8lz7Nj14BF2yw6XXeYIx4fFjvx6rL0ovhFdZS1bHkKm L/Kj/RjNMabTtzn8DfALYn95XT/VOmof+xEHSdacf8Nu66IBA3/7oQPa1vuIsshPIk3K 0CWovgEVw05fTxvBYJlnAFv+OiphQ7Va2Ve2A0C5f1jz4e6UF7UoipDgu9ErkzFGbNcQ QKMA== X-Gm-Message-State: AOAM531CCi6iHpu3AIruLMPJFHG+64htPRxDfV1KJwSDbv8iliIdTxx2 TA3xjA34eSjgzk7KD6VwS4HyCCswD7Co3+LKvQc= X-Google-Smtp-Source: ABdhPJyu6X9WsZWORN2UOxa5XsxOWtYz/s7oZ1sB/2kxB204aN6CUmy6sAFqeT/NuDU/UphlBBt0ssJTs6NraAsRDJU= X-Received: by 2002:a2e:3515:: with SMTP id z21mr2142470ljz.250.1626328175946; Wed, 14 Jul 2021 22:49:35 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: harry harry Date: Thu, 15 Jul 2021 00:49:34 -0500 Message-ID: Subject: Re: About two-dimensional page translation (e.g., Intel EPT) and shadow page table in Linux QEMU/KVM To: Sean Christopherson Cc: Maxim Levitsky , kvm@vger.kernel.org, qemu-devel@nongnu.org, Sean Christopherson , Paolo Bonzini , stefanha@redhat.com, mathieu.tarral@protonmail.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Hi Sean, > No, each vCPU has its own MMU instance, where an "MMU instance" is (mostly) a KVM > construct. Per-vCPU MMU instances are necessary because each vCPU has its own > relevant state, e.g. CR0, CR4, EFER, etc..., that affects the MMU instance in > some way. E.g. the MMU instance is used to walk guest page tables when > translating GVA->GPA for emulation, so per-vCPU MMUs are necessary even when > using TDP. > > However, shadow/TDP PTEs are shared between compatible MMU instances. E.g. in > the common case where all vCPUs in a VM use identical settings, there will > effectively be a single set of TDP page tables shared by all vCPUs. What do you mean by "MMU instance"? Do you mean VMCS? MMU is hardware. Could you please share me the code of the MMU instance in KVM? Thanks! 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 X-Spam-Level: X-Spam-Status: No, score=-0.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B661C07E96 for ; Thu, 15 Jul 2021 05:51:21 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 380D56128C for ; Thu, 15 Jul 2021 05:51:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 380D56128C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m3uHI-0003tF-E1 for qemu-devel@archiver.kernel.org; Thu, 15 Jul 2021 01:51:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3uFg-0001fZ-6z for qemu-devel@nongnu.org; Thu, 15 Jul 2021 01:49:40 -0400 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]:37500) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m3uFe-0004Ni-L0 for qemu-devel@nongnu.org; Thu, 15 Jul 2021 01:49:39 -0400 Received: by mail-lj1-x231.google.com with SMTP id h19so7003053ljl.4 for ; Wed, 14 Jul 2021 22:49:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=A/PvA1DB0W5wp+a8Jesrkmf512SBcdKf2TLwujd0mHs=; b=EQxYapb1uUstI3d8aTGl3fY9z0le160jeIBGmL2nJsbgqr8ux2VlwMfhBbvyrU8pQo bNR8hbUCicTntkRekvIJrfI1oiY8jMQY6LG2RqZZ8rH4Qk+K1mfaRAubuliuOGn32wYq 2ULQBmdyU0Zc8yZGWfUCbNYWnEUB1DckK5blR+j56gTolJ6G15pHDB3xLyijxHdOSvIJ teEKXgBkGGVXZiuFZKv90lxPVqjmPUSJf52lERWJOC5tqrLXA7MNI6VM+rFKlxR5PKOA 1/PvL9UtKxnKFn96ge3mQdQ136cbmM6nqN26LgtTtrvmyw056OBZ+Hsy9h3uVUYLcwHB J7pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=A/PvA1DB0W5wp+a8Jesrkmf512SBcdKf2TLwujd0mHs=; b=pZmui1qiZQHtktDOUfbqTUh5jk5FEP7dy+H2ErvIGEneglx+vlphB+V5XF2FfJASn3 EKhdGlYKB5RFAGjLImx6YAriNc6NfcT+u4IMLktBbp+Q7HOPtAMnnzVThs1sTUEGMqOA y2Ojm/D1SVAU/i3MEb7rsvnUKJeGpK1VLd2hx3mWZaXbdzDfDN2fs2hk9GiXLTeWWgBp CjWY+0Xu7ffSTghjMexKbHP9uK8xKa2LXd/dFCVMunjS0TDBNpX20elqnGhinWiRNGqI HGcodftXlpjdVfzY2TQCEQiv7z/stHFyDPS5ZkJyy8zT7heWWYpPx5vnNGUVjyExkGpN hIow== X-Gm-Message-State: AOAM532zPtFjBCVpZOiiAAYQAwP2w7gzl/jpae6Nug05NTgVe6dcLhIK iFqEQEswXxVDPim7Tx53Wi2rRMHK4XzBTiS/1Rk= X-Google-Smtp-Source: ABdhPJyu6X9WsZWORN2UOxa5XsxOWtYz/s7oZ1sB/2kxB204aN6CUmy6sAFqeT/NuDU/UphlBBt0ssJTs6NraAsRDJU= X-Received: by 2002:a2e:3515:: with SMTP id z21mr2142470ljz.250.1626328175946; Wed, 14 Jul 2021 22:49:35 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: harry harry Date: Thu, 15 Jul 2021 00:49:34 -0500 Message-ID: Subject: Re: About two-dimensional page translation (e.g., Intel EPT) and shadow page table in Linux QEMU/KVM To: Sean Christopherson Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2a00:1450:4864:20::231; envelope-from=hiharryharryharry@gmail.com; helo=mail-lj1-x231.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org, Sean Christopherson , Maxim Levitsky , mathieu.tarral@protonmail.com, stefanha@redhat.com, Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Hi Sean, > No, each vCPU has its own MMU instance, where an "MMU instance" is (mostly) a KVM > construct. Per-vCPU MMU instances are necessary because each vCPU has its own > relevant state, e.g. CR0, CR4, EFER, etc..., that affects the MMU instance in > some way. E.g. the MMU instance is used to walk guest page tables when > translating GVA->GPA for emulation, so per-vCPU MMUs are necessary even when > using TDP. > > However, shadow/TDP PTEs are shared between compatible MMU instances. E.g. in > the common case where all vCPUs in a VM use identical settings, there will > effectively be a single set of TDP page tables shared by all vCPUs. What do you mean by "MMU instance"? Do you mean VMCS? MMU is hardware. Could you please share me the code of the MMU instance in KVM? Thanks!