Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2645818rda; Wed, 25 Oct 2023 08:29:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1waMIT17fowkja+4VgE6y0/m7C1lJMYtoi/XJQ2lw9C84RyK36VYVUORMcMyOg21mgL1i X-Received: by 2002:a05:6830:1056:b0:6bd:a47:7bb6 with SMTP id b22-20020a056830105600b006bd0a477bb6mr13745078otp.14.1698247752476; Wed, 25 Oct 2023 08:29:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698247752; cv=none; d=google.com; s=arc-20160816; b=Fq5QYa3azF+W+JA6Xi0NMCUc0r2IWVJe+QTBSiExAP3GHx++LgP3KssQyC6nubavSb uBhMYttSL+EJE8U1J88a0XPRcEx+rRJcn2RJbMZWS9OVxh1KxqO8Us3sleRBu/QiFx7l T07jh8897/C34h+nmOtLZEgTcFA+FPhDKr3nGsqVMqqyJOzkiGRll0SY1j6wQdgtC9o0 4K0DLo0oRdY7GnkUlJA9uD7IYqsf801Vs0A5KGMzDbCj4xxS3qKUYQRQ3TbKhJSK5vDz /wV1+fo1beOQumG4Fn5X9gXkJhUOoS4k9Sa/Ym8Q/8twEtpzdzPuhgn/fcZCR/Qqz/W/ 3rPA== 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=JCE307w8DYtYzLu55wqwBWYbWWwCcRl3VdLWWJ4IDuA=; fh=WR6Fy7kGCroNKSS5jHjX5LaQseGeTC3TD3lkK7gcJQQ=; b=fd90uo0Hfo4kd6/oGjjY2JWzZBfvBYdCenFZm3HejP5GMv1aDSLUl/c15r29tgN5SR gmaryr5yFf+1AXkQ+5/es09arvocmi5LK1aKORzUd3RxWqIt03nhGagIBtfOndcUbzux cBGy7KRwGXhoOi/q0YE4fLDkDHq7PMQoSIFKMRBlDsHcAD19CGrdZZjlf/CaaU3XJNRH XjPcImgj4IIIQP1VHVj6m8SkFzgtvlw8ohAJsWuPfSqTUeo8FaMqplesICbhM9rwQfia 91btmUm/rnYxf71wg29JKkbJiPt9qSWWNVw4IloOo4qUd43vStI8JQ9Z7S71myZPLIcO lYtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ieSDagiS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id s66-20020a0dd045000000b005a4c231c8b5si11732399ywd.292.2023.10.25.08.29.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 08:29:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ieSDagiS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 A21E1812E374; Wed, 25 Oct 2023 08:29:00 -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 S1344793AbjJYP1Z (ORCPT + 99 others); Wed, 25 Oct 2023 11:27:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344785AbjJYP0o (ORCPT ); Wed, 25 Oct 2023 11:26:44 -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 DB60619F for ; Wed, 25 Oct 2023 08:24:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698247473; 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=JCE307w8DYtYzLu55wqwBWYbWWwCcRl3VdLWWJ4IDuA=; b=ieSDagiSKO9GOp4/PNISwZYE3kURfWXJ1fsmGFLI41C6IEEmXgBTDFnazB5SxApIH5sP/f OgBOAQFO3CBU9qzErZf5DXBt/k6ccRF1oprJr4KqMwz4EdCStjLi/2VwuxD/JWU1O/kj74 JQWUvROwaftfKwkagROxEMS2tRF3cWE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-620-HihJVEyBPzqMWpDA9xkrHg-1; Wed, 25 Oct 2023 11:24:24 -0400 X-MC-Unique: HihJVEyBPzqMWpDA9xkrHg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 47F6B185A789; Wed, 25 Oct 2023 15:24:24 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.226.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5AAF82166B26; Wed, 25 Oct 2023 15:24:23 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini , Sean Christopherson , Maxim Levitsky Cc: linux-kernel@vger.kernel.org Subject: [PATCH 14/14] KVM: nSVM: hyper-v: Hide more stuff under CONFIG_KVM_HYPERV/CONFIG_HYPERV Date: Wed, 25 Oct 2023 17:24:06 +0200 Message-ID: <20231025152406.1879274-15-vkuznets@redhat.com> In-Reply-To: <20231025152406.1879274-1-vkuznets@redhat.com> References: <20231025152406.1879274-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.6 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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]); Wed, 25 Oct 2023 08:29:00 -0700 (PDT) 'struct hv_vmcb_enlightenments' in VMCB only make sense when either CONFIG_KVM_HYPERV or CONFIG_HYPERV is enabled. No functional change intended. Reviewed-by: Maxim Levitsky 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 74c04102ef01..20212aac050b 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