Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751335AbeAPDnw (ORCPT + 1 other); Mon, 15 Jan 2018 22:43:52 -0500 Received: from terminus.zytor.com ([65.50.211.136]:36689 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751002AbeAPDnu (ORCPT ); Mon, 15 Jan 2018 22:43:50 -0500 Date: Mon, 15 Jan 2018 19:38:15 -0800 From: tip-bot for Tom Lendacky Message-ID: Cc: mingo@kernel.org, thomas.lendacky@amd.com, bp@alien8.de, hpa@zytor.com, torvalds@linux-foundation.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, nix.or.die@gmail.com, peterz@infradead.org, bp@suse.de, brijesh.singh@amd.com Reply-To: bp@suse.de, peterz@infradead.org, brijesh.singh@amd.com, torvalds@linux-foundation.org, hpa@zytor.com, bp@alien8.de, thomas.lendacky@amd.com, mingo@kernel.org, linux-kernel@vger.kernel.org, nix.or.die@gmail.com, tglx@linutronix.de In-Reply-To: <20180110192556.6026.74187.stgit@tlendack-t1.amdoffice.net> References: <20180110192556.6026.74187.stgit@tlendack-t1.amdoffice.net> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/mm: Clean up register saving in the __enc_copy() assembly code Git-Commit-ID: 1303880179e67c59e801429b7e5d0f6b21137d99 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: Commit-ID: 1303880179e67c59e801429b7e5d0f6b21137d99 Gitweb: https://git.kernel.org/tip/1303880179e67c59e801429b7e5d0f6b21137d99 Author: Tom Lendacky AuthorDate: Wed, 10 Jan 2018 13:25:56 -0600 Committer: Ingo Molnar CommitDate: Tue, 16 Jan 2018 01:50:58 +0100 x86/mm: Clean up register saving in the __enc_copy() assembly code Clean up the use of PUSH and POP and when registers are saved in the __enc_copy() assembly function in order to improve the readability of the code. Move parameter register saving into general purpose registers earlier in the code and move all the pushes to the beginning of the function with corresponding pops at the end. We do this to prepare fixes. Tested-by: Gabriel Craciunescu Signed-off-by: Tom Lendacky Reviewed-by: Borislav Petkov Cc: Borislav Petkov Cc: Brijesh Singh Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/20180110192556.6026.74187.stgit@tlendack-t1.amdoffice.net Signed-off-by: Ingo Molnar --- arch/x86/mm/mem_encrypt_boot.S | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/x86/mm/mem_encrypt_boot.S b/arch/x86/mm/mem_encrypt_boot.S index 730e6d5..de36884 100644 --- a/arch/x86/mm/mem_encrypt_boot.S +++ b/arch/x86/mm/mem_encrypt_boot.S @@ -103,20 +103,19 @@ ENTRY(__enc_copy) orq $X86_CR4_PGE, %rdx mov %rdx, %cr4 + push %r15 + + movq %rcx, %r9 /* Save kernel length */ + movq %rdi, %r10 /* Save encrypted kernel address */ + movq %rsi, %r11 /* Save decrypted kernel address */ + /* Set the PAT register PA5 entry to write-protect */ - push %rcx movl $MSR_IA32_CR_PAT, %ecx rdmsr - push %rdx /* Save original PAT value */ + mov %rdx, %r15 /* Save original PAT value */ andl $0xffff00ff, %edx /* Clear PA5 */ orl $0x00000500, %edx /* Set PA5 to WP */ wrmsr - pop %rdx /* RDX contains original PAT value */ - pop %rcx - - movq %rcx, %r9 /* Save kernel length */ - movq %rdi, %r10 /* Save encrypted kernel address */ - movq %rsi, %r11 /* Save decrypted kernel address */ wbinvd /* Invalidate any cache entries */ @@ -138,12 +137,13 @@ ENTRY(__enc_copy) jnz 1b /* Kernel length not zero? */ /* Restore PAT register */ - push %rdx /* Save original PAT value */ movl $MSR_IA32_CR_PAT, %ecx rdmsr - pop %rdx /* Restore original PAT value */ + mov %r15, %rdx /* Restore original PAT value */ wrmsr + pop %r15 + ret .L__enc_copy_end: ENDPROC(__enc_copy)