From patchwork Tue Nov 22 16:10:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 24451 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2302080wrr; Tue, 22 Nov 2022 08:14:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf79SqmArcZbSe07nr3VNlu1XfyxGDeCBbJIweGydCRG8ypOdlx+M0xeTelYzxRmfzAFRNKx X-Received: by 2002:a17:90a:ae0f:b0:20d:b124:33b1 with SMTP id t15-20020a17090aae0f00b0020db12433b1mr25846194pjq.202.1669133654972; Tue, 22 Nov 2022 08:14:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669133654; cv=none; d=google.com; s=arc-20160816; b=fBiZwB+e399rEcM3+gC+g6tzHbix+A9WspkQdSINGi/rxJbigtLr1cBF5lC1Qe5TcY Og0ETSZTCYNwq04EL1Xs/EmG7dPhKFDNcwKDcUiiBPmcHqIoJEY+zc+zXnx2wksX23aT iCPGkUmjnShxcnDgue5fBK96TqA7znDAzuNVClKsFimmlIFKEgCYRtVmsSjgKPnmG6Kq xGND0n+yzJvuzhN7GX3bYesfS0ye9Dp41DJNsPGLe256eMMRzbojSLl4TTFsF5pOli6b w2KNSc+AahnHTwGGOfvFwhwH/nsRNIbdAn4PFUGkc0WaUYHSFvXqjdwaP7xOV3a2wmsc bL7g== 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; bh=THcQIWKNjc8aYvog99Ju0rQTJDpP1oBswH1xDPyCyHk=; b=MXNhp01jM/yyV4nGr9eZhKVdSAHliA24D2+z0EXC92wcXlAwB2EKJ8kledQ1/RFy9o fycWWd7ilSxuNViHwVZL3jEaRiT4bKI7eJFlmLFkhPbhCpKJ9XDVKPw6MhDKLeiu0jor 71S+GYglAkK7Ywoin+0zzqg55glSzwt1Iv8jBdm4mt+Muidpah2SLkF9gyBe4GmPx+hK 7ck3eEOj8BFvXBXu6EgL+5jUW8uF53l/GZOR3YzfOJE3ofqg51t4H4BCgh49QAnZ8vq2 NbLxTCs+0BcsZQFxHa76kLy/uwpf0g4jC7cymawkW5tGTSTN4Sxp5B9o/uW1Z/lsWvBL brVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SiQbk7Da; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k4-20020a63d104000000b0046fb2a57348si14102017pgg.84.2022.11.22.08.13.59; Tue, 22 Nov 2022 08:14:14 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=SiQbk7Da; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229628AbiKVQLi (ORCPT + 99 others); Tue, 22 Nov 2022 11:11:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234227AbiKVQLG (ORCPT ); Tue, 22 Nov 2022 11:11:06 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D6A2742F5; Tue, 22 Nov 2022 08:10:53 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CE5E7B81BEE; Tue, 22 Nov 2022 16:10:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1F77C433C1; Tue, 22 Nov 2022 16:10:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669133450; bh=9jyxmHpzfRCJJf9xQ03iz+bA0Xb5QCrz4P3JHsC5SMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SiQbk7Da54coI7gkcSa+od6Hd1M1+JjCaNn0sFqcdZG0cdtYNtk4vB1aTINWnfSt9 8rfTyvgy6vUlGqeeu5V9XjhwRYFk6HMOy3qCTv95SmUw5yT9d2q+aVSqDvls4VeF+X lsf6RLOVRNnFynZZZTkLyDyUO0XyFuDkCkvd8Pph1wBlGyUwdNnYA6Z6TQtrDqCNQw deqfbqofQxcCxHpuCxXeZIaoZ9daJ8BSrPgtgAVDx9kFudVMdf27mkrsWFvKRLD1gy TMFtctu/fcOjmw2cjOIIr+yUMzat1AipaE3kkWTNRTQobTcd8bdfxCZyltHtVEubWI QAjbhcijIwlUw== From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Ard Biesheuvel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Michael Roth Subject: [PATCH v3 08/17] x86/compressed: efi-mixed: simplify IDT/GDT preserve/restore Date: Tue, 22 Nov 2022 17:10:08 +0100 Message-Id: <20221122161017.2426828-9-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221122161017.2426828-1-ardb@kernel.org> References: <20221122161017.2426828-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1663; i=ardb@kernel.org; h=from:subject; bh=9jyxmHpzfRCJJf9xQ03iz+bA0Xb5QCrz4P3JHsC5SMM=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBjfPRabAmNoz2lPub2d3CamZQemKR8yASDbUtdoT/H Brr43omJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCY3z0WgAKCRDDTyI5ktmPJPUKC/ 4t4JhAxm00y83U+Wvv2lAqOINuqkTuhkErVDG15v2jHR+wYw30ix4IghLOwk1iSHqDv0w/bCgPztVD Vw40lqEejjuygLaA/IDUXmKps3vkdJ67GWwpm2mflPDVvXO9gkh9KcU5EmUbPNZIuzO8DBkI45Tfrx wPpTaTILzpbYKv3YH11CzTBHkd8rx8eE+rN4Gd6olfriIBjDReEb6sHyWZKk/kq8iGNDLiPrukp/+s ssN1Upypo9IgxpqwnBR/hAE4BU/uoGabIvrYVpZK7l9J8DiFa82SdRCyIzUcgGBUwkessJq8KMokyT htyKWur2fjznZRSYRAGPsP3xXAbciPsZQFTkTozwyeV3AuFdJldcTsLXLoIez2YElX/Epm0RhwOaUJ Zt5RvDMgD36pIqAN5xYqx/T40dY74SZaG9w4GQGMwUz+AX1gKo9DnYze0fxdNd2ATExubRqB7cv/i/ 2SxSKLq80PD+MvCg8gRWoksHrI7ioxnnKHmJrYSwvEj2c= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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?1750213491274907223?= X-GMAIL-MSGID: =?utf-8?q?1750213491274907223?= Tweak the asm and remove some redundant instructions. While at it, fix the associated comment for style and correctness. Signed-off-by: Ard Biesheuvel --- arch/x86/boot/compressed/efi_mixed.S | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/arch/x86/boot/compressed/efi_mixed.S b/arch/x86/boot/compressed/efi_mixed.S index 8844d8ed4b1c7561..8b02e507d3bb055a 100644 --- a/arch/x86/boot/compressed/efi_mixed.S +++ b/arch/x86/boot/compressed/efi_mixed.S @@ -96,24 +96,20 @@ SYM_FUNC_START(__efi64_thunk) leaq 0x20(%rsp), %rbx sgdt (%rbx) - - addq $16, %rbx - sidt (%rbx) + sidt 16(%rbx) leaq 1f(%rip), %rbp /* - * Switch to IDT and GDT with 32-bit segments. This is the firmware GDT - * and IDT that was installed when the kernel started executing. The - * pointers were saved by the efi32_entry() routine below. + * Switch to IDT and GDT with 32-bit segments. These are the firmware + * GDT and IDT that were installed when the kernel started executing. + * The pointers were saved by the efi32_entry() routine below. * * Pass the saved DS selector to the 32-bit code, and use far return to * restore the saved CS selector. */ - leaq efi32_boot_idt(%rip), %rax - lidt (%rax) - leaq efi32_boot_gdt(%rip), %rax - lgdt (%rax) + lidt efi32_boot_idt(%rip) + lgdt efi32_boot_gdt(%rip) movzwl efi32_boot_ds(%rip), %edx movzwq efi32_boot_cs(%rip), %rax @@ -187,9 +183,7 @@ SYM_FUNC_START_LOCAL(efi_enter32) */ cli - lidtl (%ebx) - subl $16, %ebx - + lidtl 16(%ebx) lgdtl (%ebx) movl %cr4, %eax