Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp52318pxb; Tue, 24 Aug 2021 19:52:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwj3Sp49l1OtSWH22an2/jeidVSCdaVF2w/i9v+bGfVl73H4v+7Hvvu+OdYo02N7McMGB0A X-Received: by 2002:a92:8747:: with SMTP id d7mr30903693ilm.173.1629859940687; Tue, 24 Aug 2021 19:52:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629859940; cv=none; d=google.com; s=arc-20160816; b=kpLVzFMXKUK41rM0FERgIDwiqavpL4a4q6Ty8zpPplQ002b2zHGZcYeSnGsSeNaSqO 2LC7ZeVNtcoRIJ2Ccj0FT+PCf+acvOnudm8vUpOgloN+OEIOBvlClboh9UjUUrx/heZa 0hSY9bgItUlKqNT2GlGyKfNlNdx/8KHa6n2S+/hlAEYqjJMSRxlCX2qkOtu1q59aVDpm vRTqqAoCe6/Svjgbbf8TbnFDxXtXBBpFLCsbBsBFVyHhs00BUN1iMEcQTwHdp7SaAuVh nQhisM2hK1LW98q1iQOrE+CPJMZDu8HUlsckIGdGAB93tc+cwEDP65Yz7qg0lJoOU4lJ uv0w== 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=557teW+frwo4Nr6ovWUFY7KeQxNTE5k/uRPl11taWZQ=; b=qko85PqKPeNR+uFhuHWSmB9pGI2Qaw84Ils48C8h8dWDWKy9G7b2gxUP3Vi8xXdqm0 3q0NtX1CWEF+pbeeh8SFG2FGSxh33Q4iIuD6dpF/S/G7rrk6+7nGDRFMNAhISsedpCMC piQnj11M32pycWOdyBAKjkUDPxyvdeSTyeowHlT8rm84PUVYR5GuJ6EXmxVfrJUy37tq 1twFD/RwWtED0/R+LWn9LCzgSP6+FxcdrxU7xjNOYrHJ7qRxv8LyujUMt2+7DO1VSCmF Rr07P2xWWmTykxCJGXZGr+ADReYgZlfv39++9KmrcMssSNuPG4QMVX5xMZvmBWhFBRd9 l0TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dJZPNbN+; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l8si18089604ioj.7.2021.08.24.19.52.09; Tue, 24 Aug 2021 19:52:20 -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; dkim=pass header.i=@chromium.org header.s=google header.b=dJZPNbN+; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238513AbhHYCvs (ORCPT + 99 others); Tue, 24 Aug 2021 22:51:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238802AbhHYCvo (ORCPT ); Tue, 24 Aug 2021 22:51:44 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6956CC06179A for ; Tue, 24 Aug 2021 19:50:59 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id 18so20045666pfh.9 for ; Tue, 24 Aug 2021 19:50:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=557teW+frwo4Nr6ovWUFY7KeQxNTE5k/uRPl11taWZQ=; b=dJZPNbN+XP6sX7GpVU532TVhHZl6nHNwAU01QzJVrc3j/QFBm+gAVJOBv7Xnu2aH4/ n025fIzhjwX1sIIdy+r5hLJcXuY4gL2NKJ4BGijImZ6GQyb7bW2WYYYteVrgwq1wZmyq m2QIpq6RQ6SeQqx0+SxU2QK1+XenesCF0sgVg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=557teW+frwo4Nr6ovWUFY7KeQxNTE5k/uRPl11taWZQ=; b=UzPSMMqzi3zSSEX8x8uoiBWz60h/UdgI93n/FUuodd1upfY2AE+xI4XQPJ792YpkDL Qcs/jgLAa80ggN/Om4t066RL/CgXb1wIZmgAQk4Qxne62Isxoi1lQ20qzDUwUO95ruwG g8kX2HgvXLaj0A1/XCSQbV4Ba2ozSb3L0sRGF9ypaarGzZrm3V6zOvdb81f1t+RV5YHI LMy3FUurTXnLO+B2fndrB5jIJA2e77hyYIpuy8BGgBIzPXIcLRhaZq4c0zfbT2SuFtMo JZhkOHgvooUMxQShyH0ljpPXwrrTIt/jzcxmIBnXJU5R6x1PvqpzFtG7WesIqAc9vQp7 iB2w== X-Gm-Message-State: AOAM531D87diuyrCfkMlwKkQBr+vTTVaMFE82UADk0shEzf42djs57h8 IlWLMVTbrCQh7IJx5nUoscfzQQ== X-Received: by 2002:a05:6a00:a8a:b029:356:be61:7f18 with SMTP id b10-20020a056a000a8ab0290356be617f18mr42253650pfl.29.1629859858992; Tue, 24 Aug 2021 19:50:58 -0700 (PDT) Received: from localhost ([2401:fa00:8f:203:d273:c78c:fce8:a0e2]) by smtp.gmail.com with UTF8SMTPSA id y12sm22219470pgl.65.2021.08.24.19.50.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 24 Aug 2021 19:50:58 -0700 (PDT) From: David Stevens X-Google-Original-From: David Stevens To: Marc Zyngier , Paolo Bonzini Cc: James Morse , Alexandru Elisei , Suzuki K Poulose , Will Deacon , Sean Christopherson , Wanpeng Li , Jim Mattson , Joerg Roedel , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, David Stevens Subject: [PATCH v3 3/4] KVM: arm64/mmu: use gfn_to_pfn_page Date: Wed, 25 Aug 2021 11:50:08 +0900 Message-Id: <20210825025009.2081060-4-stevensd@google.com> X-Mailer: git-send-email 2.33.0.rc2.250.ged5fa647cd-goog In-Reply-To: <20210825025009.2081060-1-stevensd@google.com> References: <20210825025009.2081060-1-stevensd@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Stevens Covert usages of the deprecated gfn_to_pfn functions to the new gfn_to_pfn_page functions. Signed-off-by: David Stevens --- arch/arm64/kvm/mmu.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 0625bf2353c2..56859999b211 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -782,7 +782,7 @@ static bool fault_supports_stage2_huge_mapping(struct kvm_memory_slot *memslot, static unsigned long transparent_hugepage_adjust(struct kvm_memory_slot *memslot, unsigned long hva, kvm_pfn_t *pfnp, - phys_addr_t *ipap) + struct page **page, phys_addr_t *ipap) { kvm_pfn_t pfn = *pfnp; @@ -791,7 +791,7 @@ transparent_hugepage_adjust(struct kvm_memory_slot *memslot, * sure that the HVA and IPA are sufficiently aligned and that the * block map is contained within the memslot. */ - if (kvm_is_transparent_hugepage(pfn) && + if (*page && kvm_is_transparent_hugepage(pfn) && fault_supports_stage2_huge_mapping(memslot, hva, PMD_SIZE)) { /* * The address we faulted on is backed by a transparent huge @@ -812,10 +812,11 @@ transparent_hugepage_adjust(struct kvm_memory_slot *memslot, * page accordingly. */ *ipap &= PMD_MASK; - kvm_release_pfn_clean(pfn); + put_page(*page); pfn &= ~(PTRS_PER_PMD - 1); - kvm_get_pfn(pfn); *pfnp = pfn; + *page = pfn_to_page(pfn); + get_page(*page); return PMD_SIZE; } @@ -908,6 +909,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, short vma_shift; gfn_t gfn; kvm_pfn_t pfn; + struct page *page; bool logging_active = memslot_is_logging(memslot); unsigned long fault_level = kvm_vcpu_trap_get_fault_level(vcpu); unsigned long vma_pagesize, fault_granule; @@ -1009,8 +1011,8 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, */ smp_rmb(); - pfn = __gfn_to_pfn_memslot(memslot, gfn, false, NULL, - write_fault, &writable, NULL); + pfn = __gfn_to_pfn_page_memslot(memslot, gfn, false, NULL, + write_fault, &writable, NULL, &page); if (pfn == KVM_PFN_ERR_HWPOISON) { kvm_send_hwpoison_signal(hva, vma_shift); return 0; @@ -1052,7 +1054,8 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, */ if (vma_pagesize == PAGE_SIZE && !(force_pte || device)) vma_pagesize = transparent_hugepage_adjust(memslot, hva, - &pfn, &fault_ipa); + &pfn, &page, + &fault_ipa); if (fault_status != FSC_PERM && !device && kvm_has_mte(kvm)) { /* Check the VMM hasn't introduced a new VM_SHARED VMA */ @@ -1090,14 +1093,17 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, /* Mark the page dirty only if the fault is handled successfully */ if (writable && !ret) { - kvm_set_pfn_dirty(pfn); + if (page) + kvm_set_pfn_dirty(pfn); mark_page_dirty_in_slot(kvm, memslot, gfn); } out_unlock: spin_unlock(&kvm->mmu_lock); - kvm_set_pfn_accessed(pfn); - kvm_release_pfn_clean(pfn); + if (page) { + kvm_set_pfn_accessed(pfn); + put_page(page); + } return ret != -EAGAIN ? ret : 0; } -- 2.33.0.rc2.250.ged5fa647cd-goog