Received: by 10.192.165.156 with SMTP id m28csp234467imm; Tue, 17 Apr 2018 09:15:04 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+I/eXcSIZjiq/lFPJQ87J/eT4aUCnsId67aufsArSsI1t4tV9+itR/RiTHd3cLyTtVSVjx X-Received: by 10.98.201.15 with SMTP id k15mr2551943pfg.184.1523981704440; Tue, 17 Apr 2018 09:15:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523981704; cv=none; d=google.com; s=arc-20160816; b=dod7PCTPGdzwYCi+tDSpSGPcybi2bDi/LntmLgOyAV4fetRfjXRFnun9v1ywq9YqLP IwEkCIVn/0Zb3j6eI0TrjDtBOZ+XxEdo6OLiuLbLPeh8D82JNDeTy4uyaZLYcxB8yptE NtHFKknnfVIQODcZ8NF1tihzndCe2L7RSf/Bw803ZavMqLozhqsrOgFkhjy3gmLIDTdD ZgiPbuER6jTD67e0xBCtxOxP/PWDkS87Qd+9mDy9qVdRceEdb9ALtkSp2gYK8gqAlBc2 kOsmXCGOt1v9ZV5HtMtFmqWciSm0ej+N3GeEy/qIB2troFhu4ugyW5wgMVucJA0tMrRn B46A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=MJwLEdunmvtdW2UYhOHrrzQumAxVn104jvmAxgfUyMM=; b=Yq/Uq/eJ4+p+kqrV+RsY1F98IUSnHgbhkNO7f2cBopMspjT/LEwudFyDwpNI36e6AB umgH24+CXnPw7ekzrZtIYbbd7yyCZRwhP53HtU8xicCI0TofBWiTbV5isDbgp+iVC4jP UQB7WrccuvHGy2zUdadY9HnhEXXe5UsW9f9IIbO3tVUQe+zS8yG5T2gQdXTKDHrIfgpa q1oGfE/p3O8bt4OxESw/v0wu/1o/RosfVR1PzZd3rP6H0sOk4rV6nyJCu/M0e5s48+rZ rKaKwRoQar8FvTuxGnONfDD9uZ5FPqk/0WqBIigS04itymRZ+k3+rBJJ5r+BBKI1Tiav GjKA== 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 33-v6si14717620plk.37.2018.04.17.09.14.50; Tue, 17 Apr 2018 09:15:04 -0700 (PDT) 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 S1755954AbeDQQLA (ORCPT + 99 others); Tue, 17 Apr 2018 12:11:00 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36554 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755944AbeDQQKz (ORCPT ); Tue, 17 Apr 2018 12:10:55 -0400 Received: from localhost (unknown [46.44.180.42]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 93876D6A; Tue, 17 Apr 2018 16:10:54 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Christoffer Dall , Ard Biesheuvel , Marc Zyngier , Catalin Marinas , Greg Hackmann , Mark Rutland Subject: [PATCH 4.9 35/66] arm64: KVM: Increment PC after handling an SMC trap Date: Tue, 17 Apr 2018 17:59:08 +0200 Message-Id: <20180417155647.391743183@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180417155645.868055442@linuxfoundation.org> References: <20180417155645.868055442@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mark Rutland From: Marc Zyngier commit f5115e8869e1dfafac0e414b4f1664f3a84a4683 upstream. 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") Reviewed-by: Christoffer Dall Tested-by: Ard Biesheuvel Signed-off-by: Marc Zyngier Signed-off-by: Catalin Marinas Signed-off-by: Mark Rutland [v4.9 backport] Tested-by: Greg Hackmann Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kvm/handle_exit.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/arch/arm64/kvm/handle_exit.c +++ b/arch/arm64/kvm/handle_exit.c @@ -53,7 +53,16 @@ static int handle_hvc(struct kvm_vcpu *v 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; }