Received: by 10.223.185.116 with SMTP id b49csp6365756wrg; Wed, 28 Feb 2018 08:14:01 -0800 (PST) X-Google-Smtp-Source: AG47ELuX38cVLEH7v1D8Gq44GpPbSkjQbkBKyDaHetIK48URfXfP6gHuZhOhyVwyW/miakG3nanx X-Received: by 10.98.249.76 with SMTP id g12mr1337965pfm.76.1519834441676; Wed, 28 Feb 2018 08:14:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519834441; cv=none; d=google.com; s=arc-20160816; b=YBbmDV8mbWsqrW2UdYDiA3lu9TqLpXVxGvB48rDV5A1hKXRUk9vyGMZ0UUV1BdQvGj EFULH92gx6gyH1EpLPWbZHyVY7mp2j1iEaX/VbawGPKCkqV4/pqfhv8Dp1x+CEmL30yk C+6cdKSM1u+XuCvJhlpGwwvid77i0adPpveu+rXsB5OhbmjvD1C94tJq4wWjPa4TD925 WyX3VrG0S/y58votasEPqPAXipvcxcF55etzNEI4jMcj2ChFoFpCH18qcmCEF616hmd1 5Vzq00IhW83hoKV7AxfxU//jtiAHcmacEMP6vdCBJXeEeI2f2Cpda+Zems1SOTySNyIL hZ+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=PilCS8QiKdKJKAqkkPMXHIDOyjtYc1C1pTfn8IbQBY4=; b=G5OFZuSMADuU5ouBA9aGcePsojAf55pw6lVA5/i/YnB0vkGo0VzPecGrnnj4FFq8Xl 31a9v/H+yUaTSxl5rjk2E7/ar51SMqeOHyVbFQDYGUqh17UI2mntKGAJ/xLB22uEWE4n NIRJVnOEr7Sd4+vaNZssd8/Uc7tp25jdcWyWPRBuNHSKf41TpNyhO9a+QGnZXaUDK8Hv 7OLLQMZUwREqkXyoKQQPIDhbNeNSyHsKxxfDbP5I81SFmAWbxUVT22IA38Ye/LQ2k06m xIyqbzaOAZlVh8Np/AR4gvI6BWHWjQuouSaCZtjcQkcrntoPCLUjIqJg2R37B/op1GAQ 12bw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si1192879pgt.198.2018.02.28.08.13.46; Wed, 28 Feb 2018 08:14:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934601AbeB1QIq (ORCPT + 99 others); Wed, 28 Feb 2018 11:08:46 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:34961 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934474AbeB1QIo (ORCPT ); Wed, 28 Feb 2018 11:08:44 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1er3Yp-0006Xd-Ir; Wed, 28 Feb 2018 15:22:27 +0000 Received: from ben by deadeye with local (Exim 4.90_1) (envelope-from ) id 1er3Yj-0000GZ-VK; Wed, 28 Feb 2018 15:22:21 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Christoffer Dall" , "Marc Zyngier" Date: Wed, 28 Feb 2018 15:20:18 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 208/254] arm64: KVM: Fix SMCCC handling of unimplemented SMC/HVC calls In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.55-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Marc Zyngier commit acfb3b883f6d6a4b5d27ad7fdded11f6a09ae6dd upstream. 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. Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall [bwh: Backported to 3.16: use vcpu_reg()] Signed-off-by: Ben Hutchings --- arch/arm64/kvm/handle_exit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/arm64/kvm/handle_exit.c +++ b/arch/arm64/kvm/handle_exit.c @@ -34,7 +34,7 @@ static int handle_hvc(struct kvm_vcpu *v ret = kvm_psci_call(vcpu); if (ret < 0) { - kvm_inject_undefined(vcpu); + *vcpu_reg(vcpu, 0) = ~0UL; return 1; } @@ -43,7 +43,7 @@ static int handle_hvc(struct kvm_vcpu *v static int handle_smc(struct kvm_vcpu *vcpu, struct kvm_run *run) { - kvm_inject_undefined(vcpu); + *vcpu_reg(vcpu, 0) = ~0UL; return 1; }