Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4050638pxv; Tue, 13 Jul 2021 09:35:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGA8PQPI1iJ1fx3cYp9YZEd0XnbvotwG1b6+CfA6lhGvRTfoFRcpzSPp4twUE6ho2IPj6n X-Received: by 2002:a17:907:24d1:: with SMTP id e17mr6620318ejn.427.1626194159002; Tue, 13 Jul 2021 09:35:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626194158; cv=none; d=google.com; s=arc-20160816; b=snxTNmUry9X5hUi/KtEnbN0KY4df8Eh1NVm4adhi1Ci3Vf7XuN3K3HyoExUT7tJ+DC 0YTUCZq9blDkerrLmh7uYRqGc7NkS/98ye3hiYSEiySTEu8GBgsDXvT5LFQr0r2/u9YN aHf6e7AAiApLoj9P9ePHIJJtLrs80aVgtPR6KShokQ6gv74uTsdb21z5372DaDhJNxlL aNTWBXGH02UQ+nOKatzyQY6mFRhxrfROpA26KU9BVhKbStDesoPOh10omYr7/SvWw+tU 5RkH6cRTH1IuXx0p2EI6r+UpZA4HP7V2BM6agVTITLOFNOFJoKf5NZZY/tdZ7m07Duue JEBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:reply-to:dkim-signature; bh=EX4D+eojcaFEJw7uYtuJ66OnM1pg9jtwgYRDkvzAZPk=; b=hRDJjYMEAn6jTFKZoweDAptz1NK8M5YZee5pGklBlJLIZyMfL1o5jo1hJqw/CZz9Gz LBZNrkpyu+Ja2F48rtAt3bYCrIzaePfcR4g6bKL1bOFVpibHbrsjpqFDle2R5P3CWAmJ VLQV459qUBn0wWgPPzOACs1HM5dzjHxpEFvNwYmwgSnsOmRDdI4V05odpHp1yplvESep uyvS49Xl9b7S6GD9swvOUM9c9h3eZNxNg3tGqWONdVf01K7JlCGEDY2JCwpyINqKLIem oSQxA4xYzNQYzBM8KXl0oJKkkZT47Jnx70dLPAmUUJCSF4promoErcrm/XhzrzwBMHie kNww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=v5skcrT3; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q13si19962168ejd.76.2021.07.13.09.35.28; Tue, 13 Jul 2021 09:35:58 -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=@google.com header.s=20161025 header.b=v5skcrT3; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233898AbhGMQgv (ORCPT + 99 others); Tue, 13 Jul 2021 12:36:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233558AbhGMQgn (ORCPT ); Tue, 13 Jul 2021 12:36:43 -0400 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94DE0C0613F0 for ; Tue, 13 Jul 2021 09:33:52 -0700 (PDT) Received: by mail-qt1-x84a.google.com with SMTP id w13-20020ac843cd0000b0290251f0b91196so8008402qtn.14 for ; Tue, 13 Jul 2021 09:33:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=EX4D+eojcaFEJw7uYtuJ66OnM1pg9jtwgYRDkvzAZPk=; b=v5skcrT3HKZ7xQ2i5ono4qCe9BI8iCx1TyHGuIg8UDLy05+b783LKDIH4rcFkL6xzJ 3KtS0KgaiO5t4nVn7u39gDjZ58gPjSGiDmJKw+lcQDMDGTFKJ8ZVn4wl9fXEKfVBk/Cd Btv1eAVs1kbUS19V1NvXCCfHgbc4WAkmBfEtmVmJn4Lv2kQAE/IzKR52ksbjENONv8A4 GyELtmDz3eZM7sB3agX/9IPiFDiOROnfGFGmWLP60HjKV2qv6xJ1KwANcfan2eyF9WiL ge9TpONOShlUc+p/zl5A8mOogVdIGFRtdprH9m/URPDQWdnD7lI3NJUIzsBz0QuYSPrN w47A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=EX4D+eojcaFEJw7uYtuJ66OnM1pg9jtwgYRDkvzAZPk=; b=jukXvvwDEJuyQvLT3iCvA3f4Rk9B3IszfFJUml5mE9hFiLcTfe2M8AjX/H3FijlJ3A XwHiZsWUyx7xCvbVuxYAYlBU2Nqv2UMqTAMVb3/q4uhbSF6dsNDROpzlhV2F5ieuX6FF AQNMyZ+1oHcPLgBdKrT3F8S+sa5BiS4bQ78wqPi5vbf61IkB3bv/xTPNtJwaA2tixTDw tKjHx+Y5c6F8KwkmbevQPRjt/kM/zKqO3dsVj8Iy+gTlyRHnU6PR2KCosU/Bx24rR4Qy w5PX7F+ijdWffGwaolAmJoEJXX61uQ6XIDYhmT+Y5DX3BXN4AEod1g6uv9t8jJfnzia0 hn9g== X-Gm-Message-State: AOAM531TbjuKQCP5oWzzdWGm6QKtwjjaHm6dNF21dReThxw1VSQiHX04 Hs3mvk0ni2cDBmyx7Htx6NKpt6Gfw0k= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:90:200:825e:11a1:364b:8109]) (user=seanjc job=sendgmr) by 2002:a0c:d68f:: with SMTP id k15mr5823187qvi.14.1626194031709; Tue, 13 Jul 2021 09:33:51 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 13 Jul 2021 09:32:47 -0700 In-Reply-To: <20210713163324.627647-1-seanjc@google.com> Message-Id: <20210713163324.627647-10-seanjc@google.com> Mime-Version: 1.0 References: <20210713163324.627647-1-seanjc@google.com> X-Mailer: git-send-email 2.32.0.93.g670b81a890-goog Subject: [PATCH v2 09/46] KVM: SVM: Drop a redundant init_vmcb() from svm_create_vcpu() From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Reiji Watanabe Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Drop an extra init_vmcb() from svm_create_vcpu(), svm_vcpu_reset() is guaranteed to call init_vmcb() and there are no consumers of the VMCB data between ->vcpu_create() and ->vcpu_reset(). Keep the call to svm_switch_vmcb() as sev_es_create_vcpu() touches the current VMCB, but hoist it up a few lines to associate the switch with the allocation of vmcb01. Reviewed-by: Reiji Watanabe Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/svm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 44248548be7d..cef9520fe77f 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1431,15 +1431,13 @@ static int svm_create_vcpu(struct kvm_vcpu *vcpu) svm->vmcb01.ptr = page_address(vmcb01_page); svm->vmcb01.pa = __sme_set(page_to_pfn(vmcb01_page) << PAGE_SHIFT); + svm_switch_vmcb(svm, &svm->vmcb01); if (vmsa_page) svm->vmsa = page_address(vmsa_page); svm->guest_state_loaded = false; - svm_switch_vmcb(svm, &svm->vmcb01); - init_vmcb(vcpu); - svm_init_osvw(vcpu); vcpu->arch.microcode_version = 0x01000065; -- 2.32.0.93.g670b81a890-goog