Received: by 10.223.176.5 with SMTP id f5csp2644455wra; Thu, 1 Feb 2018 03:53:43 -0800 (PST) X-Google-Smtp-Source: AH8x225a0ZZSzdv2zPbsWaOyXeBAjnrDr87qoSUI4IIkcVPXp6hS1ptEUB4mFXwsMhh7yr5At+9Q X-Received: by 2002:a17:902:a5c5:: with SMTP id t5-v6mr10471922plq.160.1517486023197; Thu, 01 Feb 2018 03:53:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517486023; cv=none; d=google.com; s=arc-20160816; b=nN9g6loRzX7QXJDceOZ+8Bij/4gLMWgtlYFRSJVBkfYh/8USL15AOKFZ6rRqr7MocB 77Fo8dehkFpAWBu0pW2Tz3meFMyJebiELOsKlPGMMDAKdo+pIxgv0VWXesFXFyk8WT+O iOds0U8IsknqnfoHtx6IQ9B5GyWge97Y961Qcvi+A3cT043pFt6uIzVlSKHEEgy8nnhX lzP6KNzCzmNHS2PBkNeKHpJoI3YZzXtosurE/CfGROW4a8Bqb444dQ+vwnirfUzQ130G 4fn5t40OZvOLYq3EP0fexmrIfRSZC4K5GN9kuhe8AH/p/TWOZKYYhvfT+S//vhmqaaaT yp5w== 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=2zkl9JaOREtsO0w5hKffgT+hbO9nrKmvXiGJHmm/eM0=; b=jZ2nywim4lTx2fkZEQMNEDlb1xrG66jeuAiGVwGhXLUZm7mrHbb9MN68KIhTuBhd4f OSOV1NjCyjqjWNGVHXkp8ET6TAG7N9LSBKmcIUq4cXtqtx+PVqkeYRpX4zWMhCD1FxgL yweud4euKUsOJGels7H3PXl9EP54oCXyp08xyh9OBJ/k3yCuIo4moPtPwwN1qlaPaf9G GDjWUxoVInUjLixObvyoFs+Oe1H+VNpYr8SI8F/dkBUBtxzYD8aOC6y5bbnZQJbGkhHe +pv8XIEizTAn+H0Ik7nWj8BPbF2c+SXIkoORMd0nV0xAfl/gxFjstg509UtitrRDBGJy FXMQ== 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 m70si3980625pfk.201.2018.02.01.03.53.28; Thu, 01 Feb 2018 03:53:43 -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 S1752434AbeBALrw (ORCPT + 99 others); Thu, 1 Feb 2018 06:47:52 -0500 Received: from foss.arm.com ([217.140.101.70]:48330 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752402AbeBALrq (ORCPT ); Thu, 1 Feb 2018 06:47:46 -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 BCAAB15BE; Thu, 1 Feb 2018 03:47:45 -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 F37973F25C; Thu, 1 Feb 2018 03:47:42 -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 03/18] arm64: KVM: Increment PC after handling an SMC trap Date: Thu, 1 Feb 2018 11:46:42 +0000 Message-Id: <20180201114657.7323-4-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 When handling an SMC trap, the "preferred return address" is set to that of the SMC, and not the next PC (which is a departure from the behaviour of an SMC that isn't trapped). Increment PC in the handler, as the guest is otherwise forever stuck... Cc: stable@vger.kernel.org Fixes: acfb3b883f6d ("arm64: KVM: Fix SMCCC handling of unimplemented SMC/HVC calls") Signed-off-by: Marc Zyngier --- arch/arm64/kvm/handle_exit.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c index 520b0dad3c62..5493bbefbd0d 100644 --- a/arch/arm64/kvm/handle_exit.c +++ b/arch/arm64/kvm/handle_exit.c @@ -62,7 +62,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) { + /* + * "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