From patchwork Thu Mar 1 12:54:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 130208 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp2763853edc; Thu, 1 Mar 2018 04:59:41 -0800 (PST) X-Google-Smtp-Source: AG47ELt5OvSgt6fv81++ZScAOedAiWda0xwVG88lrpOGP5XOqrqMNCuRfnz5HELN/+xM/i9QlkoA X-Received: by 10.98.254.6 with SMTP id z6mr1840603pfh.155.1519909181467; Thu, 01 Mar 2018 04:59:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519909181; cv=none; d=google.com; s=arc-20160816; b=u8suQdCaoTbwG3FgV2vT3t6/0bco1jYfBdalSmMU7Tz9iSgfAZaHnc+WMPn5x67lpz kRAFCaHNs0dNxBDaU1pFcW5N7V5tsqJgWAhWEZNw6up3dFuOb8qbhj+ihIXOjPALlMBo cgUVfJJ/k4gZQ4uM/QBE9YkHqx6vVx3DFf7gs+P8AT9mCdwCWcFQ13YnMwp2jznHOrDi IAZS2CLdkXQ5Axsb/ObK2h6CgRRWHUJfQfYYm5tW+6UXUb3YAQGIxzXKi7jV6xxb4RTV upjsZxmthAyTUlciLLmzvUldsj4ITOBIbQciLGeQa7/B8vbPw+f1faXFUzn4UMS/Yb7y aasA== 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 h9si2989351pfk.72.2018.03.01.04.59.41; Thu, 01 Mar 2018 04:59:41 -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 S1031018AbeCAM7g (ORCPT + 28 others); Thu, 1 Mar 2018 07:59:36 -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(+) -- 2.7.4 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; }