Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp369271ybh; Wed, 15 Jul 2020 04:16:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWc9qjWT3J7Mxsoh2saoElTsyhcbPr2j2rpyLVdTMCquQV54AOptiR8cX3MKawDYfH8G1O X-Received: by 2002:a05:6402:b10:: with SMTP id bm16mr9357244edb.92.1594811813255; Wed, 15 Jul 2020 04:16:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594811813; cv=none; d=google.com; s=arc-20160816; b=AkwSLAySSFCjZujS5b8qlYj671HvM5vggJELEYU0Hoy5XQraZYuVUiAZ4jp3TT0c1O S4NBuB9nskbsRz8MX+Hj/oE3hzuNo7QOJdC5SoYe9ytjYevA2dcUYLLO0eP8X76CNXYV vfCIgxN0ay6e6Gt5jMgfLtdjAeAFBk0f56WYOjvZXANLjwtKAjFfFHNEYW/OGfwBO/Wd gOM9qVoxi8UueelhWSlM3ssRpCy0x1fdxwH7QayX+av1q9fW3TzVCOuSrbTc/zGIarAU HYbfnF2hj+z51mDsFDG+qD8UeckgQJujFjRWvACGjfwErr3MM0aoD4ROJjvJ+DE9TKTW SUbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=B3ZNXMdtzOl2XokoISBREh8d9nxYCRmNefNrJYQQBSo=; b=Sl34FD7Hgo5K53BOzTVg1Yev0CL/l0fENkDx/grV2Mv9QIzEYaLhzE7nW0AhBxQ1rK QW7HjEmGUYBzSfko4LENAf3f0Uxwo1jHnFm2cR8i1hlbZySnbnEXiFR3IzsVIahYG2uf X1Iir+WBcmvLx9/l0tGsljRie5xAe0M5dSMP8c49JFMERSbrGkBIMOR9qyWdrJxkYOWE d/wHW7RviFf1vK/Io/QFS6E9C4qp3PpMwwWL0eXzrLYyXJAg6LA1iGH9HBRJWVJjDcAM 2pPX5eaSZWy/gAFg360NUQKYxnx8AMT5mPQGDs37peFsCby8KglRyvWbP7Pc35k0zgVz Vv7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=oOXeAQid; 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 t8si1040543ejs.72.2020.07.15.04.15.56; Wed, 15 Jul 2020 04:16:53 -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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=oOXeAQid; 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 S1730852AbgGOJvx (ORCPT + 99 others); Wed, 15 Jul 2020 05:51:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730000AbgGOJvx (ORCPT ); Wed, 15 Jul 2020 05:51:53 -0400 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC46FC061755; Wed, 15 Jul 2020 02:51:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=B3ZNXMdtzOl2XokoISBREh8d9nxYCRmNefNrJYQQBSo=; b=oOXeAQidbZzyeFE7UCspW3f0W4 m/ZqHaKOVyZU8GAiIVD/XTz1oC1UtT6Uct1DxIuhk+QPUKXVLxCvDYtgYxRRYvVs6QmHhBp0iexPP aQW5P9xuX40hne6bOHhDOckCvOT1dHZnfrmtOu8jvk8GL0CHPWwoOpDHJy7QMjliPOex2KX6XaFfb FQt8+A49iiYfOkZNp3ScqoSUXajHVGSPqZwYtOPnECivFAM2uMjf/iDKcQbzKM8/MMP2sDK7RaKpw n2LYSmhZGN7Pq8tS0xmFttoaQaO8EXQ1k+K9IOf8wshHtE36RNC6oYGijMMSpXyDHLq5NKaH5fAgq 29Nm+15w==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jve4i-0000jr-Gx; Wed, 15 Jul 2020 09:51:40 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id B344B3028C8; Wed, 15 Jul 2020 11:51:36 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 9CC92203A5F41; Wed, 15 Jul 2020 11:51:36 +0200 (CEST) Date: Wed, 15 Jul 2020 11:51:36 +0200 From: Peter Zijlstra To: Joerg Roedel Cc: Joerg Roedel , x86@kernel.org, hpa@zytor.com, Andy Lutomirski , Dave Hansen , Jiri Slaby , Dan Williams , Tom Lendacky , Juergen Gross , Kees Cook , David Rientjes , Cfir Cohen , Erdem Aktas , Masami Hiramatsu , Mike Stunes , Sean Christopherson , Martin Radev , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH v4 63/75] x86/sev-es: Handle #DB Events Message-ID: <20200715095136.GG10769@hirez.programming.kicks-ass.net> References: <20200714120917.11253-1-joro@8bytes.org> <20200714120917.11253-64-joro@8bytes.org> <20200715084752.GD10769@hirez.programming.kicks-ass.net> <20200715091337.GI16200@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200715091337.GI16200@suse.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 15, 2020 at 11:13:37AM +0200, Joerg Roedel wrote: > On Wed, Jul 15, 2020 at 10:47:52AM +0200, Peter Zijlstra wrote: > > On Tue, Jul 14, 2020 at 02:09:05PM +0200, Joerg Roedel wrote: > > > > > @@ -1028,6 +1036,16 @@ DEFINE_IDTENTRY_VC_SAFE_STACK(exc_vmm_communication) > > > struct ghcb *ghcb; > > > > > > lockdep_assert_irqs_disabled(); > > > + > > > + /* > > > + * #DB is special and needs to be handled outside of the intrumentation_begin()/end(). > > > + * Otherwise the #VC handler could be raised recursivly. > > > + */ > > > + if (error_code == SVM_EXIT_EXCP_BASE + X86_TRAP_DB) { > > > + vc_handle_trap_db(regs); > > > + return; > > > + } > > > + > > > instrumentation_begin(); > > > > Wait what?! That makes no sense what so ever. > > Then my understanding of intrumentation_begin/end() is wrong, I thought > that the kernel will forbid setting breakpoints before > instrumentation_begin(), which is necessary here because a break-point > in the #VC handler might cause recursive #VC-exceptions when #DB is > intercepted. > Maybe you can elaborate on why this makes no sense? Kernel avoids breakpoints in any noinstr text, irrespective of instrumentation_begin(). instrumentation_begin() merely allows one to call !noinstr functions.