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: 10167697 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 01F54600CA for ; Tue, 16 Jan 2018 17:02:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1B6022638 for ; Tue, 16 Jan 2018 17:02:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6470228C9; Tue, 16 Jan 2018 17:02:49 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89F3422638 for ; Tue, 16 Jan 2018 17:02:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751398AbeAPRCr (ORCPT ); Tue, 16 Jan 2018 12:02:47 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:43756 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751355AbeAPRCn (ORCPT ); Tue, 16 Jan 2018 12:02:43 -0500 Received: by mail-wm0-f67.google.com with SMTP id g1so9753441wmg.2 for ; Tue, 16 Jan 2018 09:02:42 -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=VkQ8M/vkx7SJTpvRJV8bIRivDdinbjhlvezzHXsHaXs+T5/jf20/NHTLpD2W1UdA6I EVhdzf87YhLujeuqmS6HbuwoKaKugM2k0SYYFU+C5pZnUH8hiWbj6GBUiAn9FvpPo6gw 5vu1kC7sVbsc8xy9PAiT+MS/Gwl8JsJdRxPUa1SMcVzqT3TGXoqHvPJKRFmowPfclsvy XwcvCKpPFeE14iXiRayMepxh2Dkat5p5ebFIc5KOuJ3NaMoAVu12bdvTDzaplcd4gEgb tBB2vCWa14YeN3MBfg0uduNCJseiGUFdMPUXfS5Tjt1sPxpv7FEEXmoP0+DWI2Vjw63V 5wCg== X-Gm-Message-State: AKwxytfqP3VterRs5Nf7JKsDFTbzy4gZhJgmPxDv/FQE6gZCgEstF2FR c3aGR0D6g0aC2e9H/7rSM08jrw== 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?= Cc: Marc Zyngier , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, stable@vger.kernel.org, Christoffer Dall 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.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; }