Received: by 10.223.185.116 with SMTP id b49csp7394750wrg; Thu, 1 Mar 2018 05:00:47 -0800 (PST) X-Google-Smtp-Source: AG47ELvQ7dm+aDkLC/XT35aa8UeEL/dD0bajSaNI37TOQzaxvwQ8M1Q2f6KAxlRQYi71ovq6sbXZ X-Received: by 10.101.93.138 with SMTP id f10mr1454080pgt.255.1519909247274; Thu, 01 Mar 2018 05:00:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519909247; cv=none; d=google.com; s=arc-20160816; b=Nb6RKzCihBZx+3oBA49vTHTsWIfa/K4Q7fZssanskZnzblirG6M5luO3P/Oz4iz2hX aDkx4sMNsa67UYgG6j6hWS744hYn9B5S2l0R3wnYXbwnafspohJmlhcQGzQDxrpFghHq 4vIQ5ERLMjNYXSeWL0MCHtUf7CommxyCebDcrbJJ6NjQK5ew5dl9xJIUZ/IQ6MnrctyX NhrD7F4OmvaCtzS3ew0gk5FcPvyR/v/24pcl+PWXOmJZqvz8eGEzLQopm0gYIItvRd/3 7wAWa4ISQ3Jcc2px7MpWR28AJBeKo7hsmiLzUES4jKVVovPyuOdB76I2wXaYZqBrnMXT asKA== 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:dkim-signature:arc-authentication-results; bh=/nksGLZqHQjfpQbfH68HEgt65Nc6WZIfEk50r4t0UeE=; b=uGPrWzpsJFlLydUzbO28SteicmnRjqkROwbS1sK2u5vjfkIADMAM74jNzqHAMcpzYc +y2iPZ52DfAdv67rUemi+ppIJvQ8Jx4KdtsNofu7GaqHfKADNaKkRcnEOeftq9L38dfm tOD0su1w8pPWZR+lWS1JYX13dbXAIfVDY8JTFMmp/aiOTrYpeFHCB6c6Bs9whr6SETfv EiI5Bzkm0rj05yKv0WqYQr/9epMrqIpiOXNfn3eqQh4WsMJ7BKITMYlU5qFbsPdHBphu H3GM8ZRLRRZAK1lhNzoROFMMgx+o6vdKjGQhLDopHu9Dh2BjI2Dz+u8M/YSXtbaSlA9k 7B4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KX26itFa; 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 f10si2446336pgr.574.2018.03.01.05.00.31; Thu, 01 Mar 2018 05:00:46 -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=KX26itFa; 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 S1031013AbeCAM7f (ORCPT + 99 others); Thu, 1 Mar 2018 07:59:35 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:46325 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030881AbeCAM72 (ORCPT ); Thu, 1 Mar 2018 07:59:28 -0500 Received: by mail-pf0-f196.google.com with SMTP id z10so2394319pfh.13 for ; Thu, 01 Mar 2018 04:59:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/nksGLZqHQjfpQbfH68HEgt65Nc6WZIfEk50r4t0UeE=; b=KX26itFa6TWDAtd8NB+rYrugNbEWlF+pHs/zXVAPusKcpCZ1Yu/dj9IDJ0aaYxZZe9 cbh5KbeIX3EMOicPzUJD+vVsN8abRaPgSgXf8EH34CGpffQ5XmnVOWCzgqITfqvMGc8N wMMw5oF1PWtUflxwo4lMbqjXw14s/8YtGrJkQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/nksGLZqHQjfpQbfH68HEgt65Nc6WZIfEk50r4t0UeE=; b=kLqVex8XCkz4uPUO09IwbTNC2WcWSFLQJldcDSh+3DMJC5FHHLrg7UOaueX/Q7hp75 m9rFUkY62xv5L74/vVMggbFnmIBcOHfKcj1fRm5jXc/5Nt+de9NgNTKheChsjwpXbZr8 C2KLld95K16+umjHMV1mPjrlCbYEgxIq79N6MlfM2HK67ftBQNf+oa2Bxs+utQX1xPh6 JvMq8LTM0oC0FLFAWg8TLn/kG4FRJICqk1mxX8GRaKx1qLV7rtJJiBR5NLIyMMjjL2l9 EhGA+a1jErOQbxTIeDfARfBStL13Zywf4MjAMj3X9V4KiITmZglDy9viUSxwm+VDuI2d iM+Q== X-Gm-Message-State: APf1xPB5dUylVwwJSTQuDtZbibEJlgIgGZupBwD1DbOl59dnIENgVqDR BeClXe7j59q6WmOPEcvVFJvdAg== X-Received: by 10.99.117.24 with SMTP id q24mr1474368pgc.53.1519909168143; Thu, 01 Mar 2018 04:59:28 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id x4sm2289655pfb.46.2018.03.01.04.59.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Mar 2018 04:59:27 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alex Shi Subject: [PATCH 30/45] arm64: KVM: Increment PC after handling an SMC trap Date: Thu, 1 Mar 2018 20:54:07 +0800 Message-Id: <1519908862-11425-31-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519908862-11425-1-git-send-email-alex.shi@linaro.org> References: <1519908862-11425-1-git-send-email-alex.shi@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Zyngier commit f5115e8869e1 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: Will Deacon Signed-off-by: Alex Shi --- 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 2e6e9e9..5b56b09 100644 --- 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 *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.7.4