From nobody Thu May 2 07:32:47 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1556798023; cv=none; d=zoho.com; s=zohoarc; b=dkGfbDhj7HtKZGHZlfksR8mc68zAABqtEkgHOVYElqMSsiRqUWee3ngIo1mU4wvb35GmOmTKy8r8UlfLS5BFBd/CyQ9uIqI5nAqrUeuzpNlFXL1QOll2rE0LNG7r1V3PmBXHH6qICHctPvd1oi2LGiphBPAyLKbashupT3SRtME= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556798023; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=fqzZOS6ayTBwkoSuTSJzHFbmwnvsW9mOKcHr/DDZzm0=; b=clyA2lhJfKih2o/6erJzCePGY8l+onlIbOqbJmxGbImZCetlKnrePY9ssvQRc0Yu4zQ1JHGiAEFaSAYsP10gCsWsjmFe14ES75clFkrynY+Lvm4IX7P2s+8HGU1GGB6tWly+exF26tPC3kcmHosdSKESx3vdMJqXwFMRCn5pwXA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1556798023752632.3927526195675; Thu, 2 May 2019 04:53:43 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hMAGA-0002Q7-Cp; Thu, 02 May 2019 11:52:18 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hMAG9-0002Pz-1d for xen-devel@lists.xenproject.org; Thu, 02 May 2019 11:52:17 +0000 Received: from SMTP03.CITRIX.COM (unknown [162.221.156.55]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id b5c2b702-6cd0-11e9-8165-2ff84aa93256; Thu, 02 May 2019 11:52:07 +0000 (UTC) X-Inumbo-ID: b5c2b702-6cd0-11e9-8165-2ff84aa93256 X-IronPort-AV: E=Sophos;i="5.60,421,1549929600"; d="scan'208";a="84938001" From: Andrew Cooper To: Xen-devel Date: Thu, 2 May 2019 12:52:03 +0100 Message-ID: <1556797923-7107-1-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] x86/boot: Fix latent memory corruption with early_boot_opts_t X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , David Woodhouse , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" c/s ebb26b509f "xen/x86: make VGA support selectable" added an #ifdef CONFIG_VIDEO into the middle the backing space for early_boot_opts_t, but didn't adjust the structure definition in cmdline.c This only functions correctly because the affected fields are at the end of the structure, and cmdline.c doesn't write to them in this case. To retain the slimming effect of compiling out CONFIG_VIDEO, adjust cmdline.c with enough #ifdef-ary to make C's idea of the structure match the declaration in asm. This requires adding __maybe_unused annotations to two helper functions. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 CC: David Woodhouse This needs backporting to Xen 4.11 Discovered while reviewing David's "Clean up x86_64 boot code" series. --- xen/arch/x86/boot/cmdline.c | 14 ++++++++++---- xen/arch/x86/boot/defs.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/boot/cmdline.c b/xen/arch/x86/boot/cmdline.c index 51b0659..fc11c6d 100644 --- a/xen/arch/x86/boot/cmdline.c +++ b/xen/arch/x86/boot/cmdline.c @@ -40,10 +40,12 @@ typedef struct __packed { u8 opt_edd; u8 opt_edid; u8 padding; +#ifdef CONFIG_VIDEO u16 boot_vid_mode; u16 vesa_width; u16 vesa_height; u16 vesa_depth; +#endif } early_boot_opts_t; =20 /* @@ -127,7 +129,8 @@ static size_t strcspn(const char *s, const char *reject) return count; } =20 -static unsigned int strtoui(const char *s, const char *stop, const char **= next) +static unsigned int __maybe_unused strtoui( + const char *s, const char *stop, const char **next) { char base =3D 10, l; unsigned long long res =3D 0; @@ -176,7 +179,7 @@ static int strmaxcmp(const char *cs, const char *ct, co= nst char *_delim_chars) return strncmp(cs, ct, max(strcspn(cs, _delim_chars), strlen(ct))); } =20 -static int strsubcmp(const char *cs, const char *ct) +static int __maybe_unused strsubcmp(const char *cs, const char *ct) { return strncmp(cs, ct, strlen(ct)); } @@ -241,6 +244,7 @@ static u8 edid_parse(const char *cmdline) return !strmaxcmp(c, "no", delim_chars); } =20 +#ifdef CONFIG_VIDEO static u16 rows2vmode(unsigned int rows) { switch ( rows ) @@ -328,6 +332,7 @@ static void vga_parse(const char *cmdline, early_boot_o= pts_t *ebo) ebo->boot_vid_mode =3D tmp; } } +#endif =20 void __stdcall cmdline_parse_early(const char *cmdline, early_boot_opts_t = *ebo) { @@ -338,6 +343,7 @@ void __stdcall cmdline_parse_early(const char *cmdline,= early_boot_opts_t *ebo) ebo->opt_edd =3D edd_parse(cmdline); ebo->opt_edid =3D edid_parse(cmdline); =20 - if ( IS_ENABLED(CONFIG_VIDEO) ) - vga_parse(cmdline, ebo); +#ifdef CONFIG_VIDEO + vga_parse(cmdline, ebo); +#endif } diff --git a/xen/arch/x86/boot/defs.h b/xen/arch/x86/boot/defs.h index 05921a6..f57ad53 100644 --- a/xen/arch/x86/boot/defs.h +++ b/xen/arch/x86/boot/defs.h @@ -23,6 +23,7 @@ #include "../../../include/xen/stdbool.h" =20 #define __packed __attribute__((__packed__)) +#define __maybe_unused __attribute__((__unused__)) #define __stdcall __attribute__((__stdcall__)) =20 #define NULL ((void *)0) --=20 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel