From nobody Thu May 09 11:05:37 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VZq1Y4MVpz5JPgW; Thu, 09 May 2024 11:05:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VZq1Y3vBJz4rp8; Thu, 9 May 2024 11:05:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715252737; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jqiq2Gz4Bo8dNxga3vaJvSoeRMa0pMTGD22mXGJcw6o=; b=OChV+9Zrz37ah2tm5MVIfA4Wj0auT+j8aA7cdQY/yW/cAemGSh/VwVlpJvlFXqYfDPSYxP TK7qwanfCACCPABRbCSh7g2eizq0FkoXTZgLW7mx5r8D5uK1lvBPgYK9m7i/OJKzbAc4jo jMb/6mLSMOVMHBaTiZaH1dWzUnLEKlIS8fFTl82Ij8r9nFYmOibcKtCiSXnvdjUc5G12pO gKTq/bGPYP3Eer/NmL1DvLB5o1DlAlKOd/re0ctZ2GOCGmwYLGCsnJu884NOyRXl8jj4ku qH8vY+h8MRFDFKJkVj+8GP0HbVBjvIIdvm19mzLHSxmKmYXusnbLY1+WDcAzag== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715252737; a=rsa-sha256; cv=none; b=A5e6eRQrlNyQS9rv+yzQNUyZL+zdMem/tClJdfDZ3B/ciTPvONHCyUlQqhYvCIetmVPYQd MllfLDsHARIr9p2vwUIE3K5oQaoXwzT/bhx/QtyCqraeHSexivU1q5YxE6gUvePbapOhX4 Y0L5nQ7fpY1NY8FFW7JmAbemZKxrZJyZFOYUTyIHnx4dACXo++ZL42/uDzxglcBucxmPct gdxg7InyCHPeSYtYIrh8IqUxcLaf9Vp8gmlowo5E2HjYOEkq4cqNl2W+pruXnHB5riqNcJ LlulK8ZQ5uwo3T4UxSAmiaOlDpRIROMTQVZNTkPfrBuKGwsLCu2k+Nl2n0RqKQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715252737; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jqiq2Gz4Bo8dNxga3vaJvSoeRMa0pMTGD22mXGJcw6o=; b=QICPEmDNJLyDwUQp2K2BKj3BAzcfXJ/9lcSbWyfgM131+KVseJSi13TBXPaDILwsOmkMso biQdcISrw9AbjyU196mEmPAZnPcOr7SIjfq/bX/g8bcTwR3PrHexMKLWSr/avBSV8Ov7BP LNLJ5KN14g9I+RjKBpY8tgTK/L2UhmiS9atMKFR0mVmlwXFDri0bKhInfzCUQxfaLTTgqY g3OZEvv0S7faVlWywNWIKnfIfe5uILyixMzfQ/DTZ/dCcsUMJmsFooPAXZAN8HrzmM7bMI AwCqETaXi7Da7lk0OX76njpMJkQ/QRBghuFYGFXb/xiuJX5ECo6w3Te1dKJfvQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VZq1Y3NRrz15n5; Thu, 9 May 2024 11:05:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 449B5buV013009; Thu, 9 May 2024 11:05:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 449B5bm9013006; Thu, 9 May 2024 11:05:37 GMT (envelope-from git) Date: Thu, 9 May 2024 11:05:37 GMT Message-Id: <202405091105.449B5bm9013006@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Roger Pau =?utf-8?Q?Monn=C3=A9?= Subject: git: ee72bc1d1ff8 - main - xen/debug: remove usage of sbuf_{clear,finish}() on drained sbuf List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: royger X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ee72bc1d1ff8aa8704d5861a10ea3514154ff74d Auto-Submitted: auto-generated The branch main has been updated by royger: URL: https://cgit.FreeBSD.org/src/commit/?id=ee72bc1d1ff8aa8704d5861a10ea3514154ff74d commit ee72bc1d1ff8aa8704d5861a10ea3514154ff74d Author: Roger Pau Monné AuthorDate: 2024-05-02 13:12:16 +0000 Commit: Roger Pau Monné CommitDate: 2024-05-09 10:50:08 +0000 xen/debug: remove usage of sbuf_{clear,finish}() on drained sbuf Using sbuf_clear() on a drained sbuf is explicitly prohibited, and using sbuf_finish() after printing a trace leads to a single trace being printed, as after calling sbuf_finish() further attempts to use the same sbuf will lead to a panic. While there also switch to using xen_emergency_print() instead of attempting to write directly to the hypervisor console. xen_emergency_print() can be implemented per-arch to use a different mechanism than the console hypercall (note the default implementation still uses the console hypercall). Fixes: df62b8a25f47 ('xen: add a handler for the debug interrupt') Sponsored by: Cloud Software Group Reviewed by: markj Differential review: https://reviews.freebsd.org/D45060 --- sys/dev/xen/debug/debug.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/dev/xen/debug/debug.c b/sys/dev/xen/debug/debug.c index f17d0c612262..2889b5efdba7 100644 --- a/sys/dev/xen/debug/debug.c +++ b/sys/dev/xen/debug/debug.c @@ -58,8 +58,11 @@ static struct sbuf *buf; static int xendebug_drain(void *arg, const char *str, int len) { - - HYPERVISOR_console_write(__DECONST(char *, str), len); + /* + * Use xen_emergency_print() instead of xc_printf() to avoid the + * overhead of parsing a format string when it's not needed. + */ + xen_emergency_print(str, len); return (len); } @@ -75,10 +78,9 @@ xendebug_filter(void *arg __unused) stack_save(&st); mtx_lock_spin(&lock); - sbuf_clear(buf); xc_printf("Printing stack trace vCPU%u\n", XEN_VCPUID()); stack_sbuf_print_ddb(buf, &st); - sbuf_finish(buf); + sbuf_drain(buf); mtx_unlock_spin(&lock); #endif