From patchwork Wed Sep 27 11:25:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ene X-Patchwork-Id: 145551 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2851450vqu; Wed, 27 Sep 2023 12:24:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHD65wlZi07sGX0Q35FIR1GM2xQJWCcDxuz7weKSS810+K5FEB0WhI+BkkT39D5+1sh9vxw X-Received: by 2002:a17:903:244a:b0:1c3:64f9:45ad with SMTP id l10-20020a170903244a00b001c364f945admr3337691pls.48.1695842672803; Wed, 27 Sep 2023 12:24:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695842672; cv=none; d=google.com; s=arc-20160816; b=uXTDMGWUZ8mB/BGsdhXfMl+tE6otXur/5WNfRRqRg7F9/fLeswZN8eAcn8wX9i0k+q kb1afoAcxIimm7FB5OMMyAS5hewSr/7F4Pia1k7qcVyJMAbwXvP8WS7Q/k1yLimBsRNB hfAalpvVzH0Qu+ICS4R9uNgZew3d4zu6JJVQQkO7KoZAFT2dMASTyyUuqtyeC8HV+Yxs CKoIYn7dOMsb4CM6NwNcON9B6Kep+XhJ8kCXBUvYRtAakP1zyVZpRq7vr2jjJSYbPx49 VthO+DBGduL2noCUgZYIJIxjFTxXkV2MiNvddw97eqUmk+WfwTZM/cTN0kEnNvutdDG9 fmHQ== 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:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id i1-20020a170902c94100b001ab089f7329si4724487pla.73.2023.09.27.12.24.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 12:24:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; 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:7 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 snail.vger.email (Postfix) with ESMTP id BA2D782224EA; Wed, 27 Sep 2023 04:26:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231532AbjI0L0n (ORCPT + 22 others); Wed, 27 Sep 2023 07:26:43 -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 X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 27 Sep 2023 04:26:57 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778219926373914381 X-GMAIL-MSGID: 1778219926373914381 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;