Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2513066rwb; Mon, 15 Aug 2022 06:47:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR47ByvOxGuevB/A/eLDP7jBtsmAVB4OZH/vMPo9ndL8AeOafnnYlU4aOiuKJX4NBTMQ5Idw X-Received: by 2002:a05:6402:e96:b0:443:a086:e3e8 with SMTP id h22-20020a0564020e9600b00443a086e3e8mr6484181eda.330.1660571269633; Mon, 15 Aug 2022 06:47:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660571269; cv=none; d=google.com; s=arc-20160816; b=iGPazJ5Hzn4tKjbddYtgc3oFF6oSAynVvOJXvHO3rTpYx5qVSPqxpg97PvBqXAW+mR Fd/awKDvYmaQ6mhC47NRVHnOm3/6uW0I7Lp83EkLMokLRqbWd4M92yI71WwQJdhQj6je GMeee/ZTN7dkwa77KFbpA+IOuuR3Sj9pp2s5PkKPecGvIes5aUE2t9Iz3zBzzTkMdTKe NjtTKzW6FK/7FYSZ5+SItSM8zw1+jVSBgOSCgjn2woawfi8eJNiik2hT4kGHFHI6qAnQ CYY7UIZcui/crzRkeq0w3QTw4NDQwrcxy77bbeWJWHikoGgkQwto9X8zo2oXR5z7JDer jT6w== 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=Inq3Ei+hedm/247fyVk/Ki1HPfJAKrr2zhXP3oqDxFc=; b=ryOcDOpvKEbwCrLgVxb3LHx5kG7KZa/Fustpu1EQRh+ES7T9sYUJtBoBJtLuPW888j 0qOF+sTMtCmVD2Kza7WIAHYxElgsMGMxHuqcnaBhFNXB3jgP4GHEhXF6OvCKK/vMuuX3 ZdZcmt7Jxe0Gr4XywKZufvevgRezzVx7a9VXz4VZ9wnwItqUyhHVXIJYtAG/ADe6Uf18 xNBRWWnWQCQCOHVkuTL4HLuyF8T2/foS/oQl/xVhySt4wSW5sPErB0jeXnlVIMwJeS1r BPL6GiBcy6bw1qBCvHmK/zCwh58Soe9NCV+CJEKvoOpfMEbw+fxJKEQUoFTKahCjZBSl y3ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ncQbKvFN; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j9-20020a05640211c900b0043e57ef5606si10467554edw.9.2022.08.15.06.47.23; Mon, 15 Aug 2022 06:47:49 -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=@kernel.org header.s=k20201202 header.b=ncQbKvFN; 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 S240848AbiHONnT (ORCPT + 99 others); Mon, 15 Aug 2022 09:43:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232733AbiHONmo (ORCPT ); Mon, 15 Aug 2022 09:42:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30E582229A; Mon, 15 Aug 2022 06:42:42 -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 9136C60ECD; Mon, 15 Aug 2022 13:42:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3EAC9C433D7; Mon, 15 Aug 2022 13:42:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660570961; bh=iLZ/QdlEqOikKI8mubzHLev1D6XwzdHhOGlBP3RyGSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ncQbKvFNR4GvZaQTrJoFL4uwRNOL++xVBJ/gZIPq1GjJ5+pG8NLOyGRDXSn7Krzvh QKmddlFBh/KwULsBxFcx8Jk+PNEFUS30iC0MqEARPUN23fdXhuqDnOedRvDKfXaaIa eSP+pRcItGRCbmVuhDrHlXekc97HczehZ4FvxmsrVsiRF/1Z62qOD1XM4rHmnN4Jjy 4n5VDa6s8vgo/DZ4dcEDke+M5SNNfcAT+36OwXdCajEDNq23sPJHaEBjFCHs4bd/qo 2BI0jh2zOeegjbfzpAFQA8lrOxPzqcrT4s7mhhbLXKfKjTWgXVp0/52Er6Q40BnFa2 6epOWMCNwTDRw== From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: linux-efi@vger.kernel.org, Ard Biesheuvel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Michael Roth Subject: [PATCH 5/6] x86/compressed: adhere to calling convention in get_sev_encryption_bit() Date: Mon, 15 Aug 2022 15:42:22 +0200 Message-Id: <20220815134223.740112-6-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220815134223.740112-1-ardb@kernel.org> References: <20220815134223.740112-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2039; i=ardb@kernel.org; h=from:subject; bh=iLZ/QdlEqOikKI8mubzHLev1D6XwzdHhOGlBP3RyGSs=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBi+k07xFpdATaza7RxA3Aem61HCMPy0ZtsZWGaSeID EMnEt2WJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYvpNOwAKCRDDTyI5ktmPJFwHDA Ce2cOoBH2t9EWQu1/TVHav9JmX1u5P6RGZQQKG7TKKIjLM3iOcpjrOdLOCv+CTT5s31G76RCNRlW1Z RvDdc3Uw+uPmCztutDQG3WxpZYMo/ex1ndX281yeHO9Jz1qT69WzX8oR24t6A9rEgX2K0mNJYg7Tuv EnoVTLHmsJtqLcdz82SSzPkuGyb6W2kTf+vbA1VQOPlcHuc+WCvCgzKr9HZyjzhtqHqLL30CTaL/oY m6PxNrj1iEf3ADlBEOf/kqKe059uC1va1bDg21QyXKw4NKZWpvsjFfje/GuwEJLYBhokiSLVWHMS23 +dIlKhuJ+q2hQrTV91TO1Up8KpblLUDJ0GCSVE/eCosoSprxcXw+2viEeh2nI7fnmBgigfYUFs15M9 R59CrDAWInKMdaTPUjoDcpgnBx8QrWLxMpHKkSi338OhuvY/ulfwO1NEnCOekd+DZuOPn13Z7VAjRv lHDWxxiTzQYr2WVvfEjGEUr5XThV3wVFygsayHkHNvrdM= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 Content-Transfer-Encoding: 8bit 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,T_SCC_BODY_TEXT_LINE 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 Make get_sev_encryption_bit() follow the ordinary x86 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 | 6 ++++-- arch/x86/boot/compressed/mem_encrypt.S | 10 ---------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S index 382ed3d8b26a..4539e7c6d4c3 100644 --- a/arch/x86/boot/compressed/head_64.S +++ b/arch/x86/boot/compressed/head_64.S @@ -180,12 +180,12 @@ 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. */ +#ifdef CONFIG_AMD_MEM_ENCRYPT call get_sev_encryption_bit xorl %edx, %edx -#ifdef CONFIG_AMD_MEM_ENCRYPT testl %eax, %eax jz 1f subl $32, %eax /* Encryption bit is always above bit 31 */ @@ -199,6 +199,8 @@ SYM_FUNC_START(startup_32) */ movl $1, rva(sev_status)(%ebp) 1: +#else + xorl %edx, %edx #endif /* Initialize Page tables to 0 */ diff --git a/arch/x86/boot/compressed/mem_encrypt.S b/arch/x86/boot/compressed/mem_encrypt.S index 3cd3db0da49d..b4a116283bd9 100644 --- a/arch/x86/boot/compressed/mem_encrypt.S +++ b/arch/x86/boot/compressed/mem_encrypt.S @@ -21,12 +21,7 @@ .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 @@ -57,12 +52,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) -- 2.35.1