From owner-freebsd-virtualization@FreeBSD.ORG Wed Aug 13 01:39:20 2014 Return-Path: Delivered-To: freebsd-virtualization@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 24C62D99 for ; Wed, 13 Aug 2014 01:39:20 +0000 (UTC) Received: from mail-qa0-x234.google.com (mail-qa0-x234.google.com [IPv6:2607:f8b0:400d:c00::234]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DBD9024BE for ; Wed, 13 Aug 2014 01:39:19 +0000 (UTC) Received: by mail-qa0-f52.google.com with SMTP id j15so9658840qaq.11 for ; Tue, 12 Aug 2014 18:39:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=6ISVV57mRlzcz7Fr89U2vgzNxnlVud7RB4HwMkyOcXM=; b=DjgIsqdEiV7N3BREQPt1zSSvAfneA1OCOfofi+f83x+80DA/1ZWDDiDjVJMujbnXpW k+2EkLoxuuNBxGJmuf0K9wSxybrWFg/nzL7rgEQlTAH4sfD+5SyqpQQuT1WVUZ45S8UF 3mYyyXiDGueNO0Vl08u8qed+CeQHcp0H3ywHEUHAOQry4Ff78W5i2arxaoMqQz3CCOhk ApzBM1F8nMgYPRCQvIhg0RpJ92Vu/VfTrcoc0KDWA7ROa4OD81DSuax9fclgwVX77xEB 0ExyHS/kbuJoKzD+AXzDYj4kHZ3sGCqsh9jHKO+ggeem8+WKEbFD59v8foHfyx1VpRG6 mMXg== MIME-Version: 1.0 X-Received: by 10.224.95.74 with SMTP id c10mr1849905qan.35.1407893958886; Tue, 12 Aug 2014 18:39:18 -0700 (PDT) Received: by 10.140.84.80 with HTTP; Tue, 12 Aug 2014 18:39:18 -0700 (PDT) In-Reply-To: <20140812092407.GC11403@mail.demonism.de> References: <20140812092407.GC11403@mail.demonism.de> Date: Tue, 12 Aug 2014 18:39:18 -0700 Message-ID: Subject: Re: Problem with vmexit on mtrap From: Neel Natu To: Martin Steegmanns Content-Type: text/plain; charset=UTF-8 Cc: "freebsd-virtualization@freebsd.org" X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Aug 2014 01:39:20 -0000 Hi Martin, On Tue, Aug 12, 2014 at 2:24 AM, Martin Steegmanns wrote: > Hello list! > I modified bhyve to toggle the MTF bit on an UD2 instruction. > In a guest system, a program does: > __asm__ __volatile__( > "UD2" > "NOP" > "xor %rax,%rax" > "NOP" > "UD2" > ); > > On the first UD2, MTF bit is correctly set, but the second > UD2 is never reached (waited some hours). > If I manually reset the MTF bit via bhyvectl --setcap, > guest executione reaches the second UD2 instruction. > > A diff of my modifications is attached to this mail. > > Am I missing something on vmenter that makes the guest loop forever? > The VM-exit instruction length field is valid only for a subset of VM exits. See section 27.2.4 "Information for VM exits due to instruction execution" in the Intel SDM. In particular, the instruction length is not guaranteed to be valid if the VM-exit is due to a hardware exception. Therefore it cannot be used to "skip over" the UD2 instruction. On my machine the VM-exit instruction length field was set to '2' for the first UD2 and '5' for the second UD2. For this specific test, you can either hardcode the instruction length to '2' if the VM exit is due to a UD2 or use an instruction like "OUT" to a specific I/O port to trigger the monitor-trap-flag on and off. A VM-exit due to "OUT" will have the correct value in the VM-exit instruction length field. best Neel > Regards, > Martin > > > /usr/src/sys/modules/vmm/../../amd64/vmm/intel/vmx.c:1074 vm vm1[0]: unhandled mtf vmexit at 0xffffffff804dde70 > /usr/src/sys/modules/vmm/../../amd64/vmm/intel/vmx.c:1063 vm vm1[0]: Resume execution at 0xffffffff804dde41 > /usr/src/sys/modules/vmm/../../amd64/vmm/intel/vmx.c:2652 vm vm1[0]: returning from vmx_run: exitcode 6 > /usr/src/sys/modules/vmm/../../amd64/vmm/intel/vmx.c:1074 vm vm1[0]: unhandled mtf vmexit at 0xffffffff804dde41 > /usr/src/sys/modules/vmm/../../amd64/vmm/intel/vmx.c:1063 vm vm1[0]: Resume execution at 0xffffffff804dde39 > /usr/src/sys/modules/vmm/../../amd64/vmm/intel/vmx.c:2652 vm vm1[0]: returning from vmx_run: exitcode 6 > /usr/src/sys/modules/vmm/../../amd64/vmm/intel/vmx.c:1074 vm vm1[0]: unhandled mtf vmexit at 0xffffffff804dde39 > /usr/src/sys/modules/vmm/../../amd64/vmm/intel/vmx.c:1063 vm vm1[0]: Resume execution at 0xffffffff804dde30 > /usr/src/sys/modules/vmm/../../amd64/vmm/intel/vmx.c:2652 vm vm1[0]: returning from vmx_run: exitcode 6 > /usr/src/sys/modules/vmm/../../amd64/vmm/intel/vmx.c:1074 vm vm1[0]: unhandled mtf vmexit at 0xffffffff804dde30 > /usr/src/sys/modules/vmm/../../amd64/vmm/intel/vmx.c:1063 vm vm1[0]: Resume execution at 0xffffffff804dde27 > /usr/src/sys/modules/vmm/../../amd64/vmm/intel/vmx.c:2652 vm vm1[0]: returning from vmx_run: exitcode 6 > /usr/src/sys/modules/vmm/../../amd64/vmm/intel/vmx.c:1074 vm vm1[0]: unhandled mtf vmexit at 0xffffffff804dde27 > /usr/src/sys/modules/vmm/../../amd64/vmm/intel/vmx.c:1063 vm vm1[0]: Resume execution at 0xffffffff804dde1f > > > _______________________________________________ > freebsd-virtualization@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-virtualization > To unsubscribe, send any mail to "freebsd-virtualization-unsubscribe@freebsd.org"