Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3229660pxb; Tue, 20 Apr 2021 03:43:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9AJ8G5TJQgeq8FVDhIKSrHX1NTd3a0jc02JiVJNBpjBumYKE3BolVwBXGj9E11hnR11jw X-Received: by 2002:a17:907:d06:: with SMTP id gn6mr24501395ejc.449.1618915385905; Tue, 20 Apr 2021 03:43:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618915385; cv=none; d=google.com; s=arc-20160816; b=CxVFxgnfeNAP8+gdXgGNo+/Vk/T3ggulzhuJmjRt5oun7EA1xq5iI0b4+ATiljb1DU jNdWtKyNXvGlZgrpCQuhNJc4DDzHI66b5KFvEKrGaHSywuJt6iir89i34rttDR5B2MGk HTVoJUFwdoAwPm9IqCR/mr6x7XdsOv77WU5aRR/CiuPto/FdtncimEi83oNHeVWqqxj+ Sl9h+64bywB3iOrmru4HuqaWGKafLM+GXtHvsO8Lhh+dwSa7GityCyk7dWb9oRb09rFp y5TgwcMAXT8EfEmIIgtiynx5KlD8HKWzxnfrxXVybNFSYlWKj/tL/kcUdtZ3DDzg5m3o 5BQw== 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 :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=rRodPmo2vVm/RYv4MKtAduZXPCNjGVVH/Au+uCIdbCM=; b=H/6ZYv5mIlZDFJPUDqmUJzFalmHnsgpDQgHD8STfFG/z1x8OqINXAxj1n208bKi6nR b0/gwR5Xv3pBg8zvOQpBGEMDhm+cZIPDoZQvXF7VBD8XobaPEuI+vOMO5iakJ+a+Qd5i sJDNTwK/g4IzEOrpQB1YHgT6af5USbh/h+azwflSL5ctGI7C19rLMrhjRmqzVuwWpE8T QEGjKAJ7zPw4diZrp5Qwl//C7/ooSjRQvCiis6NRjrnAU7LSOEgtrz1sM5sf7gXSHvPO RdI90IdCmlL6O2mSvhsxB0z0LfjWq8oWWL/sz0JHDHHrV03jE2QJKol7tVNyxpe7gck1 Jv7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z3si7546904edd.61.2021.04.20.03.42.42; Tue, 20 Apr 2021 03:43:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231661AbhDTKmO (ORCPT + 99 others); Tue, 20 Apr 2021 06:42:14 -0400 Received: from mga01.intel.com ([192.55.52.88]:42730 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231616AbhDTKmO (ORCPT ); Tue, 20 Apr 2021 06:42:14 -0400 IronPort-SDR: lG7L4W8RnIU5MD3t9L40ScotXDyhO78ah+b969iYS5qieuQo8UnlF1oUWYKhWT4z7mHIniMQp1 9daQSdPkLgUg== X-IronPort-AV: E=McAfee;i="6200,9189,9959"; a="216071823" X-IronPort-AV: E=Sophos;i="5.82,236,1613462400"; d="scan'208";a="216071823" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2021 03:41:43 -0700 IronPort-SDR: 6ZzKjAGijILXCQakuNDkwtxSKSSj4WG7QnTq/nfOJEwHo+leqxCC6uKaiDMHlZs6c19yChpgOu RDVc4UFZ5DtA== X-IronPort-AV: E=Sophos;i="5.82,236,1613462400"; d="scan'208";a="420359503" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2021 03:41:43 -0700 From: Isaku Yamahata To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson Cc: isaku.yamahata@gmail.com, Isaku Yamahata Subject: [RFC PATCH 00/10] KVM: x86/mmu: simplify argument to kvm page fault handler Date: Tue, 20 Apr 2021 03:39:10 -0700 Message-Id: X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a preliminary clean up for TDX which complicates KVM page fault execution path. simplify those execution path as preparation. The current kvm page fault handlers passes around many arguments to the functions. To simplify those arguments and local variables, introduce data structure, struct kvm_page_fault, to hold those arguments, variables, and passes around the pointer to struct kvm_page_fault. struct kvm_page_fault is allocated on stack on the caller of kvm fault handler, kvm_mmu_do_page_fault(). And then push down the pointer to inner functions step by step. The conversion order is as follows . kvm_mmu_do_page_fault() with introducing struct kvm_page_fault . kvm_mmu.page_fault(): kvm_tdp_page_fault(), nonpaging_page_fault(), FNAME(page_fault) . direct_page_fault() . try_async_pf() . page_fault_handle_page_track() . handle_abnormal_pfn() . fast_page_fault() . __direct_map() . kvm_tdp_mmu_map() . FNAME(fetch) Probably more functions should be converted. or some should not converted. Only code refactoring and no functional change is intended. Isaku Yamahata (10): KVM: x86/mmu: make kvm_mmu_do_page_fault() receive single argument KVM: x86/mmu: make kvm_mmu:page_fault receive single argument KVM: x86/mmu: make direct_page_fault() receive single argument KVM: x86/mmu: make try_async_pf() receive single argument KVM: x86/mmu: make page_fault_handle_page_track() receive single argument KVM: x86/mmu: make handle_abnormal_pfn() receive single argument KVM: x86/mmu: make fast_page_fault() receive single argument KVM: x86/mmu: make __direct_map() receive single argument KVM: x86/mmu: make kvm_tdp_mmu_map() receive single argument KVM: x86/mmu: make FNAME(fetch) receive single argument arch/x86/include/asm/kvm_host.h | 4 +- arch/x86/kvm/mmu.h | 49 ++++++++++-- arch/x86/kvm/mmu/mmu.c | 130 +++++++++++++++++--------------- arch/x86/kvm/mmu/paging_tmpl.h | 60 +++++++-------- arch/x86/kvm/mmu/tdp_mmu.c | 21 +++--- arch/x86/kvm/mmu/tdp_mmu.h | 4 +- arch/x86/kvm/x86.c | 4 +- 7 files changed, 156 insertions(+), 116 deletions(-) -- 2.25.1