Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1238988ybm; Sat, 30 May 2020 02:59:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvt42WakyBIrAnv0oB4uyRenV48ecOxV5CfLds9MFy9JdfWXWVmjev5KfqS7H7yPpBmRwT X-Received: by 2002:a17:906:5e08:: with SMTP id n8mr11460828eju.132.1590832788853; Sat, 30 May 2020 02:59:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590832788; cv=none; d=google.com; s=arc-20160816; b=UUqAJdOQg2eoCir2pbDOS9pbgs2hQoZcbwHLktYLG4gFVISBrfcH/zaKQqcWG4vGHX KTG0yCTxhwmS3cKWpA9fgqbschASJAPZQ/DQbxz5ZFSkFv5s7yGsXCk9ufw5wakwyVTu 6GpFw/vegHnC8sfCQ4mVcHvIr+83isCxDYoJSvzPF1wMY4/kL6T8slQAOvxRgmQgUXDD IngFvbf8nd4o/JJylmL7wsDKpxuBa7FCUUoX/hMnFIBF9LgdURCAEKUM14YkYbbwoHK2 8oKA1wyhkmzYl+qzf865wvhJdmrp//8NeH+mHNL4PDMNEU3LVxZHCnyPpkynagkZhETm P2FQ== 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 :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=2O6PFVAMLNIahOhU2VW+2GS8JeiWeixsY+mPlgfzXjU=; b=jlyS23qQfMuEhV10dD/ofNpHWHsDFl8/nZJKvjy/J9As5n02yty5rm5CnDb9DvVVt6 iy7iiyIlDvm+54NxbYajwgxYMR0I7LEhRbtAbniT2vHvOi3D6vvWBzLqEYka9DkGZVE4 K3TJn3xLBjkn09c69MufJLAkNNbcGI7wQ8qOVwfmVkEf8ASSJUe18OJJrQXgJyTxtYUJ gYb7zScxQw3fxXw6ofPqINWjSN6wmryAMShWAF6D1ybceU/0jyOjU2ylSRBsULzbHH/p sra8pBGE5CZ9kMbNXojiYHGy4PiZdqOTqkht2yT28IMo4xVdzvb3GsoVjZHjCtcdcF5b 6cQA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l20si7408422eji.236.2020.05.30.02.59.26; Sat, 30 May 2020 02:59:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728998AbgE3J5f (ORCPT + 99 others); Sat, 30 May 2020 05:57:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728967AbgE3J5a (ORCPT ); Sat, 30 May 2020 05:57:30 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73864C08C5C9; Sat, 30 May 2020 02:57:30 -0700 (PDT) Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jeyF2-0002sy-7B; Sat, 30 May 2020 11:57:24 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 9A60A1C04D6; Sat, 30 May 2020 11:57:23 +0200 (CEST) Date: Sat, 30 May 2020 09:57:23 -0000 From: "tip-bot2 for Lai Jiangshan" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/entry] x86/hw_breakpoint: Add within_area() to check data breakpoints Cc: Lai Jiangshan , "Peter Zijlstra (Intel)" , Thomas Gleixner , x86 , LKML In-Reply-To: <20200526014221.2119-2-laijs@linux.alibaba.com> References: <20200526014221.2119-2-laijs@linux.alibaba.com> MIME-Version: 1.0 Message-ID: <159083264350.17951.12589206057870235057.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/entry branch of tip: Commit-ID: 83f7a80367e99cca0023be95538635abacec07ae Gitweb: https://git.kernel.org/tip/83f7a80367e99cca0023be95538635abacec07ae Author: Lai Jiangshan AuthorDate: Fri, 29 May 2020 23:27:29 +02:00 Committer: Thomas Gleixner CommitterDate: Sat, 30 May 2020 10:00:05 +02:00 x86/hw_breakpoint: Add within_area() to check data breakpoints Add a within_area() helper to checking whether the data breakpoints overlap with cpu_entry_area. It will be used to completely prevent data breakpoints on GDT, IDT, or TSS. Signed-off-by: Lai Jiangshan Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Thomas Gleixner Link: https://lkml.kernel.org/r/20200526014221.2119-2-laijs@linux.alibaba.com Link: https://lkml.kernel.org/r/20200529213320.784524504@infradead.org --- arch/x86/kernel/hw_breakpoint.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/hw_breakpoint.c b/arch/x86/kernel/hw_breakpoint.c index 9ddf441..c149c7b 100644 --- a/arch/x86/kernel/hw_breakpoint.c +++ b/arch/x86/kernel/hw_breakpoint.c @@ -228,13 +228,22 @@ int arch_check_bp_in_kernelspace(struct arch_hw_breakpoint *hw) } /* + * Checks whether the range [addr, end], overlaps the area [base, base + size). + */ +static inline bool within_area(unsigned long addr, unsigned long end, + unsigned long base, unsigned long size) +{ + return end >= base && addr < (base + size); +} + +/* * Checks whether the range from addr to end, inclusive, overlaps the CPU * entry area range. */ static inline bool within_cpu_entry_area(unsigned long addr, unsigned long end) { - return end >= CPU_ENTRY_AREA_BASE && - addr < (CPU_ENTRY_AREA_BASE + CPU_ENTRY_AREA_TOTAL_SIZE); + return within_area(addr, end, CPU_ENTRY_AREA_BASE, + CPU_ENTRY_AREA_TOTAL_SIZE); } static int arch_build_bp_info(struct perf_event *bp,