Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2369864imm; Mon, 28 May 2018 06:54:08 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpmYrymJ/d2xhfWrLLXi7WsIrZD+fabPcAKY7WS/ArSsz0PMmobQ+pxD6qmHP63Kb602BPP X-Received: by 2002:a65:4306:: with SMTP id j6-v6mr10780441pgq.341.1527515648830; Mon, 28 May 2018 06:54:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527515648; cv=none; d=google.com; s=arc-20160816; b=SEqnzovN6tRg97qOXgITeUGiapCT1KuiDgAkZSnfdm3x4f1oI3QhPYxKvss+k3k8Pb 0sXFtHVcucpFqg2u9ALH4Nkm4lat/JuIlOlIGWukSy23CrwkI8iqlXffWXq3TrvuKTxa EnuBlwZXFci1Gr5p182tz40gqdfPcDQ5a5plj964QrvB4NiBwaQz3axE4eMwfzYlM9Yi 3vII8Y0R1c9drjitxjVvOgHhxzzfN8SWDxJ0p5yhpKuR7bALa27bmpGYuTGVHC0EE/rT MJ43LpAm3F8dX/83ivvm0soS14PA1j1/YJmGD0boAfMCb8LWq4VwLDdX8dStKkJEXHyE ShuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=yIl3jKBYqwpQbAxUKGHc2k3JXile7xWa49TwR4nZ1g0=; b=x3zAqukEm+wLz33s3ZWTRbEa6Og9fnKFwh9kHWH/E9ybwiJYqBfpjVQ+d7n4WtbJbo 3IxKGdvvwFEVNo7ynnNWfyLvtE7uPzPFC4ToeG0dMzfWH/LSemr1hTBl6lEdNP5FNp82 YlbqhOluNlEC7TpZb/IYkAi7fCuqqt8meKYhF5S6kqWtROlIIEyvJU/2f8XmJ8df0WRh EbaaihHSRjrqrtQvPXy3+diOZOqwB/SfLx40G6rcGpb+BovoChSBbWvQf2AadR0RlQLm FeXy9CkJaWFEDlZcjtOARUeYxUkh2Gg7tz2ert9ZJs8WhYF91/k9rUiLTQxJkJuleITk Vc5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zcApblul; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s187-v6si6831906pgc.447.2018.05.28.06.53.54; Mon, 28 May 2018 06:54:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zcApblul; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1163036AbeE1Klu (ORCPT + 99 others); Mon, 28 May 2018 06:41:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:33248 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163025AbeE1Klq (ORCPT ); Mon, 28 May 2018 06:41:46 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 428C920883; Mon, 28 May 2018 10:41:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527504105; bh=0ozoiEgkEhcv9jXsPYpEk4V9SvwHCloOX2sT50pRJ04=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zcApbluliED2dXox4KJhYyr4Ft7QiV1d22kLF/z/ZgfDJmgGUAs4MQtrOfi6QHjiI WhNaKsVF+Gm6ziWkAmNnU9qUPpgrpibrRXCwU3fNXBaVjj05s8NSsU+J5ZpfphhkiI d9jkv5z64FClFHPCIGceGpo4cTmPqqLajAJVFXxY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Hellstrom , Brian Paul , Sinclair Yeh Subject: [PATCH 4.14 016/496] drm/vmwgfx: Fix 32-bit VMW_PORT_HB_[IN|OUT] macros Date: Mon, 28 May 2018 11:56:41 +0200 Message-Id: <20180528100320.264572869@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100319.498712256@linuxfoundation.org> References: <20180528100319.498712256@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Hellstrom commit 938ae7259c908ad031da35d551da297640bb640c upstream. Depending on whether the kernel is compiled with frame-pointer or not, the temporary memory location used for the bp parameter in these macros is referenced relative to the stack pointer or the frame pointer. Hence we can never reference that parameter when we've modified either the stack pointer or the frame pointer, because then the compiler would generate an incorrect stack reference. Fix this by pushing the temporary memory parameter on a known location on the stack before modifying the stack- and frame pointers. Cc: Signed-off-by: Thomas Hellstrom Reviewed-by: Brian Paul Reviewed-by: Sinclair Yeh Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/vmwgfx/vmwgfx_msg.h | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) --- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.h @@ -135,17 +135,24 @@ #else -/* In the 32-bit version of this macro, we use "m" because there is no - * more register left for bp +/* + * In the 32-bit version of this macro, we store bp in a memory location + * because we've ran out of registers. + * Now we can't reference that memory location while we've modified + * %esp or %ebp, so we first push it on the stack, just before we push + * %ebp, and then when we need it we read it from the stack where we + * just pushed it. */ #define VMW_PORT_HB_OUT(cmd, in_ecx, in_si, in_di, \ port_num, magic, bp, \ eax, ebx, ecx, edx, si, di) \ ({ \ - asm volatile ("push %%ebp;" \ - "mov %12, %%ebp;" \ + asm volatile ("push %12;" \ + "push %%ebp;" \ + "mov 0x04(%%esp), %%ebp;" \ "rep outsb;" \ - "pop %%ebp;" : \ + "pop %%ebp;" \ + "add $0x04, %%esp;" : \ "=a"(eax), \ "=b"(ebx), \ "=c"(ecx), \ @@ -167,10 +174,12 @@ port_num, magic, bp, \ eax, ebx, ecx, edx, si, di) \ ({ \ - asm volatile ("push %%ebp;" \ - "mov %12, %%ebp;" \ + asm volatile ("push %12;" \ + "push %%ebp;" \ + "mov 0x04(%%esp), %%ebp;" \ "rep insb;" \ - "pop %%ebp" : \ + "pop %%ebp;" \ + "add $0x04, %%esp;" : \ "=a"(eax), \ "=b"(ebx), \ "=c"(ecx), \