Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp118478imm; Fri, 7 Sep 2018 17:48:33 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZVVpC4XLQWDgt62gFOEbjKss2nL3OrrvJx9fIw7m9VTwg9h2N4n+Y+7RdIxzOYwLJOsfjo X-Received: by 2002:a63:904a:: with SMTP id a71-v6mr10816020pge.339.1536367713673; Fri, 07 Sep 2018 17:48:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536367713; cv=none; d=google.com; s=arc-20160816; b=LMEBiQk0rStYTZswqEFhnfOxD3IkmSnNX26fxpLAbDPu/XPSSbByQonM8cjQTXqUMR fYAvjG0+XKInTXHXQtHXhAYso7vUR/eK36ZuMAr05WviWkf3hcn5N/3hizKfzRWosQ2x tfbuMOfkxztplB3e0ZOvHsTbOhD7+O9zqBMLGmTw60wnzgPKrd69yV4awkJRl/4xaamD RtrfceVOMc7xtCH0ugeeaNtt0OVk4QDRnOVMmmoSc1Rw93ZZA+Ar6FpUv6YD3o6adCK8 Z6L9SfVifb0AFK8aCtMD8fdIKP5+++SsxYjkKqbj3BzR1DYU9kEoRIICkNGBHBs0Hj5v PFsw== 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:dkim-signature; bh=YouB2dXJf1Q+PNgUYnLSk3Ac8HJVjkZuxxNPGCrG8hI=; b=Qd61Ar0EOOXr25H8nfH+gynYwXDyWqZQiNJMf3d140ftCJQKEaxOGL+TVAiBg/9/En WCmQiCIQcEy77v8JOb4CLraLjJnlOub/f7JVFQQLrY0GgzhjoktPPWXjFKfmPYi+kts+ YxojdQbfkwPV40UwRETCALbeoadDb/hFs7swog8OmUVk/RpagUwASu8s0xanHj/nTrAQ ewgM1JLVPd4Xh5i7T6UzKTB4LexVrOi4Tx0KinjPQSX79p4F4vqbJbepYB9aeViNNcua xl/Hq6KckFIhpkJveBY3+R83twIjI5n9emm9bbqKUodamWfNoLIfDYj/Lmt1AnaiBC+E fOYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=sWN4Qj6l; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i64-v6si10563170pfb.314.2018.09.07.17.48.15; Fri, 07 Sep 2018 17:48:33 -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=@google.com header.s=20161025 header.b=sWN4Qj6l; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726190AbeIHFaf (ORCPT + 99 others); Sat, 8 Sep 2018 01:30:35 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:32850 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725731AbeIHFaf (ORCPT ); Sat, 8 Sep 2018 01:30:35 -0400 Received: by mail-oi0-f68.google.com with SMTP id 8-v6so30500000oip.0 for ; Fri, 07 Sep 2018 17:47:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YouB2dXJf1Q+PNgUYnLSk3Ac8HJVjkZuxxNPGCrG8hI=; b=sWN4Qj6llDbbCBe2yFY3EAzw4ybI3dGd7rESqU0bPCq1kLz6wNga5iQkjrr6Yl689Q 2ewTH3PhZcZrEsEjahQ2PVZf5soztu1MGLQ9BzBxrXu/kaaxgLmuK4l3KfswVjCcDhqH Bp1QvCg/8DFMOI8LuikxqiFOoMs8JmzrEqg/zT9l2DQTh8226jmxPGZzpNbLzXm1Owzw kfgLlcnehsdW3NlOy7T5vc1RDHbXR5AcoiKb7n9fr//BigKjBrYyhG9uGZ+adyPGhqg5 jVwl6if9GtUIvWvGGzH38a10jpGGVoJOYgChuTZ9XySuZtqrxkBhYptyZubujELzzG0b 2QdA== 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=YouB2dXJf1Q+PNgUYnLSk3Ac8HJVjkZuxxNPGCrG8hI=; b=POVB4GD3+zH2A+QOCGyZYiFRpYfo/u+8pjA3CITikEp03ti0/3fvJjQrnHBHpnR6mV r/Suy5BQNOEinIRSpLnaMHtRgnjzei/vkQNTQ/IBlwehNfZJfrxyEwAzSCVi5hVBZdNy S3Z6dhSqRbtuaTAfYzcM/FryXpTaNmM3y/lDaOendthT6DJm0/ciLo0gOqoH7/1h+Sh1 F2Xq/e2HJzidJ/Nkl2Fu8bpKBx9v27QiGl3V+3Z+RLC54PZy12EgI7mYue2N9kJhuDIz 8wDicJzEEuqRrwUNVGT/jWGTjrvFPlhaiUq+T4a6g84XG99u7dzIRvt6hY57rGZkGrN5 EvIw== X-Gm-Message-State: APzg51AB+AAE8efNQ5xJg0B4cgU0FODGA7gFYKXxTvJ9aCOfQxKD25o6 Yr5uZdlZlpFkpl5eyZuDQlPFcrSsfpBaoqGOqlhwag== X-Received: by 2002:aca:4204:: with SMTP id p4-v6mr9997436oia.242.1536367622774; Fri, 07 Sep 2018 17:47:02 -0700 (PDT) MIME-Version: 1.0 References: <20180907194852.3C351B82@viggo.jf.intel.com> <20180907194901.C54A0101@viggo.jf.intel.com> In-Reply-To: <20180907194901.C54A0101@viggo.jf.intel.com> From: Jann Horn Date: Sat, 8 Sep 2018 02:46:35 +0200 Message-ID: Subject: Re: [RFC][PATCH 6/8] x86/mm: add vsyscall address helper To: Dave Hansen Cc: kernel list , sean.j.christopherson@intel.com, Peter Zijlstra , Thomas Gleixner , "the arch/x86 maintainers" , Andy Lutomirski 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 Sat, Sep 8, 2018 at 2:25 AM Dave Hansen wrote: > We will shortly be using this check in two locations. Put it in > a helper before we do so. [...] > +/* > + * The (legacy) vsyscall page is the long page in the kernel portion > + * of the address space that has user-accessible permissions. > + */ > +static bool is_vsyscall_vaddr(unsigned long vaddr) > +{ > + return (vaddr & ~0xfff) == VSYSCALL_ADDR; > +} Since you're touching this code anyway: Would it make sense to change that constant to a more explicit "~0xfffUL" (or alternatively PAGE_MASK)? I tend to end up staring at code like this forever, trying to figure out whether the upper 32 bits of the constant end up being set or clear. As a reader, looking at the current code, it's quite annoying to see what actually happens - first there's a signed 32-bit literal 0xfff, then a 32-bit negation happens, and then the number is converted to 64 bits with sign extension.