From mboxrd@z Thu Jan 1 00:00:00 1970 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=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 618E6C169C4 for ; Tue, 29 Jan 2019 11:55:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3160F2083B for ; Tue, 29 Jan 2019 11:55:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548762941; bh=AgfoL3IFu1DflmBe8d6paLFyT7XAQdzHEHETgF8um5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=1OibDhXJWxTQ7gvX/ifhKh2LgfszqbELIo5n0pBL+5+s2Z9B/7HzKofb1TExy4jYb NCblUQGM10GagONprRDOZVUkDJKzeL4lICQ3PIhebI1YuDXn+XJe7RyYR+nl8nbJcR mzaDz5tDFmE8JHTQFwEE1+R4fiZEDdxeq62H9ndw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731726AbfA2Lzj (ORCPT ); Tue, 29 Jan 2019 06:55:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:41866 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730979AbfA2Lua (ORCPT ); Tue, 29 Jan 2019 06:50:30 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B2DD72083B; Tue, 29 Jan 2019 11:50:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548762630; bh=AgfoL3IFu1DflmBe8d6paLFyT7XAQdzHEHETgF8um5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jxoCYRCF9kk0TEpmwtW4GH7CMLxaR7IaHz0Va/aCj9M4SdfRYpgY14GvxoYLk1/1r vmYV7aTq25MxUQ+YJwNyegT15zNnb6v4hmaZYV3Jl6w7r/0o+A3z9oHhn9qaYBFjcU i9A8hvOGIPqTZAQyzuigBp0OcImWh+RptbICHli4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Popov , Paolo Bonzini Subject: [PATCH 4.14 41/68] KVM: x86: Fix single-step debugging Date: Tue, 29 Jan 2019 12:36:03 +0100 Message-Id: <20190129113135.219179922@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129113131.751891514@linuxfoundation.org> References: <20190129113131.751891514@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexander Popov commit 5cc244a20b86090c087073c124284381cdf47234 upstream. The single-step debugging of KVM guests on x86 is broken: if we run gdb 'stepi' command at the breakpoint when the guest interrupts are enabled, RIP always jumps to native_apic_mem_write(). Then other nasty effects follow. Long investigation showed that on Jun 7, 2017 the commit c8401dda2f0a00cd25c0 ("KVM: x86: fix singlestepping over syscall") introduced the kvm_run.debug corruption: kvm_vcpu_do_singlestep() can be called without X86_EFLAGS_TF set. Let's fix it. Please consider that for -stable. Signed-off-by: Alexander Popov Cc: stable@vger.kernel.org Fixes: c8401dda2f0a00cd25c0 ("KVM: x86: fix singlestepping over syscall") Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/x86.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -5923,8 +5923,7 @@ restart: toggle_interruptibility(vcpu, ctxt->interruptibility); vcpu->arch.emulate_regs_need_sync_to_vcpu = false; kvm_rip_write(vcpu, ctxt->eip); - if (r == EMULATE_DONE && - (ctxt->tf || (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP))) + if (r == EMULATE_DONE && ctxt->tf) kvm_vcpu_do_singlestep(vcpu, &r); if (!ctxt->have_exception || exception_type(ctxt->exception.vector) == EXCPT_TRAP)