Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755559AbeAJBDx (ORCPT + 1 other); Tue, 9 Jan 2018 20:03:53 -0500 Received: from mga14.intel.com ([192.55.52.115]:41953 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755320AbeAJBDs (ORCPT ); Tue, 9 Jan 2018 20:03:48 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,337,1511856000"; d="scan'208";a="19708741" From: Andi Kleen To: tglx@linutronix.de Cc: x86@kernel.org, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, dwmw@amazon.co.uk, pjt@google.com, luto@kernel.org, peterz@infradead.org, thomas.lendacky@amd.com, tim.c.chen@linux.intel.com, gregkh@linux-foundation.org, dave.hansen@intel.com, jikos@kernel.org, Andi Kleen Subject: [PATCH v1 2/8] x86/entry/clearregs: Add infrastructure to clear registers Date: Tue, 9 Jan 2018 17:03:22 -0800 Message-Id: <20180110010328.22163-3-andi@firstfloor.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180110010328.22163-1-andi@firstfloor.org> References: <20180110010328.22163-1-andi@firstfloor.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: From: Andi Kleen Add 64bit assembler macros to clear registers on kernel entry. Used in followon patches. Signed-off-by: Andi Kleen --- arch/x86/entry/calling.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/arch/x86/entry/calling.h b/arch/x86/entry/calling.h index 45a63e00a6af..9444e7623185 100644 --- a/arch/x86/entry/calling.h +++ b/arch/x86/entry/calling.h @@ -172,6 +172,34 @@ For 32-bit we have the following conventions - kernel is built with .byte 0xf1 .endm + .macro CLEAR_R11_TO_R15 + xorq %r15, %r15 + xorq %r14, %r14 + xorq %r13, %r13 + xorq %r12, %r12 + xorq %r11, %r11 + .endm + + .macro CLEAR_R8_TO_R15 + CLEAR_R11_TO_R15 + xorq %r10, %r10 + xorq %r9, %r9 + xorq %r8, %r8 + .endm + + .macro CLEAR_ALL_REGS + CLEAR_R8_TO_R15 + xorl %eax, %eax + xorl %ebx, %ebx + xorl %ecx, %ecx + xorl %edx, %edx + xorl %esi, %esi + xorl %edi, %edi +#ifndef CONFIG_FRAME_POINTER + xorl %ebp, %ebp +#endif + .endm + /* * This is a sneaky trick to help the unwinder find pt_regs on the stack. The * frame pointer is replaced with an encoded pointer to pt_regs. The encoding -- 2.14.3