Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp501675ybl; Fri, 23 Aug 2019 04:14:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYMZ/aeRVgR0cBAK+VJzuhEDeOTMIPlbj9U7yJze1CFt2IM9w+VJug6PHjlZPkg+4xlm/y X-Received: by 2002:a62:53c3:: with SMTP id h186mr4645794pfb.178.1566558898239; Fri, 23 Aug 2019 04:14:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566558898; cv=none; d=google.com; s=arc-20160816; b=ntYk7EUfRDM62p1fa1c1WL5dqmYQzT0w/LkAOhqtvw0BFrwIqpuiFgdokCs9ZT2RUZ AQ6N1sGEQ7u8BGXeorDyeWjbZjeWVywJjHeky2W9XYCBueUxd+DaQaso6qzeoh5dMd9a cXb46Y2yaxdMDFAM26ygjLBJVLrXHoCUP2PbiMsUEZnDpLNGOZJkg2NzF2aC4ce4Ux8L pWOwXJFSYykEvoSO6fDeXk+lIjpKfBrgMSahYmy6ssihCE3uC5YUNdeyZ94iiTIggaYW ByaH0qRvLxtJZpD5TRJSSoLxeUxKwoUqM7TBSYIsCtILiUeRahK/24Hh9bUx9P8tkj96 m5uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=4hIvhiErI/PBhr2czomH4NGnSK+5wiyAYFcemIBDRQY=; b=TszGVJFBuPxJDZBe3aECmY67lR/aauV8O2Jqdo4LlC4KWEblZqWSgt5umX4FrwThbE c7mGXl0AtwQ79bH/jeanmHUse9sFbdlfghNwz3+eRV8lC1e/vI/DorZoo2e/AOVdS2t4 amSa+FZ5rb056/ajWm/d+HieQmsXslilJswTPcV3p6CC6C6iWU9ptnDJKMogsX2ObWwc pt8Thpw8We2/qRyBthY6x5zgai9iX7oj/fdErj+8ny0XRkPsUw6tv+aJKPLF00Flj8m6 zQXtm6Rt7HTnqc7zf7OXdqrlKXFRYlGG9fRPUlBSLAwrZFU/BJ5hd2SvFeRa6kJif8eC Jh6A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x9si2033857plo.98.2019.08.23.04.14.42; Fri, 23 Aug 2019 04:14:58 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732495AbfHWJcl (ORCPT + 99 others); Fri, 23 Aug 2019 05:32:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49468 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731592AbfHWJck (ORCPT ); Fri, 23 Aug 2019 05:32:40 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6552711A12 for ; Fri, 23 Aug 2019 09:32:40 +0000 (UTC) Received: by mail-wr1-f70.google.com with SMTP id m7so4541659wrw.22 for ; Fri, 23 Aug 2019 02:32:40 -0700 (PDT) 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:in-reply-to:references:date :message-id:mime-version; bh=4hIvhiErI/PBhr2czomH4NGnSK+5wiyAYFcemIBDRQY=; b=WSenrebHBZD6iZwpkoMGDCX1klrqPx4o3UBMjvwrR8VdVgTiXxC36Eg2XZhLIGTS5X qB+3/B4B3DQEtPlRJTEXM+26yoGbLfcrlaA3j8Azf1M3lbzefof5LxsxkxwfB6jEKFJU W2kPAvltmJ/8pFeUXGHVj6O5fJwqA68Sead9uHfV5EP4wvpIQPcJ0ZNFUoRroud0OX0P 2kWRw+nv+eVUlibeYFLaXW5RrY8KZRQ4l8U0Eu1uB4XCNpgIHpyntvFySiQUQqEfxTxT yfxqIOmpHgdKgWBLaMrKj7Uuci9N04p3+lv1H0cUwLf3q+1MREBObWzemU2m1/7pk3Eo /aHg== X-Gm-Message-State: APjAAAVVDd+EKl64mMwTINLUP5dTFDIWqzvpdp7FmvwUjRYhXUOI1Hea nMBv9uf8Il/DdFsjiSPkUpEUJZwuWOGjDkJwxio2ZY34neWyxmx/b7kTWlOKkocu7A2FXgF7TD8 5zgOcThm1NVNmt2lLs46MkmQD X-Received: by 2002:a5d:4b05:: with SMTP id v5mr3974285wrq.208.1566552758933; Fri, 23 Aug 2019 02:32:38 -0700 (PDT) X-Received: by 2002:a5d:4b05:: with SMTP id v5mr3974248wrq.208.1566552758650; Fri, 23 Aug 2019 02:32:38 -0700 (PDT) Received: from vitty.brq.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id v124sm4374779wmf.23.2019.08.23.02.32.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2019 02:32:38 -0700 (PDT) From: Vitaly Kuznetsov To: Sean Christopherson Cc: Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [RESEND PATCH 03/13] KVM: x86: Refactor kvm_vcpu_do_singlestep() to remove out param In-Reply-To: <20190823010709.24879-4-sean.j.christopherson@intel.com> References: <20190823010709.24879-1-sean.j.christopherson@intel.com> <20190823010709.24879-4-sean.j.christopherson@intel.com> Date: Fri, 23 Aug 2019 11:32:37 +0200 Message-ID: <877e74p6q2.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sean Christopherson writes: > Return the single-step emulation result directly instead of via an out > param. Presumably at some point in the past kvm_vcpu_do_singlestep() > could be called with *r==EMULATE_USER_EXIT, but that is no longer the > case, i.e. all callers are happy to overwrite their own return variable. > > Signed-off-by: Sean Christopherson > --- > arch/x86/kvm/x86.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index c6de5bc4fa5e..fe847f8eb947 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -6377,7 +6377,7 @@ static int kvm_vcpu_check_hw_bp(unsigned long addr, u32 type, u32 dr7, > return dr6; > } > > -static void kvm_vcpu_do_singlestep(struct kvm_vcpu *vcpu, int *r) > +static int kvm_vcpu_do_singlestep(struct kvm_vcpu *vcpu) > { > struct kvm_run *kvm_run = vcpu->run; > > @@ -6386,10 +6386,10 @@ static void kvm_vcpu_do_singlestep(struct kvm_vcpu *vcpu, int *r) > kvm_run->debug.arch.pc = vcpu->arch.singlestep_rip; > kvm_run->debug.arch.exception = DB_VECTOR; > kvm_run->exit_reason = KVM_EXIT_DEBUG; > - *r = EMULATE_USER_EXIT; > - } else { > - kvm_queue_exception_p(vcpu, DB_VECTOR, DR6_BS); > + return EMULATE_USER_EXIT; > } > + kvm_queue_exception_p(vcpu, DB_VECTOR, DR6_BS); > + return EMULATE_DONE; > } > > int kvm_skip_emulated_instruction(struct kvm_vcpu *vcpu) > @@ -6410,7 +6410,7 @@ int kvm_skip_emulated_instruction(struct kvm_vcpu *vcpu) > * that sets the TF flag". > */ > if (unlikely(rflags & X86_EFLAGS_TF)) > - kvm_vcpu_do_singlestep(vcpu, &r); > + r = kvm_vcpu_do_singlestep(vcpu); > return r == EMULATE_DONE; > } > EXPORT_SYMBOL_GPL(kvm_skip_emulated_instruction); > @@ -6613,7 +6613,7 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, > vcpu->arch.emulate_regs_need_sync_to_vcpu = false; > kvm_rip_write(vcpu, ctxt->eip); > if (r == EMULATE_DONE && ctxt->tf) > - kvm_vcpu_do_singlestep(vcpu, &r); > + r = kvm_vcpu_do_singlestep(vcpu); > if (!ctxt->have_exception || > exception_type(ctxt->exception.vector) == EXCPT_TRAP) > __kvm_set_rflags(vcpu, ctxt->eflags); Reviewed-by: Vitaly Kuznetsov -- Vitaly