Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp4722082ybh; Tue, 6 Aug 2019 17:00:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqw24Q+FFt+AKLBEcZ8d3DJkDRvqCbOUcppGu9iTAaAmFuWJ6Wl9umfj3+bOmeyMsIEGnkNM X-Received: by 2002:a63:ee08:: with SMTP id e8mr5384322pgi.70.1565136034100; Tue, 06 Aug 2019 17:00:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565136034; cv=none; d=google.com; s=arc-20160816; b=QBrdKKsrLCOHx/OPIXkXmPZ/6CjjfEa/gZ64IX/oPWxvMsgjIJovZmJlrMWfbNL2Zo cBvfrPdzYwuUDvdCu0uAut96onF7IkeNzVGrCR3jGMoTxJchNbL3eFeF10RJqXOB/QQ/ EHUWwbTbFiXL13fhdlPATEhTOW+KWqg3nnia1TQCTy1S5uix5LJM44Ew/f2lCFuLeQB5 LelWl+ZbH3vBSXvcGMLmuHDLYD3VEtqaIXN3hUyAW6oXhVJ8JiSnmQ4p6+zYXkuPLI2G Vc84zIl4Kw2bZATejFn7ZyrLXgGqkMo06jiiDjdTBxjjzjS1N9ILydZ/RKfkLvrsLrwJ 76dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=wMdmOR08Oikb8ikVaqlyv4A1JGg1JQtorE+1XZo6ZFI=; b=pUjeHkGjgU+tsOxHPc3qkPB/lclEpMAynFk91IRyoWkLRGoNCjgcLXT9AHW+mwzmtX wlntFEdMEqRRTI3T3i+2S66WbDF8DqJwQR3K9VVm0oiYS0Z8lapr1N2296RnTTUsO6qb LhuDVRnEQOg8PLF3/bW/J6hnsMEGvzJVt1HWp9n6P6JYmQXXorb8znLne2sBMA3Kjsix FQ+xDz/SGBi5RXmSlppgd8JqrxAC94fG4vmRuutCNfAYnOWxBXvFFWqiWIsIeskQ6CEt 7WY8pRkCID7aPOKgYKgqHOFzE5n59Ph75WZyeDRQ4sGZKRq22j7xmCu2XVmdqhXH+pwD QeAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Sv03h4En; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f94si293797plb.287.2019.08.06.17.00.17; Tue, 06 Aug 2019 17:00:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Sv03h4En; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727407AbfHFX60 (ORCPT + 99 others); Tue, 6 Aug 2019 19:58:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:59396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726133AbfHFX60 (ORCPT ); Tue, 6 Aug 2019 19:58:26 -0400 Received: from localhost.localdomain (c-73-223-200-170.hsd1.ca.comcast.net [73.223.200.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 96CCD20663; Tue, 6 Aug 2019 23:58:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565135905; bh=j/RvlO/MM/u062VCfMQ2ZMvgSxU6N459yDU0a9QHEGM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Sv03h4En6sHUvjYMfXRk7QmI1g/wUlUCsu+aLDz8UlUIF+0+cyQ6Di38j7Nnhrysv 4SOmjpm0qbcj0ZtINtXe+NNaZM+B40VBZiQd0Ldi81tCJ4rI86C8d8hc1svMxl0Ha0 p2uze6hxnY52pKINnpq4ffN6GSw4LSF0BCnJxCUg= Date: Tue, 6 Aug 2019 16:58:23 -0700 From: Andrew Morton To: Steven Price Cc: linux-mm@kvack.org, Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?UTF-8?B?SsOpcsO0bWU=?= Glisse , Peter Zijlstra , Thomas Gleixner , Will Deacon , x86@kernel.org, "H. Peter Anvin" , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mark Rutland , "Liang, Kan" Subject: Re: [PATCH v10 20/22] x86: mm: Convert dump_pagetables to use walk_page_range Message-Id: <20190806165823.3f735b45a7c4163aca20a767@linux-foundation.org> In-Reply-To: <20190731154603.41797-21-steven.price@arm.com> References: <20190731154603.41797-1-steven.price@arm.com> <20190731154603.41797-21-steven.price@arm.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 31 Jul 2019 16:46:01 +0100 Steven Price wrote: > Make use of the new functionality in walk_page_range to remove the > arch page walking code and use the generic code to walk the page tables. > > The effective permissions are passed down the chain using new fields > in struct pg_state. > > The KASAN optimisation is implemented by including test_p?d callbacks > which can decide to skip an entire tree of entries > > ... > > +static const struct ptdump_range ptdump_ranges[] = { > +#ifdef CONFIG_X86_64 > > -#define pgd_large(a) (pgtable_l5_enabled() ? pgd_large(a) : p4d_large(__p4d(pgd_val(a)))) > -#define pgd_none(a) (pgtable_l5_enabled() ? pgd_none(a) : p4d_none(__p4d(pgd_val(a)))) > +#define normalize_addr_shift (64 - (__VIRTUAL_MASK_SHIFT + 1)) > +#define normalize_addr(u) ((signed long)(u << normalize_addr_shift) \ > + >> normalize_addr_shift) > > -static inline bool is_hypervisor_range(int idx) > -{ > -#ifdef CONFIG_X86_64 > - /* > - * A hole in the beginning of kernel address space reserved > - * for a hypervisor. > - */ > - return (idx >= pgd_index(GUARD_HOLE_BASE_ADDR)) && > - (idx < pgd_index(GUARD_HOLE_END_ADDR)); > + {0, PTRS_PER_PGD * PGD_LEVEL_MULT / 2}, > + {normalize_addr(PTRS_PER_PGD * PGD_LEVEL_MULT / 2), ~0UL}, This blows up because PGD_LEVEL_MULT is sometimes not a constant. x86_64 allmodconfig: In file included from ./arch/x86/include/asm/pgtable_types.h:249:0, from ./arch/x86/include/asm/paravirt_types.h:45, from ./arch/x86/include/asm/ptrace.h:94, from ./arch/x86/include/asm/math_emu.h:5, from ./arch/x86/include/asm/processor.h:12, from ./arch/x86/include/asm/cpufeature.h:5, from ./arch/x86/include/asm/thread_info.h:53, from ./include/linux/thread_info.h:38, from ./arch/x86/include/asm/preempt.h:7, from ./include/linux/preempt.h:78, from ./include/linux/spinlock.h:51, from ./include/linux/wait.h:9, from ./include/linux/wait_bit.h:8, from ./include/linux/fs.h:6, from ./include/linux/debugfs.h:15, from arch/x86/mm/dump_pagetables.c:11: ./arch/x86/include/asm/pgtable_64_types.h:56:22: error: initializer element is not constant #define PTRS_PER_PGD 512 ^ arch/x86/mm/dump_pagetables.c:363:6: note: in expansion of macro ‘PTRS_PER_PGD’ {0, PTRS_PER_PGD * PGD_LEVEL_MULT / 2}, ^~~~~~~~~~~~ ./arch/x86/include/asm/pgtable_64_types.h:56:22: note: (near initialization for ‘ptdump_ranges[0].end’) #define PTRS_PER_PGD 512 ^ arch/x86/mm/dump_pagetables.c:363:6: note: in expansion of macro ‘PTRS_PER_PGD’ {0, PTRS_PER_PGD * PGD_LEVEL_MULT / 2}, ^~~~~~~~~~~~ arch/x86/mm/dump_pagetables.c:360:27: error: initializer element is not constant #define normalize_addr(u) ((signed long)(u << normalize_addr_shift) \ ^ arch/x86/mm/dump_pagetables.c:364:3: note: in expansion of macro ‘normalize_addr’ {normalize_addr(PTRS_PER_PGD * PGD_LEVEL_MULT / 2), ~0UL}, ^~~~~~~~~~~~~~ arch/x86/mm/dump_pagetables.c:360:27: note: (near initialization for ‘ptdump_ranges[1].start’) #define normalize_addr(u) ((signed long)(u << normalize_addr_shift) \ ^ arch/x86/mm/dump_pagetables.c:364:3: note: in expansion of macro ‘normalize_addr’ {normalize_addr(PTRS_PER_PGD * PGD_LEVEL_MULT / 2), ~0UL}, I don't know what to do about this so I'll drop the series.