Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1122581yba; Wed, 24 Apr 2019 15:35:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqyYpKFidK/bdm+I0rgM0IfpOT22cF/xigzfiJyf6/TlXh4rWSlK0mO8U6h1bRjgn7hU6faU X-Received: by 2002:a17:902:a988:: with SMTP id bh8mr16277983plb.243.1556145333496; Wed, 24 Apr 2019 15:35:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556145333; cv=none; d=google.com; s=arc-20160816; b=1F2iaNbMkQzuwDsp37W7R7AdMspxn5XyBSOUmiPcte9U8W62p1ee24+sbhnePnHyzA Q1bbcwMi76xLjtSl2KK8uzzwVNXoitN73jmeSM9xB2wpOUfhyvkNlZXJMR1FNW2JbDPx rpmgp1ZdPNRnGbrA7UPVxP4OhurFzS6qVkMApd/AsuwhtSucoscxbzI1wgAqKXy6jp9h j/1C2skpM7CoPVKQBvvBOgbask3cB5//5rrIMXhgd1D7RdqXoTGECA+KLEmRAbA6XSKC R5rXcqtx0qz3xFiYKuhaQDDKHFrxmrpp5NVqTLL2nXuFtpuMWJxd1WADuVYiHe/8ZHQS 3gdw== 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; bh=HVRam6BHHZcxAmcTllBbGBM6GILzjxGdkxANGZ0igXg=; b=lxBBcecPfeqDLlqD4Q0/Mu5WpOQJuCxYMmWjyg30F1puqUe9CCACe01y8k6s8vX3Sj nM+A06BgN7M3Rj9QjcNbtx9FaNeY4AjS1ynag4Y9f52GqeIEcfqsltCOLrOUeUP26N4E gok9jZ/3IUntBw1DYgVR1iVRGEV8APObvmVV8Ybgrq5OwKX+lRTEH+wo+OSCZjKjcM0v 3vhCUoE0Jsg515goTjVl3qwcCtj6y4BKd/a+k3hlKMlxtGFJNK0Wan6uUvwkbpGv+t7f QOF4HThlgVKsxKJt5RDPyoRfLDJ7vd6Itnx4CBboMVJMHx8r75pr6pKwUWJ6nvvfQIbt TXFA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 4si20064663plh.289.2019.04.24.15.35.17; Wed, 24 Apr 2019 15:35: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; 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 S1731059AbfDXQUk (ORCPT + 99 others); Wed, 24 Apr 2019 12:20:40 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:48182 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726611AbfDXQUk (ORCPT ); Wed, 24 Apr 2019 12:20:40 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A2ED4A78; Wed, 24 Apr 2019 09:20:39 -0700 (PDT) Received: from [10.1.196.105] (eglon.cambridge.arm.com [10.1.196.105]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 33E3E3F557; Wed, 24 Apr 2019 09:20:38 -0700 (PDT) Subject: Re: [RFC PATCH 0/3] Enable kprobe to monitor sdei event handler To: Xiongfeng Wang Cc: huawei.libin@huawei.com, catalin.marinas@arm.com, will.deacon@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <1555070699-3685-1-git-send-email-wangxiongfeng2@huawei.com> From: James Morse Message-ID: Date: Wed, 24 Apr 2019 17:20:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <1555070699-3685-1-git-send-email-wangxiongfeng2@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Xiongfeng Wang, On 12/04/2019 13:04, Xiongfeng Wang wrote: > When I use kprobe to monitor a sdei event handler, Don't do this! SDEI is like an NMI, it isn't safe to kprobe it as it can interrupt the kprobe code, causing it become re-entrant. > the CPU will hang. It's > because when I probe the event handler, the instruction will be replaced with > brk instruction and brk exception is unmaskable. But 'vbar_el1' contains > 'tramp_vectors' in '_sdei_handler' when SDEI events interrupt userspace, so > we will go to the wrong place if brk exception happens. This was lucky! Its even more fun if the SDEI event interrupted a guest: the kvm vectors will give you a hyp-panic. The __kprobes and NOKPROBE_SYMBOL() litter should stop you doing this. > I notice that 'ghes_sdei_normal_callback' call several funtions that are not > marked as 'nokprobe'. Bother. We should probably blacklist those too, its not safe. > So I was wondering if we can enable kprobe in '_sdei_handler'. I don't think this can be done safely. If you need to monitor your SDEI event handler you can just use printk(). Once nmi_enter() has been called these are safe as they stash data in a per-cpu buffer. The SDEI handler will exit via the IRQ vector if it can, which will cause this buffer to be flushed to the console in a timely manner. Why do you need to kprobe an NMI handler? Thanks! James