Message ID | 1695185552-19910-1-git-send-email-ssengar@linux.microsoft.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3908318vqi; Tue, 19 Sep 2023 23:09:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGqxnwuvwzmp7jVQO1dbMgLnHUmg1m73iRsHDTUm3HvNJPXXG02QglJHGfxM/LooxIDq4e5 X-Received: by 2002:a05:6a00:4a03:b0:68a:4102:e483 with SMTP id do3-20020a056a004a0300b0068a4102e483mr5511697pfb.14.1695190175632; Tue, 19 Sep 2023 23:09:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695190175; cv=none; d=google.com; s=arc-20160816; b=KVNLc+1UiBllwhVpn/MjR9y9bZ6/cD0DsdQ7+J17g+XMkD5rpJx84r5d9htbz+Yav1 1kz4YUrY8aJO27f83d39BCVfhFXVLmUDdluWD4QAkS+9idSNuMbLXim/YXUhhUkN5KAM SeVSShcT4ynEubKUogtK6yPaDk39sqcFlBg7mpIUHL0QTkOCg7qIrk98hpodez7Antys AYDA0D8uLRCEs8zBW+dUdNdDAGakHXvl/NyXoRZDSiwEE+T2/UO4gfptFdzckli2PRby RyHK+axl8ggIfecAjZl/7LzpaXGn1l59KYcB6oKQZSNhJ18Ls9RU51+CiirKe3LvzGt9 zeKA== 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 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id w8-20020a63f508000000b005777535a67bsi2233893pgh.746.2023.09.19.23.09.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 23:09:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; 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 23.128.96.31 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 7A345826EBB2; Tue, 19 Sep 2023 21:53:09 -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 S231347AbjITEwr (ORCPT <rfc822;toshivichauhan@gmail.com> + 26 others); Wed, 20 Sep 2023 00:52:47 -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 <rfc822;linux-kernel@vger.kernel.org>); 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 <ssengar@linux.microsoft.com> 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: <linux-kernel.vger.kernel.org> 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:53:09 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777535733423808332 X-GMAIL-MSGID: 1777535733423808332 |
Series |
x86/hyperv: Remove hv_vtl_early_init initcall
|
|
Commit Message
Saurabh Singh Sengar
Sept. 20, 2023, 4:52 a.m. UTC
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 <minipli@grsecurity.net>
Closes: https://lore.kernel.org/lkml/40467722-f4ab-19a5-4989-308225b1f9f0@grsecurity.net/
Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com>
---
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(-)
Comments
On 20.09.23 06:52, Saurabh Sengar wrote: > 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 <minipli@grsecurity.net> > Closes: https://lore.kernel.org/lkml/40467722-f4ab-19a5-4989-308225b1f9f0@grsecurity.net/ > Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com> > --- > 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(); > + As the kernel's console will already be initialized when this code gets executed, the possible panic() in hv_vtl_early_init() will actually be visible, thereby... > 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 <asm-generic/mshyperv.h> Acked-by: Mathias Krause <minipli@grsecurity.net> Thanks!
On Thu, Sep 21, 2023 at 09:17:24AM +0200, Mathias Krause wrote: > On 20.09.23 06:52, Saurabh Sengar wrote: > > 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 vhv_vtl_early_init need to be replaced with hv_vtl_early_init here. Wei, Do you need a V2 for it ? - Saurabh
Missed it in my review, but the kernel bot already noticed it, so.... On 20.09.23 06:52, Saurabh Sengar wrote: > [...] > 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) {} static inline > #endif > > #include <asm-generic/mshyperv.h> Thanks, Mathias
On Thu, Sep 21, 2023 at 08:27:09PM +0200, Mathias Krause wrote: > Missed it in my review, but the kernel bot already noticed it, so.... > > On 20.09.23 06:52, Saurabh Sengar wrote: > > [...] > > 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) {} > > static inline Thanks, will send v2 fixing this and the other typo in commit Regards, Saurabh > > > #endif > > > > #include <asm-generic/mshyperv.h> > > Thanks, > Mathias
Hi Saurabh,
kernel test robot noticed the following build warnings:
[auto build test WARNING on v6.6-rc2]
[also build test WARNING on linus/master next-20230920]
[cannot apply to tip/x86/core]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Saurabh-Sengar/x86-hyperv-Remove-hv_vtl_early_init-initcall/20230920-125357
base: v6.6-rc2
patch link: https://lore.kernel.org/r/1695185552-19910-1-git-send-email-ssengar%40linux.microsoft.com
patch subject: [PATCH] x86/hyperv: Remove hv_vtl_early_init initcall
config: i386-tinyconfig (https://download.01.org/0day-ci/archive/20230920/202309201327.J4pfXnUv-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230920/202309201327.J4pfXnUv-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <yujie.liu@intel.com>
| Closes: https://lore.kernel.org/r/202309201327.J4pfXnUv-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from arch/x86/mm/pat/set_memory.c:36:
arch/x86/include/asm/mshyperv.h: In function 'hv_vtl_early_init':
arch/x86/include/asm/mshyperv.h:346:1: error: no return statement in function returning non-void [-Werror=return-type]
346 | static int __init hv_vtl_early_init(void) {}
| ^~~~~~
arch/x86/include/asm/mshyperv.h: At top level:
>> arch/x86/include/asm/mshyperv.h:346:19: warning: 'hv_vtl_early_init' defined but not used [-Wunused-function]
346 | static int __init hv_vtl_early_init(void) {}
| ^~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/hv_vtl_early_init +346 arch/x86/include/asm/mshyperv.h
79cadff2d92bb8 Vitaly Kuznetsov 2017-08-02 339
765e33f5211ab6 Michael Kelley 2019-05-30 340
3be1bc2fe9d2e4 Saurabh Sengar 2023-04-10 341 #ifdef CONFIG_HYPERV_VTL_MODE
3be1bc2fe9d2e4 Saurabh Sengar 2023-04-10 342 void __init hv_vtl_init_platform(void);
9081cfc5d0e7fa Saurabh Sengar 2023-09-19 343 int __init hv_vtl_early_init(void);
3be1bc2fe9d2e4 Saurabh Sengar 2023-04-10 344 #else
3be1bc2fe9d2e4 Saurabh Sengar 2023-04-10 345 static inline void __init hv_vtl_init_platform(void) {}
9081cfc5d0e7fa Saurabh Sengar 2023-09-19 @346 static int __init hv_vtl_early_init(void) {}
3be1bc2fe9d2e4 Saurabh Sengar 2023-04-10 347 #endif
3be1bc2fe9d2e4 Saurabh Sengar 2023-04-10 348
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 <asm-generic/mshyperv.h>