From patchwork Wed Dec 8 15:22:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 12695380 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 2BFABC433EF for ; Wed, 8 Dec 2021 15:35:31 +0000 (UTC) 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=jv3EyJR0R/A3xyvFFx7rhjQ0ti35gEcd3FXoYA2NBEA=; b=iEMx9jIi7F+nCahpTSglXP+XQj 9tOOWhEs/71gqDK+09NNiFL9NN4ErQVtXIu/mqfn3NgyFqI5TTMzC3S02KOlWSfTh+j2jHZDq3xrX KLGnZLFx2KufaygZyY+J7CfCEFxiPvxEer0RjIsI0ydA++eM7VDtXmX4OIX6Y5QPc6IrCuy9gGZAt a6XBWwT1f9qTkvh1UHPYE9PUcz5reB4dlpxxDzk2oWI99caXi6RkQ16m+NiBisR5/DJb1K6MCJoTs ByBrxSREe7C8n1hCCfXmueaxfI3aQUqBF0etLZJpvOmCMlq5bbWRrLnjjbPAF9ECsVFochPOimbby cXOyboDA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1muyws-00DHXc-Ma; Wed, 08 Dec 2021 15:33:40 +0000 Received: from mail-wm1-x349.google.com ([2a00:1450:4864:20::349]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1muymu-00DCmc-Dt for linux-arm-kernel@lists.infradead.org; Wed, 08 Dec 2021 15:23:21 +0000 Received: by mail-wm1-x349.google.com with SMTP id 138-20020a1c0090000000b00338bb803204so1465601wma.1 for ; Wed, 08 Dec 2021 07:23:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=cuQE0YW8UdMGW3rLCo6CNfwjy36MSIxkvZOeV47gVAQ=; b=KUpsl8OdrXa2TfNhJOIs3W3KwuQrGlRyqmoXmUyaJ/yuu4HpfU1Kh6qBx0/DO5VGCW 30J/V6mtYiRAmcRHM+mRVJum30AGeDLlvKOpqxYp+Jet7qFJJ1RdoNIVvktcVDiLDpqZ ehHF9n08W/1YSh/QKI1PIfTOx8lNeNdWFZqFuHY4IbZYhDWrHvWxvuQ+m8SLOOOKopWV Uch7He8l5dVKPrpUzYaPboYyMT/+vk2ZeR+zmJn7QZvuOWKOuoJdoYS5ptXP4LyB1l/u sS5qgHeFSbCTheo3xIpypUgjz9uCkJAgxoYl5uOx5eSw/hZ/dtcTXVGboSUwYK26WUuE AqJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=cuQE0YW8UdMGW3rLCo6CNfwjy36MSIxkvZOeV47gVAQ=; b=0fHSsZ74VW8zU6fqQnwi8t++YociMMgjjXCkSyaGEf6IxjGa8HscluqtV9MGghp5AO SMHOzYY82JmnLpxLnVH5uqNnfrATu9TMtwux1yUtgyNqxkMwFFvVVaa/353EWcC4hJSy t+HKk4fd4A2eMQVHFzcIiIpyE5EatlDwLVLZagZAaqtIquAXKQIQ4Vk0S9gFLwaiF/OE EA78/wiYnEFOp+tmPMfNAjt8rfOKI3FufSXyyb8cXgsFBaUr7Obi1gs+t5s+qnljLiL4 ikmQ0D6KCKjhD5Zsy0JzBFTWkAVSVWz0vudC2ilzEe6hTiDKlXluGvR1b/X0Gq/+jBd5 Z1Wg== X-Gm-Message-State: AOAM5334cMJFr9uUfSz7CqX9+TJPuVXitzl64S8WjrXeaifCILk5MW2X M8CZOJGocDm/gbwZkxNKljfuecLydOUR X-Google-Smtp-Source: ABdhPJxGsSBocOeLXiSRK4wTT3nM6evq9+M4+nial4TaliEuNBrySS5ScIR8zMauErKeWzLKuaryRYic2Qfw X-Received: from luke.lon.corp.google.com ([2a00:79e0:d:210:c718:14b8:982a:57d5]) (user=qperret job=sendgmr) by 2002:a05:600c:3506:: with SMTP id h6mr16840889wmq.122.1638976997976; Wed, 08 Dec 2021 07:23:17 -0800 (PST) Date: Wed, 8 Dec 2021 15:22:58 +0000 In-Reply-To: <20211208152300.2478542-1-qperret@google.com> Message-Id: <20211208152300.2478542-6-qperret@google.com> Mime-Version: 1.0 References: <20211208152300.2478542-1-qperret@google.com> X-Mailer: git-send-email 2.34.1.400.ga245620fadb-goog Subject: [PATCH 5/6] KVM: arm64: pkvm: Stub io map functions From: Quentin Perret To: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kernel-team@android.com, qperret@google.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211208_072320_515438_2BAA9678 X-CRM114-Status: UNSURE ( 8.84 ) X-CRM114-Notice: Please train this message. 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 Now that GICv2 is disabled in nVHE protected mode there should be no other reason for the host to use create_hyp_io_mappings() or kvm_phys_addr_ioremap(). Add sanity checks to make sure that assumption remains true looking forward. Signed-off-by: Quentin Perret Acked-by: Will Deacon --- arch/arm64/kvm/mmu.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 326cdfec74a1..605c104eb030 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -407,6 +407,9 @@ int create_hyp_io_mappings(phys_addr_t phys_addr, size_t size, unsigned long addr; int ret; + if (is_protected_kvm_enabled()) + return -EPERM; + *kaddr = ioremap(phys_addr, size); if (!*kaddr) return -ENOMEM; @@ -650,6 +653,9 @@ int kvm_phys_addr_ioremap(struct kvm *kvm, phys_addr_t guest_ipa, KVM_PGTABLE_PROT_R | (writable ? KVM_PGTABLE_PROT_W : 0); + if (is_protected_kvm_enabled()) + return -EPERM; + size += offset_in_page(guest_ipa); guest_ipa &= PAGE_MASK;