Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3771367pxj; Mon, 24 May 2021 14:39:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweEoZembkvF/2OsBrtubgVoNFxwqSqRDqFyPc3iXvV1rPBRUEwPerGu1rRGgb+dezYxB3c X-Received: by 2002:a17:906:f8c8:: with SMTP id lh8mr3962771ejb.61.1621892340955; Mon, 24 May 2021 14:39:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621892340; cv=none; d=google.com; s=arc-20160816; b=ql9njrHlion1MjynezYxyZwnvhCszqZnFvjvHhyUauooD0vS48giT7WcxmCCxlmA46 FSoMgxQuxRA42rKXlykTtQR+S0EW1d91t0vo3cI7g9RWiXL9xqEfuWUE+t30MmSoYywn A4VBky0LjiPNqe5eS2Fl7w6FsiXD1IQ2SnGjTkUPoz24PMY4cLH7YUfZ1GhYk5r59nsM RVgbH8UKoYC2BK7wf1qPcYgnB24b021eduDRFW0ieJm2LkSUdBANriOJz0P8M1UeKpFK kwi6XDDlRLMcqGvEAzJNB0fzMPWa+fHymlrwVNyK6uDoRL3c9OPfC92ZgOWRiMaXiciU Sl2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=tSqH+teOXpDHWZon+DBvYi3eou87Q03md2WpxZpsMus=; b=qznDfogOd9nxcMn6sv50s1K3D8r0qTGlLlIVAer8cu1xtr9d7hSqpXQDg/G7zNPqv/ 0gMmAggUtedTFZ2hNhW8e5qc4/g/Va5dC9HsgPUNttrwN2bhpI+HZdjW4oPSgTus/p9O bTlWBtyU/66QBxpcsqwsd48apl5/HahGHFKjQsVZ8H7Xg8VuIwTtCoUKqOopqrIrpMme 6mMzATrobHYbJa+bvzdMAn8iONaxJBjJq3QMPZucXs2gC8iJbStgJYCl9KijcyHDuv2A wjkCL2i3SO5c/In0EbI6C7RqsNyqskf+6+tG6v9sd58JAcjXv8SDR+elHsmKmf20BH1T 8CvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iD+Zcrvp; 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 dy15si12695895edb.502.2021.05.24.14.38.36; Mon, 24 May 2021 14:39:00 -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=iD+Zcrvp; 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 S233746AbhEXVQm (ORCPT + 99 others); Mon, 24 May 2021 17:16:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47704 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232693AbhEXVQl (ORCPT ); Mon, 24 May 2021 17:16:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621890912; 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=tSqH+teOXpDHWZon+DBvYi3eou87Q03md2WpxZpsMus=; b=iD+ZcrvpkHK3YpOS0c0zJUc2hFeHB4e7O6Ad4fjO40eGs1wmMYV/EEbiZPW+/PRVJtPxAd 7KYaslf9NWsBzs4y12OMxl0KRFzkADC1UFGSbQwJTaoj5ndGDjp/TOt0zqkgYWBMGqD2Y5 37p4poIP8HVJ5HpqFcLUFp7940u1axs= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-242-9l-R3px_NOKbjhKIBZEYiw-1; Mon, 24 May 2021 17:15:10 -0400 X-MC-Unique: 9l-R3px_NOKbjhKIBZEYiw-1 Received: by mail-ej1-f71.google.com with SMTP id p18-20020a1709067852b02903dab2a3e1easo5081574ejm.17 for ; Mon, 24 May 2021 14:15:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=tSqH+teOXpDHWZon+DBvYi3eou87Q03md2WpxZpsMus=; b=OgeIFpfSgmJgx2brd7CaEnLx4Ta2MVpRWQWiBhVOijYFT0xGXIdybpH8NQM03OrRk5 q0LE2zM3/VPVr0dtXi7+PvapZzZAF/i8kA1D2itxNSHi52/IR2n/T9ldr096AiEZn/Qg B4Sc5qqg8o2TwFmKIgfKpp5qJjGLiqGCH+H4awLKUZht8cB19dHkoKZm2ZVh1sxldnRW FdcQK+JokM1S+d6FHpw1kN492QW1HJwCsXoC4zueoR8x9+VIF4H2HYdihynFnbKQjAAp VRO6qoRKVieG3RwAFJYpM7/H9BDJTgazagjZVTpntIYRFyspK0zHoewy36SB6/f1q5gZ iPtw== X-Gm-Message-State: AOAM533tz7k9B05YEFcmBYhH4RFj+y9jpqL8w6Eeww9uiTCp5/h6HurN PzFiAFvJ13PADDu/c0kNuT+Ahk98sqH1UHU4l5XpVnNgA9LquCXYiG9PWkFrgjM4qrovi31GA0A ekFqNur1KqC9NqVqGIlPfPX5SSNRwYvgT1D1MfRyz/9OlsgnoRyZv6GV0tHUfX6tg2besKA7ZBc s6 X-Received: by 2002:a17:906:c04b:: with SMTP id bm11mr25020159ejb.263.1621890908976; Mon, 24 May 2021 14:15:08 -0700 (PDT) X-Received: by 2002:a17:906:c04b:: with SMTP id bm11mr25020137ejb.263.1621890908744; Mon, 24 May 2021 14:15:08 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id u1sm9837524edv.91.2021.05.24.14.15.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 May 2021 14:15:08 -0700 (PDT) Subject: Re: [PATCH 42/43] KVM: VMX: Drop VMWRITEs to zero fields at vCPU RESET To: Sean Christopherson Cc: Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210424004645.3950558-1-seanjc@google.com> <20210424004645.3950558-43-seanjc@google.com> From: Paolo Bonzini Message-ID: Date: Mon, 24 May 2021 23:15:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210424004645.3950558-43-seanjc@google.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24/04/21 02:46, Sean Christopherson wrote: > Don't waste time writing zeros via VMWRITE during vCPU RESET, the VMCS > is zero allocated. Is this guaranteed to be valid, or could the VMCS in principle use some weird encoding? (Like it does for the access rights, even though this does not matter for this patch). Paolo > No functional change intended. > > Signed-off-by: Sean Christopherson > --- > arch/x86/kvm/vmx/vmx.c | 29 ----------------------------- > 1 file changed, 29 deletions(-) > > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > index 78d17adce7e6..74258ba4832a 100644 > --- a/arch/x86/kvm/vmx/vmx.c > +++ b/arch/x86/kvm/vmx/vmx.c > @@ -4427,13 +4427,6 @@ static void init_vmcs(struct vcpu_vmx *vmx) > } > > if (kvm_vcpu_apicv_active(&vmx->vcpu)) { > - vmcs_write64(EOI_EXIT_BITMAP0, 0); > - vmcs_write64(EOI_EXIT_BITMAP1, 0); > - vmcs_write64(EOI_EXIT_BITMAP2, 0); > - vmcs_write64(EOI_EXIT_BITMAP3, 0); > - > - vmcs_write16(GUEST_INTR_STATUS, 0); > - > vmcs_write16(POSTED_INTR_NV, POSTED_INTR_VECTOR); > vmcs_write64(POSTED_INTR_DESC_ADDR, __pa((&vmx->pi_desc))); > } > @@ -4444,23 +4437,9 @@ static void init_vmcs(struct vcpu_vmx *vmx) > vmx->ple_window_dirty = true; > } > > - vmcs_write32(PAGE_FAULT_ERROR_CODE_MASK, 0); > - vmcs_write32(PAGE_FAULT_ERROR_CODE_MATCH, 0); > - vmcs_write32(CR3_TARGET_COUNT, 0); /* 22.2.1 */ > - > - vmcs_write16(HOST_FS_SELECTOR, 0); /* 22.2.4 */ > - vmcs_write16(HOST_GS_SELECTOR, 0); /* 22.2.4 */ > vmx_set_constant_host_state(vmx); > - vmcs_writel(HOST_FS_BASE, 0); /* 22.2.4 */ > - vmcs_writel(HOST_GS_BASE, 0); /* 22.2.4 */ > > - if (cpu_has_vmx_vmfunc()) > - vmcs_write64(VM_FUNCTION_CONTROL, 0); > - > - vmcs_write32(VM_EXIT_MSR_STORE_COUNT, 0); > - vmcs_write32(VM_EXIT_MSR_LOAD_COUNT, 0); > vmcs_write64(VM_EXIT_MSR_LOAD_ADDR, __pa(vmx->msr_autoload.host.val)); > - vmcs_write32(VM_ENTRY_MSR_LOAD_COUNT, 0); > vmcs_write64(VM_ENTRY_MSR_LOAD_ADDR, __pa(vmx->msr_autoload.guest.val)); > > if (vmcs_config.vmentry_ctrl & VM_ENTRY_LOAD_IA32_PAT) > @@ -4493,7 +4472,6 @@ static void init_vmcs(struct vcpu_vmx *vmx) > memset(&vmx->pt_desc, 0, sizeof(vmx->pt_desc)); > /* Bit[6~0] are forced to 1, writes are ignored. */ > vmx->pt_desc.guest.output_mask = 0x7F; > - vmcs_write64(GUEST_IA32_RTIT_CTL, 0); > } > > vmx_setup_uret_msrs(vmx); > @@ -4536,13 +4514,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); > >