From patchwork Wed Apr 7 14:48:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 12188615 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04696C433ED for ; Wed, 7 Apr 2021 14:52:09 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 93C5961369 for ; Wed, 7 Apr 2021 14:52:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 93C5961369 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc: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=8Y/dRYLgij1z/AaNC1EqIKiDTs778U3j/Qd3vrJXYYM=; b=TfY4lBmRUk6HLMPgBx7POrANS4 RtgR57IzVbOQr7pbivQpR7t3279i1VTOnD/rq/0iy/vcCuV5hKsp+O9QM7v/GHm/6KOkEdn17lRpf bOKCmQ5/q0W4u9jHDt9rTlq9zXklyIJ9fe+OS39NklrS+4QAjdQfalMbkksJKvs4c5TRFp2UmVh+E 4dSpyLxQP9idhdjQobk8IpUo73YGZvky0orgbyxpxrqVQwsKK91CTNxbOZo1qpQZ7G0Du0K33OMx+ I+E9/O1mHm8QvMPy14yT5RmgUT63yzSWtrgcjC2gLY6RHZoUnxIy2xH6RGl0VyGmF52dl2kzE/7Oy oMdejhzQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lU9Uw-005C4y-L6; Wed, 07 Apr 2021 14:49:38 +0000 Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lU9U7-005C0E-MY for linux-arm-kernel@lists.infradead.org; Wed, 07 Apr 2021 14:49:12 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B6E4F1424; Wed, 7 Apr 2021 07:48:40 -0700 (PDT) Received: from monolith.localdoman (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BE6743F792; Wed, 7 Apr 2021 07:48:39 -0700 (PDT) From: Alexandru Elisei To: maz@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu Cc: james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com Subject: [PATCH v3 0/2] KVM: arm64: Debug fixes Date: Wed, 7 Apr 2021 15:48:55 +0100 Message-Id: <20210407144857.199746-1-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210407_154905_408218_25CD1805 X-CRM114-Status: GOOD ( 10.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org v2 can be found at [1]. Patch #1 in this series is new. Tested on an odroid-c4 with VHE. vcpu->arch.mdcr_el2 is calculated to be 0x84e66. Without this patch, reading MDCR_EL2 after the first vcpu_load() in kvm_arch_vcpu_ioctl_run() returns 0, subsequent reads return 0xe66 (FEAT_TFF and FEAT_SPE are not implemented by the PE). With this patch, all reads, including the first time the VCPU is run, return 0xe66. Also tested on the odroid-c4 board with a host compiled with CONFIG_DEBUG_PREEMPT=y by running 2 VMs in parallel, saw no errors in dmesg. Changes in v3: * Patch #1 ("Documentation: KVM: Document KVM_GUESTDBG_USE_HW control flag for arm64") is new. * Rebased on top of v5.12-rc6. * kvm_arm_setup_mdcr_el2() uses __this_cpu_read() to read the host's MDCR_EL2 value and kvm_arm_vcpu_init_debug() calls it with preemption disabled. * Rewrote the condition for setting MDCR_EL2.TDA with the intention to make it clearer (to be decided if that's indeed the case). Changes in v2: * Moved kvm_arm_vcpu_init_debug() earlier in kvm_vcpu_first_run_init() so vcpu->arch.mdcr_el2 is calculated even if kvm_vgic_map_resources() fails. * Added comment to kvm_arm_setup_mdcr_el2 to explain what testing vcpu->guest_debug means. v1 can be found at [2]. [1] https://www.spinics.net/lists/kvm-arm/msg45999.html [2] https://www.spinics.net/lists/kvm-arm/msg42959.html Alexandru Elisei (2): Documentation: KVM: Document KVM_GUESTDBG_USE_HW control flag for arm64 KVM: arm64: Initialize VCPU mdcr_el2 before loading it Documentation/virt/kvm/api.rst | 3 +- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/arm.c | 2 + arch/arm64/kvm/debug.c | 88 +++++++++++++++++++++---------- 4 files changed, 65 insertions(+), 29 deletions(-)