From nobody Sun Dec 22 11:48:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1728461117; cv=none; d=zohomail.com; s=zohoarc; b=DCUdE3LlXdCvfytFuli9R24ckThsA/1oU+jUjIPvP8jiUBBRl/KUQ5d7sqhqzfP7TMK0mNZSr+55b0+0FM4/MwUb5aBOpmdScIDJjCBlH4DB4WChXg1NTlDeZKr5Xt0JkiMAc22K5TVSviZey86tRO49qqu4KPG5k3KYMW5CnHo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728461117; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IMIjAU+YIO03QyWyw7i/qsCmTQl0yrUu7IwcuHEs86A=; b=SOj84491MD/1BRc3IZzebmyqsbmw2V7mx9PC9Lt5dEHsaAqaUyA3ypH+mCgN1XYGt1oeVA7RIq7eHH+/Mft/HUbOG2QokItqoqCZmv1Cl7WvTmG9XLRCmsqjsUMRrGwm65bRZ5VlQsh9+HHosilQukQNv5foDcQpRUNtr7g+/pc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1728461117335780.5847636518673; Wed, 9 Oct 2024 01:05:17 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.813817.1226859 (Exim 4.92) (envelope-from ) id 1syRgm-0004Fg-SK; Wed, 09 Oct 2024 08:04:56 +0000 Received: by outflank-mailman (output) from mailman id 813817.1226859; Wed, 09 Oct 2024 08:04:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1syRgm-0004Ey-On; Wed, 09 Oct 2024 08:04:56 +0000 Received: by outflank-mailman (input) for mailman id 813817; Wed, 09 Oct 2024 08:04:56 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1syRgl-0004Bs-Uk for xen-devel@lists.xenproject.org; Wed, 09 Oct 2024 08:04:55 +0000 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [2a00:1450:4864:20::633]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2b70b213-8615-11ef-a0bd-8be0dac302b0; Wed, 09 Oct 2024 10:04:55 +0200 (CEST) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-a9963e47b69so336250566b.1 for ; Wed, 09 Oct 2024 01:04:55 -0700 (PDT) Received: from fziglio-desktop.. ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a992e7856bfsm624370366b.138.2024.10.09.01.04.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2024 01:04:53 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2b70b213-8615-11ef-a0bd-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1728461094; x=1729065894; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IMIjAU+YIO03QyWyw7i/qsCmTQl0yrUu7IwcuHEs86A=; b=gF+YdP+ByTWde6h2+Cpl897B2pdYeiX3sw6hCrW+IqlQcqbVtzds/PYUUQLw0FdAvi Ztk0LSqsBNC0Xip0uYxOTdJo5TVVf0uQq8nIADVtkCqjVNDJqSTTJy9sSDChA9tl0S12 xtKjfZ21q4uUlWN3nn9zjEzk4sKFmdPfE/ZlY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728461094; x=1729065894; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IMIjAU+YIO03QyWyw7i/qsCmTQl0yrUu7IwcuHEs86A=; b=vKmX0j7K6abxaT542qJ7Ihs0KelyIbNczY1Ih+njdmEh+xefdtjrOsuHX6cC175sfC jMFV1Q/uP5Jfog7tB+sZQanpWfhLk7GfTfpQP5M9jLdwPG+w7Rf5p65fJZjcFhSBcyBE NuG3ZzlhUAmT2AupSTyZqywt+O0sw/7dhtOuaIEcL8QxVN49eMXqVt+MNm+O78fLSb5j lfwFH3m2cs3LszSFF0B6ludvjRQGuTsMi8WppEgEdgHv7jmYKTNl8sT2hb9q7zOSehWK b3RtRq595g/Vnc2An1R7+ln+Pge36SZDe76eTiSGCBKaQOlLUX6vj5vDML4lgW4lgkJe rY3A== X-Gm-Message-State: AOJu0YwswGghoMhjmZLuAPMribOjvQ5pYBNQi8twryqjWYKBiFCLWtf5 RDWr9CNR1Lxw/mVgp5AQTZNs9vN1Kl/gmDmtMchWeXXUJNRvl5X2xW2MIdBAJ+sSvMDJ8D5bg7O 0 X-Google-Smtp-Source: AGHT+IHY/4HSnocNINSbzXwMxEsBwQ/IAetbhgaq1csph/ear1T8oQGeEa94SzP6aQPH9rduYiy2Vg== X-Received: by 2002:a17:907:2d8b:b0:a99:577b:b9f0 with SMTP id a640c23a62f3a-a998d1e2d05mr127260366b.30.1728461094467; Wed, 09 Oct 2024 01:04:54 -0700 (PDT) From: Frediano Ziglio To: xen-devel@lists.xenproject.org Cc: Frediano Ziglio , "Daniel P. Smith" , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v8 1/2] x86/boot: Align mbi2.c stack to 16 bytes Date: Wed, 9 Oct 2024 09:04:38 +0100 Message-Id: <20241009080439.2411730-2-frediano.ziglio@cloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241009080439.2411730-1-frediano.ziglio@cloud.com> References: <20241009080439.2411730-1-frediano.ziglio@cloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1728461118771116600 Content-Type: text/plain; charset="utf-8" Doing previous testing with an Adler Lake Intel machine the following patch (improving MBI structure checking) started to fail. Excluding it makes the tests succeed however there was not apparent reason (looking at the code) for the failure. So I instrumented code to output the structure and tested code with this extracted data with and without the following patch and results were the same. Compiled assembly code from lab was also fine beside not keeping the 16-byte alignment for the stack. Turning on stack alignment solve the problem on Adler Lake machine. Signed-off-by: Frediano Ziglio --- xen/arch/x86/efi/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/arch/x86/efi/Makefile b/xen/arch/x86/efi/Makefile index 7e2b5c07de..c2cad86856 100644 --- a/xen/arch/x86/efi/Makefile +++ b/xen/arch/x86/efi/Makefile @@ -11,6 +11,8 @@ $(obj)/boot.init.o: $(obj)/buildid.o $(call cc-option-add,cflags-stack-boundary,CC,-mpreferred-stack-boundary= =3D4) $(addprefix $(obj)/,$(EFIOBJ-y)): CFLAGS_stack_boundary :=3D $(cflags-stac= k-boundary) =20 +$(obj)/mbi2.o: CFLAGS_stack_boundary :=3D $(cflags-stack-boundary) + obj-y :=3D common-stub.o stub.o obj-$(XEN_BUILD_EFI) :=3D $(filter-out %.init.o,$(EFIOBJ-y)) obj-bin-$(XEN_BUILD_EFI) :=3D $(filter %.init.o,$(EFIOBJ-y)) --=20 2.34.1 From nobody Sun Dec 22 11:48:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1728461120; cv=none; d=zohomail.com; s=zohoarc; b=G3gAQYb7fs64TI9CFRjw7fktEcDH3bCPEwnrXciZXwCMsByXIVcNoPS3VIk2o7Rl+Q4l08BfPnTnS7GRL4iAjAGYYW+NnlKQWv035UWPfpbUI6iVct3pZy5A5OjvsT2URYZoOWmbfcfinlVrMlX0dq+YjfeU/F0LryfgpekbpaM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728461120; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5zZ3wGBySbXmRtfmFQfFr7wFwdfciZzlXfjXPqq0IY4=; b=ZAZYrWFBBJWyx6kwM1fTe1wYiaOt03AyS1LwZHyZusCC0pgnUVmXo90vzDZ8H+XRqcrgloH3Qu9KDFy4I/iX4Kr++o3kUXPnTewvBfpeQSWrIWYtw2ztyE7K17s1aQ+qgULxGhdiHKCNcCUEFh2TH2E0DvV+czT0LFBYx9TnDfE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1728461120320749.860486360935; Wed, 9 Oct 2024 01:05:20 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.813818.1226875 (Exim 4.92) (envelope-from ) id 1syRgp-0004gi-5C; Wed, 09 Oct 2024 08:04:59 +0000 Received: by outflank-mailman (output) from mailman id 813818.1226875; Wed, 09 Oct 2024 08:04:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1syRgp-0004gZ-0F; Wed, 09 Oct 2024 08:04:59 +0000 Received: by outflank-mailman (input) for mailman id 813818; Wed, 09 Oct 2024 08:04:57 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1syRgn-0004Bs-Lm for xen-devel@lists.xenproject.org; Wed, 09 Oct 2024 08:04:57 +0000 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [2a00:1450:4864:20::636]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2c7bea15-8615-11ef-a0bd-8be0dac302b0; Wed, 09 Oct 2024 10:04:57 +0200 (CEST) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a9950d27234so456976066b.1 for ; Wed, 09 Oct 2024 01:04:57 -0700 (PDT) Received: from fziglio-desktop.. ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a992e7856bfsm624370366b.138.2024.10.09.01.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2024 01:04:55 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2c7bea15-8615-11ef-a0bd-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1728461096; x=1729065896; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5zZ3wGBySbXmRtfmFQfFr7wFwdfciZzlXfjXPqq0IY4=; b=AmqjSA14peDLULBAsUEv10rvDQbnzAqnFD89+kjJNVCgZi8eEDM6+PnbqzotP8WVPC NuOZKJCi8bqgDCn2yw+2QSem95gsxoEnqJ0cMnva0hh8vZYBohvMxt7qCReylu3hJoeg hxMRabGyt8+S6cGrV9jXUookddw8CmRliBV3Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728461096; x=1729065896; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5zZ3wGBySbXmRtfmFQfFr7wFwdfciZzlXfjXPqq0IY4=; b=M1PdhPwUVV0XM4tUBt21lzG3ygnuNTT/aroJs2Hz9e+Y84zclkPW4FJpugsFOh+6ix KxK7NmbByePCvGemtMHFSWpjYJhMAr8XnDgCiiHwRQV3/M2IlFKoiufyt1OfBnViJSGA GaxYyI1hw5U2Q3iP0lfd95E9yEq0tCPeo9cUBf0F1FZPbK3nWYEfMUXkOhSo68NvDRuA mh/L01mFaVAE4gT4bCQJLqucw3Ce8so7h6FEJaP6tVKZd41Kjp2xUdgdKI6SAvO15oZ5 ccTSJ+rhXfk7k7zVYqreVAh8mj7kwYCB9wDRzKQau8Cb7d5TKK/3cLdOwnd2hHitluBm 8aGA== X-Gm-Message-State: AOJu0Yw0cUhsJhGV2CQlwJ1KWhDgLhJgE8zFSr0Z5Ds7ZR6NfcaLhZHV K3t2DzUibUZfqoATuRcYdedccYw0uix/nhZUpw8Vqw0t+tt/YtyAu2J+vRwyCWX7ygFew9AEYUI I X-Google-Smtp-Source: AGHT+IF60C0IUYkjP4YU4uNeiKMgmzNm8zNbYv9vfb52kCfxP9XStTkqXGkjyWjGt1GeaE9tNy/Caw== X-Received: by 2002:a17:907:1c96:b0:a99:6a5a:bab with SMTP id a640c23a62f3a-a998d252ef3mr114619966b.39.1728461096317; Wed, 09 Oct 2024 01:04:56 -0700 (PDT) From: Frediano Ziglio To: xen-devel@lists.xenproject.org Cc: Frediano Ziglio , "Daniel P. Smith" , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v8 2/2] x86/boot: Improve MBI2 structure check Date: Wed, 9 Oct 2024 09:04:39 +0100 Message-Id: <20241009080439.2411730-3-frediano.ziglio@cloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241009080439.2411730-1-frediano.ziglio@cloud.com> References: <20241009080439.2411730-1-frediano.ziglio@cloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1728461120813116600 Content-Type: text/plain; charset="utf-8" Tag structure should contain at least the tag header. Entire tag structure must be contained inside MBI2 data. Signed-off-by: Frediano Ziglio Reviewed-by: Jan Beulich --- Changes since v6: - compare against total_size every time to avoid overflows. Changes since v7: - check for tag type being MULTIBOOT2_TAG_TYPE_END before checking tag size. This allows caller to not fill full tag (type field is before size field). --- xen/arch/x86/efi/mbi2.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/efi/mbi2.c b/xen/arch/x86/efi/mbi2.c index 55a1777483..d2f0f0ee61 100644 --- a/xen/arch/x86/efi/mbi2.c +++ b/xen/arch/x86/efi/mbi2.c @@ -13,6 +13,7 @@ efi_multiboot2_prelude(uint32_t magic, const multiboot2_f= ixed_t *mbi) EFI_HANDLE ImageHandle =3D NULL; EFI_SYSTEM_TABLE *SystemTable =3D NULL; const char *cmdline =3D NULL; + const void *const mbi_raw =3D (const void *)mbi; bool have_bs =3D false; =20 if ( magic !=3D MULTIBOOT2_BOOTLOADER_MAGIC ) @@ -21,8 +22,10 @@ efi_multiboot2_prelude(uint32_t magic, const multiboot2_= fixed_t *mbi) /* Skip Multiboot2 information fixed part. */ tag =3D _p(ROUNDUP((unsigned long)(mbi + 1), MULTIBOOT2_TAG_ALIGN)); =20 - for ( ; (const void *)tag - (const void *)mbi < mbi->total_size && - tag->type !=3D MULTIBOOT2_TAG_TYPE_END; + for ( ; (const void *)(tag + 1) - mbi_raw <=3D mbi->total_size && + tag->type !=3D MULTIBOOT2_TAG_TYPE_END && + tag->size >=3D sizeof(*tag) && + (const void *)tag + tag->size - mbi_raw <=3D mbi->total_size; tag =3D _p(ROUNDUP((unsigned long)tag + tag->size, MULTIBOOT2_TAG_ALIGN)) ) { --=20 2.34.1