Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4053305pxv; Tue, 13 Jul 2021 09:39:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqFTs2j3QD9RVTgwrJj3SzciYgydKMi8qWuhHJg5RcrNWLl1w0oqkqh10pqsZXL09cVkd2 X-Received: by 2002:a17:907:1c94:: with SMTP id nb20mr6612544ejc.289.1626194377808; Tue, 13 Jul 2021 09:39:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626194377; cv=none; d=google.com; s=arc-20160816; b=Rc55dTILeZoPBsfvYgkRqERpfIbFEypa9KPTWdTb6V2sxLoY+iE2UR/0Yhewoo7kLC 57LhjGhgYI6p+PunwryFHWDtfV5ccgn2QjOChJ13cCEg12lZp1dy4qasgArNM6yJydFi leWGL9WXIsPNgDzMB8XWL3NIb/C43F9cJm8wImYhsYpiKHpmkmPbkjqJ0eLOV8hgSJLP xQMdULxdqxfHNKZOXvLMqphknp81SHDSE/T1NlI10kaxdCU/DIDsap9BBoNl9wSiaDJa afYqJ9bYpsYWWqlDk/tVWLYPG5LJtTvafrf0m63OSPOUqhpQgEnk+uzMAGmCHPW16pFa tY3Q== 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=kkwdoJIGvsW7E6rhoByJg5nAs3eFczhVd+MvdJJpI18=; b=0NiAYMEVBGnD2xWw1C5ioQ9wJ6NPSFt//BqAt3imVAz6MZQNfnUqOqDzbSCqP7AvuD TNnmO4JeT4jfa2FVSN2OujJWhc1m46Sbibzi7yrnZm90phHqCKj50yhXRX7OhIpGl0Ea aX+Jyt++qbCDDWmTpxZhYapUOP+6sCwqBmtK/JID8lxoHmoxarfgA16Kux/x1tpeGlOA gqxpTcj/3vLqqsskhlGUsxFjt8XkeCYn0fDudtdGbenixn037FsqSV0YLzmhBsES28b/ sYsxxr/UkAzQFJAEac4sIbkT6mQ7Nv/kVI76Wl+k+kEnETLQ+hSV7C9WJR54pkV7YR2n EuTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="qGHaSx/U"; 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 b11si9639973ejc.345.2021.07.13.09.39.11; Tue, 13 Jul 2021 09:39:37 -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="qGHaSx/U"; 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 S235607AbhGMQi4 (ORCPT + 99 others); Tue, 13 Jul 2021 12:38:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235677AbhGMQih (ORCPT ); Tue, 13 Jul 2021 12:38:37 -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 37C69C05BD31 for ; Tue, 13 Jul 2021 09:34:58 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id o12-20020a5b050c0000b02904f4a117bd74so27735164ybp.17 for ; Tue, 13 Jul 2021 09:34:58 -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=kkwdoJIGvsW7E6rhoByJg5nAs3eFczhVd+MvdJJpI18=; b=qGHaSx/UlBq3fT7bOWw8v4WtpLzwISDRglaEYJFcQBgOupLdDvDCtvgvBQ5s3lmxSg Qnk6Tu/bMf2Ll24BFQNUi1QyXQyXTWeu/+GXQAOsUuZZt33XkS054wtvx/Nogp8zmLdH ZGFzFG0XyDq4qWw0pIZB9JcQwqO1FcbyVMdd7dv3M6rnorldK9rsMLTSW2F+yJ6YZ8h5 km13PAJmaDBqmQn44DUtXDth1qM69k2l+o8Roz5hG4FDeBYbpGYxX61LZ18985TeeYMn 2PczuNTLwAuC1inZ0rmuHUezMYE+P3Kuk30agrd5tyTGS+LDCXR4/JW7N35JG/izUPJq iM2Q== 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=kkwdoJIGvsW7E6rhoByJg5nAs3eFczhVd+MvdJJpI18=; b=mkHIJOFRxyzxSlUroAdichBCxv8rHqCFDXqsIY14N+n8M0l9rqRYaZSSIC9r/KqfxD FUrJM+tak4N1TAj4NIdt+F7EJmwgD79F3dBzlPp3t0VoljSttlFhMVYQ1LFk6L+dM3Ju 9qJTMEycwWsGMH+iNWYhXaPWAbtwaufVNJQtDW+AtOXq/gA2YQ8/JrjUy+dvaMSIjekq 7x019X2F2gr9/leAYJ0quQZjkfIEqk9TD77LRzzNZBeOYZ3KMzfDAl3hxwxYo6CIzk05 PX6XMxN5sxK4CAGf3wVhxl5FBYXqyZ/6Ihtyid2fWa4fdHvxRzrDzO4flEP6c1n4X1mc Fq8Q== X-Gm-Message-State: AOAM530eUxsMmU0pAaSqMvoIIBNNiimAdxMJwPd4vyhk6VCY+hQTBVsb wBKJLdbM9/AtEhnZx7U+EGPqVXuVjfE= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:90:200:825e:11a1:364b:8109]) (user=seanjc job=sendgmr) by 2002:a25:9bc4:: with SMTP id w4mr6530083ybo.168.1626194097439; Tue, 13 Jul 2021 09:34:57 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 13 Jul 2021 09:33:21 -0700 In-Reply-To: <20210713163324.627647-1-seanjc@google.com> Message-Id: <20210713163324.627647-44-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 43/46] KVM: VMX: Move RESET-only VMWRITE sequences to init_vmcs() 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 Move VMWRITE sequences in vmx_vcpu_reset() guarded by !init_event into init_vmcs() to make it more obvious that they're, uh, initializing the VMCS. No meaningful functional change intended (though the order of VMWRITEs and whatnot is different). Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/vmx.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 4acfb2f450e6..97fa2aa676bd 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -4393,6 +4393,19 @@ static void init_vmcs(struct vcpu_vmx *vmx) vmcs_write64(GUEST_IA32_RTIT_CTL, 0); } + vmcs_write32(GUEST_SYSENTER_CS, 0); + vmcs_writel(GUEST_SYSENTER_ESP, 0); + vmcs_writel(GUEST_SYSENTER_EIP, 0); + vmcs_write64(GUEST_IA32_DEBUGCTL, 0); + + if (cpu_has_vmx_tpr_shadow()) { + vmcs_write64(VIRTUAL_APIC_PAGE_ADDR, 0); + if (cpu_need_tpr_shadow(&vmx->vcpu)) + vmcs_write64(VIRTUAL_APIC_PAGE_ADDR, + __pa(vmx->vcpu.arch.apic->regs)); + vmcs_write32(TPR_THRESHOLD, 0); + } + vmx_setup_uret_msrs(vmx); } @@ -4433,13 +4446,6 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event) vmcs_write32(GUEST_LDTR_LIMIT, 0xffff); vmcs_write32(GUEST_LDTR_AR_BYTES, 0x00082); - if (!init_event) { - vmcs_write32(GUEST_SYSENTER_CS, 0); - vmcs_writel(GUEST_SYSENTER_ESP, 0); - vmcs_writel(GUEST_SYSENTER_EIP, 0); - vmcs_write64(GUEST_IA32_DEBUGCTL, 0); - } - vmcs_writel(GUEST_GDTR_BASE, 0); vmcs_write32(GUEST_GDTR_LIMIT, 0xffff); @@ -4454,14 +4460,6 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event) vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, 0); /* 22.2.1 */ - if (cpu_has_vmx_tpr_shadow() && !init_event) { - vmcs_write64(VIRTUAL_APIC_PAGE_ADDR, 0); - if (cpu_need_tpr_shadow(vcpu)) - vmcs_write64(VIRTUAL_APIC_PAGE_ADDR, - __pa(vcpu->arch.apic->regs)); - vmcs_write32(TPR_THRESHOLD, 0); - } - kvm_make_request(KVM_REQ_APIC_PAGE_RELOAD, vcpu); vpid_sync_context(vmx->vpid); -- 2.32.0.93.g670b81a890-goog