Received: by 10.223.176.5 with SMTP id f5csp380059wra; Wed, 7 Feb 2018 00:34:27 -0800 (PST) X-Google-Smtp-Source: AH8x226ZmbjvEZmp8+x6JMcjPEVb3qEbsYBXqR1lK5uhUIFVCbV+z2gAxzd0EePI7xD4m2lhk+uX X-Received: by 10.99.53.193 with SMTP id c184mr3041819pga.180.1517992467016; Wed, 07 Feb 2018 00:34:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517992466; cv=none; d=google.com; s=arc-20160816; b=qukXQ3H+A87Vw8Y2DVFbSjHsOnzBt5PT+TzgLAdfXtSPG5VoAr63Z8nUC1P+ykrwb/ pXs4SRbDT7EysiWWUyfv2B++l04tUpxepSlaPv3UcA9JOlEse7J74wPPbD1AWbvXF/pq ZighycjkROEfghGQKKiJI88cL2rQwbh7f9GcdLI592e8v3/jP03HUwvcuI8dcuggJG7M 2qxT6hTSjdiZUXKnShJRWefZckcuxBr345pkbk52qPU4eeehLaJcao9DKN4SUSS9Q+Go gvjN/F9mYOoXcc2MbYywLirK3Yak6ByZby7vKKiGtPXBwjsIf+gahZvQmCQpZxxYXQhY Zc4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=7EwLQGes7RNryf5A7y2NFe/9FGspZgHW+INW2trKyTM=; b=R7A5iVadyB8TatGJNcUtK6VaopGBUQQhdf/V8sLIUcVeTzV2ivrEX36mB9X+KdBbeo bKA8MXlBMyLZjjkrTy3KYMIWmJGcE4qHP2o39qI1BBryhVF3R/GKMyGIjCj27qP339lz GCp9j3sfY0RHdPNpSFwHmGuHwhph96t5Jr3YD8Uznjw/FQ2lYCcqod7P2evjX2EYNnVh Sy+l6w/UdQ0yHFDQEvmhLN5IOuoxLDo5sHne0h7q3AQGxw1icYRywkw8qJ1Q28llVu3u OLPTNqF/KMGQl7jIaU3FPayLvOhdv+mnxS8QdhulcBUU5YA6VcMXdeO2c403I31Fe8dD VI5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OLetfwe9; 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; 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 3-v6si716299ple.769.2018.02.07.00.34.12; Wed, 07 Feb 2018 00:34:26 -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; dkim=pass header.i=@linaro.org header.s=google header.b=OLetfwe9; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753356AbeBGIcz (ORCPT + 99 others); Wed, 7 Feb 2018 03:32:55 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:50792 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750815AbeBGIcy (ORCPT ); Wed, 7 Feb 2018 03:32:54 -0500 Received: by mail-wm0-f65.google.com with SMTP id f71so1508547wmf.0 for ; Wed, 07 Feb 2018 00:32:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=7EwLQGes7RNryf5A7y2NFe/9FGspZgHW+INW2trKyTM=; b=OLetfwe9wvQPvhYYc67I50apc23eCkjdeU5XEa0dvIiunhiDR3mLT0Gv+YYMaZUaom h7BJ0sRzFEy4ejXGLpI69s1Ya56mujW20UCU0pHQ3n0vDAp3bC/+r8PVgd3jatymIMN6 lzlGtreLrs52riD764ekjcxSem3B/ktC8Qa3Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=7EwLQGes7RNryf5A7y2NFe/9FGspZgHW+INW2trKyTM=; b=Z0xoti1o3TrAymRfxqpMiZsPIAx7DI/qGrvx1amK1qeR1k42CUUfVvoWv3jMeeV5eV sEFyk0uJeFnEa1k08Tr1uKmjwDcjijCiW2q/1xwQ52nE0tzF+bdlfG4Eq8ncT6t9BXg2 KUiCyhTjhEmW23q739oJnQXyVVaAsaphqN7TWP3Cxm1XS6ruWc7ypLxNcgV/jhU1pKDO JZclw8B1p3nqbDXBccDnFUM66/I8hAiqG6CgH6SoKIj2KWDQnG7L4mmg8Adecd/jpvzA dCxkZS4TgsgUHkkhk0XS4PQbyC7oAf4WL/TGqE5mSfPQ04/PDOdFXFJS2XB/2pFkOMqj 9zEg== X-Gm-Message-State: APf1xPBbdA/hKRaweZhfTYdTDKnP5lkiJwRuBsYSX8qos2r9jmTi9e1J 9bhufGACvBEXwMl6MgZw3hbbqg== X-Received: by 10.80.140.248 with SMTP id r53mr7232401edr.306.1517992373434; Wed, 07 Feb 2018 00:32:53 -0800 (PST) Received: from localhost (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id 15sm920862eds.54.2018.02.07.00.32.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Feb 2018 00:32:52 -0800 (PST) Date: Wed, 7 Feb 2018 09:32:51 +0100 From: Christoffer Dall To: Marc Zyngier Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, Catalin Marinas , Will Deacon , Peter Maydell , Lorenzo Pieralisi , Mark Rutland , Robin Murphy , Ard Biesheuvel , Andrew Jones , Hanjun Guo , Jayachandran C , Jon Masters , Russell King - ARM Linux Subject: Re: [PATCH v4 02/17] arm: KVM: Fix SMCCC handling of unimplemented SMC/HVC calls Message-ID: <20180207083251.GB29286@cbox> References: <20180206175621.929-1-marc.zyngier@arm.com> <20180206175621.929-3-marc.zyngier@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180206175621.929-3-marc.zyngier@arm.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 06, 2018 at 05:56:06PM +0000, Marc Zyngier wrote: > 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. Apparently I forgot to review this: Reviewed-by: Christoffer Dall > > Cc: > Tested-by: Ard Biesheuvel > Signed-off-by: Marc Zyngier > --- > arch/arm/kvm/handle_exit.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/arch/arm/kvm/handle_exit.c b/arch/arm/kvm/handle_exit.c > index cf8bf6bf87c4..a4bf0f6f024a 100644 > --- a/arch/arm/kvm/handle_exit.c > +++ b/arch/arm/kvm/handle_exit.c > @@ -38,7 +38,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; > } > > @@ -47,7 +47,16 @@ 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); > + /* > + * "If an SMC instruction executed at Non-secure EL1 is > + * trapped to EL2 because HCR_EL2.TSC is 1, the exception is a > + * Trap exception, not a Secure Monitor Call exception [...]" > + * > + * We need to advance the PC after the trap, as it would > + * otherwise return to the same address... > + */ > + vcpu_set_reg(vcpu, 0, ~0UL); > + kvm_skip_instr(vcpu, kvm_vcpu_trap_il_is32bit(vcpu)); > return 1; > } > > -- > 2.14.2 >