Received: by 2002:a05:6358:795:b0:dc:4c66:fc3e with SMTP id n21csp1446469rwj; Sun, 30 Oct 2022 00:30:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM52pUHf96GK1iQYAQaUhHAiWkBTc+wkWDg6Dn522omKObsFGY29c5iWII1sPSXGsyB0ldw0 X-Received: by 2002:a63:5553:0:b0:43c:5c1e:424f with SMTP id f19-20020a635553000000b0043c5c1e424fmr7212701pgm.353.1667115013083; Sun, 30 Oct 2022 00:30:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667115013; cv=none; d=google.com; s=arc-20160816; b=rr2SPPOk2WiTlg/kaSdKbkeLnT4C4VHHfXl4wv9HYL8765FCjmxHPLBpWZQjEyvGkS NwgwD4AiT85ZwwhRnQrtOjGI91uqOkJcqh2UyKhRVwbOB/z995qOGjwPWtGnzchakU12 oOxbu2pOCSr/yB9GOsea6FpecgeevvkWN6fnbLQKsKCoysQ4dApZMyuq1goSNLqm2Put 3Z/TOHMQokpTTdqlmLL/KVect0pugzZlVydlhRg/zNrwbjnWzx7w7fU5emAbFvOtiDYw uAwkgnGq9HOlHq8e05psfYDZWb9aMWm50U99MrNoqFJaMIZHX7WhAlOw6aYinFdx0L9f pInQ== 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=rY1d4DRX+NYMJ+zyfNpbvpstA0n7iAQrKhKtwby2RU4=; b=zmQUK7MmpmIRR/iMktEGG1ZM44TM6jaxQRbxc49ifICrTTNhpbcWXJMPw/FmScc0ZC 0ILWOSIdNVaKn2OwlnOVPO+iFrTNbQFzNe8l7gBwdOoMNIMzd5SGb6ohdYTlrm0QVRNE FZm0DKotzNxAJDVeA3ArYHLDIvOjIavPK6g/hnRo6VMxvMbjt32rTiyK2T+NGJ8kAQNL +5Kll8n2QIvRWFDGEOw1RB1CUtc0IE0Mb0o0wdWp63fmhOa6Q12c9Xs0clbSrcu1AU6O 3yGq/+8qNpgSWL2fsMxUTPdTa2S/pVPpdB+Qauf1wsF07sa4yE0S0s5/qNYWjmjEPtDv lKxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kQ0dttyu; 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 q21-20020a63d615000000b00442e77a852dsi4661863pgg.509.2022.10.30.00.30.02; Sun, 30 Oct 2022 00:30:13 -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=kQ0dttyu; 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 S230252AbiJ3GZo (ORCPT + 99 others); Sun, 30 Oct 2022 02:25:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229887AbiJ3GYJ (ORCPT ); Sun, 30 Oct 2022 02:24:09 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 170F610A; Sat, 29 Oct 2022 23:24:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667111048; x=1698647048; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NRy7ZqKX91pWNXtRhcY8rjR1ap8KYHXHj+9Nb/db+28=; b=kQ0dttyudbN8Ld5PhggJCy1rtRbVqqDVsRB2xeUXpqyxIgoZNTOsbbdc bnC0iRsvqA77cCWKyxokXKubLB7P738Cg/yC7spRjx0KblNTNaAMuTN8m EnWujYbK2Epp/U6mXj6n7Ag2dJO7F+u1ym+uUQlqx9LbTgikdN4rdXqfk JlTlQV4qpKePYna2M4LxalAdwe7YWyseec+ENeZdKjEby0BeYxW7oC9BF oJjxI7/Vlp1hTU+fp/HPmy3kalMeUpUsWPiGFrg8lXn1LUwvZ8iEu1409 IS2AUhV5JJ39X1ua6nVKQ8gzC/KridXPyp5KVILGC0ra5z7oLelaxN4kt w==; X-IronPort-AV: E=McAfee;i="6500,9779,10515"; a="395037144" X-IronPort-AV: E=Sophos;i="5.95,225,1661842800"; d="scan'208";a="395037144" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2022 23:24:02 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10515"; a="878392948" X-IronPort-AV: E=Sophos;i="5.95,225,1661842800"; d="scan'208";a="878392948" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2022 23:24:02 -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 , David Matlack Subject: [PATCH v10 032/108] KVM: x86/mmu: Make sync_page not use hard-coded 0 as the initial SPTE value Date: Sat, 29 Oct 2022 23:22:33 -0700 Message-Id: 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.9 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 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 5ab5f94dcb6f..6db3f2b5563a 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