From patchwork Fri Dec 2 18:51:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 29083 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1024163wrr; Fri, 2 Dec 2022 11:04:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf7OO1IW1noqCctbDefZLIvJ+xNI7yom8T7Rf2qazDDiRl6l5f8K2A6u8cbw0ZHcfjRivu1Z X-Received: by 2002:a17:906:3293:b0:7bd:f540:9be7 with SMTP id 19-20020a170906329300b007bdf5409be7mr26385502ejw.434.1670007889341; Fri, 02 Dec 2022 11:04:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670007889; cv=none; d=google.com; s=arc-20160816; b=o6YctM6SPiWere5LVWZRMjCopRTwDjBQ3+6hAUNpgtzTWKMlJ3QxlJ7MTUG1qV+82E VdMvOujQY2KHgDLPB2U1ziz5GvCa3fvAvrYE/WK8V6VZfC8P2n412968ydSJHOE8uFi/ FO+g2NDmSVBBCWKqe4FC81689lKXmdBOt/PYKd7X4y5Wf+XJH4a4vckDUdTY+GWnzMtq ID/Nixsd0RfDlcD7mGuj0wWqb+khL4anJZVWSmSR8c4bz4AzV+dmbBqucikBxim9pXYn JbQTHg7Z/r/gR3ubQtfyYJhuxCxMHGTwmhX8uTIvJEbTh0UkdWIMZbhaHCxPRDdqBt30 twAg== 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=HSI8GaEsrat3YCFbYitHgJjBxasqUXZCSku/OSEtqlI=; b=TtS6Zl6SqJHdJmvqjtehI183FMS511bqzkWz+V6mtUFIggNYM2dIem3ARslXbzh8Vv 6bbJjZT7fCwxcLB7+Sd5qcm7o6sgsi+QDfMlxdPWamF4fa1ziCHH51otCJz99aN67/XR N5Xysxbh61UPtlOoq7rLAiqiY0G+cowrgdnr33ifr5L0tYluQ8PgV5tvy/LdEw3bNMBR b/XZ7eSck4PRp9mN5ga2rZY4EXAwZOP4npD3fxItnv3tNU1PGAMeEhAYZLqvpxlHeKu+ TYYXZc1n4vLq7A/Q11XSyA6hIAlojExecOP3Znl/kX1zjiiP80snpMVDEcxz5yurMacB whqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=rn85i92G; 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=linux.dev Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s19-20020a170906455300b007c08e3b0e32si5139956ejq.414.2022.12.02.11.04.24; Fri, 02 Dec 2022 11:04:49 -0800 (PST) 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=@linux.dev header.s=key1 header.b=rn85i92G; 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=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234579AbiLBSwW (ORCPT + 99 others); Fri, 2 Dec 2022 13:52:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234623AbiLBSwT (ORCPT ); Fri, 2 Dec 2022 13:52:19 -0500 Received: from out-128.mta0.migadu.com (out-128.mta0.migadu.com [IPv6:2001:41d0:1004:224b::80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89BADE3688 for ; Fri, 2 Dec 2022 10:52:16 -0800 (PST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1670007134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HSI8GaEsrat3YCFbYitHgJjBxasqUXZCSku/OSEtqlI=; b=rn85i92GvmxIPofIBwzmf1lgVTJuWw0qPq1mAfrFEoJGvXJqdyrlRYn1kHDeuX+rlP4Vx/ tmJ5gmeMa66ZXMnADmpVdaE5YinkQjY/RVPLx5K/leof84T2RL7O+6UkRik8oNep32Mcye z1yTKtG3yErw1oBHC6vUD1maCGLrZ00= From: Oliver Upton To: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Oliver Upton , Catalin Marinas , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, kvmarm@lists.linux.dev, Ricardo Koller , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/6] KVM: arm64: Use KVM's pte type/helpers in handle_access_fault() Date: Fri, 2 Dec 2022 18:51:51 +0000 Message-Id: <20221202185156.696189-2-oliver.upton@linux.dev> In-Reply-To: <20221202185156.696189-1-oliver.upton@linux.dev> References: <20221202185156.696189-1-oliver.upton@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751130192213466719?= X-GMAIL-MSGID: =?utf-8?q?1751130192213466719?= Consistently use KVM's own pte types and helpers in handle_access_fault(). No functional change intended. Signed-off-by: Oliver Upton --- arch/arm64/include/asm/kvm_pgtable.h | 5 +++++ arch/arm64/kvm/mmu.c | 10 ++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h index 63f81b27a4e3..192f33b88dc1 100644 --- a/arch/arm64/include/asm/kvm_pgtable.h +++ b/arch/arm64/include/asm/kvm_pgtable.h @@ -71,6 +71,11 @@ static inline kvm_pte_t kvm_phys_to_pte(u64 pa) return pte; } +static inline kvm_pfn_t kvm_pte_to_pfn(kvm_pte_t pte) +{ + return __phys_to_pfn(kvm_pte_to_phys(pte)); +} + static inline u64 kvm_granule_shift(u32 level) { /* Assumes KVM_PGTABLE_MAX_LEVELS is 4 */ diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index a3c71b5172cd..886ad5ee767a 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1399,20 +1399,18 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, /* Resolve the access fault by making the page young again. */ static void handle_access_fault(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa) { - pte_t pte; - kvm_pte_t kpte; + kvm_pte_t pte; struct kvm_s2_mmu *mmu; trace_kvm_access_fault(fault_ipa); write_lock(&vcpu->kvm->mmu_lock); mmu = vcpu->arch.hw_mmu; - kpte = kvm_pgtable_stage2_mkyoung(mmu->pgt, fault_ipa); + pte = kvm_pgtable_stage2_mkyoung(mmu->pgt, fault_ipa); write_unlock(&vcpu->kvm->mmu_lock); - pte = __pte(kpte); - if (pte_valid(pte)) - kvm_set_pfn_accessed(pte_pfn(pte)); + if (kvm_pte_valid(pte)) + kvm_set_pfn_accessed(kvm_pte_to_pfn(pte)); } /**