All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Tom Lendacky <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
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
Subject: [tip:x86/urgent] x86/mm: Clean up register saving in the __enc_copy() assembly code
Date: Mon, 15 Jan 2018 19:38:15 -0800	[thread overview]
Message-ID: <tip-1303880179e67c59e801429b7e5d0f6b21137d99@git.kernel.org> (raw)
In-Reply-To: <20180110192556.6026.74187.stgit@tlendack-t1.amdoffice.net>

Commit-ID:  1303880179e67c59e801429b7e5d0f6b21137d99
Gitweb:     https://git.kernel.org/tip/1303880179e67c59e801429b7e5d0f6b21137d99
Author:     Tom Lendacky <thomas.lendacky@amd.com>
AuthorDate: Wed, 10 Jan 2018 13:25:56 -0600
Committer:  Ingo Molnar <mingo@kernel.org>
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 <nix.or.die@gmail.com>
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Reviewed-by: Borislav Petkov <bp@suse.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20180110192556.6026.74187.stgit@tlendack-t1.amdoffice.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 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)

  reply	other threads:[~2018-01-16  3:43 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-10 19:25 [PATCH v3 0/5] x86: SME: BSP/SME microcode update fix Tom Lendacky
2018-01-10 19:25 ` [PATCH v3 1/5] x86/mm: Cleanup register saving in mem_encrypt_boot.S Tom Lendacky
2018-01-16  3:38   ` tip-bot for Tom Lendacky [this message]
2018-01-10 19:26 ` [PATCH v3 2/5] x86/mm: Use a struct to reduce parameters for SME PGD mapping Tom Lendacky
2018-01-16  3:38   ` [tip:x86/urgent] " tip-bot for Tom Lendacky
2018-01-10 19:26 ` [PATCH v3 3/5] x86/mm: Centralize PMD flags in sme_encrypt_kernel() Tom Lendacky
2018-01-16  3:39   ` [tip:x86/urgent] " tip-bot for Tom Lendacky
2018-01-10 19:26 ` [PATCH v3 4/5] x86/mm: Prepare sme_encrypt_kernel() for PAGE aligned encryption Tom Lendacky
2018-01-16  3:39   ` [tip:x86/urgent] " tip-bot for Tom Lendacky
2018-01-10 19:26 ` [PATCH v3 5/5] x86/mm: Encrypt the initrd earlier for BSP microcode update Tom Lendacky
2018-01-16  3:40   ` [tip:x86/urgent] " tip-bot for Tom Lendacky
2018-01-10 21:14 ` [PATCH v3 0/5] x86: SME: BSP/SME microcode update fix Gabriel C
2018-01-10 21:26   ` Tom Lendacky
2018-01-10 22:20     ` Gabriel C
2018-01-11 18:33 ` Borislav Petkov
2018-01-15 22:47   ` Gabriel C
2018-01-19 15:03     ` Tom Lendacky
2018-01-19 15:11       ` Greg Kroah-Hartman
2018-01-19 15:27         ` Tom Lendacky
2018-01-19 15:35           ` Greg Kroah-Hartman
2018-01-19 15:38             ` Greg Kroah-Hartman
2018-01-19 15:56             ` Tom Lendacky
2018-01-19 16:02               ` Gabriel C
2018-01-19 17:15                 ` Tom Lendacky
2018-01-19 15:39           ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-1303880179e67c59e801429b7e5d0f6b21137d99@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=bp@alien8.de \
    --cc=bp@suse.de \
    --cc=brijesh.singh@amd.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=nix.or.die@gmail.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.