Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp910017iob; Thu, 28 Apr 2022 13:36:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxqJqnI023D7wdqYlty9okE2QJVhTIUFzC8ltJyINXde5PnL10U2pmozKSyKrGOYtUC7ER X-Received: by 2002:a2e:a54c:0:b0:24f:27ad:8035 with SMTP id e12-20020a2ea54c000000b0024f27ad8035mr7655664ljn.334.1651178163713; Thu, 28 Apr 2022 13:36:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651178163; cv=none; d=google.com; s=arc-20160816; b=qayVLNIMz66d49WoEfpLM3Ay6Hqaux6wDeDfF6DmbnryEmd6vvA/ORDlqjs74xBke9 hMzMPMB47FG3br+4kQ1exSa3TqHAcfLbttwi0bkoENuq1gIuMySx0P0QkS+8vgX7Tlkm d4vI54MBKepw2PDLHY6mmrgWocVRMhL6f4xBuWzNYzFqCqw9+RTssbDNw32vrR9jMgyC ydgAY0duYgfRfcFdqWTqGA3T1AznFU/XsD8m8PlUfU0XamTvyeZpR4PkB8aijGpVAOEk 1DzQh3FVj1OLC7B4hkq7l+O1tKRuS1RAUqi+7SFHrE30IHpEk6LYAIN5q7fddM51nxfp OBSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1izZyID2JVcsZHuk9qcOHy8QVMSnHDmxGlhaD1X6JZE=; b=Jnahot5+oBjIE7ZyaLASNM+EwkmTZpagO67Elgc0gfJvPCWh79I+Jsn7bVASVK/QvP wM5FuSYQPn26Hm8FqonUNXQ3ne9z9GYKWLcYaKMMYDZt+zcPG5v9KGJiS/dHhqPrWWfu pVImRuoSenajOmE+ZlsVqdmCWtqCEmUQnVo+a0RwzuQ3CVR8LT3xGAncCDNFdFKDucuZ K1s8iIXcqIbKCElu86DM2SzEqKggZw/3UAiqccJ9kQt27zQUXg2XwywbV3KStaxSv6zK f8UMs2ai6HMkV28k1cfuECNArCH+csmDCG8y+Z1exWjaObcU84PCu9fAXba1J+ykGCQD m1BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=WRrJSVfX; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q29-20020a2e751d000000b0024dbc380302si5309555ljc.271.2022.04.28.13.35.00; Thu, 28 Apr 2022 13:36:03 -0700 (PDT) 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=@google.com header.s=20210112 header.b=WRrJSVfX; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348746AbiD1PID (ORCPT + 99 others); Thu, 28 Apr 2022 11:08:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346740AbiD1PH7 (ORCPT ); Thu, 28 Apr 2022 11:07:59 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98729B3DCA for ; Thu, 28 Apr 2022 08:04:44 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id x52so2921164pfu.11 for ; Thu, 28 Apr 2022 08:04:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=1izZyID2JVcsZHuk9qcOHy8QVMSnHDmxGlhaD1X6JZE=; b=WRrJSVfXKnRNEU+qLmI6Rj4HeuvfpqNhpSzfbha0UXvP5WsX/CY+Mkf0pCsoTch+hq svxDaQLsuJlSGtth0lbdJkOyy/GkU6McQfvA2Kv8LUa29WtIbFgShnyjHj7EA4fg6Usz H3Lv9xgE1ALBpsbhNoVhyIvkXT/ohsz0pgzmDDKtYscNfegRR556kZLTSOjRnBnZUJgl LsKfLKhjf8uYsT0xnqXCTzYiZ8/nzsdLgEwvM64AI5AQe5PE6wOICBBZgEscHUaq9Ros 2I6p6Pz7jYW4IGIqw3eGJ0qBdWOmeFThZBTcx+evNZtZLsoB9FQfEhVfVOGey2/NykuD fc2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=1izZyID2JVcsZHuk9qcOHy8QVMSnHDmxGlhaD1X6JZE=; b=Tt6Di9ALFPhB0HFI3KbvIx0TgFfnJfVjItNPU6KVzpc2t1lForV3svpqi8wRVk1Gly 0Jol04EKGTZcelL3M2LQKxYpBMiZjZ+cSNCcAsytLMZc6zoG1m1wu2xUK+KjogsXBhxf XugcTxX28ihlwgmbdF57YiIJJbbOQ41UCxEQl5ogvi3bGximIXbfrmTPL1SNl3oO58y+ wO7w8/Vy2Wr3E0VQwkGXJtKk/0A4h6bgV8ZN3/7OTjm3HbzufxU0xZdh8owlhwSNadW2 8MHaAeMEKdyHrKIN+IU2+UnV+jzFGM1qsLeV9v8b8HZwTuG4NG8evQb9elqknvmyt76t 1yKw== X-Gm-Message-State: AOAM533EbrFxqAPjhkYxALPVKhgZQGhLBauop9L2U0F242sd/YGVgEcJ VNyk8GUOAj9OltT9V3AjhY9t6A== X-Received: by 2002:a65:6955:0:b0:380:64fd:a2dd with SMTP id w21-20020a656955000000b0038064fda2ddmr27637714pgq.383.1651158283925; Thu, 28 Apr 2022 08:04:43 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id s9-20020a639e09000000b003c14af5063asm3225467pgd.82.2022.04.28.08.04.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Apr 2022 08:04:43 -0700 (PDT) Date: Thu, 28 Apr 2022 15:04:40 +0000 From: Sean Christopherson To: Maxim Levitsky Cc: "Maciej S. Szmigiero" , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini Subject: Re: [PATCH v2 02/11] KVM: SVM: Don't BUG if userspace injects a soft interrupt with GIF=0 Message-ID: References: <20220423021411.784383-1-seanjc@google.com> <20220423021411.784383-3-seanjc@google.com> <61ad22d6de1f6a51148d2538f992700cac5540d4.camel@redhat.com> <4baa5071-3fb6-64f3-bcd7-2ffc1181d811@maciej.szmigiero.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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 Thu, Apr 28, 2022, Maxim Levitsky wrote: > On Thu, 2022-04-28 at 15:27 +0200, Maciej S. Szmigiero wrote: > > On 28.04.2022 09:35, Maxim Levitsky wrote: > > > On Sat, 2022-04-23 at 02:14 +0000, Sean Christopherson wrote: > > > > From: Maciej S. Szmigiero > > > > > > > > Don't BUG/WARN on interrupt injection due to GIF being cleared if the > > > > injected event is a soft interrupt, which are not actually IRQs and thus > > > > > > Are any injected events subject to GIF set? I think that EVENTINJ just injects > > > unconditionaly whatever hypervisor puts in it. > > > > That's right, EVENTINJ will pretty much always inject, even when the CPU > > is in a 'wrong' state (like for example, injecting a hardware interrupt > > or a NMI with GIF masked). > > > > But KVM as a L0 is not supposed to inject a hardware interrupt into guest > > with GIF unset since the guest is obviously not expecting it then. > > Hence this WARN_ON(). > > If you mean L0->L1 injection, that sure, but if L1 injects interrupt to L2, > then it should always be allowed to do so. Yes, L1 can inject whatever it wants, whenever it wants. I kept the WARN_ON() under the assumption that KVM would refuse to inject IRQs stuffed by userspace if GIF is disabled, but looking at the code again, I have no idea why I thought that. KVM_SET_VCPU_EVENTS blindly takes whatever userspace provides, I don't see anything that would prevent userspace from shoving in a hardware IRQ.