Received: by 10.223.176.5 with SMTP id f5csp948848wra; Tue, 6 Feb 2018 09:58:15 -0800 (PST) X-Google-Smtp-Source: AH8x224/oYw8rNYt3QLbe8yAw8RFoacEiQtGdxb7Tz1PIz/InYe/yi8IqGEbWIwX5AnL6VGOdkjN X-Received: by 10.99.190.15 with SMTP id l15mr2583621pgf.197.1517939895051; Tue, 06 Feb 2018 09:58:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517939895; cv=none; d=google.com; s=arc-20160816; b=fTQG007zuczIexUwRanaj6t7lzLZjRIY+5CaZ5IZtM5VkMfFvd7YHcRXXNHlIXQCV7 ytCwQlwUeOpbEkaaSTvoL2H2YvJ1va0r/49Zypk6t4BTyOvaWvr6/jZXBgMQZXVeI6Gc qD6iGlVwxc6JygxQTC5EUw3wt/xMG2IPoyLJgwjgUAImZiT05Ewe1RkvbiiRWo4+8HGj 9oKWuzpv1ZOmLzKFFukLtXbnYnwIfGjxsNj2rZV1Rw8Tfxepg0jD7oLrj8W3EYM7TWcM JggQfj6N3ZzpWYLwnZefn7nkYMtrWKmVl2SM/97s016ftLDiNPqr7FHk4sNRheoAPHQq bcsQ== 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=xpoTWuFUsYYsEQ8Zce3iZQ9mwbkwZG9plN3fw9+vWAyGxQOiY5qaHU/2i00142qMA1 dPHDDc2JPaMdTzPScWZ2KsXRcZ5EEPpKsmyyL1rCP32Ij/zvC7bPpCCsbv7JBwZCw+WI SBknFtsetNtKY/OTP58+18rUj+33LtNV9TS4KcRSt1+j1uLYixZML5bl8ynBunMpuatv EVSy02ING/7uYeSKn1DOyBS+rZCPJ+yOq8bsZ6j61vmt1K5h6oZdyVMml7F3uo2uAayx Bfl3DcDfKkxUxu6XR3uAYo3LBiW6hqOs0OU8PfqNlQLnsrjiRyTeaf1fTi34Ugs4u8gd AMSg== 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 e90-v6si77289plb.749.2018.02.06.09.58.01; Tue, 06 Feb 2018 09:58:15 -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 S1752758AbeBFR5E (ORCPT + 99 others); Tue, 6 Feb 2018 12:57:04 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:40948 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752599AbeBFR4u (ORCPT ); Tue, 6 Feb 2018 12:56:50 -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 907671596; Tue, 6 Feb 2018 09:56:49 -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 DFC3A3F25C; Tue, 6 Feb 2018 09:56:46 -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 v4 01/17] arm64: KVM: Fix SMCCC handling of unimplemented SMC/HVC calls Date: Tue, 6 Feb 2018 17:56:05 +0000 Message-Id: <20180206175621.929-2-marc.zyngier@arm.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180206175621.929-1-marc.zyngier@arm.com> References: <20180206175621.929-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