Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3519710pxb; Mon, 4 Apr 2022 19:41:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzir848NmuRyOXoLuRZcAA4OdThfBHAFi36Ys4APX7tKzrF3AHkka9lfLaEodIWgo09wQV3 X-Received: by 2002:a63:fa56:0:b0:399:3452:ffa8 with SMTP id g22-20020a63fa56000000b003993452ffa8mr1004835pgk.255.1649126477531; Mon, 04 Apr 2022 19:41:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649126477; cv=none; d=google.com; s=arc-20160816; b=JHVyBagQYlYN0q7iDwp68UsPOIjLac/8DQNoNUnSaU0HVhRUtmVdmzy4K/jQAjmmnY ICwqi2nSucqYWZzZXxx1k28BD1uRgdd4vJLI9vHqlVoAVIO02mTQtdIvYydJnA58fD3Z Lnl35PPGEg2beXU5ZTY8s2hG/0kzyoLKqamagas86V8NrJn54DXKAUTDgt06DZJy5HDi UMIBjs0vY3Z8D+pvqy+mN+8TU/SRfOff9A4JKC3pcOD5EXbnbJscerPWSK1Nu62fGGQz Nkil57wKvqdDUdaGs4pHF9vVhdbgVye57vbCNrjBGsMTyFX2/MCkK17aS50OZhK1fuv5 H1Ng== 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:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id; bh=hbZKwCsxrifMdSSt2MZRpDmsRYER4/WXWF88QXyzJ+M=; b=aHXmY5wqjUK+LlSWUTPNTJwtV4MrcRrgimDA1PoXBB0JrF5DT4j3uQ1zEidVqXJIxU +BjlLoLsTi7wQECaj7vrp5lgKZnUYw6daTTfEsebC4iChDdSAkDMiaKhSXiw7HqXFZN6 kTOBw/gm6+GkZOt+t+i3zDBtTmeVDBh0vjXNozPxoodn5o2bxStRsek1F+lKtVl5upQT qm8M3srpiFwjNjw7kVBIE1EF6nX/5Hs0P/lQdjlvjIyDy4hTKD1w3F72sQpAqoW/bZYr t7QVT2M63vtZ2gg8N+GrI2aH85D+koysdEzUKthNkqjTzNLOnwlcO/aFMITJ4NoemZlI 9naw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id m22-20020a170902bb9600b00153b2d16548si10377358pls.336.2022.04.04.19.41.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 19:41:17 -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; 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E741E31DE8; Mon, 4 Apr 2022 18:04:55 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381338AbiDDVWw (ORCPT + 99 others); Mon, 4 Apr 2022 17:22:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380379AbiDDTxG (ORCPT ); Mon, 4 Apr 2022 15:53:06 -0400 Received: from vps-vb.mhejs.net (vps-vb.mhejs.net [37.28.154.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FC18559A; Mon, 4 Apr 2022 12:51:08 -0700 (PDT) Received: from MUA by vps-vb.mhejs.net with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1nbSj5-0003Uu-05; Mon, 04 Apr 2022 21:50:59 +0200 Message-ID: <53a9ac0a-fce5-69a0-41e5-9a1a2dab9317@maciej.szmigiero.name> Date: Mon, 4 Apr 2022 21:50:53 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Content-Language: en-US To: Sean Christopherson Cc: Maxim Levitsky , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220402010903.727604-1-seanjc@google.com> <20220402010903.727604-6-seanjc@google.com> From: "Maciej S. Szmigiero" Subject: Re: [PATCH 5/8] KVM: SVM: Re-inject INT3/INTO instead of retrying the instruction In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 4.04.2022 21:33, Sean Christopherson wrote: > On Mon, Apr 04, 2022, Maciej S. Szmigiero wrote: >>>>> index 47e7427d0395..a770a1c7ddd2 100644 >>>>> --- a/arch/x86/kvm/svm/svm.h >>>>> +++ b/arch/x86/kvm/svm/svm.h >>>>> @@ -230,8 +230,8 @@ struct vcpu_svm { >>>>> bool nmi_singlestep; >>>>> u64 nmi_singlestep_guest_rflags; >>>>> - unsigned int3_injected; >>>>> - unsigned long int3_rip; >>>>> + unsigned soft_int_injected; >>>>> + unsigned long soft_int_linear_rip; >>>>> /* optional nested SVM features that are enabled for this guest */ >>>>> bool nrips_enabled : 1; >>>> >>>> >>>> I mostly agree with this patch, but think that it doesn't address the >>>> original issue that Maciej wanted to address: >>>> >>>> Suppose that there is *no* instruction in L2 code which caused the software >>>> exception, but rather L1 set arbitrary next_rip, and set EVENTINJ to software >>>> exception with some vector, and that injection got interrupted. >>>> >>>> I don't think that this code will support this. >>> >>> Argh, you're right. Maciej's selftest injects without an instruction, but it doesn't >>> configure the scenario where that injection fails due to an exception+VM-Exit that >>> isn't intercepted by L1 and is handled by L0. The event_inj test gets the coverage >>> for the latter, but always has a backing instruction. >> >> Still reviewing the whole patch set, but want to clear this point quickly: >> The selftest does have an implicit intervening NPF (handled by L0) while >> injecting the first L1 -> L2 event. > > I'll do some debug to figure out why the test passes for me. I'm guessing I either > got lucky, e.g. IDT was faulted in already, or I screwed up and the test doesn't > actually pass. Try applying Maxim's proposed change to this test (adding two additional ud2s at the start of L2 guest code and adjusting just the next_rip field accordingly). We might have been lucky in the patched KVM code and have next_rip = rip at this re-injection case now (the next_rip field was zero in the original KVM code). Thanks, Maciej