2020-08-04 16:22:38

by Luca Stefani

[permalink] [raw]
Subject: [PATCH] RAS/CEC: Fix cec_init prototype

* late_initcall expects a function to return an integer

Signed-off-by: Luca Stefani <[email protected]>
---
drivers/ras/cec.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/ras/cec.c b/drivers/ras/cec.c
index 569d9ad2c594..e048e0e3949a 100644
--- a/drivers/ras/cec.c
+++ b/drivers/ras/cec.c
@@ -553,20 +553,20 @@ static struct notifier_block cec_nb = {
.priority = MCE_PRIO_CEC,
};

-static void __init cec_init(void)
+static int __init cec_init(void)
{
if (ce_arr.disabled)
- return;
+ return 0;

ce_arr.array = (void *)get_zeroed_page(GFP_KERNEL);
if (!ce_arr.array) {
pr_err("Error allocating CE array page!\n");
- return;
+ return 1;
}

if (create_debugfs_nodes()) {
free_page((unsigned long)ce_arr.array);
- return;
+ return 1;
}

INIT_DELAYED_WORK(&cec_work, cec_work_fn);
@@ -575,6 +575,7 @@ static void __init cec_init(void)
mce_register_decode_chain(&cec_nb);

pr_info("Correctable Errors collector initialized.\n");
+ return 0;
}
late_initcall(cec_init);

--
2.28.0


2020-08-05 05:02:33

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH] RAS/CEC: Fix cec_init prototype

On Tue, Aug 04, 2020 at 06:18:47PM +0200, Luca Stefani wrote:
> * late_initcall expects a function to return an integer

Please write a proper sentence for a commit message.

> Signed-off-by: Luca Stefani <[email protected]>
> ---
> drivers/ras/cec.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/ras/cec.c b/drivers/ras/cec.c
> index 569d9ad2c594..e048e0e3949a 100644
> --- a/drivers/ras/cec.c
> +++ b/drivers/ras/cec.c
> @@ -553,20 +553,20 @@ static struct notifier_block cec_nb = {
> .priority = MCE_PRIO_CEC,
> };
>
> -static void __init cec_init(void)
> +static int __init cec_init(void)
> {
> if (ce_arr.disabled)
> - return;
> + return 0;

Why 0?

I'm thinking all the cases when the init doesn't succeed should return
!0...

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette

2020-08-05 09:57:58

by Luca Stefani

[permalink] [raw]
Subject: [PATCH v2] RAS/CEC: Fix cec_init prototype

* late_initcall expects a function that returns an integer
-> Update the function signature to match.

Fixes: 9554bfe403nd ("x86/mce: Convert the CEC to use the MCE notifier")
Signed-off-by: Luca Stefani <[email protected]>
---
drivers/ras/cec.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/ras/cec.c b/drivers/ras/cec.c
index 569d9ad2c594..6939aa5b3dc7 100644
--- a/drivers/ras/cec.c
+++ b/drivers/ras/cec.c
@@ -553,20 +553,20 @@ static struct notifier_block cec_nb = {
.priority = MCE_PRIO_CEC,
};

-static void __init cec_init(void)
+static int __init cec_init(void)
{
if (ce_arr.disabled)
- return;
+ return -ENODEV;

ce_arr.array = (void *)get_zeroed_page(GFP_KERNEL);
if (!ce_arr.array) {
pr_err("Error allocating CE array page!\n");
- return;
+ return -ENOMEM;
}

if (create_debugfs_nodes()) {
free_page((unsigned long)ce_arr.array);
- return;
+ return -ENOMEM;
}

INIT_DELAYED_WORK(&cec_work, cec_work_fn);
@@ -575,6 +575,7 @@ static void __init cec_init(void)
mce_register_decode_chain(&cec_nb);

pr_info("Correctable Errors collector initialized.\n");
+ return 0;
}
late_initcall(cec_init);

--
2.28.0

2020-08-12 21:10:25

by Sami Tolvanen

[permalink] [raw]
Subject: Re: [PATCH v2] RAS/CEC: Fix cec_init prototype

Hi Luca,

On Wed, Aug 05, 2020 at 11:57:08AM +0200, Luca Stefani wrote:
> * late_initcall expects a function that returns an integer
> -> Update the function signature to match.
>
> Fixes: 9554bfe403nd ("x86/mce: Convert the CEC to use the MCE notifier")
> Signed-off-by: Luca Stefani <[email protected]>

Thank you for fixing this!

[Note that this v2 email never landed in my inbox, perhaps Gmail filtered
it out due to a missing To: line?]

> ---
> drivers/ras/cec.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/ras/cec.c b/drivers/ras/cec.c
> index 569d9ad2c594..6939aa5b3dc7 100644
> --- a/drivers/ras/cec.c
> +++ b/drivers/ras/cec.c
> @@ -553,20 +553,20 @@ static struct notifier_block cec_nb = {
> .priority = MCE_PRIO_CEC,
> };
>
> -static void __init cec_init(void)
> +static int __init cec_init(void)
> {
> if (ce_arr.disabled)
> - return;
> + return -ENODEV;
>
> ce_arr.array = (void *)get_zeroed_page(GFP_KERNEL);
> if (!ce_arr.array) {
> pr_err("Error allocating CE array page!\n");
> - return;
> + return -ENOMEM;
> }
>
> if (create_debugfs_nodes()) {
> free_page((unsigned long)ce_arr.array);
> - return;
> + return -ENOMEM;
> }
>
> INIT_DELAYED_WORK(&cec_work, cec_work_fn);
> @@ -575,6 +575,7 @@ static void __init cec_init(void)
> mce_register_decode_chain(&cec_nb);
>
> pr_info("Correctable Errors collector initialized.\n");
> + return 0;
> }
> late_initcall(cec_init);

The type mismatch broke allyesconfig in my test tree and your patch
fixes the issue. Please feel free to add:

Reviewed-and-tested-by: Sami Tolvanen <[email protected]>

Sami

2020-08-17 15:15:02

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH v2] RAS/CEC: Fix cec_init prototype

