Received: by 10.223.176.5 with SMTP id f5csp3171431wra; Mon, 29 Jan 2018 09:49:10 -0800 (PST) X-Google-Smtp-Source: AH8x227nHjQ+w9BcA0PZyTNMsLcy+Zl4UdKfqpebJLE9DTKkfDpPO352LazN+NQqzJwnNbS/TSWA X-Received: by 10.101.66.131 with SMTP id j3mr21360096pgp.56.1517248150177; Mon, 29 Jan 2018 09:49:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517248150; cv=none; d=google.com; s=arc-20160816; b=a6cDMiV1dhRMcl9s1jfJ/VDNg/7zodTUHPCfcRdyHV2SWzX+pH8WPac9gL8BfQX0BK jwYNM7AIKs1TiGmqPK+yp0CWez1PJk16CMNhb/O8buhhbGirO7y4gYyFa88aEXX0jcBD kfDX2cs9AHlCP+9e1gokmy80DYD2aH7SL/D/uBw7+PD9Iib3Do/82fZ+GroA0bMBWDUH cYMSMWDgUiZelxMRPvi99kxtH6jJ9I1nnjeBUEMniA54mTnTCYJ1cteTrDX9MIO+zKbA 2CDDgEjztW6LeqmmXtJbMnvgpSEjgUwQfMdJ1+8pSb1+cNMPYJosSxgA0sbgPMOXrRnL gOow== 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=R2XQd54ZbdkxHZq3e+/QsMaBBPzFcl282rfpDYO90BV3zSPjksWWjCbLBlPSl3dOUk gDbM63EPNddQ6czcWcESPPDMk9XOKZ8nFqd+zMDp+lMNslzPpAUsh44npP68e+PDuv0r EB6VyRwsgeRiL7yYJtig6BOCwLjtzwD1dbGMiYAyLE/1QblhNAWD6AVCq+jDCw7WTX3J kMi0Cy+ynEBbYQuA61F+2jgoCAIszajqLgbRrNoChUO4pP/REIiBFE/bJeeRKFFXpNhq aMCKKbxOxDyomximn6lbrxYcIqWF6uMi5UJDzisigEnhjC9TjPXFUsRyTDR5gPXbBhAY uKMA== 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 z10si7744577pgv.473.2018.01.29.09.48.56; Mon, 29 Jan 2018 09:49:10 -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 S1751593AbeA2RqU (ORCPT + 99 others); Mon, 29 Jan 2018 12:46:20 -0500 Received: from foss.arm.com ([217.140.101.70]:43452 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751411AbeA2RqQ (ORCPT ); Mon, 29 Jan 2018 12:46:16 -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 2D88E15AB; Mon, 29 Jan 2018 09:46:16 -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 1A1D93F487; Mon, 29 Jan 2018 09:46:13 -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 , Jon Masters Subject: [PATCH v2 01/16] arm64: KVM: Fix SMCCC handling of unimplemented SMC/HVC calls Date: Mon, 29 Jan 2018 17:45:44 +0000 Message-Id: <20180129174559.1866-2-marc.zyngier@arm.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180129174559.1866-1-marc.zyngier@arm.com> References: <20180129174559.1866-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