From patchwork Tue Jan 16 17:02:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10167705 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A884B600CA for ; Tue, 16 Jan 2018 17:03:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 931B322701 for ; Tue, 16 Jan 2018 17:03:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87B7423E64; Tue, 16 Jan 2018 17:03:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0CE0F22701 for ; Tue, 16 Jan 2018 17:03:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To: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:List-Owner; bh=ZnlHzq+fxNE3BkJEfboUNgRP2FQxlkZaDK0xE1Q2SmE=; b=ovwLaxVz2DkaRse4x977CRGOmP vkfWZp3CJpZ5Bp3IDM0gJ851i7Ze655oxRID7vvMIeN+JO23CnXC5sV9BjL7QwoPWAy9EQcIrwu9/ AZFvdQzVceUe0gBO1dDjehXXR/Kh+fJ95cabvCuIleBrlYHe8pJp2bR60E27RdFAN1LxUBllg19kL Gjyjrr2b35XNvE22XfplhYzELaWXEEOW0tj5WWTgAW2VpuZzre8TxFbSyETF9DPIJHSt270MfT3Lk MDQUhpdBHtZ/CdtWkXRQQhKdj9Qb+HEXtP4GUXsdzRtjoeU4IcxHI6UGPjnF6eCvyO3P+kJs9LUe7 YJy+j10Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ebUeA-0007Ue-5V; Tue, 16 Jan 2018 17:03:38 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ebUdR-0006g5-Rt for linux-arm-kernel@lists.infradead.org; Tue, 16 Jan 2018 17:03:00 +0000 Received: by mail-wm0-x244.google.com with SMTP id t74so9845951wme.3 for ; Tue, 16 Jan 2018 09:02:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dIgbhP3BAG5JtdprNvNXJy0jvAfw6BWSiFZ2vKILMAQ=; b=K4KRlCZRZn7PSkRdxiGM0VSvfva+9g2MadQedMVnVhgiEQ6hz9TJt5716dM+VELqAA bwiseM8JZxG7+MeByDvxgmj6GE/LQ7MH7FupLc4GUx1t1cGmGBUBoFCVSIhS0q1w+uk4 teDbnrlzvGsmoiTHUf4tzsvD/0n4XFlUGM0Qs= 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:in-reply-to :references; bh=dIgbhP3BAG5JtdprNvNXJy0jvAfw6BWSiFZ2vKILMAQ=; b=Q9AqyvlgLWO4gP1BDYZk8eUuDYM+YhONabBeIahLTh6WjC8igzvxvoAH6GMP0SNPoU bbqn0kKRhDrquTDLFirh+n1CVCb2QoJsPnQJKB3oP/HoQGfU1YXKgOnbDlYTH4iI/zQG miD4Auy03k+DBFjcysKwhqCIlwAdMuIRKkEeZTadQ4YZu4Iyu2hCwTDfYVz2sWad0GnS rtJj4o+FC4G9fFQ1SX7uenFnuwggX7Wrs64cVbz/k/JIzB5BcZsc1IW2B1mgrFpRAUKK VQ5I1dNvpzUbHsiY/v30wvEm0dT1tExBRGwz8VRHwCwxrXkMjou7VwPU3+HXhSys1y9L +AGQ== X-Gm-Message-State: AKwxyteK+cXQg9UZ7gyCvxnd64FoF/O9vjx6Te/0rGM602/kosLs8ODS +MgThmkDd2Hhe8MzXtQXY7aE8Q== X-Google-Smtp-Source: ACJfBotpAVwZW29k8cGgy4CmvWm2cyZ6m1HVVz/aBFdhlx4MkY1U1alAXKMOg3xtWxOAoRDzagoBOw== X-Received: by 10.80.242.144 with SMTP id f16mr14537485edm.52.1516122162044; Tue, 16 Jan 2018 09:02:42 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id r29sm2107162edl.82.2018.01.16.09.02.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Jan 2018 09:02:41 -0800 (PST) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL v2 3/3] arm64: KVM: Fix SMCCC handling of unimplemented SMC/HVC calls Date: Tue, 16 Jan 2018 18:02:33 +0100 Message-Id: <20180116170233.7085-4-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180116170233.7085-1-christoffer.dall@linaro.org> References: <20180116170233.7085-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180116_090254_051467_A9EEAE58 X-CRM114-Status: GOOD ( 11.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, Marc Zyngier , stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, Christoffer Dall MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marc Zyngier KVM doesn't follow the SMCCC when it comes to unimplemented calls, and inject an UNDEF instead of returning an error. Since firmware calls are now used for security mitigation, they are becoming more common, and the undef is counter productive. Instead, let's follow the SMCCC which states that -1 must be returned to the caller when getting an unknown function number. Cc: Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- arch/arm64/kvm/handle_exit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c index 304203fa9e33..e60494f1eef9 100644 --- a/arch/arm64/kvm/handle_exit.c +++ b/arch/arm64/kvm/handle_exit.c @@ -45,7 +45,7 @@ static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run) ret = kvm_psci_call(vcpu); if (ret < 0) { - kvm_inject_undefined(vcpu); + vcpu_set_reg(vcpu, 0, ~0UL); return 1; } @@ -54,7 +54,7 @@ static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run) static int handle_smc(struct kvm_vcpu *vcpu, struct kvm_run *run) { - kvm_inject_undefined(vcpu); + vcpu_set_reg(vcpu, 0, ~0UL); return 1; }