Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757163AbcCUQSM (ORCPT ); Mon, 21 Mar 2016 12:18:12 -0400 Received: from mga11.intel.com ([192.55.52.93]:19915 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756429AbcCUQQP (ORCPT ); Mon, 21 Mar 2016 12:16:15 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,372,1455004800"; d="scan'208";a="915706561" From: Andi Kleen To: x86@kernel.org Cc: luto@amacapital.net, linux-kernel@vger.kernel.org, Andi Kleen Subject: [PATCH 9/9] x86: Save FS/GS base in core dump Date: Mon, 21 Mar 2016 09:16:09 -0700 Message-Id: <1458576969-13309-10-git-send-email-andi@firstfloor.org> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1458576969-13309-1-git-send-email-andi@firstfloor.org> References: <1458576969-13309-1-git-send-email-andi@firstfloor.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1357 Lines: 44 From: Andi Kleen Add FS/GS base dumping to the standard ELF_CORE_COPY_REGS macro I think this is only used in some special cases, the majority of core dumps seem to go through the getregs interface also used by ptrace. Signed-off-by: Andi Kleen --- arch/x86/include/asm/elf.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h index 0df9c95..f57cc17 100644 --- a/arch/x86/include/asm/elf.h +++ b/arch/x86/include/asm/elf.h @@ -9,6 +9,8 @@ #include #include #include +#include +#include typedef unsigned long elf_greg_t; @@ -226,8 +228,13 @@ do { \ (pr_reg)[18] = (regs)->flags; \ (pr_reg)[19] = (regs)->sp; \ (pr_reg)[20] = (regs)->ss; \ - (pr_reg)[21] = current->thread.fs; \ - (pr_reg)[22] = current->thread.gs; \ + if (boot_cpu_has(X86_FEATURE_FSGSBASE)) { \ + (pr_reg)[21] = rdfsbase(); \ + (pr_reg)[22] = read_user_gsbase(); \ + } else { \ + (pr_reg)[21] = current->thread.fs; \ + (pr_reg)[22] = current->thread.gs; \ + } \ asm("movl %%ds,%0" : "=r" (v)); (pr_reg)[23] = v; \ asm("movl %%es,%0" : "=r" (v)); (pr_reg)[24] = v; \ asm("movl %%fs,%0" : "=r" (v)); (pr_reg)[25] = v; \ -- 2.5.5