Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2643242rda; Wed, 25 Oct 2023 08:25:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFXviW62wCWUOwWm/gUlutg71mp/NYcvOTgh1umPSa48noTBQj0WtE3m6/vNFRJOay/uSeb X-Received: by 2002:a05:6808:4a:b0:3b2:e0fa:61e4 with SMTP id v10-20020a056808004a00b003b2e0fa61e4mr16646082oic.25.1698247519959; Wed, 25 Oct 2023 08:25:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698247519; cv=none; d=google.com; s=arc-20160816; b=UlF8soh6YPo6xjOuWgIzpO830P+v6nB7Uze6ZeH1iFeFWULS+cVgTNrpTYXFtybkX0 pV6xE8wv08sZB6S6O0Z3osWcZfSnGERZsEN5D7W8JhIjoYu3dlnnJLffoe5fUgao2vNn Ct5pEHNPTmxUi+AQDPn6On1reF/GCPJxC0ePfWVjF3pWnkKLulWaVbIccEvwABvc55gl IO7u/niXzsfZnGbzRrv5VXViu6LlvvmAAc4JuxaODXQd5orrhTgwXHz1LkpsmJ2AgRPR b7DwKDDIcZBwphqxht1exU6uhwJ8oEwR3GKPP2Ej67+HbiGxpAicD+PfziFhwlwT7gO9 yBDg== 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=/UY00r4KJgutxwf++YFP2KIoZ7cjz3Yt618EIRpz4fA=; fh=WR6Fy7kGCroNKSS5jHjX5LaQseGeTC3TD3lkK7gcJQQ=; b=C8QF/oiN+RoCzwbcH0oL5zc2mxWpHGQx6BYCfopHdCrk3H0uGP0z5XAjk4NcFwq6Rt ECkXRsCzeWT4cMqnK5w5/Gi3zvTXVXWiiD8M8kGvYrVM78QLRXjAICtXzaPxNVI4vuql ibaYwhogShoi4W5D8Y5FC5Pmb1Cm0rfG15hymaz9Y/imvJLPGJicfP7Is/ko9BVvk23H FuewKURRcYT++wh+ZXtczYXJ5pUIBXF60tumV4rCkuuOEwQ4+RPhyGvoCbzdnM4gWy1V 3UmaurXwMZOG1LNbcMJUB9VHf0P4mcE6ElVvvTMFl4MviF+Pz+V86jr18UCsKbqgzyMR eQ/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RiwrYz2C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id e130-20020a25e788000000b00d9ac969cb05si10625657ybh.284.2023.10.25.08.25.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 08:25:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RiwrYz2C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 04627802CFB5; Wed, 25 Oct 2023 08:25:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234999AbjJYPY6 (ORCPT + 99 others); Wed, 25 Oct 2023 11:24:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232469AbjJYPY5 (ORCPT ); Wed, 25 Oct 2023 11:24:57 -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 B5E0412A for ; Wed, 25 Oct 2023 08:24:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698247451; 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=/UY00r4KJgutxwf++YFP2KIoZ7cjz3Yt618EIRpz4fA=; b=RiwrYz2CBTuwFfHJRJUmt1xsx/CW6gfSUKyfnSBhWscQ/4wjDXcflEeHCge1o9ynzPsVzP dAIkk8pbwU9gdgCPTfR9m9pAkQ3RUhfCJK8FpzzfMgFgAYZxJXX+mxKVIdHo9XgjgcUzc/ K135QiNtBLbu0zZCToRP0HdkOe5Ee3Q= 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-642-b95o5wwuO0ifj5N-nPufZg-1; Wed, 25 Oct 2023 11:24:09 -0400 X-MC-Unique: b95o5wwuO0ifj5N-nPufZg-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 564A0802891; Wed, 25 Oct 2023 15:24:09 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.226.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 69EB12166B26; Wed, 25 Oct 2023 15:24:08 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini , Sean Christopherson , Maxim Levitsky Cc: linux-kernel@vger.kernel.org Subject: [PATCH 01/14] KVM: x86: xen: Remove unneeded xen context from struct kvm_arch when !CONFIG_KVM_XEN Date: Wed, 25 Oct 2023 17:23:53 +0200 Message-ID: <20231025152406.1879274-2-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 howler.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 (howler.vger.email [0.0.0.0]); Wed, 25 Oct 2023 08:25:12 -0700 (PDT) Saving a few bytes of memory per KVM VM is certainly great but what's more important is the ability to see where the code accesses Xen emulation context while CONFIG_KVM_XEN is not enabled. Currently, kvm_cpu_get_extint() is the only such place and it is harmless: kvm_xen_has_interrupt() always returns '0' when !CONFIG_KVM_XEN. No functional change intended. Reviewed-by: Maxim Levitsky Signed-off-by: Vitaly Kuznetsov --- arch/x86/include/asm/kvm_host.h | 5 +++++ arch/x86/kvm/irq.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 394e1a31c02c..d107516b4591 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1136,6 +1136,7 @@ struct msr_bitmap_range { unsigned long *bitmap; }; +#ifdef CONFIG_KVM_XEN /* Xen emulation context */ struct kvm_xen { struct mutex xen_lock; @@ -1147,6 +1148,7 @@ struct kvm_xen { struct idr evtchn_ports; unsigned long poll_mask[BITS_TO_LONGS(KVM_MAX_VCPUS)]; }; +#endif enum kvm_irqchip_mode { KVM_IRQCHIP_NONE, @@ -1349,7 +1351,10 @@ struct kvm_arch { struct hlist_head mask_notifier_list; struct kvm_hv hyperv; + +#ifdef CONFIG_KVM_XEN struct kvm_xen xen; +#endif bool backwards_tsc_observed; bool boot_vcpu_runs_old_kvmclock; diff --git a/arch/x86/kvm/irq.c b/arch/x86/kvm/irq.c index b2c397dd2bc6..ad9ca8a60144 100644 --- a/arch/x86/kvm/irq.c +++ b/arch/x86/kvm/irq.c @@ -118,8 +118,10 @@ static int kvm_cpu_get_extint(struct kvm_vcpu *v) if (!lapic_in_kernel(v)) return v->arch.interrupt.nr; +#ifdef CONFIG_KVM_XEN if (kvm_xen_has_interrupt(v)) return v->kvm->arch.xen.upcall_vector; +#endif if (irqchip_split(v->kvm)) { int vector = v->arch.pending_external_vector; -- 2.41.0