On Wed, Aug 12, 2020 at 02:09:09PM -0700, Sami Tolvanen wrote:
> The type mismatch broke allyesconfig in my test tree and your patch
> fixes the issue.

How are you building your allyesconfigs? Because allyesconfig works here
fine on latest Linus tree.

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette

2020-08-17 18:15:52

by Sami Tolvanen

[permalink] [raw]
Subject: Re: [PATCH v2] RAS/CEC: Fix cec_init prototype

On Mon, Aug 17, 2020 at 10:40 AM Borislav Petkov <[email protected]> wrote:
>
> On Mon, Aug 17, 2020 at 08:58:26AM -0700, Sami Tolvanen wrote:
> > Sorry for not clarifying. This was in a tree with patches for enabling
> > Clang's Control-Flow Integrity.
>
> Well, I just did:
>
> $ make CC=clang-10 HOSTCC=clang-10 allyesconfig
> $ make -j...
>
> and it built fine here, no complaints. So your toolchain must have
> something else.

Not the toolchain, the tree has patches for LTO+CFI, which tends to
break with type mismatches. This doesn't affect just building the
kernel with Clang without other changes.

Sami

2020-08-17 18:40:38

by Sami Tolvanen

[permalink] [raw]
Subject: Re: [PATCH v2] RAS/CEC: Fix cec_init prototype

On Mon, Aug 17, 2020 at 8:13 AM Borislav Petkov <[email protected]> wrote:
>
> On Wed, Aug 12, 2020 at 02:09:09PM -0700, Sami Tolvanen wrote:
> > The type mismatch broke allyesconfig in my test tree and your patch
> > fixes the issue.
>
> How are you building your allyesconfigs? Because allyesconfig works here
> fine on latest Linus tree.

Sorry for not clarifying. This was in a tree with patches for enabling
Clang's Control-Flow Integrity. However, this type mismatch looks like
something that should be fixed regardless.

Sami

2020-08-17 18:55:49

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH v2] RAS/CEC: Fix cec_init prototype

On Mon, Aug 17, 2020 at 11:11:02AM -0700, Sami Tolvanen wrote:
> Not the toolchain, the tree has patches for LTO+CFI, which tends to
> break with type mismatches. This doesn't affect just building the
> kernel with Clang without other changes.

Ok, that explains it.

As for why I'm still chasing down the exact reason for the reported
breakage: this will determine the urgency with which this fix is handled
and to which trees it needs to go so please be more precise next time
when saying "it broke". :)

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette

2020-08-17 22:39:21

by Borislav Petkov

[permalink] [raw]
Subject: Re: [PATCH v2] RAS/CEC: Fix cec_init prototype

On Mon, Aug 17, 2020 at 08:58:26AM -0700, Sami Tolvanen wrote:
> Sorry for not clarifying. This was in a tree with patches for enabling
> Clang's Control-Flow Integrity.

Well, I just did:

$ make CC=clang-10 HOSTCC=clang-10 allyesconfig
$ make -j...

and it built fine here, no complaints. So your toolchain must have
something else.

