Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp471508rdb; Tue, 19 Sep 2023 00:25:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEf7BBsgPZD2vUhisXP0aNJElEEqQes6K5hJMBJ6gUKC82vGMUvu5/azziIwDK8bfdMGloW X-Received: by 2002:a17:90a:2a0f:b0:268:15f5:9191 with SMTP id i15-20020a17090a2a0f00b0026815f59191mr10898067pjd.36.1695108320030; Tue, 19 Sep 2023 00:25:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695108320; cv=none; d=google.com; s=arc-20160816; b=hhmkfl9CIQr8fWdlPS37FIPvH9eNCe2+0BrcZfLngR5V4vfI7uxz6IhT0VHQkwmuVv /NTz9ru+6lrZyZ/o9VbnGyURKtzTQ7hbKGDnTZ9nVI09JuAo5btM4tGhil6w9I5GItCN eX2yNvHwaX89HPB0V2C8LsQQsD4gYjDYVDvWMLIwrHsVOfeLKfn04W7WgwOY2JtNharo WhWBPqmOzRQZjtr4r66Uj16yuVgMy/Pe9Eam7Vvx8ZKZYmsVGF5u8OK+aNhtkEpF/Rd3 ItJ8wpyZ8Ldj/iJNC9rKmr04/a7Sil16rtvpXalq57KTXObKbcnVxZUnWQkoj2EqjQi/ 5FiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=bS/lJoH3L9FxG8X53V4Tq19fvrqY0he1EUARIKyLRGo=; fh=X76b0S9MjgH4l53FcWzDKTpXTkHyZ97zz1+LlFXz+Fk=; b=EvKm81lMEn/0DI74ZERZbKOZdBb/uVD1Cqwitx6NzyA+x8nBitPq5UZHAxejlzSLDm KCRmN9M9g5yj41ui7h1h1VX4hUAicAdM7lmbtDkvPrvlE8Qz3LeuqGlr73FBqtTd6A7H BXPtGeL7kKtwfBHHiAqqR6VDTL+q8mwiJFC4lHMawmJVUGPhmB2MWvtjuT1PUC45T6My OxjysWR307fNK0TTjuTpxDPgsT1IR7n27fBSFKrBfldXSVG4bt0akI1bIxUIHJNKqkoO ZW2P02ZF8MWMf18i0LaD87ULDlqBR/NWe/NsTPXMDXyhdrVTKJSirc8z/f6ln6sqJcKq qLnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=EEp9YaUY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id ds12-20020a17090b08cc00b00268278c51e3si2612644pjb.49.2023.09.19.00.25.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 00:25:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=EEp9YaUY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 946E580A07EE; Mon, 18 Sep 2023 22:30:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230454AbjISFaX (ORCPT + 99 others); Tue, 19 Sep 2023 01:30:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229960AbjISFaW (ORCPT ); Tue, 19 Sep 2023 01:30:22 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 69A0BFC; Mon, 18 Sep 2023 22:30:16 -0700 (PDT) Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 4FBE2212C48B; Mon, 18 Sep 2023 22:30:15 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4FBE2212C48B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1695101415; bh=bS/lJoH3L9FxG8X53V4Tq19fvrqY0he1EUARIKyLRGo=; h=From:To:Cc:Subject:Date:From; b=EEp9YaUYM3qMkV/+XK91LIsy7m5DWZKxbbsCsJen8UCzhrHF8ID+QDqMrsOCjT/+q xdUka3yi+1ZTVZRtpkLWceIho2Dgu5dH1K5ot7f6GQH0C4cY4mQa+DsgC1SRkMaLpW fEyiXgC1Bmta6EQEyM4OjTMZHV4rocdXsw3lcoRA= From: Saurabh Sengar To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, mikelley@microsoft.com, vkuznets@redhat.com Cc: ssengar@microsoft.com Subject: [PATCH v2] x86/hyperv: Restrict get_vtl to only VTL platforms Date: Mon, 18 Sep 2023 22:30:08 -0700 Message-Id: <1695101408-22432-1-git-send-email-ssengar@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Mon, 18 Sep 2023 22:30:37 -0700 (PDT) For non VTL platforms vtl is always 0, and there is no need of get_vtl function. For VTL platforms get_vtl should always succeed and should return the correct VTL. Signed-off-by: Saurabh Sengar --- [V2] - Put the if else at function definition rather then at the caller arch/x86/hyperv/hv_init.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c index 783ed339f341..f0128fd4031d 100644 --- a/arch/x86/hyperv/hv_init.c +++ b/arch/x86/hyperv/hv_init.c @@ -394,6 +394,7 @@ static void __init hv_get_partition_id(void) local_irq_restore(flags); } +#if IS_ENABLED(CONFIG_HYPERV_VTL_MODE) static u8 __init get_vtl(void) { u64 control = HV_HYPERCALL_REP_COMP_1 | HVCALL_GET_VP_REGISTERS; @@ -416,13 +417,16 @@ static u8 __init get_vtl(void) if (hv_result_success(ret)) { ret = output->as64.low & HV_X64_VTL_MASK; } else { - pr_err("Failed to get VTL(%lld) and set VTL to zero by default.\n", ret); - ret = 0; + pr_err("Failed to get VTL(error: %lld) exiting...\n", ret); + BUG(); } local_irq_restore(flags); return ret; } +#else +static inline u8 get_vtl(void) { return 0; } +#endif /* * This function is to be invoked early in the boot sequence after the @@ -604,8 +608,7 @@ void __init hyperv_init(void) hv_query_ext_cap(0); /* Find the VTL */ - if (!ms_hyperv.paravisor_present && hv_isolation_type_snp()) - ms_hyperv.vtl = get_vtl(); + ms_hyperv.vtl = get_vtl(); return; -- 2.34.1