Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp1628070ybs; Mon, 25 May 2020 22:51:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMnlsNqNK01l57W4H6b8AiBmTIa8gVcI4EVkxSKESKWbamypiWaRoFI2dvb5jtT5hXUJsl X-Received: by 2002:a17:906:6a43:: with SMTP id n3mr20591427ejs.33.1590472305891; Mon, 25 May 2020 22:51:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590472305; cv=none; d=google.com; s=arc-20160816; b=AxBzECDCaUMRdaWLsrGdW0o+SLbEjKysOz36kmvnXFI4pbOkmtKA9VtoqdzqGZShZX R/jul8Dq8MKrc0T6H7lwWcBZnQDytffclnV9rKUMOhhS3H2FZGnR8fWtP3oGeXg4vgH+ Lvv43RiQlBS2bLglio1CdDdMEdqFNZv+PTWIgoee5FJTfFg4m4LY+2clEg4WQqAqlR6C 3z8jBM+/SPl5Pbn+ZNRRdp2f92Z3EC9uQuCCD5zhZv5cN2590xrOd9UH0Q4vZA8CNpdU F5V1fxyHTuqxc/WMal0CN5BDaL9/xoLoEn/nuA1e+PT6mLd0I0p5SJBgP3qKbFrS8zYf E2jQ== 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=Fz1Eopb4QzL9a1RDMtAXkS7GQciMYbTyetHx6VLS6qU=; b=xC+WeOgdeZ9WDqO164jgqEc5e+OCGB/mVr0N4aeoHRPrSsqHAe3Qo6awZiQWaWYmz2 SG4vDPqnfMWHCKf+zfEdfyrVbFRfNsKxqjirT6XM6O4Ae8VT7wZvi4BC0rcwFWoMlK6e OjDK2hhfa0N6bDi1dpOBT1+I7tDEEx75/u3TMV/ogNaIBZIZx6WN+1uIAo0arly+o20y XihK/MrKtzK8DmT6xBSf4lYEcSjLtg/F3L578JLhC6wbt9fwdpz6x8+XRXj+HxgZEr0R 5b5KfNAJsW+Fo43fC9o9G4svVCylfzMNzH3UykGGxHFFc0oQnJTnfLaesUEUS+SMGByb eNkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bSWKVcWy; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s10si10487629ejq.400.2020.05.25.22.51.22; Mon, 25 May 2020 22:51:45 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bSWKVcWy; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726641AbgEZFsd (ORCPT + 99 others); Tue, 26 May 2020 01:48:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725771AbgEZFsc (ORCPT ); Tue, 26 May 2020 01:48:32 -0400 Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F904C061A0E for ; Mon, 25 May 2020 22:48:32 -0700 (PDT) Received: by mail-io1-xd41.google.com with SMTP id d5so11186604ios.9 for ; Mon, 25 May 2020 22:48:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Fz1Eopb4QzL9a1RDMtAXkS7GQciMYbTyetHx6VLS6qU=; b=bSWKVcWyRcVadh6xJDKKh5NcyUDyIUatsXrN3uwZO93tiW+44TeAMr1QvUFoho3Bra l3p6jsfyVsH5dyGIQGkyLSZDQ91E1rVnGDfxlhwNufAiymLRTSKzNv2jeHTVYfsEJjQo tb9dei5XqMrfgODNLbke4m2tS3g24QL68T6gSQ919xI+VY5WkG/jYGR8yCgIKrr8bktl eq4LyBGnr8oEPJe5tKNhraMmfjS+63AfosiLtrwV0d0QI0Wu7PuUF14yqnsp+mq/J8PE TD86d2SumMfkjYR3QigDqrFVmCiqWqin9BUccoVmIk0PVfB+OKjAnzyejaplsavDbSM/ 9aqw== 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=Fz1Eopb4QzL9a1RDMtAXkS7GQciMYbTyetHx6VLS6qU=; b=CwWSmnkf4Tqk7b8KL6uWla4nrbJ8x2/UZNGTi1KYgLPUWt0/7gSDqcCwgV4reMArSt 8J+D8DzzVYk5P07lqn6MdZTltRr2HH40VlXHB5UMWgPlta1LlQWLlxW9l402ZciGy+Ut iSAW9N/1UNBm9wxWu7Sceo+2G/vki6KYjh/+TRW3BRslEYn9UM3O+EWmcL1xWjbK1r5y 6A+HudMNWfSFt6fuGIM0nnS9gl+AklBVGAqAtS6AjKXQBEsZ44gPpi6S4E9orXxb7Nvq QYp+e8VK2CXyeVno3gdfB97GTOzZ7ajoxxxyrK3tngBFaB7KMnyMpn6LdQ06gLzNTVUY zhBA== X-Gm-Message-State: AOAM530DWTKyGzYoxC52O+4qeILHp3s7AQaj+WGy3hYouFCx3ltRZxFL Qf4KbeUi3AE38PlXeb4ZhDJZbx/ccu6XJorh9Xk= X-Received: by 2002:a02:6d46:: with SMTP id e6mr13489853jaf.43.1590472111699; Mon, 25 May 2020 22:48:31 -0700 (PDT) MIME-Version: 1.0 References: <20200525152517.GY325280@hirez.programming.kicks-ass.net> <20200526014221.2119-1-laijs@linux.alibaba.com> <20200526014221.2119-5-laijs@linux.alibaba.com> In-Reply-To: From: Lai Jiangshan Date: Tue, 26 May 2020 13:48:20 +0800 Message-ID: Subject: Re: [RFC PATCH V2 4/7] x86/hw_breakpoint: Prevent data breakpoints on user_pcid_flush_mask To: Andy Lutomirski Cc: Lai Jiangshan , LKML , Peter Zijlstra , Thomas Gleixner , X86 ML , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Alexandre Chartre , Steven Rostedt , Masami Hiramatsu 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 Tue, May 26, 2020 at 12:39 PM Andy Lutomirski wrote: > > On Mon, May 25, 2020 at 9:31 PM Lai Jiangshan > wrote: > > > > On Tue, May 26, 2020 at 12:21 PM Andy Lutomirski wrote: > > > > > > On Mon, May 25, 2020 at 6:42 PM Lai Jiangshan wrote: > > > > > > > > The percpu user_pcid_flush_mask is used for CPU entry > > > > If a data breakpoint on it, it will cause an unwanted #DB. > > > > Protect the full cpu_tlbstate structure to be sure. > > > > > > > > There are some other percpu data used in CPU entry, but they are > > > > either in already-protected cpu_tss_rw or are safe to trigger #DB > > > > (espfix_waddr, espfix_stack). > > > > > > How hard would it be to rework this to have DECLARE_PERCPU_NODEBUG() > > > and DEFINE_PERCPU_NODEBUG() or similar? > > > > > > I don't know, but it is an excellent idea. Although the patchset > > protects only 2 or 3 portions of percpu data, but there is many > > percpu data used in tracing or kprobe code. They are needed to be > > protected too. > > > > Adds CC: > > Steven Rostedt > > Masami Hiramatsu > > PeterZ is moving things in the direction of more aggressively > disabling hardware breakpoints in the nasty paths where we won't > survive a hardware breakpoint. Does the tracing code have portions > that won't survive a limited amount of recursion? Agree, after "aggressively disabling hardware breakpoints in the nasty paths", only percpu data used by entry code needs to be protected, even non-instrumentable percpu data used by nmi_enter() doesn't need to be marked protected, because #DB is disabled. Only percpu data used by entry code in ranges that #DB is not disabled needs to be protected, there are only a small number of portions, I don't think we need DECLARE_PERCPU_NODEBUG() or so for merely 2 or 3 portions of data. This patchset is sufficient. (espfix_waddr, espfix_stack are not counted into, which needs more review besides me) > > I'm hoping that we can keep the number of no-breakpoint-here percpu > variables low. Maybe we could recruit objtool to help make sure we > got all of them, but that would be a much larger project. > > Would we currently survive a breakpoint on the thread stack? I don't > see any extremely obvious reason that we wouldn't. Blocking such a > breakpoint would be annoying.