Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp50307lqg; Wed, 10 Apr 2024 15:09:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWkjRfbOrsDQyBbnfG7TKO8nHJ9mVFp6SES6uD9xCx8PqzZBGOSTEMkN2boHwGn9vTT0gNyGqPTbxJ6hmw+0bD87PLA/fMkLA3PkgQfbQ== X-Google-Smtp-Source: AGHT+IFVVJw9yn9DmCQoDw5oSXNhSkQTMGGdALcWv/OQIfidO0sd9rsUycS7tLUQ6G2uHNP3zn+h X-Received: by 2002:a2e:9ccf:0:b0:2d8:c38a:1ec1 with SMTP id g15-20020a2e9ccf000000b002d8c38a1ec1mr2871544ljj.38.1712786948464; Wed, 10 Apr 2024 15:09:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712786948; cv=pass; d=google.com; s=arc-20160816; b=x6AYYliY3VQltHyiGMFPOCQTG7i9LskdbcVSakYNHs+rTiWgCSCSo53pnSnSyV1AJA swX4nunDm4XpXC0kBeL8sJc1G7lLcgmiUTyLzH6+kTczFnO1zt8SIFHa7wNiJVOb2Vco yhtG5TG4YX1c4/AcOktGZuaN1PkcFZzysyLcynj2U8dSbDv3UXP/R5hkfcqigZr0rFBw 1QaKo3WJopC0QeXidzFePVigFEO4LOSUl4oQE65ucG7Kzjfmqqvy3eefB7ADVFNAgttv 9MqMrM0YytBqp4WRHK2bzBuQJHT+3vxHTyA0+tb1E4T74m2vO6dOtVT18+qYEQv0toug 5tgg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=TSmbdo1Q/Pa/DJ6rBQFK8dYcxCq1PTrHFCmbqHBAsSc=; fh=6GvjuWek5e/NmuoNTFo6o746VvXwCIN6aC0mGYYr2FM=; b=c8AlEhqHcw7rQo3I4R55FI/sUKaOXtZPkG63FtPZNBWJsyQbp3OJwYoPcY/DgDdUy/ t4emU6CIuUQkt2T6z0FQMVUF62/UmU2OWzTeGZOHB5bksKTo9l8jRBxhxjHvFvw/QUAb kypYz+e+JlGLLZ8HkuonBgr/KxebwQaTzEDmC8PoLynH/Jy3PaKYuZBtqAMSckSybOE2 4LrRvX+VTE1N1VxnyhyHG8x4S5Db9AuKQbKZX7aYQ+PWxLjUDWKVqK2C+GUOVnir3lqs FyDwbCOBcuCe2aUaTBjHFpM7SFgatn0yKoVppcVmwfXpkNcOHjBSxHAdv7EQups3WrN9 6DAQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=i3NS07Vj; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-139402-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139402-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id t1-20020a50d701000000b0056fe55b5ccfsi67215edi.364.2024.04.10.15.09.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 15:09:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139402-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=i3NS07Vj; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-139402-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139402-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3F1631F23316 for ; Wed, 10 Apr 2024 22:09:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C9463194C8C; Wed, 10 Apr 2024 22:07:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="i3NS07Vj" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45A4818412B; Wed, 10 Apr 2024 22:07:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712786879; cv=none; b=acZV3H+aYFeF+pjLJiBtH+jwaEwFH8ACUGBU42dI0Eqp5qk5Jev2hKNWlzZxvEPRhguiBx1isDjXuW9jlzbBjuSSZMOHHM8P3fU/cs1c5Hfn1C1woktKxfNVRyDGA9VVm+sfp2VTyO2PvZO4h5oWhdFhzlk65KICyAE7r++R+uM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712786879; c=relaxed/simple; bh=XwXdHZ2iQsysNrw834gj2+zq3XuIiPhYcqjrgWnIrjI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qPHwlekr+dF6uxm5VBFa1D90Wr8dqUz5cD5J6QzhaBBXvkNFk8OazfCJ8QLaXD7gIVMaERBmjFqwi5kF9/ZymrcwLNELEPm9eNWBozAbpplGGYjqx+rrtrwLlFEhMHwoC4/otdKfsxgobOi9Wjg9fogTJNZ0pwKp0CI0fuKHuBI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=i3NS07Vj; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712786878; x=1744322878; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XwXdHZ2iQsysNrw834gj2+zq3XuIiPhYcqjrgWnIrjI=; b=i3NS07VjEoxH0C8ExL1Qh+Xr3nj4nY90v/TBAIrRC9Z9Y9fZSK9O965k AwQ/Iz8JJRAexRnFk0cJ1WLWiYAHCcsCzvafF83nNgW+nCWHivOKgvPxe GnnvvyF0rmfI8kvzw2dlbZvM0lslHMjbtHo4Y0ugz4/gddAf/LWPjlSV0 QCK+YVJmTIc3knZ5+b8zzFCBcq44IexkOz88GRBpTgP/xw0V4zxyMG5bN WJqF6s4jVP1VRB6Op2oTL7cKYhNqny4INypaQrZCM08hQ3IhgYd+Woq1H bF4nKzhkdb4bZQrfHzUWKwwsAsM/CBPqFvwNrmZngZYmBQO0DvLia/BXF A==; X-CSE-ConnectionGUID: ENINn3snQUCcPWGY21U4bQ== X-CSE-MsgGUID: sRPjFllqSEuFq7f1xT4UGQ== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="8041124" X-IronPort-AV: E=Sophos;i="6.07,191,1708416000"; d="scan'208";a="8041124" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2024 15:07:55 -0700 X-CSE-ConnectionGUID: 4lTHY6vySlCEXFYBF7fIew== X-CSE-MsgGUID: FS5nXk5XQveoz4d6MiHtqQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,191,1708416000"; d="scan'208";a="25476308" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2024 15:07:54 -0700 From: isaku.yamahata@intel.com To: kvm@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, linux-kernel@vger.kernel.org, Sean Christopherson , Paolo Bonzini , Michael Roth , David Matlack , Federico Parola , Kai Huang Subject: [PATCH v2 04/10] KVM: x86/mmu: Make __kvm_mmu_do_page_fault() return mapped level Date: Wed, 10 Apr 2024 15:07:30 -0700 Message-ID: X-Mailer: git-send-email 2.43.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Isaku Yamahata The guest memory population logic will need to know what page size or level (4K, 2M, ...) is mapped. Signed-off-by: Isaku Yamahata --- v2: - Newly added. --- arch/x86/kvm/mmu/mmu_internal.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu_internal.h b/arch/x86/kvm/mmu/mmu_internal.h index 9baae6c223ee..b0a10f5a40dd 100644 --- a/arch/x86/kvm/mmu/mmu_internal.h +++ b/arch/x86/kvm/mmu/mmu_internal.h @@ -288,7 +288,8 @@ static inline void kvm_mmu_prepare_memory_fault_exit(struct kvm_vcpu *vcpu, } static inline int __kvm_mmu_do_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, - u64 err, bool prefetch, int *emulation_type) + u64 err, bool prefetch, + int *emulation_type, u8 *level) { struct kvm_page_fault fault = { .addr = cr2_or_gpa, @@ -330,6 +331,8 @@ static inline int __kvm_mmu_do_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gp if (fault.write_fault_to_shadow_pgtable && emulation_type) *emulation_type |= EMULTYPE_WRITE_PF_TO_SP; + if (level) + *level = fault.goal_level; return r; } @@ -347,7 +350,8 @@ static inline int kvm_mmu_do_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, if (!prefetch) vcpu->stat.pf_taken++; - r = __kvm_mmu_do_page_fault(vcpu, cr2_or_gpa, err, prefetch, emulation_type); + r = __kvm_mmu_do_page_fault(vcpu, cr2_or_gpa, err, prefetch, + emulation_type, NULL); /* * Similar to above, prefetch faults aren't truly spurious, and the -- 2.43.2