From patchwork Thu Aug 31 12:56:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 718996 Delivered-To: patch@linaro.org Received: by 2002:adf:e5c2:0:b0:31d:da82:a3b4 with SMTP id a2csp462551wrn; Thu, 31 Aug 2023 06:11:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGr+KTvfCE8WLf9sBe/hhoCk/qp+uHjW0d5Jot1c3ybXaetG1ztIPPEsvGjA968LZPlWq87 X-Received: by 2002:ac8:7d0a:0:b0:413:5f84:424d with SMTP id g10-20020ac87d0a000000b004135f84424dmr2703518qtb.20.1693487473174; Thu, 31 Aug 2023 06:11:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693487473; cv=none; d=google.com; s=arc-20160816; b=ZxLFkhgMlp/ts0ivT4Xg5Rswlia7oi4E0Azf8d/41YpjrRJBTrGEIoONPvyDrgmnUu /1AHkFfRZQy8SVJkQZlg0xilbyJzB6MAtFOrX6pQHbPxW1f/7UGJILtu1yvsyVxCKD3j hCb8JaLiYoD6oF5gAJPHAqF3vAW7/fshAHq5aZWQKXjyYV9ANeL1sneAp/R2iAPHQXD+ tQtDPmnPJZGYyUiyevvERBBgG59hC0U/0U5/gQpqEOLEgrmpv5FDixZj7tiY5sgB7IiP LXzrbjKd4mrx3/KK4+bElvxTJOLgb93ISStzhmDCcz2efVnmUlYPryCR+IzSs/JV5nVs zrsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RBqrh3+OwbRO0FKJwz0pOQZiq7Hglu3XVSiWyrHauk4=; fh=W7c4U4W3/8gWLrb98VKeqowzGk5A+4yUlqQlX7h+jUQ=; b=MaPyxu9/U76ySXPSYKLfAlhctaIvsCsLP0MPJeNlW4I9F6Xt/WBiU1D0SKvgY4+CmP vObwv7ovK/lupwi6NsuWhiLF61LsxXStLK0AFGpRh72xq4PkiID1YLKdR66Y6n9RQGe3 LNHVdPp8w02RzaXezx6J2UIrtl14TKJzH+BdCcnA9mhzSLAFhxHTrv+c01hr07v+nMCV KGYaoH7g+nv7cn2wCPFI2WSs7NfswnAJIrCPC/AJp1Ka/rNH9LK88au8+cQUkvHapofk GDTSTJO+PykWL57aywuRCMIvrbC9Lnl1gIc+juO5+qg/sr/WyhDReVn/Xr7z8qcIHeQa tjbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="jwS/5IOw"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f19-20020ac859d3000000b004053818fc0esi872449qtf.605.2023.08.31.06.11.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 06:11:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="jwS/5IOw"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbhLT-0008BH-0T; Thu, 31 Aug 2023 09:04:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbhHU-0005kf-7b for qemu-devel@nongnu.org; Thu, 31 Aug 2023 09:00:22 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbhHN-0006Uw-AD for qemu-devel@nongnu.org; Thu, 31 Aug 2023 09:00:15 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3fee5ddc23eso7129215e9.1 for ; Thu, 31 Aug 2023 06:00:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693486807; x=1694091607; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RBqrh3+OwbRO0FKJwz0pOQZiq7Hglu3XVSiWyrHauk4=; b=jwS/5IOwS7px3CF7UdLJXiNGi0KzHBTBrNC3LNr1yrKDqhQx7fm3CUw4PBMeKW4J1H jc1OBsWy4pZKscTGUgc96/BfumC5sIiVKA5KpA7agOKtnX9Z3GCBWmbbX9DJi7nSswyr g5CQzniYwRsFnM7KXcYMLDaRq5++/3A8p7tqiEvw5FwqAe+ovuwV5WXBc3YWm5UwObqD Q6lYKRb6zjlV4HIDhZQCPc5DQErAWV4vfZ390BvPC9USoGs5L6m+FabLrs7g2XZPw0j3 awlETQmsyds6nj0Wh7DUw3/KJS5ok5b9lhC14HhenTs48OV7AHP+Tky/SfWMHoA3+wf8 paMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693486807; x=1694091607; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RBqrh3+OwbRO0FKJwz0pOQZiq7Hglu3XVSiWyrHauk4=; b=aD7Q/MAljKoXAcY4gBEtPtdXCJV3P5Ce+Zc9kojKQ6AllmTK1XweoSIrYRkJ7NDSBl OUlzXf5AVgxTbU7csxyUmsYEzA1RY5YIIHlylhv/TZfkn/lm/y7ek5NXv8C6lXmyt8do CH3tjCZ2BM6Xr+y8htAbFg1TOrPoS1NUL7L/M/NJWZUc5x4GbkBeSIUuOiOztBvLG2Ok sHqSQDIJHb7El/CcmM3dOTKK9ri4aY8TYdakcr8d0GdW8UDJKRtZP6zpRug0Ez2XulGq SlE+LAcxZWJHzQzZk26jU7gXzw5+gSiVfgwmPHZEjFgH1DcFGPCoXIGoqQhUoeyS6SC+ R05w== X-Gm-Message-State: AOJu0Yxo3lJ2TZ3w6xj6mz7/7Y++ktJKCxpkjk3O4Fr8FBLGknfMRUx4 RPvUaEytjQmp4/it9L9rkGGxWRUvma903D57ilE= X-Received: by 2002:adf:e5cf:0:b0:317:e542:80a8 with SMTP id a15-20020adfe5cf000000b00317e54280a8mr3780210wrn.15.1693486807461; Thu, 31 Aug 2023 06:00:07 -0700 (PDT) Received: from m1x-phil.lan ([176.187.199.245]) by smtp.gmail.com with ESMTPSA id i16-20020adffc10000000b0031c5ee51638sm2147619wrr.109.2023.08.31.06.00.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 31 Aug 2023 06:00:07 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Da?= =?utf-8?q?ud=C3=A9?= , =?utf-8?q?Alex_Benn=C3=A9e?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Sergio Lopez , kvm@vger.kernel.org Subject: [PULL 33/41] hw/i386: Remove unuseful kvmclock_create() stub Date: Thu, 31 Aug 2023 14:56:35 +0200 Message-ID: <20230831125646.67855-34-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230831125646.67855-1-philmd@linaro.org> References: <20230831125646.67855-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We shouldn't call kvmclock_create() when KVM is not available or disabled: - check for kvm_enabled() before calling it - assert KVM is enabled once called Since the call is elided when KVM is not available, we can remove the stub (it is never compiled). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Message-Id: <20230620083228.88796-2-philmd@linaro.org> --- include/hw/kvm/clock.h | 10 ---------- hw/i386/kvm/clock.c | 4 +++- hw/i386/microvm.c | 4 +++- hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 4 +++- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/include/hw/kvm/clock.h b/include/hw/kvm/clock.h index 7994071c4f..3efe0a871c 100644 --- a/include/hw/kvm/clock.h +++ b/include/hw/kvm/clock.h @@ -13,16 +13,6 @@ #ifndef HW_KVM_CLOCK_H #define HW_KVM_CLOCK_H -#ifdef CONFIG_KVM - void kvmclock_create(bool create_always); -#else /* CONFIG_KVM */ - -static inline void kvmclock_create(bool create_always) -{ -} - -#endif /* !CONFIG_KVM */ - #endif diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c index df70b4a033..0824c6d313 100644 --- a/hw/i386/kvm/clock.c +++ b/hw/i386/kvm/clock.c @@ -332,8 +332,10 @@ void kvmclock_create(bool create_always) { X86CPU *cpu = X86_CPU(first_cpu); - if (!kvm_enabled() || !kvm_has_adjust_clock()) + assert(kvm_enabled()); + if (!kvm_has_adjust_clock()) { return; + } if (create_always || cpu->env.features[FEAT_KVM] & ((1ULL << KVM_FEATURE_CLOCKSOURCE) | diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index 7227a2156c..6b762bc18e 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -180,7 +180,9 @@ static void microvm_devices_init(MicrovmMachineState *mms) x86ms->ioapic2 = ioapic_init_secondary(gsi_state); } - kvmclock_create(true); + if (kvm_enabled()) { + kvmclock_create(true); + } mms->virtio_irq_base = 5; mms->virtio_num_transports = 8; diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index ce1ac95274..3de8e0d741 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -192,7 +192,7 @@ static void pc_init1(MachineState *machine, pc_machine_init_sgx_epc(pcms); x86_cpus_init(x86ms, pcmc->default_cpu_version); - if (pcmc->kvmclock_enabled) { + if (kvm_enabled() && pcmc->kvmclock_enabled) { kvmclock_create(pcmc->kvmclock_create_always); } diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 37c4814bed..a95c5d046e 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -183,7 +183,9 @@ static void pc_q35_init(MachineState *machine) pc_machine_init_sgx_epc(pcms); x86_cpus_init(x86ms, pcmc->default_cpu_version); - kvmclock_create(pcmc->kvmclock_create_always); + if (kvm_enabled()) { + kvmclock_create(pcmc->kvmclock_create_always); + } /* pci enabled */ if (pcmc->pci_enabled) {