Received: by 10.223.176.46 with SMTP id f43csp2650125wra; Mon, 22 Jan 2018 00:53:48 -0800 (PST) X-Google-Smtp-Source: AH8x227kpFQwkSPlNX2YZPGg7quCr3kETRaWIBqZ97A8vttgVn9nxjKooAttAzbJDMS/vntPldiG X-Received: by 10.99.115.82 with SMTP id d18mr6693345pgn.312.1516611228732; Mon, 22 Jan 2018 00:53:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516611228; cv=none; d=google.com; s=arc-20160816; b=Npmr9XRZBMslQT1GL63/Gb7jNj9AgHDbQ1pXG+SI0ZANPDNh3RGr6V7jPS7eL688ya uyE8JuLUJjuPQRBo834Tp0PcrKeKyRbqYQnUW3h/9a14HLbTFbWcsBOLFFTYZMMXKtww 6G3QTSYjANKkRqDckASAkfz9qsI2l7kVIf1XJbRlzFYPlyMvlPaVOA47jDTDJXW+w2tV s0TPfWgfWkpRH1YM8caOqzUAUgPWuaIeSLOTDwt49w2X6r8rm1Tg3dNRcOxJm8b5SWNp a5pFg4dG/LZGaEIWOi7efGr/K1Xirer1x6/BvoqA41wjD5vXuxmKVlUbETHCh1cvIxUu SaSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=AgG2/9URSkRU+HndEDEuzOhNj7U76+LQrLvTLAX2HqA=; b=I3s4TAB9fRDFUgupVjxRAB7nSfA+z5u/Aj2entdpCsQAnOBn63o4x8V4yqb4fbAbNd MiWH4FKptJH5FI915FpeQ0omByoOKbU76PGtVva61MWVQ3xdI6NSm55k8hryG/+i2JQL NQU1BP1iLWXpNFfEIG+1F2JQ/duCTdbB33MUohSFDy8wAPql4864w06N2GXaUL+AaC3I CXnPlZKliPce+fdvA4b5CsvYs8Xq/kL9fUn7lmaoLnxDrSltxtUg6CAZBzBz/+lerMKW +Cckb7abYDUocwih1uYz6/+6Nip8vAl5p2Ec+kGdUtufv7PiPLBxfo2U2tfB6099wW99 /H5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h132si13501985pgc.309.2018.01.22.00.53.34; Mon, 22 Jan 2018 00:53:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753166AbeAVIwK (ORCPT + 99 others); Mon, 22 Jan 2018 03:52:10 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:33548 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753144AbeAVIwI (ORCPT ); Mon, 22 Jan 2018 03:52:08 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 65A34E5F; Mon, 22 Jan 2018 08:52:07 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gabriel Craciunescu , Tom Lendacky , Borislav Petkov , Borislav Petkov , Brijesh Singh , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Ingo Molnar Subject: [PATCH 4.14 44/89] x86/mm: Clean up register saving in the __enc_copy() assembly code Date: Mon, 22 Jan 2018 09:45:24 +0100 Message-Id: <20180122083959.114892314@linuxfoundation.org> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180122083954.683903493@linuxfoundation.org> References: <20180122083954.683903493@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tom Lendacky commit 1303880179e67c59e801429b7e5d0f6b21137d99 upstream. 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 Signed-off-by: Greg Kroah-Hartman --- arch/x86/mm/mem_encrypt_boot.S | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) --- 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)