From patchwork Mon Jul 22 17:46:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1135202 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45sq0839Mpz9sBZ for ; Tue, 23 Jul 2019 03:50:48 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="tOIEAvlw"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45sq0829pdzDqKh for ; Tue, 23 Jul 2019 03:50:48 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::444; helo=mail-pf1-x444.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="tOIEAvlw"; dkim-atps=neutral Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45spw66YrpzDqSW for ; Tue, 23 Jul 2019 03:47:18 +1000 (AEST) Received: by mail-pf1-x444.google.com with SMTP id p184so17715214pfp.7 for ; Mon, 22 Jul 2019 10:47:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DIBaep/KMs89J/MccVHkX0W00/BmLKBpEzrMNK9xGOo=; b=tOIEAvlwLCMV1xbie2TbvD9K8o/L5NJZ/vZ0+ReLDuoGN6WUWjtE+sQ4MXpgnfy564 HdH/JyskY8ezfiZbtKOZG05kNd/JwGNGoRadvLaFEh19PYDXiOgGFk4Wj1YTuA2eiX/N 8a1W/4lithMBEe9dpY6/pjbJrF88nTBFcDP8qqtV/IjtUfA3qgjm67xB4rPE0Zuh+jQz QpM8HzzJkN4DcqUAZFY7aMTjQtfzoA3/QNsrP87qi7NJnUSXN97PmAHUZiwR4jG92M6O Ph9n/2F9MKWUVUlu+1EH/qHTgrcV7ZBIYUPZ8nhGFMuIJKRhbNgffvD0X8ZN9sN+dNUh DTeg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=DIBaep/KMs89J/MccVHkX0W00/BmLKBpEzrMNK9xGOo=; b=swHucD0ptymegnc7wsenUtKuzZgFJH3vvd8RymbX2CsJufO3s21wdS9ib/9ETJ2C9E +ubwlxPmRMdIm2y7C2thu74zzQQYAhtB0LeNN2ASsYXd0ZvbSBJYqE7UFJ8Ed0OjZkP3 XNmxD2QkzC0Ei2zZQtSvqGq5TJFZ8Q6EyGyX6JP0b3ef/Af7s1FfmmldfImI3Bp4TRQ/ AydNWOBZSVzpsfpMTAdYvK9WGC2butukIiqWg1K8seR8iA7rROKhcczI3ai05qxVt/pZ IFJwdSJu72ogLrdP4ZrzRsjH3wJBCROewnI9AwXpmc6gVr1dTP95GpwGwySew8RtIVQg khfQ== X-Gm-Message-State: APjAAAVLyAQQZeiMKP+1l2TFdS1uRYESao+Tqprzvz6QbBCnV9qyYVVI bwtrh8047qFQ8Oy9pmc5BovNlTY3 X-Google-Smtp-Source: APXvYqybvKn8k8MzbDYzw5lm+VnugEgaWNaxMY3Psk610ZEkGkvcNZu0QX9ZILVvadpiCiGJvE9egg== X-Received: by 2002:a63:7a01:: with SMTP id v1mr74312722pgc.310.1563817636471; Mon, 22 Jul 2019 10:47:16 -0700 (PDT) Received: from bobo.local0.net (193-116-123-212.tpgi.com.au. [193.116.123.212]) by smtp.gmail.com with ESMTPSA id z24sm69170057pfr.51.2019.07.22.10.47.13 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 22 Jul 2019 10:47:15 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH 1/4] powerpc/64s/radix: Fix memory hotplug section page table creation Date: Tue, 23 Jul 2019 03:46:57 +1000 Message-Id: <20190722174700.11483-2-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190722174700.11483-1-npiggin@gmail.com> References: <20190722174700.11483-1-npiggin@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anju T Sudhakar , Madhavan Srinivasan , Reza Arbab , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" create_physical_mapping expects physical addresses, but creating and splitting these mappings after boot is supplying virtual (effective) addresses. This can be hit by booting with limited memory then probing new physical memory sections. Cc: Reza Arbab Fixes: 6cc27341b21a8 ("powerpc/mm: add radix__create_section_mapping()") Signed-off-by: Nicholas Piggin --- arch/powerpc/mm/book3s64/radix_pgtable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c index b4ca9e95e678..c5cc16ab1954 100644 --- a/arch/powerpc/mm/book3s64/radix_pgtable.c +++ b/arch/powerpc/mm/book3s64/radix_pgtable.c @@ -902,7 +902,7 @@ int __meminit radix__create_section_mapping(unsigned long start, unsigned long e return -1; } - return create_physical_mapping(start, end, nid); + return create_physical_mapping(__pa(start), __pa(end), nid); } int __meminit radix__remove_section_mapping(unsigned long start, unsigned long end) From patchwork Mon Jul 22 17:46:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1135203 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45sq270tcxz9sBZ for ; Tue, 23 Jul 2019 03:52:31 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="a9ECEaiM"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45sq266KdfzDqP9 for ; Tue, 23 Jul 2019 03:52:30 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::543; helo=mail-pg1-x543.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="a9ECEaiM"; dkim-atps=neutral Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45spwB5NmpzDqTb for ; Tue, 23 Jul 2019 03:47:22 +1000 (AEST) Received: by mail-pg1-x543.google.com with SMTP id i18so18009739pgl.11 for ; Mon, 22 Jul 2019 10:47:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RdTkCJ5KzrkeQeowvhtZBnAx7bbV0bkpZBOFs+hjaQM=; b=a9ECEaiMetQKkYmevNL1AsxaqG6CNsnOvloAC74ynvKlsdvFXjK0FoZVc8eBg74/TU MyeFtm7EQMsO8oMsDAUdVtvwaRPiilYE//dX2tEukuWtPGHtItrflnkUptAQ8NR9A0iG uuQzS/yUF6TOxmpAD+uZv60HoCTAMq8NZaME+8HF6o6MaK3S/xk9WEt2yA+Cap7nJVs7 ZWiABZlZ2woQX9MNFy7OGLMV/q+aNj9wdLadTtN/xo/6MyxoY0b3bXRYydvxbFro+TTS IwZkobKCo+hv0eoJsXFwRO7TGzlW9Aa16Z3B+KLqSuBpu//Qfp6PWha70/mUw9LKgUx0 CHZw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=RdTkCJ5KzrkeQeowvhtZBnAx7bbV0bkpZBOFs+hjaQM=; b=dpS89547vNXDt9oeUFOSxFWnc2eSzYG5oSf+55M4dVQHPM71BcnaYiqS2iiGawDejg YGCNd1b/40g9SdoF6t6iK1AfZr/Ft3yZa6hO/RPhukjKibiKzAnfPASD561c1qRKWpGc TwdWmEaJXE532u6zZ+ckKHP5EY1pYE8YiSGwTEL7Kp0kW3vBfkxyNr9iQlivC6cBp7ce aI1IoczBhlTFKDNY2K2OM/ord9ecrP0kKHao4WJnx3lxGeKUXq51iR1NNn3tK+Vib40g N+r8BoL0NhySMCRSSSDm6/wkSSQt2iQmu6rTPK/DIFHqnaEZpfTcWz1UID/mtfhZ1xIa /MFA== X-Gm-Message-State: APjAAAVEbaaiJ5FnxokikuBUaMoWjpFuhezsjRY0/wEUNVOYiQcJQA8V HGwg7LkYwbMPFEqhucXEkmMeSP98 X-Google-Smtp-Source: APXvYqy9b/PEqLAfzYCXpFQIQU7L4CmRChEPKJavhyyG9LQdni2B706r8xiv024Vx+e9WovDhUJECQ== X-Received: by 2002:a65:500a:: with SMTP id f10mr41765738pgo.105.1563817640158; Mon, 22 Jul 2019 10:47:20 -0700 (PDT) Received: from bobo.local0.net (193-116-123-212.tpgi.com.au. [193.116.123.212]) by smtp.gmail.com with ESMTPSA id z24sm69170057pfr.51.2019.07.22.10.47.17 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 22 Jul 2019 10:47:19 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH 2/4] powerpc/64s/radix: Fix memory hot-unplug page table split Date: Tue, 23 Jul 2019 03:46:58 +1000 Message-Id: <20190722174700.11483-3-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190722174700.11483-1-npiggin@gmail.com> References: <20190722174700.11483-1-npiggin@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anju T Sudhakar , Madhavan Srinivasan , Reza Arbab , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" create_physical_mapping expects physical addresses, but splitting these mapping on hot unplug is supplying virtual (effective) addresses. [I'm not sure how to test this one] Cc: Balbir Singh Fixes: 4dd5f8a99e791 ("powerpc/mm/radix: Split linear mapping on hot-unplug") Signed-off-by: Nicholas Piggin --- arch/powerpc/mm/book3s64/radix_pgtable.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c index c5cc16ab1954..2204d8eeb784 100644 --- a/arch/powerpc/mm/book3s64/radix_pgtable.c +++ b/arch/powerpc/mm/book3s64/radix_pgtable.c @@ -737,8 +737,8 @@ static int __meminit stop_machine_change_mapping(void *data) spin_unlock(&init_mm.page_table_lock); pte_clear(&init_mm, params->aligned_start, params->pte); - create_physical_mapping(params->aligned_start, params->start, -1); - create_physical_mapping(params->end, params->aligned_end, -1); + create_physical_mapping(__pa(params->aligned_start), __pa(params->start), -1); + create_physical_mapping(__pa(params->end), __pa(params->aligned_end), -1); spin_lock(&init_mm.page_table_lock); return 0; } From patchwork Mon Jul 22 17:46:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1135205 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45sq4h423Xz9sDQ for ; Tue, 23 Jul 2019 03:54:44 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="LLRhBkii"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45sq4h39lMzDqW8 for ; Tue, 23 Jul 2019 03:54:44 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::541; helo=mail-pg1-x541.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="LLRhBkii"; dkim-atps=neutral Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45spwG3sXQzDqTF for ; Tue, 23 Jul 2019 03:47:26 +1000 (AEST) Received: by mail-pg1-x541.google.com with SMTP id i70so7268687pgd.4 for ; Mon, 22 Jul 2019 10:47:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Q5UwUccDT7idepOx9wTEsK1MsiNpu1jsT4caspeaAVc=; b=LLRhBkiisgB80uVaw2RwSttwpr0MqqYYPp8nK+UoJ5A/dERrOeGx4fwTysuzbkxaPf +QLwNK0TYm6TrnwsbczGjyqNZ2FuWKZ/prEWG/y68a+B7p4bmOkDQOE5hNdW/NdYRnPU DVaPRKSS5Bd4wWwY6I6jf8Zp3+iTj8xPeCxKhwEHzWwe6UqyRp40k+PeawRY4/pTc6eX ek1wCF1F/jnxy2+Vw2lUZpawyfTSSh4h22hdhZCuBy5J52X2AzuYjkcdMwiLT0rB7ZTd YLFE3yC92piJyeJEW4fIRKdaV6IJThJ5XszfxDwsl2abBtlBAAVSWMLmRZdbWmTJfG1q u6Sw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Q5UwUccDT7idepOx9wTEsK1MsiNpu1jsT4caspeaAVc=; b=AuuXbyteb6jVtpoEEzB3Q5CFZKLin0cw9dvVlyqAqPQ6T0EfittzU7SrtaaXEnTDIp qwDQiPFxqb8YibUqQnzcJZkYv4DbPrd4YIVxe9QOqQkRmW99Sr4VtvZzPVwkq4KLbQVe iwS/yWxNB/lriBOICzE8Thfj1gRJpYJRAfOfxQAw7MrKU1RmmxV5erZxvmjJd7rpegnf DlQToUOfXKpvY75g4eO3arlVS6Ry8crU6wSbzw/rb91zpNpU1BSmSk4W7i605vUTQ3zd BsjJKtU1vmyWAThHfx7Z9u09nOZ/s2BAYTYdWqLZvyNPkjWxpP3dggC1ucjFizCziUT2 wahw== X-Gm-Message-State: APjAAAXSH9wUJqp+sKr54K9gaT5C+7vRY2BIceQ9cuEZC7EhRo/hmGxW LiZ1jxHX0Qi99csv6Afo5zFVDGaL X-Google-Smtp-Source: APXvYqxGTGvZXyBLQkm7SKZ+aDY4hjFXYr0o5j8SDlVE78luq/8bjuwQhRhz/xFpWB/XQLxA4ESKvw== X-Received: by 2002:a17:90a:35e6:: with SMTP id r93mr78684036pjb.20.1563817643831; Mon, 22 Jul 2019 10:47:23 -0700 (PDT) Received: from bobo.local0.net (193-116-123-212.tpgi.com.au. [193.116.123.212]) by smtp.gmail.com with ESMTPSA id z24sm69170057pfr.51.2019.07.22.10.47.20 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 22 Jul 2019 10:47:23 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH 3/4] powerpc/perf: fix imc allocation failure Date: Tue, 23 Jul 2019 03:46:59 +1000 Message-Id: <20190722174700.11483-4-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190722174700.11483-1-npiggin@gmail.com> References: <20190722174700.11483-1-npiggin@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anju T Sudhakar , Madhavan Srinivasan , Reza Arbab , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" alloc_pages_node return value should be tested before applying page_address. Cc: Anju T Sudhakar Cc: Madhavan Srinivasan Signed-off-by: Nicholas Piggin Tested-by: Anju T Sudhakar --- arch/powerpc/perf/imc-pmu.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/perf/imc-pmu.c b/arch/powerpc/perf/imc-pmu.c index dea243185ea4..cb50a9e1fd2d 100644 --- a/arch/powerpc/perf/imc-pmu.c +++ b/arch/powerpc/perf/imc-pmu.c @@ -577,6 +577,7 @@ static int core_imc_mem_init(int cpu, int size) { int nid, rc = 0, core_id = (cpu / threads_per_core); struct imc_mem_info *mem_info; + struct page *page; /* * alloc_pages_node() will allocate memory for core in the @@ -587,11 +588,12 @@ static int core_imc_mem_init(int cpu, int size) mem_info->id = core_id; /* We need only vbase for core counters */ - mem_info->vbase = page_address(alloc_pages_node(nid, - GFP_KERNEL | __GFP_ZERO | __GFP_THISNODE | - __GFP_NOWARN, get_order(size))); - if (!mem_info->vbase) + page = alloc_pages_node(nid, + GFP_KERNEL | __GFP_ZERO | __GFP_THISNODE | + __GFP_NOWARN, get_order(size)); + if (!page) return -ENOMEM; + mem_info->vbase = page_address(page); /* Init the mutex */ core_imc_refc[core_id].id = core_id; @@ -849,15 +851,17 @@ static int thread_imc_mem_alloc(int cpu_id, int size) int nid = cpu_to_node(cpu_id); if (!local_mem) { + struct page *page; /* * This case could happen only once at start, since we dont * free the memory in cpu offline path. */ - local_mem = page_address(alloc_pages_node(nid, + page = alloc_pages_node(nid, GFP_KERNEL | __GFP_ZERO | __GFP_THISNODE | - __GFP_NOWARN, get_order(size))); - if (!local_mem) + __GFP_NOWARN, get_order(size)); + if (!page) return -ENOMEM; + local_mem = page_address(page); per_cpu(thread_imc_mem, cpu_id) = local_mem; } @@ -1095,11 +1099,14 @@ static int trace_imc_mem_alloc(int cpu_id, int size) int core_id = (cpu_id / threads_per_core); if (!local_mem) { - local_mem = page_address(alloc_pages_node(phys_id, - GFP_KERNEL | __GFP_ZERO | __GFP_THISNODE | - __GFP_NOWARN, get_order(size))); - if (!local_mem) + struct page *page; + + page = alloc_pages_node(phys_id, + GFP_KERNEL | __GFP_ZERO | __GFP_THISNODE | + __GFP_NOWARN, get_order(size)); + if (!page) return -ENOMEM; + local_mem = page_address(page); per_cpu(trace_imc_mem, cpu_id) = local_mem; /* Initialise the counters for trace mode */ From patchwork Mon Jul 22 17:47:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1135209 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45sq7F0cvBz9sBZ for ; Tue, 23 Jul 2019 03:56:57 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="l74Ga2UN"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45sq7D6MNXzDqKH for ; Tue, 23 Jul 2019 03:56:56 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::444; helo=mail-pf1-x444.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="l74Ga2UN"; dkim-atps=neutral Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45spwK4JyVzDqTk for ; Tue, 23 Jul 2019 03:47:29 +1000 (AEST) Received: by mail-pf1-x444.google.com with SMTP id y15so17728885pfn.5 for ; Mon, 22 Jul 2019 10:47:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7xS0c3M+AYF9dKnSJXbr9Z9WeQPtRSwknJMFizoWC90=; b=l74Ga2UN8F8Q/yrY5xAsIprRWmkxXAfNn/X4DwnYFxOyp1PozvuOzixIF5vXrPCfk3 wMT4IPrKD7VIsStfNGlc5OxVg14B+mtPtkWLdyGeN36uOks0cO1CQHPaw66VIA2VNasv 3+R599uaHPyBZofjPQTJ0zj1Om2JbP/YXyTUFbz2OVrfD3mu/m9DfL/MCQTFy4UORChe Y5cAjK66yZAmYTqaQ0m7Hs1lXeVQW3BrEzXStYWpO65/uCyZTxBn6KsyfPLYvG5VINFJ nt5iS4DecNENKw1iV6h0Q9lEkKmNQwxzapZAhnyDOydl+hV8XL6f9QSKycpy6IHzOn5D fwAQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=7xS0c3M+AYF9dKnSJXbr9Z9WeQPtRSwknJMFizoWC90=; b=GbWe/RDtRKR2qRL6hcuglBmdFfF7HmRxohhVIkHLSr27CvmAY93khr7Of4Gb9O6ESf NCYiiT+AsLtPz9qZcR2COCFDVY/IRvs4/WG7WevyVAEZLsDvqiWFuXJ+paQuSX5/EKb9 MfhXEk6ZmoE97iEdM6sFh+Y3vrSjTNtv7oMZs3BS4PxWoB5Lt4fv3XMfXgRxFQf54aaO 9LVvFgp1fbWBs7CWz/cJiz1yylsxrpS11fK1vQlLf2dZfKR6FHHmwCIEqyb2z77eMDx6 dwSdsQ6RkiNaBek5IUbi0wV4aAi/lhMmDnQGEC0onv3ugAN7vVKYUT+2sbIWjpPyrerq d1bQ== X-Gm-Message-State: APjAAAVNxNJoeoCStL17ApqGS8D790VUFpTMyOL4u/Yt1yCz0yZ8HStK E7BrjSjG1e4bIGg3eoVllMcGyO+k X-Google-Smtp-Source: APXvYqweo9oJiRNiZHFMcTx/83oiB+aspk0v/724rAEJcNrvUY5UTGh7Js9kZKkw+eMKqVHklAWKew== X-Received: by 2002:aa7:8007:: with SMTP id j7mr1394993pfi.154.1563817647434; Mon, 22 Jul 2019 10:47:27 -0700 (PDT) Received: from bobo.local0.net (193-116-123-212.tpgi.com.au. [193.116.123.212]) by smtp.gmail.com with ESMTPSA id z24sm69170057pfr.51.2019.07.22.10.47.24 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 22 Jul 2019 10:47:27 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH 4/4] powerpc/64: Add VIRTUAL_BUG_ON checks for __va and __pa addresses Date: Tue, 23 Jul 2019 03:47:00 +1000 Message-Id: <20190722174700.11483-5-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190722174700.11483-1-npiggin@gmail.com> References: <20190722174700.11483-1-npiggin@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anju T Sudhakar , Madhavan Srinivasan , Reza Arbab , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Ensure __va is given an address below PAGE_OFFSET, and __pa is given one above PAGE_OFFSET. Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/page.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h index 0d52f57fca04..c8bb14ff4713 100644 --- a/arch/powerpc/include/asm/page.h +++ b/arch/powerpc/include/asm/page.h @@ -215,9 +215,19 @@ static inline bool pfn_valid(unsigned long pfn) /* * gcc miscompiles (unsigned long)(&static_var) - PAGE_OFFSET * with -mcmodel=medium, so we use & and | instead of - and + on 64-bit. + * This also results in better code generation. */ -#define __va(x) ((void *)(unsigned long)((phys_addr_t)(x) | PAGE_OFFSET)) -#define __pa(x) ((unsigned long)(x) & 0x0fffffffffffffffUL) +#define __va(x) \ +({ \ + VIRTUAL_BUG_ON((unsigned long)(x) >= PAGE_OFFSET); \ + (void *)(unsigned long)((phys_addr_t)(x) | PAGE_OFFSET); \ +}) + +#define __pa(x) \ +({ \ + VIRTUAL_BUG_ON((unsigned long)(x) < PAGE_OFFSET); \ + (unsigned long)(x) & 0x0fffffffffffffffUL; \ +}) #else /* 32-bit, non book E */ #define __va(x) ((void *)(unsigned long)((phys_addr_t)(x) + PAGE_OFFSET - MEMORY_START))