From patchwork Tue Nov 22 16:10:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 24453 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2302175wrr; Tue, 22 Nov 2022 08:14:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf6iVU3AjK8cdyFdE3J2je5+8jcJNjz7J6Lb2LSHw4mROIKe2XH7fGRRFOmPzPHg7yAMnhQR X-Received: by 2002:a17:90a:8a82:b0:210:7cd5:db0e with SMTP id x2-20020a17090a8a8200b002107cd5db0emr27386432pjn.30.1669133664938; Tue, 22 Nov 2022 08:14:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669133664; cv=none; d=google.com; s=arc-20160816; b=Vb365HzaWbwO3eE9WxdgmBA3nQT2MSIMzBsAnUP+U5rwWp1Ln6SS+JudVIkiq/xwuP hkMm+cZRuHvbDF+LMoX6Eu/qXntYpE0ecd53DFQ40BAJDFh5U6CEfNDJWyiLVJFppgu4 0Dh8OKQveeiXijRcaeoCt4D6bbLLSrvvpm1BGEiJ7hqr0YheNwaDspr5gzOD6Q4ToCVR T1fezib/EWLW0C6ITZl1QU9+EUk1TD4AQ5mcVK01kF6+VCHddVnwI2NNBc8f3CFf9NYE 7Qh7QxbXL/fBcxH+tK9x7Pk0F6TKD1eLStaW6gE5ydyVpVelAcyUeb1M/BEXgPcdGx1y 90Kg== 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=l4W9SMLEGMM7PQrWkglCXAQUGZxuBFG4akQH1BB5gOE=; b=06J9KArPe7l7JNfHwSL0Oy1l8iwaHwIM+egaK52vuuWCGIBfdiYRS1g1qaweZN4/ne 7UosyfkEt0XM/M4SvcnelZaWdduqtA+3Q5c4t521Oi5vdLlX3N8xj6USCnaImaHgwGJh 6QAktUciRkda68cZKs4KsyOYneVG2jpzVFE3pco0hFzgWtWUR9cBBeluizGP/2148K8f LPkQt/Fr2T+lpsZq/dZQnqdsZu5q/H61zGRwDzEyXaqExc/nzT5kFimPitRZoLp1UR/o PGHooVufsSbim4k5yX+7PHoiROCorNpkb0wqLzV9JcVh3BmndsCfZqXZXJmSangFd2yQ N/0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XGRVsVzu; 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 pc3-20020a17090b3b8300b00218ac70fdefsi6482317pjb.183.2022.11.22.08.14.10; Tue, 22 Nov 2022 08:14:24 -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=XGRVsVzu; 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 S233821AbiKVQLo (ORCPT + 99 others); Tue, 22 Nov 2022 11:11:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234090AbiKVQLI (ORCPT ); Tue, 22 Nov 2022 11:11:08 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14B3C742EF; Tue, 22 Nov 2022 08:10:56 -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 dfw.source.kernel.org (Postfix) with ESMTPS id A425861791; Tue, 22 Nov 2022 16:10:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48367C433B5; Tue, 22 Nov 2022 16:10:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669133455; bh=ZGYYMFhXkrZn+e+cVgRjzokBYpzkxMdbl7BhlbBHuq8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XGRVsVzu72nJRrh0T5N78o3GOA+eT5mhSHei+3/rUxm1yaxZE+poMMlUdq6ZactgT AeOgWuHY6np+zLuLXpVRsyq0dF41Iab+ADu0YLEoAytpWqOPLygFWND/Gp1N+SrVNp ujh2x4K7XY41ddIiU8X19SX4odzbLvagQlWSBTsirmKILfnF6hQ8vpf54Z0YB+buis sMeETGVJqHbeYQOlQtpe7/0TErZ5av7oajrF8I9AVp4N1wbh7VFiKpY8LWlfHWHJGf 0+P4679VcYhSojADDfVxwou+CNpBt+apUVaV9G48YSO4xZVJd24GS6wkj2FT93p8/L 4bp5pQVas2ivw== 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 10/17] x86/compressed: pull global variable ref up into startup32_load_idt() Date: Tue, 22 Nov 2022 17:10:10 +0100 Message-Id: <20221122161017.2426828-11-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=2238; i=ardb@kernel.org; h=from:subject; bh=ZGYYMFhXkrZn+e+cVgRjzokBYpzkxMdbl7BhlbBHuq8=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBjfPRdh332hSmcyhnd6dWI3Fifx3u18Y9Dg3Bb6nFH 9BBqP/uJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCY3z0XQAKCRDDTyI5ktmPJNm3C/ 9t+i6/g+lskjGTDa4HQhq9OhoxKARAIBnekDSTufrRwq7UaYLrC70H2L/MCGzmVfYLB1mMfe+8fs05 4xAtilR1uWESgx3d9uCVVJSZ+ZPKJwirreG5+QYLr3UYwmIGnrQI9b4Q7xAHqqA9DvlXx0Snde9WSV SXk4/5AU6FQ55APrINmR9NgGPypvZhypy1CCyKxTUwRfynt7D8CSukxQpWtniES9Pe3XAMtrAxDYsm H0rQjMgT/XW7BaBFCx/GLHxJh13msz4Ye06DuT8MPnT46e5M9e8JPTtftw+cKfkarb7gSN5zvmNw/U FcCCDilzI5Rki3EDNGlCa/KP4+qoABbC1HepzwlDmJirE5PwVSQ7ug1FcnyWHHq2BhpM76O6uPxMiL aUqYchuPuatfBFGeZfVLu88K5atAk8p63BOFjF5hxJwV1vb4W+MmwW1D0OXMzjCEf+eccGmGzyspD7 PrLCXG0boJOGtG614NiQODtGnvpyZPvcOQ1p0mNEa0IHE= 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?1750213501774872871?= X-GMAIL-MSGID: =?utf-8?q?1750213501774872871?= In preparation for moving startup32_load_idt() out of head_64.S and turning it into an ordinary function using the ordinary 32-bit calling convention, pull the global variable reference to boot32_idt up into startup32_load_idt() so that startup32_set_idt_entry() does not need to discover its own runtime physical address, which will no longer be correlated with startup_32 once this code is moved into .text. While at it, give startup32_set_idt_entry() static linkage. Signed-off-by: Ard Biesheuvel --- arch/x86/boot/compressed/head_64.S | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S index f31277f455e63f5f..82d7fab99422129f 100644 --- a/arch/x86/boot/compressed/head_64.S +++ b/arch/x86/boot/compressed/head_64.S @@ -736,16 +736,11 @@ SYM_DATA_END_LABEL(boot32_idt, SYM_L_GLOBAL, boot32_idt_end) * * %eax: Handler address * %edx: Vector number - * - * Physical offset is expected in %ebp + * %ecx: IDT address */ -SYM_FUNC_START(startup32_set_idt_entry) - push %ebx - - /* IDT entry address to %ebx */ - leal rva(boot32_idt)(%ebp), %ebx - shl $3, %edx - addl %edx, %ebx +SYM_FUNC_START_LOCAL(startup32_set_idt_entry) + /* IDT entry address to %ecx */ + leal (%ecx, %edx, 8), %ecx /* Build IDT entry, lower 4 bytes */ movl %eax, %edx @@ -753,7 +748,7 @@ SYM_FUNC_START(startup32_set_idt_entry) orl $(__KERNEL32_CS << 16), %edx # Target code segment selector /* Store lower 4 bytes to IDT */ - movl %edx, (%ebx) + movl %edx, (%ecx) /* Build IDT entry, upper 4 bytes */ movl %eax, %edx @@ -761,15 +756,16 @@ SYM_FUNC_START(startup32_set_idt_entry) orl $0x00008e00, %edx # Present, Type 32-bit Interrupt Gate /* Store upper 4 bytes to IDT */ - movl %edx, 4(%ebx) + movl %edx, 4(%ecx) - pop %ebx RET SYM_FUNC_END(startup32_set_idt_entry) #endif SYM_FUNC_START(startup32_load_idt) #ifdef CONFIG_AMD_MEM_ENCRYPT + leal rva(boot32_idt)(%ebp), %ecx + /* #VC handler */ leal rva(startup32_vc_handler)(%ebp), %eax movl $X86_TRAP_VC, %edx