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: 124750 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1080483lje; Tue, 16 Jan 2018 09:02:50 -0800 (PST) X-Google-Smtp-Source: ACJfBotS/4zo3LnU6KO7TvpCm+L1RwxmfqTJ0tXqoYTLIDX77p6ut34gbkabPK4riJtjYuUK8aZA X-Received: by 10.84.235.196 with SMTP id m4mr40197269plt.118.1516122170746; Tue, 16 Jan 2018 09:02:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516122170; cv=none; d=google.com; s=arc-20160816; b=VhBJLTSK3f7qTYAOdiM8tbL7t3DHnuxEp1TaDn1nOangELCuJwKXXCCHOHlcFOoUXW KGz3Z8rxnZo8lvJEhlfZO+t9kvrszLKOr3Tt0q1Qm+0y3Gg3hJ7na/jq6F65iRTKuKSQ bFI5v/DIJ3P6N/tT/r8YUzvCYBoVsdbk6HBXeUgZiFmwHlu8x+tfslUb1SU/vCZC5buE OqnRJO4W94pxPJ9TqEZVwPCGsGQJ4+CVAQDAsipaXg4hes7pYa/7HlGTyik3T+nKlM5d eg8Oikrd5v9bwgNS1leQKOtfL6v809K0Fyku06yTHuoLs9ANYkDuW7xfQR1Sb4P5f2pu H4Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=dIgbhP3BAG5JtdprNvNXJy0jvAfw6BWSiFZ2vKILMAQ=; b=0oelV2jak7VO4MRD2rt5VhRLuIunnP4iLNzELQQkHX/0NvN65+MDdGSqhGnGr9xl7g E6+JU82D1WtLtZrGp/Oy86RXsKR8veSG18ob+UU8mMufUARe2AzRhork4+ffhfjuZygD gZWi2wkL/Vk00f3bz+1b/yNdy7eA+27xvCYHsmYPDg01f5UsfyGTlJktOFOEHsGKZHuE QjAFTOlRFR6xTiGSyQN8aXmgTeFw8mAe5vP2vKr5uixUo714gaQxqKPrXVqf1lBlIIWK prAt+u8G/Zzo0eJZ1b87ONvoId0y6R0nZ3mDk6pY1aXHEmWdlDb26NUqbuN/HNtCvS9b erzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K4KRlCZR; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u196si1956542pgc.116.2018.01.16.09.02.50; Tue, 16 Jan 2018 09:02:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K4KRlCZR; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751296AbeAPRCq (ORCPT + 10 others); Tue, 16 Jan 2018 12:02:46 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:45093 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751365AbeAPRCn (ORCPT ); Tue, 16 Jan 2018 12:02:43 -0500 Received: by mail-wm0-f67.google.com with SMTP id i186so9740135wmi.4 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=Z1g4LIZFOjmox/OEf4IGZQpA6WA5TtG+56fnFOZWNBRQjbUTRB2lH5NfX8PshhtUZ6 nlXyEFzMFDYezHXy8IAefQOoPynhUHRt+7MdMczj5Te6qfaD7FFDOMdwr04hxvM51Fn6 z/ILdzROv78n6n4nuzN4lJQWMHx5tTzTnStOr0+OjGEaFIaq9nKsIWylpzDjAqdaGurM HwivxgRJUdCVJXqw2ApU6QNEEzgiq2iSs/krrOnfgoPVzkU+EXoRtKRpq0qs10R//cDu KCiUdxtmy6UgJm5gBRJt5dG4gOe6N+ziP4fU9izGO0heEMWjXlnZnHQ1/3/ppOr6lXA1 NzBw== X-Gm-Message-State: AKwxyte83P+6hfUB1TWrNlVEJ01KkzixpfIp07Vk1ZnU2woGSOpLAFI2 c2eALqZQsdqFAEiCmHe0VC88cw== 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?b?UmFkaW0gS3LEjW3DocWZ?= 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: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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(-) -- 2.14.2 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; }