From patchwork Wed Jun 1 13:11:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Safonov X-Patchwork-Id: 9147973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C1AF760777 for ; Wed, 1 Jun 2016 18:46:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B486E1FFB9 for ; Wed, 1 Jun 2016 18:46:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A8CC9268AE; Wed, 1 Jun 2016 18:46:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F24791FFB9 for ; Wed, 1 Jun 2016 18:46:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751203AbcFASqZ (ORCPT ); Wed, 1 Jun 2016 14:46:25 -0400 Received: from mail-am1on0109.outbound.protection.outlook.com ([157.56.112.109]:43053 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750744AbcFASqX (ORCPT ); Wed, 1 Jun 2016 14:46:23 -0400 X-Greylist: delayed 19973 seconds by postgrey-1.27 at vger.kernel.org; Wed, 01 Jun 2016 14:46:23 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=DlGxu5BGtZBytL/Hj9OAxgL45NE1FnkxeMS1zH3XzL0=; b=fXd2Tv/6IK6jfeNlIJ+Hryy/ZaBhZ99VAR8N7l0/v5zqTwl/wOLKShBuc44KifJ0/Kg+P6qpbW++9kyTUw9MdA2Vl0iKzwhgHhqrKHOK6ecFkoywr2mPRp3OeNDhiqU3FNqub+X1J710ZHmioHughe/du9WJTD0BAO2NeW5cHDE= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=virtuozzo.com; Received: from dsafonov.sw.ru (195.214.232.10) by DB6PR0801MB1286.eurprd08.prod.outlook.com (10.168.11.16) with Microsoft SMTP Server (TLS) id 15.1.506.9; Wed, 1 Jun 2016 13:13:11 +0000 From: Dmitry Safonov To: , CC: , , , , <0x7f454c46@gmail.com>, , , , , Dmitry Safonov , Andy Lutomirski , Alexander Viro , Subject: [PATCH 4/6] x86/coredump: use core regs, rather that TIF_IA32 flag Date: Wed, 1 Jun 2016 16:11:35 +0300 Message-ID: <1464786697-20639-5-git-send-email-dsafonov@virtuozzo.com> X-Mailer: git-send-email 2.8.2 In-Reply-To: <1464786697-20639-1-git-send-email-dsafonov@virtuozzo.com> References: <1464786697-20639-1-git-send-email-dsafonov@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.10] X-ClientProxiedBy: AM5PR0901CA0029.eurprd09.prod.outlook.com (10.164.186.167) To DB6PR0801MB1286.eurprd08.prod.outlook.com (10.168.11.16) X-MS-Office365-Filtering-Correlation-Id: fc47bfb1-4271-4e54-0677-08d38a1e7cb8 X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1286; 2:mydu1ODOQ3CFmtm6+PXb85uimx/fht+tWA9mlvLhQxjX5lNSKLbeE/D0UIOfCxal0JxxZ3Dk+H4Ei4ag90vkyP8jsE5Ak/CQFEIAlEAY22RvPbWlEE8jTuiwPGNyruwurceXN+Az9Zz36GfP0AdDEfbFZ4h/O06nvss4E/u8TfclgswDRZxPJZ03FnfwI7hj; 3:GyV2vUTwSZb8Z6YQ+GLwQyFwPBKA7Aax+4o7yn28Fo8c9t31Du06jJXpD6wW3HYXNrPvZnjl/3MJpq1ImpoewwbnhLygWLAzTDC/O+T2DbNcssjjjaeYwl72pCMytiaq; 25:Ge72HpRcza14UHDaoT62CPztN+8kKw8QPmKMbYhgMwlT1oJL/2vQDq9quvSEyHX4A0b2VdAlhxOqv2l4qVaKhTXRt2LS+qzJ/HwFxVxmM+vVKsOrqOmPTqOMn/04JpUYytDaEniNB5ZeE+JMQncAFyg7prXDoSy+Tf0a4y/OOKf0044mwysYwrcjAj5k2s2352lXm1tq9bNd49edR8NIF4gJLaHdh9b5skVvtDwgrqVxld/cGtzQQNYTi5H30PNENjrXKXkMFOjTn0xAG9emChEmBQxVFsm0nEnSLpFzgCElYJq3jWLNErVaTcgHh7K1SjARkHje9PJ6+2u+MrteyEYCOG945HZmlrSyXU2j887mLRRyp4oO91G2DWIzGu4QuCp+sw+I3Jd+eIUipQwxzg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB6PR0801MB1286; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040130)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6041072)(6043046); SRVR:DB6PR0801MB1286; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0801MB1286; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1286; 4:qktaj9h9M+JTbyP2GyfwzsSACrMCVizmbPDpL6HZy0kl4oSGaQA4aqd99MQOfOUKKFPDFFTNYCjc+g8ab5lTMWV4Yzv7wGw5u9XFRinUEzrdawGvDXyxdRLpP4dXZlCNAb1o9Tf+C0d/vojyQeAlF3MlL5EhlEurImI4w9UmWhYmwOxlPdGHp5PUVr2lnlrYUUz3jqlEnCAMkDczQ807JOwSQxP3NgbZwW8QpGUGoCZy3GBDWUAj1BUaIqVE1Gio6nLgpPfbAv5r+tY+lH3SDrT7BgaSUmBvS2UzJtcGSzHjUBdv/3XtQ8rtAy57d5JzF5C0b4ccVGGe4Ye2LbNYmlTiUiKNlUV4piBSf1qVJnMtGc8QMP7MOdQlou5EziXBQ6h9fYwo7hwzFPNFgbcbMVWIg9ly+Cx3REi313oIHSfGvL40lmdbLJWG6MteiwYCvH6okV6kLbc52IgpCDgjww== X-Forefront-PRVS: 096029FF66 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(189998001)(5008740100001)(19580405001)(229853001)(19580395003)(8676002)(77096005)(33646002)(53416004)(5001770100001)(42186005)(5003940100001)(81166006)(586003)(50466002)(48376002)(6116002)(575784001)(86362001)(66066001)(36756003)(47776003)(2950100001)(50986999)(50226002)(92566002)(3846002)(4326007)(76176999)(5004730100002)(2906002); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR0801MB1286; H:dsafonov.sw.ru; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1286; 23:l+BqnwLTvsBuXAkSJW0XtKJmCEMUe2B3IMm62KwMUZ7LT+WiiJ/AkXmjOHKZxiQhmjiJENBaVgbzrRDQOHIqSA9ZezqUWeog7+DwyHZ7aT5SR5HJz/I2HXv+9R6ofPgBI1nb0FnypBG9G9V/7BcQ146O6U47cht/vO30RS8h9ooQ2qaCCCI5woOZkpuyMEi7lyg/drd4+DhS46D5k14vMSHRHQd7fZvZDjj9eyy1uJYRiehmdjRZ4Odr1p5K+P0ugdqy+SBJPeOL86oOp+lcEt1YSWTdloBwR4RtWw3IyB2F4ad10n0yqHvOHwN84RDCBAU2yfh/Be6Ia8ztMLqNmZxurpeRGoWvswmmU6zJgd6wfV8b+sNaG4tedraKDv52aD5jWJLAJcoKtAChBu7yfYNsz3ZvQGlOfr9xySprhe9BMkONReXRkW0Mk9s2R3VyEnnuhCm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dzjrYKevhgrdO5+T2hptn3iu7cGhRyQ5f/brJH5RBCeLkFyV7K3s9ilxaPoc9TG8TLf+LrmQ= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2016 13:13:11.5927 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1286 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As we have here core registers, use them to determine application's mode and sizes of register set and elf_prstatus instead of TIF_IA32 flag. Cc: Andy Lutomirski Cc: Ingo Molnar Cc: Thomas Gleixner Cc: "H. Peter Anvin" Cc: Oleg Nesterov Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Dmitry Safonov --- arch/x86/include/asm/compat.h | 8 ++++---- fs/binfmt_elf.c | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h index 5a3b2c119ed0..d0b517fc77ff 100644 --- a/arch/x86/include/asm/compat.h +++ b/arch/x86/include/asm/compat.h @@ -264,10 +264,10 @@ struct compat_shmid64_ds { #ifdef CONFIG_X86_X32_ABI typedef struct user_regs_struct compat_elf_gregset_t; -#define PR_REG_SIZE(S) (test_thread_flag(TIF_IA32) ? 68 : 216) -#define PRSTATUS_SIZE(S) (test_thread_flag(TIF_IA32) ? 144 : 296) -#define SET_PR_FPVALID(S,V) \ - do { *(int *) (((void *) &((S)->pr_reg)) + PR_REG_SIZE(0)) = (V); } \ +#define PR_REG_SIZE(S, R) (!user_64bit_mode(R) ? 68 : 216) +#define PRSTATUS_SIZE(S, R) (!user_64bit_mode(R) ? 144 : 296) +#define SET_PR_FPVALID(S, V, R) \ + do { *(int *) (((void *) &((S)->pr_reg)) + PR_REG_SIZE(0, R)) = (V); } \ while (0) #define COMPAT_USE_64BIT_TIME \ diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index e158b22ef32f..3876382edc72 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -1623,11 +1623,11 @@ static void do_thread_regset_writeback(struct task_struct *task, } #ifndef PR_REG_SIZE -#define PR_REG_SIZE(S) sizeof(S) +#define PR_REG_SIZE(S, R) sizeof(S) #endif #ifndef PRSTATUS_SIZE -#define PRSTATUS_SIZE(S) sizeof(S) +#define PRSTATUS_SIZE(S, R) sizeof(S) #endif #ifndef PR_REG_PTR @@ -1635,12 +1635,13 @@ static void do_thread_regset_writeback(struct task_struct *task, #endif #ifndef SET_PR_FPVALID -#define SET_PR_FPVALID(S, V) ((S)->pr_fpvalid = (V)) +#define SET_PR_FPVALID(S, V, R) ((S)->pr_fpvalid = (V)) #endif static int fill_thread_core_info(struct elf_thread_core_info *t, const struct user_regset_view *view, - long signr, size_t *total) + long signr, size_t *total, + struct pt_regs *regs __maybe_unused) { unsigned int i; @@ -1652,11 +1653,11 @@ static int fill_thread_core_info(struct elf_thread_core_info *t, */ fill_prstatus(&t->prstatus, t->task, signr); (void) view->regsets[0].get(t->task, &view->regsets[0], - 0, PR_REG_SIZE(t->prstatus.pr_reg), + 0, PR_REG_SIZE(t->prstatus.pr_reg, regs), PR_REG_PTR(&t->prstatus), NULL); fill_note(&t->notes[0], "CORE", NT_PRSTATUS, - PRSTATUS_SIZE(t->prstatus), &t->prstatus); + PRSTATUS_SIZE(t->prstatus, regs), &t->prstatus); *total += notesize(&t->notes[0]); do_thread_regset_writeback(t->task, &view->regsets[0]); @@ -1686,7 +1687,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t, regset->core_note_type, size, data); else { - SET_PR_FPVALID(&t->prstatus, 1); + SET_PR_FPVALID(&t->prstatus, 1, regs); fill_note(&t->notes[i], "CORE", NT_PRFPREG, size, data); } @@ -1772,7 +1773,8 @@ static int fill_note_info(struct elfhdr *elf, int phdrs, * Now fill in each thread's information. */ for (t = info->thread; t != NULL; t = t->next) - if (!fill_thread_core_info(t, view, siginfo->si_signo, &info->size)) + if (!fill_thread_core_info(t, view, siginfo->si_signo, + &info->size, regs)) return 0; /*