Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2271715imm; Mon, 28 May 2018 05:09:41 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqm5jp3KE5FAIvCgvZ/oq/QCUwkpftcTwb8yOh8hFse5hLqTe4Qrme09XAlmecIv4N4ZBGz X-Received: by 2002:a63:2485:: with SMTP id k127-v6mr10368164pgk.434.1527509381838; Mon, 28 May 2018 05:09:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527509381; cv=none; d=google.com; s=arc-20160816; b=PqthmF7gZi7Z7D2u8fVYlb/ADo024BdbTpwmtiXc31F5ikBjmYS64iLnxwYwbsP0jo VxxEfk7DJbDLScmcFVwu+QRQOqfqPZ1U8mwm0sy1bdlx48Xl6rbgo4p5cxIHx1+19Aw+ 0ureondr3cPFP0Su0ZIlDJUkMGKst95aae5xgjlZ9cwO8juQcUBrZxnJo0SHsN8016JT N1SMCfzwEGtI2VfIxlGB5p+arHLb6XyHRH7SIk2KGB2CQ/9qEkwX+ZEk1g5vBFGyC0Co QvYsUtAxpBGs5aboQrbyZ7MXT3rqv4XTuvAhx/7xUUdqnsy+efWCSLTbCgmFkLOTif7N Hj9g== 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=f+JK7NINZj4HQTuha5ueg9mEQDPAxEQUkXKBmSvlv3Q=; b=Hixep1RhlUNEs+GOerJaGV9vxXX2NAZO1uLguhY/mBsT4g+0PYxo4Hxvn+8gjUUE1X 1k3hRRAoBOIBNKOC6jgjXHSWIX5aJPwceanru3eo97FmZfEiS7CIP/1moDqtSPWK00Y5 zCITO4y8IqaL2sMbthfPmfuNgvdMsAsp6IUG7k/q9RsllSQ+wDzz8iSvaxlwPwOh/g32 ZH27viJ/wdiYOSm22gPggKThtDX/bfgdl1L1/yCyNppCFLR5UvWCs1uKT/T4NcDvysrs DtXemmkM28DhaO3VbGOmjQ25XB4BMg1tbP6d3ENRu5UUbKpji1RhpzYoeu0+SaMkgfPs KkFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sVhsL7Ax; 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 z73-v6si7805031pgd.122.2018.05.28.05.09.27; Mon, 28 May 2018 05:09:41 -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=sVhsL7Ax; 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 S1422821AbeE1LFA (ORCPT + 99 others); Mon, 28 May 2018 07:05:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:52032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164596AbeE1LEx (ORCPT ); Mon, 28 May 2018 07:04:53 -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 4F96A2089E; Mon, 28 May 2018 11:04:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527505492; bh=eWXj+dGDe8oRaLDuPrUZIQNcD3Zb59tmq2sXGhosWWo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sVhsL7AxnlkJ8Xu7kCt6065Fp7bbtB1o18QytlzYXeCkPaez8Pd1oRvznbMr/q9d8 Aa51cgKfsfAMsi5R70hhjwfpAjfwVql8BvNdwYNm9KXs5Wf0C5HFKFlNS91eXg/QeT b2s6bXRLAW3p1ve/X107PK2z0pbsUISHHESVfRIk= 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.16 023/272] drm/vmwgfx: Fix 32-bit VMW_PORT_HB_[IN|OUT] macros Date: Mon, 28 May 2018 12:00:56 +0200 Message-Id: <20180528100242.464675671@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100240.256525891@linuxfoundation.org> References: <20180528100240.256525891@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.16-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), \