From patchwork Fri Mar 19 10:01:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 12150591 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87400C433E0 for ; Fri, 19 Mar 2021 10:16:52 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 731D064EEE for ; Fri, 19 Mar 2021 10:16:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 731D064EEE Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Cc:To:From:Subject:References:Mime-Version: Message-Id:In-Reply-To:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NsmzyP3bqxB06n/CbpDQh5hm2XOu+UL8zVNBFyH4pyg=; b=b5VW/sEf6zjqng TYBTWtoZvR0oPCQSh3MX7iyMg5xmpdFZyQJYuKt+zxckHwhlcirv1y93PagIVvYPfxOzMx3G89B3G 9+KLAWHyLmznqYobYkxC6hXY5sgsckzCZSuNPdlcuNsgF+xDXuR1W7S9PMAyrQ0dQhNRGHVT07eT/ EH80W1VRKQzoICjLXp0oBaWZXCoCG6oDng4oLBRQjYD0PRRpiiSgufZih3+T9nUbNKQLcoR0HGcXw ajbWkARNlLsZ3eh5sTDE8zexNOAZEIVl9qlm7HHsmEOIcS3KqRCXtMFtwDwY109Nam7u4mbPlGt/U npWKhgIKjqOkOignmERw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNC9o-007575-SA; Fri, 19 Mar 2021 10:15:05 +0000 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNBy3-0070Si-MU for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 10:02:59 +0000 Received: by mail-wr1-x44a.google.com with SMTP id y5so21568414wrp.2 for ; Fri, 19 Mar 2021 03:02:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=az3qu5AfEWynjCbFKTE0XZEp3dT+VbY/5SeZh8Qx1Io=; b=cxbBujXKeT7rjNVAEodiKZztncnTfQVckR4v8vwFPMKDrgrm1aS5gn6bsHGTh26ozr 5NXwVfmV3JBwX9v2RgOlXugAGAj22i37MNTbOcZwFdW8Q8Q3L9fEdOvqiG7ablWqHS7F ZKZmf+usDnAKHy69Fovh8Oc7K0mZ1R7Kjz4m80j63v8xbEYNJT216buBFJQTuizAJmUs jBv+o9Q9+p3iUJ7tcHdP1AhV1463HK3ZlBCTE/xNJz3FJn2A+ruZ+LfKIQ85QUJhuulQ /P8bBvB0pH38dveW/rwtcRUU+iIcl/0fvhnTlyUEAkdskj8jaK4CCHehnwAvL7WIlDnt ydnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=az3qu5AfEWynjCbFKTE0XZEp3dT+VbY/5SeZh8Qx1Io=; b=s1ZFBGN0p5ZObF8p4ULlXKSazN77O0lcz2NXfXTeBerUeFWwhndrxVmyX2FXoEUNUl 2IbZwQLEYW/nTs6DzCcsqjyLl2tgMbmXJmV5Pg1yoV+R6IRwC0TQ+ilqZSa45UKTIYgN Z1M3iuqbnKk58EWgLHD3xk0xZLwbOMD9AqsDTMwTNMPaASgF4raiIcPj07cmwqCa4iwn rFw7fCas36fM7s61fYFJgIRWiQgWgXF05BMSm66NMhK4ULHDWdDY9Xb11Q0utFkJ93U5 jOFqmmurtVHR86wJpDVvnvtyVWFuU9GSzMsjY58pSqC1E1oBydpGo5zYdbiJZLtb8mbw lckQ== X-Gm-Message-State: AOAM530pIVs6SdCoh+7AD1dyey3BTJfYrKHU6EP4/kWoZeGqP4eapozU fBFr7NBgYKH3H0g16JUn21CGowlqKka1 X-Google-Smtp-Source: ABdhPJw0KphugbkLaQeWstGqY/zCm8YSOnc3bOjtBswO1zBwU/9BG0fClCmUPZTFDDpqAABcRYc9sN+uHyq/ X-Received: from r2d2-qp.c.googlers.com ([fda3:e722:ac3:10:28:9cb1:c0a8:1652]) (user=qperret job=sendgmr) by 2002:a1c:e18b:: with SMTP id y133mr2987504wmg.22.1616148174537; Fri, 19 Mar 2021 03:02:54 -0700 (PDT) Date: Fri, 19 Mar 2021 10:01:38 +0000 In-Reply-To: <20210319100146.1149909-1-qperret@google.com> Message-Id: <20210319100146.1149909-31-qperret@google.com> Mime-Version: 1.0 References: <20210319100146.1149909-1-qperret@google.com> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog Subject: [PATCH v6 30/38] KVM: arm64: Refactor the *_map_set_prot_attr() helpers From: Quentin Perret To: catalin.marinas@arm.com, will@kernel.org, maz@kernel.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com Cc: android-kvm@google.com, seanjc@google.com, mate.toth-pal@arm.com, linux-kernel@vger.kernel.org, robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org, kernel-team@android.com, kvmarm@lists.cs.columbia.edu, tabba@google.com, ardb@kernel.org, mark.rutland@arm.com, dbrazdil@google.com, qperret@google.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_100256_015500_2C7EEBDE X-CRM114-Status: GOOD ( 11.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In order to ease their re-use in other code paths, refactor the *_map_set_prot_attr() helpers to not depend on a map_data struct. No functional change intended. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/pgtable.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index eefb226e1d1e..f4a514a2e7ae 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -325,8 +325,7 @@ struct hyp_map_data { struct kvm_pgtable_mm_ops *mm_ops; }; -static int hyp_map_set_prot_attr(enum kvm_pgtable_prot prot, - struct hyp_map_data *data) +static int hyp_set_prot_attr(enum kvm_pgtable_prot prot, kvm_pte_t *ptep) { bool device = prot & KVM_PGTABLE_PROT_DEVICE; u32 mtype = device ? MT_DEVICE_nGnRE : MT_NORMAL; @@ -351,7 +350,8 @@ static int hyp_map_set_prot_attr(enum kvm_pgtable_prot prot, attr |= FIELD_PREP(KVM_PTE_LEAF_ATTR_LO_S1_AP, ap); attr |= FIELD_PREP(KVM_PTE_LEAF_ATTR_LO_S1_SH, sh); attr |= KVM_PTE_LEAF_ATTR_LO_S1_AF; - data->attr = attr; + *ptep = attr; + return 0; } @@ -408,7 +408,7 @@ int kvm_pgtable_hyp_map(struct kvm_pgtable *pgt, u64 addr, u64 size, u64 phys, .arg = &map_data, }; - ret = hyp_map_set_prot_attr(prot, &map_data); + ret = hyp_set_prot_attr(prot, &map_data.attr); if (ret) return ret; @@ -501,8 +501,7 @@ u64 kvm_get_vtcr(u64 mmfr0, u64 mmfr1, u32 phys_shift) return vtcr; } -static int stage2_map_set_prot_attr(enum kvm_pgtable_prot prot, - struct stage2_map_data *data) +static int stage2_set_prot_attr(enum kvm_pgtable_prot prot, kvm_pte_t *ptep) { bool device = prot & KVM_PGTABLE_PROT_DEVICE; kvm_pte_t attr = device ? PAGE_S2_MEMATTR(DEVICE_nGnRE) : @@ -522,7 +521,8 @@ static int stage2_map_set_prot_attr(enum kvm_pgtable_prot prot, attr |= FIELD_PREP(KVM_PTE_LEAF_ATTR_LO_S2_SH, sh); attr |= KVM_PTE_LEAF_ATTR_LO_S2_AF; - data->attr = attr; + *ptep = attr; + return 0; } @@ -742,7 +742,7 @@ int kvm_pgtable_stage2_map(struct kvm_pgtable *pgt, u64 addr, u64 size, .arg = &map_data, }; - ret = stage2_map_set_prot_attr(prot, &map_data); + ret = stage2_set_prot_attr(prot, &map_data.attr); if (ret) return ret;