From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C19D3C4743D for ; Tue, 8 Jun 2021 12:00:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A4C0B6124C for ; Tue, 8 Jun 2021 12:00:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232376AbhFHMCc (ORCPT ); Tue, 8 Jun 2021 08:02:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232134AbhFHMCa (ORCPT ); Tue, 8 Jun 2021 08:02:30 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D391C061574; Tue, 8 Jun 2021 05:00:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=DycXleRZZakhNiWk5mkor9tyBuVnVqL3f4nz52Lyagk=; b=irluC+5RhkL+SPw7n56VFsnUa3 A6KF3/s55ZYxA0h5WQdhlc9VxpnlqkRu8nOP51S/dNz3A31rBJK6S9oxeXGYaBp6omXkVTaJtnaPw sA1CuBszTSMZ3el0Og5AtmMUvXw9lHXRA54lx5KW7ZWSbHHNWG26SdVzjtdysBJ8qwWorblycsHxN KhZg4ubvQ5PehEEmgLmsFlvxhCaqrZc9CbL+PnsrR/1+U96Fd3vRr5MZ1qfG9jrGeGPfTFHGnjecO zmVJFh+nFBQ4uPBzaNuwZQj30AOVpu0rSVoXC11jIOWeScueEcUp1GtrrMROKzQ31brpts3R0AhuL +n5P3vXg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lqaNc-00Gu7t-CN; Tue, 08 Jun 2021 11:58:53 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 34544300258; Tue, 8 Jun 2021 13:58:47 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 1DF2722B9AE15; Tue, 8 Jun 2021 13:58:47 +0200 (CEST) Date: Tue, 8 Jun 2021 13:58:47 +0200 From: Peter Zijlstra To: Joerg Roedel Cc: x86@kernel.org, Joerg Roedel , 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 , Arvind Sankar , linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH v3 4/7] x86/sev-es: Run #VC handler in plain IRQ state Message-ID: References: <20210608095439.12668-1-joro@8bytes.org> <20210608095439.12668-5-joro@8bytes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210608095439.12668-5-joro@8bytes.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 08, 2021 at 11:54:36AM +0200, Joerg Roedel wrote: > From: Joerg Roedel > > Use irqentry_enter() and irqentry_exit() to track the runtime state of > the #VC handler. The reason it ran in NMI mode was solely to make sure > nothing interrupts the handler while the GHCB is in use. > > This is handled now in sev_es_get/put_ghcb() directly, so there is no > reason the #VC handler can not run in normal IRQ mode and enjoy the > benefits like being able to send signals. You sure? So #VC cannot happen with IRQs disabled? raw_spin_lock_irq(&my_lock); <#VC> raw_spin_lock_irqsave(&my_lock); // whoopsie Every exception that can happen with IRQs disabled must be NMI like. Again, what you seem to want is to split the handler in a from-user and from-kernel way, just like we did with #DB and MCE. See how exc_debug_user() is IRQ-like and can send signals, while exc_debug_kernel() is NMI like and can not.