Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3472618rwb; Fri, 30 Sep 2022 04:14:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM58N3x0Eloh2abyK/0nH/IzZewVE+NcNP5h0eWWX3VI50cf0UWKSOSwJfFi8vanbfWJJkNn X-Received: by 2002:a63:135a:0:b0:440:f2af:c4cd with SMTP id 26-20020a63135a000000b00440f2afc4cdmr3248126pgt.393.1664536445933; Fri, 30 Sep 2022 04:14:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664536445; cv=none; d=google.com; s=arc-20160816; b=S6Q/INX+O5NTHU+TAOtV+aD/gHn2xktQENn7gEACp2tN8ZcjzUPoKKRSoWJPfV9cdf srj8JHxBEixtqWkXz9P8BHvLQwUAVAB9gdk4xg6EJyvJGqvBx4GzCIhN/yKhye6vjM8E aX3/0YZn3B3e7W1okeTNfTZN2f97FnufEGOg4qopbwQbP8dVpncsmbyGMLTb95XE6ZVn pLEr/rpiTtTe2tsnEyB4x1facAcIRlZA7IqYdHaesDp7xt9BsncvN6G8ZPD3CypoNhE4 FULC9/ao2IoUdM/GWrUSF3R0LgFbva0lhzDXaoIO1yrOUJDQpDW3OzqEj73IRBlPm8kX K8Ag== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QtgBRdVs7lGAvCM6KMKCIvvWjRYckMvJXWWToY0NYPk=; b=jxy2Vugz+Q/LNVpozKK9KUhx9y8Hnmr/Onc/i2V+d+h59jvBfg3RWepCLvgYwjbk4I ZvAZq8GRR1jy7yhN8JmWxMfhxFCOkQkgkYgsubgCbtm2Qwm3aCborqHYu6KzKgjj3bXx cHtghq2NSbPURjrO9Xe2G15uaSjVbf/1zQW0TAnvJFXUNz41vFp2uZHTslhRdrJ45pd3 sALEJgofgI6nzVoBK6E7dhL+BnRCo6LvmPyQRJtCs0MokUgoEuWibBl4LCWs31U7Eky7 3f9u0e04DrPbiWOuZcOwCw+7TruuBi9Rn+P2LEDtEdmPJp10OjTCWAcIq9QNG/eEPY4W 6KWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ef2VwB7b; 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 y13-20020a170902d64d00b001786a4a4c98si2470278plh.371.2022.09.30.04.13.54; Fri, 30 Sep 2022 04:14:05 -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=Ef2VwB7b; 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 S232067AbiI3KVt (ORCPT + 99 others); Fri, 30 Sep 2022 06:21:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231459AbiI3KTC (ORCPT ); Fri, 30 Sep 2022 06:19:02 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EAE915348B; Fri, 30 Sep 2022 03:19:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664533141; x=1696069141; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fKKqQjm5zfL/HnoTp2AqWyipBAMJR5631mTIwmgWhU8=; b=Ef2VwB7btbQ1w2tdap38oieQAHDnMmwCXfTFWVnNxxkvNLOtHepF0Zmx t7VtYI43VGtJQjX8QAxDje9GDKGkIIWWHguS/P5dV2fYcYbsMFfUAxJ/H kvV8+2BpQ1FQqeUABddzUFCIIOk8gRAui02F9cWOiW6+3AjXYJnnZYw+F OmW1MWIwGXLoguHG3LovMrsBgf7nML1mtxDL+uteGBzFVpmpPNjuidcYa hS4kECcZSbM4+ktKB2rCFTXkujsqWAcCvlUUy1f4FdjUgP5twss8mGmCl BEfhG1KtMqJsytlgPUoUya84EFJ1KP33WUVEnoHNCt6H5OUy4m84nuIVC w==; X-IronPort-AV: E=McAfee;i="6500,9779,10485"; a="281870086" X-IronPort-AV: E=Sophos;i="5.93,358,1654585200"; d="scan'208";a="281870086" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2022 03:18:56 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10485"; a="726807603" X-IronPort-AV: E=Sophos;i="5.93,358,1654585200"; d="scan'208";a="726807603" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2022 03:18:56 -0700 From: isaku.yamahata@intel.com To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar Subject: [PATCH v9 031/105] KVM: x86/mmu: Make sync_page not use hard-coded 0 as the initial SPTE value Date: Fri, 30 Sep 2022 03:17:25 -0700 Message-Id: <79ca03ac97aa28df839f8818a4486407bc71c605.1664530907.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.5 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_PASS,SPF_NONE 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 From: Isaku Yamahata FNAME(sync_page) in arch/x86/kvm/mmu/paging_tmpl.h assumes that the initial shadow page table entry (SPTE) is zero. Remove the assumption by using SHADOW_NONPRESENT_VALUE that will be updated from 0 to non-zero value. Signed-off-by: Isaku Yamahata --- arch/x86/kvm/mmu/paging_tmpl.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/paging_tmpl.h index 39e0205e7300..4586de2cfe57 100644 --- a/arch/x86/kvm/mmu/paging_tmpl.h +++ b/arch/x86/kvm/mmu/paging_tmpl.h @@ -1036,7 +1036,8 @@ static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp) gpa_t pte_gpa; gfn_t gfn; - if (!sp->spt[i]) + /* spt[i] has initial value of shadow page table allocation */ + if (sp->spt[i] != SHADOW_NONPRESENT_VALUE) continue; pte_gpa = first_pte_gpa + i * sizeof(pt_element_t); -- 2.25.1