Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1860324pxb; Sat, 2 Apr 2022 06:15:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHOAn9astdlAu5eqzlm0Z0MsVA4FpWXse7aACFoDzufXWMbpzf9TofD1cUX2U393z/LnKk X-Received: by 2002:a17:902:9a98:b0:155:f634:5f37 with SMTP id w24-20020a1709029a9800b00155f6345f37mr35939311plp.86.1648905319343; Sat, 02 Apr 2022 06:15:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648905319; cv=none; d=google.com; s=arc-20160816; b=gv1hAdJVoqRXaM+xgYQj+SSwwTw+vhvKYoCDwdtmLe6GCzlwHrCIHu2F0R3e+dHRKM raVlvDiQA5ykiQjNJ1n6pWIrEuosIBwyXQTmXZCD+JN0P1B/r9QSY0FYT9RDW3VZhCNV 0Ol7TVj8QpwpJDSnuMWcoVzLQeCb72XBT1vFMpQf0YQw7rbM+p2ghXU4qyLiSFTH6INN +P2jAoo5Y2M3Ev5FmxYO4ZT1s5t3zgGVVlVzwYTNbJEoH6IBlKUNVgfWWYsbzqUs5+DG 8q7Bc1rVBElsvurtw50jPDEfS9BD4y5asIG/wAL4FN+ekt1rhsfOuyde+/3yG+pnppSi n2VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=s0kGgJqcf/9Fc7+QXcMVM75YK7Rtv4AGHGtpyjMPv8c=; b=Vv2HMgbUP00VusTePz4VK9oVwOEAic3ObPxtCnBdw5cHDvwhbPC07FhzfgOXePjOJe ResmHHZoiiW6vJ9S7usF5cWuCJJNQxl0pia0+dg645nXBdIUQxO8x1HBtTv8fA08pA1t PxKMORihd/XLz6R755egRiYMRCVzYZ3KBLnX0H7DWD3BrUB4wqDfWBb/NkRJFoH3MRph dwMbKQmQ7mTefh2oLAfxLWI6NLPA6YIkYzHiH07GYnpWg67xrdlosZsA7GR0l2jKAo9a QzzBpUilpfinBRJ5OtD8RTD5vvKCKX1s6bPpVE8UBVX1eNLj7nfXHEvBE28pgfxoNYrP 7mQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ac42CdQe; 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=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y16-20020a170902b49000b00155fc0b4904si4520477plr.234.2022.04.02.06.15.06; Sat, 02 Apr 2022 06:15:19 -0700 (PDT) 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=@intel.com header.s=Intel header.b=Ac42CdQe; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343762AbiDAHPK (ORCPT + 99 others); Fri, 1 Apr 2022 03:15:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343740AbiDAHPJ (ORCPT ); Fri, 1 Apr 2022 03:15:09 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4D0ABAE; Fri, 1 Apr 2022 00:13:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648797198; x=1680333198; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=v7BxFZS7EqBUMLT0jC44zPK3Hm0zxzgqgjgsmXPUMUw=; b=Ac42CdQetfvW8slyl4NOL6AoLTBR/8A9IIRmo7HIlpSxy16IgCCsMTSo l1IMWjIb28B8RtTdhyi/32Qe4EcZhNUtI2/SuoDd4rJEQ5XdBpDxgbxTb qeChU8nvUfzOOq1lZOLGCFf+T7HXZOnKJ4NbttwIwi+yJteois7xg/tOD qFxxZ61Kyo++AQQuGvT/r7hQle70wahFujccmTadEWRBUoUaUFUm1yr5Y 4hzHOC5HEE7RGa+iS5A/Ez0D/lPOwr3csI1b0Ppc6QRmA37f3agEDjfty 0Cvi+4ORg2+jloTOCrjpN+XN6GCDeC6xXx8hXX8jwnwDzSKSNPSf1sFrx g==; X-IronPort-AV: E=McAfee;i="6200,9189,10303"; a="240652800" X-IronPort-AV: E=Sophos;i="5.90,226,1643702400"; d="scan'208";a="240652800" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2022 00:13:18 -0700 X-IronPort-AV: E=Sophos;i="5.90,226,1643702400"; d="scan'208";a="547686744" Received: from jamendoz-mobl.amr.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.255.95.128]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2022 00:13:15 -0700 Message-ID: <3cfffe9a29e53ae58dc59d0af3d52128babde79f.camel@intel.com> Subject: Re: [RFC PATCH v5 037/104] KVM: x86/mmu: Allow non-zero init value for shadow PTE From: Kai Huang To: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@gmail.com, Paolo Bonzini , Jim Mattson , erdemaktas@google.com, Connor Kuehl , Sean Christopherson Date: Fri, 01 Apr 2022 20:13:13 +1300 In-Reply-To: <968de4765e63d8255ae1b3ac7062ffdca64706e4.camel@intel.com> References: <968de4765e63d8255ae1b3ac7062ffdca64706e4.camel@intel.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-1.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Fri, 2022-04-01 at 18:13 +1300, Kai Huang wrote: > > --- a/arch/x86/kvm/mmu/mmu.c > > +++ b/arch/x86/kvm/mmu/mmu.c > > @@ -617,9 +617,9 @@ static int mmu_spte_clear_track_bits(struct kvm *kvm, > > u64 *sptep) > >    int level = sptep_to_sp(sptep)->role.level; > >   > >    if (!spte_has_volatile_bits(old_spte)) > > - __update_clear_spte_fast(sptep, 0ull); > > + __update_clear_spte_fast(sptep, shadow_init_value); > >    else > > - old_spte = __update_clear_spte_slow(sptep, 0ull); > > + old_spte = __update_clear_spte_slow(sptep, > > shadow_init_value); > > I guess it's better to have some comment here.  Allow non-zero init value for > shadow PTE doesn't necessarily mean the initial value should be used when one > PTE is zapped.  I think mmu_spte_clear_track_bits() is only called for mapping > of normal (shared) memory but not MMIO? Then perhaps it's better to have a > comment to explain we want "suppress #VE" set to get a real EPT violation for > normal memory access from guest? Btw, I think the relevant part of TDP MMU change should be included in this patch too otherwise TDP MMU is broken with this patch. Actually in this series legacy MMU is not supported to work with TDX, so above change to legacy MMU doesn't matter actually. Instead, TDP MMU change should be here. -- Thanks, -Kai