Received: by 2002:a05:6512:2355:0:0:0:0 with SMTP id p21csp208030lfu; Wed, 30 Mar 2022 21:01:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJREvzeHVPdjxuT5uxmWGu/7C5tD3qBYeaS52/mHr9RmQyIPflqILA6kgcTTZJrQPqLQfD X-Received: by 2002:a05:6a00:114e:b0:4c8:55f7:faad with SMTP id b14-20020a056a00114e00b004c855f7faadmr3320372pfm.86.1648699278148; Wed, 30 Mar 2022 21:01:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648699278; cv=none; d=google.com; s=arc-20160816; b=NlZuk8J1zw5UIupuNGFbtu+EDsKCCnQjakpAzUQyB+meSzQeLgGbksc0wgJmrKZFM3 2+Td3KEjgggWymzOs+tKB4C2I6mA00EqCnELkGVAmVvdXZXn97yz9wp61GGe3cpHSi3U c1Sny8m0sFCL2My2xw3/J/G2YERhuD7oakqbom2gp1vgyLIipr1psZB84DxYlXAMBBIG ndkdRWLxIAZGlwxiHNPF/+ohDbYDT4H64yenZF6r/e3Lze/nCUe0UjIDD/bw3iXr0yYI ykHd+3eYNcAGtHTWSUtv423yfY+J16UAAUVcXxYXLNIcBAdUyZIziA2IcHUBzOan9FJc wygA== 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=pDli6+hXKC5s9n1yl7hKexNUnpgD/mpYIhN4/2AX5LU=; b=dS5Tq5NQ7vFyiXUBAgFhiItGtlrS17em569liPXldpV9GpUdVjkv6Z8PUSVxtnq88e B9ujpO1nKwo1/Vl4O7U6Cr6gjwZS8dC/+wTiK+hHsNOG98aF9pNnvXikqHYvTUe5PFeu 6h3F+cfLXRpsoz49OF8dKe8pJv4C4PpP0X8425IDs77JV53ge0FIHKihDBf6QqgxAGqA c0/f6sv6kfXiNYWEEFUtAUFC9FGQaFNjrwjqdpTJfZ0oo9K/v8A5BRtmMHK896UeOI3B cLwFWVJ7VkhmvCAyNluDqJh/XJopBZSlp17v+Smze9mwnXG+fdoLto59FS73DWWibC73 WUOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Gc2pDpTu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id c16-20020a170902d49000b00155c9e8029esi19351281plg.403.2022.03.30.21.01.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 21:01:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Gc2pDpTu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 630B216E7D8; Wed, 30 Mar 2022 20:08:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349694AbiC3WBR (ORCPT + 99 others); Wed, 30 Mar 2022 18:01:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240323AbiC3WBN (ORCPT ); Wed, 30 Mar 2022 18:01:13 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAFD615A18 for ; Wed, 30 Mar 2022 14:59:27 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id z16so20097316pfh.3 for ; Wed, 30 Mar 2022 14:59:27 -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=pDli6+hXKC5s9n1yl7hKexNUnpgD/mpYIhN4/2AX5LU=; b=Gc2pDpTunHkktjornaePqzCCgmOxkEvSJzLj7EEubIMjrBvHn3RSRu4y5Qv67AVdzo SVCXaeFUgPAbKgal6d4L1Y3MbeJaMiNFdU70/mxN20GMw9oSk0/dUBlJ76VAek5Gk7Wx btapBOJgOgS2Q1HXBEh4DnZ5tRUYpE48oOt+Dl8lovxojKPyLdl9uoRmJ5T8SKLTZkGm VMIHP3vrO2SlafqSHsNLiwF/T99xTdqwmkqIPEJOF69wCmLOWBRTYF/DSVmIAeKemcpW IOBjnNjeKnEKjZ2P23B64COvNr9CfHiFafff2FrknHawfHzmtd18JR6bsyVeuovIuhS4 QyBQ== 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=pDli6+hXKC5s9n1yl7hKexNUnpgD/mpYIhN4/2AX5LU=; b=0A6VsX+bGB5Pmixb/2P0HL88DoG6LOohIwfkJfqfiRMTcEHhPIGr1XUOC+hDbvPYiv pJcW50+kBOwSO8omGkx7EKPWqkMQiu+fvgMrlV6NvgkCmlLwnu9HJTQCBdaaF2n39u+W ygqtQMN5Con8B3jiGSJLe+liiwlCbDweeLxV+2TCLs71f36eYE0G5VTigpBQwEesKgwk b6jY9P3SJyHnH5UuoC5X/1ZKuD5ErEHVq+zcucblza4BLoPANbsHaATg3MijsE8hqUVS /f9cbbTYExpwVTbsjRVCYtjE5xMA156ROEEvww4n+u6oeYkNxV4fLpC299ib5oTfetSZ KeYg== X-Gm-Message-State: AOAM530/QFL3O9lmh7C/u4Ua716wa4N/lQRVkZcoRl9AQy6TVp4OqW80 bt/VKfjOyeKRg0GayVTiqKJVcA== X-Received: by 2002:a62:7b97:0:b0:4fa:7a9a:6523 with SMTP id w145-20020a627b97000000b004fa7a9a6523mr1667883pfc.80.1648677567059; Wed, 30 Mar 2022 14:59:27 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id cn9-20020a056a00340900b004fad845e9besm22785110pfb.57.2022.03.30.14.59.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 14:59:26 -0700 (PDT) Date: Wed, 30 Mar 2022 21:59:22 +0000 From: Sean Christopherson To: "Maciej S. Szmigiero" Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Tom Lendacky , Brijesh Singh , Jon Grimm , David Kaplan , Boris Ostrovsky , Liam Merwick , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/5] KVM: nSVM: Don't forget about L1-injected events Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no 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, Mar 10, 2022, Maciej S. Szmigiero wrote: > From: "Maciej S. Szmigiero" > > In SVM synthetic software interrupts or INT3 or INTO exception that L1 > wants to inject into its L2 guest are forgotten if there is an intervening > L0 VMEXIT during their delivery. > > They are re-injected correctly with VMX, however. > > This is because there is an assumption in SVM that such exceptions will be > re-delivered by simply re-executing the current instruction. > Which might not be true if this is a synthetic exception injected by L1, > since in this case the re-executed instruction will be one already in L2, > not the VMRUN instruction in L1 that attempted the injection. > > Leave the pending L1 -> L2 event in svm->nested.ctl.event_inj{,err} until > it is either re-injected successfully or returned to L1 upon a nested > VMEXIT. > Make sure to always re-queue such event if returned in EXITINTINFO. > > The handling of L0 -> {L1, L2} event re-injection is left as-is to avoid > unforeseen regressions. > > Signed-off-by: Maciej S. Szmigiero > --- ... > @@ -3627,6 +3632,14 @@ static void svm_complete_interrupts(struct kvm_vcpu *vcpu) > if (!(exitintinfo & SVM_EXITINTINFO_VALID)) > return; > > + /* L1 -> L2 event re-injection needs a different handling */ > + if (is_guest_mode(vcpu) && > + exit_during_event_injection(svm, svm->nested.ctl.event_inj, > + svm->nested.ctl.event_inj_err)) { > + nested_svm_maybe_reinject(vcpu); Why is this manually re-injecting? More specifically, why does the below (out of sight in the diff) code that re-queues the exception/interrupt not work? The re-queued event should be picked up by nested_save_pending_event_to_vmcb12() and propagatred to vmcb12.