Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp435711pxb; Thu, 14 Jan 2021 09:21:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJwlBlCsrMtciE+kWOVILpzPassA1T/KrFTfCNsj0Cmugp8/ZcQaaR56dInYd8gFefX8ouGj X-Received: by 2002:a17:906:a857:: with SMTP id dx23mr6019050ejb.189.1610644894160; Thu, 14 Jan 2021 09:21:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610644894; cv=none; d=google.com; s=arc-20160816; b=Ok8JSj153fMR47OdZO8P5WrT/OZrm4viAEgPFc3PAfpflti2lMPKQ6/BjKSoB4we+I APdsQI8DBybKLbi4b97KXH+mCLYcOXm67QW+dQsd38OtgahNcidSVRQ7nJim5Etfkv45 kGNA9todGxY9Lh22HqEUP1SIWnMI/OwXC67MoovPi6kDVtPsEivwP+9yjKo6QKrE6/eD /+9ZaB7V3qI6z84BDGUkIQyVQiSXBq6juzdqDFmGR2GloJHJz8x0QXzLKnoPwQm4q/iJ Ppg4lr9IRA+4aVhK+HjcCOk8dvcZav0zhZcp57cSSKztZl30WSE6P4dWHU0RXTBa9E4I ah4A== 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=1u0hHUSEEliOo8V4yriPq3cyKn6ullY8YW9KiIkobfk=; b=YSbniwrwYRadFXFaaadqnPujM4sqoOhcWiKo//zz24duz1IIzCJ8rIBypxgWuAhHGE MEymdugZNEe9++zJ2a7MCUNbU94epWe9D330YJxNMKL/3vR8kvl1y8hpIjvdf1sIU56M 7b9wzceJhTx2MQOWX2MMoE0rC85Il6oAzCY0xW6iqKwDyr4Cr/L8h0FNDfkeo8aE66QF lP8MwZ/aju/bjLZDNf2ZZooTaQRiaFYgE5fmvxnBq3ZJwnVWh0/KDMtpwUOxGdSeHuSp 0Fi/Tz2TbxJVBDSsXW9E6nQLv/mwHESc3TT8kQriDw+6ie/vgFvYMxgrTUtx42eJGrbL E6ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ZLp3EJqL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t5si2663204ejy.497.2021.01.14.09.21.09; Thu, 14 Jan 2021 09:21:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ZLp3EJqL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728510AbhANRUe (ORCPT + 99 others); Thu, 14 Jan 2021 12:20:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726442AbhANRUa (ORCPT ); Thu, 14 Jan 2021 12:20:30 -0500 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04D4EC061575 for ; Thu, 14 Jan 2021 09:19:49 -0800 (PST) Received: by mail-pf1-x42b.google.com with SMTP id h10so3733936pfo.9 for ; Thu, 14 Jan 2021 09:19:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=1u0hHUSEEliOo8V4yriPq3cyKn6ullY8YW9KiIkobfk=; b=ZLp3EJqLl7TKSrMFy/TKrGf2U1rKvMJs7XG0MKq6/Jv5xjQ0FqkHFtNPKAGDqSEUg6 FAxAKuhq+I5/NhJcaO9RflWofjeog+IfggZW7hrHLRI+3AU3KyzSELXgPqy7dOL+yQde jkiWFBfTWTXHCMUcNRWG/kMxZHrELQoalbMyGYO9d13qzinFZm/H9Dx3eEEnmJXGpKmh m+cw4LuXB47cfFpnAQ920Tx4rmWPmanVu3SLTovBylVQ8s9zBmPSFN4pD8QY7d+PrQ2F rGrrTcjZVFW2bBNhHodDOF5izfhgO2crwZQpgaY/bek9Rb1uMO/qNO8Zd11+rebZoiCV Mwqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=1u0hHUSEEliOo8V4yriPq3cyKn6ullY8YW9KiIkobfk=; b=ZnXcKPdlYZkped4YK2T4v8pDwZIMrXqAyo/TdWov+xnq/V9NZPXy32zY52FN6BZB39 xDb7uR7X4oiX1y1ChP872ypZJSibU2TN/4dlAbkCamwhiPzX3rGLcO2lBmu8MkXbHj3e y2G2OA/cHS/jraT9cDFqU97O15PZ58IVUalrQ1OGwI1OXGarXRl4qdpg9TbUvyd74k/8 2bP9LPEm2KosScZnJCawZJTwC1RCvomnUU8lbHJBvXly9TWh0MlBrfTcgCNiFC/3YKk3 +ljpf/Fo9T/NBh1UfjC3ryGefhDNS/vYdZyN4vrCuyHn7d9mMgHnAtgaDQsPuyscC+Wj BD4A== X-Gm-Message-State: AOAM5312gMAKKjSsyK7ODGXnbDpJP5+qceIbqi70H9O3Z2G4xeOvlWo+ ABh6RE8L/Cgpxow/BOmjT3LHLw== X-Received: by 2002:a63:4b16:: with SMTP id y22mr8432122pga.203.1610644788272; Thu, 14 Jan 2021 09:19:48 -0800 (PST) Received: from google.com ([2620:15c:f:10:1ea0:b8ff:fe73:50f5]) by smtp.gmail.com with ESMTPSA id u189sm5721402pfb.51.2021.01.14.09.19.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jan 2021 09:19:47 -0800 (PST) Date: Thu, 14 Jan 2021 09:19:40 -0800 From: Sean Christopherson To: Maxim Levitsky Cc: Bandan Das , Wei Huang , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, pbonzini@redhat.com, vkuznets@redhat.com, joro@8bytes.org, bp@alien8.de, tglx@linutronix.de, mingo@redhat.com, x86@kernel.org, jmattson@google.com, wanpengli@tencent.com, dgilbert@redhat.com Subject: Re: [PATCH 1/2] KVM: x86: Add emulation support for #GP triggered by VM instructions Message-ID: References: <20210112063703.539893-1-wei.huang2@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 14, 2021, Maxim Levitsky wrote: > On Tue, 2021-01-12 at 15:00 -0500, Bandan Das wrote: > > Sean Christopherson writes: > > ... > > > > - if ((emulation_type & EMULTYPE_VMWARE_GP) && > > > > - !is_vmware_backdoor_opcode(ctxt)) { > > > > - kvm_queue_exception_e(vcpu, GP_VECTOR, 0); > > > > - return 1; > > > > + if (emulation_type & EMULTYPE_PARAVIRT_GP) { > > > > + vminstr = is_vm_instr_opcode(ctxt); > > > > + if (!vminstr && !is_vmware_backdoor_opcode(ctxt)) { > > > > + kvm_queue_exception_e(vcpu, GP_VECTOR, 0); > > > > + return 1; > > > > + } > > > > + if (vminstr) > > > > + return vminstr; > > > > > > I'm pretty sure this doesn't correctly handle a VM-instr in L2 that hits a bad > > > L0 GPA and that L1 wants to intercept. The intercept bitmap isn't checked until > > > x86_emulate_insn(), and the vm*_interception() helpers expect nested VM-Exits to > > > be handled further up the stack. > > Actually IMHO this exactly what we want. We want L0 to always intercept > these #GPs, and hide them from the guest. > > What we do need to do (and I prepared and attached a patch for that, is that > if we run a guest, we want to inject corresponding vmexit (like > SVM_EXIT_VMRUN) instead of emulating the instruction. Yes, lack of forwarding to L1 as a nested exit is what I meant by "doesn't correctly handle".