From patchwork Wed Nov 7 17:10:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 10672703 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A2D913BF for ; Wed, 7 Nov 2018 17:20:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1D942C6F3 for ; Wed, 7 Nov 2018 17:20:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E39832C96E; Wed, 7 Nov 2018 17:20:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 911032C6F3 for ; Wed, 7 Nov 2018 17:20:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731092AbeKHCwE (ORCPT ); Wed, 7 Nov 2018 21:52:04 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:45118 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727757AbeKHCwC (ORCPT ); Wed, 7 Nov 2018 21:52:02 -0500 Received: by mail-wr1-f67.google.com with SMTP id k15-v6so15277595wre.12 for ; Wed, 07 Nov 2018 09:20:42 -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:mime-version :content-transfer-encoding; bh=i8+JfBqciwD8GJJaemPhXLLH8tzVj+bkFbbGCffDHJ8=; b=C7/iH/KwIWFkISAxgpHdW0bL79VLXTsoWgNLxtXgX1T3GyQuK6ov0kvHJKH6qN/cuk Wk5wTi5N4QKr7NkyIVP9tzRIS9qNaxZrU4qHMTGZI4ukr8XpCjHYD2RhYEoxxj0cvmxz Gv9cuhDNdI3oTF+4giC4W3iypALUe/4QdRaVg= 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:mime-version :content-transfer-encoding; bh=i8+JfBqciwD8GJJaemPhXLLH8tzVj+bkFbbGCffDHJ8=; b=ZXlFnOeBxuZsAttsWCYdApy2dG/tsX4yokW2g/+Vj9L5l5I9zj4JvlJ5ZmS3LWpf4g Q4g1fznBCyMGGNwaOfbz/FaeKRXDtPOt96Gwc/8qcQiRJi0GwdiUwTvNqocqLN5jSOox rNeuRfGq8BB3ez8cPfivA7aB7Z0SUIOUlFw308BoAnsyKRpOGM5jYyFiM/k3pMAB6S8I EV6PzCe5JBLTmHffu7rwemQpvZFAKodYRM7yMQ6Nw9hr/jL3JSgGK89Y16dlqdURdFqU RUvZo4K2dG02hIFMKmbpAIOI0zc3VUX6tY6fAEwbmOcUGP6YWTJQhaw40scLkwDK4oIU KODA== X-Gm-Message-State: AGRZ1gIFpxVKWxjcgZ4lt9Yj4iO/g4tDwRufFJDJGfrSm8qF9aJFdZ6h VyJqXk5m3ORW4F5uEEHbqiu2Rm0vZHc= X-Google-Smtp-Source: AJdET5edausxG4gihMbeYFyds7I/t2o1q5sWWDXUs2P/s0Q5DCKG6DebkYD70WzHCnDBchEuOaQE2w== X-Received: by 2002:a05:6000:11cb:: with SMTP id i11mr1028706wrx.234.1541611241684; Wed, 07 Nov 2018 09:20:41 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id t77-v6sm2590772wme.18.2018.11.07.09.20.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 07 Nov 2018 09:20:40 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 583123E02D5; Wed, 7 Nov 2018 17:10:37 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org, marc.zyngier@arm.com Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Christoffer Dall , Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org (open list) Subject: [RFC PATCH] KVM: arm64: don't single-step for non-emulated faults Date: Wed, 7 Nov 2018 17:10:31 +0000 Message-Id: <20181107171031.22573-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Not all faults handled by handle_exit are instruction emulations. For example a ESR_ELx_EC_IABT will result in the page tables being updated but the instruction that triggered the fault hasn't actually executed yet. We use the simple heuristic of checking for a changed PC before seeing if kvm_arm_handle_step_debug wants to claim we stepped an instruction. Signed-off-by: Alex Bennée --- arch/arm64/kvm/handle_exit.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c index e5e741bfffe1..b8252e72f882 100644 --- a/arch/arm64/kvm/handle_exit.c +++ b/arch/arm64/kvm/handle_exit.c @@ -214,6 +214,7 @@ static exit_handle_fn kvm_get_exit_handler(struct kvm_vcpu *vcpu) static int handle_trap_exceptions(struct kvm_vcpu *vcpu, struct kvm_run *run) { int handled; + unsigned long old_pc = *vcpu_pc(vcpu); /* * See ARM ARM B1.14.1: "Hyp traps on instructions @@ -233,7 +234,8 @@ static int handle_trap_exceptions(struct kvm_vcpu *vcpu, struct kvm_run *run) * kvm_arm_handle_step_debug() sets the exit_reason on the kvm_run * structure if we need to return to userspace. */ - if (handled > 0 && kvm_arm_handle_step_debug(vcpu, run)) + if (handled > 0 && *vcpu_pc(vcpu) != old_pc && + kvm_arm_handle_step_debug(vcpu, run)) handled = 0; return handled;