From patchwork Tue Nov 22 16:10:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 24460 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2302714wrr; Tue, 22 Nov 2022 08:15:24 -0800 (PST) X-Google-Smtp-Source: AA0mqf61VtlGPapPSl5hpTSQPv+UnLsWFBPg2QbbEuCF8PFRMxUxfj1RlQkmSDmdM7qwrgx1y4df X-Received: by 2002:a63:6f4b:0:b0:470:5619:4d7d with SMTP id k72-20020a636f4b000000b0047056194d7dmr22564405pgc.301.1669133724137; Tue, 22 Nov 2022 08:15:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669133724; cv=none; d=google.com; s=arc-20160816; b=GznCwyrfd5a3ciPssYdcEBn5FPfR+1jxk82/Suc08MtmzWhMhZW5FgjTz0c3ydaEBi SJIXBtYMlRA7iVNLfnh52Bby1D0DbRZGb5yApyw+i720ecnO46DFTYKqlKTKZ1BkMQog dbJcG+Z9OKFcSlp0IB0dtJY45CCjSkkf944SACyOTJ8sGpFPcEaEW0F12jGOXTlGzQ6H AXuMuzkqqzsx9LVwta5xXvIM56XZUlMCTRFsOVthLS4MxAUMOpWVkkg60+york0D0v4m OK7GgEvcqRFPXG4LWMLiYqRN3RiI4oWD6cOIg1IgRjX74vPe+SbEe7Nhi0JS/MQ3V1ZS zIMA== 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=Uur1aI143OsiWvJLgs7lKDLl573P209B1NQCkER1zmw=; b=gQNZ51S74zpeijYuy4jOtUR4K7SOVdGkT9h8/JpUmIUrry2jZz8Jg3VJg5Y+heL4tf yVjsZX2S1AxnR2odImS3S7x5H9F3u7Val2ybNxZ8n87tIa3BKF21oF+90lsgy9bXp8iK Wy6Xa92ZN5TgGvn9Pan5zKujK/i4KHNmBhp7yV0XUua3CDe7SrwT0vZfmnkDE4R81zga 4dnfA5XRoSQ1+fv5O4TUEyP9ZY384VTbBM9G8vkkdSXstIlN2DAUqt+h/Jf9mqIr8n4n 03Eu8VQ+bP4xwDGmFFx+vks8SyzPwwi1Sssm3FM0TYGps91ue2cRNUdi4dWeQYCQmTdL ljSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hl5LV4DC; 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 e14-20020a6558ce000000b0046f5ffcfc1dsi15692883pgu.324.2022.11.22.08.15.09; Tue, 22 Nov 2022 08:15: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=hl5LV4DC; 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 S233878AbiKVQM1 (ORCPT + 99 others); Tue, 22 Nov 2022 11:12:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232852AbiKVQLh (ORCPT ); Tue, 22 Nov 2022 11:11:37 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC30E74AA4; Tue, 22 Nov 2022 08:11:08 -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 856FEB81C10; Tue, 22 Nov 2022 16:11:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62FFEC433D7; Tue, 22 Nov 2022 16:11:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669133466; bh=WzgruzR/v1MEVPGvMfLbw7xCwZPOIioiFXKbArp2e20=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hl5LV4DCJoQbDIyuHOaHIoqt7NLovhtjIM9BVLXENuDhZK8U/Tdr8ErYt6C8UGPRl ekPienlBAffkk4JnJy+2qvhrYbP2gIw03vtJ/qWdIV2T/iw1UNhOZVRrQPaSe7wyec 4LIpSpGSaTFELxo/6SZIhqHYvmmy1KgODJ+rldbgCvUzYwbjduhynFHkGRS77txH8l wYS2NP3f0QlY9CY1O6eBScPmzdXJyQIAQiyiePRP3O1lAR57qEdGwM1aFF1ePpD/Tj TvCOZsATwQ9DIE8wMrDmAhJIbOh2MzvAq6axyZy9t39AP7DIpc1Q+bjzdXG3oGKbzE c3FXW9faPaYuw== 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 15/17] x86/compressed: adhere to calling convention in get_sev_encryption_bit() Date: Tue, 22 Nov 2022 17:10:15 +0100 Message-Id: <20221122161017.2426828-16-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=1909; i=ardb@kernel.org; h=from:subject; bh=WzgruzR/v1MEVPGvMfLbw7xCwZPOIioiFXKbArp2e20=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBjfPRlRjCxfUGcb8bUP8866wWUGhLDdGiyfHOFhXH7 xfd5BRmJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCY3z0ZQAKCRDDTyI5ktmPJGPtC/ 91APxkHaUNp4yBkeDxwprSCH28epIzimrD0vGJf9LbPi5dn6uj76y3+T4vrgtHhAYZnNO/Nw4dwzzR 14AJNAGQmmU5stvmBSm9ioWr5fHNym/ks4TYcPtA2EGDDRERG4jMI//3JpMznmg+sAm6qmiG0x6/+R JRgAU2Bu1xVw8qvnfwz722rD9r9E1zo+StiSMIYFtmRwSeVHt0F1/StamR8Ct7NW79oWFfCpi3v8bj V/+VcvkxZDTDtUWsGMVdAjVQvwq/KJqcALXNynkjfkBZEkmdcvOCRYooQ/l8e6nW/3Ih6DAxGC3f7u J+5WZeZKMAUQWsXoLYEKLEIe2bXFRNuPrYIK45sn809agJgilov8zYP/zl70UYYgRHPBFXPBD+6BMB 9Dg9cXWdGNAkUyiqJAxtG4FBqShNzg96C3R1n91sJjUnFrZa6eQ8q5NGOXR21m33tF9+LJcFYqB9Rb +stxkVfyllEXg3zFeg2EuZ9D7WppYsUGfNVjuE6iMDmLY= 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?1750213563858603838?= X-GMAIL-MSGID: =?utf-8?q?1750213563858603838?= Make get_sev_encryption_bit() follow the ordinary i386 calling convention, and only call it if CONFIG_AMD_MEM_ENCRYPT is actually enabled. This clarifies the calling code, and makes it more maintainable. Signed-off-by: Ard Biesheuvel --- arch/x86/boot/compressed/head_64.S | 5 +++-- arch/x86/boot/compressed/mem_encrypt.S | 10 ---------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S index 0cfc8ce273a2731c..dd18216cff5c37e0 100644 --- a/arch/x86/boot/compressed/head_64.S +++ b/arch/x86/boot/compressed/head_64.S @@ -188,12 +188,13 @@ SYM_FUNC_START(startup_32) */ /* * If SEV is active then set the encryption mask in the page tables. - * This will insure that when the kernel is copied and decompressed + * This will ensure that when the kernel is copied and decompressed * it will be done so encrypted. */ - call get_sev_encryption_bit xorl %edx, %edx #ifdef CONFIG_AMD_MEM_ENCRYPT + call get_sev_encryption_bit + xorl %edx, %edx testl %eax, %eax jz 1f subl $32, %eax /* Encryption bit is always above bit 31 */ diff --git a/arch/x86/boot/compressed/mem_encrypt.S b/arch/x86/boot/compressed/mem_encrypt.S index 14cf04a1ed091655..e69674588a31c81f 100644 --- a/arch/x86/boot/compressed/mem_encrypt.S +++ b/arch/x86/boot/compressed/mem_encrypt.S @@ -18,12 +18,7 @@ .text .code32 SYM_FUNC_START(get_sev_encryption_bit) - xor %eax, %eax - -#ifdef CONFIG_AMD_MEM_ENCRYPT push %ebx - push %ecx - push %edx movl $0x80000000, %eax /* CPUID to check the highest leaf */ cpuid @@ -54,12 +49,7 @@ SYM_FUNC_START(get_sev_encryption_bit) xor %eax, %eax .Lsev_exit: - pop %edx - pop %ecx pop %ebx - -#endif /* CONFIG_AMD_MEM_ENCRYPT */ - RET SYM_FUNC_END(get_sev_encryption_bit)