Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1116164pxb; Thu, 21 Oct 2021 16:15:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzy1kl5NRyX0IH1s/rcrnvOpSnBPJglFxjmZhrDt+oSKo6Ka16ZmYAtrfnqrUoXQGSzFww X-Received: by 2002:a17:906:7a0c:: with SMTP id d12mr10832584ejo.442.1634858143372; Thu, 21 Oct 2021 16:15:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634858143; cv=none; d=google.com; s=arc-20160816; b=VKvCw3BBBoBw1dpI3Udw588yFlK+w9iw4e9GmtoHZ/TFJcm9Ztk4uPGH8w+sCFH51L 9E5jk2RNc3vb6OpKDyb2WnVkjBG+koyKmc/7/S2xkBA6j/JtSJDhMpXOsNqnF4FH6MEt stf1LcGi29PTTUuSxd++3wLb+hQIq2V7wOjnfUm1HlNpQ7MiS6llBeWrqry1u+qyXKPQ FFS5P/dHq3uXgwB+NzPdr4PoAXZoggvrKXTVQVKCV9sRxErEyYvDzUlsbR9MncU8F6XR 4Hq2daF4A93aUKyDem44tB61X71wioIQ7F4z5HTXbOT/i36sFBUY5KlvENiRdNjq9tyw r6dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=KRKbHMyLQA73yDGwTOIlwI6kX+pQcdkoNgFrVNdndyA=; b=HVDGIx8+6EH5L41eyorEnaIfq0IQqtEiJSNfdbHgtCzczNEVAseLdnBudJ0ybbsXPZ 5WcxDNS4oh3LaHP22dQYVAYiahkdA8mUISEZBarZ5t4Wbrq5MiT5z1ODyQQ95ETJfhlk HKDvYRWZSF2tn/6jSkBS470GU/dOqG+aujyXM1fgne9Dwrv4VFOkzLS58uG8HoZWf3/m yV/i9eUDfq4rnycJ5+n8O31bYfs95Nird+JAiY+vDigbhfvYp613ezuSFsxF1oIV8pH2 GNXUyKvGABVid1+2A7VhjneO05xjyj3i4RrxySfnpAziatgHMNOiFBqxddOWHbXd0FYV pfLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OniK0e0e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ce15si10306514edb.612.2021.10.21.16.15.19; Thu, 21 Oct 2021 16:15:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OniK0e0e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231961AbhJUXPc (ORCPT + 99 others); Thu, 21 Oct 2021 19:15:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:46744 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232054AbhJUXPc (ORCPT ); Thu, 21 Oct 2021 19:15:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634857994; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KRKbHMyLQA73yDGwTOIlwI6kX+pQcdkoNgFrVNdndyA=; b=OniK0e0ehm4J8HSndo+ieKER/122/Smg9GzXXqTYQzWMbT06ayMc3WoJ0KXhSSICpH1HPL izZf1j0Yntvg2gL2Nc1eOwfz2AYaZtF6wUbn7ip7zq+4JNglMcLtboi4OjsE/nADfmoaDE l3CrMsvY3z0qlzU9wtfnsWYSVtyx0yI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-539-XKMFVEv3P5G88pfIQCF5rg-1; Thu, 21 Oct 2021 19:13:11 -0400 X-MC-Unique: XKMFVEv3P5G88pfIQCF5rg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 892B91926DA3; Thu, 21 Oct 2021 23:13:10 +0000 (UTC) Received: from starship (unknown [10.40.192.246]) by smtp.corp.redhat.com (Postfix) with ESMTP id 766CD69219; Thu, 21 Oct 2021 23:12:56 +0000 (UTC) Message-ID: Subject: Re: [PATCH 3/8] KVM: x86: leave vcpu->arch.pio.count alone in emulator_pio_in_out From: Maxim Levitsky To: Paolo Bonzini , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: fwilhelm@google.com, seanjc@google.com, oupton@google.com, stable@vger.kernel.org Date: Fri, 22 Oct 2021 02:12:55 +0300 In-Reply-To: <20211013165616.19846-4-pbonzini@redhat.com> References: <20211013165616.19846-1-pbonzini@redhat.com> <20211013165616.19846-4-pbonzini@redhat.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2021-10-13 at 12:56 -0400, Paolo Bonzini wrote: > Currently emulator_pio_in clears vcpu->arch.pio.count twice if > emulator_pio_in_out performs kernel PIO. Move the clear into > emulator_pio_out where it is actually necessary. > > No functional change intended. > > Cc: stable@vger.kernel.org > Fixes: 7ed9abfe8e9f ("KVM: SVM: Support string IO operations for an SEV-ES guest") > Signed-off-by: Paolo Bonzini > --- > arch/x86/kvm/x86.c | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 722f5fcf76e1..218877e297e5 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -6914,10 +6914,8 @@ static int emulator_pio_in_out(struct kvm_vcpu *vcpu, int size, > vcpu->arch.pio.count = count; > vcpu->arch.pio.size = size; > > - if (!kernel_pio(vcpu, vcpu->arch.pio_data)) { > - vcpu->arch.pio.count = 0; > + if (!kernel_pio(vcpu, vcpu->arch.pio_data)) > return 1; > - } > > vcpu->run->exit_reason = KVM_EXIT_IO; > vcpu->run->io.direction = in ? KVM_EXIT_IO_IN : KVM_EXIT_IO_OUT; > @@ -6963,9 +6961,16 @@ static int emulator_pio_out(struct kvm_vcpu *vcpu, int size, > unsigned short port, const void *val, > unsigned int count) > { > + int ret; > + > memcpy(vcpu->arch.pio_data, val, size * count); > trace_kvm_pio(KVM_PIO_OUT, port, size, count, vcpu->arch.pio_data); > - return emulator_pio_in_out(vcpu, size, port, (void *)val, count, false); > + ret = emulator_pio_in_out(vcpu, size, port, (void *)val, count, false); > + if (ret) > + vcpu->arch.pio.count = 0; > + > + return ret; > + > } > > static int emulator_pio_out_emulated(struct x86_emulate_ctxt *ctxt, Makes sense, now that both emulator_pio_in and emulator_pio_out clear the arch.pio.count once. Reviewed-by: Maxim Levitsky Best regards, Maxim Levitsky