From patchwork Tue Oct 10 16:02:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitaly Kuznetsov X-Patchwork-Id: 150861 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp310532vqb; Tue, 10 Oct 2023 09:05:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE3qJfIDRPj6CT8JXjyPg/aHi4HDVRvrLjUKJZKR/K8gUp2luItKZLap/IJKgH3ADuaHOeG X-Received: by 2002:a17:90b:4a07:b0:279:7963:cdf2 with SMTP id kk7-20020a17090b4a0700b002797963cdf2mr15219635pjb.0.1696953900406; Tue, 10 Oct 2023 09:05:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696953900; cv=none; d=google.com; s=arc-20160816; b=OZ+w4+0h6cq6jTQxAOsDgUO+IBXOh+U4N1PZrsyG8CsHrHsm99sNj0BkyrFMaRKZak pZ/lQMZzCBIdyzfu0JGccF1MWDl3BvXwYaRAQFuTS5Gy3lS4J38pUIMZc01DCXpLwsH2 +FfMkaV+F41P/VcINjmiXaLpManepyZxAjxsaFdbjcx6zN1uEdHD7OztwwCD8hmSw55L 2mC9aBF1bnkHr8TfhvI3LsXNlErmmpLeTjf2bP/rYMpRF67c5V5pbFIwT0HZ2+cb/zWq OlDxYkLUqTezPg9cUI6mpev20422dNteoNHMUfs9zvszKETPimYnBdfpTQylj1YpL+zq K4FA== 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=NWcz0QuaamBHPubxsGVpnjxU2WbSV2mTYTPQXIgc2HM=; fh=SJRVlyvhIPEM+1ZkklEUy6ba01ZQIQ4PgkK8h+im/FM=; b=kp7LHbKFua07flh0hzVmhK9nbKvpBvN4WW4PXkndm+YAEjTg/PZHdifa/maTShHkWp qvFY0v+L4Z2zJjDWwI6SYEXCVK+GfL4DFIDk3zRbEX9tFa7SNxB5Y6ASUcAAu5uAC29h mlFpG3iSkjY2O3mndVowD+nMl3qBNu3MY1AddrskcQ6Kkre75UpfX5IJ6Cdnjwt03uaM Yr1Cd8S4vU/8iPEvGbBPmWZ8ve5EKy9RpZveZn7LMg8Nz0u4shqNkz27HedBySQMyRaK xaPLZQ6Ip9uI0CiWj9LHcik7K1reT1RkupN4j+N3F3widifQF9ThOZkIsNO5mR0/vB6S l2wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fM9xEkGq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id m3-20020a17090a7f8300b002790b1320d4si14181337pjl.84.2023.10.10.09.05.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 09:05:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fM9xEkGq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 335FA81BB4E5; Tue, 10 Oct 2023 09:04:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233961AbjJJQEb (ORCPT + 20 others); Tue, 10 Oct 2023 12:04:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233751AbjJJQEI (ORCPT ); Tue, 10 Oct 2023 12:04:08 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11196E0 for ; Tue, 10 Oct 2023 09:03:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696953801; 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=NWcz0QuaamBHPubxsGVpnjxU2WbSV2mTYTPQXIgc2HM=; b=fM9xEkGqk0JhjrT7bI7TF5mXuTYO/Yu/y6sLBEV2x0Ze6CsESKVF+Ge/6zjqFyo3PwV3u2 j+r9/lesM/xAtdgv6xcQiLZxUMjcwt1y2XlgM5/9F+U9KSV1bid1Ru5TMfBdQmNLvo4q/X CkowttAiaTomHJ2Slb840srgjGXClTs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-617-bo9lrJ0uMFeRNKVEJqenWQ-1; Tue, 10 Oct 2023 12:03:13 -0400 X-MC-Unique: bo9lrJ0uMFeRNKVEJqenWQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EAA2485A5BE; Tue, 10 Oct 2023 16:03:12 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.226.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26FBE1B94; Tue, 10 Oct 2023 16:03:12 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini , Sean Christopherson Cc: linux-kernel@vger.kernel.org Subject: [PATCH RFC 10/11] KVM: nVMX: hyper-v: Hide more stuff under CONFIG_KVM_HYPERV Date: Tue, 10 Oct 2023 18:02:59 +0200 Message-ID: <20231010160300.1136799-11-vkuznets@redhat.com> In-Reply-To: <20231010160300.1136799-1-vkuznets@redhat.com> References: <20231010160300.1136799-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 10 Oct 2023 09:04:54 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779385133160060968 X-GMAIL-MSGID: 1779385133160060968 'hv_evmcs_vmptr'/'hv_evmcs_map'/'hv_evmcs' fields in 'struct nested_vmx' should not be used when !CONFIG_KVM_HYPERV, hide them when !CONFIG_KVM_HYPERV. No functional change intended. Signed-off-by: Vitaly Kuznetsov Reviewed-by: Maxim Levitsky --- arch/x86/kvm/vmx/nested.c | 2 ++ arch/x86/kvm/vmx/vmx.c | 3 +++ arch/x86/kvm/vmx/vmx.h | 2 ++ 3 files changed, 7 insertions(+) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index d539904d8f1e..10cb35cd7a19 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -6650,6 +6650,7 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu, return -EINVAL; set_current_vmptr(vmx, kvm_state->hdr.vmx.vmcs12_pa); +#ifdef CONFIG_KVM_HYPERV } else if (kvm_state->flags & KVM_STATE_NESTED_EVMCS) { /* * nested_vmx_handle_enlightened_vmptrld() cannot be called @@ -6659,6 +6660,7 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu, */ vmx->nested.hv_evmcs_vmptr = EVMPTR_MAP_PENDING; kvm_make_request(KVM_REQ_GET_NESTED_STATE_PAGES, vcpu); +#endif } else { return -EINVAL; } diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 04eb5d4d28bc..3b1bd3d97150 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -4834,7 +4834,10 @@ static void __vmx_vcpu_reset(struct kvm_vcpu *vcpu) vmx->nested.posted_intr_nv = -1; vmx->nested.vmxon_ptr = INVALID_GPA; vmx->nested.current_vmptr = INVALID_GPA; + +#ifdef CONFIG_KVM_HYPERV vmx->nested.hv_evmcs_vmptr = EVMPTR_INVALID; +#endif vcpu->arch.microcode_version = 0x100000000ULL; vmx->msr_ia32_feature_control_valid_bits = FEAT_CTL_LOCKED; diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h index c2130d2c8e24..55addb8eef01 100644 --- a/arch/x86/kvm/vmx/vmx.h +++ b/arch/x86/kvm/vmx/vmx.h @@ -241,9 +241,11 @@ struct nested_vmx { bool guest_mode; } smm; +#ifdef CONFIG_KVM_HYPERV gpa_t hv_evmcs_vmptr; struct kvm_host_map hv_evmcs_map; struct hv_enlightened_vmcs *hv_evmcs; +#endif }; struct vcpu_vmx {