Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3376371imu; Wed, 7 Nov 2018 09:21:52 -0800 (PST) X-Google-Smtp-Source: AJdET5dYtYwCBBos7fStkZ08C+7yhiFapDs6DcZZXMwz26IlpgfdUYVGgQQO/1rLs7/Q33DmxeUl X-Received: by 2002:a63:160d:: with SMTP id w13mr915260pgl.43.1541611312846; Wed, 07 Nov 2018 09:21:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541611312; cv=none; d=google.com; s=arc-20160816; b=w6uwVHnEGbZn2LCEs6GAsH9+jlYsGxP7R7gW89XBIceBSRGJcFqf+kMvoWLzlR6aD0 9xXWqk6lYSp1zB24B9f2Jr3cdztpsFL6IKeaMrJiVENscTRIcOEA76gnWtvKiSyPTPe2 YZy09nWKR6jG8YrgZC6zFQ9c6/QEBVpodUU4TDTPxxv4oGL+uSP5l8yq23qhHUdWG4Np 0qV6xT/QXTY1GiuLofxSKoH7GKyTU14ebi/pMw7ZS6YpH2sRRcjMxDrErFtJg58KxXEY c6zYzxmMaSn6BE4zIOpWxnC1domifnwIPKnS/fdsVJO2P8+BJ9+15r/fkdbJ0od7wiMr dY0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=i8+JfBqciwD8GJJaemPhXLLH8tzVj+bkFbbGCffDHJ8=; b=ZMQnM4zDCUnmqrlfx2+VtDa9cKg2qfb4JSjhaDuJJQ2GtkDQ7LZvZWYbfsnL3sBxDH L85nm/wMtWFm077ududTKGiujPqfQgmBL8wjQeq925LsICUW7GN3Xkc0KQP7itYGK2Fw /pAzpoOiLHGnLPCL/IkTXCLByUko9fzT6yE6WhgHW2tQCGHO1iosZS5968uDy/TI/BDB l80Sstr6dlBEZvC0LjeFBmW81OwiC/7hXF5u9NB6Y4HcmrB7xZTm7dQqLAvdITVAFpKA yCsyG2gUO1zJcIu5Z/g+0Cj47F6n38a0IhxWMAAk3kp0DZJdvhmPoS0cfEY4JvR9GZ68 UArg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="C7/iH/Kw"; 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 b12-v6si1163143plr.175.2018.11.07.09.21.36; Wed, 07 Nov 2018 09:21:52 -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="C7/iH/Kw"; 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 S1728106AbeKHCwC (ORCPT + 99 others); Wed, 7 Nov 2018 21:52:02 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:37977 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727576AbeKHCwC (ORCPT ); Wed, 7 Nov 2018 21:52:02 -0500 Received: by mail-wr1-f66.google.com with SMTP id d10-v6so18266089wrs.5 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=r3E9mJe5GHCB8PKmQeVDqep4TvTPuI5d+QjF0fcRKBvLxEj72fmbtSHBrWbfE+m9/C N08mCquaQ3P5GSdq7Yj8/zqvCzsRKlmzj3Zly8bd77kIoq3ln4zOqrIE0lMrU3aSNN9P JAsyREDncZHqioSafE9E4hMEaSovojMzzMNtCxXZG6EGp5m6OlcyGQB9wkstme6Ty+LE Bbjc8i/e2c5qMCVKNnUAXI1ZGwp5uIyb2zCiqC9bW2QKmKlmn4ZlykRGFI5e0X8QtHAe 8s+6YwAWrJhLoqqIT/0d446ulSWMzxiwsOOy9HoL5nqG/UWUMyYphUTsmH1msgfN6O3G TYaw== X-Gm-Message-State: AGRZ1gK/MFhf2iFqGIMA3NWOzaddpPL9QbhZ7dq+otFvkSwpyh595RZ+ mxmVH3f2hdCZXQyz3IAKlcQDTw== 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=20Benn=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=20Benn=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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.17.1