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: 10672705 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 65B7613BF for ; Wed, 7 Nov 2018 17:21:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 550022C96E for ; Wed, 7 Nov 2018 17:21:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 468332C971; Wed, 7 Nov 2018 17:21:05 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EB5E32C96E for ; Wed, 7 Nov 2018 17:21:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=TbGSNTKqiCuosgUElqVYg+MlMT3KhwFC1r34a2rCnI0=; b=PTznKZZdzUxGBN JIXhl1eRLyyOZE5iJrhBlKzMvxdqejX3X1pBAE4T38uhS8lsEPHjmZjGVSY1tiZKAzIPr1rZnvazI kQQeM6+b6dUE9dhonsUgLSN2Wc10OO5mSyrA8IuyoFDPlshbvifrqqoYPpYaCBN2nyY01g5g9l/z9 51XPVdGognGJQsEo3pSHF4SsmssFybsOery9cSv5EsihkCNs8xg3QjUxZxU7magz+IzqgOFE49Nmp ghTciVirP29nKnw4KtxHl7ZHyeJkV3UQ5jKE5/K0gejxt8lWuNfv3uBMKygETO0zdNVZqfFB4HR7L RfdgFpkj674P/r7R6fKg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gKRVg-0001ZM-VA; Wed, 07 Nov 2018 17:20:56 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gKRVd-0001Z0-Lp for linux-arm-kernel@lists.infradead.org; Wed, 07 Nov 2018 17:20:55 +0000 Received: by mail-wr1-x442.google.com with SMTP id z16-v6so18274815wrv.2 for ; Wed, 07 Nov 2018 09:20:43 -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=N1m14qW9WdtJov9gQM70Pt20+K0w3vp1QrUAJ6UvEwuLl8Hn5LQZWO9QySWwYSrm5w e2Z+01K4f86xylY+eQojm0Jx4/ANtBkIcQ33CX3sFqzqsWX/rlrhd7kg63uG/Ogf+YMc Nw9QTQDCz6Xus24StoDgHtBofHPYqk2E5XSkgq5VOK3taN/SKbuAbN++vDPatjx3BLp2 Ww0f1qArTvcQyO5q4Vx7otrFvPbtWVcpD/PG2Jilacr4RGsBYle74NBmBhPDu/xTy/vx CAo9TSblEsNSvWxNF8Q+61ABfrqPJS+v6wElU4BY8UEKDYoKj5SAk9wCTN5G4AJnxQA4 5WxA== X-Gm-Message-State: AGRZ1gLqhrugPOHBYUD3CP3grmRO3xeeqhR71JJ4qLfqNDkg+ywMFUSE jHR/zKUc8qw6OU+hwgYYmqZGwQ== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181107_092053_710399_131A0D87 X-CRM114-Status: GOOD ( 12.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Catalin Marinas , =?utf-8?q?Alex_Benn=C3=A9e?= , Christoffer Dall , Will Deacon , open list Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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;