From patchwork Wed Aug 11 17:36:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 12431659 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.4 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 DEA7CC4338F for ; Wed, 11 Aug 2021 17:38:58 +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 9452360EB5 for ; Wed, 11 Aug 2021 17:38:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9452360EB5 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:To:From:Subject:Mime-Version:Message-Id :Date:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=0hA7c2CpytMskDuef76LybUgLYcncK6gQBb1xeUz9As=; b=d+pZ/+zZbT+NjK L6Ihp9xR5Ezm30plVpi2RTH6NFrexJZTflS48FA66pc3snoFRH1R3s0P674ie95EBy3bEjkcNyiPN CAMfjc+1rMbShdowQ/CMvYJ2UI4zGuwzdzGEfN96sjz5DtozT6sRO/UwpOhGucdE5uWNe1U0vV7fJ iO2FIWST6vVwsukLXc6cBD03Pcj9lD5wOQ8vuqxuXWVm128nRmWG/yVa69G5hkchpQSNNTRqpHd4m DGwrYcWCRVvcJslUxa9+nLNDD6y8CtgHh6osOdtKRbmQ9JfRurbvL50PaMpTHOV2YcUJ7Uq9y1ILY ccMCz6V+oONEam37AAnQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mDs9n-007nlq-Qe; Wed, 11 Aug 2021 17:36:47 +0000 Received: from mail-qv1-xf49.google.com ([2607:f8b0:4864:20::f49]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mDs9k-007nkI-0k for linux-arm-kernel@lists.infradead.org; Wed, 11 Aug 2021 17:36:45 +0000 Received: by mail-qv1-xf49.google.com with SMTP id dl20-20020ad44e140000b0290347c39b05c0so1713248qvb.3 for ; Wed, 11 Aug 2021 10:36:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to; bh=600BfGro66ckGcCtHLsSTcvyovy+Yar8dj0tkkGK880=; b=L+p6M06P/C3C4ui9FQhMOHTPxJm2qikZ+jN5iqIhJgZmcX5ah7c+7XLdhiHBoQrqr5 AeOGSAdoKCTLhHfpfnfPyRyHtFjiqcizVH+aY3LSl3A/4LQVRjG1aMVmBugLHTJlXKk0 +g5t3jqDcQMw7giIw6Mb88GJreFp5SdVeQl0RZvMPXB3a4F8AAtLT8YYyM8IQgi3k/Ea NEGEmj1CnkvmyNpXuVr6XDvrdqgmFluMY9uhkWp43QnRy8deagM2lKVHMomSadhQQfd+ svhMqj8K7ffp2UB+w5bU6499e6R4myay6uPMvzAs1JW3WpgezHuWetkNKmHDst3NTgrU UcQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to; bh=600BfGro66ckGcCtHLsSTcvyovy+Yar8dj0tkkGK880=; b=iJv5HDLr0N44YoIeoItEuFsmHnvz9oIawtF9pu83OvaU5cUZx7ucT+e3wLy0h9OH3O HjWUlb3f/XABb4smO8CicEo5g8ItG3HGBPPM8jAE1f+6II5qnLGxcu+DPAALxsDZwkFX ZTc7ESPhwX+hNSXpL1SpILQo1mDWmGMeRENtWlZHbBvXlcjBHMoSjzkBalH5aa8S6BBk 7Wf2qTiJxtO4+BthJJcfIeve1G6DPfNS7qcv+yAYL/QHRm7eroqmrNcH12MF0G7b9l41 mfqcecj0Gsrd1unDC1mUazrBO3Tp234a8PNiRfx/23USZURC7PdnDGL7nqfTVVPKt1J3 GRAg== X-Gm-Message-State: AOAM533/7/0d6HIyQ9KY++nO0Hz2V8gF/7HzZ4bvHLf6TO9DRK+jypM2 NFXRWQke8vz8q56aW0aO2jY3U/HHyrtf X-Google-Smtp-Source: ABdhPJwPXKpSpNhuMaTz2hv19f1ZPNoKVo1Bsp9I8bXQZmXjrv7ZMQNSoNx0s8MSeYAAj6++CqBzRXIlgBVK X-Received: from luke.lon.corp.google.com ([2a00:79e0:d:210:43fd:e634:73d9:e10e]) (user=qperret job=sendgmr) by 2002:ad4:45a8:: with SMTP id y8mr20692593qvu.49.1628703402006; Wed, 11 Aug 2021 10:36:42 -0700 (PDT) Date: Wed, 11 Aug 2021 18:36:25 +0100 Message-Id: <20210811173630.2536721-1-qperret@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.32.0.605.g8dce9f2422-goog Subject: [PATCH] KVM: arm64: Return -EPERM from __pkvm_host_share_hyp() From: Quentin Perret To: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , Quentin Perret , Fuad Tabba , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210811_103644_128003_EAA7F0A9 X-CRM114-Status: GOOD ( 13.63 ) 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 Fix the error code returned by __pkvm_host_share_hyp() when the host attempts to share with EL2 a page that has already been shared with another entity. Reported-by: Will Deacon Signed-off-by: Quentin Perret --- This patch fixes a bug introduced in the stage-2 ownership series which is already queued in kvmarm/next: https://lore.kernel.org/lkml/20210809152448.1810400-1-qperret@google.com/ I've starred at this code for hours, but that clearly was not enough. Oh well ... --- arch/arm64/kvm/hyp/nvhe/mem_protect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c index 8165390d3ec9..6ec695311498 100644 --- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c +++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c @@ -404,7 +404,7 @@ int __pkvm_host_share_hyp(u64 pfn) cur = kvm_pgtable_hyp_pte_prot(pte); prot = pkvm_mkstate(PAGE_HYP, PKVM_PAGE_SHARED_BORROWED); if (!check_prot(cur, prot, ~prot)) - ret = EPERM; + ret = -EPERM; goto unlock; map_shared: