Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp489607imm; Fri, 5 Oct 2018 07:07:27 -0700 (PDT) X-Google-Smtp-Source: ACcGV62P7hCVlI1tPsr0WYThbrMdSPC7gX9Lm/Qz+VY5Y3EdmPzIJhHjfNpeFiyesgPhhPNt1MJR X-Received: by 2002:a17:902:722:: with SMTP id 31-v6mr11615476pli.207.1538748447465; Fri, 05 Oct 2018 07:07:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538748447; cv=none; d=google.com; s=arc-20160816; b=Du2CYFoRw2cz+arK7zdDtgjZZyffaAR9RoO2ZGqxP98gVKaEX02SnaVHXsBQZ169iN ZN334iwT8LBcH1ZHn4YED3pt2BOoLuVPE/dwJI5WjCgb0Mf8EXJMNaFQQ2/Fv4YSj0HU +DUGpvyFByLhIn9WegKOjm46DG5o0JTjSLpq5cuC2QmQY2/hit5pKG99z1E7utedlw6j CLlTl82PIG9zAkyE5DGj3M35lDiwIxgRixu9sNqqJJGH/p8NbntxcRfbZvUR3SFlHnW6 sXiK80agKmQEtz8/pTuhza8X1eEO1RmL/gKoZDJW+sjTxrNENi5KsidO5ZIegXXQ3JQk I+Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=hnhMcVTxaAJd/6pCWYaQjBEPZPbSiEhBQt0tqcSjpFk=; b=SyJaGP8ySgBuSssCRsJKsX0EkTSOKIUtD/eN7/f5tMwcFEFL5y4QZ1CDbg8DA1fd+8 CIavgmhdP2yNKMSpkWmThDRLlrET4hDM35aV+tfMtd3lnH29Q6YpZ26CuCu49Xukf0sk OFQvP7tR2i2aVzNIQC/+/samLs7jGvC6wqEO6F4kNwbV0RqxmOQVCRKixvNUx3HgGuyl 9GB7qRSx30oV8Q0pIErUbAucPimkmv/vnuGBPpJKszAsXNHYH6+O6KNL8xulkjwBZapd Pb2Vvnpok2x4VtbPqK47oGg5qkqAM9sBz2o+3y/asVzUhUGk8Vtr+W0h5XlOmPwIlHhS hEcg== ARC-Authentication-Results: i=1; mx.google.com; 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 n7-v6si7918716pgh.359.2018.10.05.07.07.10; Fri, 05 Oct 2018 07:07:27 -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; 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 S1728495AbeJEVF5 (ORCPT + 99 others); Fri, 5 Oct 2018 17:05:57 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:34565 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727581AbeJEVF5 (ORCPT ); Fri, 5 Oct 2018 17:05:57 -0400 Received: by mail-qt1-f194.google.com with SMTP id x23-v6so13903856qtr.1 for ; Fri, 05 Oct 2018 07:07:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hnhMcVTxaAJd/6pCWYaQjBEPZPbSiEhBQt0tqcSjpFk=; b=fogSQBl664kwxkRV9VGGeRHjObxKl5+uMDZ52br+tr+Q20zcAkIyzVwhiZZHkkeOfX M4PSlkVVu2U53poU2qlSE49KYXrHJO9BTYBY8UmE5xP15v12DBhS3PE8jHANNcFXJSCz KXTFwt6VzS/TmAt9wonVmrqPSRkeLo37mL68KzezyoWxkOAyAqVA6GqnFWapYHZw2OR4 5dvjnISTi00JFrBWtuasBZ3d4KwgvPvYto3szekRPJV6rC1BTWfH8s0PAkNMrowaEyto ct/miO5YN+aKDBClQh8kiRR9jIL/NpUusY40Vb7Rw4jrGnpfggN3rRzWdfMFO6FZyCvf MzxA== X-Gm-Message-State: ABuFfoi1/zrgkuilfnm7bWFZy/lFpb32ujRXN5/FDuSpviAkCSQGpfE0 bltIWBx5qp4hA6DN606Xk8OHyDNUAlKwEdm+tIM= X-Received: by 2002:aed:3f08:: with SMTP id p8-v6mr9390624qtf.185.1538748423732; Fri, 05 Oct 2018 07:07:03 -0700 (PDT) MIME-Version: 1.0 References: <1531906876-13451-1-git-send-email-joro@8bytes.org> <1531906876-13451-33-git-send-email-joro@8bytes.org> In-Reply-To: <1531906876-13451-33-git-send-email-joro@8bytes.org> From: Arnd Bergmann Date: Fri, 5 Oct 2018 16:06:47 +0200 Message-ID: Subject: Re: [PATCH 32/39] x86/pgtable/pae: Use separate kernel PMDs for user page-table To: Joerg Roedel Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , "the arch/x86 maintainers" , Linux Kernel Mailing List , Linux-MM , Linus Torvalds , Andy Lutomirski , Dave Hansen , Josh Poimboeuf , Juergen Gross , Peter Zijlstra , Borislav Petkov , Jiri Kosina , Boris Ostrovsky , Brian Gerst , David Laight , Denys Vlasenko , Eduardo Valentin , gregkh , Will Deacon , "Liguori, Anthony" , Daniel Gruss , Hugh Dickins , Kees Cook , Andrea Arcangeli , Waiman Long , Pavel Machek , dhgutteridge@sympatico.ca, Joerg Roedel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 18, 2018 at 11:43 AM Joerg Roedel wrote: > arch/x86/mm/pgtable.c | 100 ++++++++++++++++++++++++++++++++++++++++---------- > 1 file changed, 81 insertions(+), 19 deletions(-) > > diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c > index db6fb77..8e4e63d 100644 > --- a/arch/x86/mm/pgtable.c > +++ b/arch/x86/mm/pgtable.c > @@ -182,6 +182,14 @@ static void pgd_dtor(pgd_t *pgd) > */ > #define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD > > +/* > + * We allocate separate PMDs for the kernel part of the user page-table > + * when PTI is enabled. We need them to map the per-process LDT into the > + * user-space page-table. > + */ > +#define PREALLOCATED_USER_PMDS (static_cpu_has(X86_FEATURE_PTI) ? \ > + KERNEL_PGD_PTRS : 0) > * Xen paravirt assumes pgd table should be in one page. 64 bit kernel also > * assumes that pgd should be in one page. > @@ -376,6 +431,7 @@ static inline void _pgd_free(pgd_t *pgd) > pgd_t *pgd_alloc(struct mm_struct *mm) > { > pgd_t *pgd; > + pmd_t *u_pmds[PREALLOCATED_USER_PMDS]; > pmd_t *pmds[PREALLOCATED_PMDS]; > This commit from back in July now causes a build warning after the patch from Kees that enables -Wvla: In file included from /git/arm-soc/include/linux/kernel.h:15, from /git/arm-soc/include/asm-generic/bug.h:18, from /git/arm-soc/arch/x86/include/asm/bug.h:83, from /git/arm-soc/include/linux/bug.h:5, from /git/arm-soc/include/linux/mmdebug.h:5, from /git/arm-soc/include/linux/mm.h:9, from /git/arm-soc/arch/x86/mm/pgtable.c:2: /git/arm-soc/arch/x86/mm/pgtable.c: In function 'pgd_alloc': /git/arm-soc/include/linux/build_bug.h:29:45: error: ISO C90 forbids variable length array 'u_pmds' [-Werror=vla] #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); })) ^ /git/arm-soc/arch/x86/include/asm/cpufeature.h:85:5: note: in expansion of macro 'BUILD_BUG_ON_ZERO' BUILD_BUG_ON_ZERO(NCAPINTS != 19)) ^~~~~~~~~~~~~~~~~ /git/arm-soc/arch/x86/include/asm/cpufeature.h:111:32: note: in expansion of macro 'REQUIRED_MASK_BIT_SET' (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \ ^~~~~~~~~~~~~~~~~~~~~ /git/arm-soc/arch/x86/include/asm/cpufeature.h:129:27: note: in expansion of macro 'cpu_has' #define boot_cpu_has(bit) cpu_has(&boot_cpu_data, bit) ^~~~~~~ /git/arm-soc/arch/x86/include/asm/cpufeature.h:209:3: note: in expansion of macro 'boot_cpu_has' boot_cpu_has(bit) : \ ^~~~~~~~~~~~ /git/arm-soc/arch/x86/mm/pgtable.c:190:34: note: in expansion of macro 'static_cpu_has' #define PREALLOCATED_USER_PMDS (static_cpu_has(X86_FEATURE_PTI) ? \ ^~~~~~~~~~~~~~ /git/arm-soc/arch/x86/mm/pgtable.c:431:16: note: in expansion of macro 'PREALLOCATED_USER_PMDS' pmd_t *u_pmds[PREALLOCATED_USER_PMDS]; ^~~~~~~~~~~~~~~~~~~~~~ Arnd