Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2579461rdh; Wed, 27 Sep 2023 06:56:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IElXKWztASXFPPUb2IyshCYzVRPcaYos+KLbFYIHIc+wK2pZ5fV2ALThfOyBrouvFa8+F8p X-Received: by 2002:a17:902:da82:b0:1bf:728:745b with SMTP id j2-20020a170902da8200b001bf0728745bmr1770144plx.49.1695823017622; Wed, 27 Sep 2023 06:56:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695823017; cv=none; d=google.com; s=arc-20160816; b=BnbFhEdfvTG9/WcPmo2kY2FwS5XBw2UAMtHicZ/bRmkA5FH1fYWcZSbx/i7e3wg7RD 3ZD/8enx93UqLhl1JvshWQYyi8u8srwnqej+A7MWfvZ4mGIYgG3ym8DmUYbGMEYEFA3V 9oKVf5bdxb4Pigupt1x+95iWDO39Moit2rRsGp9AWsUSeRrk+7Z+lH8mFQE2YrCYe1iK Vf3V0kOQJQVBBreI2OY6GQW7caNyvqp+XcF4BIfh0nN/zWncvq3SRY4sw1WTaPoVHuV0 AOdxXZ1jMcLG9RtWhm9p6DzaVSGdi94bF+lEwVlRgQM7A21drncVZYrbkMnusN4bHTVC KDbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=Dqe/ezm7v7eNq2euMQ5a609PLiY6TU1HkFiIjMU1CM4=; fh=yikR9HT1wx5LLj7DvfR9kbE/RatD/mnQgNUS++qRsJM=; b=nHvqcNVFyCqXVeFITw3F6yZyg11vQdYVwTD+lmq0tKJnV6paA96ThrdwGkH1nfpyp5 iqTqrCKR3jMUnbKo+kNR5CjNmm5xDYum55yvYa00I3MWcnNHw7mRkoc4izN3UftB6wN2 FJ6T4xEjbgZMH8DNFTnJVoI6ZIvPJBNOitqBjeMm1uXcJ/o0VvFKnL4syd/ZJjA/BgB4 jP9nmoX0YxzIqxNSRB60v+Vc7tKtdwfgkiNSA76lEeF5xOGdANnAQzbUkvlafwWsFb98 saBfWeiWY+pddCGzVg98WlDBuISL/9QKZsh2U7k8OIgJgD4V+u8CeTReL6n1Or6Ybjtd Md8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=KkB4ZFEh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id l12-20020a170903244c00b001bb02e4b739si17171353pls.475.2023.09.27.06.56.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 06:56:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=KkB4ZFEh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 3BF1580B02BA; Wed, 27 Sep 2023 04:27:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231561AbjI0L0m (ORCPT + 99 others); Wed, 27 Sep 2023 07:26:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231600AbjI0L0T (ORCPT ); Wed, 27 Sep 2023 07:26:19 -0400 Received: from mail-wr1-x44a.google.com (mail-wr1-x44a.google.com [IPv6:2a00:1450:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8445FFC for ; Wed, 27 Sep 2023 04:26:04 -0700 (PDT) Received: by mail-wr1-x44a.google.com with SMTP id ffacd0b85a97d-3217fdf913dso8219068f8f.3 for ; Wed, 27 Sep 2023 04:26:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695813962; x=1696418762; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Dqe/ezm7v7eNq2euMQ5a609PLiY6TU1HkFiIjMU1CM4=; b=KkB4ZFEheuhGY2DHzNuQc0kEk8mD8RxGAjNExd8epS2wc0Lq/nI1h84MjdzURP/zri FlbrcRN9BjbU14sidG8Di1TblvEIDNVSFWs/5k9bzwYf0//eL6Xf8nMPVGoMI5xHOtmA FNxl2iXd808FQ6Voj9RPlJT+6ZvgTwsi1XA9Q8My22gGNLxLWpF7hWiDW23NB2GsCmMo Fax8BIo2r8iTVGp1vTgXCGc/SByl11yWg/niy0HkGJYveM/TV208+D/BFisszpDtk4Az S04xvlbaJV8fm2dgYAN2ZuetdjG9zXv8CVY04yXLI2g01lZkerwcRmM/jF9n6WrGGnUi A92Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695813962; x=1696418762; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Dqe/ezm7v7eNq2euMQ5a609PLiY6TU1HkFiIjMU1CM4=; b=uH2WnPJVYGZflHS8lcecTakcSJ1eYIkXBl0IeMvA33oUoLd8Y2A72tHvBeLPjusItG Ir/FdNF2ScYdZb0mx6PHmUCwNaRo+uKot9Jcf9l0NNqpxV/7n8DH5N/t2JENfkHUoqKB gTA/ub83JqlpjX99L3iZAShvqLi93ZDlRJI84PGtW/8PXSlV5wiFB632m+IPJtpfhzEl YP29HDD6PTigJoE1Szjesi0taCRctssgjVjFb7OvJ2gE8fZDMTV48QeieCL/BRra15l9 jQbt6XDMnRQwE+E1PNDWgw3jyso7czcNTHQ7BmO+yPLRby7IS5H3WvgEDmB9YdLBwTby oYsQ== X-Gm-Message-State: AOJu0Yx55LOveDESdlkr7ux6E6/HHXQzT24S2NrJ/XOlvZiXk20K8Ytv E/MqvXnW00nVHfXKVlGoBbiwAtFqBRUs+VDIexvFHTU83//70lwj4TLAh3BtaDn1RYFD4Ysae0r 7Gfh073U0HoGAX2XDS4SCOWVIxDzUGlOviGhOU0TcHu3C/ANWUVXfP7wuy40xNJs3lSAHszNNMZ mPF2pgWG/A0Q== X-Received: from seb.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:31bd]) (user=sebastianene job=sendgmr) by 2002:adf:ed84:0:b0:317:6e79:423c with SMTP id c4-20020adfed84000000b003176e79423cmr7349wro.3.1695813962239; Wed, 27 Sep 2023 04:26:02 -0700 (PDT) Date: Wed, 27 Sep 2023 11:25:17 +0000 In-Reply-To: <20230927112517.2631674-1-sebastianene@google.com> Mime-Version: 1.0 References: <20230927112517.2631674-1-sebastianene@google.com> X-Mailer: git-send-email 2.42.0.515.g380fc7ccd1-goog Message-ID: <20230927112517.2631674-12-sebastianene@google.com> Subject: [PATCH 11/11] arm64: ptdump: Fix format output during stage-2 pagetable dumping From: Sebastian Ene To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, will@kernel.org, ryan.roberts@arm.com, mark.rutland@arm.com, maz@kernel.org, vdonnefort@google.com, Sebastian Ene Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 27 Sep 2023 04:27:12 -0700 (PDT) Fix two issues where the printed address range from debugfs was not showing out correctly when trying to read from /sys/kernel/debug/host_stage2_kernel_page_tables entry. The first issue was printing to debugfs the following: 0x0000010000000000-0x0000000000000000 16777215T PGD If the st->start_address was larger than the current addr the delta variable used to display the size of the address range was overflowing. The second issue was printing the following wrong IPA range: 0x0000000000000000-0x0000000000000000 0E PGD Validate the current address range before printing it from the debugfs entry. Signed-off-by: Sebastian Ene --- arch/arm64/mm/ptdump.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c index 45ff4ebae01a..2c21ba9b47d1 100644 --- a/arch/arm64/mm/ptdump.c +++ b/arch/arm64/mm/ptdump.c @@ -430,6 +430,9 @@ static void note_page(struct ptdump_state *pt_st, unsigned long addr, int level, const char *unit = units; unsigned long delta; + if (st->start_address >= addr) + goto update_state; + if (st->current_prot) { note_prot_uxn(st, addr); note_prot_wx(st, addr); @@ -455,6 +458,7 @@ static void note_page(struct ptdump_state *pt_st, unsigned long addr, int level, pt_dump_seq_printf(st->seq, "---[ %s ]---\n", st->marker->name); } +update_state: st->start_address = addr; st->current_prot = prot; st->level = level; -- 2.42.0.515.g380fc7ccd1-goog