From patchwork Wed Sep 21 14:54:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 608054 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48CCEECAAD8 for ; Wed, 21 Sep 2022 14:55:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230365AbiIUOzq (ORCPT ); Wed, 21 Sep 2022 10:55:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230263AbiIUOzC (ORCPT ); Wed, 21 Sep 2022 10:55:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CF5C27CC3; Wed, 21 Sep 2022 07:54:48 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id A220B630D0; Wed, 21 Sep 2022 14:54:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F416C433B5; Wed, 21 Sep 2022 14:54:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663772087; bh=9QnYVj6z/B1v2rUoK+Ldcmd4eGkNmNagz5RXwwVDZGA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LV5F1pc72XgMbSfBcXvFa8f798xK73hAo9+GcK7JAexOkNiWrsfxHfToYrJ1u7UK1 2NjzhH+SRwfY7JMRNg7swmQMFTbcNd9YgxBibfHVchkuGgMpUjWemJlAFeS9WG9EnZ A6kt911jmqK6AK4GPdsz+EvuPOrUX11Cpz9UJ8c49iaxqszxleDNWH9fpOgbGz5NLH 9wLCcqcAYEbIvATmuCvxkqkJSev2IT1KSrwPywyJYhbPjPU8dt/zGgfYJmE3MJeKaD MANuhbOem/a9v91o0hL+7ZraShb2mhFKjkZfB/CxMNoibiI7/zNLGaUyB7QuL0NcoQ O5OxZV0B0hEiQ== 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 v2 08/16] x86/compressed: efi-mixed: simplify IDT/GDT preserve/restore Date: Wed, 21 Sep 2022 16:54:14 +0200 Message-Id: <20220921145422.437618-9-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220921145422.437618-1-ardb@kernel.org> References: <20220921145422.437618-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1655; i=ardb@kernel.org; h=from:subject; bh=9QnYVj6z/B1v2rUoK+Ldcmd4eGkNmNagz5RXwwVDZGA=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBjKyWQ3Ag0DM2zo9H8bBKsNY/cqI7OhW4UARHecPw4 H+NV04iJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYyslkAAKCRDDTyI5ktmPJHJoC/ 9zKUezLXemPXQfjghbahMwiJfosOLNu3nSZv4NsjAIRqUFe62kdapZjUdrHVuDuXvocNX9wG6G7W7c 88Hj8TLAbtHthl0J3JuiDA3+WU3tiK8eVSQaW3mPEBzdz4QGHKVtvwy8CjPB4QANf+LxhhBmw6H2iH oyp1erDEahDcycZ5B3eYOjRn3mg8XuIdsgRcmRcuqZVof31KRADuVyAbYlrm/7xPDk8ldwlm/35qLd s9+GLXLH06Uba5NYXJGcVufVHi/rlMhzpW5LyiqdrEJMa/JiMFXVv8fEZqHcRZvKTIU2ipwY+qgZXZ sAWm4Q89XxQZfMwwKHpEqHIfc+LoTldBYCt9rV+caF1IKRHCA2Crdc2EylqnbL1i3DgfP08kjRWK9L 5nl9aYQJfYM/K2JLC0i6xLeRcPl281OJTs6r75cNjfAN0tzWuxIfQE+kw/F9oodRILNDaLPdKlDyh8 FHTiMFUEgCGUztYjlRF745urnUP6GCeUfQgtD/1Jo9zXM= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org 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 838514f7685a..e5b8f1d2310c 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