From: john.hubbard@gmail.com
To: "H . Peter Anvin" <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
x86@kernel.org, LKML <linux-kernel@vger.kernel.org>,
John Hubbard <jhubbard@nvidia.com>
Subject: [PATCH 1/1] x86/boot: clear some fields explicitly
Date: Wed, 24 Jul 2019 16:15:28 -0700 [thread overview]
Message-ID: <20190724231528.32381-2-jhubbard@nvidia.com> (raw)
In-Reply-To: <20190724231528.32381-1-jhubbard@nvidia.com>
From: John Hubbard <jhubbard@nvidia.com>
Recent gcc compilers (gcc 9.1) generate warnings about an
out of bounds memset, if you trying memset across several fields
of a struct. This generated a couple of warnings on x86_64 builds.
Because struct boot_params is __packed__, normal variable
variable assignment will work just as well as a memset here.
Change three u32 fields to be cleared to zero that way, and
just memset the _pad4 field.
This clears up the build warnings for me.
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
arch/x86/include/asm/bootparam_utils.h | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/arch/x86/include/asm/bootparam_utils.h b/arch/x86/include/asm/bootparam_utils.h
index 101eb944f13c..4df87d4a043b 100644
--- a/arch/x86/include/asm/bootparam_utils.h
+++ b/arch/x86/include/asm/bootparam_utils.h
@@ -37,12 +37,11 @@ static void sanitize_boot_params(struct boot_params *boot_params)
if (boot_params->sentinel) {
/* fields in boot_params are left uninitialized, clear them */
boot_params->acpi_rsdp_addr = 0;
- memset(&boot_params->ext_ramdisk_image, 0,
- (char *)&boot_params->efi_info -
- (char *)&boot_params->ext_ramdisk_image);
- memset(&boot_params->kbd_status, 0,
- (char *)&boot_params->hdr -
- (char *)&boot_params->kbd_status);
+ boot_params->ext_ramdisk_image = 0;
+ boot_params->ext_ramdisk_size = 0;
+ boot_params->ext_cmd_line_ptr = 0;
+
+ memset(&boot_params->_pad4, 0, sizeof(boot_params->_pad4));
memset(&boot_params->_pad7[0], 0,
(char *)&boot_params->edd_mbr_sig_buffer[0] -
(char *)&boot_params->_pad7[0]);
--
2.22.0
next prev parent reply other threads:[~2019-07-24 23:15 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-24 23:15 [PATCH 0/1] x86/boot: clear some fields explicitly john.hubbard
2019-07-24 23:15 ` john.hubbard [this message]
2019-07-25 2:12 ` [PATCH 1/1] " hpa
2019-07-25 6:49 ` John Hubbard
2019-07-25 7:22 ` Thomas Gleixner
2019-07-25 20:33 ` John Hubbard
2019-07-25 21:48 ` Thomas Gleixner
2019-07-25 21:57 ` hpa
2019-07-25 22:03 ` Thomas Gleixner
2019-07-25 22:28 ` H. Peter Anvin
2019-07-25 22:37 ` Thomas Gleixner
2019-07-26 0:36 ` John Hubbard
2019-07-25 22:42 ` John Hubbard
2019-07-26 7:43 ` Thomas Gleixner
2019-07-25 20:38 ` H. Peter Anvin
2019-07-25 20:44 ` John Hubbard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190724231528.32381-2-jhubbard@nvidia.com \
--to=john.hubbard@gmail.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).