Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1305739rdb; Wed, 20 Sep 2023 05:50:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFKhe4PxiWmsqYXM72PuFY0Y+ZbsuCMLxYDcOSRMIvRT2sOWFVKEv6lCfiwb6Ymrbvyy3Jl X-Received: by 2002:a17:90b:3586:b0:274:8951:b5ed with SMTP id mm6-20020a17090b358600b002748951b5edmr3440752pjb.20.1695214207658; Wed, 20 Sep 2023 05:50:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695214207; cv=none; d=google.com; s=arc-20160816; b=CgWVLZ0J9UbLlWsMoiSU9o9brxwZEuSZ/FWvz6NdeEtP+xtGrKu55D2oya18OU27L4 6LgocFq6/zdVih2yEhz1lBQ+HeBem06YrTkNxfAyoYzEy6mmlElp6BNiQWrlb1Jp/xIu JiGQZoZHw24YQBansNQZuf2SZttkTNup1XjD98P2l+90cET2syqXLGiZF6xcHm2srw5v ym8vn8ualeoZDh1UlTYRnwYnnCrKWWIocjVQBgwpG3FTcm5wX2ENOyfU+jkObxLZ8nc8 mEVkXenKz+7fenVKOHGd+Lix5Cae4Viqe8ZpYCzJbljeXM+bCJErG9Hm8x2lkOvphftS 650Q== 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=nk8j8n5l3H6ZmjjGQXn6Qac2KVHEWrc13iwWOpAK64s=; fh=diQcnjKTNudP6DVBv2JRvKLhENNPY70FwDnSY9GqiaM=; b=EBOnhgmybsptcJS3FtKg6RaHJxx35H6ZOAAqRHD0aRTiqo0V8iCoB4ISr/tcppcwkY +3X31fccgk0WjyYLcmiEueoGveYo5z19+EOFibOB+ygNE791zf7bdwE1EUGEg09LaRVa RBFiHg6SDtBOSy6QVGKSNGOfOdQFvFaZzjwZcTd49ZURX90lPdGpEa9Oifi5g1xA+Oof oVdqho8E3fFPeVqBn7QWYa29s5zKi8pt1MXPJSIX9dBC2w/txXxyY0TtCtdN5XvCFbto R9+6cy3W/f6deuRqwH8BAqLymrC0fw5XPg4iy/ZuusR4V/Jyr7LdHbxr1U7GcCXMbwpR 9hJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=WqgMPhDi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id a17-20020a17090ad81100b00273edf4d3a5si1504751pjv.68.2023.09.20.05.50.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 05:50:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=WqgMPhDi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 063A6826EB89; Tue, 19 Sep 2023 21:52:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231191AbjITEwq (ORCPT + 99 others); Wed, 20 Sep 2023 00:52:46 -0400 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 S229534AbjITEwp (ORCPT ); Wed, 20 Sep 2023 00:52:45 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DFF7B9C; Tue, 19 Sep 2023 21:52:39 -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 5820E212C4AB; Tue, 19 Sep 2023 21:52:39 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5820E212C4AB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1695185559; bh=nk8j8n5l3H6ZmjjGQXn6Qac2KVHEWrc13iwWOpAK64s=; h=From:To:Cc:Subject:Date:From; b=WqgMPhDiZ4BklcqJlJHfmiokM/hJFbli9jKb/xJhhkjP+0cp5c5NF2zetmW38D6m7 BZm3PET2TI+8u8J4mINDSOlVh4OkLadUIEzugR9qxFfhYh7VEPjSgqmrxHw8jRrYqs gnPTNB/kfTFJ8L7a+pgiyNiaJZCTW2qkjcpPfhtM= 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 Cc: minipli@grsecurity.net, ssengar@microsoft.com Subject: [PATCH] x86/hyperv: Remove hv_vtl_early_init initcall Date: Tue, 19 Sep 2023 21:52:32 -0700 Message-Id: <1695185552-19910-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 morse.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 (morse.vger.email [0.0.0.0]); Tue, 19 Sep 2023 21:52:54 -0700 (PDT) There has been cases reported where HYPERV_VTL_MODE is enabled by mistake, on a non Hyper-V platforms. This causes the hv_vtl_early_init function to be called in an non Hyper-V/VTL platforms which results the memory corruption. Remove the early_initcall for vhv_vtl_early_init and call it at the end of hyperv_init to make sure it is never called in a non Hyper-V platform by mistake. Reported-by: Mathias Krause Closes: https://lore.kernel.org/lkml/40467722-f4ab-19a5-4989-308225b1f9f0@grsecurity.net/ Signed-off-by: Saurabh Sengar --- This patch is dependent on : https://lore.kernel.org/lkml/1695182675-13405-1-git-send-email-ssengar@linux.microsoft.com/ arch/x86/hyperv/hv_init.c | 3 +++ arch/x86/hyperv/hv_vtl.c | 3 +-- arch/x86/include/asm/mshyperv.h | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c index f0128fd4031d..608f4fe41fb7 100644 --- a/arch/x86/hyperv/hv_init.c +++ b/arch/x86/hyperv/hv_init.c @@ -610,6 +610,9 @@ void __init hyperv_init(void) /* Find the VTL */ ms_hyperv.vtl = get_vtl(); + if (ms_hyperv.vtl > 0) /* non default VTL */ + hv_vtl_early_init(); + return; clean_guest_os_id: diff --git a/arch/x86/hyperv/hv_vtl.c b/arch/x86/hyperv/hv_vtl.c index 36a562218010..999f5ac82fe9 100644 --- a/arch/x86/hyperv/hv_vtl.c +++ b/arch/x86/hyperv/hv_vtl.c @@ -215,7 +215,7 @@ static int hv_vtl_wakeup_secondary_cpu(int apicid, unsigned long start_eip) return hv_vtl_bringup_vcpu(vp_id, start_eip); } -static int __init hv_vtl_early_init(void) +int __init hv_vtl_early_init(void) { /* * `boot_cpu_has` returns the runtime feature support, @@ -230,4 +230,3 @@ static int __init hv_vtl_early_init(void) return 0; } -early_initcall(hv_vtl_early_init); diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h index 033b53f993c6..83019c3aaae9 100644 --- a/arch/x86/include/asm/mshyperv.h +++ b/arch/x86/include/asm/mshyperv.h @@ -340,8 +340,10 @@ static inline u64 hv_get_non_nested_register(unsigned int reg) { return 0; } #ifdef CONFIG_HYPERV_VTL_MODE void __init hv_vtl_init_platform(void); +int __init hv_vtl_early_init(void); #else static inline void __init hv_vtl_init_platform(void) {} +static int __init hv_vtl_early_init(void) {} #endif #include -- 2.34.1