From patchwork Mon Jul 26 09:29:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 12398947 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.5 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 18E18C4338F for ; Mon, 26 Jul 2021 09:37:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 D110060E09 for ; Mon, 26 Jul 2021 09:37:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D110060E09 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=2cEDZsns+vkqff2TKQJzfgsESppunvZlQEkCs99Evvc=; b=hsxj/1MREbwnuB1JIrKJbs1cwX fb/siKmYQ3RXuo6bDRUl1VB3tJPJt0MELgzT18jRvEQ+h2ocJJJLV+9Eb8yPoB2QcdDKXA2lVIm1a UB4uwplCO6TKQvo2yKWQLtwrO765QElBv7L5JI3fieccSipMIDkIeQKCX9cUHGBgu/aauhaIW1mb8 XZwGQC5RNAeO/XnP4hs5N6C3Gf5sNla6PMbJmwP9mpuv5ev5PB3Az5agynqtzJDSwD0sNxxDQ39li aVLxQTkWOpnbUVZWNAp+6H8k/BdNCK4R3ex9m48C7InuXMJO4IacKEJSeI1vC+4gWhAZECVYmbgvP FohQF5+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m7x1a-00AUFr-FY; Mon, 26 Jul 2021 09:35:51 +0000 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m7wvc-00ARb7-Mv for linux-arm-kernel@lists.infradead.org; Mon, 26 Jul 2021 09:29:42 +0000 Received: by mail-wr1-x44a.google.com with SMTP id o11-20020a5d474b0000b02901533f8ed22cso3019222wrs.22 for ; Mon, 26 Jul 2021 02:29:39 -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=fyCHOW6maJF9L7guSoQxIXFDKYajZ5tEfL0M1nzcu3g=; b=b6cEmvJ0vdEy2FGe8oxQq0HlmnKC08AOEIcGg2mj6fy+SSGskiuESRrYptCgJBbUZu mt0BDG+nEREOBOG2gON7kzVvLlgj83N/3hY4W0c6StPuMfpFjuKVeuGnNBubwob1lg/y noakRpnUfRpGOAidTPg/rki9g0KqzEwYypxs4M7HTnvPXf7iFxu/B6GlMaKalYBVBH14 YkQii/9BBIPj6M2rqhx9TIywxni7ift1Cnpcz6Om6njwYOV6G8R2RL+mltGn89rqQd3x lPyubLT/kp4B80c1Rt5WC3DkG7lsQlG7ga2RipuW01KExo0V3PSpKTM1DAMcXKZlw0ft 7ibg== 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=fyCHOW6maJF9L7guSoQxIXFDKYajZ5tEfL0M1nzcu3g=; b=smDbPjiVih5E8di/UEVSyPAGQQVdEmzHtLVZxQ889BPVSzmv9cNWN4k8B2JqQvtKxK 4pDmR+jcQpxXE8ZASWi/K56Z58iPwSaMGlhdmMIpG/pxerclQbp9v3FBlI5cyJv369Un zFb/yasj7xYHCk10nakcS10tncVmRSd0y/HwmzcggTrN31kH5bQtY/ZG0GvFDzjGTPbW EsW5xW/LvBs0zgrm5ZJPB2ZKrOBeZCIkukap0AXugvwzawvX/n3sTjJZL5ieYByheTvL +Ztu31G9mxiuh9RWBA3GCxY5PRDUjzOmsED3QtyVSAiSL8dj1XwSdndKAlg9SbrNwCzL mCdA== X-Gm-Message-State: AOAM531Tv1RKVHKK5gU2FAk18YiP0ss6STmNgmSLRWHfXqKkDwUHPg8H 3MJnfQuXzoGbaK8mKRIX/C7LcdIZdzP7 X-Google-Smtp-Source: ABdhPJwpwF4hCeEcD8WP2F52FmGpoCMVmSoE2R/VRCPmMc5vvMGS4yzbAZ1WyJM7j6+dONr435cj4ZE0ccVT X-Received: from luke.lon.corp.google.com ([2a00:79e0:d:210:23a0:2f14:433:e6cb]) (user=qperret job=sendgmr) by 2002:a7b:cb4d:: with SMTP id v13mr14985934wmj.68.1627291775721; Mon, 26 Jul 2021 02:29:35 -0700 (PDT) Date: Mon, 26 Jul 2021 10:29:00 +0100 In-Reply-To: <20210726092905.2198501-1-qperret@google.com> Message-Id: <20210726092905.2198501-12-qperret@google.com> Mime-Version: 1.0 References: <20210726092905.2198501-1-qperret@google.com> X-Mailer: git-send-email 2.32.0.432.gabb21c7263-goog Subject: [PATCH v2 11/16] KVM: arm64: Introduce and export host_stage2_idmap_locked() From: Quentin Perret To: maz@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, ardb@kernel.org, qwandor@google.com, tabba@google.com, dbrazdil@google.com, kernel-team@android.com, Quentin Perret X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210726_022940_776383_AD4E712F X-CRM114-Status: GOOD ( 12.93 ) 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 We will need to manipulate the host stage-2 page-table from outside mem_protect.c soon. Introduce a function wrapping the host_stage2_try() call and make it usable to users of mem_protect.h. Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/include/nvhe/mem_protect.h | 1 + arch/arm64/kvm/hyp/nvhe/mem_protect.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h b/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h index facbd9a7ab99..8e5725d032b2 100644 --- a/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h +++ b/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h @@ -50,6 +50,7 @@ extern struct host_kvm host_kvm; int __pkvm_prot_finalize(void); int __pkvm_mark_hyp(phys_addr_t start, phys_addr_t end); +int host_stage2_idmap_locked(u64 start, u64 end, enum kvm_pgtable_prot prot); int kvm_host_prepare_stage2(void *pgt_pool_base); void handle_host_mem_abort(struct kvm_cpu_context *host_ctxt); diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c index 2d41d4fa8901..223c541a7051 100644 --- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c +++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c @@ -266,6 +266,11 @@ static int host_stage2_find_range(u64 addr, struct kvm_mem_range *range) return 0; } +int host_stage2_idmap_locked(u64 start, u64 end, enum kvm_pgtable_prot prot) +{ + return host_stage2_try(__host_stage2_idmap, start, end, prot); +} + static bool host_stage2_force_pte_cb(u64 addr, u64 end, enum kvm_pgtable_prot prot) { /* @@ -303,7 +308,7 @@ static int host_stage2_idmap(u64 addr) if (ret) goto unlock; - ret = host_stage2_try(__host_stage2_idmap, range.start, range.end, prot); + ret = host_stage2_idmap_locked(range.start, range.end, prot); unlock: hyp_spin_unlock(&host_kvm.lock);