Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2129438rwb; Fri, 11 Nov 2022 05:33:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf4JGDH9BmyaMS3lUKnPYAEoY8mzTejSD6kM7QbwYSja+92kOsX00GuoUy1nSZ1MIk2WtoQH X-Received: by 2002:a17:902:a414:b0:188:abcb:a0d9 with SMTP id p20-20020a170902a41400b00188abcba0d9mr1926921plq.146.1668173598804; Fri, 11 Nov 2022 05:33:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668173598; cv=none; d=google.com; s=arc-20160816; b=RtjOEdXTPcHwnvcY3iYznJ/Ut10mxdr8+akitsE8Ntx1qgcrX1JMf2Kkz+Vi6D1Etd wtTdbTTv2tRsDn8BGSLL7ccb3xSDh5vyHX0W13jSI5rmtMH5K7LsvJCTE4spl5sapVn/ 3rSKKhiKp0nxR91FpGRfwyB8kCDbg9T/rSUO7cYlr/pKkYV0Vl0pbvdM1DtELl/867Gj tJkIMu7w0hNponQl/8JFSzM1Dgp3VhMlRdGpRh1emjHPrOGBLHrCQ50p8zKQEEdN7Q5G JQZ5Gqwe5k1OBp2jazm9xMZKUx2thTPWxM6SrglOAkk+6c0H+LhWBT3jdcMlvTSN0WD8 CPmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=ajNQehgGzAdQRTIAlCOxMOqv02DUIADA/hE0i3TN+qw=; b=t7BkGfXQ+oo2znzDLdakz4YsTUhtpz61dBHqB/dsIrCR1H+GPiRdPcfe3kqSm/pl2E vu3TYDzaOiS/QsyDaCfho2p/jLq4KJ30I/su/d3wE2f1nJ392wuq+b6/zfQKtnj/YCwW 5gzPyg3XxoNR2wofAU2ZAgYAcqvLpzjmci0cOGTacW7N35Bpxd51fFBbsOcnHhYEZCzU 1FzqAObOP/e08cKjJdkceFxavAcy8vZ6mzjsJh/MNmi1a7lpJT7aL1APLhI8uLYYpS58 bKnnYN6ybs2qd0kn2RvX9FwfiFCeBKoa6Qaf6boDPp7q7lPD6sM6GIz3L5JXTDqOpCOr WelQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=G4zAcao9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q18-20020a170902dad200b0017c2a42fc8csi2595199plx.270.2022.11.11.05.33.06; Fri, 11 Nov 2022 05:33:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=G4zAcao9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233048AbiKKMHT (ORCPT + 92 others); Fri, 11 Nov 2022 07:07:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233943AbiKKMGo (ORCPT ); Fri, 11 Nov 2022 07:06:44 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D3EB8854B for ; Fri, 11 Nov 2022 04:04:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668168271; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ajNQehgGzAdQRTIAlCOxMOqv02DUIADA/hE0i3TN+qw=; b=G4zAcao9my71qD34yLpm7rO3l1SzeOvrqXm1qz8UToUnGJwNJltoeMoSsByoIXxgvNLly1 sWtccLkoeAgI6f/SCktXNq+zFNAsaaxlFQWyYaZs/SiciBXAJHVa3I5259b+ua0hpQ6ihG Phs8djkMKbQ5penm4mMUoOR6FkZNYXY= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-657-XmJcTN3nP3aM69vlnw-peQ-1; Fri, 11 Nov 2022 07:04:30 -0500 X-MC-Unique: XmJcTN3nP3aM69vlnw-peQ-1 Received: by mail-wr1-f71.google.com with SMTP id d23-20020adfa417000000b002364a31b7c9so960442wra.15 for ; Fri, 11 Nov 2022 04:04:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ajNQehgGzAdQRTIAlCOxMOqv02DUIADA/hE0i3TN+qw=; b=V5w3IgBp0P6SKr0L3NI8gr01SGcaiywabGgYtXQNaUpoZ+xH78/p7XlXm0RjIipXeu NTrJH7mIOn8mF6IO5naoL9i+bnfAq25TOHDbaYMgrkUh5amu2a9g/wPXip6d2WmgQSNX jJShyi9C40IasoahgcXzQoaDbRNoZiCZ3EUiZXkMmmHA84r3HOSM5h0oDb8QFimPhBrL /tunp6eLddiRdPfIEBAv7kBLOhTTfidB2kJ0JY+UJ3R5rrgQ4OFUHuRzsA/IPXmw5iqt I+zgclbNsOzzFtvlF8Hr4U8gfKpDFl6BoYxGegVUkWbhQ+0LQX/df6r1xaz2NCQhpsUb i7Aw== X-Gm-Message-State: ANoB5pnYK8QBL6zwTNPrVgmceGs4MBvbhFRsY6pAYdN9KsYuDbyxg83Q MlsR6Tgbm0jBnWZUfC5J6OTJXO/33dHAxLP+8hFM4lzRO0DiDzMJcniJMtibaiA9GK/c53h1SXh 21XKwZPBRAr+O21b40pRz5gcj X-Received: by 2002:a5d:4f0a:0:b0:22c:c2f0:5091 with SMTP id c10-20020a5d4f0a000000b0022cc2f05091mr1052087wru.403.1668168269032; Fri, 11 Nov 2022 04:04:29 -0800 (PST) X-Received: by 2002:a5d:4f0a:0:b0:22c:c2f0:5091 with SMTP id c10-20020a5d4f0a000000b0022cc2f05091mr1052071wru.403.1668168268813; Fri, 11 Nov 2022 04:04:28 -0800 (PST) Received: from ?IPV6:2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e? ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.googlemail.com with ESMTPSA id n3-20020a05600c4f8300b003a8434530bbsm9193165wmq.13.2022.11.11.04.04.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Nov 2022 04:04:28 -0800 (PST) Message-ID: <6097036e-063f-5175-72b2-8935b12af853@redhat.com> Date: Fri, 11 Nov 2022 13:04:27 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [RESEND PATCH 5/6] KVM: x86/VMX: add kvm_vmx_reinject_nmi_irq() for NMI/IRQ reinjection Content-Language: en-US To: Peter Zijlstra , "Li, Xin3" Cc: "linux-kernel@vger.kernel.org" , "x86@kernel.org" , "kvm@vger.kernel.org" , "tglx@linutronix.de" , "mingo@redhat.com" , "bp@alien8.de" , "dave.hansen@linux.intel.com" , "hpa@zytor.com" , "Christopherson,, Sean" , "Tian, Kevin" References: <20221110061545.1531-1-xin3.li@intel.com> <20221110061545.1531-6-xin3.li@intel.com> From: Paolo Bonzini In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/11/22 10:15, Peter Zijlstra wrote: > I don't speak virt (but this all sounds disguisting) Yes, it is. AMD does not need this, they just hold onto the interrupt until the host has issued both STGI (for NMIs) and STI (for IRQs). On Intel you can optionally make it hold onto IRQs, but NMIs are always eaten by the VMEXIT and have to be reinjected manually. > -- but what appears to be the case is you calling into entry code > from regular kernel context, which is odd at best. > > Specifically, going by the fact that all this is not noinstr code, > the assumption is that RCU/lockdep/etc.. is all set-up and running. Indeed it is. This is called long after the noinstr area has been left: vcpu_enter_guest ... static_call(kvm_x86_vcpu_run) -> vmx_vcpu_run vmx_vcpu_enter_exit (noinstr) guest_state_enter_irqoff __vmx_vcpu_run guest_state_exit_irqoff ... static_call(kvm_x86_handle_exit_irqoff) -> vmx_handle_exit_irqoff handle_external_interrupt_irqoff ... Paolo > This means you should not be calling DEFINE_IDTENTRY_*(func) > functions because those will try and set all that up again. > > Granted, irqentry_{enter,exit}() do nest, but*yuck*.