From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30591C433E6 for ; Sat, 6 Feb 2021 00:49:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E423464FEC for ; Sat, 6 Feb 2021 00:49:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230185AbhBFAtC (ORCPT ); Fri, 5 Feb 2021 19:49:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230097AbhBEKFM (ORCPT ); Fri, 5 Feb 2021 05:05:12 -0500 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DD6FC061223 for ; Fri, 5 Feb 2021 02:04:08 -0800 (PST) Received: by mail-pj1-x102a.google.com with SMTP id my11so6447076pjb.1 for ; Fri, 05 Feb 2021 02:04:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=S5g3KjTF37TfcHKlT3L6KJoPEPgIVLEViokSkw93MzU=; b=NXRvu6Mnnlo7bgBrUUIn4t4Py1dZWIR+iWJS9IGIJy89jR/CnbPG3INRt2VQqKEoV8 vnS/Cg8artOGcsgd1Vb5W0KhHS//WSeUkfEgXw8qBfUeVYrQj+Aig6fVHXGlvH2zBuSL TU4wpoklPl1ieNayE/H/EnvxcmAUrAUiMEs9wHnxZPMlLw8XeEjmtqJfw34O88dNYpSB OSS4wjN3lk3BnVRfM3mFLh25K6f5qrAZ7bvHHW6jy+8/ZTz+kmFIIGI816uwiVMmXMiA 4libcPKqHMrOP+xVaijWjRIwqXKtLJSOuaUxofbNn51HcIHcQirXLBQm0Cqai90DBuJE 2K/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=S5g3KjTF37TfcHKlT3L6KJoPEPgIVLEViokSkw93MzU=; b=t2TGpdoZ2nw1Gk3mermV6Zoo9ObokoDQVlUamjdxQUb5duXggIIqGhSCEyQsRCiM5Y L8aIPrxWCKY1PXMPc7ItCRmj40P8gVZWjljelAB6ojqhf51dLQ2JsEfEfEPeEpNl1vz8 n54C8KLnZqVihhDt7bDNe+KHlOBqKRnnlXCTZFq6JTnLoMxaUoXYoo7rclCfkvHqPQ0I zd3k8+VU43bJOkbcMuZGGD4E5jcAG0E5ppWaOOCJsBO3MSoMeqS1n35i60avbZ+rvlio 0H3zz17Wd7ZDjpq+Mw2+Ezcd0jK4uKiYrf+Y0S9UmkByDjQR7BI5xtmYusJfrIbegblp +5OQ== X-Gm-Message-State: AOAM530AtxIE26OvIAhPZP+WzsTrdPls0zKKkSqzv8HH7F3kz+k0gs/z 0NLj4/X1qStcYKUeIU3f96Ul1A== X-Google-Smtp-Source: ABdhPJxgNSKPC+0Mk1BDOTDZhST6pkHg6VyxZAKvFAFFq3bpv58uknmblJNTXZ18cdNScr+AVMt9yw== X-Received: by 2002:a17:90a:468e:: with SMTP id z14mr3576479pjf.174.1612519447834; Fri, 05 Feb 2021 02:04:07 -0800 (PST) Received: from C02CC49MMD6R.bytedance.net ([139.177.225.239]) by smtp.gmail.com with ESMTPSA id l12sm8142562pjg.54.2021.02.05.02.04.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Feb 2021 02:04:07 -0800 (PST) From: Zhimin Feng To: x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: pbonzini@redhat.com, seanjc@google.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, fweisbec@gmail.com, zhouyibo@bytedance.com, zhanghaozhong@bytedance.com, Zhimin Feng Subject: [RFC: timer passthrough 6/9] KVM: vmx: check enable_timer_passth strictly Date: Fri, 5 Feb 2021 18:03:14 +0800 Message-Id: <20210205100317.24174-7-fengzhimin@bytedance.com> X-Mailer: git-send-email 2.24.1 (Apple Git-126) In-Reply-To: <20210205100317.24174-1-fengzhimin@bytedance.com> References: <20210205100317.24174-1-fengzhimin@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org preemption timer is default disabled timer passthrough is default enabled Signed-off-by: Zhimin Feng --- arch/x86/kvm/vmx/vmx.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 44b2fd59587e..a12da3cef86d 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -126,12 +126,12 @@ module_param(dump_invalid_vmcs, bool, 0644); /* Guest_tsc -> host_tsc conversion requires 64-bit division. */ static int __read_mostly cpu_preemption_timer_multi; -static bool __read_mostly enable_preemption_timer = 1; +static bool __read_mostly enable_preemption_timer; #ifdef CONFIG_X86_64 module_param_named(preemption_timer, enable_preemption_timer, bool, S_IRUGO); #endif -static bool __read_mostly enable_timer_passth; +static bool __read_mostly enable_timer_passth = 1; #ifdef CONFIG_X86_64 module_param_named(timer_passth, enable_timer_passth, bool, 0444); #endif @@ -8108,12 +8108,17 @@ static __init int hardware_setup(void) enable_preemption_timer = false; } - if (!enable_preemption_timer) { + if (!enable_preemption_timer || enable_timer_passth) { vmx_x86_ops.set_hv_timer = NULL; vmx_x86_ops.cancel_hv_timer = NULL; vmx_x86_ops.request_immediate_exit = __kvm_request_immediate_exit; } + if (enable_preemption_timer && enable_timer_passth) { + pr_err("cannot enable timer passthrough and preemption timer same timer\n"); + return -EINVAL; + } + kvm_set_posted_intr_wakeup_handler(pi_wakeup_handler); kvm_mce_cap_supported |= MCG_LMCE_P; -- 2.11.0