Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp546481pja; Thu, 19 Mar 2020 07:18:31 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt5D07zlJnE37bAuy74OwJ0d179dzxzpJSR66rckEeyua0iAEDFrId3rU2ouy3sQo4/ryWd X-Received: by 2002:a9d:414:: with SMTP id 20mr2574469otc.300.1584627511560; Thu, 19 Mar 2020 07:18:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584627511; cv=none; d=google.com; s=arc-20160816; b=IxwFlsPoz8dCwDbDklpi8/SV/xeBUVXRUM/X/0UD6VY6WmtpxbqJNqbTpZgtsJlqrt LeSTgvgbZ/jNZFhjMb4L3a0gi/JmtzQeH+wNP15X/YWDo3rWMLcLkYp+gZZE0uF3/kke iXNIokc/981uCp0lNtai7sG+03TdcTa1LFC5phenkCfVgL9DLgudYFF0D/knwa2CViTn LOvkVE+peLGuOQbJy1sOcgsffLvfSXXc3UQOXJPcwLLMkX3mOQAmPnMgRr3fiaNwIEEl 8HVgkOq3PkLHZpu+NLy0oWBjfZG3sfMdudSyoLzrkYjg4ibvVjE8qeRduiqDd8UdPf1Q qbjA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=Pc3Zp6RcNRELIbFsuWJ1AM6GLwe8PYn9FEq9uPAl95M=; b=unh3n0i5cht/T9MO3PCV6V/KZw5+ICFiMKGTUpqkukSN0z45Q/htBmT0rpFw53YteT BkR8NMtavDUleHYmJj0AT015ZfOBwd8nIw6IsQNvv/AF0C0GDaDhgAdWSqDWMALmi+kz LWZ/mDqM9ABRFCUNRKVaE1VwwWe0zISIzPouEvFbR3v4ChMAVtzTwQOETAcTzRzxizh9 KTaeuJWGyOZDQu4Bfsw5HvWRjv/gp078nRiG5t9f1kpyNxRH+FT7BRJINt9tADW2rzVv f6sZU8hVwuvkGuj0/zBkRgJq6UfJRgG69gXRUq+IJ4JuwS5SXZcFZ3/JpNZAB+3e3QRX r52g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=witbiSuG; 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 v129si1021329oib.58.2020.03.19.07.17.59; Thu, 19 Mar 2020 07:18:31 -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=@c-s.fr header.s=mail header.b=witbiSuG; 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 S1727183AbgCSOQQ (ORCPT + 99 others); Thu, 19 Mar 2020 10:16:16 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:48197 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726926AbgCSOQQ (ORCPT ); Thu, 19 Mar 2020 10:16:16 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48jpqJ4Zdnz9tym3; Thu, 19 Mar 2020 15:16:12 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=witbiSuG; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id XbCRxJPuXQ5k; Thu, 19 Mar 2020 15:16:12 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 48jpqJ3MwQz9tylr; Thu, 19 Mar 2020 15:16:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1584627372; bh=Pc3Zp6RcNRELIbFsuWJ1AM6GLwe8PYn9FEq9uPAl95M=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=witbiSuGtUsf6/uaua7yWVXOJbS3K3s19LwHJ9JIEjG9TYox//Q7derm/lVzUouGS Yj5gNuPEDsHe4FAQ33BTrYgOIiMAQWh8jIxC6TB4BwetAJcGyeRe4Hc9Vwhw0JNKKM Lxkmnh5GtFZhaVpmwNzVGksZvvkXH/Wd8I9w4JSg= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 6F38F8B84D; Thu, 19 Mar 2020 15:16:13 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id ukh2860n-fLR; Thu, 19 Mar 2020 15:16:13 +0100 (CET) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id CFEF08B850; Thu, 19 Mar 2020 15:16:10 +0100 (CET) Subject: Re: [PATCH v11 4/8] powerpc/perf: consolidate valid_user_sp To: Andy Shevchenko , Michal Suchanek Cc: "open list:LINUX FOR POWERPC PA SEMI PWRFICIENT" , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Alexander Viro , Mauro Carvalho Chehab , "David S. Miller" , Rob Herring , Greg Kroah-Hartman , Jonathan Cameron , Andy Shevchenko , Thomas Gleixner , Arnd Bergmann , Nayna Jain , Eric Richter , Claudio Carvalho , Nicholas Piggin , Hari Bathini , Masahiro Yamada , Thiago Jung Bauermann , Sebastian Andrzej Siewior , Valentin Schneider , Jordan Niethe , Michael Neuling , Gustavo Luiz Duarte , Allison Randal , "Eric W. Biederman" , Linux Kernel Mailing List , "linux-fsdevel @ vger . kernel . org --in-reply-to=" <20200225173541.1549955-1-npiggin@gmail.com> References: <1b612025371bb9f2bcce72c700c809ae29e57392.1584613649.git.msuchanek@suse.de> From: Christophe Leroy Message-ID: <8775f299-be1b-3457-c59d-e4f61d8223e5@c-s.fr> Date: Thu, 19 Mar 2020 15:16:03 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 19/03/2020 à 14:35, Andy Shevchenko a écrit : > On Thu, Mar 19, 2020 at 1:54 PM Michal Suchanek wrote: >> >> Merge the 32bit and 64bit version. >> >> Halve the check constants on 32bit. >> >> Use STACK_TOP since it is defined. >> >> Passing is_64 is now redundant since is_32bit_task() is used to >> determine which callchain variant should be used. Use STACK_TOP and >> is_32bit_task() directly. >> >> This removes a page from the valid 32bit area on 64bit: >> #define TASK_SIZE_USER32 (0x0000000100000000UL - (1 * PAGE_SIZE)) >> #define STACK_TOP_USER32 TASK_SIZE_USER32 > > ... > >> +static inline int valid_user_sp(unsigned long sp) >> +{ >> + bool is_64 = !is_32bit_task(); >> + >> + if (!sp || (sp & (is_64 ? 7 : 3)) || sp > STACK_TOP - (is_64 ? 32 : 16)) >> + return 0; >> + return 1; >> +} > > Perhaps better to read > > if (!sp) > return 0; > > if (is_32bit_task()) { > if (sp & 0x03) > return 0; > if (sp > STACK_TOP - 16) > return 0; > } else { > ... > } > > return 1; > > Other possibility: I prefer this one. > > unsigned long align = is_32bit_task() ? 3 : 7; I would call it mask instead of align > unsigned long top = STACK_TOP - (is_32bit_task() ? 16 : 32); > > return !(!sp || (sp & align) || sp > top); > Christophe