From patchwork Wed Mar 27 07:55:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Du X-Patchwork-Id: 13605848 Received: from zg8tmtu5ljg5lje1ms4xmtka.icoremail.net (zg8tmtu5ljg5lje1ms4xmtka.icoremail.net [159.89.151.119]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DE0B42C862 for ; Wed, 27 Mar 2024 07:59:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.89.151.119 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711526384; cv=none; b=NoVeJYnxANz7X7oIbK3QDuaG3DiEqQ0bkssa9ajPqQyR0RVSAb4pF8Sooh8xcapVx6zGmQWOuDJpqanPkSPvY1LnyzyHay1gZJWC1WKzDVEENobCqSnkFb7r7FHaxzK8BtYCLleqyhHkbBINjHfRn+/7Kj9mxlmY6tNbzOYm+Mc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711526384; c=relaxed/simple; bh=xDQhIil/nsFCOoC/0bSgfNr7zHH3INIDPe39EthX3sM=; h=From:To:Subject:Date:Message-Id; b=L3D1XXd9ajoSx1s2uxiMuwPv22w5rvWIfjEbTu5l+HP+qCTm3fEAEzX3GEiOKxvEn2SwgBfjScDboY0bRGGk/1lTYdx+mzUoN28B5vRF/0oJrNvKG0tcOwdfGcMcUWLZBc9cVNcs/dxZqCrt0MHZu7QmMfdSFqPNQNWNZ39Sspg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=eswincomputing.com; spf=pass smtp.mailfrom=eswincomputing.com; arc=none smtp.client-ip=159.89.151.119 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=eswincomputing.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=eswincomputing.com Received: from localhost.localdomain (unknown [10.12.130.31]) by app1 (Coremail) with SMTP id TAJkCgBn++KS0QNmzA4DAA--.6945S4; Wed, 27 Mar 2024 15:58:11 +0800 (CST) From: Chao Du To: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, anup@brainfault.org, atishp@atishpatra.org, pbonzini@redhat.com, shuah@kernel.org, dbarboza@ventanamicro.com, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, haibo1.xu@intel.com, duchao713@qq.com Subject: [PATCH v3 0/3] RISC-V: KVM: Guest Debug Support - Software Breakpoint Part Date: Wed, 27 Mar 2024 07:55:23 +0000 Message-Id: <20240327075526.31855-1-duchao@eswincomputing.com> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: TAJkCgBn++KS0QNmzA4DAA--.6945S4 X-Coremail-Antispam: 1UD129KBjvJXoWxJr1xJr48Gw1rAFyrWrW7Arb_yoW8tw17pF WrGr909rZ3Xr1fGayfCFnF9r4fXrs5ur4fWw1fW3y3Zw4jkFyFyrs2grWYyr98CrykWFyS y3Z2g3Wkua4UJ37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvIb7Iv0xC_Kw4lb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwV C2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC 0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr 1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4IIrI8v6xkF7I0E8cxan2IY 04v7MxkIecxEwVCm-wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s 026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_ Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20x vEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE 14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf 9x07beAp5UUUUU= X-CM-SenderInfo: xgxfxt3r6h245lqf0zpsxwx03jof0z/ Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: This series implements the "KVM Guset Debug" feature on RISC-V. This is an existing feature which is already supported by some other arches. It allows us to debug a RISC-V KVM guest from GDB in host side. As the first stage, the software breakpoints (ebreak instruction) is implemented. HW breakpoints support will come later after a synthetically consideration with the SBI debug trigger extension. A selftest case was added in this series. Manual test was done on QEMU RISC-V hypervisor emulator. (add '-s' to enable the gdbserver in QEMU) This series is based on Linux 6.9-rc1 and also available at: https://github.com/Du-Chao/kvm-riscv/tree/guest_debug_sw_v3_6.9-rc1 The matched QEMU is available at: https://github.com/Du-Chao/qemu/tree/riscv_gd_sw Changes from v2->v3: - Rebased on Linux 6.9-rc1. - Use BIT() in the macro definition. - set/clear the bit EXC_BREAKPOINT explicitly. - change the testcase name to ebreak_test. - test the scenario without GUEST_DEBUG. vm_install_exception_handler() is used thanks to Haibo's patch. Changes from v1->v2: - Rebased on Linux 6.8-rc6. - Maintain a hedeleg in "struct kvm_vcpu_config" for each VCPU. - Update the HEDELEG csr in kvm_arch_vcpu_load(). Changes from RFC->v1: - Rebased on Linux 6.8-rc2. - Merge PATCH1 and PATCH2 into one patch. - kselftest case added. v2 link: https://lore.kernel.org/kvm/20240301013545.10403-1-duchao@eswincomputing.com v1 link: https://lore.kernel.org/kvm/20240206074931.22930-1-duchao@eswincomputing.com RFC link: https://lore.kernel.org/kvm/20231221095002.7404-1-duchao@eswincomputing.com Chao Du (3): RISC-V: KVM: Implement kvm_arch_vcpu_ioctl_set_guest_debug() RISC-V: KVM: Handle breakpoint exits for VCPU RISC-V: KVM: selftests: Add ebreak test support arch/riscv/include/asm/kvm_host.h | 12 +++ arch/riscv/kvm/main.c | 18 +--- arch/riscv/kvm/vcpu.c | 16 +++- arch/riscv/kvm/vcpu_exit.c | 4 + arch/riscv/kvm/vm.c | 1 + tools/testing/selftests/kvm/Makefile | 1 + .../testing/selftests/kvm/riscv/ebreak_test.c | 84 +++++++++++++++++++ 7 files changed, 118 insertions(+), 18 deletions(-) create mode 100644 tools/testing/selftests/kvm/riscv/ebreak_test.c --- 2.17.1