Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3643902pxb; Wed, 13 Oct 2021 09:59:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwk1GqoA8WyVx2RHuwpWaFqX/Tp/8+7taomym3W4QoGY2USYmW3yUApUiyy96n3E7CyrElf X-Received: by 2002:a17:90a:6542:: with SMTP id f2mr11343548pjs.159.1634144370610; Wed, 13 Oct 2021 09:59:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634144370; cv=none; d=google.com; s=arc-20160816; b=RnnRhp2MslsTboCfYOwAnxwpjqM7aji85lHqF3E+75sUdbo3kjtrZ+8zbPAL44RdXx TFQqf669vUvXAmFw9V2gIURuVue0PzGdS3Q6IYxJZvu5nQ4M5IiWJclXvIOqaG6ngIqd 7tWsPcqr5fyk0HEQDf0na6m8qSqQG4nxxHPaJcspVrVzi8BM4OS1OsPihi6NmH+duS4y B4kdcYwDvDYIIibDKVqLMjl35ou6BRBCBdZB6yKRpipkSnMuPaBsvcRwV3UIDly1M/J6 H3VETyi0CzAo7vfafkHHAaJw5xng8285NhiDjQ7yO78os/uQc154apDObvhyrLuun6j5 JX/Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ttIAkGSptCBgBNcRMAAwBhA9MZKVi2/uSD/1xXfL/jU=; b=QDK4S2LizAr8XKSE1iFSjr71hoZeVeuYLn/uklBDDDEwau2IUmET17EuMIveJ8n2ro LzQ4IpfBXJ8GOBxOcKORdLRThnYQSqAhORWtEjwqn7sdVDlx1xbBjgQ+6aayK5MtQk+x xyqyxTBwzXcWo39RnZ8ef1kRMuqESgQiRRAo74bfOkX++5TX4yIK8SaEbHH2br3gcTyy LQCeYTLGLLPdKSQNcDytiUG/UgosUz0eCPthEJu+lufuHQ24lh8VfZYp0gqN/9xaN0yr o/SlvmpTCuINQhKXQggddVOonlvY0Qak7ySgbVnetN5KdYwWbCj1lju/WYBKkkDzNLf3 HT8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BVXAYpi3; 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 s15si9214plg.442.2021.10.13.09.59.17; Wed, 13 Oct 2021 09:59:30 -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=BVXAYpi3; 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 S238211AbhJMQ6x (ORCPT + 99 others); Wed, 13 Oct 2021 12:58:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38420 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237851AbhJMQ62 (ORCPT ); Wed, 13 Oct 2021 12:58:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634144184; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ttIAkGSptCBgBNcRMAAwBhA9MZKVi2/uSD/1xXfL/jU=; b=BVXAYpi3KWJHY58k7+yl2ahQbAyo1p1P9etr/RYyJBqLa2lnWpp5pkVxY1oa1orxFDaJf7 /F0Qb2+tLQclJIwalG2+HmJC2GIhLMxgN0yHkxIsnebp6l5AGHqWRqh5wgRu043PzK6U45 vgr3d6eeV/8kULqBrpauDNDv3XqI8xQ= 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-472-ZzMVoAZ0Pmi_kI18OAKRHg-1; Wed, 13 Oct 2021 12:56:21 -0400 X-MC-Unique: ZzMVoAZ0Pmi_kI18OAKRHg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F384C801AA7; Wed, 13 Oct 2021 16:56:19 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7662AADC5; Wed, 13 Oct 2021 16:56:19 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: fwilhelm@google.com, seanjc@google.com, oupton@google.com, stable@vger.kernel.org Subject: [PATCH 4/8] KVM: SEV-ES: clean up kvm_sev_es_ins/outs Date: Wed, 13 Oct 2021 12:56:12 -0400 Message-Id: <20211013165616.19846-5-pbonzini@redhat.com> In-Reply-To: <20211013165616.19846-1-pbonzini@redhat.com> References: <20211013165616.19846-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Remove the data argument and pull setting vcpu->arch.sev_pio_data into the caller; remove unnecessary clearing of vcpu->arch.pio.count when emulation is done by the kernel. 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 | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 218877e297e5..8880dc36a2b4 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -12382,34 +12382,32 @@ static int complete_sev_es_emulated_ins(struct kvm_vcpu *vcpu) } static int kvm_sev_es_outs(struct kvm_vcpu *vcpu, unsigned int size, - unsigned int port, void *data, unsigned int count) + unsigned int port, unsigned int count) { - int ret; + int ret = emulator_pio_out(vcpu, size, port, + vcpu->arch.sev_pio_data, count); - ret = emulator_pio_out_emulated(vcpu->arch.emulate_ctxt, size, port, - data, count); - if (ret) + if (ret) { + /* Emulation done by the kernel. */ return ret; + } vcpu->arch.pio.count = 0; - return 0; } static int kvm_sev_es_ins(struct kvm_vcpu *vcpu, unsigned int size, - unsigned int port, void *data, unsigned int count) + unsigned int port, unsigned int count) { - int ret; + int ret = emulator_pio_in(vcpu, size, port, + vcpu->arch.sev_pio_data, count); - ret = emulator_pio_in_emulated(vcpu->arch.emulate_ctxt, size, port, - data, count); if (ret) { - vcpu->arch.pio.count = 0; - } else { - vcpu->arch.sev_pio_data = data; - vcpu->arch.complete_userspace_io = complete_sev_es_emulated_ins; + /* Emulation done by the kernel. */ + return ret; } + vcpu->arch.complete_userspace_io = complete_sev_es_emulated_ins; return 0; } @@ -12417,8 +12415,9 @@ int kvm_sev_es_string_io(struct kvm_vcpu *vcpu, unsigned int size, unsigned int port, void *data, unsigned int count, int in) { - return in ? kvm_sev_es_ins(vcpu, size, port, data, count) - : kvm_sev_es_outs(vcpu, size, port, data, count); + vcpu->arch.sev_pio_data = data; + return in ? kvm_sev_es_ins(vcpu, size, port, count) + : kvm_sev_es_outs(vcpu, size, port, count); } EXPORT_SYMBOL_GPL(kvm_sev_es_string_io); -- 2.27.0