From nobody Sun Dec 24 08:22:59 2023 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 4SyYv82czjz54H0F; Sun, 24 Dec 2023 08:23:00 +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 4SyYv81295z4XZt; Sun, 24 Dec 2023 08:23:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703406180; 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=j/c1+ngXrDfc52jYsC3cjQj3Kxy7hTvU0WdV9Zu/0ug=; b=Zxa1XPMQrFQmo2njrebZNroR15BF9LSr3Ro+AIacGDByLW3FZlVPAk+1/jq+05ruXbrzBz Q4R+sIYrM7jYH4jxLnxTTA3ES9bl4j47VbARphgeSskvAPU4+ht+27Aa+N6aa++4m+MWt9 831jWqDhVS8VFAGlPn3BGDvtAlgr+y96STLrNKl2vMvS+9QvIDzDZx/4pZKmhOC+SAKrpW K6+g0dWOmebYxtzIgn75TFs9r/tkHzocMNFLRNsFqv0CgBYHlDaMg2glxQffxpps0+xT24 7p8VxALo4mtH9YmrXhGee3bHnIJz7tFFAyu6oABXjEnxpK5RhvmJLYjVVY8pOg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703406180; a=rsa-sha256; cv=none; b=GXnVe4UBcVK61mlK0NugFdGF9xgwGPO1cHiBUiGFZ2EBLbed9Dtf/eLFQh8fcbNESu2EnS /JTmrTnt17MKvr3U57SaXwhhSIw+qQNjFnxRSePbkwX8dfnTXR/XQww9HgJdowL+zzAik2 5uaup160hTViXixh6DdVCHm2gQTqJT20gkBfks0YyDinrsx0HcqFjw7GvWpy0MtsK7oYrA pe1JgJhBgIEoVIbIzI0yOINfTDi5gvDDLKaBbmdWNfI9OdQ+xpnmwcImKt5jTy5tIBee// sj09bT48Q1rtrsKWXJik+lcm5rQ3sz9DvFLE32SvK5U8o84lhC9QgM9K1fVTDw== 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=1703406180; 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=j/c1+ngXrDfc52jYsC3cjQj3Kxy7hTvU0WdV9Zu/0ug=; b=AFg1eBY+1tbLvqDGAqOsj0bz65rdWYokzuCmzTsJGCXpn0Y0Wy39SLks9Dd9MsvxL7xOti Yrcc3/2F9a1bkVEdnifGWzwvDzOk5dNi+uOGvH9m0xUv2pfTawEq7a7jzKd27b/RkEpZG+ Xy2hK6bI709hMOf53drIqK9DHBS/82biSeG56xGHGC8OrANMKwkfq9pW+bOsPWO0swmxlU lMHhIWciWfKK805SPDqM2BPzad3JD+2egZ8+CpYQsHwo9q3UWNpcwMy5pXp47NxUI5aoJE q8GC83CjJ/yKrZ3weSaphIZR0u59BJdx4gkSaGm/oGAGV+dCZWCAJdUKN6sIJg== 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 4SyYv770jMz5Vp; Sun, 24 Dec 2023 08:22:59 +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 3BO8Mx2c086692; Sun, 24 Dec 2023 08:22:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BO8MxWb086689; Sun, 24 Dec 2023 08:22:59 GMT (envelope-from git) Date: Sun, 24 Dec 2023 08:22:59 GMT Message-Id: <202312240822.3BO8MxWb086689@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: c612e3c262db - main - LinuxKPI: Add xen/xen.h header 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c612e3c262db6c8256159c4ed39018788017c7e2 Auto-Submitted: auto-generated The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=c612e3c262db6c8256159c4ed39018788017c7e2 commit c612e3c262db6c8256159c4ed39018788017c7e2 Author: Vladimir Kondratyev AuthorDate: 2023-12-24 08:19:58 +0000 Commit: Vladimir Kondratyev CommitDate: 2023-12-24 08:19:58 +0000 LinuxKPI: Add xen/xen.h header It contains proxy-implementation of xen_initial_domain() and xen_pv_domain() required by latest drm-kmod. Sponsored by: Serenity Cyber Security, LLC Reviewed by: manu, bz MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D42797 --- sys/compat/linuxkpi/common/include/xen/xen.h | 37 +++++++++++++++++++++++++++ sys/compat/linuxkpi/common/src/linux_compat.c | 30 ++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/xen/xen.h b/sys/compat/linuxkpi/common/include/xen/xen.h new file mode 100644 index 000000000000..16e77724111d --- /dev/null +++ b/sys/compat/linuxkpi/common/include/xen/xen.h @@ -0,0 +1,37 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2023 Serenity Cyber Security, LLC. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _LINUXKPI_XEN_XEN_H_ +#define _LINUXKPI_XEN_XEN_H_ + +#define xen_initial_domain() lkpi_xen_initial_domain() +#define xen_pv_domain() lkpi_xen_pv_domain() + +bool lkpi_xen_initial_domain(void); +bool lkpi_xen_pv_domain(void); + +#endif /* _LINUXKPI_XEN_XEN_H_ */ diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index 36eac309094f..664ba220e721 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -28,6 +28,7 @@ */ #include +#include "opt_global.h" #include "opt_stack.h" #include @@ -99,6 +100,15 @@ #include #endif +#include +#ifdef XENHVM +#undef xen_pv_domain +#undef xen_initial_domain +/* xen/xen-os.h redefines __must_check */ +#undef __must_check +#include +#endif + SYSCTL_NODE(_compat, OID_AUTO, linuxkpi, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, "LinuxKPI parameters"); @@ -2585,6 +2595,26 @@ lkpi_get_static_single_cpu_mask(int cpuid) return (static_single_cpu_mask[cpuid]); } +bool +lkpi_xen_initial_domain(void) +{ +#ifdef XENHVM + return (xen_initial_domain()); +#else + return (false); +#endif +} + +bool +lkpi_xen_pv_domain(void) +{ +#ifdef XENHVM + return (xen_pv_domain()); +#else + return (false); +#endif +} + static void linux_compat_init(void *arg) {