Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp630945pxb; Tue, 2 Feb 2021 13:46:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJy4eaMupQFU7G9CC9kgR9iYC60tyzi1mLU1K3C8PcruOqY6s4o7r+G0QAJLrB2nLqMN1GOc X-Received: by 2002:a50:d987:: with SMTP id w7mr120254edj.356.1612302370616; Tue, 02 Feb 2021 13:46:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612302370; cv=none; d=google.com; s=arc-20160816; b=gu59JB6fZGKx8fcARukgbj7egK97zs+XJQy6kzRdWiOLcpDUv9nBgiU8BfkZoFUaQa zY9agaOwRdCZkUjhxT1V3HzfoRgG7XKImuQgo61wYoznM6MQ4fFZrRAcM7sNa1UmBjLH ckjSWL9Off6CZReUbCN6qC+1pCBQHvZBi6+xQuccm1VP3C44a3EIBk2AohlHeTYfJAHo 0XeZZq4zbTHfW56n7diF6n2qJFdr86qppc6lxejFLtscz7FkmlBzeDyeP0Yr0dJc9xZH gT9wxrJkraiQMmNwlagAblHrzUKLVinge+sFsscVa/Ii4tinBsEjJRVun9AObbi0TZWS sJtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=27LQ1Z//PJLfeNOlJN5xT3UuRFWT+Pvn8W3WyEo7HzU=; b=baZVZIq0FCwlvthtk/OV3ldJ6gmb0QgmtC5AHnHqUXzROk0tfPk4Yq6k3vZQrrTq7w VlwCD4jXIEIDcH3ghyTGRNutNnR9Tfgi3KiIL5dRRPpmEfWpKsSVpH2uMsXKh1PAI7iq NZFH8uFzrhTBPcFJX9O8fxsCI80/Rwg/yQCw5ySyi2PfWYxf71nJx4T6zHTYB/i/4ehO f8m0fS94WIAmM3dZeXTEkxhe/MCamYzDqcqSLKFao+tx8C7sHzcEachyaK8qv0CImcHF 74mgowI9COamFgCphhra0hm+4Md+VLPcwRLWDCeAkBtyoLgm/QngucUh4RqyG+iaoZHl 2DLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qqtSnkwl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hd10si65648ejc.208.2021.02.02.13.45.46; Tue, 02 Feb 2021 13:46:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qqtSnkwl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232310AbhBBNxD (ORCPT + 99 others); Tue, 2 Feb 2021 08:53:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:36434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232933AbhBBNrH (ORCPT ); Tue, 2 Feb 2021 08:47:07 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3281F64F8F; Tue, 2 Feb 2021 13:41:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612273298; bh=rIGhx9RV0NM5CnYpvOuwXFg43rqk9ofNndTN5YDJgTQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qqtSnkwlB9TH/JdSNfKmqFqX7TCFIVlCZXzG2C8eC7Eued5FtjjyElFR/Et4FrLly kEHhxO6Y4aI4gq8xyUgM/5kWXnnIU4UWR4N73/ZI5Ul3akDHGAdwphC3QSV6l8jmzy 4CH6XBne1ffGGd6P4vdL581I+BfhMMBW/vlLvBYo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Wilson , Mika Kuoppala , Akeem G Abodunrin , Jani Nikula Subject: [PATCH 5.10 055/142] drm/i915/gt: Clear CACHE_MODE prior to clearing residuals Date: Tue, 2 Feb 2021 14:36:58 +0100 Message-Id: <20210202132959.988068617@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210202132957.692094111@linuxfoundation.org> References: <20210202132957.692094111@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chris Wilson commit ef99a60ffd9b918354e038bc5e61f007ff7e901d upstream. Since we do a bare context switch with no restore, the clear residual kernel runs on dirty state, and we must be careful to avoid executing with bad state from context registers inherited from a malicious client. Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/2955 Fixes: 09aa9e45863e ("drm/i915/gt: Restore clear-residual mitigations for Ivybridge, Baytrail") Testcase: igt/gem_ctx_isolation # ivb,vlv Signed-off-by: Chris Wilson Cc: Mika Kuoppala Cc: Akeem G Abodunrin Reviewed-by: Akeem G Abodunrin Link: https://patchwork.freedesktop.org/patch/msgid/20210117093015.29143-1-chris@chris-wilson.co.uk (cherry picked from commit ace44e13e577c2ae59980e9a6ff5ca253b1cf831) Signed-off-by: Jani Nikula Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/i915/gt/gen7_renderclear.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/drivers/gpu/drm/i915/gt/gen7_renderclear.c +++ b/drivers/gpu/drm/i915/gt/gen7_renderclear.c @@ -390,6 +390,16 @@ static void emit_batch(struct i915_vma * &cb_kernel_ivb, desc_count); + /* Reset inherited context registers */ + gen7_emit_pipeline_invalidate(&cmds); + batch_add(&cmds, MI_LOAD_REGISTER_IMM(2)); + batch_add(&cmds, i915_mmio_reg_offset(CACHE_MODE_0_GEN7)); + batch_add(&cmds, 0xffff0000); + batch_add(&cmds, i915_mmio_reg_offset(CACHE_MODE_1)); + batch_add(&cmds, 0xffff0000 | PIXEL_SUBSPAN_COLLECT_OPT_DISABLE); + gen7_emit_pipeline_flush(&cmds); + + /* Switch to the media pipeline and our base address */ gen7_emit_pipeline_invalidate(&cmds); batch_add(&cmds, PIPELINE_SELECT | PIPELINE_SELECT_MEDIA); batch_add(&cmds, MI_NOOP); @@ -399,9 +409,11 @@ static void emit_batch(struct i915_vma * gen7_emit_state_base_address(&cmds, descriptors); gen7_emit_pipeline_invalidate(&cmds); + /* Set the clear-residual kernel state */ gen7_emit_vfe_state(&cmds, bv, urb_size - 1, 0, 0); gen7_emit_interface_descriptor_load(&cmds, descriptors, desc_count); + /* Execute the kernel on all HW threads */ for (i = 0; i < num_primitives(bv); i++) gen7_emit_media_object(&cmds, i);