From patchwork Wed Mar 10 17:57:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 12128955 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=ham 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 5F5B0C433E0 for ; Wed, 10 Mar 2021 18:13:00 +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 72AD464FB2 for ; Wed, 10 Mar 2021 18:12:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 72AD464FB2 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=KMtQ7aWH9ipi2ybAK29g9KEUoGd1UxOUcITGjc4O2yg=; b=p7xmSRHxipi6T5 oRS/+NeduQml/KbbgA/GoOB5zKg9D4y9WonIX2irwjYHSsulQxcbOl0uWqhj3M1TKXtiquXQg/5pX Eh+saVLwuzucoGy0/lT0/0OseSpQWRh18ktFffZYqkPSQ+ZLD6S153xNglrZB6cJq03ia4I/mZCnc 5yWcIlwDj1XW6hgfBuHTr1IKq4xG/KmI+C/TSMqVV4oK0f3dYSmM9lWmpgjlJP2SmJvtSFJ/wKN7k LDJB7UQ3ozdkY7VhB4sjw8MwS6Vp/1sRuezWPLT5d1pgcfhX2ief7epBGtvs+ZxZSJ4EEU7huFxmi XU+sSjEfKqnWnChrqp/g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lK3IM-007SzK-6Y; Wed, 10 Mar 2021 18:10:54 +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 1lK36q-007OVR-D5 for linux-arm-kernel@lists.infradead.org; Wed, 10 Mar 2021 17:59:02 +0000 Received: by mail-qv1-xf49.google.com with SMTP id u8so13275817qvm.5 for ; Wed, 10 Mar 2021 09:58:59 -0800 (PST) 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=6iNTe0mF+hjFWLgudHI/zWSf2clb7t9N+GDYgm7EigU=; b=uaCdrsKfFSgEFJjwltC9RmF59Ae7yc016S997ZvqjUKBgk8suIeUI8tNo9lXnjVcFu 2TLmSeOAjSDRESJ/NLQB7NEcltJ8lm7/1lgfPzBhrxE0X30r58dk52bDkKiWrJ0U/ly4 RFLMCW7FhB3lzNXpvkxGbEEWw2VsVX/v89kRWom2NPXRitUUuaSEtxub5xzCfAQj/QEv ipn9/xy2+PZHU7mfi6Eelvf9mWH+vr113PBdfw6Sxgv9/ZaPo0n+ZxYF95KSUq8n96zJ 1xkQHpOlRKYCDEukUW/4tZsL1k+hh9mrB1hZ/5M5eDoytop/zTSDu4VEhsAUZqUHU6W7 SHUQ== 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=6iNTe0mF+hjFWLgudHI/zWSf2clb7t9N+GDYgm7EigU=; b=WIcFMWmz5+AFEQCPsTyAOOCBmRDtIMISJ8vQUN4b8TLth/X0p6N4MtDKhI4KInkKH3 Mp8xkmgNnY3BD0qnwddgkvsHt//hU+K3ZNYUxWczzuYpxoPpGtCVeqCL/XQ+gmZUjszg /2qXxN0x1Tf7sa5H+FPMXwZG9yxWzj82nBuwsJpcZdQvy77kswiXCZ/p5G6GUcOvLU8x H0zQNM8j23Kazdgfgtd0gXe2f96qaBO2IqzHfkFBsO9S89nP8+XaU3V6tgsVezUsoOak D0VV5W7V44+y0GeZx6MW/CdFlmXOKk8rZKiUPYaBJ094ozVq1Ircy0hROsquisF4kzcw D4zA== X-Gm-Message-State: AOAM530WS9aJ48mRIfLYKQX9yS9D3S1nusj26qaZ+6aTPn0O7EXN9P3k SD+Id3o7S/esbKbbvfm4bs7JktkFkNOz X-Google-Smtp-Source: ABdhPJyDfHqUWFaXueHB0jBN/4Y6pf8dWGEZxgcpIy7CVo3fvkDLvVm5LW+MkE2AJvNQ0cA1KndyOwMjPQzd X-Received: from r2d2-qp.c.googlers.com ([fda3:e722:ac3:10:28:9cb1:c0a8:1652]) (user=qperret job=sendgmr) by 2002:a0c:f092:: with SMTP id g18mr4249565qvk.11.1615399138690; Wed, 10 Mar 2021 09:58:58 -0800 (PST) Date: Wed, 10 Mar 2021 17:57:46 +0000 In-Reply-To: <20210310175751.3320106-1-qperret@google.com> Message-Id: <20210310175751.3320106-30-qperret@google.com> Mime-Version: 1.0 References: <20210310175751.3320106-1-qperret@google.com> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog Subject: [PATCH v4 29/34] KVM: arm64: Refactor stage2_map_set_prot_attr() 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, linux-kernel@vger.kernel.org, kernel-team@android.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, tabba@google.com, mark.rutland@arm.com, dbrazdil@google.com, mate.toth-pal@arm.com, seanjc@google.com, qperret@google.com, robh+dt@kernel.org, ardb@kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210310_175900_671693_61C5DD1C X-CRM114-Status: GOOD ( 11.43 ) 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 its re-use in other code paths, refactor stage2_map_set_prot_attr() to not depend on a stage2_map_data struct. No functional change intended. Signed-off-by: Quentin Perret Acked-by: Will Deacon --- arch/arm64/kvm/hyp/pgtable.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index e4670b639726..c16e0306dd9a 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -489,8 +489,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) : @@ -510,7 +509,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; } @@ -728,7 +728,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;