Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2229467imm; Fri, 7 Sep 2018 12:53:37 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYkSa8ghPoN1sbYpFNoDi5AxUTIrValR94oLJ246pK/43ZdNLDzMHut00BwWWd+37g61x8D X-Received: by 2002:a62:5d89:: with SMTP id n9-v6mr10450401pfj.102.1536350016994; Fri, 07 Sep 2018 12:53:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536350016; cv=none; d=google.com; s=arc-20160816; b=S71iuZihEr6T5SEM24YIHQQZFdgR30K4ThT3ZmVICgJq3xE7N93jc89gtelI5Sezm+ h/vtlCQ/RI4HEgTArDBNWRF0xY0pEWLPLhyVpwM+5ILJuZAytwR6rxv97NiwaLGAw0KJ Z/Fpi+h+AfnNS9XqEWCWPZOLiGf30SrCZ5beUEQDrE7y5Dfrh6YYpY4k8IrzmYY1sFUy 99NDpD6IgqWJv/k9x1I2i8JQ9Hv7Da18ZSqVXtP7UsH+OpHMVahcG+XfCvjQyf/6CIsW VEWsTyEB/sKs4smIiQ49pzXOlafgusLKVtSc6gBY3G44fmeQwZmNcvxHOOUAi2Kr6aQB Bwbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:in-reply-to:references:date :from:cc:to:subject; bh=WOYB8+A+JK1wihnLHwfb3A92vXicKAkN5jXt5odTmDI=; b=vEZmiGmiUSq5rv2XCGjKmhNrC1nF43YY3m6R2o4cszFF0rJkHz5tBkPxos8AKff8hy 5hw6MHVh8i6ygw+XIM5ZUIKrriEsiZYu5HpgcTFG+qFhr8T3cCeQuwhkCM/cshMpch8a gOYKpywdYbRUwCsZjI3TgElfHY9VQOWk3rPZ4BsBaVfmd2bW9zjxuMrWpoMagwsKtDW1 7GiB74jh2SamJbAvN7DHpTqvOVcwmEf/obKjN/V1TYxUAXYp7cjZs5oINz6nJVwQb2tN /Jy42825Kg0nTPJzqU2jH+UwxnJV+zIwGZuZIze6ZYa6Ag8fEtC+AHBKVwsf7ZJaBycP wFrQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a27-v6si9624786pfg.200.2018.09.07.12.53.22; Fri, 07 Sep 2018 12:53:36 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727641AbeIHAeL (ORCPT + 99 others); Fri, 7 Sep 2018 20:34:11 -0400 Received: from mga07.intel.com ([134.134.136.100]:61683 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725987AbeIHAeA (ORCPT ); Fri, 7 Sep 2018 20:34:00 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Sep 2018 12:51:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,343,1531810800"; d="scan'208";a="81760045" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by orsmga003.jf.intel.com with ESMTP; 07 Sep 2018 12:51:32 -0700 Subject: [RFC][PATCH 6/8] x86/mm: add vsyscall address helper To: linux-kernel@vger.kernel.org Cc: Dave Hansen , sean.j.christopherson@intel.com, peterz@infradead.org, tglx@linutronix.de, x86@kernel.org, luto@kernel.org From: Dave Hansen Date: Fri, 07 Sep 2018 12:49:01 -0700 References: <20180907194852.3C351B82@viggo.jf.intel.com> In-Reply-To: <20180907194852.3C351B82@viggo.jf.intel.com> Message-Id: <20180907194901.C54A0101@viggo.jf.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Hansen We will shortly be using this check in two locations. Put it in a helper before we do so. Signed-off-by: Dave Hansen Cc: Sean Christopherson Cc: "Peter Zijlstra (Intel)" Cc: Thomas Gleixner Cc: x86@kernel.org Cc: Andy Lutomirski --- b/arch/x86/mm/fault.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff -puN arch/x86/mm/fault.c~is-vsyscall-addr arch/x86/mm/fault.c --- a/arch/x86/mm/fault.c~is-vsyscall-addr 2018-09-07 11:21:48.208751897 -0700 +++ b/arch/x86/mm/fault.c 2018-09-07 11:21:48.211751897 -0700 @@ -841,6 +841,15 @@ show_signal_msg(struct pt_regs *regs, un show_opcodes((u8 *)regs->ip, loglvl); } +/* + * 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; +} + static void __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code, unsigned long address, u32 *pkey, int si_code) @@ -870,7 +879,7 @@ __bad_area_nosemaphore(struct pt_regs *r * emulation. */ if (unlikely((error_code & X86_PF_INSTR) && - ((address & ~0xfff) == VSYSCALL_ADDR))) { + is_vsyscall_vaddr(address))) { if (emulate_vsyscall(regs, address)) return; } _