From patchwork Wed Jun 29 10:57:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Safonov X-Patchwork-Id: 9204851 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 51A306075F for ; Wed, 29 Jun 2016 11:15:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 423152864C for ; Wed, 29 Jun 2016 11:15:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3684928653; Wed, 29 Jun 2016 11:15:41 +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 8EF8B2864C for ; Wed, 29 Jun 2016 11:15:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751604AbcF2LO4 (ORCPT ); Wed, 29 Jun 2016 07:14:56 -0400 Received: from mail-am1on0135.outbound.protection.outlook.com ([157.56.112.135]:60922 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751168AbcF2LOy (ORCPT ); Wed, 29 Jun 2016 07:14:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ChuwZpdo7KBPYmMufSq/xEAmfOGonKDLQUZt1sNdA1c=; b=O0mKElKwJsqasRAzBm950+5K06GGeXrTQC75OGfCm3Iy4jITZNBdnBo60y4OBHltWMLU51uVHK2XAMZvVimTYYikXLpMQTFc0pTAuCpoaF+DvidWxxV2TfeHh/IgNy7NJwX6lbzT6Cvw3hsgQ6JGP813mIkOj3nGkrLj4oPoWv8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=dsafonov@virtuozzo.com; Received: from dsafonov.sw.ru (195.214.232.10) by HE1PR0801MB1738.eurprd08.prod.outlook.com (10.168.149.150) with Microsoft SMTP Server (TLS) id 15.1.523.12; Wed, 29 Jun 2016 10:59:01 +0000 From: Dmitry Safonov To: CC: <0x7f454c46@gmail.com>, , , , , , , Dmitry Safonov , Andy Lutomirski , , Alexander Viro , Subject: [PATCHv2 4/6] x86/coredump: use pr_reg size, rather that TIF_IA32 flag Date: Wed, 29 Jun 2016 13:57:34 +0300 Message-ID: <20160629105736.15017-5-dsafonov@virtuozzo.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160629105736.15017-1-dsafonov@virtuozzo.com> References: <20160629105736.15017-1-dsafonov@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.10] X-ClientProxiedBy: HE1PR0801CA0018.eurprd08.prod.outlook.com (10.167.184.28) To HE1PR0801MB1738.eurprd08.prod.outlook.com (10.168.149.150) X-MS-Office365-Filtering-Correlation-Id: e0df8556-5bd6-4678-949e-08d3a00c61be X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB1738; 2:zCBkDV4cecBLpOXTWQZRbDY54R4fUuu5fiCLzeIpEzOHlTxNqu5ZJ5Hbaw7TRBnLCsMUnu1j826ehq/fzP7o2vAHbS7o96cruR9FFFU4S+oqLyfbmN5eq5bB/O+MsnysNVMHWx1UaDWwJnCBbhmr37RL4RYoFWK5ZAaYymRH9YDcFj5lBhPow9beguu/Iskt; 3:oNWUg02MDkQO4iGO307mhsXoOib+eM5vwcU02vjZWb53rRbQePiUjV39/ouMS1LBIgPFDSO52dpJbjj/+W/oZmYCIKKKxsEACjeSsPsG74bH7aNo5Pjkp/NuaTTk0E+U X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0801MB1738; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB1738; 25:AoE1ibe2HPI4Vd3zqnDOLCc58Z0aMm/70TLqwCaIhVTtxe/dd/AIe7aesr2bRSfZy4fJXuU4n/K3Ls9Zb6frvsVA5LGMEZ9J9b3U/BkGFJttcBu+IrZbLFlX0Aggfn3pnTAkyk5pksLNAMiwOnXqxr54qi40H3nChVBVS4snoVL7qSkV61gCD7CgzawweZlR+I2FFu4Roa49t5MqOTAi3SL0l0YqlDFL7geYIquKcFl3CZ7U/vREAXJHIV2RupVyQHAtOUZMD3hERlPQBWWzqRHD11dfCw96w9BqVDRDbCCxJJCJizyWbw9Z9X21Dx3pt3DZE0CDFJxeY4bpI0qK3E+BGlMHcxhl1F+wkp35ZxCKFscGLfBWCkHt7v+ZdFucU07o5HSXN5x03b676PeZjnXCzPZHm66/UiSZ9xB5oKsbozWPbvKEqfdNVjDhy3gi6AA0a8S0s+NXFm3mDfIHEZyRv60nr4QPDHKtIqxTzdhWD+sxyLFzAC0jf+HZR8hvB+jF9RtH7w+cdN0nMs8PU/H+CluBcC8+P5sHjEXuMRL5ycw02WKwPNFafBn1TWoa4H0XNYfS0e7TN6clYdP4Mt75eVAbNTvwVbJN/V/3M7kHQXzI+0AMPFpiKuXudHdXS412YoPVgmTDGn/RTjItX6vkoLPvy/n50zs2fx68lvdHyaGJxh682S/mZy+XkBYt 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)(5005006)(8121501046)(10201501046)(3002001)(6041072)(6043046); SRVR:HE1PR0801MB1738; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0801MB1738; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB1738; 4:ouSiiLNXnlEXQfaoc3k/5AOQEiAgCQ4vygsOSIePEwmWSH9MZZPnsXMYI1MC6NouWC9VEPhMU7dwVVv4adQ4UAbxvV+xHllUWrD7RcXtTHrPAvocE7gHzn4cpMU8kWLC5ouEZvenL6rU3TEJebOQUjs6DQG5pZUIotfZl28+RHvoaVufJFq1hgdI6Txg9iWZWMfk0LAkLYDSNgHBlZlsNJe1GV+eGFNVwekjVkChhvJyTQ51VROUuFhS4ZaVqvtABr35oXn25aSjLSmLJNgj1aXVpDpQPUvJM7M+OmSzVVe6YkzFh+mtQxIO+18lFN1rdY2UDzCk18p7gauN5m4k6iF1reSCCz6lv0kd8RQnb46LCRIHrceFZIaoEjj1MePahqs+q8BMdOr2ihUrMDekG0hLZSbNW+B85L/unSiUG6njKzFbAMJDDcb4En5nioYBmzsawS/7bEkEukkylEXwMg== X-Forefront-PRVS: 09888BC01D X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(199003)(189002)(2950100001)(5003940100001)(110136002)(19580395003)(19580405001)(77096005)(76176999)(189998001)(69596002)(50986999)(47776003)(66066001)(42186005)(101416001)(53416004)(50466002)(97736004)(33646002)(106356001)(68736007)(7846002)(86362001)(7736002)(105586002)(229853001)(2351001)(1076002)(4326007)(2906002)(3846002)(6116002)(50226002)(305945005)(36756003)(586003)(92566002)(48376002)(81166006)(8676002)(81156014); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0801MB1738; H:dsafonov.sw.ru; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0801MB1738; 23:z4jZLueyKqDm6KlAbUQOxHJ/q3NmlSdT7djSUcW?= =?us-ascii?Q?cVddAUe9n0RSFGKYIsk16r/SaUJX0tKq0BUdaI+Tus8YIYuvdzxIC13a2oG0?= =?us-ascii?Q?598jM4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jvn2ccc5sbeYL1TrnSnbim7w== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB1738; 20:YL8p+2QiZa4lZYU6s2Fk563mEYt+UXYWbeD391J1P4FZXy3b53WYWqleBTV/9gvOulUiIkVvL+wOYKMY04nR9ojWHAfxSpWGaYjUWMS/uhJsVT1ztv7dmj+pJcJHMWje0MAJ+8i/N/u4Hd0eVq1vI92gSKtjdsMEE/SsJzzQSm8= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jun 2016 10:59:01.7133 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1738 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 Killed PR_REG_SIZE and PR_REG_PTR macro as we can get regset size from regset view. Suggested-by: Oleg Nesterov Cc: Oleg Nesterov Cc: Andy Lutomirski Cc: Ingo Molnar Cc: Cyrill Gorcunov Cc: Pavel Emelyanov Cc: x86@kernel.org 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 | 23 ++++++++--------------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h index 5a3b2c119ed0..4b039bd297ac 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); } \ +/* Full regset -- prstatus on x32, otherwise on ia32 */ +#define PRSTATUS_SIZE(S, R) (R != sizeof(S.pr_reg) ? 144 : 296) +#define SET_PR_FPVALID(S, V, R) \ + do { *(int *) (((void *) &((S)->pr_reg)) + R) = (V); } \ while (0) #define COMPAT_USE_64BIT_TIME \ diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index a7a28110dc80..8fd6cf9083d0 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -1622,20 +1622,12 @@ static void do_thread_regset_writeback(struct task_struct *task, regset->writeback(task, regset, 1); } -#ifndef PR_REG_SIZE -#define PR_REG_SIZE(S) sizeof(S) -#endif - #ifndef PRSTATUS_SIZE -#define PRSTATUS_SIZE(S) sizeof(S) -#endif - -#ifndef PR_REG_PTR -#define PR_REG_PTR(S) (&((S)->pr_reg)) +#define PRSTATUS_SIZE(S, R) sizeof(S) #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, @@ -1643,6 +1635,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t, long signr, size_t *total) { unsigned int i; + unsigned int regset_size = view->regsets[0].n * view->regsets[0].size; /* * NT_PRSTATUS is the one special case, because the regset data @@ -1651,12 +1644,11 @@ static int fill_thread_core_info(struct elf_thread_core_info *t, * We assume that regset 0 is NT_PRSTATUS. */ 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), - PR_REG_PTR(&t->prstatus), NULL); + (void) view->regsets[0].get(t->task, &view->regsets[0], 0, regset_size, + &t->prstatus.pr_reg, NULL); fill_note(&t->notes[0], "CORE", NT_PRSTATUS, - PRSTATUS_SIZE(t->prstatus), &t->prstatus); + PRSTATUS_SIZE(t->prstatus, regset_size), &t->prstatus); *total += notesize(&t->notes[0]); do_thread_regset_writeback(t->task, &view->regsets[0]); @@ -1686,7 +1678,8 @@ 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, regset_size); fill_note(&t->notes[i], "CORE", NT_PRFPREG, size, data); }