From patchwork Wed Jul 24 08:46:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1136176 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 45tpss0ksSz9s4Y for ; Wed, 24 Jul 2019 18:48:49 +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="Q4CBc+7V"; 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 45tpsr6W8CzDqK9 for ; Wed, 24 Jul 2019 18:48: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::643; helo=mail-pl1-x643.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="Q4CBc+7V"; dkim-atps=neutral Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) (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 45tprC1hldzDqGN for ; Wed, 24 Jul 2019 18:47:22 +1000 (AEST) Received: by mail-pl1-x643.google.com with SMTP id c14so21674431plo.0 for ; Wed, 24 Jul 2019 01: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:mime-version :content-transfer-encoding; bh=m3tGfPDVejnwkWnCSlcWnnqbFggamsWGmMc5sXy1MHk=; b=Q4CBc+7VmcFulRnttG/sJQ9aN1lZVf3+XVKXxp7oJHleHkZoxFhLoiUNAmCbvVDy2d G9cD+bzYgBqSpM3FMowrZk7Zao8fjWTZgy0x0CyTWF4yrmO0MXWfxXmtEu7iEUD+xsGw 2w8TeBp5R8zozpXtISR7AVkd7o0XqfYUASf2IqkpyvjSY+NXX5HHgyqekNeXasIYPbge sr1Ktrx43Aadu/87nelIw+ZHG/JPMwUD98EtZ281RJZ3+CNHTP4vuIJL1UtgQH+elXiv MIU/kssNuhODq2iyuVgeMK4HqiG6CjnRPRHCBr23HnxJsOX6UiCqMEdOYf7Rno70k6vM I3cg== 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=m3tGfPDVejnwkWnCSlcWnnqbFggamsWGmMc5sXy1MHk=; b=fvZaGp4+90xb+wS19HRV9A5541mLNLb/emORu1GTFEaVCxtVRu69p+PGxBpSMbAVBz uQQL7wA8ky7+uDWJpPlEAFxXz5g4AQWAE5fl85aS4eMq6jnLN+ip92C9uscaSIkuZJ90 hnuDb3GGQAqb+qqh/ArcpWljlB+sZi50uQYU57e9XaNIVCB9napk+vJfxOCS+llR/oCK fNlLP6SuDoJk/2aRnvpCT1aTaI1cK5TJQA+Y/SBdhYPHxw5XGt/4uFHPYblX7Ut4Stdm LbxNTCe/UIjRTAD4QzK5VfP9waPSFaJDOxk/yxUoYNErXBlOsK3XTwFATvkE6oUemm/b 3p3g== X-Gm-Message-State: APjAAAWTOW9Qek6nVRIhtmGeXnGwkadGgk+SkAjkotPhQOeTrpEGmVxf EYpbHbeVwygeFO+Q5zBb+NXoOtBU X-Google-Smtp-Source: APXvYqxzeDXN4VxSPM5Me/edo7k/zakNUefxtJ/V2rKbZWMOLoa49Kb7OzWbblDemaMW4pguuWbpqA== X-Received: by 2002:a17:902:24c:: with SMTP id 70mr84077613plc.2.1563958040508; Wed, 24 Jul 2019 01:47:20 -0700 (PDT) Received: from bobo.ozlabs.ibm.com ([220.240.251.33]) by smtp.gmail.com with ESMTPSA id a3sm54286745pje.3.2019.07.24.01.47.16 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 24 Jul 2019 01:47:19 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 1/5] powerpc/64s/radix: Fix memory hotplug section page table creation Date: Wed, 24 Jul 2019 18:46:34 +1000 Message-Id: <20190724084638.24982-1-npiggin@gmail.com> X-Mailer: git-send-email 2.22.0 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: Madhavan Srinivasan , "Aneesh Kumar K . V" , Reza Arbab , Anju T Sudhakar , 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 irritated by booting with mem= to limit memory then probing an unused physical memory range: echo > /sys/devices/system/memory/probe This mostly works by accident, firstly because __va(__va(x)) == __va(x) so the virtual address does not get corrupted. Secondly because pfn_pte masks out the upper bits of the pfn beyond the physical address limit, so a pfn constructed with a 0xc000000000000000 virtual linear address will be masked back to the correct physical address in the pte. Cc: Reza Arbab Fixes: 6cc27341b21a8 ("powerpc/mm: add radix__create_section_mapping()") Signed-off-by: Nicholas Piggin Reviewed-by: Aneesh Kumar K.V --- 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 Wed Jul 24 08:46:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1136177 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 45tpwL3ZMwz9s4Y for ; Wed, 24 Jul 2019 18:50:58 +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="W7UQM/EE"; 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 45tpwK4RlczDqGW for ; Wed, 24 Jul 2019 18:50:57 +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::644; helo=mail-pl1-x644.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="W7UQM/EE"; dkim-atps=neutral Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) (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 45tprJ3jdxzDqGN for ; Wed, 24 Jul 2019 18:47:28 +1000 (AEST) Received: by mail-pl1-x644.google.com with SMTP id w24so21737993plp.2 for ; Wed, 24 Jul 2019 01:47:28 -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=yeA5fh1Ch0+CG67IzCY8H8gbbjcLsTzUO6FW9sn2dao=; b=W7UQM/EEkwZUnRQDmo0f4C6cp/7AAHUPIAs/GO4dL8LL+qiFh2QETn3XY9W1LpPo7e eQPmSId9eALHHAlDry6/dFXDiVMQ48zlO0xPgD5Xx+0qgljkx45zOo1dVkxuHdblbCbL Seik2vAlvECi1bHNBDeVmyewUDxXijnbEFMt9U8/ZjyvdPyjXiX8AJhF/l9qWF0gTVtT mNTble4bDKrXySCbUHSl5cr7ED5CQPcAlf3I9O9IP9qpy2prcPBZqjYQpoY1Fx8z9xLN l/VgfANRjkgQfYJX8Jrk7G+xFW2AOl2RQfN6KqwkRL60A1gmH9OEtyZHejkm1CEKB95U wSeg== 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=yeA5fh1Ch0+CG67IzCY8H8gbbjcLsTzUO6FW9sn2dao=; b=dZOyMoALnSrk8Kt49/3RhUM7E5hLcmw0Hg90zXSixMEj0+0u4unfTuP7HjmH4ASWWZ aoIFGtlQ9MaCSlMoTPoNL7MqA5QLyAmSlLW98OoT9pDVJ36DjlzpmfDthQBZLg4pQRRX LT2tmpQTyS98CMTi7IRwVrhaYg2x2dmHBz1jgWyS6q+Ex1kkNxrvspEBt46gBTCsBxXO HY51DHnowSXpM8CS4A9tsWKlW+UKUCc9iWhuM9Vp12dZioDnfTA6uAmABz0VdiYceXOT AC7JfZxKx7TWML1E6K057+yzuDCYItXPQalCKrnjAswRV9niIv52o19Cu3+plDNijfQf IH4w== X-Gm-Message-State: APjAAAVczGA5E7fsuDBZCjJq8fn+0lM3S3qYbRhqCBWEgmNLieHaq55P hUHk3I5B2h/yd0EiUqR7jxxtMLL0 X-Google-Smtp-Source: APXvYqwdwuBrHDD40DIzNFrxMK1BhePBf+6XCrMoWGjhNGHH+ZyAfyWckYNZoTVEezvN3p5cKFZKXg== X-Received: by 2002:a17:902:aa95:: with SMTP id d21mr81364588plr.185.1563958045209; Wed, 24 Jul 2019 01:47:25 -0700 (PDT) Received: from bobo.ozlabs.ibm.com ([220.240.251.33]) by smtp.gmail.com with ESMTPSA id a3sm54286745pje.3.2019.07.24.01.47.21 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 24 Jul 2019 01:47:24 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 2/5] powerpc/64s/radix: Fix memory hot-unplug page table split Date: Wed, 24 Jul 2019 18:46:35 +1000 Message-Id: <20190724084638.24982-2-npiggin@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724084638.24982-1-npiggin@gmail.com> References: <20190724084638.24982-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: Madhavan Srinivasan , "Aneesh Kumar K . V" , Reza Arbab , Anju T Sudhakar , 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 Reviewed-by: Aneesh Kumar K.V --- 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 Wed Jul 24 08:46:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1136184 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 45tpzD6qByz9s4Y for ; Wed, 24 Jul 2019 18:53:28 +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="a6FNF4/P"; 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 45tpzD4fw6zDqKt for ; Wed, 24 Jul 2019 18:53:28 +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::542; helo=mail-pg1-x542.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="a6FNF4/P"; dkim-atps=neutral Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (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 45tprN1y0kzDqKr for ; Wed, 24 Jul 2019 18:47:32 +1000 (AEST) Received: by mail-pg1-x542.google.com with SMTP id w10so20872101pgj.7 for ; Wed, 24 Jul 2019 01:47:32 -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=KXdZnBt4Dikq7l5rtbuptsrDWxyJ2ir0gklP9Kfry+c=; b=a6FNF4/PnRSINU/7k8ZCRYWki2wse5zEEYQXIgDOushwzdAYwFDVbhuHXX6hcZRkpj epN+IgLepizsLL0/eOGQfyNVoLQUah4exe3n1k+3TTg63jDQRwOTw3vZUF0VATjNDiAf e0R8rtgYKVTI5lFjDC1rV9np6XQh+W7JmwaotZCra6pmk9RgxzzDPksr0QGu4hRtMAl1 5ujYVCntAT/QyIF5xeuqyT/DNklxHK8yZtYaDJpiQ8RTUIZFeYqgDzouHXpF0e71lUaX VORLFTOXQ1GKUgVdT0YDR8O8yueIxLzPgnz3d6t79idcBL6aqApTfuMhz+chcCan4quP 7qIw== 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=KXdZnBt4Dikq7l5rtbuptsrDWxyJ2ir0gklP9Kfry+c=; b=e/j7Dzu7hVDHKUy3xFTqt2P1qMIaPEUy4wSDEPRHXCgkYhX/2+kgw9aRRm9kVw4uUM cGZ7IuxNQmFqNQl/1hylWt1Ak/p7EivPoQYcZHCkwwbXupAy1uMrWXeLXiP5w7uVKct/ 4hNoYEVD45WjFQV32fgrH9LUnmUykzjwMSdaS2HyerGzeEhQrp6WD8sGBYhHkDMz/5de fCsRNW0HJ+vnEcFwNmy/EvRMWsybfWV3CZX+NcuOu3nRCNq5FlZ8hpua6K3G/7KfgYT2 jmEzI+rAtDzc/D7N1E1X9CWd3NEmU1nuSW6YymlwxMEODvJt+cdKiWGq/kAmS3bSsR9m f66Q== X-Gm-Message-State: APjAAAXq8x65Xb4AgylTIeDBPzWtt7sT6OjSDv9n+hGfr5jEtIVlCytA xnce3hRqhYIDYA69CVUOdPsOm50l X-Google-Smtp-Source: APXvYqxH4DwsS1yENbxqxfO4JF8419EBgN3hVFI7yVBlpT72dPdA5GqzcXfC1YomQUAVpuBiJagGwA== X-Received: by 2002:aa7:940c:: with SMTP id x12mr10362462pfo.80.1563958049588; Wed, 24 Jul 2019 01:47:29 -0700 (PDT) Received: from bobo.ozlabs.ibm.com ([220.240.251.33]) by smtp.gmail.com with ESMTPSA id a3sm54286745pje.3.2019.07.24.01.47.25 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 24 Jul 2019 01:47:29 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 3/5] powerpc/perf: fix imc allocation failure handling Date: Wed, 24 Jul 2019 18:46:36 +1000 Message-Id: <20190724084638.24982-3-npiggin@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724084638.24982-1-npiggin@gmail.com> References: <20190724084638.24982-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: Madhavan Srinivasan , "Aneesh Kumar K . V" , Reza Arbab , Anju T Sudhakar , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" The alloc_pages_node return value should be tested for failure before being passed to page_address. Cc: Madhavan Srinivasan Tested-by: Anju T Sudhakar Signed-off-by: Nicholas Piggin Reviewed-by: Aneesh Kumar K.V --- 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 Wed Jul 24 08:46:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1136187 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 45tq1T1MBsz9s4Y for ; Wed, 24 Jul 2019 18:55:25 +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="gutmkJci"; 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 45tq1R0HGYzDqMF for ; Wed, 24 Jul 2019 18:55:23 +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="gutmkJci"; 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 45tprT3xQ8zDqM0 for ; Wed, 24 Jul 2019 18:47:37 +1000 (AEST) Received: by mail-pg1-x541.google.com with SMTP id x15so10521813pgg.8 for ; Wed, 24 Jul 2019 01:47:37 -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=NsmW12Fmq8hNgptqCPadGxkBE6wheyoqQdCYhpttBkA=; b=gutmkJcirNHc/1KUzEDuJL84/YT39nwvd26Z/zet8TbVK5Qeflszgx0VS1KtH72sp8 So8a54+lrfD8Wjoy7naXWFeCQkD9NcLfKIaQfqXZ3xPLqJsAyRVcizBrDyffcRzKKK0B vOrHhVeZS5hDk7IW8usGOtY6XLA2LFpBym99Tgqv9LObNZM5jKHFPimvGT5n7kEPx61D 3/T46i+c67i1iVNXdi8TV+PlW2vDYaprIiITS5uKrrgCnuvF7rOECvvAunKwomcubk5n LpsLatPhQmt0VAFL0eWekEbcMFEHguGwlpOyXds+FBMc6FAOIBSK/pZPiPT0oTwFdjY+ B77A== 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=NsmW12Fmq8hNgptqCPadGxkBE6wheyoqQdCYhpttBkA=; b=VCRbYQfs4/Dnck/YvWhg4HoR4Ek8No9zq5e2lb+WU3Gfkgr7OSn9QisGlVJ6m9fSJo iEg6eB75dQTiiAAjYE9vILgivXOn7fpHfO6wWToRqtz6lZQIauVIN6jMybIv7NW6msTs HqU94JXVB+fvqH44fNDTQkPx0miE+IaQUCU2kZS0APbLc1zc84LY2QlnzU3JR+Qe8PiN HARnNdh9W7hkZwj+8JRZXKOw89vGd1doyaV06dRjDzNYT67GrQEFzbCa/bLInpndFJpY PTuQisYrhEKIyS17mmTtHVp4t7JZ8RJV4ogIXJCuWHiLPtb3AgJe9+Ej9Pkz6bsRmZE/ 1tmA== X-Gm-Message-State: APjAAAU1Rlwks5b/275D8Ieb/ws9hLQTh8nU9rRHw8KcADud2LCMp3yv dkuF8xduFE7jtFlaucQOYT+QKvbP X-Google-Smtp-Source: APXvYqyytfNlpv7NZYR/kBzAw5PZXiB2X+nSGus2kjDiG0ulwLQhOOJuNydMx7cDG6v4Z7OGcuWfkA== X-Received: by 2002:a62:4e86:: with SMTP id c128mr10160644pfb.64.1563958054089; Wed, 24 Jul 2019 01:47:34 -0700 (PDT) Received: from bobo.ozlabs.ibm.com ([220.240.251.33]) by smtp.gmail.com with ESMTPSA id a3sm54286745pje.3.2019.07.24.01.47.30 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 24 Jul 2019 01:47:33 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 4/5] powerpc/64: Add VIRTUAL_BUG_ON checks for __va and __pa addresses Date: Wed, 24 Jul 2019 18:46:37 +1000 Message-Id: <20190724084638.24982-4-npiggin@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724084638.24982-1-npiggin@gmail.com> References: <20190724084638.24982-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: Madhavan Srinivasan , "Aneesh Kumar K . V" , Reza Arbab , Anju T Sudhakar , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Ensure __va is given a physical address below PAGE_OFFSET, and __pa is given a virtual address above PAGE_OFFSET. Signed-off-by: Nicholas Piggin Reviewed-by: Aneesh Kumar K.V --- 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)) From patchwork Wed Jul 24 08:46:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1136189 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 45tq3T5jKRz9sBF for ; Wed, 24 Jul 2019 18:57:09 +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="jRfSrlUO"; 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 45tq3T3cS7zDqL2 for ; Wed, 24 Jul 2019 18:57:09 +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::544; helo=mail-pg1-x544.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="jRfSrlUO"; dkim-atps=neutral Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) (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 45tprY2jYfzDqKL for ; Wed, 24 Jul 2019 18:47:41 +1000 (AEST) Received: by mail-pg1-x544.google.com with SMTP id i70so10124593pgd.4 for ; Wed, 24 Jul 2019 01:47:41 -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=ln+hwsFnBjTw71UPQVoDeIDK4O+AEVvk1M3CJkiXSfg=; b=jRfSrlUOb+EVALoflHyZ2JW1OGR5akqxW6Rr+c6maDZZ3/4Y14qLXtGmC5DJ+65pPn MYB3tn87kNbro0/E2af+AYzpSEE3Prnyef9X56BtD7yz0aC6FZxN2YdqI2Zftu+HvXjv uHY4dr6/02GUaqNp/gP7J6fiXIIRWEl6jhlTbb/zidIoXfgJXEbreTPMTk8Gb5fSWrk7 AnpzFqxe3QkTU6SqIvOA6XTez7RlNdX9AHEXkDTNbAUQzwSigYV7iox0kAuxwzfmyoMM Lag1hxIgLiHeltwA8AQQo8iCPx2b6a5wUktG3u/cG7MqXS7coX51YAA65Sg3Pm1O+Kzm NiIw== 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=ln+hwsFnBjTw71UPQVoDeIDK4O+AEVvk1M3CJkiXSfg=; b=WfqjbEAiHvrN0s1/B83DgKOB+AQbrFRM4w9WxIRGFWOKXoufmYkZBwDfcwhhgRkXc5 Ggi2Qdi59CH33hZynSz5LnyjLdw7TZHW5lGGpMfxrcKZe5diSs13BJuLInJFJiEKIMBP 9l5J0HLFlhXOl/+RI/xxkkS3YaXaoxbojtS97087JuBRXSHF5c8/+i27OiH4Bhm1dUo0 IB7ON/Z0zRtXWWFUeZ5bUBD1JgKn+n/OI4R+EGPcMiRmRL6IXd5RvsteZzFTahqJY464 to9is/L74voODfXiYtw/zSRBvcxmHu2FKzgWp19ox2zQQ2d5rkr2vOZm4CNr5Xm+jedT 8LTw== X-Gm-Message-State: APjAAAXukCIr52cjJvKPaUPDi5Ws6ZqUqMtYEq3LWifsD8uDCl/BXCfb V3mfe0Em68NxBLIG64JsLCF4APRL X-Google-Smtp-Source: APXvYqzhmgwINpa1TvBUOT+kZVg34/bKWlWbbrSss/EAfgxpx/YOj6moVanVtM+OLEAzTCTAcigugw== X-Received: by 2002:a17:90a:d58c:: with SMTP id v12mr85009191pju.7.1563958058448; Wed, 24 Jul 2019 01:47:38 -0700 (PDT) Received: from bobo.ozlabs.ibm.com ([220.240.251.33]) by smtp.gmail.com with ESMTPSA id a3sm54286745pje.3.2019.07.24.01.47.34 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 24 Jul 2019 01:47:38 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 5/5] powerpc/64s/radix: Remove redundant pfn_pte bitop, add VM_BUG_ON Date: Wed, 24 Jul 2019 18:46:38 +1000 Message-Id: <20190724084638.24982-5-npiggin@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724084638.24982-1-npiggin@gmail.com> References: <20190724084638.24982-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: Madhavan Srinivasan , "Aneesh Kumar K . V" , Reza Arbab , Anju T Sudhakar , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" pfn_pte is never given a pte above the addressable physical memory limit, so the masking is redundant. In case of a software bug, it is not obviously better to silently truncate the pfn than to corrupt the pte (either one will result in memory corruption or crashes), so there is no reason to add this to the fast path. Add VM_BUG_ON to catch cases where the pfn is invalid. These would catch the create_section_mapping bug fixed by a previous commit. [16885.256466] ------------[ cut here ]------------ [16885.256492] kernel BUG at arch/powerpc/include/asm/book3s/64/pgtable.h:612! cpu 0x0: Vector: 700 (Program Check) at [c0000000ee0a36d0] pc: c000000000080738: __map_kernel_page+0x248/0x6f0 lr: c000000000080ac0: __map_kernel_page+0x5d0/0x6f0 sp: c0000000ee0a3960 msr: 9000000000029033 current = 0xc0000000ec63b400 paca = 0xc0000000017f0000 irqmask: 0x03 irq_happened: 0x01 pid = 85, comm = sh kernel BUG at arch/powerpc/include/asm/book3s/64/pgtable.h:612! Linux version 5.3.0-rc1-00001-g0fe93e5f3394 enter ? for help [c0000000ee0a3a00] c000000000d37378 create_physical_mapping+0x260/0x360 [c0000000ee0a3b10] c000000000d370bc create_section_mapping+0x1c/0x3c [c0000000ee0a3b30] c000000000071f54 arch_add_memory+0x74/0x130 Signed-off-by: Nicholas Piggin Reviewed-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/book3s/64/pgtable.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index 8308f32e9782..8e47fb85dfa6 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -608,8 +608,10 @@ static inline bool pte_access_permitted(pte_t pte, bool write) */ static inline pte_t pfn_pte(unsigned long pfn, pgprot_t pgprot) { - return __pte((((pte_basic_t)(pfn) << PAGE_SHIFT) & PTE_RPN_MASK) | - pgprot_val(pgprot)); + VM_BUG_ON(pfn >> (64 - PAGE_SHIFT)); + VM_BUG_ON((pfn << PAGE_SHIFT) & ~PTE_RPN_MASK); + + return __pte(((pte_basic_t)pfn << PAGE_SHIFT) | pgprot_val(pgprot)); } static inline unsigned long pte_pfn(pte_t pte)