From patchwork Mon Mar 15 14:35:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 12139717 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, 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 891ECC4360C for ; Mon, 15 Mar 2021 14:49:47 +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 70E1164E1F for ; Mon, 15 Mar 2021 14:49:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 70E1164E1F 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=S3hp/XXSXcgW5VKeY9XQBmN5tLb5K+kSaPeUAzTqYdU=; b=mXXfYNruk5jhZk nHq94U9DX71xITMyyccyMKG74jYfD9fm1b5eB5h9JzMb6OfiqONXEhSWrhOHpf+728vRrSFNBCY3z hqhRDuHVdpYzo8M5VNQ+q8MFUve7u5puFRdyRkmHhaXonnlND384WrnfUDIs0mlGISvzei9A1Ukmn rHHb2MiZf3K/m+4Zp0eHv0ZM50vaPfUEHCk+35dUxAQn9vsbMDXBYfvtW5Fx2W9CvCC600+MhfIN8 N2L2Sr5NExUOSW6wcdfY0l2AlfoxSp4TVkSiOaRcu71zi6DkU49NsTEGM/Tq3J9bGMjgjlz3bA3JB txJbQII12eecAWEossVQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lLoVN-00GAHs-6G; Mon, 15 Mar 2021 14:47:38 +0000 Received: from mail-qv1-xf49.google.com ([2607:f8b0:4864:20::f49]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lLoKq-00G5zA-Rs for linux-arm-kernel@lists.infradead.org; Mon, 15 Mar 2021 14:36:46 +0000 Received: by mail-qv1-xf49.google.com with SMTP id dz17so23101518qvb.14 for ; Mon, 15 Mar 2021 07:36:42 -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=N5s0/RbCYhUO0g3Zm7KUzHx7P+K05LDC1HPuvdfEh+U=; b=Zsr83XwouEaIFsOmKQebxP45mo30AcyU+79WfY13WWpqz/30q9YdfnTxkyZhfj4VMZ 5N/PN65sKtqHEJ0F7UO0XwE1vmkX7WtfR826THltDl1QzGmODdsxznZTxGJxLzAu/yzG y9RwL/puLSAhwnVRhvMKPNlJawAso9JrVyO4xGrNIXpLUR6kLrUXrcYr49cGvE61PFPf FZePHK8+5oT3IAIqvVyfnn5LOye9zY9F3xBDEwVULgG+wtjmJJ9jFJlhz3Nr+lQOKnpP t27x2C0hTSaHAYrMf2x4MjJFG86zg9sHfStokpDLnSewSGscu7pYDrp+0JNAcI0xlpwV nGtw== 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=N5s0/RbCYhUO0g3Zm7KUzHx7P+K05LDC1HPuvdfEh+U=; b=n0nI9lMF14XJyQ3+I+IwqI8l1KwjztXdrEXxTU9HgrTZqkg86Cvio32MjsXMYeQ5Uj 5BpGOQ/wuJgP7hSE9Yv/9NNNy7CiU/r9LkHRuh1gj3+dItLUEcUaOIwjmdNo0ilNs+/E lsGoHVZBJfukq5+aMj9kIh+poGYrXIfpvhbi0vlsr+F0D5X6VrZol9Uf61CZQrfxviM7 u/gosvNJxfZH9sf6qwTjW4kOj1RVfDqU4smSccsZ7BvSR5JANdnZMDfU5cqAhd6VAVUc 1g3nTSOHWYnzEdCbLL0GDcXO5RrkPxgV248aqu+iajweEKrr9L3kakjUOT6mH7rDnOa4 c3uw== X-Gm-Message-State: AOAM532zMjL3n8qQTcDJhMv2/RHqDLoa0p99LzKIzGnESUP8K7dD2wvz HttkaSBbsXOfljxOrzQ1gm7ks/SXIady X-Google-Smtp-Source: ABdhPJwsW3+UISmJa1GuCOTEPA/v4H+6KrK3TX2T8OvR6HABWCt5lvp9HyL96vdBHaY+aTq+PjSpuKjXnCOH X-Received: from r2d2-qp.c.googlers.com ([fda3:e722:ac3:10:28:9cb1:c0a8:1652]) (user=qperret job=sendgmr) by 2002:ad4:472d:: with SMTP id l13mr11032486qvz.17.1615819002072; Mon, 15 Mar 2021 07:36:42 -0700 (PDT) Date: Mon, 15 Mar 2021 14:35:30 +0000 In-Reply-To: <20210315143536.214621-1-qperret@google.com> Message-Id: <20210315143536.214621-31-qperret@google.com> Mime-Version: 1.0 References: <20210315143536.214621-1-qperret@google.com> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog Subject: [PATCH v5 30/36] 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-20210315_143645_131790_245810CE X-CRM114-Status: GOOD ( 11.72 ) 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 bd44e84dedc4..a5347d78293f 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -324,8 +324,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; @@ -350,7 +349,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; } @@ -407,7 +407,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; @@ -500,8 +500,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) : @@ -521,7 +520,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; } @@ -741,7 +741,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;