From owner-freebsd-virtualization@freebsd.org Sun May 31 17:10:31 2020 Return-Path: Delivered-To: freebsd-virtualization@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0BEC13396D1 for ; Sun, 31 May 2020 17:10:31 +0000 (UTC) (envelope-from crowston@protonmail.com) Received: from mail2.protonmail.ch (mail2.protonmail.ch [185.70.40.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "protonmail.com", Issuer "SwissSign Server Gold CA 2014 - G22" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49ZlDj4b9Sz4Ppf for ; Sun, 31 May 2020 17:10:29 +0000 (UTC) (envelope-from crowston@protonmail.com) Date: Sun, 31 May 2020 17:10:25 +0000 To: FreeBSD virtualization From: Robert Crowston Reply-To: Robert Crowston Subject: Single stepping a bhyve guest on AMD64 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=7.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mail.protonmail.ch X-Rspamd-Queue-Id: 49ZlDj4b9Sz4Ppf X-Spamd-Bar: -- X-Spamd-Result: default: False [-2.79 / 15.00]; ARC_NA(0.00)[]; HAS_REPLYTO(0.00)[crowston@protonmail.com]; R_DKIM_ALLOW(-0.20)[protonmail.com:s=protonmail]; REPLYTO_EQ_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:185.70.40.0/24:c]; FREEMAIL_FROM(0.00)[protonmail.com]; MIME_GOOD(-0.10)[text/plain]; FREEMAIL_REPLYTO(0.00)[protonmail.com]; NEURAL_HAM_LONG(-0.74)[-0.737]; RCPT_COUNT_ONE(0.00)[1]; RWL_MAILSPIKE_POSSIBLE(0.00)[185.70.40.22:from]; NEURAL_HAM_MEDIUM(-0.61)[-0.608]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[protonmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[protonmail.com,quarantine]; NEURAL_HAM_SHORT(-0.35)[-0.347]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[protonmail.com]; ASN(0.00)[asn:62371, ipnet:185.70.40.0/24, country:CH]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_IN_DNSWL_LOW(-0.10)[185.70.40.22:from] X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.33 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: Sun, 31 May 2020 17:10:31 -0000 I am investigating using the -G flag to attach gdb to a running guest machi= ne. It looks like breakpoints and single instruction stepping are not implement= ed in vmm/amd/svm.c. It seems that it was added to vmm/intel/vmx.c. I spent= a little bit of time reading through the AMD64 Architecture Manual; it doe= sn't seem to provide a direct way to implement this in a way transparent to= the guest? One way to implement single stepping that occurs to me is to set the trap f= lag in the guest's RFLAGS register, and then intercept each #DB exception i= n the vmm. Has anyone looked at this on the AMD side? Any advice? --- Rob Crowston.