From patchwork Sun Mar 22 16:14:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 11451891 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F11286CA for ; Sun, 22 Mar 2020 16:16:18 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D738820724 for ; Sun, 22 Mar 2020 16:16:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D738820724 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jG3FQ-0004hZ-BN; Sun, 22 Mar 2020 16:14:48 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jG3FP-0004gr-7p for xen-devel@lists.xenproject.org; Sun, 22 Mar 2020 16:14:47 +0000 X-Inumbo-ID: 3779db0e-6c58-11ea-8134-12813bfff9fa Received: from mail-ed1-f65.google.com (unknown [209.85.208.65]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 3779db0e-6c58-11ea-8134-12813bfff9fa; Sun, 22 Mar 2020 16:14:33 +0000 (UTC) Received: by mail-ed1-f65.google.com with SMTP id a20so13525554edj.2 for ; Sun, 22 Mar 2020 09:14:33 -0700 (PDT) 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; bh=/5jiq14GiLSWNnqAgN6SMPOo4zQIP4LpAFn+6K8zDb8=; b=erZUGwjuwtE8Avn9f60efM0fc2MB8Mzclh4F4+qlUpOepfKT5Pyc+PWxaWj6O9yNeP w0povH6pcdT/GP+IwAW6Fzv2ekyCIhTz/4AVkxBaVmsfA0quUoFlF6GPc3k6hGtXrmez zRQ6F1seaoLZoIJ0p8Ww83AoOlhSaE6/UfemW5PAHCLjo9uRzoN3mrJy/Bdqq6TWO9oM FTDmpy+jw1DUeFn82j20B76JkMqElpyMgwbTEhBixDtPsu51+NjeAyZxUPaOzcW6SvP4 IRu/u2giW6+49qIJ13KGIm2dFCNHKUOFBJ4mAh43WXNDpOlVbxTDl6KBOxsT0RA5htd0 6oSg== X-Gm-Message-State: ANhLgQ1eVhjXzZg8F5ncJu1Hy7Yo+disazMBstc2mhSY3cLyM0QgWTiF V8lUkG0rSbYfPBQgqn0bdVzN6QD7mXTC6w== X-Google-Smtp-Source: ADFU+vt5MFpsUyDo/Clv14Mi5UAG0f1ZNtcUxTkSdcRj7tVwLZfJgz4rGcZu2ybIRehMoMymyxF29w== X-Received: by 2002:a50:d7d3:: with SMTP id m19mr17288059edj.329.1584893672524; Sun, 22 Mar 2020 09:14:32 -0700 (PDT) Received: from ufe34d9ed68d054.ant.amazon.com (54-240-197-235.amazon.com. [54.240.197.235]) by smtp.gmail.com with ESMTPSA id v13sm106693edj.62.2020.03.22.09.14.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Mar 2020 09:14:32 -0700 (PDT) From: julien@xen.org To: xen-devel@lists.xenproject.org Date: Sun, 22 Mar 2020 16:14:09 +0000 Message-Id: <20200322161418.31606-9-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200322161418.31606-1-julien@xen.org> References: <20200322161418.31606-1-julien@xen.org> Subject: [Xen-devel] [PATCH 08/17] xen/x86: traps: Convert show_page_walk() to use typesafe MFN X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: julien@xen.org, Wei Liu , Andrew Cooper , Julien Grall , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Julien Grall Note that the code is now using cr3_to_mfn() to get the MFN. This is slightly different as the top 12-bits will now be masked. No functional changes intended. Signed-off-by: Julien Grall --- xen/arch/x86/x86_64/traps.c | 42 ++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/xen/arch/x86/x86_64/traps.c b/xen/arch/x86/x86_64/traps.c index c3d4faea6b..811c2cb37b 100644 --- a/xen/arch/x86/x86_64/traps.c +++ b/xen/arch/x86/x86_64/traps.c @@ -184,7 +184,8 @@ void vcpu_show_registers(const struct vcpu *v) void show_page_walk(unsigned long addr) { - unsigned long pfn, mfn = read_cr3() >> PAGE_SHIFT; + unsigned long pfn; + mfn_t mfn = cr3_to_mfn(read_cr3()); l4_pgentry_t l4e, *l4t; l3_pgentry_t l3e, *l3t; l2_pgentry_t l2e, *l2t; @@ -194,52 +195,51 @@ void show_page_walk(unsigned long addr) if ( !is_canonical_address(addr) ) return; - l4t = map_domain_page(_mfn(mfn)); + l4t = map_domain_page(mfn); l4e = l4t[l4_table_offset(addr)]; unmap_domain_page(l4t); - mfn = l4e_get_pfn(l4e); - pfn = mfn_valid(_mfn(mfn)) && machine_to_phys_mapping_valid ? - get_gpfn_from_mfn(mfn) : INVALID_M2P_ENTRY; + mfn = l4e_get_mfn(l4e); + pfn = mfn_valid(mfn) && machine_to_phys_mapping_valid ? + get_gpfn_from_mfn(mfn_x(mfn)) : INVALID_M2P_ENTRY; printk(" L4[0x%03lx] = %"PRIpte" %016lx\n", l4_table_offset(addr), l4e_get_intpte(l4e), pfn); - if ( !(l4e_get_flags(l4e) & _PAGE_PRESENT) || - !mfn_valid(_mfn(mfn)) ) + if ( !(l4e_get_flags(l4e) & _PAGE_PRESENT) || !mfn_valid(mfn) ) return; - l3t = map_domain_page(_mfn(mfn)); + l3t = map_domain_page(mfn); l3e = l3t[l3_table_offset(addr)]; unmap_domain_page(l3t); - mfn = l3e_get_pfn(l3e); - pfn = mfn_valid(_mfn(mfn)) && machine_to_phys_mapping_valid ? - get_gpfn_from_mfn(mfn) : INVALID_M2P_ENTRY; + mfn = l3e_get_mfn(l3e); + pfn = mfn_valid(mfn) && machine_to_phys_mapping_valid ? + get_gpfn_from_mfn(mfn_x(mfn)) : INVALID_M2P_ENTRY; printk(" L3[0x%03lx] = %"PRIpte" %016lx%s\n", l3_table_offset(addr), l3e_get_intpte(l3e), pfn, (l3e_get_flags(l3e) & _PAGE_PSE) ? " (PSE)" : ""); if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) || (l3e_get_flags(l3e) & _PAGE_PSE) || - !mfn_valid(_mfn(mfn)) ) + !mfn_valid(mfn) ) return; - l2t = map_domain_page(_mfn(mfn)); + l2t = map_domain_page(mfn); l2e = l2t[l2_table_offset(addr)]; unmap_domain_page(l2t); - mfn = l2e_get_pfn(l2e); - pfn = mfn_valid(_mfn(mfn)) && machine_to_phys_mapping_valid ? - get_gpfn_from_mfn(mfn) : INVALID_M2P_ENTRY; + mfn = l2e_get_mfn(l2e); + pfn = mfn_valid(mfn) && machine_to_phys_mapping_valid ? + get_gpfn_from_mfn(mfn_x(mfn)) : INVALID_M2P_ENTRY; printk(" L2[0x%03lx] = %"PRIpte" %016lx%s\n", l2_table_offset(addr), l2e_get_intpte(l2e), pfn, (l2e_get_flags(l2e) & _PAGE_PSE) ? " (PSE)" : ""); if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) || (l2e_get_flags(l2e) & _PAGE_PSE) || - !mfn_valid(_mfn(mfn)) ) + !mfn_valid(mfn) ) return; - l1t = map_domain_page(_mfn(mfn)); + l1t = map_domain_page(mfn); l1e = l1t[l1_table_offset(addr)]; unmap_domain_page(l1t); - mfn = l1e_get_pfn(l1e); - pfn = mfn_valid(_mfn(mfn)) && machine_to_phys_mapping_valid ? - get_gpfn_from_mfn(mfn) : INVALID_M2P_ENTRY; + mfn = l1e_get_mfn(l1e); + pfn = mfn_valid(mfn) && machine_to_phys_mapping_valid ? + get_gpfn_from_mfn(mfn_x(mfn)) : INVALID_M2P_ENTRY; printk(" L1[0x%03lx] = %"PRIpte" %016lx\n", l1_table_offset(addr), l1e_get_intpte(l1e), pfn); }