From patchwork Tue Mar 14 10:13:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evgeniy Baskov X-Patchwork-Id: 69458 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1677632wrd; Tue, 14 Mar 2023 03:36:30 -0700 (PDT) X-Google-Smtp-Source: AK7set9L65SedtSHY6nGE3Vq5Tns9OJOUUfox3ru43eU2+Z6XzdBYBpjxvxt9r/wZ2zQ4znjMjkk X-Received: by 2002:a17:902:6b81:b0:19d:1725:a655 with SMTP id p1-20020a1709026b8100b0019d1725a655mr30103908plk.13.1678790190448; Tue, 14 Mar 2023 03:36:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678790190; cv=none; d=google.com; s=arc-20160816; b=zweL9vxR+YD7nKPhdYBoLSyr3Rqdjm7fiOoK2o2Kwy6Iqol3kAC+keOlAQZcgWPELG jLgIH5xpcY2YlymUS6ns2RX7jBo0r44NsL46FYTSpm7NQR/kL6DrDt02pPVYho4YA8Qb n/nNP1NFt2dLy5qdeYdCghKi2GrF7GDBTMCPJLML671eozcnNiACAyYhG0xkjZOlWUwd +b8tYxQacpxOyg06xml6/8c4xjCJyq5dTscDpC11r7dJaBq0oreYvfLCSdgxGtsAi8r8 rSzAlgnhUEe0zCLaqxnWo/Qj5EcmEcfjjGQyDS3mp0cqCsF71qOOLvZI24NFzCt9uhb3 EFAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=+Rs2iCTiek3yYBbmemqEMQIzt9ito44oHZ0zp2gqc10=; b=rSdQLmdCEh9Q6DaLzzNYjuu9doKVSI+yRCOFuneiO68cPu0WJJ3wYeydK8f2Xq4MiI MoL2RUzgGS5owvZ45+mURYT1EOfc6fFEmozYLSNXIjq7VXlomnevzuAvcU/E3gW3eLCn PaiFfrWMIs5lMUfk1jA4rIy/XomJTY0j0Mtj4bI+CXwVKOOvgt9J4K8LbMWdMrNkfcKo o5Kcgq4SkEEcynVxcqdRa0iWGRE252WFqKC7uH/lpluBY87CNjJeN1KEBp8Mv00aTw0U tC5DRsZas0iS7hawKwpy3ZRN0tOzOjQqwaTYBAZhteGNIkoz+arfwFCWcNhrEUauzcFW hvtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=YIY13fl2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jc7-20020a17090325c700b0019ac69e7385si2153115plb.123.2023.03.14.03.36.17; Tue, 14 Mar 2023 03:36:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=YIY13fl2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229946AbjCNKZe (ORCPT + 99 others); Tue, 14 Mar 2023 06:25:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229949AbjCNKYp (ORCPT ); Tue, 14 Mar 2023 06:24:45 -0400 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26BAD5FE94; Tue, 14 Mar 2023 03:24:18 -0700 (PDT) Received: from localhost.localdomain (unknown [83.149.199.65]) by mail.ispras.ru (Postfix) with ESMTPSA id 3AEEF40755C6; Tue, 14 Mar 2023 10:23:25 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 3AEEF40755C6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1678789405; bh=+Rs2iCTiek3yYBbmemqEMQIzt9ito44oHZ0zp2gqc10=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YIY13fl2vX+jnARjSEo+Jv4ClNtCdXk4Pb/VJtM+8ZvDtbZgMkT8CnMO0Ah0uRMCh EOva3BjomKBhR5fGAuUY6HWaCaBouOUtq33ZsGbwBST0QntXMNxWXIFx2EJIIWcl8y Sp1t4Pjeb6CQWgnhTvv22eHB2np7MU6/5q4HTYuk= From: Evgeniy Baskov To: Ard Biesheuvel Cc: Evgeniy Baskov , Borislav Petkov , Andy Lutomirski , Dave Hansen , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Alexey Khoroshilov , Peter Jones , Gerd Hoffmann , "Limonciello, Mario" , joeyli , lvc-project@linuxtesting.org, x86@kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v5 22/27] x86/build: set type_of_loader for EFISTUB Date: Tue, 14 Mar 2023 13:13:49 +0300 Message-Id: <111d4120936d23e6023619660778444eb226a22f.1678785672.git.baskov@ispras.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760339102397258527?= X-GMAIL-MSGID: =?utf-8?q?1760339102397258527?= After switching to the local copy of boot_params, EFISTUB stopped setting type_of_loader, using the default value of 0. Restore that behavior by assigning the right value at the build time. Signed-off-by: Evgeniy Baskov --- arch/x86/boot/tools/build.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/boot/tools/build.c b/arch/x86/boot/tools/build.c index 476ef05f16fb..5ac4f08ed923 100644 --- a/arch/x86/boot/tools/build.c +++ b/arch/x86/boot/tools/build.c @@ -588,6 +588,8 @@ int main(int argc, char **argv) memcpy(output + setup_size + efi_boot_params + SETUP_HEADER_OFFSET, setup_header, 0x290 - SETUP_HEADER_OFFSET /* == max possible sizeof(struct setup_header) */); + /* Set type_of_loader to the one that EFISTUB uses for the local copy */ + output[setup_size + efi_boot_params + SETUP_HEADER_OFFSET + 0x1F] = 0x21; #endif /* Calculate and write kernel checksum. */