Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1793341pxy; Fri, 23 Apr 2021 17:50:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwtWuSGbvZ807mWa6t4SMe0ShXUIaESueRN5kxDZGp+fKNUHDC8Wgk6cJ4sLA0gz+6Tt6+ X-Received: by 2002:a50:fe01:: with SMTP id f1mr7690635edt.272.1619225431581; Fri, 23 Apr 2021 17:50:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619225431; cv=none; d=google.com; s=arc-20160816; b=OKSrCtZsYHdSx9WO4nysjK8iA2cwzN3EuotJg34tZUzMjKnrNpNpqtuTS0q8tzAwTn 7T1sO+39lZdcnDeb3V4ZDmfO+qUQumzWCt0TbLWhgxpCaNchDSGOhzp4B7OlkGPAB8ZO /uOAePyyhSK5u3DQ1YzHV+e4wC6m13fK9UKvaIvRNCl0ajBbbHLufrzuvazPXpcpiDDI UhqKtqfKwXZTkie8qu2ELcNKNXPY8W6kpYCH0cWyD4P7KYu6vYZEZ1LpTHyE79/xBRy4 jNrYfEo3XRaDVAWLQswBGBMyOSnDHScZKgFY66+luKB+6CDYYbk91gLpW3u6/98G38mh KwEA== 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=H46lT8DkG1h570Zv+xu7UsGwwPn89nRKlivzLO/8BXo=; b=DmCHI4KNEelctu4BsAxjwuHPXyalqOo0suUdv7PMEHj04Z1dVzaeHvrZekBMB1vQ6Y DyGGuYQM36SwhlUeVC4GKRdJwJg+21FDyr5zp7ro9Bx/vd3K0J+aVU9kike/Vck580vM +Iu+K9WbUbvDWnAPPokJ9Y4Ji4wCzD3eGcOW/6iqq5FtBBF4gzjpv8NPSSkfuT9ZWbj+ Pc6S37a9qK/1B/7DZERikqtxks8JmMMTHwh2AU7kVy8Wv/4AfZ7tb4+iRHS1ivnENtpf RlsbbsYsWlZml2k7g+tYeIfeLT8kquF9WXcu3XPdEAw2qFWj6Yjv2eWu/Xij1ZKSj+DP iu+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=owrm6gGD; 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 b8si6938752edz.99.2021.04.23.17.50.08; Fri, 23 Apr 2021 17:50:31 -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=owrm6gGD; 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 S244370AbhDXAsk (ORCPT + 99 others); Fri, 23 Apr 2021 20:48:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244221AbhDXAsB (ORCPT ); Fri, 23 Apr 2021 20:48:01 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90AE8C061347 for ; Fri, 23 Apr 2021 17:47:20 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id p9-20020a2574090000b02904e2cb6a90e7so26400581ybc.17 for ; Fri, 23 Apr 2021 17:47:20 -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=H46lT8DkG1h570Zv+xu7UsGwwPn89nRKlivzLO/8BXo=; b=owrm6gGDzwQ7FwWNwHfNIhmy9Lqo8phxgwqD6ABoLD/cJGiyhu67gPfYzx0aSg+8KF tVdZy/nzRqIfcXY4br9XBeoi78tHRe3ubmjQT59+rK0iYKK4LkR1s244D39i+m91gT8u f+sumHioWtfft0u9tpTeh6BWiOzfc1hhyPvnA7V357DF5/1Gnfj1wq1OVqzA6AsSLa1r mqM1r+FWCGacwM+kT0PDIzDlcmmbN6JPXkDJ8FOoEmv3182DZfKtdhhTXdYkKqIfF5+8 guepsKVT6MArtV8J1s+UvpX+oUhkOMM3Pgp/mi4ozsj3IsviwkeKfdxzB/SjoAP54D0y YP2g== 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=H46lT8DkG1h570Zv+xu7UsGwwPn89nRKlivzLO/8BXo=; b=TDzWrRbok+92ITIbx0Sw6LO+qgjHIsZxvyS10BOi3Zg533vUeHjxCICX4YppKG+R61 h7E+IYrDHxKQUhET9iqD/g2LkL6WsCYDitWxg6XbRClVd0cuiVXXHSk4beNOkAYHQxYr L7V6uYSiym880ecySJMg8ydaygjk+TkxdPAoChkVXXKgEwDjmGmdy2WjvWGD3W4ECm1a I0h7R37gr/UdEJkomDLx44P66G6xNnRra4jaFtpAb3WRuvQaPHLoOQrVNwHU22oFTO6V fbNI2FngKAnxNHielXrT2lBODtgMdC/5M7lmuCTNL15SIv0NNz+9Ty5FGUuFeaLO5gpu vIKg== X-Gm-Message-State: AOAM530zcCcL9fHN4fbz2dTwNIDvJngaWM8F2gaW0DKse9Kgx9rjV0oB RILDCYKL8dMUPHHaAVA7CpepfY18l1c= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:ad52:3246:e190:f070]) (user=seanjc job=sendgmr) by 2002:a25:ab53:: with SMTP id u77mr9566083ybi.48.1619225239877; Fri, 23 Apr 2021 17:47:19 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 23 Apr 2021 17:46:11 -0700 In-Reply-To: <20210424004645.3950558-1-seanjc@google.com> Message-Id: <20210424004645.3950558-10-seanjc@google.com> Mime-Version: 1.0 References: <20210424004645.3950558-1-seanjc@google.com> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog Subject: [PATCH 09/43] 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 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. 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 fbea2f45de9a..6c73ea3d20c6 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1371,15 +1371,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.31.1.498.g6c1eba8ee3d-goog