From patchwork Fri Sep 9 04:46:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reiji Watanabe X-Patchwork-Id: 12971015 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7F90DECAAD5 for ; Fri, 9 Sep 2022 04:47:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: Mime-Version:Date: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=yci5p0pEE/PuJnftzy14ahj1DNUfwNjd+OPvGumbdgk=; b=Rbi AFGV2DwZYpH9zg7sRNDuIucF5NdFAmI2cx5IDntnVyN1+9+Pn/1REFn3A7izsXvT6C/CDoKlgBIxc DphxqiZzLzXePqFhB7TPJyuUOWMlmmIOcGbOzix5hh9q389jlRc2c7Mq0ovo+eC/FZN5s87f9BtSy v8ZPDalAADPRTLGp9/ZVCcF2BTlSlqiTJZG9dpOuDHtC8DUHuCgXR738WIMdGpd04q51Y0oZGaXFU Ni7jdnsRyP11/rEysdLN89Jz+wxDlhgHEll8Rc9ztpmKMsQ1ekcPH4vZttekS5DcVTNlNBoIcPlBH ZROeuwNoSDPMo5duhzFyoO/HC2rjGXA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oWVui-00CNrL-MH; Fri, 09 Sep 2022 04:46:48 +0000 Received: from mail-pl1-x64a.google.com ([2607:f8b0:4864:20::64a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oWVuf-00CNqf-UV for linux-arm-kernel@lists.infradead.org; Fri, 09 Sep 2022 04:46:47 +0000 Received: by mail-pl1-x64a.google.com with SMTP id b9-20020a170902d50900b0016f0342a417so571555plg.21 for ; Thu, 08 Sep 2022 21:46:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date; bh=QJB73MLDhafVA5mzk0y7NRG1yy1AsLNoloEV+fqwUaA=; b=IYHa6MwCs2cLrpdrnCoumxBXe9npI1GWJqBc7iHtrCKZGdhnamRw7ygg7mk67IFO0D CTL0FLaT9eObj1mrMFt9EryTVC8NUm+WsK2nG+L+xWJy6RrH6NGeAhl2DkdWJWiM/HKM BqRTFp2qkCawdUae1SBp+qy9ipxtkEOPUcwU0wjr3ilxXjXGeANeV3GbE2es41/wZlDP 0YlrUFK80JucWbwCSrMpX4K4tmUJxN4Zquvt9ecAylsdxe//KfHKhmyodN8wYOlgCJ8f 5HJyE1c/clPUjzMKSiRThQFUAOOt1leM62vSiTuvcF0Vm7eqxUndojfAZxjm14DQtJJV xoSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date; bh=QJB73MLDhafVA5mzk0y7NRG1yy1AsLNoloEV+fqwUaA=; b=IZVeSMVYCgcub/xSfSpNo+Zkl3VcLMyk0+XqXMsRiKgymDcguanB3xe6BPrVXKnRbu h8Nkt1Qpbipr8anQvCk1Ks84Rg6RctLjWqUFHyRoFid7RE9xJGrXkL63BMAQl9yg8KL/ Ew8BX6dhuw+fUd3A6DPCUpO+wSDTZFQkXZeA4NiLJRsZx3AIXqZ8ce0SR1M1MsritRV2 q0Wpglmm28R364Y3vfx5dgU+FdrtQU5Fp3/Gbdtd//+f7lkovisjdM9yJQDKsVmqETH1 r6CwPau89Sl1SAko5d5lbgflSHKxtf3yUhKUVRdrTfpkm5gsGvXt1hy4OpedP0Ik5Zrq hQAg== X-Gm-Message-State: ACgBeo29lHaW1L3EELl/P3VElBfLfF+Ugoo+uv9C7z3OE4I3P/CkDzb5 yJn79/fSE15PP7uJExCZVPtU2LitwvI= X-Google-Smtp-Source: AA6agR67XHqJPDelywKoy02FeiedN0d6WTuCg15FUtrlXR/yHe1DDpqixxtKRWyEF/Iu/+vIeepM+t92WtM= X-Received: from reijiw-west4.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:aa1]) (user=reijiw job=sendgmr) by 2002:a65:68c8:0:b0:438:744d:b340 with SMTP id k8-20020a6568c8000000b00438744db340mr3297212pgt.142.1662698803471; Thu, 08 Sep 2022 21:46:43 -0700 (PDT) Date: Thu, 8 Sep 2022 21:46:33 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.37.2.789.g6183377224-goog Message-ID: <20220909044636.1997755-1-reijiw@google.com> Subject: [PATCH 0/3] KVM: arm64: Fix a bug of single-step execution enabled by userspace From: Reiji Watanabe To: Marc Zyngier , kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, James Morse , Alexandru Elisei , Suzuki K Poulose , Paolo Bonzini , Ricardo Koller , Oliver Upton , Jing Zhang , Raghavendra Rao Anata , Reiji Watanabe X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220908_214646_023993_A10DB1CC X-CRM114-Status: GOOD ( 10.07 ) 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 Fix a bug that KVM could erroneously perform an extra single step execution (without returning to userspace) due to setting PSTATE.SS to 1 on every guest entry, when single-step execution is enabled for the vCPU by userspace. Add a test for KVM_GUESTDBG_SINGLESTEP to the debug-exception test to verify the single-step behavior. The series is based on 6.0-rc4. Reiji Watanabe (3): KVM: arm64: Don't set PSTATE.SS when Software Step state is Active-pending KVM: arm64: selftests: Refactor debug-exceptions to make it amenable to new test cases KVM: arm64: selftests: Add a test case for KVM_GUESTDBG_SINGLESTEP arch/arm64/include/asm/kvm_host.h | 3 + arch/arm64/kvm/debug.c | 19 ++- arch/arm64/kvm/guest.c | 1 + arch/arm64/kvm/handle_exit.c | 2 + .../selftests/kvm/aarch64/debug-exceptions.c | 149 +++++++++++++++++- 5 files changed, 169 insertions(+), 5 deletions(-) base-commit: 7e18e42e4b280c85b76967a9106a13ca61c16179