Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933770AbcCHABI (ORCPT ); Mon, 7 Mar 2016 19:01:08 -0500 Received: from mail-bl2on0089.outbound.protection.outlook.com ([65.55.169.89]:8352 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933790AbcCHAAg convert rfc822-to-8bit (ORCPT ); Mon, 7 Mar 2016 19:00:36 -0500 X-Greylist: delayed 26008 seconds by postgrey-1.27 at vger.kernel.org; Mon, 07 Mar 2016 19:00:36 EST From: "Deucher, Alexander" To: "'Josh Poimboeuf'" , "Koenig, Christian" CC: "dri-devel@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" , "kbuild test robot" , Ingo Molnar Subject: RE: [PATCH] drm/radeon: refactor CIK tiling table initialization Thread-Topic: [PATCH] drm/radeon: refactor CIK tiling table initialization Thread-Index: AQHReMa7iOzAU+yB30+fugzN1fkQTJ9OpHzQ Date: Mon, 7 Mar 2016 23:45:36 +0000 Message-ID: References: <201603060006.yNZ9xTcs%fengguang.wu@intel.com> <446c4b8e7ed25c86f9d3204ff05339f4553fb79f.1457391777.git.jpoimboe@redhat.com> In-Reply-To: <446c4b8e7ed25c86f9d3204ff05339f4553fb79f.1457391777.git.jpoimboe@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=amd.com; x-originating-ip: [165.204.77.1] x-ms-office365-filtering-correlation-id: 29ea3b88-d042-446f-9647-08d346e294ec x-microsoft-exchange-diagnostics: 1;CY1PR12MB0134;5:VCX+g7L0Sz7gXNNhW+a2H0XqmAPtynNcVcdPB9rCkJW5K4XcCg9ba9cggjr76/slWO8/T4Tq8MBWT74RGU1LCKr8cqdU5TaYu/UPhz4dZ8M1t82jkny21tQJ+QwzDo5f+y7zlIcBJRw+1Iy7iDyphw==;24:JJOa6KtwtYHI0YVSqgmQqj2+ni026KUVB8vHIrzPMPGqu4JNh/lLassYm4coeahKGJ3NRFJy95mme+ACcGt1Kkh0W0eI+wrNfN6GSvVzMkg=;20:LT4nsNZTYjiTri1z8XYG3KQJnr2vxA2hHj1eSWWdPQE0VhZhAf9F7THKgVSkspFSY9LmC1TR3HBbh3uVRelxRx7rg/+5YE4bIhck4X5UhIHS/vQRfTtEfhQO8MDQuYV7ZBWwVBpmZOIz1+7ATdja31FXyCG0rvQkdNQ8pLh5X+xPNQZSzGSW5zEXdzDCG+eRlW2aTZVdmJYBHWIVIqfWnZRMbHm8OFmAwGuQQlLYjTyGSUVxQ7B0usImd7NnQjP+ x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR12MB0134; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001);SRVR:CY1PR12MB0134;BCL:0;PCL:0;RULEID:;SRVR:CY1PR12MB0134; x-forefront-prvs: 087474FBFA x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(13464003)(377454003)(19580395003)(2900100001)(2950100001)(19580405001)(5002640100001)(86362001)(106116001)(5001770100001)(99286002)(40100003)(77096005)(87936001)(5003600100002)(50986999)(3660700001)(76576001)(586003)(6116002)(1220700001)(102836003)(3846002)(1096002)(81166005)(5008740100001)(92566002)(3280700002)(4326007)(5004730100002)(66066001)(2906002)(76176999)(74316001)(122556002)(189998001)(10400500002)(54356999);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1PR12MB0134;H:BLUPR12MB0691.namprd12.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Mar 2016 23:45:36.2269 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0134 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3394 Lines: 72 > -----Original Message----- > From: Josh Poimboeuf [mailto:jpoimboe@redhat.com] > Sent: Monday, March 07, 2016 6:10 PM > To: Deucher, Alexander; Koenig, Christian > Cc: dri-devel@lists.freedesktop.org; linux-kernel@vger.kernel.org; kbuild > test robot; Ingo Molnar > Subject: [PATCH] drm/radeon: refactor CIK tiling table initialization > > When compiling the radeon driver on x86_64 with > CONFIG_STACK_VALIDATION > enabled, objtool gives the following warnings: > > drivers/gpu/drm/radeon/cik.o: warning: objtool: > cik_tiling_mode_table_init()+0x6ce: call without frame pointer save/setup > drivers/gpu/drm/radeon/cik.o: warning: objtool: > cik_tiling_mode_table_init()+0x72b: call without frame pointer save/setup > drivers/gpu/drm/radeon/cik.o: warning: objtool: > cik_tiling_mode_table_init()+0x464: call without frame pointer save/setup > ... > > These are actually false positive warnings; there are no frame pointer > bugs. Instead objtool gets confused by the jump tables created by all > the switch statements, combined with some other gcc optimizations. It > tries to follows all possible code paths, but it fails to realize that > some of the paths aren't possible. For example: > > 4c97: 31 c0 xor %eax,%eax > ... > 4ca2: 89 c1 mov %eax,%ecx > 4ca4: ff 24 cd 00 00 00 00 jmpq *0x0(,%rcx,8) 4ca7: R_X86_64_32S > .rodata+0x148 > > First eax is cleared to zero with the "xor %eax,%eax" instruction. > Later, it moves the value of eax (zero in this case) to ecx, and uses > that value to jump to the first entry in a jump table in .rodata. > > Because objtool doesn't have an x86 emulator, it doesn't know that rcx > is zero. So instead of following a single code path to the first jump > table entry, it follows all possible jump table entry paths in parallel. > > Usually such overactive analysis isn't a problem. In every other jump > table in the kernel, all the jump targets have the same frame pointer > state. But in this exceedingly rare case, different targets have > different frame pointer states. Objtool notices that and creates the > false positive warnings. > > In theory we could use the STACK_FRAME_NON_STANDARD marker to tell > objtool to skip analysis of the function. However, that's less than > ideal. > > Looking at the cik_tiling_mode_table_init() code, it seems overly > complex with lots of repetition. So let's simplify it. All the switch > statements and conditionals can be replaced with much simpler logic by > generalizing the different behaviors and moving the initialization data > into data structures. > > The change is a win-win: it's easier to parse for both humans and > machines. It also reduces the binary size by about 2%: > > text data bss dec hex filename > 101011 30360 0 131371 2012b cik-before.o > 98699 30200 0 128899 1f783 cik-after.o > > [ Note: Unfortunately I don't know how to test this code, so it's > completely untested. Any help or guidance with ensuring that the > correct initialization is still being written would be greatly > appreciated! ] I think it would be clearer to rework it similarly to how it was reworked in amdgpu (see gfx_v8_0.c and gfx_v7_0.c in drm-next). Also ideally you'd update the similar code in si.c as well for consistency. Alex