From patchwork Sat Dec 2 09:30:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhao X-Patchwork-Id: 172788 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp1676889vqy; Sat, 2 Dec 2023 01:59:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IEfr0zNNAVc9VEGgIZBVWiWOw0Cz/ypRxM1CXG8223tsLbC6Grl+vbazQx8TSQ6f6/XOaQF X-Received: by 2002:a05:6830:191:b0:6d8:74e2:5d1a with SMTP id q17-20020a056830019100b006d874e25d1amr1055170ota.67.1701511166506; Sat, 02 Dec 2023 01:59:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701511166; cv=none; d=google.com; s=arc-20160816; b=y1FNj7N1mwAizv1CbLDeNFUW4FsRgWuR9nJrnC+VL9aPaXqh4M44T1EgeInQgRjCie ZiinN5ycysfcGtr7bA9U8fcwfoDUkJcymHCub0sdLTDTqoNILLUI4WOvO7Sssls0I3fO kdt56bk5HDQXFxPq0JcRquc7KPslbog8IZ9hxY9epzSP8o9vBLXoPZIXzqsiijRLMDH+ apLDSl0iD4SIpS169hcY+C+JI40BLp2lSsA9UsKXPB0mluQKbO9eVh3qCNgacXjzGQeV ecNb3y2WT4hp3XIUfMp7z+p+cfyLHadCxXuaqtPn5v73wzyydpeBroIPzbXSfre4zIRi DTEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=ZX6ofDM9uIj2ZCiVgYM+Mee7wnmizTEgJBAqyVImBrg=; fh=+WI4m5k3dRLR+dR3neThuZkNBTzIm/a8HgtddERL9fA=; b=QJWy7m0ChQE/TynF+3ak/qpyrJDwzt90v/GBvDUd7+EYPPZEkt1fxDH1eWnwEUKxqQ cYpBuvMZuiOr0i0iYnEzCAX1l+0AtJ31fpVYPQJbwba+7FJ7nsjVtDpLx/w9sK92FiiI R214w7W3MUCfSzVJT9Vd8rY6ZKW+KraBQJNfeRz3AQTAlHejEPqaiQKY86CLVauQfZ5W TvVBoYff/zWVSx+tXCp4Ra712yE3jjASj8+OaDXSsF9yAMcmMxIlhOTtd1CeAwSqqAju LBei1oD/GS6qGiwx5c/nyQ3f/SJHpYzvPEWjNu2TmKra6mlDa4M39uuxIM2nTVfNXWd/ QuOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=O1YzupEp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id dr2-20020a056a004a8200b006cbef05beddsi4546383pfb.11.2023.12.02.01.59.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Dec 2023 01:59:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=O1YzupEp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id CC1C58087203; Sat, 2 Dec 2023 01:59:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232345AbjLBJ7O (ORCPT + 99 others); Sat, 2 Dec 2023 04:59:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232257AbjLBJ7N (ORCPT ); Sat, 2 Dec 2023 04:59:13 -0500 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 998CFCC; Sat, 2 Dec 2023 01:59:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701511160; x=1733047160; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=wAzhYUH58e3QaRHxpmVeodzpQMpT0HkCfncirII7TQo=; b=O1YzupEpSEyeQiZfgQr5dumCrIRT7Crl2oGy5iIHdBPHtRQto/iYQd8t F00XLSUgnjZojfkHhq9lVGVmNkvkIMvpqhsNMXyZcYELKJ2M2ptPgC6fz fSQXHDVmsQiLi62rUIxdaUPDvMoNW+sfzaRHkwPh/I606wovvNBwuuTR3 0hY3VGVOtWR2fHuxpnziPKZuA3C7hrnrQjkofme7zWRtvsvxJt0LwsTL2 ko1kMFegXVtISNNmhL7IenEEmQHeHs6Z+NWsdHlO9kYlwoSTAk6JQrXXN 9/nXjoYqh3FWUMnbjS7JbT2yYGtQmAQ1WSQdsv6PUV2d5pYxw7i0zJryb g==; X-IronPort-AV: E=McAfee;i="6600,9927,10911"; a="606859" X-IronPort-AV: E=Sophos;i="6.04,245,1695711600"; d="scan'208";a="606859" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2023 01:59:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,245,1695711600"; d="scan'208";a="18038610" Received: from yzhao56-desk.sh.intel.com ([10.239.159.62]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2023 01:59:15 -0800 From: Yan Zhao To: iommu@lists.linux.dev, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: alex.williamson@redhat.com, jgg@nvidia.com, pbonzini@redhat.com, seanjc@google.com, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, kevin.tian@intel.com, baolu.lu@linux.intel.com, dwmw2@infradead.org, yi.l.liu@intel.com, Yan Zhao Subject: [RFC PATCH 30/42] KVM: x86/mmu: remove param "vcpu" from kvm_calc_tdp_mmu_root_page_role() Date: Sat, 2 Dec 2023 17:30:21 +0800 Message-Id: <20231202093021.15281-1-yan.y.zhao@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231202091211.13376-1-yan.y.zhao@intel.com> References: <20231202091211.13376-1-yan.y.zhao@intel.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sat, 02 Dec 2023 01:59:23 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784163773414944339 X-GMAIL-MSGID: 1784163773414944339 kvm_calc_tdp_mmu_root_page_role() only requires "vcpu" to get maxphyaddr for kvm_mmu_get_tdp_level(). So, just pass in the value of maxphyaddr from the caller to get rid of param "vcpu". This is a preparation patch for later KVM MMU to export TDP. No functional changes expected. Signed-off-by: Yan Zhao --- arch/x86/kvm/mmu/mmu.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index abdf49b5cdd79..bcf17aef29119 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -5200,7 +5200,7 @@ static inline int kvm_mmu_get_tdp_level(int maxphyaddr) } static union kvm_mmu_page_role -kvm_calc_tdp_mmu_root_page_role(struct kvm_vcpu *vcpu, +kvm_calc_tdp_mmu_root_page_role(int maxphyaddr, union kvm_cpu_role cpu_role) { union kvm_mmu_page_role role = {0}; @@ -5211,7 +5211,7 @@ kvm_calc_tdp_mmu_root_page_role(struct kvm_vcpu *vcpu, role.smm = cpu_role.base.smm; role.guest_mode = cpu_role.base.guest_mode; role.ad_disabled = !kvm_ad_enabled(); - role.level = kvm_mmu_get_tdp_level(cpuid_maxphyaddr(vcpu)); + role.level = kvm_mmu_get_tdp_level(maxphyaddr); role.direct = true; role.has_4_byte_gpte = false; @@ -5222,7 +5222,9 @@ static void init_kvm_tdp_mmu(struct kvm_vcpu *vcpu, union kvm_cpu_role cpu_role) { struct kvm_mmu *context = &vcpu->arch.root_mmu; - union kvm_mmu_page_role root_role = kvm_calc_tdp_mmu_root_page_role(vcpu, cpu_role); + union kvm_mmu_page_role root_role; + + root_role = kvm_calc_tdp_mmu_root_page_role(cpuid_maxphyaddr(vcpu), cpu_role); if (cpu_role.as_u64 == context->cpu_role.as_u64 && root_role.word == context->common.root_role.word)