> However, this type mismatch looks like something that should be fixed
> regardless.

No question there - I'm just trying to figure out how something as minor
as this would break a build.

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette

Subject: [tip: ras/core] RAS/CEC: Fix cec_init() prototype

The following commit has been merged into the ras/core branch of tip:

Commit-ID: 71aefb9a89d4ad751726ff5b902896c35c7df5b9
Gitweb: https://git.kernel.org/tip/71aefb9a89d4ad751726ff5b902896c35c7df5b9
Author: Luca Stefani <[email protected]>
AuthorDate: Wed, 05 Aug 2020 11:57:08 +02:00
Committer: Borislav Petkov <[email protected]>
CommitterDate: Tue, 18 Aug 2020 10:50:07 +02:00

RAS/CEC: Fix cec_init() prototype

late_initcall() expects a function that returns an integer. Update the
function signature to match.

[ bp: Massage commit message into proper sentences. ]

Fixes: 9554bfe403nd ("x86/mce: Convert the CEC to use the MCE notifier")
Signed-off-by: Luca Stefani <[email protected]>
Signed-off-by: Borislav Petkov <[email protected]>
Reviewed-by: Sami Tolvanen <[email protected]>
Tested-by: Sami Tolvanen <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
---
drivers/ras/cec.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/ras/cec.c b/drivers/ras/cec.c
index 569d9ad..6939aa5 100644
--- a/drivers/ras/cec.c
+++ b/drivers/ras/cec.c
@@ -553,20 +553,20 @@ static struct notifier_block cec_nb = {
.priority = MCE_PRIO_CEC,
};

-static void __init cec_init(void)
+static int __init cec_init(void)
{
if (ce_arr.disabled)
- return;
+ return -ENODEV;

ce_arr.array = (void *)get_zeroed_page(GFP_KERNEL);
if (!ce_arr.array) {
pr_err("Error allocating CE array page!\n");
- return;
+ return -ENOMEM;
}

if (create_debugfs_nodes()) {
free_page((unsigned long)ce_arr.array);
- return;
+ return -ENOMEM;
}

INIT_DELAYED_WORK(&cec_work, cec_work_fn);
@@ -575,6 +575,7 @@ static void __init cec_init(void)
mce_register_decode_chain(&cec_nb);

pr_info("Correctable Errors collector initialized.\n");
+ return 0;
}
late_initcall(cec_init);

Subject: [tip: ras/core] RAS/CEC: Fix cec_init() prototype

The following commit has been merged into the ras/core branch of tip:

Commit-ID: 85e6084e0b436cabe9c909e679937998ffbf9c9d
Gitweb: https://git.kernel.org/tip/85e6084e0b436cabe9c909e679937998ffbf9c9d
Author: Luca Stefani <[email protected]>
AuthorDate: Wed, 05 Aug 2020 11:57:08 +02:00
Committer: Borislav Petkov <[email protected]>
CommitterDate: Thu, 20 Aug 2020 10:33:33 +02:00

RAS/CEC: Fix cec_init() prototype

late_initcall() expects a function that returns an integer. Update the
function signature to match.

[ bp: Massage commit message into proper sentences. ]

Fixes: 9554bfe403bd ("x86/mce: Convert the CEC to use the MCE notifier")
Signed-off-by: Luca Stefani <[email protected]>
Signed-off-by: Borislav Petkov <[email protected]>
Reviewed-by: Sami Tolvanen <[email protected]>
Tested-by: Sami Tolvanen <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
---
drivers/ras/cec.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/ras/cec.c b/drivers/ras/cec.c
index 569d9ad..6939aa5 100644
--- a/drivers/ras/cec.c
+++ b/drivers/ras/cec.c
@@ -553,20 +553,20 @@ static struct notifier_block cec_nb = {
.priority = MCE_PRIO_CEC,
};

-static void __init cec_init(void)
+static int __init cec_init(void)
{
if (ce_arr.disabled)
- return;
+ return -ENODEV;

ce_arr.array = (void *)get_zeroed_page(GFP_KERNEL);
if (!ce_arr.array) {
pr_err("Error allocating CE array page!\n");
- return;
+ return -ENOMEM;
}

if (create_debugfs_nodes()) {
free_page((unsigned long)ce_arr.array);
- return;
+ return -ENOMEM;
}

INIT_DELAYED_WORK(&cec_work, cec_work_fn);
@@ -575,6 +575,7 @@ static void __init cec_init(void)
mce_register_decode_chain(&cec_nb);

pr_info("Correctable Errors collector initialized.\n");
+ return 0;
}
late_initcall(cec_init);