From patchwork Tue Dec 29 16:00:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Brazdil X-Patchwork-Id: 11992465 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=-16.8 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 DE95AC4332B for ; Tue, 29 Dec 2020 16:02:45 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 9A3E120825 for ; Tue, 29 Dec 2020 16:02:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A3E120825 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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=mtm2l+eOx/eP2hW2WHVzVJnmgT2B/r9LRtPG7nevHmw=; b=mv3UTVIa/rQXoqANPRhDiHkdyc WsKHPKluEk5Nz8+lt44GoKw+1NXWyYGEulsA3XEH1jeQD0QhlBYNlml3ldcOSX662BhLLemQIFpZR YsgUj9X71iqCqJJFXziU4/YBVvgUj/xqauoyCmvSZHk1SKoKyMjXyuI3WUap0GDpUZc15d5OSVhiA wMUbzHOrou54dwr6ozzKbgDJrgvYu6JGsNKh9ThWC7kXZPLD0xHR2ZRuBc7jwu4xnRgKSxbc9sBSc 5II9pGYALvNAKe6JUx0mOq2QRwzoTUVyGDZEGAp/OhPzUksB0feUO9gimjSFV9Shb2wznHl1x2RKT pltF4iHQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kuHRD-0002eD-Lb; Tue, 29 Dec 2020 16:01:31 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kuHRA-0002ce-8t for linux-arm-kernel@lists.infradead.org; Tue, 29 Dec 2020 16:01:29 +0000 Received: by mail-wr1-x430.google.com with SMTP id d26so15005535wrb.12 for ; Tue, 29 Dec 2020 08:01:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NtCljhLriYtvqTyh0Oi7f3SoeajHUSS/0DAzm3hIGXE=; b=Oz7Ml7QJVCMzwv2c3OvZUVS1nQR+4abLjG0AvTqtcYOBygQ3cV++dq2Q6H5LlAKrJT yiLsX9sMElJJfJRsPvDEaP+TbemQEMjDGRraLIfCVxGD+J1oRK5SOotiiGSBR1h+utFs k3pYH3lbVXXATfVz7oopjMSJzngGXuu/egoKdfuLkxzdA0cJVJK5H1HBZcheS6le/UX2 bR7Wy/OEayCryx50CMsvlN8wahXfGjPH3yP5ucV7N9nK9AGU3X/DyctWqEyNDF6LCIEA 4b7vbgmlTU4v2FSk5RCmiSPrrdDZY0nYjL0nBX3BHVA/0Xyyv+6JRgMuPGWQUtZ8JJrL yrYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NtCljhLriYtvqTyh0Oi7f3SoeajHUSS/0DAzm3hIGXE=; b=VHaKZmNBYkaNEskmjK0uZuZ9xrrZsA0DIz/eiUYc7iPUMIVWx9Nzd1XT4XIrL5uVLc mlB6JblVuDbTBk3L7gbsDl+4BO7Zpjjw1eGNrkGRalKscIWlty5DdXcZr/fFkr2Z5+Y3 6UhamtD9lQXnpMZxP7lEzkIbOFa8+j0G/CuqKUaGgJw3xTfUmlT3DMiMG4yyNXYW9fIj mLc5kH4gLjmc7LUX8iq16QGLJdZitxh49mE14KHpnXSQBIT6lFZxmghYxfIOjZux0nsS ytuSIy8LokLInQxhUIdgPWJeBO8pU8KvgTrCn8WVSsM0ytUXJmW6802lkY00pBLwBJTM x8Lg== X-Gm-Message-State: AOAM533ruO6WvZUT6Dy78FbRapajv/vaU1VgdZn4fcmPTmSUI8WlegvB eZ1aEvqGtDaaPbAClo/8Bg7UxA== X-Google-Smtp-Source: ABdhPJw9Ayoh9M0GtPyVtC0R8Y+dAZ8drQfvlYeo93ZmkqUpL9igbq4DREd39sZg1DlSlN4TeaAUKw== X-Received: by 2002:adf:8290:: with SMTP id 16mr54668406wrc.27.1609257682161; Tue, 29 Dec 2020 08:01:22 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:b0e4:997:fb3:e517]) by smtp.gmail.com with ESMTPSA id l5sm61284118wrv.44.2020.12.29.08.01.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 29 Dec 2020 08:01:20 -0800 (PST) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Subject: [PATCH] KVM: arm64: Allow PSCI SYSTEM_OFF/RESET to return Date: Tue, 29 Dec 2020 16:00:59 +0000 Message-Id: <20201229160059.64135-1-dbrazdil@google.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201229_110128_438571_73DB4E81 X-CRM114-Status: GOOD ( 15.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Lorenzo Pieralisi , Suzuki K Poulose , Marc Zyngier , Sudeep Holla , linux-kernel@vger.kernel.org, James Morse , linux-arm-kernel@lists.infradead.org, Catalin Marinas , kernel-team@android.com, David Brazdil , Will Deacon , Julien Thierry Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The KVM/arm64 PSCI relay assumes that SYSTEM_OFF and SYSTEM_RESET should not return, as dictated by the PSCI spec. However, there is firmware out there which breaks this assumption, leading to a hyp panic. Make KVM more robust to broken firmware by allowing these to return. Signed-off-by: David Brazdil --- arch/arm64/kvm/hyp/nvhe/psci-relay.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/psci-relay.c b/arch/arm64/kvm/hyp/nvhe/psci-relay.c index e3947846ffcb..8e7128cb7667 100644 --- a/arch/arm64/kvm/hyp/nvhe/psci-relay.c +++ b/arch/arm64/kvm/hyp/nvhe/psci-relay.c @@ -77,12 +77,6 @@ static unsigned long psci_forward(struct kvm_cpu_context *host_ctxt) cpu_reg(host_ctxt, 2), cpu_reg(host_ctxt, 3)); } -static __noreturn unsigned long psci_forward_noreturn(struct kvm_cpu_context *host_ctxt) -{ - psci_forward(host_ctxt); - hyp_panic(); /* unreachable */ -} - static unsigned int find_cpu_id(u64 mpidr) { unsigned int i; @@ -251,10 +245,13 @@ static unsigned long psci_0_2_handler(u64 func_id, struct kvm_cpu_context *host_ case PSCI_0_2_FN_MIGRATE_INFO_TYPE: case PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU: return psci_forward(host_ctxt); + /* + * SYSTEM_OFF/RESET should not return according to the spec. + * Allow it so as to stay robust to broken firmware. + */ case PSCI_0_2_FN_SYSTEM_OFF: case PSCI_0_2_FN_SYSTEM_RESET: - psci_forward_noreturn(host_ctxt); - unreachable(); + return psci_forward(host_ctxt); case PSCI_0_2_FN64_CPU_SUSPEND: return psci_cpu_suspend(func_id, host_ctxt); case PSCI_0_2_FN64_CPU_ON: