Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp245368rdg; Tue, 10 Oct 2023 09:04:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGn9jIxGmMbBovnlBOVALjqyot/j201x0ZOcfGa+Abc5o7g+XHKn5QHAtOtTfuFjYoI79Rh X-Received: by 2002:a17:90b:1d85:b0:274:8f11:96c9 with SMTP id pf5-20020a17090b1d8500b002748f1196c9mr15150955pjb.44.1696953898927; Tue, 10 Oct 2023 09:04:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696953898; cv=none; d=google.com; s=arc-20160816; b=z4+MyG5cSqrx02E3I8qJLvW9eTd1fBa3J3AwsbtQU2FzRkpzVRKp5hbpV3+mSCul7B YV20EykVDI7bQ/DdVemomkRih/oAb1PwVjj+EATIkA39e2a90kXZAHzKX4N39Y2/UUnJ 6Xs9C6CfjhrKmtx3ArGjSwq5jeXfL1Erzj3+lvdyp9+aVuQcxArOgl6iOoba0lfO4hyp wVVAYBeijqZYoHO5o646FCoL8sPSHquGdTlr6rOG0jF+BWrZmfDSUYEFrVmvccfOv4kP eyDsopJA88GR1lS/0h+mdTJF8kVsedrtKbqknbfTTsFVOaDXLm+j7DJo5rFzq/ypzm4M wdWA== 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=0PzOYNiEjMNfxgDoRNUukN0hkebqWs832TM4JCa3Qvo=; fh=SJRVlyvhIPEM+1ZkklEUy6ba01ZQIQ4PgkK8h+im/FM=; b=Y+C5zklADVarlqpWBLXI/Hoh/k891mBro9y8qd+saeIV0VPVQ4iIhj6Voizf/RCHrE UivtJNSKsChN1Xr6FD+l1R7fllJQQ5cPH+MvybLfi1uNbomtluRYPSorr7mBR+T+wxOG YgRdTAyCJZBlZ0L3r+4GS52pdBVy8hqZCvhlX77RpbOsNqvhDBOfYfNL68SOFiNg7m/L MjV+PK8b+ZsGIMkR6pajlBDUF29+8DEJmL+dhofPdX1YB9Y3LV7XGPEZ/uQHeyDPRTLN /+SJHDDDOEU/LVomS7PGY9arwg7abCHj9PZTq5WJsvVqUWLRR3J5C/UDjchwo7aRpGoc z76Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ACzS66X6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id cu13-20020a17090afa8d00b002681fea6d14si1736693pjb.79.2023.10.10.09.04.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 09:04:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ACzS66X6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 16B32806E29F; Tue, 10 Oct 2023 09:04:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233895AbjJJQES (ORCPT + 99 others); Tue, 10 Oct 2023 12:04:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233786AbjJJQEG (ORCPT ); Tue, 10 Oct 2023 12:04:06 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A34CCC for ; Tue, 10 Oct 2023 09:03:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696953797; 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=0PzOYNiEjMNfxgDoRNUukN0hkebqWs832TM4JCa3Qvo=; b=ACzS66X6xxMLuwChwCYr3WgXmJCJXEG+GjdZCoeZ/rdxsZsSWouD3c3UDNA4o22sNOwxBs F4HgIOLLbWHUfYn85ieu2cDVbEJV1pnDMlkAPPIdhNX8oiqv4TcWghwT4QTDTmeV3L8RLd JKh49EdFWqFk2zjCyMZE3uwx3UKT/Qw= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-620-Vw-Xhwn5NZ23BnzXlR3Yqg-1; Tue, 10 Oct 2023 12:03:14 -0400 X-MC-Unique: Vw-Xhwn5NZ23BnzXlR3Yqg-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 EEF4C2932486; Tue, 10 Oct 2023 16:03:13 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.226.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B848158; Tue, 10 Oct 2023 16:03:13 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini , Sean Christopherson Cc: linux-kernel@vger.kernel.org Subject: [PATCH RFC 11/11] KVM: nSVM: hyper-v: Hide more stuff under CONFIG_KVM_HYPERV/CONFIG_HYPERV Date: Tue, 10 Oct 2023 18:03:00 +0200 Message-ID: <20231010160300.1136799-12-vkuznets@redhat.com> In-Reply-To: <20231010160300.1136799-1-vkuznets@redhat.com> References: <20231010160300.1136799-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit 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 pete.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 (pete.vger.email [0.0.0.0]); Tue, 10 Oct 2023 09:04:41 -0700 (PDT) X-Spam-Level: ** 'struct hv_vmcb_enlightenments' in VMCB only make sense when either CONFIG_KVM_HYPERV or CONFIG_HYPERV is enabled. No functional change intended. Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/svm/nested.c | 20 ++++++++++++++------ arch/x86/kvm/svm/svm.h | 2 ++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 4d8cd378a30b..5ae41a708005 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -187,7 +187,6 @@ void recalc_intercepts(struct vcpu_svm *svm) */ static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm) { - struct hv_vmcb_enlightenments *hve = &svm->nested.ctl.hv_enlightenments; int i; /* @@ -198,11 +197,16 @@ static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm) * - Nested hypervisor (L1) is using Hyper-V emulation interface and * tells KVM (L0) there were no changes in MSR bitmap for L2. */ - if (!svm->nested.force_msr_bitmap_recalc && - kvm_hv_hypercall_enabled(&svm->vcpu) && - hve->hv_enlightenments_control.msr_bitmap && - (svm->nested.ctl.clean & BIT(HV_VMCB_NESTED_ENLIGHTENMENTS))) - goto set_msrpm_base_pa; +#ifdef CONFIG_KVM_HYPERV + if (!svm->nested.force_msr_bitmap_recalc) { + struct hv_vmcb_enlightenments *hve = &svm->nested.ctl.hv_enlightenments; + + if (kvm_hv_hypercall_enabled(&svm->vcpu) && + hve->hv_enlightenments_control.msr_bitmap && + (svm->nested.ctl.clean & BIT(HV_VMCB_NESTED_ENLIGHTENMENTS))) + goto set_msrpm_base_pa; + } +#endif if (!(vmcb12_is_intercept(&svm->nested.ctl, INTERCEPT_MSR_PROT))) return true; @@ -230,7 +234,9 @@ static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm) svm->nested.force_msr_bitmap_recalc = false; +#ifdef CONFIG_KVM_HYPERV set_msrpm_base_pa: +#endif svm->vmcb->control.msrpm_base_pa = __sme_set(__pa(svm->nested.msrpm)); return true; @@ -378,12 +384,14 @@ void __nested_copy_vmcb_control_to_cache(struct kvm_vcpu *vcpu, to->msrpm_base_pa &= ~0x0fffULL; to->iopm_base_pa &= ~0x0fffULL; +#ifdef CONFIG_KVM_HYPERV /* Hyper-V extensions (Enlightened VMCB) */ if (kvm_hv_hypercall_enabled(vcpu)) { to->clean = from->clean; memcpy(&to->hv_enlightenments, &from->hv_enlightenments, sizeof(to->hv_enlightenments)); } +#endif } void nested_copy_vmcb_control_to_cache(struct vcpu_svm *svm, diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index be67ab7fdd10..59adff7bbf55 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -148,7 +148,9 @@ struct vmcb_ctrl_area_cached { u64 virt_ext; u32 clean; union { +#if IS_ENABLED(CONFIG_HYPERV) || IS_ENABLED(CONFIG_KVM_HYPERV) struct hv_vmcb_enlightenments hv_enlightenments; +#endif u8 reserved_sw[32]; }; }; -- 2.41.0