From patchwork Fri Nov 18 19:51:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jason Ekstrand X-Patchwork-Id: 9437273 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 E2ED060469 for ; Fri, 18 Nov 2016 19:51:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBA9F2988C for ; Fri, 18 Nov 2016 19:51:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD4562993E; Fri, 18 Nov 2016 19:51:31 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 373942988C for ; Fri, 18 Nov 2016 19:51:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 83B4489E36; Fri, 18 Nov 2016 19:51:30 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pf0-x243.google.com (mail-pf0-x243.google.com [IPv6:2607:f8b0:400e:c00::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 322EA89E36 for ; Fri, 18 Nov 2016 19:51:30 +0000 (UTC) Received: by mail-pf0-x243.google.com with SMTP id c4so11504509pfb.3 for ; Fri, 18 Nov 2016 11:51:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jlekstrand-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=z6b/W8fcDVhaGf4BgLTq7dBXiMyOtx4SS7UzPcnr8G0=; b=1TQj4pV/68e97cCgEOtby4KhSFcA0fYx5vao9KGy8Yy4ea2+nEztamo911RbbeMKLn XOmg71tuYewUdV5DzWqxCWzwRBX/IraMPb7JnoM2P/bjjLFL+bzsaivB3/zllMUvpjps zOQEx833MxR2hghLV09PKyYJgqaiiJus+TxM/gEFv4e3UTt1ZPneawxWwwyacakz6Q5M da9cnJz3ZOnrSBxGcJmQEO6oa5idn+uG1RnBT3groCQKmoqnIc1kfvCz1gz06RftYnc5 vlj0eXziq9fUXPp37p7uI68X2utDJpXsh9GkqtVLTnc66zIcvvskJe+5ECzhQFTzuIZO ytGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=z6b/W8fcDVhaGf4BgLTq7dBXiMyOtx4SS7UzPcnr8G0=; b=lTC0BTBDGcxwwdD5vtlRELfXVIqxkyhSJoMHnBBLEPZ4GAcC6x8h1ZrAw5cWYfTEem W8gx47iyBc1yxYRb4me3VLS6W25aU7Af4VXdzMplKc9tSxGJGVigOVA3xjaQ+t9/v20/ oNam25W6BeNS4BELUw0tVYhEBqd/k2BmDO9M/BTAItTBjNgsCshLEM9FOW2OH0Xih2ql 8xXVETEflTgkjKMCzNQhLzxBDM3Mf4iWrHArA/YE7GslYUcDEYoccRqvd8v4VI5DiPFA yfUR0wG2/9xOU1Aga3X+nelrShkGm+9is7VE4tgTC4t5c9UiPHh1XJ/1IR5xvOXfCIpD cyBw== X-Gm-Message-State: AKaTC02H1IrYRPmJuUPPmwg0sUwRw+RohV/o2ILJTJ+QVCrlqknPsJVd2LQy8tz6tzYjOA== X-Received: by 10.98.58.132 with SMTP id v4mr1857335pfj.7.1479498689247; Fri, 18 Nov 2016 11:51:29 -0800 (PST) Received: from omlet.jf.intel.com ([134.134.139.76]) by smtp.gmail.com with ESMTPSA id 186sm19813859pfv.61.2016.11.18.11.51.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Nov 2016 11:51:28 -0800 (PST) From: Jason Ekstrand X-Google-Original-From: Jason Ekstrand To: intel-gfx@lists.freedesktop.org Date: Fri, 18 Nov 2016 11:51:26 -0800 Message-Id: <1479498686-8710-1-git-send-email-jason.ekstrand@intel.com> X-Mailer: git-send-email 2.5.0.400.gff86faf MIME-Version: 1.0 Cc: Jason Ekstrand Subject: [Intel-gfx] [PATCH] aubdump: Handle 48-bit relocations properly X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP aubdump was only writing 32-bits regardless of platform. This is fine if the client being dumped leaves the top 32 bits zero since the aubdump GTT is fairly small. However, if the client does store something in the upper 32 bits, this results in an invalid relocation. Cc: Kristian Høgsberg Reviewed-by: Lionel Landwerlin --- tools/aubdump.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/tools/aubdump.c b/tools/aubdump.c index 4e0d0a8..0cf993d 100644 --- a/tools/aubdump.c +++ b/tools/aubdump.c @@ -284,6 +284,32 @@ aub_dump_ringbuffer(uint64_t batch_offset, uint64_t offset, int ring_flag) data_out(ringbuffer, ring_count * 4); } +static void +write_reloc(void *p, uint64_t v) +{ + if (gen >= 8) { + /* From the Broadwell PRM Vol. 2a, + * MI_LOAD_REGISTER_MEM::MemoryAddress: + * + * "This field specifies the address of the memory + * location where the register value specified in the + * DWord above will read from. The address specifies + * the DWord location of the data. Range = + * GraphicsVirtualAddress[63:2] for a DWord register + * GraphicsAddress [63:48] are ignored by the HW and + * assumed to be in correct canonical form [63:48] == + * [47]." + * + * In practice, this will always mean the top bits are zero + * because of the GTT size limitation of the aubdump tool. + */ + const int shift = 63 - 47; + *(uint64_t *)p = (((int64_t)v) << shift) >> shift; + } else { + *(uint32_t *)p = v; + } +} + static void * relocate_bo(struct bo *bo, const struct drm_i915_gem_execbuffer2 *execbuffer2, const struct drm_i915_gem_exec_object2 *obj) @@ -293,7 +319,6 @@ relocate_bo(struct bo *bo, const struct drm_i915_gem_execbuffer2 *execbuffer2, const struct drm_i915_gem_relocation_entry *relocs = (const struct drm_i915_gem_relocation_entry *) (uintptr_t) obj->relocs_ptr; void *relocated; - uint32_t *dw; int handle; relocated = malloc(bo->size); @@ -307,8 +332,8 @@ relocate_bo(struct bo *bo, const struct drm_i915_gem_execbuffer2 *execbuffer2, else handle = relocs[i].target_handle; - dw = (uint32_t*)(((char *) relocated) + relocs[i].offset); - *dw = get_bo(handle)->offset + relocs[i].delta; + write_reloc(((char *)relocated) + relocs[i].offset, + get_bo(handle)->offset + relocs[i].delta); } return relocated;