From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E11DC282D8 for ; Thu, 31 Jan 2019 01:54:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1383120989 for ; Thu, 31 Jan 2019 01:54:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LFCR1gvC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729304AbfAaByB (ORCPT ); Wed, 30 Jan 2019 20:54:01 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:46695 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725535AbfAaByB (ORCPT ); Wed, 30 Jan 2019 20:54:01 -0500 Received: by mail-pl1-f194.google.com with SMTP id t13so700775ply.13 for ; Wed, 30 Jan 2019 17:54:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iSwJVF0akr2kVYJppTgvIyWL79BXicuVcEgnc3zIsas=; b=LFCR1gvCt7VgAvXOY092LW3oC1Ypi0k84WXZrf61a2DR2T3hkE8VdATF2prGZ17h5R hME/nZ3HGgnu/q/aWzYz+A63Jjs7ULxreEbHupjdWr3BEtCCgUIUhNNcjJ9Enp/ykL/f cVTYcRxzYwl2kmGRbAlcxtjKwzCu3OufCYT7J2mAGgl+PS9eQV+xjtbQe1RG42PBmGVN e68cZ9VGM/Jb3mOtl0GlR/STKRqnb7QR9GI+/sgfnn9j6cpduA7vwsbHZKy2QBWN9qwU cfarce1QOWzAqXF5LcZyWqEli8o7DgUf5g98PvOxvAh5DB0PzLzaGqD07qYJwf66C1Ad EkAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iSwJVF0akr2kVYJppTgvIyWL79BXicuVcEgnc3zIsas=; b=SIyDQFdzb8rOWPIWW57g4n80YwXxRXBp42c3R8Awuw8dLsHRq7/QMrXVJWfjcA/U51 nCb6XC19Pnz7+2pbds5qP9ZoZDy7r9ZO9g7uyTZdlNmGEk1GoK6bU2l6lafWi36AkYUr Zgvpxo2aH49KWtF5VOXN2tZbocCuRAweEh8wgfOjv4bFDKeS8fuvB8YDhgUAuUrL8FB4 9INZcelSVyBUT6rziPeZp0S8MtkYJFXaCP5lKVK4G67dqLPL3rP8RVLLx1IWYJiyG9VK Rfs7Fd05BRCWDpIAxp/VRftgyc/KA9MwQQqPYh3IgsQkn1yD/6pN7JN46WKPrwHJKyp7 9DkA== X-Gm-Message-State: AJcUukfFlhVhvE+qUv5R1o76Aoqk0zvHJkYRjJGdbKT4+BxCOg7TUTKA n/zWsnPeGcWYQQYexRZXbBCw6dbe X-Google-Smtp-Source: ALg8bN7sQo+G9SoV+f59SYzq9x8NFo7VObZz9hKM0VS1BpQjnnmsD3OANjUSX8o458be9Sv3cWntiw== X-Received: by 2002:a17:902:714c:: with SMTP id u12mr32466424plm.234.1548899640226; Wed, 30 Jan 2019 17:54:00 -0800 (PST) Received: from wafer.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id p64sm4322108pfi.56.2019.01.30.17.53.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 Jan 2019 17:53:59 -0800 (PST) From: Oliver O'Halloran To: linuxppc-dev@lists.ozlabs.org Cc: Oliver O'Halloran , stable@vger.kernel.org Subject: [PATCH] powerpc/papr_scm: Use the correct bind address Date: Thu, 31 Jan 2019 12:53:47 +1100 Message-Id: <20190131015347.21674-1-oohall@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org When binding an SCM volume to a physical address the hypervisor has the option to return early with a continue token with the expectation that the guest will resume the bind operation until it completes. A quirk of this interface is that the bind address will only be returned by the first bind h-call and the subsequent calls will return 0xFFFF_FFFF_FFFF_FFFF for the bind address. We currently do not save the address returned by the first h-call. As a result we will use the junk address as the base of the bound region if the hypervisor decides to split the bind across multiple h-calls. This bug was found when testing with very large SCM volumes where the bind process would take more time than they hypervisor's internal h-call time limit would allow. This patch fixes the issue by saving the bind address from the first call. Cc: stable@vger.kernel.org Fixes: b5beae5e224f ("powerpc/pseries: Add driver for PAPR SCM regions") Signed-off-by: Oliver O'Halloran --- arch/powerpc/platforms/pseries/papr_scm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/pseries/papr_scm.c b/arch/powerpc/platforms/pseries/papr_scm.c index 7d6457ab5d34..bba281b1fe1b 100644 --- a/arch/powerpc/platforms/pseries/papr_scm.c +++ b/arch/powerpc/platforms/pseries/papr_scm.c @@ -43,6 +43,7 @@ static int drc_pmem_bind(struct papr_scm_priv *p) { unsigned long ret[PLPAR_HCALL_BUFSIZE]; uint64_t rc, token; + uint64_t saved = 0; /* * When the hypervisor cannot map all the requested memory in a single @@ -56,6 +57,8 @@ static int drc_pmem_bind(struct papr_scm_priv *p) rc = plpar_hcall(H_SCM_BIND_MEM, ret, p->drc_index, 0, p->blocks, BIND_ANY_ADDR, token); token = ret[0]; + if (!saved) + saved = ret[1]; cond_resched(); } while (rc == H_BUSY); @@ -64,7 +67,7 @@ static int drc_pmem_bind(struct papr_scm_priv *p) return -ENXIO; } - p->bound_addr = ret[1]; + p->bound_addr = saved; dev_dbg(&p->pdev->dev, "bound drc %x to %pR\n", p->drc_index, &p->res); -- 2.20.1