Received: by 10.223.176.5 with SMTP id f5csp2640634wra; Thu, 1 Feb 2018 03:49:03 -0800 (PST) X-Google-Smtp-Source: AH8x227SUTL7h+IKrnvOGiogE1qoG36e73BytVqJ7l+G5GnyG2L/4QtV/Hj+Q91hGwxbPj4xvfTt X-Received: by 10.98.218.81 with SMTP id w17mr2120979pfl.161.1517485743062; Thu, 01 Feb 2018 03:49:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517485743; cv=none; d=google.com; s=arc-20160816; b=wqLKqnvP/IVcNX5DPveDJ+S3xkUZIa5oRFs+6jGZ4I+SAa3TsDYOammw/QV5Rq9NXr OOZvffAJl4oZ6HakHvhQyVRZSLSLy2AhN/rVu7uhsKF3dBLJwusXYrIPLc+n9+Uy/KTF HsTkDQ/TGq1gwZ+s/ppm35UzmWRCaCdBLAeiuSmDfE7mMrODM1mYu5jq+0gVbdR8uTTa b8mrj1iSB2W0nfght/F1zSsMQsUJoNTJ7toxo5mumi/P/tDPc8BJpNsNQLA7Kj1vTk8E fgrp5jNvSmnNIP1CPnhc0N3KaKUCiY6RvPB10ZT1WvtB4Wwo2mTxfWk27wLH4A/8a91n yeXQ== 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:arc-authentication-results; bh=3sgZH/KJM+5fkdatcfV7EYF6rPkoTScuILR4g42x3x0=; b=Aqyuh/Cmnc8ZcyVLxvcIyzEAJTk9X8tsMMI4Zlywq6dRl6XRhnS5M6kvsR80xX02H9 K1Oa4lS8IUM9J6TqO3bX8LL5ndhb/qMS5Luxg2E+oY966o+jYz5rqltwmC4lG47rUPfH a88DMyy0B9NoGX+UcskNNJn0HMjVIxKHlA6UGTC1o7CIWLrLuhKizK7B9aKPmVlrfN3r 0/ebgJc0jQa+lZ/SRMgjVC5cAtdIvCgmFDwm/KYh7g5htJIIWKxAujpFe70KisXO1WLL 8Uh3TzPUOxE5S8qQIlGJ6vWDkDqnAweY+t2g+4Px3r9fsiuBOysJv3AoqehudSTN19d3 ROQA== 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 i1si1469632pgn.373.2018.02.01.03.48.48; Thu, 01 Feb 2018 03:49:03 -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 S1752392AbeBALro (ORCPT + 99 others); Thu, 1 Feb 2018 06:47:44 -0500 Received: from foss.arm.com ([217.140.101.70]:48304 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752301AbeBALrk (ORCPT ); Thu, 1 Feb 2018 06:47:40 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A6D131529; Thu, 1 Feb 2018 03:47:39 -0800 (PST) Received: from approximate.cambridge.arm.com (approximate.cambridge.arm.com [10.1.207.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DDF413F25C; Thu, 1 Feb 2018 03:47:36 -0800 (PST) From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu Cc: Catalin Marinas , Will Deacon , Peter Maydell , Christoffer Dall , Lorenzo Pieralisi , Mark Rutland , Robin Murphy , Ard Biesheuvel , Andrew Jones , Hanjun Guo , Jayachandran C , Jon Masters , Russell King - ARM Linux Subject: [PATCH v3 01/18] arm64: KVM: Fix SMCCC handling of unimplemented SMC/HVC calls Date: Thu, 1 Feb 2018 11:46:40 +0000 Message-Id: <20180201114657.7323-2-marc.zyngier@arm.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180201114657.7323-1-marc.zyngier@arm.com> References: <20180201114657.7323-1-marc.zyngier@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 c09fc5a576c7..520b0dad3c62 100644 --- a/arch/arm64/kvm/handle_exit.c +++ b/arch/arm64/kvm/handle_exit.c @@ -53,7 +53,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; } @@ -62,7 +62,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; } -- 2.14.2