Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp14046pxb; Tue, 12 Jan 2021 18:30:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxBffoPWkzhe0zTlyTQN1D3arW26vTBBJeXON+ieJemWka5AB0ZzU5uwFhGFvQqvKw4bcCJ X-Received: by 2002:a17:906:705:: with SMTP id y5mr1204335ejb.428.1610505047557; Tue, 12 Jan 2021 18:30:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610505047; cv=none; d=google.com; s=arc-20160816; b=BYk6Kd98FlLHamNvByhS9ISsWO96R+8rEO0UkxkeH7TCntIB0xP8H0hXr7XFEDyKIk xo2c3gKkOYNJmWJLwKyMzcD8yaNQs2zjdJ9iFo8qdZBJh28MQB8+rh3YCLRW8zK/ww8V RCKegvg4BsKVf3qgwWcRsRnELLxn65JJm+GSNKIG4oyrQJevXT6BEfI547pBAf01uUOj 8c0wenMxxXlsji/dpdXzHj9knY4BF1UZQ2YKVZtwKFYdiZpfscpIzk4KrPXab22l7Zlv xtBde5PM1yR3nxak1gbGEpJN3R5I1uhH3ouQ0UjjN+Uv6BN2TKR9OQqZogp8z9h03Nga 016Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=YFXb4Pk6zkZotZ7QFJdBiZxTuzhscJ3Ufo92Lo64mQQ=; b=UZ365PS+00ffdzxl/mp7IfXpEHmDMCCHNcAsdBIV1d5g0llPN6OWRDC2+3OgVn5Jgd wiapHyQnYXqjSdJ+dW4PAqA9EeDs0c9Wpe/Zb1K7kO2fe6elRm00I2maHtC8C5zRbMXf tweleyKajR4ryGZrCYAPyplmEcH5JxcWPXfgyUJ3BCx6rLsVGaYdlYi8zioEdaxxcmd7 fT6YjhCmxiXq4F7MFaBcOKWX0KwVR15Ha1lX9V5r+R0Dl1Aa1YMz4GYQvqAf8gsM9dTU 5o3zuKIqoWm/qjaNPwx7DCjLV4vB1DuxiBGGWMv/wlWFOY+rq3H8pWF5Vjhc+1VDkpBn 5W4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=afZOpGs9; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u22si263239ejt.406.2021.01.12.18.30.24; Tue, 12 Jan 2021 18:30:47 -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=@redhat.com header.s=mimecast20190719 header.b=afZOpGs9; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437172AbhALVeO (ORCPT + 99 others); Tue, 12 Jan 2021 16:34:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:39422 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406963AbhALUBs (ORCPT ); Tue, 12 Jan 2021 15:01:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610481621; 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: in-reply-to:in-reply-to:references:references; bh=YFXb4Pk6zkZotZ7QFJdBiZxTuzhscJ3Ufo92Lo64mQQ=; b=afZOpGs9VO/ZBnxEWtJjPnwqaLvvK2JkTN6YTDLN8309EzJizjePxiWOgDvUJSZp5wUPj3 ydSRcYvsQIRUEH/GlRpmNlPGB9XIomqaqaAqxi5gbq8EutiFn13d9BApwI4OX7On79Qqbg aHufEHDLMi2ImJA77rK5e1tuEvFlSqg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-576-FbFMmpNeNgW9eXHRb0esVQ-1; Tue, 12 Jan 2021 15:00:18 -0500 X-MC-Unique: FbFMmpNeNgW9eXHRb0esVQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 632211DE0E; Tue, 12 Jan 2021 20:00:11 +0000 (UTC) Received: from gigantic.usersys.redhat.com (helium.bos.redhat.com [10.18.17.132]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C5BB378206; Tue, 12 Jan 2021 20:00:09 +0000 (UTC) From: Bandan Das To: Sean Christopherson Cc: 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, mlevitsk@redhat.com Subject: Re: [PATCH 1/2] KVM: x86: Add emulation support for #GP triggered by VM instructions References: <20210112063703.539893-1-wei.huang2@amd.com> Date: Tue, 12 Jan 2021 15:00:09 -0500 In-Reply-To: (Sean Christopherson's message of "Tue, 12 Jan 2021 11:40:48 -0800") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > So, the condition is that L2 executes a vmload and #GPs on a reserved address, jumps to L0 - L0 doesn't check if L1 has asked for the instruction to be intercepted and goes on with emulating vmload and returning back to L2 ? >> } >> >> /* >> -- >> 2.27.0 >>